Browse Source

合同预览

guomengjiao 6 months ago
parent
commit
c82de4e520

+ 1 - 0
ruoyi-admin/src/main/resources/application-dev.yml

@@ -254,6 +254,7 @@ jzq:
   applySign: /v2/sign/applySign
   organizationCreate: /v2/user/organizationCreate
   cloudCertiPerInfo: /v2/user/cloudCertiPerInfo
+  tmplPre: /v2/tmpl/pre
 
 fubei:
   appId: 6927ab8bbdaa24db3fb4f511

+ 9 - 0
ruoyi-api/src/main/java/com/ruoyi/api/controller/shop/ApiAgentApplyController.java

@@ -94,6 +94,15 @@ public class ApiAgentApplyController extends AbstractApiController {
         return toAjax(iAgentApplyService.updateByBo(bo) ? 1 : 0);
     }
 
+    /**
+     * 合同预览
+     */
+    @ApiOperation("合同预览")
+    @PostMapping("/contract/preview")
+    public R<String> contractPreview(@Validated @RequestBody AgentApplyBo bo) {
+        return R.ok(iAgentApplyService.contractPreview(bo));
+    }
+
     /**
      * 审核代理申请
      */

+ 2 - 2
ruoyi-api/src/main/java/com/ruoyi/api/controller/user/ApiUserLoginController.java

@@ -58,7 +58,7 @@ public class ApiUserLoginController extends AbstractApiController {
     @ApiOperation("获取小程序openId")
     @PostMapping("/user/getOpenId")
     public R<Map<String, Object>> getOpenId(@RequestBody WxUserDto dto) {
-        String openId = userService.getOpenId(dto.getCode());
+        String openId = userService.getOpenId(dto.getCode(), dto.getAppId());
         Map<String, Object> stringObjectHashMap = new HashMap<>();
         stringObjectHashMap.put("openId", openId);
         return R.ok(stringObjectHashMap);
@@ -83,7 +83,7 @@ public class ApiUserLoginController extends AbstractApiController {
     @ApiOperation("小程序获取手机号")
     @PostMapping("/user/phone")
     public R<Map<String, Object>> wxPhone(@RequestBody WxUserDto dto) {
-        WxMaPhoneNumberInfo wxMaPhoneNumberInfo = wxUserService.getPhoneByCode(dto.getCode());
+        WxMaPhoneNumberInfo wxMaPhoneNumberInfo = wxUserService.getPhoneByCode(dto.getCode(), dto.getAppId());
         HashMap<String, Object> result = new HashMap<>();
         result.put("phone", wxMaPhoneNumberInfo.getPhoneNumber());
         return R.ok(result);

+ 2 - 0
ruoyi-business/src/main/java/com/ruoyi/agent/service/IAgentApplyService.java

@@ -77,4 +77,6 @@ public interface IAgentApplyService {
     Boolean audit(AgentApplyBo bo);
 
     AgentApplyVo queryByUserId(Long userId);
+
+    String contractPreview(AgentApplyBo bo);
 }

+ 37 - 4
ruoyi-business/src/main/java/com/ruoyi/agent/service/impl/AgentApplyServiceImpl.java

@@ -3,6 +3,7 @@ package com.ruoyi.agent.service.impl;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.json.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -17,22 +18,22 @@ import com.ruoyi.agent.exception.AgentApplyExceptionEnum;
 import com.ruoyi.agent.mapper.AgentApplyMapper;
 import com.ruoyi.agent.service.IAgentApplyService;
 import com.ruoyi.agent.service.IAgentService;
+import com.ruoyi.base.platform.domain.vo.PlatformInfoVo;
+import com.ruoyi.base.platform.service.IPlatformInfoService;
 import com.ruoyi.common.core.domain.PageQuery;
 import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.enums.AuditStatus;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.BeanCopyUtils;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.tool.service.JzqService;
 import lombok.RequiredArgsConstructor;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 代理申请Service业务层处理
@@ -48,6 +49,8 @@ public class AgentApplyServiceImpl implements IAgentApplyService {
     @Lazy
     @Resource
     private IAgentService agentService;
+    private final IPlatformInfoService platformInfoService;
+    private final JzqService jzqService;
 
     /**
      * 查询代理申请分页
@@ -255,4 +258,34 @@ public class AgentApplyServiceImpl implements IAgentApplyService {
         return agentApplyVo;
     }
 
+    @Override
+    public String contractPreview(AgentApplyBo bo) {
+        PlatformInfoVo platformInfoVo = platformInfoService.getInfo();
+        JSONObject templateParams = new JSONObject();
+        templateParams.set("enterpriseFullName", platformInfoVo.getEnterpriseFullName());
+        templateParams.set("legalPersonName", platformInfoVo.getLegalPersonName());
+        templateParams.set("uscCode", platformInfoVo.getUscCode());
+        templateParams.set("contractSigner", platformInfoVo.getContractSigner());
+        templateParams.set("signerMobile", platformInfoVo.getSignerMobile());
+        templateParams.set("registeredAddress", platformInfoVo.getRegisteredAddress());
+        templateParams.set("agentLevel", bo.getAgentLevel().getMsg());
+        templateParams.set("idCard", bo.getIdCard());
+        templateParams.set("realName", bo.getRealName());
+        templateParams.set("phone", bo.getPhone());
+        templateParams.set("provinceName", bo.getProvinceName());
+        templateParams.set("areaName", bo.getAreaName());
+        templateParams.set("bankName", platformInfoVo.getBankName());
+        templateParams.set("subBranchName", platformInfoVo.getSubBranchName());
+        templateParams.set("bankCardNumber", platformInfoVo.getBankCardNumber());
+        //构建请求参数
+        Map<String, Object> params = new HashMap<>();
+        if (AgentLevel.PROVINCE_AGENT.equals(bo.getAgentLevel())) {
+            params.put("templateNo", "4");
+        } else {
+            params.put("templateNo", "2");
+        }
+        params.put("contractParams", templateParams.toString());
+        return jzqService.tmplPre(params);
+    }
+
 }

+ 4 - 0
ruoyi-tool/src/main/java/com/ruoyi/tool/config/JzqProperties.java

@@ -53,4 +53,8 @@ public class JzqProperties {
      * 个人证书申请资料上传
      */
     private String cloudCertiPerInfo;
+    /**
+     * 合同模版预览
+     */
+    private String tmplPre;
 }

+ 10 - 0
ruoyi-tool/src/main/java/com/ruoyi/tool/service/JzqService.java

@@ -155,4 +155,14 @@ public class JzqService {
         }
         return null;
     }
+
+    public String tmplPre(Map<String, Object> params) {
+        RequestUtils requestUtils = RequestUtils.init(jzqProperties.getBaseUrl(), jzqProperties.getAppKey(), jzqProperties.getAppSecret());
+        ResultInfo<String> ri = requestUtils.doPost(jzqProperties.getTmplPre(), params);
+        log.info("模板预览:{}", ri.getMsg());
+        if (ri.isSuccess()) {
+            return ri.getData();
+        }
+        return null;
+    }
 }

+ 1 - 1
ruoyi-user/src/main/java/com/ruoyi/user/service/IUserService.java

@@ -122,7 +122,7 @@ public interface IUserService {
      */
     User changeUserIntegral(User user, Integer integral, Boolean isAdd);
 
-    String getOpenId(String code);
+    String getOpenId(String code, String appId);
 
     User loginAuthorization(String openId);
 

+ 2 - 2
ruoyi-user/src/main/java/com/ruoyi/user/service/impl/UserServiceImpl.java

@@ -365,8 +365,8 @@ public class UserServiceImpl implements IUserService {
     }
 
     @Override
-    public String getOpenId(String code) {
-        return  wxUserService.getOpenIdByCode(code);
+    public String getOpenId(String code, String appId) {
+        return  wxUserService.getOpenIdByCode(code, appId);
     }
 
     @Override

+ 3 - 0
ruoyi-weixin/ruoyi-weixin-miniapp/src/main/java/com/ruoyi/weixin/domain/WxUserDto.java

@@ -31,6 +31,9 @@ public class WxUserDto implements Serializable {
     @NotBlank(message = "openId不能为空", groups = {RegGroup.class})
     private String openId;
 
+    @NotBlank(message = "appId不能为空", groups = {RegGroup.class})
+    private String appId;
+
     //微信用户信息
     /**
      * 昵称

+ 7 - 13
ruoyi-weixin/ruoyi-weixin-miniapp/src/main/java/com/ruoyi/weixin/service/WxUserService.java

@@ -20,12 +20,6 @@ import org.springframework.stereotype.Service;
 @Service
 public class WxUserService {
 
-    /**
-     * 微信app id
-     */
-    @Value("${wx.miniapp.configs[0].appid}")
-    private String appid;
-
     /**
      * 获取openid
      *
@@ -36,7 +30,7 @@ public class WxUserService {
         if (StringUtils.isBlank(wxUserDto.getCode())) {
             return null;
         }
-        final WxMaService wxService = WxMaConfiguration.getMaService(appid);
+        final WxMaService wxService = WxMaConfiguration.getMaService(wxUserDto.getAppId());
 
         try {
             WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(wxUserDto.getCode());
@@ -59,11 +53,11 @@ public class WxUserService {
      * @param code
      * @return
      */
-    public String getOpenIdByCode(String code) {
+    public String getOpenIdByCode(String code, String appId) {
         if (StringUtils.isBlank(code)) {
             return null;
         }
-        final WxMaService wxService = WxMaConfiguration.getMaService(appid);
+        final WxMaService wxService = WxMaConfiguration.getMaService(appId);
 
         try {
             WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(code);
@@ -82,7 +76,7 @@ public class WxUserService {
      * @return
      */
     public WxMaUserInfo getInfo(WxUserDto dto) {
-        final WxMaService wxService = WxMaConfiguration.getMaService(appid);
+        final WxMaService wxService = WxMaConfiguration.getMaService(dto.getAppId());
 
         // 用户信息校验
         if (!wxService.getUserService().checkUserInfo(dto.getSessionKey(), dto.getRawData(), dto.getSignature())) {
@@ -100,7 +94,7 @@ public class WxUserService {
      * @return
      */
     public WxMaPhoneNumberInfo getPhone(WxUserDto dto) {
-        final WxMaService wxService = WxMaConfiguration.getMaService(appid);
+        final WxMaService wxService = WxMaConfiguration.getMaService(dto.getAppId());
 
         // 用户信息校验
         if (!wxService.getUserService().checkUserInfo(dto.getSessionKey(), dto.getRawData(), dto.getSignature())) {
@@ -117,8 +111,8 @@ public class WxUserService {
      * @param code
      * @return
      */
-    public WxMaPhoneNumberInfo getPhoneByCode(String code) {
-        final WxMaService wxService = WxMaConfiguration.getMaService(appid);
+    public WxMaPhoneNumberInfo getPhoneByCode(String code, String appId) {
+        final WxMaService wxService = WxMaConfiguration.getMaService(appId);
         WxMaPhoneNumberInfo newPhoneNoInfo = null;
         try {
 //            newPhoneNoInfo = wxService.getUserService().getNewPhoneNoInfo(code);