Explorar el Código

Merge branch 'develop/v1.0' of http://git.kdan.cc:8865/Server_Service/pdf_office_back_end into develop/v1.0

Bob hace 4 meses
padre
commit
86c5b87a90

+ 3 - 0
pdf-office-api/pdf-office-api-payment/src/main/java/cn/kdan/cloud/pdf/office/api/payment/vo/OrdersVO.java

@@ -131,4 +131,7 @@ public class OrdersVO implements Serializable {
 
     private String simplifiedChineseName;
     private String traditionalChineseName;
+
+    private String currency;
+
 }

+ 2 - 1
pdf-office-payment/src/main/java/cn/kdan/cloud/pdf/office/payment/client/GooglePayClient.java

@@ -145,7 +145,8 @@ public class GooglePayClient {
 //        testID();
         RestTemplate restTemplate = new RestTemplate();
         String url = "https://backend.pdfreaderpro.com/system/google/getSubscriptionGoogleOrderV2" +
-                "?packageName=" + "com.pdftechnologies.pdfreaderpro" + "&purchaseToken=" + "addcgghjnngggjcmcciogdmc.AO-J1OwbnlU9brbdzMiRUTGYOyDJbdmPl1AaJWaIjqyYhTFQXkMlw2qdwTUsvNRNSf45PANqkhVghwYUdT8viJ8wfbMeILsj6S6BHLEtU4WKKH0GossQJrc";
+                "?packageName=" + "com.pdftechnologies.pdfreaderpro" + "&purchaseToken="
+                + "ciakhdogdhngcciamhfgeoac.AO-J1Ozzc45cKdz61hjcmAhF1D7RWdqMUICmdtZYFoi7h9cwU8wT2Pq2mYfScT38EeKRvmjMPkzEXu8NfBJuayzS2vXjaLZBPppIkK10bJRyjx-d4nXgkBM";
 
         // 设置请求头
         HttpHeaders headers = new HttpHeaders();

+ 1 - 1
pdf-office-payment/src/main/java/cn/kdan/cloud/pdf/office/payment/service/impl/AppStoreServiceImpl.java

@@ -127,7 +127,7 @@ public class AppStoreServiceImpl implements AppStoreService {
             CreateOrderManualDTO orderManualDTO = CreateOrderManualDTO.builder()
                     .thirdTradeNo(originalTransactionId)
                     .thirdOrderNo(transactionId)
-                    .price(product.getPrice())
+                    .price(currency.equals("cny")?product.getCnyPrice():product.getPrice())
                     .reducedPrice(price)
                     .subscriptionId(subscriptionId)
                     .userId(equityVerificationDTO.getUserId())

+ 8 - 1
pdf-office-payment/src/main/java/cn/kdan/cloud/pdf/office/payment/service/impl/AppStoreWebhookServiceImpl.java

@@ -10,6 +10,7 @@ import cn.kdan.cloud.pdf.office.payment.properties.AppStoreProperties;
 import cn.kdan.cloud.pdf.office.payment.service.*;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -44,7 +45,13 @@ public class AppStoreWebhookServiceImpl implements AppStoreWebhookService {
         }
         OrdersVO ordersVONew = ordersVOS.get(0);
         ProductVO productVO = ordersService.getProduct(ordersVONew.getProductId());
-        webhookService.handleSubsequentAutomaticDeduction(productVO.getPrice(), thirdTradeNo, thirdOrderId,ordersVONew,payTime);
+        BigDecimal price;
+        if(StringUtils.isNotEmpty(ordersVONew.getCurrency())&&ordersVONew.getCurrency().equals("USD")){
+            price = productVO.getPrice();
+        }else{
+            price = productVO.getCnyPrice();
+        }
+        webhookService.handleSubsequentAutomaticDeduction(price, thirdTradeNo, thirdOrderId,ordersVONew,payTime);
     }
 
     @Override

+ 1 - 1
pdf-office-payment/src/main/java/cn/kdan/cloud/pdf/office/payment/service/impl/GooglePayServiceImpl.java

@@ -303,7 +303,7 @@ public class GooglePayServiceImpl implements GooglePayService {
         }
         OrdersVO ordersVONew = orderByTradeNo.get(0);
         ProductVO productVO = orderService.getProduct(ordersVONew.getProductId());
-        //todo 价格怎么办
+
         webhookService.handleSubsequentAutomaticDeduction(productVO.getPrice(), thirdTradeNo, thirdOrderId,ordersVONew, 1);
     }
 

+ 3 - 4
pdf-office-payment/src/main/java/cn/kdan/cloud/pdf/office/payment/service/impl/OrderGiftLogServiceImpl.java

@@ -61,11 +61,10 @@ public class OrderGiftLogServiceImpl extends ServiceImpl<OrderGiftLogMapper, Ord
     }
 
     @Override
-    public void expire(String orderGiftLogId) {
-        this.update(Wrappers.<OrderGiftLog>lambdaUpdate().set(OrderGiftLog::getValidFlag, OrderGiftLogVaildFlagEnum.RECEIVE_FAIL.getCode()).eq(OrderGiftLog::getId, orderGiftLogId));
-        OrderGiftLog log1 = this.getById(orderGiftLogId);
+    public void expire(String orderGiftId) {
+        this.update(Wrappers.<OrderGiftLog>lambdaUpdate().set(OrderGiftLog::getValidFlag, OrderGiftLogVaildFlagEnum.RECEIVE_FAIL.getCode()).eq(OrderGiftLog::getOrderGiftId, orderGiftId));
         //并且更新orderGift表中对应记录的validFlag
-        orderGiftMapper.update(null, Wrappers.<OrderGift>lambdaUpdate().set(OrderGift::getValidFlag, OrderGiftVaildFlagEnum.GIFT_ABLE.getCode()).eq(OrderGift::getId, log1.getOrderGiftId()));
+        orderGiftMapper.update(null, Wrappers.<OrderGift>lambdaUpdate().set(OrderGift::getValidFlag, OrderGiftVaildFlagEnum.GIFT_ABLE.getCode()).eq(OrderGift::getId, orderGiftId));
     }
     //接收会员
     @Override

+ 1 - 0
pdf-office-payment/src/main/java/cn/kdan/cloud/pdf/office/payment/webhook/GoogleWebhookMonitor.java

@@ -72,6 +72,7 @@ public class GoogleWebhookMonitor {
             // 获取订阅订单信息
             SubscriptionPurchaseV3 subscriptionGoogleOrderV2 = googlePayClient.getSubscription(developerNotification.getPackageName(), purchaseToken);
             //测试订单
+            log.info("谷歌 订阅:{}", subscriptionGoogleOrderV2.toString());
             if (subscriptionGoogleOrderV2.getTestPurchase() != null) {
                 if (googlePayConfig.getIsSandbox().equals("false")) {
                     log.info("正式环境转发测试回调", purchaseToken);

+ 2 - 1
pdf-office-payment/src/main/java/cn/kdan/cloud/pdf/office/payment/webhook/appstore/notification/NotificationType.java

@@ -28,5 +28,6 @@ public enum NotificationType {
 
   REVOKE,
 
-  SUBSCRIBED
+  SUBSCRIBED,
+  ONE_TIME_CHARGE
 }

+ 1 - 1
pdf-office-payment/src/main/resources/mapper/OrderMapper.xml

@@ -46,7 +46,7 @@
             ,type
             ,detail_type
             ,user_id
-            ,email,discount_type,subscription_type,payment_model
+            ,email,discount_type,subscription_type,payment_model,currency
         from `order`
         where third_trade_no = #{tradeNo}
         order by created_at desc

+ 6 - 2
pdf-office-pdf-website/src/main/java/cn/kdan/cloud/pdf/office/website/controller/AIController.java

@@ -162,10 +162,14 @@ public class AIController {
         Optional<UserSubscriptionInfoVO> activeUserSubscriptionInfoVO = voList.stream()
                 .filter(vo -> {
                     // Check if 'isAi' is not empty
-                    return !ObjectUtils.isEmpty(vo.getIsAi()) &&
-                            vo.getStatus().equals(PDFOfficeUserSubscriptionStatusEnum.SUBSCRIPTION_IN_PROGRESS.value());
+                    return !ObjectUtils.isEmpty(vo.getIsAi()) ;
                 })
                 .findFirst(); // Get the first matching VO
+        // Check if
+        if (!activeUserSubscriptionInfoVO.isPresent()) {
+            throw new RuntimeException("No AI subscription found for user: " + userId);
+        }
+        // Get the first matching VO from the list (should be the only one) and return it as the active subscription info.
         UserSubscriptionInfoVO userSubscriptionInfoVO = activeUserSubscriptionInfoVO.get();
         return userSubscriptionInfoVO;
     }

+ 1 - 1
pdf-office-pdf-website/src/main/java/cn/kdan/cloud/pdf/office/website/controller/TranslateController.java

@@ -71,7 +71,7 @@ public class TranslateController {
             if (vo.getCharCount() < 10000) {
                 cost = 2; // 不满1000字符的费用为1
             } else {
-                cost = (int) Math.ceil(vo.getCharCount() / 1000.0 )*2;
+                cost = (int) Math.ceil(vo.getCharCount() / 10000.0 )*2;
             }
             vo.setCredit(cost);
             result.setData(vo);

+ 7 - 7
pdf-office-pdf-website/src/main/resources/generatorConfig.xml

@@ -39,18 +39,18 @@
 			<property name="enableSubPackages" value="true" />
 		</javaClientGenerator>
 <!--		<table tableName="oauth_client_details"/>-->
-		<table tableName="user">
-			<columnOverride column="platform_type"  javaType="java.lang.Integer"/>
-			<columnOverride column="account_type"  javaType="java.lang.Integer"/>
-			<columnOverride column="account_source" javaType="java.lang.Integer"/>
-			<columnOverride column="remark" javaType="java.lang.String" jdbcType="VARCHAR"/>
-		</table>
+<!--		<table tableName="user">-->
+<!--			<columnOverride column="platform_type"  javaType="java.lang.Integer"/>-->
+<!--			<columnOverride column="account_type"  javaType="java.lang.Integer"/>-->
+<!--			<columnOverride column="account_source" javaType="java.lang.Integer"/>-->
+<!--			<columnOverride column="remark" javaType="java.lang.String" jdbcType="VARCHAR"/>-->
+<!--		</table>-->
 <!--		<table tableName="user_subscription_info">-->
 <!--			<columnOverride column="platform" javaType="java.lang.Integer"/>-->
 <!--			<columnOverride column="status" javaType="java.lang.Integer"/>-->
 <!--			<columnOverride column="pay_type" javaType="java.lang.Integer"/>-->
 <!--		</table>-->
-
+		<table tableName="order_gift"/>
 <!--		<table tableName="vpp_company">-->
 <!--		</table>-->
 <!--		<table tableName="login_device"/>-->

+ 6 - 6
pdf-office-sso/src/main/java/cn/kdan/cloud/pdf/office/sso/service/impl/AuthServiceImpl.java

@@ -659,7 +659,7 @@ public class AuthServiceImpl implements AuthService {
     @Override
     public boolean getVerifyCode(EmailCodeTypeEnum action, VerifyTypeEnum type, String receiver, String appId) {
         boolean flag = false;
-        if (redisUtils.hexists(CommonConstant.VERIFY_CODE_TIME_OUT + action.value() + CommonConstant.STRING_SIGN_COLON + appId, receiver)) {
+        if (redisUtils.hexists(CommonConstant.VERIFY_CODE_TIME_OUT + action.value() + CommonConstant.STRING_SIGN_COLON + appId, receiver.toLowerCase())) {
             throw new BackendRuntimeException(ExceptionEnum.VERIFY_CODE_SEND_TOO_QUICKLY);
         }
         String code = CommonUtils.generateVerifyCode();
@@ -683,9 +683,9 @@ public class AuthServiceImpl implements AuthService {
         }
         //存入缓存
         if (flag) {
-            redisUtils.hset(CommonConstant.EMAIL_VERIFY_CODE_KEY + action.value() + CommonConstant.STRING_SIGN_COLON + appId, receiver, code, AuthConstant.VERIFY_CODE_KEY_EXPIRE_TIME);
+            redisUtils.hset(CommonConstant.EMAIL_VERIFY_CODE_KEY + action.value() + CommonConstant.STRING_SIGN_COLON + appId, receiver.toLowerCase(), code, AuthConstant.VERIFY_CODE_KEY_EXPIRE_TIME);
             //再次发送计时
-            redisUtils.hset(CommonConstant.VERIFY_CODE_TIME_OUT + action.value() + CommonConstant.STRING_SIGN_COLON + appId , receiver, "1", AuthConstant.VERIFY_CODE_KEY_RESEND_TIME);
+            redisUtils.hset(CommonConstant.VERIFY_CODE_TIME_OUT + action.value() + CommonConstant.STRING_SIGN_COLON + appId , receiver.toLowerCase(), "1", AuthConstant.VERIFY_CODE_KEY_RESEND_TIME);
         }
         return flag;
     }
@@ -811,10 +811,10 @@ public class AuthServiceImpl implements AuthService {
     @Override
     public void checkEmailCodeValid(EmailCodeTypeEnum type, String account, String code, String appId) {
         //获取用户存在redis中的登录邮箱验证码
-        String captchaCode = redisUtils.hget(CommonConstant.EMAIL_VERIFY_CODE_KEY + type.value() + CommonConstant.STRING_SIGN_COLON + appId, account);
+        String captchaCode = redisUtils.hget(CommonConstant.EMAIL_VERIFY_CODE_KEY + type.value() + CommonConstant.STRING_SIGN_COLON + appId, account.toLowerCase());
         if(StringUtils.isNotEmpty(code) && code.equals(captchaCode)){
             if(!type.value().equals("member_login")){
-                redisUtils.hdel(CommonConstant.EMAIL_VERIFY_CODE_KEY + type.value() + CommonConstant.STRING_SIGN_COLON + appId, account);
+                redisUtils.hdel(CommonConstant.EMAIL_VERIFY_CODE_KEY + type.value() + CommonConstant.STRING_SIGN_COLON + appId, account.toLowerCase());
             }
             //验证通过删除
         }else{
@@ -832,7 +832,7 @@ public class AuthServiceImpl implements AuthService {
     @Override
     public void isEmailCodeValid(EmailCodeTypeEnum type, String account, String code, String appId) {
         //获取用户存在redis中的登录邮箱验证码
-        String captchaCode = redisUtils.hget(CommonConstant.EMAIL_VERIFY_CODE_KEY + type.value() + CommonConstant.STRING_SIGN_COLON + appId, account);
+        String captchaCode = redisUtils.hget(CommonConstant.EMAIL_VERIFY_CODE_KEY + type.value() + CommonConstant.STRING_SIGN_COLON + appId, account.toLowerCase());
         if(StringUtils.isNotEmpty(code) && !code.equals(captchaCode)){
             throw new BackendRuntimeException(ExceptionEnum.EMAIL_VERIFY_CODE_KEY_ERROR);
         }