diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index 1cd990211..3754ebb98 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -425,6 +425,7 @@ func (c *OrderManager) updateOrderOtherInfo(order *model.GoodsOrder, db *dao.Dao } if err = c.updateOrderSkuOtherInfo(order, db, payPercentage, changePriceType); err == nil { jxutils.RefreshOrderSkuRelated(order) + jxutils.RefreshOrderEarningPrice2(order, payPercentage) // caculateOrderEarningPrice(order, payPercentage) } return err diff --git a/business/jxcallback/orderman/orderman_ext.go b/business/jxcallback/orderman/orderman_ext.go index a9ca5ffb1..1b15815af 100644 --- a/business/jxcallback/orderman/orderman_ext.go +++ b/business/jxcallback/orderman/orderman_ext.go @@ -670,6 +670,7 @@ func (c *OrderManager) GetStoresOrderSaleInfoNew(ctx *jxcontext.Context, storeID saleInfo.VendorPrice += v.VendorPrice * int64(v.Count) saleInfo.SalePrice += v.SalePrice * int64(v.Count) saleInfo.EarningPrice += v.EarningPrice * int64(v.Count) + saleInfo.EarningPrice2 = v.EarningPrice2 universalOrderID := jxutils.ComposeUniversalOrderID(v.VendorOrderID, v.VendorID) if orderMap[universalOrderID] == nil { @@ -746,6 +747,7 @@ func (c *OrderManager) GetStoresOrderSaleInfoNew(ctx *jxcontext.Context, storeID saleInfo.SalePrice += v.SalePrice saleInfo.EarningPrice += v.EarningPrice saleInfo.Count++ + saleInfo.EarningPrice2 = v.EarningPrice2 } for _, v := range saleInfoMap { saleInfoList = append(saleInfoList, v) diff --git a/business/jxcallback/scheduler/basesch/basesch_ext.go b/business/jxcallback/scheduler/basesch/basesch_ext.go index ed6afc1d4..0801a3f0a 100644 --- a/business/jxcallback/scheduler/basesch/basesch_ext.go +++ b/business/jxcallback/scheduler/basesch/basesch_ext.go @@ -37,6 +37,13 @@ func (c *BaseScheduler) CreateWaybillOnProviders(ctx *jxcontext.Context, order * courierVendorID := storeCourier.VendorID bill, err2 := c.CreateWaybill(courierVendorID, order, maxDeliveryFee) if err = err2; err == nil { + stores, _ := dao.GetStoreList(dao.GetDB(), []int{order.StoreID}, nil, nil, nil, "") + if len(stores) > 0 { + if stores[0].PayPercentage <= 50 { + order.EarningPrice2 = (order.TotalShopMoney - bill.DesiredFee) * int64((100 - stores[0].PayPercentage/2)) / 10000 + dao.UpdateEntity(dao.GetDB(), order, "EarningPrice2") + } + } globals.SugarLogger.Debugf("CreateWaybillOnProviders orderID:%s userName:%s vendorID:%d bill:%v", order.VendorOrderID, userName, courierVendorID, bill) bills = append(bills, bill) if createOnlyOne { diff --git a/business/jxcallback/scheduler/defsch/defsch.go b/business/jxcallback/scheduler/defsch/defsch.go index 5b3bbca22..01a515b14 100644 --- a/business/jxcallback/scheduler/defsch/defsch.go +++ b/business/jxcallback/scheduler/defsch/defsch.go @@ -655,7 +655,7 @@ func (s *DefScheduler) isWaybillCourierSame(savedOrderInfo *WatchOrderInfo, bill func (s *DefScheduler) addWaybill2Map(savedOrderInfo *WatchOrderInfo, bill *model.Waybill) { if _, ok := savedOrderInfo.waybills[bill.WaybillVendorID]; ok { - if !model.IsWaybillPlatformOwn(bill) { // 购买平台重复发相同号的新运单是正常的,京东就是 + if !model.IsWaybillPlatformOwn(bill) && savedOrderInfo.order.StoreID != 666666 { // 购买平台重复发相同号的新运单是正常的,京东就是 globals.SugarLogger.Warnf("addWaybill2Map bill:%v already exists", bill) } } diff --git a/business/jxutils/jxutils.go b/business/jxutils/jxutils.go index 160073540..7b2a749b1 100644 --- a/business/jxutils/jxutils.go +++ b/business/jxutils/jxutils.go @@ -540,6 +540,15 @@ func RefreshOrderSkuRelated(order *model.GoodsOrder) *model.GoodsOrder { return order } +func RefreshOrderEarningPrice2(order *model.GoodsOrder, payPercentage int) *model.GoodsOrder { + if payPercentage <= 50 { + order.EarningPrice2 = order.TotalShopMoney * int64((100 - payPercentage/2)) / 10000 + } else { + order.EarningPrice2 = order.EarningPrice + } + return order +} + func RefreshAfsOrderSkuRelated(afsOrder *model.AfsOrder) *model.AfsOrder { afsOrder.SkuUserMoney = 0 afsOrder.PmSkuSubsidyMoney = 0 diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index 7691bcbf8..8ab89944b 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -26,7 +26,9 @@ type StoresOrderSaleInfo struct { SalePrice int64 `json:"salePrice"` ActualPayPrice int64 `json:"actualPayPrice"` - EarningPrice int64 `json:"earningPrice"` // 预估结算给门店老板的钱 + EarningPrice int64 `json:"earningPrice"` // 预估结算给门店老板的钱 + EarningPrice2 int64 `json:"earningPrice2"` // 预估结算给门店老板的钱(新规则) + DistanceFreightMoney int64 `json:"distanceFreightMoney"` // 商户承担的远距离配送费(当前只有京东到家有值) WaybillTipMoney int64 `json:"waybillTipMoney"` // 京西加的平台配送小费 } @@ -41,7 +43,8 @@ type OrderSkuWithActualPayPrice struct { StoreID int `orm:"column(store_id)" json:"storeID"` // 外部系统里记录的 jxstoreid Status int `json:"status"` // 参见OrderStatus*相关的常量定义 - PayPercentage int `json:"payPercentage"` + PayPercentage int `json:"payPercentage"` + EarningPrice2 int64 `json:"earningPrice2"` } type tGoodsAndOrder struct { @@ -356,7 +359,7 @@ func GetStoreOrderSkuList(db *DaoDB, storeIDs []int, finishedAtBegin, finishedAt // order_finished_at sql := ` SELECT t1.*, - IF(t2.jx_store_id > 0, t2.jx_store_id, t2.store_id) store_id, t2.status, t2.actual_pay_price, t2.distance_freight_money, t2.waybill_tip_money, + IF(t2.jx_store_id > 0, t2.jx_store_id, t2.store_id) store_id, t2.status, t2.actual_pay_price, t2.distance_freight_money, t2.waybill_tip_money, t2.earning_price2, t3.pay_percentage FROM order_sku t1 JOIN goods_order t2 ON t2.vendor_order_id = t1.vendor_order_id AND t2.vendor_id = t1.vendor_id diff --git a/business/model/order.go b/business/model/order.go index 7ed0fce5d..a5d66b33d 100644 --- a/business/model/order.go +++ b/business/model/order.go @@ -64,6 +64,7 @@ type GoodsOrder struct { DistanceFreightMoney int64 `json:"distanceFreightMoney"` // 商户承担的远距离配送费(当前只有京东到家有值) WaybillTipMoney int64 `json:"waybillTipMoney"` // 京西加的平台配送小费 EarningPrice int64 `json:"earningPrice"` // 结算给门店老板的钱(未扣除可能的三方配送费) + EarningPrice2 int64 `json:"earningPrice2"` // 结算给门店老板的钱(未扣除可能的三方配送费)(新规则) Weight int `json:"weight"` // 单位为克 VendorUserID string `orm:"column(vendor_user_id);size(48)" json:"vendorUserID"` UserID string `orm:"column(user_id);size(48);index" json:"userID"`