From 3a5e49666af1da441633b0a9bae4c3c2b18974b3 Mon Sep 17 00:00:00 2001
From: sgj <1442489573@qq.com>
Date: 星期二, 14 四月 2026 16:05:41 +0800
Subject: [PATCH] 质押合同添加业务经理绑定,H5相关逻辑完善

---
 fzzy-igdss-web/src/main/java/com/fzzy/appwx/manager/WeChatManager.java |  112 +++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 74 insertions(+), 38 deletions(-)

diff --git a/fzzy-igdss-web/src/main/java/com/fzzy/appwx/manager/WeChatManager.java b/fzzy-igdss-web/src/main/java/com/fzzy/appwx/manager/WeChatManager.java
index 4eb73be..27322c9 100644
--- a/fzzy-igdss-web/src/main/java/com/fzzy/appwx/manager/WeChatManager.java
+++ b/fzzy-igdss-web/src/main/java/com/fzzy/appwx/manager/WeChatManager.java
@@ -7,26 +7,42 @@
 import com.fzzy.igds.constant.RespCodeEnum;
 import com.fzzy.igds.data.IgdsBaseParam;
 import com.fzzy.igds.data.PageResponse;
+import com.fzzy.igds.domain.PledgeContract;
+import com.fzzy.igds.domain.PledgeContractDepot;
 import com.fzzy.igds.domain.SnapReply;
+import com.fzzy.igds.service.PledgeContractDepotService;
+import com.fzzy.igds.service.PledgeContractService;
 import com.fzzy.igds.service.SnapReplyService;
+import com.google.code.kaptcha.Constants;
 import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.utils.ShiroUtils;
 import com.ruoyi.system.service.ISysUserService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
 import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
 
 @Component
 public class WeChatManager {
 
-    @Autowired
+    @Resource
     private WeChatUtil weChatUtil;
     @Autowired
     private ISysUserService sysUserService;
     @Resource
     private SnapReplyService snapReplyService;
+
+    @Resource
+    private PledgeContractService pledgeContractService;
+
+    @Resource
+    private PledgeContractDepotService pledgeContractDepotService;
 
 
     public String getOpenid(String code) {
@@ -69,8 +85,25 @@
         return new PageResponse(RespCodeEnum.CODE_0000.getCode(), "鏌ヨ鎴愬姛", user);
     }
 
+    //鏍¢獙楠岃瘉鐮�
+    public boolean validateResponse(HttpServletRequest request, String validateCode) {
+        // 鈶� 浠嶴ession鑾峰彇鐢熸垚鐨勯獙璇佺爜
+        Object obj = ShiroUtils.getSession().getAttribute(Constants.KAPTCHA_SESSION_KEY);
+        String code = String.valueOf(obj != null ? obj : "");
+
+        // 鈶� 绔嬪嵆娓呴櫎Session涓殑楠岃瘉鐮侊紙闃叉閲嶅浣跨敤锛�
+        request.getSession().removeAttribute(Constants.KAPTCHA_SESSION_KEY);
+
+        // 鈶� 姣斿鐢ㄦ埛杈撳叆鍜屾纭瓟妗堬紙蹇界暐澶у皬鍐欙級
+        if (StringUtils.isEmpty(validateCode) || !validateCode.equalsIgnoreCase(code)) {
+            return false;
+
+        }
+        return true;
+    }
+
     //缁戝畾openId
-    public PageResponse<String> bandOpenId(WeChatBaseParam param) {
+    public PageResponse<String> bandOpenId(HttpServletRequest httpRequest,WeChatBaseParam param) {
 
         //鍒ゆ柇鍙傛暟
         if (null == param || StringUtils.isEmpty(param.getOpenid())) {
@@ -81,22 +114,15 @@
             return new PageResponse<String>(RespCodeEnum.CODE_1007.getCode(), "鎵嬫満鍙蜂负绌猴紝璇峰~鍐�");
 
         }
-//        if (StringUtils.isEmpty(param.getMsgCode())) {
-//            return new PageResponse<String>(RespCodeEnum.CODE_1007.getCode(), "楠岃瘉鐮佷笉鑳戒负绌�");
-//
-//        }
-//
-//        String code = (String) redisService.getCacheObject(WeChatConst.WX_MOBILE_CODE + param.getMobile());
-//        if(StringUtils.isEmpty(code)){
-//            res.put("code","1007");
-//            res.put("msg","楠岃瘉鐮佸凡澶辨晥锛岃閲嶆柊鑾峰彇");
-//            return res;
-//        }
-//        if(! code.equals(param.getMsgCode())){
-//            res.put("code","1007");
-//            res.put("msg","楠岃瘉鐮侀敊璇�");
-//            return res;
-//        }
+        if (StringUtils.isEmpty(param.getMsgCode())) {
+            return new PageResponse<String>(RespCodeEnum.CODE_1007.getCode(), "楠岃瘉鐮佷笉鑳戒负绌�");
+
+        }
+        //楠岃瘉鐮侀獙璇�
+        boolean validateResponse = validateResponse(httpRequest, param.getMsgCode());
+        if (!validateResponse) {
+            return new PageResponse<String>(RespCodeEnum.CODE_1007.getCode(), "楠岃瘉鐮侀敊璇�");
+        }
 
         //鏍规嵁鎵嬫満鍙锋煡鐪嬬敤鎴锋槸鍚︽槸绯荤粺鐢ㄦ埛
         SysUser user = sysUserService.selectUserByPhoneNumber(param.getMobile());
@@ -110,13 +136,13 @@
 
 //        redisService.deleteObject(WeChatConst.WX_MOBILE_CODE + param.getMobile());
 
-        return new PageResponse<String>(RespCodeEnum.CODE_0000.getCode(), "璇锋眰鎴愬姛");
+        return new PageResponse<String>(RespCodeEnum.CODE_0000.getCode(), "缁戝畾鎴愬姛");
 
     }
 
 
     //瑙g粦openId
-    public PageResponse<String> unBandOpenId(WeChatBaseParam param) {
+    public PageResponse<String> unBandOpenId(HttpServletRequest httpRequest,WeChatBaseParam param) {
 
         //鍒ゆ柇鍙傛暟
         if (null == param || StringUtils.isEmpty(param.getOpenid())) {
@@ -130,20 +156,11 @@
             return new PageResponse<String>(RespCodeEnum.CODE_1007.getCode(), "楠岃瘉鐮佷笉鑳戒负绌�");
 
         }
-
-//        String code = (String) redisService.getCacheObject(WeChatConst.WX_MOBILE_CODE + param.getMobile());
-//        if(StringUtils.isEmpty(code)){
-//            res.put("code","1007");
-//            res.put("msg","楠岃瘉鐮佸凡澶辨晥锛岃閲嶆柊鑾峰彇");
-//            return res;
-//
-//        }
-//        if(! code.equals(param.getMsgCode())){
-//            res.put("code","1007");
-//            res.put("msg","楠岃瘉鐮侀敊璇�");
-//            return res;
-//        }
-
+        //楠岃瘉鐮侀獙璇�
+        boolean validateResponse = validateResponse(httpRequest, param.getMsgCode());
+        if (!validateResponse) {
+            return new PageResponse<String>(RespCodeEnum.CODE_1007.getCode(), "楠岃瘉鐮侀敊璇�");
+        }
         //鏍规嵁鎵嬫満鍙锋煡璇㈢敤鎴锋槸鍚﹀凡缁忕粦瀹�
         SysUser user = sysUserService.selectUserByPhoneNumber(param.getMobile());
         if (user == null || StringUtils.isEmpty(user.getPhonenumber())) {
@@ -153,8 +170,6 @@
 
         user.setOpenId("");
         sysUserService.updateUserInfo(user);
-
-//        redisService.deleteObject(WeChatConst.WX_MOBILE_CODE + param.getMobile());
 
         return new PageResponse<String>(RespCodeEnum.CODE_0000.getCode(), "璇锋眰鎴愬姛");
 
@@ -179,14 +194,35 @@
             return new PageResponse<Page<SnapReply>>(RespCodeEnum.CODE_1006.getCode(), "灏氭湭缁戝畾鏈嶅姟锛岃鍏堢粦瀹氾紒");
 
         }
+        //鑾峰彇涓氬姟缁忕悊缁戝畾鐨勮川鎶煎悎鍚�
+        List<PledgeContract> dateByUser = pledgeContractService.getDateByUser(String.valueOf(user.getUserId()));
+        if (dateByUser == null || dateByUser.isEmpty()) {
+            //杩斿洖绌烘暟鎹�
+            return new PageResponse<Page<SnapReply>>(RespCodeEnum.CODE_0000.getCode(), "璇锋眰鎴愬姛", new Page<>(param.getPageNo(), param.getPageSize()));
+        }
+        List<PledgeContractDepot> pledgeContractDepots = new ArrayList<>() ;
+        for (PledgeContract pledgeContract : dateByUser) {
+            String id = pledgeContract.getId();
+            IgdsBaseParam depotPParam = new IgdsBaseParam();
+            depotPParam.setParentId(id);
+            List<PledgeContractDepot> pledgeContractDepots1 = pledgeContractDepotService.listAll(depotPParam);
+            pledgeContractDepots.addAll(pledgeContractDepots1);
+        }
+        if(pledgeContractDepots.isEmpty()){
+            //杩斿洖绌烘暟鎹�
+            return new PageResponse<Page<SnapReply>>(RespCodeEnum.CODE_0000.getCode(), "璇锋眰鎴愬姛", new Page<>(param.getPageNo(), param.getPageSize()));
+        }
+
+        // 鑾峰彇pledgeContractDepots涓幓閲嶅悗鐨勫簱鍖篒DList
+        List<String> deptIdList = pledgeContractDepots.stream().map(PledgeContractDepot::getPledgeDept).distinct().collect(Collectors.toList());
+
         //鍒嗛〉鎷兼帴
         Page<SnapReply> page = new Page<>(param.getPageNo(), param.getPageSize());
         //鏌ヨ鍙傛暟缁勮
         IgdsBaseParam queryParam = new IgdsBaseParam();
-        queryParam.setDeptId(String.valueOf(user.getDeptId()));
         queryParam.setCompanyId(user.getCompanyId());
         queryParam.setKey(Constant.YN_N);
-        snapReplyService.listPage(page, queryParam);
+        snapReplyService.listPageByListDept(page, queryParam,deptIdList);
         return new PageResponse<Page<SnapReply>>(RespCodeEnum.CODE_0000.getCode(), "璇锋眰鎴愬姛", page);
     }
 

--
Gitblit v1.9.3