门店红线/黄线统计-写入数据库
This commit is contained in:
@@ -2,15 +2,24 @@ package misc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/weixinmsg"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
)
|
||||
|
||||
const (
|
||||
EnableCheckStoreAlert = true
|
||||
EnableSendStoreAlert = true
|
||||
|
||||
IncludeToday = true
|
||||
CheckStoreAlertOneMonthDayNum = 30
|
||||
CheckStoreAlertOneDayNum = 1
|
||||
@@ -26,10 +35,10 @@ const (
|
||||
OneDayName = "单日"
|
||||
OneWeekDayName = "七日"
|
||||
OneMonthDayName = "三十日"
|
||||
YellowAlertInfo = "您的店铺京西菜市-%s,由于%s%s%s%v%%,可能会被系统下线,请及时补救。"
|
||||
RedAlertInfo = "您的店铺京西菜市-%s,由于%s%s%s%v%%,会被系统下线,需要马上补救。"
|
||||
YellowAlertInfo = "您的店铺京西菜市-%s,由于%s%s%s%d%%,可能会被系统下线,请及时补救。"
|
||||
RedAlertInfo = "您的店铺京西菜市-%s,由于%s%s%s%d%%,会被系统下线,需要马上补救。"
|
||||
NoOrderAlertInfo = "您的店铺京西菜市-%s,由于近%s无订单,会被系统下线,需要马上补救。"
|
||||
RiskOrderAlertInfo = "系统检测到您的店铺可能有虚假定单,定单号为:%s,可能会被罚款,请及时与运营联系!"
|
||||
RiskOrderAlertInfo = "您的店铺京西菜市-%s,可能有虚假定单,定单号为:%s,可能会被罚款,请及时与运营联系!"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -44,8 +53,40 @@ var (
|
||||
AlertTypeStandardFinishTimeOrderSelfDelivery: "按时履约率(商家自送)",
|
||||
AlertTypeStandardPickUpTimeOrderDaDa: "10分钟取货完成率(达达)",
|
||||
}
|
||||
|
||||
storeAlertDataWrapper StoreAlertDataWrapper
|
||||
)
|
||||
|
||||
type StoreAlertDataWrapper struct {
|
||||
storeAlertList map[int]*model.StoreAlert
|
||||
}
|
||||
|
||||
func (s *StoreAlertDataWrapper) InitData() {
|
||||
s.storeAlertList = make(map[int]*model.StoreAlert)
|
||||
}
|
||||
|
||||
func (s *StoreAlertDataWrapper) ClearData() {
|
||||
s.storeAlertList = nil
|
||||
}
|
||||
|
||||
func (s *StoreAlertDataWrapper) SetData(storeID int, valueName string, value int) {
|
||||
data := s.storeAlertList[storeID]
|
||||
if data == nil {
|
||||
data = &model.StoreAlert{}
|
||||
data.StoreID = storeID
|
||||
data.AlertDate = utils.GetCurDate()
|
||||
s.storeAlertList[storeID] = data
|
||||
}
|
||||
valueInfo := reflect.ValueOf(data).Elem()
|
||||
valueInfo.FieldByName(valueName).SetInt(int64(value))
|
||||
}
|
||||
|
||||
func (s StoreAlertDataWrapper) InsertStoreAlertList() {
|
||||
for _, value := range s.storeAlertList {
|
||||
dao.InsertStoreAlert(value)
|
||||
}
|
||||
}
|
||||
|
||||
func ConvertListToMap(listData []*model.StoreCount) (mapData map[int]int) {
|
||||
mapData = make(map[int]int)
|
||||
for _, value := range listData {
|
||||
@@ -67,7 +108,7 @@ func ConvertListToMapEx(listData []*model.StoreOrder) (mapData map[int][]string)
|
||||
return mapData
|
||||
}
|
||||
|
||||
func GetAlertInfo(dayNum int, isRedAlert bool, storeName string, alertType int, logicCondition string, ratio float64) (info string) {
|
||||
func GetAlertInfo(dayNum int, isRedAlert bool, storeName string, alertType int, logicCondition string, ratio int) (info string) {
|
||||
if dayNum == CheckStoreAlertOneDayNum {
|
||||
if isRedAlert {
|
||||
info = fmt.Sprintf(RedAlertInfo, storeName, OneDayName, AlertTypeNameMap[alertType], logicCondition, ratio)
|
||||
@@ -87,9 +128,9 @@ 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, logicCondtion string, outRatio float64) {
|
||||
yellowRatio := float64(-1)
|
||||
redRatio := float64(-1)
|
||||
func CheckAlert(alertType int, dayNum int, ratio int, count int) (isYellowAlert, isRedAlert bool, logicCondtion string, outRatio int) {
|
||||
yellowRatio := -1
|
||||
redRatio := -1
|
||||
extraCount := -1
|
||||
conditionLessEqual := false
|
||||
|
||||
@@ -158,25 +199,29 @@ func CheckAlert(alertType int, dayNum int, ratio float64, count int) (isYellowAl
|
||||
return isYellowAlert, isRedAlert, logicCondtion, outRatio
|
||||
}
|
||||
|
||||
func SendAlertInfo(storeID int, alertInfo string) {
|
||||
fmt.Printf("SendAlertInfo:%d %s\n", storeID, alertInfo)
|
||||
func SendAlertInfo(storeID int, storeName, alertInfo string) {
|
||||
if EnableSendStoreAlert {
|
||||
baseapi.SugarLogger.Debugf("SendAlertInfo: %d, %s", storeID, alertInfo)
|
||||
weixinmsg.NotifyStoreAlertMessage(storeID, storeName, "门店警告", alertInfo)
|
||||
}
|
||||
}
|
||||
|
||||
func SendAlertInfoWrapper(storeID int, storeName string, dayNum, alertType, count, totalCount int) {
|
||||
if totalCount > 0 {
|
||||
ratio := float64(count) * 100 / float64(totalCount)
|
||||
ratio := int(math.Round(float64(count) * 100 / float64(totalCount)))
|
||||
yellowAlert, redAlert, logicCondtion, outRatio := CheckAlert(alertType, dayNum, ratio, count)
|
||||
isAlert := false
|
||||
isRedAlert := redAlert
|
||||
isAlert = yellowAlert || redAlert
|
||||
if isAlert {
|
||||
alertInfo := GetAlertInfo(dayNum, isRedAlert, storeName, alertType, logicCondtion, outRatio)
|
||||
SendAlertInfo(storeID, alertInfo)
|
||||
SendAlertInfo(storeID, storeName, alertInfo)
|
||||
storeAlertDataWrapper.SetData(storeID, model.FieldRiskOrderCount, ratio)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func CheckStoreDayAlert(storeMapData map[int]*cms.StoreExt, dayNum int) {
|
||||
func CheckStoreDayAlert(storeList []*cms.StoreExt, dayNum int) {
|
||||
db := dao.GetDB()
|
||||
//拣货履约订单(达达)
|
||||
pickTimeOrderCountDaDaList, _ := dao.GetStandardPickTimeOrderCountByDaDa(db, dayNum, IncludeToday)
|
||||
@@ -219,7 +264,7 @@ func CheckStoreDayAlert(storeMapData map[int]*cms.StoreExt, dayNum int) {
|
||||
standardPickUpTimeOrderCountDaDaMapData = ConvertListToMap(standardPickUpTimeOrderCountDaDaList)
|
||||
}
|
||||
|
||||
for _, storeInfo := range storeMapData {
|
||||
for _, storeInfo := range storeList {
|
||||
storeID := storeInfo.ID
|
||||
storeName := storeInfo.Name
|
||||
count := pickTimeOrderCountDaDaMapData[storeID]
|
||||
@@ -244,7 +289,7 @@ func CheckStoreDayAlert(storeMapData map[int]*cms.StoreExt, dayNum int) {
|
||||
}
|
||||
}
|
||||
|
||||
func CheckStoreMonthAlert(storeMapData map[int]*cms.StoreExt) {
|
||||
func CheckStoreMonthAlert(storeList []*cms.StoreExt) {
|
||||
db := dao.GetDB()
|
||||
storeCountList, _ := dao.GetFinishOrderCountByDayNum(db, CheckStoreAlertOneMonthDayNum, IncludeToday)
|
||||
storeCountMapData := make(map[int]int)
|
||||
@@ -252,22 +297,24 @@ func CheckStoreMonthAlert(storeMapData map[int]*cms.StoreExt) {
|
||||
storeCountMapData[value.StoreID] = value.Count
|
||||
}
|
||||
|
||||
for _, storeInfo := range storeMapData {
|
||||
for _, storeInfo := range storeList {
|
||||
storeID := storeInfo.ID
|
||||
storeName := storeInfo.Name
|
||||
if _, ok := storeCountMapData[storeID]; !ok {
|
||||
alertInfo := GetAlertInfo(CheckStoreAlertOneMonthDayNum, true, storeName, -1, "", -1)
|
||||
SendAlertInfo(storeID, alertInfo)
|
||||
SendAlertInfo(storeID, storeName, alertInfo)
|
||||
storeAlertDataWrapper.SetData(storeID, model.FieldNoOrderInMonth, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func CheckStoreRiskOrderAlert(storeMapData map[int]*cms.StoreExt, dayNum int) {
|
||||
func CheckStoreRiskOrderAlert(storeList []*cms.StoreExt, dayNum int) {
|
||||
db := dao.GetDB()
|
||||
storeOrderList, _ := dao.GetRiskOrderCount(db, dayNum, IncludeToday)
|
||||
storeOrderMapData := ConvertListToMapEx(storeOrderList)
|
||||
for _, storeInfo := range storeMapData {
|
||||
for _, storeInfo := range storeList {
|
||||
storeID := storeInfo.ID
|
||||
storeName := storeInfo.Name
|
||||
vendorOrderIDList := storeOrderMapData[storeID]
|
||||
if vendorOrderIDList != nil {
|
||||
vendorOrderIDStr := ""
|
||||
@@ -278,8 +325,9 @@ func CheckStoreRiskOrderAlert(storeMapData map[int]*cms.StoreExt, dayNum int) {
|
||||
vendorOrderIDStr += "," + vendorOrderID
|
||||
}
|
||||
}
|
||||
alertInfo := fmt.Sprintf(RiskOrderAlertInfo, vendorOrderIDStr)
|
||||
SendAlertInfo(storeID, alertInfo)
|
||||
alertInfo := fmt.Sprintf(RiskOrderAlertInfo, storeName, vendorOrderIDStr)
|
||||
SendAlertInfo(storeID, storeName, alertInfo)
|
||||
storeAlertDataWrapper.SetData(storeID, model.FieldRiskOrderCount, len(vendorOrderIDList))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,22 +336,43 @@ func GetWeekDay() int {
|
||||
return int(time.Now().Weekday())
|
||||
}
|
||||
|
||||
func CheckStoreAlert(ctx *jxcontext.Context) {
|
||||
func CheckStoreAlert(ctx *jxcontext.Context, storeIDList []int) {
|
||||
storeAlertDataWrapper.InitData()
|
||||
storeList, _ := GetStoreList(ctx)
|
||||
storeMapData := make(map[int]*cms.StoreExt)
|
||||
for _, value := range storeList {
|
||||
storeMapData[value.ID] = value
|
||||
}
|
||||
storeIDMap := jxutils.IntList2Map(storeIDList)
|
||||
storeList = GetFilterStoreListEx(storeList, storeIDMap)
|
||||
if GetWeekDay() == MonthCheckOnWeekDay {
|
||||
CheckStoreMonthAlert(storeMapData)
|
||||
CheckStoreMonthAlert(storeList)
|
||||
}
|
||||
CheckStoreDayAlert(storeMapData, CheckStoreAlertOneDayNum)
|
||||
CheckStoreDayAlert(storeMapData, CheckStoreAlertOneWeekDayNum)
|
||||
CheckStoreRiskOrderAlert(storeMapData, CheckStoreAlertOneDayNum)
|
||||
CheckStoreDayAlert(storeList, CheckStoreAlertOneDayNum)
|
||||
CheckStoreDayAlert(storeList, CheckStoreAlertOneWeekDayNum)
|
||||
CheckStoreRiskOrderAlert(storeList, CheckStoreAlertOneDayNum)
|
||||
storeAlertDataWrapper.InsertStoreAlertList()
|
||||
storeAlertDataWrapper.ClearData()
|
||||
}
|
||||
|
||||
func ScheduleCheckStoreAlert() {
|
||||
ScheduleTimerFunc("ScheduleCheckStoreAlert", func() {
|
||||
CheckStoreAlert(jxcontext.AdminCtx)
|
||||
}, checkStoreAlertTimeList)
|
||||
if EnableCheckStoreAlert {
|
||||
ScheduleTimerFunc("ScheduleCheckStoreAlert", func() {
|
||||
CheckStoreAlert(jxcontext.AdminCtx, nil)
|
||||
}, checkStoreAlertTimeList)
|
||||
}
|
||||
}
|
||||
|
||||
func GetStoreAlertList(storeIDList []int, cityCode int, keyWord string, beginTime, endTime time.Time, offset, pageSize int) (storeAlertData model.StoreAlertData, err error) {
|
||||
db := dao.GetDB()
|
||||
storeAlertList, err := dao.GetStoreAlertList(db, storeIDList, cityCode, keyWord, beginTime, endTime)
|
||||
if err == nil && len(storeAlertList) > 0 {
|
||||
offset = jxutils.FormalizePageOffset(offset)
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
var pagedStoreAlertList []*model.StoreAlertEx
|
||||
for i := offset; i < offset+pageSize && i < len(storeAlertList); i++ {
|
||||
pagedStoreAlertList = append(pagedStoreAlertList, storeAlertList[i])
|
||||
}
|
||||
|
||||
storeAlertData.TotalCount = len(storeAlertList)
|
||||
storeAlertData.StoreAlertList = pagedStoreAlertList
|
||||
}
|
||||
|
||||
return storeAlertData, err
|
||||
}
|
||||
|
||||
@@ -105,6 +105,7 @@ func Init() {
|
||||
dao.UpdateActStatusByTime(dao.GetDB(), time.Now().Add(-48*time.Hour))
|
||||
}, updateActStatusTimeList)
|
||||
ScheduleScoreStore()
|
||||
ScheduleCheckStoreAlert()
|
||||
}
|
||||
ScheduleTimerFunc("AutoSaleStoreSku", func() {
|
||||
cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil, false)
|
||||
|
||||
@@ -64,6 +64,8 @@ const (
|
||||
WX_AFS_ORDER_STATUS_CHANGED_TEMPLATE_ID = "99T33rrXX0VboO1hljs4x8dDoLiSj3QX_rOikPHIXkg"
|
||||
|
||||
WS_NOTIFY_STORE_STATUS_CHHANGED_TEMPLATE_ID = "Fl0vOnBKTQqRFx3-shGKxdCnxMdQXNeODzgkuwd7oxw"
|
||||
|
||||
WX_STORE_ALERT_TEMPLATE_ID = "0AjzVl1wPl6iO4nFOS4IEsJYSzBymlT37DciIvcCOxE"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -83,6 +85,7 @@ var (
|
||||
debugOpenIDMap = map[string]int{
|
||||
"oYN_usk0AeGc_C6VEZfmFQP5VHMQ": 1, // 周小扬
|
||||
"oYN_ust9hXKEvEv0X6Mq6nlAWs_E": 1, // me
|
||||
"oYN_usqnpGVQ4xxlao_yybsbYJh4": 1, // 朱丹
|
||||
}
|
||||
)
|
||||
|
||||
@@ -144,7 +147,7 @@ func GetWeixinOpenIDsFromStoreID(storeID int) (retVal []string) {
|
||||
func SendMsgToStore(storeID int, templateID, downloadURL, miniPageURL string, data interface{}) (err error) {
|
||||
globals.SugarLogger.Debugf("SendMsgToStore storeID:%d, templateID:%s, downloadURL:%s, miniPageURL:%s", storeID, templateID, downloadURL, miniPageURL)
|
||||
if storeID == 0 { // 测试,只发给我
|
||||
// SmartMessageTemplateSend("oYN_ust9hXKEvEv0X6Mq6nlAWs_E", templateID, downloadURL, miniPageURL, data)
|
||||
//SmartMessageTemplateSend("oYN_usk0AeGc_C6VEZfmFQP5VHMQ", templateID, downloadURL, miniPageURL, data)
|
||||
} else {
|
||||
openIDs := GetWeixinOpenIDsFromStoreID(storeID)
|
||||
successCount := 0
|
||||
@@ -637,3 +640,32 @@ func NotifyStoreStatusChanged(openUserID, title, content string) (err error) {
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func NotifyStoreAlertMessage(storeID int, storeName, title, content string) (err error) {
|
||||
globals.SugarLogger.Debugf("NotifyStoreAlertMessage storeID:%d, storeName:%d, title:%s, content:%s", storeID, storeName, title, content)
|
||||
templateID := WX_STORE_ALERT_TEMPLATE_ID
|
||||
msgID, msgStatusID := -1, -1
|
||||
fileURL := globals.WxBackstageHost + fmt.Sprintf(WX_TO_SHOW_MSG, msgID, msgStatusID)
|
||||
data := map[string]interface{}{
|
||||
"first": map[string]interface{}{
|
||||
"value": "",
|
||||
"color": "#333333",
|
||||
},
|
||||
"keyword1": map[string]interface{}{
|
||||
"value": storeName,
|
||||
"color": "#2E408E",
|
||||
},
|
||||
"keyword2": map[string]interface{}{
|
||||
"value": utils.GetCurTimeStr(),
|
||||
"color": "#2E408E",
|
||||
},
|
||||
"keyword3": map[string]interface{}{
|
||||
"value": content,
|
||||
"color": "#2E408E",
|
||||
},
|
||||
"remark": map[string]interface{}{
|
||||
"value": "",
|
||||
},
|
||||
}
|
||||
return SendMsgToStore(storeID, templateID, fileURL, fmt.Sprintf(WX_MINI_TO_SHOW_MSG, msgID, msgStatusID), data)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,72 @@ package model
|
||||
|
||||
import "time"
|
||||
|
||||
const (
|
||||
FieldPickTimeDaDa = "PickTimeDaDa"
|
||||
FieldBadComment = "BadComment"
|
||||
FieldAbsentGoods = "AbsentGoods"
|
||||
FieldPickTimeDaDaOneWeek = "PickTimeDaDaOneWeek"
|
||||
FieldBadCommentOneWeek = "BadCommentOneWeek"
|
||||
FieldAbsentGoodsOneWeek = "AbsentGoodsOneWeek"
|
||||
FieldStandardFinishTimeSelfDelivery = "StandardFinishTimeSelfDelivery"
|
||||
FieldStandardPickUpTimeDaDa = "StandardPickUpTimeDaDa"
|
||||
FieldNoOrderInMonth = "NoOrderInMonth"
|
||||
FieldRiskOrderCount = "RiskOrderCount"
|
||||
)
|
||||
|
||||
type StoreAlert struct {
|
||||
ID int `orm:"column(id)" json:"id"`
|
||||
CreatedTime time.Time `orm:"auto_now_add;type(datetime)" json:"createdTime"`
|
||||
AlertDate time.Time `orm:"auto_now_add;type(datetime)" json:"alertDate"`
|
||||
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||||
|
||||
PickTimeDaDa int `orm:"column(pick_time_order_dada)" json:"pickTimeDaDa"`
|
||||
BadComment int `orm:"column(bad_comment)" json:"badComment"`
|
||||
AbsentGoods int `orm:"column(absent_goods)" json:"absentGoods"`
|
||||
PickTimeDaDaOneWeek int `orm:"column(pick_time_dada_oneweek)" json:"pickTimeDaDaOneWeek"`
|
||||
BadCommentOneWeek int `orm:"column(bad_comment_oneweek)" json:"badCommentOneWeek"`
|
||||
AbsentGoodsOneWeek int `orm:"column(absent_goods_oneweek)" json:"absentGoodsOneWeek"`
|
||||
StandardFinishTimeSelfDelivery int `orm:"column(standard_finish_time_selfdelivery)" json:"standardFinishTimeSelfDelivery"`
|
||||
StandardPickUpTimeDaDa int `orm:"column(standard_pickup_time_dada)" json:"standardPickUpTimeDaDa"`
|
||||
|
||||
NoOrderInMonth int `json:"noOrderInMonth"`
|
||||
RiskOrderCount int `json:"riskOrderCount"`
|
||||
}
|
||||
|
||||
type StoreAlertEx struct {
|
||||
StoreAlert
|
||||
StoreName string `json:"storeName"`
|
||||
}
|
||||
|
||||
type StoreAlertProperty struct {
|
||||
Value string `json:"value"`
|
||||
Color string `json:"color"`
|
||||
}
|
||||
|
||||
type StoreAlertAdvanced struct {
|
||||
ID int `json:"id"`
|
||||
CreatedTime time.Time `json:"createdTime"`
|
||||
AlertDate time.Time `json:"alertDate"`
|
||||
StoreID int `json:"storeID"`
|
||||
|
||||
PickTimeDaDa StoreAlertProperty
|
||||
BadComment StoreAlertProperty
|
||||
AbsentGoods StoreAlertProperty
|
||||
PickTimeDaDaOneWeek StoreAlertProperty
|
||||
BadCommentOneWeek StoreAlertProperty
|
||||
AbsentGoodsOneWeek StoreAlertProperty
|
||||
StandardFinishTimeSelfDelivery StoreAlertProperty
|
||||
StandardPickUpTimeDaDa StoreAlertProperty
|
||||
|
||||
NoOrderInMonth StoreAlertProperty
|
||||
RiskOrderCount StoreAlertProperty
|
||||
}
|
||||
|
||||
type StoreAlertData struct {
|
||||
StoreAlertList []*StoreAlertEx `json:"storeAlertList"`
|
||||
TotalCount int `json:"totalCount"`
|
||||
}
|
||||
|
||||
type StoreOrderTime struct {
|
||||
StoreID int `orm:"column(store_id)"`
|
||||
OrderCreateTime time.Time `orm:"column(order_created_at)"`
|
||||
@@ -16,6 +82,6 @@ type StoreOrderStatus struct {
|
||||
}
|
||||
|
||||
type StoreOrder struct {
|
||||
StoreID int `orm:"column(store_id)"`
|
||||
VendorOrderID string `orm:"column(vendor_order_id)"`
|
||||
}
|
||||
StoreID int `orm:"column(store_id)"`
|
||||
VendorOrderID string `orm:"column(vendor_order_id)"`
|
||||
}
|
||||
|
||||
@@ -1,3 +1,49 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
func InsertStoreAlert(storeAlert *model.StoreAlert) error {
|
||||
storeAlert.CreatedTime = time.Now()
|
||||
return CreateEntity(nil, storeAlert)
|
||||
}
|
||||
|
||||
func GetStoreAlertList(db *DaoDB, storeIDList []int, cityCode int, keyWord string, beginTime, endTime time.Time) (storeAlertList []*model.StoreAlertEx, err error) {
|
||||
sql := `
|
||||
SELECT t1.*
|
||||
FROM store_alert t1
|
||||
JOIN store t2 ON t1.store_id = t2.id
|
||||
JOIN place t3 ON t2.city_code = t3.code
|
||||
WHERE DATE(t1.alert_date) >= DATE(?) AND DATE(t1.alert_date) <= DATE(?)
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
beginTime,
|
||||
endTime,
|
||||
}
|
||||
if len(storeIDList) > 0 {
|
||||
sql += `
|
||||
AND t2.id in (` + GenQuestionMarks(len(storeIDList)) + `)`
|
||||
sqlParams = append(sqlParams, storeIDList)
|
||||
}
|
||||
if cityCode > 0 {
|
||||
sql += `
|
||||
AND t3.code = ?`
|
||||
sqlParams = append(sqlParams, cityCode)
|
||||
}
|
||||
if keyWord != "" {
|
||||
sql += `
|
||||
AND (t2.id LIKE ? OR t2.name LIKE ? OR t3.name LIKE ?)`
|
||||
keyWord = fmt.Sprintf("%%%s%%", keyWord)
|
||||
sqlParams = append(sqlParams, keyWord, keyWord, keyWord)
|
||||
}
|
||||
sql += `
|
||||
ORDER BY t1.store_id
|
||||
`
|
||||
err = GetRows(db, &storeAlertList, sql, sqlParams)
|
||||
|
||||
return storeAlertList, err
|
||||
}
|
||||
|
||||
@@ -485,3 +485,29 @@ func (c *StoreController) GetStoreTotalScoreList() {
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 得到门店触犯红线/黄线数据
|
||||
// @Description 得到门店触犯红线/黄线数据
|
||||
// @Param token header string true "认证token"
|
||||
// @Param storeIDs formData string false "京西门店ID列表"
|
||||
// @Param cityCode formData int false "城市编码"
|
||||
// @Param keyword formData string false "关键字"
|
||||
// @Param beginTime formData string true "开始日期"
|
||||
// @Param endTime formData string true "结束日期"
|
||||
// @Param offset formData int false "列表起始序号(以0开始,缺省为0)"
|
||||
// @Param pageSize formData int false "列表页大小(缺省为50,-1表示全部)"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetStoreAlertList [post]
|
||||
func (c *StoreController) GetStoreAlertList() {
|
||||
c.callGetStoreAlertList(func(params *tStoreGetStoreAlertListParams) (retVal interface{}, errCode string, err error) {
|
||||
timeList, err := jxutils.BatchStr2Time(params.BeginTime, params.EndTime)
|
||||
if err == nil {
|
||||
var storeIDList []int
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil {
|
||||
retVal, err = misc.GetStoreAlertList(storeIDList, params.CityCode, params.Keyword, timeList[0], timeList[1], params.Offset, params.PageSize)
|
||||
}
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -320,13 +320,16 @@ func (c *TempOpController) CreateConsumerFromOrders() {
|
||||
// @Title 触犯红线通知
|
||||
// @Description 触犯红线通知
|
||||
// @Param token header string true "认证token"
|
||||
// @Param storeIDs formData string false "门店列表"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /CheckStoreAlert [post]
|
||||
func (c *TempOpController) CheckStoreAlert() {
|
||||
c.callCheckStoreAlert(func(params *tTempopCheckStoreAlertParams) (retVal interface{}, errCode string, err error) {
|
||||
misc.CheckStoreAlert(params.Ctx)
|
||||
|
||||
var storeIDs []int
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err == nil {
|
||||
misc.CheckStoreAlert(params.Ctx, storeIDs)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ func Init() {
|
||||
orm.RegisterModel(&model.CasbinRule{})
|
||||
orm.RegisterModel(&model.SensitiveWord{})
|
||||
orm.RegisterModel(&model.StoreScore{})
|
||||
orm.RegisterModel(&model.StoreAlert{})
|
||||
orm.RegisterModel(&model.FoodRecipe{}, &model.FoodRecipeStep{}, &model.FoodRecipeItem{}, &model.FoodRecipeItemChoice{}, &model.FoodRecipeUser{})
|
||||
orm.RegisterModel(&model.DataResource{})
|
||||
|
||||
|
||||
@@ -1242,6 +1242,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||
beego.ControllerComments{
|
||||
Method: "GetStoreAlertList",
|
||||
Router: `/GetStoreAlertList`,
|
||||
AllowHTTPMethods: []string{"post"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||
beego.ControllerComments{
|
||||
Method: "GetStoreCourierMaps",
|
||||
|
||||
Reference in New Issue
Block a user