package user import ( "app.yhyue.com/moapp/jybase/common" "context" "fmt" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/util/gconv" "jyOrderManager/internal/jyutil" "jyOrderManager/internal/logic/product" "jyOrderManager/internal/model" ) func OrderUserChangePhone(ctx context.Context, param model.UserServiceParams) (interface{}, error) { buySubject, _ := g.DB().GetCount(ctx, fmt.Sprintf(`SELECT * FROM dataexport_order WHERE order_code = '%s' and buy_subject =1`, param.OrderCode)) if buySubject == 0 { return nil, nil } userData, _ := jyutil.MG.DB().FindOne("user", map[string]interface{}{ "$or": []map[string]interface{}{ {"s_phone": param.Phone}, {"s_m_phone": param.Phone}, }, }) if userData == nil || len(*userData) == 0 { return nil, nil } order, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT * FROM jy_order_detail WHERE order_code = '%s' and status =1 `, param.OrderCode)) if order.IsEmpty() { return nil, nil } for _, tParam := range order.List() { //参数注入 tParam["phone"] = param.Phone //开通手机号 tParam["order_code"] = param.OrderCode //订单号 tParam["reqSubject"] = 1 //购买主体 productCode := gconv.String(tParam["product_code"]) pFunc, pErr := product.JyProFunc.GetProductInitFuncByCode(productCode) if pErr != nil { return nil, pErr } pObj, pErr := pFunc(tParam) if pErr != nil { return nil, pErr } var ( actCode = gconv.String(tParam["activityCode"]) //活动code checkCode = common.If(actCode != "", 2, 1).(int) //1:普通商品 2:活动商品 ) if err := pObj.Check(ctx, checkCode); err != nil { return nil, err } } return nil, nil }