Commit 3fde0018 by guanzhenshan

1、修复库龄列表没有数据的问题;2、修改平台利润统计报表获取ebay广告费和上架费的取数判断条件

parent 257c8820
......@@ -1042,8 +1042,12 @@ namespace Bailun.DC.Services
public List<dc_mid_stock_date> ListStockDate(BtTableParameter parameter, string sku, string warehousetype, string warehouse,DateTime? start,DateTime? end,string buyername,ref int total)
{
var sqlparam = new DynamicParameters();
var sql = "select t1.bailun_sku,t1.warehouse_code,t2.warehouse_name,sum(t1.quantity_stock) as quantity_stock,sum(t1.quantity_stock*t1.unit_price) as amount,stock_time from dc_mid_stock_date t1 ";
var sqlwhere = " join dc_base_warehouse t2 on t1.warehouse_code=t2.warehouse_code ";
//var sql = "select t1.bailun_sku,t1.warehouse_code,t2.warehouse_name,sum(t1.quantity_stock) as quantity_stock,sum(t1.quantity_stock*t1.unit_price) as amount,stock_time from dc_mid_stock_date t1 ";
var sql = "select t1.bailun_sku,t1.warehouse_code,t2.warehouse_name,t1.stock as quantity_stock,t3.unit_price,(t1.stock*t3.unit_price) as amount,t1.`day` as stock_time from dc_mid_stock_age t1";
var sqlwhere = " left join dc_base_warehouse t2 on t1.warehouse_code=t2.warehouse_code ";
sqlwhere += " left join dc_base_sku t3 on t1.bailun_sku=t3.bailun_sku ";
sqlwhere += " where t1.stock>0 ";
if (!string.IsNullOrEmpty(warehousetype))
{
......@@ -1053,11 +1057,11 @@ namespace Bailun.DC.Services
if (!string.IsNullOrEmpty(buyername))
{
sqlwhere += " join dc_base_sku t3 on t1.bailun_sku=t3.bailun_sku and t3.buyer_name=@";
sqlwhere += " and t3.buyer_name=@";
sqlparam.Add("buyer_name", buyername);
}
sqlwhere += " where t1.quantity_stock>0 ";
if (!string.IsNullOrEmpty(sku))
{
......@@ -1071,17 +1075,17 @@ namespace Bailun.DC.Services
}
if (start.HasValue)
{
sqlwhere += " and t1.stock_time>=@start";
sqlwhere += " and t1.day>=@start";
sqlparam.Add("start", start.Value);
}
if (end.HasValue)
{
sqlwhere += " and t1.stock_time<@end";
sqlwhere += " and t1.day<@end";
sqlparam.Add("end", end.Value.AddDays(1));
}
sqlwhere += " group by t1.bailun_sku,t1.warehouse_code,stock_time";
//sqlwhere += " group by t1.bailun_sku,t1.warehouse_code,stock_time";
var sqlsort = "";
if (!string.IsNullOrEmpty(parameter.sort))
......@@ -1103,7 +1107,7 @@ namespace Bailun.DC.Services
}
else
{
var obj = cn.Page<dc_mid_stock_date>(parameter.pageIndex, parameter.limit, sql + sqlwhere + sqlsort, ref total, sqlparam, "select count(*) from (select t1.bailun_sku,t1.warehouse_code from dc_mid_stock_date t1 " + sqlwhere + ") tb", 2 * 60).AsList();
var obj = cn.Page<dc_mid_stock_date>(parameter.pageIndex, parameter.limit, sql + sqlwhere + sqlsort, ref total, sqlparam, "select count(*) from (select t1.bailun_sku,t1.warehouse_code from dc_mid_stock_age t1 " + sqlwhere + ") tb", 2 * 60).AsList();
return obj;
}
......@@ -1122,9 +1126,12 @@ namespace Bailun.DC.Services
public dc_mid_stock_date ListStockDateCount(string sku, string warehousetype, string warehouse, DateTime? start, DateTime? end,string buyername)
{
var sqlparam = new DynamicParameters();
var sql = "select sum(t1.quantity_stock) as quantity_stock,sum(t1.quantity_stock*t1.unit_price) as amount from dc_mid_stock_date t1 ";
var sql = "select sum(t1.stock) as quantity_stock,sum(t1.stock*t3.unit_price) as amount from dc_mid_stock_age t1 ";
var sqlwhere = " left join dc_base_warehouse t2 on t1.warehouse_code=t2.warehouse_code ";
sqlwhere += " left join dc_base_sku t3 on t1.bailun_sku=t3.bailun_sku ";
var sqlwhere = " join dc_base_warehouse t2 on t1.warehouse_code=t2.warehouse_code ";
sqlwhere += " where t1.stock>0 ";
if (!string.IsNullOrEmpty(warehousetype))
{
......@@ -1134,11 +1141,11 @@ namespace Bailun.DC.Services
if (!string.IsNullOrEmpty(buyername))
{
sqlwhere += " join dc_base_sku t3 on t1.bailun_sku=t3.bailun_sku and t3.buyer_name=@";
sqlwhere += " and t3.buyer_name=@";
sqlparam.Add("buyer_name", buyername);
}
sqlwhere += " where t1.quantity_stock>0 ";
if (!string.IsNullOrEmpty(sku))
{
......@@ -1152,15 +1159,15 @@ namespace Bailun.DC.Services
}
if (start.HasValue)
{
sqlwhere += " and t1.stock_time>=@start";
sqlwhere += " and t1.day>=@start";
sqlparam.Add("start", start.Value);
}
if (end.HasValue)
{
sqlwhere += " and t1.stock_time<@end";
sqlwhere += " and t1.day<@end";
sqlparam.Add("end", end.Value.AddDays(1));
}
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
......
......@@ -3343,7 +3343,7 @@ namespace Bailun.DC.Services
/// <param name="total"></param>
/// <param name="feetype">费用类型</param>
/// <returns></returns>
public List<dc_base_finance_ebay> ListEbayFee(BtTableParameter parameter, int? companyid, DateTime? start, DateTime? end, ref int total, string[] feetype, string orderno, string account,string itemid)
public List<dc_base_finance_ebay> ListEbayFee(BtTableParameter parameter, int? companyid, DateTime? start, DateTime? end, ref int total, string[] feetype, string[] description, string orderno, string account,string itemid)
{
var sqlparam = new DynamicParameters();
var sql = "select t1.id,t1.account_entry_type,t1.description,t1.bj_date as gmt_date,t1.gross_amount,t1.item_id,t1.net_amount,t1.vat_percent,t1.order_line_id,t1.currency,t1.exchange_rate,(t1.exchange_rate*t1.gross_amount) gross_amount_rmb,t2.account_name from dc_base_finance_ebay t1 ";
......@@ -3378,6 +3378,11 @@ namespace Bailun.DC.Services
sql += " and t1.account_entry_type in ('" + string.Join("','", feetype) + "')";
}
if (description != null && description.Length > 0)
{
sql += " and t1.description in ('" + string.Join("','", description) + "') ";
}
if (!string.IsNullOrWhiteSpace(account))
{
sql += " and t2.account_name=@account_name";
......@@ -3439,7 +3444,7 @@ namespace Bailun.DC.Services
/// <param name="total"></param>
/// <param name="feetype"></param>
/// <returns></returns>
public dc_base_finance_ebay EbayFeeCount(int? companyid, DateTime? start, DateTime? end, string[] feetype, string orderno, string account,bool isUSD,string itemid, int[] producttype, int? skusource, int? shippingstrategy,string platform, string website)
public dc_base_finance_ebay EbayFeeCount(int? companyid, DateTime? start, DateTime? end, string[] feetype,string[] description, string orderno, string account,bool isUSD,string itemid, int[] producttype, int? skusource, int? shippingstrategy,string platform, string website)
{
if (platform != null && platform.ToLower() != "ebay")
{
......@@ -3530,6 +3535,13 @@ namespace Bailun.DC.Services
sql += " and t1.account_entry_type in ('" + string.Join("','", feetype) + "')";
}
if (description != null && description.Length > 0)
{
sql += " and t1.description in ('" + string.Join("','", description) + "') ";
}
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString_read))
{
if (cn.State == System.Data.ConnectionState.Closed)
......@@ -3552,7 +3564,7 @@ namespace Bailun.DC.Services
/// <param name="total"></param>
/// <param name="feetype"></param>
/// <returns></returns>
public List<dc_base_finance_ebay> EbayFeeCount(int? companyid, DateTime? start, DateTime? end, string[] feetype, string orderno, string account, bool isUSD, string itemid, int[] producttype, int? skusource, int? shippingstrategy, int statistictype,string platform,string website)
public List<dc_base_finance_ebay> EbayFeeCount(int? companyid, DateTime? start, DateTime? end, string[] feetype, string[] description, string orderno, string account, bool isUSD, string itemid, int[] producttype, int? skusource, int? shippingstrategy, int statistictype,string platform,string website)
{
if (platform != null && platform.ToLower() != "ebay")
{
......@@ -3655,6 +3667,11 @@ namespace Bailun.DC.Services
sql += " and t1.account_entry_type in ('" + string.Join("','", feetype) + "')";
}
if (description != null && description.Length > 0)
{
sql += " and t1.description in ('" + string.Join("','", description) + "') ";
}
if (statistictype == 1) //1:sku品类
{
......
......@@ -123,12 +123,22 @@ namespace Bailun.DC.SkuDataWareHouse
str += $@"('{item.warehousetype}','{item.area_id ?? 0}','{item.area_name}','{item.warehousename}','{item.warehouse_code}','{item.sku}',{item.category_id ?? 0},'{(!string.IsNullOrEmpty(item.categoryname) ? item.categoryname : "")}','{item.skuname.Replace("'", "")}',{item.monitorstatus ?? 1},{item.clearancestatus ?? 0},{item.tortstatus ?? 0},'{item.str_skutag}',{item.buyprice ?? 0},{item.usable_stock ?? 0},{item.amount_stock ?? 0},{item.quantity_purchase ?? 0},{item.purchase_amount ?? 0},{item.quantity_transfer ?? 0},{item.amount_transit ?? 0},{item.quantity_out_stock ?? 0},{item.oneday_total_sales ?? 0},{item.amount_onedaysale ?? 0},{item.sevenday_total_sales ?? 0},{item.amount_sevendaysale ?? 0},{item.fourteenday_total_sales ?? 0},{item.thirtyday_total_sales ?? 0},{item.sevenday_average_sales ?? 0},{item.fourteenday_average_sales ?? 0},{item.thirtyday_average_sales ?? 0},'{(item.skucreatetime.HasValue ? item.skucreatetime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "1970-01-01")}','{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}','{item.skubrand.Replace("'", "''")}',{(item.is_redundancy ?? 0)}),";
}
if (resultcount > 0)
{
str = str.Substring(0, str.Length - 1);
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
if (cn.State == System.Data.ConnectionState.Closed)
{
cn.Open();
}
str = str.Substring(0, str.Length - 1);
cn.Execute(str, null, null, 5 * 60);
Console.WriteLine("当前页:" + page + ",每页记录:" + pagesize + ";" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
}
cn.Execute(str, null, null, 5 * 60);
Console.WriteLine("当前页:" + page + ",每页记录:" + pagesize + ";" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
}
page++;
......
......@@ -1156,9 +1156,13 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
};
var obj = _service.ListEbayFee(parameter, companyid, start, end, ref total, feeType,orderno,account,"");
var descript = new string[] {
"Gallery Plus Fee","Insertion Fee","不公開出價者刊登費","副標題功能費","特大圖片瀏覽費用","物品刊登費","一口價刊登費","粗體字刊登費用","提早結束拍賣物品的費用"
};
var obj = _service.ListEbayFee(parameter, companyid, start, end, ref total, null,descript,orderno,account,"");
var countObj = _service.EbayFeeCount(companyid, start, end, feeType, orderno,account,false,"",null,null,null,"Ebay","");
var countObj = _service.EbayFeeCount(companyid, start, end, null,descript, orderno,account,false,"",null,null,null,"Ebay","");
var list = obj.Select(a => new {
a.id,
......@@ -1224,9 +1228,11 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
"FeeAd"
};
var obj = _service.ListEbayFee(parameter, companyid, start, end, ref total, feeType, orderno, account,itemid);
var description = new string[] { "廣告費", "Ad fee" };
var obj = _service.ListEbayFee(parameter, companyid, start, end, ref total, null, description, orderno, account,itemid);
var countObj = _service.EbayFeeCount(companyid, start, end, feeType, orderno, account,false,itemid,null,null,null,"","");
var countObj = _service.EbayFeeCount(companyid, start, end, null,description, orderno, account,false,itemid,null,null,null,"","");
var list = obj.Select(a => new {
a.id,
......@@ -1280,7 +1286,9 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
"FeeAd"
};
var obj = _service.ListEbayFee(new BtTableParameter { offset=0,limit=0}, companyid, start, end, ref total, feeType, orderno, account,itemid);
var description = new string[] { "廣告費", "Ad fee" };
var obj = _service.ListEbayFee(new BtTableParameter { offset=0,limit=0}, companyid, start, end, ref total, null, description, orderno, account,itemid);
var colNames = new List<string> {"销售帐号","费用类型","费用名称","总费用","币种","汇率","RMB金额","item_id","记录时间"};
......@@ -1608,6 +1616,11 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
"BuyItNowFee","CreditInsertion","FeeGalleryPlus","PrivateListing","SubscriptioneBayStores","SubscriptionSMBasic","SubscriptionSMBasicPro","SubtitleFee"
};
var ADfeeDescription = new string[] { "廣告費", "Ad fee" };
var PutAwayFeeDescript = new string[] {
"Gallery Plus Fee","Insertion Fee","不公開出價者刊登費","副標題功能費","特大圖片瀏覽費用","物品刊登費","一口價刊登費","粗體字刊登費用","提早結束拍賣物品的費用"
};
var producttype = new int[] { };
if (!string.IsNullOrEmpty(product_type))
......@@ -1754,8 +1767,8 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
if (statistictype == 0)
{
ebayADFee = _service.EbayFeeCount(companyid, dtstart, dtend, ADfeeType, "", "", currency.ToUpper() == "USD", "", producttype, skusource, shippingstrategy,platform,website);
ebayPutAway = _service.EbayFeeCount(companyid, dtstart, dtend, PutAwayFeeType, "", "", currency.ToUpper() == "USD", "", producttype, skusource, shippingstrategy,platform,website);
ebayADFee = _service.EbayFeeCount(companyid, dtstart, dtend, null,ADfeeDescription, "", "", currency.ToUpper() == "USD", "", producttype, skusource, shippingstrategy,platform,website);
ebayPutAway = _service.EbayFeeCount(companyid, dtstart, dtend, null,PutAwayFeeDescript, "", "", currency.ToUpper() == "USD", "", producttype, skusource, shippingstrategy,platform,website);
amazonAD = _service.ListAmazonADSkuCount("", dtstart, dtend, companyid, currency.ToUpper() == "USD", producttype, skusource, shippingstrategy,platform,website,null);
......@@ -1764,8 +1777,8 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
}
else
{
listebayADFee = _service.EbayFeeCount(companyid, dtstart, dtend, ADfeeType, "", "", currency.ToUpper() == "USD", "", producttype, skusource, shippingstrategy, statistictype,platform,website);
listebayPutAway = _service.EbayFeeCount(companyid, dtstart, dtend, PutAwayFeeType, "", "", currency.ToUpper() == "USD", "", producttype, skusource, shippingstrategy,statistictype,platform,website);
listebayADFee = _service.EbayFeeCount(companyid, dtstart, dtend, null, ADfeeDescription, "", "", currency.ToUpper() == "USD", "", producttype, skusource, shippingstrategy, statistictype,platform,website);
listebayPutAway = _service.EbayFeeCount(companyid, dtstart, dtend, null,PutAwayFeeDescript, "", "", currency.ToUpper() == "USD", "", producttype, skusource, shippingstrategy,statistictype,platform,website);
listamazonAD = _service.ListAmazonADSkuCount("", dtstart, dtend, companyid, currency.ToUpper() == "USD", producttype, skusource, shippingstrategy,statistictype,platform,website);
}
......@@ -1799,8 +1812,8 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
if (statistictype == 0)
{
ebayADFee = _service.EbayFeeCount(companyid, dtstart, dtend, ADfeeType, "", "", currency.ToUpper() == "USD", "", null, null, null,platform,website);
ebayPutAway = _service.EbayFeeCount(companyid, dtstart, dtend, PutAwayFeeType, "", "", currency.ToUpper() == "USD", "", null, null, null,platform,website);
ebayADFee = _service.EbayFeeCount(companyid, dtstart, dtend, null,ADfeeDescription, "", "", currency.ToUpper() == "USD", "", null, null, null,platform,website);
ebayPutAway = _service.EbayFeeCount(companyid, dtstart, dtend, null,PutAwayFeeDescript, "", "", currency.ToUpper() == "USD", "", null, null, null,platform,website);
amazonAD = _service.ListAmazonADSkuCount("", dtstart, dtend, companyid, currency.ToUpper() == "USD", null, null, null,platform,website,null);
wishAD = _service.ListWishADCount(companyid, null, dtstart, dtend, currency.ToUpper() == "USD");
......@@ -1808,8 +1821,8 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
}
else
{
listebayADFee = _service.EbayFeeCount(companyid, dtstart, dtend, ADfeeType, "", "", currency.ToUpper() == "USD", "", producttype, skusource, shippingstrategy, statistictype,platform,website);
listebayPutAway = _service.EbayFeeCount(companyid, dtstart, dtend, PutAwayFeeType, "", "", currency.ToUpper() == "USD", "", producttype, skusource, shippingstrategy, statistictype,platform,website);
listebayADFee = _service.EbayFeeCount(companyid, dtstart, dtend, null,ADfeeDescription, "", "", currency.ToUpper() == "USD", "", producttype, skusource, shippingstrategy, statistictype,platform,website);
listebayPutAway = _service.EbayFeeCount(companyid, dtstart, dtend, null,PutAwayFeeDescript, "", "", currency.ToUpper() == "USD", "", producttype, skusource, shippingstrategy, statistictype,platform,website);
listamazonAD = _service.ListAmazonADSkuCount("", dtstart, dtend, companyid, currency.ToUpper() == "USD", producttype, skusource, shippingstrategy, statistictype,platform,website);
}
......
......@@ -235,7 +235,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
a.warehouse_name,
quantity_stock = a.quantity_stock.ToString("N0"),
amount = a.amount.ToString("N2"),
stock_time = (DateTime.Now-a.stock_time).Days+"d"
stock_time = (DateTime.Now-a.stock_time).Days+((DateTime.Now - a.stock_time).Hours>0?1:0) +"d"
});
......@@ -313,7 +313,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
var list = new List<string>();
foreach (var item in obj)
{
list.Add(item.bailun_sku + "|" + item.warehouse_code + "|" + item.warehouse_name + "|" + item.quantity_stock + "|" + item.amount+"|"+(DateTime.Now-item.stock_time).Days+"d");
list.Add(item.bailun_sku + "|" + item.warehouse_code + "|" + item.warehouse_name + "|" + item.quantity_stock + "|" + item.amount+"|"+(((DateTime.Now - item.stock_time).Days + ((DateTime.Now - item.stock_time).Hours > 0 ? 1 : 0)) + "d");
}
var guid = Guid.NewGuid().ToString();
......
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