Commit 61950156 by guanzhenshan

月销售利润报表增加导出功能

parent 7837af01
using System;
using System.Collections.Generic;
using System.Text;
namespace Bailun.DC.Models.Common
{
public class KeyValue
{
public string Key { get; set; }
public string Value { get; set; }
}
}
...@@ -5530,8 +5530,8 @@ group by currency"; ...@@ -5530,8 +5530,8 @@ group by currency";
obj.fee_platform_and_refund = obj.fee_platform + obj.fee_fba + obj.fee_refund+obj.fee_ad; obj.fee_platform_and_refund = obj.fee_platform + obj.fee_fba + obj.fee_refund+obj.fee_ad;
sql_update += " ,fee_platform_and_refund=" + obj.fee_platform_and_refund; sql_update += " ,fee_platform_and_refund=" + obj.fee_platform_and_refund;
//物流仓储费用 = 头程运输+直邮物流费+海外仓仓储+海外仓杂费 //物流仓储费用 = 头程运输+直邮物流费+尾程物流费+海外仓仓储+海外仓杂费
obj.fee_logistics_storage = obj.fee_logistics_first + obj.fee_logistics_direct + obj.fee_storage+ obj.fee_storage_incidentals; obj.fee_logistics_storage = obj.fee_logistics_first + obj.fee_logistics_direct+obj.fee_logistics_tail + obj.fee_storage+ obj.fee_storage_incidentals;
sql_update += " ,fee_logistics_storage=" + obj.fee_logistics_storage; sql_update += " ,fee_logistics_storage=" + obj.fee_logistics_storage;
//销售费用合计=平台扣费及退款+物流仓储费用+付现销售费用 //销售费用合计=平台扣费及退款+物流仓储费用+付现销售费用
......
...@@ -8905,6 +8905,233 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -8905,6 +8905,233 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
}); });
} }
/// <summary>
/// 导出月销售利润报表
/// </summary>
/// <param name="month">月份</param>
/// <returns></returns>
public ActionResult ExportMonthSaleProfitNew(string month)
{
var _service = new Services.FinanceReportServices();
var obj = _service.ListMonthSaleProfitNew(month, "");
var listCount = new List<dc_month_sales_profit>();
var listMonth = obj.GroupBy(a => a.month);
var arrValue = new List<Models.Common.KeyValue>();
arrValue.Add(new Models.Common.KeyValue() { Key = "销售额", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "精油产品", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "电子产品", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "家居产品", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "美容美甲产品", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "服装", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "其他", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "退款", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "成本", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "精油产品 ", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "电子产品 ", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "家居产品 ", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "美容美甲产品 ", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "服装 ", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "其他 ", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "平台费用", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "平台费", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "FBA费", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "广告及宣传费", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "物流仓储费用", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "头程运输", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "直邮物流费", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "尾程物流费", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "海外仓仓储费", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "海外仓其他杂费", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "付现销售费用", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "销售费用合计", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "销售利润", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "销售毛利率", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "财务费用", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "管理成本合计", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "广州百伦供应链科技有限公司", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "广州歌戈儿生活科技有限公司", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "深圳前海扬杉创新科技有限公司", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "广州信荟蓝科技有限公司", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "广州电子服装仓&阳山", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "广州迪致美容科技有限公司", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "营业利润", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "营业毛利率", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "加:其他收入", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "其中:出口退税收入", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "加:营业外收入", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "减:营业外支出", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "实际利润", Value = "" });
arrValue.Add(new Models.Common.KeyValue() { Key = "净利率", Value = "" });
var str_head = "项目,";
foreach (var item in listMonth)
{
str_head += item.Key + "基础数据," + item.Key + "调整数据," + item.Key + "合计数据,";
var objBase = item.Where(a => a.isedit == 0).FirstOrDefault();
var objEdit = item.Where(a => a.isedit == 1).FirstOrDefault();
if (objBase == null)
{
continue;
}
if (objEdit == null)
{
objEdit = new dc_month_sales_profit();
}
var amount_sales = arrValue.Where(a => a.Key == "销售额").FirstOrDefault();
amount_sales.Value += objBase.amount_sales + "," + objEdit.amount_sales + "," + (objBase.amount_sales + objEdit.amount_sales + ",");
var amount_sales_jingyou = arrValue.Where(a => a.Key == "精油产品").FirstOrDefault();
amount_sales_jingyou.Value += objBase.amount_sales_jingyou + "," + objEdit.amount_sales_jingyou + "," + (objBase.amount_sales_jingyou + objEdit.amount_sales_jingyou + ",");
var amount_sales_dianzi = arrValue.Where(a => a.Key == "电子产品").FirstOrDefault();
amount_sales_dianzi.Value += objBase.amount_sales_dianzi + "," + objEdit.amount_sales_dianzi + "," + (objBase.amount_sales_dianzi + objEdit.amount_sales_dianzi + ",");
var amount_sales_jiaju = arrValue.Where(a => a.Key == "家居产品").FirstOrDefault();
amount_sales_jiaju.Value += objBase.amount_sales_jiaju + "," + objEdit.amount_sales_jiaju + "," + (objBase.amount_sales_jiaju + objEdit.amount_sales_jiaju + ",");
var amount_sales_meirongmj = arrValue.Where(a => a.Key == "美容美甲产品").FirstOrDefault();
amount_sales_meirongmj.Value += objBase.amount_sales_meirongmj + "," + objEdit.amount_sales_meirongmj + "," + (objBase.amount_sales_meirongmj + objEdit.amount_sales_meirongmj + ",");
var amount_sales_fuzhuang = arrValue.Where(a => a.Key == "服装").FirstOrDefault();
amount_sales_fuzhuang.Value += objBase.amount_sales_fuzhuang + "," + objEdit.amount_sales_fuzhuang + "," + (objBase.amount_sales_fuzhuang + objEdit.amount_sales_fuzhuang + ",");
var amount_sales_other = arrValue.Where(a => a.Key == "其他").FirstOrDefault();
amount_sales_other.Value += objBase.amount_sales_other + "," + objEdit.amount_sales_other + "," + (objBase.amount_sales_other + objEdit.amount_sales_other + ",");
var fee_refund = arrValue.Where(a => a.Key == "退款").FirstOrDefault();
fee_refund.Value += objBase.fee_refund + "," + objEdit.fee_refund + "," + (objBase.fee_refund + objEdit.fee_refund + ",");
var cost = arrValue.Where(a => a.Key == "成本").FirstOrDefault();
cost.Value += objBase.cost + "," + objEdit.cost + "," + (objBase.cost + objEdit.cost + ",");
var cost_jingyou = arrValue.Where(a => a.Key == "精油产品 ").FirstOrDefault();
cost_jingyou.Value += objBase.cost_jingyou + "," + objEdit.cost_jingyou + "," + (objBase.cost_jingyou + objEdit.cost_jingyou + ",");
var cost_dianzi = arrValue.Where(a => a.Key == "电子产品 ").FirstOrDefault();
cost_dianzi.Value += objBase.cost_dianzi + "," + objEdit.cost_dianzi + "," + (objBase.cost_dianzi + objEdit.cost_dianzi + ",");
var cost_jiaju = arrValue.Where(a => a.Key == "家居产品 ").FirstOrDefault();
cost_jiaju.Value += objBase.cost_jiaju + "," + objEdit.cost_jiaju + "," + (objBase.cost_jiaju + objEdit.cost_jiaju + ",");
var cost_meirongmj = arrValue.Where(a => a.Key == "美容美甲产品 ").FirstOrDefault();
cost_meirongmj.Value += objBase.cost_meirongmj + "," + objEdit.cost_meirongmj + "," + (objBase.cost_meirongmj + objEdit.cost_meirongmj + ",");
var cost_fuzhuang = arrValue.Where(a => a.Key == "服装 ").FirstOrDefault();
cost_fuzhuang.Value += objBase.cost_fuzhuang + "," + objEdit.cost_fuzhuang + "," + (objBase.cost_fuzhuang + objEdit.cost_fuzhuang + ",");
var cost_other = arrValue.Where(a => a.Key == "其他 ").FirstOrDefault();
cost_other.Value += objBase.cost_other + "," + objEdit.cost_other + "," + (objBase.cost_other + objEdit.cost_other + ",");
var fee_platform_and_refund = arrValue.Where(a => a.Key == "平台费用").FirstOrDefault();
fee_platform_and_refund.Value += objBase.fee_platform_and_refund + "," + objEdit.fee_platform_and_refund + "," + (objBase.fee_platform_and_refund + objEdit.fee_platform_and_refund + ",");
var fee_platform = arrValue.Where(a => a.Key == "平台费").FirstOrDefault();
fee_platform.Value += objBase.fee_platform + "," + objEdit.fee_platform + "," + (objBase.fee_platform + objEdit.fee_platform + ",");
var fee_fba = arrValue.Where(a => a.Key == "FBA费").FirstOrDefault();
fee_fba.Value += objBase.fee_fba + "," + objEdit.fee_fba + "," + (objBase.fee_fba + objEdit.fee_fba + ",");
var fee_ad = arrValue.Where(a => a.Key == "广告及宣传费").FirstOrDefault();
fee_ad.Value += objBase.fee_ad + "," + objEdit.fee_ad + "," + (objBase.fee_ad + objEdit.fee_ad + ",");
var fee_logistics_storage = arrValue.Where(a => a.Key == "物流仓储费用").FirstOrDefault();
fee_logistics_storage.Value += objBase.fee_logistics_storage + "," + objEdit.fee_logistics_storage + "," + (objBase.fee_logistics_storage + objEdit.fee_logistics_storage + ",");
var fee_logistics_first = arrValue.Where(a => a.Key == "头程运输").FirstOrDefault();
fee_logistics_first.Value += objBase.fee_logistics_first + "," + objEdit.fee_logistics_first + "," + (objBase.fee_logistics_first + objEdit.fee_logistics_first + ",");
var fee_logistics_direct = arrValue.Where(a => a.Key == "直邮物流费").FirstOrDefault();
fee_logistics_direct.Value += objBase.fee_logistics_direct + "," + objEdit.fee_logistics_direct + "," + (objBase.fee_logistics_direct + objEdit.fee_logistics_direct + ",");
var fee_logistics_tail = arrValue.Where(a => a.Key == "尾程物流费").FirstOrDefault();
fee_logistics_tail.Value += objBase.fee_logistics_tail + "," + objEdit.fee_logistics_tail + "," + (objBase.fee_logistics_tail + objEdit.fee_logistics_tail + ",");
var fee_storage = arrValue.Where(a => a.Key == "海外仓仓储费").FirstOrDefault();
fee_storage.Value += objBase.fee_storage + "," + objEdit.fee_storage + "," + (objBase.fee_storage + objEdit.fee_storage + ",");
var fee_storage_incidentals = arrValue.Where(a => a.Key == "海外仓其他杂费").FirstOrDefault();
fee_storage_incidentals.Value += objBase.fee_storage_incidentals + "," + objEdit.fee_storage_incidentals + "," + (objBase.fee_storage_incidentals + objEdit.fee_storage_incidentals + ",");
var fee_paycash_sales = arrValue.Where(a => a.Key == "付现销售费用").FirstOrDefault();
fee_paycash_sales.Value += objBase.fee_paycash_sales + "," + objEdit.fee_paycash_sales + "," + (objBase.fee_paycash_sales + objEdit.fee_paycash_sales + ",");
var fee_sales_count = arrValue.Where(a => a.Key == "销售费用合计").FirstOrDefault();
fee_sales_count.Value += objBase.fee_sales_count + "," + objEdit.fee_sales_count + "," + (objBase.fee_sales_count + objEdit.fee_sales_count + ",");
var profit_sales = arrValue.Where(a => a.Key == "销售利润").FirstOrDefault();
profit_sales.Value += objBase.profit_sales + "," + objEdit.profit_sales + "," + (objBase.profit_sales + objEdit.profit_sales + ",");
var rate_profit_sales = arrValue.Where(a => a.Key == "销售毛利率").FirstOrDefault();
rate_profit_sales.Value += objBase.rate_profit_sales + "," + objEdit.rate_profit_sales + "," + ((item.Sum(m=>m.profit_sales) / item.Sum(m=>m.amount_sales)) + ",");
var fee_finance = arrValue.Where(a => a.Key == "财务费用").FirstOrDefault();
fee_finance.Value += objBase.fee_finance + "," + objEdit.fee_finance + "," + (objBase.fee_finance + objEdit.fee_finance + ",");
var managercost_count = arrValue.Where(a => a.Key == "管理成本合计").FirstOrDefault();
managercost_count.Value += objBase.managercost_count + "," + objEdit.managercost_count + "," + (objBase.managercost_count + objEdit.managercost_count + ",");
var managecost_bl_gz = arrValue.Where(a => a.Key == "广州百伦供应链科技有限公司").FirstOrDefault();
managecost_bl_gz.Value += objBase.managecost_bl_gz + "," + objEdit.managecost_bl_gz + "," + (objBase.managecost_bl_gz + objEdit.managecost_bl_gz + ",");
var managecost_meijia = arrValue.Where(a => a.Key == "广州歌戈儿生活科技有限公司").FirstOrDefault();
managecost_meijia.Value += objBase.managecost_meijia + "," + objEdit.managecost_meijia + "," + (objBase.managecost_meijia + objEdit.managecost_meijia + ",");
var managercost_yangshan = arrValue.Where(a => a.Key == "深圳前海扬杉创新科技有限公司").FirstOrDefault();
managercost_yangshan.Value += objBase.managercost_yangshan + "," + objEdit.managercost_yangshan + "," + (objBase.managercost_yangshan + objEdit.managercost_yangshan + ",");
var managercost_xinhuilan = arrValue.Where(a => a.Key == "广州信荟蓝科技有限公司").FirstOrDefault();
managercost_xinhuilan.Value += objBase.managercost_xinhuilan + "," + objEdit.managercost_xinhuilan + "," + (objBase.managercost_xinhuilan + objEdit.managercost_xinhuilan + ",");
var managercost_chengpincang = arrValue.Where(a => a.Key == "广州电子服装仓&阳山").FirstOrDefault();
managercost_chengpincang.Value += objBase.managercost_chengpincang + "," + objEdit.managercost_chengpincang + "," + (objBase.managercost_chengpincang + objEdit.managercost_chengpincang + ",");
var managercost_dizhi = arrValue.Where(a => a.Key == "广州迪致美容科技有限公司").FirstOrDefault();
managercost_dizhi.Value += objBase.managercost_dizhi + "," + objEdit.managercost_dizhi + "," + (objBase.managercost_dizhi + objEdit.managercost_dizhi + ",");
var profit = arrValue.Where(a => a.Key == "营业利润").FirstOrDefault();
profit.Value += objBase.profit + "," + objEdit.profit + "," + (objBase.profit + objEdit.profit + ",");
var rate_profit = arrValue.Where(a => a.Key == "营业毛利率").FirstOrDefault();
rate_profit.Value += objBase.rate_profit + "," + objEdit.rate_profit + "," + ((item.Sum(m=>m.profit) / item.Sum(m=>m.amount_sales)) + ",");
var incoming_other = arrValue.Where(a => a.Key == "加:其他收入").FirstOrDefault();
incoming_other.Value += objBase.incoming_other + "," + objEdit.incoming_other + "," + (objBase.incoming_other + objEdit.incoming_other + ",");
var incoming_refundtax = arrValue.Where(a => a.Key == "其中:出口退税收入").FirstOrDefault();
incoming_refundtax.Value += objBase.incoming_refundtax + "," + objEdit.incoming_refundtax + "," + (objBase.incoming_refundtax + objEdit.incoming_refundtax + ",");
var incoming_non_operating = arrValue.Where(a => a.Key == "加:营业外收入").FirstOrDefault();
incoming_non_operating.Value += objBase.incoming_non_operating + "," + objEdit.incoming_non_operating + "," + (objBase.incoming_non_operating + objEdit.incoming_non_operating + ",");
var pay_non_operating = arrValue.Where(a => a.Key == "减:营业外支出").FirstOrDefault();
pay_non_operating.Value += objBase.pay_non_operating + "," + objEdit.pay_non_operating + "," + (objBase.pay_non_operating + objEdit.pay_non_operating + ",");
var actual_profit = arrValue.Where(a => a.Key == "实际利润").FirstOrDefault();
actual_profit.Value += objBase.actual_profit + "," + objEdit.actual_profit + "," + (objBase.actual_profit + objEdit.actual_profit + ",");
var rate_profit_actual = arrValue.Where(a => a.Key == "净利率").FirstOrDefault();
rate_profit_actual.Value += objBase.rate_profit_actual + "," + objEdit.rate_profit_actual + "," + ((item.Sum(a=>a.profit_balance)/item.Sum(a=>a.amount_sales)) + ",");
}
var colNames = str_head.Split(',').Where(a=>!string.IsNullOrEmpty(a)).ToList();
var list = new List<string>();
foreach (var item in arrValue)
{
list.Add(item.Key + "|" + item.Value.Replace(",", "|").Substring(0,item.Value.Length-1));
}
var guid = Guid.NewGuid().ToString();
var filename = "月销售利润报表" + DateTime.Now.ToString("yyyyMMddHHmmss");
var filepath = _hostingEnvironment.WebRootPath + "\\Files\\Report\\" + DateTime.Now.ToString("yyyy-MM-dd") + "\\";
ToCSV(list, colNames, guid, filepath);
var ms = new System.IO.MemoryStream();
using (var f = new System.IO.FileStream(filepath + guid + ".csv", System.IO.FileMode.Open))
{
f.CopyTo(ms);
}
ms.Position = 0;
return File(ms, "text/csv", filename + ".csv");
}
#endregion #endregion
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<div class="form-group"> <div class="form-group">
<label>&nbsp;</label> <label>&nbsp;</label>
<button type="button" class="btn btn-primary" onclick="list();"><i class="fa fa-search"></i>&nbsp;查询</button> <button type="button" class="btn btn-primary" onclick="list();"><i class="fa fa-search"></i>&nbsp;查询</button>
@*<button type="button" class="btn btn-danger" onclick="exportxls();">导出</button>*@ <button type="button" class="btn btn-danger" onclick="exportxls();">导出</button>
</div> </div>
</div> </div>
</form> </form>
...@@ -231,6 +231,16 @@ ...@@ -231,6 +231,16 @@
layer_show(mon + ' ' + name + "的明细", '@Url.Content("~/Reports/Finance/MonthSaleProfitDetails")' + '?month=' + mon + '&col=' + col + '&colname=' + name, '95%', '95%'); layer_show(mon + ' ' + name + "的明细", '@Url.Content("~/Reports/Finance/MonthSaleProfitDetails")' + '?month=' + mon + '&col=' + col + '&colname=' + name, '95%', '95%');
} }
function exportxls() {
var mon = $('#month').val();
if (mon == '') {
alert('请选择月份');
return;
}
window.open('@Url.Content("~/Reports/Finance/ExportMonthSaleProfitNew?month=")' + mon, '_blank');
}
function clearHtml(s) { function clearHtml(s) {
// 去除 富文本格式 // 去除 富文本格式
s = s.replace(/(\n)/g, ""); s = s.replace(/(\n)/g, "");
......
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