billdrtail
This commit is contained in:
@@ -8,15 +8,10 @@ import (
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/financial"
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/excel"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/dingding"
|
||||
"git.rosy.net.cn/jx-callback/business/authz"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jsonerr"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
@@ -24,7 +19,6 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"git.rosy.net.cn/jx-callback/globals/api2"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -123,16 +117,6 @@ func (*UserProvider) UpdateLastLogin(userID string, lastLoginType, fromIP string
|
||||
return err
|
||||
}
|
||||
|
||||
// func (*UserProvider) CreateUser(userID2, mobile, email, name string) (user auth2.IUser, err error) {
|
||||
// realUser := &model.User{
|
||||
// UserID2: userID2,
|
||||
// Mobile: mobile,
|
||||
// Email: email,
|
||||
// Name: name,
|
||||
// }
|
||||
// return realUser, CreateUser(realUser)
|
||||
// }
|
||||
|
||||
func init() {
|
||||
auth2.Init(userProvider)
|
||||
}
|
||||
@@ -300,31 +284,6 @@ func GetUsers(ctx *jxcontext.Context, userType int, keyword string, userIDs []st
|
||||
return pagedInfo, err
|
||||
}
|
||||
|
||||
func GetStoreRoleList(ctx *jxcontext.Context) (roleList []*authz.RoleInfo, err error) {
|
||||
return authz.StoreRoleList, nil
|
||||
}
|
||||
|
||||
func GetUserRoleList(ctx *jxcontext.Context, userID string) (roleList []*authz.RoleInfo, err error) {
|
||||
return api2.RoleMan.GetUserRoleList(userID)
|
||||
}
|
||||
|
||||
func GetRoleUserList(ctx *jxcontext.Context, r *authz.RoleInfo) (userIDList []string, err error) {
|
||||
return api2.RoleMan.GetRoleUserList(r)
|
||||
}
|
||||
|
||||
func GetRolesUserList(ctx *jxcontext.Context, rList []*authz.RoleInfo) (userIDMap map[string][]string, err error) {
|
||||
userIDMap = make(map[string][]string)
|
||||
for _, r := range rList {
|
||||
userIDList, err2 := api2.RoleMan.GetRoleUserList(r)
|
||||
if err = err2; err == nil {
|
||||
userIDMap[r.GetFullName()] = userIDList
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return userIDMap, err
|
||||
}
|
||||
|
||||
func checkUserType(userID string, userType int8) (err error) {
|
||||
userList, _, err := dao.GetUsers(dao.GetDB(), 0, "", []string{userID}, nil, nil, 0, 0)
|
||||
if err != nil {
|
||||
@@ -453,108 +412,6 @@ func GetSelfInfo(ctx *jxcontext.Context) (getSelfInfoResult *dao.GetSelfInfoResu
|
||||
return getSelfInfoResult, err
|
||||
}
|
||||
|
||||
func (d *GetJdUsersStruct) AppendData(jd JdUserStruct) {
|
||||
d.locker.RLock()
|
||||
defer d.locker.RUnlock()
|
||||
d.userMap = append(d.userMap, jd)
|
||||
}
|
||||
|
||||
func WriteToExcelJd(task *tasksch.SeqTask, jd []JdUserStruct) (err error) {
|
||||
var sheetList []*excel.Obj2ExcelSheetConfig
|
||||
var downloadURL, fileName string
|
||||
excelConf := &excel.Obj2ExcelSheetConfig{
|
||||
Title: "京东用户列表",
|
||||
Data: jd,
|
||||
CaptionList: titleListJdUser,
|
||||
}
|
||||
sheetList = append(sheetList, excelConf)
|
||||
if excelConf != nil {
|
||||
downloadURL, fileName, err = jxutils.UploadExeclAndPushMsg(sheetList, "京东用户列表")
|
||||
} else {
|
||||
baseapi.SugarLogger.Debug("WriteToExcel: JdUserStruct is nil!")
|
||||
}
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Errorf("WriteToExcel:upload %s,failed error:%v", fileName, err)
|
||||
} else {
|
||||
noticeMsg := fmt.Sprintf("[详情点我]path=%s, \n", downloadURL)
|
||||
task.SetNoticeMsg(noticeMsg)
|
||||
baseapi.SugarLogger.Debugf("WriteToExcel:upload %s, success, downloadURL:%s", fileName, downloadURL)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func DeleteUserInfo(ctx *jxcontext.Context, userID string) (err error) {
|
||||
db := dao.GetDB()
|
||||
sql := `
|
||||
UPDATE user
|
||||
SET status = ?
|
||||
WHERE user_id = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
model.NO,
|
||||
userID,
|
||||
}
|
||||
_, err = dao.ExecuteSQL(db, sql, sqlParams)
|
||||
|
||||
/* 删除离职人员门店市场人员 */
|
||||
sql2 := `
|
||||
UPDATE store t1
|
||||
LEFT JOIN user t2 ON t2.mobile = t1.market_man_phone AND t2.status <> 0
|
||||
SET t1.market_man_phone = ''
|
||||
WHERE t2.id IS NULL
|
||||
`
|
||||
_, err = dao.ExecuteSQL(db, sql2, nil)
|
||||
|
||||
/* 删除离职人员门店运营人员 */
|
||||
sql3 := `
|
||||
UPDATE store t1
|
||||
LEFT JOIN user t2 ON t2.mobile = t1.operator_phone AND t2.status <> 0
|
||||
SET t1.operator_phone = ''
|
||||
WHERE t2.id IS NULL
|
||||
`
|
||||
_, err = dao.ExecuteSQL(db, sql3, nil)
|
||||
|
||||
/* 删除离职人员门店运营人员 */
|
||||
sql4 := `
|
||||
UPDATE store t1
|
||||
LEFT JOIN user t2 ON t2.mobile = t1.operator_phone2 AND t2.status <> 0
|
||||
SET t1.operator_phone2 = ''
|
||||
WHERE t2.id IS NULL
|
||||
`
|
||||
_, err = dao.ExecuteSQL(db, sql4, nil)
|
||||
|
||||
/*删除离职人员的角色信息*/
|
||||
sql5 := `
|
||||
DELETE t1
|
||||
FROM casbin_rule t1
|
||||
LEFT JOIN user t2 ON t2.user_id = t1.v0 AND t2.status <> 0
|
||||
WHERE t2.id IS NULL
|
||||
`
|
||||
_, err = dao.ExecuteSQL(db, sql5, nil)
|
||||
|
||||
//删除token
|
||||
tokens, err := api.Cacher.Keys("TOKEN.V2." + userID + "*")
|
||||
for _, v := range tokens {
|
||||
err = api.Cacher.Del(v)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func CleanUserOrderSMSMark(ctx *jxcontext.Context) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
if time.Now().Day() == 1 {
|
||||
sql := `
|
||||
UPDATE user_order_sms
|
||||
SET sms_mark = ?
|
||||
`
|
||||
sqlParams := []interface{}{model.NO}
|
||||
_, err = dao.ExecuteSQL(db, sql, sqlParams)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func RefreshUserMemberStatus(ctx *jxcontext.Context) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package financial
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
@@ -33,3 +34,7 @@ func AddUserBill(db *dao.DaoDB, billID int64, userID string) (err error) {
|
||||
dao.WrapAddIDCULDEntity(userBillInsert, jxcontext.AdminCtx.GetUserName())
|
||||
return dao.CreateEntity(db, userBillInsert)
|
||||
}
|
||||
|
||||
func GetUserBillDetail(ctx *jxcontext.Context, userID, fromTime, toTime string, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) {
|
||||
return dao.GetUserBillDetail(dao.GetDB(), userID, utils.Str2Time(fromTime), utils.Str2Time(toTime), pageSize, offset)
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
@@ -51,3 +52,60 @@ func GetBillExpend(db *DaoDB, userID string, billType int, fromTime, toTime time
|
||||
err = GetRow(db, &billExpends, sql, sqlParams)
|
||||
return billExpends, err
|
||||
}
|
||||
|
||||
type UserBillDetail struct {
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
LastOperator string `json:"lastOperator"`
|
||||
BillType int `json:"billType"`
|
||||
Price int `json:"price"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
func GetUserBillDetail(db *DaoDB, userID string, fromTime, toTime time.Time, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) {
|
||||
var userBillDetails []*UserBillDetail
|
||||
sql := `
|
||||
SELECT SQL_CALC_FOUND_ROWS k.* FROM (
|
||||
SELECT a.created_at, a.last_operator, a.type bill_type, a.income_price price, 'income' type
|
||||
FROM bill_income a
|
||||
JOIN user_bill b ON a.bill_id = b.bill_id AND b.user_id = ?
|
||||
`
|
||||
sqlParams := []interface{}{userID}
|
||||
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)
|
||||
}
|
||||
sql += `
|
||||
UNION ALL
|
||||
SELECT a.created_at, a.last_operator, a.type bill_type, a.expend_price price, 'expend' type
|
||||
FROM bill_expend a
|
||||
JOIN user_bill b ON a.bill_id = b.bill_id AND b.user_id = ?
|
||||
`
|
||||
sqlParams = append(sqlParams, userID)
|
||||
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)
|
||||
}
|
||||
sql += `
|
||||
)k
|
||||
ORDER BY k.created_at LIMIT ? OFFSET ?
|
||||
`
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
sqlParams = append(sqlParams, pageSize, offset)
|
||||
Begin(db)
|
||||
defer Commit(db)
|
||||
if err = GetRows(db, &userBillDetails, sql, sqlParams...); err == nil {
|
||||
pagedInfo = &model.PagedInfo{
|
||||
TotalCount: GetLastTotalRowCount(db),
|
||||
Data: userBillDetails,
|
||||
}
|
||||
}
|
||||
return pagedInfo, err
|
||||
}
|
||||
|
||||
28
controllers/bill_controller.go
Normal file
28
controllers/bill_controller.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/financial"
|
||||
"github.com/astaxie/beego"
|
||||
)
|
||||
|
||||
type BillController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
// @Title 查看用户账户收支明细
|
||||
// @Description 查看用户账户收支明细
|
||||
// @Param token header string true "认证token"
|
||||
// @Param userID query string true "用户ID"
|
||||
// @Param fromTime query string false "开始时间"
|
||||
// @Param toTime 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 /GetUserBillDetail [get]
|
||||
func (c *BillController) GetUserBillDetail() {
|
||||
c.callGetUserBillDetail(func(params *tBillGetUserBillDetailParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = financial.GetUserBillDetail(params.Ctx, params.UserID, params.FromTime, params.ToTime, params.PageSize, params.Offset)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
@@ -177,20 +177,6 @@ func (c *Auth2Controller) UpdateUserByMiniInfo() {
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 禁用用户(删除离职用户信息)
|
||||
// @Description 禁用用户(删除离职用户信息)
|
||||
// @Param token header string true "认证token"
|
||||
// @Param userID query string true "用户userID"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /DeleteUserInfo [delete]
|
||||
func (c *User2Controller) DeleteUserInfo() {
|
||||
c.callDeleteUserInfo(func(params *tUser2DeleteUserInfoParams) (retVal interface{}, errCode string, err error) {
|
||||
err = cms.DeleteUserInfo(params.Ctx, params.UserID)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 会员充值
|
||||
// @Description 会员充值
|
||||
// @Param token header string false "认证token"
|
||||
|
||||
@@ -124,6 +124,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:BillController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:BillController"],
|
||||
beego.ControllerComments{
|
||||
Method: "GetUserBillDetail",
|
||||
Router: `/GetUserBillDetail`,
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:EventController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:EventController"],
|
||||
beego.ControllerComments{
|
||||
Method: "AddMessageGroup",
|
||||
@@ -358,15 +367,6 @@ 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: "DeleteUserInfo",
|
||||
Router: `/DeleteUserInfo`,
|
||||
AllowHTTPMethods: []string{"delete"},
|
||||
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: "GetBindAuthInfo",
|
||||
|
||||
@@ -46,6 +46,11 @@ func init() {
|
||||
&controllers.EventController{},
|
||||
),
|
||||
),
|
||||
beego.NSNamespace("/bill",
|
||||
beego.NSInclude(
|
||||
&controllers.BillController{},
|
||||
),
|
||||
),
|
||||
)
|
||||
beego.AddNamespace(ns)
|
||||
beego.AutoRouter(&controllers.WXPayController{})
|
||||
|
||||
Reference in New Issue
Block a user