From 82e919c00d65b0c6507dc2df8622845f44a11fef Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Wed, 19 Jun 2024 10:41:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=B7=E8=BF=90=E8=BE=BE=E5=9B=9E=E6=8E=A8?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=98=A0=E5=B0=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/OpenController.cs | 86 +++++++++++++++++-- 1 file changed, 78 insertions(+), 8 deletions(-) diff --git a/EntrustSettle.Api/Controllers/OpenController.cs b/EntrustSettle.Api/Controllers/OpenController.cs index af2c3f7..9ffd801 100644 --- a/EntrustSettle.Api/Controllers/OpenController.cs +++ b/EntrustSettle.Api/Controllers/OpenController.cs @@ -252,22 +252,42 @@ namespace EntrustSettle.Api.Controllers // 更新订单状态 bool isUpdate = false; var orderUpdateable = orderService.AsUpdateable(); - if (input.status != null && input.status != order.Status) + + // 海运达正式环境上线后才提出:只有已接单和已完结两种状态,所以这里做了映射 + if (input.status is 0 or 1 && input.status != order.Status) { isUpdate = true; order.Status = input.status; - orderUpdateable.SetColumns(x => x.Status == input.status); + orderUpdateable.SetColumns(x => x.Status == order.Status); + + // 记录订单状态变更历史 + await orderHistoryService.Add(new OrderHistory() + { + Pid = order.Id, + Status = (int)order.Status, + StatusTime = DateTime.Now, + CreateBy = "系统", + Remark = "(状态接收)" + }); + } + else if (input.status == 4 && order.Status != 2) + { + isUpdate = true; + order.Status = 2; + orderUpdateable.SetColumns(x => x.Status == 2); // 记录订单状态变更历史 await orderHistoryService.Add(new OrderHistory() { Pid = order.Id, - Status = (int)input.status, + Status = 2, StatusTime = DateTime.Now, CreateBy = "系统", Remark = "(状态接收)" }); } + + if (isHasBill) { isUpdate = true; @@ -293,7 +313,7 @@ namespace EntrustSettle.Api.Controllers MessageDesc = "状态更新推送", Remark = "", Status = order.Status ?? 0, - StatusDesc = input.status switch + StatusDesc = order.Status switch { 0 => "已下单", 1 => "已接单", @@ -481,6 +501,7 @@ namespace EntrustSettle.Api.Controllers // 更新订单状态 await orderService.AsUpdateable() .SetColumns(x => x.IsApplyInvoice == false) + .SetColumns(x => x.Status == 4) // 2024.6.18 上线后提出需求:收到海运达发票后,订单状态改为已完结 .Where(x => waitSendOrderIdList.Contains(x.Id)) .ExecuteCommandAsync(); @@ -493,9 +514,10 @@ namespace EntrustSettle.Api.Controllers x.CompanyId, x.MailBillNo, x.MailFlag, + x.Status, }).ToListAsync(); - var logTitle = $"Id列表:[{string.Join(',', orderInfoList.Select(x => x.Id))}],提单号列表:[{string.Join(',', orderInfoList.Select(x => x.Mblno))}],将每一票所有的发票推送队列"; + var logTitle = $"Id列表:[{string.Join(',', orderInfoList.Select(x => x.Id))}],提单号列表:[{string.Join(',', orderInfoList.Select(x => x.Mblno))}],将每一票所有的发票及已完结状态推送队列"; logger.LogInformation(logTitle); try { @@ -512,7 +534,8 @@ namespace EntrustSettle.Api.Controllers var logItemTitle = $"Id:[{item.Id}],提单号:[{item.Mblno}],附件Id列表:[({string.Join(',', invoiceAnnexIdList)})]开始推送队列"; - BillPushDto pushDto = new() + // 推送发票 + BillPushDto pushDto1 = new() { MessageType = 3, MessageDesc = "发票附件信息推送", @@ -523,11 +546,58 @@ namespace EntrustSettle.Api.Controllers MailBillNo = item.MailBillNo, }; - var json = JsonConvert.SerializeObject(pushDto, Formatting.Indented, new JsonSerializerSettings() + var json1 = JsonConvert.SerializeObject(pushDto1, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); - queueService.Push(logItemTitle, orderInfoList.FirstOrDefault().CompanyId, json); + queueService.Push(logItemTitle, item.CompanyId, json1); + + // 推送状态 + StatusPushDto pushDto2 = new() + { + OrderId = item.Id, + Mblno = item.Mblno, + MessageType = 1, + MessageDesc = "状态更新推送", + Remark = "", + Status = item.Status ?? 0, + StatusDesc = item.Status switch + { + 0 => "已下单", + 1 => "已接单", + 2 => "待缴费", + 3 => "已缴费", + 4 => "已完结", + _ => "未知状态", + } + }; + var feeList = orderFeeService.AsQueryable().Where(x => x.OrderId == item.Id).ToList(); + if (feeList.Count > 0) + { + pushDto2.FeeList = feeList.Select(x => new StatusPushDto.FeeDto() + { + FeeId = x.Id, + FeeName = x.Name, + FeeAmount = x.Amount + }).ToList(); + } + var annexList = orderAnnexService.AsQueryable() + .LeftJoin((o, a) => o.AnnexId == a.Id) + .Where((o, a) => o.OrderId == item.Id && a.Type == 5) + .Select((o, a) => a) + .ToList(); + if (annexList.Count > 0) + { + pushDto2.FeebackAnnexList = annexList.Select(x => new StatusPushDto.FeebackAnnex() + { + Id = x.Id, + BusinessTime = x.BusinessTime, + FileName = x.Name, + Remark = x.Remark + }).ToList(); + } + var json2 = JsonConvert.SerializeObject(pushDto2, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); + queueService.Push(logTitle, item.CompanyId, json2); } } catch (Exception ex)