From 8ffda541b48cbf619f8493196da4fb44d4f3ddc5 Mon Sep 17 00:00:00 2001 From: sunpengfei <i@angelzzz.com> Date: 星期五, 05 九月 2025 10:22:55 +0800 Subject: [PATCH] feat:开发 --- FlexJobApi.Core/Jobs/RefreshEnterpriseWalletTransactionStatusJob.cs | 115 ++++++++++++++++++++++++++++++--------------------------- 1 files changed, 60 insertions(+), 55 deletions(-) diff --git a/FlexJobApi.Core/Jobs/RefreshEnterpriseWalletTransactionStatusJob.cs b/FlexJobApi.Core/Jobs/RefreshEnterpriseWalletTransactionStatusJob.cs index bfa894c..19c6efc 100644 --- a/FlexJobApi.Core/Jobs/RefreshEnterpriseWalletTransactionStatusJob.cs +++ b/FlexJobApi.Core/Jobs/RefreshEnterpriseWalletTransactionStatusJob.cs @@ -1,4 +1,5 @@ 锘縰sing Aop.Api.Domain; +using Furion; using Furion.DatabaseAccessor; using Furion.FriendlyException; using Furion.Schedule; @@ -25,70 +26,74 @@ public async Task ExecuteAsync(JobExecutingContext context, CancellationToken stoppingToken) { - var entities = await rep.AsQueryable() + var env = App.GetConfig<string>("Environment"); + if (env != "Local") + { + var entities = await rep.AsQueryable() .Where(it => it.TransactionStatus == EnumEnterpriseWalletTransactionStatus.WaitPay || it.TransactionStatus == EnumEnterpriseWalletTransactionStatus.Dealing) .ToListAsync(); - if (entities.IsNotNull()) - { - foreach (var entity in entities) + if (entities.IsNotNull()) { - var response = alipayUtils.FundTransCommonQuery(new Aop.Api.Domain.AlipayFundTransCommonQueryModel + foreach (var entity in entities) { - ProductCode = entity.ProductCode, - BizScene = entity.BizScene, - OutBizNo = entity.Code - }); - if (response.IsError) throw Oops.Oh(EnumErrorCodeType.s510, response.SubMsg ?? response.Msg); - entity.OrderId = response.OrderId; - entity.InflowSettleSerialNo = response.InflowSettleSerialNo; - entity.SettleSerialNo = response.SettleSerialNo; - entity.ReceiverOpenId = response.ReceiverOpenId; - entity.ReceiverUserId = response.ReceiverUserId; - entity.PayFundOrderId = response.PayFundOrderId; - entity.ArrivalTimeEnd = response.ArrivalTimeEnd.ToDateTime(); - entity.OrderFee = response.OrderFee.ToDecimal(); - entity.ErrorCode = response.ErrorCode; - entity.FailReason = response.FailReason; - entity.FailInstReason = response.FailInstReason; - entity.FailInstName = response.FailInstName; - entity.FailInstErrorCode = response.FailInstErrorCode; - entity.SubStatus = response.SubStatus; - entity.TransDate = response.PayDate.ToDateTime(); - entity.Status = response.Status; - entity.TransactionStatus = response.Status == "SUCCESS" - ? EnumEnterpriseWalletTransactionStatus.Success - : response.Status == "DEALING" - ? EnumEnterpriseWalletTransactionStatus.Dealing - : response.Status == "REFUND" - ? EnumEnterpriseWalletTransactionStatus.Refund - : response.Status == "FAIL" - ? EnumEnterpriseWalletTransactionStatus.Fail - : throw Oops.Oh(EnumErrorCodeType.s510, $"鏈瘑鍒殑鐘舵�侊細{response.Status}"); - await rep.UpdateAsync(entity); - } - var walletIds = entities - .Where(it => it.TransactionStatus == EnumEnterpriseWalletTransactionStatus.Success) - .Select(it => it.WalletId) - .Distinct() - .ToList(); - if (walletIds.IsNotNull()) - { - var wallets = await repEnterpriseWallet.AsQueryable() - .Where(it => walletIds.Contains(it.Id)) - .ToListAsync(); - foreach (var wallet in wallets) - { - var response = alipayUtils.FundAccountbookQuery(new AlipayFundAccountbookQueryModel + var response = alipayUtils.FundTransCommonQuery(new Aop.Api.Domain.AlipayFundTransCommonQueryModel { - AccountBookId = wallet.AccountBookId, - SceneCode = "SATF_FUND_BOOK", - MerchantUserId = wallet.Code, + ProductCode = entity.ProductCode, + BizScene = entity.BizScene, + OutBizNo = entity.Code }); if (response.IsError) throw Oops.Oh(EnumErrorCodeType.s510, response.SubMsg ?? response.Msg); - wallet.Balance = response.AvailableAmount.ToDecimal() ?? 0; - await repEnterpriseWallet.UpdateAsync(wallet); + entity.OrderId = response.OrderId; + entity.InflowSettleSerialNo = response.InflowSettleSerialNo; + entity.SettleSerialNo = response.SettleSerialNo; + entity.ReceiverOpenId = response.ReceiverOpenId; + entity.ReceiverUserId = response.ReceiverUserId; + entity.PayFundOrderId = response.PayFundOrderId; + entity.ArrivalTimeEnd = response.ArrivalTimeEnd.ToDateTime(); + entity.OrderFee = response.OrderFee.ToDecimal(); + entity.ErrorCode = response.ErrorCode; + entity.FailReason = response.FailReason; + entity.FailInstReason = response.FailInstReason; + entity.FailInstName = response.FailInstName; + entity.FailInstErrorCode = response.FailInstErrorCode; + entity.SubStatus = response.SubStatus; + entity.TransDate = response.PayDate.ToDateTime(); + entity.Status = response.Status; + entity.TransactionStatus = response.Status == "SUCCESS" + ? EnumEnterpriseWalletTransactionStatus.Success + : response.Status == "DEALING" + ? EnumEnterpriseWalletTransactionStatus.Dealing + : response.Status == "REFUND" + ? EnumEnterpriseWalletTransactionStatus.Refund + : response.Status == "FAIL" + ? EnumEnterpriseWalletTransactionStatus.Fail + : throw Oops.Oh(EnumErrorCodeType.s510, $"鏈瘑鍒殑鐘舵�侊細{response.Status}"); + await rep.UpdateAsync(entity); + } + var walletIds = entities + .Where(it => it.TransactionStatus == EnumEnterpriseWalletTransactionStatus.Success) + .Select(it => it.WalletId) + .Distinct() + .ToList(); + if (walletIds.IsNotNull()) + { + var wallets = await repEnterpriseWallet.AsQueryable() + .Where(it => walletIds.Contains(it.Id)) + .ToListAsync(); + foreach (var wallet in wallets) + { + var response = alipayUtils.FundAccountbookQuery(new AlipayFundAccountbookQueryModel + { + AccountBookId = wallet.AccountBookId, + SceneCode = "SATF_FUND_BOOK", + MerchantUserId = wallet.Code, + }); + if (response.IsError) throw Oops.Oh(EnumErrorCodeType.s510, response.SubMsg ?? response.Msg); + wallet.Balance = response.AvailableAmount.ToDecimal() ?? 0; + await repEnterpriseWallet.UpdateAsync(wallet); + } } } } -- Gitblit v1.9.1