- CreateWaybillOnProviders4SavedOrder及CreateWaybillOnProviders添加excludeCourierVendorIDs参数

This commit is contained in:
gazebo
2019-07-31 20:05:23 +08:00
parent a69c591f6c
commit 758f44b439
3 changed files with 18 additions and 14 deletions

View File

@@ -13,23 +13,19 @@ import (
"git.rosy.net.cn/jx-callback/globals"
)
func (c *BaseScheduler) CreateWaybillOnProviders(ctx *jxcontext.Context, order *model.GoodsOrder, courierVendorIDs []int, policyHandler partner.CreateWaybillPolicyFunc, createOnlyOne bool) (bills []*model.Waybill, err error) {
func (c *BaseScheduler) CreateWaybillOnProviders(ctx *jxcontext.Context, order *model.GoodsOrder, courierVendorIDs, excludeCourierVendorIDs []int, policyHandler partner.CreateWaybillPolicyFunc, createOnlyOne bool) (bills []*model.Waybill, err error) {
userName := ctx.GetUserName()
globals.SugarLogger.Infof("CreateWaybillOnProviders orderID:%s userName:%s", order.VendorOrderID, userName)
storeCourierList, err := dao.GetStoreCourierList(dao.GetDB(), jxutils.GetSaleStoreIDFromOrder(order), model.StoreStatusOpened)
if err != nil {
return nil, err
}
var courierVendorIDMap map[int]bool
if len(courierVendorIDs) > 0 {
courierVendorIDMap = make(map[int]bool)
for _, courierVendorID := range courierVendorIDs {
courierVendorIDMap[courierVendorID] = true
}
}
courierVendorIDMap := jxutils.IntList2Map(courierVendorIDs)
excludeCourierVendorIDMap := jxutils.IntList2Map(excludeCourierVendorIDs)
var errList []string
for _, storeCourier := range storeCourierList {
if courierVendorIDMap == nil || courierVendorIDMap[storeCourier.VendorID] {
if (courierVendorIDMap == nil || courierVendorIDMap[storeCourier.VendorID] == 1) &&
(excludeCourierVendorIDMap == nil || excludeCourierVendorIDMap[storeCourier.VendorID] == 0) {
if handler := partner.GetDeliveryPlatformFromVendorID(storeCourier.VendorID); handler != nil && handler.Use4CreateWaybill {
courierVendorID := storeCourier.VendorID
if order.VendorID != model.VendorIDWSC || courierVendorID != model.VendorIDDada { // 达达作为微商城的自有配送,不参与配送竞争
@@ -51,7 +47,7 @@ func (c *BaseScheduler) CreateWaybillOnProviders(ctx *jxcontext.Context, order *
if len(bills) > 0 {
err = nil
} else if len(errList) == 0 {
err = fmt.Errorf("orderID:%s没有绑定有效的三方配送门店", order.VendorOrderID)
err = fmt.Errorf("orderID:%s没有绑定有效的三方配送门店或没有剩下可用的三方配送", order.VendorOrderID)
} else {
err = fmt.Errorf("orderID:%s所有运单失败\n%s", order.VendorOrderID, utils.Format4Output(errList, false))
}