aa
This commit is contained in:
@@ -338,7 +338,7 @@ func (c *BaseScheduler) SetOrderWaybillTipByOrder(ctx *jxcontext.Context, order
|
|||||||
} else {
|
} else {
|
||||||
//加小费成功扣钱
|
//加小费成功扣钱
|
||||||
if order.CreateDeliveryType == model.YES {
|
if order.CreateDeliveryType == model.YES {
|
||||||
if err = partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), 100, partner.StoreAcctTypeExpendCreateWaybillTip, order.VendorOrderID); err == nil {
|
if err = partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), 100, partner.StoreAcctTypeExpendCreateWaybillTip, order.VendorOrderID, 0); err == nil {
|
||||||
flag = true
|
flag = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -374,7 +374,7 @@ func (c *BaseScheduler) SetOrderWaybillTipByOrder(ctx *jxcontext.Context, order
|
|||||||
if !flag {
|
if !flag {
|
||||||
//加小费成功扣钱
|
//加小费成功扣钱
|
||||||
if order.CreateDeliveryType == model.YES {
|
if order.CreateDeliveryType == model.YES {
|
||||||
partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), 100, partner.StoreAcctTypeExpendCreateWaybillTip, order.VendorOrderID)
|
partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), 100, partner.StoreAcctTypeExpendCreateWaybillTip, order.VendorOrderID, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -586,6 +586,8 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
|
|||||||
if order.VendorID == model.VendorIDJDShop {
|
if order.VendorID == model.VendorIDJDShop {
|
||||||
s.solutionJdsOrder(bill)
|
s.solutionJdsOrder(bill)
|
||||||
}
|
}
|
||||||
|
//门店发单的门店,需要根据实际运费更新账户(多退少补)
|
||||||
|
s.updateStoreAccount(order, bill)
|
||||||
//订单已经是结束状态之后来的运单143945553920000001
|
//订单已经是结束状态之后来的运单143945553920000001
|
||||||
if order.Status > model.OrderStatusEndBegin {
|
if order.Status > model.OrderStatusEndBegin {
|
||||||
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
|
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
|
||||||
@@ -1318,6 +1320,10 @@ func (s *DefScheduler) updateOrderByBill(order *model.GoodsOrder, bill *model.Wa
|
|||||||
partner.CurOrderManager.UpdateOrderFields(order, updateFields)
|
partner.CurOrderManager.UpdateOrderFields(order, updateFields)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *DefScheduler) updateStoreAccount(order *model.GoodsOrder, bill *model.Waybill) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func (s *DefScheduler) updateBillsInfo(savedOrderInfo *WatchOrderInfo, bill *model.Waybill) (isBillExist bool) {
|
func (s *DefScheduler) updateBillsInfo(savedOrderInfo *WatchOrderInfo, bill *model.Waybill) (isBillExist bool) {
|
||||||
if savedOrderInfo != nil {
|
if savedOrderInfo != nil {
|
||||||
if savedBill := savedOrderInfo.waybills[bill.WaybillVendorID]; savedBill != nil {
|
if savedBill := savedOrderInfo.waybills[bill.WaybillVendorID]; savedBill != nil {
|
||||||
|
|||||||
@@ -152,15 +152,15 @@ func (s *DefScheduler) CreateWaybillOnProviders4SavedOrder(ctx *jxcontext.Contex
|
|||||||
}
|
}
|
||||||
newPrice = maxFee
|
newPrice = maxFee
|
||||||
}
|
}
|
||||||
lastFee, _ := partner.CurStoreAcctManager.GetStoreAcctExpendLastCreateWayBillFee(order.VendorOrderID)
|
expend, lastFee, _ := partner.CurStoreAcctManager.GetStoreAcctExpendLastCreateWayBillFee(order.VendorOrderID)
|
||||||
if int(newPrice) > lastFee {
|
if int(newPrice) > lastFee {
|
||||||
partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(newPrice)-lastFee, partner.StoreAcctTypeExpendCreateWaybillEx, order.VendorOrderID)
|
partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(newPrice)-lastFee, partner.StoreAcctTypeExpendCreateWaybill2ndMore, order.VendorOrderID, expend.ID)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if len(courierVendorIDs) == 1 {
|
if len(courierVendorIDs) == 1 {
|
||||||
courierVendorID := courierVendorIDs[0]
|
courierVendorID := courierVendorIDs[0]
|
||||||
if _, ok := deliveryFeeMap[courierVendorID]; ok {
|
if _, ok := deliveryFeeMap[courierVendorID]; ok {
|
||||||
partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(deliveryFeeMap[courierVendorID].DeliveryFee), partner.StoreAcctTypeExpendCreateWaybillEx, order.VendorOrderID)
|
partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(deliveryFeeMap[courierVendorID].DeliveryFee), partner.StoreAcctTypeExpendCreateWaybillEx, order.VendorOrderID, 0)
|
||||||
}
|
}
|
||||||
} else if len(courierVendorIDs) == 0 {
|
} else if len(courierVendorIDs) == 0 {
|
||||||
var maxFee int64
|
var maxFee int64
|
||||||
@@ -169,7 +169,7 @@ func (s *DefScheduler) CreateWaybillOnProviders4SavedOrder(ctx *jxcontext.Contex
|
|||||||
v.DeliveryFee = maxFee
|
v.DeliveryFee = maxFee
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(maxFee), partner.StoreAcctTypeExpendCreateWaybillEx, order.VendorOrderID)
|
partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(maxFee), partner.StoreAcctTypeExpendCreateWaybillEx, order.VendorOrderID, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -264,7 +264,7 @@ func (s *DefScheduler) CheckStoreBalance(ctx *jxcontext.Context, order *model.Go
|
|||||||
}
|
}
|
||||||
newPrice = maxFee
|
newPrice = maxFee
|
||||||
}
|
}
|
||||||
lastFee, _ := partner.CurStoreAcctManager.GetStoreAcctExpendLastCreateWayBillFee(order.VendorOrderID)
|
_, lastFee, _ := partner.CurStoreAcctManager.GetStoreAcctExpendLastCreateWayBillFee(order.VendorOrderID)
|
||||||
if int(newPrice) > lastFee {
|
if int(newPrice) > lastFee {
|
||||||
if storeAcct.AccountBalance < int(newPrice)-lastFee {
|
if storeAcct.AccountBalance < int(newPrice)-lastFee {
|
||||||
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("门店账户余额小于[%v]元,不能发配送!", jxutils.IntPrice2Standard(newPrice-int64(lastFee)))
|
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("门店账户余额小于[%v]元,不能发配送!", jxutils.IntPrice2Standard(newPrice-int64(lastFee)))
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ func (s *StoreAcctManager) InsertStoreAcctIncome(ctx *jxcontext.Context, storeID
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StoreAcctManager) InsertStoreAcctExpend(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string) (err error) {
|
func (s *StoreAcctManager) InsertStoreAcctExpend(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string, expendID int) (err error) {
|
||||||
var (
|
var (
|
||||||
userID, userName string
|
userID, userName string
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
@@ -79,6 +79,9 @@ func (s *StoreAcctManager) InsertStoreAcctExpend(ctx *jxcontext.Context, storeID
|
|||||||
VendorOrderID: vendorOrderID,
|
VendorOrderID: vendorOrderID,
|
||||||
}
|
}
|
||||||
dao.WrapAddIDCULEntity(storeAcctExpend, userName)
|
dao.WrapAddIDCULEntity(storeAcctExpend, userName)
|
||||||
|
if expendID != 0 {
|
||||||
|
|
||||||
|
}
|
||||||
err = dao.CreateEntity(db, storeAcctExpend)
|
err = dao.CreateEntity(db, storeAcctExpend)
|
||||||
globals.SugarLogger.Debugf("InsertStoreAcctExpend orderID: [%v] , price :[%v] , type :[%v]", vendorOrderID, price, acctType)
|
globals.SugarLogger.Debugf("InsertStoreAcctExpend orderID: [%v] , price :[%v] , type :[%v]", vendorOrderID, price, acctType)
|
||||||
return err
|
return err
|
||||||
@@ -128,9 +131,9 @@ func (s *StoreAcctManager) UpdateStoreAcctBalance(ctx *jxcontext.Context, storeI
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StoreAcctManager) InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string) (err error) {
|
func (s *StoreAcctManager) InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string, expendID int) (err error) {
|
||||||
utils.CallFuncAsync(func() {
|
utils.CallFuncAsync(func() {
|
||||||
if err = s.InsertStoreAcctExpend(ctx, storeID, price, acctType, vendorOrderID); err == nil {
|
if err = s.InsertStoreAcctExpend(ctx, storeID, price, acctType, vendorOrderID, expendID); err == nil {
|
||||||
s.UpdateStoreAcctBalance(ctx, storeID, price, false)
|
s.UpdateStoreAcctBalance(ctx, storeID, price, false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -170,6 +173,6 @@ func (s *StoreAcctManager) CheckStoreAcctExpendExist(vendorOrderID string) (isEq
|
|||||||
return false, false, err
|
return false, false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StoreAcctManager) GetStoreAcctExpendLastCreateWayBillFee(vendorOrderID string) (lastFee int, err error) {
|
func (s *StoreAcctManager) GetStoreAcctExpendLastCreateWayBillFee(vendorOrderID string) (expend *dao.GetStoreAcctExpendLastCreateWayBillFeeResult, lastFee int, err error) {
|
||||||
return dao.GetStoreAcctExpendLastCreateWayBillFee(dao.GetDB(), vendorOrderID)
|
return dao.GetStoreAcctExpendLastCreateWayBillFee(dao.GetDB(), vendorOrderID)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1146,8 +1146,7 @@ type GetStoreAcctExpendLastCreateWayBillFeeResult struct {
|
|||||||
MulitIncomePrice int `json:"mulitIncomePrice"`
|
MulitIncomePrice int `json:"mulitIncomePrice"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetStoreAcctExpendLastCreateWayBillFee(db *DaoDB, vendorOrderID string) (lastFee int, err error) {
|
func GetStoreAcctExpendLastCreateWayBillFee(db *DaoDB, vendorOrderID string) (expend *GetStoreAcctExpendLastCreateWayBillFeeResult, lastFee int, err error) {
|
||||||
var expend *GetStoreAcctExpendLastCreateWayBillFeeResult
|
|
||||||
sql := `
|
sql := `
|
||||||
SELECT a.id, b.id exp_id, c.id inc_id,
|
SELECT a.id, b.id exp_id, c.id inc_id,
|
||||||
a.expend_price, b.expend_price mulit_expend_price, c.income_price mulit_income_price
|
a.expend_price, b.expend_price mulit_expend_price, c.income_price mulit_income_price
|
||||||
@@ -1176,7 +1175,7 @@ func GetStoreAcctExpendLastCreateWayBillFee(db *DaoDB, vendorOrderID string) (la
|
|||||||
if expend.IncID != 0 {
|
if expend.IncID != 0 {
|
||||||
lastFee -= expend.MulitIncomePrice
|
lastFee -= expend.MulitIncomePrice
|
||||||
}
|
}
|
||||||
return lastFee, err
|
return expend, lastFee, err
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetStoreManageStateResult struct {
|
type GetStoreManageStateResult struct {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package partner
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"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/model/dao"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -12,9 +13,10 @@ const (
|
|||||||
StoreAcctTypeIncomeCancelReal = 19 //运单取消,回退的真实运费
|
StoreAcctTypeIncomeCancelReal = 19 //运单取消,回退的真实运费
|
||||||
|
|
||||||
//账户支出类型
|
//账户支出类型
|
||||||
StoreAcctTypeExpendCreateWaybillEx = 20 //发单扣除的临时运费
|
StoreAcctTypeExpendCreateWaybillEx = 20 //发单扣除的临时运费
|
||||||
StoreAcctTypeExpendCreateWaybillTip = 21 //手动加小费扣除
|
StoreAcctTypeExpendCreateWaybillTip = 21 //手动加小费扣除
|
||||||
StoreAcctTypeRealFeeExpend = 25 //真实运费 > 临时运费, 真实运费的值 - 临时运费的值
|
StoreAcctTypeExpendCreateWaybill2ndMore = 22 //第二次发运单,并且比上次需要更多钱扣的差价
|
||||||
|
StoreAcctTypeRealFeeExpend = 25 //真实运费 > 临时运费, 真实运费的值 - 临时运费的值
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -33,11 +35,11 @@ type IStoreAcctManager interface {
|
|||||||
//增加一条收入流水
|
//增加一条收入流水
|
||||||
InsertStoreAcctIncome(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string) (err error)
|
InsertStoreAcctIncome(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string) (err error)
|
||||||
//增加一条支出流水
|
//增加一条支出流水
|
||||||
InsertStoreAcctExpend(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string) (err error)
|
InsertStoreAcctExpend(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string, expendID int) (err error)
|
||||||
//更新门店账户
|
//更新门店账户
|
||||||
UpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price int, isIncome bool) (err error)
|
UpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price int, isIncome bool) (err error)
|
||||||
InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string) (err error)
|
InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string, expendID int) (err error)
|
||||||
InsertStoreAcctIncomeAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string) (err error)
|
InsertStoreAcctIncomeAndUpdateStoreAcctBalance(ctx *jxcontext.Context, storeID, price, acctType int, vendorOrderID string) (err error)
|
||||||
CheckStoreAcctExpendExist(vendorOrderID string) (isEqual, isZero bool, err error)
|
CheckStoreAcctExpendExist(vendorOrderID string) (isEqual, isZero bool, err error)
|
||||||
GetStoreAcctExpendLastCreateWayBillFee(vendorOrderID string) (lastFee int, err error)
|
GetStoreAcctExpendLastCreateWayBillFee(vendorOrderID string) (expend *dao.GetStoreAcctExpendLastCreateWayBillFeeResult, lastFee int, err error)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user