diff --git a/app/hdl/financial_center/hdl_withdraw.go b/app/hdl/financial_center/hdl_withdraw.go index 88f995c..079652c 100644 --- a/app/hdl/financial_center/hdl_withdraw.go +++ b/app/hdl/financial_center/hdl_withdraw.go @@ -25,6 +25,24 @@ import ( // @Failure 400 {object} md.Response "具体错误" // @Router /api/financialCenter/withdraw/setting [get] func GetWithdrawSetting(c *gin.Context) { + + // 等级列表 + levelDb := implement.NewUserLevelDb(db.Db) + levels, err1 := levelDb.UserLevelAllByAsc() + if err1 != nil { + e.OutErr(c, e.ERR_DB_ORM, err1.Error()) + return + } + levelsList := make([]map[string]interface{}, 0) + levelsMap := make(map[int]string) + for _, level := range levels { + levelsList = append(levelsList, map[string]interface{}{ + "id": level.Id, + "name": level.LevelName, + }) + levelsMap[level.Id] = level.LevelName + } + settingDb := implement.NewFinWithdrawSettingDb(db.Db) setting, err := settingDb.FinWithdrawSettingGetOne() if err != nil { @@ -107,6 +125,7 @@ func GetWithdrawSetting(c *gin.Context) { FirstWithdrawSet: firstWithdrawSet, CreateAt: setting.CreateAt, UpdateAt: setting.UpdateAt, + LevelList: levelsList, } e.OutSuc(c, resp, nil) @@ -220,37 +239,86 @@ func GetWithdrawApplyList(c *gin.Context) { } list := make([]md.GetWithdrawApplyListNode, len(*applies)) + parentIDs := make([]int64, len(*applies)) + UserIDs := make([]int64, len(*applies)) + for _, apply := range *applies { + parentIDs = append(parentIDs, apply.ParentID) + UserIDs = append(UserIDs, apply.UserID) + } + + // 查询上级 + userDb := implement.NewUserDb(db.Db) + parents, err := userDb.UserFindByParams(map[string]interface{}{ + "key": "id", + "value": parentIDs, + }) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + parentsMap := make(map[int64]model.User) + for _, parent := range parents { + parentsMap[parent.Id] = parent + } + + // 查询标签 + recordsDb := implement.NewUserTagRecordsDb(db.Db) + records, err := recordsDb.UserTagRecordsFindByParams(map[string]interface{}{ + "key": "uid", + "value": UserIDs, + }) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + recordsMap := make(map[int64][]md.TagNode) + for _, record := range *records { + temp := md.TagNode{ + TagID: record.TagId, + TagName: "", + } + tagName, ok := tagsMap[record.TagId] + temp.TagName = tagName + v, ok := recordsMap[record.Uid] + if ok { + v = append(v, temp) + } else { + recordsMap[record.Uid] = []md.TagNode{temp} + } + } + for i, apply := range *applies { list[i] = md.GetWithdrawApplyListNode{ - UserID: apply.UserID, - Nickname: apply.Nickname, - ParentID: apply.ParentID, - ParentPhone: apply.ParentPhone, - WithdrawType: apply.WithdrawType, - InviteCode: apply.InviteCode, - Amount: apply.Amount, - ActualReceipt: "", - SysFee: apply.SysFee, - State: apply.State, - ApplyAt: apply.ApplyAt, - PayAt: apply.PayAt, - Memo: apply.Memo, + UserID: apply.UserID, + Nickname: apply.Nickname, + ParentID: apply.ParentID, + AliPayName: apply.AliPayName, + WechatPayName: apply.WxPayName, + AliPayAccount: apply.AliPayAccount, + WechatPayAccount: apply.WxPayAccount, + WithdrawType: apply.WithdrawType, + InviteCode: apply.InviteCode, + Amount: apply.Amount, + ActualReceipt: apply.RealAmount, + SysFee: apply.SysFee, + State: apply.State, + ApplyAt: apply.ApplyAt, + PayAt: apply.PayAt, + Memo: apply.Memo, } if apply.Amount != "" && apply.SysFee != "" { actualReceipt := utils.StrToFloat64(apply.Amount) - utils.StrToFloat64(apply.SysFee) list[i].ActualReceipt = utils.Float64ToStr(actualReceipt) } - switch apply.WithdrawType { - case 1: - list[i].AliPayName = apply.PayName - list[i].AliPayAccount = apply.PayAccount - case 2: - list[i].WechatPayName = apply.PayName - list[i].WechatPayAccount = apply.PayAccount + if apply.ParentID != 0 { + v, ok := parentsMap[apply.ParentID] + if ok { + list[i].ParentPhone = v.Phone + } } - tag, ok := tagsMap[apply.Tag] + tagList, ok := recordsMap[apply.UserID] if ok { - list[i].Tag = tag + list[i].Tag = tagList } } diff --git a/app/md/financial_center/md_withdraw.go b/app/md/financial_center/md_withdraw.go index 5c1a015..46efe6f 100644 --- a/app/md/financial_center/md_withdraw.go +++ b/app/md/financial_center/md_withdraw.go @@ -1,6 +1,8 @@ package md -import "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md" +import ( + "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md" +) type Paginate struct { Limit int `json:"limit"` // 每页大小 @@ -25,6 +27,7 @@ type GetWithdrawSettingResp struct { FirstWithdrawSet md.FirstWithdrawSet `json:"first_withdraw_set"` // 首次提现设置 CreateAt string `json:"create_at"` // 申请时间 UpdateAt string `json:"update_at"` // 处理时间 + LevelList []map[string]interface{} `json:"level_list"` // 会员等级列表 } type UpdateWithdrawSettingReq struct { @@ -66,21 +69,22 @@ type GetWithdrawApplyListReq struct { } type WithdrawApplyInfo struct { - UserID int64 `xorm:"usera.id"` // 会员 ID - Nickname string `xorm:"usera.nickname"` // 用户名称 - ParentID int64 `xorm:"parent_id"` // 推荐人ID - ParentPhone string `xorm:"userb.phone"` // 推荐人手机号 - PayName string `json:"apply.withdraw_name"` // 支付宝/微信昵称 - PayAccount string `json:"apply.withdraw_account"` // 支付宝/微信账号 - Tag int `json:"tag.id"` // 标签 - WithdrawType int `json:"wallet_flow.withdraw_type"` // 提现方式(1:支付宝 2:微信) - InviteCode string `json:"usera.system_invite_code"` // 邀请码 - Amount string `json:"apply.amount"` // 提现金额 - SysFee string `json:"wallet_flow.sys_fee"` // 手续费 - State int `json:"apply.state"` // 状态 0申请中,1通过,2完成,3失败,4处理中(队列) - ApplyAt string `json:"apply.create_at"` // 申请时间 - PayAt string `json:"wallet_flow.create_at"` // 到账时间 - Memo string `json:"apply.memo"` // 备注 + UserID int64 `xorm:"usera.id"` // 会员 ID + Nickname string `xorm:"usera.nickname"` // 用户名称 + ParentID int64 `xorm:"parent_id"` // 推荐人ID + AliPayName string `xorm:"alipay.user_name"` // 支付宝昵称 + AliPayAccount string `xorm:"alipay.user_id"` // 支付宝账号 + WxPayName string `xorm:"wx.user_name"` // 微信昵称 + WxPayAccount string `xorm:"wx.user_id"` // 微信账号 + WithdrawType int `xorm:"withdraw_kind"` // 提现方式(1:支付宝 2:微信) + InviteCode string `xorm:"usera.system_invite_code"` // 邀请码 + Amount string `xorm:"apply.amount"` // 提现金额 + RealAmount string `xorm:"apply.real_amount"` // 实际到账金额 + SysFee string `xorm:"apply.fee"` // 手续费 + State int `xorm:"apply.state"` // 状态 0申请中,1通过,2完成,3失败,4处理中(队列) + ApplyAt string `xorm:"apply.create_at"` // 申请时间 + PayAt string `xorm:"apply.update_at"` // 到账时间 + Memo string `xorm:"apply.memo"` // 备注 } type GetWithdrawApplyListResp struct { @@ -91,22 +95,27 @@ type GetWithdrawApplyListResp struct { } type GetWithdrawApplyListNode struct { - UserID int64 `json:"user_id"` // 会员 ID - Nickname string `json:"nickname"` // 用户名称 - ParentID int64 `xorm:"parent_id"` // 推荐人ID - ParentPhone string `xorm:"parent_phone"` // 推荐人手机号 - AliPayName string `json:"ali_pay_name"` // 支付宝昵称 - WechatPayName string `json:"wechat_pay_name"` // 微信昵称 - AliPayAccount string `json:"ali_pay_account"` // 支付宝账号 - WechatPayAccount string `json:"wechat_pay_account"` // 微信账号 - Tag string `json:"tag"` // 标签 - WithdrawType int `json:"withdraw_type"` // 提现方式(1:支付宝 2:微信) - InviteCode string `json:"invite_code"` // 邀请码 - Amount string `json:"amount"` // 提现金额 - ActualReceipt string `json:"actual_receipt"` // 实际到账 - SysFee string `json:"sys_fee"` // 手续费 - State int `json:"state"` // 状态 0申请中,1通过,2完成,3失败,4处理中(队列) - ApplyAt string `json:"apply_at"` // 申请时间 - PayAt string `json:"pay_at"` // 到账时间 - Memo string `json:"memo"` // 备注 + UserID int64 `json:"user_id"` // 会员 ID + Nickname string `json:"nickname"` // 用户名称 + ParentID int64 `xorm:"parent_id"` // 推荐人ID + ParentPhone string `xorm:"parent_phone"` // 推荐人手机号 + AliPayName string `json:"ali_pay_name"` // 支付宝昵称 + WechatPayName string `json:"wechat_pay_name"` // 微信昵称 + AliPayAccount string `json:"ali_pay_account"` // 支付宝账号 + WechatPayAccount string `json:"wechat_pay_account"` // 微信账号 + Tag []TagNode `json:"tag"` // 标签 + WithdrawType int `json:"withdraw_type"` // 转账平台(1:支付宝 2:微信) + InviteCode string `json:"invite_code"` // 邀请码 + Amount string `json:"amount"` // 提现金额 + ActualReceipt string `json:"actual_receipt"` // 实际到账 + SysFee string `json:"sys_fee"` // 手续费 + State int `json:"state"` // 状态 0申请中,1通过,2完成,3失败,4处理中(队列) + ApplyAt string `json:"apply_at"` // 申请时间 + PayAt string `json:"pay_at"` // 到账时间 + Memo string `json:"memo"` // 备注 +} + +type TagNode struct { + TagID int `json:"tag_id"` + TagName string `json:"tag_name"` } diff --git a/app/svc/financial_center/svc_withdraw.go b/app/svc/financial_center/svc_withdraw.go index f145b2e..55d0e61 100644 --- a/app/svc/financial_center/svc_withdraw.go +++ b/app/svc/financial_center/svc_withdraw.go @@ -6,12 +6,11 @@ import ( ) func WithDrawManagementGetApply(engine *xorm.Engine, req *md.GetWithdrawApplyListReq) (*[]md.WithdrawApplyInfo, int64, error) { - applies := make([]md.WithdrawApplyInfo, 0) + var applies []md.WithdrawApplyInfo session := engine.Table("fin_withdraw_apply").Alias("apply"). Join("LEFT OUTER", []string{"user", "usera"}, "usera.id = apply.uid"). - Join("LEFT OUTER", []string{"user", "userb"}, "userb.id = usera.parent_uid"). - Join("LEFT OUTER", []string{"user_tag_records", "tag"}, "tag.uid = apply.id"). - Join("LEFT OUTER", []string{"user_wallet_flow", "wallet_flow"}, "wallet_flow.ord_id = apply.id") + Join("LEFT OUTER", []string{"alipay_user_info", "alipay"}, "usera.id = alipay.uid"). + Join("LEFT OUTER", []string{"wx_user_info", "wx"}, "usera.id = wx.uid") if req.Uid != "0" && req.Uid != "" { session = session.Where("usera.uid = ?", req.Uid) @@ -26,7 +25,7 @@ func WithDrawManagementGetApply(engine *xorm.Engine, req *md.GetWithdrawApplyLis } if req.ParentID != "0" && req.ParentID != "" { - session = session.Where("userb.parent_id = ?", req.ParentID) + session = session.Where("usera.parent_id = ?", req.ParentID) } switch req.IsFirst { @@ -37,7 +36,7 @@ func WithDrawManagementGetApply(engine *xorm.Engine, req *md.GetWithdrawApplyLis session = session.Where("apply.is_first", req.IsFirst) } - if req.WithdrawType != "0" { + if req.WithdrawType != "" { session = session.Where("apply.withdraw_kind = ?", req.WithdrawType) } diff --git a/go.mod b/go.mod index f398048..6926533 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,7 @@ require ( ) require ( - code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241129070804-d5cc77e19dcb + code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241129082300-a528fb63b590 code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241129071929-add8a8e2196a code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5