饿百 部分退款订单退款之后由于原正向订单佣金改变而导致扣款金额不准的问题
This commit is contained in:
@@ -158,7 +158,7 @@ func (c *OrderManager) SaveAfsOrderFinancialInfo(afsOrder *model.AfsOrder) (err
|
|||||||
}()
|
}()
|
||||||
// 平台结算扣除汇总--平台补贴,售后产生运费,平台收包装费,同城运费、、、
|
// 平台结算扣除汇总--平台补贴,售后产生运费,平台收包装费,同城运费、、、
|
||||||
deductionsByPm := afsOrder.PmSubsidyMoney + afsOrder.AfsFreightMoney + afsOrder.BoxMoney + afsOrder.TongchengFreightMoney
|
deductionsByPm := afsOrder.PmSubsidyMoney + afsOrder.AfsFreightMoney + afsOrder.BoxMoney + afsOrder.TongchengFreightMoney
|
||||||
afsOrder.RefundMoneyByCal = afsOrder.SkuUserMoney + afsOrder.FreightUserMoney + deductionsByPm
|
afsOrder.RefundMoneyByCal = afsOrder.SkuUserMoney + afsOrder.FreightUserMoney + deductionsByPm - afsOrder.PmRefundMoney
|
||||||
// order.TotalMoney += order.SkuJxMoney // 退款单京西补贴部分先不作计算
|
// order.TotalMoney += order.SkuJxMoney // 退款单京西补贴部分先不作计算
|
||||||
if err = dao.CreateEntity(db, afsOrder); err != nil {
|
if err = dao.CreateEntity(db, afsOrder); err != nil {
|
||||||
if !dao.IsDuplicateError(err) {
|
if !dao.IsDuplicateError(err) {
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ type AfsOrder struct {
|
|||||||
SkuBoxMoney int64 `json:"skuBoxMoney"` // 应退订单餐盒费
|
SkuBoxMoney int64 `json:"skuBoxMoney"` // 应退订单餐盒费
|
||||||
PmSubsidyMoney int64 `json:"pmSubsidyMoney"` // 平台总补贴金额
|
PmSubsidyMoney int64 `json:"pmSubsidyMoney"` // 平台总补贴金额
|
||||||
PmSkuSubsidyMoney int64 `json:"pmSkuSubsidyMoney"` // 平台sku补贴金额
|
PmSkuSubsidyMoney int64 `json:"pmSkuSubsidyMoney"` // 平台sku补贴金额
|
||||||
|
PmRefundMoney int64 `json:"pmRefundMoney"` // 订单取消后可能存在佣金减少,平台退回部分金额的情况
|
||||||
RefundMoney int64 `json:"refundMoney"` // 平台扣款总额 1
|
RefundMoney int64 `json:"refundMoney"` // 平台扣款总额 1
|
||||||
RefundMoneyByCal int64 `json:"refundMoneyByCal"` // 平台扣款总额-通过公式计算平台扣除京西的金额M
|
RefundMoneyByCal int64 `json:"refundMoneyByCal"` // 平台扣款总额-通过公式计算平台扣除京西的金额M
|
||||||
// JxSkuMoney int64 `json:"jxSkuMoney"` // 京西补贴金额,现阶段是平台扣京西多少钱,京西扣商家多少钱,暂不考虑撤回京西补贴
|
// JxSkuMoney int64 `json:"jxSkuMoney"` // 京西补贴金额,现阶段是平台扣京西多少钱,京西扣商家多少钱,暂不考虑撤回京西补贴
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
|
|
||||||
|
_ "git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||||
_ "git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch"
|
_ "git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch"
|
||||||
"git.rosy.net.cn/jx-callback/globals/testinit"
|
"git.rosy.net.cn/jx-callback/globals/testinit"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ import (
|
|||||||
func OnFinancialMsg(msg *ebaiapi.CallbackMsg) (err error) {
|
func OnFinancialMsg(msg *ebaiapi.CallbackMsg) (err error) {
|
||||||
if msg.Cmd == ebaiapi.CmdOrderPartRefund { // 部分退款处理
|
if msg.Cmd == ebaiapi.CmdOrderPartRefund { // 部分退款处理
|
||||||
if utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["status"])) == ebaiapi.OrderPartRefundSuccess {
|
if utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["status"])) == ebaiapi.OrderPartRefundSuccess {
|
||||||
|
// 获取到部分退款订单id
|
||||||
afsOrderID := utils.Interface2String(msg.Body["order_id"])
|
afsOrderID := utils.Interface2String(msg.Body["order_id"])
|
||||||
|
// 处理部分退款信息
|
||||||
orderData, err2 := api.EbaiAPI.OrderPartrefundGet(afsOrderID)
|
orderData, err2 := api.EbaiAPI.OrderPartrefundGet(afsOrderID)
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
afsOrder := CurPurchaseHandler.AfsOrderDetail2Financial(orderData)
|
afsOrder := CurPurchaseHandler.AfsOrderDetail2Financial(orderData)
|
||||||
@@ -114,6 +116,14 @@ func (p *PurchaseHandler) AfsOrderDetail2Financial(orderData map[string]interfac
|
|||||||
globals.SugarLogger.Warnf("ebai AfsOrderDetail2Financial, afsOrderID:%s is not found from partner.CurOrderManager.LoadOrder", afsOrder.VendorOrderID)
|
globals.SugarLogger.Warnf("ebai AfsOrderDetail2Financial, afsOrderID:%s is not found from partner.CurOrderManager.LoadOrder", afsOrder.VendorOrderID)
|
||||||
err = nil
|
err = nil
|
||||||
}
|
}
|
||||||
|
// 部分退款订单,第三方平台佣金会变化,金额为 orderData["commission"],是否将该字段更新到正向订单结算表中
|
||||||
|
// 不作更新的话,商户可以得到的钱会少几毛钱,最终京西收益
|
||||||
|
// 如果要更新,总佣金,京西佣金是否都要更新,而其它一系列连锁反应,是否需要考虑更新
|
||||||
|
// 或者换个思路,不考虑变更之前的正向订单,在佣金上入手,退款金额减去佣金减少的部分
|
||||||
|
orderFinancial, err := partner.CurOrderManager.LoadOrderFinancial(afsOrder.VendorOrderID, model.VendorIDEBAI)
|
||||||
|
if err == nil {
|
||||||
|
afsOrder.PmRefundMoney = orderFinancial.PmMoney - utils.MustInterface2Int64(orderData["commission"])
|
||||||
|
}
|
||||||
if orderData["refund_detail"] != nil {
|
if orderData["refund_detail"] != nil {
|
||||||
refundDetail := orderData["refund_detail"].([]interface{})
|
refundDetail := orderData["refund_detail"].([]interface{})
|
||||||
for _, refundInfo := range refundDetail {
|
for _, refundInfo := range refundDetail {
|
||||||
|
|||||||
@@ -7,20 +7,24 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
|
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestOnFinancialMsg(t *testing.T) {
|
func TestOnFinancialMsg(t *testing.T) {
|
||||||
msg := &ebaiapi.CallbackMsg{
|
msg := &ebaiapi.CallbackMsg{
|
||||||
// Cmd: "order.partrefund.push",
|
Timestamp: time.Now().Unix(),
|
||||||
Cmd: "order.user.cancel",
|
Body: make(map[string]interface{}),
|
||||||
Body: make(map[string]interface{}),
|
|
||||||
}
|
}
|
||||||
msg.Body["refund_id"] = "15531567190216"
|
msg.Body["order_id"] = "1554939646172038357"
|
||||||
msg.Body["timestamp"] = utils.Int64ToStr(time.Now().Unix())
|
|
||||||
// msg.Body["status"] = json.Number("20")
|
// 部分退款
|
||||||
msg.Body["type"] = json.Number("40")
|
msg.Cmd = "order.partrefund.push"
|
||||||
msg.Body["cancel_type"] = json.Number("2")
|
msg.Body["status"] = json.Number("20")
|
||||||
|
|
||||||
|
// 全单退款
|
||||||
|
// msg.Cmd = "order.user.cancel"
|
||||||
|
// msg.Body["type"] = json.Number("40")
|
||||||
|
// msg.Body["cancel_type"] = json.Number("2")
|
||||||
|
|
||||||
res := OnFinancialMsg(msg)
|
res := OnFinancialMsg(msg)
|
||||||
fmt.Println(res)
|
fmt.Println(res)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user