This commit is contained in:
邹宗楠
2023-05-31 13:57:37 +08:00
parent 833dcddced
commit 982c7568b3
2 changed files with 13 additions and 7 deletions

View File

@@ -620,7 +620,7 @@ func orderFeeSettle(db *dao.DaoDB, order *model.GoodsOrder, bill *model.Waybill,
for _, v := range bills {
allFee += int(v.DesiredFee)
allFee += int(v.TipFee)
//allFee += int(v.TipFee)
}
// 运单支出费用统计,应该等于 支出费用- 退还费用
globals.SugarLogger.Errorf("计算错误:订单支出费用应该=退还费用+运单支出费用,支出费用:%d,已经退还费用:%d,运单计算费用:%d", billExpend, billIncome, allFee)

View File

@@ -370,6 +370,9 @@ func (c *BaseScheduler) CheckStoreBalanceWithTip(ctx *jxcontext.Context, order *
if roundTipFee != tipFee {
return model.ErrCodeOnePayTipFeeMore, fmt.Errorf("小费必须是1元的整数倍")
}
if order.WaybillTipMoney >= tipFee {
return model.ErrCodeOnePayTipFeeMore, fmt.Errorf("本次小费金额不能小于已经支付的小费")
}
if order.CreateDeliveryType == model.YES {
//加小费只判断余额
storeAcct, err := cms.GetStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order))
@@ -415,20 +418,21 @@ func isWaybillCanAddTip(waybill *model.Waybill) (isCan bool) {
func (c *BaseScheduler) SetOrderWaybillTipByOrder(ctx *jxcontext.Context, order *model.GoodsOrder, tipFee int64) (err error) {
db := dao.GetDB()
thisTimeTipFee := tipFee - order.WaybillTipMoney
storeDetail, _ := dao.GetStoreDetail(db, jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, "")
flag := false
// 如果平台支持设置配送小费,必须要成功设置
if handler := partner.GetWaybillTipUpdater(order.VendorID); handler != nil {
if err = handler.UpdateWaybillTip(ctx, order.VendorOrgCode, order.VendorStoreID, order.VendorOrderID, "", "", utils.Int2Str(storeDetail.CityCode), tipFee); err != nil {
if err = handler.UpdateWaybillTip(ctx, order.VendorOrgCode, order.VendorStoreID, order.VendorOrderID, "", "", utils.Int2Str(storeDetail.CityCode), thisTimeTipFee); err != nil {
return err
} else {
//加小费成功扣钱
if order.CreateDeliveryType == model.YES {
if err = partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(tipFee), partner.StoreAcctTypeExpendCreateWaybillTip, order.VendorOrderID, "", 0); err == nil {
if err = partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(thisTimeTipFee), partner.StoreAcctTypeExpendCreateWaybillTip, order.VendorOrderID, "", 0); err == nil {
flag = true
}
} else if order.CreateDeliveryType == model.NO {
if err = partner.CurStoreAcctManager.InsertBrandBill(ctx, storeDetail.BrandID, int(tipFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeTipFee, order.VendorOrderID, ""); err == nil {
if err = partner.CurStoreAcctManager.InsertBrandBill(ctx, storeDetail.BrandID, int(thisTimeTipFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeTipFee, order.VendorOrderID, ""); err == nil {
flag = true
}
}
@@ -452,8 +456,10 @@ func (c *BaseScheduler) SetOrderWaybillTipByOrder(ctx *jxcontext.Context, order
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
waybill := batchItemList[0].(*model.Waybill)
handler := partner.GetWaybillTipUpdater(waybill.WaybillVendorID)
if err == nil {
if waybill.WaybillVendorID == model.VendorIDDada {
err = handler.UpdateWaybillTip(ctx, waybill.VendorOrgCode, storeDetail.VendorStoreID, waybill.VendorOrderID, waybill.VendorWaybillID, waybill.VendorWaybillID2, utils.Int2Str(storeDetail.CityCode), tipFee)
} else {
err = handler.UpdateWaybillTip(ctx, waybill.VendorOrgCode, storeDetail.VendorStoreID, waybill.VendorOrderID, waybill.VendorWaybillID, waybill.VendorWaybillID2, utils.Int2Str(storeDetail.CityCode), thisTimeTipFee)
}
return nil, err
}, waybills2)
@@ -464,9 +470,9 @@ func (c *BaseScheduler) SetOrderWaybillTipByOrder(ctx *jxcontext.Context, order
if !flag {
//加小费成功扣钱
if order.CreateDeliveryType == model.YES {
partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(tipFee), partner.StoreAcctTypeExpendCreateWaybillTip, order.VendorOrderID, "", 0)
partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(thisTimeTipFee), partner.StoreAcctTypeExpendCreateWaybillTip, order.VendorOrderID, "", 0)
} else if order.CreateDeliveryType == model.NO {
partner.CurStoreAcctManager.InsertBrandBill(ctx, storeDetail.BrandID, int(tipFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeTipFee, order.VendorOrderID, "")
partner.CurStoreAcctManager.InsertBrandBill(ctx, storeDetail.BrandID, int(thisTimeTipFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeTipFee, order.VendorOrderID, "")
}
}
}