1
This commit is contained in:
@@ -204,22 +204,8 @@ func (c *BaseScheduler) CreateWaybill(platformVendorID int, order *model.GoodsOr
|
||||
if !model.IsOrderSolid(order) { // 如果订单是不完整的
|
||||
return nil, scheduler.ErrOrderIsNotSolid
|
||||
}
|
||||
// if order.DeliveryFlag&model.OrderDeliveryFlagMaskScheduleDisabled != 0 {
|
||||
// waybillList, err := partner.CurOrderManager.GetOrderWaybillInfo(jxcontext.AdminCtx, order.VendorOrderID, order.VendorID, true)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// if len(waybillList) > 0 {
|
||||
// return nil, fmt.Errorf("转商家自送的订单只允许有一个有效运单,当前已经有%s运单", jxutils.GetVendorName(waybillList[0].WaybillVendorID))
|
||||
// }
|
||||
// }
|
||||
|
||||
storeDetail, _ := dao.GetStoreDetail(dao.GetDB(), jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, order.VendorOrgCode)
|
||||
// 如果门店没钱,查看品牌,查询门店品牌id
|
||||
//result, err := partner.CurStoreAcctManager.GetBrandBalance(storeDetail.BrandID) // 品牌余额
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
var balance int
|
||||
|
||||
// 门店发单,如果是京西门店,直接使用京西余额,非京西门店使用门店余额,余额不足使用品牌余额!
|
||||
@@ -229,30 +215,19 @@ func (c *BaseScheduler) CreateWaybill(platformVendorID int, order *model.GoodsOr
|
||||
return nil, err
|
||||
}
|
||||
balance = storeAcct.AccountBalance
|
||||
//if storeDetail.BrandID == scheduler.JXC4B_SHOP || storeDetail.BrandID == scheduler.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 = 0
|
||||
// }
|
||||
//}
|
||||
} else {
|
||||
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 {
|
||||
if _, ok := model.DeliveryBrandMarkMap[platformVendorID]; ok && storeDetail.BrandIsOpen != 0 && balance >= model.BrandBalanceLimit {
|
||||
if c.IsReallyCallPlatformAPI {
|
||||
// 如果门店是美团服务商且订单为美团订单
|
||||
if storeDetail.IsService == model.YES && order.VendorID == model.VendorIDMTWM {
|
||||
err = fmt.Errorf("京西ID:[%d],平台id[%s],平台[美团]:错误:[%s]", storeDetail.Store.ID, storeDetail.VendorStoreID, "此门店美团平台为服务商模式,不支持本系统提供的三方配送![仅美团,其余平台订单正常使用.]")
|
||||
} else {
|
||||
|
||||
// 生成三方运单
|
||||
bill, err = handlerInfo.Handler.CreateWaybill(order, maxDeliveryFee)
|
||||
if err != nil {
|
||||
|
||||
@@ -36,23 +36,28 @@ func (c *BaseScheduler) CreateWaybillOnProviders(ctx *jxcontext.Context, order *
|
||||
errList := errlist.New()
|
||||
|
||||
for _, storeCourier := range storeCourierList {
|
||||
if (courierVendorIDs == nil || courierVendorIDMap[storeCourier.VendorID] == 1) &&
|
||||
(excludeCourierVendorIDs == nil || excludeCourierVendorIDMap[storeCourier.VendorID] == 0) {
|
||||
if handler := partner.GetDeliveryPlatformFromVendorID(storeCourier.VendorID); handler != nil && handler.Use4CreateWaybill {
|
||||
courierVendorID := storeCourier.VendorID
|
||||
// 创建运单
|
||||
bill, err2 := c.CreateWaybill(courierVendorID, order, maxDeliveryFee)
|
||||
if err = err2; err == nil {
|
||||
bill.DesiredFee += model.WayBillDeliveryMarkUp
|
||||
bill.ActualFee += model.WayBillDeliveryMarkUp
|
||||
bills = append(bills, bill)
|
||||
if createOnlyOne {
|
||||
break
|
||||
switch storeCourier.Status {
|
||||
case model.YES:
|
||||
if (courierVendorIDs == nil || courierVendorIDMap[storeCourier.VendorID] == 1) &&
|
||||
(excludeCourierVendorIDs == nil || excludeCourierVendorIDMap[storeCourier.VendorID] == 0) {
|
||||
if handler := partner.GetDeliveryPlatformFromVendorID(storeCourier.VendorID); handler != nil && handler.Use4CreateWaybill {
|
||||
courierVendorID := storeCourier.VendorID
|
||||
// 创建运单
|
||||
bill, err2 := c.CreateWaybill(courierVendorID, order, maxDeliveryFee)
|
||||
if err = err2; err == nil {
|
||||
bill.DesiredFee += model.WayBillDeliveryMarkUp
|
||||
bill.ActualFee += model.WayBillDeliveryMarkUp
|
||||
bills = append(bills, bill)
|
||||
if createOnlyOne {
|
||||
break
|
||||
}
|
||||
} else {
|
||||
errList.AddErr(fmt.Errorf("平台:%s,%s", jxutils.GetVendorName(courierVendorID), err.Error()))
|
||||
}
|
||||
} else {
|
||||
errList.AddErr(fmt.Errorf("平台:%s,%s", jxutils.GetVendorName(courierVendorID), err.Error()))
|
||||
}
|
||||
}
|
||||
case model.NO:
|
||||
errList.AddErr(fmt.Errorf("平台:%s,发单配送被关闭,打开后发单", jxutils.GetVendorName(storeCourier.VendorID)))
|
||||
}
|
||||
}
|
||||
if len(bills) > 0 {
|
||||
@@ -208,7 +213,8 @@ func (c *BaseScheduler) CancelWaybillByID(ctx *jxcontext.Context, vendorWaybillI
|
||||
if err := c.CancelWaybill(bill, cancelReasonID, cancelReason); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
order, _ := partner.CurOrderManager.LoadOrder(bill.VendorOrderID, bill.OrderVendorID)
|
||||
partner.CurOrderManager.OnOrderMsg(order, utils.Int64ToStr(model.WaybillStatusCancel), "商户发起运单取消")
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -1005,6 +1005,7 @@ func (s *DefScheduler) cancelOtherWaybills(savedOrderInfo *WatchOrderInfo, bill2
|
||||
if err2 == nil {
|
||||
// 在这里就从map里删除,而不是等收到运单结束事件才删除,可避免不必要的重复取消(第二次取消还会失败)
|
||||
s.removeWaybillFromMap(savedOrderInfo, v.WaybillVendorID)
|
||||
partner.CurOrderManager.OnOrderMsg(savedOrderInfo.order, utils.Int64ToStr(model.WaybillStatusCancel), "管理系统取消或自动取消")
|
||||
} else {
|
||||
// 至少返回一个错误
|
||||
if err == nil {
|
||||
|
||||
Reference in New Issue
Block a user