diff --git a/business/jxcallback/scheduler/basesch/basesch_ext.go b/business/jxcallback/scheduler/basesch/basesch_ext.go index d2559c9dd..f7d01fead 100644 --- a/business/jxcallback/scheduler/basesch/basesch_ext.go +++ b/business/jxcallback/scheduler/basesch/basesch_ext.go @@ -35,6 +35,7 @@ func (c *BaseScheduler) CreateWaybillOnProviders(ctx *jxcontext.Context, order * excludeCourierVendorIDMap := jxutils.IntList2Map(excludeCourierVendorIDs) errList := errlist.New() + store, _ := dao.GetStoreDetail(dao.GetDB(), order.JxStoreID, order.VendorID, order.VendorOrgCode) for _, storeCourier := range storeCourierList { switch storeCourier.Status { case model.YES: @@ -45,8 +46,12 @@ func (c *BaseScheduler) CreateWaybillOnProviders(ctx *jxcontext.Context, order * // 创建运单 bill, err2 := c.CreateWaybill(courierVendorID, order, maxDeliveryFee) if err = err2; err == nil { - bill.DesiredFee += model.WayBillDeliveryMarkUp - bill.ActualFee += model.WayBillDeliveryMarkUp + // 其实这个bill没啥用,运单的创建是通过回调产生的 + bill.DesiredFee += int64(model.WayBillDeliveryMarkUp + store.FreightMarkup) + if bill.WaybillVendorID == model.VendorIDFengNiao { + bill.DesiredFee += model.WayBillDeliveryMarkUp + } + bill.DesiredFee += int64(store.FreightMarkup) bills = append(bills, bill) if createOnlyOne { break diff --git a/business/jxcallback/scheduler/defsch/defsch_ext.go b/business/jxcallback/scheduler/defsch/defsch_ext.go index a3b3017f6..5a427fe26 100644 --- a/business/jxcallback/scheduler/defsch/defsch_ext.go +++ b/business/jxcallback/scheduler/defsch/defsch_ext.go @@ -477,6 +477,8 @@ func (s *DefScheduler) QueryOrderWaybillFeeInfoEx(ctx *jxcontext.Context, vendor if savedOrderInfo := s.loadSavedOrderByID(vendorOrderID, vendorID, false); savedOrderInfo != nil { timeoutSecond = savedOrderInfo.GetCreateWaybillTimeout() } + + store, _ := dao.GetStoreDetail(db, order.JxStoreID, order.VendorID, order.VendorOrgCode) for _, storeCourier := range storeCourierList { var feeInfo *partner.WaybillFeeInfo if waybillMap[storeCourier.VendorID] != nil { @@ -503,6 +505,7 @@ func (s *DefScheduler) QueryOrderWaybillFeeInfoEx(ctx *jxcontext.Context, vendor if storeCourier.VendorID == model.VendorIDFengNiao { feeInfo.DeliveryFee += model.WayBillDeliveryMarkUp // 蜂鸟加 } + feeInfo.DeliveryFee += int64(store.FreightMarkup) feeInfo.TimeoutSecond = timeoutSecond } } else { diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index d52477a58..7db40f444 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -915,6 +915,9 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa if payload["packageSwitch"] != nil { valid["packageSwitch"], _ = payload["packageSwitch"].(json.Number).Int64() } + if payload["freightMarkup"] != nil { + valid["freightMarkup"], _ = payload["freightMarkup"].(json.Number).Int64() + } if valid["originalName"] != nil { delete(valid, "originalName") diff --git a/business/model/store.go b/business/model/store.go index 7919d9f19..6198daaa0 100644 --- a/business/model/store.go +++ b/business/model/store.go @@ -403,6 +403,7 @@ type Store struct { IDCardHandBack string `orm:"size(255);column(id_card_hand_back)" json:"idCardHandBack"` //手持身份证背面 PackageSetting int `orm:"size(8);column(package_setting);default(0)" json:"packageSetting"` //门店包装袋扣费设置 PackageSwitch int `orm:"size(8);column(package_switch);default(0)" json:"packageSwitch"` //物料购物单门店购买袋子开关[0打开/1关闭] + FreightMarkup int `orm:"size(8);column(freight_markup);default(0)" json:"freightMarkup"` //门店为三方运单时,设置的运营加价 } func (*Store) TableUnique() [][]string { diff --git a/business/partner/delivery/dada/waybill.go b/business/partner/delivery/dada/waybill.go index 54e099ce6..884dbc3d3 100644 --- a/business/partner/delivery/dada/waybill.go +++ b/business/partner/delivery/dada/waybill.go @@ -80,13 +80,14 @@ func (c *DeliveryHandler) OnWaybillMsg(msg *dadaapi.CallbackMsg) (retVal *dadaap } func (c *DeliveryHandler) onWaybillMsg(msg *dadaapi.CallbackMsg) (retVal *dadaapi.CallbackResponse) { - order := c.callbackMsg2Waybill(msg) + order, goodsOrder := c.callbackMsg2Waybill(msg) + store, _ := dao.GetStoreDetail(dao.GetDB(), goodsOrder.JxStoreID, goodsOrder.VendorID, goodsOrder.VendorOrgCode) switch msg.OrderStatus { case dadaapi.OrderStatusWaitingForAccept: dadaOrder, err := api.DadaAPI.QueryOrderInfo(msg.OrderID) if err == nil { order.ActualFee = jxutils.StandardPrice2Int(dadaOrder.ActualFee) - order.DesiredFee = jxutils.StandardPrice2Int(dadaOrder.DeliveryFee) + order.DesiredFee = jxutils.StandardPrice2Int(dadaOrder.DeliveryFee) + int64(store.FreightMarkup) } order.Status = model.WaybillStatusNew case dadaapi.OrderStatusAccepted: @@ -94,7 +95,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *dadaapi.CallbackMsg) (retVal *dadaap order.Remark = order.CourierName + "," + order.CourierMobile if dadaOrder, err := api.DadaAPI.QueryOrderInfo(msg.OrderID); err == nil { order.ActualFee = jxutils.StandardPrice2Int(dadaOrder.ActualFee) - order.DesiredFee = jxutils.StandardPrice2Int(dadaOrder.DeliveryFee) + order.DesiredFee = jxutils.StandardPrice2Int(dadaOrder.DeliveryFee) + int64(store.FreightMarkup) } case dadaapi.OrderStatusReturningInOrder: order.Status = model.WaybillStatusCourierArrived @@ -161,7 +162,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *dadaapi.CallbackMsg) (retVal *dadaap return err } -func (c *DeliveryHandler) callbackMsg2Waybill(msg *dadaapi.CallbackMsg) (retVal *model.Waybill) { +func (c *DeliveryHandler) callbackMsg2Waybill(msg *dadaapi.CallbackMsg) (retVal *model.Waybill, goods *model.GoodsOrder) { retVal = &model.Waybill{ VendorWaybillID: msg.ClientID, WaybillVendorID: model.VendorIDDada, @@ -179,12 +180,11 @@ func (c *DeliveryHandler) callbackMsg2Waybill(msg *dadaapi.CallbackMsg) (retVal retVal.StatusTime = utils.Timestamp2Time(updateTime) retVal.VendorOrderID, retVal.OrderVendorID = jxutils.SplitUniversalOrderID(msg.OrderID) - var good *model.GoodsOrder sql := `SELECT * FROM goods_order WHERE vendor_order_id = ? ORDER BY order_created_at DESC LIMIT 1 OFFSET 0` sqlParams := []interface{}{msg.OrderID} - dao.GetRow(dao.GetDB(), &good, sql, sqlParams) - retVal.OrderVendorID = good.VendorID - return retVal + dao.GetRow(dao.GetDB(), &goods, sql, sqlParams) + retVal.OrderVendorID = goods.VendorID + return retVal, goods } func StoreDetail2ShopInfo(storeDetail *dao.StoreDetail2) (shopInfo *dadaapi.ShopInfo) { diff --git a/business/partner/delivery/fn/waybill.go b/business/partner/delivery/fn/waybill.go index 03497baee..56a76c93c 100644 --- a/business/partner/delivery/fn/waybill.go +++ b/business/partner/delivery/fn/waybill.go @@ -248,14 +248,17 @@ func OnWaybillMsg(msg *fnpsapi.OrderStatusNottify, resultParam *fnpsapi.ShortSta } order.VendorOrderID, order.OrderVendorID = jxutils.SplitUniversalOrderID(cc.PartnerOrderCode) order.OrderVendorID = good.VendorID + store, _ := dao.GetStoreDetail(dao.GetDB(), good.JxStoreID, good.VendorID, good.VendorOrgCode) orderStatus := utils.Str2Int64(order.VendorStatus) switch orderStatus { case fnpsapi.OrderStatusAcceptCreate, fnpsapi.OrderStatusAccept: // 0 创建订单 order.DesiredFee, order.ActualFee = GetDesiredFee(order.VendorOrderID) - order.Status = model.WaybillStatusNew //5 带调度 + order.DesiredFee += int64(store.FreightMarkup) // 运营加价 + order.Status = model.WaybillStatusNew //5 带调度 case fnpsapi.OrderStatusAssigned: //20分配骑手 - //order.DesiredFee, order.ActualFee = GetDesiredFee(order.VendorOrderID) + order.DesiredFee, order.ActualFee = GetDesiredFee(order.VendorOrderID) + order.DesiredFee += int64(store.FreightMarkup) order.Status = model.WaybillStatusCourierAssigned //12 order.Remark = order.CourierName + "," + order.CourierMobile case fnpsapi.OrderStatusArrived: // 80 到店 diff --git a/business/partner/delivery/mtps/waybill.go b/business/partner/delivery/mtps/waybill.go index 071f877a8..254da65da 100644 --- a/business/partner/delivery/mtps/waybill.go +++ b/business/partner/delivery/mtps/waybill.go @@ -85,7 +85,7 @@ func (c *DeliveryHandler) OnWaybillExcept(msg *mtpsapi.CallbackOrderExceptionMsg } func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *mtpsapi.CallbackResponse) { - order := c.callbackMsg2Waybill(msg) + order, goodsOrder := c.callbackMsg2Waybill(msg) // 多次取消,只处理第一次 if msg.Status == mtpsapi.OrderStatusCanceled { orderStatus, _ := orderman.FixedOrderManager.GetWayBillStatusList(msg.OrderID, msg.MtPeisongID, model.VendorIDMTPS) @@ -96,6 +96,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *m } } + store, _ := dao.GetStoreDetail(dao.GetDB(), goodsOrder.JxStoreID, goodsOrder.VendorID, goodsOrder.VendorOrgCode) switch msg.Status { case mtpsapi.OrderStatusWaitingForSchedule: data, err := api.MtpsAPI.QueryOrderStatus(msg.DeliveryID, msg.MtPeisongID) @@ -104,6 +105,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *m } order.DesiredFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["delivery_fee"]) * 100) order.ActualFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["pay_amount"]) * 100) + order.DesiredFee += int64(store.FreightMarkup) order.Status = model.WaybillStatusNew case mtpsapi.OrderStatusAccepted: // 已接单 data, err := api.MtpsAPI.QueryOrderStatus(msg.DeliveryID, msg.MtPeisongID) @@ -112,6 +114,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *m } order.DesiredFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["delivery_fee"]) * 100) order.ActualFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["pay_amount"]) * 100) + order.DesiredFee += int64(store.FreightMarkup) order.Status = model.WaybillStatusCourierAssigned order.Remark = order.CourierName + "," + order.CourierMobile case mtpsapi.OrderStatusPickedUp: // 已取货 @@ -230,7 +233,7 @@ func signParams(params url.Values) string { return fmt.Sprintf("%x", sha1.Sum([]byte(finalStr))) } -func (c *DeliveryHandler) callbackMsg2Waybill(msg *mtpsapi.CallbackOrderMsg) (retVal *model.Waybill) { +func (c *DeliveryHandler) callbackMsg2Waybill(msg *mtpsapi.CallbackOrderMsg) (retVal *model.Waybill, good2 *model.GoodsOrder) { retVal = &model.Waybill{ VendorWaybillID: msg.MtPeisongID, VendorWaybillID2: utils.Int64ToStr(msg.DeliveryID), @@ -250,7 +253,7 @@ func (c *DeliveryHandler) callbackMsg2Waybill(msg *mtpsapi.CallbackOrderMsg) (re } else { retVal.OrderVendorID = good.VendorID } - return retVal + return retVal, good } // 老方法是自己计算 diff --git a/business/partner/delivery/sfps/waybill.go b/business/partner/delivery/sfps/waybill.go index e90594724..601d6528f 100644 --- a/business/partner/delivery/sfps/waybill.go +++ b/business/partner/delivery/sfps/waybill.go @@ -140,9 +140,10 @@ func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee i return nil, err } - //+0.2 + // 系统加价 desiredFee := utils.Float64TwoInt(sfTotalPrice) + utils.WayBillDeliveryMarkUp - + // 运营加价 + desiredFee += store.FreightMarkup bill = &model.Waybill{ VendorOrderID: order.VendorOrderID, OrderVendorID: order.VendorID, @@ -220,8 +221,6 @@ func (d DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo } deliveryFeeInfo = &partner.WaybillFeeInfo{} price, err := api.SfPsAPI.PreCreateOrder(param) - //+0.2 - //deliveryFee := utils.Float64TwoInt(price) + utils.WayBillDeliveryMarkUp deliveryFeeInfo.DeliveryFee = utils.Float64TwoInt64(price) globals.SugarLogger.Debugf("GetWaybillFee deliveryFeeInfo.DeliveryFee=%d", deliveryFeeInfo.DeliveryFee) return deliveryFeeInfo, err @@ -330,8 +329,7 @@ func OnWaybillMsg(urlIndex string, msg interface{}) (resp *sfps2.CallbackRespons order.CourierMobile = sfOrder.RiderPhone } - //+0.2 - sfTotalPrice := utils.Float64TwoInt(sfOrder.TotalPrice) + utils.WayBillDeliveryMarkUp + sfTotalPrice := utils.Float64TwoInt(sfOrder.TotalPrice) sfActualPrice := utils.Float64TwoInt64(sfOrder.RealPayMoney) globals.SugarLogger.Debugf("SFPS OnWaybillMsg,sfTotalPrice=%d,sfActualPrice=%d", sfTotalPrice, sfActualPrice) @@ -341,6 +339,9 @@ func OnWaybillMsg(urlIndex string, msg interface{}) (resp *sfps2.CallbackRespons dao.GetRow(dao.GetDB(), &good, sql, sqlParams) order.OrderVendorID = good.VendorID + store, _ := dao.GetStoreDetail(dao.GetDB(), good.JxStoreID, good.VendorID, good.VendorOrgCode) + sfTotalPrice += store.FreightMarkup + orderStatus := utils.Str2Int64(order.VendorStatus) switch orderStatus { case sfps2.OrderStatusNewOrder: //1:订单创建 diff --git a/business/partner/delivery/uupt/waybill.go b/business/partner/delivery/uupt/waybill.go index 81f5b8c18..cbd261055 100644 --- a/business/partner/delivery/uupt/waybill.go +++ b/business/partner/delivery/uupt/waybill.go @@ -329,6 +329,10 @@ func OnWaybillMsg(req *uuptapi.WaybillCallbackParam) (resp *uuptapi.CallbackResp } else { reallyPrice = int64(utils.Str2Float64(uuPrice.OrderPrice) * 100) } + + store, _ := dao.GetStoreDetail(dao.GetDB(), good.JxStoreID, good.VendorID, good.VendorOrgCode) + reallyPrice += int64(store.FreightMarkup) + actualFee := int64((utils.Str2Float64(uuPrice.OrderPrice)-utils.Str2Float64(uuPrice.PriceOff))*100) - int64(utils.WayBillDeliveryMarkUp) switch req.State { case uuptapi.StateConfirmSuccess: