Pārlūkot izejas kodu

fix:修改我的奖励校验

duxin 3 gadi atpakaļ
vecāks
revīzija
bc702fd8cb
1 mainītis faili ar 12 papildinājumiem un 8 dzēšanām
  1. 12 8
      services/activity/myPrize.go

+ 12 - 8
services/activity/myPrize.go

@@ -16,8 +16,9 @@ type MyPrize struct {
 
 func (c *MyPrize) Show(r *ghttp.Request) {
 	var (
-		allShare []map[string]interface{}
-		max      = 4
+		allShare    []map[string]interface{}
+		max         = 4
+		shareStatus = "share_interests" //默认邀请权益 用户判断
 	)
 	userid := r.Get("userId").String()
 	aData, b := db.Mgo.FindOne("user_share", map[string]interface{}{"shared_uid": userid})
@@ -27,8 +28,8 @@ func (c *MyPrize) Show(r *ghttp.Request) {
 	}
 	fmt.Println("被邀请人信息:", aData)
 	query := map[string]interface{}{
-		"share_uid":     userid,
-		"giving_rights": map[string]interface{}{"$exists": 0},
+		"share_uid":       userid,
+		"share_interests": map[string]interface{}{"$exists": 0},
 	}
 	//老版用户关联
 	bData, _b := db.Mgo.Find("user_share", query, `{"createtime":1}`, nil, false, 0, max)
@@ -37,7 +38,7 @@ func (c *MyPrize) Show(r *ghttp.Request) {
 	}
 	log.Println("老版邀请用户关联信息:", bData)
 	//giving_rights:不存在为老版本信息 1:赠送超级订阅与剑鱼币, 2赠送剑鱼币
-	delete(query, "giving_rights")
+	delete(query, "share_interests")
 	query["giving_rights"] = map[string]interface{}{"$in": []int{1, 2}}
 	cData, _s := db.Mgo.Find("user_share", query, "", nil, false, -1, -1)
 	if cData != nil && len(*cData) > 0 && _s {
@@ -45,6 +46,7 @@ func (c *MyPrize) Show(r *ghttp.Request) {
 	}
 	log.Println("新版邀请用户关联信息:", cData)
 	var allData []map[string]interface{}
+
 	for _, data := range allShare {
 		_d := make(map[string]interface{})  //超级订阅数据
 		_ds := make(map[string]interface{}) //剑鱼币数据
@@ -57,15 +59,17 @@ func (c *MyPrize) Show(r *ghttp.Request) {
 		_d["prizeMethods"] = 0
 		_d["prizeName"] = "7天超级订阅"
 		_d["createTime"] = data["createtime"]
+
 		if common.InterfaceToStr(data["share_uid"]) != userid {
+			shareStatus = "shared_interests"
 			_d["prizeMethods"] = 1
 			_ds["prizeMethods"] = 1
 		}
-		if common.IntAll(data["giving_rights"]) == 0 {
+		if common.IntAll(data[shareStatus]) == 0 {
 			allData = append(allData, _d)
-		} else if common.IntAll(data["giving_rights"]) == 1 {
+		} else if common.IntAll(data[shareStatus]) == 1 {
 			allData = append(allData, _d, _ds)
-		} else if common.IntAll(data["giving_rights"]) == 2 {
+		} else if common.IntAll(data[shareStatus]) == 2 {
 			allData = append(allData, _ds)
 		}
 	}