限制门店老板直接修改门店改价属性为:StoreChangePriceTypeBossDisabled的门店商品价格
This commit is contained in:
@@ -131,6 +131,8 @@ type tStoreSkuBindAndSpec struct {
|
|||||||
SkuNamePrice int
|
SkuNamePrice int
|
||||||
SkuNameUnit string
|
SkuNameUnit string
|
||||||
RealSkuID int `orm:"column(real_sku_id)"`
|
RealSkuID int `orm:"column(real_sku_id)"`
|
||||||
|
|
||||||
|
ChangePriceType int8 `json:"changePriceType"` // 修改价格类型,即是否需要审核
|
||||||
}
|
}
|
||||||
|
|
||||||
type SkuSaleInfo struct {
|
type SkuSaleInfo struct {
|
||||||
@@ -907,6 +909,10 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
|||||||
// return nil, err
|
// return nil, err
|
||||||
// }
|
// }
|
||||||
// globals.SugarLogger.Debugf("updateStoresSkusWithoutSync2, storeIDs:%v, skuBindInfos:%s", storeIDs, utils.Format4Output(skuBindInfos, false))
|
// globals.SugarLogger.Debugf("updateStoresSkusWithoutSync2, storeIDs:%v, skuBindInfos:%s", storeIDs, utils.Format4Output(skuBindInfos, false))
|
||||||
|
isUserCanDirectChangePrice := true
|
||||||
|
if user := ctx.GetFullUser(); user != nil {
|
||||||
|
isUserCanDirectChangePrice = user.Type&model.UserTypeOperator != 0
|
||||||
|
}
|
||||||
|
|
||||||
userName := ctx.GetUserName()
|
userName := ctx.GetUserName()
|
||||||
needSyncIDMap := make(map[int]int)
|
needSyncIDMap := make(map[int]int)
|
||||||
@@ -931,7 +937,8 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
|||||||
sql += " IF(t5.unit_price > 0, t5.unit_price, t3.price) sku_name_price,"
|
sql += " IF(t5.unit_price > 0, t5.unit_price, t3.price) sku_name_price,"
|
||||||
}
|
}
|
||||||
sql += `
|
sql += `
|
||||||
t3.unit sku_name_unit, t3.name, t3.status sku_name_status
|
t3.unit sku_name_unit, t3.name, t3.status sku_name_status,
|
||||||
|
ts.change_price_type
|
||||||
FROM sku t1
|
FROM sku t1
|
||||||
JOIN store ts ON ts.id = ? AND ts.deleted_at = ?
|
JOIN store ts ON ts.id = ? AND ts.deleted_at = ?
|
||||||
LEFT JOIN store_sku_bind t2 ON t2.sku_id = t1.id AND t2.store_id = ts.id AND t2.deleted_at = ?
|
LEFT JOIN store_sku_bind t2 ON t2.sku_id = t1.id AND t2.store_id = ts.id AND t2.deleted_at = ?
|
||||||
@@ -981,10 +988,11 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
|||||||
for _, v := range allBinds {
|
for _, v := range allBinds {
|
||||||
var num int64
|
var num int64
|
||||||
inSkuBind := inSkuBinsMap[v.RealSkuID]
|
inSkuBind := inSkuBinsMap[v.RealSkuID]
|
||||||
|
isCanChangePrice := (isUserCanDirectChangePrice || v.ChangePriceType != model.StoreChangePriceTypeBossDisabled)
|
||||||
// globals.SugarLogger.Debug(utils.Format4Output(inSkuBind, false))
|
// globals.SugarLogger.Debug(utils.Format4Output(inSkuBind, false))
|
||||||
var skuBind *model.StoreSkuBind
|
var skuBind *model.StoreSkuBind
|
||||||
if v.ID == 0 {
|
if v.ID == 0 {
|
||||||
if skuBindInfo.IsFocus == 1 && v.SkuNameStatus == model.SkuStatusNormal && v.SkuStatus == model.SkuStatusNormal {
|
if skuBindInfo.IsFocus == 1 && v.SkuNameStatus == model.SkuStatusNormal && v.SkuStatus == model.SkuStatusNormal && isCanChangePrice {
|
||||||
skuBind = &model.StoreSkuBind{
|
skuBind = &model.StoreSkuBind{
|
||||||
StoreID: storeID,
|
StoreID: storeID,
|
||||||
SkuID: v.RealSkuID,
|
SkuID: v.RealSkuID,
|
||||||
@@ -1008,7 +1016,7 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
|||||||
} else {
|
} else {
|
||||||
skuBind = &v.StoreSkuBind
|
skuBind = &v.StoreSkuBind
|
||||||
|
|
||||||
if skuBindInfo.IsFocus == -1 {
|
if skuBindInfo.IsFocus == -1 && isCanChangePrice {
|
||||||
if num, err = dao.DeleteEntityLogically(db, skuBind, map[string]interface{}{
|
if num, err = dao.DeleteEntityLogically(db, skuBind, map[string]interface{}{
|
||||||
model.FieldStatus: model.StoreSkuBindStatusDeleted,
|
model.FieldStatus: model.StoreSkuBindStatusDeleted,
|
||||||
model.FieldJdSyncStatus: model.SyncFlagDeletedMask,
|
model.FieldJdSyncStatus: model.SyncFlagDeletedMask,
|
||||||
@@ -1038,7 +1046,7 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
|||||||
setStoreSkuBindStatus(skuBind, model.SyncFlagSaleMask)
|
setStoreSkuBindStatus(skuBind, model.SyncFlagSaleMask)
|
||||||
updateFieldMap[model.FieldStatus] = 1
|
updateFieldMap[model.FieldStatus] = 1
|
||||||
}
|
}
|
||||||
if skuBindInfo.UnitPrice != 0 { // 这里是否需要加此条件限制
|
if skuBindInfo.UnitPrice != 0 && isCanChangePrice { // 这里是否需要加此条件限制
|
||||||
skuBind.UnitPrice = unitPrice
|
skuBind.UnitPrice = unitPrice
|
||||||
skuBind.Price = jxutils.CaculateSkuPrice(unitPrice, v.SpecQuality, v.SpecUnit, v.SkuNameUnit)
|
skuBind.Price = jxutils.CaculateSkuPrice(unitPrice, v.SpecQuality, v.SpecUnit, v.SkuNameUnit)
|
||||||
setStoreSkuBindStatus(skuBind, model.SyncFlagPriceMask)
|
setStoreSkuBindStatus(skuBind, model.SyncFlagPriceMask)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -156,3 +157,14 @@ func (ctx *Context) GetUserID() (userID string) {
|
|||||||
}
|
}
|
||||||
return userID
|
return userID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) GetFullUser() (user *model.User) {
|
||||||
|
token := ctx.GetToken()
|
||||||
|
authInfo, err2 := auth2.GetTokenInfo(token)
|
||||||
|
if err2 == nil {
|
||||||
|
if authInfo.TokenType == auth2.TokenTypeNormal {
|
||||||
|
user, _ = dao.GetUserByID(dao.GetDB(), "user_id", authInfo.GetID())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return user
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user