diff --git a/business/cs/weimob_order.go b/business/cs/weimob_order.go index 932ff1d12..1f2afd8e6 100644 --- a/business/cs/weimob_order.go +++ b/business/cs/weimob_order.go @@ -83,9 +83,10 @@ func GetStoreList4Mobile(db *dao.DaoDB, mobileList []string) (storeList []*model sql := ` SELECT t1.* FROM store t1 - WHERE t1.deleted_at = ?` + WHERE t1.deleted_at = ? /*AND t1.change_price_type = ?*/` sqlParams := []interface{}{ utils.DefaultTimeValue, + // model.StoreChangePriceTypeBossDisabled, } if len(mobileList) > 0 { questionMarks := dao.GenQuestionMarks(len(mobileList)) 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/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index 24b9a9670..74efff588 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -238,10 +238,12 @@ func sku2Update(vendorID int, sku *dao.StoreSkuSyncInfo, syncStatus int8) (item kvs[dao.GetVendorThingIDStructField(model.VendorNames[vendorID])] = utils.Str2Int64WithDefault(sku.VendorSkuID, 0) } else if model.IsSyncStatusDelete(syncStatus) { sku.StoreSkuSyncStatus = 0 - if utils.IsTimeZero(sku.BindDeletedAt) { + if utils.IsTimeZero(sku.BindDeletedAt) && (sku.ID == 0 || sku.NameID == 0) { kvs[model.FieldDeletedAt] = time.Now() } - kvs[dao.GetVendorThingIDStructField(model.VendorNames[vendorID])] = 0 + if !dao.IsVendorThingIDEmpty(sku.VendorSkuID) && !partner.IsMultiStore(vendorID) { + kvs[dao.GetVendorThingIDStructField(model.VendorNames[vendorID])] = 0 + } } else { sku.StoreSkuSyncStatus = sku.StoreSkuSyncStatus & 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 +} diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index c83416d25..d61410ad5 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -286,10 +286,11 @@ func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty boo sql += " AND t1.sku_id IN (" + GenQuestionMarks(len(skuIDs)) + ")" sqlParams = append(sqlParams, skuIDs) } - if !isSingleStorePF { - sql += " AND t2.%s_id <> 0" - fmtParams = append(fmtParams, fieldPrefix) - } + // 多门店平台没有成功创建的商品,不直接过滤,让上层同步时报错 + // if !isSingleStorePF { + // sql += " AND t2.%s_id <> 0" + // fmtParams = append(fmtParams, fieldPrefix) + // } sql = fmt.Sprintf(sql, fmtParams...) sql += " ORDER BY t1.price" // globals.SugarLogger.Debug(sql) diff --git a/business/model/store.go b/business/model/store.go index 9338dd8d5..2bbab4956 100644 --- a/business/model/store.go +++ b/business/model/store.go @@ -43,8 +43,9 @@ const ( ) const ( - StoreChangePriceTypeDirect = 0 - StoreChangePriceTypeNeedApprove = 1 + StoreChangePriceTypeDirect = 0 + StoreChangePriceTypeNeedApprove = 1 + StoreChangePriceTypeBossDisabled = 2 ) var ( diff --git a/business/partner/partner.go b/business/partner/partner.go index 28dadcba3..102304630 100644 --- a/business/partner/partner.go +++ b/business/partner/partner.go @@ -265,6 +265,5 @@ func IsMultiStore(vendorID int) bool { if _, ok := GetPurchasePlatformFromVendorID(vendorID).(IMultipleStoresHandler); ok { return true } - return false } diff --git a/business/partner/purchase/ebai/store.go b/business/partner/purchase/ebai/store.go index b50caaef9..d76a5c13e 100644 --- a/business/partner/purchase/ebai/store.go +++ b/business/partner/purchase/ebai/store.go @@ -80,7 +80,10 @@ func getCoordintate(data interface{}) float64 { } func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string) (*dao.StoreDetail, error) { - baiduShopID := utils.Str2Int64(vendorStoreID) + baiduShopID := utils.Str2Int64WithDefault(vendorStoreID, 0) + if baiduShopID == 0 { + return nil, fmt.Errorf("饿百门店ID:%s非法,应该是一个整数", vendorStoreID) + } result, err := api.EbaiAPI.ShopGet("", baiduShopID) if err == nil { // globals.SugarLogger.Debug(utils.Format4Output(result, false))