Commit 561f1614 by guanzhenshan

增加财务会计流水报表

parent 0975cc27
using System;
using System.Collections.Generic;
using System.Text;
namespace Bailun.DC.Models.DataWareHouse
{
public class order_fee
{
/// <summary>
///
/// </summary>
public int id { get; set; }
/// <summary>
///
/// </summary>
public string platform { get; set; }
/// <summary>
///
/// </summary>
public string website { get; set; }
/// <summary>
///
/// </summary>
public string orderno { get; set; }
/// <summary>
///
/// </summary>
public string jsonvalue { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Bailun.DC.Models.DataWareHouse
{
public class order_fee_col
{
/// <summary>
///
/// </summary>
public int id { get; set; }
/// <summary>
///
/// </summary>
public string platform { get; set; }
/// <summary>
///
/// </summary>
public string website { get; set; }
/// <summary>
/// 需要解析出来的字段,通过"||"隔开
/// </summary>
public string cols { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Bailun.DC.Models.DataWareHouse
{
public class order_fee_config
{
/// <summary>
///
/// </summary>
public int id { get; set; }
/// <summary>
///
/// </summary>
public string platform { get; set; }
/// <summary>
///
/// </summary>
public string website { get; set; }
/// <summary>
/// 分类归集
/// </summary>
public string financecategory { get; set; }
/// <summary>
/// 费用类型
/// </summary>
public string feetype { get; set; }
/// <summary>
/// 取数列
/// </summary>
public string colname_fee { get; set; }
/// <summary>
/// 取数判断条件
/// </summary>
public string condition_forfee { get; set; }
/// <summary>
/// 科目编码
/// </summary>
public string subjectcode { get; set; }
/// <summary>
/// 项目编码
/// </summary>
public string projectcode { get; set; }
/// <summary>
/// 备注
/// </summary>
public string note { get; set; }
/// <summary>
/// 数据中心字段
/// </summary>
public string datacenter_col { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Bailun.DC.Models.DataWareHouse
{
public class order_fee_value_amazon
{
/// <summary>
///
/// </summary>
public int id { get; set; }
/// <summary>
///
/// </summary>
public string platform { get; set; }
/// <summary>
///
/// </summary>
public string website { get; set; }
/// <summary>
///
/// </summary>
public string orderno { get; set; }
/// <summary>
///
/// </summary>
public DateTime? datatime { get; set; }
public int flowing_sales_id { get; set; }
/// <summary>
///
/// </summary>
public int order_fee_config_id { get; set; }
/// <summary>
///
/// </summary>
public string typename { get; set; }
/// <summary>
///
/// </summary>
public string typevalue { get; set; }
/// <summary>
///
/// </summary>
public string descriptname { get; set; }
/// <summary>
///
/// </summary>
public string descriptvalue { get; set; }
/// <summary>
///
/// </summary>
public string fulfillmentname { get; set; }
/// <summary>
///
/// </summary>
public string fulfillmentvalue { get; set; }
/// <summary>
/// 金额取值字段
/// </summary>
public string amountname { get; set; }
/// <summary>
/// 金额值
/// </summary>
public decimal amountval { get; set; }
public order_fee_config fee_config { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;
using Bailun.DC.Models.DataWareHouse;
using Bailun.DC.Common;
using Dapper;
using System.Linq;
namespace Bailun.DC.Services.DataWareHouse
{
public class PlatformOrderFeeServices
{
#region 配置保存
//需要存的费用字段
/// <summary>
/// 保存需要解析的字段配置
/// </summary>
/// <param name="cols"></param>
/// <returns></returns>
public string SaveOrderFeeCol(List<order_fee_col> cols)
{
if (cols.Count == 0)
{
return "没有可保存的字段配置";
}
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString_DW))
{
if (cn.State == System.Data.ConnectionState.Closed)
{
cn.Open();
}
foreach(var item in cols)
{
var m = cn.QueryFirstOrDefault<order_fee_col>($"select * from order_fee_col where platform='{item.platform}' and website='{item.website}'");
if (m == null)
{
cn.Insert(item);
}
else
{
m.cols = item.cols;
cn.Update(m);
}
}
}
return "";
}
/// <summary>
/// 保存平台+站点的不同费用类型的取值条件和会计科目
/// </summary>
/// <param name="configs"></param>
/// <returns></returns>
public string SaveOrderFeeConfig(List<order_fee_config> configs)
{
if(configs.Count==0)
{
return "至少需要有一个配置。";
}
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString_DW))
{
if (cn.State == System.Data.ConnectionState.Closed)
{
cn.Open();
}
cn.Execute($"delete from order_fee_config where platform='{configs.FirstOrDefault().platform}' and website='{configs.FirstOrDefault().website}'");
foreach (var item in configs)
{
cn.Insert(item);
}
}
return "";
}
#endregion
public List<order_fee_col> ListOrderFeeCol()
{
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString_DW))
{
if (cn.State == System.Data.ConnectionState.Closed)
{
cn.Open();
}
return cn.Query<order_fee_col>("select * from order_fee_col").ToList();
}
}
/// <summary>
/// 获取财务会计流水明细
/// </summary>
/// <param name="page"></param>
/// <param name="pagesize"></param>
/// <param name="platform"></param>
/// <param name="website"></param>
/// <param name="start"></param>
/// <param name="end"></param>
/// <param name="orderno"></param>
/// <param name="total"></param>
/// <returns></returns>
public List<order_fee_value_amazon> ListOrderFeeValue(int page, int pagesize, string platform, string website, DateTime? start, DateTime? end, string orderno,ref int total)
{
var sql = $@"select t1.* from order_fee_value_amazon 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(month))
//{
// sql += " and t1.month=@month";
// sqlparam.Add("month", month);
//}
if (!string.IsNullOrEmpty(orderno))
{
sql += " and t1.orderno=@orderno";
sqlparam.Add("orderno", orderno);
}
if (start.HasValue)
{
sql += $" and t1.datatime>='{start.Value.ToString("yyyy-MM-dd")}'";
}
if (end.HasValue)
{
sql += $" and t1.datatime<'{end.Value.AddDays(1).ToString("yyyy-MM-dd")}'";
}
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString_DW))
{
if (cn.State == System.Data.ConnectionState.Closed)
{
cn.Open();
}
var list = new List<order_fee_value_amazon>();
if (pagesize > 0)
{
list = cn.Page<order_fee_value_amazon>(page, pagesize, sql, ref total, sqlparam).ToList();
}
else
{
list = cn.Query<order_fee_value_amazon>(sql, sqlparam).ToList();
}
var config = cn.Query<order_fee_config>($"select * from order_fee_config where id in ('{string.Join("','", list.Select(a => a.order_fee_config_id).Distinct().ToList())}')");
foreach (var item in list)
{
item.fee_config = config.Where(a => a.id == item.order_fee_config_id).FirstOrDefault();
}
return list;
}
}
}
}
...@@ -22,6 +22,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -22,6 +22,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
_hostingEnvironment = hostingEnvironment; _hostingEnvironment = hostingEnvironment;
} }
#region 销售平台流水相关
public IActionResult OrderBillings(string platform) public IActionResult OrderBillings(string platform)
{ {
var listsite = new Services.DataWareHouse.PlatformOrderServices().ListPlatformSite(platform); var listsite = new Services.DataWareHouse.PlatformOrderServices().ListPlatformSite(platform);
...@@ -403,6 +405,57 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -403,6 +405,57 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
} }
public ActionResult FinanceAccount_OrderBilling()
{
var listPlatform = new List<string>();
var listFeeCol = new Services.DataWareHouse.PlatformOrderFeeServices().ListOrderFeeCol();
ViewBag.platform = listPlatform = listFeeCol.Select(a => a.platform).Distinct().ToList();
ViewBag.website = listFeeCol.Where(a => a.platform == listPlatform.FirstOrDefault()).Select(a => a.website).Distinct().ToList();
return View();
}
public string FinanceAccount_OrderBillingJson(Models.BtTableParameter request, string platform, string website, string account, DateTime? start, DateTime? end, string orderno)
{
var total = 0;
var obj = new Services.DataWareHouse.PlatformOrderFeeServices().ListOrderFeeValue(request.pageIndex, request.limit, platform, website, start, end, orderno, ref total);
var list = obj.Select(a => new
{
a.platform,
a.website,
a.orderno,
a.datatime,
a.amountval,
feetype = a.fee_config?.feetype??"",
subjectcode = a.fee_config?.subjectcode??"",
projectcode = a.fee_config?.projectcode??"",
financecategory = a.fee_config?.financecategory??"",
datacenter_col = a.fee_config?.datacenter_col??"",
});
return Newtonsoft.Json.JsonConvert.SerializeObject(new {
rows = list,
total = total
});
}
public ActionResult ExportFinanceAccount_OrderBilling(string platform, string website, string account, DateTime? start, DateTime? end, string orderno)
{
return View();
}
#endregion
#region 私有方法
private System.Collections.ArrayList Dtb2Json(DataTable dtb) private System.Collections.ArrayList Dtb2Json(DataTable dtb)
{ {
...@@ -431,5 +484,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -431,5 +484,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
return dic; return dic;
} }
#endregion
} }
} }

@{
ViewData["Title"] = "财务会计流水";
Layout = "~/Pages/Shared/_MainLayout.cshtml";
ViewBag.Nav = new string[] { "销售平台流水", "财务会计流水" };
}
<div class="row">
<div class="col-sm-12">
<div class="alert alert-warning">
</div>
<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="platform" name="platform" class="form-control" style="width:120px;">
@if(ViewBag.platform.Count>0)
{
foreach(var item in ViewBag.platform)
{
<option value="@item">@item</option>
}
}
</select>
</div>
<div class="form-group">
<label>站点:</label>
<select id="website" name="website" class="form-control" style="width:120px;">
<option value="">请选择站点</option>
@if (ViewBag.website.Count > 0)
{
foreach (var item in ViewBag.website)
{
<option value="@item">@item</option>
}
}
</select>
</div>
<div class="form-group">
<label>时间</label>
<input id="start" name="start" type="text" class="form-control" style="width:130px;" value="" />
<span>至</span>
<input id="end" name="end" type="text" class="form-control" style="width:130px;" value="" />
</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>
</div>
</div>
</form>
</div>
<div class="ibox-content m-b-sm border-bottom">
<table id="roletable" style="table-layout:fixed;"></table>
</div>
</div>
</div>
@section css{
<link href="~/js/webuploader-0.1.5/webuploader.css" rel="stylesheet" />
<link href="~/css/bootstrap-table-fixed-columns.css" rel="stylesheet" />
<style>
.mules {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.webuploader-pick {
position: relative;
display: block;
cursor: pointer;
background: none;
padding: 0px;
color: #fff;
text-align: center;
border-radius: 3px;
overflow: hidden;
}
.webuploader-container {
background-color: cornflowerblue !important;
}
</style>
}
@section scripts{
<script src="~/js/bootstrap-table-fixed-columns.js" type="text/javascript"></script>
<script src="~/js/webuploader-0.1.5/webuploader.min.js"></script>
<script type="text/javascript">
var BASE_URL = '@(Url.Content("~/js/webuploader-0.1.5/"))';
var tb;
var companyid = 0;
$(document).ready(function () {
laydate.render({ elem: '#start' });
laydate.render({ elem: '#end' });
var height = document.body.clientHeight;
$("#roletable").attr("data-height", (height - 170));
list();
})
function list() {
var columns = [
{ field: 'company', title: '主体', width: '160'},
{ field: 'platform', title: '平台', width: '130' },
{ field: 'website', title: '站点', width: '110'},
{
field: 'datatime', title: '账单时间', width: '160'
},
{ field: 'orderno', title: '单号', width: '160'},
{ field: 'feetype', title: '费用类型', width: '120'},
{ field: 'financecategory', title: '会计科目分类', width: '130' },
{ field: 'subjectcode', title: '会计科目编码', width: '130' },
{ field: 'projectcode', title: '项目编码', width: '120' },
{
field: 'currency', title: '币种', width: '100'
},
{
field: 'amountval', title: '原币金额', width: '120'
},
{
field: 'exchangerate', title: '汇率', width: '100'
},
{ field: 'amountval_rmb', title: 'RMB金额', width: '120' },
{ field: 'note', title: '备注', width: '160' },
];
var url = '@Url.Content("~/DataWareHouse/PlatformOrder/FinanceAccount_OrderBillingJson")' + '?' + $("#toolbar").serialize();
if (tb == undefined) {
tb = OnlyTable("roletable", columns, url, "", {
showfooter: true, loadsuccess: function (d) {
//替换汇总行的相关列值
var tr = $('.fixed-table-footer').find('tr');
for (var c in columns) {
var key = columns[c].field;
if (columns[c].iscount) {
for (var v in d.count_row) {
if (key == v) {
tr.find('td').eq(c).children('div').first().html(d.count_row[v]);
break;
}
}
}
}
companyid = d.companyid;
}
});
}
else {
tb.bootstrapTable('refresh', { url: url });
}
}
</script>
}
...@@ -1071,7 +1071,6 @@ namespace Bailun.DC.Web.Controllers ...@@ -1071,7 +1071,6 @@ namespace Bailun.DC.Web.Controllers
msg = ex.Message, msg = ex.Message,
}); });
} }
} }
/// <summary> /// <summary>
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bailun.ServiceFabric.Authorize; using Bailun.ServiceFabric.Authorize;
...@@ -281,5 +282,139 @@ namespace Bailun.DC.Web.Controllers ...@@ -281,5 +282,139 @@ namespace Bailun.DC.Web.Controllers
return View(); return View();
} }
public ActionResult DemoFile()
{
return View();
}
public ActionResult UploadDemoFile()
{
if (Request.Form.Files.Count == 0)
{
return Json(new
{
success = false,
msg = "请上传文件!"
});
}
//var user = HttpContextHelper.Current?.User;
var file = Request.Form.Files[0];
Dictionary<string, DataTable> dic = Base.NpolHelper.ExcelToDataTable(file.OpenReadStream(), file.FileName, true);
var platform = "";
var website = "";
var filename = file.FileName.Split(' ')[0].Split('-');
if (filename.Length > 1)
{
platform = filename[0];
website = filename[1];
}
if (dic.Count > 0)
{
var tb = dic.FirstOrDefault();
var list = new List<Bailun.DC.Models.DataWareHouse.order_fee_config>();
var cols = new List<string>();
var columns = tb.Value.Columns;
cols.Add(columns[1].ColumnName.Split('-')[1]);
cols.Add(columns[2].ColumnName.Split('-')[1]);
cols.Add(columns[3].ColumnName.Split('-')[1]);
for (var i = 0; i < tb.Value.Rows.Count; i++)
{
//解析行
var row = tb.Value.Rows[i];
if (row == null || string.IsNullOrEmpty(row[0].ToString()))
{
continue;
}
var type = row[1].ToString();
var description = row[2].ToString();
var fulfillment = row[3].ToString();
var valcol = row["取数列"].ToString();
var feetype = row["费用类型"].ToString();
var category = row["分录归集"].ToString();
var subjectcode = row["科目编码"].ToString();
var projectcode = row["项目编码"].ToString();
var datacentercol = row["数据中心字段"].ToString();
var note = row["备注"].ToString();
//格式化组合条件
var _condition = "{";
if (!string.IsNullOrEmpty(type))
{
_condition += "\""+ columns[1].ColumnName.Split('-')[1]+"\":\""+type.Trim()+"\",";
}
if (!string.IsNullOrEmpty(description))
{
_condition += "\"" + columns[2].ColumnName.Split('-')[1] + "\":\"" + description.Trim() + "\",";
}
if (!string.IsNullOrEmpty(fulfillment))
{
_condition += "\"" + columns[3].ColumnName.Split('-')[1] + "\":\"" + fulfillment.Trim() + "\",";
}
if (_condition.Length > 1)
{
_condition = _condition.Substring(0, _condition.Length - 1);
}
_condition += "}";
//需要解析的字段
cols.Add(valcol);
var m = new Models.DataWareHouse.order_fee_config {
subjectcode = subjectcode,
colname_fee = valcol,
condition_forfee = _condition,
datacenter_col = datacentercol,
feetype = feetype,
financecategory = category,
note = note,
projectcode = projectcode,
platform = platform,
website = website,
};
list.Add(m);
}
var _service = new Services.DataWareHouse.PlatformOrderFeeServices();
//保存需要解析的字段
var result = _service.SaveOrderFeeCol(new List<Models.DataWareHouse.order_fee_col> { new Models.DataWareHouse.order_fee_col {
cols = string.Join("||",cols.Distinct().ToList()),
platform = platform,
website = website,
}});
if (!string.IsNullOrEmpty(result))
{
return Content("保存字段解析配置异常,请确认字段格式是否正确。");
}
//保存取数逻辑条件
result = _service.SaveOrderFeeConfig(list);
if (!string.IsNullOrEmpty(result))
{
return Content("保存平台费用取数逻辑配置异常:"+result);
}
}
return Content("OK");
}
} }
} }
\ No newline at end of file
@{
ViewData["Title"] = "平台账单流水";
Layout = "~/Pages/Shared/_MainLayout.cshtml";
ViewBag.Nav = new string[] { "销售平台流水", (ViewBag.platform == "" ? "其他" : ViewBag.platform) + "账单流水" };
}
<button id="btn_Upload" type="button" style="" class="btn btn-warning">导入配置文件</button>
@section css{
<link href="~/js/webuploader-0.1.5/webuploader.css" rel="stylesheet" />
<style>
.webuploader-pick {
position: relative;
display: block;
cursor: pointer;
background: none;
padding: 0px;
color: #fff;
text-align: center;
border-radius: 3px;
overflow: hidden;
}
.webuploader-container {
background-color: cornflowerblue !important;
}
.mules {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
}
@section scripts{
<script src="~/js/webuploader-0.1.5/webuploader.min.js"></script>
<script type="text/javascript">
var BASE_URL = '@(Url.Content("~/js/webuploader-0.1.5/"))';
$(document).ready(function () {
uploadfile('btn_Upload',
'@Url.Content("~/Home/UploadDemoFile")',
function (result) {
alert('上传成功!');
});
})
function uploadfile(id,url,callback)
{
var uploader = new WebUploader.Uploader({
// swf文件路径
swf: BASE_URL + 'Uploader.swf',
// 文件接收服务端。
server: url!=undefined?url:'@Url.Content("~/File/UploadFile")',
// 选择文件的按钮。可选。
// 内部根据当前运行是创建,可能是input元素,也可能是flash.
pick: '#'+id,
// 不压缩image, 默认如果是jpeg,文件上传前会压缩一把再上传!
resize: false,
auto: true,
timeout: 0,
accept: {
extensions: "xls,xlsx",
mimeTypes: ".xls,.xlsx"
}
});
uploader.on('uploadSuccess', function (file, response) {
if(callback!=undefined)
{
callback(response);
}
});
uploader.on('uploadError', function (file) {
layer.msg("上传出错");
});
}
</script>
}
\ No newline at end of file
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