|
- 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) {
- 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{"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.id = ?", 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("usera.parent_uid = ?", req.ParentID)
- }
-
- switch req.IsFirst {
- case "1":
- // 首次提现
- session = session.Where("apply.is_first = ?", req.IsFirst)
- case "0":
- session = session.Where("apply.is_first = ?", req.IsFirst)
- }
-
- if req.WithdrawType != "" {
- 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.Select("apply.*, alipay.open_id as alipay_open_id, alipay.user_name as alipay_user_name,"+
- " wx.user_id as wx_user_id, wx.user_name as wx_user_name,"+
- " usera.system_invite_code as system_invite_code, usera.custom_invite_code as custom_invite_code").
- Limit(req.Limit, (req.Page-1)*req.Limit).Asc("apply.id").FindAndCount(&applies)
- if err != nil {
- return nil, 0, err
- }
- return &applies, total, nil
- }
|