From c9f07c1f79e7ea9eb00925975d3ae2c9e8dcbd25 Mon Sep 17 00:00:00 2001
From: nidapeng <jp@doumee.com>
Date: 星期三, 20 三月 2024 11:37:34 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/1.0.1' into 1.0.1

---
 server/service/src/main/java/com/doumee/core/wx/WxMiniConfig.java                        |   90 +++++
 server/service/src/main/java/com/doumee/core/wx/WxMsgVO.java                             |   23 +
 server/service/src/main/java/com/doumee/core/model/LoginUserInfo.java                    |    1 
 server/service/src/main/java/com/doumee/dao/business/dto/SaveUnionApplyDTO.java          |   36 ++
 server/service/src/main/java/com/doumee/service/system/impl/SystemLoginServiceImpl.java  |  137 +++++++
 server/service/src/main/java/com/doumee/core/wx/SpringUtils.java                         |   69 ++++
 server/service/src/main/java/com/doumee/core/utils/Constants.java                        |   97 +++++
 server/service/src/main/java/com/doumee/dao/system/dto/LoginPhoneDTO.java                |    1 
 server/service/src/main/java/com/doumee/core/wx/WxPayProperties.java                     |   48 +++
 server/service/src/main/java/com/doumee/core/wx/SendWxMessage.java                       |  164 ++++++++++
 server/company/src/main/java/com/doumee/api/system/SystemController.java                 |   16 
 server/platform/src/main/java/com/doumee/api/system/SystemController.java                |    4 
 server/service/src/main/java/com/doumee/dao/system/model/SystemUser.java                 |    6 
 server/shop/src/main/java/com/doumee/api/system/SystemController.java                    |   10 
 server/service/src/main/java/com/doumee/config/shiro/ShiroConfig.java                    |    1 
 server/service/src/main/java/com/doumee/core/wx/AccessToken.java                         |   30 +
 server/service/src/main/java/com/doumee/config/shiro/ShiroCredentialsMatcher.java        |   14 
 server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java |   80 +++++
 server/service/src/main/java/com/doumee/core/wx/TemplateData.java                        |   19 +
 server/service/src/main/java/com/doumee/service/system/SystemLoginService.java           |   15 
 server/pom.xml                                                                           |   10 
 server/service/src/main/java/com/doumee/dao/system/dto/WxMiniLoginDTO.java               |   28 +
 server/service/src/main/java/com/doumee/service/business/UnionApplyService.java          |    7 
 server/service/src/main/java/com/doumee/dao/business/model/InsuranceApply.java           |    3 
 server/service/src/main/java/com/doumee/dao/system/dto/LoginDTO.java                     |    4 
 25 files changed, 873 insertions(+), 40 deletions(-)

diff --git a/server/company/src/main/java/com/doumee/api/system/SystemController.java b/server/company/src/main/java/com/doumee/api/system/SystemController.java
index a65b2c8..85cb705 100644
--- a/server/company/src/main/java/com/doumee/api/system/SystemController.java
+++ b/server/company/src/main/java/com/doumee/api/system/SystemController.java
@@ -7,10 +7,7 @@
 import com.doumee.core.model.ApiResponse;
 import com.doumee.core.model.LoginUserInfo;
 import com.doumee.core.utils.Constants;
-import com.doumee.dao.system.dto.LoginDTO;
-import com.doumee.dao.system.dto.LoginPhoneDTO;
-import com.doumee.dao.system.dto.UpdatePwdDto;
-import com.doumee.dao.system.dto.WebLoginDTO;
+import com.doumee.dao.system.dto.*;
 import com.doumee.service.system.SystemLoginService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -46,20 +43,27 @@
     @ApiOperation("鐧诲綍 - 鍚庣")
     @PostMapping("/login")
     public ApiResponse<String> login (@Validated @RequestBody LoginDTO dto, HttpServletRequest request) {
-        return ApiResponse.success(systemLoginService.loginByPassword(dto, Constants.ONE, request));
+        return ApiResponse.success(systemLoginService.loginByPassword(dto, Constants.ONE, true, request));
     }
 
     @PreventRepeat(limit = 10, lockTime = 10000)
     @ApiOperation("鐭俊楠岃瘉鐮佺櫥褰�")
     @PostMapping("/loginByPhone")
     public ApiResponse<String> loginByPhone (@Validated @RequestBody LoginPhoneDTO dto, HttpServletRequest request) {
-        return ApiResponse.success(systemLoginService.loginByPhone(dto, Constants.ZERO, request));
+        return ApiResponse.success(systemLoginService.loginByPhone(dto, Constants.ONE, true, request));
     }
 
+    @PreventRepeat(limit = 10, lockTime = 10000)
+    @ApiOperation("寰俊灏忕▼搴忕櫥褰�")
+    @PostMapping("/loginByWxMini")
+    public ApiResponse<String> loginByWxMini (@Validated @RequestBody WxMiniLoginDTO dto, HttpServletRequest request) {
+        return ApiResponse.success(systemLoginService.loginByWxMini(dto, request));
+    }
 
     @ApiOperation("閫�鍑虹櫥褰�")
     @PostMapping("/logout")
     public ApiResponse logout () {
+        systemLoginService.cleaOpenid();
         Subject subject = SecurityUtils.getSubject();
         subject.logout();
         return ApiResponse.success(null);
diff --git a/server/platform/src/main/java/com/doumee/api/system/SystemController.java b/server/platform/src/main/java/com/doumee/api/system/SystemController.java
index f2d6829..ba128c3 100644
--- a/server/platform/src/main/java/com/doumee/api/system/SystemController.java
+++ b/server/platform/src/main/java/com/doumee/api/system/SystemController.java
@@ -44,13 +44,13 @@
     @ApiOperation("鐧诲綍")
     @PostMapping("/login")
     public ApiResponse<String> login (@Validated @RequestBody LoginDTO dto, HttpServletRequest request) {
-        return ApiResponse.success(systemLoginService.loginByPassword(dto, Constants.ZERO, request));
+        return ApiResponse.success(systemLoginService.loginByPassword(dto, Constants.ZERO,true, request));
     }
     @PreventRepeat(limit = 10, lockTime = 10000)
     @ApiOperation("鐭俊楠岃瘉鐮佺櫥褰�")
     @PostMapping("/loginByPhone")
     public ApiResponse<String> loginByPhone (@Validated @RequestBody LoginPhoneDTO dto, HttpServletRequest request) {
-        return ApiResponse.success(systemLoginService.loginByPhone(dto, Constants.ZERO, request));
+        return ApiResponse.success(systemLoginService.loginByPhone(dto, Constants.ZERO, true,request));
     }
 
     @ApiOperation("閫�鍑虹櫥褰�")
diff --git a/server/pom.xml b/server/pom.xml
index 19ed8a1..96b6768 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -37,6 +37,8 @@
     <oshi.version>5.7.0</oshi.version>
     <jna.version>5.7.0</jna.version>
     <poi.version>5.0.0</poi.version>
+    <!-- 寰俊灏忕▼搴� -->
+    <weixin-java-miniapp.version>4.1.0</weixin-java-miniapp.version>
   </properties>
 
   <dependencies>
@@ -212,6 +214,14 @@
       <version>2.5.1</version>
     </dependency>
 
+
+    <!-- WeChat 灏忕▼搴� -->
+    <dependency>
+      <groupId>com.github.binarywang</groupId>
+      <artifactId>weixin-java-miniapp</artifactId>
+      <version>${weixin-java-miniapp.version}</version>
+    </dependency>
+
     <dependency>
       <groupId>net.sourceforge.jexcelapi</groupId>
       <artifactId>jxl</artifactId>
diff --git a/server/service/src/main/java/com/doumee/config/shiro/ShiroConfig.java b/server/service/src/main/java/com/doumee/config/shiro/ShiroConfig.java
index 18aeb0a..7078689 100644
--- a/server/service/src/main/java/com/doumee/config/shiro/ShiroConfig.java
+++ b/server/service/src/main/java/com/doumee/config/shiro/ShiroConfig.java
@@ -90,6 +90,7 @@
         // 璺緞鎷︽埅閰嶇疆
         map.put("/system/login", "anon");
         map.put("/system/loginByPhone", "anon");
+        map.put("/system/loginByWxMini", "anon");
         map.put("/system/logout", "anon");
         map.put("/common/captcha", "anon");
         map.put("/business/smsEmail/sendSms", "anon");
diff --git a/server/service/src/main/java/com/doumee/config/shiro/ShiroCredentialsMatcher.java b/server/service/src/main/java/com/doumee/config/shiro/ShiroCredentialsMatcher.java
index cde2c50..24ef699 100644
--- a/server/service/src/main/java/com/doumee/config/shiro/ShiroCredentialsMatcher.java
+++ b/server/service/src/main/java/com/doumee/config/shiro/ShiroCredentialsMatcher.java
@@ -26,15 +26,21 @@
     public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
         ShiroToken usernamePasswordToken = (ShiroToken) token;
         SystemUser queryUserDto = new SystemUser();
-        queryUserDto.setUsername(usernamePasswordToken.getUsername());
         queryUserDto.setDeleted(Boolean.FALSE);
+        if(!usernamePasswordToken.isNeedPassword()){
+            queryUserDto.setMobile(usernamePasswordToken.getUsername());
+            SystemUser systemUser = systemUserService.findOne(queryUserDto);
+            if (systemUser == null) {
+                return Boolean.FALSE;
+            }
+            return Boolean.TRUE;
+        }
+        queryUserDto.setUsername(usernamePasswordToken.getUsername());
         SystemUser systemUser = systemUserService.findOne(queryUserDto);
         if (systemUser == null) {
             return Boolean.FALSE;
         }
-        if(!usernamePasswordToken.isNeedPassword()){
-            return Boolean.TRUE;
-        }
+
         // 鍔犲瘑瀵嗙爜
         String pwd = Utils.Secure.encryptPassword(new String(usernamePasswordToken.getPassword()), systemUser.getSalt());
         // 姣旇緝瀵嗙爜
diff --git a/server/service/src/main/java/com/doumee/core/model/LoginUserInfo.java b/server/service/src/main/java/com/doumee/core/model/LoginUserInfo.java
index e73d456..54bd7f9 100644
--- a/server/service/src/main/java/com/doumee/core/model/LoginUserInfo.java
+++ b/server/service/src/main/java/com/doumee/core/model/LoginUserInfo.java
@@ -34,6 +34,7 @@
     private String sex;
     private String mobile;
 
+    private String openid;
     private Integer companyId;
     private Integer areaId;
     private Integer cityId;
diff --git a/server/service/src/main/java/com/doumee/core/utils/Constants.java b/server/service/src/main/java/com/doumee/core/utils/Constants.java
index 9d91bb1..4efd1ab 100644
--- a/server/service/src/main/java/com/doumee/core/utils/Constants.java
+++ b/server/service/src/main/java/com/doumee/core/utils/Constants.java
@@ -43,7 +43,9 @@
     public static final String RANGE_SIZE = "RANGE_SIZE";
     public static final String CATE_PARAM_OPEN = "_CATE_PARAM_OPEN";
     public static final String OPEN_SYNC_SWITCH = "OPEN_SYNC_SWITCH";
-
+    public static final String WX_MIN_PROGRAM = "WX_MIN_PROGRAM";
+    public static final String WX_MIN_APPID = "WX_MIN_APPID";
+    public static final String WX_MIN_SECRET = "WX_MIN_SECRET";
 
     public static final String SYSTEM ="SYSTEM";
     public static final String GOODS_IMG_DIR ="GOODS_IMG_DIR";
@@ -564,7 +566,7 @@
 
         SYSTEM(0, "绯荤粺鐢ㄦ埛", "绠$悊鍛�",Arrays.asList(0,1,2,3,4,5,6,7,8,9,10,11)),
         COMPANY(1, "浼佷笟鐢ㄦ埛", "浼佷笟",Arrays.asList(-1)),
-        ZHUBO(2, "涓绘挱", "涓绘挱",Arrays.asList(-1)),
+        ZHUBO(2, "鍟嗘埛", "鍟嗘埛",Arrays.asList(-1)),
         ;
         // 鎴愬憳鍙橀噺
         private String name;
@@ -844,6 +846,97 @@
         }
     }
 
+    public  enum UnionApplyStatus {
+        UPLOAD(1, "寰呬笂浼犳姇淇濆崟","",0),
+        ;
+        // 鎴愬憳鍙橀噺
+        private String name;
+        private String info;
+        private int key;
+        private int collectStatus;
+
+
+        // 鏋勯�犳柟娉�
+        UnionApplyStatus(int key, String name,String info,int collectStatus) {
+            this.name = name;
+            this.key = key;
+            this.info = info;
+            this.collectStatus = collectStatus;
+        }
+
+        // 鏅�氭柟娉�
+        public static String getName(int index) {
+            for (UnionApplyStatus c : UnionApplyStatus.values()) {
+                if (c.getKey() == index) {
+                    return c.name;
+                }
+            }
+            return null;
+        }
+        public static List<Integer> getKesByStatus(Integer collectStatus) {
+            List<Integer>  list = new ArrayList<>();
+            if(collectStatus!=null){
+                for (UnionApplyStatus c : UnionApplyStatus.values()) {
+                    if (Constants.equalsInteger(c.getCollectStatus() ,collectStatus)) {
+                        list.add(c.getKey());
+                    }
+                }
+            }
+            return list;
+        }
+        public static Integer getCollectStatus(Integer index) {
+            for (UnionApplyStatus c : UnionApplyStatus.values()) {
+                if (Constants.equalsInteger(c.getKey() , index)) {
+                    return c.collectStatus;
+                }
+            }
+            return null;
+        }
+        public static String getInfo(int index) {
+            for (UnionApplyStatus c : UnionApplyStatus.values()) {
+                if (c.getKey() == index) {
+                    return c.info;
+                }
+            }
+            return null;
+        }
+
+        // get set 鏂规硶
+        public String getName() {
+            return name;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+
+        public int getKey() {
+            return key;
+        }
+
+        public void setKey(int key) {
+            this.key = key;
+        }
+
+        public String getInfo() {
+            return info;
+        }
+
+        public void setInfo(String info) {
+            this.info = info;
+        }
+
+        public int getCollectStatus() {
+            return collectStatus;
+        }
+
+        public void setCollectStatus(int collectStatus) {
+            this.collectStatus = collectStatus;
+        }
+    }
+
+
+
     public  enum InsuranceApplyStatus {
         UPLOAD(0, "鎻愪氦鎶曚繚","",0),
         PLATFORM_RETURN(1, "瀹℃牳涓嶉�氳繃","鎻愪氦鎰忚锛�${param}",4),
diff --git a/server/service/src/main/java/com/doumee/core/wx/AccessToken.java b/server/service/src/main/java/com/doumee/core/wx/AccessToken.java
new file mode 100644
index 0000000..ff6a0c4
--- /dev/null
+++ b/server/service/src/main/java/com/doumee/core/wx/AccessToken.java
@@ -0,0 +1,30 @@
+package com.doumee.core.wx;
+
+import lombok.Data;
+
+/**
+ * Created by IntelliJ IDEA.
+ *
+ * @Author : Rk
+ * @create 2022/12/7 17:26
+ */
+@Data
+public class AccessToken {
+
+    private String accessToken;
+    //杩囨湡鏃堕棿 褰撳墠绯荤粺鏃堕棿+寰俊浼犳潵鐨勮繃鏈熸椂闂�
+    private Long expiresTime;
+
+    public AccessToken(String accessToken, String expiresIn) {
+        this.accessToken = accessToken;
+        this.expiresTime = System.currentTimeMillis()+Integer.parseInt(expiresIn)*1000;
+    }
+
+    /**
+     * 鍒ゆ柇token鏄惁杩囨湡
+     * @return
+     */
+    public boolean isExpired(){
+        return System.currentTimeMillis()>expiresTime;
+    }
+}
diff --git a/server/service/src/main/java/com/doumee/core/wx/SendWxMessage.java b/server/service/src/main/java/com/doumee/core/wx/SendWxMessage.java
new file mode 100644
index 0000000..4f124a6
--- /dev/null
+++ b/server/service/src/main/java/com/doumee/core/wx/SendWxMessage.java
@@ -0,0 +1,164 @@
+package com.doumee.core.wx;
+
+import com.alibaba.fastjson.JSONObject;
+import com.doumee.biz.system.SystemDictDataBiz;
+import com.doumee.core.utils.DateUtil;
+import com.doumee.dao.system.model.SystemUser;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Created by IntelliJ IDEA.
+ *
+ * @Author : Rk
+ * @create 2022/12/7 17:27
+ */
+@Service
+@Slf4j
+public class SendWxMessage {
+
+    private static String programUrl = "packagesMine/meetingDetails/meetingDetails?id=";
+
+    @Autowired
+    private SystemDictDataBiz systemDictDataBiz;
+
+//    /**
+//     * 浼氳寮�濮嬮�氱煡
+//     * @param systemUser 鐢ㄦ埛
+//     * @param bookings 浼氳淇℃伅
+//     * @param rooms 浼氳瀹や俊鎭�
+//     */
+//    public  void  bookingsStart(SystemUser systemUser, Bookings bookings, Rooms rooms){
+//        RestTemplate restTemplate = new RestTemplate();
+//        String accessToken = systemDictDataBiz.queryCodeById(106);
+//        log.info("寰俊灏忕▼搴� 浼氳寮�濮嬭闃呮秷鎭彂閫佹棩蹇� -> accessToken锛歿}",accessToken);
+//        //杩欓噷绠�鍗曡捣瑙佹垜浠瘡娆¢兘鑾峰彇鏈�鏂扮殑access_token锛堟椂闂村紑鍙戜腑锛屽簲璇ュ湪access_token蹇繃鏈熸椂鍐嶉噸鏂拌幏鍙栵級
+//        String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="+accessToken;
+//        //鎷兼帴鎺ㄩ�佺殑妯$増
+//        WxMsgVO wxMsgVo = new WxMsgVO();
+//        //鐢ㄦ埛鐨刼penid锛堣鍙戦�佺粰閭d釜鐢ㄦ埛锛�
+//        wxMsgVo.setTouser(systemUser.getOpenid());
+//        //璁㈤槄娑堟伅妯℃澘id
+//        wxMsgVo.setTemplate_id("di_lWUtlqvWAo7aWKZCH8Kzs1Cv2z3H6fOkKI4RwJzg");
+//        Map<String, TemplateData> m = new HashMap<>(4);
+//        //浼氳涓婚
+//        m.put("thing1", new TemplateData(bookings.getName()));
+//        //浼氳鍦扮偣
+//        m.put("thing2", new TemplateData(rooms.getName()));
+//        //鏃堕棿
+//        m.put("thing3", new TemplateData(DateUtil.getDate(bookings.getStartTime(),"yyyy-MM-dd")));
+//        //涓绘寔浜�
+//        m.put("name4", new TemplateData(systemUser.getRealname()));
+//        wxMsgVo.setPage(programUrl +bookings.getId());
+//        wxMsgVo.setData(m);
+//        ResponseEntity<String> responseEntity =
+//                restTemplate.postForEntity(url, wxMsgVo, String.class);
+//        log.info("寰俊灏忕▼搴�-> 鍙栨秷閫氱煡璁㈤槄娑堟伅鍙戦�佹棩蹇楋細{}",JSONObject.toJSONString(responseEntity));
+//    }
+//
+//    /**
+//     * 浼氳鍙栨秷閫氱煡
+//     * @param systemUser 鐢ㄦ埛
+//     * @param bookings 浼氳淇℃伅
+//     * @param rooms 浼氳瀹や俊鎭�
+//     */
+//    public  void  bookingsCancel(SystemUser systemUser, Bookings bookings, Rooms rooms){
+//        RestTemplate restTemplate = new RestTemplate();
+//        String accessToken = systemDictDataBiz.queryCodeById(106);
+//        log.info("寰俊灏忕▼搴� 浼氳寮�濮嬭闃呮秷鎭彂閫佹棩蹇� -> accessToken锛歿}",accessToken);
+//        //杩欓噷绠�鍗曡捣瑙佹垜浠瘡娆¢兘鑾峰彇鏈�鏂扮殑access_token锛堟椂闂村紑鍙戜腑锛屽簲璇ュ湪access_token蹇繃鏈熸椂鍐嶉噸鏂拌幏鍙栵級
+//        String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="+accessToken;
+//        //鎷兼帴鎺ㄩ�佺殑妯$増
+//        WxMsgVO wxMsgVo = new WxMsgVO();
+//        //鐢ㄦ埛鐨刼penid锛堣鍙戦�佺粰閭d釜鐢ㄦ埛锛�
+//        wxMsgVo.setTouser(systemUser.getOpenid());
+//        //璁㈤槄娑堟伅妯℃澘id
+//        wxMsgVo.setTemplate_id("6A79DG8Fd9CjUDHhxJVv8dWcqww0v9_wwQLr7_ZuNqU");
+//        Map<String, TemplateData> m = new HashMap<>(4);
+//        //浼氳鍚嶇О
+//        m.put("thing4", new TemplateData(bookings.getName()));
+//        //浼氳鏃堕棿
+//        m.put("time2", new TemplateData(DateUtil.getDate(bookings.getStartTime(),"yyyy-MM-dd")));
+////        m.put("time4", new TemplateData(
+////                DateUtil.getDate(bookings.getStartTime(),"yyyy-MM-dd")+
+////                        " " + DateUtil.getDate(bookings.getStartTime(),"HH:mm")+
+////                        " 鑷� " + DateUtil.getDate(bookings.getEndTime(),"HH:mm") ) );
+//        //浼氳瀹�
+//        m.put("thing1", new TemplateData(rooms.getName()));
+//        //澶囨敞
+//        m.put("thing3", new TemplateData(bookings.getRemark()));
+//        wxMsgVo.setPage(programUrl +bookings.getId());
+//        wxMsgVo.setData(m);
+//        ResponseEntity<String> responseEntity =
+//                restTemplate.postForEntity(url, wxMsgVo, String.class);
+//        log.info("寰俊灏忕▼搴�->鍙栨秷閫氱煡璁㈤槄娑堟伅鍙戦�佹棩蹇楋細{}",JSONObject.toJSONString(responseEntity));
+//    }
+//
+//
+//    /**
+//     * 浼氳棰勭害鎴愬姛閫氱煡
+//     * @param systemUser 鐢ㄦ埛
+//     * @param bookings 浼氳淇℃伅
+//     * @param rooms 浼氳瀹や俊鎭�
+//     */
+//    public void  bookingsReservation(SystemUser systemUser, Bookings bookings, Rooms rooms){
+//        RestTemplate restTemplate = new RestTemplate();
+//        String accessToken = systemDictDataBiz.queryCodeById(106);
+//        log.info("寰俊灏忕▼搴� 浼氳寮�濮嬭闃呮秷鎭彂閫佹棩蹇� -> accessToken锛歿}",accessToken);
+//
+//        //杩欓噷绠�鍗曡捣瑙佹垜浠瘡娆¢兘鑾峰彇鏈�鏂扮殑access_token锛堟椂闂村紑鍙戜腑锛屽簲璇ュ湪access_token蹇繃鏈熸椂鍐嶉噸鏂拌幏鍙栵級
+//        String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="+accessToken;
+//        //鎷兼帴鎺ㄩ�佺殑妯$増
+//        WxMsgVO wxMsgVo = new WxMsgVO();
+//        //鐢ㄦ埛鐨刼penid锛堣鍙戦�佺粰閭d釜鐢ㄦ埛锛�
+//        wxMsgVo.setTouser(systemUser.getOpenid());
+//        //璁㈤槄娑堟伅妯℃澘id
+//        wxMsgVo.setTemplate_id("usZxJqJ2AYPg24ViPMuY2lI-YRjdSD2JvFY3gY5kqh4");
+//        Map<String, TemplateData> m = new HashMap<>(4);
+//        //浼氳涓婚
+//        m.put("thing3", new TemplateData(bookings.getName()));
+//        //浼氳鏃堕棿
+//        m.put("time1", new TemplateData(
+//                DateUtil.getDate(bookings.getStartTime(),"yyyy-MM-dd")
+////                        +
+////                        " " + DateUtil.getDate(bookings.getStartTime(),"HH:mm")+
+////                        " 鑷� " + DateUtil.getDate(bookings.getEndTime(),"HH:mm")
+//        ) );
+//        //浼氳鍦扮偣
+//        m.put("thing2", new TemplateData(rooms.getName()));
+//        //鍙戣捣浜�
+//        m.put("thing4", new TemplateData(systemUser.getRealname()));
+//        wxMsgVo.setPage(programUrl +bookings.getId());
+//        wxMsgVo.setData(m);
+//        ResponseEntity<String> responseEntity =
+//                restTemplate.postForEntity(url, wxMsgVo, String.class);
+//        log.info("寰俊灏忕▼搴�-> 浼氳棰勭害鎴愬姛璁㈤槄娑堟伅鍙戦�佹棩蹇楋細{}",JSONObject.toJSONString(responseEntity));
+//    }
+
+
+
+//    /**
+//     * 鑾峰彇token
+//     */
+//    private static String getAccessToken() {
+//        //鍙戦�佽姹傝幏鍙杢oken
+//        JSONObject token = null;
+//        try {
+//            token = JSONObject.parseObject(HttpsUtil.get(APP_ACCESS_TOKEN_URL,false));
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//        JSONObject jsonObject = token;
+//        String accessToken = (String) jsonObject.get("access_token");
+//        Integer expiresIn = (Integer) jsonObject.get("expires_in");
+//        //鍒涘缓token瀵硅薄锛屽苟瀛樺偍
+//        return new AccessToken(accessToken,String.valueOf(expiresIn)).getAccessToken();
+//    }
+
+}
diff --git a/server/service/src/main/java/com/doumee/core/wx/SpringUtils.java b/server/service/src/main/java/com/doumee/core/wx/SpringUtils.java
new file mode 100644
index 0000000..d12ab86
--- /dev/null
+++ b/server/service/src/main/java/com/doumee/core/wx/SpringUtils.java
@@ -0,0 +1,69 @@
+package com.doumee.core.wx;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Component;
+
+/**
+ * NOTICE: NEVER USE IT WHEN REGISTERING A SPRING BEAN.
+ *
+ * @author Guang YANG
+ */
+@Component
+public class SpringUtils implements ApplicationContextAware {
+
+    private static ApplicationContext CTX;
+
+    public static ApplicationContext get() {
+        return CTX;
+    }
+
+    @Override
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+        CTX = applicationContext;
+    }
+
+    /**
+     * 鍚戝鍣ㄤ腑鍔ㄦ�佹坊鍔燘ean
+     *
+     * @param ctx
+     * @param beanName
+     * @param beanClass
+     */
+    public static void addBean(ApplicationContext ctx, String beanName, Class beanClass) {
+        BeanDefinitionRegistry beanDefReg = (DefaultListableBeanFactory)ctx.getAutowireCapableBeanFactory();
+        BeanDefinitionBuilder beanDefBuilder = BeanDefinitionBuilder.genericBeanDefinition(beanClass);
+        BeanDefinition beanDef = beanDefBuilder.getBeanDefinition();
+        if (!beanDefReg.containsBeanDefinition(beanName)) {
+            beanDefReg.registerBeanDefinition(beanName, beanDef);
+        }
+    }
+
+    /**
+     * 浠庡鍣ㄤ腑绉婚櫎Bean
+     *
+     * @param ctx
+     * @param beanName
+     */
+   public static void removeBean(ApplicationContext ctx, String beanName) {
+        BeanDefinitionRegistry beanDefReg = (DefaultListableBeanFactory) ctx.getAutowireCapableBeanFactory();
+        beanDefReg.getBeanDefinition(beanName);
+        beanDefReg.removeBeanDefinition(beanName);
+    }
+
+    /**
+     * 閬嶅巻杈撳嚭鎵�鏈塀ean鐨勪俊鎭�
+     */
+    static void showAllBeans(ApplicationContext ctx) {
+        //閬嶅巻
+        for (String name : ctx.getBeanDefinitionNames()) {
+            System.out.println("name:" + name + ",class:" + ctx.getBean(name).getClass());
+        }
+    }
+
+}
diff --git a/server/service/src/main/java/com/doumee/core/wx/TemplateData.java b/server/service/src/main/java/com/doumee/core/wx/TemplateData.java
new file mode 100644
index 0000000..aad9cf6
--- /dev/null
+++ b/server/service/src/main/java/com/doumee/core/wx/TemplateData.java
@@ -0,0 +1,19 @@
+package com.doumee.core.wx;
+
+import lombok.Data;
+
+/**
+ * Created by IntelliJ IDEA.
+ *
+ * @Author : Rk
+ * @create 2022/12/7 17:28
+ */
+@Data
+public class TemplateData {
+    private String value;
+
+    public TemplateData(String value) {
+        this.value = value;
+    }
+
+}
diff --git a/server/service/src/main/java/com/doumee/core/wx/WxMiniConfig.java b/server/service/src/main/java/com/doumee/core/wx/WxMiniConfig.java
new file mode 100644
index 0000000..f38d911
--- /dev/null
+++ b/server/service/src/main/java/com/doumee/core/wx/WxMiniConfig.java
@@ -0,0 +1,90 @@
+package com.doumee.core.wx;
+
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
+import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
+import com.doumee.biz.system.SystemDictDataBiz;
+import com.doumee.core.utils.Constants;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * 寰俊灏忕▼搴忕粍浠�
+ */
+@Configuration
+public class WxMiniConfig {
+    /********寰俊灏忕▼搴忔湇鍔�**********/
+    public static WxMaService wxMaService;
+    /********寰俊灏忕▼搴忔敮浠�**********/
+//    public static WxPayService wxPayService;
+//    /********寰俊APP鏀粯**********/
+//    public static WxPayService wxAppPayService;
+
+    @Autowired
+    private SystemDictDataBiz systemDictDataBiz;
+
+    public static WxMiniConfig me() {
+        return SpringUtils.get().getBean(WxMiniConfig.class);
+    }
+
+    @PostConstruct
+    void init() {
+        this.load_WxMaService();
+//        this.load_wxPayService();
+//        this.load_wxAppPayService();
+    }
+    /**
+     * 鍒濆鍖栧井淇″皬绋嬪簭
+     */
+    public void load_WxMaService() {
+        WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
+        config.setAppid(StringUtils.trimToNull(systemDictDataBiz.queryByCode(Constants.WX_MIN_PROGRAM,Constants.WX_MIN_APPID).getCode()));
+        config.setSecret(StringUtils.trimToNull(systemDictDataBiz.queryByCode(Constants.WX_MIN_PROGRAM,Constants.WX_MIN_SECRET).getCode()));
+        config.setMsgDataFormat("JSON");
+        //config.setToken("");
+        //config.setAesKey("");
+        WxMaService wxMaService = new WxMaServiceImpl();
+        wxMaService.setWxMaConfig(config);
+        this.wxMaService = wxMaService;
+    }
+
+    /**
+     * 鍒濆鍖栧井淇″皬绋嬪簭鏀粯
+     */
+//    public void load_wxPayService() {
+//        WxPayConfig payConfig = new WxPayConfig();
+//        payConfig.setTradeType(WxPayConstants.TradeType.JSAPI);
+//        payConfig.setSignType(WxPayConstants.SignType.MD5);
+//        payConfig.setAppId(StringUtils.trimToNull(wxPayProperties.getAppId()));
+//        payConfig.setMchId(StringUtils.trimToNull(wxPayProperties.getMchId()));
+//        payConfig.setMchKey(StringUtils.trimToNull(wxPayProperties.getMchKey()));
+//        payConfig.setKeyPath(StringUtils.trimToNull(wxPayProperties.getKeyPath()));
+//        payConfig.setNotifyUrl(StringUtils.trimToNull(wxPayProperties.getNotifyUrl()));
+//        WxPayService wxPayService = new WxPayServiceImpl();
+//        wxPayService.setConfig(payConfig);
+//        this.wxPayService = wxPayService;
+//    }
+
+
+
+//    /**
+//     * 鍒濆鍖朅pp鏀粯
+//     */
+//    public void load_wxAppPayService() {
+//        WxPayConfig payConfig = new WxPayConfig();
+//        payConfig.setTradeType(WxPayConstants.TradeType.APP);
+//        payConfig.setSignType(WxPayConstants.SignType.MD5);
+//        payConfig.setAppId("");
+//        payConfig.setMchId(StringUtils.trimToNull(sysDictService.getSysDictValue(SysDictEnum.WX_MINI_MchId.getCode())));
+//        payConfig.setMchKey(StringUtils.trimToNull(sysDictService.getSysDictValue(SysDictEnum.WX_MINI_MchKey.getCode())));
+//        payConfig.setKeyPath(StringUtils.trimToNull(sysDictService.getSysDictValue(SysDictEnum.WX_MINI_KeyPath.getCode())));
+//        payConfig.setNotifyUrl(StringUtils.trimToNull(sysDictService.getSysDictValue(SysDictEnum.WX_MINI_NotifyUrl.getCode())));
+//        WxPayService wxPayService = new WxPayServiceImpl();
+//        wxPayService.setConfig(payConfig);
+//        this.wxAppPayService = wxPayService;
+//    }
+
+}
diff --git a/server/service/src/main/java/com/doumee/core/wx/WxMsgVO.java b/server/service/src/main/java/com/doumee/core/wx/WxMsgVO.java
new file mode 100644
index 0000000..cee69e6
--- /dev/null
+++ b/server/service/src/main/java/com/doumee/core/wx/WxMsgVO.java
@@ -0,0 +1,23 @@
+package com.doumee.core.wx;
+
+import lombok.Data;
+
+import java.util.Map;
+
+/**
+ * Created by IntelliJ IDEA.
+ *
+ * @Author : Rk
+ * @create 2022/12/7 17:27
+ */
+@Data
+public class WxMsgVO {
+    //鐢ㄦ埛openId
+    private String touser;
+    //妯$増id
+    private String template_id;
+    //鎺ㄩ�佹枃瀛�
+    private Map<String , TemplateData> data;
+    //璺宠浆璺緞 锛岄粯璁よ烦杞埌灏忕▼搴忛椤�
+    private String page="pages/index/index";
+}
diff --git a/server/service/src/main/java/com/doumee/core/wx/WxPayProperties.java b/server/service/src/main/java/com/doumee/core/wx/WxPayProperties.java
new file mode 100644
index 0000000..efe67cb
--- /dev/null
+++ b/server/service/src/main/java/com/doumee/core/wx/WxPayProperties.java
@@ -0,0 +1,48 @@
+package com.doumee.core.wx;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created by IntelliJ IDEA.
+ *
+ * @Author : Rk
+ * @create 2023/3/22 18:04
+ */
+@Component
+@ConfigurationProperties(prefix = "wx.pay")
+@Data
+public class WxPayProperties {
+
+    /**
+     * AppID
+     */
+    private String appId;
+
+    /**
+     * AppSecret
+     */
+    private String appSecret;
+
+    /**
+     * 寰俊鍟嗘埛鍙�
+     */
+    private String mchId;
+
+    /**
+     * 鏀粯API瀵嗛挜
+     */
+    private String mchKey;
+
+    /**
+     * 鏀粯鍥炶皟鍦板潃
+     */
+    private String notifyUrl;
+
+    /**
+     * 鏀粯璇佷功(p12)
+     */
+    private String keyPath;
+
+}
diff --git a/server/service/src/main/java/com/doumee/dao/business/dto/SaveUnionApplyDTO.java b/server/service/src/main/java/com/doumee/dao/business/dto/SaveUnionApplyDTO.java
new file mode 100644
index 0000000..3d4bbab
--- /dev/null
+++ b/server/service/src/main/java/com/doumee/dao/business/dto/SaveUnionApplyDTO.java
@@ -0,0 +1,36 @@
+package com.doumee.dao.business.dto;
+
+import com.doumee.core.annotation.excel.ExcelColumn;
+import java.util.Date;
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.models.auth.In;
+import lombok.Data;
+
+/**
+ * Created by IntelliJ IDEA.
+ *
+ * @Author : Rk
+ * @create 2024/3/15 14:42
+ */
+@Data
+public class SaveUnionApplyDTO {
+
+    @ApiModelProperty(value = "鏂规鍩虹鏁版嵁涓婚敭")
+    private Integer baseSolutionId;
+
+    @ApiModelProperty(value = "淇濆崟涓婚敭 澶氫釜浠�,鍒嗗壊")
+    private List<Integer> applyIds;
+
+    @ApiModelProperty(value = "寮�濮嬫棩鏈�")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date startDate;
+
+    @ApiModelProperty(value = "缁撴潫鏃ユ湡")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date endDate;
+
+
+}
diff --git a/server/service/src/main/java/com/doumee/dao/business/model/InsuranceApply.java b/server/service/src/main/java/com/doumee/dao/business/model/InsuranceApply.java
index 412f5c3..36ade21 100644
--- a/server/service/src/main/java/com/doumee/dao/business/model/InsuranceApply.java
+++ b/server/service/src/main/java/com/doumee/dao/business/model/InsuranceApply.java
@@ -214,6 +214,9 @@
     @TableField(exist = false)
     private Integer timeUnit;
 
+    @ApiModelProperty(value = "鏂规鍩虹鐗堟湰涓婚敭", example = "1")
+    @TableField(exist = false)
+    private Integer solutionBaseId;
 
     @ApiModelProperty(value = "鏈�鏂扮増鏈殑鏂规涓婚敭", example = "1")
     @TableField(exist = false)
diff --git a/server/service/src/main/java/com/doumee/dao/system/dto/LoginDTO.java b/server/service/src/main/java/com/doumee/dao/system/dto/LoginDTO.java
index 91902c9..7ffff82 100644
--- a/server/service/src/main/java/com/doumee/dao/system/dto/LoginDTO.java
+++ b/server/service/src/main/java/com/doumee/dao/system/dto/LoginDTO.java
@@ -30,4 +30,8 @@
     @NotBlank(message = "楠岃瘉鐮乁UID涓嶈兘涓虹┖")
     @ApiModelProperty(value = "楠岃瘉鐮乁UID")
     private String uuid;
+
+    @ApiModelProperty(value = "openid",hidden = true)
+    private String openid;
+
 }
diff --git a/server/service/src/main/java/com/doumee/dao/system/dto/LoginPhoneDTO.java b/server/service/src/main/java/com/doumee/dao/system/dto/LoginPhoneDTO.java
index b1bbdf4..4646b5f 100644
--- a/server/service/src/main/java/com/doumee/dao/system/dto/LoginPhoneDTO.java
+++ b/server/service/src/main/java/com/doumee/dao/system/dto/LoginPhoneDTO.java
@@ -21,5 +21,4 @@
     @NotBlank(message = "楠岃瘉鐮佷笉鑳戒负绌�")
     @ApiModelProperty(value = "楠岃瘉鐮�")
     private String code;
-
 }
diff --git a/server/service/src/main/java/com/doumee/dao/system/dto/WxMiniLoginDTO.java b/server/service/src/main/java/com/doumee/dao/system/dto/WxMiniLoginDTO.java
new file mode 100644
index 0000000..261507b
--- /dev/null
+++ b/server/service/src/main/java/com/doumee/dao/system/dto/WxMiniLoginDTO.java
@@ -0,0 +1,28 @@
+package com.doumee.dao.system.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import java.io.Serializable;
+
+/**
+ * @author Eva.Caesar Liu
+ * @date 2023/02/14 11:14
+ */
+@Data
+@ApiModel("寰俊灏忕▼搴忕櫥褰曞弬鏁�")
+public class WxMiniLoginDTO implements Serializable {
+
+    @ApiModelProperty(value = "鐢ㄦ埛鍚�")
+    private String username;
+
+    @ApiModelProperty(value = "瀵嗙爜")
+    private String password;
+
+    @ApiModelProperty(value = "寰俊code")
+    private String code;
+
+
+}
diff --git a/server/service/src/main/java/com/doumee/dao/system/model/SystemUser.java b/server/service/src/main/java/com/doumee/dao/system/model/SystemUser.java
index 76f617f..74ae18e 100644
--- a/server/service/src/main/java/com/doumee/dao/system/model/SystemUser.java
+++ b/server/service/src/main/java/com/doumee/dao/system/model/SystemUser.java
@@ -73,9 +73,6 @@
     @ApiModelProperty(value = "瀵嗙爜")
     @NotBlank(message = "鍒濆瀵嗙爜涓嶈兘涓虹┖")
     private String password;
-    @ApiModelProperty(value = "openid")
-    @NotBlank(message = "openid")
-    private String openid;
 
     @ApiModelProperty(value = "鐩�")
     private String salt;
@@ -102,6 +99,9 @@
     @ApiModelProperty(value = "0 鍚敤 1 绂佺敤")
     private Integer status;
 
+    @ApiModelProperty(value = "寰俊灏忕▼搴廜PENID")
+    private String openid;
+
     @ApiModelProperty(value = "鎵�灞炰紒涓氫俊鎭")
     @TableField(exist = false)
     private Company company;
diff --git a/server/service/src/main/java/com/doumee/service/business/UnionApplyService.java b/server/service/src/main/java/com/doumee/service/business/UnionApplyService.java
index b5346b2..354081f 100644
--- a/server/service/src/main/java/com/doumee/service/business/UnionApplyService.java
+++ b/server/service/src/main/java/com/doumee/service/business/UnionApplyService.java
@@ -2,6 +2,7 @@
 
 import com.doumee.core.model.PageData;
 import com.doumee.core.model.PageWrap;
+import com.doumee.dao.business.dto.SaveUnionApplyDTO;
 import com.doumee.dao.business.model.UnionApply;
 import java.util.List;
 
@@ -94,4 +95,10 @@
      * @return long
      */
     long count(UnionApply unionApply);
+
+    /**
+     * 淇濆崟鍚堝苟
+     * @param saveUnionApplyDTO
+     */
+    void merge(SaveUnionApplyDTO saveUnionApplyDTO);
 }
diff --git a/server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java
index 2acd28e..b9450d7 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/UnionApplyServiceImpl.java
@@ -1,20 +1,35 @@
 package com.doumee.service.business.impl;
 
+import com.doumee.core.constants.ResponseStatus;
+import com.doumee.core.exception.BusinessException;
+import com.doumee.core.model.LoginUserInfo;
 import com.doumee.core.model.PageData;
 import com.doumee.core.model.PageWrap;
+import com.doumee.core.utils.Constants;
 import com.doumee.core.utils.Utils;
 import com.doumee.dao.business.UnionApplyMapper;
+import com.doumee.dao.business.dto.SaveUnionApplyDTO;
+import com.doumee.dao.business.join.InsuranceApplyJoinMapper;
+import com.doumee.dao.business.model.InsuranceApply;
+import com.doumee.dao.business.model.Solutions;
 import com.doumee.dao.business.model.UnionApply;
 import com.doumee.service.business.UnionApplyService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import io.swagger.models.auth.In;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shiro.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import java.math.BigDecimal;
+import java.util.Date;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * 鍚堝苟鎶曚繚鍗曚俊鎭〃Service瀹炵幇
@@ -26,6 +41,9 @@
 
     @Autowired
     private UnionApplyMapper unionApplyMapper;
+
+    @Autowired
+    private InsuranceApplyJoinMapper insuranceApplyJoinMapper;
 
     @Override
     public Integer create(UnionApply unionApply) {
@@ -166,4 +184,66 @@
         QueryWrapper<UnionApply> wrapper = new QueryWrapper<>(unionApply);
         return unionApplyMapper.selectCount(wrapper);
     }
+
+
+    @Override
+    public void merge(SaveUnionApplyDTO saveUnionApplyDTO){
+        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+        if(user.getType().equals(Constants.TWO)){
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炲晢鎴风敤鎴凤紝鏃犳硶杩涜璇ユ搷浣�");
+        }
+        if(Objects.isNull(saveUnionApplyDTO)
+            || Objects.isNull(saveUnionApplyDTO.getApplyIds())
+            || Objects.isNull(saveUnionApplyDTO.getStartDate())
+            || Objects.isNull(saveUnionApplyDTO.getEndDate())
+        ){
+            throw new BusinessException(ResponseStatus.BAD_REQUEST);
+        }
+        List<InsuranceApply> insuranceApplyList = insuranceApplyJoinMapper.selectJoinList(InsuranceApply.class,
+                new MPJLambdaWrapper<InsuranceApply>()
+                        .selectAll(InsuranceApply.class)
+                        .selectAs(InsuranceApply::getSolutionBaseId,Solutions::getBaseId)
+                        .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
+                        .eq(InsuranceApply::getIsdeleted, Constants.ZERO)
+                        .eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.PLATFORM_CHECK_PASS.getKey())
+                        .eq(Solutions::getBaseId,saveUnionApplyDTO.getBaseSolutionId())
+                        .in(InsuranceApply::getId,saveUnionApplyDTO.getApplyIds())
+                        .isNull(InsuranceApply::getUnionApplyId)
+        );
+        //鏌ヨ鏁版嵁鏄惁瀛樺湪鏈浜庡鎵归�氳繃鐨勬暟鎹�
+        if(insuranceApplyList.size()!=saveUnionApplyDTO.getApplyIds().size()){
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀛樺湪鏁版嵁宸插鐞嗭紝璇峰埛鏂伴噸璇�");
+        }
+
+        UnionApply unionApply = new UnionApply();
+        unionApply.setCreateDate(new Date());
+        unionApply.setCreator(user.getId());
+        unionApply.setCompanyId(user.getCompanyId());
+        unionApply.setStartTime(saveUnionApplyDTO.getStartDate());
+        unionApply.setEndTime(saveUnionApplyDTO.getEndDate());
+        unionApply.setCheckDate(new Date());
+        unionApply.setStatus(Constants.UnionApplyStatus.UPLOAD.getKey());
+        unionApply.setCheckUserId(user.getId());
+        unionApply.setFee(insuranceApplyList.stream().map(i->i.getFee()).reduce(BigDecimal.ZERO,BigDecimal::add));
+        unionApply.setCurrentFee(BigDecimal.ZERO);
+        unionApplyMapper.insert(unionApply);
+
+        insuranceApplyJoinMapper.update(null,new UpdateWrapper<InsuranceApply>().lambda()
+                .set(InsuranceApply::getUnionApplyId,unionApply.getId())
+                .set(InsuranceApply::getCheckDate,new Date())
+                .set(InsuranceApply::getCheckUserId,user.getId())
+                .in(InsuranceApply::getId,saveUnionApplyDTO.getApplyIds()));
+
+    }
+
+
+    public void cancelMerge(Integer id){
+        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+        if(user.getType().equals(Constants.TWO)){
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炲晢鎴风敤鎴凤紝鏃犳硶杩涜璇ユ搷浣�");
+        }
+
+    }
+
+
 }
diff --git a/server/service/src/main/java/com/doumee/service/system/SystemLoginService.java b/server/service/src/main/java/com/doumee/service/system/SystemLoginService.java
index 6805744..8ce4a7e 100644
--- a/server/service/src/main/java/com/doumee/service/system/SystemLoginService.java
+++ b/server/service/src/main/java/com/doumee/service/system/SystemLoginService.java
@@ -2,6 +2,7 @@
 
 import com.doumee.dao.system.dto.LoginDTO;
 import com.doumee.dao.system.dto.LoginPhoneDTO;
+import com.doumee.dao.system.dto.WxMiniLoginDTO;
 
 import javax.servlet.http.HttpServletRequest;
 
@@ -17,6 +18,16 @@
      * @author Eva.Caesar Liu
      * @date 2023/03/21 14:49
      */
-    String loginByPassword (LoginDTO dto,int type, HttpServletRequest request);
-    String loginByPhone (LoginPhoneDTO dto, int type, HttpServletRequest request);
+    String loginByPassword (LoginDTO dto,int type,Boolean checkCaptcha, HttpServletRequest request);
+    String loginByPhone (LoginPhoneDTO dto, int type,Boolean checkSmsCode, HttpServletRequest request);
+
+    /**
+     *
+     * @param wxMiniLoginDTO
+     * @param request
+     * @return
+     */
+    String loginByWxMini (WxMiniLoginDTO wxMiniLoginDTO, HttpServletRequest request);
+
+    void cleaOpenid();
 }
diff --git a/server/service/src/main/java/com/doumee/service/system/impl/SystemLoginServiceImpl.java b/server/service/src/main/java/com/doumee/service/system/impl/SystemLoginServiceImpl.java
index 2f0c381..822a624 100644
--- a/server/service/src/main/java/com/doumee/service/system/impl/SystemLoginServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/system/impl/SystemLoginServiceImpl.java
@@ -1,5 +1,8 @@
 package com.doumee.service.system.impl;
 
+import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.api.R;
 import com.doumee.config.shiro.ShiroToken;
 import com.doumee.core.constants.ResponseStatus;
@@ -7,15 +10,21 @@
 import com.doumee.core.model.LoginUserInfo;
 import com.doumee.core.utils.Constants;
 import com.doumee.core.utils.Utils;
+import com.doumee.core.wx.WxMiniConfig;
 import com.doumee.dao.business.SmsEmailMapper;
+import com.doumee.dao.system.SystemUserMapper;
 import com.doumee.dao.system.dto.LoginDTO;
 import com.doumee.dao.system.dto.LoginPhoneDTO;
+import com.doumee.dao.system.dto.WxMiniLoginDTO;
 import com.doumee.dao.system.model.SystemLoginLog;
+import com.doumee.dao.system.model.SystemUser;
 import com.doumee.service.business.impl.SmsEmailServiceImpl;
 import com.doumee.service.common.CaptchaService;
 import com.doumee.service.system.SystemLoginLogService;
 import com.doumee.service.system.SystemLoginService;
 import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.error.WxErrorException;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.authc.AuthenticationException;
 import org.apache.shiro.subject.Subject;
@@ -43,8 +52,92 @@
     @Autowired
     private SystemLoginLogService systemLoginLogService;
 
+    @Autowired
+    private SystemUserMapper systemUserMapper;
+
+
+//    /**
+//     * 寰俊鎺堟潈锛堢櫥褰曞悗锛�
+//     * @param code
+//     */
+//    @Override
+//    public String wxEmpower(String code,Integer userId){
+//        try {
+//            //鑾峰彇寰俊鏁忔劅鏁版嵁
+//            WxMaJscode2SessionResult session = WxMiniConfig.wxMaService.getUserService().getSessionInfo(code);
+//            String openId = session.getOpenid();
+//            if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isBlank(openId)) {
+//                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鑾峰彇openid澶辫触锛佽鑱旂郴绠$悊鍛�");
+//            }
+//            if(Objects.nonNull(userId)){
+//                systemUserMapper.update(null,new UpdateWrapper<SystemUser>()
+//                        .lambda()
+//                        .set(SystemUser::getOpenid,null)
+//                        .eq(SystemUser::getOpenid,openId)
+//                        .ne(SystemUser::getId,userId));
+//
+//                systemUserMapper.update(null,new UpdateWrapper<SystemUser>()
+//                        .lambda()
+//                        .set(SystemUser::getOpenid,openId)
+//                        .eq(SystemUser::getId,userId));
+//            }
+//            return openId;
+//        } catch (WxErrorException e) {
+//            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"寰俊鐧诲綍寮傚父锛佽鑱旂郴绠$悊鍛�");
+//        }
+//    }
+
     @Override
-    public String loginByPassword(LoginDTO dto, int type,HttpServletRequest request) {
+    public void cleaOpenid(){
+        LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+        if(StringUtils.isNotBlank(loginUserInfo.getOpenid())){
+            systemUserMapper.update(null,new UpdateWrapper<SystemUser>().lambda()
+                    .set(SystemUser::getOpenid,null)
+                    .eq(SystemUser::getId,loginUserInfo.getId()));
+        }
+    }
+
+
+    @Override
+    public String loginByWxMini (WxMiniLoginDTO wxMiniLoginDTO, HttpServletRequest request){
+        LoginDTO dto = new LoginDTO();
+        if(StringUtils.isNotBlank(wxMiniLoginDTO.getCode())){
+            try{
+                WxMaJscode2SessionResult session = WxMiniConfig.wxMaService.getUserService().getSessionInfo(wxMiniLoginDTO.getCode());
+                String openId = session.getOpenid();
+                if (StringUtils.isNotBlank(openId)&&StringUtils.isBlank(wxMiniLoginDTO.getUsername())) {
+                    SystemUser systemUser = systemUserMapper.selectOne(new QueryWrapper<SystemUser>()
+                            .lambda().eq(SystemUser::getOpenid,openId)
+                            .eq(SystemUser::getDeleted,Constants.ZERO)
+                            .eq(SystemUser::getType,Constants.UserType.COMPANY.getKey())
+                            .orderByDesc(SystemUser::getCreateTime)
+                            .last(" limit 1")
+                    );
+                    if(Objects.nonNull(systemUser)){
+                        LoginPhoneDTO loginPhoneDTO = new LoginPhoneDTO();
+                        loginPhoneDTO.setPhone(systemUser.getMobile());
+                        return  this.loginByPhone(loginPhoneDTO,Constants.ONE,false,request);
+                    }else{
+                        return null;
+                    }
+                }else{
+                    dto.setOpenid(openId);
+                }
+            } catch (WxErrorException e) {
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"寰俊鐧诲綍寮傚父锛佽鑱旂郴绠$悊鍛�");
+            }
+        }
+        if(StringUtils.isBlank(wxMiniLoginDTO.getUsername())
+                || StringUtils.isBlank(wxMiniLoginDTO.getPassword())){
+            throw new BusinessException(ResponseStatus.BAD_REQUEST);
+        }
+        dto.setUsername(wxMiniLoginDTO.getUsername());
+        dto.setPassword(wxMiniLoginDTO.getPassword());
+        return this.loginByPassword(dto,Constants.ONE,false,request);
+    }
+
+    @Override
+    public String loginByPassword(LoginDTO dto, int type,Boolean checkCaptcha,HttpServletRequest request) {
         SystemLoginLog loginLog = new SystemLoginLog();
         loginLog.setLoginUsername(dto.getUsername());
         loginLog.setLoginTime(new Date());
@@ -57,7 +150,7 @@
         loginLog.setServerIp(Utils.Server.getIP());
         // 鏍¢獙楠岃瘉鐮�
         try {
-            if(!debugModel){
+            if(!debugModel&&checkCaptcha){
                 captchaService.check(dto.getUuid(), dto.getCode());
             }
         } catch (Exception e) {
@@ -75,6 +168,17 @@
             loginLog.setUserId(((LoginUserInfo)subject.getPrincipal()).getId());
             loginLog.setSuccess(Boolean.TRUE);
             systemLoginLogService.create(loginLog);
+
+            //鏇存柊openid鎵�灞炵敤鎴蜂俊鎭�
+            if(StringUtils.isNotBlank(dto.getOpenid())){
+                systemUserMapper.update(null,new UpdateWrapper<SystemUser>().lambda()
+                        .set(SystemUser::getOpenid,null)
+                        .eq(SystemUser::getOpenid,dto.getOpenid())
+                        .ne(SystemUser::getId,loginLog.getUserId()));
+                systemUserMapper.update(null,new UpdateWrapper<SystemUser>().lambda()
+                        .set(SystemUser::getOpenid,dto.getOpenid())
+                        .eq(SystemUser::getId,loginLog.getUserId()));
+            }
             return (String)subject.getSession().getId();
         } catch (AuthenticationException e) {
             log.error(ResponseStatus.ACCOUNT_INCORRECT.getMessage(), e);
@@ -84,8 +188,9 @@
             throw new BusinessException(ResponseStatus.ACCOUNT_INCORRECT.getCode(), Objects.isNull(e.getCause())?ResponseStatus.ACCOUNT_INCORRECT.getMessage():e.getCause().getMessage());
         }
     }
+
     @Override
-    public String loginByPhone (LoginPhoneDTO dto, int type, HttpServletRequest request) {
+    public String loginByPhone (LoginPhoneDTO dto, int type,Boolean checkSmsCode, HttpServletRequest request) {
         SystemLoginLog loginLog = new SystemLoginLog();
         loginLog.setLoginUsername(dto.getPhone());
         loginLog.setLoginTime(new Date());
@@ -97,18 +202,16 @@
         loginLog.setOsInfo(Utils.User_Client.getOS(request));
         loginLog.setServerIp(Utils.Server.getIP());
         // 鏍¢獙楠岃瘉鐮�
-        if(type!= Constants.TWO){
-            try {
-                if(!debugModel){
-                    SmsEmailServiceImpl.isCaptcheValide(smsEmailMapper,dto.getPhone(), dto.getCode());
-                }
-            } catch (Exception e) {
-                log.error(e.getMessage(), e);
-                loginLog.setReason(e.getMessage().length() > 200 ? (e.getMessage().substring(0, 190) + "...") : e.getMessage());
-                loginLog.setSuccess(Boolean.FALSE);
-                systemLoginLogService.create(loginLog);
-                throw e;
+        try {
+            if(!debugModel&& checkSmsCode){
+                SmsEmailServiceImpl.isCaptcheValide(smsEmailMapper,dto.getPhone(), dto.getCode());
             }
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            loginLog.setReason(e.getMessage().length() > 200 ? (e.getMessage().substring(0, 190) + "...") : e.getMessage());
+            loginLog.setSuccess(Boolean.FALSE);
+            systemLoginLogService.create(loginLog);
+            throw e;
         }
         // 鏍¢獙鐢ㄦ埛鍚嶅拰瀵嗙爜
         Subject subject = SecurityUtils.getSubject();
@@ -127,4 +230,10 @@
             throw new BusinessException(ResponseStatus.ACCOUNT_INCORRECT.getCode(), Objects.isNull(e.getCause())?ResponseStatus.ACCOUNT_INCORRECT.getMessage():e.getCause().getMessage());
         }
     }
+
+
+
+
+
+
 }
diff --git a/server/shop/src/main/java/com/doumee/api/system/SystemController.java b/server/shop/src/main/java/com/doumee/api/system/SystemController.java
index 3cdb87f..902b3ed 100644
--- a/server/shop/src/main/java/com/doumee/api/system/SystemController.java
+++ b/server/shop/src/main/java/com/doumee/api/system/SystemController.java
@@ -7,10 +7,7 @@
 import com.doumee.core.model.ApiResponse;
 import com.doumee.core.model.LoginUserInfo;
 import com.doumee.core.utils.Constants;
-import com.doumee.dao.system.dto.LoginDTO;
-import com.doumee.dao.system.dto.LoginPhoneDTO;
-import com.doumee.dao.system.dto.UpdatePwdDto;
-import com.doumee.dao.system.dto.WebLoginDTO;
+import com.doumee.dao.system.dto.*;
 import com.doumee.service.system.SystemLoginService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -46,17 +43,18 @@
     @ApiOperation("鐧诲綍 - 鍚庣")
     @PostMapping("/login")
     public ApiResponse<String> login (@Validated @RequestBody LoginDTO dto, HttpServletRequest request) {
-        return ApiResponse.success(systemLoginService.loginByPassword(dto, Constants.TWO, request));
+        return ApiResponse.success(systemLoginService.loginByPassword(dto, Constants.TWO,true, request));
     }
 
     @PreventRepeat(limit = 10, lockTime = 10000)
     @ApiOperation("鐭俊楠岃瘉鐮佺櫥褰�")
     @PostMapping("/loginByPhone")
     public ApiResponse<String> loginByPhone (@Validated @RequestBody LoginPhoneDTO dto, HttpServletRequest request) {
-        return ApiResponse.success(systemLoginService.loginByPhone(dto, Constants.TWO, request));
+        return ApiResponse.success(systemLoginService.loginByPhone(dto, Constants.TWO,true, request));
     }
 
 
+
     @ApiOperation("閫�鍑虹櫥褰�")
     @PostMapping("/logout")
     public ApiResponse logout () {

--
Gitblit v1.9.3