From bdc28d88a168872a21fc7d3ff81d5cd5d144431b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=94=A6=E9=BA=9F=20=E7=8E=8B?= Date: Wed, 15 Apr 2026 15:56:13 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E4=B9=A6=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E5=8F=91=E9=80=81=E9=80=BB=E8=BE=91=EF=BC=8C=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E6=94=B9=E4=B8=BAtradeId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SwapModule/SwapEndConfirmService.cs | 27 +++++++++++++++++-- YLErpWeb/Controllers/SwapTrade2Controller.cs | 4 +-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/YLErpDAL/Modules/SwapModule/SwapEndConfirmService.cs b/YLErpDAL/Modules/SwapModule/SwapEndConfirmService.cs index 3b1a1c8a..8ddb7786 100644 --- a/YLErpDAL/Modules/SwapModule/SwapEndConfirmService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapEndConfirmService.cs @@ -169,19 +169,42 @@ namespace YLErp.Modules.SwapModule /// /// /// - public string SendConfirmEamil(string contractCode) + /// + public string SendConfirmEamil(int tradeId) + { + var tradeContract = DbContext.trade_contract_r.Where(x => x.IsValid && x.TradeId == tradeId && x.Type == ContractTypeEnum.Trade).FirstOrDefault(); + if (tradeContract == null) + { + return ""; + } + tradeContract.send_email_result = "发送中"; + DbContext.SaveChanges(); + var sendResult = SendEmail(tradeContract.ContractCode); + if (string.IsNullOrEmpty(sendResult)) + { + tradeContract.send_email_result = "已发送"; + } + else + { + tradeContract.send_email_result = "发送失败:" + sendResult; + } + DbContext.SaveChanges(); + return string.IsNullOrEmpty(sendResult) ? "已发送" : "发送失败:" + sendResult; + } + public string SendConfirmEamil(string ContractCode) { //var tradeContract = DbContext.trade_contract_r.Where(x => x.IsValid && x.TradeId == tradeId && x.Type == ContractTypeEnum.Trade).FirstOrDefault(); //if (tradeContract == null) //{ // return ""; //} - var contracts = DbContext.trade_contract_r.Where(o => o.ContractCode == contractCode && o.Type == ContractTypeEnum.Trade && o.IsValid).ToArray(); + var contracts = DbContext.trade_contract_r.Where(o => o.ContractCode == ContractCode && o.Type == ContractTypeEnum.Trade && o.IsValid).ToArray(); foreach (var tradeContract in contracts) { tradeContract.send_email_result = "发送中"; DbContext.SaveChanges(); } + var contractCode = contracts.FirstOrDefault()?.ContractCode; var sendResult = SendEmail(contractCode); foreach (var tradeContract in contracts) diff --git a/YLErpWeb/Controllers/SwapTrade2Controller.cs b/YLErpWeb/Controllers/SwapTrade2Controller.cs index d2d53680..03bac4c3 100644 --- a/YLErpWeb/Controllers/SwapTrade2Controller.cs +++ b/YLErpWeb/Controllers/SwapTrade2Controller.cs @@ -1078,10 +1078,10 @@ namespace YLErp.Web.Controllers /// /// /// - public JsonResult SendConfimEmail(string contractCode) + public JsonResult SendConfimEmail(int tradeId) { SwapEndConfirmService service = new SwapEndConfirmService(CurUser); - var result = service.SendConfirmEamil(contractCode); + var result = service.SendConfirmEamil(tradeId); return JsonSuccess(result); }