Browse Source

Merge branch 'develop'

songfuqiang 1 year ago
parent
commit
63763ce4c8
26 changed files with 169 additions and 24 deletions
  1. 1 1
      backend-common/src/main/java/constant/CommonConstant.java
  2. 1 0
      backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/AdvertisementController.java
  3. 1 0
      backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/AuthController.java
  4. 2 4
      backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/AvatarController.java
  5. 2 4
      backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/ConvertTypeController.java
  6. 2 4
      backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/DeviceController.java
  7. 1 0
      backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/MembersController.java
  8. 1 0
      backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/MissionController.java
  9. 1 0
      backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/MissionFilesController.java
  10. 1 0
      backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/OrderController.java
  11. 1 0
      backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/PricingController.java
  12. 1 0
      backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/SetPricingController.java
  13. 1 0
      backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/SubscriptionController.java
  14. 1 1
      backend-core/src/main/java/cn/kdan/pdf/backend/core/enums/CaptchaActionEnum.java
  15. 6 0
      backend-core/src/main/java/cn/kdan/pdf/backend/core/mapper/ext/ExtMissionFilesMapper.java
  16. 13 3
      backend-core/src/main/java/cn/kdan/pdf/backend/core/service/impl/AlipayServiceImpl.java
  17. 9 0
      backend-core/src/main/java/cn/kdan/pdf/backend/core/service/impl/AuthServiceImpl.java
  18. 8 3
      backend-core/src/main/java/cn/kdan/pdf/backend/core/service/impl/AvatarServiceImpl.java
  19. 1 1
      backend-core/src/main/java/cn/kdan/pdf/backend/core/service/impl/MissionFileServiceImpl.java
  20. 6 2
      backend-core/src/main/java/cn/kdan/pdf/backend/core/service/impl/MissionServiceImpl.java
  21. 23 0
      backend-core/src/main/java/cn/kdan/pdf/backend/core/utils/CommonBusinessUtils.java
  22. 4 0
      backend-core/src/main/resources/application-pro-db.properties
  23. 9 0
      backend-core/src/main/resources/application-pro-redis.properties
  24. 65 0
      backend-core/src/main/resources/application-pro.yml
  25. 1 1
      backend-core/src/main/resources/application-test-db.properties
  26. 7 0
      backend-core/src/main/resources/sqlmap/ext/ExtMissionFilesMapper.xml

+ 1 - 1
backend-common/src/main/java/constant/CommonConstant.java

@@ -115,7 +115,7 @@ public interface CommonConstant {
     String verifyMessage = "您正在%s,验证码为%s,十五分钟后失效。请您按照提示填写验证码,切勿将验证码泄露于他人。";
 
     String resetPasswordEmailTemplate = "<p>尊敬的用户您好:</p>\n" +
-            "<p>请点击下方的链接以便对您的17PDF Reader(Staging)账号密码进行重置</p>\n" +
+            "<p>请点击下方的链接以便对您的17PDF Reader账号密码进行重置</p>\n" +
             "<table class=\"btn-primary\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n" +
             "  <tr>\n" +
             "    <td>\n" +

+ 1 - 0
backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/AdvertisementController.java

@@ -15,6 +15,7 @@ import java.util.List;
  * @author sfq
  * @description
  */
+@CrossOrigin(origins = "*")
 @RestController
 @RequestMapping("/advertisement")
 public class AdvertisementController {

+ 1 - 0
backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/AuthController.java

@@ -25,6 +25,7 @@ import java.io.IOException;
 /**
  * @author tangxiangan
  */
+@CrossOrigin(origins = "*")
 @RestController
 @RequestMapping("/auth")
 public class AuthController {

+ 2 - 4
backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/AvatarController.java

@@ -6,10 +6,7 @@ import cn.kdan.pdf.backend.core.service.AvatarService;
 import constant.CommonConstant;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 import pojo.AppResultMap;
 
@@ -19,6 +16,7 @@ import java.util.List;
  * @author sfq
  * @description
  */
+@CrossOrigin(origins = "*")
 @RestController
 @RequestMapping("/avatar")
 public class AvatarController {

+ 2 - 4
backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/ConvertTypeController.java

@@ -7,15 +7,13 @@ import cn.kdan.pdf.backend.core.service.ConvertFileService;
 import constant.CommonConstant;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import pojo.AppResultMap;
 import pojo.ResultMap;
 
 import java.util.List;
 
+@CrossOrigin(origins = "*")
 @RestController
 @RequestMapping("/convertType")
 public class ConvertTypeController {

+ 2 - 4
backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/DeviceController.java

@@ -4,10 +4,7 @@ import cn.kdan.pdf.backend.core.params.RelationParam;
 import cn.kdan.pdf.backend.core.service.DeviceService;
 import constant.CommonConstant;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import pojo.AppRequestParam;
 import pojo.AppResultMap;
 import pojo.Device;
@@ -16,6 +13,7 @@ import pojo.Device;
  * @author sfq
  * @description
  */
+@CrossOrigin(origins = "*")
 @RestController
 @RequestMapping("/device")
 public class DeviceController {

+ 1 - 0
backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/MembersController.java

@@ -28,6 +28,7 @@ import pojo.ResultMap;
 /**
  * @author tangxiangan
  */
+@CrossOrigin(origins = "*")
 @RestController
 @RequestMapping("/members")
 public class MembersController {

+ 1 - 0
backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/MissionController.java

@@ -11,6 +11,7 @@ import pojo.ResultMap;
 
 import java.util.List;
 
+@CrossOrigin(origins = "*")
 @RestController
 @RequestMapping("/mission")
 public class MissionController {

+ 1 - 0
backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/MissionFilesController.java

@@ -26,6 +26,7 @@ import java.util.Map;
 /**
  * @author tangxiangan
  */
+@CrossOrigin(origins = "*")
 @RestController
 @RequestMapping("/missionFile")
 public class MissionFilesController {

+ 1 - 0
backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/OrderController.java

@@ -13,6 +13,7 @@ import javax.validation.constraints.NotBlank;
 /**
  * @author tangxiangan
  */
+@CrossOrigin(origins = "*")
 @RestController
 @RequestMapping("/order")
 public class OrderController {

+ 1 - 0
backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/PricingController.java

@@ -13,6 +13,7 @@ import pojo.ResultMap;
 /**
  * @author songfuqiang
  */
+@CrossOrigin(origins = "*")
 @RestController
 @RequestMapping("/pricing")
 public class PricingController {

+ 1 - 0
backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/SetPricingController.java

@@ -14,6 +14,7 @@ import java.util.List;
 /**
  * @author tangxiangan
  */
+@CrossOrigin(origins = "*")
 @RestController
 @RequestMapping("/setPricing")
 public class SetPricingController {

+ 1 - 0
backend-core/src/main/java/cn/kdan/pdf/backend/core/controller/SubscriptionController.java

@@ -17,6 +17,7 @@ import javax.annotation.Resource;
 /**
  * @author tangxiangan
  */
+@CrossOrigin(origins = "*")
 @RestController
 @RequestMapping("/subscription")
 public class SubscriptionController {

+ 1 - 1
backend-core/src/main/java/cn/kdan/pdf/backend/core/enums/CaptchaActionEnum.java

@@ -8,7 +8,7 @@ public enum CaptchaActionEnum {
     //注册用户
     USER_REGISTER("0", "注册用户", "PDF Reader - 验证您的电子邮件!"),
     //忘记密码
-    FORGET_PASSWORD("1", "忘记密码", "17PDF Reader(Staging)账号密码重置");
+    FORGET_PASSWORD("1", "忘记密码", "17PDF Reader账号密码重置");
 
     private final String value;
     private final String action;

+ 6 - 0
backend-core/src/main/java/cn/kdan/pdf/backend/core/mapper/ext/ExtMissionFilesMapper.java

@@ -34,4 +34,10 @@ public interface ExtMissionFilesMapper extends MissionFilesMapper {
      * @param status 状态
      */
     void updateByProcessId(@Param("processId") String processId, @Param("status") Integer status);
+
+    /**
+     * 查询出总转档文件数
+     * @return 文件数
+     */
+    long selectTotalFile();
 }

+ 13 - 3
backend-core/src/main/java/cn/kdan/pdf/backend/core/service/impl/AlipayServiceImpl.java

@@ -4,6 +4,7 @@ import cn.kdan.pdf.backend.core.constant.OrderConstant;
 import cn.kdan.pdf.backend.core.enums.ClientEnum;
 import cn.kdan.pdf.backend.core.model.Subscriptions;
 import cn.kdan.pdf.backend.core.service.AlipayService;
+import cn.kdan.pdf.backend.core.utils.CommonBusinessUtils;
 import com.alibaba.fastjson.JSONObject;
 import com.alipay.api.AlipayApiException;
 import com.alipay.api.AlipayClient;
@@ -19,6 +20,7 @@ import com.alipay.api.response.AlipayTradeQueryResponse;
 import enums.CommonEnum;
 import exception.BackendRuntimeException;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Service;
@@ -38,6 +40,8 @@ public class AlipayServiceImpl implements AlipayService {
     @Autowired
     private Environment config;
 
+    private static final String rightUrl = "http://17pdf.com/";
+
     /**
      * 支付宝开放平台接收 request 请求对象后
      * 会为开发者生成一个html形式的form表单,包含自动提交的脚本
@@ -77,13 +81,19 @@ public class AlipayServiceImpl implements AlipayService {
             request = new AlipayTradeAppPayRequest();
         }
 //        AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
+//        String outUrl = CommonBusinessUtils.getOutUrl();
+        String property = "";
         if(CommonEnum.SubscriptionTypeEnum.SET_PRICING.value().equals(subscription.getTargetType())){
-            request.setReturnUrl(config.getProperty("ali.pay.setPricingReturnUrl"));
+            property = config.getProperty("ali.pay.setPricingReturnUrl");
         }else if(CommonEnum.SubscriptionTypeEnum.PRICING.value().equals(subscription.getTargetType())){
-            request.setReturnUrl(config.getProperty("ali.pay.pricingReturnUrl"));
+            property = config.getProperty("ali.pay.pricingReturnUrl");
         }else{
-            request.setReturnUrl(config.getProperty("ali.pay.returnUrl"));
+            property = config.getProperty("ali.pay.returnUrl");
         }
+//        if(StringUtils.isNotBlank(outUrl)){
+//            property = property.replace(rightUrl,outUrl);
+//        }
+        request.setReturnUrl(property);
         //设置回调return_url、响应url
         request.setNotifyUrl(config.getProperty("ali.pay.notifyUrl"));
         request.setBizModel(model);

+ 9 - 0
backend-core/src/main/java/cn/kdan/pdf/backend/core/service/impl/AuthServiceImpl.java

@@ -19,9 +19,12 @@ import cn.kdan.pdf.backend.core.pojo.third.Wechat;
 import cn.kdan.pdf.backend.core.properties.Oauth2LoginProperties;
 import cn.kdan.pdf.backend.core.service.*;
 import cn.kdan.pdf.backend.core.utils.CommonBusinessUtils;
+import cn.kdan.pdf.backend.core.utils.HttpClientUtils;
 import cn.kdan.pdf.backend.core.utils.TencentUtils;
 import cn.kdan.pdf.backend.core.utils.TokenUtils;
 import cn.kdan.pdf.backend.core.utils.WechatUtils;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
 import constant.CommonConstant;
 import enums.ValidStatusEnum;
 import exception.BackendRuntimeException;
@@ -58,6 +61,7 @@ import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 import java.awt.image.BufferedImage;
 import java.io.IOException;
+import java.net.URL;
 import java.security.Principal;
 import java.util.*;
 
@@ -220,6 +224,11 @@ public class AuthServiceImpl implements AuthService {
                 if(!CommonBusinessUtils.verifyBlackEmail(receiver)) {
                     //忘记密码时邮箱验证 发送重置密码邮件
                     if (CaptchaActionEnum.FORGET_PASSWORD.value().equals(action.value())) {
+//                        // 上线后再改回来,不再使用cn.17pdf.com
+//                        String outUrl = CommonBusinessUtils.getOutUrl();
+//                        if (StringUtils.isNotBlank(outUrl)) {
+//                            url = outUrl;
+//                        }
                         String content = String.format(CommonConstant.resetPasswordEmailTemplate, url + "resetPsw?verifyCode=" + code + "&account=" + receiver);
                         flag = emailUtils.sendMail(action.subject(), content, Collections.singletonList(receiver));
                     } else {

+ 8 - 3
backend-core/src/main/java/cn/kdan/pdf/backend/core/service/impl/AvatarServiceImpl.java

@@ -43,6 +43,8 @@ public class AvatarServiceImpl implements AvatarService {
     @Autowired
     private OssProperties ossProperties;
 
+    private static String defaultAvatarUrl = "avatars/2018/01/02/f183029426a996325853fa244e7df661.jpg";
+
     // 图片文件类型
     public static String IMG_TYPE_PNG = "PNG";
     public static String IMG_TYPE_JPG = "JPG";
@@ -55,7 +57,8 @@ public class AvatarServiceImpl implements AvatarService {
     @Override
     public List<Avatars> list() {
         AvatarsExample example = new AvatarsExample();
-        example.createCriteria().andMemberIdIsNull();
+        AvatarsExample.Criteria criteria = example.createCriteria();
+        criteria.andMemberIdIsNull().andNumberNotEqualTo(0).andAppScopeEqualTo(1);
         List<Avatars> avatars = avatarsMapper.selectByExample(example);
         String viewUrl = ossProperties.getViewUrl();
         for (Avatars avatar : avatars) {
@@ -99,9 +102,11 @@ public class AvatarServiceImpl implements AvatarService {
         Date now = new Date();
         if(!CollectionUtils.isEmpty(list)){
             Avatars avatars = list.get(0);
-            // 将用户原来的头像数据先删除
+            // 将用户原来的头像数据先删除,默认头像不删除
             String oldUrl = avatars.getAvatar();
-            ossFileClient.delete(oldUrl);
+            if(!defaultAvatarUrl.equals(oldUrl)){
+                ossFileClient.delete(oldUrl);
+            }
             avatars.setAvatar(ossFileName);
             avatars.setUpdatedAt(now);
             avatarsMapper.updateByPrimaryKey(avatars);

+ 1 - 1
backend-core/src/main/java/cn/kdan/pdf/backend/core/service/impl/MissionFileServiceImpl.java

@@ -141,7 +141,7 @@ public class MissionFileServiceImpl implements MissionFilesService {
     @Override
     public Integer getTotalConvertFile() {
         MissionFilesExample example = new MissionFilesExample();
-        long l = missionFilesMapper.countByExample(example);
+        long l = missionFilesMapper.selectTotalFile();
         return (int)l;
     }
 

+ 6 - 2
backend-core/src/main/java/cn/kdan/pdf/backend/core/service/impl/MissionServiceImpl.java

@@ -299,7 +299,7 @@ public class MissionServiceImpl implements MissionService {
             for (FileInfoDto file : list) {
                 MissionFiles missionFiles = missionFilesService.queryByProcessId(file.getFileKey());
                 if("success".equals(file.getStatus())){
-                    if(!missionFiles.getStatus().equals(MissionFileStatusEnum.SUCCESS.value())) {
+                    if(!MissionFileStatusEnum.SUCCESS.value().equals(missionFiles.getStatus())) {
                         //成功的话修改本地missionFile表状态
                         //修改missionFile对象信息(convert_end_at,convert_at)
                         missionFiles.setOutFilename(file.getDownFileName());
@@ -320,10 +320,13 @@ public class MissionServiceImpl implements MissionService {
                         outputFileService.insert(outputFile);
                     }
                 }else if ("failed".equals(file.getStatus())){
-                    //先查询文件状态是否已更新成失败状态,已更新则不返回券数
+                    //先查询文件状态是否已更新成失败状态,已更新为失败状态,但是价格没改回0的文件继续返回券数
                     if(!MissionFileStatusEnum.FAILED.value().equals(missionFiles.getStatus())){
                         //修改文件状态为失败
                         fileFailUpdate(members, file, missionFiles,false);
+                    }else if(MissionFileStatusEnum.FAILED.value().equals(missionFiles.getStatus()) && 0 != missionFiles.getPrice()){
+                        //修改文件状态为失败
+                        fileFailUpdate(members, file, missionFiles,false);
                     }
                 } else{
                     // 如果文件超时15分钟,将文件设置为转档失败
@@ -344,6 +347,7 @@ public class MissionServiceImpl implements MissionService {
      * @param flag 是否超时
      */
     private void fileFailUpdate(Members members, FileInfoDto file, MissionFiles missionFiles, boolean flag) {
+        log.info("文件转档更新失败原因,missionFileId:{}", missionFiles.getId());
         missionFiles.setStatus(MissionFileStatusEnum.FAILED.value());
         if(flag){
             missionFiles.setFailReason("文件转换失败:文件转换超时");

+ 23 - 0
backend-core/src/main/java/cn/kdan/pdf/backend/core/utils/CommonBusinessUtils.java

@@ -1,9 +1,13 @@
 package cn.kdan.pdf.backend.core.utils;
 
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 import org.springframework.util.StringUtils;
 
+import java.util.Map;
+
 /**
  * @author sfq
  * @description
@@ -78,4 +82,23 @@ public class CommonBusinessUtils {
         return true;
     }
 
+    /**
+     * 获取临时url
+     * @return 返回临时url
+     */
+    public static String getOutUrl() {
+        String outUrl = "";
+        String url = "http://test-store.kdan.cn:3018/api/test17PDF";
+        try {
+            String s = HttpClientUtils.get(url);
+            Map<String, Object> map = JSONObject.parseObject(s, new TypeReference<Map<String, Object>>() {});
+            Map<String,String> data = (Map<String,String>)map.get("data");
+            outUrl = data.get("url");
+        } catch (Exception e) {
+//            outUrl = "http://17pdf.com/";
+            outUrl = "";
+        }
+        return outUrl;
+    }
+
 }

+ 4 - 0
backend-core/src/main/resources/application-pro-db.properties

@@ -0,0 +1,4 @@
+jdbc.driverClassName=com.mysql.cj.jdbc.Driver
+jdbc.url=jdbc\:mysql\://rm-uf6d6460w57jslo58co.mysql.rds.aliyuncs.com\:3306/e7pdf_backend_pro?autoReconnect\=true&&useSSL\=false
+jdbc.username=deployer
+jdbc.password=deployer@123!

+ 9 - 0
backend-core/src/main/resources/application-pro-redis.properties

@@ -0,0 +1,9 @@
+redis.max-redirects=3
+redis.maxIdle=100
+redis.connectionTimeout=100000
+redis.socketTimeout=100000
+redis.maxAttempts=5
+redis.maxTotal=200
+redis.minIdle=10
+redis.nodes=101.132.176.111:6371,101.132.176.111:6372,101.132.176.111:6373,101.132.176.111:6374,101.132.176.111:6375,101.132.176.111:6376
+redis.password=1qazZAQ2

File diff suppressed because it is too large
+ 65 - 0
backend-core/src/main/resources/application-pro.yml


+ 1 - 1
backend-core/src/main/resources/application-test-db.properties

@@ -1,4 +1,4 @@
 jdbc.driverClassName=com.mysql.cj.jdbc.Driver
 jdbc.url=jdbc\:mysql\://139.196.160.101\:33056/17pdf_backend_test?autoReconnect\=true&&useSSL\=false
 jdbc.username=root
-jdbc.password=root123
+jdbc.password=Kdan123456!

+ 7 - 0
backend-core/src/main/resources/sqlmap/ext/ExtMissionFilesMapper.xml

@@ -58,4 +58,11 @@
         set status = #{status}, updated_at = now()
         where process_id = #{processId}
     </update>
+
+    <select id="selectTotalFile" resultType="long">
+        select
+            count(created_at)
+        from
+             mission_files
+    </select>
 </mapper>