- 新同步逻辑调整,京东还有问题
This commit is contained in:
@@ -34,9 +34,9 @@ type StoreSkuInfo struct {
|
||||
NameID int `json:"nameID,omitempty"`
|
||||
VendorNameID string `json:"vendorNameID,omitempty"`
|
||||
|
||||
Stock int `json:"stock,omitempty"`
|
||||
Price int64 `json:"price,omitempty"`
|
||||
Status int `json:"status,omitempty"`
|
||||
Stock int `json:"stock,omitempty"`
|
||||
VendorPrice int64 `json:"price,omitempty"`
|
||||
Status int `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type SkuInfo struct {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ func (p *PurchaseHandler) GetStoreSkusBareInfo(ctx *jxcontext.Context, parentTas
|
||||
storeSkuMap[v.SkuID].Status = jdStoreSkuStatus2Jx(v.Vendibility)
|
||||
}
|
||||
for _, v := range priceInfo {
|
||||
storeSkuMap[v.SkuID].Price = v.Price
|
||||
storeSkuMap[v.SkuID].VendorPrice = v.Price
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,14 +94,14 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID
|
||||
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (err error) {
|
||||
if len(storeSkuList) == 1 {
|
||||
if globals.EnableJdStoreWrite {
|
||||
_, err = api.JdAPI.UpdateStationPrice(utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), vendorStoreID, int(storeSkuList[0].Price))
|
||||
_, err = api.JdAPI.UpdateStationPrice(utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), vendorStoreID, int(storeSkuList[0].VendorPrice))
|
||||
}
|
||||
} else {
|
||||
var skuPriceInfoList []*jdapi.SkuPriceInfo
|
||||
for _, v := range storeSkuList {
|
||||
skuPriceInfoList = append(skuPriceInfoList, &jdapi.SkuPriceInfo{
|
||||
OutSkuId: utils.Int2Str(v.SkuID),
|
||||
Price: int(v.Price),
|
||||
Price: int(v.VendorPrice),
|
||||
})
|
||||
}
|
||||
if globals.EnableJdStoreWrite {
|
||||
|
||||
@@ -10,6 +10,11 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/globals/testinit"
|
||||
)
|
||||
|
||||
const (
|
||||
testShopVendorID = "2523687"
|
||||
testShopID = 2
|
||||
)
|
||||
|
||||
func init() {
|
||||
testinit.Init()
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user