自动对账接口及收发通末班修改

usertest
cjy 5 months ago
parent fb4746a351
commit e10a267bf2

@ -21,6 +21,8 @@ using NPOI.SS.Formula.Functions;
using NPOI.Util;
using Quartz.Logging;
using DS.Module.Core.Data;
using System.Collections;
using LanguageExt.ClassInstances.Pred;
namespace DS.WMS.Core.Check.Method
{
@ -133,7 +135,7 @@ namespace DS.WMS.Core.Check.Method
foreach (var item in req)
{
var mblno = item.;
var bizList = tenantDb.Queryable<VW_Op_Business>().Where(x => x.CustomerId == info.CustomerId && x.MBLNO.Contains(mblno)).ToList();
var bizList = tenantDb.Queryable<VW_Op_Business>().Where(x => x.MBLNO.Contains(mblno)).ToList();
if (bizList.Count > 1)
{
var mblnos = bizList.Select(x => x.MBLNO).Distinct();
@ -336,28 +338,138 @@ namespace DS.WMS.Core.Check.Method
/// <summary>
/// 自动对账重新匹配
/// </summary>
/// <param name="req">主表Ids</param>
/// <param name="req">主表Id</param>
/// <returns></returns>
public DataResult RecountCheckBillAuto(IdModel req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (req.Ids.Length == 0)
return DataResult.Failed("业务Ids不能为空");
var billLists = tenantDb.Queryable<CheckBillAuto>().Where(x => req.Ids.Contains(x.Id)).ToList();
if (billLists.Count > 0)
if (req.Id.IsNull())
return DataResult.Failed("业务Id不能为空");
var info = tenantDb.Queryable<CheckBillAuto>().Where(x => x.Id ==long.Parse(req.Id)).First();
if (info.IsNotNull())
{
foreach (var bill in billLists)
if (info.BillNo.IsNotNull())
{
return DataResult.Failed("存在已生成的对账信息!");
}
var list = tenantDb.Queryable<CheckBillAutoDetail>().Where(x => x.CheckId == long.Parse(req.Id)).ToList();
foreach (var bill in list)
{
var mblno = bill.MBLNO;
var usdAmount = 0M;
var rmbAmount = 0M;
var bizList = tenantDb.Queryable<VW_Op_Business>().Where(x => x.MBLNO.Contains(mblno)).ToList();
var mblnos = bizList.Select(x => x.MBLNO).Distinct();
foreach (var temp in mblnos)
{
var mblno1 = temp;
var bizlist1 = bizList.Where(x => x.MBLNO == mblno1).ToList();
//var mainBiz = bizlist1[0];
foreach (var biz in bizlist1)
{
var feeList = tenantDb.Queryable<FeeRecord>().Where(x => x.BusinessId == biz.BusinessId && x.CustomerId == info.CustomerId && x.FeeType == FeeType.Payable).ToList();
foreach (var record in feeList)
{
if (record.Currency == "RMB")
{
rmbAmount += record.Amount;
}
if (record.Currency == "USD")
{
usdAmount += record.Amount;
}
}
}
}
bill.RMBLocalAmount = rmbAmount;
bill.USDLocalAmount = usdAmount;
bill.RMBDifferenceAmount = rmbAmount - bill.RMBCheckAmount;
bill.USDDifferenceAmount = usdAmount - bill.USDCheckAmount;
bill.IsEqual = (rmbAmount - bill.RMBCheckAmount == 0 && usdAmount - bill.USDCheckAmount == 0) ? true : false;
}
tenantDb.Updateable(list).ExecuteCommand();
//更新主表
if (list.Where(x => x.IsEqual == false).Any())
{
info.CheckStatus = 2;
info.CheckStatusName = "对账不一致";
}
else
{
info.CheckStatus = 1;
info.CheckStatusName = "对账一致";
}
tenantDb.Updateable(info).ExecuteCommand();
}
else {
return DataResult.Failed("无匹配的自动对账信息");
return DataResult.Failed("自动对账主表信息不存在");
}
return DataResult.Successed("重新匹配成功!", MultiLanguageConst.DataUpdateSuccess);
}
/// <summary>
/// 生成对账单
/// </summary>
/// <param name="req">主表Id</param>
/// <returns></returns>
public DataResult CreateCheckBill(IdModel req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (req.Id.IsNull())
return DataResult.Failed("业务Id不能为空");
var info = tenantDb.Queryable<CheckBillAuto>().Where(x => x.Id == long.Parse(req.Id)).First();
if (info.IsNull())
return DataResult.Failed("自动对账主表信息不存在");
if (info.BillNo.IsNotNull())
return DataResult.Failed("对账信息已生成!");
var list = tenantDb.Queryable<CheckBillAutoDetail>().Where(x => x.CheckId == long.Parse(req.Id)).ToList();
foreach (var bill in list)
{
var mblno = bill.MBLNO;
var usdAmount = 0M;
var rmbAmount = 0M;
var bizList = tenantDb.Queryable<VW_Op_Business>().Where(x => x.MBLNO.Contains(mblno)).ToList();
var mblnos = bizList.Select(x => x.MBLNO).Distinct();
foreach (var temp in mblnos)
{
var mblno1 = temp;
var bizlist1 = bizList.Where(x => x.MBLNO == mblno1).ToList();
//var mainBiz = bizlist1[0];
foreach (var biz in bizlist1)
{
var feeList = tenantDb.Queryable<FeeRecord>().Where(x => x.BusinessId == biz.BusinessId && x.CustomerId == info.CustomerId && x.FeeType == FeeType.Payable).ToList();
foreach (var record in feeList)
{
if (record.Currency == "RMB")
{
rmbAmount += record.Amount;
}
if (record.Currency == "USD")
{
usdAmount += record.Amount;
}
}
}
}
bill.RMBLocalAmount = rmbAmount;
bill.USDLocalAmount = usdAmount;
bill.RMBDifferenceAmount = rmbAmount - bill.RMBCheckAmount;
bill.USDDifferenceAmount = usdAmount - bill.USDCheckAmount;
bill.IsEqual = (rmbAmount - bill.RMBCheckAmount == 0 && usdAmount - bill.USDCheckAmount == 0) ? true : false;
}
tenantDb.Updateable(list).ExecuteCommand(); ;
return DataResult.Successed("重新匹配成功!", MultiLanguageConst.DataUpdateSuccess);
}
}

@ -1,4 +1,5 @@
using DS.Module.Core;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
@ -42,6 +43,10 @@ namespace DS.WMS.Core.Op.Dtos
/// </summary>
public string Tel { get; set; }
/// <summary>
/// 邮箱
/// </summary>
public string Email { get; set; }
/// <summary>
/// 类型 1 收 2 发 3 通
/// </summary>
public string Type { get; set; }

@ -43,6 +43,10 @@ namespace DS.WMS.Core.Op.Dtos
/// </summary>
public string Tel { get; set; }
/// <summary>
/// 邮箱
/// </summary>
public string Email { get; set; }
/// <summary>
/// 类型 1 收 2 发 3 通
/// </summary>
public string Type { get; set; }

@ -43,6 +43,10 @@ namespace DS.WMS.Core.Op.Dtos
/// </summary>
public string Tel { get; set; }
/// <summary>
/// 邮箱
/// </summary>
public string Email { get; set; }
/// <summary>
/// 类型 1 收 2 发 3 通
/// </summary>
public string Type { get; set; }

@ -45,7 +45,11 @@ namespace DS.WMS.Core.Op.Entity
/// </summary>
[SugarColumn(ColumnDescription = "电话", IsNullable = true, Length = 50)]
public string Tel { get; set; }
/// <summary>
/// 邮箱
/// </summary>
[SugarColumn(ColumnDescription = "邮箱", IsNullable = true, Length = 100)]
public string Email { get; set; }
/// <summary>
/// 模板内容
/// </summary>

Loading…
Cancel
Save