getorders
This commit is contained in:
@@ -117,3 +117,7 @@ func Cash(ctx *jxcontext.Context, orderID string, payType int, vendorPayType str
|
||||
err = payHandler.CreateRefund()
|
||||
return errCode, err
|
||||
}
|
||||
|
||||
func GetOrders(ctx *jxcontext.Context, orderID string, orderType int, cityCodes []int, fromTime, toTime, keyword string, offset, pageSize int) (pageInfo *model.PagedInfo, err error) {
|
||||
return dao.GetOrders(dao.GetDB(), orderID, orderType, cityCodes, utils.Str2Time(fromTime), utils.Str2Time(toTime), keyword, offset, pageSize)
|
||||
}
|
||||
|
||||
@@ -92,3 +92,52 @@ func GetDeliveryOrders(db *DaoDB, userIDs []string, statuss []int, fromTime, toT
|
||||
}
|
||||
return pagedInfo, err
|
||||
}
|
||||
|
||||
func GetOrders(db *DaoDB, orderID string, orderType int, cityCodes []int, fromTime, toTime time.Time, keyword string, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) {
|
||||
var orders []*model.Order
|
||||
sql := `
|
||||
SELECT SQL_CALC_FOUND_ROWS a.*
|
||||
FROM order a
|
||||
JOIN user b ON b.user_id = a.user_id AND b.deleted_at = ?
|
||||
WHERE 1 = 1
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if orderID != "" {
|
||||
sql += ` AND a.order_id = ?`
|
||||
sqlParams = append(sqlParams, orderID)
|
||||
}
|
||||
if orderType != 0 {
|
||||
sql += ` AND a.type = ?`
|
||||
sqlParams = append(sqlParams, orderType)
|
||||
}
|
||||
if len(cityCodes) > 0 {
|
||||
sql += ` AND a.city_code IN ` + GenQuestionMarks(len(cityCodes)) + `)`
|
||||
sqlParams = append(sqlParams, cityCodes)
|
||||
}
|
||||
if fromTime != utils.ZeroTimeValue {
|
||||
sql += ` AND a.created_at >= ?`
|
||||
sqlParams = append(sqlParams, fromTime)
|
||||
}
|
||||
if toTime != utils.ZeroTimeValue {
|
||||
sql += ` AND a.created_at <= ?`
|
||||
sqlParams = append(sqlParams, toTime)
|
||||
}
|
||||
if keyword != "" {
|
||||
sql += ` AND (b.mobile LIKE ? OR b.name LIKE ?)`
|
||||
sqlParams = append(sqlParams, "%"+keyword+"%", "%"+keyword+"%")
|
||||
}
|
||||
sql += " LIMIT ? OFFSET ?"
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
sqlParams = append(sqlParams, pageSize, offset)
|
||||
Begin(db)
|
||||
defer Commit(db)
|
||||
if err = GetRows(db, &orders, sql, sqlParams); err == nil {
|
||||
pagedInfo = &model.PagedInfo{
|
||||
TotalCount: GetLastTotalRowCount(db),
|
||||
Data: orders,
|
||||
}
|
||||
}
|
||||
return pagedInfo, err
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package controllers
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"github.com/astaxie/beego"
|
||||
)
|
||||
|
||||
@@ -63,12 +64,21 @@ func (c *OrderController) CreateOrder() {
|
||||
// @Param token header string true "认证token"
|
||||
// @Param orderID query string false "订单号"
|
||||
// @Param orderType query int false "订单类型,1为支付,2为提现"
|
||||
// @Param cityCodes query string false "城市code列表"
|
||||
// @Param fromTime query string false "开始时间"
|
||||
// @Param toTime query string false "结束时间"
|
||||
// @Param keyword query string false "关键字"
|
||||
// @Param offset query int false "门店列表起始序号(以0开始,缺省为0)"
|
||||
// @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetOrders [get]
|
||||
func (c *OrderController) GetOrders() {
|
||||
c.callGetOrders(func(params *tOrderGetOrdersParams) (retVal interface{}, errCode string, err error) {
|
||||
var cityCodes []int
|
||||
if err = jxutils.Strings2Objs(params.CityCodes, &cityCodes); err == nil {
|
||||
retVal, err = cms.GetOrders(params.Ctx, params.OrderID, params.OrderType, cityCodes, params.FromTime, params.ToTime, params.Keyword, params.Offset, params.PageSize)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user