yz_server/Server/Controllers/FinancialManagement/CashListController.cs

143 lines
4.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Common.Models.Enums;
using Common.Models.SubTables;
using Common.Models.UnqTables;
using Server.MyClass.Views;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Web.Http;
namespace Server.Controllers.FinancialManagement
{
public class CashListController : DefaultController
{
/// <summary>
/// 获取机器人信息
/// </summary>
/// <returns></returns>
[HttpPost, ErrorFilter]
public WebResult GetRobotInfo()
{
var PageIndex = GetInt("PageIndex");
var PageSize = GetInt("PageSize");
var tNumber = 0;
var Keyword = GetString("Keyword");
var exp = Expressionable.Create<Robot>();
if (!string.IsNullOrEmpty(Keyword))
{
exp.And(f => f.Nickname.Contains(Keyword));
}
var DataList = Db.Queryable<Robot>().Where(exp.ToExpression())
.Select(m => new RobotInfo { RobotId = m.Id, RobotName = m.Nickname })
.ToPageList(PageIndex, PageSize, ref tNumber);
var res = new PageResult<RobotInfo>(DataList, tNumber, PageSize, PageIndex);
return PutData(res);
}
/// <summary>
/// 查询提现记录
/// </summary>
/// <returns></returns>
[HttpPost, ErrorFilter]
public WebResult GetCashList()
{
var RobotId = GetInt("RobotId");//机器人Id:0:所有机器人 不为0指定机器人
var MinTime = GetTime("MinTime");//起始时间
var MaxTime = GetTime("MaxTime");//结束时间
var VerifyStatus = GetEnum<VerifyStatus>("VerifyStatus");//审核状态:1: 未审核 2已审核
/*
微信昵称 = 1, 微信ID = 2
*/
var KeywordType = GetInt("KeywordType");
var Keyword = GetString("Keyword");
var PageIndex = GetInt("PageIndex", true);
var PageSize = GetInt("PageSize", true);
if (PageSize > 100) PageSize = 100;
var tNumber = 0;
var exp = Expressionable.Create<TixianHist>();
if (MinTime == DateTime.MinValue)
MinTime = DateTime.Now.AddMonths(-6);
if (MaxTime == DateTime.MinValue)
MaxTime = DateTime.Now;
exp.And(a => a.ApplyTime > MinTime && a.ApplyTime < MaxTime);
if (RobotId > 0)
exp.And(a => a.RobotId == RobotId);
if (VerifyStatus != 0)
exp.And(a => a.VerifyStatus == VerifyStatus);
if (!string.IsNullOrEmpty(Keyword))
{
/*
微信昵称 = 1, 微信ID = 2, 推荐人微信ID = 3,推荐人昵称 = 4
*/
if (KeywordType == 1)
{
var nickNames = Db.Queryable<User>().Where(f => f.NickName.Contains(Keyword))
.Select(f => f.Id).Take(20).ToList();
if (nickNames == null)
{
return PutData(new PageResult<CashListShow>(new List<CashListShow>(), tNumber, PageSize, PageIndex));
}
exp.And(a => nickNames.Contains(a.UserId));
}
else if (KeywordType == 2)
{
var user = Db.Queryable<User>().Where(f => f.Username == Keyword && f.UserType == Common.Models.Enums.UserType.).First();
if (user == null)
{
return PutData(new PageResult<CashListShow>(new List<CashListShow>(), tNumber, PageSize, PageIndex));
}
exp.And(a => a.UserId == user.Id);
}
}
var DataList = Db.Queryable<TixianHist>()
.Where(exp.ToExpression())
.LeftJoin<Robot>((a, b) => a.RobotId == b.Id)
.LeftJoin<User>((a, b, c) => a.UserId == c.Id)
.Select((a, b, c) => new CashListShow
{
Id = a.Id,
UserId = c.Id,
NickName = c.NickName,
RobotId = b.Id,
RobotName = b.Nickname,
CashAmount = a.CashAmount,
TotalCash = a.TotalCash,
TotalConfirm = a.TotalConfirm,
TotalRefund = a.TotalRefund,
ApplyTime = a.ApplyTime,
VerifyStatus = a.VerifyStatus,
VerifyTime = a.VerifyTime,
Remark = a.Remark,
})
.SplitTable(MinTime, MaxTime)
.ToPageList(PageIndex, PageSize, ref tNumber);
var res = new PageResult<CashListShow>(DataList, tNumber, PageSize, PageIndex);
return PutData(res);
}
}
}