aa
This commit is contained in:
@@ -776,3 +776,74 @@ func UserMemberReport(ctx *jxcontext.Context, vendorID int, keyword string, offs
|
||||
}
|
||||
return page, err
|
||||
}
|
||||
|
||||
type OrderNotifyReportResult struct {
|
||||
}
|
||||
|
||||
func OrderNotifyReport(ctx *jxcontext.Context, storeIDs, brandIDs []int, vendorID, notifyType int, keyword string, isFinished bool, fromTime, toTime string, offset, pageSize int) (page *model.PagedInfo, err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
results []*OrderNotifyReportResult
|
||||
)
|
||||
sql := `
|
||||
SELECT *
|
||||
FROM goods_order a
|
||||
LEFT JOIN store b ON IF(a.store_id = 0 ,a.jx_store_id, a.store_id) = b.id
|
||||
LEFT JOIN user c ON c.mobile = b.market_man_phone
|
||||
LEFT JOIN user d ON d.mobile = b.operator_phone
|
||||
WHERE a.status = ? AND a.notify_type <> ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
model.OrderStatusFinished, 0,
|
||||
}
|
||||
if len(storeIDs) > 0 {
|
||||
sql += ` AND IF(a.jx_store_id != 0, a.jx_store_id, a.store_id) IN(` + dao.GenQuestionMarks(len(storeIDs)) + `)`
|
||||
sqlParams = append(sqlParams, storeIDs)
|
||||
}
|
||||
if len(brandIDs) > 0 {
|
||||
sql += ` AND b.brand_id IN(` + dao.GenQuestionMarks(len(brandIDs)) + `)`
|
||||
sqlParams = append(sqlParams, brandIDs)
|
||||
}
|
||||
if vendorID != -1 {
|
||||
sql += " AND a.vendor_id = ?"
|
||||
sqlParams = append(sqlParams, vendorID)
|
||||
}
|
||||
if notifyType != -1 {
|
||||
sql += " AND a.notify_type = ?"
|
||||
sqlParams = append(sqlParams, notifyType)
|
||||
}
|
||||
if keyword != "" {
|
||||
sql += " AND (b.name LIKE ? OR c.name LIKE ? OR d.name LIKE ? OR b.id = ? OR a.vendor_order_id = ?)"
|
||||
sqlParams = append(sqlParams, "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%", keyword, keyword)
|
||||
}
|
||||
if !utils.IsTimeZero(utils.Str2Time(fromTime)) {
|
||||
if isFinished {
|
||||
sql += " AND a.order_finished_at > ?"
|
||||
} else {
|
||||
sql += " AND a.order_created_at > ?"
|
||||
}
|
||||
}
|
||||
if !utils.IsTimeZero(utils.Str2Time(toTime)) {
|
||||
if isFinished {
|
||||
sql += " AND a.order_finished_at < ?"
|
||||
} else {
|
||||
sql += " AND a.order_created_at < ?"
|
||||
}
|
||||
}
|
||||
sql += `
|
||||
LIMIT ? OFFSET ?
|
||||
`
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
sqlParams = append(sqlParams, pageSize, offset)
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer dao.Commit(db, txDB)
|
||||
fmt.Println(sql)
|
||||
fmt.Println(sqlParams)
|
||||
if err = dao.GetRowsTx(txDB, &results, sql, sqlParams...); err == nil {
|
||||
page = &model.PagedInfo{
|
||||
TotalCount: dao.GetLastTotalRowCount2(db, txDB),
|
||||
Data: results,
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user