From 45eed8f2f6b197f880143838589e9f8aa6b04921 Mon Sep 17 00:00:00 2001 From: TS-QD1 Date: Thu, 24 Apr 2025 19:51:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=85=E5=80=BCBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/AccountRechargeServiceImpl.java | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/src/main/java/cn/com/tenlion/operator/service/accountrecharge/impl/AccountRechargeServiceImpl.java b/src/main/java/cn/com/tenlion/operator/service/accountrecharge/impl/AccountRechargeServiceImpl.java index c6b13bc..701a663 100644 --- a/src/main/java/cn/com/tenlion/operator/service/accountrecharge/impl/AccountRechargeServiceImpl.java +++ b/src/main/java/cn/com/tenlion/operator/service/accountrecharge/impl/AccountRechargeServiceImpl.java @@ -8,8 +8,11 @@ import cn.com.tenlion.operator.pojo.dtos.account.AccountDTO; import cn.com.tenlion.operator.pojo.dtos.accountbank.AccountBankDTO; import cn.com.tenlion.operator.pojo.dtos.accountrecharge.AccountRechargePayDTO; import cn.com.tenlion.operator.pojo.dtos.accountrecharge.AccountRechargePayResultDTO; +import cn.com.tenlion.operator.pojo.dtos.accountrecharge.AccountRechargeWxPrepayDTO; import cn.com.tenlion.operator.pojo.dtos.ic.UsericDTO; +import cn.com.tenlion.operator.pojo.pos.user.expand.UserExpandPO; import cn.com.tenlion.operator.pojo.vos.accountitem.AccountItemVO; +import cn.com.tenlion.operator.pojo.vos.accountrecharge.AccountRechargeWxPrepayVO; import cn.com.tenlion.operator.properties.SystemApiPathProperties; import cn.com.tenlion.operator.remote.IOperatorPluginRemoteService; import cn.com.tenlion.operator.remote.PackageInfoDTO; @@ -20,6 +23,7 @@ import cn.com.tenlion.operator.service.accountbank.IAccountBankService; import cn.com.tenlion.operator.service.accountitem.IAccountItemService; import cn.com.tenlion.operator.service.remote.IRemoteWangGengInvoiceService; import cn.com.tenlion.operator.service.sys.callback.SysCallbackService; +import cn.com.tenlion.operator.service.user.expand.UserExpandServiceImpl; import cn.com.tenlion.operator.util.TenlionSMS; import cn.com.tenlion.operator.util.UserUtil; import cn.com.tenlion.operator.util.pay.ALiPay; @@ -92,6 +96,8 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA private SystemApiPathProperties systemApiPathProperties; @Autowired private IOperatorPluginRemoteService operatorPluginRemoteService; + @Autowired + private UserExpandServiceImpl userExpandServiceImpl; @Override public void save(AccountRechargeVO accountRechargeVO) { @@ -484,6 +490,72 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA return payDTO; } + /** + * 获取预支付ID + * + * @param accountRechargeWxPrepayVO + * @return + */ + @Override + public AccountRechargeWxPrepayDTO saveWxMiniappPayPrepayId(AccountRechargeWxPrepayVO accountRechargeWxPrepayVO) { + String userId = securityComponent.getCurrentUser().getUserId(); + UserExpandPO po = userExpandServiceImpl.getPO(userId); + if (po == null) { + throw new SearchException("用户小程序信息不存在"); + } + if (StringUtils.isBlank(po.getWxMiniappOpenId())) { + throw new SearchException("用户未绑定微信小程序"); + } + AccountRechargeVO accountRechargeVO = new AccountRechargeVO(); + accountRechargeVO.setUserId(userId); + accountRechargeVO.setThirdParty("微信"); + accountRechargeVO.setAccountId(userId); + accountRechargeVO.setRechargeCheck(RechargeCheckEnum.UN_RECHARGE.getValue()); + accountRechargeVO.setReconciliationStatus(ReconciliationStatusEnum.UN_RECONCILIATION.getValue()); + accountRechargeVO.setRechargeMoney(accountRechargeWxPrepayVO.getRechargeMoney()); + accountRechargeVO.setPackageInfoId(accountRechargeWxPrepayVO.getPackageInfoId()); + String accountRechargeId = getUUID("wx"); + Integer totalMoney = PayUtil.buiderMoney(accountRechargeVO.getRechargeMoney()); + String currentDate = DateUtil.getTime(); + + Map params = HashMapUtil.beanToMap(accountRechargeVO); + params.put("userId", userId); + params.put("rechargeType", RechargeTypeEnum.ONLINE.getValue()); + params.put("accountRechargeId", accountRechargeId); + params.put("rechargeFinalTime", currentDate); + params.put("creator", userId); + params.put("gmtCreate", currentDate); + params.put("modifier", userId); + params.put("gmtModified", currentDate); + params.put("isDelete", 0); + accountRechargeDao.save(params); + savePackageInfo(accountRechargeId, accountRechargeVO); + return WXPay.createPrepayId(po.getWxMiniappOpenId(), accountRechargeId, totalMoney, ProjectConfigUtil.getText("RechargePayTitle")); + } + + /** + * 保存套餐包记录 + * + * @param accountRechargeId + * @param accountRechargeVO + */ + private void savePackageInfo(String accountRechargeId, AccountRechargeVO accountRechargeVO) { + // 创建套餐包购买记录 + if (!StringUtils.isEmpty(accountRechargeVO.getPackageInfoId())) { + PackageOrderAppVO appVO = new PackageOrderAppVO(); + appVO.setPackageInfoId(accountRechargeVO.getPackageInfoId()); + appVO.setUserId(accountRechargeVO.getUserId()); + appVO.setAccountRechargeId(accountRechargeId); + + String accessToken = OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(); + SuccessResultData result = operatorPluginRemoteService.saveOrder(systemApiPathProperties.getOperatorPlugin(), appVO, accessToken); + if (!result.getData().equals("Success")) { + System.out.println("调用套餐包创建结果 : " + result); + throw new SaveException(result.getData()); + } + } + } + private Integer countByUserIdAndRechargeCheck(String userId, RechargeCheckEnum rechargeCheck) { Map params = getHashMap(4); params.put("userId", userId);