diff --git a/src/main/java/cn/com/tenlion/operator/pojo/vos/accountitem/AccountItemVO.java b/src/main/java/cn/com/tenlion/operator/pojo/vos/accountitem/AccountItemVO.java index fbd393c..2683a08 100644 --- a/src/main/java/cn/com/tenlion/operator/pojo/vos/accountitem/AccountItemVO.java +++ b/src/main/java/cn/com/tenlion/operator/pojo/vos/accountitem/AccountItemVO.java @@ -18,6 +18,8 @@ public class AccountItemVO { @ApiModelProperty(name = "accountId", value = "关联账户ID") private String accountId; + @ApiModelProperty(name = "accountItemId", value = "关联账户流水ID") + private String accountItemId; @ApiModelProperty(name = "accountBeforeMoney", value = "动账前余额") @CheckNumberAnnotation(name = "动账前余额") private Integer accountBeforeMoney; @@ -43,6 +45,13 @@ public class AccountItemVO { private String checkStatus; private Integer isPostpaid; + public String getAccountItemId() { + return accountItemId == null ? "" : accountItemId.trim(); + } + + public void setAccountItemId(String accountItemId) { + this.accountItemId = accountItemId; + } public String getOrderType() { return orderType == null ? "" : orderType.trim(); diff --git a/src/main/java/cn/com/tenlion/operator/service/accountitem/impl/AccountItemServiceImpl.java b/src/main/java/cn/com/tenlion/operator/service/accountitem/impl/AccountItemServiceImpl.java index d809a57..ebdab94 100644 --- a/src/main/java/cn/com/tenlion/operator/service/accountitem/impl/AccountItemServiceImpl.java +++ b/src/main/java/cn/com/tenlion/operator/service/accountitem/impl/AccountItemServiceImpl.java @@ -87,7 +87,7 @@ public class AccountItemServiceImpl extends DefaultBaseService implements IAccou @Override public synchronized String saveReturnId(String token, AccountItemVO accountItemVO) { - String accountItemId = UUIDUtil.getUUID(); + String accountItemId = StringUtils.isEmpty(accountItemVO.getAccountItemId()) ? UUIDUtil.getUUID() : accountItemVO.getAccountItemId(); /** * 找出账户 */ 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 1ea512c..81e10e0 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 @@ -4,6 +4,7 @@ import cn.com.tenlion.operator.enums.RechargeCheckEnum; import cn.com.tenlion.operator.enums.RechargeTypeEnum; import cn.com.tenlion.operator.enums.ReconciliationStatusEnum; import cn.com.tenlion.operator.enums.ThirdPartyEnum; +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; @@ -366,22 +367,30 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA 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); - /** - * 1. 创建流水 - */ - AccountItemVO vo = new AccountItemVO(); - vo.setType(2); - vo.setMode(2); - vo.setAccountId(dto.getCreator()); - vo.setOrderId(packageInfoDTO.getPackageOrderId()); - vo.setAccountMoney(packageInfoDTO.getPackageTotalMoney()); - vo.setDescription("购买" + (packageInfoDTO.getPackageInfoAppDTO().getPackageType().equals("ALL") ? "全托管" : "写材料" ) + "套餐包 " + packageInfoDTO.getPackageInfoAppDTO().getPackageCount() + " 件:" + packageInfoDTO.getPackageInfoAppDTO().getPackageName()); - String accountItemId1 = iAccountItemService.saveReturnId(vo); // 远程更改套餐包的付款到账状态 - SuccessResultData result = operatorPluginRemoteService.updatePay(systemApiPathProperties.getOperatorPlugin(), accountRechargeId, accountItemId1, accessToken); - if (!result.getData().equals("Success")) { - System.out.println("调用套餐包到账结果 : " + result); - throw new SaveException(result.getData()); + String accountItemId1 = UUIDUtil.getUUID(); + // 获取用户余额 , 如果不够 , 则不购买 + AccountDTO accountDTO = iAccountService.get(dto.getAccountId()); + 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()) { + /** + * 1. 创建流水 + */ + AccountItemVO vo = new AccountItemVO(); + vo.setType(2); + vo.setMode(2); + vo.setAccountId(dto.getCreator()); + vo.setOrderId(packageInfoDTO.getPackageOrderId()); + vo.setAccountMoney(packageInfoDTO.getPackageTotalMoney()); + vo.setDescription("购买" + (packageInfoDTO.getPackageInfoAppDTO().getPackageType().equals("ALL") ? "全托管" : "写材料") + "套餐包 " + packageInfoDTO.getPackageInfoAppDTO().getPackageCount() + " 件:" + packageInfoDTO.getPackageInfoAppDTO().getPackageName()); + iAccountItemService.saveReturnId(vo); + } + }else{ + System.out.println("调用套餐包到账结果 : " + result); + } } } // 绑定了套餐包 & 已对账 & 已关闭