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) } 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 != "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 }