- add dao.SetWeiXinsEmpty2Null
- call SetWeiXinsEmpty2Null in BindMobile2Store and AddMobile2Mobile
This commit is contained in:
@@ -114,7 +114,10 @@ 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 {
|
||||
num, err = dao.UpdateEntity(db, user, "JxStoreID")
|
||||
// todo transaction
|
||||
if num, err = dao.UpdateEntity(db, user, "JxStoreID"); err == nil {
|
||||
err = dao.SetWeiXinsEmpty2Null(db, user)
|
||||
}
|
||||
} else {
|
||||
user.ParentID = -1
|
||||
if err = dao.CreateWeiXins(db, user); err == nil {
|
||||
@@ -137,7 +140,10 @@ func AddMobile2Mobile(ctx *jxcontext.Context, parentMobile, mobile string) (num
|
||||
if err = err2; err == nil || err == orm.ErrNoRows {
|
||||
user.ParentID = parentUser.ID
|
||||
if err == nil {
|
||||
num, err = dao.UpdateEntity(db, user, "ParentID")
|
||||
// todo transaction
|
||||
if num, err = dao.UpdateEntity(db, user, "ParentID"); err == nil {
|
||||
err = dao.SetWeiXinsEmpty2Null(db, user)
|
||||
}
|
||||
} else {
|
||||
if err = dao.CreateWeiXins(db, user); err == nil {
|
||||
num = 1
|
||||
|
||||
@@ -10,7 +10,16 @@ func CreateWeiXins(db *DaoDB, user *legacymodel.WeiXins) (err error) {
|
||||
Rollback(db)
|
||||
return err
|
||||
}
|
||||
if _, err = ExecuteSQL(db, `
|
||||
if err = SetWeiXinsEmpty2Null(db, user); err != nil {
|
||||
Rollback(db)
|
||||
return err
|
||||
}
|
||||
Commit(db)
|
||||
return err
|
||||
}
|
||||
|
||||
func SetWeiXinsEmpty2Null(db *DaoDB, user *legacymodel.WeiXins) (err error) {
|
||||
_, err = ExecuteSQL(db, `
|
||||
UPDATE weixins
|
||||
SET
|
||||
openid = IF(openid = '', NULL, openid),
|
||||
@@ -19,11 +28,7 @@ func CreateWeiXins(db *DaoDB, user *legacymodel.WeiXins) (err error) {
|
||||
tel = IF(tel = '', NULL, tel),
|
||||
parentid = IF(parentid = 0, -1, parentid)
|
||||
WHERE id = ?
|
||||
`, user.ID); err != nil {
|
||||
Rollback(db)
|
||||
return err
|
||||
}
|
||||
Commit(db)
|
||||
`, user.ID)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user