Commit 2ff7340f by jianshuqin

新增功能:平台利润增加财务发货时间过虑条件

parent eff1e8bf
using System;
using System.Collections.Generic;
using System.Text;
using Dapper;
using System;
namespace Bailun.DC.Models
{
......@@ -67,14 +66,25 @@ namespace Bailun.DC.Models
/// <summary>
/// 销售帐号
/// </summary>
[NotMapped]
public string sales_account { get; set; }
/// <summary>
/// 站点
/// </summary>
[NotMapped]
public string market { get; set; }
public string account_name { get; set; }
[NotMapped]
public dynamic data_json { get; set; }
public string website { get; set; }
public long fund_id { get; set; }
public string seller_account { get; set; }
}
}
......@@ -1512,7 +1512,7 @@ namespace Bailun.DC.Services
/// <param name="start">付款开始时间</param>
/// <param name="end">付款结束时间</param>
/// <returns></returns>
public List<Models.Orders.dc_base_oms_sku> ListPlatformProfit(string platform, string website, DateTime? start, DateTime? end, DateTime? shipstart, DateTime? shipend, bool isUSD, int? companyid, string skucategoryids, DateTime? createstart = null, DateTime? createend = null)
public List<Models.Orders.dc_base_oms_sku> ListPlatformProfit(string platform, string website, DateTime? start, DateTime? end, DateTime? shipstart, DateTime? shipend, bool isUSD, int? companyid, string skucategoryids, DateTime? createstart = null, DateTime? createend = null, DateTime? shipmentstart = null, DateTime? shipmentend = null)
{
var sqlparam = new DynamicParameters();
var sql = "select tb.platform_type,count(tb.bailun_order_id) order_count,sum(tb.amount_sales*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + ") as amount_sales,sum(tb.cost_platform_fee*(if(tb.platform_type='Ebay'," + (isUSD ? "tb.other_to_usd_exchange_rate" : "tb.seller_other_exchange_rate") + "," + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + "))) as cost_platform_fee,sum(tb.cost_first*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ") as cost_first,sum(tb.cost_logistics*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ") cost_tail,sum(tb.cost_handle_bailun*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ") cost_handle_bailun,sum(tb.cost_handle_platform*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ") cost_handle_platform,sum(tb.amount_refund*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + ") amount_refund,sum(tb.cost_fba_fee*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + ") cost_fba_fee,sum(tb.cost_paypal_fee*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + ") cost_paypal_fee,sum(tb.amount_shipping*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + ") amount_shipping,sum(tb.cost_promotion*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + ") cost_promotion,sum(tb.cost_product*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ") cost_product,sum(tb.profit_total*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ") profit_total,(sum(tb.profit_total*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ")/sum(tb.amount_sales*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + ")) profit_rate,count((tb.amount_prepaid>0 and tb.bailun_order_status!='Finished') or null) as noshippingcount,sum(tb.amount_prepaid*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ") amount_prepaid from dc_base_oms_order tb ";
......@@ -1627,6 +1627,16 @@ namespace Bailun.DC.Services
sql += " and tb.purchase_create_time<@createend";
sqlparam.Add("createend", createend.Value.AddDays(1));
}
if (shipmentstart.HasValue)
{
sql += " and tb.shipment_date>=@shipmentstart";
sqlparam.Add("shipmentstart", shipmentstart.Value);
}
if (shipmentend.HasValue)
{
sql += " and tb.shipment_date<@shipmentend";
sqlparam.Add("shipmentend", shipmentend.Value.AddDays(1));
}
//从2021年12月23号后过虑 美美哒和达馨('Lagunamoon_Beauty','Lagunamoon Nail Varnish','dawarmthEU','dawarmth') 数据
sql += " and tb.id not in (select id from dc_base_oms_order where seller_account in ('Lagunamoon_Beauty', 'Lagunamoon Nail Varnish', 'dawarmthEU','dawarmth') and purchase_create_time >= '2021-12-23')";
......@@ -1654,7 +1664,7 @@ namespace Bailun.DC.Services
/// <param name="start">付款开始时间</param>
/// <param name="end">付款结束时间</param>
/// <returns></returns>
public List<Models.Orders.dc_base_oms_sku> ListPlatformProfit(string platform, string website, DateTime? start, DateTime? end, DateTime? shipstart, DateTime? shipend, bool isUSD, int? companyid, string skucategoryids, int[] producttype, int? skusource, int? shippingstrategy, int statistictype, int? skunewcategoryid, DateTime? createstart = null, DateTime? createend = null)
public List<Models.Orders.dc_base_oms_sku> ListPlatformProfit(string platform, string website, DateTime? start, DateTime? end, DateTime? shipstart, DateTime? shipend, bool isUSD, int? companyid, string skucategoryids, int[] producttype, int? skusource, int? shippingstrategy, int statistictype, int? skunewcategoryid, DateTime? createstart = null, DateTime? createend = null, DateTime? shipmentstart = null, DateTime? shipmentend = null)
{
var str_statistic_col = "tb.platform_type";
......@@ -1855,6 +1865,16 @@ namespace Bailun.DC.Services
sql += " and tb.create_time<@createend";
sqlparam.Add("createend", createend.Value.AddDays(1));
}
if (shipmentstart.HasValue)
{
sql += " and tb.shipment_date>=@shipmentstart";
sqlparam.Add("shipmentstart", shipmentstart.Value);
}
if (shipmentend.HasValue)
{
sql += " and tb.shipment_date<@shipmentend";
sqlparam.Add("shipmentend", shipmentend.Value.AddDays(1));
}
//从2021年12月23号后过虑 美美哒和达馨('Lagunamoon_Beauty','Lagunamoon Nail Varnish','dawarmthEU','dawarmth') 数据
sql += " and tb.id not in (SELECT id from dc_base_oms_sku WHERE seller_account in ('Lagunamoon_Beauty', 'Lagunamoon Nail Varnish', 'dawarmthEU','dawarmth') AND purchase_create_time >= '2021-12-23')";
......
......@@ -1590,8 +1590,8 @@ t1.exchange_rate AS ExchangeRate,t1.amountval_rmb AS AmountValRmb,t1.month AS Mo
Console.WriteLine("开始统计平台费用");
oldData.fee_fba = Math.Abs(Math.Round(SyncMonthProfitFeePlatformFeeSummary(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "佣金及平台费-亚马逊FBA" }), 2)) * (-1);
oldData.fee_nofba = Math.Abs(Math.Round(SyncMonthProfitFeePlatformFeeSummary(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "佣金及平台费-亚马逊非FBA" }), 2)) * (-1);
oldData.fee_nofba = (Math.Round(SyncMonthProfitFeePlatformFeeSummary(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "佣金及平台费-亚马逊非FBA" }), 2));
oldData.fee_ebay = Math.Abs(Math.Round(SyncMonthProfitFeePlatformFeeSummary(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "佣金及平台费-Ebay" }), 2)) * (-1);
oldData.fee_ohtre = Math.Abs(Math.Round(SyncMonthProfitFeePlatformFeeSummary(
......
using Bailun.DC.Common;
using Bailun.DC.Models;
using Bailun.DC.Models.Component.DTO;
using Bailun.DC.Models.Report;
using Bailun.ServiceFabric.Authorize;
using Bailun.ServiceFabric.Core.Extension;
......@@ -10941,8 +10942,30 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
#endregion
#region 同步FBA发货
[HttpPost]
public JsonResult SyncFbaShipmentDate([FromForm] IList<dc_base_fba_shipping_detail> listData)
{
ResultDTO result = default(ResultDTO);
try
{
result = new Services.FinanceReportServices().SyncFbaShipmentDate(listData);
}
catch (Exception ex)
{
result = new ResultDTO() { Message = ex.Message };
}
return Json(result);
}
#endregion
}
class mHappenAmount
{
/// <summary>
......
......@@ -1652,7 +1652,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
[BailunAuthentication(LoginMode.Enforce)]
[HttpPost]
[BrowseLog("Bailun_data", "访问【百伦数据中心】->【利润统计】->【平台利润统计】->【查询】页面", 0)]
public JsonResult PlatformProfitCountJson(string platform, string website, DateTime? start, DateTime? end, DateTime? shipstart, DateTime? shipend, string currency, string skucategoryids, string product_type, int? skusource, int? shippingstrategy, int? skunewcategory, int statistictype = 0)
public JsonResult PlatformProfitCountJson(string platform, string website, DateTime? start, DateTime? end, DateTime? shipstart, DateTime? shipend, string currency, string skucategoryids, string product_type, int? skusource, int? shippingstrategy, int? skunewcategory, DateTime? shipmentstart, DateTime? shipmentend, int statistictype = 0)
{
var _service = new Services.OrdersServices();
var companyid = HttpContextHelper.Current?.User?.GetCompanyId().ToInt32();
......@@ -1722,22 +1722,23 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
//Add by Allan at 20200320,for 增加sku级别的利润统计
if (producttype.Length > 0 || skusource.HasValue || shippingstrategy.HasValue)
{
if (shipstart.HasValue || shipend.HasValue)
if ((shipstart.HasValue || shipend.HasValue) || (shipmentstart.HasValue || shipmentend.HasValue))
{
result = _service.ListPlatformProfitByShipTime(platform, website, start, end, shipstart, shipend, currency.ToUpper() == "USD", companyid, skucategoryids, producttype, skusource, shippingstrategy, statistictype, skunewcategory);
dtstart = shipstart ?? shipmentstart;
dtend = shipend ?? shipmentend;
result = _service.ListPlatformProfitByShipTime(platform, website, start, end, dtstart, dtend, currency.ToUpper() == "USD", companyid, skucategoryids, producttype, skusource, shippingstrategy, statistictype, skunewcategory);
var fbaResult = _service.ListPlatformProfit(string.IsNullOrEmpty(platform) ? "FBA" : "", website, null, null, null, null, currency.ToUpper() == "USD", companyid, skucategoryids, producttype, skusource, shippingstrategy, statistictype, skunewcategory, shipstart, shipend, shipmentstart, shipmentend);
var fbaResult = _service.ListPlatformProfit(string.IsNullOrEmpty(platform) ? "FBA" : "", website, null, null, null, null, currency.ToUpper() == "USD", companyid, skucategoryids, producttype, skusource, shippingstrategy, statistictype, skunewcategory, shipstart, shipend);
dtstart = shipstart;
dtend = shipend;
listRefund = _service.ListPlatformRefund(dtstart, dtend, companyid, platform, website, currency.ToUpper() == "USD", false, producttype, skusource, shippingstrategy, statistictype); //不包含未发货的退款金额
//针对SKU FJH-L-2 做特殊处理
if (producttype.Length > 0)
{
var result_FJH = _service.ListSkuProfit_FJH_L_2_ByShipTime(platform, website, start, end, shipstart, shipend, currency.ToUpper() == "USD", companyid, skucategoryids, producttype, skusource, shippingstrategy);
var fbaresult_FJH = _service.ListSkuProfit_FJH_L_2(string.IsNullOrEmpty(platform) ? "FBA" : "", website, null, null, null, null, currency.ToUpper() == "USD", companyid, skucategoryids, producttype, skusource, shippingstrategy, shipstart, shipend);
var result_FJH = _service.ListSkuProfit_FJH_L_2_ByShipTime(platform, website, start, end, dtstart, dtend, currency.ToUpper() == "USD", companyid, skucategoryids, producttype, skusource, shippingstrategy);
var fbaresult_FJH = _service.ListSkuProfit_FJH_L_2(string.IsNullOrEmpty(platform) ? "FBA" : "", website, null, null, null, null, currency.ToUpper() == "USD", companyid, skucategoryids, producttype, skusource, shippingstrategy, dtstart, dtend);
foreach (var item in result)
{
......@@ -1877,20 +1878,18 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
}
else
{
if (shipstart.HasValue || shipend.HasValue)
if ((shipstart.HasValue || shipend.HasValue) || (shipmentstart.HasValue || shipmentend.HasValue))
{
result = _service.ListPlatformProfitByShipTime(platform, website, start, end, shipstart, shipend, currency.ToUpper() == "USD", companyid, skucategoryids, null, null, null, statistictype, skunewcategory);
dtstart = shipstart ?? shipmentstart;
dtend = shipend ?? shipmentend;
result = _service.ListPlatformProfitByShipTime(platform, website, start, end, dtstart, dtend, currency.ToUpper() == "USD", companyid, skucategoryids, null, null, null, statistictype, skunewcategory);
if (platform == "FBA" || string.IsNullOrEmpty(platform))
{
var fbaResult = _service.ListPlatformProfit("FBA", website, null, null, null, null, currency.ToUpper() == "USD", companyid, skucategoryids, shipstart, shipend);
var fbaResult = _service.ListPlatformProfit("FBA", website, null, null, null, null, currency.ToUpper() == "USD", companyid, skucategoryids, shipstart, shipend, shipmentstart, shipmentend);
result.AddRange(fbaResult);
}
dtstart = shipstart;
dtend = shipend;
listRefund = _service.ListPlatformRefund(dtstart, dtend, companyid, platform, website, currency.ToUpper() == "USD", false, null, null, null, statistictype); //不包含未发货的退款金额
}
else
......@@ -2032,7 +2031,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
{
//判断是否是按月份搜索,如果是,则加上4px的返利利润
//Add by Allan at 20210317
if (IsMonth(start, end) || IsMonth(shipstart, shipend))
if (IsMonth(start, end) || IsMonth(shipstart, shipend) || IsMonth(shipmentstart, shipmentend))
{
var _str_month = "";
if (start.HasValue)
......@@ -2043,6 +2042,10 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
{
_str_month = shipstart.Value.ToString("yyyy-MM");
}
else if (shipmentstart.HasValue)
{
_str_month = shipmentstart.Value.ToString("yyyy-MM");
}
if (!string.IsNullOrEmpty(_str_month))
{
......
......@@ -92,7 +92,12 @@
<option value="4">FBA仓</option>
</select>
</div>
<div class="form-group">
<label>财务发货时间</label>
<input id="shipmentstart" name="shipmentstart" type="text" class="form-control" style="width:130px;" placeholder="财务发货开始时间" />
<span>至</span>
<input id="shipmentend" name="shipmentend" type="text" class="form-control" style="width:130px;" placeholder="财务发货结束时间" />
</div>
<div class="form-group">
<label>&nbsp;</label>
<button type="button" class="btn btn-primary" onclick="list();"><i class="fa fa-search"></i>&nbsp;查询</button>
......@@ -102,7 +107,7 @@
</form>
</div>
<div class="ibox-content m-b-sm border-bottom">
<table id="roletable" class="table table-hover table-bordered table-condensed table-striped" >
<table id="roletable" class="table table-hover table-bordered table-condensed table-striped">
<thead>
<tr>
@if (ViewBag.statistictype == 0)
......@@ -177,7 +182,10 @@
cursor: pointer;
}
.skuprofit{color:#1D84C6;cursor: pointer;}
.skuprofit {
color: #1D84C6;
cursor: pointer;
}
.tablesorter-headerDesc {
background-position: right;
......@@ -192,8 +200,6 @@
padding-right: 30px;
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZ0lEQVQ4y2NgGLKgquEuFxBPAGI2ahhWCsS/gDibUoO0gPgxEP8H4ttArEyuQYxAPBdqEAxPBImTY5gjEL9DM+wTENuQahAvEO9DMwiGdwAxOymGJQLxTyD+jgWDxCMZRsEoGAVoAADeemwtPcZI2wAAAABJRU5ErkJggg==');
}
</style>
}
@section scripts{
......@@ -211,6 +217,9 @@
laydate.render({ elem: '#shipstart' });
laydate.render({ elem: '#shipend' });
laydate.render({ elem: '#shipmentstart' });
laydate.render({ elem: '#shipmentend' });
list();
listPlatform();
......@@ -249,14 +258,17 @@
var shipstart = $('#shipstart').val();
var shipend = $('#shipend').val();
var shipmentstart = $('#shipmentstart').val();
var shipmentend = $('#shipmentend').val();
var start = $('#start').val();
var end = $('#end').val();
if ((shipstart != '' || shipend != '') && (start != '' || end != '')) {
if (((shipstart != '' || shipend != '') && ((start != '' || end != '') || (shipmentstart != '' || shipmentend != ''))) || ((start != '' || end != '') && ((shipstart != '' || shipend != '') || (shipmentstart != '' || shipmentend != '')))) {
layer.alert('搜索条件不能同时选择付款时间和发货时间,只能选其一。');
return false;
}
if (start == '' && end == '' && shipstart == '' && shipend == '') {
if (start == '' && end == '' && shipstart == '' && shipend == '' && shipmentstart == '' && shipmentend == '') {
layer.alert('请选择时间进行搜索。');
return false;
}
......@@ -503,14 +515,14 @@
var start = $('#start').val();
var end = $('#end').val();
layer_show(platform + ' 按站点统计', '@Url.Content("~/Reports/Orders/PlatformProfitCountByWebSite?platform=")' + platform + '&start=' + start + '&end=' + end, '90%', '90%');
layer_show(platform + ' 按站点统计', '@Url.Content("~/Reports/Orders/PlatformProfitCountByWebSite?platform=")' + platform + '&start=' + start + '&end=' + end + '&shipstart=' + $('#shipstart').val() + '&shipend=' + $('#shipend').val() + '&shipmentstart=' + $('#shipmentstart').val() + '&shipmentend=' + $('#shipmentend').val(), '90%', '90%');
}
}
function ShowDetail(platform, coltitle, colval, single) {
if ('@(ViewBag.statistictype)' == 0) {
layer_show(platform + " " + $('#start').val() + "至" + $('#end').val() + ' 订单明细', '@Url.Content("~/Reports/Orders/ListOrderDetail?platform=")' + platform + '&start=' + $('#start').val() + '&end=' + $('#end').val() + '&col=' + colval + '&coltitle=' + coltitle + '&showsingle=' + single + '&shipstart=' + $('#shipstart').val() + '&shipend=' + $('#shipend').val(), '90%', '90%');
layer_show(platform + " " + $('#start').val() + "至" + $('#end').val() + ' 订单明细', '@Url.Content("~/Reports/Orders/ListOrderDetail?platform=")' + platform + '&start=' + $('#start').val() + '&end=' + $('#end').val() + '&col=' + colval + '&coltitle=' + coltitle + '&showsingle=' + single + '&shipstart=' + $('#shipstart').val() + '&shipend=' + $('#shipend').val() + '&shipmentstart=' + $('#shipmentstart').val() + '&shipmentend=' + $('#shipmentend').val(), '90%', '90%');
}
}
......@@ -596,6 +608,9 @@
var shipstart = $('#shipstart').val();
var shipend = $('#shipend').val();
var shipmenstart = $('#shipmentstart').val();
var shipmentend = $('#shipmentend').val();
var start = $('#start').val();
var end = $('#end').val();
......@@ -605,7 +620,7 @@
}
layer_show(platform + " " + title+"曲线图", '@Url.Content("~/Reports/Orders/OrderProfitGraph?platform=")' + platform + '&start=' + $('#start').val() + '&end=' + $('#end').val() + '&col=' + colval + '&shipstart=' + $('#shipstart').val() + '&shipend=' + $('#shipend').val() + '&currency=' + $('#currency').val() + '&skucategoryids=' + s + '&titlename=' + title, '90%', '90%');
layer_show(platform + " " + title + "曲线图", '@Url.Content("~/Reports/Orders/OrderProfitGraph?platform=")' + platform + '&start=' + $('#start').val() + '&end=' + $('#end').val() + '&col=' + colval + '&shipstart=' + $('#shipstart').val() + '&shipend=' + $('#shipend').val() + '&shipmentstart=' + $('#shipmentstart').val() + '&shipmentend=' + $('#shipmentend').val()+ '&currency=' + $('#currency').val() + '&skucategoryids=' + s + '&titlename=' + title, '90%', '90%');
}
function skucategorychildren(categoryid, title) {
......@@ -620,14 +635,16 @@
var shipstart = $('#shipstart').val();
var shipend = $('#shipend').val();
var shipmenstart = $('#shipmentstart').val();
var shipmentend = $('#shipmentend').val();
var start = $('#start').val();
var end = $('#end').val();
if ((shipstart != '' || shipend != '') && (start != '' || end != '')) {
if (((shipstart != '' || shipend != '') && ((start != '' || end != '') || (shipmentstart != '' || shipmentend != ''))) || ((start != '' || end != '') && ((shipstart != '' || shipend != '') || (shipmentstart != '' || shipmentend != '')))) {
layer.alert('搜索条件不能同时选择付款时间和发货时间,只能选其一。');
return false;
}
if (start == '' && end == '' && shipstart == '' && shipend == '') {
if (start == '' && end == '' && shipstart == '' && shipend == '' && shipmenstart == '' && shipmentend == '') {
layer.alert('请选择时间进行搜索。');
return false;
}
......
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