diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index f808d311f..155767a77 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -225,10 +225,21 @@ func calVendorPrice4StoreSku(inSku *dao.StoreSkuSyncInfo, pricePercentagePack mo return inSku } +func getSkuBoxFee(vendorID int) (boxFee int64) { + if vendorID == model.VendorIDMTWM { + boxFee, _ = dao.GetSysConfigAsInt64(dao.GetDB(), model.ConfigSysMtwmSkuBoxFee) + } + return boxFee +} + func formalizeStoreSkuList(inSkuList []*dao.StoreSkuSyncInfo) []*dao.StoreSkuSyncInfo { - for _, skuItem := range inSkuList { - skuItem.MergedStatus = jxutils.MergeSkuStatus(skuItem.Status, skuItem.StoreSkuStatus) - skuItem.SkuName = jxutils.ComposeSkuNameSync(skuItem.Prefix, skuItem.Name, skuItem.Comment, skuItem.Unit, skuItem.SpecQuality, skuItem.SpecUnit, 0, skuItem.ExPrefix, skuItem.ExPrefixBegin, skuItem.ExPrefixEnd) + if len(inSkuList) > 0 { + boxFee := getSkuBoxFee(inSkuList[0].VendorID) + for _, skuItem := range inSkuList { + skuItem.BoxFee = boxFee + skuItem.MergedStatus = jxutils.MergeSkuStatus(skuItem.Status, skuItem.StoreSkuStatus) + skuItem.SkuName = jxutils.ComposeSkuNameSync(skuItem.Prefix, skuItem.Name, skuItem.Comment, skuItem.Unit, skuItem.SpecQuality, skuItem.SpecUnit, 0, skuItem.ExPrefix, skuItem.ExPrefixBegin, skuItem.ExPrefixEnd) + } } return inSkuList } diff --git a/business/model/dao/new_config.go b/business/model/dao/new_config.go index 36ccb70ec..60261137f 100644 --- a/business/model/dao/new_config.go +++ b/business/model/dao/new_config.go @@ -49,3 +49,13 @@ func ValidateRoles(db *DaoDB, roles ...string) (err error) { } return errList.GetErrListAsOne() } + +func GetSysConfigAsInt64(db *DaoDB, key string) (value int64, err error) { + configList, err := QueryConfigs(db, key, model.ConfigTypeSys, "") + if err == nil && len(configList) > 0 { + value = utils.Str2Int64WithDefault(configList[0].Value, 0) + } else if IsNoRowsError(err) { + err = nil + } + return value, err +} diff --git a/business/model/dao/store.go b/business/model/dao/store.go index 3fca98344..c1b82afea 100644 --- a/business/model/dao/store.go +++ b/business/model/dao/store.go @@ -26,7 +26,6 @@ type StoreDetail struct { FreightDeductionPackStr string `orm:"size(4096)" json:"-"` // FreightDeductionPackObj *model.FreightDeductionPack `orm:"-" json:"-"` - BoxFee int `orm:"default(1)" json:"boxFee"` // 打包费 AutoPickup int8 `orm:"default(1)" json:"autoPickup"` // 是否自动拣货 DeliveryType int8 `orm:"default(0)" json:"deliveryType"` // 配送类型 @@ -85,7 +84,7 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (sto sql := ` SELECT t1.*, t2.vendor_store_id, t2.status vendor_status, t2.delivery_fee, t2.sync_status, t2.vendor_org_code, - t2.price_percentage, t2.auto_pickup, t2.delivery_type, t2.delivery_competition, t2.is_sync, t2.vendor_store_name, t2.box_fee, + t2.price_percentage, t2.auto_pickup, t2.delivery_type, t2.delivery_competition, t2.is_sync, t2.vendor_store_name, t3.value price_percentage_pack_str, t4.value freight_deduction_pack_str, district.name district_name, diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index 65925ece8..e8e3c6caf 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -45,6 +45,8 @@ type StoreSkuSyncInfo struct { StoreID int `orm:"column(store_id)"` SkuID int `orm:"column(sku_id)"` // 这个与Sku.ID的区别是SkuID是必然存在的 + BoxFee int64 + Price int64 UnitPrice int64 diff --git a/business/model/new_config.go b/business/model/new_config.go index bf0b26cea..a3805bac0 100644 --- a/business/model/new_config.go +++ b/business/model/new_config.go @@ -10,6 +10,9 @@ const ( const ( ConfigSysFakeOrderMobiles = "FakeOrderMobiles" // 假订单手机 + ConfigSysEbaiBoxFee = "EbaiBoxFee" // 饿百打包费 + ConfigSysMtwmBoxFee = "MtwmBoxFee" // 美团外卖打包费 + ConfigSysMtwmSkuBoxFee = "MtwmSkuBoxFee" // 美团外卖单商品打包费 ) var ( diff --git a/business/model/store.go b/business/model/store.go index 5afa67828..83467b027 100644 --- a/business/model/store.go +++ b/business/model/store.go @@ -398,8 +398,6 @@ type StoreMap struct { FreightDeductionPack string `orm:"size(32)" json:"freightDeductionPack"` // - BoxFee int `orm:"default(0)" json:"boxFee"` // 打包费 - AutoPickup int8 `orm:"default(1)" json:"autoPickup"` // 是否自动拣货 DeliveryType int8 `orm:"default(0)" json:"deliveryType"` // 配送类型 DeliveryFee int `json:"deliveryFee"` diff --git a/business/partner/purchase/ebai/store.go b/business/partner/purchase/ebai/store.go index 3d36ed191..808c8b8ad 100644 --- a/business/partner/purchase/ebai/store.go +++ b/business/partner/purchase/ebai/store.go @@ -400,6 +400,9 @@ func genStoreMapFromStore(store *tEbaiStoreInfo) map[string]interface{} { params["name"] = jxutils.ComposeStoreName(store.Name, model.VendorIDEBAI) } } + // boxFee, _ := dao.GetSysConfigAsInt64(dao.GetDB(), model.ConfigSysEbaiBoxFee) + // params["package_box_price"] = boxFee + params["address"] = store.Address // todo 饿百 开店审核通过后不允许修改商户信息 if store.SyncStatus&(model.SyncFlagNewMask /*|model.SyncFlagStoreAddress*/) != 0 { diff --git a/business/partner/purchase/mtwm/store.go b/business/partner/purchase/mtwm/store.go index 75d35c49b..de23fa33d 100644 --- a/business/partner/purchase/mtwm/store.go +++ b/business/partner/purchase/mtwm/store.go @@ -156,7 +156,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin errList.AddErr(p.UpdateStoreStatus(jxcontext.AdminCtx, storeDetail.VendorOrgCode, storeID, storeDetail.VendorStoreID, mergedStoreStatus)) } errList.AddErr(p.UpdateStoreOpTime(jxcontext.AdminCtx, storeDetail.VendorOrgCode, storeID, storeDetail.VendorStoreID, storeDetail.GetOpTimeList())) - errList.AddErr(p.UpdateStoreBoxFee(jxcontext.AdminCtx, storeDetail.VendorOrgCode, storeID, storeDetail.VendorStoreID, storeDetail.BoxFee)) + errList.AddErr(p.UpdateStoreBoxFee(jxcontext.AdminCtx, storeDetail.VendorOrgCode, storeID, storeDetail.VendorStoreID)) return errList.GetErrListAsOne() } @@ -292,7 +292,10 @@ func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorOrgC return err } -func (c *PurchaseHandler) UpdateStoreBoxFee(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, boxFee int) (err error) { - err = api.MtwmAPI.PackagePriceUpdate(vendorStoreID, 1, boxFee) +func (c *PurchaseHandler) UpdateStoreBoxFee(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string) (err error) { + // boxFee, err := dao.GetSysConfigAsInt64(dao.GetDB(), model.ConfigSysMtwmBoxFee) + // if err == nil { + // err = api.MtwmAPI.PackagePriceUpdate(vendorStoreID, 1, int(boxFee)) + // } return err } diff --git a/business/partner/purchase/mtwm/store_sku2.go b/business/partner/purchase/mtwm/store_sku2.go index 6266bbbcd..ec63fe9ae 100644 --- a/business/partner/purchase/mtwm/store_sku2.go +++ b/business/partner/purchase/mtwm/store_sku2.go @@ -28,7 +28,6 @@ const ( specialStoreID = "8171010" // specialStoreID = "2523687" - fixBoxFee = 10 ) var ( @@ -254,7 +253,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI foodData["min_order_count"] = 1 foodData["unit"] = storeSku.Unit foodData["box_num"] = 1 - foodData["box_price"] = jxutils.IntPrice2Standard(fixBoxFee) + foodData["box_price"] = jxutils.IntPrice2Standard(storeSku.BoxFee) catCode := tryCatName2Code(storeSku.VendorCatID) if catCode != "" { foodData["category_code"] = catCode