|
@@ -215,6 +215,91 @@ func (s *Synthesis) FindWithdrawal(req entity.UserWithdrawalReq) (*entity.UserWi
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
+// 导出提现记录
|
|
|
+func (s *Synthesis) WithdrawalExport(req entity.UserWithdrawalExportReq) (*entity.UserWithdrawalResp, *code.Result) {
|
|
|
+ ctx, cancel := context.WithTimeout(context.Background(), 100*time.Second)
|
|
|
+ defer cancel()
|
|
|
+ collection := mdb.MDB.Collection(constant.CNameCashOutRecord)
|
|
|
+
|
|
|
+ // 构建过滤器
|
|
|
+ filter := bson.M{}
|
|
|
+ if req.UserName != "" {
|
|
|
+ filter["userName"] = req.UserName
|
|
|
+ }
|
|
|
+ if req.NickName != "" {
|
|
|
+ filter["nickName"] = req.NickName
|
|
|
+ }
|
|
|
+ if req.ID != "" {
|
|
|
+ filter["_id"], _ = primitive.ObjectIDFromHex(req.ID)
|
|
|
+ }
|
|
|
+ if req.Address != "" {
|
|
|
+ filter["address"] = req.Address
|
|
|
+ }
|
|
|
+ if req.State > 0 {
|
|
|
+ filter["state"] = req.State
|
|
|
+ }
|
|
|
+ if req.Withdrawal > 0 {
|
|
|
+ filter["withdrawal"] = req.Withdrawal
|
|
|
+ }
|
|
|
+ if req.StartTime > 0 && req.EndTime > 0 && req.StartTime <= req.EndTime {
|
|
|
+ filter["createAt"] = bson.M{
|
|
|
+ "$gte": req.StartTime,
|
|
|
+ "$lte": req.EndTime,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if req.AmountMin > 0 && req.AmountMax > 0 && req.AmountMin <= req.AmountMax {
|
|
|
+ filter["amount"] = bson.M{
|
|
|
+ "$gte": req.AmountMin,
|
|
|
+ "$lte": req.AmountMax,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if req.AfterAmountMin > 0 && req.AfterAmountMax > 0 && req.AfterAmountMin <= req.AfterAmountMax {
|
|
|
+ filter["after_amount"] = bson.M{
|
|
|
+ "$gte": req.AfterAmountMin,
|
|
|
+ "$lte": req.AfterAmountMax,
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ findOptions := options.Find()
|
|
|
+ findOptions.SetSort(bson.D{{"createAt", -1}})
|
|
|
+
|
|
|
+ // 获取总数total
|
|
|
+ count, err := collection.CountDocuments(ctx, filter)
|
|
|
+ if err != nil {
|
|
|
+ mhayaLogger.Warnf("WithdrawalExportData CountDocuments error:%v", err)
|
|
|
+ return nil, common.NewResult(code.InternalError)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询数据
|
|
|
+ var results []*entity.UserWithdrawalDetail
|
|
|
+ cursor, err := collection.Find(ctx, filter, findOptions)
|
|
|
+ if err != nil {
|
|
|
+ mhayaLogger.Warnf("WithdrawalExportData Find error:%v", err)
|
|
|
+ return nil, common.NewResult(code.InternalError)
|
|
|
+ }
|
|
|
+
|
|
|
+ defer cursor.Close(ctx)
|
|
|
+ // 解析结果
|
|
|
+ for cursor.Next(ctx) {
|
|
|
+ var result entity.UserWithdrawalDetail
|
|
|
+ if err := cursor.Decode(&result); err != nil {
|
|
|
+ mhayaLogger.Warnf("WithdrawalExportData Decode error:%v", err)
|
|
|
+ return nil, common.NewResult(code.InternalError)
|
|
|
+ }
|
|
|
+ results = append(results, &result)
|
|
|
+ }
|
|
|
+
|
|
|
+ if err := cursor.Err(); err != nil {
|
|
|
+ mhayaLogger.Warnf("WithdrawalExportData cursor error:%v", err)
|
|
|
+ return nil, common.NewResult(code.InternalError)
|
|
|
+ }
|
|
|
+
|
|
|
+ return &entity.UserWithdrawalResp{
|
|
|
+ Details: results,
|
|
|
+ Total: count,
|
|
|
+ }, nil
|
|
|
+}
|
|
|
+
|
|
|
// WithdrawalStatus 更新提现状态
|
|
|
func (s *Synthesis) WithdrawalStatus(req entity.UserWithdrawalStatus) *code.Result {
|
|
|
// ctx, cancel := context.WithTimeout(context.Background(), 100*time.Second)
|