用户统计接口

This commit is contained in:
苏尹岚
2020-09-25 09:05:38 +08:00
parent 0b0930ccd1
commit 1ff25bfa33
4 changed files with 45 additions and 44 deletions

View File

@@ -1,9 +1,8 @@
package localjx
import (
"time"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/globals/api"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils"
@@ -14,12 +13,11 @@ import (
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"`
BuyCount int `json:"buyCount"`
ActualPayPrice int `json:"actualPayPrice"`
GoodCommentCount int `json:"goodCommentCount"`
BadCommentCount int `json:"badCommentCount"`
UserMembers []*model.UserMember `json:"userMembers"`
}
func GetJxShopUsers(ctx *jxcontext.Context, keyword string, offset, pageSize int) (pagedInfo *model.PagedInfo, err error) {
@@ -28,23 +26,24 @@ func GetJxShopUsers(ctx *jxcontext.Context, keyword string, offset, pageSize int
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 = ?
SELECT SQL_CALC_FOUND_ROWS DISTINCT a.*, b.buy_count, b.actual_pay_price
FROM user a,
(SELECT a.user_id, COUNT(*) buy_count, SUM(c.actual_pay_price) actual_pay_price
FROM user a
JOIN auth_bind b ON b.user_id = a.user_id AND b.deleted_at = ? AND b.type_id = ?
JOIN goods_order c ON c.user_id = a.user_id AND c.status <> ?
WHERE a.deleted_at = ?
GROUP BY 1) b
WHERE a.user_id = b.user_id
`
sqlParams := []interface{}{
utils.DefaultTimeValue, api.WeixinMiniAppID2,
model.OrderStatusCanceled,
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 += " AND (a.user_id LIKE ? OR a.name LIKE ? OR a.moblie LIKE ? OR a.user_id2 LIKE ?)"
sqlParams = append(sqlParams, "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%")
}
sql += "LIMIT ? OFFSET ?"
pageSize = jxutils.FormalizePageSize(pageSize)

View File

@@ -12,6 +12,7 @@ import (
"git.rosy.net.cn/jx-callback/business/jxutils/jsonerr"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/business/partner/purchase/jx/localjx"
"github.com/astaxie/beego"
)
@@ -533,3 +534,19 @@ func (c *User2Controller) GetUserAgreement() {
return retVal, "", err
})
}
// @Title 查询京西商城用户信息
// @Description 查询京西商城用户信息
// @Param token header string true "认证token"
// @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 /GetJxShopUsers [get]
func (c *User2Controller) GetJxShopUsers() {
c.callGetJxShopUsers(func(params *tUser2GetJxShopUsersParams) (retVal interface{}, errCode string, err error) {
retVal, err = localjx.GetJxShopUsers(params.Ctx, params.Keyword, params.Offset, params.PageSize)
return retVal, "", err
})
}

View File

@@ -283,18 +283,3 @@ func (c *JxOrderController) TestDefend() {
return retVal, "", err
})
}
// @Title 查询京西商城用户信息
// @Description 查询京西商城用户信息
// @Param token header string true "认证token"
// @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 /GetJxShopUsers [get]
func (c *JxOrderController) GetJxShopUsers() {
c.callGetJxShopUsers(func(params *tJxorderGetJxShopUsersParams) (retVal interface{}, errCode string, err error) {
return retVal, "", err
})
}

View File

@@ -700,15 +700,6 @@ func init() {
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:JxOrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:JxOrderController"],
beego.ControllerComments{
Method: "GetJxShopUsers",
Router: `/GetJxShopUsers`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:JxOrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:JxOrderController"],
beego.ControllerComments{
Method: "GetMatterOrderStatus",
@@ -2952,6 +2943,15 @@ func init() {
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"],
beego.ControllerComments{
Method: "GetJxShopUsers",
Router: `/GetJxShopUsers`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"],
beego.ControllerComments{
Method: "GetMyJxStoreList",