- 同步平台商品时,如果修复一个不存在的SKU,要报错。删除成功后清除平台SKUID
This commit is contained in:
@@ -212,11 +212,12 @@ func sku2Update(vendorID int, sku *dao.StoreSkuSyncInfo, syncStatus int8) (item
|
|||||||
if syncStatus&(model.SyncFlagDeletedMask|model.SyncFlagNewMask|model.SyncFlagModifiedMask) != 0 {
|
if syncStatus&(model.SyncFlagDeletedMask|model.SyncFlagNewMask|model.SyncFlagModifiedMask) != 0 {
|
||||||
sku.StoreSkuSyncStatus = 0
|
sku.StoreSkuSyncStatus = 0
|
||||||
if model.IsSyncStatusNew(syncStatus) {
|
if model.IsSyncStatusNew(syncStatus) {
|
||||||
kvs[dao.GetVendorThingIDStructField(model.VendorNames[vendorID])] = sku.VendorSkuID
|
kvs[dao.GetVendorThingIDStructField(model.VendorNames[vendorID])] = utils.Str2Int64WithDefault(sku.VendorSkuID, 0)
|
||||||
} else if model.IsSyncStatusDelete(syncStatus) {
|
} else if model.IsSyncStatusDelete(syncStatus) {
|
||||||
if utils.IsTimeZero(sku.BindDeletedAt) {
|
if utils.IsTimeZero(sku.BindDeletedAt) {
|
||||||
kvs[model.FieldDeletedAt] = time.Now()
|
kvs[model.FieldDeletedAt] = time.Now()
|
||||||
}
|
}
|
||||||
|
kvs[dao.GetVendorThingIDStructField(model.VendorNames[vendorID])] = 0
|
||||||
}
|
}
|
||||||
} else if syncStatus&model.SyncFlagStockMask != 0 {
|
} else if syncStatus&model.SyncFlagStockMask != 0 {
|
||||||
if isStoreSkuSyncNeedDelete(sku) {
|
if isStoreSkuSyncNeedDelete(sku) {
|
||||||
@@ -310,29 +311,37 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, isFull bo
|
|||||||
createList = append(createList, sku)
|
createList = append(createList, sku)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if !dao.IsVendorThingIDEmpty(sku.VendorSkuID) {
|
} else {
|
||||||
if model.IsSyncStatusUpdate(sku.StoreSkuSyncStatus) && singleStoreHandler != nil {
|
if dao.IsVendorThingIDEmpty(sku.VendorSkuID) {
|
||||||
updateList = append(updateList, calVendorPrice4StoreSku(sku, storeDetail.PricePercentagePackObj, int(storeDetail.PricePercentage)))
|
err = fmt.Errorf("门店:%d,修改没有创建的商品:%d", storeID, sku.SkuID)
|
||||||
|
if parentTask == nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
parentTask.AddBatchErr(err)
|
||||||
} else {
|
} else {
|
||||||
if model.IsSyncStatusPrice(sku.StoreSkuSyncStatus) {
|
if model.IsSyncStatusUpdate(sku.StoreSkuSyncStatus) && singleStoreHandler != nil {
|
||||||
bareSku = storeSkuSyncInfo2Bare(calVendorPrice4StoreSku(sku, storeDetail.PricePercentagePackObj, int(storeDetail.PricePercentage)))
|
updateList = append(updateList, calVendorPrice4StoreSku(sku, storeDetail.PricePercentagePackObj, int(storeDetail.PricePercentage)))
|
||||||
priceList = append(priceList, bareSku)
|
} else {
|
||||||
}
|
if model.IsSyncStatusPrice(sku.StoreSkuSyncStatus) {
|
||||||
if model.IsSyncStatusUpdate(sku.StoreSkuSyncStatus) && singleStoreHandler == nil { // 正常就不应该进到这里
|
bareSku = storeSkuSyncInfo2Bare(calVendorPrice4StoreSku(sku, storeDetail.PricePercentagePackObj, int(storeDetail.PricePercentage)))
|
||||||
if bareSku == nil {
|
priceList = append(priceList, bareSku)
|
||||||
bareSku = storeSkuSyncInfo2Bare(sku)
|
|
||||||
}
|
}
|
||||||
updateItems = append(updateItems, sku2Update(vendorID, sku, model.SyncFlagStockMask))
|
if model.IsSyncStatusUpdate(sku.StoreSkuSyncStatus) && singleStoreHandler == nil { // 正常就不应该进到这里
|
||||||
}
|
if bareSku == nil {
|
||||||
if model.IsSyncStatusSale(sku.StoreSkuSyncStatus) {
|
bareSku = storeSkuSyncInfo2Bare(sku)
|
||||||
if bareSku == nil {
|
}
|
||||||
bareSku = storeSkuSyncInfo2Bare(sku)
|
updateItems = append(updateItems, sku2Update(vendorID, sku, model.SyncFlagStockMask))
|
||||||
}
|
}
|
||||||
if sku.MergedStatus == model.SkuStatusNormal {
|
if model.IsSyncStatusSale(sku.StoreSkuSyncStatus) {
|
||||||
onlineList = append(onlineList, bareSku)
|
if bareSku == nil {
|
||||||
stockList = append(stockList, bareSku)
|
bareSku = storeSkuSyncInfo2Bare(sku)
|
||||||
} else {
|
}
|
||||||
offlineList = append(offlineList, bareSku)
|
if sku.MergedStatus == model.SkuStatusNormal {
|
||||||
|
onlineList = append(onlineList, bareSku)
|
||||||
|
stockList = append(stockList, bareSku)
|
||||||
|
} else {
|
||||||
|
offlineList = append(offlineList, bareSku)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -471,6 +480,7 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, isFull bo
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 清除京西没有,平台有的商品
|
||||||
func PruneMissingStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorID, storeID int, vendorStoreID string, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func PruneMissingStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorID, storeID int, vendorStoreID string, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
handler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler)
|
handler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler)
|
||||||
if handler == nil {
|
if handler == nil {
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ type ITask interface {
|
|||||||
GetErr() error
|
GetErr() error
|
||||||
// GetDetailErrList() []error
|
// GetDetailErrList() []error
|
||||||
GetLeafResult() (finishedItemCount, failedItemCount int)
|
GetLeafResult() (finishedItemCount, failedItemCount int)
|
||||||
|
AddBatchErr(err error)
|
||||||
|
|
||||||
json.Marshaler
|
json.Marshaler
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user