62 lines
1.9 KiB
Go
62 lines
1.9 KiB
Go
package localjx
|
|
|
|
import (
|
|
"time"
|
|
|
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
|
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
|
"git.rosy.net.cn/jx-callback/business/model"
|
|
|
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
|
)
|
|
|
|
type GetJxShopUsersResult struct {
|
|
model.User
|
|
RegisterTime time.Time `json:"registerTime"`
|
|
BuyCount int `json:"buyCount"`
|
|
ActualPayPrice int `json:"actualPayPrice"`
|
|
GoodComment string `json:"goodComment"`
|
|
BadComment string `json:"badComment"`
|
|
UserMembers []*model.UserMember `json:"userMembers"`
|
|
}
|
|
|
|
func GetJxShopUsers(ctx *jxcontext.Context, keyword string, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) {
|
|
var (
|
|
requestList []*GetJxShopUsersResult
|
|
db = dao.GetDB()
|
|
)
|
|
sql := `
|
|
SELECT SQL_CALC_FOUND_ROWS DISTINCT a.*, b.name user_name, c.name city_name
|
|
FROM store_audit a
|
|
JOIN user b ON b.user_id = a.user_id
|
|
JOIN place c ON c.code = a.city_code
|
|
WHERE a.deleted_at = ?
|
|
`
|
|
sqlParams := []interface{}{
|
|
utils.DefaultTimeValue,
|
|
}
|
|
// if len(statuss) > 0 {
|
|
// sql += " AND a.audit_status IN (" + GenQuestionMarks(len(statuss)) + ")"
|
|
// sqlParams = append(sqlParams, statuss)
|
|
// }
|
|
|
|
if keyword != "" {
|
|
sql += " AND (a.user_id LIKE ? OR a.name LIKE ? OR a.tel1 LIKE ? OR a.tel2 LIKE ? OR a.address LIKE ?)"
|
|
sqlParams = append(sqlParams, "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%")
|
|
}
|
|
sql += "LIMIT ? OFFSET ?"
|
|
pageSize = jxutils.FormalizePageSize(pageSize)
|
|
sqlParams = append(sqlParams, pageSize, offset)
|
|
dao.Begin(db)
|
|
defer dao.Commit(db)
|
|
if err = dao.GetRows(db, &requestList, sql, sqlParams...); err == nil {
|
|
return &model.PagedInfo{
|
|
TotalCount: dao.GetLastTotalRowCount(db),
|
|
Data: requestList,
|
|
}, nil
|
|
}
|
|
return pagedInfo, err
|
|
}
|