aa
This commit is contained in:
@@ -602,3 +602,53 @@ func GetMyUnionOrders(db *DaoDB, userID string, statuss []int, vendorID, offset,
|
||||
}
|
||||
return page, err
|
||||
}
|
||||
|
||||
type GetUnionOrdersPageResult struct {
|
||||
model.UnionOrder
|
||||
Name string `json:"name"`
|
||||
Moble string `json:"moble"`
|
||||
}
|
||||
|
||||
func GetUnionOrdersPage(db *DaoDB, vendorIDs, statuss []int, beginTime, endTime time.Time, keyword string, offset, pageSize int) (page *model.PagedInfo, err error) {
|
||||
var orders []*GetUnionOrdersPageResult
|
||||
sql := `
|
||||
SELECT SQL_CALC_FOUND_ROWS a.*, b.name, b.mobile
|
||||
FROM union_order a
|
||||
LEFT JOIN user b ON a.user_id = b.user_id
|
||||
WHERE 1 = 1
|
||||
`
|
||||
sqlParams := []interface{}{}
|
||||
if len(vendorIDs) > 0 {
|
||||
sql += ` AND a.vendor_id IN (` + GenQuestionMarks(len(vendorIDs)) + `)`
|
||||
sqlParams = append(sqlParams, vendorIDs)
|
||||
}
|
||||
if len(statuss) > 0 {
|
||||
sql += ` AND a.status IN (` + GenQuestionMarks(len(statuss)) + `)`
|
||||
sqlParams = append(sqlParams, statuss)
|
||||
}
|
||||
if !utils.IsTimeZero(beginTime) {
|
||||
sql += ` AND a.order_settle_at > ?`
|
||||
sqlParams = append(sqlParams, beginTime)
|
||||
}
|
||||
if !utils.IsTimeZero(endTime) {
|
||||
sql += ` AND a.order_settle_at < ?`
|
||||
sqlParams = append(sqlParams, endTime)
|
||||
}
|
||||
if keyword != "" {
|
||||
keywordLike := "%" + keyword + "%"
|
||||
sql += ` AND (b.name LIKE ? OR b.mobile LIKE ? OR a.vendor_order_id LIKE ? OR a.goods_name LIKE ? OR a.comment LIKE ?)`
|
||||
sqlParams = append(sqlParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike)
|
||||
}
|
||||
sql += " LIMIT ? OFFSET ?"
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
sqlParams = append(sqlParams, pageSize, offset)
|
||||
txDB, _ := Begin(db)
|
||||
defer Commit(db, txDB)
|
||||
if err = GetRowsTx(txDB, &orders, sql, sqlParams...); err == nil {
|
||||
page = &model.PagedInfo{
|
||||
TotalCount: GetLastTotalRowCountTx(txDB),
|
||||
Data: orders,
|
||||
}
|
||||
}
|
||||
return page, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user