触犯红线通知

This commit is contained in:
Rosy-zhudan
2019-09-27 17:59:39 +08:00
parent 6f579e7f1b
commit 0c0ac4fd69
2 changed files with 30 additions and 25 deletions

View File

@@ -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)
}
}

View File

@@ -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})
}
}
}