银豹创建商品尝试

This commit is contained in:
苏尹岚
2020-03-20 15:56:42 +08:00
parent 3a7c01313f
commit 5ea2ae970b

View File

@@ -2,20 +2,27 @@ package yb
import ( import (
"git.rosy.net.cn/baseapi/platformapi/yinbaoapi" "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/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/model/dao"
"git.rosy.net.cn/jx-callback/business/partner" "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" "git.rosy.net.cn/jx-callback/globals/api"
) )
const ( var (
stock = 100 stock float64 = 100
) )
func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) { func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
storeSku := storeSkuList[0] storeSku := storeSkuList[0]
api.YinBaoAPI = yinbaoapi.New(storeSku.YbAppKey, storeSku.YbAppID) 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 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) { 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{} productInfoParam = &yinbaoapi.ProductInfoParam{}
productInfo := &yinbaoapi.ProductInfo{ productInfo := &yinbaoapi.ProductInfo{
Stock: stock, Stock: &stock,
Name: storeSku.SkuName, Name: storeSku.SkuName,
Barcode: storeSku.SkuID, Barcode: utils.Int2Str(storeSku.SkuID),
BuyPrice: storeSku.pr BuyPrice: &buyPrice,
SellPrice: &sellPrice,
} }
productInfoParam.ProductInfo = productInfo
return productInfoParam return productInfoParam
} }