Parcourir la source

fix:校验修改

duxin il y a 1 mois
Parent
commit
b00f2e2bec

+ 2 - 3
internal/logic/dayActivity/activity.go

@@ -25,12 +25,11 @@ func ActivityNsqPublish(ctx context.Context, productType string, userId string,
 		//  如果是mgoid  则根据 mgoid 查询base_user_id  根据 base_user_id 查询 职位id
 		mgoId = userId
 		userRs, b := jyutil.MG.DB().FindById("user", userId, `{"base_user_id":1,"s_nickname":1}`)
-		log.Println("抽奖order_code ==", orderCode, userRs)
 		if b && userRs != nil && len(*userRs) > 0 {
 			nickName = gconv.String((*userRs)["s_nickname"])
 			baseUserId := gconv.Int((*userRs)["base_user_id"])
-			log.Println("抽奖order_code ==", orderCode, baseUserId)
-			positionData, _ := g.DB("base").GetOne(ctx, "SELECT id FROM base_position WHERE type=0 and user_id = ?", baseUserId)
+			positionData, err := g.DB("base").GetOne(ctx, "SELECT id FROM base_position WHERE type=0 and user_id = ?", baseUserId)
+			log.Println("抽奖order_code ==", orderCode, baseUserId, err, positionData)
 			if !positionData.IsEmpty() {
 				positionId = gconv.Int64(positionData.Map()["id"])
 			}

+ 22 - 18
internal/logic/product/bigmember/bigcommon.go

@@ -79,6 +79,7 @@ func (p jyBigProduct) UserEquityDistribution(ctx context.Context, startDate, end
 	}
 	serverData, _ := g.DB().Ctx(ctx).Query(ctx, fmt.Sprintf(`SELECT * FROM bigmember_service WHERE id in (%s) `, strings.Join(serviceIdArr, ",")))
 	if !serverData.IsEmpty() {
+		var ziBool bool
 		for _, m := range serverData.List() {
 			serverId := common.If(gconv.Int(m["i_pid"]) > 0, gconv.Int(m["i_pid"]), gconv.Int(m["id"])).(int)
 			mainId := gconv.Int(m["id"])
@@ -138,6 +139,7 @@ func (p jyBigProduct) UserEquityDistribution(ctx context.Context, startDate, end
 				}
 			case Renew:
 				if !userService.IsEmpty() {
+					log.Println("用户存在生肖中的服务", p.param.UserId, saveFrequency, frequency)
 					if status == 1 {
 						sql1 := fmt.Sprintf("update bigmember_service_user set i_frequency = i_frequency + %v,l_updatetime = '%v',l_endtime = '%v' where s_serviceid = %v and s_userid = '%v'", saveFrequency, date.NowFormat(date.Date_Full_Layout), endDate, serverId, p.param.UserId)
 						_, err := g.DB().Ctx(ctx).Exec(ctx, sql1)
@@ -170,34 +172,36 @@ func (p jyBigProduct) UserEquityDistribution(ctx context.Context, startDate, end
 					}
 				}
 				//更新子账号延长服务
-				userData, ok := jyutil.MG.DB().Find("user", map[string]interface{}{"s_member_mainid": p.param.UserId, "i_member_sub_status": 1}, nil, nil, false, -1, -1)
-				if ok && userData != nil && len(*userData) > 0 {
-					var err error
-					if status == 1 {
-						_, err = g.DB().Ctx(ctx).Update(ctx, "bigmember_service_user", map[string]interface{}{
-							"l_updatetime": date.NowFormat(date.Date_Full_Layout),
-							"l_endtime":    date.FormatDate(&endDate, date.Date_Full_Layout),
-						}, map[string]interface{}{
-							"s_userid": p.param.UserId,
-						})
-					} else {
+				if !ziBool {
+					ziBool = true
+					userData, ok := jyutil.MG.DB().Find("user", map[string]interface{}{"s_member_mainid": p.param.UserId, "i_member_sub_status": 1}, nil, nil, false, -1, -1)
+					if ok && userData != nil && len(*userData) > 0 {
+						var err error
+						//if status == 1 {
+						//	_, err = g.DB().Ctx(ctx).Update(ctx, "bigmember_service_user", map[string]interface{}{
+						//		"l_updatetime": date.NowFormat(date.Date_Full_Layout),
+						//		"l_endtime":    date.FormatDate(&endDate, date.Date_Full_Layout),
+						//	}, map[string]interface{}{
+						//		"s_userid": p.param.UserId,
+						//	})
+						//} else {
 						_, err = g.DB().Ctx(ctx).Update(ctx, "bigmember_service_user", map[string]interface{}{
 							"l_updatetime": date.NowFormat(date.Date_Full_Layout),
 							"l_endtime":    date.FormatDate(&endDate, date.Date_Full_Layout),
 							"l_starttime":  date.FormatDate(&startDate, date.Date_Full_Layout),
-							"i_status":     0,
+							"i_status":     status,
 						}, map[string]interface{}{
 							"s_userid":    p.param.UserId,
 							"s_serviceid": 2,
 						})
-					}
-					if err == nil {
-						log.Println("用户服务表更新成功")
-					} else {
-						return errors.New("用户服务表更新失败")
+						//}
+						if err == nil {
+							log.Println("用户服务表更新成功")
+						} else {
+							return errors.New("用户服务表更新失败")
+						}
 					}
 				}
-
 			case Upgrades:
 				if gconv.Int(m["id"]) == 16 {
 					err := p.UserServiceRecharge(ctx, []string{"12", "13"}, gconv.Int(m["count"]), endDate)