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

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

@@ -10,6 +10,11 @@ import (
"git.rosy.net.cn/jx-callback/globals/testinit"
)
const (
testShopVendorID = "2523687"
testShopID = 2
)
func init() {
testinit.Init()
}

View File

@@ -117,15 +117,15 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
},
}
foodData["skus"] = skus
foodData["name"] = utils.LimitUTF8StringLen(storeSku.Name, 30)
foodData["name"] = utils.LimitUTF8StringLen(storeSku.SkuName, mtwmapi.MaxSkuNameCharCount)
foodData["description"] = storeSku.Comment
foodData["price"] = storeSku.VendorPrice
foodData["price"] = jxutils.IntPrice2Standard(storeSku.VendorPrice)
foodData["min_order_count"] = 1
foodData["unit"] = storeSku.Unit
foodData["box_num"] = 0
foodData["box_price"] = 0.0
foodData["category_name"] = storeSku.VendorCatID
foodData["is_sold_out"] = skuStatusJX2Mtwm(storeSku.StoreSkuStatus)
foodData["is_sold_out"] = skuStatusJX2Mtwm(storeSku.MergedStatus)
foodData["picture"] = storeSku.Img
if storeSku.DescImg != "" {
foodData["picture_contents"] = storeSku.DescImg
@@ -205,7 +205,7 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
Skus: []*mtwmapi.BareStoreSkuInfo{
&mtwmapi.BareStoreSkuInfo{
SkuID: storeSku.VendorSkuID,
Price: utils.Int64ToStr(storeSku.Price),
Price: jxutils.IntPrice2StandardString(storeSku.VendorPrice),
},
},
}
@@ -289,9 +289,9 @@ func vendorSku2Jx(appFood *mtwmapi.AppFood) (skuName *partner.SkuNameInfo) {
VendorSkuID: vendorSku.SkuID,
SkuID: skuID,
Stock: int(utils.Str2Int64WithDefault(vendorSku.Stock, partner.UnlimitedStoreSkuStock)),
Price: jxutils.StandardPrice2Int(utils.Str2Float64WithDefault(vendorSku.Price, 0)),
Status: mtwmSkuStatus2Jx(appFood.IsSoldOut),
Stock: int(utils.Str2Int64WithDefault(vendorSku.Stock, partner.UnlimitedStoreSkuStock)),
VendorPrice: jxutils.StandardPrice2Int(utils.Str2Float64WithDefault(vendorSku.Price, 0)),
Status: mtwmSkuStatus2Jx(appFood.IsSoldOut),
},
SkuName: appFood.Name,
Comment: comment,

View File

@@ -8,7 +8,7 @@ import (
)
func TestSyncStoreCategory(t *testing.T) {
hint, err := new(PurchaseHandler).SyncStoreCategory(jxcontext.AdminCtx, nil, 100077, false)
hint, err := curPurchaseHandler.SyncStoreCategory(jxcontext.AdminCtx, nil, testShopID, false)
if err != nil {
t.Fatal(err)
}
@@ -16,7 +16,7 @@ func TestSyncStoreCategory(t *testing.T) {
}
func TestSyncLocalStoreCategory(t *testing.T) {
hint, err := new(PurchaseHandler).SyncLocalStoreCategory(jxcontext.AdminCtx, nil, 100077, true, nil)
hint, err := curPurchaseHandler.SyncLocalStoreCategory(jxcontext.AdminCtx, nil, testShopID, true, nil)
if err != nil {
t.Fatal(err)
}
@@ -24,7 +24,7 @@ func TestSyncLocalStoreCategory(t *testing.T) {
}
func TestSyncStoreSkus(t *testing.T) {
hint, err := new(PurchaseHandler).SyncStoreSkus(jxcontext.AdminCtx, nil, 100077, nil, false, true)
hint, err := curPurchaseHandler.SyncStoreSkus(jxcontext.AdminCtx, nil, testShopID, nil, false, true)
if err != nil {
t.Fatal(err)
}
@@ -32,14 +32,14 @@ func TestSyncStoreSkus(t *testing.T) {
}
func TestDeleteRemoteSkus(t *testing.T) {
err := new(PurchaseHandler).DeleteRemoteSkus(jxcontext.AdminCtx, nil, 100077, nil)
err := curPurchaseHandler.DeleteStoreAllSkus(jxcontext.AdminCtx, nil, testShopID, testShopVendorID, true)
if err != nil {
t.Fatal(err)
}
}
func TestDeleteRemoteCategories(t *testing.T) {
err := new(PurchaseHandler).DeleteRemoteCategories(jxcontext.AdminCtx, nil, 100077, nil)
err := curPurchaseHandler.DeleteStoreAllCategories(jxcontext.AdminCtx, nil, testShopID, testShopVendorID, true)
if err != nil {
t.Fatal(err)
}