Commit 0923450d by zhouminghui

fix

parent c196b382
......@@ -825,7 +825,8 @@ ON s2.id = s1.order_fee_config_id WHERE s1.amountval != 0 AND s1.month = '{input
/// <returns></returns>
public CommonApiResponseDto<PageResult<List<MonthReFundDto>>> GetMonthProfitFeeReFundDetail(GetMonthProfitPlatformDetailInput input)
{
var sql = BuildMonthProfitFeeReFundDetailSql(input, false, false);
var sql = BuildMonthProfitFeeReFundDetailSql(input, out DynamicParameters param, false, false);
Console.WriteLine($"查询退款分页信息的SQL:{sql}");
var result = new PageResult<List<MonthReFundDto>>();
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
......@@ -834,12 +835,13 @@ ON s2.id = s1.order_fee_config_id WHERE s1.amountval != 0 AND s1.month = '{input
cn.Open();
}
int total = 0;
var obj = cn.Page<MonthReFundDto>(input.PageIndex, input.PageNumber, sql, ref total);
var obj = cn.Page<MonthReFundDto>(input.PageIndex, input.PageNumber, sql, ref total, param);
var data = obj.ToList();
if (data.Count > 0)
{
var sumSql = BuildMonthProfitFeeReFundDetailSql(input, false, true);
var count = cn.Query<(decimal, decimal)>(sumSql).FirstOrDefault();
var sumSql = BuildMonthProfitFeeReFundDetailSql(input, out DynamicParameters paramSum, false, true);
Console.WriteLine($"查询退款金额汇总信息的SQL:{sql}");
var count = cn.Query<(decimal, decimal)>(sumSql, param).FirstOrDefault();
data.Add(new MonthReFundDto
{
BailunAccount = "合计",
......@@ -858,8 +860,9 @@ ON s2.id = s1.order_fee_config_id WHERE s1.amountval != 0 AND s1.month = '{input
/// <returns></returns>
public CommonApiResponseDto<List<MonthReFundSummary>> GetMonthProfitPlatformPlatformSummary(GetMonthProfitPlatformDetailInput input)
{
var sql = BuildMonthProfitFeeReFundDetailSql(input, false, false, true);
var data = SimpleCRUD.Query<MonthReFundSummary>(sql, null, GlobalConfig.ConnectionString).ToList();
var sql = BuildMonthProfitFeeReFundDetailSql(input, out DynamicParameters param, false, false, true);
Console.WriteLine($"查询根据平台汇总退款金额信息的SQL:{sql}");
var data = SimpleCRUD.Query<MonthReFundSummary>(sql, param, GlobalConfig.ConnectionString).ToList();
return new CommonApiResponseDto<List<MonthReFundSummary>>
{
Data = data.Select(x => new MonthReFundSummary
......@@ -872,36 +875,49 @@ ON s2.id = s1.order_fee_config_id WHERE s1.amountval != 0 AND s1.month = '{input
};
}
public string BuildMonthProfitFeeReFundDetailSql(GetMonthProfitPlatformDetailInput input, bool isPage = false, bool isSum = false,bool isSummary = false)
public string BuildMonthProfitFeeReFundDetailSql(GetMonthProfitPlatformDetailInput input, out DynamicParameters parameters, bool isPage = false, bool isSum = false, bool isSummary = false)
{
parameters = new DynamicParameters();
StringBuilder sql = new StringBuilder();
input.Month = input.Month.Replace("月份", "");
var start = Convert.ToDateTime(input.Month).Date;
var end = start.AddMonths(1).Date;
if (isSummary)//根据平台分组明细汇总
{
return $@"select platform_type AS Platform,SUM(amount_refund_rmb) AS RefundRmb,
sql.Append(@"select platform_type AS Platform,SUM(amount_refund_rmb) AS RefundRmb,
SUM(amount_refund_usd) AS RefundUsd,Count(*) AS Totals
from dc_base_crm_refund
where refund_time >= '{start}' and refund_time < '{end}'
group by platform_type ";
where refund_time >= @start and refund_time < @end
group by platform_type ");
parameters.Add("start", start);
parameters.Add("end", end);
return sql.ToString();
}
var coulms = @"t1.platform_type AS PlatformType, t1.bailun_account AS BailunAccount, t1.website AS WebSite,
t1.origin_order_id AS OriginOrderId, t1.amount_refund_rmb AS RefundRmb, t1.amount_refund_usd AS RefundUsd, t1.refund_time AS RefundTime";
if (isSum)
{
coulms = "sum(t1.amount_refund_rmb) AS RefundRmb,sum(t1.amount_refund_usd) AS RefundUsd";
sql.Append($@"
select sum(t1.amount_refund_rmb) AS RefundRmb,sum(t1.amount_refund_usd) AS RefundUsd from dc_base_crm_refund t1
where t1.refund_time >= @start and t1.refund_time < @end ");
}
sql.Append($@"
select {coulms} from dc_base_crm_refund t1
where t1.refund_time >= '{start}' and t1.refund_time < '{end}' ");
else
{
sql.Append($@"
select t1.platform_type AS PlatformType, t1.bailun_account AS BailunAccount, t1.website AS WebSite,
t1.origin_order_id AS OriginOrderId, t1.amount_refund_rmb AS RefundRmb, t1.amount_refund_usd AS RefundUsd, t1.refund_time AS RefundTime from dc_base_crm_refund t1
where t1.refund_time >= @start and t1.refund_time < @end ");
}
parameters.Add("start", start);
parameters.Add("end", end);
if (!string.IsNullOrWhiteSpace(input.PlatformType))
{
sql.Append($" AND t1.platform_type = '{input.PlatformType}'");
sql.Append($" AND t1.platform_type = @PlatformType ");
parameters.Add("PlatformType", input.PlatformType);
}
if (isPage)
{
sql.Append($" LIMIT {input.PageNumber} OFFSET {(input.PageIndex - 1) * input.PageNumber}");
sql.Append($" LIMIT @linits OFFSET @offsets");
parameters.Add("linits", input.PageNumber);
parameters.Add("offsets", (input.PageIndex - 1) * input.PageNumber);
}
return sql.ToString();
}
......
......@@ -493,6 +493,14 @@ namespace Bailun.DC.WebApi.Controllers
ms.Position = 0;
return File(ms, "text/csv", $"{input.Month}_月销售费用合计》费用利润表明细.csv");
}
[HttpGet("getReFundTest")]
public object GetReFundTest()
{
var sql = "select * from dc_month_sales_profit_orderdetail limit 1";
var data = Dapper.SimpleCRUD.Query<dc_month_sales_profit_orderdetail>(sql, null, Common.GlobalConfig.ConnectionString).FirstOrDefault();
return data;
}
#endregion
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment