Browse Source

Merge branch 'develop/v1.0' into master-test

tangxiangan 3 months ago
parent
commit
70475ff1a1

+ 2 - 1
pdf-office-email/src/main/java/cn/kdan/cloud/pdf/office/email/rabbit/listener/SendEmailListener.java

@@ -22,6 +22,7 @@ import org.springframework.mail.javamail.JavaMailSenderImpl;
 import org.springframework.mail.javamail.MimeMessageHelper;
 import org.springframework.stereotype.Component;
 
+import javax.mail.internet.InternetAddress;
 import javax.mail.internet.MimeMessage;
 import java.io.File;
 import java.net.URL;
@@ -84,7 +85,7 @@ import java.util.Objects;
             helper.setTo(emailSendBO.getToEmail());
             helper.setFrom(ObjectUtils.isEmpty(emailSendBO.getFromEmail())
                     ? Objects.requireNonNull(mailSender.getUsername())
-                    : emailSendBO.getFromEmail());
+                    : emailSendBO.getFromEmail(), "PDF Reader Pro");
             if(ObjectUtils.isNotEmpty(emailSendBO.getFileUrl())){
                 file = new File(emailSendBO.getFileName());
                 FileUtils.copyURLToFile(new URL(emailSendBO.getFileUrl()), file);

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

@@ -184,6 +184,7 @@ public class AppStoreServiceImpl implements AppStoreService {
             bo.setSendContent(contentMap);
             String file = sendInvoice(userVO.getEmail(),formattedDate,orderManualDTO.getTradeNo(),orderManualDTO.getInvoiceNo(),renewPrice,orderManualDTO.getPrice());
             bo.setFileUrl(file);
+            bo.setFileName("invoice.pdf");
             emailApi.sendEmail(bo);
         }else{
             EmailSendBO bo = new EmailSendBO();
@@ -216,6 +217,7 @@ public class AppStoreServiceImpl implements AppStoreService {
             bo.setSendContent(contentMap);
             String file = sendInvoice(userVO.getEmail(),formattedDate,orderManualDTO.getTradeNo(),orderManualDTO.getInvoiceNo(),renewPrice,orderManualDTO.getPrice());
             bo.setFileUrl(file);
+            bo.setFileName("invoice.pdf");
             emailApi.sendEmail(bo);
         }
     }

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

@@ -197,6 +197,7 @@ public class GooglePayServiceImpl implements GooglePayService {
             bo.setSendContent(contentMap);
             String file = sendInvoice(userVO.getEmail(),formattedDate,orderManualDTO.getTradeNo(),orderManualDTO.getInvoiceNo(),renewPrice,orderManualDTO.getPrice());
             bo.setFileUrl(file);
+            bo.setFileName("invoice.pdf");
             emailApi.sendEmail(bo);
         }else{
             EmailSendBO bo = new EmailSendBO();
@@ -229,6 +230,7 @@ public class GooglePayServiceImpl implements GooglePayService {
             bo.setSendContent(contentMap);
             String file = sendInvoice(userVO.getEmail(),formattedDate,orderManualDTO.getTradeNo(),orderManualDTO.getInvoiceNo(),renewPrice,orderManualDTO.getPrice());
             bo.setFileUrl(file);
+            bo.setFileName("invoice.pdf");
             emailApi.sendEmail(bo);
         }
     }

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

@@ -57,8 +57,10 @@
         SELECT COUNT(*)
         FROM subscription s
                  LEFT JOIN product p ON s.product_id = p.id
+                 LEFT JOIN `order` o on s.order_id  = o.id
         WHERE s.user_id = #{userId}
-             AND p.code not like '%ai%'
+          AND p.code not like '%ai%'
+          AND o.pay_number = 1
     </select>
     <select id="countAdvancedSubscriptions" resultMap="SubscriptionsResultMap">
         SELECT s.*,p.code

+ 10 - 0
pdf-office-pdf-website/src/main/java/cn/kdan/cloud/pdf/office/website/service/impl/ProductInfoServiceImpl.java

@@ -90,7 +90,9 @@ public class ProductInfoServiceImpl implements ProductInfoService {
         }
         // 筛选订单购买的产品中有没有vip订阅类型
         boolean hasVip = false;
+        UserSubscriptionInfoVO vipSubscriptionInfoVO = null;
         boolean hasSVip = false;
+        UserSubscriptionInfoVO sVipSubscriptionInfoVO = null;
         // 买断版  平台数
         int permanentPlatform = 0;
         for (UserSubscriptionInfoVO userSubscriptionInfoVO : userSubscriptionInfoVOList) {
@@ -109,8 +111,10 @@ public class ProductInfoServiceImpl implements ProductInfoService {
             } else {
                 if (StringUtils.isNotEmpty(userSubscriptionInfoVO.getLevels())&&userSubscriptionInfoVO.getLevels().contains("2")) {
                     hasVip = true;
+                    vipSubscriptionInfoVO = userSubscriptionInfoVO;
                 } else if (StringUtils.isNotEmpty(userSubscriptionInfoVO.getLevels())&&userSubscriptionInfoVO.getLevels().contains("3")) {
                     hasSVip = true;
+                    sVipSubscriptionInfoVO = userSubscriptionInfoVO;
                 }
             }
         }
@@ -127,6 +131,9 @@ public class ProductInfoServiceImpl implements ProductInfoService {
                         .anyMatch(userSubscriptionInfoVO -> userSubscriptionInfoVO.getPlatform().equals(2) && userSubscriptionInfoVO.getPayType() == 1)) {
                     throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_USER_ALREADY_SUBSCRIBED);
                 }
+                if (!sVipSubscriptionInfoVO.getProductId().equals(productId)) {
+                    throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_USER_ALREADY_SUBSCRIBED);
+                }
                 // svip原价提前续费
                 return listingProductVO;
             }
@@ -154,6 +161,9 @@ public class ProductInfoServiceImpl implements ProductInfoService {
                         .anyMatch(userSubscriptionInfoVO -> userSubscriptionInfoVO.getPlatform().equals(2) && userSubscriptionInfoVO.getPayType() == 1)) {
                     throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_USER_ALREADY_SUBSCRIBED);
                 }
+                if (!vipSubscriptionInfoVO.getProductId().equals(productId)) {
+                    throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_USER_ALREADY_SUBSCRIBED);
+                }
                 return listingProductVO;
             }
             // svip无法购买vip