结账报错优化

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

@@ -112,7 +112,7 @@ func (c *OrderManager) SaveOrderFinancialInfo(order *model.OrderFinancial, opera
// 加上京西对单条sku的补贴再存数据库
order.JxSubsidyMoney += order.JxSkuSubsidyMoney
if err = dao.CreateEntity(db, order); err != nil {
globals.SugarLogger.Warnf("On SaveOrderFinancialInfo err: order is err")
globals.SugarLogger.Warnf("On SaveOrderFinancialInfo err: order is err,order.VendorOrderID:%s,order.VendorID:%d", order.VendorOrderID, order.VendorID)
return err
}
dao.Commit(db)
@@ -137,7 +137,7 @@ func (c *OrderManager) SaveAfsOrderFinancialInfo(afsOrder *model.AfsOrder) (err
afsOrder.RefundMoneyByCal = afsOrder.SkuUserMoney + afsOrder.FreightUserMoney + deductionsByPm
// order.TotalMoney += order.SkuJxMoney // 退款单京西补贴部分先不作计算
if err = dao.CreateEntity(db, afsOrder); err != nil {
globals.SugarLogger.Warnf("On SaveAfsOrderFinancialInfo err: SaveAfsOrder is err")
globals.SugarLogger.Warnf("On SaveAfsOrderFinancialInfo err: SaveAfsOrder is err,afsOrder.AfsOrderID:%s,afsOrder.VendorID:%d", afsOrder.AfsOrderID, afsOrder.VendorID)
return err
}

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"]),

View File

@@ -68,7 +68,7 @@ func (p *PurchaseHandler) OrderDetail2Financial(orderData map[string]interface{}
// OrderFinancialID: orderFinancial.VendorOrderID,
// ConfirmTime: utils.Str2Time(utils.Interface2String(orderData["orderStartTime"])),
VendorStoreID: utils.Interface2String(orderData["deliveryStationNo"]),
StoreID: int(utils.Str2Int64(utils.Interface2String(orderData["deliveryStationNoIsv"]))),
StoreID: int(utils.Str2Int64WithDefault(utils.Interface2String(orderData["deliveryStationNoIsv"]), 0)),
JxStoreID: order.JxStoreID,
VendorSkuID: utils.Int64ToStr(utils.MustInterface2Int64(xMap["skuId"])),
// SkuID: int(utils.Str2Int64(utils.Interface2String(xMap["skuIdIsv"]))),
@@ -164,7 +164,7 @@ func (p *PurchaseHandler) AfsOrderDetail2Financial(orderData map[string]interfac
AfsOrderID: utils.Interface2String(orderData["afsServiceOrder"]),
VendorOrderID: utils.Interface2String(orderData["orderId"]),
VendorStoreID: utils.Interface2String(orderData["stationId"]),
StoreID: int(utils.Str2Int64(utils.Interface2String(orderData["stationNumOutSystem"]))),
StoreID: int(utils.Str2Int64WithDefault(utils.Interface2String(orderData["stationNumOutSystem"]), 0)),
AfsCreateAt: utils.Timestamp2Time(utils.MustInterface2Int64(orderData["updateTime"].(map[string]interface{})["time"]) / 1000),
FreightUserMoney: utils.MustInterface2Int64(orderData["orderFreightMoney"]),
AfsFreightMoney: utils.MustInterface2Int64(orderData["afsFreight"]),
@@ -190,7 +190,7 @@ func (p *PurchaseHandler) AfsOrderDetail2Financial(orderData map[string]interfac
StoreID: afsOrder.StoreID,
// ConfirmTime: afsOrder.AfsCreateAt,
VendorSkuID: utils.Int64ToStr(utils.MustInterface2Int64(xMap["wareId"])),
SkuID: int(utils.Str2Int64(utils.Interface2String(xMap["skuIdIsv"]))),
SkuID: int(utils.Str2Int64WithDefault(utils.Interface2String(xMap["skuIdIsv"]), 0)),
Name: utils.Interface2String(xMap["wareName"]),
UserMoney: utils.MustInterface2Int64(xMap["afsMoney"]),
PmSkuSubsidyMoney: utils.MustInterface2Int64(xMap["platPayMoney"]),

View File

@@ -45,7 +45,7 @@ func (p *PurchaseHandler) OrderFinancialDetail2Refund(orderFinancial *model.Orde
VendorID: model.VendorIDMTWM,
AfsOrderID: orderData.Get("order_id"),
VendorOrderID: orderData.Get("order_id"),
AfsCreateAt: utils.Timestamp2Time(utils.Str2Int64(orderData.Get("timestamp"))),
AfsCreateAt: utils.Timestamp2Time(utils.Str2Int64WithDefault(orderData.Get("timestamp"), 0)),
// BoxMoney: orderFinancial.BoxMoney,
// SkuBoxMoney: orderFinancial.SkuBoxMoney, // 美团的餐盒费已经拆到单条SKU里面去了,退款时直接计算用户支付sku金额就好了
FreightUserMoney: orderFinancial.FreightMoney,
@@ -96,6 +96,12 @@ func (p *PurchaseHandler) AfsOrderDetail2Financial(orderData url.Values) (afsOrd
AfsCreateAt: utils.Timestamp2Time(utils.Str2Int64(orderData.Get("timestamp"))),
RefundMoney: jxutils.StandardPrice2Int(utils.Str2Float64(orderData.Get("money"))),
}
// if orderData.Get("timestamp") != "" {
// afsOrder.AfsCreateAt = utils.Timestamp2Time(utils.Str2Int64(orderData.Get("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)
if err == nil {
afsOrder.JxStoreID = order.JxStoreID
@@ -113,7 +119,7 @@ func (p *PurchaseHandler) AfsOrderDetail2Financial(orderData url.Values) (afsOrd
VendorOrderID: afsOrder.VendorOrderID,
// ConfirmTime: afsOrder.AfsCreateAt,
VendorSkuID: utils.Interface2String(xMap["app_food_code"]),
SkuID: int(utils.Str2Int64(utils.Interface2String(xMap["sku_id"]))),
SkuID: int(utils.Str2Int64WithDefault(utils.Interface2String(xMap["sku_id"]), 0)),
Name: utils.Interface2String(xMap["food_name"]),
UserMoney: jxutils.StandardPrice2Int(utils.MustInterface2Float64(xMap["refund_price"]))*utils.MustInterface2Int64(xMap["count"]) + jxutils.StandardPrice2Int(utils.MustInterface2Float64(xMap["box_price"]))*int64(utils.MustInterface2Float64(xMap["box_num"])),
IsAfsOrder: 1,