From 2f38b2341e1572502fd6b4510670107f57ed261c Mon Sep 17 00:00:00 2001
From: jiangqs <343695869@qq.com>
Date: 星期五, 18 八月 2023 23:05:34 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/HongRuiTang

---
 ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml                                 |    4 
 ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml                                                 |    8 
 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/poji/sys/SysDept.java                |   12 
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/conslole/QYWXCallBackController.java |   29 +
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/MgtSysStaffImportDto.java            |   42 +++
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/management/MgtStaffController.java   |   19 +
 ruoyi-modules/ruoyi-system/src/test/java/com/ruoyi/system/systemTest.java                                 |   12 
 ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/config/WxPayConfiguration.java                    |    1 
 ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/miniapp/AppOrderController.java        |    2 
 ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/order/OrderService.java                   |    6 
 ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/domain/vo/MerAgencyPageVo.java                      |    6 
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/config/WxCpProperties.java                      |   36 ++
 ruoyi-modules/ruoyi-order/pom.xml                                                                         |   17 +
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/config/WxCpConfiguration.java                   |   51 +++
 ruoyi-modules/ruoyi-system/pom.xml                                                                        |    1 
 ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/domain/vo/MgtShopAuthPageVo.java                    |   11 
 ruoyi-modules/ruoyi-shop/src/main/resources/mapper/shop/ShopMapper.xml                                    |    7 
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/sys/SysDeptServiceImpl.java        |   13 +
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/staff/SysWxCpService.java               |   29 ++
 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/dto/AppMemberBindingDto.java         |    3 
 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/poji/member/Member.java              |    5 
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/pojo/staff/SysStaff.java                 |    3 
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/sys/ISysDeptService.java                |   12 
 ruoyi-modules/ruoyi-order/src/test/java/com/ruoyi/order/orderTest.java                                    |   38 ++
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/scheduler/SystemScheduler.java                  |   15 +
 ruoyi-modules/ruoyi-order/src/main/resources/bootstrap.yml                                                |    8 
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysStaffServiceImpl.java     |   73 ++++
 ruoyi-modules/ruoyi-system/src/main/resources/mapper/sys/SysDeptMapper.xml                                |   10 
 ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java              |   23 +
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberServiceImpl.java      |    3 
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/sys/SysDeptMapper.java                   |   15 +
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/staff/SysStaffService.java              |   19 
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysWxCpServiceImpl.java      |   97 +++++++
 ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java          |   48 ++-
 ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/miniapp/NotifyController.java          |    2 
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/staff/StaffSysController.java        |   14 
 ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/util/WechatPayUtils.java                            |   16 
 ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/business/MerOrderController.java       |   10 
 ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml                                               |   11 
 ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/domain/pojo/shop/ShopAuthentication.java            |    8 
 40 files changed, 667 insertions(+), 72 deletions(-)

diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/dto/AppMemberBindingDto.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/dto/AppMemberBindingDto.java
index 15b5dbd..f83490f 100644
--- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/dto/AppMemberBindingDto.java
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/dto/AppMemberBindingDto.java
@@ -19,6 +19,9 @@
     @ApiModelProperty(value = "商户id")
     private Long shopId;
 
+    @ApiModelProperty(value = "绑定类型1商城订单2活动订单3线下订单4核销优惠券5核销奖品6商户创建会员7平台变动")
+    private Integer bindingType;
+
     @ApiModelProperty(value = "商户名称")
     private String shopName;
 }
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/poji/member/Member.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/poji/member/Member.java
index 310c3d3..5416f94 100644
--- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/poji/member/Member.java
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/poji/member/Member.java
@@ -166,6 +166,11 @@
     @TableField("frozen_flag")
     private Integer frozenFlag;
 
+    /**
+     * 绑定类型1商城订单2活动订单3线下订单4核销优惠券5核销奖品6商户创建7平台变动
+     */
+    @TableField("binding_type")
+    private Integer bindingType;
 
     @Override
     protected Serializable pkVal() {
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/poji/sys/SysDept.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/poji/sys/SysDept.java
index 7d75726..f5e1dd7 100644
--- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/poji/sys/SysDept.java
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/poji/sys/SysDept.java
@@ -66,6 +66,9 @@
     /** 菜单组 */
     private Long[] staffMenuIds;
 
+    /** 微信部门id */
+    private Long wxDeptId;
+
     public Long getDeptId()
     {
         return deptId;
@@ -216,6 +219,14 @@
         this.staffMenuIds = staffMenuIds;
     }
 
+    public Long getWxDeptId() {
+        return wxDeptId;
+    }
+
+    public void setWxDeptId(Long wxDeptId) {
+        this.wxDeptId = wxDeptId;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@@ -234,6 +245,7 @@
             .append("updateBy", getUpdateBy())
             .append("updateTime", getUpdateTime())
             .append("dataScope", getDataScope())
+            .append("wxDeptId", getWxDeptId())
             .toString();
     }
 }
diff --git a/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml b/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml
index bd0eefb..9963b58 100644
--- a/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml
+++ b/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml
@@ -21,10 +21,18 @@
         # 服务注册地址
         server-addr: 47.109.78.184:5000
         #server-addr: 127.0.0.1:8848
+        #pro
+        #namespace: 9591ef9f-a49a-4900-be35-d77258bdd639
+        #dev
+        namespace: d39a744d-116f-4280-8445-0502dd1a3116
       config:
         # 配置中心地址
         server-addr: 47.109.78.184:5000
         #server-addr: 127.0.0.1:8848
+        #pro
+        #namespace: 9591ef9f-a49a-4900-be35-d77258bdd639
+        #dev
+        namespace: d39a744d-116f-4280-8445-0502dd1a3116
         # 配置文件格式
         file-extension: yml
         # 共享配置
diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberServiceImpl.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberServiceImpl.java
index 71b248d..4cb8276 100644
--- a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberServiceImpl.java
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberServiceImpl.java
@@ -527,6 +527,7 @@
         member.setBindingFlag(appMemberBindingDto.getBindingFlag());
         member.setRelationShopId(appMemberBindingDto.getShopId());
         member.setRelationShopName(appMemberBindingDto.getShopName());
+        member.setBindingType(appMemberBindingDto.getBindingType());
         this.saveOrUpdate(member);
     }
 
@@ -659,6 +660,7 @@
             member.setMiniOpenid(null);
             member.setBindingFlag(1);
             member.setBindingTime(new Date());
+            member.setBindingType(6);
             // Get shop information and set it to the member
             Shop shop = remoteShopService.getShop(merMemberAddDto.getShopId()).getData();
             member.setRelationShopName(shop.getShopName());
@@ -971,6 +973,7 @@
                 member.setRelationShopId(shop.getShopId());
                 member.setRelationShopName(shop.getShopName());
                 member.setBindingFlag(1);
+                member.setBindingType(7);
                 member.setBindingTime(new Date());
                 member.setUpdateTime(new Date());
                 member.setUpdateUserId(mgtMemberRelEditDto.getUserId());
diff --git a/ruoyi-modules/ruoyi-order/pom.xml b/ruoyi-modules/ruoyi-order/pom.xml
index 506669a..d180c09 100644
--- a/ruoyi-modules/ruoyi-order/pom.xml
+++ b/ruoyi-modules/ruoyi-order/pom.xml
@@ -102,20 +102,17 @@
             <version>2.3.3</version>
         </dependency>
 
-
         <!--  微信支付分提供的工具包,用于生成公用的http-client客户端 -->
         <dependency>
             <groupId>com.github.wechatpay-apiv3</groupId>
             <artifactId>wechatpay-apache-httpclient</artifactId>
             <version>0.4.9</version>
         </dependency>
-
         <dependency>
             <groupId>com.github.wechatpay-apiv3</groupId>
             <artifactId>wechatpay-java</artifactId>
             <version>0.2.10</version>
         </dependency>
-
         <dependency>
             <groupId>com.github.binarywang</groupId>
             <artifactId>weixin-java-miniapp</artifactId>
@@ -126,12 +123,26 @@
             <artifactId>weixin-java-pay</artifactId>
             <version>4.5.0</version>
         </dependency>
+
+        <!-- 阿里云 -->
         <dependency>
             <groupId>com.aliyun</groupId>
             <artifactId>alibabacloud-dysmsapi20170525</artifactId>
             <version>2.0.24</version>
         </dependency>
 
+        <!-- 测试类 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <version>2.7.7</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.13.1</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/config/WxPayConfiguration.java b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/config/WxPayConfiguration.java
index 386931d..666c4f6 100644
--- a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/config/WxPayConfiguration.java
+++ b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/config/WxPayConfiguration.java
@@ -42,6 +42,7 @@
     payConfig.setApiV3Key(StringUtils.trimToNull(this.properties.getApiV3Key()));
     payConfig.setPrivateKeyPath(StringUtils.trimToNull(this.properties.getPrivateKeyPath()));
     payConfig.setPrivateCertPath(StringUtils.trimToNull(this.properties.getPrivateCertPath()));
+    payConfig.setNotifyUrl("https://wxapp.hhhrt.cn/order/app/notify/payNotify");
 
     // 平台特约商户号
     PLATFORM_TY_MAC_ID = this.properties.getPlatformTyMacId();
diff --git a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/business/MerOrderController.java b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/business/MerOrderController.java
index e1047d3..bb77b82 100644
--- a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/business/MerOrderController.java
+++ b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/business/MerOrderController.java
@@ -64,6 +64,16 @@
         return R.ok(merVerifyCodeVo);
     }
 
+    @RequestMapping(value = "/verifyOrder", method = RequestMethod.POST)
+    @ApiOperation(value = "核销code")
+    public R<MerVerifyOrderVo> verifyOrder(@RequestBody MerVerifyCodeDto merVerifyCodeDto) {
+        Long userId = SecurityUtils.getUserId();
+        merVerifyCodeDto.setUserId(userId);
+        String verifyCode = merVerifyCodeDto.getVerifyCode();
+        MerVerifyOrderVo merVerifyOrderVo = orderService.verifyOrder(verifyCode,merVerifyCodeDto.getShopId());
+        return R.ok(merVerifyOrderVo);
+    }
+
     @RequestMapping(value = "/sureVerifyOrder", method = RequestMethod.POST)
     @ApiOperation(value = "核销订单")
     public R<MerVerifyOrderVo> sureVerifyOrder(@RequestBody MerVerifyOrderDto merVerifyOrderDto) {
diff --git a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/miniapp/AppOrderController.java b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/miniapp/AppOrderController.java
index 9965f68..1eb127a 100644
--- a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/miniapp/AppOrderController.java
+++ b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/miniapp/AppOrderController.java
@@ -107,6 +107,7 @@
                     appMemberBindingDto.setShopId(appPlaceOrderDto.getShopId());
                     appMemberBindingDto.setUserId(userId);
                     appMemberBindingDto.setBindingFlag(1);
+                    appMemberBindingDto.setBindingType(1);
                     memberService.updateMemberBinding(appMemberBindingDto);
                 }
             }
@@ -131,6 +132,7 @@
                 appMemberBindingDto.setShopId(appPlaceActivityDto.getShopId());
                 appMemberBindingDto.setUserId(userId);
                 appMemberBindingDto.setBindingFlag(1);
+                appMemberBindingDto.setBindingType(2);
                 memberService.updateMemberBinding(appMemberBindingDto);
             }
         }
diff --git a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/miniapp/NotifyController.java b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/miniapp/NotifyController.java
index 775d9da..921b532 100644
--- a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/miniapp/NotifyController.java
+++ b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/miniapp/NotifyController.java
@@ -51,7 +51,7 @@
     @Resource
     private OrderService orderService;
 
-    @Autowired
+    @Resource
     private WxPayService wxService;
     @Resource
     private BackMessageService backMessageService;
diff --git a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java
index a94f3ca..d1cce04 100644
--- a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java
+++ b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java
@@ -5,9 +5,17 @@
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.binarywang.wxpay.bean.ecommerce.PartnerTransactionsRequest;
 import com.github.binarywang.wxpay.bean.ecommerce.PartnerTransactionsResult;
 import com.github.binarywang.wxpay.bean.ecommerce.RefundNotifyResult;
+import com.github.binarywang.wxpay.bean.ecommerce.TransactionsResult;
+import com.github.binarywang.wxpay.bean.ecommerce.enums.TradeTypeEnum;
 import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingNotifyResult;
+import com.github.binarywang.wxpay.config.WxPayConfig;
+import com.github.binarywang.wxpay.exception.WxPayException;
+import com.github.binarywang.wxpay.service.WxPayService;
+import com.google.common.base.Joiner;
+import com.google.gson.Gson;
 import com.ruoyi.common.core.exception.ServiceException;
 import com.ruoyi.common.core.utils.DateUtils;
 import com.ruoyi.common.core.utils.StringUtils;
@@ -52,7 +60,6 @@
 import lombok.extern.slf4j.Slf4j;
 import org.redisson.api.RLock;
 import org.redisson.api.RedissonClient;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -119,11 +126,11 @@
     @Resource
     private PayRecordService payRecordService;
 
-    @Autowired
+    @Resource
     private RedissonClient redissonClient;
 
-    /*@Autowired
-    private WxPayService wxService;*/
+    @Resource
+    private WxPayService wxService;
 
     @Resource
     private PaymentMessageService paymentMessageService;
@@ -740,8 +747,8 @@
         appPlaceOrderVo.setOrderNo(orderNo);
 
         String goodsName = "";
-        if (null != goods) {
-            goodsName = goods.getGoodsName();
+        if (null != goodsNameList) {
+            goodsName = String.join(",", goodsNameList);
         }
 
         // 小程序微信下单支付
@@ -784,14 +791,14 @@
      * @param payerClientIp
      * @param goodsNameList
      */
-    /*private void createWxPayInfo(AppPlaceOrderVo appPlaceOrderVo, Long userId, Long shopId,
+    public void createWxPayInfo(AppPlaceOrderVo appPlaceOrderVo, Long userId, Long shopId,
                                  String goodsName, String orderNo,
                                  String orderId, BigDecimal payMoney,
                                  String openid, String payerClientIp, List<String> goodsNameList){
         try {
             // 创建支付订单
-            R<String> resultMch = remoteShopService.getShopSubMchId(shopId);
-            String subMchId = resultMch.getData();
+            //R<String> resultMch = remoteShopService.getShopSubMchId(shopId);
+            String subMchId = "1650744551";
             if (StringUtils.isEmpty(subMchId)) {
                 throw new ServiceException("获取微信商户号失败");
             }
@@ -859,7 +866,7 @@
         } catch (WxPayException e) {
             throw new ServiceException(e.getMessage());
         }
-    }*/
+    }
 
 
     /**
@@ -1712,6 +1719,7 @@
         if (member.getBindingFlag() != 1) {
             AppMemberBindingDto appMemberBindingDto = new AppMemberBindingDto();
             appMemberBindingDto.setBindingFlag(1);
+            appMemberBindingDto.setBindingType(4);
             appMemberBindingDto.setShopId(shop.getShopId());
             appMemberBindingDto.setShopName(shop.getShopName());
             appMemberBindingDto.setUserId(memberCoupon.getUserId());
@@ -1828,6 +1836,7 @@
         if (member.getBindingFlag() != 1) {
             AppMemberBindingDto appMemberBindingDto = new AppMemberBindingDto();
             appMemberBindingDto.setBindingFlag(1);
+            appMemberBindingDto.setBindingType(5);
             appMemberBindingDto.setShopId(shop.getShopId());
             appMemberBindingDto.setShopName(shop.getShopName());
             appMemberBindingDto.setUserId(memberGiftRecord.getUserId());
@@ -1920,7 +1929,6 @@
                 sysUser.setAvatar("https://hongruitang.oss-cn-beijing.aliyuncs.com/default.png");
                 String password = "hongruitang";
                 sysUser.setPassword(SecurityUtils.encryptPassword(password));
-                log.debug("sysUser" + sysUser.toString());
                 sysUser = remoteUserService.registerUser(sysUser).getData();
                 member = new Member();
                 member.setMemberId(memberId);
@@ -1929,6 +1937,7 @@
                 member.setRealName(name);
                 member.setNickName(name);
                 member.setBindingFlag(1);
+                member.setBindingType(3);
                 member.setRelationShopId(shopId);
                 member.setRelationShopName(shop.getShopName());
                 remoteMemberService.createNewMember(member);
@@ -2188,6 +2197,7 @@
             appMemberBindingDto.setShopName(shop.getShopName());
             appMemberBindingDto.setUserId(userId);
             appMemberBindingDto.setBindingFlag(1);
+            appMemberBindingDto.setBindingType(3);
             remoteMemberService.updateMemberBinding(appMemberBindingDto);
         }
         //更新商户统计
@@ -2217,10 +2227,12 @@
     @Override
     public List<MerOrderPageVo> pageMerOrder(Page page, MerOrderPageDto merOrderPageDto) {
         if (StringUtils.isNotBlank(merOrderPageDto.getKeyword())) {
+            // 获取关键字对应的用户ID
             MgtUserIdByKeywordDto userIdByKeywordDto = new MgtUserIdByKeywordDto();
             userIdByKeywordDto.setKeyword(merOrderPageDto.getKeyword());
             MgtUserIdByKeywordVo userIdByKeywordVo = remoteMemberService.getUserIdByKeyword(userIdByKeywordDto).getData();
             if (StringUtils.isNotBlank(userIdByKeywordVo.getUserIds())) {
+                // 将用户ID转换成List<Long>类型
                 List<Long> userIdList = Arrays.stream(userIdByKeywordVo.getUserIds().split(","))
                         .map(Long::parseLong)
                         .collect(Collectors.toList());
@@ -2228,6 +2240,8 @@
                 merOrderPageDto.setMemberUserId(null);
             }
         }
+
+        // 获取订单列表
         List<MerOrderPageVo> merOrderPageVoList = orderMapper.pageMerOrder(page, merOrderPageDto);
         if (merOrderPageVoList != null && !merOrderPageVoList.isEmpty()) {
             Long userId;
@@ -2236,15 +2250,17 @@
             String orderFromDesc;
             BigDecimal zeroBig = new BigDecimal("0.00");
             StringJoiner userIdSj = new StringJoiner(",");
+            // 遍历订单列表
             for (MerOrderPageVo merOrderPageVo : merOrderPageVoList) {
                 userId = merOrderPageVo.getUserId();
                 userIdSj.add(userId.toString());
                 orderFrom = merOrderPageVo.getOrderFrom();
+                // 根据订单来源设置订单来源描述
                 if (orderFrom != null) {
                     if (orderFrom == 1) {
                         orderFromDesc = "商城订单";
-                    } else if(orderFrom == 2){
-                        orderFromDesc = "店铺砍价活动("+merOrderPageVo.getActivityName()+")";
+                    } else if (orderFrom == 2) {
+                        orderFromDesc = "店铺砍价活动(" + merOrderPageVo.getActivityName() + ")";
                     } else {
                         orderFromDesc = "线下创建";
                     }
@@ -2252,18 +2268,22 @@
                     orderFromDesc = "商城订单";
                 }
                 merOrderPageVo.setOrderFromDesc(orderFromDesc);
+                // 设置未支付金额为0.00,如果未支付金额小于0,则设置为0.00
                 if (merOrderPageVo.getUnPaidMoney() == null) {
                     merOrderPageVo.setUnPaidMoney(zeroBig);
                 }
-                if(merOrderPageVo.getUnPaidMoney().compareTo(zeroBig)<0){
+                if (merOrderPageVo.getUnPaidMoney().compareTo(zeroBig) < 0) {
                     merOrderPageVo.setUnPaidMoney(zeroBig);
                 }
             }
+
+            // 根据用户ID列表获取用户信息
             MgtBaseBathDto mgtBaseBathDto = new MgtBaseBathDto();
             mgtBaseBathDto.setIds(userIdSj.toString());
             List<MgtSimpleMemberVo> simpleMemberVoList = remoteMemberService.listSimpleVoByIds(mgtBaseBathDto).getData();
             Map<Long, MgtSimpleMemberVo> userMap = simpleMemberVoList.stream()
                     .collect(Collectors.toMap(MgtSimpleMemberVo::getUserId, Function.identity()));
+            // 遍历订单列表,设置用户信息
             for (MerOrderPageVo merOrderPageVo : merOrderPageVoList) {
                 if (merOrderPageVo.getUserId() != null && userMap.get(merOrderPageVo.getUserId()) != null) {
                     merOrderPageVo.setUserName(userMap.get(merOrderPageVo.getUserId()).getRealName());
diff --git a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/order/OrderService.java b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/order/OrderService.java
index c1a444f..0012d41 100644
--- a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/order/OrderService.java
+++ b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/order/OrderService.java
@@ -521,4 +521,10 @@
      * @return
      */
     List<MerOrderPageVo> pageMerMemberPayOrder(Page page,MerMemberNoClearOrderDto merOrderPageDto);
+
+
+    void createWxPayInfo(AppPlaceOrderVo appPlaceOrderVo, Long userId, Long shopId,
+                                 String goodsName, String orderNo,
+                                 String orderId, BigDecimal payMoney,
+                                 String openid, String payerClientIp, List<String> goodsNameList);
 }
diff --git a/ruoyi-modules/ruoyi-order/src/main/resources/bootstrap.yml b/ruoyi-modules/ruoyi-order/src/main/resources/bootstrap.yml
index 59efa1b..893fe2c 100644
--- a/ruoyi-modules/ruoyi-order/src/main/resources/bootstrap.yml
+++ b/ruoyi-modules/ruoyi-order/src/main/resources/bootstrap.yml
@@ -16,10 +16,18 @@
         # 服务注册地址
         server-addr: 47.109.78.184:5000
         #server-addr: 127.0.0.1:8848
+        #pro
+        #namespace: 9591ef9f-a49a-4900-be35-d77258bdd639
+        #dev
+        namespace: d39a744d-116f-4280-8445-0502dd1a3116
       config:
         # 配置中心地址
         server-addr: 47.109.78.184:5000
         #server-addr: 127.0.0.1:8848
+        #pro
+        #namespace: 9591ef9f-a49a-4900-be35-d77258bdd639
+        #dev
+        namespace: d39a744d-116f-4280-8445-0502dd1a3116
         # 配置文件格式
         file-extension: yml
         # 共享配置
diff --git a/ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml b/ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
index b50b79f..b1dc538 100644
--- a/ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
+++ b/ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
@@ -1719,7 +1719,7 @@
         <if test="param.goodsType !=null and param.goodsType != ''">
             AND tog.goods_type = #{param.goodsType}
         </if>
-        GROUP BY toc.create_time
+        GROUP BY mapKey
     </select>
 
     <select id="getStaffActivityMemberTotal" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
@@ -1735,7 +1735,7 @@
         <if test="param.goodsType !=null and param.goodsType != ''">
             AND tog.goods_type = #{param.goodsType}
         </if>
-        GROUP BY toc.create_time
+        GROUP BY mapKey
     </select>
 
     <select id="countUserBuyGoodsNum" resultType="java.lang.Integer">
diff --git a/ruoyi-modules/ruoyi-order/src/test/java/com/ruoyi/order/orderTest.java b/ruoyi-modules/ruoyi-order/src/test/java/com/ruoyi/order/orderTest.java
new file mode 100644
index 0000000..a73a88d
--- /dev/null
+++ b/ruoyi-modules/ruoyi-order/src/test/java/com/ruoyi/order/orderTest.java
@@ -0,0 +1,38 @@
+package com.ruoyi.order;
+
+import com.ruoyi.order.service.order.OrderService;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.annotation.Resource;
+
+/**
+ * @ClassName orderTest
+ * @Description TODO
+ * @Author jqs
+ * @Date 2023/8/18 11:12
+ * @Version 1.0
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringBootTest(classes = RuoYiOrderApplication.class)
+public class orderTest {
+
+
+    @Resource
+    private OrderService orderService;
+
+    /*@Test
+    public void main() {
+
+        AppPlaceOrderVo appPlaceOrderVo = new AppPlaceOrderVo();
+
+        orderService.createWxPayInfo( appPlaceOrderVo, 280L, 50L,
+                "测试支付商品", "SC202308160046",
+                "0fa36ad3edcc40bebc2795cc505b5272", new BigDecimal("0.1"),
+                "oL-gp5GG6-KRVSIAE_qYLMULPFjw", "127.0.0.1", Arrays.asList("测试支付商品"));
+        System.out.println(appPlaceOrderVo.toString());
+    }*/
+
+
+}
diff --git a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/domain/pojo/shop/ShopAuthentication.java b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/domain/pojo/shop/ShopAuthentication.java
index 6543d6f..e1a9da3 100644
--- a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/domain/pojo/shop/ShopAuthentication.java
+++ b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/domain/pojo/shop/ShopAuthentication.java
@@ -61,6 +61,7 @@
      */
     @TableField("audit_status")
     private Integer auditStatus;
+
     /**
      * 主题类型1个人2企业
      */
@@ -86,6 +87,9 @@
      */
     @TableField("bl_registered_address")
     private String blRegisteredAddress;
+
+    @TableField("bl_business_start_time")
+    private String blBusinessStartTime;
     /**
      * 营业执照期限
      */
@@ -106,6 +110,10 @@
      */
     @TableField("lp_id_card")
     private String lpIdCard;
+
+    @TableField("lp_id_address")
+    private String lpIdAddress;
+
     /**
      * 法人身份证开始日期
      */
diff --git a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/domain/vo/MerAgencyPageVo.java b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/domain/vo/MerAgencyPageVo.java
index f9bd453..c1f5a9e 100644
--- a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/domain/vo/MerAgencyPageVo.java
+++ b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/domain/vo/MerAgencyPageVo.java
@@ -22,6 +22,9 @@
     @ApiModelProperty(value="商户状态0冻结1正常2终止合作")
     private Integer shopStatus;
 
+    @ApiModelProperty(value = "商户图片")
+    private String shopPicture;
+
     @ApiModelProperty(value = "商户名称")
     private String shopName;
 
@@ -38,5 +41,6 @@
     @JsonFormat(pattern = "yyyy-MM-dd")
     private Date cooperationEndTime;
 
-
+    @ApiModelProperty(value="合作状态0终止1开启")
+    private Integer cooperativeFlag;
 }
diff --git a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/domain/vo/MgtShopAuthPageVo.java b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/domain/vo/MgtShopAuthPageVo.java
index 6010114..68b6603 100644
--- a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/domain/vo/MgtShopAuthPageVo.java
+++ b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/domain/vo/MgtShopAuthPageVo.java
@@ -32,9 +32,18 @@
     @ApiModelProperty(value="认证类型")
     private String mainType;
 
-    @ApiModelProperty(value="审核状态")
+    @ApiModelProperty(value="审核状态0待进件1资料校验中2待账户验证3审核中4已驳回5待签约6完成7已冻结8已作废")
     private Integer auditStatus;
 
     @ApiModelProperty(value="审核状态描述")
     private String auditStatusDesc;
+
+    @ApiModelProperty(value = "签约状态1待签约2已签约3无法签约")
+    private Integer signState;
+
+    @ApiModelProperty(value = "签约链接")
+    private String signUrl;
+
+
+
 }
diff --git a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java
index 7d3ae1b..166b0fd 100644
--- a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java
+++ b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java
@@ -6,6 +6,7 @@
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsResult;
 import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsStatusResult;
 import com.github.binarywang.wxpay.exception.WxPayException;
 import com.ruoyi.common.core.constant.CacheConstants;
@@ -352,6 +353,8 @@
         shopAuthentication.setAuthId(authId);
         shopAuthentication.setDelFlag(0);
         shopAuthentication.setShopId(shop.getShopId());
+        shopAuthentication.setAuditStatus(0);
+        shopAuthentication.setSignState(1);
         shopAuthenticationService.save(shopAuthentication);
         //商户分成信息初始化
         ShopProportion shopProportion = new ShopProportion();
@@ -593,13 +596,19 @@
             }
             mgtShopInfoVo.setShopTagIds(shopTagJs.toString());
         }
+        //归属员工
         if(mgtShopInfoVo.getBelongUserId()!=null){
             SysUser sysUser = sysUserService.getSysUser(mgtShopInfoVo.getBelongUserId()).getData();
-            mgtShopInfoVo.setBelongUserName(sysUser.getNickName());
+            if(sysUser!=null){
+                mgtShopInfoVo.setBelongUserName(sysUser.getNickName());
+            }
         }
+        //归属商户
         if(mgtShopInfoVo.getBelongShopId()!=null){
             Shop belongShop = this.getByShopId(mgtShopInfoVo.getBelongShopId());
-            mgtShopInfoVo.setBelongShopName(belongShop.getShopName());
+            if(belongShop!=null){
+                mgtShopInfoVo.setBelongShopName(belongShop.getShopName());
+            }
         }
         //商户关联用户
         List<ShopRelUser> shopRelUserList = shopRelUserService.listByShopId(shopId);
@@ -994,16 +1003,22 @@
         Shop shop = this.getByShopId(shopAuthentication.getShopId());
         String applyNumber = IdUtils.simpleUUID();
         if(mgtShopAuthDto.getBlBusinessFoeverFlag()!=null&&mgtShopAuthDto.getBlBusinessFoeverFlag()==1){
-            mgtShopAuthDto.setBlBusinessDeanline("长期");
+            mgtShopAuthDto.setBlBusinessDeanline(mgtShopAuthDto.getBlBusinessStartTime()+",长期");
         }
         if(mgtShopAuthDto.getLpIcForeverFlag()!=null&&mgtShopAuthDto.getLpIcForeverFlag()==1){
             mgtShopAuthDto.setLpIcEndDate("长期");
         }
         BeanUtils.copyProperties(mgtShopAuthDto , shopAuthentication);
         shopAuthentication.setApplyNumber(applyNumber);
+        ApplymentsResult applymentsResult;
+        try {
+            applymentsResult = wechatPayUtils.ecommerceApply(shopAuthentication,applyNumber,shop);
+        } catch (Exception e) {
+            log.debug("-----"+shop.getShopId()+":进件异常-----");
+            throw new RuntimeException(e);
+        }
         shopAuthentication.setAuditStatus(3);
         shopAuthenticationService.saveOrUpdate(shopAuthentication);
-        //wechatPayUtils.ecommerceApply(shopAuthentication,applyNumber,shop);
     }
 
     /**
diff --git a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/util/WechatPayUtils.java b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/util/WechatPayUtils.java
index dc63d0f..95f4c24 100644
--- a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/util/WechatPayUtils.java
+++ b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/util/WechatPayUtils.java
@@ -1,5 +1,6 @@
 package com.ruoyi.shop.util;
 
+import com.alibaba.fastjson.JSONObject;
 import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsRequest;
 import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsResult;
 import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsStatusResult;
@@ -56,7 +57,13 @@
         business_license_info.setMerchantName(shopAuthentication.getBlShopName());
         business_license_info.setLegalPerson(shopAuthentication.getBlCorporateName());
         business_license_info.setCompanyAddress(shopAuthentication.getBlRegisteredAddress());
-        business_license_info.setBusinessTime("[\"2023-05-08\",\"长期\"]");
+        List<String> businessTimeList = new ArrayList<>();
+        businessTimeList.add(0,shopAuthentication.getBlBusinessStartTime());
+        businessTimeList.add(1,shopAuthentication.getBlBusinessDeanline());
+        if(businessTimeList!=null&&businessTimeList.size()>1){
+            String businessTime = JSONObject.toJSONString(businessTimeList);
+            business_license_info.setBusinessTime(businessTime);
+        }
         request.setBusinessLicenseInfo(business_license_info);
         //法人证件
         request.setIdDocType("IDENTIFICATION_TYPE_MAINLAND_IDCARD");
@@ -71,7 +78,7 @@
         lpIcBackIO.close();
         id_card_info.setIdCardName(shopAuthentication.getLpCorporateName());
         id_card_info.setIdCardNumber(shopAuthentication.getLpIdCard());
-        id_card_info.setIdCardAddress("四川省泸州市江阳区桃园路1号2号楼4单元1号");
+        id_card_info.setIdCardAddress(shopAuthentication.getLpIdAddress());
         id_card_info.setIdCardValidTimeBegin(shopAuthentication.getLpIcStartDate());
         id_card_info.setIdCardValidTime(shopAuthentication.getLpIcEndDate());
         request.setIdCardInfo(id_card_info);
@@ -118,8 +125,8 @@
         contactInfo.setContactType("65");
         contactInfo.setContactName(shopAuthentication.getLpCorporateName());
         contactInfo.setContactIdCardNumber(shopAuthentication.getLpIdCard());
-        contactInfo.setMobilePhone("13882237106");
-        contactInfo.setContactEmail("343695869@qq.com");
+        contactInfo.setMobilePhone(shopAuthentication.getLpMobilePhone());
+        contactInfo.setContactEmail(shopAuthentication.getLpContactEmail());
         request.setContactInfo(contactInfo);
         //店铺信息
         ApplymentsRequest.SalesSceneInfo salesSceneInfo = new ApplymentsRequest.SalesSceneInfo();
@@ -127,6 +134,7 @@
         InputStream storeQrCodeIO = OBSUploadUtils.getOSSInputStream(shop.getShopCode().replace("https://hongruitang.oss-cn-beijing.aliyuncs.com/",""));
         ImageUploadResult storeQrCodeIR = merchantMediaService.imageUploadV3(storeQrCodeIO,applyNumber+"storeQrCode.jpg");
         salesSceneInfo.setStoreQrCode(storeQrCodeIR.getMediaId());
+        storeQrCodeIO.close();
         request.setSalesSceneInfo(salesSceneInfo);
         request.setMerchantShortname(shop.getShopName());
         request.setBusinessAdditionPics(shopAuthentication.getBaPics());
diff --git a/ruoyi-modules/ruoyi-shop/src/main/resources/mapper/shop/ShopMapper.xml b/ruoyi-modules/ruoyi-shop/src/main/resources/mapper/shop/ShopMapper.xml
index 0dfdb71..3be5496 100644
--- a/ruoyi-modules/ruoyi-shop/src/main/resources/mapper/shop/ShopMapper.xml
+++ b/ruoyi-modules/ruoyi-shop/src/main/resources/mapper/shop/ShopMapper.xml
@@ -404,8 +404,11 @@
         CONCAT(ts.shop_area_name,ts.shop_address) shopAddress,
         ts.shopowner_name shopownerName,
         ts.shopowner_phone shopownerPhone,
-        ts.cooperation_end_time cooperationEndTime
+        ts.cooperation_end_time cooperationEndTime,
+        ts.cooperative_flag cooperativeFlag,
+        tsf.file_uel shopPicture
         FROM t_shop ts
+        LEFT JOIN t_shop_file tsf ON tsf.shop_id = ts.shop_id AND tsf.del_flag = 0 AND tsf.file_type = 1
         WHERE ts.del_flag = 0 AND ts.belong_shop_id = #{param.shopId}
         <if test="param.shopStatus!=null and param.shopStatus==1">
             AND ts.shop_status = 1
@@ -530,6 +533,8 @@
             WHEN 2 THEN '企业'
             END mainType,
         tsa.audit_status auditStatus,
+        tsa.sign_state signState,
+        tsa.sign_url signUrl,
         CASE tsa.audit_status
             WHEN 0 THEN '待审核'
             WHEN 1 THEN '审核中'
diff --git a/ruoyi-modules/ruoyi-system/pom.xml b/ruoyi-modules/ruoyi-system/pom.xml
index 22676f1..ea8ad32 100644
--- a/ruoyi-modules/ruoyi-system/pom.xml
+++ b/ruoyi-modules/ruoyi-system/pom.xml
@@ -102,6 +102,7 @@
             <version>2.3.3</version>
         </dependency>
 
+        <!-- 测试类 -->
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/config/WxCpConfiguration.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/config/WxCpConfiguration.java
new file mode 100644
index 0000000..4dedcc4
--- /dev/null
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/config/WxCpConfiguration.java
@@ -0,0 +1,51 @@
+package com.ruoyi.system.config;
+
+import lombok.AllArgsConstructor;
+import me.chanjar.weixin.common.util.crypto.WxCryptUtil;
+import me.chanjar.weixin.cp.api.WxCpService;
+import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
+import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @ClassName WxCpConfiguration
+ * @Description TODO
+ * @Author jqs
+ * @Date 2023/8/17 12:42
+ * @Version 1.0
+ */
+@Configuration
+@ConditionalOnClass(WxCpService.class)
+@EnableConfigurationProperties(WxCpProperties.class)
+@AllArgsConstructor
+public class WxCpConfiguration {
+
+    private WxCpProperties properties;
+
+    @Bean
+    @ConditionalOnMissingBean
+    public WxCpService wxService() {
+
+        WxCpDefaultConfigImpl wxCpConfigStorage = new WxCpDefaultConfigImpl();
+        wxCpConfigStorage.setCorpId(properties.getCorpId());
+        wxCpConfigStorage.setAgentId(properties.getAgentId());
+        wxCpConfigStorage.setCorpSecret(properties.getAgentSecret());
+
+        WxCpService wxService = new WxCpServiceImpl();
+        wxService.setWxCpConfigStorage(wxCpConfigStorage);
+
+        return wxService;
+    }
+
+    @Bean
+    public WxCryptUtil wxCryptUtil() {
+
+        WxCryptUtil wxCryptUtil = new WxCryptUtil("", "", properties.getCorpId());
+
+        return wxCryptUtil;
+    }
+}
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/config/WxCpProperties.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/config/WxCpProperties.java
new file mode 100644
index 0000000..3eacd2f
--- /dev/null
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/config/WxCpProperties.java
@@ -0,0 +1,36 @@
+package com.ruoyi.system.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+/**
+ * @ClassName WxCpProperties
+ * @Description TODO
+ * @Author jqs
+ * @Date 2023/8/17 12:43
+ * @Version 1.0
+ */
+@Data
+@ConfigurationProperties(prefix = "wx.cp")
+public class WxCpProperties {
+
+    /**
+     *
+     */
+    private String corpId;
+
+    /**
+     *
+     */
+    private Integer agentId;
+
+    /**
+     *
+     */
+    private String agentSecret;
+
+    /**
+     *
+     */
+    private String authorizeState;
+}
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/conslole/QYWXCallBackController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/conslole/QYWXCallBackController.java
index e18eb1b..11c4e89 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/conslole/QYWXCallBackController.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/conslole/QYWXCallBackController.java
@@ -1,10 +1,16 @@
 package com.ruoyi.system.controller.conslole;
 
-import com.esotericsoftware.minlog.Log;
+import com.ruoyi.common.core.utils.StringUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import lombok.extern.log4j.Log4j2;
+import me.chanjar.weixin.common.util.crypto.WxCryptUtil;
 import org.apache.commons.io.IOUtils;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -19,13 +25,15 @@
 @Api(value = "企业微信通知控制", tags = "企业微信通知控制", description = "企业微信通知控制")
 @RestController
 @RequestMapping("/qywx")
+@Log4j2
 public class QYWXCallBackController {
 
+    @Autowired
+    private  WxCryptUtil wxCryptUtil;
 
     @ApiOperation(value = "消息与事件接收配置")
-    @RequestMapping(value = "/qywxNotify",
-            method = RequestMethod.POST,consumes = "text/xml",produces = "text/xml;charset=utf-8")
-    public String wechatPlatformEvent(@PathVariable String APPID,
+    @RequestMapping(value = "/qywxNotify", method = {RequestMethod.GET,RequestMethod.POST})
+    public String wechatPlatformEvent(@RequestBody(required = false) String body,
                                       HttpServletRequest request,
                                       HttpServletResponse response
     ) throws Exception {
@@ -35,7 +43,16 @@
         String msgSignature = request.getParameter("msg_signature");
         String encType =  request.getParameter("encrypt_type");
         String xml =  IOUtils.toString(request.getReader());
-        Log.info("企业微信回调"+xml);
+        log.info("企业微信回调参数nonce"+nonce);
+        log.info("企业微信回调参数timestamp"+timestamp);
+        log.info("企业微信回调参数signature"+signature);
+        log.info("企业微信回调参数msgSignature"+msgSignature);
+        log.info("企业微信回调参数encType"+encType);
+        log.info("企业微信回调参数xml"+xml);
+        if(StringUtils.isNotBlank(msgSignature)&&StringUtils.isNotBlank(timestamp)&&StringUtils.isNotBlank(nonce)&&StringUtils.isNotBlank(xml)){
+            String reponseStr = wxCryptUtil.decryptXml(msgSignature,timestamp,nonce,xml);
+            log.info("企业微信回调参数xml解析"+reponseStr);
+        }
         return "SUCCESS";
     }
 }
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/management/MgtStaffController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/management/MgtStaffController.java
index 45b35c9..29cc75a 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/management/MgtStaffController.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/management/MgtStaffController.java
@@ -3,6 +3,7 @@
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.web.domain.AjaxResult;
 import com.ruoyi.common.log.annotation.Log;
 import com.ruoyi.common.log.enums.BusinessType;
 import com.ruoyi.common.security.utils.SecurityUtils;
@@ -17,14 +18,14 @@
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import java.util.List;
+
+import static com.ruoyi.common.core.web.domain.AjaxResult.success;
 
 /**
  * @author jqs34
@@ -150,4 +151,14 @@
         sysStaffService.mgtDeleteStaff(mgtBaseGetDto);
         return R.ok();
     }
+
+    @ApiOperation(value = "导入员工数据")
+    @PostMapping("/importSysStaff")
+    public AjaxResult importSysStaff(@RequestPart("file") MultipartFile file) throws Exception
+    {
+        ExcelUtil<MgtSysStaffImportDto> util = new ExcelUtil<MgtSysStaffImportDto>(MgtSysStaffImportDto.class);
+        List<MgtSysStaffImportDto> sysStaffImportDtoList = util.importExcel(file.getInputStream());
+        String message = sysStaffService.importSysStaff(sysStaffImportDtoList);
+        return success(message);
+    }
 }
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/staff/StaffSysController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/staff/StaffSysController.java
index f9df96f..150f3ce 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/staff/StaffSysController.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/staff/StaffSysController.java
@@ -2,10 +2,12 @@
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.web.domain.AjaxResult;
 import com.ruoyi.common.security.utils.SecurityUtils;
-import com.ruoyi.system.api.domain.dto.MerPageDto;
 import com.ruoyi.system.api.domain.dto.StaffPageDto;
 import com.ruoyi.system.api.domain.poji.sys.SysUser;
+import com.ruoyi.system.domain.dto.MgtSysStaffImportDto;
 import com.ruoyi.system.domain.dto.StaffUseSuggestDto;
 import com.ruoyi.system.domain.pojo.staff.SysStaff;
 import com.ruoyi.system.domain.vo.StaffSuggestPageVo;
@@ -15,13 +17,13 @@
 import com.ruoyi.system.service.sys.ISysUserService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import java.util.List;
+
+import static com.ruoyi.common.core.web.domain.AjaxResult.success;
 
 /**
  * @author jqs34
@@ -80,4 +82,6 @@
         List<StaffSuggestPageVo> staffSuggestPageVoList = staffSuggestService.pageStaffShopSuggest(page,staffPageDto);
         return R.ok(page.setRecords(staffSuggestPageVoList));
     }
+
+
 }
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/MgtSysStaffImportDto.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/MgtSysStaffImportDto.java
new file mode 100644
index 0000000..f6ff933
--- /dev/null
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/MgtSysStaffImportDto.java
@@ -0,0 +1,42 @@
+package com.ruoyi.system.domain.dto;
+
+import com.ruoyi.common.core.annotation.Excel;
+import lombok.Data;
+
+/**
+ * @ClassName MgtSysStaffImportDto
+ * @Description TODO
+ * @Author jqs
+ * @Date 2023/8/18 15:56
+ * @Version 1.0
+ */
+@Data
+public class MgtSysStaffImportDto {
+
+    @Excel(name = "姓名")
+    private String staffName;
+
+    @Excel(name = "账号")
+    private String userName;
+
+    @Excel(name = "昵称")
+    private String nickName;
+
+    @Excel(name = "职务")
+    private String post;
+
+    @Excel(name = "部门")
+    private String department;
+
+    @Excel(name = "性别")
+    private String gender;
+
+    @Excel(name = "手机")
+    private String mobile;
+
+    @Excel(name = "座机")
+    private String phone;
+
+    @Excel(name = "邮箱")
+    private String email;
+}
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/pojo/staff/SysStaff.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/pojo/staff/SysStaff.java
index 65885b1..2bf0276 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/pojo/staff/SysStaff.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/pojo/staff/SysStaff.java
@@ -72,6 +72,9 @@
     @TableField("head_flag")
     private String headFlag;
 
+    /**
+     * 企业微信userId
+     */
     @TableField("wx_user_id")
     private String wxUserId;
 
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/sys/SysDeptMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/sys/SysDeptMapper.java
index 7bb1b1e..81348ac 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/sys/SysDeptMapper.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/sys/SysDeptMapper.java
@@ -1,8 +1,9 @@
 package com.ruoyi.system.mapper.sys;
 
-import java.util.List;
-import org.apache.ibatis.annotations.Param;
 import com.ruoyi.system.api.domain.poji.sys.SysDept;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 部门管理 数据层
@@ -36,6 +37,16 @@
      */
     public SysDept selectDeptById(Long deptId);
 
+
+    /**
+     * @description  通过微信部门id获取部门
+     * @author  jqs
+     * @date    2023/8/17 16:21
+     * @param wxDeptId
+     * @return  SysDept
+     */
+    SysDept getByWxDeptId(Long wxDeptId);
+
     /**
      * 根据ID查询所有子部门
      * 
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/scheduler/SystemScheduler.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/scheduler/SystemScheduler.java
index b4169bb..2921a7d 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/scheduler/SystemScheduler.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/scheduler/SystemScheduler.java
@@ -1,8 +1,10 @@
 package com.ruoyi.system.scheduler;
 
 
+import com.ruoyi.system.service.staff.SysWxCpService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
 
@@ -14,7 +16,20 @@
     @Autowired
     private SchedulerUtils schedulerUtils;
 
+    @Autowired
+    private SysWxCpService sysWxCpService;
 
 
 
+    /**
+     * 定时同步企业微信部门
+     */
+    @Scheduled(cron="0 0 2 * * ?")
+    private void timingCheckMemberCoupon(){
+        if(schedulerUtils.getSchedulerRun()) {
+            log.info("定时同步企业微信部门任务开始执行");
+            sysWxCpService.syncDepartment();
+        }
+    }
+
 }
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysStaffServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysStaffServiceImpl.java
index 03acb69..fd20568 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysStaffServiceImpl.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysStaffServiceImpl.java
@@ -18,6 +18,7 @@
 import com.ruoyi.system.api.service.RemoteShopService;
 import com.ruoyi.system.domain.dto.MgtStaffEditDto;
 import com.ruoyi.system.domain.dto.MgtStaffPageDto;
+import com.ruoyi.system.domain.dto.MgtSysStaffImportDto;
 import com.ruoyi.system.domain.pojo.staff.SysStaff;
 import com.ruoyi.system.domain.vo.MgtDeptStaffListVo;
 import com.ruoyi.system.domain.vo.MgtStaffPageVo;
@@ -28,6 +29,7 @@
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.Date;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
@@ -218,19 +220,7 @@
     }
 
 
-    /**
-     * @description  同步组织架构
-     * @author  jqs
-     * @date    2023/7/18 19:06
-     * @param
-     * @return  void
-     */
-    @Override
-    public void synchronizeOrganizationalStructure(){
-        String accessToken = getQYToken();
 
-
-    }
 
 
     /**
@@ -291,4 +281,63 @@
         }
         this.saveOrUpdate(sysStaff);
     }
+
+    /**
+     * @description  导入员工
+     * @author  jqs
+     * @date    2023/8/18 16:04
+     * @param
+     * @return  void
+     */
+    @Override
+    public String importSysStaff(List<MgtSysStaffImportDto> staffImportDtoList){
+        if (StringUtils.isNull(staffImportDtoList) || staffImportDtoList.size() == 0) {
+            throw new ServiceException("导入数据不能为空!");
+        }
+        int successNum = 0;
+        int failureNum = 0;
+        StringBuilder successMsg = new StringBuilder();
+        StringBuilder failureMsg = new StringBuilder();
+        SysStaff sysStaff;
+        Date nowTime = new Date();
+        for (MgtSysStaffImportDto entity : staffImportDtoList) {
+            try {
+                /*tagName = entity.getTagName();
+                sysTagSame = null;
+                // 验证是否存在这个用户
+                queryWrapper = new LambdaQueryWrapper<>();
+                queryWrapper.eq(SysTag::getDelFlag, 0) // 查询条件:delFlag=0
+                        .eq(SysTag::getTagType, tagType) // 查询条件:tagType=mgtTagEditDto的tagType属性
+                        .eq(SysTag::getTagName, tagName); // 查询条件:tagName=mgtTagEditDto的tagName属性
+                // 执行查询,获取与查询条件匹配的SysTag对象
+                sysTagSame = this.getOne(queryWrapper);
+                if (sysTagSame == null) {
+                    sysTagNew = new SysTag();
+                    sysTagNew.setDelFlag(0);
+                    sysTagNew.setTagType(tagType);
+                    sysTagNew.setTagName(tagName);
+                    sysTagNew.setCreateTime(nowTime);
+                    sysTagNew.setSynFlag(0);
+                    this.save(sysTagNew);
+                    successNum++;
+                    successMsg.append("<br/>" + successNum + "、标签 " + sysTagNew.getTagName() + " 导入成功");
+                } else {
+                    failureNum++;
+                    failureMsg.append("<br/>" + failureNum + "、标签 " + sysTagSame.getTagName() + " 已存在");
+                }*/
+            } catch (Exception e) {
+                failureNum++;
+                String msg = "<br/>" + failureNum + "、标签 " + entity.getStaffName() + " 导入失败:";
+                failureMsg.append(msg + e.getMessage());
+                log.error(msg, e);
+            }
+        }
+        if (failureNum > 0) {
+            failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
+            throw new ServiceException(failureMsg.toString());
+        } else {
+            successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
+        }
+        return successMsg.toString();
+    }
 }
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysWxCpServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysWxCpServiceImpl.java
new file mode 100644
index 0000000..2b94fce
--- /dev/null
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysWxCpServiceImpl.java
@@ -0,0 +1,97 @@
+package com.ruoyi.system.service.impl.staff;
+
+import com.ruoyi.system.api.domain.poji.sys.SysDept;
+import com.ruoyi.system.service.staff.SysWxCpService;
+import com.ruoyi.system.service.sys.ISysDeptService;
+import lombok.extern.log4j.Log4j2;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.cp.api.WxCpDepartmentService;
+import me.chanjar.weixin.cp.api.WxCpService;
+import me.chanjar.weixin.cp.bean.WxCpDepart;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * @ClassName WxCpServiceImpl
+ * @Description TODO
+ * @Author jqs
+ * @Date 2023/8/17 15:25
+ * @Version 1.0
+ */
+@Service
+@Log4j2
+public class SysWxCpServiceImpl implements SysWxCpService {
+
+    @Resource
+    private WxCpService wxCpService;
+
+    @Resource
+    private ISysDeptService  sysDeptService;
+    /**
+     * @description
+     * @author  jqs
+     * @date    2023/8/17 15:26
+     * @param
+     * @return  String
+     */
+    @Override
+    public String getToken(){
+        String accessToken = null;
+        try {
+            accessToken = wxCpService.getAccessToken();
+        } catch (WxErrorException e) {
+            throw new RuntimeException(e);
+        }
+        return accessToken;
+    }
+
+    /**
+     * @description  同步部门
+     * @author  jqs
+     * @date    2023/8/17 15:42
+     * @param
+     * @return  void
+     */
+    @Override
+    public void syncDepartment(){
+        WxCpDepartmentService wxCpDepartmentService = wxCpService.getDepartmentService();
+        try {
+            //从企业微信拉去部门名单
+            List<WxCpDepart> wxCpDepartList = wxCpDepartmentService.list(null);
+            if(wxCpDepartList!=null&&wxCpDepartList.size()>0){
+                for(WxCpDepart wxCpDepart : wxCpDepartList){
+                    if(wxCpDepart.getParentId().compareTo(24L)<0){
+                        //获取系统内对应部门
+                        SysDept sysDept = sysDeptService.getByWxDeptId(wxCpDepart.getId());
+                        //判断是否有该部门,没有则新建
+                        if(sysDept!=null){
+                            //判断是否有变化
+                            if(!sysDept.getDeptName().equals(wxCpDepart.getName())||sysDept.getOrderNum()!=wxCpDepart.getOrder().intValue()){
+                                sysDept.setDeptName(wxCpDepart.getName());
+                                sysDept.setOrderNum(wxCpDepart.getOrder().intValue());
+                                sysDept.setUpdateBy("企业微信同步");
+                                sysDeptService.updateDept(sysDept);
+                                log.info("企业微信同步更新部门:"+wxCpDepart.getName());
+                            }
+                        }else{
+                            sysDept = new SysDept();
+                            sysDept.setDelFlag("0");
+                            sysDept.setStatus("0");
+                            sysDept.setParentId(100L);
+                            sysDept.setOrderNum(wxCpDepart.getOrder().intValue());
+                            sysDept.setCreateBy("企业微信同步");
+                            sysDept.setDeptName(wxCpDepart.getName());
+                            sysDept.setWxDeptId(wxCpDepart.getId());
+                            sysDeptService.insertDept(sysDept);
+                            log.info("企业微信同步新增部门:"+wxCpDepart.getName());
+                        }
+                    }
+                }
+            }
+        } catch (WxErrorException e) {
+            throw new RuntimeException(e);
+        }
+    }
+}
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/sys/SysDeptServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/sys/SysDeptServiceImpl.java
index 0bdc6ed..9e21529 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/sys/SysDeptServiceImpl.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/sys/SysDeptServiceImpl.java
@@ -383,4 +383,17 @@
     {
         return getChildList(list, t).size() > 0 ? true : false;
     }
+
+
+    /**
+     * @description  通过微信部门id获取部门
+     * @author  jqs
+     * @date    2023/8/17 16:21
+     * @param wxDeptId
+     * @return  SysDept
+     */
+    @Override
+    public SysDept getByWxDeptId(Long wxDeptId){
+        return deptMapper.getByWxDeptId(wxDeptId);
+    }
 }
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/staff/SysStaffService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/staff/SysStaffService.java
index f432e18..59c4b1a 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/staff/SysStaffService.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/staff/SysStaffService.java
@@ -5,6 +5,7 @@
 import com.ruoyi.system.api.domain.dto.MgtBaseGetDto;
 import com.ruoyi.system.domain.dto.MgtStaffEditDto;
 import com.ruoyi.system.domain.dto.MgtStaffPageDto;
+import com.ruoyi.system.domain.dto.MgtSysStaffImportDto;
 import com.ruoyi.system.domain.pojo.staff.SysStaff;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.system.domain.vo.MgtDeptStaffListVo;
@@ -86,14 +87,7 @@
      */
     SysStaff getByMobile(String mobile);
 
-    /**
-     * @description  同步组织架构
-     * @author  jqs
-     * @date    2023/7/18 19:06
-     * @param 
-     * @return  void
-     */
-    void synchronizeOrganizationalStructure();
+
 
     /**
      * @description  编辑商户员工
@@ -103,4 +97,13 @@
      * @return  void
      */
     void editSysStaffInfo(MerEditUserDto merEditUserDto);
+
+    /**
+     * @description  导入员工
+     * @author  jqs
+     * @date    2023/8/18 16:04
+     * @param
+     * @return  void
+     */
+    String importSysStaff(List<MgtSysStaffImportDto> staffImportDtoList);
 }
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/staff/SysWxCpService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/staff/SysWxCpService.java
new file mode 100644
index 0000000..0bfc9ad
--- /dev/null
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/staff/SysWxCpService.java
@@ -0,0 +1,29 @@
+package com.ruoyi.system.service.staff;
+
+/**
+ * @ClassName WxCpService
+ * @Description TODO
+ * @Author jqs
+ * @Date 2023/8/17 15:22
+ * @Version 1.0
+ */
+public interface SysWxCpService {
+
+    /**
+     * @description 获取token
+     * @author  jqs
+     * @date    2023/8/17 15:26
+     * @param
+     * @return  String
+     */
+    String getToken();
+
+    /**
+     * @description  同步部门
+     * @author  jqs
+     * @date    2023/8/17 15:42
+     * @param
+     * @return  void
+     */
+    void syncDepartment();
+}
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/sys/ISysDeptService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/sys/ISysDeptService.java
index 788a8e6..4eb0e9c 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/sys/ISysDeptService.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/sys/ISysDeptService.java
@@ -1,8 +1,9 @@
 package com.ruoyi.system.service.sys;
 
-import java.util.List;
 import com.ruoyi.system.api.domain.poji.sys.SysDept;
 import com.ruoyi.system.domain.vo.TreeSelect;
+
+import java.util.List;
 
 /**
  * 部门管理 服务层
@@ -121,4 +122,13 @@
      * @return 结果
      */
     public int deleteDeptById(Long deptId);
+
+    /**
+     * @description  通过微信部门id获取部门
+     * @author  jqs
+     * @date    2023/8/17 16:21
+     * @param wxDeptId
+     * @return  SysDept
+     */
+    SysDept getByWxDeptId(Long wxDeptId);
 }
diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml b/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml
index 5374e41..551276b 100644
--- a/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml
+++ b/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml
@@ -35,3 +35,14 @@
       max-request-size: 200MB
       location: /home/temp
 
+wx:
+  cp:
+    corpId: ww11400938eb1b91bc
+    agentId: 1000024
+    agentSecret: -wuQ2EBxNT9BJa40LdpFqyxI_8RqrZTCUNiabzBasi8
+    authorizeState: HONGRUITANG
+    suiteSecret: ""
+    token: ""
+    encodingAESKey: ""
+
+
diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/sys/SysDeptMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/sys/SysDeptMapper.xml
index 7e4d3c3..645ff84 100644
--- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/sys/SysDeptMapper.xml
+++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/sys/SysDeptMapper.xml
@@ -21,10 +21,11 @@
 		<result property="updateBy"   column="update_by"   />
 		<result property="updateTime" column="update_time" />
 		<result property="dataScope" column="data_scope" />
+		<result property="wxDeptId" column="wx_dept_id" />
 	</resultMap>
 	
 	<sql id="selectDeptVo">
-        select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time ,d.data_scope
+        select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time ,d.data_scope,d.wx_dept_id
         from sys_dept d
     </sql>
     
@@ -63,6 +64,11 @@
 		<include refid="selectDeptVo"/>
 		where dept_id = #{deptId}
 	</select>
+
+	<select id="getByWxDeptId" parameterType="Long" resultMap="SysDeptResult">
+		<include refid="selectDeptVo"/>
+		where wx_dept_id = #{wxDeptId}
+	</select>
     
     <select id="checkDeptExistUser" parameterType="Long" resultType="int">
 		select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0'
@@ -99,6 +105,7 @@
  			<if test="status != null">status,</if>
  			<if test="createBy != null and createBy != ''">create_by,</if>
 			<if test="dataScope != null and dataScope != ''">data_scope,</if>
+			<if test="wxDeptId != null and wxDeptId != ''">wx_dept_id,</if>
  			create_time
  		)values(
  			<if test="deptId != null and deptId != 0">#{deptId},</if>
@@ -112,6 +119,7 @@
  			<if test="status != null">#{status},</if>
  			<if test="createBy != null and createBy != ''">#{createBy},</if>
 			<if test="dataScope != null and dataScope != ''">#{dataScope},</if>
+			<if test="wxDeptId != null and wxDeptId != ''">#{wxDeptId},</if>
  			sysdate()
  		)
 	</insert>
diff --git a/ruoyi-modules/ruoyi-system/src/test/java/com/ruoyi/system/systemTest.java b/ruoyi-modules/ruoyi-system/src/test/java/com/ruoyi/system/systemTest.java
index 0f8acae..3c10423 100644
--- a/ruoyi-modules/ruoyi-system/src/test/java/com/ruoyi/system/systemTest.java
+++ b/ruoyi-modules/ruoyi-system/src/test/java/com/ruoyi/system/systemTest.java
@@ -1,9 +1,13 @@
 package com.ruoyi.system;
 
 
+import com.ruoyi.system.service.staff.SysWxCpService;
+import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.annotation.Resource;
 
 /**
  * @ClassName systemTest
@@ -16,7 +20,11 @@
 @SpringBootTest(classes = RuoYiSystemApplication.class)
 public class systemTest {
 
+    @Resource
+    private SysWxCpService sysWxCpService;
 
-
-
+    @Test
+    public void main() {
+        sysWxCpService.syncDepartment();
+    }
 }

--
Gitblit v1.7.1