- 将IsMobileFake用IsStringLikeMobile替换
- 添加HandleOrder4Consignee, GetRealMobile4Order和GetAuthType4Vendor - 添加GoodsOrder.VendorUserID
This commit is contained in:
@@ -125,23 +125,61 @@ func RegisterUserWithMobile(ctx *jxcontext.Context, user *model.User, mobileVeri
|
||||
}
|
||||
|
||||
func HandleOrder4Consignee(order *model.GoodsOrder) (err error) {
|
||||
// user := &model.User{
|
||||
// Mobile:&order.ConsigneeMobile2
|
||||
// }
|
||||
// user.Type = model.UserTypeConsumer
|
||||
// if err = CreateUser(user, ctx.GetUserName()); err == nil {
|
||||
// if vendorID >= 0 {
|
||||
// authBind := &model.AuthBind{
|
||||
// UserID: user.GetID(),
|
||||
// BindType: model.AuthBindTypeID,
|
||||
// AuthID: vendorUserID,
|
||||
// Type: model.VendorNames[vendorID],
|
||||
// }
|
||||
// dao.WrapAddIDCULDEntity(authBind, ctx.GetUserName())
|
||||
// authBind.Status = model.AuthBindStatusNormal
|
||||
// err = dao.CreateEntity(nil, authBind)
|
||||
// }
|
||||
// }
|
||||
var user *model.User
|
||||
authType := jxutils.GetAuthType4Vendor(order.VendorID)
|
||||
if authType == "" {
|
||||
msg := fmt.Sprintf("平台ID:%d当前不支持", order.VendorID)
|
||||
globals.SugarLogger.Warn(msg)
|
||||
return fmt.Errorf(msg)
|
||||
}
|
||||
|
||||
oeratorName := order.VendorOrderID
|
||||
mobileNumber := jxutils.GetRealMobile4Order(order)
|
||||
db := dao.GetDB()
|
||||
if mobileNumber != "" {
|
||||
userList, _, err2 := dao.GetUsers(db, 0, "", nil, "", mobileNumber, 0, 0)
|
||||
if err = err2; err != nil {
|
||||
return err
|
||||
}
|
||||
if len(userList) > 0 {
|
||||
user = userList[0]
|
||||
}
|
||||
}
|
||||
|
||||
vendorUserID := order.VendorUserID
|
||||
if err == nil {
|
||||
authList, err2 := dao.GetUserBindAuthInfo(db, "", model.AuthBindTypeID, "", []string{authType})
|
||||
if err = err2; err != nil {
|
||||
return err
|
||||
}
|
||||
if len(authList) > 0 {
|
||||
if user, err = dao.GetUserByID(db, "UserID", authList[0].UserID); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if user == nil {
|
||||
user = &model.User{
|
||||
UserID2: mobileNumber,
|
||||
Name: order.ConsigneeName,
|
||||
Mobile: &mobileNumber,
|
||||
Type: model.UserTypeConsumer,
|
||||
Remark: order.VendorOrderID,
|
||||
}
|
||||
user.Type = model.UserTypeConsumer
|
||||
err = CreateUser(user, oeratorName)
|
||||
}
|
||||
if err == nil && vendorUserID != "" {
|
||||
authBind := &model.AuthBind{
|
||||
UserID: user.GetID(),
|
||||
BindType: model.AuthBindTypeID,
|
||||
AuthID: vendorUserID,
|
||||
Type: authType,
|
||||
}
|
||||
dao.WrapAddIDCULDEntity(authBind, oeratorName)
|
||||
authBind.Status = model.AuthBindStatusNormal
|
||||
err = dao.CreateEntity(nil, authBind)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user