结账报错优化
This commit is contained in:
@@ -112,7 +112,7 @@ func (c *OrderManager) SaveOrderFinancialInfo(order *model.OrderFinancial, opera
|
|||||||
// 加上京西对单条sku的补贴,再存数据库
|
// 加上京西对单条sku的补贴,再存数据库
|
||||||
order.JxSubsidyMoney += order.JxSkuSubsidyMoney
|
order.JxSubsidyMoney += order.JxSkuSubsidyMoney
|
||||||
if err = dao.CreateEntity(db, order); err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
dao.Commit(db)
|
dao.Commit(db)
|
||||||
@@ -137,7 +137,7 @@ func (c *OrderManager) SaveAfsOrderFinancialInfo(afsOrder *model.AfsOrder) (err
|
|||||||
afsOrder.RefundMoneyByCal = afsOrder.SkuUserMoney + afsOrder.FreightUserMoney + deductionsByPm
|
afsOrder.RefundMoneyByCal = afsOrder.SkuUserMoney + afsOrder.FreightUserMoney + deductionsByPm
|
||||||
// order.TotalMoney += order.SkuJxMoney // 退款单京西补贴部分先不作计算
|
// order.TotalMoney += order.SkuJxMoney // 退款单京西补贴部分先不作计算
|
||||||
if err = dao.CreateEntity(db, afsOrder); err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ func OnFinancialMsg(msg *ebaiapi.CallbackMsg) (err error) {
|
|||||||
messageType := utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["type"]))
|
messageType := utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["type"]))
|
||||||
if utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["cancel_type"])) == ebaiapi.AfterOrderFinishedCancelType &&
|
if utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["cancel_type"])) == ebaiapi.AfterOrderFinishedCancelType &&
|
||||||
(messageType == ebaiapi.OrderUserCancelSuccessA || messageType == ebaiapi.OrderUserCancelSuccessB) {
|
(messageType == ebaiapi.OrderUserCancelSuccessA || messageType == ebaiapi.OrderUserCancelSuccessB) {
|
||||||
globals.SugarLogger.Debug(utils.Interface2String(msg.Body["refund_id"])) // 获得退款订单ID,去本地数据库拿?饿百消息推送只给了订单号,但是没有查询全额退款的接口,只有部分退款才可以查询
|
globals.SugarLogger.Debug(utils.Interface2String(msg.Body["order_id"])) // 获得退款订单ID,去本地数据库拿?饿百消息推送只给了订单号,但是没有查询全额退款的接口,只有部分退款才可以查询
|
||||||
afsOrderID := utils.Interface2String(msg.Body["refund_id"])
|
afsOrderID := utils.Interface2String(msg.Body["order_id"])
|
||||||
orderFinancial, err := partner.CurOrderManager.LoadOrderFinancial(afsOrderID, model.VendorIDEBAI)
|
orderFinancial, err := partner.CurOrderManager.LoadOrderFinancial(afsOrderID, model.VendorIDEBAI)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
globals.SugarLogger.Debug(utils.Format4Output(orderFinancial, false))
|
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) {
|
func (p *PurchaseHandler) OrderFinancialDetail2Refund(orderFinancial *model.OrderFinancial, msg *ebaiapi.CallbackMsg) (afsOrder *model.AfsOrder) {
|
||||||
afsOrder = &model.AfsOrder{
|
afsOrder = &model.AfsOrder{
|
||||||
VendorID: model.VendorIDEBAI,
|
VendorID: model.VendorIDEBAI,
|
||||||
AfsOrderID: utils.Interface2String(msg.Body["refund_id"]),
|
AfsOrderID: utils.Interface2String(msg.Body["order_id"]),
|
||||||
VendorOrderID: utils.Interface2String(msg.Body["refund_id"]),
|
VendorOrderID: utils.Interface2String(msg.Body["order_id"]),
|
||||||
AfsCreateAt: utils.Timestamp2Time(utils.Str2Int64(utils.Interface2String(msg.Body["timestamp"]))),
|
AfsCreateAt: utils.Timestamp2Time(utils.MustInterface2Int64(msg.Body["timestamp"])),
|
||||||
// BoxMoney: orderFinancial.BoxMoney, // 饿百的餐盒费已经拆分到单条Sku里面,退款时直接计算用户支付sku金额就好了
|
// BoxMoney: orderFinancial.BoxMoney, // 饿百的餐盒费已经拆分到单条Sku里面,退款时直接计算用户支付sku金额就好了
|
||||||
// SkuBoxMoney: orderFinancial.SkuBoxMoney,
|
// SkuBoxMoney: orderFinancial.SkuBoxMoney,
|
||||||
FreightUserMoney: orderFinancial.FreightMoney,
|
FreightUserMoney: orderFinancial.FreightMoney,
|
||||||
SkuUserMoney: orderFinancial.ActualPayMoney - orderFinancial.FreightMoney,
|
SkuUserMoney: orderFinancial.ActualPayMoney - orderFinancial.FreightMoney,
|
||||||
PmSubsidyMoney: orderFinancial.PmSubsidyMoney,
|
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)
|
order, err := partner.CurOrderManager.LoadOrder(afsOrder.VendorOrderID, afsOrder.VendorID)
|
||||||
globals.SugarLogger.Debug(utils.Format4Output(order, false))
|
globals.SugarLogger.Debug(utils.Format4Output(order, false))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -117,7 +123,7 @@ func (p *PurchaseHandler) AfsOrderDetail2Financial(orderData map[string]interfac
|
|||||||
VendorOrderID: afsOrder.VendorOrderID,
|
VendorOrderID: afsOrder.VendorOrderID,
|
||||||
// ConfirmTime: getTimeFromInterface(xMap["apply_time"]),
|
// ConfirmTime: getTimeFromInterface(xMap["apply_time"]),
|
||||||
VendorSkuID: utils.Interface2String(xMap["sku_id"]),
|
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"]),
|
Name: utils.Interface2String(xMap["name"]),
|
||||||
UserMoney: utils.MustInterface2Int64(xMap["total_refund"]),
|
UserMoney: utils.MustInterface2Int64(xMap["total_refund"]),
|
||||||
PmSubsidyMoney: utils.MustInterface2Int64(xMap["shop_ele_refund"]),
|
PmSubsidyMoney: utils.MustInterface2Int64(xMap["shop_ele_refund"]),
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ func (p *PurchaseHandler) OrderDetail2Financial(orderData map[string]interface{}
|
|||||||
// OrderFinancialID: orderFinancial.VendorOrderID,
|
// OrderFinancialID: orderFinancial.VendorOrderID,
|
||||||
// ConfirmTime: utils.Str2Time(utils.Interface2String(orderData["orderStartTime"])),
|
// ConfirmTime: utils.Str2Time(utils.Interface2String(orderData["orderStartTime"])),
|
||||||
VendorStoreID: utils.Interface2String(orderData["deliveryStationNo"]),
|
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,
|
JxStoreID: order.JxStoreID,
|
||||||
VendorSkuID: utils.Int64ToStr(utils.MustInterface2Int64(xMap["skuId"])),
|
VendorSkuID: utils.Int64ToStr(utils.MustInterface2Int64(xMap["skuId"])),
|
||||||
// SkuID: int(utils.Str2Int64(utils.Interface2String(xMap["skuIdIsv"]))),
|
// 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"]),
|
AfsOrderID: utils.Interface2String(orderData["afsServiceOrder"]),
|
||||||
VendorOrderID: utils.Interface2String(orderData["orderId"]),
|
VendorOrderID: utils.Interface2String(orderData["orderId"]),
|
||||||
VendorStoreID: utils.Interface2String(orderData["stationId"]),
|
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),
|
AfsCreateAt: utils.Timestamp2Time(utils.MustInterface2Int64(orderData["updateTime"].(map[string]interface{})["time"]) / 1000),
|
||||||
FreightUserMoney: utils.MustInterface2Int64(orderData["orderFreightMoney"]),
|
FreightUserMoney: utils.MustInterface2Int64(orderData["orderFreightMoney"]),
|
||||||
AfsFreightMoney: utils.MustInterface2Int64(orderData["afsFreight"]),
|
AfsFreightMoney: utils.MustInterface2Int64(orderData["afsFreight"]),
|
||||||
@@ -190,7 +190,7 @@ func (p *PurchaseHandler) AfsOrderDetail2Financial(orderData map[string]interfac
|
|||||||
StoreID: afsOrder.StoreID,
|
StoreID: afsOrder.StoreID,
|
||||||
// ConfirmTime: afsOrder.AfsCreateAt,
|
// ConfirmTime: afsOrder.AfsCreateAt,
|
||||||
VendorSkuID: utils.Int64ToStr(utils.MustInterface2Int64(xMap["wareId"])),
|
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"]),
|
Name: utils.Interface2String(xMap["wareName"]),
|
||||||
UserMoney: utils.MustInterface2Int64(xMap["afsMoney"]),
|
UserMoney: utils.MustInterface2Int64(xMap["afsMoney"]),
|
||||||
PmSkuSubsidyMoney: utils.MustInterface2Int64(xMap["platPayMoney"]),
|
PmSkuSubsidyMoney: utils.MustInterface2Int64(xMap["platPayMoney"]),
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ func (p *PurchaseHandler) OrderFinancialDetail2Refund(orderFinancial *model.Orde
|
|||||||
VendorID: model.VendorIDMTWM,
|
VendorID: model.VendorIDMTWM,
|
||||||
AfsOrderID: orderData.Get("order_id"),
|
AfsOrderID: orderData.Get("order_id"),
|
||||||
VendorOrderID: 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,
|
// BoxMoney: orderFinancial.BoxMoney,
|
||||||
// SkuBoxMoney: orderFinancial.SkuBoxMoney, // 美团的餐盒费已经拆到单条SKU里面去了,退款时直接计算用户支付sku金额就好了
|
// SkuBoxMoney: orderFinancial.SkuBoxMoney, // 美团的餐盒费已经拆到单条SKU里面去了,退款时直接计算用户支付sku金额就好了
|
||||||
FreightUserMoney: orderFinancial.FreightMoney,
|
FreightUserMoney: orderFinancial.FreightMoney,
|
||||||
@@ -96,6 +96,12 @@ func (p *PurchaseHandler) AfsOrderDetail2Financial(orderData url.Values) (afsOrd
|
|||||||
AfsCreateAt: utils.Timestamp2Time(utils.Str2Int64(orderData.Get("timestamp"))),
|
AfsCreateAt: utils.Timestamp2Time(utils.Str2Int64(orderData.Get("timestamp"))),
|
||||||
RefundMoney: jxutils.StandardPrice2Int(utils.Str2Float64(orderData.Get("money"))),
|
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)
|
order, err := partner.CurOrderManager.LoadOrder(afsOrder.VendorOrderID, afsOrder.VendorID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
afsOrder.JxStoreID = order.JxStoreID
|
afsOrder.JxStoreID = order.JxStoreID
|
||||||
@@ -113,7 +119,7 @@ func (p *PurchaseHandler) AfsOrderDetail2Financial(orderData url.Values) (afsOrd
|
|||||||
VendorOrderID: afsOrder.VendorOrderID,
|
VendorOrderID: afsOrder.VendorOrderID,
|
||||||
// ConfirmTime: afsOrder.AfsCreateAt,
|
// ConfirmTime: afsOrder.AfsCreateAt,
|
||||||
VendorSkuID: utils.Interface2String(xMap["app_food_code"]),
|
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"]),
|
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"])),
|
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,
|
IsAfsOrder: 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user