Jelajahi Sumber

feat:数量修改

wangchuanjin 1 tahun lalu
induk
melakukan
3ff5cbc7ba
1 mengubah file dengan 1 tambahan dan 3 penghapusan
  1. 1 3
      service/service.go

+ 1 - 3
service/service.go

@@ -44,7 +44,7 @@ func AddUsePerson(this *entmanageapplication.AddUsePersonReq) *entmanageapplicat
 	sourceData := JyMysql.FindOne(EntnicheWaitEmpower, map[string]interface{}{"id": this.WaitEmpowerId}, "", "")
 	if sourceData != nil && len(*sourceData) > 0 {
 		empower_count := common.IntAll((*sourceData)["empower_count"])
-		use_count := common.IntAll((*sourceData)["use_count"])
+		use_count := int(JyMysql.CountBySql(`select count(1) as count from entniche_power where wait_empower_id=? and status=1`, this.WaitEmpowerId))
 		if empower_count-use_count < len(UserArr) {
 			msg = "购买数量不足"
 			code = int64(-1)
@@ -77,7 +77,6 @@ func AddUsePerson(this *entmanageapplication.AddUsePersonReq) *entmanageapplicat
 						"create_time":     timeStr,
 						"update_time":     timeStr,
 					})
-					JyMysql.UpdateOrDeleteBySql(`update `+EntnicheWaitEmpower+` set use_count = use_count + 1 where id = ?`, this.WaitEmpowerId)
 					addPower(this.WaitEmpowerId, entUserId, this.EntId)
 				}
 			}
@@ -254,7 +253,6 @@ func delPower(id int64) {
 	if data != nil && len(*data) > 0 {
 		waitEmpowerId := common.Int64All((*data)["wait_empower_id"])
 		entUserId := common.IntAll((*data)["ent_user_id"])
-		JyMysql.UpdateOrDeleteBySql(`update `+EntnicheWaitEmpower+` set use_count = use_count - 1 where id = ? and use_count > 0`, waitEmpowerId)
 		identity := getPositionId(entUserId)
 		eOData := JyMysql.FindOne(EntnicheOrder, map[string]interface{}{"wait_empower_id": waitEmpowerId}, "", "")
 		if eOData != nil && len(*eOData) > 0 {