shenjiachi преди 9 часа
родител
ревизия
7d80489071
променени са 4 файла, в които са добавени 270 реда и са изтрити 1 реда
  1. +105
    -0
      app/hdl/financial_center/hdl_withdraw.go
  2. +77
    -1
      app/md/financial_center/md_withdraw.go
  3. +1
    -0
      app/router/router.go
  4. +87
    -0
      app/svc/financial_center/svc_withdraw.go

+ 105
- 0
app/hdl/financial_center/hdl_withdraw.go Целия файл

@@ -4,6 +4,7 @@ import (
"applet/app/db"
"applet/app/e"
md "applet/app/md/financial_center"
svc "applet/app/svc/financial_center"
"applet/app/utils"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
@@ -128,3 +129,107 @@ func UpdateWithdrawSetting(c *gin.Context) {
}
e.OutSuc(c, affected, nil)
}

// GetWithdrawApplyList
// @Summary 财务中心-提现-提现申请列表(获取)
// @Tags 提现
// @Description 提现申请列表(获取)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param req body md.GetWithdrawApplyListReq false "筛选条件"
// @Success 200 {object} md.GetWithdrawApplyListResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/financialCenter/withdraw/applyList [POST]
func GetWithdrawApplyList(c *gin.Context) {
var req *md.GetWithdrawApplyListReq
if err1 := c.ShouldBindJSON(&req); err1 != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
return
}

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
}

tagDb := implement.NewUserTagDb(db.Db)
tags, err2 := tagDb.UserTagAllByAsc()
if err2 != nil {
e.OutErr(c, e.ERR_DB_ORM, err2.Error())
return
}
tagsList := make([]map[string]interface{}, 0)
tagsMap := make(map[int]string)
for _, tag := range tags {
tagsList = append(tagsList, map[string]interface{}{
"id": tag.Id,
"name": tag.TagName,
})
tagsMap[tag.Id] = tag.TagName
}

applies, total, err3 := svc.WithDrawManagementGetApply(db.Db, req)
if err3 != nil {
e.OutErr(c, e.ERR_DB_ORM, err3.Error())
return
}

list := make([]md.GetWithdrawApplyListNode, len(*applies))
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,
}
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
}
tag, ok := tagsMap[apply.Tag]
if ok {
list[i].Tag = tag
}
}

resp := md.GetWithdrawApplyListResp{
LevelsList: levelsList,
TagsList: tagsList,
List: list,
Paginate: md.Paginate{
Limit: req.Limit,
Page: req.Page,
Total: total,
},
}
e.OutSuc(c, resp, nil)
}

+ 77
- 1
app/md/financial_center/md_withdraw.go Целия файл

@@ -1,6 +1,14 @@
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"` // 每页大小
Page int `json:"page"` // 页数
Total int64 `json:"total"` // 总数据量
}

type GetWithdrawSettingResp struct {
Id int64 `json:"id"`
@@ -33,3 +41,71 @@ type UpdateWithdrawSettingReq struct {
WithdrawTimeInterval string `json:"withdraw_time_interval"` // 提现时段
WithdrawFeeSet string `json:"withdraw_fee_set"` // 提现手续费设置
}

type GetWithdrawApplyListReq struct {
Uid string `json:"uid"` // 用户 ID
Nickname string `json:"nickname"` // 用户昵称
Phone string `json:"phone"` // 用户手机号
ParentID string `json:"parent_id"` // 推荐人 ID
IsFirst string `json:"is_first"` // 是否首次提现 (0. 全部 1.是 2.否)
WithdrawType string `json:"withdraw_type"` // 提现方式(1:支付宝 2:微信)
WithdrawAccount string `json:"withdraw_account"` // 支付宝/微信昵称
WithdrawName string `json:"withdraw_name"` // 支付宝姓名
PaymentType string `json:"payment_type"` // 打款类型 1:手动;2:自动
State string `json:"state"` // 状态 0申请中,1通过,2完成,3失败,4处理中(队列)
ApplyStartAt string `json:"apply_start_at"` // 申请开始时间
ApplyEndAt string `json:"apply_end_at"` // 申请结束时间
ExamineStartAt string `json:"examine_start_at"` // 审核开始时间
ExamineEndAt string `json:"examine_end_at"` // 审核结束时间
AmountBegin string `json:"amount_begin"` // 最小金额
AmountEnd string `json:"amount_end"` // 最大金额
Level string `json:"level"` // 会员等级
Page int `json:"page"` // 页数
Limit int `json:"limit"` //页面大小
}

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"` // 备注
}

type GetWithdrawApplyListResp struct {
LevelsList []map[string]interface{} `json:"levels_list"` // 等级列表
TagsList []map[string]interface{} `json:"tags_list"` // 标签列表
List []GetWithdrawApplyListNode `json:"list"`
Paginate Paginate `json:"paginate"` // 分页信息
}

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"` // 备注
}

+ 1
- 0
app/router/router.go Целия файл

@@ -193,6 +193,7 @@ func rFinancialCenter(r *gin.RouterGroup) {
{
rWithdraw.GET("/setting", financial_center.GetWithdrawSetting)
rWithdraw.POST("/updateWithdrawSetting", financial_center.UpdateWithdrawSetting)
rWithdraw.GET("/applyList", financial_center.GetWithdrawApplyList)
}
}



+ 87
- 0
app/svc/financial_center/svc_withdraw.go Целия файл

@@ -0,0 +1,87 @@
package financial_center

import (
md "applet/app/md/financial_center"
"xorm.io/xorm"
)

func WithDrawManagementGetApply(engine *xorm.Engine, req *md.GetWithdrawApplyListReq) (*[]md.WithdrawApplyInfo, int64, error) {
applies := make([]md.WithdrawApplyInfo, 0)
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")

if req.Uid != "0" && req.Uid != "" {
session = session.Where("usera.uid = ?", req.Uid)
}

if req.Nickname != "" {
session = session.Where("usera.nickname = ?", req.Nickname)
}

if req.Phone != "" {
session = session.Where("usera.phone = ?", req.Phone)
}

if req.ParentID != "0" && req.ParentID != "" {
session = session.Where("userb.parent_id = ?", req.ParentID)
}

if req.IsFirst == "1" {
// 首次提现
}

if req.WithdrawType != "0" {
session = session.Where("apply.withdraw_kind = ?", req.WithdrawType)
}

if req.WithdrawAccount != "" {
session = session.Where("apply.withdraw_account = ?", req.WithdrawAccount)
}

if req.WithdrawName != "" {
session = session.Where("apply.withdraw_name = ?", req.WithdrawName)
}

if req.PaymentType != "" {
session = session.Where("apply.type = ?", req.PaymentType)
}

if req.State != "" {
session = session.Where("apply.state = ?", req.State)
}

if req.ApplyStartAt != "" {
session = session.Where("apply.create_at > ?", req.ApplyStartAt)
}
if req.ApplyEndAt != "" {
session = session.Where("apply.create_at < ?", req.ApplyEndAt)
}

if req.ExamineStartAt != "" {
session = session.Where("apply.update_at > ?", req.ExamineStartAt)
}

if req.ExamineEndAt != "" {
session = session.Where("apply.update_at < ?", req.ExamineEndAt)
}

if req.AmountBegin != "" {
session = session.Where("apply.amount > ?", req.AmountBegin)
}

if req.AmountEnd != "" {
session = session.Where("apply.amount < ?", req.AmountEnd)
}

if req.Level != "" {
session = session.Where("usera.level = ?", req.Level)
}
total, err := session.Limit(req.Limit, (req.Page-1)*req.Limit).Asc("apply.id").FindAndCount(&applies)
if err != nil {
return nil, 0, err
}
return &applies, total, nil
}

Зареждане…
Отказ
Запис