Accept Merge Request #2: (lyb -> master)
Merge Request: 从京东平台API获取结账必须信息放入数据表新字段中 Created By: @LYB-Rosy Accepted By: @XJH-Rosy URL: https://coding.net/u/XJH-Rosy/p/jx-callback/git/merge/2
This commit is contained in:
@@ -137,9 +137,16 @@ func (c *OrderController) GetOrder(orderID string) (order *model.GoodsOrder, err
|
|||||||
order.Weight += sku.Weight * sku.Count
|
order.Weight += sku.Weight * sku.Count
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setOrederDetailFee(result, order)
|
||||||
return order, err
|
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) {
|
func (c *OrderController) onOrderNew(msg *jdapi.CallbackOrderMsg) (response *jdapi.CallbackResponse) {
|
||||||
order, err := c.GetOrder(msg.BillID)
|
order, err := c.GetOrder(msg.BillID)
|
||||||
|
|||||||
@@ -33,3 +33,10 @@ func TestSwitch2SelfDeliver(t *testing.T) {
|
|||||||
t.Fatal(err.Error())
|
t.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_GetOrder(t *testing.T) {
|
||||||
|
_, err := new(OrderController).GetOrder("815536199000222")
|
||||||
|
if err != nil {
|
||||||
|
panic(err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,7 +26,9 @@ func (c *WaybillController) onWaybillMsg(msg *jdapi.CallbackDeliveryStatusMsg) (
|
|||||||
order.Status = model.WaybillStatusNew
|
order.Status = model.WaybillStatusNew
|
||||||
case jdapi.DeliveryStatusAccepted:
|
case jdapi.DeliveryStatusAccepted:
|
||||||
if result, err := api.JdAPI.QuerySingleOrder(msg.OrderID); err == nil {
|
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["merchantPaymentDistanceFreightMoney"], 0) +
|
||||||
utils.Interface2Int64WithDefault(result["tips"], 0)
|
utils.Interface2Int64WithDefault(result["tips"], 0)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,3 +123,12 @@ const (
|
|||||||
BusinessTypeImmediate = 1
|
BusinessTypeImmediate = 1
|
||||||
BusinessTypeDingshida = 2
|
BusinessTypeDingshida = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
JdSkuPromotion = []int64{2, 3, 4, 6, 8, 1203, 8001, 9998, 9997, 9996}
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
JdPlatformFeeRate = 10
|
||||||
|
MtPlatformFeeRate = 10
|
||||||
|
)
|
||||||
|
|||||||
@@ -44,6 +44,13 @@ type GoodsOrder struct {
|
|||||||
ModelTimeInfo
|
ModelTimeInfo
|
||||||
OriginalData string `orm:"type(text)"`
|
OriginalData string `orm:"type(text)"`
|
||||||
Skus []*OrderSku `orm:"-"`
|
Skus []*OrderSku `orm:"-"`
|
||||||
|
SkuPmFee int64 //门店商品促销总支出
|
||||||
|
OrderPmFee int64 //门店订单促销支出
|
||||||
|
SkuPmSubsidy int64 //平台商品促销总补贴
|
||||||
|
OrderPmSubsidy int64 //平台订单促销补贴
|
||||||
|
BoxFee int64 //餐盒费
|
||||||
|
PlatformFeeRate int16 //平台费
|
||||||
|
BillStoreFreightFee int64 //需要回调,门店所承担的运费
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GoodsOrder) TableUnique() [][]string {
|
func (o *GoodsOrder) TableUnique() [][]string {
|
||||||
@@ -69,6 +76,8 @@ type OrderSku struct {
|
|||||||
SkuType int // 当前如果为gift就为1,否则缺省为0
|
SkuType int // 当前如果为gift就为1,否则缺省为0
|
||||||
PromotionType int // todo 当前是用于记录京东的PromotionType(生成jxorder用),没有做转换
|
PromotionType int // todo 当前是用于记录京东的PromotionType(生成jxorder用),没有做转换
|
||||||
OrderCreatedAt time.Time `orm:"type(datetime);index"` // 分区考虑
|
OrderCreatedAt time.Time `orm:"type(datetime);index"` // 分区考虑
|
||||||
|
SkuPmSubsidy int64 //平台商品活动补贴
|
||||||
|
SkuPmFee int64 //门店商品促销支出
|
||||||
}
|
}
|
||||||
|
|
||||||
// 同样商品在一个订单中可能重复出现(比如搞活动时,相同商品价格不一样,第一个有优惠)
|
// 同样商品在一个订单中可能重复出现(比如搞活动时,相同商品价格不一样,第一个有优惠)
|
||||||
|
|||||||
Reference in New Issue
Block a user