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

94 lines
2.1 KiB
Go
Raw Normal View History

2024-07-12 18:11:21 +08:00
package orders
import (
models "com.snow.auto_monitor/app/models/orders"
)
func GetLimitStart(limit int, page int) (int, int) {
if limit <= 0 {
limit = 20
}
if page > 0 {
page = (page - 1) * limit
} else {
page = 0
}
return limit, page
}
func GetById(id int64) (res *models.Orders, err error) {
res, _, err = models.GetInstance().GetById(id)
return
}
func Search(id int64,
order_no string,
merchant_id int64,
product_id int64,
2024-08-07 13:46:10 +08:00
device_no string,
2024-07-12 18:11:21 +08:00
out_trade_no string,
recharge_account string,
account_type int64,
status int64,
transfer_status int64,
startTime string,
endTime string,
limit int,
page int) (res []*models.Orders, err error) {
limit, page = GetLimitStart(limit, page)
2024-08-07 13:46:10 +08:00
res, err = models.GetInstance().Search(id, order_no, merchant_id, product_id, device_no, out_trade_no,
2024-07-12 18:11:21 +08:00
recharge_account, account_type, status, transfer_status,
startTime, endTime, limit, page)
return
}
func CountAll(id int64,
order_no string,
merchant_id int64,
product_id int64,
2024-08-07 13:46:10 +08:00
device_no string,
2024-07-12 18:11:21 +08:00
out_trade_no string,
recharge_account string,
account_type int64,
status int64,
transfer_status int64,
startTime string,
endTime string) (res int64, err error) {
2024-08-21 10:18:34 +08:00
res, err = models.GetInstance().CountAll(id, order_no, merchant_id, product_id, device_no, out_trade_no,
2024-07-12 18:11:21 +08:00
recharge_account, account_type, status, transfer_status,
startTime, endTime)
return
}
func Create(orders *models.Orders) (affected int64, err error) {
affected, err = models.GetInstance().Create(orders)
return
}
func Update(orders *models.Orders) (affected int64, err error) {
affected, err = models.GetInstance().Update(orders)
return
}
2024-07-26 15:09:57 +08:00
func Cancel(id int64) (affected int64, err error) {
affected, err = models.GetInstance().CancelOrder(id)
return
}
2024-08-30 15:16:16 +08:00
func DangerousConfirm(id int64) (affected int64, err error) {
affected, err = models.GetInstance().DangerousConfirm(id)
return
}
2024-08-21 19:50:25 +08:00
func DangerousCancel(id int64) (affected int64, err error) {
affected, err = models.GetInstance().DangerousCancel(id)
return
}
2024-07-12 18:11:21 +08:00
func Delete(id int64) (affected int64, err error) {
affected, err = models.GetInstance().Delete(id)
return
}