Commit b19947c7 by guanzhenshan

完善物流供应商往来统计报表

parent f3d79838
...@@ -146,6 +146,78 @@ namespace Bailun.DC.Services ...@@ -146,6 +146,78 @@ namespace Bailun.DC.Services
} }
} }
/// <summary>
/// 更新往来的其他金额
/// </summary>
/// <param name="day">日期</param>
/// <param name="name">供应商名称</param>
/// <param name="amount">调整金额</param>
/// <param name="uid">当前用户ID</param>
/// <param name="username">当前用户名称</param>
/// <returns></returns>
public string UpdateSupplierTrancation(DateTime day, string name, decimal amount,int uid,string username)
{
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
if (cn.State == System.Data.ConnectionState.Closed)
{
cn.Open();
}
var sql = $"select * from dc_daily_logistics_supplier_transaction where suppliername='{name}' and day='{day.ToString("yyyy-MM-dd")}'";
var obj = cn.QueryFirstOrDefault<dc_daily_logistics_supplier_transaction>(sql);
if (obj != null)
{
obj.amount_other = amount;
obj.amount_end = obj.amount_start + obj.amount_happen - obj.amount_pay + (obj.amount_receipt) + obj.amount_other;
cn.Execute("update dc_daily_logistics_supplier_transaction set amount_other=" + obj.amount_other + ",amount_end=" + obj.amount_end + ",lastupdatetime='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") +"',lastupdateuserid=" + uid + ",lastupdateusername='" + username + "' where id=" + obj.id);
return UpdateSupplierTrancationAmountEnd(name, obj.amount_end, obj.day, cn, uid, username);
}
return "";
}
}
/// <summary>
/// 更新物流供应商往来的期末
/// </summary>
/// <returns></returns>
private string UpdateSupplierTrancationAmountEnd(string suppliername,decimal amount_start,DateTime day,MySqlConnection cn, int uid, string username)
{
try
{
if (cn.State == System.Data.ConnectionState.Closed)
{
cn.Open();
}
var sql = $"select * from dc_daily_logistics_supplier_transaction where suppliername='{suppliername}' and day='{day.AddDays(1).ToString("yyyy-MM-dd")}'";
var obj = cn.QueryFirstOrDefault<dc_daily_logistics_supplier_transaction>(sql);
if (obj != null)
{
obj.amount_start = amount_start;
obj.amount_end = obj.amount_start + obj.amount_happen - obj.amount_pay + (obj.amount_receipt) + obj.amount_other;
cn.Execute("update dc_daily_logistics_supplier_transaction set amount_other=" + obj.amount_other + ",amount_end=" + obj.amount_end + ",lastupdatetime='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',lastupdateuserid=" + uid + ",lastupdateusername='" + username + "' where id=" + obj.id);
amount_start = obj.amount_end;
}
if (day.AddDays(2) < DateTime.Now)
{
UpdateSupplierTrancationAmountEnd(suppliername, amount_start, day.AddDays(1), cn, uid, username);
}
return "";
}
catch (Exception ex)
{
return ex.Message;
}
}
} }
} }
...@@ -6,6 +6,8 @@ using Microsoft.AspNetCore.Mvc; ...@@ -6,6 +6,8 @@ using Microsoft.AspNetCore.Mvc;
using Bailun.DC.Models; using Bailun.DC.Models;
using Bailun.ServiceFabric.Authorize; using Bailun.ServiceFabric.Authorize;
using Newtonsoft.Json; using Newtonsoft.Json;
using Bailun.ServiceFabric.Core.Extension.HttpContext;
using Bailun.ServiceFabric.Core.Extension;
namespace Bailun.DC.Web.Areas.Reports.Controllers namespace Bailun.DC.Web.Areas.Reports.Controllers
{ {
...@@ -69,5 +71,26 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -69,5 +71,26 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
} }
}); });
} }
/// <summary>
/// 更新物流供应商往来报表的调整金额
/// </summary>
/// <param name="name">供应商名称</param>
/// <param name="day">日期</param>
/// <param name="amount">调整金额</param>
/// <returns></returns>
[BailunAuthentication(LoginMode.Enforce)]
[HttpPost]
public JsonResult UpdateSupplierTrancation(string name, DateTime day, decimal amount)
{
var user = HttpContextHelper.Current?.User;
var obj = new Services.LogisticsServices().UpdateSupplierTrancation(day, name, amount, (user != null ? user.GetUid() : 0), (user != null ? user.GetUserName() : ""));
return Json(new {
success = string.IsNullOrEmpty(obj),
msg = obj
});
}
} }
} }
\ No newline at end of file
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
} }
@section scripts{ @section scripts{
<script src="~/css/Layer-2.1/extend/layer.ext.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var tb; var tb;
$(document).ready(function () { $(document).ready(function () {
...@@ -78,7 +79,11 @@ ...@@ -78,7 +79,11 @@
{ field: 'amount_happen', title: '发生额', width: '110', iscount: true }, { field: 'amount_happen', title: '发生额', width: '110', iscount: true },
{ field: 'amount_pay', title: '付款额', width: '110', iscount: true }, { field: 'amount_pay', title: '付款额', width: '110', iscount: true },
{ field: 'amount_receipt', title: '收款额', width: '110', iscount: true }, { field: 'amount_receipt', title: '收款额', width: '110', iscount: true },
{ field: 'amount_other', title: '调整金额', width: '110', iscount: true }, {
field: 'amount_other', title: '调整金额', width: '110', iscount: true, formatter: function (idx, data) {
return '<div>' + data.amount_other + '<a style="margin-left:5px;color:#bbb;" onclick="updateAmount(\'' + data.suppliername + '\',\'' + data.str_day + '\',' + data.amount_other+');">修改</a></div>';
}
},
{ field: 'amount_end', title: '期末金额', width: '120', iscount: true } { field: 'amount_end', title: '期末金额', width: '120', iscount: true }
]; ];
...@@ -108,6 +113,43 @@ ...@@ -108,6 +113,43 @@
} }
} }
var suppliername = '';
var day = '';
function updateAmount(n, d, v) {
if (d.indexOf('至') > 0) {
alert("请选择开始日期和结束日期一致时,再修改调整金额。");
return false;
}
suppliername = n;
day = d;
layer.prompt({ title: '编辑' + d + n, value: v }, function (text, index) {
layer.close(index);
Save(text);
});
}
function Save(val) {
$.submit({
url: '@Url.Content("~/Reports/Logistics/UpdateSupplierTrancation")',
paramData: 'name=' + suppliername + '&day=' + day + '&amount=' + val,
type:'POST',
func: function (result) {
if (result.success) {
layer.msg('提交成功');
setTimeout(function () {
list();
}, 1.5 * 1000);
}
else {
layer.msg(result.msg);
}
}
})
}
function exportFile() { function exportFile() {
var start = $('#start').val(); var start = $('#start').val();
var end = $('#end').val(); var end = $('#end').val();
......
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