Browse Source

fix:开通权益计费校验修改

duxin 1 month ago
parent
commit
f837b2e7b0
3 changed files with 16 additions and 11 deletions
  1. 3 2
      internal/jyutil/user.go
  2. 12 9
      internal/logic/order/serviceOpen.go
  3. 1 0
      internal/logic/user/getService.go

+ 3 - 2
internal/jyutil/user.go

@@ -429,7 +429,6 @@ INNER JOIN entniche_department_user edu on eu.id = edu.user_id WHERE phone = '%s
 
 
 	deptId := dept.Map()["dept_id"]
 	deptId := dept.Map()["dept_id"]
 	if err := g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
 	if err := g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
-
 		entUser, _ := g.DB().Save(ctx, "entniche_user", map[string]interface{}{
 		entUser, _ := g.DB().Save(ctx, "entniche_user", map[string]interface{}{
 			"name":       personName,
 			"name":       personName,
 			"phone":      personPhone,
 			"phone":      personPhone,
@@ -464,13 +463,15 @@ INNER JOIN entniche_department_user edu on eu.id = edu.user_id WHERE phone = '%s
 		r, err := rpc.DialHTTP("tcp", g.Cfg().MustGet(context.Background(), "paymentAddress").String())
 		r, err := rpc.DialHTTP("tcp", g.Cfg().MustGet(context.Background(), "paymentAddress").String())
 		err = r.Call("JyUser.AddUserInfo", &data, &respData)
 		err = r.Call("JyUser.AddUserInfo", &data, &respData)
 		if err != nil {
 		if err != nil {
+			log.Println("tcp 调用失败", err.Error())
 			return errors.New("tcp 调用失败")
 			return errors.New("tcp 调用失败")
 		}
 		}
 		if respData.Fool {
 		if respData.Fool {
 			//entniche_user表,用户名字段 user_name
 			//entniche_user表,用户名字段 user_name
 			//base_user表,用户名字段 user_name
 			//base_user表,用户名字段 user_name
 			//mog库user表,用户名字段 user_name
 			//mog库user表,用户名字段 user_name
-			GetCreateUserData(personPhone, "", false)
+			_, _, _, err = GetCreateUserData(personPhone, "", false)
+			log.Println("tcp 调用失败", err.Error())
 		}
 		}
 
 
 		return nil
 		return nil

+ 12 - 9
internal/logic/order/serviceOpen.go

@@ -26,6 +26,10 @@ func ServiceOpen(ctx context.Context, param model.OrderOpenServiceParams) error
 	if orderData.IsEmpty() {
 	if orderData.IsEmpty() {
 		return errors.New("未查询到订单信息")
 		return errors.New("未查询到订单信息")
 	}
 	}
+	//全额回款开通权益
+	if !consts.PhoneRegex.MatchString(param.Phone) {
+		return errors.New("手机号异常")
+	}
 	if gconv.String(orderData.Map()["user_phone"]) != param.Phone {
 	if gconv.String(orderData.Map()["user_phone"]) != param.Phone {
 		g.DB().Update(ctx, "dataexport_order", map[string]interface{}{
 		g.DB().Update(ctx, "dataexport_order", map[string]interface{}{
 			"user_phone":         param.Phone,
 			"user_phone":         param.Phone,
@@ -35,6 +39,7 @@ func ServiceOpen(ctx context.Context, param model.OrderOpenServiceParams) error
 			"order_code": param.OrderCode,
 			"order_code": param.OrderCode,
 		})
 		})
 	}
 	}
+
 	productDetail, err := g.DB().Ctx(ctx).Query(ctx, fmt.Sprintf(`SELECT * FROM jy_order_detail WHERE order_code ='%s' and is_service_open = 0 and status =1`, param.OrderCode))
 	productDetail, err := g.DB().Ctx(ctx).Query(ctx, fmt.Sprintf(`SELECT * FROM jy_order_detail WHERE order_code ='%s' and is_service_open = 0 and status =1`, param.OrderCode))
 	if err != nil || productDetail.IsEmpty() {
 	if err != nil || productDetail.IsEmpty() {
 		return err
 		return err
@@ -81,25 +86,23 @@ func ServiceOpen(ctx context.Context, param model.OrderOpenServiceParams) error
 		if gconv.Int(orderData.Map()["buy_subject"]) == 2 {
 		if gconv.Int(orderData.Map()["buy_subject"]) == 2 {
 			uData["userId"] = userPositionId
 			uData["userId"] = userPositionId
 		}
 		}
+		upData := g.Map{"order_status": 1}
 		if orderUserId := gconv.String(orderData.Map()["user_id"]); orderUserId == "" || orderUserId != gconv.String(uData["userId"]) || (gconv.Int(orderData.Map()["buy_subject"]) == 2 && gconv.Int64(orderData.Map()["ent_id"]) != entId) {
 		if orderUserId := gconv.String(orderData.Map()["user_id"]); orderUserId == "" || orderUserId != gconv.String(uData["userId"]) || (gconv.Int(orderData.Map()["buy_subject"]) == 2 && gconv.Int64(orderData.Map()["ent_id"]) != entId) {
 			log.Printf("同步更新订单用户身份:orderUserId:%s,userId:%v,entId:%d\n", orderUserId, uData["userId"], entId)
 			log.Printf("同步更新订单用户身份:orderUserId:%s,userId:%v,entId:%d\n", orderUserId, uData["userId"], entId)
-			upData := g.Map{
-				"user_id": uData["userId"],
-			}
+			upData["user_id"] = uData["userId"]
 			if entId > 0 { //企业服务
 			if entId > 0 { //企业服务
 				upData["ent_id"] = entId
 				upData["ent_id"] = entId
 				if personPhone := gconv.String(orderData.Map()["personPhone"]); personPhone != "" {
 				if personPhone := gconv.String(orderData.Map()["personPhone"]); personPhone != "" {
 					jyutil.EndAddUser(ctx, entId, gconv.String(orderData.Map()["user_phone"]), personPhone, gconv.String(orderData.Map()["personName"]))
 					jyutil.EndAddUser(ctx, entId, gconv.String(orderData.Map()["user_phone"]), personPhone, gconv.String(orderData.Map()["personName"]))
 				}
 				}
 			}
 			}
-			upData["order_status"] = 1
-			//更新订单
-			_, err = g.DB().Update(ctx, consts.OrderListTableName, upData, "order_code=?", param.OrderCode)
-			if err != nil {
-				return err
-			}
 		}
 		}
 
 
+		//更新订单
+		_, err = g.DB().Update(ctx, consts.OrderListTableName, upData, "order_code=?", param.OrderCode)
+		if err != nil {
+			return err
+		}
 		return nil
 		return nil
 	}); err != nil {
 	}); err != nil {
 		log.Println(err)
 		log.Println(err)

+ 1 - 0
internal/logic/user/getService.go

@@ -22,6 +22,7 @@ func GetUserService(ctx context.Context, param model.UserServiceParams) (interfa
 		whereEntTime  string
 		whereEntTime  string
 		entRec        gdb.Record
 		entRec        gdb.Record
 	)
 	)
+
 	if param.Phone != "" {
 	if param.Phone != "" {
 		//大会员超||级订阅 判断是否有待生效订单
 		//大会员超||级订阅 判断是否有待生效订单
 		if (strings.Contains(param.ProductType, "大会员") || strings.Contains(param.ProductType, "订阅")) && param.BuySubject == "1" {
 		if (strings.Contains(param.ProductType, "大会员") || strings.Contains(param.ProductType, "订阅")) && param.BuySubject == "1" {