Commit a7447cdc by jianshuqin

优化:组件功能

parent de9dd982
...@@ -6,6 +6,8 @@ using Bailun.DC.Models.DataWareHouse; ...@@ -6,6 +6,8 @@ using Bailun.DC.Models.DataWareHouse;
using Bailun.DC.Common; using Bailun.DC.Common;
using Dapper; using Dapper;
using System.Linq; using System.Linq;
using System.Data;
using Bailun.DC.Models.Component.DTO;
namespace Bailun.DC.Services.DataWareHouse namespace Bailun.DC.Services.DataWareHouse
{ {
...@@ -34,7 +36,7 @@ namespace Bailun.DC.Services.DataWareHouse ...@@ -34,7 +36,7 @@ namespace Bailun.DC.Services.DataWareHouse
cn.Open(); cn.Open();
} }
foreach(var item in cols) 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}'"); var m = cn.QueryFirstOrDefault<order_fee_col>($"select * from order_fee_col where platform='{item.platform}' and website='{item.website}'");
...@@ -65,7 +67,7 @@ namespace Bailun.DC.Services.DataWareHouse ...@@ -65,7 +67,7 @@ namespace Bailun.DC.Services.DataWareHouse
var listpw = configs.Select(a => new Tuple<string, string>(a.platform, a.website)); var listpw = configs.Select(a => new Tuple<string, string>(a.platform, a.website));
listpw = listpw.Distinct(); listpw = listpw.Distinct();
if(configs.Count==0) if (configs.Count == 0)
{ {
return "至少需要有一个配置。"; return "至少需要有一个配置。";
} }
...@@ -81,7 +83,7 @@ namespace Bailun.DC.Services.DataWareHouse ...@@ -81,7 +83,7 @@ namespace Bailun.DC.Services.DataWareHouse
{ {
cn.Execute($"update order_fee_config set delstatus=1 where platform='{item.Item1}' and website='{item.Item2}'"); cn.Execute($"update order_fee_config set delstatus=1 where platform='{item.Item1}' and website='{item.Item2}'");
} }
foreach (var item in configs) foreach (var item in configs)
{ {
cn.Insert(item); cn.Insert(item);
...@@ -98,7 +100,7 @@ namespace Bailun.DC.Services.DataWareHouse ...@@ -98,7 +100,7 @@ namespace Bailun.DC.Services.DataWareHouse
{ {
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString_DW)) using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString_DW))
{ {
if(cn.State== System.Data.ConnectionState.Closed) if (cn.State == System.Data.ConnectionState.Closed)
{ {
cn.Open(); cn.Open();
} }
...@@ -131,7 +133,7 @@ namespace Bailun.DC.Services.DataWareHouse ...@@ -131,7 +133,7 @@ namespace Bailun.DC.Services.DataWareHouse
cn.Open(); cn.Open();
} }
return cn.Query<order_fee_config>("select * from order_fee_config where datatype="+datatype).ToList(); return cn.Query<order_fee_config>("select * from order_fee_config where datatype=" + datatype).ToList();
} }
} }
...@@ -183,7 +185,7 @@ namespace Bailun.DC.Services.DataWareHouse ...@@ -183,7 +185,7 @@ namespace Bailun.DC.Services.DataWareHouse
/// <param name="orderno"></param> /// <param name="orderno"></param>
/// <param name="total"></param> /// <param name="total"></param>
/// <returns></returns> /// <returns></returns>
public List<order_fee_value_amazon> ListOrderFeeValue(int page, int pagesize, string platform, string website, DateTime? start, DateTime? end, string orderno,string month,ref int total,int? datatype,string datacenter_col) public List<order_fee_value_amazon> ListOrderFeeValue(int page, int pagesize, string platform, string website, DateTime? start, DateTime? end, string orderno, string month, ref int total, int? datatype, string datacenter_col)
{ {
var sql = $@"select t1.* from order_fee_value_amazon t1 var sql = $@"select t1.* from order_fee_value_amazon t1
join order_fee_config t2 on t1.order_fee_config_id=t2.id join order_fee_config t2 on t1.order_fee_config_id=t2.id
...@@ -201,7 +203,7 @@ namespace Bailun.DC.Services.DataWareHouse ...@@ -201,7 +203,7 @@ namespace Bailun.DC.Services.DataWareHouse
if (datatype.HasValue) if (datatype.HasValue)
{ {
sql += " and t1.datatype="+datatype.Value; sql += " and t1.datatype=" + datatype.Value;
} }
...@@ -245,7 +247,7 @@ namespace Bailun.DC.Services.DataWareHouse ...@@ -245,7 +247,7 @@ namespace Bailun.DC.Services.DataWareHouse
sqlparam.Add("month", month); sqlparam.Add("month", month);
} }
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString_DW)) using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString_DW))
{ {
...@@ -262,7 +264,7 @@ namespace Bailun.DC.Services.DataWareHouse ...@@ -262,7 +264,7 @@ namespace Bailun.DC.Services.DataWareHouse
} }
else else
{ {
list = cn.Query<order_fee_value_amazon>(sql, sqlparam,null,true,2*60).ToList(); list = cn.Query<order_fee_value_amazon>(sql, sqlparam, null, true, 2 * 60).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())}')"); 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())}')");
...@@ -356,7 +358,7 @@ namespace Bailun.DC.Services.DataWareHouse ...@@ -356,7 +358,7 @@ namespace Bailun.DC.Services.DataWareHouse
cn.Open(); cn.Open();
} }
var obj = cn.QueryFirstOrDefault<order_fee_value_amazon>(sql,sqlparam); var obj = cn.QueryFirstOrDefault<order_fee_value_amazon>(sql, sqlparam);
return obj; return obj;
...@@ -368,9 +370,9 @@ namespace Bailun.DC.Services.DataWareHouse ...@@ -368,9 +370,9 @@ namespace Bailun.DC.Services.DataWareHouse
/// </summary> /// </summary>
/// <param name="list"></param> /// <param name="list"></param>
/// <returns></returns> /// <returns></returns>
public string SaveOrderFee(List<order_fee_value_amazon> list,int uid,string username) public string SaveOrderFee(List<order_fee_value_amazon> list, int uid, string username)
{ {
using (var cn=new MySqlConnection(Common.GlobalConfig.ConnectionString_DW)) using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString_DW))
{ {
if (cn.State == System.Data.ConnectionState.Closed) if (cn.State == System.Data.ConnectionState.Closed)
{ {
...@@ -396,7 +398,7 @@ namespace Bailun.DC.Services.DataWareHouse ...@@ -396,7 +398,7 @@ namespace Bailun.DC.Services.DataWareHouse
return ex.Message; return ex.Message;
} }
} }
} }
...@@ -404,6 +406,283 @@ namespace Bailun.DC.Services.DataWareHouse ...@@ -404,6 +406,283 @@ namespace Bailun.DC.Services.DataWareHouse
return ""; return "";
} }
public ResultDTO SaveFlowingSalesFee(flowing_sales_fee entity)
{
ResultDTO result = result = this.BeforeSaveFlowingSalesFee(entity);
if (result.Result)
{
using (var db = new MySqlConnection(GlobalConfig.ConnectionString_DW))
{
if (db.State == ConnectionState.Closed)
{
db.Open();
}
using (var trans = db.BeginTransaction())
{
try
{
int? resultCount = entity.id > 0 ? db.Update(entity) : db.Insert(entity);
if (resultCount > 0)
{
}
trans.Commit();
result.Result = true;
}
catch (Exception ex)
{
trans.Rollback();
trans.Dispose();
result.Message = ex.Message;
}
}
}
}
return result;
}
public ResultDTO ImportFlowingSalesFee(DataTable dt)
{
ResultDTO result = new ResultDTO();
if (dt?.Rows?.Count > 0)
{
DateTime now = DateTime.Now;
decimal amount = 0m;
using (var db = new MySqlConnection(GlobalConfig.ConnectionString_DW))
{
if (db.State == ConnectionState.Closed)
{
db.Open();
}
using (var trans = db.BeginTransaction())
{
try
{
foreach (DataRow row in dt.Rows)
{
flowing_sales_fee entity = new flowing_sales_fee();
entity.platform = row["平台"]?.ToString();
if (string.IsNullOrWhiteSpace(entity.platform))
{
continue;
}
entity.account_name = row["账号"]?.ToString();
entity.fee_type = row["费用类型"]?.ToString();
entity.month = row["结算时间"]?.ToString()?.Replace("年", "-")?.Replace("月", string.Empty);
entity.origin_order_id = row["订单号"]?.ToString();
if (decimal.TryParse(row["金额"]?.ToString(), out amount))
{
entity.amount = amount;
}
entity.currency = row["币种"]?.ToString();
entity.remark = row["备注"]?.ToString();
entity.create_time = now;
entity.update_time = now;
int? resultCount = db.Insert(entity);
}
trans.Commit();
result.Result = true;
}
catch (Exception ex)
{
trans.Rollback();
trans.Dispose();
result.Message = ex.Message;
}
}
}
}
else
{
result.Message = "数据不能为空";
}
return result;
}
public ResultDTO ImportFlowingSalesFeeDetail(int[] feeId)
{
ResultDTO result = new ResultDTO();
if (feeId?.Length > 0)
{
DateTime now = DateTime.Now;
string sql = "select * from flowing_sales_fee where id in @fee_id";
using (var db = new MySqlConnection(GlobalConfig.ConnectionString_DW))
{
if (db.State == ConnectionState.Closed)
{
db.Open();
}
IList<flowing_sales_fee> list = db.Query<flowing_sales_fee>(sql, new { fee_id = feeId }).ToList();
List<flowing_sales_fee_detail> listDetail = new List<flowing_sales_fee_detail>();
if (list?.Count > 0)
{
sql = "select * from exchange_rate_finance where month in @month";
IList<exchange_rate_finance> listRate = db.Query<exchange_rate_finance>(sql, new { month = list.Select(l => l.month).Distinct() }).ToList();
if (listRate?.Count > 0)
{
DateTime date = DateTime.MinValue;
foreach (flowing_sales_fee entity in list)
{
if (DateTime.TryParse(entity.month, out date))
{
DateTime monthTime = date;
int days = DateTime.DaysInMonth(monthTime.Year, monthTime.Month);
for (int day = 1; day <= days; day++)
{
flowing_sales_fee_detail detailEntity = new flowing_sales_fee_detail()
{
fee_id = entity.id,
platform = entity.platform,
fee_type = entity.fee_type,
date = new DateTime(monthTime.Year, monthTime.Month, day),
amount = Math.Round(entity.amount / days, 2),
currency = entity.currency,
create_time = now,
update_time = now
};
if (day == days)
{
detailEntity.amount = Math.Round(entity.amount - (Math.Round(entity.amount / days, 2) * (days - 1)), 2);
}
exchange_rate_finance rate_cny = listRate.FirstOrDefault(l => l.month == entity.month && l.code.Equals(entity.currency, StringComparison.OrdinalIgnoreCase));
exchange_rate_finance rate_usd = listRate.FirstOrDefault(l => l.month == entity.month && l.code.Equals(entity.currency, StringComparison.OrdinalIgnoreCase));
if (rate_cny != null && rate_usd != null)
{
detailEntity.amount_cny = Math.Round(detailEntity.amount / rate_cny.exchange_rate, 2);
detailEntity.amount_usd = Math.Round(detailEntity.amount_cny * rate_usd.exchange_rate, 2);
}
listDetail.Add(detailEntity);
}
}
}
using (var trans = db.BeginTransaction())
{
try
{
sql = "delete from flowing_sales_fee_detail where fee_id in @fee_id";
int resultCount = db.Execute(sql, new { fee_id = feeId });
sql = "insert into flowing_sales_fee_detail(fee_id,platform,fee_type,date,amount,currency,amount_cny,amount_usd,delstatus,create_time,update_time)values(@fee_id,@platform,@fee_type,@date,@amount,@currency,@amount_cny,@amount_usd,@delstatus,@create_time,@update_time)";
resultCount = db.Execute(sql, listDetail.ToArray());
trans.Commit();
result.Result = true;
}
catch (Exception ex)
{
trans.Rollback();
trans.Dispose();
result.Message = ex.Message;
}
}
}
else
{
result.Message = "没有汇率信息";
}
}
}
}
else
{
result.Message = "数据不能为空";
}
return result;
}
public ResultDTO DeleteFlowingSalesFee(int[] id)
{
ResultDTO result = this.BeforeDeleteFlowingSalesFee(id);
if (result.Result)
{
string sql = "update flowing_sales_fee set delstatus = @delstatus, update_time = @update_time where id in @id";
using (var db = new MySqlConnection(GlobalConfig.ConnectionString_DW))
{
if (db.State == ConnectionState.Closed)
{
db.Open();
}
//开启事务
using (MySqlTransaction transaction = db.BeginTransaction())
{
try
{
int resultCount = db.Execute(sql, new { id = id, delstatus = 1, update_time = DateTime.Now });
if (resultCount > 0)
{
sql = "update flowing_sales_fee_detail set delstatus = @delstatus, update_time = @update_time where fee_id in @fee_id";
resultCount = db.Execute(sql, new { fee_id = id, delstatus = 1, update_time = DateTime.Now });
//提交事务
transaction.Commit();
result.Message = "保存成功";
}
}
catch (Exception ex)
{
//回滚事务
transaction.Rollback();
result.Message = ex.Message;
result.Result = false;
}
}
}
}
return result;
}
public ResultDTO BeforeSaveFlowingSalesFee(flowing_sales_fee entity)
{
ResultDTO result = new ResultDTO();
if (entity == null)
{
result.Message = "数据不能为空";
}
else if (string.IsNullOrWhiteSpace(entity.platform))
{
result.Message = "平台不能为空";
}
else if (string.IsNullOrWhiteSpace(entity.fee_type))
{
result.Message = "费用类型不能为空";
}
else if (string.IsNullOrWhiteSpace(entity.month))
{
result.Message = "月份不能为空";
}
else if (entity.amount == 0m)
{
result.Message = "金额不能为空";
}
else if (string.IsNullOrWhiteSpace(entity.currency))
{
result.Message = "币种不能为空";
}
else
{
result.Result = true;
}
return result;
}
public ResultDTO BeforeDeleteFlowingSalesFee(int[] id)
{
ResultDTO result = new ResultDTO();
if (id == null || id.Length == 0 || id.Contains(0))
{
result.Message = "ID不能为空";
}
else
{
result.Result = true;
}
return result;
}
} }
} }
...@@ -181,22 +181,6 @@ namespace Bailun.DC.Web.Areas.Component.Controllers ...@@ -181,22 +181,6 @@ namespace Bailun.DC.Web.Areas.Component.Controllers
return Json(result); return Json(result);
} }
[HttpPost]
public JsonResult Import(IFormFile file)
{
ResultDTO result = default(ResultDTO);
try
{
result = new ResultDTO { Result = true };
}
catch (Exception ex)
{
result = new ResultDTO() { Message = ex.Message };
}
return Json(result);
}
private class IgnoreJsonAttributesResolver : DefaultContractResolver private class IgnoreJsonAttributesResolver : DefaultContractResolver
{ {
private string Id { get; set; } private string Id { get; set; }
......
...@@ -9,6 +9,8 @@ using Bailun.ServiceFabric.Authorize; ...@@ -9,6 +9,8 @@ using Bailun.ServiceFabric.Authorize;
using Bailun.ServiceFabric.Core.Extension.HttpContext; using Bailun.ServiceFabric.Core.Extension.HttpContext;
using Bailun.ServiceFabric.Core.Extension; using Bailun.ServiceFabric.Core.Extension;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Bailun.DC.Models.Component.DTO;
using Bailun.DC.Models.DataWareHouse;
namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
{ {
...@@ -24,13 +26,13 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -24,13 +26,13 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
#region 流水解析配置 #region 流水解析配置
public ActionResult FlowingConfig(int datatype,string platform) public ActionResult FlowingConfig(int datatype, string platform)
{ {
var listPlatform = new List<string>(); var listPlatform = new List<string>();
var _service = new Services.DataWareHouse.PlatformOrderFeeServices(); var _service = new Services.DataWareHouse.PlatformOrderFeeServices();
//var listFeeCol = _service.ListOrderFeeCol(); //var listFeeCol = _service.ListOrderFeeCol();
var listFeeConfig = _service.ListOrderFeeConfig(datatype); var listFeeConfig = _service.ListOrderFeeConfig(datatype);
...@@ -66,7 +68,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -66,7 +68,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
item.colname_currency = item.colname_currency ?? ""; item.colname_currency = item.colname_currency ?? "";
} }
return Json(new { return Json(new
{
success = true, success = true,
list = obj, list = obj,
...@@ -112,15 +115,16 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -112,15 +115,16 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
var time = row["时间字段列"].ToString(); var time = row["时间字段列"].ToString();
var currency = row["币种字段列"].ToString(); var currency = row["币种字段列"].ToString();
if(string.IsNullOrEmpty(platform)) if (string.IsNullOrEmpty(platform))
{ {
return Json(new { return Json(new
{
success = false, success = false,
msg = "平台不能为空", msg = "平台不能为空",
}); });
} }
if(string.IsNullOrEmpty(time)) if (string.IsNullOrEmpty(time))
{ {
return Json(new return Json(new
{ {
...@@ -140,7 +144,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -140,7 +144,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
if (datatype == 1) //销售平台 if (datatype == 1) //销售平台
{ {
listOrderConfigs.Add(new Models.DataWareHouse.flowing_sales_config { listOrderConfigs.Add(new Models.DataWareHouse.flowing_sales_config
{
platform = platform, platform = platform,
website = website, website = website,
colname_currency = currency, colname_currency = currency,
...@@ -152,7 +157,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -152,7 +157,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
} }
else if (datatype == 2) //物流平台 else if (datatype == 2) //物流平台
{ {
listLogisticConfigs.Add(new Models.DataWareHouse.flowing_logistic_config { listLogisticConfigs.Add(new Models.DataWareHouse.flowing_logistic_config
{
platform = platform, platform = platform,
website = website, website = website,
col_datatime = time, col_datatime = time,
...@@ -206,11 +212,11 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -206,11 +212,11 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
foreach (var item in obj) foreach (var item in obj)
{ {
list.Add(item.platform + "~~" + (item.website ?? "") + "~~" + item.colname_orderno+ "~~" + item.colname_platformsku+ "~~" + item.colname_datatime+ "~~" + item.colname_currency); list.Add(item.platform + "~~" + (item.website ?? "") + "~~" + item.colname_orderno + "~~" + item.colname_platformsku + "~~" + item.colname_datatime + "~~" + item.colname_currency);
} }
var guid = Guid.NewGuid().ToString(); var guid = Guid.NewGuid().ToString();
var filename = (datatype==1?"销售平台 ":"物流 ") + " " + platform + "-" + website + " 流水字段解析配置"; var filename = (datatype == 1 ? "销售平台 " : "物流 ") + " " + platform + "-" + website + " 流水字段解析配置";
var filepath = _hostingEnvironment.WebRootPath + "\\Files\\Report\\" + DateTime.Now.ToString("yyyy-MM-dd") + "\\"; var filepath = _hostingEnvironment.WebRootPath + "\\Files\\Report\\" + DateTime.Now.ToString("yyyy-MM-dd") + "\\";
ToCSV(list, colnames, guid, filepath, "~~"); ToCSV(list, colnames, guid, filepath, "~~");
...@@ -236,7 +242,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -236,7 +242,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
{ {
var result = new Services.DataWareHouse.PlatformOrderServices().DelFlowingConfig(id, datatype); var result = new Services.DataWareHouse.PlatformOrderServices().DelFlowingConfig(id, datatype);
return Json(new { return Json(new
{
success = string.IsNullOrEmpty(result), success = string.IsNullOrEmpty(result),
msg = result msg = result
}); });
...@@ -254,7 +261,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -254,7 +261,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
var _service = new Services.DataWareHouse.PlatformOrderFeeServices(); var _service = new Services.DataWareHouse.PlatformOrderFeeServices();
//var listFeeCol = _service.ListOrderFeeCol(); //var listFeeCol = _service.ListOrderFeeCol();
var listFeeConfig = _service.ListOrderFeeConfig(datatype??0); var listFeeConfig = _service.ListOrderFeeConfig(datatype ?? 0);
ViewBag.listplatform = listPlatform = listFeeConfig.Select(a => a.platform).Distinct().ToList(); ViewBag.listplatform = listPlatform = listFeeConfig.Select(a => a.platform).Distinct().ToList();
if (string.IsNullOrEmpty(platform)) if (string.IsNullOrEmpty(platform))
...@@ -264,7 +271,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -264,7 +271,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
ViewBag.website = listFeeConfig.Where(a => a.platform == platform).Select(a => a.website).Distinct().ToList(); ViewBag.website = listFeeConfig.Where(a => a.platform == platform).Select(a => a.website).Distinct().ToList();
ViewBag.platform = platform; ViewBag.platform = platform;
ViewBag.datatype = datatype.HasValue?datatype.Value+"":""; ViewBag.datatype = datatype.HasValue ? datatype.Value + "" : "";
return View(); return View();
} }
...@@ -282,7 +289,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -282,7 +289,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
var total = 0; var total = 0;
var obj = new Services.DataWareHouse.OrderFeeConfigServices().ListOrderFeeConfig(new Models.BtTableParameter { limit = 0 }, platform, website, datatype, ref total); var obj = new Services.DataWareHouse.OrderFeeConfigServices().ListOrderFeeConfig(new Models.BtTableParameter { limit = 0 }, platform, website, datatype, ref total);
var list = obj.Select(a => new { var list = obj.Select(a => new
{
a.platform, a.platform,
a.website, a.website,
a.colname_fee, a.colname_fee,
...@@ -294,7 +302,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -294,7 +302,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
a.projectcode, a.projectcode,
a.subjectcode, a.subjectcode,
a.versionno, a.versionno,
a.condition_forfee, a.condition_forfee,
}); });
...@@ -306,7 +314,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -306,7 +314,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
}); });
} }
public ActionResult ExportOrderFeeConfig(int? datatype, string platform, string website) { public ActionResult ExportOrderFeeConfig(int? datatype, string platform, string website)
{
var total = 0; var total = 0;
var obj = new Services.DataWareHouse.OrderFeeConfigServices().ListOrderFeeConfig(new Models.BtTableParameter { limit = 0 }, platform, website, datatype, ref total); var obj = new Services.DataWareHouse.OrderFeeConfigServices().ListOrderFeeConfig(new Models.BtTableParameter { limit = 0 }, platform, website, datatype, ref total);
...@@ -353,7 +362,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -353,7 +362,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
}); });
} }
if(datatype==0) if (datatype == 0)
{ {
return Json(new return Json(new
{ {
...@@ -394,7 +403,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -394,7 +403,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
var datacentercol = row["数据中心字段"].ToString(); var datacentercol = row["数据中心字段"].ToString();
var currency = row["币种"].ToString(); var currency = row["币种"].ToString();
var note = row["备注"].ToString(); var note = row["备注"].ToString();
if (string.IsNullOrEmpty(platform)) if (string.IsNullOrEmpty(platform))
{ {
...@@ -439,20 +448,20 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -439,20 +448,20 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
listFeeConfig.Add(new Models.DataWareHouse.order_fee_config listFeeConfig.Add(new Models.DataWareHouse.order_fee_config
{ {
platform = platform.Trim(), platform = platform.Trim(),
website = (website??"").Trim(), website = (website ?? "").Trim(),
subjectcode = subjectcode.Trim(), subjectcode = subjectcode.Trim(),
colname_fee = valcol.Trim(), colname_fee = valcol.Trim(),
condition_forfee = _condition, condition_forfee = _condition,
currency = (currency??"").Trim(), currency = (currency ?? "").Trim(),
datacenter_col = (datacentercol??"").Trim(), datacenter_col = (datacentercol ?? "").Trim(),
datatype = datatype, datatype = datatype,
delstatus = 0, delstatus = 0,
feetype = (feetype??"").Trim(), feetype = (feetype ?? "").Trim(),
financecategory = (category??"").Trim(), financecategory = (category ?? "").Trim(),
note = note, note = note,
projectcode = (projectcode??"").Trim(), projectcode = (projectcode ?? "").Trim(),
versionno = DateTime.Now.ToString("YYMMddHHmm"), versionno = DateTime.Now.ToString("YYMMddHHmm"),
}); });
...@@ -481,7 +490,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -481,7 +490,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
{ {
var result = new Services.DataWareHouse.OrderFeeConfigServices().DelOrderFeeConfig(id); var result = new Services.DataWareHouse.OrderFeeConfigServices().DelOrderFeeConfig(id);
return Json(new { return Json(new
{
success = string.IsNullOrEmpty(result), success = string.IsNullOrEmpty(result),
msg = result msg = result
}); });
...@@ -493,7 +503,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -493,7 +503,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
public ActionResult ExchangeRate(string month) public ActionResult ExchangeRate(string month)
{ {
ViewBag.month = string.IsNullOrEmpty(month)?DateTime.Now.AddMonths(-1).ToString("yyyy-MM"):month; ViewBag.month = string.IsNullOrEmpty(month) ? DateTime.Now.AddMonths(-1).ToString("yyyy-MM") : month;
return View(); return View();
} }
...@@ -507,7 +517,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -507,7 +517,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
{ {
var obj = new Services.DataWareHouse.PlatformOrderServices().ListExchangeRate(month); var obj = new Services.DataWareHouse.PlatformOrderServices().ListExchangeRate(month);
return Json(new { return Json(new
{
success = true, success = true,
list = obj, list = obj,
}); });
...@@ -552,7 +563,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -552,7 +563,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
msg = "月份不能为空,请填写月份!" msg = "月份不能为空,请填写月份!"
}); });
} }
if(string.IsNullOrEmpty(_currency)) if (string.IsNullOrEmpty(_currency))
{ {
return Json(new return Json(new
{ {
...@@ -560,7 +571,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -560,7 +571,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
msg = "币种不能为空,请填写币种!" msg = "币种不能为空,请填写币种!"
}); });
} }
if (_exchangerate<=0) if (_exchangerate <= 0)
{ {
return Json(new return Json(new
{ {
...@@ -572,7 +583,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -572,7 +583,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
list.Add(new Models.DataWareHouse.exchange_rate_finance list.Add(new Models.DataWareHouse.exchange_rate_finance
{ {
month= _month, month = _month,
currency = _currency, currency = _currency,
exchange_rate = _exchangerate exchange_rate = _exchangerate
}); });
...@@ -609,12 +620,13 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -609,12 +620,13 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
[HttpPost] [HttpPost]
public JsonResult OrderBillingsJson(int page,string platform,string website,string account,DateTime? start,DateTime? end,string orderno,string month, int pagesize = 25) public JsonResult OrderBillingsJson(int page, string platform, string website, string account, DateTime? start, DateTime? end, string orderno, string month, int pagesize = 25)
{ {
if (string.IsNullOrEmpty(platform)) if (string.IsNullOrEmpty(platform))
{ {
return Json(new { return Json(new
success= false, {
success = false,
msg = "请选择平台类型" msg = "请选择平台类型"
}); });
} }
...@@ -635,15 +647,16 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -635,15 +647,16 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
// }); // });
//} //}
if(page<=0) if (page <= 0)
{ {
page = 1; page = 1;
} }
int total = 0; int total = 0;
var obj = new Services.DataWareHouse.PlatformOrderServices().List(page, platform, website, account, start,end,orderno, month, ref total,pagesize); var obj = new Services.DataWareHouse.PlatformOrderServices().List(page, platform, website, account, start, end, orderno, month, ref total, pagesize);
var list = obj.Select(a => new { var list = obj.Select(a => new
{
a.accountname, a.accountname,
a.createtime, a.createtime,
jsondata = Newtonsoft.Json.Linq.JRaw.Parse(a.jsondata), jsondata = Newtonsoft.Json.Linq.JRaw.Parse(a.jsondata),
...@@ -651,20 +664,21 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -651,20 +664,21 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
a.orderno, a.orderno,
a.platform, a.platform,
a.website, a.website,
datatime = a.datatime.HasValue?a.datatime.Value.ToString("yyyy-MM-dd HH:mm:ss"):"", datatime = a.datatime.HasValue ? a.datatime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
}); });
return Json(new { return Json(new
{
success = true, success = true,
msg = "", msg = "",
rows = list, rows = list,
total = total, total = total,
page = page, page = page,
totalpage = total/pagesize+(total%pagesize>0?1:0), totalpage = total / pagesize + (total % pagesize > 0 ? 1 : 0),
}); });
} }
public ActionResult ExportOrderBillings(string platform, string website, string account, DateTime? start,DateTime? end,string orderno,string month) public ActionResult ExportOrderBillings(string platform, string website, string account, DateTime? start, DateTime? end, string orderno, string month)
{ {
if (string.IsNullOrEmpty(platform)) if (string.IsNullOrEmpty(platform))
{ {
...@@ -695,9 +709,9 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -695,9 +709,9 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
var total = 0; var total = 0;
var obj = new Services.DataWareHouse.PlatformOrderServices().List(1, platform, website, account, start,end, orderno, month, ref total, 0); var obj = new Services.DataWareHouse.PlatformOrderServices().List(1, platform, website, account, start, end, orderno, month, ref total, 0);
if(obj.Count==0) if (obj.Count == 0)
{ {
return Json(new return Json(new
{ {
...@@ -720,7 +734,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -720,7 +734,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
} }
foreach (var item in obj) foreach (var item in obj)
{ {
jsonData = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(item.jsondata); jsonData = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(item.jsondata);
DataRow dataRow = dataTable.NewRow(); DataRow dataRow = dataTable.NewRow();
...@@ -734,7 +748,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -734,7 +748,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
dataTable.Rows.Add(dataRow); dataTable.Rows.Add(dataRow);
} }
//for (var i = 0; i < dataTable.Columns.Count; i++) //for (var i = 0; i < dataTable.Columns.Count; i++)
//{ //{
// colnames.Add(dataTable.Columns[i].ColumnName); // colnames.Add(dataTable.Columns[i].ColumnName);
...@@ -756,7 +770,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -756,7 +770,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
} }
var guid = Guid.NewGuid().ToString(); var guid = Guid.NewGuid().ToString();
var filename = platform+ " " + ((start.HasValue?start.Value.ToString("yyyy-MM-dd"):""+(end.HasValue?"至"+end.Value.ToString("yyyy-MM-dd"):""))) + "的账单流水"; var filename = platform + " " + ((start.HasValue ? start.Value.ToString("yyyy-MM-dd") : "" + (end.HasValue ? "至" + end.Value.ToString("yyyy-MM-dd") : ""))) + "的账单流水";
var filepath = _hostingEnvironment.WebRootPath + "\\Files\\Report\\" + DateTime.Now.ToString("yyyy-MM-dd") + "\\"; var filepath = _hostingEnvironment.WebRootPath + "\\Files\\Report\\" + DateTime.Now.ToString("yyyy-MM-dd") + "\\";
ToCSV(listVal, colnames, guid, filepath); ToCSV(listVal, colnames, guid, filepath);
...@@ -769,7 +783,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -769,7 +783,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
ms.Position = 0; ms.Position = 0;
return File(ms, "text/csv", filename + ".csv"); return File(ms, "text/csv", filename + ".csv");
} }
/// <summary> /// <summary>
/// 下载销售平台流水上传模版 /// 下载销售平台流水上传模版
/// </summary> /// </summary>
...@@ -778,7 +792,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -778,7 +792,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
/// <param name="start"></param> /// <param name="start"></param>
/// <param name="end"></param> /// <param name="end"></param>
/// <returns></returns> /// <returns></returns>
public ActionResult DownLoadOrderBillingTemplate(string platform,string website,DateTime? start,DateTime? end,string month) public ActionResult DownLoadOrderBillingTemplate(string platform, string website, DateTime? start, DateTime? end, string month)
{ {
if (string.IsNullOrEmpty(platform)) if (string.IsNullOrEmpty(platform))
{ {
...@@ -860,7 +874,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -860,7 +874,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
/// <returns></returns> /// <returns></returns>
//[BailunAuthentication(LoginMode.Enforce)] //[BailunAuthentication(LoginMode.Enforce)]
[DisableRequestSizeLimit] [DisableRequestSizeLimit]
public JsonResult UploadOrderBilling(string platform, string website,string month,string guid) public JsonResult UploadOrderBilling(string platform, string website, string month, string guid)
{ {
if (string.IsNullOrEmpty(platform)) if (string.IsNullOrEmpty(platform))
{ {
...@@ -889,13 +903,13 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -889,13 +903,13 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
}); });
} }
//var user = HttpContextHelper.Current?.User; //var user = HttpContextHelper.Current?.User;
var file = Request.Form.Files[0]; var file = Request.Form.Files[0];
var errmsg = ""; var errmsg = "";
Dictionary<string, DataTable> dic = Base.NpolHelper.ExcelToDataTable(file.OpenReadStream(), file.FileName, true,ref errmsg); Dictionary<string, DataTable> dic = Base.NpolHelper.ExcelToDataTable(file.OpenReadStream(), file.FileName, true, ref errmsg);
if (dic.Count > 0) if (dic.Count > 0)
{ {
var tb = dic.FirstOrDefault(); var tb = dic.FirstOrDefault();
...@@ -905,31 +919,34 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -905,31 +919,34 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
foreach (var item in list) foreach (var item in list)
{ {
//保存数据 //保存数据
var m = new Models.DataWareHouse.flowing_sales { var m = new Models.DataWareHouse.flowing_sales
{
accountname = "", accountname = "",
createtime = DateTime.Now, createtime = DateTime.Now,
jsondata = Newtonsoft.Json.JsonConvert.SerializeObject(item), jsondata = Newtonsoft.Json.JsonConvert.SerializeObject(item),
month = month, month = month,
platform = platform, platform = platform,
website = website??"", website = website ?? "",
orderno = "", orderno = "",
platformsku = "", platformsku = "",
createuser = "页面上传" createuser = "页面上传"
}; };
listOrders.Add(m); listOrders.Add(m);
} }
var result = new Services.DataWareHouse.PlatformOrderServices().InsertOrderBilling(listOrders); var result = new Services.DataWareHouse.PlatformOrderServices().InsertOrderBilling(listOrders);
return Json(new { return Json(new
{
success = string.IsNullOrEmpty(result), success = string.IsNullOrEmpty(result),
msg = result msg = result
}); });
} }
return Json(new { return Json(new
{
success = false, success = false,
msg="无法识别表格的数据,请下载模版重新导入,或者检查下表格数据是否正确。", msg = "无法识别表格的数据,请下载模版重新导入,或者检查下表格数据是否正确。",
}); });
} }
...@@ -939,7 +956,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -939,7 +956,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
/// <param name="platform"></param> /// <param name="platform"></param>
/// <param name="website"></param> /// <param name="website"></param>
/// <returns></returns> /// <returns></returns>
public JsonResult UploadOrderBillingMerge(string platform,string month) public JsonResult UploadOrderBillingMerge(string platform, string month)
{ {
if (string.IsNullOrEmpty(platform)) if (string.IsNullOrEmpty(platform))
{ {
...@@ -974,7 +991,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -974,7 +991,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
var file = Request.Form.Files[0]; var file = Request.Form.Files[0];
var errmsg = ""; var errmsg = "";
Dictionary<string, DataTable> dic = Base.NpolHelper.ExcelToDataTable(file.OpenReadStream(), file.FileName, true,ref errmsg); Dictionary<string, DataTable> dic = Base.NpolHelper.ExcelToDataTable(file.OpenReadStream(), file.FileName, true, ref errmsg);
if (dic.Count > 0) if (dic.Count > 0)
{ {
...@@ -1025,7 +1042,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -1025,7 +1042,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
var _service = new Services.DataWareHouse.PlatformOrderFeeServices(); var _service = new Services.DataWareHouse.PlatformOrderFeeServices();
//var listFeeCol = _service.ListOrderFeeCol(); //var listFeeCol = _service.ListOrderFeeCol();
var listFeeConfig = _service.ListOrderFeeConfig(); var listFeeConfig = _service.ListOrderFeeConfig();
ViewBag.platform = listPlatform = listFeeConfig.Select(a => a.platform).Distinct().ToList(); ViewBag.platform = listPlatform = listFeeConfig.Select(a => a.platform).Distinct().ToList();
ViewBag.website = listFeeConfig.Where(a => a.platform == listPlatform.FirstOrDefault()).Select(a => a.website).Distinct().ToList(); ViewBag.website = listFeeConfig.Where(a => a.platform == listPlatform.FirstOrDefault()).Select(a => a.website).Distinct().ToList();
...@@ -1034,11 +1051,11 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -1034,11 +1051,11 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
return View(); return View();
} }
public string FinanceAccount_OrderBillingJson(Models.BtTableParameter request, string platform, string website, string account, DateTime? start, DateTime? end, string orderno,string month,int? datatype,string datacentercol) public string FinanceAccount_OrderBillingJson(Models.BtTableParameter request, string platform, string website, string account, DateTime? start, DateTime? end, string orderno, string month, int? datatype, string datacentercol)
{ {
var total = 0; var total = 0;
var obj = new Services.DataWareHouse.PlatformOrderFeeServices().ListOrderFeeValue(request.pageIndex, request.limit, platform, website, start, end, orderno,month, ref total,datatype, datacentercol); var obj = new Services.DataWareHouse.PlatformOrderFeeServices().ListOrderFeeValue(request.pageIndex, request.limit, platform, website, start, end, orderno, month, ref total, datatype, datacentercol);
var objCount = new Services.DataWareHouse.PlatformOrderFeeServices().ListOrderFeeValueCount(platform, website, start, end, orderno, month, datatype, datacentercol); var objCount = new Services.DataWareHouse.PlatformOrderFeeServices().ListOrderFeeValueCount(platform, website, start, end, orderno, month, datatype, datacentercol);
...@@ -1046,24 +1063,25 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -1046,24 +1063,25 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
{ {
company = "香港百伦", company = "香港百伦",
a.platform, a.platform,
website = a.website??"global", website = a.website ?? "global",
a.orderno, a.orderno,
a.datatime, a.datatime,
a.amountval, a.amountval,
feetype = a.fee_config?.feetype??"", feetype = a.fee_config?.feetype ?? "",
subjectcode = a.fee_config?.subjectcode??"", subjectcode = a.fee_config?.subjectcode ?? "",
projectcode = a.fee_config?.projectcode??"", projectcode = a.fee_config?.projectcode ?? "",
financecategory = a.fee_config?.financecategory??"", financecategory = a.fee_config?.financecategory ?? "",
datacenter_col = a.fee_config?.datacenter_col??"", datacenter_col = a.fee_config?.datacenter_col ?? "",
currency = (!string.IsNullOrEmpty(a.currency)?a.currency: a.fee_config.currency), currency = (!string.IsNullOrEmpty(a.currency) ? a.currency : a.fee_config.currency),
exchange_rate = a.exchange_rate.HasValue?a.exchange_rate.Value+"":"", exchange_rate = a.exchange_rate.HasValue ? a.exchange_rate.Value + "" : "",
amountval_rmb = a.amountval_rmb.HasValue?a.amountval_rmb.Value+"":"", amountval_rmb = a.amountval_rmb.HasValue ? a.amountval_rmb.Value + "" : "",
a.month, a.month,
}); });
var countRow = new { var countRow = new
{
company = "香港百伦", company = "香港百伦",
platform = "", platform = "",
website = "", website = "",
...@@ -1080,11 +1098,12 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -1080,11 +1098,12 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
exchange_rate = "", exchange_rate = "",
amountval_rmb = objCount.amountval_rmb.HasValue ? objCount.amountval_rmb.Value.ToString("N2") : "", amountval_rmb = objCount.amountval_rmb.HasValue ? objCount.amountval_rmb.Value.ToString("N2") : "",
month="", month = "",
}; };
return Newtonsoft.Json.JsonConvert.SerializeObject(new { return Newtonsoft.Json.JsonConvert.SerializeObject(new
{
rows = list, rows = list,
total = total, total = total,
count_row = countRow count_row = countRow
...@@ -1101,7 +1120,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -1101,7 +1120,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
/// <param name="end"></param> /// <param name="end"></param>
/// <param name="orderno"></param> /// <param name="orderno"></param>
/// <returns></returns> /// <returns></returns>
public ActionResult ExportFinanceAccount_OrderBilling(string platform, string website, string account, DateTime? start, DateTime? end, string orderno,string month, int? datatype,string datacentercol) public ActionResult ExportFinanceAccount_OrderBilling(string platform, string website, string account, DateTime? start, DateTime? end, string orderno, string month, int? datatype, string datacentercol)
{ {
var total = 0; var total = 0;
var page = 1; var page = 1;
...@@ -1109,9 +1128,9 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -1109,9 +1128,9 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
var obj = new Services.DataWareHouse.PlatformOrderFeeServices().ListOrderFeeValue(1, pagesize, platform, website, start, end, orderno, month, ref total, datatype, datacentercol); var obj = new Services.DataWareHouse.PlatformOrderFeeServices().ListOrderFeeValue(1, pagesize, platform, website, start, end, orderno, month, ref total, datatype, datacentercol);
if(total>obj.Count) if (total > obj.Count)
{ {
while((page-1)*pagesize<total) while ((page - 1) * pagesize < total)
{ {
page++; page++;
obj.AddRange(new Services.DataWareHouse.PlatformOrderFeeServices().ListOrderFeeValue(page, pagesize, platform, website, start, end, orderno, month, ref total, datatype, datacentercol)); obj.AddRange(new Services.DataWareHouse.PlatformOrderFeeServices().ListOrderFeeValue(page, pagesize, platform, website, start, end, orderno, month, ref total, datatype, datacentercol));
...@@ -1126,11 +1145,11 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -1126,11 +1145,11 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
foreach (var item in obj) foreach (var item in obj)
{ {
list.Add("公司主体|"+item.platform+"|"+(item.website??"global")+"|"+(item.datatime.HasValue?item.datatime.Value.ToString("yyyy-MM-dd HH:mm:ss"):"")+"|"+item.orderno+"|"+(item.fee_config?.feetype ?? "") +"|"+(item.fee_config?.financecategory ?? "")+"|"+(item.fee_config?.datacenter_col ?? "")+"|"+(item.fee_config?.subjectcode ?? "")+"|"+(item.fee_config?.projectcode ?? "")+"|"+ (!string.IsNullOrEmpty(item.currency) ? item.currency : item.fee_config.currency) + "|"+(item.amountval)+"|"+(item.exchange_rate.HasValue ? item.exchange_rate.Value + "" : "")+"|"+(item.amountval_rmb.HasValue ? item.amountval_rmb.Value + "" : "")+"|"+item.month); list.Add("公司主体|" + item.platform + "|" + (item.website ?? "global") + "|" + (item.datatime.HasValue ? item.datatime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") + "|" + item.orderno + "|" + (item.fee_config?.feetype ?? "") + "|" + (item.fee_config?.financecategory ?? "") + "|" + (item.fee_config?.datacenter_col ?? "") + "|" + (item.fee_config?.subjectcode ?? "") + "|" + (item.fee_config?.projectcode ?? "") + "|" + (!string.IsNullOrEmpty(item.currency) ? item.currency : item.fee_config.currency) + "|" + (item.amountval) + "|" + (item.exchange_rate.HasValue ? item.exchange_rate.Value + "" : "") + "|" + (item.amountval_rmb.HasValue ? item.amountval_rmb.Value + "" : "") + "|" + item.month);
} }
var guid = Guid.NewGuid().ToString(); var guid = Guid.NewGuid().ToString();
var filename = month+" "+platform+"-"+website+"财务会计流水"; var filename = month + " " + platform + "-" + website + "财务会计流水";
var filepath = _hostingEnvironment.WebRootPath + "\\Files\\Report\\" + DateTime.Now.ToString("yyyy-MM-dd") + "\\"; var filepath = _hostingEnvironment.WebRootPath + "\\Files\\Report\\" + DateTime.Now.ToString("yyyy-MM-dd") + "\\";
ToCSV(list, colnames, guid, filepath); ToCSV(list, colnames, guid, filepath);
...@@ -1151,7 +1170,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -1151,7 +1170,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
/// <param name="platform"></param> /// <param name="platform"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public JsonResult ListWebsite(string platform,int? datatype) public JsonResult ListWebsite(string platform, int? datatype)
{ {
//if (string.IsNullOrEmpty(platform)) //if (string.IsNullOrEmpty(platform))
//{ //{
...@@ -1222,21 +1241,22 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -1222,21 +1241,22 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
m.platform = row["平台"].ToString().Trim(); m.platform = row["平台"].ToString().Trim();
m.website = row["站点"].ToString().Trim(); m.website = row["站点"].ToString().Trim();
if(string.IsNullOrEmpty(m.platform)) if (string.IsNullOrEmpty(m.platform))
{ {
continue; continue;
} }
if (row["账单时间"] != null && row["账单时间"].ToString()!="") if (row["账单时间"] != null && row["账单时间"].ToString() != "")
{ {
m.datatime = DateTime.Parse(row["账单时间"].ToString()); m.datatime = DateTime.Parse(row["账单时间"].ToString());
} }
if (row["月份"] == null || row["月份"].ToString() == "") if (row["月份"] == null || row["月份"].ToString() == "")
{ {
return Json(new { return Json(new
{
success = false, success = false,
msg = $"第{(i+1)}行没有填写月份", msg = $"第{(i + 1)}行没有填写月份",
}); });
} }
...@@ -1258,8 +1278,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -1258,8 +1278,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
}); });
} }
var datacentercol = row["数据中心费用类型"].ToString().Trim(); var datacentercol = row["数据中心费用类型"].ToString().Trim();
if(row["币种"]==null) if (row["币种"] == null)
{ {
return Json(new return Json(new
{ {
...@@ -1281,7 +1301,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -1281,7 +1301,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
var str_amount = row["原币金额"].ToString().Trim(); var str_amount = row["原币金额"].ToString().Trim();
var amount = 0m; var amount = 0m;
decimal.TryParse(str_amount, out amount); decimal.TryParse(str_amount, out amount);
if(amount==0) if (amount == 0)
{ {
continue; continue;
} }
...@@ -1371,7 +1391,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -1371,7 +1391,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
} }
var result = new Services.DataWareHouse.PlatformOrderFeeServices().SaveOrderFee(listorder,0,""); var result = new Services.DataWareHouse.PlatformOrderFeeServices().SaveOrderFee(listorder, 0, "");
return Json(new return Json(new
{ {
success = string.IsNullOrEmpty(result), success = string.IsNullOrEmpty(result),
...@@ -1400,15 +1420,17 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -1400,15 +1420,17 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
{ {
if (string.IsNullOrEmpty(platform)) if (string.IsNullOrEmpty(platform))
{ {
return Json(new { return Json(new
success= false, {
success = false,
msg = "平台不能为空 platform must have value", msg = "平台不能为空 platform must have value",
}); });
} }
if (string.IsNullOrEmpty(website)) if (string.IsNullOrEmpty(website))
{ {
return Json(new { return Json(new
{
success = false, success = false,
msg = "站点不能为空 website must have value", msg = "站点不能为空 website must have value",
}); });
...@@ -1416,7 +1438,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -1416,7 +1438,8 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
if (string.IsNullOrEmpty(month)) if (string.IsNullOrEmpty(month))
{ {
return Json(new { return Json(new
{
success = false, success = false,
msg = "请选择月份 please choose the month" msg = "请选择月份 please choose the month"
}); });
...@@ -1428,17 +1451,90 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers ...@@ -1428,17 +1451,90 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
var result = new Services.DataWareHouse.PlatformOrderServices().BatchDeleteFinanceAccountFlowing(datatype, platform, website, month, (user != null ? user.GetUid() : 0), (user != null ? user.GetUserName() : ""), ref count); var result = new Services.DataWareHouse.PlatformOrderServices().BatchDeleteFinanceAccountFlowing(datatype, platform, website, month, (user != null ? user.GetUid() : 0), (user != null ? user.GetUserName() : ""), ref count);
return Json(new { return Json(new
{
success = string.IsNullOrEmpty(result), success = string.IsNullOrEmpty(result),
msg = result, msg = result,
count = count count = count
}); });
} }
[HttpPost]
public JsonResult SaveFlowingSalesFee([FromBody] flowing_sales_fee entity)
{
ResultDTO result = default(ResultDTO);
try
{
result = new Services.DataWareHouse.PlatformOrderFeeServices().SaveFlowingSalesFee(entity);
}
catch (Exception ex)
{
result = new ResultDTO() { Message = ex.Message };
}
return Json(result);
}
[HttpPost]
public JsonResult ImportFlowingSalesFee(IFormFile file)
{
ResultDTO result = new ResultDTO();
if (file != null)
{
try
{
string message = string.Empty;
Dictionary<string, DataTable> dic = Base.NpolHelper.ExcelToDataTable(file.OpenReadStream(), file.FileName, true, ref message);
result = new Services.DataWareHouse.PlatformOrderFeeServices().ImportFlowingSalesFee(dic?.FirstOrDefault().Value);
}
catch (Exception ex)
{
result = new ResultDTO() { Message = ex.Message };
}
}
else
{
result = new ResultDTO() { Message = "无文件导入" };
}
return Json(result);
}
[HttpPost]
public JsonResult ImportFlowingSalesFeeDetail(int[] id)
{
ResultDTO result = default(ResultDTO);
try
{
result = new Services.DataWareHouse.PlatformOrderFeeServices().ImportFlowingSalesFeeDetail(id);
}
catch (Exception ex)
{
result = new ResultDTO() { Message = ex.Message };
}
return Json(result);
}
[HttpPost]
public JsonResult DeleteFlowingSalesFee(int[] id)
{
ResultDTO result = default(ResultDTO);
try
{
result = new Services.DataWareHouse.PlatformOrderFeeServices().DeleteFlowingSalesFee(id);
}
catch (Exception ex)
{
result = new ResultDTO() { Message = ex.Message };
}
return Json(result);
}
#endregion #endregion
} }
......
...@@ -216,6 +216,7 @@ ...@@ -216,6 +216,7 @@
}, },
//上传文件 //上传文件
upLoad() { upLoad() {
Vue.set(this.$root, "loading", true);
this.$refs.upload.submit(); this.$refs.upload.submit();
}, },
//清除文件 //清除文件
...@@ -252,12 +253,14 @@ ...@@ -252,12 +253,14 @@
that.loading = false that.loading = false
that.$emit("import", false, file, response.message || "上传文件失败!") that.$emit("import", false, file, response.message || "上传文件失败!")
} }
Vue.set(this.$root, "loading", false);
}, },
//文件上传失败 //文件上传失败
onError(err, file, listFile) { onError(err, file, listFile) {
file.status = "ready" file.status = "ready"
this.loading = false this.loading = false
this.$emit("import", false, file, err) this.$emit("import", false, file, err)
Vue.set(this.$root, "loading", false);
}, },
}, },
template: '#elFormControl' template: '#elFormControl'
......
...@@ -121,6 +121,7 @@ ...@@ -121,6 +121,7 @@
onImport: function (result, file, message) { onImport: function (result, file, message) {
if (result) { if (result) {
this.$message("导入成功!") this.$message("导入成功!")
this.onSearch();
} else { } else {
this.$message.error(message) this.$message.error(message)
} }
......
...@@ -42,7 +42,9 @@ ...@@ -42,7 +42,9 @@
return { return {
isFirst: false, isFirst: false,
listData: [], listData: [],
setting: {} setting: {},
rows: [],
row: null
} }
}, },
methods: { methods: {
...@@ -224,7 +226,7 @@ ...@@ -224,7 +226,7 @@
}, },
//选择项发生变化事件 //选择项发生变化事件
onSelectionChange(selection) { onSelectionChange(selection) {
this.rows = selection this.$set(this, "rows", selection);
this.$emit("selection-change", selection) this.$emit("selection-change", selection)
}, },
//顺序号 //顺序号
......
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