- 重构partner_store_sku
This commit is contained in:
@@ -17,10 +17,14 @@ func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) (batchSize int) {
|
||||
switch funcID {
|
||||
case partner.FuncUpdateStoreSkusStock, partner.FuncUpdateStoreSkusStatus, partner.FuncUpdateStoreSkusPrice:
|
||||
batchSize = mtwmapi.MaxStoreSkuBatchSize
|
||||
case partner.FuncGetStoreSkusBareInfo:
|
||||
batchSize = 1
|
||||
case partner.FuncDeleteStoreSkus:
|
||||
batchSize = 1 // 可考虑用批量操作
|
||||
case partner.FuncCreateStoreSkus, partner.FuncUpdateStoreSkus:
|
||||
batchSize = 1 // 可考虑用批量操作
|
||||
case partner.FuncGetStoreSkusFullInfo:
|
||||
batchSize = 1
|
||||
}
|
||||
return batchSize
|
||||
}
|
||||
@@ -151,7 +155,7 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.BareStoreSkuInfo) (err error) {
|
||||
func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (err error) {
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
if len(storeSkuList) == 1 {
|
||||
err = api.MtwmAPI.RetailDelete(vendorStoreID, storeSkuList[0].VendorSkuID)
|
||||
@@ -165,7 +169,7 @@ func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.BareStoreSkuInfo) (err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (err error) {
|
||||
var validSkus, invalidSkus []*mtwmapi.BareStoreFoodInfo
|
||||
for _, storeSku := range storeSkuList {
|
||||
skuInfo := &mtwmapi.BareStoreFoodInfo{
|
||||
@@ -193,7 +197,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.BareStoreSkuInfo) (err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (err error) {
|
||||
var priceList []*mtwmapi.BareStoreFoodInfo
|
||||
for _, storeSku := range storeSkuList {
|
||||
skuInfo := &mtwmapi.BareStoreFoodInfo{
|
||||
@@ -213,7 +217,7 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.BareStoreSkuInfo) (err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (err error) {
|
||||
var stockList []*mtwmapi.BareStoreFoodInfo
|
||||
for _, storeSku := range storeSkuList {
|
||||
skuInfo := &mtwmapi.BareStoreFoodInfo{
|
||||
@@ -233,7 +237,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID i
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.BareStoreSkuInfo) (outStoreSkuList []*partner.BareStoreSkuInfo, err error) {
|
||||
func (p *PurchaseHandler) GetStoreSkusBareInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.StoreSkuInfo) (outStoreSkuList []*partner.StoreSkuInfo, err error) {
|
||||
vendorSkuIDList := partner.BareStoreSkuInfoList(inStoreSkuList).GetVendorSkuIDList()
|
||||
var vendorFoodList []*mtwmapi.AppFood
|
||||
if len(vendorSkuIDList) > 1 {
|
||||
@@ -258,7 +262,7 @@ func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask ta
|
||||
return nil, nil
|
||||
}
|
||||
if err == nil {
|
||||
storeSkuMap := make(map[string]*partner.BareStoreSkuInfo)
|
||||
storeSkuMap := make(map[string]*partner.StoreSkuInfo)
|
||||
for _, v := range inStoreSkuList {
|
||||
storeSkuMap[v.VendorSkuID] = v
|
||||
}
|
||||
@@ -283,16 +287,24 @@ func mtwmSkuStatus2Jx(mtwmSkuStatus int) (jxSkuStatus int) {
|
||||
return jxSkuStatus
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetStoreAllSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string) (skuNameList []*partner.SkuNameInfo, err error) {
|
||||
for {
|
||||
result, err := api.MtwmAPI.RetailList(vendorStoreID, len(skuNameList), mtwmapi.GeneralMaxLimit)
|
||||
func (p *PurchaseHandler) GetStoreSkusFullInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, skuIDs []int) (skuNameList []*partner.SkuNameInfo, err error) {
|
||||
if len(skuIDs) == 0 {
|
||||
for {
|
||||
result, err := api.MtwmAPI.RetailList(vendorStoreID, len(skuNameList), mtwmapi.GeneralMaxLimit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
skuNameList = append(skuNameList, vendorSkuList2Jx(result)...)
|
||||
if len(result) < mtwmapi.GeneralMaxLimit {
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
skuInfo, err := api.MtwmAPI.RetailGet(vendorStoreID, utils.Int2Str(skuIDs[0]))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
skuNameList = append(skuNameList, vendorSkuList2Jx(result)...)
|
||||
if len(result) < mtwmapi.GeneralMaxLimit {
|
||||
break
|
||||
}
|
||||
skuNameList = append(skuNameList, vendorSku2Jx(skuInfo))
|
||||
}
|
||||
return skuNameList, err
|
||||
}
|
||||
@@ -308,9 +320,9 @@ func vendorSku2Jx(vendorSku *mtwmapi.AppFood) (skuName *partner.SkuNameInfo) {
|
||||
Prefix: prefix,
|
||||
Name: name,
|
||||
Unit: unit,
|
||||
SkuList: []*partner.FullSkuInfo{
|
||||
&partner.FullSkuInfo{
|
||||
BareStoreSkuInfo: partner.BareStoreSkuInfo{
|
||||
SkuList: []*partner.SkuInfo{
|
||||
&partner.SkuInfo{
|
||||
StoreSkuInfo: partner.StoreSkuInfo{
|
||||
VendorSkuID: mtwmSku.SkuID,
|
||||
SkuID: int(utils.Str2Int64WithDefault(mtwmSku.SkuID, 0)),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user