diff --git a/business/model/store.go b/business/model/store.go index b1ccae923..4920e0233 100644 --- a/business/model/store.go +++ b/business/model/store.go @@ -406,6 +406,7 @@ type Store struct { PackageSwitch int `orm:"size(8);column(package_switch);default(0)" json:"packageSwitch"` //物料购物单门店购买袋子开关[0打开/1关闭] PushBill int `orm:"size(8);column(push_bill);default(0)" json:"pushBill"` //是否推送门店账单[0推送/1不推送] FreightMarkup int `orm:"size(8);column(freight_markup);default(0)" json:"freightMarkup"` //门店为三方运单时,设置的运营加价 + QuotationPrice int `orm:"size(8);column(quotation_price);default(0)" json:"quotationPrice"` //报价门店,美团报价金额,单位分 } func (*Store) TableUnique() [][]string { diff --git a/business/partner/purchase/mtwm/store_sku2.go b/business/partner/purchase/mtwm/store_sku2.go index fb92815f6..3dea0611a 100644 --- a/business/partner/purchase/mtwm/store_sku2.go +++ b/business/partner/purchase/mtwm/store_sku2.go @@ -469,14 +469,15 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } } + api := getAPI(getStoreVendorOrgCode(storeID), storeID, vendorStoreID) if globals.EnableMtwmStoreWrite { if len(foodDataList) == 1 { foodDataList[0]["skus"] = string(utils.MustMarshal(foodDataList[0]["skus"])) - if err = getAPI(getStoreVendorOrgCode(storeID), storeID, vendorStoreID).RetailInitData(ctx.GetTrackInfo(), vendorStoreID, utils.Int2Str(storeSkuList[0].SkuID), foodDataList[0]); err != nil { + if err = api.RetailInitData(ctx.GetTrackInfo(), vendorStoreID, utils.Int2Str(storeSkuList[0].SkuID), foodDataList[0]); err != nil { failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDMTWM], syncType) } } else if len(foodDataList) > 0 { - failedFoodList, err2 := getAPI(getStoreVendorOrgCode(storeID), storeID, vendorStoreID).RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList) + failedFoodList, err2 := api.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList) if err = err2; err == nil { if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil { failedList = SelectStoreSkuListByFoodList(storeSkuList, failedFoodList, storeID, model.VendorChineseNames[model.VendorIDMTWM], syncType) @@ -490,12 +491,38 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } } } + + storeDetail, _ := dao.GetStoreDetail(dao.GetDB(), storeID, model.VendorIDMTWM, "") + spuList := make([]*mtwmapi.SpuData, 0, 0) for _, storeSku := range storeSkuList { + if storeDetail.QuotationPrice != 0 && storeDetail.PayPercentage >= 50 { + spuList = append(spuList, &mtwmapi.SpuData{ + AppSpuCode: utils.Int2Str(storeSku.SkuID), + SkuID: utils.Int2Str(storeSku.SkuID), + PurchasePrice: utils.Float64ToStr(float64(storeDetail.QuotationPrice) / float64(100)), + }) + } storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) } if len(failedList) > 0 { err = nil } + + // 报价门店同步进货价 + if len(spuList) > 0 { + count := len(spuList) / 50 + if len(spuList)%50 != 0 { + count++ + } + for i := 1; i <= count; i++ { + if i == count { + api.BatchSetRestockingPrice(utils.GetUUID(), vendorStoreID, spuList[(i-1)*50:]) + } else { + api.BatchSetRestockingPrice(utils.GetUUID(), vendorStoreID, spuList[(i-1)*50:i*50]) + } + } + } + return failedList, err }