- 新增,修改门店时,自动创建门店用户
This commit is contained in:
@@ -615,6 +615,9 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
|
||||
if err2 := updateCourierStores(ctx, storeID); err2 != nil && err == nil {
|
||||
err = err2
|
||||
}
|
||||
if valid["tel1"] != nil {
|
||||
BindMobile2Store(ctx, utils.Interface2String(valid["tel1"]), storeID)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dao.Commit(db)
|
||||
@@ -695,6 +698,7 @@ func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (i
|
||||
store.ID = existingID
|
||||
if err = dao.CreateEntity(nil, store); err == nil {
|
||||
UpdateOrCreateCourierStores(ctx, store.ID, false, false, false)
|
||||
BindMobile2Store(ctx, storeExt.Tel1, storeExt.ID)
|
||||
return store.ID, err
|
||||
}
|
||||
return 0, err
|
||||
|
||||
@@ -83,10 +83,21 @@ func BindMobile2Store(ctx *jxcontext.Context, mobile string, storeID int) (num i
|
||||
if err = err2; err == nil || err == orm.ErrNoRows {
|
||||
user.JxStoreID = storeID
|
||||
if err == nil {
|
||||
// todo transaction
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db)
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
if num, err = dao.UpdateEntity(db, user, "JxStoreID"); err == nil {
|
||||
err = dao.SetWeiXinsEmpty2Null(db, user)
|
||||
}
|
||||
if err != nil {
|
||||
dao.Rollback(db)
|
||||
} else {
|
||||
dao.Commit(db)
|
||||
}
|
||||
} else {
|
||||
dao.WrapAddIDCULEntity(user, ctx.GetUserName())
|
||||
user.ParentID = -1
|
||||
@@ -140,6 +151,9 @@ func ChangeMobile(ctx *jxcontext.Context, curMobile, expectedMobile string) (num
|
||||
}
|
||||
|
||||
func verifyMobileIsBlank(db *dao.DaoDB, mobile string) (user *legacymodel.WeiXins, err error) {
|
||||
if !jxutils.IsStringLikeMobile(mobile) {
|
||||
return nil, fmt.Errorf("%s看起来不像是一个手机号", mobile)
|
||||
}
|
||||
user = &legacymodel.WeiXins{
|
||||
Tel: mobile,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user