- updateStoresSkusWithoutSync与UpdateStoresSkusSale过滤重复项
This commit is contained in:
@@ -605,7 +605,29 @@ func checkStoresSkusSaleCity(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs []i
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func uniqueStoreIDs(storeIDs []int) []int {
|
||||||
|
storeIDMap := make(map[int]int)
|
||||||
|
for _, v := range storeIDs {
|
||||||
|
storeIDMap[v] = 1
|
||||||
|
}
|
||||||
|
return jxutils.IntMap2List(storeIDMap)
|
||||||
|
}
|
||||||
|
|
||||||
|
func uniqueStoreNameBind(skuBindInfos []*StoreSkuBindInfo) (outSkuBindInfos []*StoreSkuBindInfo) {
|
||||||
|
nameIDMap := make(map[int]int)
|
||||||
|
for _, v := range skuBindInfos {
|
||||||
|
if nameIDMap[v.NameID] != 1 {
|
||||||
|
outSkuBindInfos = append(outSkuBindInfos, v)
|
||||||
|
nameIDMap[v.NameID] = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return outSkuBindInfos
|
||||||
|
}
|
||||||
|
|
||||||
func updateStoresSkusWithoutSync(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*StoreSkuBindInfo) (needSyncSkus []int, err error) {
|
func updateStoresSkusWithoutSync(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*StoreSkuBindInfo) (needSyncSkus []int, err error) {
|
||||||
|
storeIDs = uniqueStoreIDs(storeIDs)
|
||||||
|
skuBindInfos = uniqueStoreNameBind(skuBindInfos)
|
||||||
|
|
||||||
sort.Ints(storeIDs)
|
sort.Ints(storeIDs)
|
||||||
globals.SugarLogger.Debugf("updateStoresSkusWithoutSync, storeIDs:%v, skuBindInfos:%s", storeIDs, utils.Format4Output(skuBindInfos, false))
|
globals.SugarLogger.Debugf("updateStoresSkusWithoutSync, storeIDs:%v, skuBindInfos:%s", storeIDs, utils.Format4Output(skuBindInfos, false))
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
@@ -839,7 +861,21 @@ func updateStoreSkusSaleWithoutSync(ctx *jxcontext.Context, storeID int, skuBind
|
|||||||
return needSyncSkus, err
|
return needSyncSkus, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func uniqueStoreSkuBind(skuBindSkuInfos []*StoreSkuBindSkuInfo) (outSkuBindSkuInfos []*StoreSkuBindSkuInfo) {
|
||||||
|
skuIDMap := make(map[int]int)
|
||||||
|
for _, v := range skuBindSkuInfos {
|
||||||
|
if skuIDMap[v.SkuID] != 1 {
|
||||||
|
outSkuBindSkuInfos = append(outSkuBindSkuInfos, v)
|
||||||
|
skuIDMap[v.SkuID] = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return outSkuBindSkuInfos
|
||||||
|
}
|
||||||
|
|
||||||
func UpdateStoresSkusSale(ctx *jxcontext.Context, storeIDs []int, skuBindSkuInfos []*StoreSkuBindSkuInfo, userName string, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func UpdateStoresSkusSale(ctx *jxcontext.Context, storeIDs []int, skuBindSkuInfos []*StoreSkuBindSkuInfo, userName string, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
|
storeIDs = uniqueStoreIDs(storeIDs)
|
||||||
|
skuBindSkuInfos = uniqueStoreSkuBind(skuBindSkuInfos)
|
||||||
|
|
||||||
var num int64
|
var num int64
|
||||||
for _, storeID := range storeIDs {
|
for _, storeID := range storeIDs {
|
||||||
skuIDs, err2 := updateStoreSkusSaleWithoutSync(ctx, storeID, skuBindSkuInfos, userName)
|
skuIDs, err2 := updateStoreSkusSaleWithoutSync(ctx, storeID, skuBindSkuInfos, userName)
|
||||||
|
|||||||
Reference in New Issue
Block a user