|
@@ -20,9 +20,9 @@ import cn.kdan.cloud.pdf.office.common.utils.MyDateUtils;
|
|
|
import cn.kdan.cloud.pdf.office.common.vo.UserInfoVO;
|
|
|
import cn.kdan.cloud.pdf.office.common.vo.UserVO;
|
|
|
import cn.kdan.cloud.pdf.office.payment.client.GooglePayClient;
|
|
|
+import cn.kdan.cloud.pdf.office.payment.properties.GooglePayConfig;
|
|
|
import cn.kdan.cloud.pdf.office.payment.service.GooglePayService;
|
|
|
import cn.kdan.cloud.pdf.office.payment.service.OrderService;
|
|
|
-import cn.kdan.cloud.pdf.office.payment.service.RestorePurchaseLogsService;
|
|
|
import cn.kdan.cloud.pdf.office.payment.service.SubscriptionsService;
|
|
|
import cn.kdan.cloud.pdf.office.payment.utils.TemplatesUtil;
|
|
|
import cn.kdan.cloud.pdf.office.payment.webhook.google.SubscriptionPurchaseLineItemMS;
|
|
@@ -30,14 +30,10 @@ import cn.kdan.cloud.pdf.office.payment.webhook.google.SubscriptionPurchaseV3;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
-import com.google.api.services.androidpublisher.model.SubscriptionPurchaseLineItem;
|
|
|
-import com.google.api.services.androidpublisher.model.SubscriptionPurchaseV2;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.http.HttpEntity;
|
|
|
-import org.springframework.http.HttpHeaders;
|
|
|
-import org.springframework.http.MediaType;
|
|
|
+import org.springframework.http.*;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
@@ -49,9 +45,6 @@ import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.time.ZoneOffset;
|
|
|
-import java.time.ZonedDateTime;
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -81,6 +74,7 @@ public class GooglePayServiceImpl implements GooglePayService {
|
|
|
|
|
|
private final EmailApi emailApi;
|
|
|
private static final RestTemplate restTemplate = new RestTemplate();
|
|
|
+ private final GooglePayConfig googlePayConfig;
|
|
|
@Value("${htmlToPdfUrl:http://139.196.160.101:3060/api/get-invoice}")
|
|
|
private String htmlToPdfUrl;
|
|
|
|
|
@@ -96,6 +90,9 @@ public class GooglePayServiceImpl implements GooglePayService {
|
|
|
}
|
|
|
log.info("谷歌权益校验,用户id:{}", googlePayDTO.getUserId());
|
|
|
SubscriptionPurchaseV3 subscriptionPurchaseV2 = this.verify(googlePayDTO.getPurchaseToken(),googlePayDTO.getPackageName());
|
|
|
+ if (subscriptionPurchaseV2.getTestPurchase() != null) {
|
|
|
+ throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_COUPON_INVALID);
|
|
|
+ }
|
|
|
// 获取票据订单信息
|
|
|
if(ObjectUtils.isEmpty(subscriptionPurchaseV2.getExternalAccountIdentifiers())){
|
|
|
throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_MSG_GOOGLE_STORE_TRANSACTION_ID_VALIDATION_FAILED);
|
|
@@ -123,7 +120,7 @@ public class GooglePayServiceImpl implements GooglePayService {
|
|
|
|
|
|
CreateSubscriptionDTO createSubscription = new CreateSubscriptionDTO();
|
|
|
String subscriptionId = CommonUtils.generateId();
|
|
|
- String orderId = CommonUtils.generateId();
|
|
|
+ String orderId = cn.kdan.cloud.pdf.office.payment.utils.CommonUtils.generateRightsId((long) ((Math.random() * 9999 + 1) * 10000));
|
|
|
String appId = product.getAppId().toString();
|
|
|
createSubscription.setId(subscriptionId);
|
|
|
createSubscription.setUserId(googlePayDTO.getUserId());
|
|
@@ -170,7 +167,6 @@ public class GooglePayServiceImpl implements GooglePayService {
|
|
|
result.setDigestPassword(null);
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
private void sendBuyEmail(ProductVO product, UserVO userVO,CreateOrderManualDTO orderManualDTO) {
|
|
|
if(product.getCode().contains("upgrade")){
|
|
|
EmailSendBO bo = new EmailSendBO();
|
|
@@ -289,7 +285,7 @@ public class GooglePayServiceImpl implements GooglePayService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void subscriptionPaymentSucceeded(Boolean isDiscount, String thirdTradeNo, String thirdOrderId, Integer payTime) {
|
|
|
+ public void subscriptionPaymentSucceeded(Boolean isDiscount, String thirdTradeNo, String thirdOrderId, Integer payTime, SubscriptionPurchaseV3 subscriptionGoogleOrderV2) {
|
|
|
log.info("谷歌 订阅的续费订单已成功 谷歌订单id:{},订阅id{}", thirdOrderId,thirdTradeNo);
|
|
|
OrdersVO ordersVO = orderService.getOrderByThirdOrderNo(thirdOrderId);
|
|
|
//如果订单处理过直接返回
|
|
@@ -304,7 +300,7 @@ public class GooglePayServiceImpl implements GooglePayService {
|
|
|
OrdersVO ordersVONew = orderByTradeNo.get(0);
|
|
|
ProductVO productVO = orderService.getProduct(ordersVONew.getProductId());
|
|
|
|
|
|
- webhookService.handleSubsequentAutomaticDeduction(productVO.getPrice(), thirdTradeNo, thirdOrderId,ordersVONew, 1);
|
|
|
+ webhookService.handleSubsequentAutomaticDeduction(productVO.getPrice(), thirdTradeNo, thirdOrderId,ordersVONew, 1, subscriptionGoogleOrderV2.toString());
|
|
|
}
|
|
|
|
|
|
@Override
|