jdshop
This commit is contained in:
@@ -357,6 +357,37 @@ func sku2Update(vendorID int, sku *dao.StoreSkuSyncInfo, syncStatus int8) (item
|
|||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func bindSkuAllStore(v *dao.StoreSkuSyncInfo) (err error) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
)
|
||||||
|
storeMaps, _ := dao.GetStoresMapList(db, []int{model.VendorIDJDShop}, nil, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "", "2")
|
||||||
|
task := tasksch.NewParallelTask("京东商城门店建商品", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(true), jxcontext.AdminCtx,
|
||||||
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
|
storeMap := batchItemList[0].(*model.StoreMap)
|
||||||
|
if err = api.JdShop2API.StoreSkuBindStore(false, []string{utils.Int64ToStr(v.JdsID)}, []string{storeMap.VendorStoreID}); err == nil {
|
||||||
|
storeSkus2, _ := dao.GetStoresSkusInfo(db, []int{storeMap.StoreID}, []int{v.SkuID})
|
||||||
|
if len(storeSkus2) > 0 {
|
||||||
|
status := storeSkus2[0].Status
|
||||||
|
stock := storeSkus2[0].Stock
|
||||||
|
price := storeSkus2[0].Price
|
||||||
|
if status == model.StoreSkuBindStatusNormal {
|
||||||
|
api.JdShop2API.StoreWareDoUpdate(status, v.JdsID, storeMap.VendorStoreID)
|
||||||
|
}
|
||||||
|
if stock != 0 {
|
||||||
|
api.JdShop2API.StoreUpdateStock(stock, v.JdsID, storeMap.VendorStoreID)
|
||||||
|
}
|
||||||
|
api.JdShop2API.StoreUpdatePrice(utils.Float64ToStr(jxutils.IntPrice2Standard(int64(price))), v.JdsID, storeMap.VendorStoreID)
|
||||||
|
} else {
|
||||||
|
return retVal, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retVal, err
|
||||||
|
}, storeMaps)
|
||||||
|
tasksch.HandleTask(task, nil, true).Run()
|
||||||
|
_, err = task.GetResult(0)
|
||||||
|
}
|
||||||
|
|
||||||
func updateStoreSku(db *dao.DaoDB, vendorID int, storeSkuList []*dao.StoreSkuSyncInfo, syncStatus int8) (num int64, err error) {
|
func updateStoreSku(db *dao.DaoDB, vendorID int, storeSkuList []*dao.StoreSkuSyncInfo, syncStatus int8) (num int64, err error) {
|
||||||
if len(storeSkuList) > 0 {
|
if len(storeSkuList) > 0 {
|
||||||
// defer func() {
|
// defer func() {
|
||||||
@@ -372,6 +403,9 @@ func updateStoreSku(db *dao.DaoDB, vendorID int, storeSkuList []*dao.StoreSkuSyn
|
|||||||
for k, vv := range v.StoreSkuSyncInfoJds {
|
for k, vv := range v.StoreSkuSyncInfoJds {
|
||||||
updateItemList[k] = sku2Update(vendorID, vv, syncStatus)
|
updateItemList[k] = sku2Update(vendorID, vv, syncStatus)
|
||||||
err = updateJdsWareID(db, vv)
|
err = updateJdsWareID(db, vv)
|
||||||
|
if v.VendorOrgCode == "2" {
|
||||||
|
err = bindSkuAllStore(vv)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
num, err = dao.BatchUpdateEntityByKV(db, updateItemList)
|
num, err = dao.BatchUpdateEntityByKV(db, updateItemList)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user