82 lines
1.8 KiB
Go
82 lines
1.8 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,
|
|
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, 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,
|
|
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, 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 Delete(id int64) (affected int64, err error) {
|
|
affected, err = models.GetInstance().Delete(id)
|
|
return
|
|
}
|