dingdan
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package tiktok_store
|
||||
|
||||
import (
|
||||
order_orderDetail_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_orderDetail/response"
|
||||
"net/url"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||
@@ -135,18 +136,15 @@ func (p *PurchaseHandler) AfsOrderDetail2Financial(orderData url.Values) (afsOrd
|
||||
}
|
||||
|
||||
// 存储美团正向订单结账信息
|
||||
func (p *PurchaseHandler) OnOrderDetail(result map[string]interface{}, operation string) (err error) {
|
||||
globals.SugarLogger.Debug(utils.Int64ToStr(utils.MustInterface2Int64(result["order_id"])))
|
||||
err = partner.CurOrderManager.SaveOrderFinancialInfo(p.OrderDetail2Financial(result), operation)
|
||||
return err
|
||||
func (p *PurchaseHandler) OnOrderDetail(result *order_orderDetail_response.ShopOrderDetail, operation string) (err error) {
|
||||
return partner.CurOrderManager.SaveOrderFinancialInfo(p.OrderDetail2Financial(result), operation)
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) OrderDetail2Financial(result map[string]interface{}) (orderFinancial *model.OrderFinancial) {
|
||||
func (p *PurchaseHandler) OrderDetail2Financial(result *order_orderDetail_response.ShopOrderDetail) (orderFinancial *model.OrderFinancial) {
|
||||
orderFinancial = &model.OrderFinancial{
|
||||
VendorID: model.VendorIDMTWM,
|
||||
VendorOrderID: utils.Int64ToStr(utils.MustInterface2Int64(result["order_id"])),
|
||||
VendorID: model.VendorIDDD,
|
||||
VendorOrderID: result.OrderId,
|
||||
}
|
||||
// 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 {
|
||||
@@ -157,96 +155,50 @@ func (p *PurchaseHandler) OrderDetail2Financial(result map[string]interface{}) (
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//globals.SugarLogger.Warnf("mtwm OrderDetail2Financial, orderID:%s is not found from partner.CurOrderManager.LoadOrder", orderFinancial.VendorOrderID)
|
||||
err = nil
|
||||
}
|
||||
if result["package_bag_money"] != nil {
|
||||
orderFinancial.BoxMoney = utils.MustInterface2Int64(result["package_bag_money"])
|
||||
|
||||
// 订单
|
||||
for _, x := range result.SkuOrderList {
|
||||
orderSkuFinancial := &model.OrderSkuFinancial{
|
||||
VendorID: orderFinancial.VendorID,
|
||||
VendorOrderID: orderFinancial.VendorOrderID,
|
||||
VendorStoreID: x.StoreInfo.StoreId,
|
||||
StoreID: 0,
|
||||
JxStoreID: jxStoreID,
|
||||
VendorSkuID: utils.Interface2String(x.SkuId),
|
||||
SkuID: int(utils.Str2Int64WithDefault(x.OutSkuId, 0)),
|
||||
Name: utils.Interface2String(x.ProductName),
|
||||
SalePrice: x.OrderAmount / x.ItemNum,
|
||||
Count: int(x.ItemNum),
|
||||
SkuBoxMoney: 0,
|
||||
IsAfsOrder: 0,
|
||||
}
|
||||
orderFinancial.Skus = append(orderFinancial.Skus, orderSkuFinancial)
|
||||
orderFinancial.SalePriceMoney += orderSkuFinancial.SalePrice * int64(orderSkuFinancial.Count)
|
||||
orderFinancial.SkuBoxMoney += orderSkuFinancial.SkuBoxMoney
|
||||
}
|
||||
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.SkuOrderList {
|
||||
for _, v := range x.CampaignInfo {
|
||||
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 +=
|
||||
}
|
||||
activity.VendorActivityID = utils.Int64ToStr(v.CampaignId)
|
||||
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
|
||||
globals.SugarLogger.Debug(orderFinancial.VendorOrderID)
|
||||
|
||||
orderFinancial.ReceivableFreight = result.PostAmount
|
||||
orderFinancial.FreightMoney = 0
|
||||
orderFinancial.ActualPayMoney = result.PayAmount
|
||||
orderFinancial.PmMoney = 0 // 平台费
|
||||
orderFinancial.ShopMoney = 0 // 应结金额
|
||||
orderFinancial.TotalDiscountMoney = result.PromotionAmount // 订单优惠总金额
|
||||
orderFinancial.PmSubsidyMoney = result.PromotionPlatformAmount // 平台活动补贴(订单主体活动补贴+订单单条sku补贴)1+
|
||||
orderFinancial.SelfDeliveryDiscountMoney = 0 // 平台承担运费补贴(商家自送)+
|
||||
orderFinancial.DistanceFreightMoney = 0
|
||||
return orderFinancial
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user