Kaynağa Gözat

最大上限判断

zhangxinlei1996 4 yıl önce
ebeveyn
işleme
a663f5fed3

+ 12 - 12
src/jfw/modules/publicapply/src/bidcollection/entity/entity.go

@@ -300,19 +300,19 @@ func LabelAction(labInfo *LabelInfo, userid string) map[string]interface{} {
 			labInfo.Binfo = FormatColl(labInfo.Binfo)
 			for _, bd := range labInfo.Binfo {
 				now := time.Now().Unix()
-				if collCount >= maxCount {
-					ok, msg = false, qu.If(isPay, "付费用户收藏已达上限", "免费用户收藏已达上限").(string)
-					log.Printf("userid :%s,收藏失败 id : %s ,已收藏数量:%v ,上限数量:%v", userid, util.DecodeId(bd.Bid), collCount, maxCount)
+				if collMap[util.DecodeId(bd.Bid)] {
+					//更新
+					if updatesql == fmt.Sprintf("update %s set labelid=? where userid = ? and ", db.DbConf.Bdcollection) {
+						updatesql += `( bid =? `
+					} else {
+						updatesql += `or bid =? `
+					}
+					updateValue = append(updateValue, util.DecodeId(bd.Bid))
+					i++
 				} else {
-					if collMap[util.DecodeId(bd.Bid)] {
-						//更新
-						if updatesql == fmt.Sprintf("update %s set labelid=? where userid = ? and ", db.DbConf.Bdcollection) {
-							updatesql += `( bid =? `
-						} else {
-							updatesql += `or bid =? `
-						}
-						updateValue = append(updateValue, util.DecodeId(bd.Bid))
-						i++
+					if collCount >= maxCount {
+						ok, msg = false, qu.If(isPay, "付费用户收藏已达上限", "免费用户收藏已达上限").(string)
+						log.Printf("userid :%s,收藏失败 id : %s ,已收藏数量:%v ,上限数量:%v", userid, util.DecodeId(bd.Bid), collCount, maxCount)
 					} else {
 						i++
 						//新增并绑定标签 "userid", "bid", "labelid", "buyerclass", "buyerinfo", "winnerinfo", "createdate"