94 lines
2.1 KiB
Go
94 lines
2.1 KiB
Go
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,
|
|
device_no string,
|
|
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)
|
|
res, err = models.GetInstance().Search(id, order_no, merchant_id, product_id, device_no, out_trade_no,
|
|
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,
|
|
device_no string,
|
|
out_trade_no string,
|
|
recharge_account string,
|
|
account_type int64,
|
|
|
|
status int64,
|
|
transfer_status int64,
|
|
startTime string,
|
|
endTime string) (res int64, err error) {
|
|
res, err = models.GetInstance().CountAll(id, order_no, merchant_id, product_id, device_no, out_trade_no,
|
|
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
|
|
}
|
|
|
|
func Cancel(id int64) (affected int64, err error) {
|
|
affected, err = models.GetInstance().CancelOrder(id)
|
|
return
|
|
}
|
|
|
|
func DangerousConfirm(id int64) (affected int64, err error) {
|
|
affected, err = models.GetInstance().DangerousConfirm(id)
|
|
return
|
|
}
|
|
|
|
func DangerousCancel(id int64) (affected int64, err error) {
|
|
affected, err = models.GetInstance().DangerousCancel(id)
|
|
return
|
|
}
|
|
|
|
func Delete(id int64) (affected int64, err error) {
|
|
affected, err = models.GetInstance().Delete(id)
|
|
return
|
|
}
|