From beef260fe1c8329769c98103e8efa61da3d92d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 2 Nov 2023 15:51:40 +0800 Subject: [PATCH 01/21] 1 --- business/jxcallback/scheduler/basesch/basesch.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/business/jxcallback/scheduler/basesch/basesch.go b/business/jxcallback/scheduler/basesch/basesch.go index 31fb0718e..f9c20fbdc 100644 --- a/business/jxcallback/scheduler/basesch/basesch.go +++ b/business/jxcallback/scheduler/basesch/basesch.go @@ -141,7 +141,7 @@ func (c *BaseScheduler) SelfDeliverDelivering(order *model.GoodsOrder, userName } else if order.VendorID == model.VendorIDDD { //抖音配送 localBill, _ := partner.CurOrderManager.LoadWaybill(order.VendorWaybillID, order.WaybillVendorID) // 获取抖音配送状态 - tiktokWayBillStatus, _ := partner.GetPurchasePlatformFromVendorID(order.VendorID).OrderLogisticsStatus(order.VendorOrderID) + 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+"抖音骑手已经接单,无法取消") @@ -151,7 +151,10 @@ func (c *BaseScheduler) SelfDeliverDelivering(order *model.GoodsOrder, userName if err := partner.GetPurchaseOrderHandlerFromVendorID(order.VendorID).SelfDeliverDelivering(order, userName); err != nil { partner.CurOrderManager.OnOrderMsg(order, "抖音转自送,平台无运力", "tiktokWayBillStatus = -1") } + } else if err2 != nil && strings.Contains(err.Error(), "当前状态获取不到运力信息") { + 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 { partner.CurOrderManager.OnOrderMsg(order, "取消抖音平台运单错误,无法转自送", err.Error()) return err From 7d65cc5a4646efa9e7d331669c27e7df44920216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 2 Nov 2023 16:52:19 +0800 Subject: [PATCH 02/21] 1 --- business/partner/purchase/mtwm/store_sku2.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/business/partner/purchase/mtwm/store_sku2.go b/business/partner/purchase/mtwm/store_sku2.go index 44c24e46e..4517abd83 100644 --- a/business/partner/purchase/mtwm/store_sku2.go +++ b/business/partner/purchase/mtwm/store_sku2.go @@ -2,6 +2,7 @@ package mtwm import ( "encoding/json" + "fmt" "regexp" "strings" @@ -392,6 +393,25 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI if storeSku.DescImg != "" { foodData["picture_contents"] = storeSku.DescImg } + // 周期性可售时间段 + saleStart := utils.Int2Str(int(storeSku.StatusSaleBegin)) + saleEnd := utils.Int2Str(int(storeSku.StatusSaleEnd)) + for { + if len(saleStart) != 4 { + saleStart = "0" + saleStart + } + if len(saleEnd) != 4 { + saleEnd += "0" + saleEnd + } + if len(saleEnd) == 4 && len(saleStart) == 4 { + break + } + } + saleStart = fmt.Sprintf("%s:%s", saleStart[:2], saleStart[2:]) + saleEnd = fmt.Sprintf("%s:%s", saleEnd[:2], saleEnd[2:]) + availableTimes := fmt.Sprintf("%s-%s", saleStart, saleEnd) + foodData["available_times"] = fmt.Sprintf(`{"monday":%s, "tuesday":%s, "wednesday":%s, "thursday":%s, "friday":%s, "saturday":%s, "sunday":%s}`, availableTimes, availableTimes, availableTimes, availableTimes, availableTimes, availableTimes, availableTimes) + foodData["sequence"] = storeSku.GetSeq() if storeSku.VendorVendorCatID != 0 { foodData["tag_id"] = utils.Int64ToStr(storeSku.VendorVendorCatID) From 0a89f42340d03ee32c8f282a63172641ddfc4c19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 2 Nov 2023 16:57:36 +0800 Subject: [PATCH 03/21] 1 --- business/partner/purchase/mtwm/store_sku2.go | 1 + 1 file changed, 1 insertion(+) diff --git a/business/partner/purchase/mtwm/store_sku2.go b/business/partner/purchase/mtwm/store_sku2.go index 4517abd83..c8783622e 100644 --- a/business/partner/purchase/mtwm/store_sku2.go +++ b/business/partner/purchase/mtwm/store_sku2.go @@ -439,6 +439,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } } + globals.SugarLogger.Debugf("============================%s", utils.Format4Output(foodDataList, false)) if globals.EnableMtwmStoreWrite { if len(foodDataList) == 1 { foodDataList[0]["skus"] = string(utils.MustMarshal(foodDataList[0]["skus"])) From c78184830b942f8a6a0e972f3fbea07981200dea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 2 Nov 2023 17:02:33 +0800 Subject: [PATCH 04/21] 1 --- business/partner/purchase/mtwm/store_sku2.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/business/partner/purchase/mtwm/store_sku2.go b/business/partner/purchase/mtwm/store_sku2.go index c8783622e..0aebc6cdb 100644 --- a/business/partner/purchase/mtwm/store_sku2.go +++ b/business/partner/purchase/mtwm/store_sku2.go @@ -410,7 +410,8 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI saleStart = fmt.Sprintf("%s:%s", saleStart[:2], saleStart[2:]) saleEnd = fmt.Sprintf("%s:%s", saleEnd[:2], saleEnd[2:]) availableTimes := fmt.Sprintf("%s-%s", saleStart, saleEnd) - foodData["available_times"] = fmt.Sprintf(`{"monday":%s, "tuesday":%s, "wednesday":%s, "thursday":%s, "friday":%s, "saturday":%s, "sunday":%s}`, availableTimes, availableTimes, availableTimes, availableTimes, availableTimes, availableTimes, availableTimes) + available, _ := json.Marshal(map[string]string{"monday": availableTimes, "tuesday": availableTimes, "wednesday": availableTimes, "thursday": availableTimes, "friday": availableTimes, "saturday": availableTimes, "sunday": availableTimes}) + foodData["available_times"] = string(available) foodData["sequence"] = storeSku.GetSeq() if storeSku.VendorVendorCatID != 0 { From 20695782fa9d567934702f0a51f07713a13ba567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 2 Nov 2023 17:20:37 +0800 Subject: [PATCH 05/21] 1 --- business/partner/purchase/mtwm/store_sku2.go | 36 +++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/business/partner/purchase/mtwm/store_sku2.go b/business/partner/purchase/mtwm/store_sku2.go index 0aebc6cdb..408aed0ed 100644 --- a/business/partner/purchase/mtwm/store_sku2.go +++ b/business/partner/purchase/mtwm/store_sku2.go @@ -394,25 +394,27 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI foodData["picture_contents"] = storeSku.DescImg } // 周期性可售时间段 - saleStart := utils.Int2Str(int(storeSku.StatusSaleBegin)) - saleEnd := utils.Int2Str(int(storeSku.StatusSaleEnd)) - for { - if len(saleStart) != 4 { - saleStart = "0" + saleStart + if storeSku.StatusSaleBegin != model.NO && storeSku.StatusSaleEnd != model.NO { + saleStart := utils.Int2Str(int(storeSku.StatusSaleBegin)) + saleEnd := utils.Int2Str(int(storeSku.StatusSaleEnd)) + for { + if len(saleStart) != 4 { + saleStart = "0" + saleStart + } + if len(saleEnd) != 4 { + saleEnd += "0" + saleEnd + } + if len(saleEnd) == 4 && len(saleStart) == 4 { + break + } } - if len(saleEnd) != 4 { - saleEnd += "0" + saleEnd - } - if len(saleEnd) == 4 && len(saleStart) == 4 { - break - } - } - saleStart = fmt.Sprintf("%s:%s", saleStart[:2], saleStart[2:]) - saleEnd = fmt.Sprintf("%s:%s", saleEnd[:2], saleEnd[2:]) - availableTimes := fmt.Sprintf("%s-%s", saleStart, saleEnd) - available, _ := json.Marshal(map[string]string{"monday": availableTimes, "tuesday": availableTimes, "wednesday": availableTimes, "thursday": availableTimes, "friday": availableTimes, "saturday": availableTimes, "sunday": availableTimes}) - foodData["available_times"] = string(available) + saleStart = fmt.Sprintf("%s:%s", saleStart[:2], saleStart[2:]) + saleEnd = fmt.Sprintf("%s:%s", saleEnd[:2], saleEnd[2:]) + availableTimes := fmt.Sprintf("%s-%s", saleStart, saleEnd) + available, _ := json.Marshal(map[string]string{"monday": availableTimes, "tuesday": availableTimes, "wednesday": availableTimes, "thursday": availableTimes, "friday": availableTimes, "saturday": availableTimes, "sunday": availableTimes}) + foodData["available_times"] = string(available) + } foodData["sequence"] = storeSku.GetSeq() if storeSku.VendorVendorCatID != 0 { foodData["tag_id"] = utils.Int64ToStr(storeSku.VendorVendorCatID) From dc18a543004166c1ccf83edcc40bdc8118c6412f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 2 Nov 2023 17:38:51 +0800 Subject: [PATCH 06/21] 1 --- business/partner/purchase/tao_vegetable/order_afs.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/business/partner/purchase/tao_vegetable/order_afs.go b/business/partner/purchase/tao_vegetable/order_afs.go index 03ecfc6ff..c46261b03 100644 --- a/business/partner/purchase/tao_vegetable/order_afs.go +++ b/business/partner/purchase/tao_vegetable/order_afs.go @@ -386,6 +386,15 @@ func (c *PurchaseHandler) onAfsOrderMsg(status string, msg interface{}) (retVal goodsOrder.VendorStatus = orderStatus.VendorStatus dao.UpdateEntity(db, goodsOrder, "Status", "VendorStatus") // 取消三方运单 + 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, "订单被取消了") + if err != nil { + partner.CurOrderManager.OnOrderMsg(goodsOrder, fmt.Sprintf("订单[%s]被取消了,运单[%s]取消失败Err: %s", goodsOrder.VendorOrderID, v.VendorWaybillID, err.Error()), "") + } else { + partner.CurOrderManager.OnOrderMsg(goodsOrder, fmt.Sprintf("订单[%s]被取消了,运单[%s]取消成功", goodsOrder.VendorOrderID, v.VendorWaybillID), "") + } + } } } From 2f6678654889a76dd80da2d75cac06374c24b388 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 3 Nov 2023 10:01:45 +0800 Subject: [PATCH 07/21] 1 --- business/jxcallback/scheduler/basesch/basesch.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxcallback/scheduler/basesch/basesch.go b/business/jxcallback/scheduler/basesch/basesch.go index f9c20fbdc..d6b224a1b 100644 --- a/business/jxcallback/scheduler/basesch/basesch.go +++ b/business/jxcallback/scheduler/basesch/basesch.go @@ -151,7 +151,7 @@ func (c *BaseScheduler) SelfDeliverDelivering(order *model.GoodsOrder, userName if err := partner.GetPurchaseOrderHandlerFromVendorID(order.VendorID).SelfDeliverDelivering(order, userName); err != nil { partner.CurOrderManager.OnOrderMsg(order, "抖音转自送,平台无运力", "tiktokWayBillStatus = -1") } - } else if err2 != nil && strings.Contains(err.Error(), "当前状态获取不到运力信息") { + } else if err2 != nil && strings.Contains(err.Error(), "当前状态获取不到运力信息") || tiktokWayBillStatus.LogisticsStatus == tiktokShop.ShipmentStatusCanceled { 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()) From 0d913b49a334c2d8d7c0b4b3ee5021e2e4b77807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 3 Nov 2023 18:49:10 +0800 Subject: [PATCH 08/21] 1 --- business/partner/purchase/mtwm/order.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/business/partner/purchase/mtwm/order.go b/business/partner/purchase/mtwm/order.go index 2ac73a2da..7905cd66f 100644 --- a/business/partner/purchase/mtwm/order.go +++ b/business/partner/purchase/mtwm/order.go @@ -3,6 +3,8 @@ package mtwm import ( "errors" "fmt" + "git.rosy.net.cn/baseapi/platformapi/dingdingapi" + "git.rosy.net.cn/jx-callback/business/jxutils/ddmsg" "math" "net/url" "regexp" @@ -503,8 +505,10 @@ func (c *PurchaseHandler) postFakeMsg(vendorOrderID, cmd, vendorStatus string) { func (c *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptIt bool, userName string) (err error) { if isAcceptIt { if globals.EnableMtwmStoreWrite { - // err = api.MtwmAPI.OrderReceived(utils.Str2Int64(order.VendorOrderID)) err = getAPI(order.VendorOrgCode, jxutils.GetSaleStoreIDFromOrder(order), "").OrderConfirm(utils.Str2Int64(order.VendorOrderID)) + if err != nil { + ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", fmt.Sprintf("美团拣货异常:%s,%d", order.VendorOrderID, order.JxStoreID), err.Error()) + } if err != nil { if utils.IsErrMatch(err, utils.Int2Str(mtwmapi.ErrCodeOpFailed), []string{ "订单已经确认过了", @@ -515,9 +519,6 @@ func (c *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptI } } } - // if err == nil { - // c.postFakeMsg(order.VendorOrderID, FakeMsgType, mtwmapi.OrderStatusReceived) - // } } else { if globals.EnableMtwmStoreWrite { err = c.CancelOrder(jxcontext.AdminCtx, order, "bu") From 42f2f96f4b0ebc2fd03351585a0420d2b2534f22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 3 Nov 2023 18:54:48 +0800 Subject: [PATCH 09/21] 1 --- business/partner/purchase/mtwm/order.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/partner/purchase/mtwm/order.go b/business/partner/purchase/mtwm/order.go index 7905cd66f..6ceca0765 100644 --- a/business/partner/purchase/mtwm/order.go +++ b/business/partner/purchase/mtwm/order.go @@ -507,7 +507,7 @@ func (c *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptI if globals.EnableMtwmStoreWrite { err = getAPI(order.VendorOrgCode, jxutils.GetSaleStoreIDFromOrder(order), "").OrderConfirm(utils.Str2Int64(order.VendorOrderID)) if err != nil { - ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", fmt.Sprintf("美团拣货异常:%s,%d", order.VendorOrderID, order.JxStoreID), err.Error()) + ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "111", fmt.Sprintf("美团拣货异常:%s,%d :", order.VendorOrderID, order.JxStoreID)+err.Error()) } if err != nil { if utils.IsErrMatch(err, utils.Int2Str(mtwmapi.ErrCodeOpFailed), []string{ From 2f4c474a05abfb714ec92c8171308c1dea7c7482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Sun, 5 Nov 2023 08:34:16 +0800 Subject: [PATCH 10/21] 1 --- business/partner/purchase/mtwm/order.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/business/partner/purchase/mtwm/order.go b/business/partner/purchase/mtwm/order.go index 6ceca0765..0bca9a9e2 100644 --- a/business/partner/purchase/mtwm/order.go +++ b/business/partner/purchase/mtwm/order.go @@ -3,8 +3,6 @@ package mtwm import ( "errors" "fmt" - "git.rosy.net.cn/baseapi/platformapi/dingdingapi" - "git.rosy.net.cn/jx-callback/business/jxutils/ddmsg" "math" "net/url" "regexp" @@ -506,9 +504,6 @@ func (c *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptI if isAcceptIt { if globals.EnableMtwmStoreWrite { err = getAPI(order.VendorOrgCode, jxutils.GetSaleStoreIDFromOrder(order), "").OrderConfirm(utils.Str2Int64(order.VendorOrderID)) - if err != nil { - ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "111", fmt.Sprintf("美团拣货异常:%s,%d :", order.VendorOrderID, order.JxStoreID)+err.Error()) - } if err != nil { if utils.IsErrMatch(err, utils.Int2Str(mtwmapi.ErrCodeOpFailed), []string{ "订单已经确认过了", From 04672d141bac6d612c7fda21434054d7e82660e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 6 Nov 2023 09:29:15 +0800 Subject: [PATCH 11/21] 1 --- business/partner/purchase/tiktok_store/waybill.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/business/partner/purchase/tiktok_store/waybill.go b/business/partner/purchase/tiktok_store/waybill.go index ab7592b04..4427900fa 100644 --- a/business/partner/purchase/tiktok_store/waybill.go +++ b/business/partner/purchase/tiktok_store/waybill.go @@ -59,6 +59,13 @@ func (c *PurchaseHandler) onWaybillMsg(tag, orderId string, data interface{}) *t }, } err = partner.CurOrderManager.OnOrderStatusChanged(localOrder.VendorOrgCode, status) + if err != nil { + partner.CurOrderManager.OnOrderMsg(localOrder, "", "抖店运单骑手状态修改异常:"+err.Error()) + } + if status.VendorStatus == utils.Int2Str(tiktok_api.ShipmentStatusCanceled) { + localOrder.Status = model.WaybillStatusCourierArrived + dao.UpdateEntity(dao.GetDB(), localOrder, "Status") + } } return tiktok_api.Err2CallbackResponse(err, "") } From 7ce4acafcf287b80cf2ac060b7e2aebdf4dc1032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 6 Nov 2023 11:08:45 +0800 Subject: [PATCH 12/21] 1 --- business/jxstore/misc/misc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 7df0aa3fd..43082461e 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -272,7 +272,7 @@ func Init() { ScheduleTimerFuncByInterval(func() { curDate := utils.Time2Date(time.Now()) orderman.FixedOrderManager.AmendMissingOrders(jxcontext.AdminCtx, []int{model.VendorIDJD, model.VendorIDMTWM, model.VendorIDEBAI, model.VendorIDDD}, 0, curDate, curDate, true, true) - }, 5*time.Second, 10*time.Minute) + }, 5*time.Second, 5*time.Minute) // 抖音更新门店商品 ,接口收费暂不使用 //if beego.BConfig.RunMode != "jxgy" { From 2713997e37a2ae47c4db93346cf159b66ad0eeff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 8 Nov 2023 11:50:09 +0800 Subject: [PATCH 13/21] 1 --- business/partner/purchase/tao_vegetable/order_afs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/partner/purchase/tao_vegetable/order_afs.go b/business/partner/purchase/tao_vegetable/order_afs.go index c46261b03..a359e8505 100644 --- a/business/partner/purchase/tao_vegetable/order_afs.go +++ b/business/partner/purchase/tao_vegetable/order_afs.go @@ -521,7 +521,7 @@ func (c *PurchaseHandler) AgreeOrRefuseRefund(ctx *jxcontext.Context, order *mod for _, v := range afsSkuOrder { subRefundList = append(subRefundList, domain3156.AlibabaTclsAelophyRefundAgreeSubrefundlist{ OutSubOrderId: utils.String2Pointer(v.VendorSubOrderID), - RefundFee: utils.Int64ToPointer(v.UserMoney), + RefundFee: utils.Int64ToPointer(v.UserMoney / int64(v.Count)), }) } From a76269a4e9b54e328bff931404a16db27009bf63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 8 Nov 2023 15:14:39 +0800 Subject: [PATCH 14/21] 1 --- .../partner/purchase/tiktok_store/waybill.go | 65 +++++++++++-------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/business/partner/purchase/tiktok_store/waybill.go b/business/partner/purchase/tiktok_store/waybill.go index 4427900fa..a9a6ec786 100644 --- a/business/partner/purchase/tiktok_store/waybill.go +++ b/business/partner/purchase/tiktok_store/waybill.go @@ -39,37 +39,46 @@ func (p *PurchaseHandler) GetWaybillStatusFromVendorStatus(vendorStatus string) func (c *PurchaseHandler) onWaybillMsg(tag, orderId string, data interface{}) *tiktok_api.CallbackResponse { waybill := c.callbackMsg2Waybill(tag, orderId, data) - if localOrder, err := partner.CurOrderManager.LoadOrder(waybill.VendorOrderID, model.VendorIDDD); err == nil { - err := partner.CurOrderManager.OnWaybillStatusChanged(waybill) - if err == nil { - status := &model.OrderStatus{ - VendorOrderID: waybill.VendorOrderID, - VendorID: model.VendorIDDD, - OrderType: model.OrderTypeWaybill, - RefVendorOrderID: waybill.VendorOrderID, - RefVendorID: model.VendorIDDD, - Status: waybill.Status, - VendorStatus: waybill.VendorStatus, - StatusTime: time.Now(), - DuplicatedCount: 0, - Remark: "", - ModelTimeInfo: model.ModelTimeInfo{ - CreatedAt: time.Now(), - UpdatedAt: time.Now(), - }, - } - err = partner.CurOrderManager.OnOrderStatusChanged(localOrder.VendorOrgCode, status) - if err != nil { - partner.CurOrderManager.OnOrderMsg(localOrder, "", "抖店运单骑手状态修改异常:"+err.Error()) - } - if status.VendorStatus == utils.Int2Str(tiktok_api.ShipmentStatusCanceled) { - localOrder.Status = model.WaybillStatusCourierArrived - dao.UpdateEntity(dao.GetDB(), localOrder, "Status") + localOrder, _ := partner.CurOrderManager.LoadOrder(waybill.VendorOrderID, model.VendorIDDD) + // 当前订单的运力状态发生变化时,抖店侧会对open侧推送消息。当前运力状态变化的原因有两个来源:1:呼叫平台运力,平台运力有变化,此时会推送消息;2:商家自配,erp通过回传配送状态触发运力状态变化,此时也会推送消息 + // 问题:当前两种消息来源是没有区分的,都是统一发送消息,但erp侧针对不同的情况有特殊处理,因此需要区分这两种消息 + // 当本地记录骑手数据(非抖音平台运单)与当前运单匹配上是,就直接返回 + if waybill.CourierName != "" && waybill.CourierMobile != "" { + localWaybill, _ := dao.GetWaybills(dao.GetDB(), localOrder.VendorOrderID, nil) + for _, v := range localWaybill { + if v.CourierName != "" && v.CourierMobile != "" && v.WaybillVendorID != model.VendorIDDD && v.CourierName == waybill.CourierName && v.CourierMobile == waybill.CourierMobile { + return tiktok_api.Err2CallbackResponse(nil, "") } } - return tiktok_api.Err2CallbackResponse(err, "") } - return tiktok_api.Err2CallbackResponse(nil, "") + err := partner.CurOrderManager.OnWaybillStatusChanged(waybill) + if err == nil { + status := &model.OrderStatus{ + VendorOrderID: waybill.VendorOrderID, + VendorID: model.VendorIDDD, + OrderType: model.OrderTypeWaybill, + RefVendorOrderID: waybill.VendorOrderID, + RefVendorID: model.VendorIDDD, + Status: waybill.Status, + VendorStatus: waybill.VendorStatus, + StatusTime: time.Now(), + DuplicatedCount: 0, + Remark: "", + ModelTimeInfo: model.ModelTimeInfo{ + CreatedAt: time.Now(), + UpdatedAt: time.Now(), + }, + } + err = partner.CurOrderManager.OnOrderStatusChanged(localOrder.VendorOrgCode, status) + if err != nil { + partner.CurOrderManager.OnOrderMsg(localOrder, "", "抖店运单骑手状态修改异常:"+err.Error()) + } + if status.VendorStatus == utils.Int2Str(tiktok_api.ShipmentStatusCanceled) { + localOrder.Status = model.WaybillStatusCourierArrived + dao.UpdateEntity(dao.GetDB(), localOrder, "Status") + } + } + return tiktok_api.Err2CallbackResponse(err, "") } func (c *PurchaseHandler) callbackMsg2Waybill(tag, orderId string, data interface{}) (retVal *model.Waybill) { From 78882a474953e82f0b759a2ca12a9861fa34d29b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 9 Nov 2023 16:11:02 +0800 Subject: [PATCH 15/21] 1 --- business/jxcallback/orderman/order.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index f8a4bca26..ef57cfdd1 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -182,7 +182,7 @@ func (c *OrderManager) OnOrderStatusChanged(vendorOrgCode string, orderStatus *m c.OnOrderNew(order, orderStatus) } } - } else if loadOrder.Status < model.OrderStatusAccepted { + } else if loadOrder.Status < model.OrderStatusAccepted && loadOrder.VendorID == model.VendorIDTaoVegetable { loadOrder.Status = model.OrderStatusAccepted loadOrder.VendorStatus = tao_vegetable.OrderStatusNew c.UpdateOrderFields(loadOrder, []string{"Status", "VendorStatus"}) From a703fb0fcd4e36a968508ff3ae52801b2c008b4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 9 Nov 2023 16:15:29 +0800 Subject: [PATCH 16/21] 1 --- business/jxcallback/orderman/order.go | 1 + 1 file changed, 1 insertion(+) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index ef57cfdd1..2d21f676e 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -189,6 +189,7 @@ func (c *OrderManager) OnOrderStatusChanged(vendorOrgCode string, orderStatus *m } } + globals.SugarLogger.Debugf("==========orderStatus := %s", utils.Format4Output(orderStatus, false)) isDuplicated, order, err := c.addOrderStatus(orderStatus, db) if err == nil { dao.Commit(db, txDB) From 1b1289231a877572c9fdc1e44875b08f5812f3b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 9 Nov 2023 16:29:09 +0800 Subject: [PATCH 17/21] 1 --- business/partner/purchase/mtwm/order.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/partner/purchase/mtwm/order.go b/business/partner/purchase/mtwm/order.go index 0bca9a9e2..1b9e52e04 100644 --- a/business/partner/purchase/mtwm/order.go +++ b/business/partner/purchase/mtwm/order.go @@ -345,7 +345,7 @@ func (c *PurchaseHandler) onOrderMsg(msg *mtwmapi.CallbackMsg) (response *mtwmap return response } else { status := c.callbackMsg2Status(msg) - if partner.CurOrderManager.GetStatusDuplicatedCount(status) > 0 { + if partner.CurOrderManager.GetStatusDuplicatedCount(status) > 1 { // 重复消息推送校验,允许推送两次 return nil } if msg.Cmd == mtwmapi.MsgTypeNewOrder { From f697f6a6ff6a3273cbe8bf5600634012edd0c218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 9 Nov 2023 16:29:38 +0800 Subject: [PATCH 18/21] 1 --- business/jxcallback/orderman/order.go | 1 - 1 file changed, 1 deletion(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index 2d21f676e..ef57cfdd1 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -189,7 +189,6 @@ func (c *OrderManager) OnOrderStatusChanged(vendorOrgCode string, orderStatus *m } } - globals.SugarLogger.Debugf("==========orderStatus := %s", utils.Format4Output(orderStatus, false)) isDuplicated, order, err := c.addOrderStatus(orderStatus, db) if err == nil { dao.Commit(db, txDB) From 0a3cb8b526b2e579977a399e588c081f545d1659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 10 Nov 2023 08:58:42 +0800 Subject: [PATCH 19/21] 1 --- business/jxcallback/scheduler/basesch/basesch.go | 2 +- business/jxstore/cms/store.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/business/jxcallback/scheduler/basesch/basesch.go b/business/jxcallback/scheduler/basesch/basesch.go index d6b224a1b..f99d9a9a5 100644 --- a/business/jxcallback/scheduler/basesch/basesch.go +++ b/business/jxcallback/scheduler/basesch/basesch.go @@ -151,7 +151,7 @@ func (c *BaseScheduler) SelfDeliverDelivering(order *model.GoodsOrder, userName if err := partner.GetPurchaseOrderHandlerFromVendorID(order.VendorID).SelfDeliverDelivering(order, userName); err != nil { partner.CurOrderManager.OnOrderMsg(order, "抖音转自送,平台无运力", "tiktokWayBillStatus = -1") } - } else if err2 != nil && strings.Contains(err.Error(), "当前状态获取不到运力信息") || tiktokWayBillStatus.LogisticsStatus == tiktokShop.ShipmentStatusCanceled { + } else if (err2 != nil && strings.Contains(err.Error(), "当前状态获取不到运力信息")) || (tiktokWayBillStatus != nil && tiktokWayBillStatus.LogisticsStatus == tiktokShop.ShipmentStatusCanceled) { 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()) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 441976f06..c55760a5a 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -949,6 +949,11 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa valid["name"] = jxutils.FormalizeName(valid["name"].(string)) store.Name = valid["name"].(string) syncStatus |= model.SyncFlagStoreName + courierList, _ := dao.GetStoreCourierList2(db, []int{storeID}, nil, 0, nil) + for _, v := range courierList { + v.VendorStoreName = store.Name + dao.UpdateEntity(db, v, "VendorStoreName") + } } printerVendorID := int(utils.Interface2Int64WithDefault(valid["printerVendorID"], 0)) if printerVendorID == 0 { @@ -1143,7 +1148,7 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa TryAddStoreBossRole4StoreByMobile(ctx, store.ID, []string{utils.Interface2String(valid["tel1"]), utils.Interface2String(valid["tel2"])}) } if syncStatus&model.SyncFlagStoreAddress != 0 || valid["tel1"] != nil || valid["payeeName"] != nil { - // 修改门店信息(第三方平台同步) + // 修改门店信息(第三方配送平台同步) updateCourierStores(ctx, storeID) } } From c9866522f1867d188872d1082ed71f76524a631f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 10 Nov 2023 09:02:39 +0800 Subject: [PATCH 20/21] 1 --- business/jxcallback/scheduler/basesch/basesch.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxcallback/scheduler/basesch/basesch.go b/business/jxcallback/scheduler/basesch/basesch.go index f99d9a9a5..7228e5887 100644 --- a/business/jxcallback/scheduler/basesch/basesch.go +++ b/business/jxcallback/scheduler/basesch/basesch.go @@ -151,7 +151,7 @@ func (c *BaseScheduler) SelfDeliverDelivering(order *model.GoodsOrder, userName if err := partner.GetPurchaseOrderHandlerFromVendorID(order.VendorID).SelfDeliverDelivering(order, userName); err != nil { partner.CurOrderManager.OnOrderMsg(order, "抖音转自送,平台无运力", "tiktokWayBillStatus = -1") } - } else if (err2 != nil && strings.Contains(err.Error(), "当前状态获取不到运力信息")) || (tiktokWayBillStatus != nil && tiktokWayBillStatus.LogisticsStatus == tiktokShop.ShipmentStatusCanceled) { + } else if (err2 != nil && strings.Contains(err2.Error(), "当前状态获取不到运力信息")) || (tiktokWayBillStatus != nil && tiktokWayBillStatus.LogisticsStatus == tiktokShop.ShipmentStatusCanceled) { 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()) From 382c45297a7a496724d256e8f1a7d6de1d962fd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 10 Nov 2023 10:58:24 +0800 Subject: [PATCH 21/21] 1 --- business/jxstore/misc/misc.go | 2 +- business/partner/purchase/mtwm/store_sku2.go | 1 - business/partner/purchase/tiktok_store/order.go | 17 +++++++++++++---- .../purchase/tiktok_store/order_afs_utils.go | 12 +++++++++++- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 43082461e..2e16a79b2 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -195,7 +195,7 @@ func Init() { orderman.UpdateTiktokShopTotalMoney() }, []string{ "03:35:00", - "16:35:00", + "11:05:00", }) /// 更新淘鲜达结算信息 ScheduleTimerFunc("UpdateTaoTotalMoney", func() { diff --git a/business/partner/purchase/mtwm/store_sku2.go b/business/partner/purchase/mtwm/store_sku2.go index 408aed0ed..504ecce37 100644 --- a/business/partner/purchase/mtwm/store_sku2.go +++ b/business/partner/purchase/mtwm/store_sku2.go @@ -442,7 +442,6 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI } } - globals.SugarLogger.Debugf("============================%s", utils.Format4Output(foodDataList, false)) if globals.EnableMtwmStoreWrite { if len(foodDataList) == 1 { foodDataList[0]["skus"] = string(utils.MustMarshal(foodDataList[0]["skus"])) diff --git a/business/partner/purchase/tiktok_store/order.go b/business/partner/purchase/tiktok_store/order.go index b3c3c32e6..ff46b3dff 100644 --- a/business/partner/purchase/tiktok_store/order.go +++ b/business/partner/purchase/tiktok_store/order.go @@ -242,9 +242,10 @@ func (p *PurchaseHandler) getOrder(vendorOrgCode, vendorOrderID, vendorStoreID s // GetOrderRider 商家自配送同步配送信息 func (p *PurchaseHandler) GetOrderRider(vendorOrgCode, vendorStoreID string, param map[string]interface{}) (err error) { - appKey := `7152420904331429407` // 暂时定死 - appSecret := `cc7ba367-2394-4cbb-81c6-26f0e929d1c6` //暂时定死 - return tiktokShop.NewExpress(appKey, appSecret, "").OrderStatusAndPsInfoNew(param) + //appKey := `7152420904331429407` // 暂时定死 + //appSecret := `cc7ba367-2394-4cbb-81c6-26f0e929d1c6` //暂时定死 + //return tiktokShop.NewExpress(appKey, appSecret, "").OrderStatusAndPsInfoNew(param) + return getAPI(vendorOrgCode, 0, vendorStoreID).OrderStatusAndPsInfoNew(param) } func (p *PurchaseHandler) GetOrder(vendorOrgCode, vendorOrderID, vendorStoreID string) (order *model.GoodsOrder, err error) { @@ -653,13 +654,21 @@ func (c *PurchaseHandler) SelfDeliverDelivered(order *model.GoodsOrder, userName ThirdCarrierOrderId: order.VendorOrderID, CourierName: "", CourierPhone: "", - LogisticsProviderCode: "10002", + LogisticsProviderCode: utils.MyselfPsCode, LogisticsStatus: 0, LogisticsContext: "商家自配送,已送达", Latitude: "", Longitude: "", OpCode: tiktokShop.TiktokLogisticsDELIVERED, } + bills, _ := dao.GetWaybills(dao.GetDB(), order.VendorOrderID, nil) + for _, v := range bills { + if v.Status == model.OrderStatusCanceled { + continue + } + riderInfo.CourierName = v.CourierName + riderInfo.CourierPhone = v.CourierMobile + } return c.GetOrderRider("", "", utils.Struct2MapByJson(riderInfo)) } diff --git a/business/partner/purchase/tiktok_store/order_afs_utils.go b/business/partner/purchase/tiktok_store/order_afs_utils.go index 554600739..e3be092a0 100644 --- a/business/partner/purchase/tiktok_store/order_afs_utils.go +++ b/business/partner/purchase/tiktok_store/order_afs_utils.go @@ -124,7 +124,7 @@ func (c *PurchaseHandler) onAfsOrderMsg(msgId string, msg interface{}) (retVal * } } else { if err2 := partner.CurOrderManager.OnAfsOrderStatusChanged(orderStatus); err2 == nil { - if msgId == tiktokShop.CallbackRefundOrderSuccessMsgTagId { + if msgId == tiktokShop.CallbackRefundOrderSuccessMsgTagId || msgId == tiktokShop.CallbackReturnRefundAgreedMsgTagId { skuList, _ := dao.GetSimpleOrderSkus(db, orderStatus.RefVendorOrderID, nil) totalSkuCount := 0 for _, v := range skuList { @@ -142,6 +142,16 @@ func (c *PurchaseHandler) onAfsOrderMsg(msgId string, msg interface{}) (retVal * goodsOrder.VendorStatus = orderStatus.VendorStatus dao.UpdateEntity(db, goodsOrder, "Status", "VendorStatus") // 取消三方运单 + wayBill, _ := dao.GetWaybills(db, orderStatus.RefVendorOrderID, nil) + 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 { + partner.CurOrderManager.OnOrderMsg(goodsOrder, "", fmt.Sprintf("抖店订单取消时,取消运单异常:%s", err.Error())) + } + } + } + } } }