修改门店发单和品牌发单是扣费问题
This commit is contained in:
@@ -2,6 +2,7 @@ package defsch
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/smsmsg"
|
||||
"math/rand"
|
||||
"strings"
|
||||
@@ -634,13 +635,19 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
|
||||
//if bill.Status == model.WaybillStatusDelivering && order.VendorID == model.VendorIDJX && order.OrderType == model.OrderTypeNormal {
|
||||
// smsmsg.NotifyJxOrder(order, bill)
|
||||
//}
|
||||
//扣除品牌费用
|
||||
if storeDetail, err2 := dao.GetStoreDetail(dao.GetDB(), jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, ""); err2 == nil {
|
||||
if storeDetail.CreateDeliveryType == model.YES {
|
||||
s.updateStoreAccount(order, bill)
|
||||
}
|
||||
if !model.IsWaybillPlatformOwn(bill) {
|
||||
s.updateBrandAccount(storeDetail, bill)
|
||||
// 当运单时三方配送时,美团状态20
|
||||
if bill.WaybillVendorID == model.VendorIDDada || bill.WaybillVendorID == model.VendorIDMTPS || bill.WaybillVendorID == model.VendorIDFengNiao || bill.WaybillVendorID == model.VendorIDUUPT {
|
||||
if (bill.VendorStatus == utils.Int64ToStr(mtpsapi.OrderStatusPickedUp) && bill.OrderVendorID == model.VendorIDMTWM) || bill.Status == model.WaybillStatusCourierArrived {
|
||||
if storeDetail, err2 := dao.GetStoreDetail(dao.GetDB(), jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, ""); err2 == nil {
|
||||
if storeDetail.CreateDeliveryType == model.YES {
|
||||
s.updateStoreAccount(order, bill)
|
||||
} else {
|
||||
s.updateBrandAccount(storeDetail, bill)
|
||||
}
|
||||
//if !model.IsWaybillPlatformOwn(bill) {
|
||||
// s.updateBrandAccount(storeDetail, bill)
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -763,6 +770,7 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
|
||||
// // s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
|
||||
// globals.SugarLogger.Infof("OnWaybillStatusChanged Delivering order(%d, %s) bill(%d, %s), bill:%v shouldn't get here", order.WaybillVendorID, order.VendorWaybillID, bill.WaybillVendorID, bill.VendorWaybillID, bill)
|
||||
// }
|
||||
|
||||
case model.WaybillStatusDelivered:
|
||||
s.resetTimer(savedOrderInfo, bill, isPending)
|
||||
s.removeWaybillFromMap(savedOrderInfo, bill.WaybillVendorID)
|
||||
@@ -1439,10 +1447,10 @@ func (s *DefScheduler) updateStoreAccount(order *model.GoodsOrder, bill *model.W
|
||||
var diffFee int64
|
||||
if lastFee64 > realDesiredFee {
|
||||
diffFee = lastFee64 - realDesiredFee
|
||||
partner.CurStoreAcctManager.InsertStoreAcctIncomeAndUpdateStoreAcctBalance(jxcontext.AdminCtx, jxutils.GetSaleStoreIDFromOrder(order), int(diffFee), partner.StoreAcctTypeRealFeeIncome, order.VendorOrderID, expend.ID)
|
||||
partner.CurStoreAcctManager.InsertStoreAcctIncomeAndUpdateStoreAcctBalance(jxcontext.AdminCtx, jxutils.GetSaleStoreIDFromOrder(order), int(diffFee), partner.StoreAcctTypeRealFeeIncome, order.VendorOrderID, bill.VendorWaybillID, expend.ID)
|
||||
} else {
|
||||
diffFee = realDesiredFee - lastFee64
|
||||
partner.CurStoreAcctManager.InsertStoreAcctIncomeAndUpdateStoreAcctBalance(jxcontext.AdminCtx, jxutils.GetSaleStoreIDFromOrder(order), int(diffFee), partner.StoreAcctTypeRealFeeExpend, order.VendorOrderID, expend.ID)
|
||||
partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(jxcontext.AdminCtx, jxutils.GetSaleStoreIDFromOrder(order), int(diffFee), partner.StoreAcctTypeRealFeeExpend, order.VendorOrderID, "", expend.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1460,6 +1468,10 @@ func (s *DefScheduler) updateBrandAccount(store *dao.StoreDetail, bill *model.Wa
|
||||
}
|
||||
if sum == 0 {
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, store.BrandID, int(bill.DesiredFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery, bill.VendorOrderID, bill.VendorWaybillID)
|
||||
} else if bill.DesiredFee > int64(sum) {
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, store.BrandID, int(bill.DesiredFee-int64(sum)), model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery, bill.VendorOrderID, bill.VendorWaybillID)
|
||||
} else if bill.DesiredFee < int64(sum) {
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, store.BrandID, int(int64(sum)-bill.DesiredFee), model.BrandBillTypeIncome, model.BrandBillFeeTypeDelivery, bill.VendorOrderID, bill.VendorWaybillID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user