diff --git a/src/main/java/cn/com/tenlion/operator/controller/resource/accountitem/AccountItemResourceController.java b/src/main/java/cn/com/tenlion/operator/controller/resource/accountitem/AccountItemResourceController.java index 5bf8f70..9f1d65a 100644 --- a/src/main/java/cn/com/tenlion/operator/controller/resource/accountitem/AccountItemResourceController.java +++ b/src/main/java/cn/com/tenlion/operator/controller/resource/accountitem/AccountItemResourceController.java @@ -8,6 +8,7 @@ import cn.com.tenlion.operator.service.user.expand.UserExpandServiceImpl; import cn.com.tenlion.operator.util.EncryptUtil; import com.alibaba.fastjson.JSONObject; import ink.wgink.annotation.CheckRequestBodyAnnotation; +import ink.wgink.common.advice.ResponseAdvice; import ink.wgink.common.base.DefaultBaseController; import ink.wgink.common.component.SecurityComponent; import ink.wgink.exceptions.SaveException; 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 0cec732..c6b13bc 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,19 +8,18 @@ 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.pos.user.expand.UserExpandPO; +import cn.com.tenlion.operator.pojo.dtos.ic.UsericDTO; 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; import cn.com.tenlion.operator.remote.PackageOrderAppVO; import cn.com.tenlion.operator.remote.PackageOrderDTO; import cn.com.tenlion.operator.service.account.IAccountService; 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; @@ -30,6 +29,7 @@ import cn.com.tenlion.operator.util.pay.WXPay; import cn.com.tenlion.projectconfig.util.ProjectConfigUtil; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson2.JSON; import ink.wgink.common.base.DefaultBaseService; import ink.wgink.exceptions.ParamsException; import ink.wgink.exceptions.SaveException; @@ -38,6 +38,7 @@ import ink.wgink.interfaces.user.IUserBaseService; import ink.wgink.module.oauth2.manager.OAuth2ClientTokenManager; import ink.wgink.pojo.ListPage; import ink.wgink.pojo.dtos.user.UserDTO; +import ink.wgink.pojo.result.SuccessResult; import ink.wgink.pojo.result.SuccessResultData; import ink.wgink.pojo.result.SuccessResultList; import ink.wgink.util.date.DateUtil; @@ -91,8 +92,6 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA private SystemApiPathProperties systemApiPathProperties; @Autowired private IOperatorPluginRemoteService operatorPluginRemoteService; - @Autowired - private UserExpandServiceImpl userExpandServiceImpl; @Override public void save(AccountRechargeVO accountRechargeVO) { @@ -183,6 +182,7 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA } params.put("rechargeRemark", rechargeRemark); accountRechargeDao.updateRemark(params); + AccountRechargeDTO dto = accountRechargeDao.get(params); if (StringUtils.isEmpty(po.getAccountItemId()) && po.getReconciliationStatus().equals("0")) { // 1. 生成流水记录 AccountItemVO vo = new AccountItemVO(); @@ -194,10 +194,14 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA String accountItemId = iAccountItemService.saveReturnId(vo); // 2. 修改状态为2 updateCheck(po.getAccountRechargeId(), RechargeCheckEnum.RECHARGE_SUCCESS, rechargeRemark, accountItemId, "", DateUtil.getTime()); - // 3.通知到账 - JSONObject jsonObject = new JSONObject(); - jsonObject.put("money", accountRechargeVO.getRechargeMoney()); - sysCallbackService.save("项目充值到账", systemApiPathProperties.getCopyright() + "api/pay/recharge-success/user-id/" + po.getAccountId(), jsonObject); + + // 套餐包购买的不通知 + if(StringUtils.isEmpty(dto.getPackageInfoId())) { + // 3. 平台通知到账 + JSONObject jsonobject =new JSONObject(); + jsonobject.put("money", po.getRechargeMoney()); + sysCallbackService.save("对公充值到账", systemApiPathProperties.getCopyright() + "api/pay/recharge-success/user-id/" + po.getAccountId(), jsonobject); + } } } @@ -320,7 +324,7 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA accountRechargeDao.updateCheck(params); AccountRechargeDTO dto = get(accountRechargeId); // 创建套餐包关闭支付 - if (!StringUtils.isEmpty(dto.getPackageInfoId())) { + if(!StringUtils.isEmpty(dto.getPackageInfoId())) { String accessToken = OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(); SuccessResultData result = operatorPluginRemoteService.updateClose(systemApiPathProperties.getOperatorPlugin(), accountRechargeId, accessToken); if (!result.getData().equals("Success")) { @@ -367,18 +371,18 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA // 2025年2月28日11:12:47 CBC 新增 套餐包 逻辑 AccountRechargeDTO dto = get(accountRechargeId); // 绑定了套餐包 & 已对账 & 已到账 - if (!StringUtils.isEmpty(dto.getPackageInfoId()) && dto.getReconciliationStatus().equals("1") && dto.getRechargeCheck().equals("2")) { + if(!StringUtils.isEmpty(dto.getPackageInfoId()) && dto.getReconciliationStatus().equals("1") && dto.getRechargeCheck().equals("2")) { String accessToken = OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(); - PackageOrderDTO packageInfoDTO = operatorPluginRemoteService.getByNo(systemApiPathProperties.getOperatorPlugin(), accountRechargeId, accessToken); + PackageOrderDTO packageInfoDTO = operatorPluginRemoteService.getByNo(systemApiPathProperties.getOperatorPlugin(), accountRechargeId , accessToken); // 远程更改套餐包的付款到账状态 String accountItemId1 = UUIDUtil.getUUID(); // 获取用户余额 , 如果不够 , 则不购买 AccountDTO accountDTO = iAccountService.get(dto.getAccountId()); - if (accountDTO.getAccountMoney() >= packageInfoDTO.getPackageTotalMoney()) { + if(accountDTO.getAccountMoney() >= packageInfoDTO.getPackageTotalMoney()) { SuccessResultData result = operatorPluginRemoteService.updatePay(systemApiPathProperties.getOperatorPlugin(), accountRechargeId, accountItemId1, accessToken); if (result.getData().equals("Success")) { AccountDTO accountDTO2 = iAccountService.get(dto.getAccountId()); - if (accountDTO2.getAccountMoney() >= packageInfoDTO.getPackageTotalMoney()) { + if(accountDTO2.getAccountMoney() >= packageInfoDTO.getPackageTotalMoney()) { /** * 1. 创建流水 */ @@ -392,13 +396,13 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA vo.setDescription("购买" + (packageInfoDTO.getPackageInfoAppDTO().getPackageType().equals("ALL") ? "全托管" : "写材料") + "套餐包 " + packageInfoDTO.getPackageInfoAppDTO().getPackageCount() + " 件:" + packageInfoDTO.getPackageInfoAppDTO().getPackageName()); iAccountItemService.saveReturnId(vo); } - } else { + }else{ System.out.println("调用套餐包到账结果 : " + result); } } } // 绑定了套餐包 & 已对账 & 已关闭 - if (!StringUtils.isEmpty(dto.getPackageInfoId()) && dto.getReconciliationStatus().equals("1") && dto.getRechargeCheck().equals("-1")) { + if(!StringUtils.isEmpty(dto.getPackageInfoId()) && dto.getReconciliationStatus().equals("1") && dto.getRechargeCheck().equals("-1")) { String accessToken = OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(); SuccessResultData result = operatorPluginRemoteService.updateClose(systemApiPathProperties.getOperatorPlugin(), accountRechargeId, accessToken); if (!result.getData().equals("Success")) { @@ -412,122 +416,72 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA public AccountRechargePayDTO saveAccount(String thirdParty, AccountRechargeVO accountRechargeVO) { AccountRechargePayDTO payDTO = new AccountRechargePayDTO(); // synchronized (lock) { - String userId = accountRechargeVO.getUserId(); - // 未支付的订单 -// Integer count = countByUserIdAndRechargeCheck(userId, RechargeCheckEnum.UN_RECHARGE); + String userId = accountRechargeVO.getUserId(); + // 未支付的订单 + Integer count = countByUserIdAndRechargeCheck(userId, RechargeCheckEnum.UN_RECHARGE); /* if (count > ProjectConfigUtil.getInt("ToDayMaxRechargeCount")) { throw new SaveException("超过创建订单数量上限"); }*/ - accountRechargeVO.setThirdParty(thirdParty); - accountRechargeVO.setAccountId(userId); - accountRechargeVO.setRechargeCheck(RechargeCheckEnum.UN_RECHARGE.getValue()); - accountRechargeVO.setReconciliationStatus(ReconciliationStatusEnum.UN_RECONCILIATION.getValue()); - Integer totalMoney = PayUtil.buiderMoney(accountRechargeVO.getRechargeMoney()); - String currentDate = DateUtil.getTime(); + accountRechargeVO.setThirdParty(thirdParty); + accountRechargeVO.setAccountId(userId); + accountRechargeVO.setRechargeCheck(RechargeCheckEnum.UN_RECHARGE.getValue()); + accountRechargeVO.setReconciliationStatus(ReconciliationStatusEnum.UN_RECONCILIATION.getValue()); + Integer totalMoney = PayUtil.buiderMoney(accountRechargeVO.getRechargeMoney()); + String currentDate = DateUtil.getTime(); - Map params = HashMapUtil.beanToMap(accountRechargeVO); - if (ThirdPartyEnum.WX.getValue().equals(thirdParty)) { - String accountRechargeId = getUUID("wx"); - params.put("rechargeType", RechargeTypeEnum.ONLINE.getValue()); - params.put("accountRechargeId", accountRechargeId); - params.put("rechargeFinalTime", currentDate); + Map params = HashMapUtil.beanToMap(accountRechargeVO); + if (ThirdPartyEnum.WX.getValue().equals(thirdParty)) { + String accountRechargeId = getUUID("wx"); + params.put("rechargeType", RechargeTypeEnum.ONLINE.getValue()); + params.put("accountRechargeId", accountRechargeId); + params.put("rechargeFinalTime", currentDate); - String brcode = WXPay.createPay(accountRechargeId, totalMoney, ProjectConfigUtil.getText("RechargePayTitle")); - payDTO.setAccountRechargeId(accountRechargeId); - payDTO.setThirdParty(thirdParty); - payDTO.setThirdPartyPayUrl(brcode); - } else if (ThirdPartyEnum.ZFB.getValue().equals(thirdParty)) { - String accountRechargeId = getUUID("zfb"); - params.put("rechargeType", RechargeTypeEnum.ONLINE.getValue()); - params.put("accountRechargeId", accountRechargeId); - params.put("rechargeFinalTime", currentDate); + String brcode = WXPay.createPay(accountRechargeId, totalMoney, ProjectConfigUtil.getText("RechargePayTitle")); + payDTO.setAccountRechargeId(accountRechargeId); + payDTO.setThirdParty(thirdParty); + payDTO.setThirdPartyPayUrl(brcode); + } else if (ThirdPartyEnum.ZFB.getValue().equals(thirdParty)) { + String accountRechargeId = getUUID("zfb"); + params.put("rechargeType", RechargeTypeEnum.ONLINE.getValue()); + params.put("accountRechargeId", accountRechargeId); + params.put("rechargeFinalTime", currentDate); - String brcode = ALiPay.createPay(accountRechargeId, totalMoney, ProjectConfigUtil.getText("RechargePayTitle")); - payDTO.setAccountRechargeId(accountRechargeId); - payDTO.setThirdParty(thirdParty); - payDTO.setThirdPartyPayUrl(brcode); - } else if (ThirdPartyEnum.DGZZ.getValue().equals(thirdParty)) { - String accountRechargeId = getUUID("oto"); - params.put("rechargeType", RechargeTypeEnum.OFFLINE.getValue()); - params.put("accountRechargeId", accountRechargeId); - payDTO.setAccountRechargeId(accountRechargeId); - } else { - throw new ParamsException("充值类型错误"); - } - params.put("creator", userId); - params.put("gmtCreate", currentDate); - params.put("modifier", userId); - params.put("gmtModified", currentDate); - params.put("isDelete", 0); - accountRechargeDao.save(params); - savePackageInfo(payDTO.getAccountRechargeId(), accountRechargeVO); - 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()); + String brcode = ALiPay.createPay(accountRechargeId, totalMoney, ProjectConfigUtil.getText("RechargePayTitle")); + payDTO.setAccountRechargeId(accountRechargeId); + payDTO.setThirdParty(thirdParty); + payDTO.setThirdPartyPayUrl(brcode); + } else if (ThirdPartyEnum.DGZZ.getValue().equals(thirdParty)) { + String accountRechargeId = getUUID("oto"); + params.put("rechargeType", RechargeTypeEnum.OFFLINE.getValue()); + params.put("accountRechargeId", accountRechargeId); + payDTO.setAccountRechargeId(accountRechargeId); + } else { + throw new ParamsException("充值类型错误"); } - } + params.put("creator", userId); + params.put("gmtCreate", currentDate); + params.put("modifier", userId); + params.put("gmtModified", currentDate); + params.put("isDelete", 0); + accountRechargeDao.save(params); + + // 创建套餐包购买记录 + if(!StringUtils.isEmpty(accountRechargeVO.getPackageInfoId())) { + PackageOrderAppVO appVO = new PackageOrderAppVO(); + appVO.setPackageInfoId(accountRechargeVO.getPackageInfoId()); + appVO.setUserId(userId); + appVO.setAccountRechargeId(payDTO.getAccountRechargeId()); + + 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()); + } + } + + // } + return payDTO; } private Integer countByUserIdAndRechargeCheck(String userId, RechargeCheckEnum rechargeCheck) { @@ -614,7 +568,7 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA AccountRechargeDTO accountRechargeDTO = get(accountRechargeId); JSONArray phoneArray = new JSONArray(); String[] phones = ProjectConfigUtil.getText("HandleRechargePhones").split(","); - for (String phone : phones) { + for(String phone : phones) { com.alibaba.fastjson.JSONObject obj1 = new JSONObject(); obj1.put("phone", phone); phoneArray.add(obj1); @@ -622,7 +576,7 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA Map templateParams = new HashMap<>(); templateParams.put("count", 1 + ""); templateParams.put("money", accountRechargeDTO.getRechargeMoney() + ""); - TenlionSMS.sendMessage(UUIDUtil.getUUID(), "M00005", templateParams, phoneArray); + TenlionSMS.sendMessage(UUIDUtil.getUUID(), "M00005", templateParams, phoneArray); accountRechargeDao.update(params); } @@ -647,7 +601,7 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA rechargePayResultDTO.setOrderMessage("付款信息已提交, 请等待平台核对"); updateOrgData(accountRechargeId, accountRechargeVO); return rechargePayResultDTO; - } else if (dto.getThirdParty().equals(ThirdPartyEnum.XT.getValue())) { + } else if(dto.getThirdParty().equals(ThirdPartyEnum.XT.getValue())) { /** * 保存充值信息 * 2025年3月24日14:12:44 @@ -719,7 +673,7 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA public synchronized void saveConfirmOnline(String id, String orderId, String successTime) { AccountRechargeDTO dto = get(id); if (StringUtils.isEmpty(dto.getAccountItemId()) && - dto.getReconciliationStatus().equals(ReconciliationStatusEnum.UN_RECONCILIATION.getValue())) { + dto.getReconciliationStatus().equals(ReconciliationStatusEnum.UN_RECONCILIATION.getValue())) { // 1. 生成流水记录 AccountItemVO vo = new AccountItemVO(); vo.setType(1); @@ -731,10 +685,13 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA // 2. 修改状态为2 updateCheck(dto.getAccountRechargeId(), RechargeCheckEnum.RECHARGE_SUCCESS, "线上充值", accountItemId, orderId, successTime); - // 3. 调用第三方接口, 告知充值到账 - JSONObject jsonObject = new JSONObject(); - jsonObject.put("money", dto.getRechargeMoney()); - sysCallbackService.save("项目充值到账", systemApiPathProperties.getCopyright() + "api/pay/recharge-success/user-id/" + dto.getAccountId(), jsonObject); + // 套餐包购买的不通知 + if(StringUtils.isEmpty(dto.getPackageInfoId())) { + // 3. 平台通知到账 + JSONObject jsonobject =new JSONObject(); + jsonobject.put("money", dto.getRechargeMoney()); + sysCallbackService.save("对公充值到账", systemApiPathProperties.getCopyright() + "api/pay/recharge-success/user-id/" + dto.getAccountId(), jsonobject); + } } }