- 新同步逻辑调整,京东还有问题

This commit is contained in:
gazebo
2019-07-18 09:11:31 +08:00
parent b5b3d82130
commit 2c2659b0ed
10 changed files with 98 additions and 59 deletions

View File

@@ -138,7 +138,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (err error) {
skuPriceList := make([]string, len(storeSkuList))
for k, v := range storeSkuList {
skuPriceList[k] = fmt.Sprintf("%s:%d", v.VendorSkuID, v.Price)
skuPriceList[k] = fmt.Sprintf("%s:%d", v.VendorSkuID, v.VendorPrice)
}
if globals.EnableEbaiStoreWrite {
if len(skuPriceList) > 1 {
@@ -167,7 +167,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID i
func genSkuParamsFromStoreSkuInfo2(storeSku *dao.StoreSkuSyncInfo) (params map[string]interface{}) {
params = map[string]interface{}{
"name": storeSku.Name,
"name": utils.LimitMixedStringLen(storeSku.SkuName, ebaiapi.MaxSkuNameByteCount),
"left_num": model.MaxStoreSkuStockQty,
"category_id": utils.Str2Int64(storeSku.VendorCatID),
"predict_cat": 0, // 不使用推荐类目
@@ -190,7 +190,7 @@ func genSkuParamsFromStoreSkuInfo2(storeSku *dao.StoreSkuSyncInfo) (params map[s
params["market_price"] = storeSku.VendorPrice
}
if storeSku.StoreSkuSyncStatus&(model.SyncFlagSaleMask|model.SyncFlagNewMask) != 0 {
params["status"] = jxSkuStatus2Ebai(storeSku.StoreSkuStatus)
params["status"] = jxSkuStatus2Ebai(storeSku.MergedStatus)
}
// todo 饿百如果给的UPC是空要报错但如果我要删除UPC怎么弄
// if storeSku.Upc != "" {
@@ -275,9 +275,9 @@ func vendorSku2Jx(vendorSku *ebaiapi.SkuInfo) (skuName *partner.SkuNameInfo) {
VendorSkuID: vendorSkuID,
SkuID: skuID,
Stock: vendorSku.LeftNum,
Price: vendorSku.SalePrice,
Status: ebaiSkuStatus2Jx(vendorSku.Status),
Stock: vendorSku.LeftNum,
VendorPrice: vendorSku.SalePrice,
Status: ebaiSkuStatus2Jx(vendorSku.Status),
},
SkuName: vendorSku.Name,
Comment: comment,

View File

@@ -13,7 +13,7 @@ func TestSyncStoresSkus(t *testing.T) {
for i := 0; i < 100; i++ {
skus[i] = i + 1
}
_, err := new(PurchaseHandler).SyncStoreSkus(jxcontext.AdminCtx, nil, testShopID, skus, false, false)
_, err := CurPurchaseHandler.SyncStoreSkus(jxcontext.AdminCtx, nil, testShopID, skus, false, false)
if err != nil {
t.Fatal(err.Error())
}
@@ -22,21 +22,21 @@ func TestSyncStoresSkus(t *testing.T) {
func TestSyncOneStoreCategoriesFromRemote2Local(t *testing.T) {
db := dao.GetDB()
err := new(PurchaseHandler).SyncLocalStoreCategory(db, testShopID, "autotest")
err := CurPurchaseHandler.SyncLocalStoreCategory(db, testShopID, "autotest")
if err != nil {
t.Fatal(err.Error())
}
}
func TestSyncOneStoreCategoriesFromLocal2Remote(t *testing.T) {
_, err := new(PurchaseHandler).SyncStoreCategory(jxcontext.AdminCtx, nil, testShopID, false)
_, err := CurPurchaseHandler.SyncStoreCategory(jxcontext.AdminCtx, nil, testShopID, false)
if err != nil {
t.Fatal(err.Error())
}
}
func TestGetAllRemoteSkus(t *testing.T) {
result, err := new(PurchaseHandler).GetAllRemoteSkus(jxcontext.AdminCtx, testShopID, nil)
result, err := CurPurchaseHandler.GetStoreSkusFullInfo(jxcontext.AdminCtx, nil, testShopID, testShopBaiduID, nil)
if err != nil {
t.Fatal(err.Error())
} else {
@@ -45,14 +45,14 @@ func TestGetAllRemoteSkus(t *testing.T) {
}
func TestDeleteRemoteSkus(t *testing.T) {
err := new(PurchaseHandler).DeleteRemoteSkus(jxcontext.AdminCtx, nil, testShopID, nil)
err := CurPurchaseHandler.DeleteStoreAllSkus(jxcontext.AdminCtx, nil, testShopID, testShopBaiduID, true)
if err != nil {
t.Fatal(err.Error())
}
}
func TestDeleteRemoteCategories(t *testing.T) {
err := new(PurchaseHandler).DeleteRemoteCategories(jxcontext.AdminCtx, nil, testShopID, nil)
err := new(PurchaseHandler).DeleteStoreAllCategories(jxcontext.AdminCtx, nil, testShopID, testShopBaiduID, true)
if err != nil {
t.Fatal(err.Error())
}