添加运单,号,添加下单价格校验

This commit is contained in:
邹宗楠
2022-04-06 16:35:56 +08:00
parent 204b3bf215
commit 2c366de072
4 changed files with 27 additions and 23 deletions

View File

@@ -5,8 +5,6 @@ import (
"math"
"time"
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/model/dao"
@@ -140,7 +138,7 @@ func (s *DefScheduler) CreateWaybillOnProviders4SavedOrder(ctx *jxcontext.Contex
deliveryFeeMap, _ := s.QueryOrderWaybillFeeInfoEx(ctx, order.VendorOrderID, order.VendorID)
// 运费相等为0或支出大于收入不做
isEqual, isZero, _ := partner.CurStoreAcctManager.CheckStoreAcctExpendExist(order.VendorOrderID)
// 收最贵的一个订单配送费
// 收最贵的一个订单配送费(配送费发送变化,收取最贵的价格)
if !isZero && !isEqual {
var newPrice int64
if len(courierVendorIDs) == 1 {
@@ -249,7 +247,16 @@ func (s *DefScheduler) CheckStoreBalance(ctx *jxcontext.Context, order *model.Go
//京西后台则是点一下发3个len courierVendorIDs 是0
//如果是小程序上点哪个扣哪个平台的钱
//如果是后台,则选最高的那个扣
storeAcct, err := cms.GetStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order)) // 0.0
//storeAcct, err := cms.GetStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order)) // 0.0
// 如果门店没钱,查看品牌查询门店品牌id
storeList, err := dao.GetStoreList(dao.GetDB(), []int{order.JxStoreID}, nil, nil, nil, nil, "")
if err != nil || len(storeList) != 1 {
return "", fmt.Errorf("门店id:[%d],所属品牌不唯一,或其他查询错误", order.JxStoreID)
}
result, err := dao.GetBrandBalance(dao.GetDB(), storeList[0].BrandID)
if err != nil {
return "", err
}
deliveryFeeMap, _ := s.QueryOrderWaybillFeeInfoEx(ctx, order.VendorOrderID, order.VendorID)
if err != nil {
return errCode, fmt.Errorf("获取账户余额失败!")
@@ -280,24 +287,21 @@ func (s *DefScheduler) CheckStoreBalance(ctx *jxcontext.Context, order *model.Go
}
_, lastFee, _ := partner.CurStoreAcctManager.GetStoreAcctExpendLastCreateWayBillFee(order.VendorOrderID)
if int(newPrice) > lastFee {
if storeAcct.AccountBalance < int(newPrice)-lastFee {
if result < int(newPrice)-lastFee {
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("门店账户余额小于[%v]元,不能发配送!", jxutils.IntPrice2Standard(newPrice-int64(lastFee)))
}
}
} else {
if storeAcct.AccountBalance < partner.MinCreateWaybillBalance {
//// 如果门店没钱,查看品牌
//if storeAcct.AccountBalance == 0 {
// // 查询门店品牌id
// dao.GetStoreList(dao.GetDB(), []int{order.JxStoreID}, nil, nil, nil, nil, "")
// dao.GetBrandBalance(dao.GetDB(),brandId)
//}
//if storeAcct.AccountBalance < partner.MinCreateWaybillBalance {
if result < partner.MinCreateWaybillBalance { // 门店品牌账户余额
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("门店账户余额小于[%v]元,不能发配送!", jxutils.IntPrice2Standard(partner.MinCreateWaybillBalance))
}
//}
if len(courierVendorIDs) == 1 {
courierVendorID := courierVendorIDs[0]
if _, ok := deliveryFeeMap[courierVendorID]; ok {
if deliveryFeeMap[courierVendorID].DeliveryFee > int64(storeAcct.AccountBalance) {
//if deliveryFeeMap[courierVendorID].DeliveryFee > int64(storeAcct.AccountBalance) {
if deliveryFeeMap[courierVendorID].DeliveryFee > int64(result) {
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("门店账户余额小于[%v]元,不能发配送!", jxutils.IntPrice2Standard(deliveryFeeMap[courierVendorID].DeliveryFee))
}
}
@@ -308,7 +312,7 @@ func (s *DefScheduler) CheckStoreBalance(ctx *jxcontext.Context, order *model.Go
v.DeliveryFee = maxFee
}
}
if maxFee > int64(storeAcct.AccountBalance) {
if maxFee > int64(result) {
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("门店账户余额小于[%v]元,不能发配送!", jxutils.IntPrice2Standard(maxFee))
}
}