Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/cn/com/tenlion/operator/service/accountrecharge/impl/AccountRechargeServiceImpl.java
This commit is contained in:
TS-QD1 2025-04-24 19:48:05 +08:00
commit 98df9a09ef
2 changed files with 92 additions and 134 deletions

View File

@ -8,6 +8,7 @@ import cn.com.tenlion.operator.service.user.expand.UserExpandServiceImpl;
import cn.com.tenlion.operator.util.EncryptUtil; import cn.com.tenlion.operator.util.EncryptUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import ink.wgink.annotation.CheckRequestBodyAnnotation; import ink.wgink.annotation.CheckRequestBodyAnnotation;
import ink.wgink.common.advice.ResponseAdvice;
import ink.wgink.common.base.DefaultBaseController; import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.common.component.SecurityComponent; import ink.wgink.common.component.SecurityComponent;
import ink.wgink.exceptions.SaveException; import ink.wgink.exceptions.SaveException;

View File

@ -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.accountbank.AccountBankDTO;
import cn.com.tenlion.operator.pojo.dtos.accountrecharge.AccountRechargePayDTO; 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.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.accountitem.AccountItemVO;
import cn.com.tenlion.operator.pojo.vos.accountrecharge.AccountRechargeWxPrepayVO;
import cn.com.tenlion.operator.properties.SystemApiPathProperties; import cn.com.tenlion.operator.properties.SystemApiPathProperties;
import cn.com.tenlion.operator.remote.IOperatorPluginRemoteService; 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.PackageOrderAppVO;
import cn.com.tenlion.operator.remote.PackageOrderDTO; import cn.com.tenlion.operator.remote.PackageOrderDTO;
import cn.com.tenlion.operator.service.account.IAccountService; import cn.com.tenlion.operator.service.account.IAccountService;
import cn.com.tenlion.operator.service.accountbank.IAccountBankService; import cn.com.tenlion.operator.service.accountbank.IAccountBankService;
import cn.com.tenlion.operator.service.accountitem.IAccountItemService; 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.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.TenlionSMS;
import cn.com.tenlion.operator.util.UserUtil; import cn.com.tenlion.operator.util.UserUtil;
import cn.com.tenlion.operator.util.pay.ALiPay; 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 cn.com.tenlion.projectconfig.util.ProjectConfigUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import ink.wgink.common.base.DefaultBaseService; import ink.wgink.common.base.DefaultBaseService;
import ink.wgink.exceptions.ParamsException; import ink.wgink.exceptions.ParamsException;
import ink.wgink.exceptions.SaveException; 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.module.oauth2.manager.OAuth2ClientTokenManager;
import ink.wgink.pojo.ListPage; import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.user.UserDTO; import ink.wgink.pojo.dtos.user.UserDTO;
import ink.wgink.pojo.result.SuccessResult;
import ink.wgink.pojo.result.SuccessResultData; import ink.wgink.pojo.result.SuccessResultData;
import ink.wgink.pojo.result.SuccessResultList; import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.util.date.DateUtil; import ink.wgink.util.date.DateUtil;
@ -91,8 +92,6 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA
private SystemApiPathProperties systemApiPathProperties; private SystemApiPathProperties systemApiPathProperties;
@Autowired @Autowired
private IOperatorPluginRemoteService operatorPluginRemoteService; private IOperatorPluginRemoteService operatorPluginRemoteService;
@Autowired
private UserExpandServiceImpl userExpandServiceImpl;
@Override @Override
public void save(AccountRechargeVO accountRechargeVO) { public void save(AccountRechargeVO accountRechargeVO) {
@ -183,6 +182,7 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA
} }
params.put("rechargeRemark", rechargeRemark); params.put("rechargeRemark", rechargeRemark);
accountRechargeDao.updateRemark(params); accountRechargeDao.updateRemark(params);
AccountRechargeDTO dto = accountRechargeDao.get(params);
if (StringUtils.isEmpty(po.getAccountItemId()) && po.getReconciliationStatus().equals("0")) { if (StringUtils.isEmpty(po.getAccountItemId()) && po.getReconciliationStatus().equals("0")) {
// 1. 生成流水记录 // 1. 生成流水记录
AccountItemVO vo = new AccountItemVO(); AccountItemVO vo = new AccountItemVO();
@ -194,10 +194,14 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA
String accountItemId = iAccountItemService.saveReturnId(vo); String accountItemId = iAccountItemService.saveReturnId(vo);
// 2. 修改状态为2 // 2. 修改状态为2
updateCheck(po.getAccountRechargeId(), RechargeCheckEnum.RECHARGE_SUCCESS, rechargeRemark, accountItemId, "", DateUtil.getTime()); updateCheck(po.getAccountRechargeId(), RechargeCheckEnum.RECHARGE_SUCCESS, rechargeRemark, accountItemId, "", DateUtil.getTime());
// 3.通知到账
JSONObject jsonObject = new JSONObject(); // 套餐包购买的不通知
jsonObject.put("money", accountRechargeVO.getRechargeMoney()); if(StringUtils.isEmpty(dto.getPackageInfoId())) {
sysCallbackService.save("项目充值到账", systemApiPathProperties.getCopyright() + "api/pay/recharge-success/user-id/" + po.getAccountId(), jsonObject); // 3. 平台通知到账
JSONObject jsonobject =new JSONObject();
jsonobject.put("money", po.getRechargeMoney());
sysCallbackService.save("对公充值到账", systemApiPathProperties.getCopyright() + "api/pay/recharge-success/user-id/" + po.getAccountId(), jsonobject);
}
} }
} }
@ -414,7 +418,7 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA
// synchronized (lock) { // synchronized (lock) {
String userId = accountRechargeVO.getUserId(); String userId = accountRechargeVO.getUserId();
// 未支付的订单 // 未支付的订单
// Integer count = countByUserIdAndRechargeCheck(userId, RechargeCheckEnum.UN_RECHARGE); Integer count = countByUserIdAndRechargeCheck(userId, RechargeCheckEnum.UN_RECHARGE);
/* if (count > ProjectConfigUtil.getInt("ToDayMaxRechargeCount")) { /* if (count > ProjectConfigUtil.getInt("ToDayMaxRechargeCount")) {
throw new SaveException("超过创建订单数量上限"); throw new SaveException("超过创建订单数量上限");
}*/ }*/
@ -460,66 +464,13 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA
params.put("gmtModified", currentDate); params.put("gmtModified", currentDate);
params.put("isDelete", 0); params.put("isDelete", 0);
accountRechargeDao.save(params); 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<String, Object> 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())) { if(!StringUtils.isEmpty(accountRechargeVO.getPackageInfoId())) {
PackageOrderAppVO appVO = new PackageOrderAppVO(); PackageOrderAppVO appVO = new PackageOrderAppVO();
appVO.setPackageInfoId(accountRechargeVO.getPackageInfoId()); appVO.setPackageInfoId(accountRechargeVO.getPackageInfoId());
appVO.setUserId(accountRechargeVO.getUserId()); appVO.setUserId(userId);
appVO.setAccountRechargeId(accountRechargeId); appVO.setAccountRechargeId(payDTO.getAccountRechargeId());
String accessToken = OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(); String accessToken = OAuth2ClientTokenManager.getInstance().getToken().getAccessToken();
SuccessResultData<String> result = operatorPluginRemoteService.saveOrder(systemApiPathProperties.getOperatorPlugin(), appVO, accessToken); SuccessResultData<String> result = operatorPluginRemoteService.saveOrder(systemApiPathProperties.getOperatorPlugin(), appVO, accessToken);
@ -528,6 +479,9 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA
throw new SaveException(result.getData()); throw new SaveException(result.getData());
} }
} }
// }
return payDTO;
} }
private Integer countByUserIdAndRechargeCheck(String userId, RechargeCheckEnum rechargeCheck) { private Integer countByUserIdAndRechargeCheck(String userId, RechargeCheckEnum rechargeCheck) {
@ -731,10 +685,13 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA
// 2. 修改状态为2 // 2. 修改状态为2
updateCheck(dto.getAccountRechargeId(), RechargeCheckEnum.RECHARGE_SUCCESS, "线上充值", accountItemId, orderId, successTime); updateCheck(dto.getAccountRechargeId(), RechargeCheckEnum.RECHARGE_SUCCESS, "线上充值", accountItemId, orderId, successTime);
// 3. 调用第三方接口, 告知充值到账 // 套餐包购买的不通知
JSONObject jsonObject = new JSONObject(); if(StringUtils.isEmpty(dto.getPackageInfoId())) {
jsonObject.put("money", dto.getRechargeMoney()); // 3. 平台通知到账
sysCallbackService.save("项目充值到账", systemApiPathProperties.getCopyright() + "api/pay/recharge-success/user-id/" + dto.getAccountId(), jsonObject); JSONObject jsonobject =new JSONObject();
jsonobject.put("money", dto.getRechargeMoney());
sysCallbackService.save("对公充值到账", systemApiPathProperties.getCopyright() + "api/pay/recharge-success/user-id/" + dto.getAccountId(), jsonobject);
}
} }
} }