Commit 31e8ce15 by guanzhenshan

平台应收账款服务调整

parent d2d5e753
...@@ -23,7 +23,7 @@ namespace Bailun.DC.DailyPlatformReceivable ...@@ -23,7 +23,7 @@ namespace Bailun.DC.DailyPlatformReceivable
// var _services = new Services(); // var _services = new Services();
// var start = DateTime.Parse("2019-11-01"); // var start = DateTime.Parse("2020-04-01");
// while (start.AddDays(1) < DateTime.Now) // while (start.AddDays(1) < DateTime.Now)
// { // {
// Console.WriteLine(start); // Console.WriteLine(start);
......
...@@ -65,7 +65,7 @@ namespace Bailun.DC.DailyPlatformReceivable ...@@ -65,7 +65,7 @@ namespace Bailun.DC.DailyPlatformReceivable
cn.Open(); cn.Open();
} }
//Ebay 预收账款=期初预收余额+本期收款(订单付款金额)-发货金额-退款(未发货的) //Ebay 预收账款=期初预收余额+本期收款(订单付款金额)-发货金额-退款(未发货的)+其他
//期初预收余额 //期初预收余额
var sql = $"select * from dc_daily_receivable where day='{day.AddDays(-1).ToString("yyyy-MM-dd")}' and platform='Ebay'"; var sql = $"select * from dc_daily_receivable where day='{day.AddDays(-1).ToString("yyyy-MM-dd")}' and platform='Ebay'";
...@@ -83,25 +83,46 @@ namespace Bailun.DC.DailyPlatformReceivable ...@@ -83,25 +83,46 @@ namespace Bailun.DC.DailyPlatformReceivable
sql = $"select sum(amount_refund_rmb) amount from dc_base_crm_refund where platform_type = 'Ebay' and company_id = 1 and is_deleted = 0 and is_freeze = 0 and shipping_status = 'UnShipping' and refund_time>= '{day.ToString("yyyy-MM-dd")}' and refund_time<'{day.AddDays(1).ToString("yyyy-MM-dd")}'"; sql = $"select sum(amount_refund_rmb) amount from dc_base_crm_refund where platform_type = 'Ebay' and company_id = 1 and is_deleted = 0 and is_freeze = 0 and shipping_status = 'UnShipping' and refund_time>= '{day.ToString("yyyy-MM-dd")}' and refund_time<'{day.AddDays(1).ToString("yyyy-MM-dd")}'";
var EbayRefund = cn.QueryFirstOrDefault<decimal?>(sql)??0; var EbayRefund = cn.QueryFirstOrDefault<decimal?>(sql)??0;
var m_ebay = new dc_daily_receivable { sql = $"select * from dc_daily_receivable where day='{day.ToString("yyyy-MM-dd")}' and platform='Ebay'";
day = day, var m_ebay = cn.QueryFirstOrDefault<dc_daily_receivable>(sql);
amount_end = (objBefore != null ? objBefore.amount_end : 0) + EbaySales - EbayShipping - EbayRefund,
amount_start = (objBefore != null ? objBefore.amount_end : 0), if (m_ebay == null)
amount_sale_pay = EbaySales, {
amount_shipping = EbayShipping, m_ebay = new dc_daily_receivable
amount_refund = EbayRefund, {
day = day,
amount_incoming = 0, amount_end = (objBefore != null ? objBefore.amount_end : 0) + EbaySales - EbayShipping - EbayRefund,
amount_other = 0, amount_start = (objBefore != null ? objBefore.amount_end : 0),
amount_platformfee = 0, amount_sale_pay = EbaySales,
amount_sale_shipping = 0, amount_shipping = EbayShipping,
createtime = DateTime.Now, amount_refund = EbayRefund,
lastupdatetime = DateTime.Now, amount_incoming = 0,
lastupdateuserid = 0, amount_other = 0,
lastupdateusername = "system", amount_platformfee = 0,
platform = "Ebay", amount_sale_shipping = 0,
}; createtime = DateTime.Now,
lastupdatetime = DateTime.Now,
lastupdateuserid = 0,
lastupdateusername = "system",
platform = "Ebay",
};
}
else
{
m_ebay.amount_start = (objBefore != null ? objBefore.amount_end : 0);
m_ebay.amount_sale_pay = EbaySales;
m_ebay.amount_shipping = EbayShipping;
m_ebay.amount_refund = EbayRefund;
m_ebay.amount_end = m_ebay.amount_start + EbaySales - EbayShipping - EbayRefund + m_ebay.amount_other;
m_ebay.lastupdatetime = DateTime.Now;
m_ebay.lastupdateuserid = 0;
m_ebay.lastupdateusername = "system";
}
//非Ebay 应收账款=期初应收余额+本期销售收入-平台扣费-放款金额-退款金额+其他 //非Ebay 应收账款=期初应收余额+本期销售收入-平台扣费-放款金额-退款金额+其他
sql = $@"select * from ( sql = $@"select * from (
...@@ -114,6 +135,16 @@ namespace Bailun.DC.DailyPlatformReceivable ...@@ -114,6 +135,16 @@ namespace Bailun.DC.DailyPlatformReceivable
) tb"; ) tb";
var listAmount = cn.Query<platformamount>(sql); var listAmount = cn.Query<platformamount>(sql);
//非Ebay 平台费,按付款时间
sql = $@"select * from (
select t1.platform_type,sum(t1.cost_platform_fee*t1.seller_order_exchange_rate*t1.bailun_sku_quantity_ordered) cost_platform_fee,0 as cost_fba_fee
from dc_base_oms_sku t1 where t1.has_scalp=0 and t1.has_delete=0 and t1.has_innersale=0 and t1.bailun_order_status!='Canceled' and t1.has_innersale=0 and t1.company_id=1 and t1.platform_type!='Ebay' and t1.platform_type!='FBA' and t1.paid_time>='{day.ToString("yyyy-MM-dd")}' and t1.paid_time<'{day.AddDays(1).ToString("yyyy-MM-dd")}'
group by platform_type
union all
select platform_type,sum((cost_platform_fee+cost_fba_fee)*seller_order_exchange_rate) cost_platform_fee,sum(cost_fba_fee*seller_order_exchange_rate) cost_fba_fee from dc_base_oms_order where platform_type='FBA' and create_time>='{day.ToString("yyyy-MM-dd")}' and create_time<'{day.AddDays(1).ToString("yyyy-MM-dd")}' and company_id=1 and bailun_order_status!='Canceled' and has_scalp=0 and has_innersale=0
) tb";
var listPlatformFee = cn.Query<platformamount>(sql);
var listPlatform = cn.Query<string>("select platform_type from dc_base_oms_order group by platform_type").Where(a=>a.ToLower()!= "amazon2b" && a.ToLower()!= "fba" && a.ToLower()!="ebay").ToList(); var listPlatform = cn.Query<string>("select platform_type from dc_base_oms_order group by platform_type").Where(a=>a.ToLower()!= "amazon2b" && a.ToLower()!= "fba" && a.ToLower()!="ebay").ToList();
//退款 //退款
...@@ -135,39 +166,64 @@ namespace Bailun.DC.DailyPlatformReceivable ...@@ -135,39 +166,64 @@ namespace Bailun.DC.DailyPlatformReceivable
var obj = listAmount.Where(a => a.platform_type == item).FirstOrDefault(); var obj = listAmount.Where(a => a.platform_type == item).FirstOrDefault();
var objPlatformFee = listPlatformFee.Where(a => a.platform_type.ToLower() == item.ToLower()).FirstOrDefault();
if (item.ToLower() == "amazon") if (item.ToLower() == "amazon")
{ {
var objAmazon = listAmount.Where(a => a.platform_type.ToLower() == "fba" || a.platform_type.ToLower() == "amazon"); var objAmazon = listAmount.Where(a => a.platform_type.ToLower() == "fba" || a.platform_type.ToLower() == "amazon");
var objPlatformFee_s = listPlatformFee.Where(a => a.platform_type.ToLower() == "fba" || a.platform_type.ToLower() == "amazon");
if (objAmazon.Count() > 0) if (objAmazon.Count() > 0)
{ {
obj = new platformamount { obj = new platformamount {
amount = objAmazon.Sum(a=>a.amount), amount = objAmazon.Sum(a=>a.amount),
cost_platform_fee = objAmazon.Sum(a=>a.cost_platform_fee), //cost_platform_fee = objPlatformFee_s.Sum(a=>a.cost_platform_fee),
platform_type = item, platform_type = item,
}; };
objPlatformFee.cost_platform_fee = objPlatformFee_s.Sum(a => a.cost_platform_fee);
} }
} }
var m = new dc_daily_receivable { sql = $"select * from dc_daily_receivable where day='{day.ToString("yyyy-MM-dd")}' and platform='{item}'";
platform = item, var m = cn.QueryFirstOrDefault<dc_daily_receivable>(sql);
amount_start = objBefore!=null? objBefore.amount_end:0, if (m == null)
amount_other = 0, {
amount_platformfee = obj!=null?obj.cost_platform_fee:0, m = new dc_daily_receivable
amount_sale_shipping = obj!=null?obj.amount:0, {
platform = item,
amount_start = objBefore != null ? objBefore.amount_end : 0,
amount_other = 0,
amount_platformfee = objPlatformFee != null ? objPlatformFee.cost_platform_fee : 0,
amount_sale_shipping = obj != null ? obj.amount : 0,
amount_sale_pay = 0,
amount_shipping = 0,
amount_incoming = 0,
amount_refund = 0,
amount_end = 0,
createtime = DateTime.Now,
day = day,
lastupdatetime = DateTime.Now,
lastupdateuserid = 0,
lastupdateusername = "system",
};
}
else
{
m.amount_start = objBefore != null ? objBefore.amount_end : 0;
m.amount_platformfee = objPlatformFee != null ? objPlatformFee.cost_platform_fee : 0;
m.amount_sale_shipping = obj != null ? obj.amount : 0;
amount_sale_pay = 0, m.lastupdatetime = DateTime.Now;
amount_shipping = 0, m.lastupdateuserid = 0;
m.lastupdateusername = "system";
}
amount_incoming = 0,
amount_refund = 0,
amount_end = 0,
createtime = DateTime.Now,
day = day,
lastupdatetime = DateTime.Now,
lastupdateuserid = 0,
lastupdateusername = "system",
};
//平台扣费 //平台扣费
if (item.ToLower() == "amazon") if (item.ToLower() == "amazon")
......
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
<body class="fixed-sidebar full-height-layout gray-bg" style="overflow:hidden"> <body class="fixed-sidebar full-height-layout gray-bg" style="overflow:hidden">
<script type="text/javascript"> <script type="text/javascript">
//login_localhost(); login_localhost();
login(); //login();
window.location = "@Url.Content("~/Home/Main")"; window.location = "@Url.Content("~/Home/Main")";
</script> </script>
</body> </body>
......
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