Browse Source

2.2.1版本,前端列表返回和新接口,调用运营后台

Bob 11 months ago
parent
commit
92b88e6a39

+ 5 - 0
pdf-tech-core/pom.xml

@@ -52,6 +52,11 @@
             <artifactId>spring-boot-starter-aop</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.squareup.okhttp3</groupId>
+            <artifactId>okhttp</artifactId>
+            <version>3.10.0</version>
+        </dependency>
 
         <!-- logback  -->
         <dependency>

+ 10 - 0
pdf-tech-core/src/main/java/cn/kdan/pdf/tech/core/controller/VppMemberController.java

@@ -37,6 +37,16 @@ public class VppMemberController {
         return new ResultMap<>(CommonConstant.SUCCESS, AuthConstant.SUCCESS_MSG_Register, vppMemberService.create(param));
     }
 
+    /**
+     * 试用超管注册
+     * @param param 用户注册入参
+     * @return 用户注册出参
+     */
+    @PostMapping("/createTrial")
+    public ResultMap<Boolean> createTrial(@RequestBody VppMemberRegisterParam param) {
+        return new ResultMap<>(CommonConstant.SUCCESS, AuthConstant.SUCCESS_MSG_Register, vppMemberService.createTrial(param));
+    }
+
     /**
      * 用于忘记密码时重置密码
      *

+ 22 - 0
pdf-tech-core/src/main/java/cn/kdan/pdf/tech/core/params/VppMemberRegisterParam.java

@@ -10,18 +10,40 @@ import java.util.List;
  */
 @Data
 public class VppMemberRegisterParam {
+    /**
+     * 用户名
+     */
     private String username;
 
+    /**
+     * 密码
+     */
     private String password;
 
     private String confirmPassword;
 
+    /**
+     * 邮箱
+     */
     private String email;
 
     private String verifyCode;
 
+    private String job;
+
+    /**
+     * 平台 1 mac 2 win
+     */
+    private Integer[] platform;
+
+    /**
+     * 行业
+     */
     private String industry;
 
+    /**
+     * 公司,组织,默认团队名
+     */
     private String company;
 
     /**

+ 1 - 0
pdf-tech-core/src/main/java/cn/kdan/pdf/tech/core/pojo/vo/SubscriptionVO.java

@@ -25,5 +25,6 @@ public class SubscriptionVO {
 
     private Integer availableDeviceAmount;
 
+    private Integer detailType;
 
 }

+ 7 - 0
pdf-tech-core/src/main/java/cn/kdan/pdf/tech/core/service/VppMemberService.java

@@ -40,6 +40,13 @@ public interface VppMemberService extends BeanConverter<VppMember, UserInfo> {
      */
     VppMember create(VppMemberRegisterParam param);
 
+    /**
+     * 试用管理员注册
+     * @param param
+     * @return
+     */
+    Boolean createTrial(VppMemberRegisterParam param);
+
     /**
      * 更新用户信息
      *

+ 29 - 3
pdf-tech-core/src/main/java/cn/kdan/pdf/tech/core/service/impl/VppMemberServiceImpl.java

@@ -19,6 +19,8 @@ import cn.kdan.pdf.tech.core.service.VppRTeamMemberRoleService;
 import cn.kdan.pdf.tech.core.service.VppTeamService;
 import cn.kdan.pdf.tech.core.utils.RSAUtils;
 import cn.kdan.pdf.tech.core.utils.ThreadPoolSingleUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import constant.CommonConstant;
 import enums.ValidStatusEnum;
 import exception.BackendRuntimeException;
@@ -26,6 +28,8 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.*;
+import org.springframework.http.MediaType;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.stereotype.Service;
@@ -33,15 +37,14 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.ObjectUtils;
 import org.springframework.util.StringUtils;
+import org.springframework.web.client.RestTemplate;
 import pojo.CustomUserDetails;
 import utils.CommonUtils;
 import cn.kdan.pdf.tech.core.utils.EmailUtils;
 import utils.RedisUtils;
 
 import javax.annotation.Resource;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 
 /**
@@ -148,6 +151,29 @@ public class VppMemberServiceImpl implements VppMemberService {
         return vppMember;
     }
 
+    @Override
+    public Boolean createTrial(VppMemberRegisterParam param) {
+        // 校验
+        validRegisterParam(param);
+        // 发送http请求
+        RestTemplate restTemplate = new RestTemplate();
+        String url = emailImagesUrl + "/api/vpp_members/register";
+        String jsonString = JSON.toJSONString(param);
+        log.info("调用运营后台创建试用用户接口 url:{},json:{}", url, jsonString);
+        HttpHeaders headers = new HttpHeaders();
+        headers.setContentType(MediaType.APPLICATION_JSON);
+        headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE);
+        HttpEntity<String> request = new HttpEntity<>(jsonString, headers);
+        ResponseEntity<JSONObject> response = restTemplate
+                .exchange(url, HttpMethod.POST, request, JSONObject.class);
+        log.info("result:" + response.getStatusCodeValue());
+        if (!response.getStatusCode().is2xxSuccessful()) {
+            log.error("调用运营后台创建试用用户接口失败,返回状态码:{},返回内容:{}", response.getStatusCode(), response.getBody());
+            return null;
+        }
+        return Boolean.TRUE;
+    }
+
     @Override
     public void insert(VppMember vppMember) {
         vppMemberMapper.insert(vppMember);

+ 2 - 1
pdf-tech-core/src/main/resources/sqlmap/ext/ExtSubscriptionMapper.xml

@@ -13,9 +13,10 @@
   </resultMap>
 
   <select id="listByCompany" resultMap="BaseResultMap">
-    select vod.id, p.code, p.name, vod.price, vod.payment, vod.created_at, vod.max_device_amount quantity, vod.end_date expiration_at
+    select vod.id, p.code, p.name, vod.price, vod.payment, vod.created_at, vod.max_device_amount quantity, vod.end_date expiration_at, o.detail_type detailType
     from subscriptions vod
     left join products p on p.id = vod.product_id
+    left join orders o on o.subscription_id = vod.id and o.status = '2'
     where vod.company_id = #{companyId} and p.code != 'com.brother.pdfreaderpro.combination.product'
     <if test="code != null and code != ''">
       and p.code = #{code}