From 1c4828e4c7c2db06387379510c1b9043ce0c9af9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 21 Sep 2020 17:14:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=94=AE=E5=90=8E=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/order.go | 17 +++++----- .../jxcallback/scheduler/defsch/defsch_afs.go | 2 ++ business/jxutils/unipush/push.go | 33 ++++++++++++------- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index bfd914ce9..e9221b96a 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -1500,8 +1500,8 @@ func TransferJdsOrder(ctx *jxcontext.Context, vendorOrderID string, storeID int) if order.Status >= model.OrderStatusDelivering && order.Status != model.OrderStatusCanceled { return "", fmt.Errorf("暂不支持此状态的订单进行转移!") } - if order.VendorID != model.VendorIDJDShop { - return "", fmt.Errorf("暂不支持非京狗的订单进行转移!") + if order.VendorID != model.VendorIDJDShop || order.VendorID != model.VendorIDJX { + return "", fmt.Errorf("暂不支持该平台的订单进行转移!") } skus, err := dao.GetSimpleOrderSkus(db, vendorOrderID, nil) if err != nil || order == nil { @@ -1519,10 +1519,8 @@ func TransferJdsOrder(ctx *jxcontext.Context, vendorOrderID string, storeID int) } } if waybill != nil { - if waybill.WaybillVendorID != model.VendorIDJDWL { - if handler := partner.GetDeliveryPlatformFromVendorID(waybill.WaybillVendorID); handler != nil { - err = handler.Handler.CancelWaybill(waybill, 0, "订单转移被取消") - } + if handler := partner.GetDeliveryPlatformFromVendorID(waybill.WaybillVendorID); handler != nil { + err = handler.Handler.CancelWaybill(waybill, 0, "订单转移被取消") } } } @@ -1533,12 +1531,12 @@ func TransferJdsOrder(ctx *jxcontext.Context, vendorOrderID string, storeID int) //重新构建order的数据 storeMaps, err := dao.GetStoresMapList(db, []int{order.VendorID}, []int{storeID}, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "") if err != nil || len(storeMaps) == 0 { - return "", fmt.Errorf("该门店未绑定京狗平台,请先绑定后再转移!门店:[%v]", storeID) + return "", fmt.Errorf("该门店未绑定平台,请先绑定后再转移!门店:[%v]", storeID) } stores, err := dao.GetStoreList(db, []int{storeID}, nil, nil, nil, "") if len(storeMaps) > 0 && len(stores) > 0 { if storeMaps[0].VendorStoreID == "" { - return "", fmt.Errorf("该门店未绑定京狗平台,或绑定有误,请联系技术部!门店:[%v]", storeID) + return "", fmt.Errorf("该门店未绑定平台,或绑定有误,请联系技术部!门店:[%v]", storeID) } order.StoreID = storeID order.StoreName = stores[0].Name @@ -1558,6 +1556,9 @@ func TransferJdsOrder(ctx *jxcontext.Context, vendorOrderID string, storeID int) if store.OpenTime1 == 0 || store.CloseTime1 == 0 { return "", fmt.Errorf("该门店没有营业时间,不能接单!门店:[%v]", storeID) } + if opentime2.Sub(opentime1) <= time.Hour { + return "", fmt.Errorf("该门店营业时间间隔过小,请确认!门店:[%v]", storeID) + } if !(orderCreatedAt.Sub(opentime1) >= 0 && orderCreatedAt.Sub(closetime1) <= 0) { if store.OpenTime2 != 0 && store.CloseTime2 != 0 { if !(orderCreatedAt.Sub(opentime2) >= 0 && orderCreatedAt.Sub(closetime2) <= 0) { diff --git a/business/jxcallback/scheduler/defsch/defsch_afs.go b/business/jxcallback/scheduler/defsch/defsch_afs.go index f8a00c562..260aec703 100644 --- a/business/jxcallback/scheduler/defsch/defsch_afs.go +++ b/business/jxcallback/scheduler/defsch/defsch_afs.go @@ -3,6 +3,7 @@ package defsch import ( "git.rosy.net.cn/jx-callback/business/jxutils" "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" + push "git.rosy.net.cn/jx-callback/business/jxutils/unipush" "git.rosy.net.cn/jx-callback/business/jxutils/weixinmsg" "git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/business/msghub" @@ -31,6 +32,7 @@ func (s *DefScheduler) OnAfsOrderNew(order *model.AfsOrder, isPending bool) (err } msghub.OnNewWait4ApproveAfsOrder(order) weixinmsg.NotifyAfsOrderStatus(order) + push.NotifyAfsOrder(order) } } return err diff --git a/business/jxutils/unipush/push.go b/business/jxutils/unipush/push.go index 288bc68e3..eb73b8547 100644 --- a/business/jxutils/unipush/push.go +++ b/business/jxutils/unipush/push.go @@ -13,24 +13,19 @@ import ( "github.com/astaxie/beego" ) -func NotifyNewOrder(order *model.GoodsOrder) { +func pushToSingle(content, title string, storeID int) { var ( db = dao.GetDB() ) - globals.SugarLogger.Debugf("NotifyNewOrder push begin orderID :[%v]", order.VendorOrderID) - storePushs, err := dao.GetStorePushClient(db, jxutils.GetSaleStoreIDFromOrder(order), "") + storePushs, err := dao.GetStorePushClient(db, storeID, "") if err != nil { return } for _, v := range storePushs { - sb := new(strings.Builder) - sb.WriteString("老板,") - sb.WriteString(order.ConsigneeName) - sb.WriteString("购买了商品") - sb.WriteString(getOrderDetailBrief(order)) + status, err2 := api.PushAPI.PushToSingle(v.ClientID, false, &unipushapi.Notification{ - Title: "京西菜市新订单推送", - Body: sb.String(), + Title: title, + Body: content, }) if err = err2; err != nil { globals.SugarLogger.Debugf("NotifyNewOrder push error: [%v]", err) @@ -38,7 +33,7 @@ func NotifyNewOrder(order *model.GoodsOrder) { } if status == unipushapi.SuccessOffLine { _, err = api.PushAPI.PushToSingle(v.ClientID, true, &unipushapi.Notification{ - Body: sb.String(), + Body: content, }) if err != nil { globals.SugarLogger.Debugf("NotifyNewOrder push2 error: [%v]", err) @@ -49,6 +44,16 @@ func NotifyNewOrder(order *model.GoodsOrder) { } } +func NotifyNewOrder(order *model.GoodsOrder) { + globals.SugarLogger.Debugf("NotifyNewOrder push begin orderID :[%v]", order.VendorOrderID) + sb := new(strings.Builder) + sb.WriteString("老板,") + sb.WriteString(order.ConsigneeName) + sb.WriteString("购买了商品") + sb.WriteString(getOrderDetailBrief(order)) + pushToSingle(sb.String(), "京西菜市新订单推送", jxutils.GetSaleStoreIDFromOrder(order)) +} + func getOrderDetailBrief(order *model.GoodsOrder) (brief string) { sb := new(strings.Builder) sb.WriteString(order.Skus[0].SkuName) @@ -72,3 +77,9 @@ func getOrderDetailBrief(order *model.GoodsOrder) (brief string) { sb.WriteString("元") return sb.String() } + +func NotifyAfsOrder(afsOrder *model.AfsOrder) (err error) { + globals.SugarLogger.Debugf("NotifyAfsOrder push begin orderID :[%v]", afsOrder.VendorOrderID) + pushToSingle("老板,您有新的售后单,请尽快处理!", "京西菜市售后单推送", jxutils.GetSaleStoreIDFromAfsOrder(afsOrder)) + return err +}