触犯红线通知
This commit is contained in:
@@ -26,8 +26,8 @@ const (
|
|||||||
OneDayName = "单日"
|
OneDayName = "单日"
|
||||||
OneWeekDayName = "七日"
|
OneWeekDayName = "七日"
|
||||||
OneMonthDayName = "三十日"
|
OneMonthDayName = "三十日"
|
||||||
YellowAlertInfo = "您的店铺京西菜市-%s,由于%s%s>=%d%%,可能会被系统下线,请及时补救。"
|
YellowAlertInfo = "您的店铺京西菜市-%s,由于%s%s%s%v%%,可能会被系统下线,请及时补救。"
|
||||||
RedAlertInfo = "您的店铺京西菜市-%s,由于%s%s>=%d%%,会被系统下线,需要马上补救。"
|
RedAlertInfo = "您的店铺京西菜市-%s,由于%s%s%s%v%%,会被系统下线,需要马上补救。"
|
||||||
NoOrderAlertInfo = "您的店铺京西菜市-%s,由于近%s无订单,会被系统下线,需要马上补救。"
|
NoOrderAlertInfo = "您的店铺京西菜市-%s,由于近%s无订单,会被系统下线,需要马上补救。"
|
||||||
RiskOrderAlertInfo = "系统检测到您的店铺可能有虚假定单,定单号为:%s,可能会被罚款,请及时与运营联系!"
|
RiskOrderAlertInfo = "系统检测到您的店铺可能有虚假定单,定单号为:%s,可能会被罚款,请及时与运营联系!"
|
||||||
)
|
)
|
||||||
@@ -61,25 +61,24 @@ func ConvertListToMapEx(listData []*model.StoreOrder) (mapData map[int][]string)
|
|||||||
if mapData[value.StoreID] == nil {
|
if mapData[value.StoreID] == nil {
|
||||||
mapData[value.StoreID] = []string{}
|
mapData[value.StoreID] = []string{}
|
||||||
}
|
}
|
||||||
vendorOrderIDList := mapData[value.StoreID]
|
mapData[value.StoreID] = append(mapData[value.StoreID], value.VendorOrderID)
|
||||||
vendorOrderIDList = append(vendorOrderIDList, value.VendorOrderID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapData
|
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 dayNum == CheckStoreAlertOneDayNum {
|
||||||
if isRedAlert {
|
if isRedAlert {
|
||||||
info = fmt.Sprintf(RedAlertInfo, storeName, OneDayName, AlertTypeNameMap[alertType], ratio)
|
info = fmt.Sprintf(RedAlertInfo, storeName, OneDayName, AlertTypeNameMap[alertType], logicCondition, ratio)
|
||||||
} else {
|
} else {
|
||||||
info = fmt.Sprintf(YellowAlertInfo, storeName, OneDayName, AlertTypeNameMap[alertType], ratio)
|
info = fmt.Sprintf(YellowAlertInfo, storeName, OneDayName, AlertTypeNameMap[alertType], logicCondition, ratio)
|
||||||
}
|
}
|
||||||
} else if dayNum == CheckStoreAlertOneWeekDayNum {
|
} else if dayNum == CheckStoreAlertOneWeekDayNum {
|
||||||
if isRedAlert {
|
if isRedAlert {
|
||||||
info = fmt.Sprintf(RedAlertInfo, storeName, OneWeekDayName, AlertTypeNameMap[alertType], ratio)
|
info = fmt.Sprintf(RedAlertInfo, storeName, OneWeekDayName, AlertTypeNameMap[alertType], logicCondition, ratio)
|
||||||
} else {
|
} else {
|
||||||
info = fmt.Sprintf(YellowAlertInfo, storeName, OneWeekDayName, AlertTypeNameMap[alertType], ratio)
|
info = fmt.Sprintf(YellowAlertInfo, storeName, OneWeekDayName, AlertTypeNameMap[alertType], logicCondition, ratio)
|
||||||
}
|
}
|
||||||
} else if dayNum == CheckStoreAlertOneMonthDayNum {
|
} else if dayNum == CheckStoreAlertOneMonthDayNum {
|
||||||
info = fmt.Sprintf(NoOrderAlertInfo, storeName, OneMonthDayName)
|
info = fmt.Sprintf(NoOrderAlertInfo, storeName, OneMonthDayName)
|
||||||
@@ -88,7 +87,7 @@ func GetAlertInfo(dayNum int, isRedAlert bool, storeName string, alertType int,
|
|||||||
return info
|
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)
|
yellowRatio := float64(-1)
|
||||||
redRatio := float64(-1)
|
redRatio := float64(-1)
|
||||||
extraCount := -1
|
extraCount := -1
|
||||||
@@ -103,7 +102,7 @@ func CheckAlert(alertType int, dayNum int, ratio float64, count int) (isYellowAl
|
|||||||
redRatio = 50
|
redRatio = 50
|
||||||
extraCount = 5
|
extraCount = 5
|
||||||
}
|
}
|
||||||
conditionLessEqual = false
|
conditionLessEqual = true
|
||||||
case AlertTypeBadCommentOrder:
|
case AlertTypeBadCommentOrder:
|
||||||
if dayNum == CheckStoreAlertOneDayNum {
|
if dayNum == CheckStoreAlertOneDayNum {
|
||||||
redRatio = 100
|
redRatio = 100
|
||||||
@@ -112,7 +111,7 @@ func CheckAlert(alertType int, dayNum int, ratio float64, count int) (isYellowAl
|
|||||||
redRatio = 3
|
redRatio = 3
|
||||||
extraCount = 5
|
extraCount = 5
|
||||||
}
|
}
|
||||||
conditionLessEqual = true
|
conditionLessEqual = false
|
||||||
case AlertTypeAbsentGoodsOrder:
|
case AlertTypeAbsentGoodsOrder:
|
||||||
if dayNum == CheckStoreAlertOneDayNum {
|
if dayNum == CheckStoreAlertOneDayNum {
|
||||||
redRatio = 100
|
redRatio = 100
|
||||||
@@ -121,36 +120,42 @@ func CheckAlert(alertType int, dayNum int, ratio float64, count int) (isYellowAl
|
|||||||
redRatio = 5
|
redRatio = 5
|
||||||
extraCount = 5
|
extraCount = 5
|
||||||
}
|
}
|
||||||
conditionLessEqual = true
|
conditionLessEqual = false
|
||||||
case AlertTypeStandardFinishTimeOrderSelfDelivery:
|
case AlertTypeStandardFinishTimeOrderSelfDelivery:
|
||||||
yellowRatio = 85
|
yellowRatio = 85
|
||||||
redRatio = 70
|
redRatio = 70
|
||||||
conditionLessEqual = false
|
conditionLessEqual = true
|
||||||
case AlertTypeStandardPickUpTimeOrderDaDa:
|
case AlertTypeStandardPickUpTimeOrderDaDa:
|
||||||
yellowRatio = 85
|
yellowRatio = 85
|
||||||
redRatio = 70
|
redRatio = 70
|
||||||
conditionLessEqual = false
|
conditionLessEqual = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if conditionLessEqual {
|
if conditionLessEqual {
|
||||||
|
logicCondtion = "<="
|
||||||
if extraCount != -1 && count >= extraCount {
|
if extraCount != -1 && count >= extraCount {
|
||||||
isRedAlert = true
|
isRedAlert = true
|
||||||
} else if redRatio != -1 && ratio <= redRatio {
|
} else if redRatio != -1 && ratio <= redRatio {
|
||||||
isRedAlert = true
|
isRedAlert = true
|
||||||
|
outRatio = redRatio
|
||||||
} else if yellowRatio != -1 && ratio <= yellowRatio {
|
} else if yellowRatio != -1 && ratio <= yellowRatio {
|
||||||
isYellowAlert = true
|
isYellowAlert = true
|
||||||
|
outRatio = yellowRatio
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
logicCondtion = ">="
|
||||||
if extraCount != -1 && count >= extraCount {
|
if extraCount != -1 && count >= extraCount {
|
||||||
isRedAlert = true
|
isRedAlert = true
|
||||||
} else if redRatio != -1 && ratio >= redRatio {
|
} else if redRatio != -1 && ratio >= redRatio {
|
||||||
isRedAlert = true
|
isRedAlert = true
|
||||||
|
outRatio = redRatio
|
||||||
} else if yellowRatio != -1 && ratio >= yellowRatio {
|
} else if yellowRatio != -1 && ratio >= yellowRatio {
|
||||||
isYellowAlert = true
|
isYellowAlert = true
|
||||||
|
outRatio = yellowRatio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return isYellowAlert, isRedAlert
|
return isYellowAlert, isRedAlert, logicCondtion, outRatio
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendAlertInfo(storeID int, alertInfo string) {
|
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) {
|
func SendAlertInfoWrapper(storeID int, storeName string, dayNum, alertType, count, totalCount int) {
|
||||||
if totalCount > 0 {
|
if totalCount > 0 {
|
||||||
ratio := float64(count) * 100 / float64(totalCount)
|
ratio := float64(count) * 100 / float64(totalCount)
|
||||||
yellowAlert, redAlert := CheckAlert(alertType, dayNum, ratio, count)
|
yellowAlert, redAlert, logicCondtion, outRatio := CheckAlert(alertType, dayNum, ratio, count)
|
||||||
isAlert := false
|
isAlert := false
|
||||||
isRedAlert := redAlert
|
isRedAlert := redAlert
|
||||||
isAlert = yellowAlert || redAlert
|
isAlert = yellowAlert || redAlert
|
||||||
if isAlert {
|
if isAlert {
|
||||||
alertInfo := GetAlertInfo(dayNum, isRedAlert, storeName, alertType, ratio)
|
alertInfo := GetAlertInfo(dayNum, isRedAlert, storeName, alertType, logicCondtion, outRatio)
|
||||||
SendAlertInfo(storeID, alertInfo)
|
SendAlertInfo(storeID, alertInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,7 +256,7 @@ func CheckStoreMonthAlert(storeMapData map[int]*cms.StoreExt) {
|
|||||||
storeID := storeInfo.ID
|
storeID := storeInfo.ID
|
||||||
storeName := storeInfo.Name
|
storeName := storeInfo.Name
|
||||||
if _, ok := storeCountMapData[storeID]; !ok {
|
if _, ok := storeCountMapData[storeID]; !ok {
|
||||||
alertInfo := GetAlertInfo(CheckStoreAlertOneMonthDayNum, true, storeName, -1, -1)
|
alertInfo := GetAlertInfo(CheckStoreAlertOneMonthDayNum, true, storeName, -1, "", -1)
|
||||||
SendAlertInfo(storeID, alertInfo)
|
SendAlertInfo(storeID, alertInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) {
|
func GetStandardFinishTimeOrderCountBySelfDelivery(db *DaoDB, dayNum int, includeToday bool) (storeCountList []*model.StoreCount, err error) {
|
||||||
sql := `
|
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
|
FROM goods_order
|
||||||
where order_finished_at >= ? AND order_finished_at <= ?
|
where order_finished_at >= ? AND order_finished_at <= ?
|
||||||
AND status = ?
|
AND status = ?
|
||||||
@@ -523,11 +523,9 @@ func GetStandardPickUpTimeOrderCountByDaDa(db *DaoDB, dayNum int, includeToday b
|
|||||||
if err == nil && len(storeOrderStatusList) > 0 {
|
if err == nil && len(storeOrderStatusList) > 0 {
|
||||||
for _, value := range storeOrderStatusList {
|
for _, value := range storeOrderStatusList {
|
||||||
if storeOrderTimeMapData[value.StoreID] == nil {
|
if storeOrderTimeMapData[value.StoreID] == nil {
|
||||||
storeOrderTimeSubList := []*model.StoreOrderStatus{}
|
storeOrderTimeMapData[value.StoreID] = []*model.StoreOrderStatus{}
|
||||||
storeOrderTimeMapData[value.StoreID] = storeOrderTimeSubList
|
|
||||||
}
|
}
|
||||||
storeOrderTimeSubList := storeOrderTimeMapData[value.StoreID]
|
storeOrderTimeMapData[value.StoreID] = append(storeOrderTimeMapData[value.StoreID], value)
|
||||||
storeOrderTimeSubList = append(storeOrderTimeSubList, value)
|
|
||||||
}
|
}
|
||||||
for storeID, valueList := range storeOrderTimeMapData {
|
for storeID, valueList := range storeOrderTimeMapData {
|
||||||
count := 0
|
count := 0
|
||||||
@@ -556,7 +554,9 @@ func GetStandardPickUpTimeOrderCountByDaDa(db *DaoDB, dayNum int, includeToday b
|
|||||||
count++
|
count++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
storeCountList = append(storeCountList, &model.StoreCount{storeID, count})
|
if count > 0 {
|
||||||
|
storeCountList = append(storeCountList, &model.StoreCount{storeID, count})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user