diff --git a/business/controller/jd/order.go b/business/controller/jd/order.go index 142a570ea..64a9d371d 100644 --- a/business/controller/jd/order.go +++ b/business/controller/jd/order.go @@ -137,9 +137,16 @@ func (c *OrderController) GetOrder(orderID string) (order *model.GoodsOrder, err order.Weight += sku.Weight * sku.Count } } + setOrederDetailFee(result, order) return order, err } +func setOrederDetailFee(result map[string]interface{}, order *model.GoodsOrder) { + order.BoxFee = utils.MustInterface2Int64(result["packagingMoney"]) + order.PlatformFeeRate = model.JdPlatformFeeRate + order.BillStoreFreightFee = utils.MustInterface2Int64(result["merchantPaymentDistanceFreightMoney"]) + utils.MustInterface2Int64(result["tips"]) +} + // func (c *OrderController) onOrderNew(msg *jdapi.CallbackOrderMsg) (response *jdapi.CallbackResponse) { order, err := c.GetOrder(msg.BillID) diff --git a/business/controller/jd/order_test.go b/business/controller/jd/order_test.go index 0cbda7a2c..92d1a9664 100644 --- a/business/controller/jd/order_test.go +++ b/business/controller/jd/order_test.go @@ -33,3 +33,10 @@ func TestSwitch2SelfDeliver(t *testing.T) { t.Fatal(err.Error()) } } + +func Test_GetOrder(t *testing.T) { + _, err := new(OrderController).GetOrder("815536199000222") + if err != nil { + panic(err.Error()) + } +} diff --git a/business/controller/jd/waybill.go b/business/controller/jd/waybill.go index 718f9786e..0aacb59bd 100644 --- a/business/controller/jd/waybill.go +++ b/business/controller/jd/waybill.go @@ -26,7 +26,9 @@ func (c *WaybillController) onWaybillMsg(msg *jdapi.CallbackDeliveryStatusMsg) ( order.Status = model.WaybillStatusNew case jdapi.DeliveryStatusAccepted: if result, err := api.JdAPI.QuerySingleOrder(msg.OrderID); err == nil { - order.DesiredFee = utils.Interface2Int64WithDefault(result["orderFreightMoney"], 0) + + // 默认配送费=订单应付运费(orderReceivableFreight) + //订单应付运费为未优惠前应付运费(满免优惠,运费优惠券,VIP免基础运费,用户小费)ps:用户小费是用户给配送员的小费 + order.DesiredFee = utils.Interface2Int64WithDefault(result["orderReceivableFreight"], 0) + utils.Interface2Int64WithDefault(result["merchantPaymentDistanceFreightMoney"], 0) + utils.Interface2Int64WithDefault(result["tips"], 0) } diff --git a/business/model/const.go b/business/model/const.go index bc99e4245..7bed36380 100644 --- a/business/model/const.go +++ b/business/model/const.go @@ -123,3 +123,12 @@ const ( BusinessTypeImmediate = 1 BusinessTypeDingshida = 2 ) + +var ( + JdSkuPromotion = []int64{2, 3, 4, 6, 8, 1203, 8001, 9998, 9997, 9996} +) + +const ( + JdPlatformFeeRate = 10 + MtPlatformFeeRate = 10 +) diff --git a/business/model/order.go b/business/model/order.go index 2d3137363..af90dce21 100644 --- a/business/model/order.go +++ b/business/model/order.go @@ -42,8 +42,15 @@ type GoodsOrder struct { OrderFinishedAt time.Time `orm:"type(datetime)"` StatusTime time.Time `orm:"type(datetime)"` // last status time ModelTimeInfo - OriginalData string `orm:"type(text)"` - Skus []*OrderSku `orm:"-"` + OriginalData string `orm:"type(text)"` + Skus []*OrderSku `orm:"-"` + SkuPmFee int64 //门店商品促销总支出 + OrderPmFee int64 //门店订单促销支出 + SkuPmSubsidy int64 //平台商品促销总补贴 + OrderPmSubsidy int64 //平台订单促销补贴 + BoxFee int64 //餐盒费 + PlatformFeeRate int16 //平台费 + BillStoreFreightFee int64 //需要回调,门店所承担的运费 } func (o *GoodsOrder) TableUnique() [][]string { @@ -69,6 +76,8 @@ type OrderSku struct { SkuType int // 当前如果为gift就为1,否则缺省为0 PromotionType int // todo 当前是用于记录京东的PromotionType(生成jxorder用),没有做转换 OrderCreatedAt time.Time `orm:"type(datetime);index"` // 分区考虑 + SkuPmSubsidy int64 //平台商品活动补贴 + SkuPmFee int64 //门店商品促销支出 } // 同样商品在一个订单中可能重复出现(比如搞活动时,相同商品价格不一样,第一个有优惠)