银豹创建商品尝试

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 (
"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
}