aa
This commit is contained in:
@@ -487,23 +487,29 @@ func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool
|
||||
}
|
||||
|
||||
func GetStoresSkus(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus, isHighPrice bool, priceType int, keyword string, isBySku, isAct bool, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *dao.StoreSkuNamesInfo, err error) {
|
||||
return GetStoresSkusNew(ctx, storeIDs, skuIDs, isFocus, isHighPrice, priceType, keyword, isBySku, isAct, params, offset, pageSize)
|
||||
}
|
||||
|
||||
func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus, isHighPrice bool, priceType int, keyword string, isBySku, isAct bool, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *dao.StoreSkuNamesInfo, err error) {
|
||||
//权限
|
||||
if permission.IsRoled(ctx) {
|
||||
if storeIDsMap, err := permission.GetUserStoresResultMap(ctx.GetUserID()); err == nil {
|
||||
var storeIDs2 []int
|
||||
for _, v := range storeIDs {
|
||||
if storeIDsMap[v] != 0 {
|
||||
storeIDs2 = append(storeIDs2, v)
|
||||
if len(storeIDs) > 0 {
|
||||
for _, v := range storeIDs {
|
||||
if storeIDsMap[v] != 0 {
|
||||
storeIDs2 = append(storeIDs2, v)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for k, _ := range storeIDsMap {
|
||||
storeIDs2 = append(storeIDs2, k)
|
||||
}
|
||||
}
|
||||
storeIDs = nil
|
||||
storeIDs = storeIDs2
|
||||
}
|
||||
}
|
||||
return GetStoresSkusNew(ctx, storeIDs, skuIDs, isFocus, isHighPrice, priceType, keyword, isBySku, isAct, params, offset, pageSize)
|
||||
}
|
||||
|
||||
func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus, isHighPrice bool, priceType int, keyword string, isBySku, isAct bool, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *dao.StoreSkuNamesInfo, err error) {
|
||||
if !isFocus && !isBySku && (len(storeIDs) > 1 || len(storeIDs) == 0) {
|
||||
return nil, fmt.Errorf("未关注按SkuName只能查询单店")
|
||||
}
|
||||
@@ -1631,6 +1637,19 @@ func CopyStoreSkus(ctx *jxcontext.Context, fromStoreID int, toStoreIDs []int, co
|
||||
if copyMode != CopyStoreSkuModeFresh && copyMode != CopyStoreSkuModeUpdate && copyMode != CopyStoreSkuModeUpdatePrice {
|
||||
return 0, fmt.Errorf("不支持的拷贝模式:%s", copyMode)
|
||||
}
|
||||
//权限
|
||||
if permission.IsRoled(ctx) {
|
||||
if storeIDsMap, err := permission.GetUserStoresResultMap(ctx.GetUserID()); err == nil {
|
||||
if storeIDsMap[fromStoreID] == 0 {
|
||||
return 0, fmt.Errorf("抱歉,您无权更改他人店铺商品 [%v]", fromStoreID)
|
||||
}
|
||||
for _, v := range toStoreIDs {
|
||||
if storeIDsMap[v] == 0 {
|
||||
return 0, fmt.Errorf("抱歉,您无权更改他人店铺商品 [%v]", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
db := dao.GetDB()
|
||||
fromStore, err := checkStoreExisting(db, fromStoreID)
|
||||
if err != nil {
|
||||
@@ -3715,24 +3734,32 @@ func UpdateStoreSkusSpecTagBin(ctx *jxcontext.Context, reader io.Reader, vendorI
|
||||
results[i] = results[len(results)-i-1]
|
||||
results[len(results)-i-1] = tmp
|
||||
}
|
||||
for _, v := range results {
|
||||
store, err := dao.GetStoreDetail(db, v.StoreID, model.VendorIDMTWM, "")
|
||||
if err != nil || store == nil {
|
||||
continue
|
||||
}
|
||||
mtapi := apimanager.CurAPIManager.GetAPI(model.VendorIDMTWM, store.VendorOrgCode).(*mtwmapi.API)
|
||||
food, err := mtapi.RetailGet(store.VendorStoreID, utils.Int2Str(v.SkuID))
|
||||
if err != nil || food == nil {
|
||||
continue
|
||||
}
|
||||
var foodData = make(map[string]interface{})
|
||||
if v.IsSpec != 0 && v.IsSpec == -1 {
|
||||
v.IsSpec = 0
|
||||
}
|
||||
foodData["is_specialty"] = v.IsSpec
|
||||
foodData["price"] = food.Price
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
err = mtapi.RetailInitData(ctx.GetTrackInfo(), store.VendorStoreID, utils.Int2Str(v.SkuID), foodData)
|
||||
//权限
|
||||
if permission.IsRoled(ctx) {
|
||||
if storeIDsMap, err := permission.GetUserStoresResultMap(ctx.GetUserID()); err == nil {
|
||||
for _, v := range results {
|
||||
if storeIDsMap[v.StoreID] == 0 {
|
||||
continue
|
||||
}
|
||||
store, err := dao.GetStoreDetail(db, v.StoreID, model.VendorIDMTWM, "")
|
||||
if err != nil || store == nil {
|
||||
continue
|
||||
}
|
||||
mtapi := apimanager.CurAPIManager.GetAPI(model.VendorIDMTWM, store.VendorOrgCode).(*mtwmapi.API)
|
||||
food, err := mtapi.RetailGet(store.VendorStoreID, utils.Int2Str(v.SkuID))
|
||||
if err != nil || food == nil {
|
||||
continue
|
||||
}
|
||||
var foodData = make(map[string]interface{})
|
||||
if v.IsSpec != 0 && v.IsSpec == -1 {
|
||||
v.IsSpec = 0
|
||||
}
|
||||
foodData["is_specialty"] = v.IsSpec
|
||||
foodData["price"] = food.Price
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
err = mtapi.RetailInitData(ctx.GetTrackInfo(), store.VendorStoreID, utils.Int2Str(v.SkuID), foodData)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user