Commit e7d4cad9 by guanzhenshan

增加销售平台账单流水报表

parent ec923d7c
using System;
using System.Collections.Generic;
using System.Text;
namespace Bailun.DC.Models.DataWareHouse
{
/// <summary>
/// 平台账单流水
/// </summary>
public class flowing_sales
{
public int id { get; set; }
public string platform { get; set; }
public string website { get; set; }
public string jsondata { get; set; }
public string month { get; set; }
public DateTime createtime { get; set; }
public string orderno { get; set; }
public string accountname { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;
using Dapper;
using System.Linq;
using Bailun.DC.Models;
namespace Bailun.DC.Services.DataWareHouse
{
public class PlatformOrderServices
{
/// <summary>
/// 获取平台站点信息
/// </summary>
/// <param name="platform"></param>
/// <returns></returns>
public List<string> ListPlatformSite(string platform)
{
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString_DW))
{
if(cn.State== System.Data.ConnectionState.Closed)
{
cn.Open();
}
var sql = $"select t1.website from flowing_sales t1 where t1.platform='{platform}' group by t1.website";
return cn.Query<string>(sql).ToList();
}
}
/// <summary>
/// 获取平台销售账单流水
/// </summary>
/// <param name="parameter">分页信息</param>
/// <param name="platform">平台类型</param>
/// <param name="website">站点</param>
/// <param name="account">销售帐号</param>
/// <param name="month">月份</param>
/// <param name="total">符合条件的记录数</param>
/// <returns></returns>
public List<Models.DataWareHouse.flowing_sales> List(int page, string platform, string website, string account, string month,ref int total,int pagesize)
{
var sql = "select * from flowing_sales t1 where 1=1";
var sqlparam = new DynamicParameters();
if(!string.IsNullOrEmpty(platform))
{
sql += " and t1.platform=@platform";
sqlparam.Add("platform", platform);
}
if (!string.IsNullOrEmpty(website))
{
sql += " and t1.website=@website";
sqlparam.Add("website", website);
}
if (!string.IsNullOrEmpty(account))
{
sql += " and t1.accountname=@account";
sqlparam.Add("account", account);
}
if(!string.IsNullOrEmpty(month))
{
sql += " and t1.month=@month";
sqlparam.Add("month", month);
}
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString_DW))
{
if(cn.State== System.Data.ConnectionState.Closed)
{
cn.Open();
}
if (pagesize > 0)
{
var obj = cn.Page<Models.DataWareHouse.flowing_sales>(page, pagesize, sql, ref total, sqlparam);
return obj.ToList();
}
else
{
var obj = cn.Query<Models.DataWareHouse.flowing_sales>(sql, sqlparam);
return obj.ToList();
}
}
}
}
}
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using Microsoft.AspNetCore.Hosting;
using System.Threading.Tasks;
namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
{
[Area("DataWareHouse")]
public class PlatformOrderController : Base.BaseController
{
private readonly IHostingEnvironment _hostingEnvironment;
public PlatformOrderController(IHostingEnvironment hostingEnvironment)
{
_hostingEnvironment = hostingEnvironment;
}
public IActionResult OrderBillings(string platform)
{
var listsite = new Services.DataWareHouse.PlatformOrderServices().ListPlatformSite(platform);
ViewBag.platform = platform;
ViewBag.sites = listsite;
return View();
}
[HttpPost]
public JsonResult OrderBillingsJson(int page,string platform,string website,string account,string month, int pagesize = 25)
{
if (string.IsNullOrEmpty(platform))
{
return Json(new {
success= false,
msg = "请选择平台类型"
});
}
if(string.IsNullOrEmpty(website))
{
return Json(new {
success = false,
msg = "请选择站点",
});
}
if(string.IsNullOrEmpty(month))
{
return Json(new {
success = false,
msg = "请选择月份"
});
}
if(page<=0)
{
page = 1;
}
int total = 0;
var obj = new Services.DataWareHouse.PlatformOrderServices().List(page, platform, website, account, month, ref total,pagesize);
var list = obj.Select(a => new {
a.accountname,
a.createtime,
jsondata = Newtonsoft.Json.Linq.JRaw.Parse(a.jsondata),
a.month,
a.orderno,
a.platform,
a.website,
});
return Json(new {
success = true,
msg = "",
rows = list,
total = total,
page = page,
totalpage = total/pagesize+(total%pagesize>0?1:0),
});
}
public ActionResult ExportOrderBillings(string platform, string website, string account, string month)
{
if (string.IsNullOrEmpty(platform))
{
return Json(new
{
success = false,
msg = "请选择平台类型"
});
}
if (string.IsNullOrEmpty(website))
{
return Json(new
{
success = false,
msg = "请选择站点",
});
}
if (string.IsNullOrEmpty(month))
{
return Json(new
{
success = false,
msg = "请选择月份"
});
}
var total = 0;
var obj = new Services.DataWareHouse.PlatformOrderServices().List(1, platform, website, account, month, ref total, 0);
if(obj.Count==0)
{
return Json(new
{
success = true,
msg = "没有数据"
});
}
//列头
DataTable dataTable = new DataTable(); //实例化
var objFirst = obj.FirstOrDefault();
var jsonData = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(objFirst.jsondata);
foreach (var item in jsonData)
{
dataTable.Columns.Add(item.Key, typeof(string));
}
foreach (var item in obj)
{
jsonData = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(item.jsondata);
DataRow dataRow = dataTable.NewRow();
foreach (var c in jsonData)
{
dataRow[c.Key] = c.Value;
}
dataTable.Rows.Add(dataRow);
}
var colnames = new List<string>();
for (var i = 0; i < dataTable.Columns.Count; i++)
{
colnames.Add(dataTable.Columns[i].ColumnName);
}
var listVal = new List<string>();
for (int j = 0; j < dataTable.Rows.Count; j++)
{
var s = "";
for (int k = 0; k < dataTable.Columns.Count; k++)
{
string tmpRowValue = dataTable.Rows[j][k].ToString();
s += tmpRowValue + "|";
}
//s = s.Substring(0, s.Length - 1);
listVal.Add(s);
}
var guid = Guid.NewGuid().ToString();
var filename = platform+ " " + month + "的账单流水";
var filepath = _hostingEnvironment.WebRootPath + "\\Files\\Report\\" + DateTime.Now.ToString("yyyy-MM-dd") + "\\";
ToCSV(listVal, listVal, 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");
}
}
}
@{
ViewData["Title"] = "平台账单流水";
Layout = "~/Pages/Shared/_MainLayout.cshtml";
ViewBag.Nav = new string[] { "销售平台流水", ViewBag.platform+"账单流水" };
}
<div class="row">
<div class="col-sm-12">
<div class="ibox-content m-b-sm border-bottom">
<form id="toolbar">
<div class="form-inline" style="line-height:40px;">
<div class="form-group">
<label>站点</label>
<select id="website" name="website" class="form-control" style="width:130px;">
<option value="">请选择站点</option>
@foreach (var item in ViewBag.sites)
{
<option value="@item">@item</option>
}
</select>
</div>
<div class="form-group">
<label>月份</label>
<input id="month" name="month" class="form-control" style="width:100px" value="@(DateTime.Now.AddMonths(-1).ToString("yyyy-MM"))" />
</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>
<button id="btnexport" style="display:;" type="button" class="btn btn-success" onclick="ExportCSV()">导出</button>
</div>
</div>
</form>
</div>
<div class="ibox-content m-b-sm border-bottom table-responsive">
<table id="roletable" class="table table-hover table-bordered table-striped" style="table-layout:fixed;">
<thead id="tb_head">
</thead>
<tbody id="tb">
</tbody>
</table>
<div id="page-contain">
<span id="pageresult"></span>
<div id="pagination" class="pagination" style="margin-left:50px;"></div>
</div>
</div>
</div>
</div>
@section css{
<style>
.mules {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
/*.pagination ul{
list-style-type:none;
padding:0px;
margin:0px;
}
.pagination ul li{float:left;width:20px;}
*/
.pagination {
margin: 20px 0;
}
.pagination ul {
display: inline-block;
*display: inline;
margin-bottom: 0;
margin-left: 0;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
*zoom: 1;
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
padding-left:0px;
}
.pagination ul > li {
display: inline;
}
.pagination ul > li > a,
.pagination ul > li > span {
float: left;
padding: 4px 12px;
line-height: 20px;
text-decoration: none;
background-color: #ffffff;
border: 1px solid #dddddd;
border-left-width: 0;
}
.pagination ul > li > a:hover,
.pagination ul > li > a:focus,
.pagination ul > .active > a,
.pagination ul > .active > span {
background-color: #f5f5f5;
}
.pagination ul > .active > a,
.pagination ul > .active > span {
color: #999999;
cursor: default;
}
.pagination ul > .disabled > span,
.pagination ul > .disabled > a,
.pagination ul > .disabled > a:hover,
.pagination ul > .disabled > a:focus {
color: #999999;
cursor: default;
background-color: transparent;
}
.pagination ul > li:first-child > a,
.pagination ul > li:first-child > span {
border-left-width: 1px;
-webkit-border-bottom-left-radius: 4px;
border-bottom-left-radius: 4px;
-webkit-border-top-left-radius: 4px;
border-top-left-radius: 4px;
-moz-border-radius-bottomleft: 4px;
-moz-border-radius-topleft: 4px;
}
.pagination ul > li:last-child > a,
.pagination ul > li:last-child > span {
-webkit-border-top-right-radius: 4px;
border-top-right-radius: 4px;
-webkit-border-bottom-right-radius: 4px;
border-bottom-right-radius: 4px;
-moz-border-radius-topright: 4px;
-moz-border-radius-bottomright: 4px;
}
.pagination-centered {
text-align: center;
}
.pagination-right {
text-align: right;
}
</style>
}
@section scripts{
<script src="~/js/jspagination/bootstrap-paginator.js"></script>
<script type="text/javascript">
var tb;
var current_page = 1;
$(document).ready(function () {
//list();
laydate.render({ elem: '#month', type: 'month' });
})
function list() {
var website = $('#website').val();
var month = $('#month').val();
if (website == '') {
alert('请选择站点');
return false;
}
if (month == '') {
alert('请选择月份');
return false;
}
var load_index = layer.load();
$.submit({
url: '@Url.Content("~/DataWareHouse/PlatformOrder/OrderBillingsJson")',
type:'POST',
paramData: 'page=' + current_page + '&platform=@(ViewBag.platform)&website=' + website + '&month=' + month,
func: function (result) {
layer.close(load_index)
$('#tb').html('');
if (result.success) {
//表头
if (result.total == 0) {
alert('没有找到该平台数据,请上传');
return false;
}
var firstrow = result.rows[0].jsondata;
var _head = '<tr>';
for (var i in firstrow) {
_head += '<th style="width:130px;">' + '<div class="mules" title="' + i + '">' + i + '</div>'+'</th>';
}
_head += '</tr>';
$('#tb_head').html(_head);
//内容
for (var i in result.rows) {
var _obj = result.rows[i].jsondata;
var _r = '<tr>';
for (var r in _obj) {
_r += '<td style="width:130px;">' + '<div class="mules" title="' + _obj[r] + '">' + _obj[r] + '</div>' +'</td>';
}
_r += '</tr>';
$('#tb').append(_r);
}
//分页
InitPage(result.totalpage);
$('#pageresult').html('总记录数:' + result.total + ';总页数:' + result.totalpage);
}
else {
alert('获取数据出现异常')
}
}
})
}
function InitPage(totalpage) {
$('#page-contain').html('<span id="pageresult"></span><div id="pagination" class="pagination" style="margin-left:5px;"></div>');
var container = $('#pagination');
options = {
containerClass: "pagination"
, currentPage: current_page
//, numberOfPages: 6
, totalPages: totalpage
, pageUrl: function (type, page) {
//return null;
}
, onPageClicked: function (e, originalEvent, type, page) {
current_page = page;
list();
}
, onPageChanged: function (page) {
}
};
container.bootstrapPaginator(options);
}
function ExportCSV() {
var website = $('#website').val();
var month = $('#month').val();
if (website == '') {
alert('请选择站点');
return false;
}
if (month == '') {
alert('请选择月份');
return false;
}
window.open('@Url.Content("~/DataWareHouse/PlatformOrder/ExportOrderBillings")' + '?platform=@(ViewBag.platform)&website=' + website + '&month=' + month);
}
</script>
}
\ No newline at end of file
...@@ -2482,7 +2482,6 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -2482,7 +2482,6 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
} }
#region 资产负债表-子表 #region 资产负债表-子表
public ActionResult MonetaryFund(DateTime date, int paycompanyid) public ActionResult MonetaryFund(DateTime date, int paycompanyid)
{ {
var m = new Services.FinanceReportServices().GetMonetaryFundCount(date, paycompanyid); var m = new Services.FinanceReportServices().GetMonetaryFundCount(date, paycompanyid);
......
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