com.snow.auto_monitor/app/services/transfersys/transfersys.go

54 lines
1.1 KiB
Go
Raw Normal View History

2024-07-12 18:11:21 +08:00
package transfersys
import (
"errors"
2024-07-26 10:52:53 +08:00
"time"
2024-07-12 18:11:21 +08:00
mermod "com.snow.auto_monitor/app/models/merchant"
models "com.snow.auto_monitor/app/models/orders"
promod "com.snow.auto_monitor/app/models/product"
2024-07-26 10:52:53 +08:00
"com.snow.auto_monitor/app/utils/rdbdq"
2024-07-12 18:11:21 +08:00
)
func GetOrder() (res *models.Orders, err error) {
res, _, err = models.GetInstance().GetIdleOrder()
return
}
func FinishOrder(orders *models.Orders) (affected int64, err error) {
//验证商户是否存在
_, has, err := mermod.GetInstance().GetById(orders.MerchantId)
if err != nil {
return
}
if !has {
err = errors.New("商户不存在")
return
}
//验证产品是否存在
_, has, err = promod.GetInstance().GetById(orders.ProductId)
if err != nil {
return
}
if !has {
err = errors.New("产品不存在")
return
}
2024-07-16 11:05:28 +08:00
if orders.TransferStatus == 1 {
orders.Status = 1
}
if orders.TransferStatus == 4 || orders.TransferStatus == 5 {
orders.Status = orders.TransferStatus - 1
}
2024-07-12 18:11:21 +08:00
affected, err = models.GetInstance().SetDealingOrder(orders)
return
}
2024-07-26 10:52:53 +08:00
func AddCallback(order_id string) (err error) {
err = rdbdq.WriteOne("1_"+order_id, time.Now().Add(1*time.Second).Unix())
return
}