Merge branch 'jdshop' of https://e.coding.net/rosydev/jx-callback into jdshop

This commit is contained in:
richboo111
2024-02-18 10:28:12 +08:00
20 changed files with 143 additions and 73 deletions

View File

@@ -263,7 +263,7 @@ func (c *OrderManager) OnOrderStatusChanged(vendorOrgCode string, orderStatus *m
if orderStatus.OrderType == model.OrderTypeOrder {
waybill, _ := dao.GetWaybills(db, order2.VendorOrderID, []int64{model.VendorIDMTPS, model.VendorIDDada, model.VendorIDFengNiao, model.VendorIDUUPT, model.VendorIDSFPS})
for _, v := range waybill {
if err := partner.GetDeliveryPlatformFromVendorID(v.WaybillVendorID).Handler.CancelWaybill(v, 0, "订单被取消了"); err != nil {
if err := partner.GetDeliveryPlatformFromVendorID(v.WaybillVendorID).Handler.CancelWaybill(v, 0, "订单被取消了1"); err != nil {
partner.CurOrderManager.OnOrderMsg(order2, fmt.Sprintf("订单[%s]被取消了,运单[%s]取消失败Err: %s", order.VendorOrderID, v.VendorWaybillID, err.Error()), "")
} else {
partner.CurOrderManager.OnOrderMsg(order2, fmt.Sprintf("订单[%s]被取消了,运单[%s]取消成功", order.VendorOrderID, v.VendorWaybillID), "")
@@ -1529,7 +1529,7 @@ func MergeJdsOrders(ctx *jxcontext.Context, vendorOrderIDs []string) (vendorOrde
if waybill != nil {
if waybill.WaybillVendorID != model.VendorIDJDWL {
if handler := partner.GetDeliveryPlatformFromVendorID(waybill.WaybillVendorID); handler != nil {
err = handler.Handler.CancelWaybill(waybill, 0, "订单合并被取消")
err = handler.Handler.CancelWaybill(waybill, 0, "订单合并被取消2")
}
}
}
@@ -1661,7 +1661,7 @@ func TransferJdsOrder(ctx *jxcontext.Context, vendorOrderID string, storeID int)
}
if waybill != nil {
if handler := partner.GetDeliveryPlatformFromVendorID(waybill.WaybillVendorID); handler != nil {
err = handler.Handler.CancelWaybill(waybill, 0, "订单转移被取消")
err = handler.Handler.CancelWaybill(waybill, 0, "订单转移被取消3")
}
}
}
@@ -1841,7 +1841,7 @@ func SendJdwlForJdsOrder(ctx *jxcontext.Context, vendorOrderID string) (err erro
}
}
if handler := partner.GetDeliveryPlatformFromVendorID(model.VendorIDJDWL); handler != nil {
err = handler.Handler.CancelWaybill(waybill, 0, "订单已发送其他物流")
err = handler.Handler.CancelWaybill(waybill, 0, "订单已发送其他物流4")
}
if err != nil {
return err

View File

@@ -134,7 +134,7 @@ func (c *BaseScheduler) SelfDeliverDelivering(order *model.GoodsOrder, userName
err = nil
} else {
bill, _ := partner.CurOrderManager.LoadWaybill(order.VendorWaybillID, order.WaybillVendorID)
err = c.CancelWaybill(bill, partner.CancelWaybillReasonOther, userName+":"+partner.CancelWaybillReasonStrActive)
err = c.CancelWaybill(bill, partner.CancelWaybillReasonOther, userName+":5"+partner.CancelWaybillReasonStrActive)
partner.CurOrderManager.OnOrderMsg(order, "美团外卖运单无法取消,", err.Error())
return err
}
@@ -144,7 +144,7 @@ func (c *BaseScheduler) SelfDeliverDelivering(order *model.GoodsOrder, userName
tiktokWayBillStatus, err2 := partner.GetPurchasePlatformFromVendorID(order.VendorID).OrderLogisticsStatus(order.VendorOrderID)
if tiktokWayBillStatus != nil && tiktokWayBillStatus.LogisticsStatus >= tiktokShop.ShipmentStatusReceived && tiktokWayBillStatus.LogisticsStatus != tiktokShop.ShipmentStatusCanceled {
//取消抖音配送转自送
err = c.CancelWaybill(localBill, partner.CancelWaybillReasonDYPSCancel, partner.CancelWaybillReasonStrDYPSCancel+"抖音骑手已经接单,无法取消")
err = c.CancelWaybill(localBill, partner.CancelWaybillReasonDYPSCancel, partner.CancelWaybillReasonStrDYPSCancel+"抖音骑手已经接单,无法取消6")
partner.CurOrderManager.OnOrderMsg(order, "取消抖音配送,转用门店自配送/三方配送", "抖音骑手已经接单,无法取消")
return err
} else if tiktokWayBillStatus != nil && tiktokWayBillStatus.LogisticsStatus == -1 { // 先转自送,自送不成功取消平台配送.
@@ -155,7 +155,7 @@ func (c *BaseScheduler) SelfDeliverDelivering(order *model.GoodsOrder, userName
partner.GetPurchasePlatformFromVendorID(order.VendorID).SelfDeliverDelivering(order, "")
} else if err = partner.GetPurchasePlatformFromVendorID(order.VendorID).CancelLogisticsByWmOrderId(order, "", "", order.VendorStoreID, order.VendorOrderID); err != nil {
partner.CurOrderManager.OnOrderMsg(order, "取消抖音配送异常:", err.Error())
if err = c.CancelWaybill(localBill, partner.CancelWaybillReasonDYPSCancel, partner.CancelWaybillReasonStrDYPSCancel); err != nil {
if err = c.CancelWaybill(localBill, partner.CancelWaybillReasonDYPSCancel, partner.CancelWaybillReasonStrDYPSCancel+"7"); err != nil {
partner.CurOrderManager.OnOrderMsg(order, "取消抖音平台运单错误,无法转自送", err.Error())
return err
}
@@ -192,7 +192,7 @@ func (c *BaseScheduler) SelfDeliverDelivered(order *model.GoodsOrder, userName s
if err = partner.GetPurchaseOrderHandlerFromVendorID(order.VendorID).SelfDeliverDelivered(order, userName); err == nil {
bill, _ := partner.CurOrderManager.LoadWaybill(order.VendorWaybillID, order.WaybillVendorID)
if bill != nil && bill.WaybillVendorID != model.VendorJXFakeWL && bill.WaybillVendorID != model.VendorIDUnknown {
c.CancelWaybill(bill, partner.CancelWaybillReasonOther, userName+":"+partner.CancelWaybillReasonStrActive)
c.CancelWaybill(bill, partner.CancelWaybillReasonOther, userName+":"+partner.CancelWaybillReasonStrActive+"8")
}
}
return err
@@ -235,7 +235,9 @@ func (c *BaseScheduler) CreateWaybill(platformVendorID int, order *model.GoodsOr
if storeDetail.IsService == model.YES && order.VendorID == model.VendorIDMTWM {
err = fmt.Errorf("京西ID:[%d],平台id[%s],平台[美团]:错误:[%s]", storeDetail.Store.ID, storeDetail.VendorStoreID, "此门店美团平台为服务商模式,不支持本系统提供的三方配送![仅美团,其余平台订单正常使用.]")
} else {
if order.VendorID == model.VendorIDEBAI && strings.Contains(order.ConsigneeAddress, EBaiOrderAddressHide) {
return nil, fmt.Errorf("由于饿了么用户数据隐私保护,发三方配送前请先将订单转为自配送,获取详情地址")
}
// 生成三方运单
bill, err = handlerInfo.Handler.CreateWaybill(order, maxDeliveryFee)
if err != nil {
@@ -261,7 +263,7 @@ func (c *BaseScheduler) CancelWaybill(bill *model.Waybill, cancelReasonID int, c
if c.IsReallyCallPlatformAPI && bill.OrderVendorID != bill.WaybillVendorID && bill.Status != model.WaybillStatusCanceled {
if handlerInfo := partner.GetDeliveryPlatformFromVendorID(bill.WaybillVendorID); handlerInfo != nil {
if err = utils.CallFuncLogErrorWithInfo(func() error {
if err := handlerInfo.Handler.CancelWaybill(bill, cancelReasonID, cancelReason); err != nil {
if err := handlerInfo.Handler.CancelWaybill(bill, cancelReasonID, cancelReason+"9"); err != nil {
return err
}
return nil

View File

@@ -26,6 +26,10 @@ const (
autoSelfTakeCode = "135246"
)
const (
EBaiOrderAddressHide = "[隐私保护]顾客地址已隐藏"
)
func (c *BaseScheduler) CreateWaybillOnProviders(ctx *jxcontext.Context, order *model.GoodsOrder, courierVendorIDs, excludeCourierVendorIDs []int, maxDeliveryFee int64, createOnlyOne bool) (bills []*model.Waybill, err error) {
storeCourierList, err := dao.GetStoreCourierList2(dao.GetDB(), []int{jxutils.GetSaleStoreIDFromOrder(order)}, courierVendorIDs, model.StoreStatusOpened, []int{model.StoreAuditStatusOnline, model.StoreAuditStatusUpdated})
if err != nil {
@@ -220,7 +224,7 @@ func (c *BaseScheduler) CancelWaybillByID(ctx *jxcontext.Context, vendorWaybillI
return err
}
order, _ := partner.CurOrderManager.LoadOrder(bill.VendorOrderID, bill.OrderVendorID)
partner.CurOrderManager.OnOrderMsg(order, utils.Int64ToStr(model.WaybillStatusCancel), "商户发起运单取消")
partner.CurOrderManager.OnOrderMsg(order, utils.Int64ToStr(model.WaybillStatusCancel), "商户发起运单取消10")
return err
}
@@ -260,7 +264,7 @@ func (c *BaseScheduler) AgreeOrRefuseRefund(ctx *jxcontext.Context, afsOrderID s
order.DeliveryFlag |= model.OrderDeliveryFlagMaskScheduleDisabled
partner.CurOrderManager.UpdateOrderFields(order, []string{"DeliveryFlag"})
for _, v := range waybills {
c.CancelWaybill(v, partner.CancelWaybillReasonOther, ctx.GetUserName()+":"+partner.CancelWaybillReasonStrActive)
c.CancelWaybill(v, partner.CancelWaybillReasonOther, ctx.GetUserName()+":11"+partner.CancelWaybillReasonStrActive)
}
}
if afsCount == orderCount && order.VendorID == model.VendorIDJX {
@@ -275,7 +279,7 @@ func (c *BaseScheduler) AgreeOrRefuseRefund(ctx *jxcontext.Context, afsOrderID s
order.VendorStatus = "10" // 饿百取消订单
partner.CurOrderManager.UpdateOrderFields(order, []string{"DeliveryFlag", "Status", "VendorStatus"})
for _, v := range waybills {
c.CancelWaybill(v, partner.CancelWaybillReasonOther, ctx.GetUserName()+":"+partner.CancelWaybillReasonStrActive)
c.CancelWaybill(v, partner.CancelWaybillReasonOther, ctx.GetUserName()+":12"+partner.CancelWaybillReasonStrActive)
}
}

View File

@@ -450,7 +450,7 @@ func (s *DefScheduler) OnOrderStatusChanged(order *model.GoodsOrder, status *mod
}
}
}
s.cancelOtherWaybills(savedOrderInfo, curWaybill, partner.CancelWaybillReasonOther, partner.CancelWaybillReasonStrOrderAlreadyFinished)
s.cancelOtherWaybills(savedOrderInfo, curWaybill, partner.CancelWaybillReasonOther, partner.CancelWaybillReasonStrOrderAlreadyFinished+"13")
if status.Status >= model.OrderStatusEndBegin {
s.orderMap.Delete(jxutils.GetUniversalOrderIDFromOrderStatus(status))
}
@@ -518,10 +518,10 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
// 将订单冲购物平台转自送(混合送转自送)
s.swtich2SelfDeliverWithRetry(savedOrderInfo, bill, switch2SelfDeliverRetryCount, switch2SelfDeliverRetryGap)
} else {
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime+"14")
}
} else if order.Status > model.OrderStatusEndBegin {
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime) // 取消三方配送调度
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime+"15") // 取消三方配送调度
s.SelfDeliverDelivering(order, "自配送中")
s.swtich2SelfDeliverWithRetry(savedOrderInfo, bill, switch2SelfDeliverRetryCount, switch2SelfDeliverRetryGap) // 转自送
s.SelfDeliverDelivered(order, "自送或三方") // 取消当前运单调度
@@ -533,7 +533,7 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
if !model.IsOrderHaveOwnWaybill(order) { // 既有运单不是购物平台运单
oldBill := savedOrderInfo.waybills[order.WaybillVendorID]
if oldBill != nil {
s.ProxyCancelWaybill(order, oldBill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
s.ProxyCancelWaybill(order, oldBill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime+"16")
} else {
globals.SugarLogger.Warnf("OnWaybillStatusChanged bill:%v, oldBill is null, strange!!!", bill)
}
@@ -544,7 +544,7 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
}
} else {
needAddTip = false
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime+"20")
}
}
if needAddTip {
@@ -586,7 +586,7 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
s.updateOrderByBill(order, nil, true)
}
} else if model.IsOrderHaveWaybill(order) {
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime+"21")
if !isPending {
globals.SugarLogger.Warnf("OnWaybillStatusChanged AcceptCanceled orderID:%s got multiple bill:%v, order details:%v", order.VendorOrderID, bill, order)
}
@@ -646,13 +646,15 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
s.SelfDeliverDelivering(order, "自配送中")
s.swtich2SelfDeliverWithRetry(savedOrderInfo, bill, switch2SelfDeliverRetryCount, switch2SelfDeliverRetryGap) // 转自送
} else {
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
if order.VendorWaybillID != bill.VendorWaybillID {
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime+"22")
}
}
}
//订单已经是结束状态之后来的运单143945553920000001
if order.Status > model.OrderStatusEndBegin {
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime+"23")
s.SelfDeliverDelivering(order, "自配送中")
s.swtich2SelfDeliverWithRetry(savedOrderInfo, bill, switch2SelfDeliverRetryCount, switch2SelfDeliverRetryGap) // 转自送
s.SelfDeliverDelivered(order, "自配送结束") // 取消当前运单调度
@@ -680,7 +682,7 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
}
} else if !s.isBillCandidate(order, bill) && bill.WaybillVendorID != order.VendorID {
// 发生这种情况的原因就是两个接单事件几乎同时到达(来不及取消),也算正常
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime+"24")
}
if isBillAlreadyCandidate && !s.isWaybillCourierSame(savedOrderInfo, bill) && !model.IsWaybillPlatformOwn(bill) {
s.notify3rdPartyWaybill(order, bill, isBillAlreadyCandidate)
@@ -701,7 +703,7 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
s.updateOrderByBill(order, nil, true)
}
} else if model.IsOrderHaveWaybill(order) {
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime+"25")
if !isPending {
globals.SugarLogger.Warnf("OnWaybillStatusChanged AcceptCanceled orderID:%s got multiple bill:%v, order details:%v", order.VendorOrderID, bill, order)
}
@@ -1084,7 +1086,7 @@ func (s *DefScheduler) swtich2SelfDeliverWithRetry(savedOrderInfo *WatchOrderInf
//partner.CurOrderManager.UpdateOrderFields(order, []string{"DeliveryFlag"})
//partner.CurOrderManager.OnOrderMsg(order, "饿了么专送平台门店,无法切自送,需要平台推送配送异常才能转自送!", err.Error())
} else {
if s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonSwitch2SelfFailed, partner.CancelWaybillReasonStrSwitch2SelfFailed) == nil {
if s.ProxyCancelWaybill(order, bill, partner.CancelWaybillReasonSwitch2SelfFailed, partner.CancelWaybillReasonStrSwitch2SelfFailed+"26") == nil {
// 转自送失败的取消,要将订单中的运单状态更新
if s.isBillCandidate(order, bill) {
s.updateOrderByBill(order, nil, false)
@@ -1099,7 +1101,11 @@ func (s *DefScheduler) swtich2SelfDeliverWithRetry(savedOrderInfo *WatchOrderInf
} else {
s.notify3rdPartyWaybill(order, bill, false)
s.removeWaybillFromMap(savedOrderInfo, order.VendorID)
partner.CurOrderManager.OnOrderMsg(order, "转自送成功", "")
data := "断点打印"
if err != nil {
data = err.Error()
}
partner.CurOrderManager.OnOrderMsg(order, "转自送成功", data)
}
} else {
s.cancelOtherWaybills(savedOrderInfo, nil, partner.CancelWaybillReasonOther, partner.CancelWaybillReasonStrNotAcceptIntime)

View File

@@ -33,7 +33,7 @@ func (s *DefScheduler) SelfDeliveringAndUpdateStatus(ctx *jxcontext.Context, ven
if savedOrderInfo != nil {
order = savedOrderInfo.order
if err = s.isPossibleSwitch2SelfDelivery(order); err == nil { // 是否能转自送
err = s.cancelOtherWaybillsCheckOrderDeliveryFlag(savedOrderInfo, nil, partner.CancelWaybillReasonOther, ctx.GetUserName()+""+partner.CancelWaybillReasonStrActive)
err = s.cancelOtherWaybillsCheckOrderDeliveryFlag(savedOrderInfo, nil, partner.CancelWaybillReasonOther, ctx.GetUserName()+"17"+partner.CancelWaybillReasonStrActive)
if err == nil {
if model.IsOrderDeliveryByStore(order) {
if order.Status < model.OrderStatusDelivering {
@@ -298,7 +298,6 @@ func (s *DefScheduler) CreateWaybillOnProvidersEx(ctx *jxcontext.Context, vendor
excludeCourierVendorIDs = append(excludeCourierVendorIDs, k)
}
globals.SugarLogger.Debugf("===excludeCourierVendorIDs===========:%s", utils.Format4Output(excludeCourierVendorIDs, false))
billFunc := func() {
bills, err = func() (bills []*model.Waybill, err error) {
if vendorID == model.VendorIDELM {
@@ -451,7 +450,7 @@ func (s *DefScheduler) CancelAll3rdWaybills(ctx *jxcontext.Context, vendorOrderI
// 取消三方运单,取消各平台单号信息,间隔一段时间后定时任务重新调度
savedOrderInfo := s.loadSavedOrderByID(vendorOrderID, vendorID, true)
if savedOrderInfo != nil {
err = s.cancelOtherWaybills(savedOrderInfo, nil, partner.CancelWaybillReasonOther, ctx.GetUserName()+":"+partner.CancelWaybillReasonStrActive)
err = s.cancelOtherWaybills(savedOrderInfo, nil, partner.CancelWaybillReasonOther, ctx.GetUserName()+":18"+partner.CancelWaybillReasonStrActive)
} else {
err = scheduler.ErrCanNotFindOrder
}

View File

@@ -1140,6 +1140,7 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
kv[model.FieldStatus] = status
//}
}
globals.SugarLogger.Debugf("data := %s,%d", utils.Format4Output(kv, false), store.ID)
_, err2 := dao.UpdateEntityLogicallyAndUpdateSyncStatus(db, dummy, kv, userName, map[string]interface{}{
model.FieldStoreID: store.ID,
}, model.FieldSyncStatus, syncStatus)
@@ -1848,11 +1849,8 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
if err != nil || storeDetail == nil {
return 0, fmt.Errorf("基础门店信息异常,请联系管理员")
}
if storeDetail != nil && payload["address"] != nil && payload["address"].(string) != storeDetail.Address {
// // 修改门店地址
// storeDetail.Address = payload["address"].(string)
// dao.UpdateEntity(db, storeDetail, "Address")
// // 添加同步
if storeDetail != nil && payload["address"] != nil {
// 添加同步
valid["address"] = payload["address"].(string)
syncStatus |= model.SyncFlagStoreName
address = payload["address"].(string)
@@ -1922,6 +1920,8 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor
valid["address"] = address
}
globals.SugarLogger.Debugf("=valid============ : %s", utils.Format4Output(valid, false))
globals.SugarLogger.Debugf("=valid============ : %s", utils.Format4Output(isUpdateStoreNeedSync(valid), false))
if isUpdateStoreNeedSync(valid) { // 同步修改门店已经配送门店
_, err = CurVendorSync.SyncStore(ctx, db, vendorID, storeID, false, userName) // address原来的userName 因为storeMap无法保存address,所以美团暂时使用该参数代替
//updateCourierStores(ctx, storeID)

View File

@@ -212,6 +212,7 @@ func CopyMtToMT(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail, isA
//}
case 2:
i := offSet
errList := make([]*mtwmapi.AppFoodResult, 0, 0)
for {
// 同步商品
fromFoodList, err1 := fromApi.RetailListAll(fromStore.VendorStoreID, i)
@@ -219,16 +220,20 @@ func CopyMtToMT(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail, isA
return nil, fmt.Errorf("fromFoodList 为空 %s ,i:= %d", utils.Format4Output(err1, false), i)
}
if err = BatchInitSkuMT2MT(ctx, fromFoodList, toApi, toStore.VendorStoreID, i); err != nil {
globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false))
errDataList, err := BatchInitSkuMT2MT(ctx, fromFoodList, toApi, toStore.VendorStoreID, i)
if err != nil {
globals.SugarLogger.Debugf("BatchInitData : %v", err)
}
if len(errDataList) > model.NO {
errList = append(errList, errDataList...)
}
globals.SugarLogger.Debugf("==============i: %d len: %d", i, len(fromFoodList))
if len(fromFoodList) < 100 {
return nil, nil
break
}
i++
}
globals.SugarLogger.Debugf("errListData := %s", utils.Format4Output(errList, false))
}
return
}
@@ -244,7 +249,7 @@ func CopyMtToMT(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail, isA
}
// BatchInitSkuMT2MT 批量创建商品
func BatchInitSkuMT2MT(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mtwmapi.API, vendorStoreID string, offset int) error {
func BatchInitSkuMT2MT(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mtwmapi.API, vendorStoreID string, offset int) (errList []*mtwmapi.AppFoodResult, err error) {
foodDataList := make([]map[string]interface{}, len(fromSku))
for k, storeSku := range fromSku {
foodData := make(map[string]interface{})
@@ -255,6 +260,7 @@ func BatchInitSkuMT2MT(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi
}
skus := make([]interface{}, 0)
upc := ""
for _, v := range storeSku.SkuList {
if v.SkuId == "" {
v.SkuId = storeSku.AppFoodCode
@@ -267,6 +273,9 @@ func BatchInitSkuMT2MT(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi
if v.BoxPrice == "" {
delete(mapSkuList, "box_price")
}
if v.Upc != "" {
upc = v.Upc
}
mapSkuList["available_times"] = string(salesCycle)
skus = append(skus, mapSkuList)
}
@@ -298,7 +307,10 @@ func BatchInitSkuMT2MT(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi
foodData["sequence"] = storeSku.Sequence
foodData["tag_id"] = storeSku.TagID
foodData["upc"] = storeSku.UpcCode
if storeSku.UpcCode == "" {
if foodData["upc"].(string) == "" {
foodData["upc"] = upc
}
if foodData["upc"].(string) == "" {
foodData["upc"] = "no_upc"
}
@@ -313,16 +325,16 @@ func BatchInitSkuMT2MT(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi
if i == count-1 {
failedFoodList, _ := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*10:])
if len(failedFoodList) != 0 {
globals.SugarLogger.Debugf("RetailBatchInitData2 failedFoodList :%s", utils.Format4Output(failedFoodList, false))
errList = append(errList, failedFoodList...)
}
} else {
failedFoodList, _ := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*10:(i+1)*10])
if len(failedFoodList) != 0 {
globals.SugarLogger.Debugf("RetailBatchInitData4 failedFoodList :%s", utils.Format4Output(failedFoodList, false))
errList = append(errList, failedFoodList...)
}
}
}
return nil
return errList, nil
}

View File

@@ -142,7 +142,10 @@ func UpdateEntityLogicallyAndUpdateSyncStatus(db *DaoDB, item interface{}, kvs m
if userName != "" {
params[model.FieldLastOperator] = userName
}
globals.SugarLogger.Debugf("=========MergeMaps := %s", utils.Format4Output(utils.MergeMaps(kvs, params), false))
num2, err2 := UpdateEntityByKV(db, value.Interface(), utils.MergeMaps(kvs, params), nil)
globals.SugarLogger.Debugf("=========num := %d", num2)
globals.SugarLogger.Debugf("=========err := %v", err2)
if err = err2; err == nil {
num += num2
} else {

View File

@@ -309,6 +309,7 @@ func (c *DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInf
}
deliveryFeeInfo.DeliveryFee = jxutils.StandardPrice2Int(result.DeliverFee) // jxutils.StandardPrice2Int(result.Fee)
deliveryFeeInfo.RefDeliveryFee = deliveryFeeInfo.DeliveryFee
deliveryFeeInfo.RefAddFee = deliveryFeeInfo.DeliveryFee
}
return deliveryFeeInfo, err
}

View File

@@ -293,7 +293,7 @@ func (d DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo
deliveryFeeInfo = &partner.WaybillFeeInfo{}
price, err := api.SfPsAPI.PreCreateOrder(param)
deliveryFeeInfo.DeliveryFee = utils.Float64TwoInt64(price)
globals.SugarLogger.Debugf("GetWaybillFee deliveryFeeInfo.DeliveryFee=%d", deliveryFeeInfo.DeliveryFee)
deliveryFeeInfo.RefAddFee = utils.Float64TwoInt64(price)
return deliveryFeeInfo, err
}

View File

@@ -203,7 +203,7 @@ func (d DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo
return nil, err
} else {
deliveryFeeInfo = &partner.WaybillFeeInfo{}
// deliveryFeeInfo.DeliveryFee = jxutils.StandardPrice2Int(utils.Str2Float64(orderPrice.NeedPayMoney)) 优惠后金额
deliveryFeeInfo.RefAddFee = jxutils.StandardPrice2Int(utils.Str2Float64(orderPrice.NeedPayMoney)) // 优惠后金额
deliveryFeeInfo.DeliveryFee = jxutils.StandardPrice2Int(utils.Str2Float64(orderPrice.TotalMoney)) // 原始金额
}
return deliveryFeeInfo, err

View File

@@ -477,9 +477,9 @@ func (c *PrinterHandler) getCancelOrRefundOrderContent(order *model.GoodsOrder,
title,
)
orderFmt += `<LEFT><font# bolder=1 height=2 width=1>共%d种%d件商品</font#></LEFT>
<LEFT><font# bolder=1 height=2 width=1>实付金额: %s</font#></LEFT>
<font# bolder=0 height=1 width=1>--------------#%d完-------------</font#>`
orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice), order.OrderSeq)
/*<LEFT><font# bolder=1 height=2 width=1>实付金额: %s</font#></LEFT>*/
orderParams = append(orderParams, order.SkuCount, order.GoodsCount /* jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice),*/, order.OrderSeq)
return fmt.Sprintf(orderFmt, orderParams...)
}
@@ -518,8 +518,8 @@ func (c *PrinterHandler) getCancelOrRefundOrderContentBig(order *model.GoodsOrde
)
orderFmt += xpyunapi.StrRepeat("-", 32)
orderFmt += `<LEFT><font# bolder=1 height=2 width=1>共%d种%d件商品</font#></LEFT>
<LEFT><font# bolder=1 height=2 width=1>实付金额: %s</font#></LEFT>
<font# bolder=0 height=1 width=1>--------------#%d完-------------</font#>`
orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice), order.OrderSeq)
/*<LEFT><font# bolder=1 height=2 width=1>实付金额: %s</font#></LEFT>*/
orderParams = append(orderParams, order.SkuCount, order.GoodsCount /*jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice),*/, order.OrderSeq)
return fmt.Sprintf(orderFmt, orderParams...)
}

View File

@@ -471,10 +471,10 @@ func (c *PrinterHandler) getCancelOrRefundOrderContent(order *model.GoodsOrder,
order.OrderSeq,
)
orderFmt += xpyunapi.StrRepeat("-", 32)
orderFmt += `<L>共%d种%d件商品</L>
实际支付:%s<BR>`
orderFmt += `<L>共%d种%d件商品</L>`
/*实际支付:%s<BR>`*/
orderFmt += xpyunapi.StrRepeat("-", 14) + "#%d完</HB>" + xpyunapi.StrRepeat("-", 14) + `<BR>`
orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice), order.OrderSeq)
orderParams = append(orderParams, order.SkuCount, order.GoodsCount /*jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice),*/, order.OrderSeq)
return fmt.Sprintf(orderFmt, orderParams...)
}
@@ -516,9 +516,9 @@ func (c *PrinterHandler) getCancelOrRefundOrderContentBig(order *model.GoodsOrde
order.OrderSeq,
)
orderFmt += xpyunapi.StrRepeat("-", 32)
orderFmt += `<L><HB>共%d种%d件商品</L>
实际支付:%s</HB><BR>`
orderFmt += `<L><HB>共%d种%d件商品</L>`
/*实际支付:%s</HB><BR>`*/
orderFmt += xpyunapi.StrRepeat("-", 14) + "#%d完</HB>" + xpyunapi.StrRepeat("-", 14) + `<BR>`
orderParams = append(orderParams, order.SkuCount, order.GoodsCount, jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice), order.OrderSeq)
orderParams = append(orderParams, order.SkuCount, order.GoodsCount /*jxutils.IntPrice2StandardCurrencyString(order.ActualPayPrice),*/, order.OrderSeq)
return fmt.Sprintf(orderFmt, orderParams...)
}

View File

@@ -1,6 +1,8 @@
package ebai
import (
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/globals"
"time"
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
@@ -65,6 +67,17 @@ func (c *PurchaseHandler) onWaybillMsg(msg *ebaiapi.CallbackMsg) (retVal *ebaiap
}
}
})
} else if order.VendorStatus == ebaiapi.WaybillStatusSelfDelivery {
result1, err1 := api.EbaiAPI.OrderGet(order.VendorOrderID)
if err1 == nil {
address := utils.Interface2String(result1["user"].(map[string]interface{})["address"])
localOrder, _ := partner.CurOrderManager.LoadOrder(order.VendorOrderID, model.VendorIDEBAI)
localOrder.ConsigneeAddress = address
dao.UpdateEntity(dao.GetDB(), localOrder, "ConsigneeAddress")
} else {
globals.SugarLogger.Debugf("饿了么转自送解密用户配送地址,查询平台订单时错误:%v", err1)
}
}
return api.EbaiAPI.Err2CallbackResponse(msg.Cmd, partner.CurOrderManager.OnWaybillStatusChanged(order), order.VendorStatus)
}

View File

@@ -182,7 +182,7 @@ func (c *PurchaseHandler) onAfsOrderMsg(msg *mtwmapi.CallbackMsg) (retVal *mtwma
for _, v := range wayBill {
handlerInfo := partner.GetDeliveryPlatformFromVendorID(v.WaybillVendorID)
if handlerInfo != nil {
handlerInfo.Handler.CancelWaybill(v, 0, "订单转移被取消")
handlerInfo.Handler.CancelWaybill(v, 0, "订单转移被取消10")
}
}
}

View File

@@ -230,6 +230,7 @@ func (p *PurchaseHandler) DeleteStore(db *dao.DaoDB, storeID int, userName strin
}
func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName string) (err error) {
globals.SugarLogger.Debugf("===========data : %s",utils.Format4Output(storeID,false))
if db == nil {
db = dao.GetDB()
}
@@ -280,6 +281,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
}
if globals.EnableMtwmStoreWrite {
globals.SugarLogger.Debugf("===========data : %s",utils.Format4Output(params,false))
errList.AddErr(mtapi.PoiSave(storeDetail.VendorStoreID, params))
}
if storeDetail.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreStatus) != 0 {

View File

@@ -401,7 +401,7 @@ func (c *PurchaseHandler) onAfsOrderMsg(status string, msg interface{}) (retVal
// 取消三方运单
waybill, _ := dao.GetWaybills(db, goodsOrder.VendorOrderID, []int64{model.VendorIDMTPS, model.VendorIDDada, model.VendorIDFengNiao, model.VendorIDUUPT, model.VendorIDSFPS})
for _, v := range waybill {
err = partner.GetDeliveryPlatformFromVendorID(v.WaybillVendorID).Handler.CancelWaybill(v, 0, "订单被取消了")
err = partner.GetDeliveryPlatformFromVendorID(v.WaybillVendorID).Handler.CancelWaybill(v, 0, "订单被取消了11")
if err != nil {
partner.CurOrderManager.OnOrderMsg(goodsOrder, fmt.Sprintf("订单[%s]被取消了,运单[%s]取消失败Err: %s", goodsOrder.VendorOrderID, v.VendorWaybillID, err.Error()), "")
} else {

View File

@@ -3,6 +3,7 @@ package tiktok_store
import (
"errors"
"fmt"
instantShopping_reportRiderLocation_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/instantShopping_reportRiderLocation/request"
"regexp"
"strings"
"time"
@@ -255,12 +256,42 @@ func (p *PurchaseHandler) GetOrderRider(vendorOrgCode, vendorStoreID string, par
param["longitude"] = utils.Float64ToStr(lng)
}
}
order, _ := partner.CurOrderManager.LoadOrder(param["order_id"].(string), model.VendorIDDD)
if vendorStoreID == "" {
order, _ := partner.CurOrderManager.LoadOrder(param["order_id"].(string), model.VendorIDDD)
vendorStoreID = order.VendorStoreID
}
return getAPI(vendorOrgCode, 0, vendorStoreID).OrderStatusAndPsInfoNew(param, vendorStoreID)
api := getAPI(vendorOrgCode, 0, vendorStoreID)
// 同步骑手状态
if err = api.OrderStatusAndPsInfoNew(param, vendorStoreID); err != nil {
partner.CurOrderManager.OnOrderMsg(order, param["opcode"].(string), "抖音订单三方配送状态信息回传记录异常:"+err.Error())
}
if err = SyncOrderRiderLine(vendorOrgCode, vendorStoreID, param); err != nil {
partner.CurOrderManager.OnOrderMsg(order, param["opcode"].(string), "抖音订单三方配送轨迹信息回传记录异常:"+err.Error())
}
return err
}
// SyncOrderRiderLine 同步骑手轨迹
func SyncOrderRiderLine(vendorOrgCode, vendorStoreID string, param map[string]interface{}) error {
// 同步骑手轨迹(其实状态和轨迹应该分开同步才对)
param2 := &instantShopping_reportRiderLocation_request.InstantShoppingReportRiderLocationParam{
ShopOrderId: param["order_id"].(string),
DistributionCode: tiktokShop.JxLogistics2Tiktok(param["logistics_provider_code"].(string)),
DistributionDeliveryId: param["order_id"].(string),
RiderName: param["courier_name"].(string),
RiderPhoneType: 0,
RiderPhone: param["courier_phone"].(string),
RiderLongitude: param["longitude"].(string),
RiderLatitude: param["latitude"].(string),
ReportTime: time.Now().Unix(),
}
if len(param["courier_phone"].(string)) > 11 {
param2.RiderPhoneType = 1
}
return getAPI(vendorOrgCode, 0, vendorStoreID).OrderStatusReportRiderLocation(param2)
}
func (p *PurchaseHandler) GetOrder(vendorOrgCode, vendorOrderID, vendorStoreID string) (order *model.GoodsOrder, err error) {
@@ -596,7 +627,7 @@ func (c *PurchaseHandler) Swtich2SelfDeliver(order *model.GoodsOrder, userName s
if remoteWaybill.Status >= tiktokShop.ShipmentStatusArrived && remoteWaybill.Status != tiktokShop.ShipmentStatusCanceled { //骑手取货后不可取消
return errors.New("抖音配送骑手已取货,不可转门店自配送/三方配送")
}
if remoteWaybill.Status < tiktokShop.ShipmentStatusArrived || remoteWaybill.Status == tiktokShop.ShipmentStatusCanceled { //存在运单
if remoteWaybill.Status < tiktokShop.ShipmentStatusArrived /*|| remoteWaybill.Status == tiktokShop.ShipmentStatusCanceled */ { //存在运单
if err := api.ShopOrderDispatcher(utils.Str2Int64(order.VendorStoreID), order.VendorOrderID, tiktokShop.DispatcherFeeTypeCancel); err != nil {
return err
}

View File

@@ -146,7 +146,7 @@ func (c *PurchaseHandler) onAfsOrderMsg(msgId string, msg interface{}) (retVal *
for _, v := range wayBill {
if v.Status != model.WaybillStatusCanceled {
if handlerInfo := partner.GetDeliveryPlatformFromVendorID(v.WaybillVendorID); handlerInfo != nil {
if err := handlerInfo.Handler.CancelWaybill(v, 0, "订单被取消了"); err != nil {
if err := handlerInfo.Handler.CancelWaybill(v, 0, "订单被取消了12"); err != nil {
partner.CurOrderManager.OnOrderMsg(goodsOrder, "", fmt.Sprintf("抖店订单取消时,取消运单异常:%s", err.Error()))
}
}

View File

@@ -231,19 +231,16 @@ func (c *TaoBaoVegetableController) CancelOnSaleRefundOrder() {
return
}
if order.Status < model.OrderStatusDelivering || order.Status == model.OrderStatusCanceled {
if order.Status == model.OrderStatusCanceled {
c.Data["json"] = tao_vegetable.CallBackResultOnSaleCancel(nil)
c.ServeJSON()
}
if order.Status >= model.OrderStatusDelivering {
c.Data["json"] = tao_vegetable.CallBackResultOnSaleCancel(fmt.Errorf("不支持售中取消"))
c.ServeJSON()
} else {
c.Data["json"] = tao_vegetable.CallBackResultOnSaleCancel(nil)
c.ServeJSON()
}
if order.Status == model.OrderStatusCanceled {
c.Data["json"] = tao_vegetable.CallBackResultOnSaleCancel(nil)
c.ServeJSON()
}
if order.Status >= model.OrderStatusDelivering {
c.Data["json"] = tao_vegetable.CallBackResultOnSaleCancel(fmt.Errorf("不支持售中取消"))
c.ServeJSON()
} else {
c.Data["json"] = tao_vegetable.CallBackResultOnSaleCancel(nil)
c.ServeJSON()
}
}
}