|
|
@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
|
|
|
using DS.Module.Core;
|
|
|
|
using DS.Module.Core;
|
|
|
|
using DS.Module.Core.Data;
|
|
|
|
using DS.Module.Core.Data;
|
|
|
|
using DS.Module.Core.Helpers;
|
|
|
|
using DS.Module.Core.Helpers;
|
|
|
|
|
|
|
|
using DS.Module.MQ;
|
|
|
|
using DS.Module.SqlSugar;
|
|
|
|
using DS.Module.SqlSugar;
|
|
|
|
using DS.Module.UserModule;
|
|
|
|
using DS.Module.UserModule;
|
|
|
|
using DS.WMS.Core.Fee.Entity;
|
|
|
|
using DS.WMS.Core.Fee.Entity;
|
|
|
@ -126,6 +127,7 @@ namespace DS.WMS.FeeBillRecvService
|
|
|
|
|
|
|
|
|
|
|
|
string msg = string.Empty;
|
|
|
|
string msg = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string gid = string.Empty;
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var model = GetInfo(json, out msg);
|
|
|
|
var model = GetInfo(json, out msg);
|
|
|
@ -153,19 +155,33 @@ namespace DS.WMS.FeeBillRecvService
|
|
|
|
|
|
|
|
|
|
|
|
string blno = model.BookingBill?.Trim();
|
|
|
|
string blno = model.BookingBill?.Trim();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gid = model.GID?.Trim();
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"提取订单信息 GID={model.GID} BookingBill={model.BookingBill}");
|
|
|
|
_logger.LogInformation($"提取订单信息 GID={model.GID} BookingBill={model.BookingBill}");
|
|
|
|
|
|
|
|
|
|
|
|
var booking = tenantDb.Queryable<SeaExport>().ClearFilter(typeof(IOrgId)).First(a => a.MBLNO == blno && a.Deleted == false && (a.IsRefund == null || a.IsRefund.Value == false)
|
|
|
|
var booking = tenantDb.Queryable<SeaExport>().ClearFilter(typeof(IOrgId)).First(a => a.MBLNO == blno && a.Deleted == false && (a.IsRefund == null || a.IsRefund.Value == false)
|
|
|
|
&& (a.IsChangeETD == null || a.IsChangeETD.Value == false));
|
|
|
|
&& (a.IsChangeETD == null || a.IsChangeETD.Value == false));
|
|
|
|
|
|
|
|
|
|
|
|
var ctnList = tenantDb.Queryable<OpCtn>().ClearFilter(typeof(IOrgId)).Where(a => a.BSNO == booking.Id.ToString() && a.Deleted == false).ToList();
|
|
|
|
_logger.LogInformation($"提取订单完成 GID={model.GID} BookingBill={model.BookingBill} Order={JsonConvert.SerializeObject(booking)}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (booking != null && booking.IsFeeLocking.HasValue && booking.IsFeeLocking.Value)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
SendCallBack(new SingleBillReceiveResult
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ReceiveId = model.GID,
|
|
|
|
|
|
|
|
Success = false,
|
|
|
|
|
|
|
|
Reason = "订单费用已锁定"
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"提取订单完成 GID={model.GID} BookingBill={model.BookingBill} Order={JsonConvert.SerializeObject(booking)}");
|
|
|
|
_logger.LogInformation($"提取订单完成 GID={model.GID} BookingBill={model.BookingBill} id={booking.Id}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (booking != null)
|
|
|
|
if (booking != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
var ctnList = tenantDb.Queryable<OpCtn>().ClearFilter(typeof(IOrgId)).Where(a => a.BSNO == booking.Id.ToString() && a.Deleted == false).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
DateTime etd = DateTime.MinValue;
|
|
|
|
DateTime etd = DateTime.MinValue;
|
|
|
|
|
|
|
|
|
|
|
|
if (booking.ETD.HasValue)
|
|
|
|
if (booking.ETD.HasValue)
|
|
|
@ -187,197 +203,378 @@ namespace DS.WMS.FeeBillRecvService
|
|
|
|
|
|
|
|
|
|
|
|
int start = 1;
|
|
|
|
int start = 1;
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var fee in model.DetailList)
|
|
|
|
//需要先全部费用跟库匹配,存在不匹配的,终止整个入库
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dictionary<string, Tuple<string, bool>> doResultDict = new Dictionary<string, Tuple<string, bool>>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var checkFeeArg = model.DetailList.Select(f=>f.CustSysName).Distinct().ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string reason = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool isStop = false;
|
|
|
|
|
|
|
|
bool isNoNotice = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (checkFeeArg.Any(x => string.IsNullOrWhiteSpace(x)))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string qFee = fee.CustSysName?.Trim();
|
|
|
|
isStop = true;
|
|
|
|
|
|
|
|
reason = "费用名称不能为空";
|
|
|
|
|
|
|
|
|
|
|
|
//if(string.IsNullOrWhiteSpace(qFee))
|
|
|
|
//new EmailNoticeHelper().SendEmailNotice("")
|
|
|
|
//{
|
|
|
|
isNoNotice = true;
|
|
|
|
// errorMsgList.Add("没有费用名称");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// continue;
|
|
|
|
var queryFeeList = tenantDb.Queryable<FeeCode>().Where(x => checkFeeArg.Contains(x.Name) && x.IsSea == true).ToList();
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var feecode = tenantDb.Queryable<FeeCode>().First(x => x.Name == qFee);
|
|
|
|
if(queryFeeList.Count == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
isStop = true;
|
|
|
|
|
|
|
|
reason = $"费用名称不存在,{(string.Join(",", checkFeeArg))}";
|
|
|
|
|
|
|
|
|
|
|
|
if (feecode == null)
|
|
|
|
isNoNotice = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var checkRlt = checkFeeArg.GroupJoin(queryFeeList, l => l, r => r.Name, (l, r) =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
var currFee = r.FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
if (currFee == null)
|
|
|
|
|
|
|
|
return new { Succ = false, Obj = l };
|
|
|
|
|
|
|
|
|
|
|
|
var newfee = new FeeRecord();
|
|
|
|
return new { Succ = true, Obj = l };
|
|
|
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
newfee.BusinessId = booking.Id;
|
|
|
|
if (checkRlt.Any(b => !b.Succ))
|
|
|
|
newfee.FeeId = feecode.Id;
|
|
|
|
{
|
|
|
|
newfee.FeeName = feecode.Name;
|
|
|
|
isStop = true;
|
|
|
|
newfee.FeeCode = feecode.Code;
|
|
|
|
reason = "费用名称不存在," + string.Join(",", checkRlt.Where(b => !b.Succ).Select(b => b.Obj).ToArray());
|
|
|
|
newfee.TaxRate = feecode.TaxRate == null ? 0 : (decimal)feecode.TaxRate;
|
|
|
|
|
|
|
|
newfee.BusinessType = BusinessType.OceanShippingExport;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string custShortName = string.Empty;
|
|
|
|
isNoNotice = true;
|
|
|
|
string custType = string.Empty;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (fee.CustSettleFor.IndexOf("#") >= 0)
|
|
|
|
if (!isStop)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
foreach (var fee in model.DetailList)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var currArg = fee.CustSettleFor.Split(new char[] { '#' });
|
|
|
|
string qFee = fee.CustSysName?.Trim();
|
|
|
|
custShortName = currArg[0]?.Trim();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (currArg.Length == 2)
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
custType = currArg.LastOrDefault().Trim();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
custShortName = fee.CustSettleFor?.Trim();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var customerInfo = tenantDb.Queryable<InfoClient>().ClearFilter(typeof(ISharedOrgId)).First(x => x.ShortName == custShortName);
|
|
|
|
var feecode = tenantDb.Queryable<FeeCode>().First(x => x.Name == qFee && x.IsSea == true);
|
|
|
|
|
|
|
|
|
|
|
|
newfee.CustomerId = customerInfo.Id;
|
|
|
|
if (feecode == null)
|
|
|
|
newfee.CustomerName = customerInfo.Description;
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(custType))
|
|
|
|
}
|
|
|
|
{
|
|
|
|
|
|
|
|
var custTypeKey = custTypeDict.FirstOrDefault(x => x.Value == custType);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
newfee.CustomerType = custTypeKey.Key;
|
|
|
|
var newfee = new FeeRecord();
|
|
|
|
newfee.CustomerTypeText = custTypeKey.Value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
newfee.BusinessId = booking.Id;
|
|
|
|
|
|
|
|
newfee.FeeId = feecode.Id;
|
|
|
|
|
|
|
|
newfee.FeeName = feecode.Name;
|
|
|
|
|
|
|
|
newfee.FeeCode = feecode.Code;
|
|
|
|
|
|
|
|
newfee.TaxRate = feecode.TaxRate == null ? 0 : (decimal)feecode.TaxRate;
|
|
|
|
|
|
|
|
newfee.BusinessType = BusinessType.OceanShippingExport;
|
|
|
|
|
|
|
|
|
|
|
|
newfee.FeeType = FeeType.Payable; //租箱月结明细.FeeType;
|
|
|
|
string custShortName = string.Empty;
|
|
|
|
|
|
|
|
string custType = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (fee.CustSettleFor.IndexOf("#") >= 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var currArg = fee.CustSettleFor.Split(new char[] { '#' });
|
|
|
|
|
|
|
|
custShortName = currArg[0]?.Trim();
|
|
|
|
|
|
|
|
|
|
|
|
var feeUnitKey = feeUnitDict.FirstOrDefault(x => x.Value == fee.CustFeeStandard?.Trim());
|
|
|
|
if (currArg.Length == 2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
custType = currArg.LastOrDefault().Trim();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
custShortName = fee.CustSettleFor?.Trim();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
newfee.Unit = feeUnitKey.Key;
|
|
|
|
var customerInfo = tenantDb.Queryable<InfoClient>().ClearFilter(typeof(ISharedOrgId)).First(x => x.ShortName == custShortName);
|
|
|
|
newfee.UnitText = feeUnitKey.Value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var currCurrCode = codeCurrency.First(a => a.CodeName == fee.CustCurrency);
|
|
|
|
newfee.CustomerId = customerInfo.Id;
|
|
|
|
|
|
|
|
newfee.CustomerName = customerInfo.Description;
|
|
|
|
|
|
|
|
|
|
|
|
newfee.Currency = currCurrCode.CodeName;
|
|
|
|
if (!string.IsNullOrWhiteSpace(custType))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var custTypeKey = custTypeDict.FirstOrDefault(x => x.Value == custType);
|
|
|
|
|
|
|
|
|
|
|
|
decimal qty = 0;
|
|
|
|
newfee.CustomerType = custTypeKey.Key;
|
|
|
|
|
|
|
|
newfee.CustomerTypeText = custTypeKey.Value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (fee.CustFeeStandard.Equals("箱"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var ctnSumList = ctnList.GroupBy(a => a.Ctn)
|
|
|
|
|
|
|
|
.Select(a => new { Key = a.Key, Code = a.ToList().FirstOrDefault().CtnCode, Num = a.Sum(b => b.CtnNum.HasValue ? b.CtnNum.Value : 1) }).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ctnSumList.Count == 1)
|
|
|
|
newfee.FeeType = FeeType.Payable; //租箱月结明细.FeeType;
|
|
|
|
{
|
|
|
|
|
|
|
|
newfee.Unit = ctnSumList.FirstOrDefault().Code;
|
|
|
|
|
|
|
|
newfee.UnitText = ctnSumList.FirstOrDefault().Key;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!fee.Quantity.HasValue)
|
|
|
|
|
|
|
|
{
|
|
|
|
var feeUnitKey = feeUnitDict.FirstOrDefault(x => x.Value == fee.CustFeeStandard?.Trim());
|
|
|
|
qty = ctnSumList.Sum(x => x.Num);
|
|
|
|
|
|
|
|
|
|
|
|
newfee.Unit = feeUnitKey.Key;
|
|
|
|
|
|
|
|
newfee.UnitText = feeUnitKey.Value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var currCurrCode = codeCurrency.First(a => a.CodeName == fee.CustCurrency);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
newfee.Currency = currCurrCode.CodeName;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
decimal qty = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (fee.CustFeeStandard.Equals("箱"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var ctnSumList = ctnList.GroupBy(a => a.Ctn)
|
|
|
|
|
|
|
|
.Select(a => new { Key = a.Key, Code = a.ToList().FirstOrDefault().CtnCode, Num = a.Sum(b => b.CtnNum.HasValue ? b.CtnNum.Value : 1) }).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ctnSumList.Count == 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
newfee.Unit = ctnSumList.FirstOrDefault().Code;
|
|
|
|
|
|
|
|
newfee.UnitText = ctnSumList.FirstOrDefault().Key;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!fee.Quantity.HasValue)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
qty = ctnSumList.Sum(x => x.Num);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
qty = fee.Quantity.Value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (fee.CustFeeStandard.Equals("票"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
qty = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!fee.UnitPrice.HasValue)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (fee.Amount.HasValue)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var price = fee.Amount.Value / qty;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
newfee.TaxUnitPrice = price;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
newfee.TaxUnitPrice = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
newfee.TaxUnitPrice = fee.UnitPrice.Value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (newfee.Currency.Equals("RMB", StringComparison.OrdinalIgnoreCase) || newfee.Currency.Equals("CNY", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
newfee.ExchangeRate = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (etd != DateTime.MinValue)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var exchangeInfo = tenantDb.Queryable<FeeCurrencyExchange>().ClearFilter(typeof(IOrgId))
|
|
|
|
|
|
|
|
.First(x => x.CurrencyCode == newfee.Currency && x.OrgId == booking.OrgId
|
|
|
|
|
|
|
|
&& x.StartDate.Value <= etd && x.EndDate.Value >= etd && x.LocalCurrency == "RMB");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (exchangeInfo == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
exchangeInfo = tenantDb.Queryable<FeeCurrencyExchange>().ClearFilter(typeof(IOrgId))
|
|
|
|
|
|
|
|
.First(x => x.CurrencyCode == newfee.Currency && x.StartDate.Value <= etd && x.EndDate.Value >= etd && x.LocalCurrency == "RMB");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (exchangeInfo != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
newfee.ExchangeRate = exchangeInfo.CRValue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
newfee.Quantity = qty;
|
|
|
|
|
|
|
|
newfee.Amount = fee.Amount.HasValue ? fee.Amount.Value : 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
newfee.CreateTime = nowDate;
|
|
|
|
|
|
|
|
newfee.CreateBy = userInfo.Id;
|
|
|
|
|
|
|
|
newfee.CreateUserName = userInfo.UserName;
|
|
|
|
|
|
|
|
newfee.UpdateTime = nowDate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//2024-11-08 按照董怡含要求,先不要默认审批通过,暂时关闭
|
|
|
|
|
|
|
|
//newfee.FeeStatus = FeeStatus.AuditPassed;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
newfee.Note = "大简云账单解析";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"写入账单开始 第【{start}】条 GID={model.GID} BookingBill={model.BookingBill} Order={JsonConvert.SerializeObject(newfee)}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tenantDb.Insertable<FeeRecord>(newfee).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"写入账单完成 第【{start}】条 GID={model.GID} BookingBill={model.BookingBill} Order={JsonConvert.SerializeObject(newfee)}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//入库成功
|
|
|
|
|
|
|
|
doResultDict.Add(fee.GID, new Tuple<string, bool>(qFee, true));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
qty = fee.Quantity.Value;
|
|
|
|
doResultDict.Add(fee.GID, new Tuple<string, bool>(qFee, false));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"明细写入产生异常,qFee={qFee} 原因:{ex.Message}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//callbackList.Add()
|
|
|
|
else if (fee.CustFeeStandard.Equals("票"))
|
|
|
|
start++;
|
|
|
|
{
|
|
|
|
|
|
|
|
qty = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果存在失败情况,回执失败
|
|
|
|
if (!fee.UnitPrice.HasValue)
|
|
|
|
if (doResultDict.Count(b => !b.Value.Item2) > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (fee.Amount.HasValue)
|
|
|
|
reason = "入库失败," + string.Join(",", doResultDict.Where(b => !b.Value.Item2).ToArray());
|
|
|
|
{
|
|
|
|
|
|
|
|
var price = fee.Amount.Value / qty;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
newfee.TaxUnitPrice = price;
|
|
|
|
SendCallBack(new SingleBillReceiveResult
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
newfee.TaxUnitPrice = 0;
|
|
|
|
ReceiveId = model.GID,
|
|
|
|
}
|
|
|
|
Success = false,
|
|
|
|
|
|
|
|
Reason = reason
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
newfee.TaxUnitPrice = fee.UnitPrice.Value;
|
|
|
|
//全部成功,推送成功回执
|
|
|
|
}
|
|
|
|
SendCallBack(new SingleBillReceiveResult
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ReceiveId = model.GID,
|
|
|
|
|
|
|
|
Success = true,
|
|
|
|
if (newfee.Currency.Equals("RMB", StringComparison.OrdinalIgnoreCase) || newfee.Currency.Equals("CNY", StringComparison.OrdinalIgnoreCase))
|
|
|
|
Reason = string.Empty
|
|
|
|
{
|
|
|
|
});
|
|
|
|
newfee.ExchangeRate = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!isNoNotice)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (etd != DateTime.MinValue)
|
|
|
|
SendCallBack(new SingleBillReceiveResult
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var exchangeInfo = tenantDb.Queryable<FeeCurrencyExchange>().ClearFilter(typeof(IOrgId))
|
|
|
|
ReceiveId = model.GID,
|
|
|
|
.First(x => x.CurrencyCode == newfee.Currency && x.OrgId == booking.OrgId
|
|
|
|
Success = false,
|
|
|
|
&& x.StartDate.Value <= etd && x.EndDate.Value >= etd && x.LocalCurrency == "RMB");
|
|
|
|
Reason = reason
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
SendCallBack(new SingleBillReceiveResult
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ReceiveId = model.GID,
|
|
|
|
|
|
|
|
Success = false,
|
|
|
|
|
|
|
|
Reason = "当前订单不存在"
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.LogInformation($"产生异常,原因:{ex.Message}");
|
|
|
|
|
|
|
|
|
|
|
|
if(exchangeInfo == null)
|
|
|
|
if (!string.IsNullOrWhiteSpace(gid))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
exchangeInfo = tenantDb.Queryable<FeeCurrencyExchange>().ClearFilter(typeof(IOrgId))
|
|
|
|
//SendCallBack(new SingleBillReceiveResult
|
|
|
|
.First(x => x.CurrencyCode == newfee.Currency && x.StartDate.Value <= etd && x.EndDate.Value >= etd && x.LocalCurrency == "RMB");
|
|
|
|
//{
|
|
|
|
}
|
|
|
|
// ReceiveId = gid,
|
|
|
|
|
|
|
|
// Success = false,
|
|
|
|
|
|
|
|
// Reason = "当前订单不存在"
|
|
|
|
|
|
|
|
//});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (exchangeInfo != null)
|
|
|
|
private void SendCallBack(SingleBillReceiveResult dto)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
newfee.ExchangeRate = exchangeInfo.CRValue;
|
|
|
|
_logger.LogInformation($"开始准备发送回执MQ json={JsonConvert.SerializeObject(dto)}");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
newfee.Quantity = qty;
|
|
|
|
var mqRlt = PublishMessage(new MQPublishMessageReqDto
|
|
|
|
newfee.Amount = fee.Amount.HasValue ? fee.Amount.Value : 0;
|
|
|
|
{
|
|
|
|
|
|
|
|
BusinessId = dto.ReceiveId,
|
|
|
|
|
|
|
|
IsZip = false,
|
|
|
|
|
|
|
|
json = JsonConvert.SerializeObject(dto),
|
|
|
|
|
|
|
|
mqUri = AppSetting.app(new string[] { "FeeCallBacSettings", "MQUrl" }),
|
|
|
|
|
|
|
|
mqExchangeName = AppSetting.app(new string[] { "FeeCallBacSettings", "ExchangeName" }),
|
|
|
|
|
|
|
|
mqQueueName = AppSetting.app(new string[] { "FeeCallBacSettings", "QueueName" })
|
|
|
|
|
|
|
|
}).GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"发送回执MQ完成,结果 json={JsonConvert.SerializeObject(mqRlt)}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
newfee.CreateTime = nowDate;
|
|
|
|
#region 发送MQ报文
|
|
|
|
newfee.CreateBy = userInfo.Id;
|
|
|
|
/// <summary>
|
|
|
|
newfee.CreateUserName = userInfo.UserName;
|
|
|
|
/// 发送MQ报文
|
|
|
|
newfee.UpdateTime = nowDate;
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="request">请求参数</param>
|
|
|
|
|
|
|
|
/// <returns>true-发送成功 false-发送失败</returns>
|
|
|
|
|
|
|
|
public async Task<string> PublishMessage(MQPublishMessageReqDto request)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bool isException = false;
|
|
|
|
|
|
|
|
string msg = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
//2024-11-08 按照董怡含要求,先不要默认审批通过,暂时关闭
|
|
|
|
try
|
|
|
|
//newfee.FeeStatus = FeeStatus.AuditPassed;
|
|
|
|
{
|
|
|
|
|
|
|
|
ConnectionFactory factory = new ConnectionFactory();
|
|
|
|
|
|
|
|
factory.Uri = new Uri(request.mqUri);
|
|
|
|
|
|
|
|
|
|
|
|
newfee.Note = "大简云账单解析";
|
|
|
|
using (IConnection conn = factory.CreateConnection())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"写入账单开始 第【{start}】条 GID={model.GID} BookingBill={model.BookingBill} Order={JsonConvert.SerializeObject(newfee)}");
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
IModel mqModel = conn.CreateModel();
|
|
|
|
|
|
|
|
mqModel.ExchangeDeclare(request.mqExchangeName, ExchangeType.Direct);
|
|
|
|
|
|
|
|
|
|
|
|
tenantDb.Insertable<FeeRecord>(newfee).ExecuteCommand();
|
|
|
|
//var queueName = $"{MqActionQueueName}.{(item.SubTenantId.HasValue && item.SubTenantId > 0 ? item.SubTenantId.Value : item.TenantId)}";
|
|
|
|
|
|
|
|
mqModel.QueueDeclare(request.mqQueueName, false, false, false, null);
|
|
|
|
|
|
|
|
mqModel.QueueBind(request.mqQueueName, request.mqExchangeName, request.mqQueueName, null);
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"写入账单完成 第【{start}】条 GID={model.GID} BookingBill={model.BookingBill} Order={JsonConvert.SerializeObject(newfee)}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//callbackList.Add()
|
|
|
|
byte[] messageBodyBytes = Encoding.UTF8.GetBytes(request.json);
|
|
|
|
start++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<SingleBillReceiveResult> callbackList = new List<SingleBillReceiveResult>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IBasicProperties props = mqModel.CreateBasicProperties();
|
|
|
|
|
|
|
|
props.DeliveryMode = 2;
|
|
|
|
|
|
|
|
mqModel.BasicPublish(request.mqExchangeName, request.mqQueueName, props, messageBodyBytes);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//发送回执
|
|
|
|
_logger.LogInformation($"Id:{request.BusinessId},订舱数据回推,已发送数据到消息队列【{request.mqUri}】,队列名称:【{request.mqQueueName}】");
|
|
|
|
//var jsonBody = Newtonsoft.Json.JsonConvert.SerializeObject(queryInfo, Formatting.Indented, new JsonSerializerSettings
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// NullValueHandling = NullValueHandling.Ignore
|
|
|
|
|
|
|
|
//});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//_logger.LogInformation($"请求MSK API查询船期请求,{jsonBody}");
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception inne)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.LogInformation($"Id:{request.BusinessId},推送MQ时发生异常,原因:{inne.Message}");
|
|
|
|
|
|
|
|
|
|
|
|
//var rlt = RequestHelper.Post(jsonBody, AppSetting.app(new string[] { "FeeSettings", "CallBackUrl" }));
|
|
|
|
msg = $"Id:{request.BusinessId},推送MQ时发生异常,原因:{inne.Message}";
|
|
|
|
////var rlt = await queryUrl.SetBody(jsonBody).PostAsStringAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//_logger.LogInformation($"请求MSK API查询船期请求,{jsonBody}");
|
|
|
|
isException = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
finally
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
conn.Close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogInformation($"产生异常,原因:{ex.Message}");
|
|
|
|
_logger.LogInformation($"Id:{request.BusinessId},启动推送MQ时发生异常,原因:{ex.Message}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
msg = $"Id:{request.BusinessId},启动推送MQ时发生异常,原因:{ex.Message}";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isException = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isException)
|
|
|
|
|
|
|
|
return msg;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return string.Empty;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
private FeeBillReadDto GetInfo(string json,out string msg)
|
|
|
|
private FeeBillReadDto GetInfo(string json,out string msg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|