fix
This commit is contained in:
parent
959a0d00b6
commit
4670c706fc
|
@ -222,6 +222,11 @@ func (m *ordersModel) CountAll(
|
|||
return
|
||||
}
|
||||
|
||||
func (m *ordersModel) CountErrHour() (res int64, err error) {
|
||||
res, err = m.GetDb().Where("(transfer_status = 4 or transfer_status = 5) and created_at >= NOW() + INTERVAL 7 HOUR").Table("orders").Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (m *ordersModel) Create(orders *Orders) (affected int64, err error) {
|
||||
orders.CreatedAt = time.Now()
|
||||
affected, err = m.GetDb().Insert(orders)
|
||||
|
|
|
@ -2,13 +2,11 @@ package transfersys
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
mermod "com.snow.auto_monitor/app/models/merchant"
|
||||
models "com.snow.auto_monitor/app/models/orders"
|
||||
promod "com.snow.auto_monitor/app/models/product"
|
||||
"com.snow.auto_monitor/app/services/device"
|
||||
dingServ "com.snow.auto_monitor/app/services/dingding"
|
||||
"com.snow.auto_monitor/app/utils/rdbdq"
|
||||
)
|
||||
|
@ -45,35 +43,42 @@ func FinishOrder(orders *models.Orders) (affected int64, err error) {
|
|||
|
||||
if orders.TransferStatus == 4 || orders.TransferStatus == 5 {
|
||||
orders.Status = orders.TransferStatus - 1
|
||||
device, err := device.Search(0, orders.DeviceNo, "", 0, "", "", 1, 1)
|
||||
// device, err := device.Search(0, orders.DeviceNo, "", 0, "", "", 1, 1)
|
||||
// if err != nil {
|
||||
// return 0, err
|
||||
// }
|
||||
// orderDetail, _, err := models.GetInstance().GetById(orders.Id)
|
||||
// if err != nil {
|
||||
// return 0, err
|
||||
// }
|
||||
// var deviceNumber int64 = -1
|
||||
// if device != nil {
|
||||
// deviceNumber = device[0].Code
|
||||
// }
|
||||
// dingStr := fmt.Sprintf(
|
||||
// `
|
||||
// - 异常设备: %d 号机;
|
||||
// - 异常单号: %s;
|
||||
// - 充值账号: %s;
|
||||
// - 产品号: %d;
|
||||
// - 失败原因: %s;
|
||||
// - 失败时间: %s;
|
||||
// `,
|
||||
// deviceNumber,
|
||||
// orderDetail.OutTradeNo,
|
||||
// orderDetail.RechargeAccount,
|
||||
// orders.ProductId,
|
||||
// orders.FailReason,
|
||||
// orderDetail.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||
// )
|
||||
count, err := models.GetInstance().CountErrHour()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
orderDetail, _, err := models.GetInstance().GetById(orders.Id)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
if count > 5 {
|
||||
dingStr := "新的设备异常提醒,一小时内有超过5台设备异常啦!快去监控系统查看(已处理请忽略本条信息) "
|
||||
dingServ.DingSend("订单异常", dingStr, true)
|
||||
}
|
||||
var deviceNumber int64 = -1
|
||||
if device != nil {
|
||||
deviceNumber = device[0].Code
|
||||
}
|
||||
dingStr := fmt.Sprintf(
|
||||
`
|
||||
- 异常设备: %d 号机;
|
||||
- 异常单号: %s;
|
||||
- 充值账号: %s;
|
||||
- 产品号: %d;
|
||||
- 失败原因: %s;
|
||||
- 失败时间: %s;
|
||||
`,
|
||||
deviceNumber,
|
||||
orderDetail.OutTradeNo,
|
||||
orderDetail.RechargeAccount,
|
||||
orders.ProductId,
|
||||
orders.FailReason,
|
||||
orderDetail.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||
)
|
||||
dingServ.DingSend("订单异常", dingStr, true)
|
||||
}
|
||||
|
||||
affected, err = models.GetInstance().SetDealingOrder(orders)
|
||||
|
|
Loading…
Reference in New Issue