结账报错优化

This commit is contained in:
renyutian
2019-04-08 11:27:56 +08:00
parent 7d820a6131
commit 976a7d0d76
4 changed files with 25 additions and 13 deletions

View File

@@ -23,8 +23,8 @@ func OnFinancialMsg(msg *ebaiapi.CallbackMsg) (err error) {
messageType := utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["type"]))
if utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["cancel_type"])) == ebaiapi.AfterOrderFinishedCancelType &&
(messageType == ebaiapi.OrderUserCancelSuccessA || messageType == ebaiapi.OrderUserCancelSuccessB) {
globals.SugarLogger.Debug(utils.Interface2String(msg.Body["refund_id"])) // 获得退款订单ID去本地数据库拿饿百消息推送只给了订单号但是没有查询全额退款的接口只有部分退款才可以查询
afsOrderID := utils.Interface2String(msg.Body["refund_id"])
globals.SugarLogger.Debug(utils.Interface2String(msg.Body["order_id"])) // 获得退款订单ID去本地数据库拿饿百消息推送只给了订单号但是没有查询全额退款的接口只有部分退款才可以查询
afsOrderID := utils.Interface2String(msg.Body["order_id"])
orderFinancial, err := partner.CurOrderManager.LoadOrderFinancial(afsOrderID, model.VendorIDEBAI)
if err == nil {
globals.SugarLogger.Debug(utils.Format4Output(orderFinancial, false))
@@ -48,15 +48,21 @@ func OnFinancialMsg(msg *ebaiapi.CallbackMsg) (err error) {
func (p *PurchaseHandler) OrderFinancialDetail2Refund(orderFinancial *model.OrderFinancial, msg *ebaiapi.CallbackMsg) (afsOrder *model.AfsOrder) {
afsOrder = &model.AfsOrder{
VendorID: model.VendorIDEBAI,
AfsOrderID: utils.Interface2String(msg.Body["refund_id"]),
VendorOrderID: utils.Interface2String(msg.Body["refund_id"]),
AfsCreateAt: utils.Timestamp2Time(utils.Str2Int64(utils.Interface2String(msg.Body["timestamp"]))),
AfsOrderID: utils.Interface2String(msg.Body["order_id"]),
VendorOrderID: utils.Interface2String(msg.Body["order_id"]),
AfsCreateAt: utils.Timestamp2Time(utils.MustInterface2Int64(msg.Body["timestamp"])),
// BoxMoney: orderFinancial.BoxMoney, // 饿百的餐盒费已经拆分到单条Sku里面退款时直接计算用户支付sku金额就好了
// SkuBoxMoney: orderFinancial.SkuBoxMoney,
FreightUserMoney: orderFinancial.FreightMoney,
SkuUserMoney: orderFinancial.ActualPayMoney - orderFinancial.FreightMoney,
PmSubsidyMoney: orderFinancial.PmSubsidyMoney,
}
// if msg.Body["timestamp"] != nil {
// afsOrder.AfsCreateAt = utils.Timestamp2Time(utils.Str2Int64(utils.Interface2String(msg.Body["timestamp"])))
// } else {
// globals.SugarLogger.Warnf("ebai OrderFinancialDetail2Refund timestamp is not found in afsOrder:%s", afsOrder.AfsOrderID)
// afsOrder.AfsCreateAt = time.Now()
// }
order, err := partner.CurOrderManager.LoadOrder(afsOrder.VendorOrderID, afsOrder.VendorID)
globals.SugarLogger.Debug(utils.Format4Output(order, false))
if err == nil {
@@ -117,7 +123,7 @@ func (p *PurchaseHandler) AfsOrderDetail2Financial(orderData map[string]interfac
VendorOrderID: afsOrder.VendorOrderID,
// ConfirmTime: getTimeFromInterface(xMap["apply_time"]),
VendorSkuID: utils.Interface2String(xMap["sku_id"]),
SkuID: int(utils.Str2Int64(utils.Interface2String(xMap["custom_sku_id"]))),
SkuID: int(utils.Str2Int64WithDefault(utils.Interface2String(xMap["custom_sku_id"]), 0)),
Name: utils.Interface2String(xMap["name"]),
UserMoney: utils.MustInterface2Int64(xMap["total_refund"]),
PmSubsidyMoney: utils.MustInterface2Int64(xMap["shop_ele_refund"]),