From 0c0ac4fd695246b94dcb1e5434e007b49a61607b Mon Sep 17 00:00:00 2001 From: Rosy-zhudan Date: Fri, 27 Sep 2019 17:59:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A6=E7=8A=AF=E7=BA=A2=E7=BA=BF=E9=80=9A?= =?UTF-8?q?=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/misc/Store_Alert_Inform.go | 43 ++++++++++++--------- business/model/dao/dao_order.go | 12 +++--- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/business/jxstore/misc/Store_Alert_Inform.go b/business/jxstore/misc/Store_Alert_Inform.go index 24d242448..873991463 100644 --- a/business/jxstore/misc/Store_Alert_Inform.go +++ b/business/jxstore/misc/Store_Alert_Inform.go @@ -26,8 +26,8 @@ const ( OneDayName = "单日" OneWeekDayName = "七日" OneMonthDayName = "三十日" - YellowAlertInfo = "您的店铺京西菜市-%s,由于%s%s>=%d%%,可能会被系统下线,请及时补救。" - RedAlertInfo = "您的店铺京西菜市-%s,由于%s%s>=%d%%,会被系统下线,需要马上补救。" + YellowAlertInfo = "您的店铺京西菜市-%s,由于%s%s%s%v%%,可能会被系统下线,请及时补救。" + RedAlertInfo = "您的店铺京西菜市-%s,由于%s%s%s%v%%,会被系统下线,需要马上补救。" NoOrderAlertInfo = "您的店铺京西菜市-%s,由于近%s无订单,会被系统下线,需要马上补救。" RiskOrderAlertInfo = "系统检测到您的店铺可能有虚假定单,定单号为:%s,可能会被罚款,请及时与运营联系!" ) @@ -61,25 +61,24 @@ func ConvertListToMapEx(listData []*model.StoreOrder) (mapData map[int][]string) if mapData[value.StoreID] == nil { mapData[value.StoreID] = []string{} } - vendorOrderIDList := mapData[value.StoreID] - vendorOrderIDList = append(vendorOrderIDList, value.VendorOrderID) + mapData[value.StoreID] = append(mapData[value.StoreID], value.VendorOrderID) } return mapData } -func GetAlertInfo(dayNum int, isRedAlert bool, storeName string, alertType int, ratio float64) (info string) { +func GetAlertInfo(dayNum int, isRedAlert bool, storeName string, alertType int, logicCondition string, ratio float64) (info string) { if dayNum == CheckStoreAlertOneDayNum { if isRedAlert { - info = fmt.Sprintf(RedAlertInfo, storeName, OneDayName, AlertTypeNameMap[alertType], ratio) + info = fmt.Sprintf(RedAlertInfo, storeName, OneDayName, AlertTypeNameMap[alertType], logicCondition, ratio) } else { - info = fmt.Sprintf(YellowAlertInfo, storeName, OneDayName, AlertTypeNameMap[alertType], ratio) + info = fmt.Sprintf(YellowAlertInfo, storeName, OneDayName, AlertTypeNameMap[alertType], logicCondition, ratio) } } else if dayNum == CheckStoreAlertOneWeekDayNum { if isRedAlert { - info = fmt.Sprintf(RedAlertInfo, storeName, OneWeekDayName, AlertTypeNameMap[alertType], ratio) + info = fmt.Sprintf(RedAlertInfo, storeName, OneWeekDayName, AlertTypeNameMap[alertType], logicCondition, ratio) } else { - info = fmt.Sprintf(YellowAlertInfo, storeName, OneWeekDayName, AlertTypeNameMap[alertType], ratio) + info = fmt.Sprintf(YellowAlertInfo, storeName, OneWeekDayName, AlertTypeNameMap[alertType], logicCondition, ratio) } } else if dayNum == CheckStoreAlertOneMonthDayNum { info = fmt.Sprintf(NoOrderAlertInfo, storeName, OneMonthDayName) @@ -88,7 +87,7 @@ func GetAlertInfo(dayNum int, isRedAlert bool, storeName string, alertType int, return info } -func CheckAlert(alertType int, dayNum int, ratio float64, count int) (isYellowAlert, isRedAlert bool) { +func CheckAlert(alertType int, dayNum int, ratio float64, count int) (isYellowAlert, isRedAlert bool, logicCondtion string, outRatio float64) { yellowRatio := float64(-1) redRatio := float64(-1) extraCount := -1 @@ -103,7 +102,7 @@ func CheckAlert(alertType int, dayNum int, ratio float64, count int) (isYellowAl redRatio = 50 extraCount = 5 } - conditionLessEqual = false + conditionLessEqual = true case AlertTypeBadCommentOrder: if dayNum == CheckStoreAlertOneDayNum { redRatio = 100 @@ -112,7 +111,7 @@ func CheckAlert(alertType int, dayNum int, ratio float64, count int) (isYellowAl redRatio = 3 extraCount = 5 } - conditionLessEqual = true + conditionLessEqual = false case AlertTypeAbsentGoodsOrder: if dayNum == CheckStoreAlertOneDayNum { redRatio = 100 @@ -121,36 +120,42 @@ func CheckAlert(alertType int, dayNum int, ratio float64, count int) (isYellowAl redRatio = 5 extraCount = 5 } - conditionLessEqual = true + conditionLessEqual = false case AlertTypeStandardFinishTimeOrderSelfDelivery: yellowRatio = 85 redRatio = 70 - conditionLessEqual = false + conditionLessEqual = true case AlertTypeStandardPickUpTimeOrderDaDa: yellowRatio = 85 redRatio = 70 - conditionLessEqual = false + conditionLessEqual = true } if conditionLessEqual { + logicCondtion = "<=" if extraCount != -1 && count >= extraCount { isRedAlert = true } else if redRatio != -1 && ratio <= redRatio { isRedAlert = true + outRatio = redRatio } else if yellowRatio != -1 && ratio <= yellowRatio { isYellowAlert = true + outRatio = yellowRatio } } else { + logicCondtion = ">=" if extraCount != -1 && count >= extraCount { isRedAlert = true } else if redRatio != -1 && ratio >= redRatio { isRedAlert = true + outRatio = redRatio } else if yellowRatio != -1 && ratio >= yellowRatio { isYellowAlert = true + outRatio = yellowRatio } } - return isYellowAlert, isRedAlert + return isYellowAlert, isRedAlert, logicCondtion, outRatio } func SendAlertInfo(storeID int, alertInfo string) { @@ -160,12 +165,12 @@ func SendAlertInfo(storeID int, alertInfo string) { func SendAlertInfoWrapper(storeID int, storeName string, dayNum, alertType, count, totalCount int) { if totalCount > 0 { ratio := float64(count) * 100 / float64(totalCount) - yellowAlert, redAlert := CheckAlert(alertType, dayNum, ratio, count) + yellowAlert, redAlert, logicCondtion, outRatio := CheckAlert(alertType, dayNum, ratio, count) isAlert := false isRedAlert := redAlert isAlert = yellowAlert || redAlert if isAlert { - alertInfo := GetAlertInfo(dayNum, isRedAlert, storeName, alertType, ratio) + alertInfo := GetAlertInfo(dayNum, isRedAlert, storeName, alertType, logicCondtion, outRatio) SendAlertInfo(storeID, alertInfo) } } @@ -251,7 +256,7 @@ func CheckStoreMonthAlert(storeMapData map[int]*cms.StoreExt) { storeID := storeInfo.ID storeName := storeInfo.Name if _, ok := storeCountMapData[storeID]; !ok { - alertInfo := GetAlertInfo(CheckStoreAlertOneMonthDayNum, true, storeName, -1, -1) + alertInfo := GetAlertInfo(CheckStoreAlertOneMonthDayNum, true, storeName, -1, "", -1) SendAlertInfo(storeID, alertInfo) } } diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index 163e33a81..d974f86dd 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -462,7 +462,7 @@ func GetStandardPickTimeOrderCountByDaDa(db *DaoDB, dayNum int, includeToday boo //按时履约订单量, 仅统计商家自送门店 func GetStandardFinishTimeOrderCountBySelfDelivery(db *DaoDB, dayNum int, includeToday bool) (storeCountList []*model.StoreCount, err error) { sql := ` - SELECT jx_store_id store_id, order_created_at orderCreateTime, order_finished_at orderFinishTime + SELECT jx_store_id store_id, order_created_at, order_finished_at FROM goods_order where order_finished_at >= ? AND order_finished_at <= ? AND status = ? @@ -523,11 +523,9 @@ func GetStandardPickUpTimeOrderCountByDaDa(db *DaoDB, dayNum int, includeToday b if err == nil && len(storeOrderStatusList) > 0 { for _, value := range storeOrderStatusList { if storeOrderTimeMapData[value.StoreID] == nil { - storeOrderTimeSubList := []*model.StoreOrderStatus{} - storeOrderTimeMapData[value.StoreID] = storeOrderTimeSubList + storeOrderTimeMapData[value.StoreID] = []*model.StoreOrderStatus{} } - storeOrderTimeSubList := storeOrderTimeMapData[value.StoreID] - storeOrderTimeSubList = append(storeOrderTimeSubList, value) + storeOrderTimeMapData[value.StoreID] = append(storeOrderTimeMapData[value.StoreID], value) } for storeID, valueList := range storeOrderTimeMapData { count := 0 @@ -556,7 +554,9 @@ func GetStandardPickUpTimeOrderCountByDaDa(db *DaoDB, dayNum int, includeToday b count++ } } - storeCountList = append(storeCountList, &model.StoreCount{storeID, count}) + if count > 0 { + storeCountList = append(storeCountList, &model.StoreCount{storeID, count}) + } } }