Commit 5095a1ad by guanzhenshan

处理逻辑仓库排序不了的问题,处理平台余额的期初期末不对的问题

parent eee0b886
......@@ -27,8 +27,8 @@ namespace Bailun.DC.Services
try
{
// "\"{\\\"Rate\\\":6.7941,\\\"ToCurName\\\":\\\"USD->CNY\\\",\\\"CreateTime\\\":\\\"2019-01-25 19:36:38\\\"}\""
result = result.Replace("\\", "").Substring(1);
result = result.Substring(0, result.Length - 1);
//result = result.Replace("\\", "").Substring(1);
//result = result.Substring(0, result.Length - 1);
var obj = Newtonsoft.Json.JsonConvert.DeserializeObject<ExchangeRate>(result);
return obj.Rate;
......
......@@ -383,16 +383,40 @@ namespace Bailun.DC.Services
{
var m = cn.QueryFirstOrDefault<dc_platform_balance>($"select * from dc_platform_balance where platformcode='{item.platformcode}' and currency='{item.currency}' and delstatus=0 order by day desc limit 1");
if (m.platformcode.ToUpper() != "EBAY" && m.platformcode.ToUpper() != "ALIEXPRESS" && m.amount==item.amount)
if (item.platformcode.ToUpper() != "EBAY" && item.platformcode.ToUpper() != "ALIEXPRESS")
{
item.amount = m.amount + m.amount_sales - m.withdraw_amount;
if (m != null && m.userable_amount == item.userable_amount)
{
item.amount = m.amount + item.amount_sales - item.withdraw_amount; //本期期末=上一期期末+本期销售额-本期提现额
item.amount_rmb = item.amount * item.exchangerate;
item.before_balance = m.amount;
}
if (m != null)
else if (m != null && m.userable_amount != item.userable_amount)
{
item.amount = item.userable_amount + item.amount_sales - item.withdraw_amount;
item.amount_rmb = item.amount * item.exchangerate;
item.before_balance = item.userable_amount;
}
else if (m == null && m.userable_amount == item.userable_amount)
{
item.amount = 0 + item.amount_sales - item.withdraw_amount; //本期期末=上一期期末+本期销售额-本期提现额
item.amount_rmb = item.amount * item.exchangerate;
item.before_balance = 0;
}
else if (m == null && m.userable_amount != item.userable_amount)
{
item.before_balance = m.userable_amount + m.amount_sales - m.withdraw_amount;
item.amount = item.userable_amount + item.amount_sales - item.withdraw_amount;
item.amount_rmb = item.amount * item.exchangerate;
item.before_balance = item.userable_amount;
}
}
else
{
item.amount = item.userable_amount;
item.amount_rmb = item.userable_amount * item.exchangerate;
item.before_balance = m.userable_amount;
}
cn.Insert<dc_platform_balance>(item);
}
......
......@@ -775,7 +775,7 @@ namespace Bailun.DC.Services
public List<Models.Orders.mPlatformProfit> ListPlatformProfit(string platform, DateTime? start, DateTime? end)
{
var sqlparam = new DynamicParameters();
var sql = "select platform_type as platform, sum(amount_total*seller_order_exchange_rate) saleamount,count(id) ordercount,sum(cost_platform_fee*seller_order_exchange_rate) platformfee,(sum(amount_total*seller_order_exchange_rate)/count(id)) customerprice,sum(profit_total) profit,(sum(profit_total)/sum(amount_total*seller_order_exchange_rate)) profitrate,sum(amount_refund*seller_order_exchange_rate) returnamount,(sum(amount_refund*seller_order_exchange_rate)/sum(amount_total*seller_order_exchange_rate)) returnamountrate,sum(cost_first) cost_first,sum(cost_tail) cost_tail,sum(cost_handle_bailun) cost_handle_bailun,sum(cost_handle_platform) cost_handle_platform,sum(amount_prepaid*seller_order_exchange_rate) amount_prepaid from dc_base_oms_order where bailun_order_status!='Canceled'";
var sql = "select platform_type as platform, sum(amount_total*seller_order_exchange_rate) saleamount,count(id) ordercount,sum(cost_platform_fee*seller_order_exchange_rate) platformfee,(sum(amount_total*seller_order_exchange_rate)/count(id)) customerprice,sum(profit_total) profit,(sum(profit_total)/sum(amount_total*seller_order_exchange_rate)) profitrate,sum(amount_refund*seller_order_exchange_rate) returnamount,(sum(amount_refund*seller_order_exchange_rate)/sum(amount_total*seller_order_exchange_rate)) returnamountrate,sum(cost_first) cost_first,sum(cost_tail) cost_tail,sum(cost_handle_bailun) cost_handle_bailun,sum(cost_handle_platform) cost_handle_platform,sum(amount_prepaid) amount_prepaid from dc_base_oms_order where bailun_order_status!='Canceled'";
if (!string.IsNullOrWhiteSpace(platform))
{
......@@ -914,7 +914,7 @@ namespace Bailun.DC.Services
public List<Models.Orders.dc_base_oms_order> ListPlatformProfitOrders(BtTableParameter parameter, string platform, string website,string account, DateTime? start, DateTime? end, string orderno, ref int total)
{
var sqlparam = new DynamicParameters();
var sql = "select id,platform_type,website,origin_order_id,bailun_order_id,seller_account,order_currency,amount_total,amount_product,amount_shipping,amount_tax,amount_adjustment,amount_gift_wrap,amount_refund,cost_total,cost_promotion,cost_platform_fee,cost_product,cost_shipping,cost_package,cost_fba_fee,cost_paypal_fee,cost_refund_commisson,cost_handle_bailun,cost_handle_platform,cost_tail,cost_first,profit_total,profit_rate,create_time,paid_time,seller_order_exchange_rate,seller_other_exchange_rate,(seller_order_exchange_rate*amount_prepaid) amount_prepaid from dc_base_oms_order where bailun_order_status!='Canceled' ";
var sql = "select id,platform_type,website,origin_order_id,bailun_order_id,seller_account,order_currency,amount_total,amount_product,amount_shipping,amount_tax,amount_adjustment,amount_gift_wrap,amount_refund,cost_total,cost_promotion,cost_platform_fee,cost_product,cost_shipping,cost_package,cost_fba_fee,cost_paypal_fee,cost_refund_commisson,cost_handle_bailun,cost_handle_platform,cost_tail,cost_first,profit_total,profit_rate,create_time,paid_time,seller_order_exchange_rate,seller_other_exchange_rate,(amount_prepaid) amount_prepaid from dc_base_oms_order where bailun_order_status!='Canceled' ";
if (!string.IsNullOrWhiteSpace(platform))
{
......@@ -978,7 +978,7 @@ namespace Bailun.DC.Services
public Models.Orders.dc_base_oms_order ListPlatformProfitOrdersCount(string platform, string website,string account, DateTime? start, DateTime? end, string orderno)
{
var sqlparam = new DynamicParameters();
var sql = "select sum(amount_total*seller_order_exchange_rate) amount_total,sum(amount_product*seller_order_exchange_rate) amount_product,sum(amount_shipping*seller_order_exchange_rate) amount_shipping,sum(amount_tax*seller_order_exchange_rate) amount_tax,sum(amount_adjustment*seller_order_exchange_rate) amount_adjustment,sum(amount_gift_wrap*seller_order_exchange_rate) amount_gift_wrap,sum(amount_refund*seller_order_exchange_rate) amount_refund,sum(cost_total) cost_total,sum(cost_promotion*seller_order_exchange_rate) cost_promotion,sum(cost_platform_fee*seller_order_exchange_rate) cost_platform_fee,sum(cost_product) cost_product,sum(cost_shipping) cost_shipping,sum(cost_package) cost_package,sum(cost_fba_fee*seller_order_exchange_rate) cost_fba_fee,sum(cost_paypal_fee*seller_order_exchange_rate) cost_paypal_fee,sum(cost_refund_commisson*seller_order_exchange_rate) cost_refund_commisson,sum(cost_handle_bailun) cost_handle_bailun,sum(cost_handle_platform) cost_handle_platform,sum(cost_tail) cost_tail,sum(cost_first) cost_first,sum(profit_total) profit_total,sum(seller_order_exchange_rate*amount_prepaid) amount_prepaid from dc_base_oms_order where bailun_order_status!='Canceled' ";
var sql = "select sum(amount_total*seller_order_exchange_rate) amount_total,sum(amount_product*seller_order_exchange_rate) amount_product,sum(amount_shipping*seller_order_exchange_rate) amount_shipping,sum(amount_tax*seller_order_exchange_rate) amount_tax,sum(amount_adjustment*seller_order_exchange_rate) amount_adjustment,sum(amount_gift_wrap*seller_order_exchange_rate) amount_gift_wrap,sum(amount_refund*seller_order_exchange_rate) amount_refund,sum(cost_total) cost_total,sum(cost_promotion*seller_order_exchange_rate) cost_promotion,sum(cost_platform_fee*seller_order_exchange_rate) cost_platform_fee,sum(cost_product) cost_product,sum(cost_shipping) cost_shipping,sum(cost_package) cost_package,sum(cost_fba_fee*seller_order_exchange_rate) cost_fba_fee,sum(cost_paypal_fee*seller_order_exchange_rate) cost_paypal_fee,sum(cost_refund_commisson*seller_order_exchange_rate) cost_refund_commisson,sum(cost_handle_bailun) cost_handle_bailun,sum(cost_handle_platform) cost_handle_platform,sum(cost_tail) cost_tail,sum(cost_first) cost_first,sum(profit_total) profit_total,sum(amount_prepaid) amount_prepaid from dc_base_oms_order where bailun_order_status!='Canceled' ";
if (!string.IsNullOrWhiteSpace(platform))
{
......
......@@ -45,7 +45,7 @@ namespace Bailun.DC.Services
var sqlwhere = @"from dc_base_sku t1
left join dc_base_stock t2 on t1.bailun_sku=t2.bailun_sku
left join dc_mid_transit t3 on t1.bailun_sku=t3.bailun_sku
left join dc_daily_sales t5 on t1.bailun_sku =t5.bailun_sku and t5.record_date = DATE_SUB(curdate(),INTERVAL 0 DAY)
left join dc_daily_sales t5 on t1.bailun_sku =t5.bailun_sku and t5.record_date = DATE_SUB(curdate(),INTERVAL 1 DAY)
where 1=1 ";
if (!string.IsNullOrWhiteSpace(sku))
{
......@@ -98,7 +98,7 @@ namespace Bailun.DC.Services
var sqlwhere = @"from dc_base_sku t1
left join dc_base_stock t2 on t1.bailun_sku=t2.bailun_sku
left join dc_mid_transit t3 on t1.bailun_sku=t3.bailun_sku
left join dc_daily_sales t5 on t1.bailun_sku =t5.bailun_sku and t5.record_date = DATE_SUB(curdate(),INTERVAL 0 DAY)
left join dc_daily_sales t5 on t1.bailun_sku =t5.bailun_sku and t5.record_date = DATE_SUB(curdate(),INTERVAL 1 DAY)
where 1=1 ";
if (!string.IsNullOrWhiteSpace(sku))
{
......
......@@ -76,30 +76,38 @@ namespace Bailun.DC.Services
left join dc_mid_transit t2 on t1.warehouse_code=t2.warehouse_code and t1.bailun_sku=t2.bailun_sku
left join dc_base_sku t3 on t1.bailun_sku=t3.bailun_sku
left join dc_base_warehouse t4 on t1.warehouse_code=t4.warehouse_code
left join dc_daily_sales t5 on t1.warehouse_code=t5.warehouse_code and t1.bailun_sku =t5.bailun_sku and t5.record_date = DATE_SUB(curdate(),INTERVAL 0 DAY)
left join dc_daily_sales t5 on t1.warehouse_code=t5.warehouse_code and t1.bailun_sku =t5.bailun_sku and t5.record_date = DATE_SUB(curdate(),INTERVAL 1 DAY)
";
var sqlcount = "select t1.warehouse_code from dc_base_stock t1 ";
if (!string.IsNullOrWhiteSpace(warehousetype))
{
sqlwhere += " and t4.hq_type=@hq_type";
sqlparam.Add("hq_type", warehousetype);
sqlcount += " left join dc_base_warehouse t4 on t1.warehouse_code=t4.warehouse_code and hq_type=@hq_type";
}
if (!string.IsNullOrWhiteSpace(warehouse))
{
sqlwhere += "t1.warehouse_code=@warehouse_code";
sqlparam.Add("warehouse_code", warehouse);
sqlcount+= "t1.warehouse_code=@warehouse_code";
}
sqlwhere += " group by t1.warehouse_code";
var sqlorder = "";
if (!string.IsNullOrWhiteSpace(parameter.sort))
{
sqlwhere += " order by " + parameter.sort;
sqlorder += " order by " + parameter.sort;
if (!string.IsNullOrWhiteSpace(parameter.order))
{
sqlwhere += " " + parameter.order;
sqlorder += " " + parameter.order;
}
}
......@@ -110,7 +118,7 @@ namespace Bailun.DC.Services
cn.Open();
}
var obj = cn.Page<Models.Stock.mLogicWarehouse>(parameter.pageIndex, parameter.limit, sql+ sqlwhere, ref total, parameter, "select count(*) from (select t1.warehouse_code from dc_base_stock t1 left join dc_mid_transit t2 on t1.warehouse_code=t2.warehouse_code and t1.bailun_sku=t2.bailun_sku left join dc_base_sku t3 on t1.bailun_sku=t3.bailun_sku left join dc_base_warehouse t4 on t1.warehouse_code=t4.warehouse_code left join dc_daily_sales t5 on t1.warehouse_code=t5.warehouse_code and t1.bailun_sku =t5.bailun_sku and t5.record_date = DATE_SUB(curdate(),INTERVAL 0 DAY)" + sqlwhere+ ") tb");
var obj = cn.Page<Models.Stock.mLogicWarehouse>(parameter.pageIndex, parameter.limit, sql+ sqlwhere+ sqlorder, ref total, sqlparam, "select count(*) from (" + sqlcount+ " group by t1.warehouse_code) tb");
return obj.AsList();
}
}
......@@ -130,7 +138,7 @@ namespace Bailun.DC.Services
left join dc_mid_transit t2 on t1.warehouse_code=t2.warehouse_code and t1.bailun_sku=t2.bailun_sku
left join dc_base_sku t3 on t1.bailun_sku=t3.bailun_sku
left join dc_base_warehouse t4 on t1.warehouse_code=t4.warehouse_code
left join dc_daily_sales t5 on t1.warehouse_code=t5.warehouse_code and t1.bailun_sku =t5.bailun_sku and t5.record_date = DATE_SUB(curdate(),INTERVAL 0 DAY)
left join dc_daily_sales t5 on t1.warehouse_code=t5.warehouse_code and t1.bailun_sku =t5.bailun_sku and t5.record_date = DATE_SUB(curdate(),INTERVAL 1 DAY)
";
......
......@@ -822,7 +822,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
countM.amount_refund = Math.Round(countM.amount_refund, 2, MidpointRounding.AwayFromZero);
countM.amount_prepaid = Math.Round(countM.amount_prepaid, 2, MidpointRounding.AwayFromZero);
countM.profit_total = Math.Round(countM.profit_total, 2, MidpointRounding.AwayFromZero);
countM.profit_rate = Math.Round((countM.profit_total / countM.amount_product), 2, MidpointRounding.AwayFromZero);
countM.profit_rate = countM.amount_product>0?Math.Round((countM.profit_total / countM.amount_product), 2, MidpointRounding.AwayFromZero):0;
var obj = list.Select(p => new
......
......@@ -49,24 +49,39 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
countM.purchase_amount = Math.Round(countM.purchase_amount ?? 0, 2, MidpointRounding.AwayFromZero);
var list = obj.Select(p => new {
amount_onedaysale = p.amount_onedaysale??0,
amount_stock = p.amount_stock,
amount_transit = p.amount_transit??0.00M,
fourteenday_total_sales = p.fourteenday_total_sales??0,
noshippingcount = p.noshippingcount??0,
nostockcount = p.nostockcount??0,
oneday_total_sales = p.oneday_total_sales??0,
purchase_amount = p.purchase_amount??0,
quantity_purchase = p.quantity_purchase??0,
quantity_transfer = p.quantity_transfer??0,
sevenday_total_sales = p.sevenday_total_sales??0,
thirtyday_total_sales = p.thirtyday_total_sales??0,
p.usable_stock,
amount_onedaysale = (p.amount_onedaysale??0).ToString("N2"),
amount_stock = p.amount_stock.ToString("N2"),
amount_transit = (p.amount_transit??0.00M).ToString("N2"),
fourteenday_total_sales = (p.fourteenday_total_sales??0).ToString("N2"),
noshippingcount = (p.noshippingcount??0).ToString("N2"),
nostockcount = (p.nostockcount??0).ToString("N2"),
oneday_total_sales = (p.oneday_total_sales??0).ToString("N2"),
purchase_amount = (p.purchase_amount??0).ToString("N2"),
quantity_purchase = (p.quantity_purchase??0).ToString("N2"),
quantity_transfer = (p.quantity_transfer??0).ToString("N2"),
sevenday_total_sales = (p.sevenday_total_sales??0).ToString("N2"),
thirtyday_total_sales = (p.thirtyday_total_sales??0).ToString("N2"),
usable_stock = p.usable_stock.ToString("N2"),
p.warehouse_code,
p.warehouse_name,
});
return JsonConvert.SerializeObject(new { total = total, rows = list, count_row = countM });
return JsonConvert.SerializeObject(new { total = total, rows = list, count_row = new {
countM.warehouse_name,
amount_onedaysale = (countM.amount_onedaysale??0).ToString("N2"),
amount_stock = countM.amount_stock.ToString("N2"),
amount_transit = (countM.amount_transit??0).ToString("N2"),
noshippingcount = (countM.noshippingcount??0).ToString("N2"),
nostockcount = (countM.nostockcount??0).ToString("N2"),
oneday_total_sales = (countM.oneday_total_sales??0).ToString("N2"),
purchase_amount = (countM.purchase_amount??0).ToString("N2"),
quantity_purchase = (countM.quantity_purchase??0).ToString("N2"),
quantity_transfer = (countM.quantity_transfer??0).ToString("N2"),
sevenday_total_sales = (countM.sevenday_total_sales??0).ToString("N2"),
thirtyday_total_sales = (countM.thirtyday_total_sales??0).ToString("N2"),
usable_stock = countM.usable_stock.ToString("N2"),
fourteenday_total_sales = (countM.fourteenday_total_sales??0).ToString("N2")
} });
}
/// <summary>
......
......@@ -12,16 +12,16 @@
<div class="form-inline" style="line-height:40px;">
<div class="form-group">
<label>销售帐号:</label>
<select id="saleaccount" name="saleaccount" class="form-control" style="width:160px;">
<select id="selleraccount" name="selleraccount" class="form-control" style="width:160px;">
<option value="">选择帐号</option>
</select>
</div>
<div class="form-group">
@*<div class="form-group">
<label>站点:</label>
<select id="website" name="website" class="form-control">
<option value="">选择站点</option>
</select>
</div>
</div>*@
<div class="form-group">
<label>仓库类型:</label>
<select id="warehousetype" name="warehousetype" class="form-control">
......@@ -82,7 +82,7 @@
listAccount();
listWebsite();
//listWebsite();
listwarehousetype();
......@@ -102,7 +102,7 @@
return str;
}
},
{ field: 'website', title: '站点', width: '80', sortable: false, iscount: true },
//{ field: 'website', title: '站点', width: '80', sortable: false, iscount: true },
{
field: 'amount_product', title: '商品收入', width: '100', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'商品收入\',\'amount_product\',1)">' + data.amount_product + '</span>';
......@@ -185,9 +185,9 @@
paramData: 'platform=Ebay',
func: function (result) {
if (result != null && result != undefined) {
$('#saleaccount').html('<option value="">选择帐号</option>');
$('#selleraccount').html('<option value="">选择帐号</option>');
for (var i = 0; i < result.length; i++) {
$('#saleaccount').append('<option value="' + result[i] + '">' + result[i]+'</option>');
$('#selleraccount').append('<option value="' + result[i] + '">' + result[i]+'</option>');
}
}
}
......@@ -220,6 +220,7 @@
$('#warehousetype').html('<option value="">选择仓库类型</option>');
for (var i in result) {
$('#warehousetype').append('<option value="' + result[i] + '">' + result[i] + '</option>');
}
}
}
......@@ -237,10 +238,12 @@
if (result != null && result != undefined) {
$('#warehousecode').html('<option value="">仓库不限</option>');
for (var i = 0; i < result.length; i++) {
if (result[i].warehouse_name.indexOf('FBA') < 0) {
$('#warehousecode').append('<option value="' + result[i].warehouse_code + '">' + result[i].warehouse_name + '</option>');
}
}
}
}
})
}
......
......@@ -60,7 +60,7 @@
listwarehouse();
$('#listwarehouse').change(function () {
$('#warehousetype').change(function () {
listwarehouse();
})
......
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