Commit 166934e4 by guanzhenshan

调整获取退款数据的统计方式

parent 05f2ac8e
......@@ -35,6 +35,16 @@ namespace Bailun.DC.Models
public string bailun_sku { get; set; }
/// <summary>
/// 期初库存
/// </summary>
public int stock_start { get; set; }
/// <summary>
/// 期末库存
/// </summary>
public int stock_end { get; set; }
/// <summary>
/// 销售数量
/// </summary>
public int count_sales { get; set; }
......@@ -55,16 +65,36 @@ namespace Bailun.DC.Models
public decimal amount_purchase { get; set; }
/// <summary>
/// 数量差
/// 入库数
/// </summary>
public int count_putin { get; set; }
/// <summary>
/// 入库金额
/// </summary>
public decimal amount_putin { get; set; }
/// <summary>
/// 采购下单的差异数
/// </summary>
public int difference_count { get; set; }
/// <summary>
/// 金额差
/// 采购下单的差异金额
/// </summary>
public decimal difference_amount { get; set; }
/// <summary>
/// 入库的差异数
/// </summary>
public int diff_putin_count { get; set; }
/// <summary>
/// 入库的差异金额
/// </summary>
public decimal diff_putin_amount { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime createtime { get; set; }
......
......@@ -4299,10 +4299,25 @@ namespace Bailun.DC.Services
var sql1 = $" union all select t1.platform_type,{(isUSD ? "sum(t1.amount_refund_usd)" : "sum(t1.amount_refund_rmb)")} as amount_refund from dc_base_crm_refund t1 join dc_base_oms_order t2 on t1.origin_order_id=t2.transaction_id and t2.bailun_order_status!='Canceled' ";
sql += " where t1.is_deleted=0 and t1.is_freeze=0 and t1.platform_type!='Ebay' ";
sql1 += " where t1.is_deleted=0 and t1.is_freeze=0 and t1.platform_type='Ebay' ";
//合并订单的退款数据 非Ebay
var sql01 = $@" union all select t01.platform_type,{(isUSD ? "sum(t01.amount_refund_usd)" : "sum(t01.amount_refund_rmb)")} as amount_refund from (
select t1.amount_refund_rmb,t1.amount_refund_usd,t1.platform_type,t2.aftermerged_bailun_order_no from dc_base_crm_refund t1
join dc_base_oms_order t2 on t1.origin_order_id=t2.origin_order_id and t2.aftermerged_bailun_order_no != ''
where t1.is_deleted=0 and t1.is_freeze=0 and t1.platform_type!='Ebay' ";
//合并订单的退款数据 Ebay
var sql02 = $@" union all select t01.platform_type,{(isUSD ? "sum(t01.amount_refund_usd)" : "sum(t01.amount_refund_rmb)")} as amount_refund from (
select t1.amount_refund_rmb,t1.amount_refund_usd,t1.platform_type,t2.aftermerged_bailun_order_no from dc_base_crm_refund t1
join dc_base_oms_order t2 on t1.origin_order_id=t2.transaction_id and t2.aftermerged_bailun_order_no !=''
where t1.is_deleted=0 and t1.is_freeze=0 and t1.platform_type='Ebay' ";
if (companyid.HasValue && companyid.Value != 0)
{
sql += " and t1.company_id="+companyid.Value;
sql1 += " and t1.company_id=" + companyid.Value;
sql01 += " and t1.company_id=" + companyid.Value;
sql02 += " and t1.company_id=" + companyid.Value;
}
if (!string.IsNullOrWhiteSpace(platform))
......@@ -4312,6 +4327,13 @@ namespace Bailun.DC.Services
sql1 += " and t1.platform_type=@platform_type1";
sqlparam.Add("platform_type1", platform);
sql01 += " and t1.platform_type=@platform_type01";
sqlparam.Add("platform_type01", platform);
sql02 += " and t1.platform_type=@platform_type02";
sqlparam.Add("platform_type02", platform);
}
if (!string.IsNullOrWhiteSpace(website))
......@@ -4321,6 +4343,12 @@ namespace Bailun.DC.Services
sql1 += " and t1.website=@website1";
sqlparam.Add("website1", website);
sql01 += " and t1.website=@website01";
sqlparam.Add("website01", website);
sql02 += " and t1.website=@website02";
sqlparam.Add("website02", website);
}
if (start.HasValue)
......@@ -4330,6 +4358,12 @@ namespace Bailun.DC.Services
sql1 += " and t1.refund_time>=@start1";
sqlparam.Add("start1", start.Value);
sql01 += " and t1.refund_time>=@start01";
sqlparam.Add("start01", start.Value);
sql02 += " and t1.refund_time>=@start02";
sqlparam.Add("start02", start.Value);
}
if (end.HasValue)
{
......@@ -4338,11 +4372,25 @@ namespace Bailun.DC.Services
sql1 += " and t1.refund_time<@end1";
sqlparam.Add("end1", end.Value.AddDays(1));
sql01 += " and t1.refund_time<@end01";
sqlparam.Add("end01", end.Value.AddDays(1));
sql02 += " and t1.refund_time<@end02";
sqlparam.Add("end02", end.Value.AddDays(1));
}
sql += " group by t1.platform_type";
sql1 += " group by t1.platform_type";
sql01 += @" ) t01
join dc_base_oms_order t02 on t01.aftermerged_bailun_order_no = t02.bailun_order_id and t02.bailun_order_status != 'Canceled'
group by t01.platform_type";
sql02 += @" ) t01
join dc_base_oms_order t02 on t01.aftermerged_bailun_order_no = t02.bailun_order_id and t02.bailun_order_status != 'Canceled'
group by t01.platform_type";
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
if(cn.State== System.Data.ConnectionState.Closed)
......@@ -4350,9 +4398,19 @@ namespace Bailun.DC.Services
cn.Open();
}
var obj = cn.Query<dc_base_oms_order>(sql+sql1, sqlparam, null, true, 2 * 60);
var obj = cn.Query<dc_base_oms_order>(sql+sql1+sql01+sql02, sqlparam, null, true, 2 * 60);
return obj.AsList();
var list = new List<dc_base_oms_order>();
foreach (var item in obj.AsList().GroupBy(a=>a.platform_type))
{
list.Add(new dc_base_oms_order {
platform_type = item.Key,
amount_refund = item.Sum(a=>a.amount_refund),
});
}
return list;
}
}
......
......@@ -853,5 +853,12 @@ namespace Bailun.DC.Services
}
public List<dc_daily_purchase_sales> ListDailyPurchaseSale(BtTableParameter parameter, DateTime start, DateTime end)
{
//var sql = "select * from dc_daily_purchase_sales ";
return null;
}
}
}
......@@ -48,8 +48,11 @@ namespace Bailun.DC.SkuDailyPurchaseAndSales
cn.Open();
}
var sql = $@"select t1.warehouse_code,t1.bailun_sku,t1.usable_stock from dc_base_stock t1";
//var objStock = cn.Query<Models.mSkuCount>()
//先保存采购的
var sql = $@"select t1.warehouse_code,t1.warehouse_name,t1.bailun_sku,sum(t1.count) count,sum(t1.count*t2.unit_price) amount from dc_base_purchase t1
sql = $@"select t1.warehouse_code,t1.warehouse_name,t1.bailun_sku,sum(t1.count) count,sum(t1.count*t2.unit_price) amount from dc_base_purchase t1
left join dc_base_sku t2 on t1.bailun_sku=t2.bailun_sku
where t1.has_delete=0 and t1.status!=-1 and t1.create_time>='{start.ToString("yyyy-MM-dd HH:mm:ss")}' and t1.create_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}'
group by t1.warehouse_code,t1.bailun_sku";
......@@ -64,6 +67,18 @@ namespace Bailun.DC.SkuDailyPurchaseAndSales
var objSales = cn.Query<Models.mSkuCount>(sql, null, null, true, 2 * 60).AsList();
//获取入库的
sql = $@"select tb.warehouse_code,tb.bailun_sku,sum(tb.count) count,sum(tb.count*t4.unit_price) amount from (
select t1.warehouse_code,t1.warehouse_name,t1.bailun_sku,t1.count from dc_base_purchase_inbound t1
join dc_base_purchase t2 on t1.purchase_id=t2.purchase_id and t1.bailun_sku=t2.bailun_sku and t2.has_transfer=0 and t2.`status`>0
where t1.`status`=1 and t1.update_time>='{start.ToString("yyyy-MM-dd HH:mm:ss")}' and t1.update_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}'
union all
select warehouse_code,warehouse_name,bailun_sku,count from dc_base_transfer_inbound t1 where t1.deleted=0 and t1.count>0 and t1.create_time>='{start.ToString("yyyy-MM-dd HH:mm:ss")}' and t1.create_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}'
) tb
left join dc_base_sku t4 on tb.bailun_sku=t4.bailun_sku
group by tb.warehouse_code,tb.bailun_sku";
var objPutin = cn.Query<Models.mSkuCount>(sql, null, null, true, 2 * 60).AsList();
var list = new List<dc_daily_purchase_sales>();
foreach (var item in objPurchase)
{
......@@ -111,6 +126,8 @@ namespace Bailun.DC.SkuDailyPurchaseAndSales
}
}
if (list.Count > 0)
{
Save(cn, list, DateTime.Parse(start.ToString("yyyy-MM-dd")));
......
......@@ -147,5 +147,21 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
return File(ms, "text/csv", filename + ".csv");
}
/// <summary>
/// SKU 的每日采购和发货情况报表
/// </summary>
/// <returns></returns>
public ActionResult ListDailyPurchaseSales()
{
return View();
}
public string ListDailyPurchaseSalesJson(BtTableParameter parameter, DateTime start, DateTime end)
{
//var result = new Services.
return "";
}
}
}
\ No newline at end of file
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