This commit is contained in:
richboo111
2022-11-16 10:45:57 +08:00
parent 4e2fc9e4c0
commit 7ba43abb27
4 changed files with 53 additions and 11 deletions

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"fmt"
"git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm"
"git.rosy.net.cn/jx-callback/business/partner/purchase/tiktok_store"
"io"
"math"
@@ -6638,11 +6639,25 @@ func SyncTiktokMainIdToLocal(ctx *jxcontext.Context, param *tiktok_store.MainSku
}
//批量更新美团商品进货价
func BatchSetRestockingPrice(ctx *jxcontext.Context, preData map[string]interface{}) error {
//spuData := []*mtwmapi.SpuData{}
//for k, v := range preData {
// //获取京西平台storeID
// err := dao.GetStoreDetail()
//}
func BatchSetRestockingPrice(ctx *jxcontext.Context, preData map[string][]mtwmapi.SpuData) error {
var params []*mtwmapi.SpuData
for k, v := range preData {
//获取京西平台storeID
if storeID, vendorOrgCode, err := dao.GetCodeAndIDByMeiTuan(k); err != nil {
return errors.New(fmt.Sprintf("获取京西本地门店ID失败:%v 请重试", err))
} else {
for _, i := range v {
param := &mtwmapi.SpuData{
AppSpuCode: i.AppSpuCode,
SkuID: i.SkuID,
PurchasePrice: i.PurchasePrice,
}
params = append(params, param)
}
if err := mtwm.GetAPI(vendorOrgCode, storeID, "").BatchSetRestockingPrice(ctx.GetTrackInfo(), k, params); err != nil {
return err
}
}
}
return nil
}

View File

@@ -1632,7 +1632,7 @@ func InsertIntoFreightTemplate(storeID int, vendorStoreID string, templateID, wa
}
//只获取美团平台的京西storeID
func GetStoreIDByMeiTuan(vendorStoreID string) (storeID int, err error) {
return 0, err
func GetCodeAndIDByMeiTuan(vendorStoreID string) (storeID int, vendorOrgCode string, err error) {
err = GetRow(GetDB(), &storeID, "SELECT s.store_id,s.vendor_org_code FROM store_map s WHERE s.vendor_store_id = ? AND s.vendor_id = ? ", vendorStoreID, model.VendorIDMTWM)
return storeID, vendorStoreID, err
}

View File

@@ -195,6 +195,30 @@ func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, storeID in
return err
}
//批量更新商品进货价
func (p *PurchaseHandler) BatchSetRestockingPrice(ctx *jxcontext.Context, preData map[string][]mtwmapi.SpuData) error {
var params []*mtwmapi.SpuData
for k, v := range preData {
//获取京西平台storeID
if storeID, vendorOrgCode, err := dao.GetCodeAndIDByMeiTuan(k); err != nil {
return err
} else {
for _, i := range v {
param := &mtwmapi.SpuData{
AppSpuCode: i.AppSpuCode,
SkuID: i.SkuID,
PurchasePrice: i.PurchasePrice,
}
params = append(params, param)
}
if err := GetAPI(vendorOrgCode, storeID, "").BatchSetRestockingPrice(ctx.GetTrackInfo(), k, params); err != nil {
return err
}
}
}
return nil
}
// 门店商品
// 多门店平台不需要实现这个接口

View File

@@ -1,6 +1,7 @@
package controllers
import (
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
"git.rosy.net.cn/jx-callback/business/jxstore/misc"
@@ -822,10 +823,12 @@ func (c *SkuController) SyncTiktokMainSkuToLocalSku() {
func (c *SkuController) BatchSetRestockingPrice() {
c.callBatchSetRestockingPrice(func(params *tSkuBatchSetRestockingPriceParams) (interface{}, string, error) {
payload := make(map[string]interface{})
payload := make(map[string][]mtwmapi.SpuData)
if err := utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err == nil {
err = cms.BatchSetRestockingPrice(params.Ctx, payload)
} else {
return nil, "", err
}
return nil, "", err
return nil, "", nil
})
}