门店红线/黄线统计-写入数据库
This commit is contained in:
@@ -2,15 +2,24 @@ package misc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
|
"reflect"
|
||||||
"time"
|
"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/jxstore/cms"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"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"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
EnableCheckStoreAlert = true
|
||||||
|
EnableSendStoreAlert = true
|
||||||
|
|
||||||
IncludeToday = true
|
IncludeToday = true
|
||||||
CheckStoreAlertOneMonthDayNum = 30
|
CheckStoreAlertOneMonthDayNum = 30
|
||||||
CheckStoreAlertOneDayNum = 1
|
CheckStoreAlertOneDayNum = 1
|
||||||
@@ -26,10 +35,10 @@ const (
|
|||||||
OneDayName = "单日"
|
OneDayName = "单日"
|
||||||
OneWeekDayName = "七日"
|
OneWeekDayName = "七日"
|
||||||
OneMonthDayName = "三十日"
|
OneMonthDayName = "三十日"
|
||||||
YellowAlertInfo = "您的店铺京西菜市-%s,由于%s%s%s%v%%,可能会被系统下线,请及时补救。"
|
YellowAlertInfo = "您的店铺京西菜市-%s,由于%s%s%s%d%%,可能会被系统下线,请及时补救。"
|
||||||
RedAlertInfo = "您的店铺京西菜市-%s,由于%s%s%s%v%%,会被系统下线,需要马上补救。"
|
RedAlertInfo = "您的店铺京西菜市-%s,由于%s%s%s%d%%,会被系统下线,需要马上补救。"
|
||||||
NoOrderAlertInfo = "您的店铺京西菜市-%s,由于近%s无订单,会被系统下线,需要马上补救。"
|
NoOrderAlertInfo = "您的店铺京西菜市-%s,由于近%s无订单,会被系统下线,需要马上补救。"
|
||||||
RiskOrderAlertInfo = "系统检测到您的店铺可能有虚假定单,定单号为:%s,可能会被罚款,请及时与运营联系!"
|
RiskOrderAlertInfo = "您的店铺京西菜市-%s,可能有虚假定单,定单号为:%s,可能会被罚款,请及时与运营联系!"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -44,8 +53,40 @@ var (
|
|||||||
AlertTypeStandardFinishTimeOrderSelfDelivery: "按时履约率(商家自送)",
|
AlertTypeStandardFinishTimeOrderSelfDelivery: "按时履约率(商家自送)",
|
||||||
AlertTypeStandardPickUpTimeOrderDaDa: "10分钟取货完成率(达达)",
|
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) {
|
func ConvertListToMap(listData []*model.StoreCount) (mapData map[int]int) {
|
||||||
mapData = make(map[int]int)
|
mapData = make(map[int]int)
|
||||||
for _, value := range listData {
|
for _, value := range listData {
|
||||||
@@ -67,7 +108,7 @@ func ConvertListToMapEx(listData []*model.StoreOrder) (mapData map[int][]string)
|
|||||||
return mapData
|
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 dayNum == CheckStoreAlertOneDayNum {
|
||||||
if isRedAlert {
|
if isRedAlert {
|
||||||
info = fmt.Sprintf(RedAlertInfo, storeName, OneDayName, AlertTypeNameMap[alertType], logicCondition, ratio)
|
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
|
return info
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckAlert(alertType int, dayNum int, ratio float64, count int) (isYellowAlert, isRedAlert bool, logicCondtion string, outRatio float64) {
|
func CheckAlert(alertType int, dayNum int, ratio int, count int) (isYellowAlert, isRedAlert bool, logicCondtion string, outRatio int) {
|
||||||
yellowRatio := float64(-1)
|
yellowRatio := -1
|
||||||
redRatio := float64(-1)
|
redRatio := -1
|
||||||
extraCount := -1
|
extraCount := -1
|
||||||
conditionLessEqual := false
|
conditionLessEqual := false
|
||||||
|
|
||||||
@@ -158,25 +199,29 @@ func CheckAlert(alertType int, dayNum int, ratio float64, count int) (isYellowAl
|
|||||||
return isYellowAlert, isRedAlert, logicCondtion, outRatio
|
return isYellowAlert, isRedAlert, logicCondtion, outRatio
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendAlertInfo(storeID int, alertInfo string) {
|
func SendAlertInfo(storeID int, storeName, alertInfo string) {
|
||||||
fmt.Printf("SendAlertInfo:%d %s\n", storeID, alertInfo)
|
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) {
|
func SendAlertInfoWrapper(storeID int, storeName string, dayNum, alertType, count, totalCount int) {
|
||||||
if totalCount > 0 {
|
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)
|
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, logicCondtion, outRatio)
|
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()
|
db := dao.GetDB()
|
||||||
//拣货履约订单(达达)
|
//拣货履约订单(达达)
|
||||||
pickTimeOrderCountDaDaList, _ := dao.GetStandardPickTimeOrderCountByDaDa(db, dayNum, IncludeToday)
|
pickTimeOrderCountDaDaList, _ := dao.GetStandardPickTimeOrderCountByDaDa(db, dayNum, IncludeToday)
|
||||||
@@ -219,7 +264,7 @@ func CheckStoreDayAlert(storeMapData map[int]*cms.StoreExt, dayNum int) {
|
|||||||
standardPickUpTimeOrderCountDaDaMapData = ConvertListToMap(standardPickUpTimeOrderCountDaDaList)
|
standardPickUpTimeOrderCountDaDaMapData = ConvertListToMap(standardPickUpTimeOrderCountDaDaList)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, storeInfo := range storeMapData {
|
for _, storeInfo := range storeList {
|
||||||
storeID := storeInfo.ID
|
storeID := storeInfo.ID
|
||||||
storeName := storeInfo.Name
|
storeName := storeInfo.Name
|
||||||
count := pickTimeOrderCountDaDaMapData[storeID]
|
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()
|
db := dao.GetDB()
|
||||||
storeCountList, _ := dao.GetFinishOrderCountByDayNum(db, CheckStoreAlertOneMonthDayNum, IncludeToday)
|
storeCountList, _ := dao.GetFinishOrderCountByDayNum(db, CheckStoreAlertOneMonthDayNum, IncludeToday)
|
||||||
storeCountMapData := make(map[int]int)
|
storeCountMapData := make(map[int]int)
|
||||||
@@ -252,22 +297,24 @@ func CheckStoreMonthAlert(storeMapData map[int]*cms.StoreExt) {
|
|||||||
storeCountMapData[value.StoreID] = value.Count
|
storeCountMapData[value.StoreID] = value.Count
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, storeInfo := range storeMapData {
|
for _, storeInfo := range storeList {
|
||||||
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, 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()
|
db := dao.GetDB()
|
||||||
storeOrderList, _ := dao.GetRiskOrderCount(db, dayNum, IncludeToday)
|
storeOrderList, _ := dao.GetRiskOrderCount(db, dayNum, IncludeToday)
|
||||||
storeOrderMapData := ConvertListToMapEx(storeOrderList)
|
storeOrderMapData := ConvertListToMapEx(storeOrderList)
|
||||||
for _, storeInfo := range storeMapData {
|
for _, storeInfo := range storeList {
|
||||||
storeID := storeInfo.ID
|
storeID := storeInfo.ID
|
||||||
|
storeName := storeInfo.Name
|
||||||
vendorOrderIDList := storeOrderMapData[storeID]
|
vendorOrderIDList := storeOrderMapData[storeID]
|
||||||
if vendorOrderIDList != nil {
|
if vendorOrderIDList != nil {
|
||||||
vendorOrderIDStr := ""
|
vendorOrderIDStr := ""
|
||||||
@@ -278,8 +325,9 @@ func CheckStoreRiskOrderAlert(storeMapData map[int]*cms.StoreExt, dayNum int) {
|
|||||||
vendorOrderIDStr += "," + vendorOrderID
|
vendorOrderIDStr += "," + vendorOrderID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
alertInfo := fmt.Sprintf(RiskOrderAlertInfo, vendorOrderIDStr)
|
alertInfo := fmt.Sprintf(RiskOrderAlertInfo, storeName, vendorOrderIDStr)
|
||||||
SendAlertInfo(storeID, alertInfo)
|
SendAlertInfo(storeID, storeName, alertInfo)
|
||||||
|
storeAlertDataWrapper.SetData(storeID, model.FieldRiskOrderCount, len(vendorOrderIDList))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -288,22 +336,43 @@ func GetWeekDay() int {
|
|||||||
return int(time.Now().Weekday())
|
return int(time.Now().Weekday())
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckStoreAlert(ctx *jxcontext.Context) {
|
func CheckStoreAlert(ctx *jxcontext.Context, storeIDList []int) {
|
||||||
|
storeAlertDataWrapper.InitData()
|
||||||
storeList, _ := GetStoreList(ctx)
|
storeList, _ := GetStoreList(ctx)
|
||||||
storeMapData := make(map[int]*cms.StoreExt)
|
storeIDMap := jxutils.IntList2Map(storeIDList)
|
||||||
for _, value := range storeList {
|
storeList = GetFilterStoreListEx(storeList, storeIDMap)
|
||||||
storeMapData[value.ID] = value
|
|
||||||
}
|
|
||||||
if GetWeekDay() == MonthCheckOnWeekDay {
|
if GetWeekDay() == MonthCheckOnWeekDay {
|
||||||
CheckStoreMonthAlert(storeMapData)
|
CheckStoreMonthAlert(storeList)
|
||||||
}
|
}
|
||||||
CheckStoreDayAlert(storeMapData, CheckStoreAlertOneDayNum)
|
CheckStoreDayAlert(storeList, CheckStoreAlertOneDayNum)
|
||||||
CheckStoreDayAlert(storeMapData, CheckStoreAlertOneWeekDayNum)
|
CheckStoreDayAlert(storeList, CheckStoreAlertOneWeekDayNum)
|
||||||
CheckStoreRiskOrderAlert(storeMapData, CheckStoreAlertOneDayNum)
|
CheckStoreRiskOrderAlert(storeList, CheckStoreAlertOneDayNum)
|
||||||
|
storeAlertDataWrapper.InsertStoreAlertList()
|
||||||
|
storeAlertDataWrapper.ClearData()
|
||||||
}
|
}
|
||||||
|
|
||||||
func ScheduleCheckStoreAlert() {
|
func ScheduleCheckStoreAlert() {
|
||||||
ScheduleTimerFunc("ScheduleCheckStoreAlert", func() {
|
if EnableCheckStoreAlert {
|
||||||
CheckStoreAlert(jxcontext.AdminCtx)
|
ScheduleTimerFunc("ScheduleCheckStoreAlert", func() {
|
||||||
}, checkStoreAlertTimeList)
|
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))
|
dao.UpdateActStatusByTime(dao.GetDB(), time.Now().Add(-48*time.Hour))
|
||||||
}, updateActStatusTimeList)
|
}, updateActStatusTimeList)
|
||||||
ScheduleScoreStore()
|
ScheduleScoreStore()
|
||||||
|
ScheduleCheckStoreAlert()
|
||||||
}
|
}
|
||||||
ScheduleTimerFunc("AutoSaleStoreSku", func() {
|
ScheduleTimerFunc("AutoSaleStoreSku", func() {
|
||||||
cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil, false)
|
cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil, false)
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ const (
|
|||||||
WX_AFS_ORDER_STATUS_CHANGED_TEMPLATE_ID = "99T33rrXX0VboO1hljs4x8dDoLiSj3QX_rOikPHIXkg"
|
WX_AFS_ORDER_STATUS_CHANGED_TEMPLATE_ID = "99T33rrXX0VboO1hljs4x8dDoLiSj3QX_rOikPHIXkg"
|
||||||
|
|
||||||
WS_NOTIFY_STORE_STATUS_CHHANGED_TEMPLATE_ID = "Fl0vOnBKTQqRFx3-shGKxdCnxMdQXNeODzgkuwd7oxw"
|
WS_NOTIFY_STORE_STATUS_CHHANGED_TEMPLATE_ID = "Fl0vOnBKTQqRFx3-shGKxdCnxMdQXNeODzgkuwd7oxw"
|
||||||
|
|
||||||
|
WX_STORE_ALERT_TEMPLATE_ID = "0AjzVl1wPl6iO4nFOS4IEsJYSzBymlT37DciIvcCOxE"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -83,6 +85,7 @@ var (
|
|||||||
debugOpenIDMap = map[string]int{
|
debugOpenIDMap = map[string]int{
|
||||||
"oYN_usk0AeGc_C6VEZfmFQP5VHMQ": 1, // 周小扬
|
"oYN_usk0AeGc_C6VEZfmFQP5VHMQ": 1, // 周小扬
|
||||||
"oYN_ust9hXKEvEv0X6Mq6nlAWs_E": 1, // me
|
"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) {
|
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)
|
globals.SugarLogger.Debugf("SendMsgToStore storeID:%d, templateID:%s, downloadURL:%s, miniPageURL:%s", storeID, templateID, downloadURL, miniPageURL)
|
||||||
if storeID == 0 { // 测试,只发给我
|
if storeID == 0 { // 测试,只发给我
|
||||||
// SmartMessageTemplateSend("oYN_ust9hXKEvEv0X6Mq6nlAWs_E", templateID, downloadURL, miniPageURL, data)
|
//SmartMessageTemplateSend("oYN_usk0AeGc_C6VEZfmFQP5VHMQ", templateID, downloadURL, miniPageURL, data)
|
||||||
} else {
|
} else {
|
||||||
openIDs := GetWeixinOpenIDsFromStoreID(storeID)
|
openIDs := GetWeixinOpenIDsFromStoreID(storeID)
|
||||||
successCount := 0
|
successCount := 0
|
||||||
@@ -637,3 +640,32 @@ func NotifyStoreStatusChanged(openUserID, title, content string) (err error) {
|
|||||||
})
|
})
|
||||||
return err
|
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"
|
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 {
|
type StoreOrderTime struct {
|
||||||
StoreID int `orm:"column(store_id)"`
|
StoreID int `orm:"column(store_id)"`
|
||||||
OrderCreateTime time.Time `orm:"column(order_created_at)"`
|
OrderCreateTime time.Time `orm:"column(order_created_at)"`
|
||||||
@@ -16,6 +82,6 @@ type StoreOrderStatus struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type StoreOrder struct {
|
type StoreOrder struct {
|
||||||
StoreID int `orm:"column(store_id)"`
|
StoreID int `orm:"column(store_id)"`
|
||||||
VendorOrderID string `orm:"column(vendor_order_id)"`
|
VendorOrderID string `orm:"column(vendor_order_id)"`
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,49 @@
|
|||||||
package dao
|
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
|
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 触犯红线通知
|
// @Title 触犯红线通知
|
||||||
// @Description 触犯红线通知
|
// @Description 触犯红线通知
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
|
// @Param storeIDs formData string false "门店列表"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /CheckStoreAlert [post]
|
// @router /CheckStoreAlert [post]
|
||||||
func (c *TempOpController) CheckStoreAlert() {
|
func (c *TempOpController) CheckStoreAlert() {
|
||||||
c.callCheckStoreAlert(func(params *tTempopCheckStoreAlertParams) (retVal interface{}, errCode string, err error) {
|
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
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ func Init() {
|
|||||||
orm.RegisterModel(&model.CasbinRule{})
|
orm.RegisterModel(&model.CasbinRule{})
|
||||||
orm.RegisterModel(&model.SensitiveWord{})
|
orm.RegisterModel(&model.SensitiveWord{})
|
||||||
orm.RegisterModel(&model.StoreScore{})
|
orm.RegisterModel(&model.StoreScore{})
|
||||||
|
orm.RegisterModel(&model.StoreAlert{})
|
||||||
orm.RegisterModel(&model.FoodRecipe{}, &model.FoodRecipeStep{}, &model.FoodRecipeItem{}, &model.FoodRecipeItemChoice{}, &model.FoodRecipeUser{})
|
orm.RegisterModel(&model.FoodRecipe{}, &model.FoodRecipeStep{}, &model.FoodRecipeItem{}, &model.FoodRecipeItemChoice{}, &model.FoodRecipeUser{})
|
||||||
orm.RegisterModel(&model.DataResource{})
|
orm.RegisterModel(&model.DataResource{})
|
||||||
|
|
||||||
|
|||||||
@@ -1242,6 +1242,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: 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.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "GetStoreCourierMaps",
|
Method: "GetStoreCourierMaps",
|
||||||
|
|||||||
Reference in New Issue
Block a user