From 5ea2ae970bdaa93005612bec3ae63d3f345e6c9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Fri, 20 Mar 2020 15:56:42 +0800 Subject: [PATCH] =?UTF-8?q?=E9=93=B6=E8=B1=B9=E5=88=9B=E5=BB=BA=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=B0=9D=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/partner/purchase/yb/store_sku.go | 27 +++++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/business/partner/purchase/yb/store_sku.go b/business/partner/purchase/yb/store_sku.go index bc5647bef..3b5f20f0a 100644 --- a/business/partner/purchase/yb/store_sku.go +++ b/business/partner/purchase/yb/store_sku.go @@ -2,20 +2,27 @@ package yb import ( "git.rosy.net.cn/baseapi/platformapi/yinbaoapi" + "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" + "git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/business/model/dao" "git.rosy.net.cn/jx-callback/business/partner" + "git.rosy.net.cn/jx-callback/business/partner/putils" "git.rosy.net.cn/jx-callback/globals/api" ) -const ( - stock = 100 +var ( + stock float64 = 100 ) func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) { storeSku := storeSkuList[0] api.YinBaoAPI = yinbaoapi.New(storeSku.YbAppKey, storeSku.YbAppID) - api.YinBaoAPI.AddProductInfo(buildProductInfoParam(storeSku)) + result, err := api.YinBaoAPI.AddProductInfo(buildProductInfoParam(storeSku)) + if err != nil { + failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDYB], "εˆ›ε»Ίε•†ε“") + } + storeSku.VendorSkuID = utils.Int64ToStr(result.UID) return failedList, err } @@ -24,12 +31,18 @@ func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, storeID int, v } func buildProductInfoParam(storeSku *dao.StoreSkuSyncInfo) (productInfoParam *yinbaoapi.ProductInfoParam) { + var ( + buyPrice float64 = utils.Str2Float64(utils.Int64ToStr(storeSku.Price)) + sellPrice float64 = utils.Str2Float64(utils.Int64ToStr(storeSku.VendorPrice)) + ) productInfoParam = &yinbaoapi.ProductInfoParam{} productInfo := &yinbaoapi.ProductInfo{ - Stock: stock, - Name: storeSku.SkuName, - Barcode: storeSku.SkuID, - BuyPrice: storeSku.pr + Stock: &stock, + Name: storeSku.SkuName, + Barcode: utils.Int2Str(storeSku.SkuID), + BuyPrice: &buyPrice, + SellPrice: &sellPrice, } + productInfoParam.ProductInfo = productInfo return productInfoParam }