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/RefreshEnterpriseWalletStatusJob.cs |  151 ++++++++++++++++++++++++++------------------------
 1 files changed, 78 insertions(+), 73 deletions(-)

diff --git a/FlexJobApi.Core/Jobs/RefreshEnterpriseWalletStatusJob.cs b/FlexJobApi.Core/Jobs/RefreshEnterpriseWalletStatusJob.cs
index bc174a2..7a2b393 100644
--- a/FlexJobApi.Core/Jobs/RefreshEnterpriseWalletStatusJob.cs
+++ b/FlexJobApi.Core/Jobs/RefreshEnterpriseWalletStatusJob.cs
@@ -1,4 +1,5 @@
 锘縰sing Aop.Api.Domain;
+using Furion;
 using Furion.DatabaseAccessor;
 using Furion.FriendlyException;
 using Furion.Schedule;
@@ -24,92 +25,96 @@
         [UnitOfWork(false)]
         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()
                 .Include(it => it.Enterprise)
                 .Where(it =>
                     it.Access == EnumEnterpriseWalletAccess.Alipay
                     && (it.SignStatus == EnumEnterpriseWalletSignStatus.Apply
                     || it.AccountBookStatus == null))
                 .ToListAsync();
-            foreach (var entity in entities)
-            {
-                var update = false;
-                if (entity.Access == EnumEnterpriseWalletAccess.Alipay)
+                foreach (var entity in entities)
                 {
-                    if (entity.SignStatus == EnumEnterpriseWalletSignStatus.Apply)
+                    var update = false;
+                    if (entity.Access == EnumEnterpriseWalletAccess.Alipay)
                     {
-                        var response = alipayUtils.UserAgreementQuery(new Aop.Api.Domain.AlipayUserAgreementQueryModel
+                        if (entity.SignStatus == EnumEnterpriseWalletSignStatus.Apply)
                         {
-                            PersonalProductCode = entity.PersonalProductCode,
-                            SignScene = entity.SignScene,
-                            ExternalAgreementNo = entity.Code,
-                            ThirdPartyType = entity.ThirdPartyType,
-                        });
-                        if (response.IsError) throw Oops.Oh(EnumErrorCodeType.s510, response.SubMsg ?? response.Msg);
-                        entity.AgreementNo = response.AgreementNo;
-                        entity.SignTime = response.SignTime.ToDateTime();
-                        entity.ValidTime = response.ValidTime.ToDateTime();
-                        entity.InvalidTime = response.InvalidTime.ToDateTime();
-                        entity.SignStatus = response.Status == "TEMP"
-                            ? EnumEnterpriseWalletSignStatus.Apply
-                            : response.Status == "NORMAL"
-                            ? EnumEnterpriseWalletSignStatus.Normal
-                            : response.Status == "STOP"
-                            ? EnumEnterpriseWalletSignStatus.Stop
-                            : throw Oops.Oh(EnumErrorCodeType.s510, "鐘舵�佸紓甯�");
-                        entity.PricipalType = response.PricipalType;
-                        entity.AlipayLogonId = response.AlipayLogonId;
-                        entity.PrincipalId = response.PrincipalId;
-                        entity.PrincipalOpenId = response.PrincipalOpenId;
-                        entity.ZmOpenId = response.ZmOpenId;
-                        entity.CreditAuthMode = response.CreditAuthMode;
-                        update = true;
-                    }
-
-                    if (entity.SignStatus == EnumEnterpriseWalletSignStatus.Normal && entity.AccountBookStatus != EnumEnterpriseWalletAccountBookStatus.Normal)
-                    {
-                        var response = alipayUtils.FundAccountbookCreate(new Aop.Api.Domain.AlipayFundAccountbookCreateModel
-                        {
-                            MerchantUserId = entity.Code,
-                            MerchantUserType = "BUSINESS_ORGANIZATION",
-                            SceneCode = "SATF_FUND_BOOK",
-                            ExtInfo = new
+                            var response = alipayUtils.UserAgreementQuery(new Aop.Api.Domain.AlipayUserAgreementQueryModel
                             {
-                                agreement_no = entity.AgreementNo,
-                                cert_no = entity.Enterprise.SocietyCreditCode
-                            }.ToJson()
-                        });
-                        if (response.IsError) throw Oops.Oh(EnumErrorCodeType.s510, response.SubMsg ?? response.Msg);
-                        entity.AccountBookId = response.AccountBookId;
-                        entity.BankAccName = response.ExtCardInfo.BankAccName;
-                        entity.CardBank = response.ExtCardInfo.CardBank;
-                        entity.CardBranch = response.ExtCardInfo.CardBranch;
-                        entity.CardDeposit = response.ExtCardInfo.CardDeposit;
-                        entity.CardLocation = response.ExtCardInfo.CardLocation;
-                        entity.CardNo = response.ExtCardInfo.CardNo;
-                        entity.AccountBookStatus = response.ExtCardInfo.Status == "A"
-                            ? EnumEnterpriseWalletAccountBookStatus.Normal
-                            : EnumEnterpriseWalletAccountBookStatus.Exception;
-                        update = true;
-                    }
+                                PersonalProductCode = entity.PersonalProductCode,
+                                SignScene = entity.SignScene,
+                                ExternalAgreementNo = entity.Code,
+                                ThirdPartyType = entity.ThirdPartyType,
+                            });
+                            if (response.IsError) throw Oops.Oh(EnumErrorCodeType.s510, response.SubMsg ?? response.Msg);
+                            entity.AgreementNo = response.AgreementNo;
+                            entity.SignTime = response.SignTime.ToDateTime();
+                            entity.ValidTime = response.ValidTime.ToDateTime();
+                            entity.InvalidTime = response.InvalidTime.ToDateTime();
+                            entity.SignStatus = response.Status == "TEMP"
+                                ? EnumEnterpriseWalletSignStatus.Apply
+                                : response.Status == "NORMAL"
+                                ? EnumEnterpriseWalletSignStatus.Normal
+                                : response.Status == "STOP"
+                                ? EnumEnterpriseWalletSignStatus.Stop
+                                : throw Oops.Oh(EnumErrorCodeType.s510, "鐘舵�佸紓甯�");
+                            entity.PricipalType = response.PricipalType;
+                            entity.AlipayLogonId = response.AlipayLogonId;
+                            entity.PrincipalId = response.PrincipalId;
+                            entity.PrincipalOpenId = response.PrincipalOpenId;
+                            entity.ZmOpenId = response.ZmOpenId;
+                            entity.CreditAuthMode = response.CreditAuthMode;
+                            update = true;
+                        }
 
-                    if (entity.AccountBookStatus == EnumEnterpriseWalletAccountBookStatus.Normal)
-                    {
-                        var response = alipayUtils.FundAccountbookQuery(new AlipayFundAccountbookQueryModel
+                        if (entity.SignStatus == EnumEnterpriseWalletSignStatus.Normal && entity.AccountBookStatus != EnumEnterpriseWalletAccountBookStatus.Normal)
                         {
-                            AccountBookId = entity.AccountBookId,
-                            SceneCode = "SATF_FUND_BOOK",
-                            MerchantUserId = entity.Code,
-                        });
-                        if (response.IsError) throw Oops.Oh(EnumErrorCodeType.s510, response.SubMsg ?? response.Msg);
-                        entity.Balance = response.AvailableAmount.ToDecimal() ?? 0;
-                        update = true;
-                    }
-                }
+                            var response = alipayUtils.FundAccountbookCreate(new Aop.Api.Domain.AlipayFundAccountbookCreateModel
+                            {
+                                MerchantUserId = entity.Code,
+                                MerchantUserType = "BUSINESS_ORGANIZATION",
+                                SceneCode = "SATF_FUND_BOOK",
+                                ExtInfo = new
+                                {
+                                    agreement_no = entity.AgreementNo,
+                                    cert_no = entity.Enterprise.SocietyCreditCode
+                                }.ToJson()
+                            });
+                            if (response.IsError) throw Oops.Oh(EnumErrorCodeType.s510, response.SubMsg ?? response.Msg);
+                            entity.AccountBookId = response.AccountBookId;
+                            entity.BankAccName = response.ExtCardInfo.BankAccName;
+                            entity.CardBank = response.ExtCardInfo.CardBank;
+                            entity.CardBranch = response.ExtCardInfo.CardBranch;
+                            entity.CardDeposit = response.ExtCardInfo.CardDeposit;
+                            entity.CardLocation = response.ExtCardInfo.CardLocation;
+                            entity.CardNo = response.ExtCardInfo.CardNo;
+                            entity.AccountBookStatus = response.ExtCardInfo.Status == "A"
+                                ? EnumEnterpriseWalletAccountBookStatus.Normal
+                                : EnumEnterpriseWalletAccountBookStatus.Exception;
+                            update = true;
+                        }
 
-                if (update)
-                {
-                    await rep.UpdateAsync(entity);
+                        if (entity.AccountBookStatus == EnumEnterpriseWalletAccountBookStatus.Normal)
+                        {
+                            var response = alipayUtils.FundAccountbookQuery(new AlipayFundAccountbookQueryModel
+                            {
+                                AccountBookId = entity.AccountBookId,
+                                SceneCode = "SATF_FUND_BOOK",
+                                MerchantUserId = entity.Code,
+                            });
+                            if (response.IsError) throw Oops.Oh(EnumErrorCodeType.s510, response.SubMsg ?? response.Msg);
+                            entity.Balance = response.AvailableAmount.ToDecimal() ?? 0;
+                            update = true;
+                        }
+                    }
+
+                    if (update)
+                    {
+                        await rep.UpdateAsync(entity);
+                    }
                 }
             }
         }

--
Gitblit v1.9.1