From 846442f478df9385304f9e08b46f694cb20bde0a 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, 23 Dec 2019 10:29:35 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=88=A9=E6=B6=A6?= =?UTF-8?q?=E6=8A=A5=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jxcallback/scheduler/defsch/defsch.go | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/business/jxcallback/scheduler/defsch/defsch.go b/business/jxcallback/scheduler/defsch/defsch.go index 4f1c53477..6207f0a97 100644 --- a/business/jxcallback/scheduler/defsch/defsch.go +++ b/business/jxcallback/scheduler/defsch/defsch.go @@ -6,11 +6,14 @@ import ( "sync" "time" + "git.rosy.net.cn/jx-callback/business/jxutils/ddmsg" + "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" "git.rosy.net.cn/jx-callback/business/jxutils/netprinter" "git.rosy.net.cn/jx-callback/business/jxutils/smsmsg" "git.rosy.net.cn/jx-callback/business/msghub" + "git.rosy.net.cn/baseapi/platformapi/dingdingapi" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxcallback/scheduler" "git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/basesch" @@ -1277,6 +1280,7 @@ func (s *DefScheduler) notifyNewOrder(order *model.GoodsOrder) { netprinter.PrintOrderByOrder(jxcontext.AdminCtx, order) weixinmsg.NotifyNewOrder(order) smsmsg.NotifyNewOrder(order) + OrderProfitWarning(order) }) } } @@ -1313,3 +1317,42 @@ func isOrderCanSwitch2SelfDeliver(order *model.GoodsOrder) (isCan bool) { } return isCan } + +func OrderProfitWarning(order *model.GoodsOrder) { + var ( + operatorName string + noticeMsg string + profit float64 + storeID int + ) + db := dao.GetDB() + if order == nil { + return + } + if order.JxStoreID == 0 { + storeID = order.StoreID + } else { + storeID = order.JxStoreID + } + storeDetail, err := dao.GetStoreDetail(db, storeID, order.VendorID) + if storeDetail != nil && err == nil { + payPercentage := storeDetail.PayPercentage + if payPercentage >= 50 { + profit = utils.Str2Float64(utils.Int64ToStr(order.TotalShopMoney-order.EarningPrice-order.DistanceFreightMoney-order.WaybillTipMoney)) / 100 + } else { + profit = utils.Str2Float64(utils.Int64ToStr(order.TotalShopMoney*int64(payPercentage)/200)) / 100 + } + if profit < 0 { + if storeDetail.OperatorName != "" { + operatorName = storeDetail.OperatorName + } else if storeDetail.OperatorName2 != "" { + operatorName = storeDetail.OperatorName2 + } + noticeMsg = fmt.Sprintf("订单号:[%v],利润 :[%v],运营负责人:[%v]", order.VendorOrderID, profit, operatorName) + user, err := dao.GetUserByID(db, "name", operatorName) + if user != nil && err == nil { + ddmsg.SendUserMessage(dingdingapi.MsgTyeText, user.UserID, "警告!此订单利润低于0", noticeMsg) + } + } + } +} From ddb129dbc047b0d17747a71ba34bc003fabc34fc 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, 23 Dec 2019 10:32:40 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E9=A2=84=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/scheduler/defsch/defsch.go | 1 + 1 file changed, 1 insertion(+) diff --git a/business/jxcallback/scheduler/defsch/defsch.go b/business/jxcallback/scheduler/defsch/defsch.go index 6207f0a97..49db17696 100644 --- a/business/jxcallback/scheduler/defsch/defsch.go +++ b/business/jxcallback/scheduler/defsch/defsch.go @@ -1318,6 +1318,7 @@ func isOrderCanSwitch2SelfDeliver(order *model.GoodsOrder) (isCan bool) { return isCan } +//订单预计利润若低于0,则向门店运营负责人发送钉钉消息 func OrderProfitWarning(order *model.GoodsOrder) { var ( operatorName string From 3f98af6a112e65c6c4a235f65fc64168a5e1e72c 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, 23 Dec 2019 10:45:12 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=88=A9=E6=B6=A6?= =?UTF-8?q?=E9=A2=84=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jxcallback/scheduler/defsch/defsch.go | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/business/jxcallback/scheduler/defsch/defsch.go b/business/jxcallback/scheduler/defsch/defsch.go index 49db17696..56b791344 100644 --- a/business/jxcallback/scheduler/defsch/defsch.go +++ b/business/jxcallback/scheduler/defsch/defsch.go @@ -1321,20 +1321,17 @@ func isOrderCanSwitch2SelfDeliver(order *model.GoodsOrder) (isCan bool) { //订单预计利润若低于0,则向门店运营负责人发送钉钉消息 func OrderProfitWarning(order *model.GoodsOrder) { var ( - operatorName string - noticeMsg string - profit float64 - storeID int + operatorName string + operatorPhone string + noticeMsg string + profit float64 + storeID int ) db := dao.GetDB() if order == nil { return } - if order.JxStoreID == 0 { - storeID = order.StoreID - } else { - storeID = order.JxStoreID - } + storeID = jxutils.GetShowStoreIDFromOrder(order) storeDetail, err := dao.GetStoreDetail(db, storeID, order.VendorID) if storeDetail != nil && err == nil { payPercentage := storeDetail.PayPercentage @@ -1344,13 +1341,15 @@ func OrderProfitWarning(order *model.GoodsOrder) { profit = utils.Str2Float64(utils.Int64ToStr(order.TotalShopMoney*int64(payPercentage)/200)) / 100 } if profit < 0 { - if storeDetail.OperatorName != "" { + if storeDetail.OperatorPhone != "" { operatorName = storeDetail.OperatorName - } else if storeDetail.OperatorName2 != "" { + operatorPhone = storeDetail.OperatorPhone + } else if storeDetail.OperatorPhone2 != "" { operatorName = storeDetail.OperatorName2 + operatorPhone = storeDetail.OperatorPhone2 } noticeMsg = fmt.Sprintf("订单号:[%v],利润 :[%v],运营负责人:[%v]", order.VendorOrderID, profit, operatorName) - user, err := dao.GetUserByID(db, "name", operatorName) + user, err := dao.GetUserByID(db, "mobile", operatorPhone) if user != nil && err == nil { ddmsg.SendUserMessage(dingdingapi.MsgTyeText, user.UserID, "警告!此订单利润低于0", noticeMsg) }