Merge remote-tracking branch 'origin/mark' into don

This commit is contained in:
Rosy-zhudan
2019-10-10 08:45:07 +08:00
6 changed files with 31 additions and 19 deletions

View File

@@ -50,7 +50,7 @@ func (a *Auther) VerifySecret(userID, passMD5 string) (authBindEx *auth2.AuthBin
} }
// 特殊接口 // 特殊接口
func (a *Auther) ChangePassword(userID, oldPassMD5, newPassMD5 string) (err error) { func (a *Auther) ChangePassword(userID, userName, oldPassMD5, newPassMD5 string) (err error) {
var authBind *model.AuthBind var authBind *model.AuthBind
db := dao.GetDB() db := dao.GetDB()
salt := utils.GetUUID() salt := utils.GetUUID()
@@ -60,7 +60,7 @@ func (a *Auther) ChangePassword(userID, oldPassMD5, newPassMD5 string) (err erro
_, err = dao.UpdateEntityLogically(db, authBind, map[string]interface{}{ _, err = dao.UpdateEntityLogically(db, authBind, map[string]interface{}{
"AuthSecret": encryptPwd, "AuthSecret": encryptPwd,
"AuthSecret2": salt, "AuthSecret2": salt,
}, model.AdminName, nil) }, userName, nil)
} }
} else if dao.IsNoRowsError(err) { } else if dao.IsNoRowsError(err) {
err = a.AddAuthBind(&auth2.AuthBindEx{ err = a.AddAuthBind(&auth2.AuthBindEx{
@@ -71,7 +71,7 @@ func (a *Auther) ChangePassword(userID, oldPassMD5, newPassMD5 string) (err erro
AuthSecret: encryptPwd, AuthSecret: encryptPwd,
AuthSecret2: salt, AuthSecret2: salt,
}, },
}, model.AdminName) }, userName)
} }
return err return err
} }

View File

@@ -139,7 +139,6 @@ func (c *OrderManager) OnOrderComments(orderCommentList []*model.OrderComment) (
} }
if err == nil { if err == nil {
if isNewComment { if isNewComment {
// dao.WrapAddIDCULEntity(orderComment, model.AdminName)
err = dao.CreateEntity(db, comment2) err = dao.CreateEntity(db, comment2)
} else if comment2 != nil { } else if comment2 != nil {
_, err = dao.UpdateEntity(db, comment2) _, err = dao.UpdateEntity(db, comment2)

View File

@@ -52,6 +52,7 @@ const (
maxWaybillTipMoney = 400 // 最大小费 maxWaybillTipMoney = 400 // 最大小费
baseWaybillFee = 600 // 基本运费 baseWaybillFee = 600 // 基本运费
ebaiCancelWaybillMaxFee = 1000 // 饿百取消运单最高运费 ebaiCancelWaybillMaxFee = 1000 // 饿百取消运单最高运费
maxJxStoreDeliveryFee = 2000
) )
const ( const (
@@ -1004,7 +1005,11 @@ func getWaybillTip(order *model.GoodsOrder) (tipFee int64) {
} }
func getMaxDeliveryFee(order *model.GoodsOrder) (maxDeliveryFee int64) { func getMaxDeliveryFee(order *model.GoodsOrder) (maxDeliveryFee int64) {
maxDeliveryFee = baseWaybillFee + order.DistanceFreightMoney + getWaybillTip(order) if order.VendorID == model.VendorIDJX {
maxDeliveryFee = maxJxStoreDeliveryFee
} else {
maxDeliveryFee = baseWaybillFee + order.DistanceFreightMoney + getWaybillTip(order)
}
return maxDeliveryFee return maxDeliveryFee
} }

View File

@@ -55,7 +55,7 @@ func (*UserProvider) GetUser(authID, authIDType string) (user auth2.IUser) {
func (*UserProvider) UpdateUserMobile(userID string, mobile string) (err error) { func (*UserProvider) UpdateUserMobile(userID string, mobile string) (err error) {
_, err = dao.UpdateEntityLogically(dao.GetDB(), &model.User{}, map[string]interface{}{ _, err = dao.UpdateEntityLogically(dao.GetDB(), &model.User{}, map[string]interface{}{
"Mobile": mobile, "Mobile": mobile,
}, model.AdminName, map[string]interface{}{ }, userID, map[string]interface{}{
"UserID": userID, "UserID": userID,
}) })
return err return err
@@ -64,7 +64,7 @@ func (*UserProvider) UpdateUserMobile(userID string, mobile string) (err error)
func (*UserProvider) UpdateUserEmail(userID string, email string) (err error) { func (*UserProvider) UpdateUserEmail(userID string, email string) (err error) {
_, err = dao.UpdateEntityLogically(dao.GetDB(), &model.User{}, map[string]interface{}{ _, err = dao.UpdateEntityLogically(dao.GetDB(), &model.User{}, map[string]interface{}{
"Email": email, "Email": email,
}, model.AdminName, map[string]interface{}{ }, userID, map[string]interface{}{
"UserID": userID, "UserID": userID,
}) })
return err return err
@@ -83,7 +83,8 @@ func (*UserProvider) UpdateUserType(userID string, userTypeMask int8, updateType
} else { } else {
user.Type = userTypeMask user.Type = userTypeMask
} }
_, err = dao.UpdateEntity(db, user, "Type") dao.WrapUpdateULEntity(user, userID)
_, err = dao.UpdateEntity(db, user, "Type", model.FieldUpdatedAt, model.FieldLastOperator)
} }
return err return err
} }
@@ -93,7 +94,7 @@ func (*UserProvider) UpdateLastLogin(userID string, lastLoginType, fromIP string
"LastLoginAt": utils.Time2Pointer(time.Now()), "LastLoginAt": utils.Time2Pointer(time.Now()),
"LastLoginType": lastLoginType, "LastLoginType": lastLoginType,
"LastLoginIP": fromIP, "LastLoginIP": fromIP,
}, model.AdminName, map[string]interface{}{ }, userID, map[string]interface{}{
"UserID": userID, "UserID": userID,
}) })
return err return err
@@ -126,6 +127,7 @@ func RegisterUserWithMobile(ctx *jxcontext.Context, user *model.User, mobileVeri
user.Type |= model.UserTypeStoreBoss user.Type |= model.UserTypeStoreBoss
} }
if err = CreateUser(user, utils.LimitUTF8StringLen(ctx.GetRealRemoteIP()+","+inAuthInfo.GetAuthID(), 32)); err == nil { if err = CreateUser(user, utils.LimitUTF8StringLen(ctx.GetRealRemoteIP()+","+inAuthInfo.GetAuthID(), 32)); err == nil {
userProvider.UpdateLastLogin(user.GetID(), inAuthInfo.GetAuthType(), ctx.GetRealRemoteIP())
TryAddStoreBossRole4User(ctx, user) TryAddStoreBossRole4User(ctx, user)
if outAuthInfo, err = auth2.BindUser(mobileAuth, user); err == nil && inAuthInfo != nil { if outAuthInfo, err = auth2.BindUser(mobileAuth, user); err == nil && inAuthInfo != nil {
err = auth2.AddAuthBind(&outAuthInfo.UserBasic, inAuthInfo) err = auth2.AddAuthBind(&outAuthInfo.UserBasic, inAuthInfo)

View File

@@ -107,10 +107,13 @@ func UpdateEntityLogically(db *DaoDB, item interface{}, kvs map[string]interface
model.FieldDeletedAt: utils.DefaultTimeValue, model.FieldDeletedAt: utils.DefaultTimeValue,
}) })
} }
return UpdateEntityByKV(db, item, utils.MergeMaps(kvs, map[string]interface{}{ params := map[string]interface{}{
model.FieldUpdatedAt: time.Now(), model.FieldUpdatedAt: time.Now(),
model.FieldLastOperator: userName, }
}), conditions) if userName != "" {
params[model.FieldLastOperator] = userName
}
return UpdateEntityByKV(db, item, utils.MergeMaps(kvs, params), conditions)
} }
// 此函数会更新同步标志 // 此函数会更新同步标志
@@ -133,11 +136,14 @@ func UpdateEntityLogicallyAndUpdateSyncStatus(db *DaoDB, item interface{}, kvs m
for i := 0; i < valueRows.Len(); i++ { for i := 0; i < valueRows.Len(); i++ {
value := reflect.Indirect(valueRows.Index(i)) value := reflect.Indirect(valueRows.Index(i))
status := value.FieldByName(syncStatusFieldName).Int() | int64(valueMask) status := value.FieldByName(syncStatusFieldName).Int() | int64(valueMask)
num2, err2 := UpdateEntityByKV(db, value.Interface(), utils.MergeMaps(kvs, map[string]interface{}{ params := map[string]interface{}{
model.FieldUpdatedAt: time.Now(), model.FieldUpdatedAt: time.Now(),
model.FieldLastOperator: userName, syncStatusFieldName: status,
syncStatusFieldName: status, }
}), nil) if userName != "" {
params[model.FieldLastOperator] = userName
}
num2, err2 := UpdateEntityByKV(db, value.Interface(), utils.MergeMaps(kvs, params), nil)
if err = err2; err == nil { if err = err2; err == nil {
num += num2 num += num2
} else { } else {

View File

@@ -290,7 +290,7 @@ func (c *Auth2Controller) ChangePassword() {
c.callChangePassword(func(params *tAuth2ChangePasswordParams) (retVal interface{}, errCode string, err error) { c.callChangePassword(func(params *tAuth2ChangePasswordParams) (retVal interface{}, errCode string, err error) {
authInfo, err := params.Ctx.GetV2AuthInfo() authInfo, err := params.Ctx.GetV2AuthInfo()
if err == nil { if err == nil {
err = password.AutherObj.ChangePassword(authInfo.GetID(), params.OldPwd, params.NewPwd) err = password.AutherObj.ChangePassword(authInfo.GetID(), params.Ctx.GetUserName(), params.OldPwd, params.NewPwd)
} }
return retVal, "", err return retVal, "", err
}) })