- 一些与门店商品信息操作相关的API
This commit is contained in:
@@ -32,14 +32,29 @@ type PendingSaveB2CSkuVo struct {
|
||||
|
||||
type PendingSaveSkuVo struct {
|
||||
OuterSkuCode string `json:"outerSkuCode"`
|
||||
ImageURL string `json:"imageUrl"`
|
||||
SalePrice float32 `json:"salePrice"`
|
||||
OriginalPrice float32 `json:"originalPrice"`
|
||||
CostPrice float32 `json:"costPrice"`
|
||||
ImageURL string `json:"imageUrl,omitempty"`
|
||||
SalePrice float64 `json:"salePrice"`
|
||||
OriginalPrice float64 `json:"originalPrice,omitempty"`
|
||||
CostPrice float64 `json:"costPrice"`
|
||||
EditStockNum int `json:"editStockNum"`
|
||||
B2cSku *PendingSaveB2CSkuVo `json:"b2cSku"`
|
||||
}
|
||||
|
||||
type PendingSaveGoodsVo struct {
|
||||
Title string `json:"title"`
|
||||
OuterGoodsCode string `json:"outerGoodsCode,omitempty"`
|
||||
IsMultiSku int `json:"isMultiSku"`
|
||||
GoodsImageURL []string `json:"goodsImageUrl"`
|
||||
GoodsDesc string `json:"goodsDesc"`
|
||||
InitialSales int `json:"initialSales,omitempty"`
|
||||
DeductStockType int `json:"deductStockType"`
|
||||
IsPutAway int `json:"isPutAway"`
|
||||
Sort int `json:"Sort,omitempty"`
|
||||
CategoryID int64 `json:"categoryId"`
|
||||
B2cGoods []*PendingSaveB2CGoodsVo `json:"b2cGoods"`
|
||||
SkuList []*PendingSaveSkuVo `json:"skuList"`
|
||||
}
|
||||
|
||||
type Category struct {
|
||||
CategoryID int64 `json:"categoryId"`
|
||||
Title string `json:"title"`
|
||||
@@ -198,6 +213,16 @@ func (a *API) UpdateClassify(classifyID int64, title string, imageURL string) (e
|
||||
return err
|
||||
}
|
||||
|
||||
func getDataFromCUGoodsResult(result interface{}) (goodsId int64, skuMap map[string]int64, err error) {
|
||||
skuMap = make(map[string]int64)
|
||||
skuList := result.(map[string]interface{})["skuList"].([]interface{})
|
||||
for _, v := range skuList {
|
||||
sku := v.(map[string]interface{})
|
||||
skuMap[utils.Interface2String(sku[KeyOuterSkuCode])] = utils.MustInterface2Int64(sku[KeySkuID])
|
||||
}
|
||||
return utils.MustInterface2Int64(result.(map[string]interface{})["goodsId"]), skuMap, nil
|
||||
}
|
||||
|
||||
func (a *API) AddGoods(outerGoodsCode, title string, isMultiSku bool, goodsImageUrl []string, goodsDesc string, isPutAway bool, sort int, categoryId int64, classifyIdList []int64, b2cGoods *PendingSaveB2CGoodsVo, skuList []map[string]interface{}, addParams map[string]interface{}) (goodsId int64, skuMap map[string]int64, err error) {
|
||||
goodsInfo := map[string]interface{}{
|
||||
"outerGoodsCode": outerGoodsCode,
|
||||
@@ -221,13 +246,20 @@ func (a *API) AddGoods(outerGoodsCode, title string, isMultiSku bool, goodsImage
|
||||
"goods": mergedMap,
|
||||
})
|
||||
if err == nil {
|
||||
skuMap := make(map[string]int64)
|
||||
skuList := result.(map[string]interface{})["skuList"].([]interface{})
|
||||
for _, v := range skuList {
|
||||
sku := v.(map[string]interface{})
|
||||
skuMap[utils.Interface2String(sku[KeyOuterSkuCode])] = utils.MustInterface2Int64(sku[KeySkuID])
|
||||
}
|
||||
return utils.MustInterface2Int64(result.(map[string]interface{})["goodsId"]), skuMap, nil
|
||||
return getDataFromCUGoodsResult(result)
|
||||
}
|
||||
return 0, nil, err
|
||||
}
|
||||
|
||||
func (a *API) AddGoods2(goodsInfo *PendingSaveGoodsVo) (goodsId int64, skuMap map[string]int64, err error) {
|
||||
if goodsInfo.DeductStockType == 0 {
|
||||
goodsInfo.DeductStockType = DeductStockTypePay
|
||||
}
|
||||
result, err := a.AccessAPI("goods/addGoods", map[string]interface{}{
|
||||
"goods": goodsInfo,
|
||||
})
|
||||
if err == nil {
|
||||
return getDataFromCUGoodsResult(result)
|
||||
}
|
||||
return 0, nil, err
|
||||
}
|
||||
@@ -254,13 +286,20 @@ func (a *API) UpdateGoods(goodsID int64, title string, isMultiSku bool, goodsIma
|
||||
"goods": mergedMap,
|
||||
})
|
||||
if err == nil {
|
||||
skuMap := make(map[string]int64)
|
||||
skuList := result.(map[string]interface{})["skuList"].([]interface{})
|
||||
for _, v := range skuList {
|
||||
sku := v.(map[string]interface{})
|
||||
skuMap[utils.Interface2String(sku[KeyOuterSkuCode])] = utils.MustInterface2Int64(sku[KeySkuID])
|
||||
}
|
||||
return utils.MustInterface2Int64(result.(map[string]interface{})["goodsId"]), skuMap, nil
|
||||
return getDataFromCUGoodsResult(result)
|
||||
}
|
||||
return 0, nil, err
|
||||
}
|
||||
|
||||
func (a *API) UpdateGoods2(goodsInfo *PendingSaveGoodsVo) (goodsId int64, skuMap map[string]int64, err error) {
|
||||
if goodsInfo.DeductStockType == 0 {
|
||||
goodsInfo.DeductStockType = DeductStockTypePay
|
||||
}
|
||||
result, err := a.AccessAPI("goods/updateGoods", map[string]interface{}{
|
||||
"goods": goodsInfo,
|
||||
})
|
||||
if err == nil {
|
||||
return getDataFromCUGoodsResult(result)
|
||||
}
|
||||
return 0, nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user