|
@@ -26,6 +26,10 @@ func ServiceOpen(ctx context.Context, param model.OrderOpenServiceParams) error
|
|
|
if orderData.IsEmpty() {
|
|
|
return errors.New("未查询到订单信息")
|
|
|
}
|
|
|
+ //全额回款开通权益
|
|
|
+ if !consts.PhoneRegex.MatchString(param.Phone) {
|
|
|
+ return errors.New("手机号异常")
|
|
|
+ }
|
|
|
if gconv.String(orderData.Map()["user_phone"]) != param.Phone {
|
|
|
g.DB().Update(ctx, "dataexport_order", map[string]interface{}{
|
|
|
"user_phone": param.Phone,
|
|
@@ -35,6 +39,7 @@ func ServiceOpen(ctx context.Context, param model.OrderOpenServiceParams) error
|
|
|
"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))
|
|
|
if err != nil || productDetail.IsEmpty() {
|
|
|
return err
|
|
@@ -81,25 +86,23 @@ func ServiceOpen(ctx context.Context, param model.OrderOpenServiceParams) error
|
|
|
if gconv.Int(orderData.Map()["buy_subject"]) == 2 {
|
|
|
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) {
|
|
|
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 { //企业服务
|
|
|
upData["ent_id"] = entId
|
|
|
if personPhone := gconv.String(orderData.Map()["personPhone"]); personPhone != "" {
|
|
|
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
|
|
|
}); err != nil {
|
|
|
log.Println(err)
|