提单号校验重复、运踪订阅校验重复

master
zhangxiaofeng 5 months ago
parent 51061961b6
commit 309df7a2dd

@ -273,6 +273,13 @@ namespace EntrustSettle.Api.Controllers
inputDto.MblnoList = inputDto.MblnoList.Where(x => !string.IsNullOrWhiteSpace(x)).Select(x => x.Trim()).ToArray();
StringHelper.TrimStringProperties(inputDto);
// 提单号校验重复
var existsMblnoList = await orderService.Query(x => inputDto.MblnoList.Contains(x.Mblno), x => x.Mblno);
if (existsMblnoList.Any())
{
throw new Exception($"下列提单号已存在,无需重复下单:{string.Join("", existsMblnoList)}");
}
// 查询税号
var custBalanceService = App.GetService<IBaseServices<CompanyNew>>();
var taxCode = await custBalanceService.Db.Queryable<CompanyNew>().Where(x => x.CompId == inputDto.CompanyId).Select(x => x.TaxCode).FirstAsync();
@ -281,27 +288,32 @@ namespace EntrustSettle.Api.Controllers
var billtraceList = new List<OpSeaiBillTrace>(inputDto.MblnoList.Length);
foreach (var item in inputDto.MblnoList)
{
var billtrace = new OpSeaiBillTrace
var billtraceGid = await billtraceService.QueryFirst(x => x.MBLNO == item && x.CompID == inputDto.CompanyId && x.IsOuter, x => x.GID);
if (billtraceGid == null)
{
GID = Guid.NewGuid().ToString(),
UserID = App.User.ID,
UserName = App.User.Name,
CompID = inputDto.CompanyId,
CompName = inputDto.CompanyName,
MBLNO = item,
StaCangDan = "N",
StaHaiGuan = "N",
StaTiHuo = "N",
StaFanKong = "N",
IsOuter = true,
CreateTime = DateTime.Now
};
billtraceList.Add(billtrace);
billtraceGid = Guid.NewGuid().ToString();
var billtrace = new OpSeaiBillTrace
{
GID = billtraceGid,
UserID = App.User.ID,
UserName = App.User.Name,
CompID = inputDto.CompanyId,
CompName = inputDto.CompanyName,
MBLNO = item,
StaCangDan = "N",
StaHaiGuan = "N",
StaTiHuo = "N",
StaFanKong = "N",
IsOuter = true,
CreateTime = DateTime.Now
};
billtraceList.Add(billtrace);
}
var order = new Order
{
Mblno = item,
BilltraceGid = billtrace.GID,
BilltraceGid = billtraceGid,
CompanyId = inputDto.CompanyId,
CompanyName = inputDto.CompanyName,
TaxCode = taxCode,
@ -360,7 +372,7 @@ namespace EntrustSettle.Api.Controllers
unitOfWorkManage.CommitTran();
// 保存到运踪表中
await billtraceService.Add(billtraceList);
await billtraceService.AsInsertable(billtraceList).ExecuteCommandAsync();
// 查询所有待处理订单列表
var pendingOrderList = await orderService.Query(x => x.IsSend == false && orderIdList.Contains(x.Id));

@ -189,7 +189,7 @@
"ConnId": "BillTrace",
"DBType": 1,
"Enabled": true,
"Connection": "172.31.85.161,1433;Database=BillTrace;User=sa;Password=QDdjy#2020*;MultipleActiveResultSets=True;"
"Connection": "Server=172.31.85.161,1433;Database=BillTrace;User=sa;Password=QDdjy#2020*;MultipleActiveResultSets=True;"
}
],
"Mongo": {

@ -44,14 +44,14 @@ namespace EntrustSettle.IServices.Base
#region 新增
IInsertable<TEntity> AsInsertable(TEntity model);
IInsertable<TEntity> AsInsertable(params TEntity[] entities);
IInsertable<TEntity> AsInsertable(List<TEntity> listEntity);
Task<long> Add(TEntity model);
Task<List<long>> Add(List<TEntity> listEntity);
#endregion
#region 删除
Task<bool> Delete(Expression<Func<TEntity, bool>> whereExpression);
Task<bool> Delete(Expression<Func<TEntity, bool>> whereExpression);
Task<bool> DeleteById(object id);
Task<bool> Delete(TEntity model);
Task<bool> DeleteByIds(object[] ids);

@ -120,9 +120,9 @@ namespace EntrustSettle.Services.Base
{
return Db.Insertable(model);
}
public IInsertable<TEntity> AsInsertable(params TEntity[] entities)
public IInsertable<TEntity> AsInsertable(List<TEntity> listEntity)
{
return Db.Insertable(entities);
return Db.Insertable(listEntity);
}
public async Task<long> Add(TEntity entity)
{

Loading…
Cancel
Save