添加淘鲜达
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package mtwm
|
||||
package tao_vegetable
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/tao_vegetable"
|
||||
"net/url"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||
domain591 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability591/domain"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
@@ -131,17 +133,16 @@ func (p *PurchaseHandler) AfsOrderDetail2Financial(orderData url.Values) (afsOrd
|
||||
}
|
||||
|
||||
// 存储美团正向订单结账信息
|
||||
func (p *PurchaseHandler) OnOrderDetail(result map[string]interface{}, operation string) (err error) {
|
||||
func (p *PurchaseHandler) OnOrderDetail(result *domain591.AlibabaAelophyOrderGetOrderResponse, operation string) (err error) {
|
||||
err = partner.CurOrderManager.SaveOrderFinancialInfo(p.OrderDetail2Financial(result), operation)
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) OrderDetail2Financial(result map[string]interface{}) (orderFinancial *model.OrderFinancial) {
|
||||
func (p *PurchaseHandler) OrderDetail2Financial(result *domain591.AlibabaAelophyOrderGetOrderResponse) (orderFinancial *model.OrderFinancial) {
|
||||
orderFinancial = &model.OrderFinancial{
|
||||
VendorID: model.VendorIDMTWM,
|
||||
VendorOrderID: utils.Int64ToStr(utils.MustInterface2Int64(result["order_id"])),
|
||||
VendorID: model.VendorIDTaoVegetable,
|
||||
VendorOrderID: utils.Int64ToStr(*result.BizOrderId),
|
||||
}
|
||||
// orderFinancial.DeliveryConfirmTime = utils.Str2TimeWithDefault(utils.Interface2String(result["order_completed_time"]), utils.DefaultTimeValue)
|
||||
order, err := partner.CurOrderManager.LoadOrder(orderFinancial.VendorOrderID, orderFinancial.VendorID)
|
||||
jxStoreID := 0
|
||||
if err == nil {
|
||||
@@ -154,92 +155,58 @@ func (p *PurchaseHandler) OrderDetail2Financial(result map[string]interface{}) (
|
||||
} else {
|
||||
err = nil
|
||||
}
|
||||
if result["package_bag_money"] != nil {
|
||||
orderFinancial.BoxMoney = utils.MustInterface2Int64(result["package_bag_money"])
|
||||
}
|
||||
detail := result["detail"]
|
||||
if detail != nil {
|
||||
var data []map[string]interface{}
|
||||
utils.UnmarshalUseNumber([]byte(utils.Interface2String(detail)), &data)
|
||||
for _, x := range data {
|
||||
orderSkuFinancial := &model.OrderSkuFinancial{
|
||||
|
||||
// 订单
|
||||
for _, x := range *result.SubOrderResponseList {
|
||||
orderSkuFinancial := &model.OrderSkuFinancial{
|
||||
VendorID: orderFinancial.VendorID,
|
||||
VendorOrderID: orderFinancial.VendorOrderID,
|
||||
VendorStoreID: *result.StoreId,
|
||||
StoreID: 0,
|
||||
JxStoreID: jxStoreID,
|
||||
VendorSkuID: utils.Int64ToStr(utils.MustInterface2Int64(x.SkuCode)),
|
||||
SkuID: utils.Str2Int(*x.SkuCode),
|
||||
Name: utils.Interface2String(x.SkuName),
|
||||
SalePrice: *x.Price,
|
||||
Count: utils.Str2Int(*x.BuySaleQuantity),
|
||||
SkuBoxMoney: 0,
|
||||
IsAfsOrder: 0,
|
||||
}
|
||||
orderFinancial.Skus = append(orderFinancial.Skus, orderSkuFinancial)
|
||||
orderFinancial.SalePriceMoney += orderSkuFinancial.SalePrice * int64(orderSkuFinancial.Count)
|
||||
orderFinancial.SkuBoxMoney += orderSkuFinancial.SkuBoxMoney
|
||||
|
||||
// 活动
|
||||
for _, v := range *x.Activitys {
|
||||
activity := &model.OrderDiscountFinancial{
|
||||
VendorID: orderFinancial.VendorID,
|
||||
VendorOrderID: orderFinancial.VendorOrderID,
|
||||
// OrderFinancialID: orderFinancial.VendorOrderID,
|
||||
// ConfirmTime: utils.Str2TimeWithDefault(utils.Interface2String(result["ctime"]), utils.DefaultTimeValue),
|
||||
VendorStoreID: result["app_poi_code"].(string),
|
||||
StoreID: 0,
|
||||
JxStoreID: jxStoreID,
|
||||
VendorSkuID: utils.Interface2String(x["sku_id"]),
|
||||
SkuID: int(utils.Str2Int64WithDefault(utils.Interface2String(x["sku_id"]), 0)),
|
||||
Name: utils.Interface2String(x["food_name"]),
|
||||
SalePrice: jxutils.StandardPrice2Int(utils.MustInterface2Float64(x["price"])),
|
||||
Count: int(utils.MustInterface2Int64(x["quantity"])),
|
||||
SkuBoxMoney: jxutils.StandardPrice2Int(utils.MustInterface2Float64(x["box_price"])) * jxutils.StandardPrice2Int(utils.MustInterface2Float64(x["box_num"])),
|
||||
IsAfsOrder: 0,
|
||||
}
|
||||
orderFinancial.Skus = append(orderFinancial.Skus, orderSkuFinancial)
|
||||
orderFinancial.SalePriceMoney += orderSkuFinancial.SalePrice * int64(orderSkuFinancial.Count)
|
||||
orderFinancial.SkuBoxMoney += orderSkuFinancial.SkuBoxMoney
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Warnf("mtwm OrderDetail2Financial, orderID:%s have no detail", orderFinancial.VendorOrderID)
|
||||
}
|
||||
extras := result["extras"]
|
||||
if extras != nil {
|
||||
var data []map[string]interface{}
|
||||
utils.UnmarshalUseNumber([]byte(utils.Interface2String(extras)), &data)
|
||||
for _, x := range data {
|
||||
if x["rider_fee"] == nil {
|
||||
activity := &model.OrderDiscountFinancial{
|
||||
VendorID: orderFinancial.VendorID,
|
||||
VendorOrderID: orderFinancial.VendorOrderID,
|
||||
// ActivityName: utils.Interface2String(x["remark"]),
|
||||
// ActivityMoney: jxutils.StandardPrice2Int(utils.MustInterface2Float64(x["reduce_fee"])),
|
||||
// VendorActivityID: utils.Int64ToStr(utils.MustInterface2Int64(x["act_detail_id"])),
|
||||
}
|
||||
if x["act_detail_id"] != nil { // 容错处理
|
||||
activity.VendorActivityID = utils.Int64ToStr(utils.MustInterface2Int64(x["act_detail_id"]))
|
||||
orderFinancial.Discounts = append(orderFinancial.Discounts, activity)
|
||||
}
|
||||
// 通过活动Id去取,京西活动补贴
|
||||
// orderFinancial.JxSubsidyMoney +=
|
||||
if v.ChannelActivityId != nil {
|
||||
activity.VendorActivityID = *v.ChannelActivityId
|
||||
activity.Type = tao_vegetable.ActivityTypeChannel
|
||||
}
|
||||
if v.BizActivityId != nil {
|
||||
activity.VendorActivityID = *v.BizActivityId
|
||||
activity.Type = tao_vegetable.ActivityTypeBiz
|
||||
}
|
||||
if v.MerchantActivityId != nil {
|
||||
activity.VendorActivityID = *v.MerchantActivityId
|
||||
activity.Type = tao_vegetable.ActivityTypeMerchant
|
||||
}
|
||||
orderFinancial.Discounts = append(orderFinancial.Discounts, activity)
|
||||
}
|
||||
}
|
||||
poiReceiveDetail := result["poi_receive_detail"]
|
||||
if poiReceiveDetail != nil {
|
||||
var data map[string]interface{}
|
||||
utils.UnmarshalUseNumber([]byte(utils.Interface2String(poiReceiveDetail)), &data)
|
||||
orderFinancial.ReceivableFreight = utils.MustInterface2Int64(data["logisticsFee"])
|
||||
orderFinancial.FreightMoney = utils.MustInterface2Int64(data["logisticsFee"])
|
||||
orderFinancial.ActualPayMoney = utils.MustInterface2Int64(data["onlinePayment"])
|
||||
orderFinancial.PmMoney = utils.MustInterface2Int64(data["foodShareFeeChargeByPoi"])
|
||||
orderFinancial.ShopMoney = utils.MustInterface2Int64(data["wmPoiReceiveCent"])
|
||||
for _, x := range data["actOrderChargeByMt"].([]interface{}) {
|
||||
orderFinancial.TotalDiscountMoney += utils.MustInterface2Int64(x.(map[string]interface{})["moneyCent"])
|
||||
orderFinancial.PmSubsidyMoney += utils.MustInterface2Int64(x.(map[string]interface{})["moneyCent"])
|
||||
}
|
||||
for _, x := range data["actOrderChargeByPoi"].([]interface{}) {
|
||||
orderFinancial.TotalDiscountMoney += utils.MustInterface2Int64(x.(map[string]interface{})["moneyCent"])
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Warnf("mtwm OrderDetail2Financial, orderID:%s have no poi_receive_detail", orderFinancial.VendorOrderID)
|
||||
}
|
||||
if utils.MustInterface2Int64(result["is_third_shipping"]) == SelfDeliveryCarrierNo { // is_third_shipping int 是否是第三方配送平台配送,0表否,1表是)
|
||||
orderFinancial.SelfDeliveryDiscountMoney = orderFinancial.ReceivableFreight
|
||||
orderFinancial.DistanceFreightMoney = 0
|
||||
// 通过本地数据库去取是否转美团/达达,并计算运费
|
||||
// wayBill, err := partner.CurOrderManager.LoadWaybill(orderFinancial.VendorOrderID, orderFinancial.VendorID)
|
||||
// if err == nil {
|
||||
// orderFinancial.JxFreightMoney = wayBill.DesiredFee
|
||||
// }
|
||||
}
|
||||
// // 美团订单单独处理部分,美团正向订单接口推送时总结算金额没有计算公益捐款一分钱,是否在这里直接提前扣除?
|
||||
// // 3/18之后的订单一直都不显示公益捐款金额,而且结算现在结算到了3/18之后的订单,没有的已经不计算了,先注释
|
||||
// // 2019-04-03 10.52 询问赵mf, 此计划是必须参加的,而且是长期的,每单固定扣除一分钱
|
||||
orderFinancial.DonationMoney = PublicWelfareDonation
|
||||
// 不应该对第三方结账金额做更改,就算有异常,也要保留异常,知道问题出在哪里
|
||||
// orderFinancial.ShopMoney -= PublicWelfareDonation
|
||||
|
||||
orderFinancial.ReceivableFreight = *result.PostFee
|
||||
orderFinancial.FreightMoney = 0
|
||||
orderFinancial.ActualPayMoney = *result.PayFee
|
||||
orderFinancial.PmMoney = 0 // 平台费
|
||||
orderFinancial.ShopMoney = 0 // 应结金额
|
||||
orderFinancial.TotalDiscountMoney = *result.DiscountFee // 订单优惠总金额
|
||||
orderFinancial.PmSubsidyMoney = *result.PostDiscountPlatformFee // 平台活动补贴(订单主体活动补贴+订单单条sku补贴)1+
|
||||
orderFinancial.SelfDeliveryDiscountMoney = *result.SkuDiscountPlatformFee // 平台承担运费补贴(商家自送)+
|
||||
orderFinancial.DistanceFreightMoney = 0
|
||||
|
||||
return orderFinancial
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user