49 lines
1.8 KiB
Go
49 lines
1.8 KiB
Go
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"
|
|
)
|
|
|
|
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)
|
|
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
|
|
}
|
|
|
|
func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
|
return failedList, err
|
|
}
|
|
|
|
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: utils.Int2Str(storeSku.SkuID),
|
|
BuyPrice: &buyPrice,
|
|
SellPrice: &sellPrice,
|
|
}
|
|
productInfoParam.ProductInfo = productInfo
|
|
return productInfoParam
|
|
}
|