|
@@ -76,6 +76,7 @@ public class PayCenterWebhookServiceImpl implements PayCenterWebhookService {
|
|
|
* @return String 支付链接
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public Boolean webhookMonitor(Map<String, String> body) {
|
|
|
if (body == null || body.isEmpty()) {
|
|
|
log.error("支付中台统一回调,请求参数为空");
|
|
@@ -284,106 +285,8 @@ public class PayCenterWebhookServiceImpl implements PayCenterWebhookService {
|
|
|
userSubscriptionInfoApi.insert(userSubscriptionInfo);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- /*if (ordersVO.getPaymentModel() == 1) {
|
|
|
- log.info("订阅订单回调,{}", ordersVO);
|
|
|
-// ProductVO productVO = productApi.getProduct(ordersVO.getProductId()).getResult();
|
|
|
- // 自动订阅,查询用户有没有订阅信息
|
|
|
- List<UserSubscriptionInfoVO> collect = subscriptionInfoList.stream().filter(
|
|
|
- userSubscriptionInfoVO -> userSubscriptionInfoVO.getPlatform().equals(productVO.getPlatform())
|
|
|
- ).collect(Collectors.toList());
|
|
|
- if (CollectionUtils.isNotEmpty(collect)) {
|
|
|
- log.info("用户有订阅信息,更新记录");
|
|
|
- UserSubscriptionInfoVO userSubscriptionInfoVO = collect.get(0);
|
|
|
- BeanUtil.copyProperties(userSubscriptionInfoVO, userSubscriptionInfo);
|
|
|
- userSubscriptionInfo.setStatus(PDFOfficeUserSubscriptionStatusEnum.SUBSCRIPTION_IN_PROGRESS.value());
|
|
|
- // 获取当前时间
|
|
|
- Date currentDate = new Date();
|
|
|
- // 根据产品周期添加订阅信息记录的结束时间
|
|
|
- if (currentDate.compareTo(userSubscriptionInfoVO.getEndDate()) < 0) {
|
|
|
- // 订阅未过期,设置结束时间为当前时间加产品周期
|
|
|
- currentDate = userSubscriptionInfoVO.getEndDate();
|
|
|
- }
|
|
|
- Date endDate = getDateByCycle(currentDate, productVO.getCycle());
|
|
|
- userSubscriptionInfo.setEndDate(endDate);
|
|
|
- userSubscriptionInfo.setPayType(1);
|
|
|
- userSubscriptionInfo.setPlatform(productVO.getPlatform());
|
|
|
- if(productVO.getPlatform()==3){
|
|
|
- //如果是ai还要加ai点数
|
|
|
- userSubscriptionInfo.setPoint(userSubscriptionInfo.getPoint()+Integer.valueOf(productVO.getPoints()));
|
|
|
- if(productVO.getCode().contains("trail")){
|
|
|
- UserVO userVO = new UserVO();
|
|
|
- userVO.setId(ordersVO.getUserId());
|
|
|
- userVO.setCanAccessAi("0");
|
|
|
- userApi.updateUser(userVO);
|
|
|
- }
|
|
|
- }
|
|
|
- userSubscriptionInfo.setAppId(ordersVO.getAppId());
|
|
|
- userSubscriptionInfo.setProductId(ordersVO.getProductId());
|
|
|
- userSubscriptionInfoApi.update(userSubscriptionInfo);
|
|
|
- } else {
|
|
|
- log.info("用户没有订阅信息,新增记录");
|
|
|
- userSubscriptionInfo.setId(CommonUtils.generateId());
|
|
|
- userSubscriptionInfo.setUserId(ordersVO.getUserId());
|
|
|
- userSubscriptionInfo.setStatus(PDFOfficeUserSubscriptionStatusEnum.SUBSCRIPTION_IN_PROGRESS.value());
|
|
|
- // 获取当前时间
|
|
|
- Date currentDate = new Date();
|
|
|
- Date endDate = getDateByCycle(currentDate, productVO.getCycle());
|
|
|
- userSubscriptionInfo.setEndDate(endDate);
|
|
|
- userSubscriptionInfo.setPayType(1);
|
|
|
- //0免费,1永久版,2订阅,3ai
|
|
|
- userSubscriptionInfo.setPlatform(productVO.getPlatform());
|
|
|
- if(productVO.getPlatform()==3){
|
|
|
- //如果是ai还要加ai点数
|
|
|
- userSubscriptionInfo.setPoint(Integer.valueOf(productVO.getPoints()));
|
|
|
- if(productVO.getCode().contains("trail")){
|
|
|
- UserVO userVO = new UserVO();
|
|
|
- userVO.setId(ordersVO.getUserId());
|
|
|
- userVO.setCanAccessAi("0");
|
|
|
- userApi.updateUser(userVO);
|
|
|
- }
|
|
|
- }
|
|
|
- userSubscriptionInfo.setAppId(ordersVO.getAppId());
|
|
|
- userSubscriptionInfo.setProductId(ordersVO.getProductId());
|
|
|
- userSubscriptionInfoApi.insert(userSubscriptionInfo);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.info("买断订单回调,{}", ordersVO);
|
|
|
- // 买断,查询用户买断信息
|
|
|
- List<UserSubscriptionInfoVO> collect = subscriptionInfoList.stream().filter(userSubscriptionInfoVO -> userSubscriptionInfoVO.getPlatform().equals(productVO.getPlatform())).collect(Collectors.toList());
|
|
|
- if (CollectionUtils.isNotEmpty(collect) || ordersVO.getPayNumber() > 1) {
|
|
|
- String info = CollectionUtils.isNotEmpty(collect) ? "用户有买断的订阅信息,新增订单赠送" : String.format("批量购买%s个,新增订单赠送", order.getPayNumber());
|
|
|
- log.info(info);
|
|
|
- // 批量购买和用户已购买的买断商品,放入 order_gift
|
|
|
- List<OrderGift> orderGiftList = new ArrayList<>();
|
|
|
- for (Integer i = 0; i < ordersVO.getPayNumber(); i++) {
|
|
|
- OrderGift orderGift = new OrderGift();
|
|
|
- orderGift.setId(CommonUtils.generateId());
|
|
|
- orderGift.setOrderId(ordersVO.getId());
|
|
|
- orderGift.setProductId(ordersVO.getProductId());
|
|
|
- orderGift.setUserId(ordersVO.getUserId());
|
|
|
- orderGift.setValidFlag("1");
|
|
|
- orderGiftList.add(orderGift);
|
|
|
- }
|
|
|
- orderGiftService.saveBatch(orderGiftList);
|
|
|
- } else {
|
|
|
- log.info("用户没有订阅信息,新增记录");
|
|
|
- userSubscriptionInfo.setId(CommonUtils.generateId());
|
|
|
- userSubscriptionInfo.setUserId(ordersVO.getUserId());
|
|
|
- userSubscriptionInfo.setPlatform(1);
|
|
|
- userSubscriptionInfo.setStatus(PDFOfficeUserSubscriptionStatusEnum.SUBSCRIPTION_IN_PROGRESS.value());
|
|
|
- // 设置过期时间一百年
|
|
|
- // 获取当前时间
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
- // 向当前时间增加100年
|
|
|
- calendar.add(Calendar.YEAR, 100);
|
|
|
- userSubscriptionInfo.setEndDate(calendar.getTime());
|
|
|
- userSubscriptionInfo.setPayType(0);
|
|
|
- userSubscriptionInfo.setAppId(ordersVO.getAppId());
|
|
|
- userSubscriptionInfo.setProductId(ordersVO.getProductId());
|
|
|
- userSubscriptionInfoApi.insert(userSubscriptionInfo);
|
|
|
- }
|
|
|
- }*/
|
|
|
+ //删除缓存中的订单
|
|
|
+ ordersService.deleteTheCacheInTheCacheManager(ordersVO.getUserId() + "-" + ordersVO.getProductId() + "-" + ordersVO.getPayment());
|
|
|
break;
|
|
|
case "2":
|
|
|
// 支付失败,有延时队列暂不处理
|
|
@@ -406,7 +309,7 @@ public class PayCenterWebhookServiceImpl implements PayCenterWebhookService {
|
|
|
// 更新user_subscription_info
|
|
|
UserSubscriptionInfo userSubscriptionInfo1 = new UserSubscriptionInfo();
|
|
|
// 查询用户订阅的信息
|
|
|
- List<UserSubscriptionInfoVO> collect = subscriptionInfoList.stream().filter(userSubscriptionInfoVO -> userSubscriptionInfoVO.getPaymentModel().equals("1")).collect(Collectors.toList());
|
|
|
+ List<UserSubscriptionInfoVO> collect = subscriptionInfoList.stream().filter(userSubscriptionInfoVO -> userSubscriptionInfoVO.getPlatform().equals(productVO.getPlatform())).collect(Collectors.toList());
|
|
|
if (CollectionUtils.isNotEmpty(collect)) {
|
|
|
log.error("订阅周期付款,用户订阅信息异常,thirdTradeId:{}", thirdTradeId);
|
|
|
break;
|
|
@@ -431,9 +334,9 @@ public class PayCenterWebhookServiceImpl implements PayCenterWebhookService {
|
|
|
// 更新user_subscription_info
|
|
|
UserSubscriptionInfo userSubscriptionInfo2 = new UserSubscriptionInfo();
|
|
|
// 查询用户订阅的信息
|
|
|
- List<UserSubscriptionInfoVO> collect1 = subscriptionInfoList.stream().filter(userSubscriptionInfoVO -> userSubscriptionInfoVO.getPaymentModel().equals("1")).collect(Collectors.toList());
|
|
|
+ List<UserSubscriptionInfoVO> collect1 = subscriptionInfoList.stream().filter(userSubscriptionInfoVO -> userSubscriptionInfoVO.getPlatform().equals(productVO.getPlatform())).collect(Collectors.toList());
|
|
|
if (CollectionUtils.isNotEmpty(collect1)) {
|
|
|
- log.error("订阅周期付款,用户订阅信息异常,thirdTradeId:{}", thirdTradeId);
|
|
|
+ log.error("订阅取消,用户订阅信息异常,thirdTradeId:{}", thirdTradeId);
|
|
|
break;
|
|
|
}
|
|
|
BeanUtil.copyProperties(collect1.get(0), userSubscriptionInfo2);
|