From f4e29f719a1ace8f86406d9140ef057d442d8c67 Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 31 Oct 2019 18:36:19 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=90=E5=88=B6=E9=97=A8=E5=BA=97=E8=80=81?= =?UTF-8?q?=E6=9D=BF=E7=9B=B4=E6=8E=A5=E4=BF=AE=E6=94=B9=E9=97=A8=E5=BA=97?= =?UTF-8?q?=E6=94=B9=E4=BB=B7=E5=B1=9E=E6=80=A7=E4=B8=BA=EF=BC=9AStoreChan?= =?UTF-8?q?gePriceTypeBossDisabled=E7=9A=84=E9=97=A8=E5=BA=97=E5=95=86?= =?UTF-8?q?=E5=93=81=E4=BB=B7=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 16 ++++++++++++---- business/jxutils/jxcontext/jxcontext.go | 12 ++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 25d9e9bf1..3f91a1525 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -131,6 +131,8 @@ type tStoreSkuBindAndSpec struct { SkuNamePrice int SkuNameUnit string RealSkuID int `orm:"column(real_sku_id)"` + + ChangePriceType int8 `json:"changePriceType"` // 修改价格类型,即是否需要审核 } type SkuSaleInfo struct { @@ -907,6 +909,10 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs // return nil, err // } // 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() 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 += ` - 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 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 = ? @@ -981,10 +988,11 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs for _, v := range allBinds { var num int64 inSkuBind := inSkuBinsMap[v.RealSkuID] + isCanChangePrice := (isUserCanDirectChangePrice || v.ChangePriceType != model.StoreChangePriceTypeBossDisabled) // globals.SugarLogger.Debug(utils.Format4Output(inSkuBind, false)) var skuBind *model.StoreSkuBind 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{ StoreID: storeID, SkuID: v.RealSkuID, @@ -1008,7 +1016,7 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs } else { skuBind = &v.StoreSkuBind - if skuBindInfo.IsFocus == -1 { + if skuBindInfo.IsFocus == -1 && isCanChangePrice { if num, err = dao.DeleteEntityLogically(db, skuBind, map[string]interface{}{ model.FieldStatus: model.StoreSkuBindStatusDeleted, model.FieldJdSyncStatus: model.SyncFlagDeletedMask, @@ -1038,7 +1046,7 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs setStoreSkuBindStatus(skuBind, model.SyncFlagSaleMask) updateFieldMap[model.FieldStatus] = 1 } - if skuBindInfo.UnitPrice != 0 { // 这里是否需要加此条件限制 + if skuBindInfo.UnitPrice != 0 && isCanChangePrice { // 这里是否需要加此条件限制 skuBind.UnitPrice = unitPrice skuBind.Price = jxutils.CaculateSkuPrice(unitPrice, v.SpecQuality, v.SpecUnit, v.SkuNameUnit) setStoreSkuBindStatus(skuBind, model.SyncFlagPriceMask) diff --git a/business/jxutils/jxcontext/jxcontext.go b/business/jxutils/jxcontext/jxcontext.go index 7c91a9bd3..b7a46648e 100644 --- a/business/jxutils/jxcontext/jxcontext.go +++ b/business/jxutils/jxcontext/jxcontext.go @@ -6,6 +6,7 @@ import ( "git.rosy.net.cn/jx-callback/business/auth2" "git.rosy.net.cn/jx-callback/business/model" + "git.rosy.net.cn/jx-callback/business/model/dao" "git.rosy.net.cn/jx-callback/globals" ) @@ -156,3 +157,14 @@ func (ctx *Context) GetUserID() (userID string) { } 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 +}