This commit is contained in:
duyu 2024-08-26 18:04:49 +08:00
parent 959a0d00b6
commit 4670c706fc
2 changed files with 37 additions and 27 deletions

View File

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

View File

@ -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,36 +43,43 @@ 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
}
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"),
)
if count > 5 {
dingStr := "新的设备异常提醒一小时内有超过5台设备异常啦快去监控系统查看已处理请忽略本条信息 "
dingServ.DingSend("订单异常", dingStr, true)
}
}
affected, err = models.GetInstance().SetDealingOrder(orders)
return