修改门店发单配送费

This commit is contained in:
邹宗楠
2022-04-07 18:38:11 +08:00
parent 167f2b357e
commit 91dc8e6210

View File

@@ -4,6 +4,8 @@ import (
"fmt"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler"
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch"
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"git.rosy.net.cn/jx-callback/business/model"
@@ -171,7 +173,30 @@ func (c *BaseScheduler) CreateWaybill(platformVendorID int, order *model.GoodsOr
// }
storeDetail, _ := dao.GetStoreDetail(dao.GetDB(), jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, order.VendorOrgCode)
balance, _ := partner.CurStoreAcctManager.GetBrandBalance(storeDetail.BrandID)
// 获取门店品牌余额
storeAcct, err := cms.GetStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order)) // 获取门店余额
// 如果门店没钱,查看品牌查询门店品牌id
storeList, err := dao.GetStoreList(dao.GetDB(), []int{jxutils.GetSaleStoreIDFromOrder(order)}, nil, nil, nil, nil, "")
if err != nil || len(storeList) != 1 {
return nil, fmt.Errorf("门店id:[%d],所属品牌不唯一,或其他查询错误", order.JxStoreID)
}
result, err := dao.GetBrandBalance(dao.GetDB(), storeList[0].BrandID) // 品牌余额
if err != nil {
return nil, err
}
var balance int
if storeList[0].BrandID == defsch.JXC4B_SHOP || storeList[0].BrandID == defsch.JXC4B_RAND_JXGY { // 京西品牌,扣门店
balance = storeAcct.AccountBalance
} else {
if storeAcct.AccountBalance >= model.BrandBalanceLimit {
balance = storeAcct.AccountBalance
} else if storeAcct.AccountBalance < model.BrandBalanceLimit && result >= model.BrandBalanceLimit {
balance = result
} else {
balance = result
}
}
//balance, _ = partner.CurStoreAcctManager.GetBrandBalance(storeDetail.BrandID)
handlerInfo := partner.GetDeliveryPlatformFromVendorID(platformVendorID)
if handlerInfo != nil && handlerInfo.Use4CreateWaybill {
if model.DeliveryBrandMarkMap[platformVendorID]&storeDetail.BrandIsOpen != 0 && balance >= model.BrandBalanceLimit {
@@ -186,7 +211,7 @@ func (c *BaseScheduler) CreateWaybill(platformVendorID int, order *model.GoodsOr
}
}
} else {
err = fmt.Errorf("CreateWaybill failed brand is close orderID: %s, isOpen: %d", order.VendorOrderID, storeDetail.BrandIsOpen)
err = fmt.Errorf("CreateWaybill failed brand is close orderID: %s, isOpen: %d or store/brand money is enought ", order.VendorOrderID, storeDetail.BrandIsOpen)
}
} else {
err = scheduler.ErrDeliverProviderWrong