Ver Fonte

fix:领取卡卷存储记录修改

duxin há 3 anos atrás
pai
commit
84400785cb
1 ficheiros alterados com 14 adições e 10 exclusões
  1. 14 10
      handler/activity/lotteryService.go

+ 14 - 10
handler/activity/lotteryService.go

@@ -12,6 +12,7 @@ import (
 	"net/http"
 	url2 "net/url"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -61,21 +62,24 @@ func (BP *JyActivity) GetLottery(userId, userName, lotteryIds string) error {
 	if code != 1 {
 		return fmt.Errorf("领取优惠券异常%s", msg)
 	}
-
 	//存入奖励列表
 	var awardList []map[string]interface{}
 	nowStamp := time.Now().Unix()
 	list, _ := activityLotteryRequest(userId, "0")
 	for _, v := range list.Data {
-		awardList = append(awardList, map[string]interface{}{
-			"activity_code": BP.ActivityCode,
-			"detail":        v.LotteryName,
-			"userid":        userId,
-			"award":         "lottery-fullReduce", //满减券
-			"num":           v.Reduce,
-			"getway":        "福利一",
-			"date":          nowStamp,
-		})
+		for _, v1 := range strings.Split(lotteryIds, ",") {
+			if v.LotteryIdStr == v1 {
+				awardList = append(awardList, map[string]interface{}{
+					"activity_code": BP.ActivityCode,
+					"detail":        v.LotteryName,
+					"userid":        userId,
+					"award":         "lottery-fullReduce", //满减券
+					"num":           v.Reduce,
+					"getway":        "福利一",
+					"date":          nowStamp,
+				})
+			}
+		}
 	}
 	if len(awardList) > 0 {
 		db.Mgo.SaveBulk("activity_award", awardList...)