Pārlūkot izejas kodu

微信客户同步的开发

dongxin 1 gadu atpakaļ
vecāks
revīzija
2ea77a7c48
42 mainītis faili ar 2076 papildinājumiem un 343 dzēšanām
  1. 93 0
      linkwe-api/src/main/java/com/linkwechat/controller/WeCustomerUserController.java
  2. 82 0
      linkwe-api/src/main/java/com/linkwechat/controller/WeUserController.java
  3. 22 22
      linkwe-auth/src/main/java/com/linkwechat/web/service/SysLoginService.java
  4. 167 0
      linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/bdshdb/customer/controller/LocalAppUserController.java
  5. 0 34
      linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/bdshdb/customer/controller/TestController.java
  6. 27 0
      linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/bdshdb/customer/domain/dto/LocalAppUserDto.java
  7. 4 1
      linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/bdshdb/customer/domain/vo/LocalAppUserVo.java
  8. 11 0
      linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/bdshdb/customer/mapper/LocalAppUserMapper.java
  9. 277 0
      linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/bdshdb/customer/scheduled/SyncUserDataScheduledService.java
  10. 0 4
      linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/bdshdb/customer/scheduled/tes.java
  11. 10 0
      linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/bdshdb/customer/service/ILocalAppUserService.java
  12. 8 0
      linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/bdshdb/customer/service/impl/LocalAppUserServiceImpl.java
  13. 87 0
      linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/jzgdb/customer/controller/SysUserJzgController.java
  14. 22 0
      linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/jzgdb/customer/domain/dto/SysUserJzgDto.java
  15. 51 0
      linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/jzgdb/customer/domain/entity/SysUserJzg.java
  16. 59 0
      linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/jzgdb/customer/domain/vo/SysUserJzgVo.java
  17. 19 0
      linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/jzgdb/customer/mapper/SysUserJzgMapper.java
  18. 18 0
      linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/jzgdb/customer/service/ISysUserJzgService.java
  19. 20 0
      linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/jzgdb/customer/service/impl/SysUserJzgServiceImpl.java
  20. 22 0
      linkwe-chinacoal/src/main/resources/mapper/modules/bdshdb/customer/LocalAppUserMapper.xml
  21. 0 141
      linkwe-chinacoal/src/main/resources/mapper/modules/bdshdb/customer/test.xml
  22. 23 0
      linkwe-chinacoal/src/main/resources/mapper/modules/jzgdb/customer/SysUserJzgMapper.xml
  23. 0 141
      linkwe-chinacoal/src/main/resources/mapper/modules/jzgdb/customer/test.xml
  24. 78 0
      linkwe-service/src/main/java/com/linkwechat/domain/WeCustomerUser.java
  25. 105 0
      linkwe-service/src/main/java/com/linkwechat/domain/WeUser.java
  26. 45 0
      linkwe-service/src/main/java/com/linkwechat/domain/customer/query/WeCuUserQuery.java
  27. 43 0
      linkwe-service/src/main/java/com/linkwechat/domain/customer/query/WeCustomerUserQuery.java
  28. 5 0
      linkwe-service/src/main/java/com/linkwechat/domain/customer/query/WeCustomersQuery.java
  29. 44 0
      linkwe-service/src/main/java/com/linkwechat/domain/customer/vo/WeCustomerUserDetailInfoVo.java
  30. 67 0
      linkwe-service/src/main/java/com/linkwechat/domain/customer/vo/WeCustomerUserVo.java
  31. 6 0
      linkwe-service/src/main/java/com/linkwechat/domain/customer/vo/WeCustomersVo.java
  32. 58 0
      linkwe-service/src/main/java/com/linkwechat/domain/customer/vo/WeUserDetailInfoVo.java
  33. 90 0
      linkwe-service/src/main/java/com/linkwechat/domain/customer/vo/WeUserVo.java
  34. 45 0
      linkwe-service/src/main/java/com/linkwechat/mapper/WeCustomerUserMapper.java
  35. 44 0
      linkwe-service/src/main/java/com/linkwechat/mapper/WeUserMapper.java
  36. 49 0
      linkwe-service/src/main/java/com/linkwechat/service/IWeCustomerUserService.java
  37. 44 0
      linkwe-service/src/main/java/com/linkwechat/service/IWeUserService.java
  38. 95 0
      linkwe-service/src/main/java/com/linkwechat/service/impl/WeCustomerUserServiceImpl.java
  39. 63 0
      linkwe-service/src/main/java/com/linkwechat/service/impl/WeUserServiceImpl.java
  40. 8 0
      linkwe-service/src/main/resources/mapper/wecom/WeCustomerMapper.xml
  41. 73 0
      linkwe-service/src/main/resources/mapper/wecom/WeCustomerUserMapper.xml
  42. 92 0
      linkwe-service/src/main/resources/mapper/wecom/WeUserMapper.xml

+ 93 - 0
linkwe-api/src/main/java/com/linkwechat/controller/WeCustomerUserController.java

@@ -0,0 +1,93 @@
+package com.linkwechat.controller;
+
+import com.linkwechat.common.core.controller.BaseController;
+import com.linkwechat.common.core.domain.AjaxResult;
+import com.linkwechat.common.core.page.TableDataInfo;
+import com.linkwechat.common.core.page.TableSupport;
+import com.linkwechat.domain.customer.query.WeCustomerUserQuery;
+import com.linkwechat.domain.customer.vo.WeCustomerUserDetailInfoVo;
+import com.linkwechat.domain.customer.vo.WeCustomerUserVo;
+import com.linkwechat.domain.customer.vo.WeUserDetailInfoVo;
+import com.linkwechat.domain.fission.WeFission;
+import com.linkwechat.service.IWeCustomerUserService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 微信客户Controller
+ *
+ * @author ruoyi
+ * @date 2020-09-13
+ */
+@RestController
+@RequestMapping("/we/customerUser")
+@Api(tags = "微信客户接口")
+@Slf4j
+public class WeCustomerUserController extends BaseController {
+
+    @Autowired
+    private IWeCustomerUserService weCustomerUserService;
+
+    /**
+     * 查询微信客户列表(分页),索引优化用户列表,未使用默认分页
+     */
+    @GetMapping("/findWeCustomerUserList")
+    @ApiOperation(value = "查询微信客户列表(分页)",httpMethod = "GET")
+    public TableDataInfo findWeCustomerUserList(WeCustomerUserQuery weCustomerUserQuery) {
+        List<WeCustomerUserVo> list = weCustomerUserService.findWeCustomerUserList(weCustomerUserQuery, TableSupport.buildPageRequest());
+        TableDataInfo dataTable = getDataTable(list);
+        //设置总条数
+        dataTable.setTotal(
+                weCustomerUserService.countWeCustomerUserList(weCustomerUserQuery)
+        );
+
+        return dataTable;
+    }
+
+
+    /**
+     * 微信客户详情基础
+     * @param id
+     * @return
+     */
+    @GetMapping("/findWeCustomerUserBaseInfo")
+    @ApiOperation(value = "微信客户详情基础",httpMethod = "GET")
+    public AjaxResult<WeCustomerUserDetailInfoVo> findWeCustomerUserBaseInfo(String id){
+        return AjaxResult.success(
+                weCustomerUserService.findWeCustomerUserBaseInfo(id)
+        );
+    }
+
+    /**
+     * 绑定用户
+     * @param userId
+     * @param id
+     * @return
+     */
+    @PostMapping("/bindUser/{id}")
+    @ApiOperation(value = "绑定用户",httpMethod = "POST")
+    public AjaxResult bindUser(@RequestBody String userId, @PathVariable String id) {
+
+        weCustomerUserService.bindUser(userId,id);
+        return AjaxResult.success();
+    }
+
+    /**
+     * 解绑用户
+     * @param id
+     * @return
+     */
+    @PostMapping("/unbindUser/{id}")
+    @ApiOperation(value = "解绑用户",httpMethod = "POST")
+    public AjaxResult unbindUser(@PathVariable String id) {
+
+        weCustomerUserService.unbindUser(id);
+        return AjaxResult.success();
+    }
+
+}

+ 82 - 0
linkwe-api/src/main/java/com/linkwechat/controller/WeUserController.java

@@ -0,0 +1,82 @@
+package com.linkwechat.controller;
+
+import com.linkwechat.common.annotation.Log;
+import com.linkwechat.common.core.controller.BaseController;
+import com.linkwechat.common.core.domain.AjaxResult;
+import com.linkwechat.common.core.page.TableDataInfo;
+import com.linkwechat.common.core.page.TableSupport;
+import com.linkwechat.common.enums.BusinessType;
+import com.linkwechat.domain.customer.query.WeCuUserQuery;
+import com.linkwechat.domain.customer.vo.WeUserDetailInfoVo;
+import com.linkwechat.domain.customer.vo.WeUserVo;
+import com.linkwechat.service.IWeUserService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 同步用户Controller
+ *
+ * @author ruoyi
+ * @date 2020-09-13
+ */
+@Slf4j
+@RestController
+@RequestMapping("/we/user")
+@Api(tags = "同步用户接口")
+public class WeUserController extends BaseController {
+
+    @Autowired
+    private IWeUserService weUserService;
+
+    /**
+     * 查询同步用户列表(分页),索引优化用户列表,未使用默认分页
+     */
+    @GetMapping("/findWeUserList")
+    @ApiOperation(value = "询同步用户列表(分页)",httpMethod = "GET")
+    public TableDataInfo findWeCustomerList(WeCuUserQuery weUserQuery) {
+        List<WeUserVo> list = weUserService.findWeUserList(weUserQuery, TableSupport.buildPageRequest());
+        TableDataInfo dataTable = getDataTable(list);
+        //设置总条数
+        dataTable.setTotal(
+                weUserService.countWeUserList(weUserQuery)
+        );
+
+        return dataTable;
+    }
+
+
+    /**
+     * 分配/转移
+     * @param id
+     * @param userId
+     * @return
+     */
+    @Log(title = "分配/转出", businessType = BusinessType.UPDATE)
+    @ApiOperation(value = "分配/转移",httpMethod = "POST")
+    @PostMapping("/transferOwner/{id}")
+    public AjaxResult transferOwner(@PathVariable("id") Long id, @RequestBody Long userId){
+
+        weUserService.transferOwner(id, userId);
+        return AjaxResult.success();
+    }
+
+    /**
+     * 同步用户详情基础
+     * @param id
+     * @return
+     */
+    @GetMapping("/findWeUserBaseInfo")
+    @ApiOperation(value = "同步用户详情基础",httpMethod = "GET")
+    public AjaxResult<WeUserDetailInfoVo> findWeUserBaseInfo(String id){
+        return AjaxResult.success(
+                weUserService.findWeUserBaseInfo(id)
+        );
+    }
+
+
+}

+ 22 - 22
linkwe-auth/src/main/java/com/linkwechat/web/service/SysLoginService.java

@@ -91,33 +91,33 @@ public class SysLoginService {
      */
     public Map<String, Object> login(String userName, String password) {
         SysUser sysUser = sysUserService.selectUserByUserName(userName);
-//        if (StringUtils.isNull(sysUser)) {
-//            throw new WeComException("用户名或密码错误,请重新输入!");
-//        }
-//
-//        // 密码解密
-//        try {
-//            password = SecurityUtils.Base64Decode3(password);
-//        } catch (Exception e) {
-//            throw new WeComException("密码解密失败!");
-//        }
-//
+        if (StringUtils.isNull(sysUser)) {
+            throw new WeComException("用户名或密码错误,请重新输入!");
+        }
+
+        // 密码解密
+        try {
+            password = SecurityUtils.Base64Decode3(password);
+        } catch (Exception e) {
+            throw new WeComException("密码解密失败!");
+        }
+
 //        if ("admin".equals(userName)) {
 //            if (!SecurityUtils.matchesPassword(password, sysUser.getPassword())) {
 //                throw new WeComException("用户名或密码错误,请重新输入");
 //            }
 //        }else {
-//            if (StringUtils.isEmpty(sysUser.getPassword())) {
-//                // 设置默认密码
-//                sysUser.setPassword(new BCryptPasswordEncoder().encode("zmbx@Z023"));
-//                sysUserService.updateById(sysUser);
-//                log.info("设置默认密码不校验");
-//            }else {
-//                if (!SecurityUtils.matchesPassword(password, sysUser.getPassword())) {
-//                    throw new WeComException("用户名或密码错误,请重新输入");
-//                }
-//            }
-       // }
+            if (StringUtils.isEmpty(sysUser.getPassword())) {
+                // 设置默认密码
+                sysUser.setPassword(new BCryptPasswordEncoder().encode("zmbx@Z023"));
+                sysUserService.updateById(sysUser);
+                log.info("设置默认密码不校验");
+            }else {
+                if (!SecurityUtils.matchesPassword(password, sysUser.getPassword())) {
+                    throw new WeComException("用户名或密码错误,请重新输入");
+                }
+            }
+//        }
         LoginUser sysUserVo = findLoginUser(sysUser);
 
         // 生成token

+ 167 - 0
linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/bdshdb/customer/controller/LocalAppUserController.java

@@ -0,0 +1,167 @@
+package com.linkwechat.coal.modules.bdshdb.customer.controller;
+
+
+import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.linkwechat.coal.modules.bdshdb.customer.domain.dto.LocalAppUserDto;
+import com.linkwechat.coal.modules.bdshdb.customer.domain.vo.LocalAppUserVo;
+import com.linkwechat.coal.modules.bdshdb.customer.service.ILocalAppUserService;
+import com.linkwechat.common.core.domain.AjaxResult;
+import com.linkwechat.domain.WeCustomerUser;
+import com.linkwechat.domain.WeUser;
+import com.linkwechat.service.IWeCustomerUserService;
+import com.linkwechat.service.IWeUserService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+@Slf4j
+@RestController
+@RequestMapping("/localAppUser")
+@Api(tags = "手动更新本地生活用户数据")
+public class LocalAppUserController {
+
+    @Autowired
+    private ILocalAppUserService localAppUserService;
+
+    @Autowired
+    private IWeUserService weUserService;
+
+    @Autowired
+    private IWeCustomerUserService weCustomerUserService;
+
+    /**
+     * 查询同步用户列表(分页),索引优化用户列表,未使用默认分页
+     */
+    @PostMapping("/syncUserData")
+    @ApiOperation(value = "同步用户",httpMethod = "POST")
+    public AjaxResult syncUserData(@RequestBody LocalAppUserDto localAppUserDto) {
+
+        // 查询本地生活 所有的用户 条件 普通用户 创建时间
+        List<LocalAppUserVo> localAppUserList = localAppUserService.selectUserList(localAppUserDto);
+        List<LocalAppUserVo> distinctList = localAppUserList.stream()
+                .collect(Collectors.collectingAndThen(
+                        Collectors.toMap(
+                                LocalAppUserVo::getPhone,   // 按手机号作为Key
+                                Function.identity(),       // 值是对象本身
+                                (existing, replacement) -> existing, // 有重复时保留第一个
+                                LinkedHashMap::new         // 保持原顺序
+                        ),
+                        m -> m.values().stream().collect(Collectors.toList())
+                ));
+        LambdaQueryWrapper<WeUser> wrapper = new LambdaQueryWrapper<>();
+        wrapper.select(WeUser::getPhone);
+        wrapper.eq(WeUser::getSource, 1);
+        List<WeUser> phoneList = weUserService.list(wrapper);
+        // 提取手机号并去重
+        Set<String> phoneSet = phoneList.stream()
+                .map(WeUser::getPhone)   // 提取手机号
+                .filter(phone -> phone != null && !phone.isEmpty()) // 可选,去掉空值
+                .collect(Collectors.toSet());
+        if(CollUtil.isNotEmpty(distinctList)){
+            Date now = new Date();
+            List<WeUser> users = new ArrayList<>();
+            for (LocalAppUserVo localAppUserVo : distinctList) {
+                if(phoneSet.contains(localAppUserVo.getPhone())){continue;}
+                localAppUserVo.setGender(Objects.isNull(localAppUserVo.getGender())? 1 : localAppUserVo.getGender());
+                WeUser weUser = new WeUser();
+                weUser.setUserCode(localAppUserVo.getId().toString());
+                weUser.setName(localAppUserVo.getName());
+                weUser.setPhone(localAppUserVo.getPhone());
+                weUser.setSex(localAppUserVo.getGender().equals(1) ? 1 : 0);
+                weUser.setBirthday(localAppUserVo.getBirthdayTime());
+                weUser.setSource(1); // 本地生活
+                weUser.setStatus(localAppUserVo.getIsFormal().equals(1)? 1 : 0);
+                weUser.setType(0);
+                weUser.setRegisterTime(localAppUserVo.getCreateTime());
+                weUser.setDeliveredStatus(0);
+                weUser.setCreateTime(now);
+                users.add(weUser);
+            }
+            weUserService.saveBatch(users);
+        }
+        return AjaxResult.success();
+    }
+
+    /**
+     * 查询同步用户列表(分页),索引优化用户列表,未使用默认分页
+     */
+    @PostMapping("/syncCustomerUserData")
+    @ApiOperation(value = "同步用户",httpMethod = "POST")
+    public AjaxResult syncCustomerUserData(@RequestBody LocalAppUserDto localAppUserDto) {
+
+        // 查询本地生活 所有的用户 条件 普通用户 创建时间
+        localAppUserDto.setIsWx(1);
+        List<LocalAppUserVo> localAppUserList = localAppUserService.selectUserList(localAppUserDto);
+
+        List<LocalAppUserVo> distinctList = localAppUserList.stream()
+                .collect(Collectors.collectingAndThen(
+                        Collectors.toMap(
+                                LocalAppUserVo::getPhone,   // 按手机号作为Key
+                                Function.identity(),       // 值是对象本身
+                                (existing, replacement) -> existing, // 有重复时保留第一个
+                                LinkedHashMap::new         // 保持原顺序
+                        ),
+                        m -> m.values().stream().collect(Collectors.toList())
+                ));
+
+        List<String> userPhoneList = distinctList.stream().map(LocalAppUserVo::getPhone).collect(Collectors.toList());
+        LambdaQueryWrapper<WeUser> phoenWrapper = new LambdaQueryWrapper<>();
+        phoenWrapper.select(WeUser::getId);
+        phoenWrapper.select(WeUser::getUserCode);
+        phoenWrapper.select(WeUser::getPhone);
+        phoenWrapper.eq(WeUser::getPhone, userPhoneList);
+        phoenWrapper.eq(WeUser::getSource, 1);
+        List<WeUser> users = weUserService.list(phoenWrapper);
+        // 转为 Map,手机号为 key
+        Map<String, WeUser> userMap = users.stream()
+                .filter(user -> user.getPhone() != null && !user.getPhone().isEmpty()) // 去掉空手机号
+                .collect(Collectors.toMap(
+                        WeUser::getPhone, // key = phone
+                        user -> user,     // value = WeUser 对象
+                        (existing, replacement) -> existing // 如果有重复手机号,保留第一个
+                ));
+
+
+        LambdaQueryWrapper<WeCustomerUser> wrapper = new LambdaQueryWrapper<>();
+        wrapper.select(WeCustomerUser::getWxPhone);
+        List<WeCustomerUser> phoneList = weCustomerUserService.list(wrapper);
+
+        // 提取手机号并去重
+        Set<String> phoneSet = phoneList.stream()
+                .map(WeCustomerUser::getWxPhone)   // 提取手机号
+                .filter(phone -> phone != null && !phone.isEmpty()) // 可选,去掉空值
+                .collect(Collectors.toSet());
+
+        if(CollUtil.isNotEmpty(distinctList)) {
+            Date now = new Date();
+            List<WeCustomerUser> weCustomerUserList = new ArrayList<>();
+            for (LocalAppUserVo localAppUserVo : distinctList) {
+                if(phoneSet.contains(localAppUserVo.getPhone())){continue;}
+                WeCustomerUser customerUser = new WeCustomerUser();
+                if(userMap.containsKey(localAppUserVo.getPhone())){
+                    customerUser.setUserId(userMap.get(localAppUserVo.getPhone()).getId());
+                    customerUser.setUserCode(userMap.get(localAppUserVo.getPhone()).getUserCode());
+                    customerUser.setStatus(1);
+                    customerUser.setBindTime(now);
+                }else{
+                    customerUser.setStatus(0);
+                }
+                customerUser.setWxNickname(localAppUserVo.getWechatNickname());
+                customerUser.setWxPhone(localAppUserVo.getPhone());
+                customerUser.setWxOpenid(localAppUserVo.getOpenId());
+                customerUser.setWxAvatar(localAppUserVo.getWechatHeadPhoto());
+                customerUser.setCreateTime(now);
+                weCustomerUserList.add(customerUser);
+            }
+            weCustomerUserService.saveBatch(weCustomerUserList);
+        }
+        return AjaxResult.success();
+    }
+}

+ 0 - 34
linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/bdshdb/customer/controller/TestController.java

@@ -1,34 +0,0 @@
-package com.linkwechat.coal.modules.bdshdb.customer.controller;
-
-import com.linkwechat.coal.modules.bdshdb.customer.domain.entity.LocalAppUser;
-import com.linkwechat.coal.modules.bdshdb.customer.service.ILocalAppUserService;
-import com.linkwechat.common.core.domain.AjaxResult;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-
-@Slf4j
-@RestController
-@RequestMapping("/test")
-@Api(tags = "测试")
-public class TestController {
-
-    @Autowired
-    private ILocalAppUserService localAppUserService;
-
-    /**
-     * 查询同步用户列表(分页),索引优化用户列表,未使用默认分页
-     */
-    @GetMapping("/test")
-    @ApiOperation(value = "测试",httpMethod = "GET")
-    public AjaxResult test() {
-        LocalAppUser localAppUser = localAppUserService.getById(1897462048076500994L);
-        System.out.println(localAppUser.getUserType());
-        return AjaxResult.success(localAppUser);
-    }
-}

+ 27 - 0
linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/bdshdb/customer/domain/dto/LocalAppUserDto.java

@@ -0,0 +1,27 @@
+package com.linkwechat.coal.modules.bdshdb.customer.domain.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class LocalAppUserDto {
+
+    /**
+     * 开始时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date startDate;
+
+    /**
+     * 结束时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date endDate;
+
+    /**
+     * 是否是微信 1 是
+     */
+    private Integer isWx;
+}

+ 4 - 1
linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/bdshdb/customer/domain/vo/LocalAppUserVo.java

@@ -74,7 +74,10 @@ public class LocalAppUserVo {
     @JsonFormat(pattern = "yyyy-MM-dd")
     private Date createTime;
 
-
+    /**
+     * 微信openId
+     */
+    private String openId;
 
 
 }

+ 11 - 0
linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/bdshdb/customer/mapper/LocalAppUserMapper.java

@@ -1,8 +1,19 @@
 package com.linkwechat.coal.modules.bdshdb.customer.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.linkwechat.coal.modules.bdshdb.customer.domain.dto.LocalAppUserDto;
 import com.linkwechat.coal.modules.bdshdb.customer.domain.entity.LocalAppUser;
+import com.linkwechat.coal.modules.bdshdb.customer.domain.vo.LocalAppUserVo;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface LocalAppUserMapper  extends BaseMapper<LocalAppUser> {
 
+    /**
+     * 获取本地生活用户列表
+     * @param localAppUserDto
+     * @return
+     */
+    List<LocalAppUserVo> selectUserList(@Param("localAppUserDto") LocalAppUserDto localAppUserDto);
 }

+ 277 - 0
linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/bdshdb/customer/scheduled/SyncUserDataScheduledService.java

@@ -0,0 +1,277 @@
+package com.linkwechat.coal.modules.bdshdb.customer.scheduled;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.RandomUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.linkwechat.coal.modules.bdshdb.customer.domain.dto.LocalAppUserDto;
+import com.linkwechat.coal.modules.bdshdb.customer.domain.vo.LocalAppUserVo;
+import com.linkwechat.coal.modules.bdshdb.customer.service.ILocalAppUserService;
+import com.linkwechat.coal.modules.jzgdb.customer.domain.dto.SysUserJzgDto;
+import com.linkwechat.coal.modules.jzgdb.customer.domain.vo.SysUserJzgVo;
+import com.linkwechat.coal.modules.jzgdb.customer.service.ISysUserJzgService;
+import com.linkwechat.domain.WeCustomerUser;
+import com.linkwechat.domain.WeUser;
+import com.linkwechat.service.IWeCustomerUserService;
+import com.linkwechat.service.IWeUserService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+/**
+ *
+ * <p>
+ * 目前此类是单线程类,如果一个执行不完,另一个会卡死,错开时间执行
+ */
+@Slf4j
+@Component
+public class SyncUserDataScheduledService {
+
+    @Autowired
+    private ILocalAppUserService localAppUserService;
+
+    @Autowired
+    private IWeUserService weUserService;
+
+    @Autowired
+    private IWeCustomerUserService weCustomerUserService;
+
+    @Autowired
+    private ISysUserJzgService sysUserJzgService;
+
+    /**
+     * 定义一个按一定频率执行的定时任务 每天三点执行一次 更新同步用户
+     * 本地生活
+     */
+//    @Scheduled(cron = "0 0 3 * * ?")
+//    @PostConstruct
+    @Transactional(rollbackFor = Exception.class)
+    public void syncUserDataScheduled() {
+        try {
+            // 随机停几秒
+            Thread.sleep(RandomUtil.randomInt(5));
+        } catch (InterruptedException e) {
+            throw new RuntimeException(e);
+        }
+        LocalAppUserDto localAppUserDto = new LocalAppUserDto();
+        this.setDate(localAppUserDto);
+        Date now = new Date();
+        // 查询本地生活 所有的用户 条件 普通用户 创建时间
+        List<LocalAppUserVo> localAppUserList = localAppUserService.selectUserList(localAppUserDto);
+        List<LocalAppUserVo> distinctList = localAppUserList.stream()
+                .collect(Collectors.collectingAndThen(
+                        Collectors.toMap(
+                                LocalAppUserVo::getPhone,   // 按手机号作为Key
+                                Function.identity(),       // 值是对象本身
+                                (existing, replacement) -> existing, // 有重复时保留第一个
+                                LinkedHashMap::new         // 保持原顺序
+                        ),
+                        m -> m.values().stream().collect(Collectors.toList())
+                ));
+        LambdaQueryWrapper<WeUser> wrapper = new LambdaQueryWrapper<>();
+        wrapper.select(WeUser::getPhone);
+        wrapper.eq(WeUser::getSource, 1);
+        List<WeUser> phoneList = weUserService.list(wrapper);
+        // 提取手机号并去重
+        Set<String> phoneSet = phoneList.stream()
+                .map(WeUser::getPhone)   // 提取手机号
+                .filter(phone -> phone != null && !phone.isEmpty()) // 可选,去掉空值
+                .collect(Collectors.toSet());
+        if(CollUtil.isNotEmpty(distinctList)){
+            List<WeUser> users = new ArrayList<>();
+            for (LocalAppUserVo localAppUserVo : distinctList) {
+                if(phoneSet.contains(localAppUserVo.getPhone())){continue;}
+                localAppUserVo.setGender(Objects.isNull(localAppUserVo.getGender())? 1 : localAppUserVo.getGender());
+                WeUser weUser = new WeUser();
+                weUser.setUserCode(localAppUserVo.getId().toString());
+                weUser.setName(localAppUserVo.getName());
+                weUser.setPhone(localAppUserVo.getPhone());
+                weUser.setSex(localAppUserVo.getGender().equals(1) ? 1 : 0);
+                weUser.setBirthday(localAppUserVo.getBirthdayTime());
+                weUser.setSource(1); // 本地生活
+                weUser.setStatus(localAppUserVo.getIsFormal().equals(1)? 1 : 0);
+                weUser.setType(0);
+                weUser.setRegisterTime(localAppUserVo.getCreateTime());
+                weUser.setDeliveredStatus(0);
+                weUser.setCreateTime(now);
+                users.add(weUser);
+            }
+            weUserService.saveBatch(users);
+        }
+
+
+
+        SysUserJzgDto sysUserDto = new SysUserJzgDto();
+        this.setDate(sysUserDto);
+        // 查询本地生活 所有的用户 条件 普通用户 创建时间
+        List<SysUserJzgVo> sysUserJzgVoList = sysUserJzgService.selectUserList(sysUserDto);
+        List<SysUserJzgVo> distinctUserList = sysUserJzgVoList.stream()
+                .collect(Collectors.collectingAndThen(
+                        Collectors.toMap(
+                                SysUserJzgVo::getMobile,   // 按手机号作为Key
+                                Function.identity(),       // 值是对象本身
+                                (existing, replacement) -> existing, // 有重复时保留第一个
+                                LinkedHashMap::new         // 保持原顺序
+                        ),
+                        m -> m.values().stream().collect(Collectors.toList())
+                ));
+        LambdaQueryWrapper<WeUser> userWrapper = new LambdaQueryWrapper<>();
+        userWrapper.select(WeUser::getPhone);
+        userWrapper.eq(WeUser::getSource, 0);
+        List<WeUser> userPhoneList = weUserService.list(userWrapper);
+        // 提取手机号并去重
+        Set<String> userPhoneSet = userPhoneList.stream()
+                .map(WeUser::getPhone)   // 提取手机号
+                .filter(phone -> phone != null && !phone.isEmpty()) // 可选,去掉空值
+                .collect(Collectors.toSet());
+        if(CollUtil.isNotEmpty(distinctList)){
+            List<WeUser> users = new ArrayList<>();
+            for (SysUserJzgVo sysUserJzgVo : distinctUserList) {
+                if(userPhoneSet.contains(sysUserJzgVo.getMobile())){continue;}
+                WeUser weUser = new WeUser();
+                weUser.setUserCode(sysUserJzgVo.getId().toString());
+                weUser.setName(sysUserJzgVo.getName());
+                weUser.setPhone(sysUserJzgVo.getMobile());
+                weUser.setSex(sysUserJzgVo.getSex().equals("M") ? 1 : 0);
+                weUser.setBirthday(sysUserJzgVo.getBirthday());
+                weUser.setSource(0); // 晋掌柜
+                weUser.setType(0);
+                weUser.setRegisterTime(sysUserJzgVo.getCreateTime());
+                weUser.setDeliveredStatus(0);
+                weUser.setCreateTime(now);
+                users.add(weUser);
+            }
+            weUserService.saveBatch(users);
+        }
+
+    }
+
+    /**
+     * 定义一个按一定频率执行的定时任务 每天三点半执行一次 更新微信客户
+     * 本地生活
+     */
+//    @Scheduled(cron = "0 30 3 * * ?")
+//    @PostConstruct
+    @Transactional(rollbackFor = Exception.class)
+    public void syncCustomerUserDataScheduled() {
+        try {
+            // 随机停几秒
+            Thread.sleep(RandomUtil.randomInt(5));
+        } catch (InterruptedException e) {
+            throw new RuntimeException(e);
+        }
+        LocalAppUserDto localAppUserDto = new LocalAppUserDto();
+        this.setDate(localAppUserDto);
+        // 查询本地生活 所有的用户 条件 普通用户 创建时间
+        localAppUserDto.setIsWx(1);
+        List<LocalAppUserVo> localAppUserList = localAppUserService.selectUserList(localAppUserDto);
+
+        List<LocalAppUserVo> distinctList = localAppUserList.stream()
+                .collect(Collectors.collectingAndThen(
+                        Collectors.toMap(
+                                LocalAppUserVo::getPhone,   // 按手机号作为Key
+                                Function.identity(),       // 值是对象本身
+                                (existing, replacement) -> existing, // 有重复时保留第一个
+                                LinkedHashMap::new         // 保持原顺序
+                        ),
+                        m -> m.values().stream().collect(Collectors.toList())
+                ));
+
+        List<String> userPhoneList = distinctList.stream().map(LocalAppUserVo::getPhone).collect(Collectors.toList());
+        LambdaQueryWrapper<WeUser> phoenWrapper = new LambdaQueryWrapper<>();
+        phoenWrapper.select(WeUser::getId);
+        phoenWrapper.select(WeUser::getUserCode);
+        phoenWrapper.select(WeUser::getPhone);
+        phoenWrapper.eq(WeUser::getPhone, userPhoneList);
+        phoenWrapper.eq(WeUser::getSource, 1);
+        List<WeUser> users = weUserService.list(phoenWrapper);
+        // 转为 Map,手机号为 key
+        Map<String, WeUser> userMap = users.stream()
+                .filter(user -> user.getPhone() != null && !user.getPhone().isEmpty()) // 去掉空手机号
+                .collect(Collectors.toMap(
+                        WeUser::getPhone, // key = phone
+                        user -> user,     // value = WeUser 对象
+                        (existing, replacement) -> existing // 如果有重复手机号,保留第一个
+                ));
+
+
+        LambdaQueryWrapper<WeCustomerUser> wrapper = new LambdaQueryWrapper<>();
+        wrapper.select(WeCustomerUser::getWxPhone);
+        List<WeCustomerUser> phoneList = weCustomerUserService.list(wrapper);
+
+        // 提取手机号并去重
+        Set<String> phoneSet = phoneList.stream()
+                .map(WeCustomerUser::getWxPhone)   // 提取手机号
+                .filter(phone -> phone != null && !phone.isEmpty()) // 可选,去掉空值
+                .collect(Collectors.toSet());
+
+        if(CollUtil.isNotEmpty(distinctList)) {
+            Date now = new Date();
+            List<WeCustomerUser> weCustomerUserList = new ArrayList<>();
+            for (LocalAppUserVo localAppUserVo : distinctList) {
+                if(phoneSet.contains(localAppUserVo.getPhone())){continue;}
+                WeCustomerUser customerUser = new WeCustomerUser();
+                if(userMap.containsKey(localAppUserVo.getPhone())){
+                    customerUser.setUserId(userMap.get(localAppUserVo.getPhone()).getId());
+                    customerUser.setUserCode(userMap.get(localAppUserVo.getPhone()).getUserCode());
+                    customerUser.setStatus(1);
+                    customerUser.setBindTime(now);
+                }else{
+                    customerUser.setStatus(0);
+                }
+                customerUser.setWxNickname(localAppUserVo.getWechatNickname());
+                customerUser.setWxPhone(localAppUserVo.getPhone());
+                customerUser.setWxOpenid(localAppUserVo.getOpenId());
+                customerUser.setWxAvatar(localAppUserVo.getWechatHeadPhoto());
+                customerUser.setCreateTime(now);
+                weCustomerUserList.add(customerUser);
+            }
+            weCustomerUserService.saveBatch(weCustomerUserList);
+        }
+    }
+
+    private void setDate(LocalAppUserDto localAppUserDto){
+        // 获取 Calendar 实例
+        Calendar cal = Calendar.getInstance();
+
+        // 设置昨天 03:00
+        cal.set(Calendar.HOUR_OF_DAY, 3);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 0);
+        cal.set(Calendar.MILLISECOND, 0);
+        cal.add(Calendar.DAY_OF_MONTH, -1);
+        Date start = cal.getTime();
+
+        // 设置今天 03:00
+        cal.add(Calendar.DAY_OF_MONTH, 1);
+        Date end = cal.getTime();
+
+        localAppUserDto.setStartDate(start);
+        localAppUserDto.setEndDate(end);
+    }
+
+    private void setDate(SysUserJzgDto sysUserDto){
+        // 获取 Calendar 实例
+        Calendar cal = Calendar.getInstance();
+
+        // 设置昨天 03:00
+        cal.set(Calendar.HOUR_OF_DAY, 3);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 0);
+        cal.set(Calendar.MILLISECOND, 0);
+        cal.add(Calendar.DAY_OF_MONTH, -1);
+        Date start = cal.getTime();
+
+        // 设置今天 03:00
+        cal.add(Calendar.DAY_OF_MONTH, 1);
+        Date end = cal.getTime();
+
+        sysUserDto.setStartDate(start);
+        sysUserDto.setEndDate(end);
+    }
+}

+ 0 - 4
linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/bdshdb/customer/scheduled/tes.java

@@ -1,4 +0,0 @@
-package com.linkwechat.coal.modules.bdshdb.customer.scheduled;
-
-public class tes {
-}

+ 10 - 0
linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/bdshdb/customer/service/ILocalAppUserService.java

@@ -1,8 +1,18 @@
 package com.linkwechat.coal.modules.bdshdb.customer.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.linkwechat.coal.modules.bdshdb.customer.domain.dto.LocalAppUserDto;
 import com.linkwechat.coal.modules.bdshdb.customer.domain.entity.LocalAppUser;
+import com.linkwechat.coal.modules.bdshdb.customer.domain.vo.LocalAppUserVo;
+
+import java.util.List;
 
 public interface ILocalAppUserService extends IService<LocalAppUser> {
 
+    /**
+     * 获取本地生活用户列表
+     * @param localAppUserDto
+     * @return
+     */
+    List<LocalAppUserVo> selectUserList(LocalAppUserDto localAppUserDto);
 }

+ 8 - 0
linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/bdshdb/customer/service/impl/LocalAppUserServiceImpl.java

@@ -1,13 +1,21 @@
 package com.linkwechat.coal.modules.bdshdb.customer.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.linkwechat.coal.modules.bdshdb.customer.domain.dto.LocalAppUserDto;
 import com.linkwechat.coal.modules.bdshdb.customer.domain.entity.LocalAppUser;
+import com.linkwechat.coal.modules.bdshdb.customer.domain.vo.LocalAppUserVo;
 import com.linkwechat.coal.modules.bdshdb.customer.mapper.LocalAppUserMapper;
 import com.linkwechat.coal.modules.bdshdb.customer.service.ILocalAppUserService;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 @Service
 public class LocalAppUserServiceImpl extends ServiceImpl<LocalAppUserMapper, LocalAppUser> implements ILocalAppUserService {
 
 
+    @Override
+    public List<LocalAppUserVo> selectUserList(LocalAppUserDto localAppUserDto) {
+        return this.baseMapper.selectUserList(localAppUserDto);
+    }
 }

+ 87 - 0
linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/jzgdb/customer/controller/SysUserJzgController.java

@@ -0,0 +1,87 @@
+package com.linkwechat.coal.modules.jzgdb.customer.controller;
+
+import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.linkwechat.coal.modules.jzgdb.customer.domain.dto.SysUserJzgDto;
+import com.linkwechat.coal.modules.jzgdb.customer.domain.vo.SysUserJzgVo;
+import com.linkwechat.coal.modules.jzgdb.customer.service.ISysUserJzgService;
+import com.linkwechat.common.core.domain.AjaxResult;
+import com.linkwechat.common.utils.StringUtils;
+import com.linkwechat.domain.WeUser;
+import com.linkwechat.service.IWeUserService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+@Slf4j
+@RestController
+@RequestMapping("/sysUser")
+@Api(tags = "手动更新晋掌柜用户数据")
+public class SysUserJzgController {
+
+    @Autowired
+    private ISysUserJzgService sysUserJzgService;
+
+    @Autowired
+    private IWeUserService weUserService;
+    /**
+     * 查询同步用户列表(分页),索引优化用户列表,未使用默认分页
+     */
+    @PostMapping("/syncUserData")
+    @ApiOperation(value = "同步用户",httpMethod = "POST")
+    public AjaxResult syncUserData(@RequestBody SysUserJzgDto sysUserDto) {
+
+        // 查询本地生活 所有的用户 条件 普通用户 创建时间
+        List<SysUserJzgVo> sysUserJzgVoList = sysUserJzgService.selectUserList(sysUserDto);
+        List<SysUserJzgVo> distinctList = sysUserJzgVoList.stream()
+                .collect(Collectors.collectingAndThen(
+                        Collectors.toMap(
+                                SysUserJzgVo::getMobile,   // 按手机号作为Key
+                                Function.identity(),       // 值是对象本身
+                                (existing, replacement) -> existing, // 有重复时保留第一个
+                                LinkedHashMap::new         // 保持原顺序
+                        ),
+                        m -> m.values().stream().collect(Collectors.toList())
+                ));
+        LambdaQueryWrapper<WeUser> wrapper = new LambdaQueryWrapper<>();
+        wrapper.select(WeUser::getPhone);
+        wrapper.eq(WeUser::getSource, 0);
+        List<WeUser> phoneList = weUserService.list(wrapper);
+        // 提取手机号并去重
+        Set<String> phoneSet = phoneList.stream()
+                .map(WeUser::getPhone)   // 提取手机号
+                .filter(phone -> phone != null && !phone.isEmpty()) // 可选,去掉空值
+                .collect(Collectors.toSet());
+        if(CollUtil.isNotEmpty(distinctList)){
+            Date now = new Date();
+            List<WeUser> users = new ArrayList<>();
+            for (SysUserJzgVo sysUserJzgVo : distinctList) {
+                if(phoneSet.contains(sysUserJzgVo.getMobile())){continue;}
+                WeUser weUser = new WeUser();
+                sysUserJzgVo.setSex(StringUtils.isNotEmpty(sysUserJzgVo.getSex()) ? sysUserJzgVo.getSex() : "M");
+                weUser.setUserCode(sysUserJzgVo.getId().toString());
+                weUser.setName(sysUserJzgVo.getName());
+                weUser.setPhone(sysUserJzgVo.getMobile());
+                weUser.setSex(sysUserJzgVo.getSex().equals("M") ? 1 : 0);
+                weUser.setBirthday(sysUserJzgVo.getBirthday());
+                weUser.setSource(0); // 晋掌柜
+                weUser.setType(0);
+                weUser.setRegisterTime(sysUserJzgVo.getCreateTime());
+                weUser.setDeliveredStatus(0);
+                weUser.setCreateTime(now);
+                users.add(weUser);
+            }
+            weUserService.saveBatch(users);
+        }
+        return AjaxResult.success();
+    }
+}

+ 22 - 0
linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/jzgdb/customer/domain/dto/SysUserJzgDto.java

@@ -0,0 +1,22 @@
+package com.linkwechat.coal.modules.jzgdb.customer.domain.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class SysUserJzgDto {
+
+    /**
+     * 开始时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date startDate;
+
+    /**
+     * 结束时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date endDate;
+}

+ 51 - 0
linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/jzgdb/customer/domain/entity/SysUserJzg.java

@@ -0,0 +1,51 @@
+package com.linkwechat.coal.modules.jzgdb.customer.domain.entity;
+
+import com.alibaba.excel.annotation.format.DateTimeFormat;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+@TableName("sys_user")
+public class SysUserJzg {
+
+    /**
+     * 主键
+     */
+    @TableId(type = IdType.ASSIGN_ID)
+    @TableField("id")
+    private Long id;
+
+    /**
+     * 用户姓名
+     */
+    @TableField("name")
+    private String name;
+
+    /**
+     * 用户手机号
+     */
+    @TableField("mobile")
+    private String mobile;
+
+    /**
+     * 创建时间
+     */
+    @DateTimeFormat("yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @TableField("create_time")
+    private Date createTime;
+
+
+}

+ 59 - 0
linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/jzgdb/customer/domain/vo/SysUserJzgVo.java

@@ -0,0 +1,59 @@
+package com.linkwechat.coal.modules.jzgdb.customer.domain.vo;
+
+import com.alibaba.excel.annotation.format.DateTimeFormat;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class SysUserJzgVo {
+
+    /**
+     * 主键
+     */
+    @TableId(type = IdType.ASSIGN_ID)
+    @TableField("id")
+    private String id;
+
+    /**
+     * 用户姓名
+     */
+    @TableField("name")
+    private String name;
+
+    /**
+     * 用户手机号
+     */
+    @TableField("mobile")
+    private String mobile;
+
+    /**
+     * 创建时间
+     */
+    @DateTimeFormat("yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @TableField("create_time")
+    private Date createTime;
+
+    /**
+     * 性别 M.男U.女
+     */
+    private String sex;
+
+    /**
+     * 注册时间
+     */
+    @DateTimeFormat("yyyy-MM-dd")
+    @JsonFormat(pattern = "M月d日")
+    private Date birthday;
+}

+ 19 - 0
linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/jzgdb/customer/mapper/SysUserJzgMapper.java

@@ -0,0 +1,19 @@
+package com.linkwechat.coal.modules.jzgdb.customer.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.linkwechat.coal.modules.jzgdb.customer.domain.dto.SysUserJzgDto;
+import com.linkwechat.coal.modules.jzgdb.customer.domain.entity.SysUserJzg;
+import com.linkwechat.coal.modules.jzgdb.customer.domain.vo.SysUserJzgVo;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface SysUserJzgMapper extends BaseMapper<SysUserJzg> {
+
+    /**
+     * 获取晋掌柜用户列表
+     * @param sysUserDto
+     * @return
+     */
+    List<SysUserJzgVo> selectUserList(@Param("sysUserDto") SysUserJzgDto sysUserDto);
+}

+ 18 - 0
linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/jzgdb/customer/service/ISysUserJzgService.java

@@ -0,0 +1,18 @@
+package com.linkwechat.coal.modules.jzgdb.customer.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.linkwechat.coal.modules.jzgdb.customer.domain.dto.SysUserJzgDto;
+import com.linkwechat.coal.modules.jzgdb.customer.domain.entity.SysUserJzg;
+import com.linkwechat.coal.modules.jzgdb.customer.domain.vo.SysUserJzgVo;
+
+import java.util.List;
+
+public interface ISysUserJzgService extends IService<SysUserJzg> {
+
+    /**
+     * 获取晋掌柜用户列表
+     * @param sysUserDto
+     * @return
+     */
+    List<SysUserJzgVo> selectUserList(SysUserJzgDto sysUserDto);
+}

+ 20 - 0
linkwe-chinacoal/src/main/java/com/linkwechat/coal/modules/jzgdb/customer/service/impl/SysUserJzgServiceImpl.java

@@ -0,0 +1,20 @@
+package com.linkwechat.coal.modules.jzgdb.customer.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.linkwechat.coal.modules.jzgdb.customer.domain.dto.SysUserJzgDto;
+import com.linkwechat.coal.modules.jzgdb.customer.domain.entity.SysUserJzg;
+import com.linkwechat.coal.modules.jzgdb.customer.domain.vo.SysUserJzgVo;
+import com.linkwechat.coal.modules.jzgdb.customer.mapper.SysUserJzgMapper;
+import com.linkwechat.coal.modules.jzgdb.customer.service.ISysUserJzgService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class SysUserJzgServiceImpl extends ServiceImpl<SysUserJzgMapper, SysUserJzg> implements ISysUserJzgService {
+
+    @Override
+    public List<SysUserJzgVo> selectUserList(SysUserJzgDto sysUserDto) {
+        return this.baseMapper.selectUserList(sysUserDto);
+    }
+}

+ 22 - 0
linkwe-chinacoal/src/main/resources/mapper/modules/bdshdb/customer/LocalAppUserMapper.xml

@@ -4,4 +4,26 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.linkwechat.coal.modules.bdshdb.customer.mapper.LocalAppUserMapper">
 
+    <select id="selectUserList"
+            resultType="com.linkwechat.coal.modules.bdshdb.customer.domain.vo.LocalAppUserVo">
+        SELECT
+            lau.id, lau.name, lau.phone, lau.user_type as userType,
+            lau.wechat_nickname as wechatNickname, lau.wechat_head_photo as wechatHeadPhoto,
+            loup.gender, loup.birthday_time AS birthdayTime, lau.is_formal as isFormal,lau.create_time as createTime,
+            lau.open_id AS openId
+        FROM local_app_user as lau
+        LEFT JOIN local_ordinary_user_process loup ON lau.ordinary_user_id = loup.ordinary_user_id
+        <where>
+            lau.user_type = 1 and lau.del_flag = 0
+            <if test="localAppUserDto.startDate != null and localAppUserDto.endDate != null">
+                AND date_format(lau.create_time,'%Y-%m-%d')
+                BETWEEN
+                date_format(#{localAppUserDto.startDate},'%Y-%m-%d') AND date_format(#{localAppUserDto.endDate},'%Y-%m-%d')
+            </if>
+            <if test="localAppUserDto.isWx != null">
+                AND lau.open_id is not null
+            </if>
+        </where>
+        limit 10
+    </select>
 </mapper>

+ 0 - 141
linkwe-chinacoal/src/main/resources/mapper/modules/bdshdb/customer/test.xml

@@ -1,141 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.linkwechat.coal.modules.qywx.system.mapper.SysDeptMapper">
-
-	<resultMap type="com.linkwechat.common.core.domain.entity.SysDept" id="SysDeptResult">
-		<id     property="deptId"     column="dept_id"     />
-		<result property="parentId"   column="parent_id"   />
-		<result property="ancestors"  column="ancestors"   />
-		<result property="deptName"   column="dept_name"   />
-		<result property="deptEnName"   column="dept_en_name"   />
-		<result property="orderNum"   column="order_num"   />
-		<result property="leader"     column="leader"      />
-		<result property="phone"      column="phone"       />
-		<result property="email"      column="email"       />
-		<result property="status"     column="status"      />
-		<result property="delFlag"    column="del_flag"    />
-		<result property="parentName" column="parent_name" />
-		<result property="createBy"   column="create_by"   />
-		<result property="createTime" column="create_time" />
-		<result property="updateBy"   column="update_by"   />
-		<result property="updateTime" column="update_time" />
-	</resultMap>
-
-	<sql id="Base_Column_List">
-		d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.dept_en_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
-	</sql>
-	<sql id="selectDeptVo">
-        select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.dept_en_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
-        from sys_dept d
-    </sql>
-
-	<select id="selectDeptList" parameterType="com.linkwechat.common.core.domain.entity.SysDept" resultMap="SysDeptResult">
-        <include refid="selectDeptVo"/>
-        where d.del_flag = '0'
-        <if test="parentId != null and parentId != 0">
-			AND parent_id = #{parentId}
-		</if>
-		<if test="deptName != null and deptName != ''">
-			AND dept_name like concat('%', #{deptName}, '%')
-		</if>
-		<if test="status != null and status != ''">
-			AND status = #{status}
-		</if>
-		order by d.parent_id, d.order_num
-    </select>
-	<select id="select3DeptList" resultType="com.linkwechat.common.core.domain.entity.SysDept">
-		<include refid="selectDeptVo"/>
-		where d.del_flag = '0' /*and
-		(d.ancestors REGEXP  '^[0-9]+,[0-9]+,[0-9]+,[0-9]+$'
-			or d.ancestors REGEXP  '^[0-9]+,[0-9]+,[0-9]+$'
-			or d.parent_id='1' )*/
-		<if test="parentId != null and parentId != 0">
-			AND parent_id = #{parentId}
-		</if>
-		<if test="deptName != null and deptName != ''">
-			AND dept_name like concat('%', #{deptName}, '%')
-		</if>
-		<if test="status != null and status != ''">
-			AND status = #{status}
-		</if>
-		order by d.parent_id, d.order_num
-	</select>
-	<select id="selectByDeptIds" resultType="com.linkwechat.common.core.domain.entity.SysDept">
-		<include refid="selectDeptVo"/>
-		where d.del_flag = '0'
-		and d.dept_id in
-		<foreach collection="deptIds" open="(" item="item" index="index" separator="," close=")">
-			#{item}
-		</foreach>
-	</select>
-	<select id="selectDeptListAllChildren" resultType="com.linkwechat.common.core.domain.entity.SysDept">
-		select * from (SELECT
-		d.dept_id, d.parent_id, d.ancestors,
-		case
-		when d.ancestors like '0,1,4%' then concat(d.dept_name,'(公司总部)')
-		when d.ancestors like '0,1,3007%' then concat(d.dept_name,'(个人代理)')
-		when d.ancestors like '0,1,3026%' then concat(d.dept_name,'(业务员)')
-		else d.dept_name
-		end as dept_name,
-		d.dept_en_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
-		FROM sys_dept d
-		where status = 0 and del_flag = '0'
-		and dept_id =#{deptId}
-		union
-		select
-		<include refid="Base_Column_List"/>
-		from sys_dept d
-		where status = 0 and del_flag = '0'
-		and (ancestors like concat('%,',#{deptId},',%') or ancestors like concat('%,', #{deptId}))
-		) aa
-	</select>
-	<select id="selectDeptListGetAllChildren" resultType="com.linkwechat.common.core.domain.entity.SysDept">
-		select * from (SELECT
-		d.dept_id, d.parent_id, d.ancestors,
-		case
-		when d.ancestors like '0,1,4%' then concat(d.dept_name,'(公司总部)')
-		when d.ancestors like '0,1,2973%' then concat(d.dept_name,'(离职人员)')
-		when d.ancestors like '0,1,3007%' then concat(d.dept_name,'(个人代理)')
-		when d.ancestors like '0,1,3026%' then concat(d.dept_name,'(业务员)')
-		when d.ancestors like '0,1,3088%' then concat(d.dept_name,'(IT)')
-		when d.ancestors like '0,1,3092%' then concat(d.dept_name,'(IT支持)')
-		when d.ancestors like '0,1,3104%' then concat(d.dept_name,'(专业代理)')
-		else d.dept_name
-		end as dept_name,
-		d.dept_en_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
-		FROM sys_dept d
-		where status = 0 and del_flag = '0'
-		and dept_id  =#{dept}
-		union
-		select
-		<include refid="Base_Column_List"/>
-		from sys_dept d
-		where status = 0 and del_flag = '0'
-		and (ancestors like concat('%,',#{dept},',%') or ancestors like concat('%,', #{dept}))
-		) aa
-	</select>
-	<select id="selectByParentId" resultType="com.linkwechat.common.core.domain.entity.SysDept">
-		SELECT <include refid="Base_Column_List"/> from sys_dept a where a.parent_id=#{deptId}
-		and status = 0 and del_flag = '0'
-	</select>
-
-	<select id="selectParentDeptId" resultType="java.lang.String">
-		SELECT a.parent_id from sys_dept a
-		where a.dept_id in
-		<foreach collection="deptIds" open="(" item="item" index="index" separator="," close=")">
-			#{item}
-		</foreach>
-		and a.del_flag = '0'
-    </select>
-	<select id="selectByDeptId" resultType="java.lang.String">
-		select aaa.map_type from sys_dept_map aaa where aaa.dept_id = #{deptId}
-
-	</select>
-    <select id="selectByDeptIdGetDept" resultType="com.linkwechat.common.core.domain.entity.SysDept">
-		SELECT <include refid="Base_Column_List"/>
-		from sys_dept d
-		where d.dept_id =#{deptId}
-	</select>
-</mapper>

+ 23 - 0
linkwe-chinacoal/src/main/resources/mapper/modules/jzgdb/customer/SysUserJzgMapper.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.linkwechat.coal.modules.jzgdb.customer.mapper.SysUserJzgMapper">
+
+    <select id="selectUserList" resultType="com.linkwechat.coal.modules.jzgdb.customer.domain.vo.SysUserJzgVo">
+        SELECT
+        su.id, su.name, su.mobile,
+        suif.sex, suif.birthday, su.create_time as createTime
+        FROM sys_user as su
+        LEFT JOIN sys_user_info suif on suif.id =su.id
+        <where>
+            su.type = 0 and su.status != 0
+            <if test="sysUserDto.startDate != null and sysUserDto.endDate != null">
+                AND date_format(su.create_time,'%Y-%m-%d')
+                BETWEEN
+                date_format(#{sysUserDto.startDate},'%Y-%m-%d') AND date_format(#{sysUserDto.endDate},'%Y-%m-%d')
+            </if>
+        </where>
+        limit 10
+    </select>
+</mapper>

+ 0 - 141
linkwe-chinacoal/src/main/resources/mapper/modules/jzgdb/customer/test.xml

@@ -1,141 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.linkwechat.coal.modules.qywx.system.mapper.SysDeptMapper">
-
-	<resultMap type="com.linkwechat.common.core.domain.entity.SysDept" id="SysDeptResult">
-		<id     property="deptId"     column="dept_id"     />
-		<result property="parentId"   column="parent_id"   />
-		<result property="ancestors"  column="ancestors"   />
-		<result property="deptName"   column="dept_name"   />
-		<result property="deptEnName"   column="dept_en_name"   />
-		<result property="orderNum"   column="order_num"   />
-		<result property="leader"     column="leader"      />
-		<result property="phone"      column="phone"       />
-		<result property="email"      column="email"       />
-		<result property="status"     column="status"      />
-		<result property="delFlag"    column="del_flag"    />
-		<result property="parentName" column="parent_name" />
-		<result property="createBy"   column="create_by"   />
-		<result property="createTime" column="create_time" />
-		<result property="updateBy"   column="update_by"   />
-		<result property="updateTime" column="update_time" />
-	</resultMap>
-
-	<sql id="Base_Column_List">
-		d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.dept_en_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
-	</sql>
-	<sql id="selectDeptVo">
-        select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.dept_en_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
-        from sys_dept d
-    </sql>
-
-	<select id="selectDeptList" parameterType="com.linkwechat.common.core.domain.entity.SysDept" resultMap="SysDeptResult">
-        <include refid="selectDeptVo"/>
-        where d.del_flag = '0'
-        <if test="parentId != null and parentId != 0">
-			AND parent_id = #{parentId}
-		</if>
-		<if test="deptName != null and deptName != ''">
-			AND dept_name like concat('%', #{deptName}, '%')
-		</if>
-		<if test="status != null and status != ''">
-			AND status = #{status}
-		</if>
-		order by d.parent_id, d.order_num
-    </select>
-	<select id="select3DeptList" resultType="com.linkwechat.common.core.domain.entity.SysDept">
-		<include refid="selectDeptVo"/>
-		where d.del_flag = '0' /*and
-		(d.ancestors REGEXP  '^[0-9]+,[0-9]+,[0-9]+,[0-9]+$'
-			or d.ancestors REGEXP  '^[0-9]+,[0-9]+,[0-9]+$'
-			or d.parent_id='1' )*/
-		<if test="parentId != null and parentId != 0">
-			AND parent_id = #{parentId}
-		</if>
-		<if test="deptName != null and deptName != ''">
-			AND dept_name like concat('%', #{deptName}, '%')
-		</if>
-		<if test="status != null and status != ''">
-			AND status = #{status}
-		</if>
-		order by d.parent_id, d.order_num
-	</select>
-	<select id="selectByDeptIds" resultType="com.linkwechat.common.core.domain.entity.SysDept">
-		<include refid="selectDeptVo"/>
-		where d.del_flag = '0'
-		and d.dept_id in
-		<foreach collection="deptIds" open="(" item="item" index="index" separator="," close=")">
-			#{item}
-		</foreach>
-	</select>
-	<select id="selectDeptListAllChildren" resultType="com.linkwechat.common.core.domain.entity.SysDept">
-		select * from (SELECT
-		d.dept_id, d.parent_id, d.ancestors,
-		case
-		when d.ancestors like '0,1,4%' then concat(d.dept_name,'(公司总部)')
-		when d.ancestors like '0,1,3007%' then concat(d.dept_name,'(个人代理)')
-		when d.ancestors like '0,1,3026%' then concat(d.dept_name,'(业务员)')
-		else d.dept_name
-		end as dept_name,
-		d.dept_en_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
-		FROM sys_dept d
-		where status = 0 and del_flag = '0'
-		and dept_id =#{deptId}
-		union
-		select
-		<include refid="Base_Column_List"/>
-		from sys_dept d
-		where status = 0 and del_flag = '0'
-		and (ancestors like concat('%,',#{deptId},',%') or ancestors like concat('%,', #{deptId}))
-		) aa
-	</select>
-	<select id="selectDeptListGetAllChildren" resultType="com.linkwechat.common.core.domain.entity.SysDept">
-		select * from (SELECT
-		d.dept_id, d.parent_id, d.ancestors,
-		case
-		when d.ancestors like '0,1,4%' then concat(d.dept_name,'(公司总部)')
-		when d.ancestors like '0,1,2973%' then concat(d.dept_name,'(离职人员)')
-		when d.ancestors like '0,1,3007%' then concat(d.dept_name,'(个人代理)')
-		when d.ancestors like '0,1,3026%' then concat(d.dept_name,'(业务员)')
-		when d.ancestors like '0,1,3088%' then concat(d.dept_name,'(IT)')
-		when d.ancestors like '0,1,3092%' then concat(d.dept_name,'(IT支持)')
-		when d.ancestors like '0,1,3104%' then concat(d.dept_name,'(专业代理)')
-		else d.dept_name
-		end as dept_name,
-		d.dept_en_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
-		FROM sys_dept d
-		where status = 0 and del_flag = '0'
-		and dept_id  =#{dept}
-		union
-		select
-		<include refid="Base_Column_List"/>
-		from sys_dept d
-		where status = 0 and del_flag = '0'
-		and (ancestors like concat('%,',#{dept},',%') or ancestors like concat('%,', #{dept}))
-		) aa
-	</select>
-	<select id="selectByParentId" resultType="com.linkwechat.common.core.domain.entity.SysDept">
-		SELECT <include refid="Base_Column_List"/> from sys_dept a where a.parent_id=#{deptId}
-		and status = 0 and del_flag = '0'
-	</select>
-
-	<select id="selectParentDeptId" resultType="java.lang.String">
-		SELECT a.parent_id from sys_dept a
-		where a.dept_id in
-		<foreach collection="deptIds" open="(" item="item" index="index" separator="," close=")">
-			#{item}
-		</foreach>
-		and a.del_flag = '0'
-    </select>
-	<select id="selectByDeptId" resultType="java.lang.String">
-		select aaa.map_type from sys_dept_map aaa where aaa.dept_id = #{deptId}
-
-	</select>
-    <select id="selectByDeptIdGetDept" resultType="com.linkwechat.common.core.domain.entity.SysDept">
-		SELECT <include refid="Base_Column_List"/>
-		from sys_dept d
-		where d.dept_id =#{deptId}
-	</select>
-</mapper>

+ 78 - 0
linkwe-service/src/main/java/com/linkwechat/domain/WeCustomerUser.java

@@ -0,0 +1,78 @@
+package com.linkwechat.domain;
+
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.baomidou.mybatisplus.annotation.*;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.linkwechat.common.core.domain.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+/**
+ * 微信客户
+ */
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+@TableName("we_customer_user")
+public class WeCustomerUser {
+
+    /**
+     * 主键
+     */
+    @TableId(type = IdType.ASSIGN_ID)
+    private Long id;
+
+    /**
+     * 用户编码
+     */
+    private Long userId;
+
+    /**
+     * 用户编码
+     */
+    private String userCode;
+
+    /**
+     * 微信昵称
+     */
+    private String wxNickname;
+
+    /**
+     * 微信头像URL
+     */
+    private String wxAvatar;
+
+    /**
+     * 微信OpenID
+     */
+    private String wxOpenid;
+
+    /**
+     * 微信手机号
+     */
+    private String wxPhone;
+
+    /**
+     * 绑定时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date bindTime;
+
+    /**
+     * 状态 0.未绑定 1.已绑定
+     */
+    private Integer status;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createTime;
+
+}

+ 105 - 0
linkwe-service/src/main/java/com/linkwechat/domain/WeUser.java

@@ -0,0 +1,105 @@
+package com.linkwechat.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.linkwechat.common.core.domain.BaseEntity;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+/**
+ * 同步用户
+ */
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+@TableName("we_user")
+public class WeUser {
+
+    /**
+     * 主键
+     */
+    @TableId(type = IdType.ASSIGN_ID)
+    private Long id;
+
+    /**
+     * 用户编码
+     */
+    private String userCode;
+
+    /**
+     * 用户姓名
+     */
+    private String name;
+
+    /**
+     * 性别0.女 1.男
+     */
+    private Integer sex;
+
+    /**
+     * 生日
+     */
+    private Date birthday;
+
+    /**
+     * 手机号
+     */
+    private String phone;
+
+    /**
+     * 用户来源 0.晋掌柜 1. 掌柜生活
+     */
+    private Integer source;
+
+    /**
+     * 用户状态 0.正式用户 1.临时用户
+     */
+    private Integer status;
+
+    /**
+     * 用户类型 0.普通用户
+     */
+    private Integer type;
+
+    /**
+     * 归属员工ID
+     */
+    private Long ownerUserId;
+
+    /**
+     * 注册时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date registerTime;
+
+    /**
+     * 企微触达状态 0.未触达 1.已触达
+     */
+    private Integer deliveredStatus;
+
+    /**
+     * 添加时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date addTime;
+
+    /**
+     * 最近互动时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date lastInteractionTime;
+
+    /**
+     * 添加时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createTime;
+
+}

+ 45 - 0
linkwe-service/src/main/java/com/linkwechat/domain/customer/query/WeCuUserQuery.java

@@ -0,0 +1,45 @@
+package com.linkwechat.domain.customer.query;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+@NoArgsConstructor
+@AllArgsConstructor
+@Data
+@Builder
+public class WeCuUserQuery implements Serializable {
+
+    /**
+     * 用户编码
+     */
+    private String userCode;
+
+    /**
+     * 用户姓名
+     */
+    private String name;
+
+    /**
+     * 手机号
+     */
+    private String phone;
+
+    /**
+     * 用户来源 0.晋掌柜 1. 掌柜生活
+     */
+    private Integer source;
+
+    /**
+     * 用户状态 0.正式用户 1.临时用户
+     */
+    private Integer status;
+
+    /**
+     * 企微触达状态 0.未触达 1.已触达
+     */
+    private Integer deliveredStatus;
+}

+ 43 - 0
linkwe-service/src/main/java/com/linkwechat/domain/customer/query/WeCustomerUserQuery.java

@@ -0,0 +1,43 @@
+package com.linkwechat.domain.customer.query;
+
+import com.linkwechat.common.core.page.PageDomain;
+import com.linkwechat.domain.customer.vo.WeCustomerUserVo;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+@NoArgsConstructor
+@AllArgsConstructor
+@Data
+@Builder
+public class WeCustomerUserQuery implements Serializable {
+
+    /**
+     * 微信OpenID
+     */
+    private String wxOpenid;
+
+    /**
+     * 用户编码
+     */
+    private String userCode;
+
+    /**
+     * 微信昵称
+     */
+    private String wxNickname;
+
+    /**
+     * 状态 0.未绑定 1.已绑定
+     */
+    private Integer status;
+
+
+    public List<WeCustomerUserVo> findWeCustomerUserList(WeCustomerUserQuery weCustomerUserQuery, PageDomain pageDomain) {
+        return null;
+    }
+}

+ 5 - 0
linkwe-service/src/main/java/com/linkwechat/domain/customer/query/WeCustomersQuery.java

@@ -108,4 +108,9 @@ public class WeCustomersQuery {
      * 标签名,多个逗号隔开
      */
     private String tagNames;
+
+    /**
+     * 客户来源 0.客群活码 1.门店活码 2.识客活码 3.拉新活码
+     */
+    private Integer source;
 }

+ 44 - 0
linkwe-service/src/main/java/com/linkwechat/domain/customer/vo/WeCustomerUserDetailInfoVo.java

@@ -0,0 +1,44 @@
+package com.linkwechat.domain.customer.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 微信客户详情
+ */
+@Data
+public class WeCustomerUserDetailInfoVo {
+
+    /**
+     * 微信OpenID
+     */
+    private String wxOpenid;
+
+    /**
+     * 用户编码
+     */
+    private String userCode;
+
+    /**
+     * 微信昵称
+     */
+    private String wxNickname;
+
+    /**
+     * 微信头像URL
+     */
+    private String wxAvatar;
+
+    /**
+     * 微信手机号
+     */
+    private String wxPhone;
+
+    /**
+     * 绑定时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date bindTime;
+}

+ 67 - 0
linkwe-service/src/main/java/com/linkwechat/domain/customer/vo/WeCustomerUserVo.java

@@ -0,0 +1,67 @@
+package com.linkwechat.domain.customer.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class WeCustomerUserVo {
+
+
+    /**
+     * 主键
+     */
+    private Long id;
+
+    /**
+     * 微信手机号
+     */
+    private String wxPhone;
+
+    /**
+     * 用户编码
+     */
+    private String userCode;
+
+    /**
+     * 微信昵称
+     */
+    private String wxNickname;
+
+    /**
+     * 微信头像URL
+     */
+    private String wxAvatar;
+
+    /**
+     * 微信OpenID
+     */
+    private String wxOpenid;
+
+    /**
+     * 绑定时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date bindTime;
+
+    /**
+     * 状态 0.未绑定 1.已绑定
+     */
+    private Integer status;
+
+    /**
+     * 最后同步绑定时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date updateTime;
+
+}

+ 6 - 0
linkwe-service/src/main/java/com/linkwechat/domain/customer/vo/WeCustomersVo.java

@@ -244,5 +244,11 @@ public class WeCustomersVo {
     @ExcelProperty(value = "关系说明", index = 15)
     private String delFlagStatus;
 
+    /**
+     * 客户来源 0.客群活码 1.门店活码 2.识客活码 3.拉新活码
+     */
+    @ExcelProperty(value = "客户来源", index = 16, converter = CustomerTypeConverter.class)
+    private Integer source;
+
 
 }

+ 58 - 0
linkwe-service/src/main/java/com/linkwechat/domain/customer/vo/WeUserDetailInfoVo.java

@@ -0,0 +1,58 @@
+package com.linkwechat.domain.customer.vo;
+
+import com.alibaba.excel.annotation.format.DateTimeFormat;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 同步用户详情
+ */
+@Data
+public class WeUserDetailInfoVo {
+
+    /**
+     * 用户编码
+     */
+    private String userCode;
+
+    /**
+     * 用户姓名
+     */
+    private String name;
+
+    /**
+     * 性别0.女 1.男
+     */
+    private Integer sex;
+
+    /**
+     * 生日
+     */
+    @DateTimeFormat("yyyy-MM-dd")
+    @JsonFormat(pattern = "M月d日")
+    private Date birthday;
+
+    /**
+     * 手机号
+     */
+    private String phone;
+
+    /**
+     * 用户状态 0.正式用户 1.临时用户
+     */
+    private Integer status;
+
+    /**
+     * 用户类型 0.普通用户
+     */
+    private Integer type;
+
+    /**
+     * 注册时间
+     */
+    @DateTimeFormat("yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date registerTime;
+}

+ 90 - 0
linkwe-service/src/main/java/com/linkwechat/domain/customer/vo/WeUserVo.java

@@ -0,0 +1,90 @@
+package com.linkwechat.domain.customer.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.alibaba.excel.annotation.format.DateTimeFormat;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class WeUserVo {
+
+    /**
+     * Id
+     */
+    private Long id;
+
+    /**
+     * 用户编码
+     */
+    private String userCode;
+
+    /**
+     * 用户姓名
+     */
+    private String name;
+
+    /**
+     * 性别0.女 1.男
+     */
+    private Integer sex;
+
+    /**
+     * 生日
+     */
+    @DateTimeFormat("yyyy-MM-dd")
+    @JsonFormat(pattern = "M月d日")
+    private Date birthday;
+
+    /**
+     * 手机号
+     */
+    private String phone;
+
+    /**
+     * 用户来源 0.晋掌柜 1. 掌柜生活
+     */
+    private Integer source;
+
+    /**
+     * 用户状态 0.正式用户 1.临时用户
+     */
+    private Integer status;
+
+    /**
+     * 用户类型 0.普通用户
+     */
+    private Integer type;
+
+    /**
+     * 归属员工ID
+     */
+    private Long ownerUserId;
+
+    /**
+     * 注册时间
+     */
+    @DateTimeFormat("yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date registerTime;
+
+    /**
+     * 企微触达状态 0.未触达 1.已触达
+     */
+    private Integer deliveredStatus;
+
+    /**
+     * 最近互动时间
+     */
+    @DateTimeFormat("yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date updateTime;
+}

+ 45 - 0
linkwe-service/src/main/java/com/linkwechat/mapper/WeCustomerUserMapper.java

@@ -0,0 +1,45 @@
+package com.linkwechat.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.linkwechat.common.annotation.DataColumn;
+import com.linkwechat.common.annotation.DataScope;
+import com.linkwechat.common.core.page.PageDomain;
+import com.linkwechat.domain.WeCustomerUser;
+import com.linkwechat.domain.customer.query.WeCustomerUserQuery;
+import com.linkwechat.domain.customer.vo.WeCustomerUserVo;
+import com.linkwechat.domain.customer.vo.WeCustomersVo;
+import com.linkwechat.domain.customer.vo.WeUserVo;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface WeCustomerUserMapper extends BaseMapper<WeCustomerUser> {
+
+    /**
+     * 分页获取微信客户id列表
+     *
+     * @param weCustomerUserQuery
+     * @param pageDomain
+     * @return
+     */
+    @DataScope(type = "2", value = @DataColumn(alias = "wcu", name = "create_by_id", userid = "user_id"))
+    List<String> findWeCustomerUserListIds(@Param("weCustomerUserList")WeCustomerUserQuery weCustomerUserQuery, @Param("pageDomain") PageDomain pageDomain);
+
+    /**
+     * 微信客户列表接口
+     *
+     * @param ids
+     * @return
+     */
+    List<WeCustomerUserVo> findWeCustomerUserList(@Param("ids") List<String> ids);
+
+
+    /**
+     * 微信客户客户总数统计
+     *
+     * @param weCustomerUserQuery
+     * @return
+     */
+    @DataScope(type = "2", value = @DataColumn(alias = "wcu", name = "create_by_id", userid = "user_id"))
+    long countWeCustomerUserList(@Param("weCustomerUserList") WeCustomerUserQuery weCustomerUserQuery);
+}

+ 44 - 0
linkwe-service/src/main/java/com/linkwechat/mapper/WeUserMapper.java

@@ -0,0 +1,44 @@
+package com.linkwechat.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.linkwechat.common.annotation.DataColumn;
+import com.linkwechat.common.annotation.DataScope;
+import com.linkwechat.common.core.page.PageDomain;
+import com.linkwechat.domain.WeUser;
+import com.linkwechat.domain.customer.query.WeCuUserQuery;
+import com.linkwechat.domain.customer.vo.WeUserVo;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+public interface WeUserMapper extends BaseMapper<WeUser> {
+
+    /**
+     * 分页获取同步用户id列表
+     *
+     * @param weUserQuery
+     * @param pageDomain
+     * @return
+     */
+    @DataScope(type = "2", value = @DataColumn(alias = "wur", name = "create_by_id", userid = "user_id"))
+    List<String> findWeUserListIds(@Param("weUserList") WeCuUserQuery weUserQuery, @Param("pageDomain") PageDomain pageDomain);
+
+    /**
+     * 同步用户列表接口
+     *
+     * @param ids
+     * @return
+     */
+    List<WeUserVo> findWeUserList(@Param("ids") List<String> ids);
+
+
+    /**
+     * 客户总数统计
+     *
+     * @param weUserQuery
+     * @return
+     */
+    @DataScope(type = "2", value = @DataColumn(alias = "wur", name = "create_by_id", userid = "user_id"))
+    long countWeUserList(@Param("weUserList") WeCuUserQuery weUserQuery);
+}

+ 49 - 0
linkwe-service/src/main/java/com/linkwechat/service/IWeCustomerUserService.java

@@ -0,0 +1,49 @@
+package com.linkwechat.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.linkwechat.common.core.page.PageDomain;
+import com.linkwechat.domain.WeCustomerUser;
+import com.linkwechat.domain.customer.query.WeCustomerUserQuery;
+import com.linkwechat.domain.customer.vo.WeCustomerUserDetailInfoVo;
+import com.linkwechat.domain.customer.vo.WeCustomerUserVo;
+
+import java.util.List;
+
+public interface IWeCustomerUserService  extends IService<WeCustomerUser> {
+
+    /**
+     * 微信客户列表
+     *
+     * @param weCustomerUserQuery
+     * @return
+     */
+    List<WeCustomerUserVo> findWeCustomerUserList(WeCustomerUserQuery weCustomerUserQuery, PageDomain pageDomain);
+
+    /**
+     * 微信客户总数统计
+     *
+     * @param weCustomerUserQuery
+     * @return
+     */
+    long countWeCustomerUserList(WeCustomerUserQuery weCustomerUserQuery);
+
+    /**
+     * 微信客户详情
+     * @param id
+     * @return
+     */
+    WeCustomerUserDetailInfoVo findWeCustomerUserBaseInfo(String id);
+
+    /**
+     * 绑定用户
+     * @param userId
+     * @param id
+     */
+    void bindUser(String userId, String id);
+
+    /**
+     * 解绑用户
+     * @param id
+     */
+    void unbindUser(String id);
+}

+ 44 - 0
linkwe-service/src/main/java/com/linkwechat/service/IWeUserService.java

@@ -0,0 +1,44 @@
+package com.linkwechat.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.linkwechat.common.core.page.PageDomain;
+import com.linkwechat.domain.WeUser;
+import com.linkwechat.domain.customer.query.WeCuUserQuery;
+import com.linkwechat.domain.customer.vo.WeUserDetailInfoVo;
+import com.linkwechat.domain.customer.vo.WeUserVo;
+
+import java.util.List;
+
+public interface IWeUserService extends IService<WeUser> {
+
+    /**
+     * 同步用户列表
+     *
+     * @param weUserQuery
+     * @return
+     */
+    List<WeUserVo> findWeUserList(WeCuUserQuery weUserQuery, PageDomain pageDomain);
+
+    /**
+     * 同步用户总数统计
+     *
+     * @param weUserQuery
+     * @return
+     */
+    long countWeUserList(WeCuUserQuery weUserQuery);
+
+    /**
+     * 分配/转出
+     *
+     * @param id
+     * @param userId
+     */
+    void transferOwner(Long id, Long userId);
+
+    /**
+     * 同步用户详情
+     * @param id
+     * @return
+     */
+    WeUserDetailInfoVo findWeUserBaseInfo(String id);
+}

+ 95 - 0
linkwe-service/src/main/java/com/linkwechat/service/impl/WeCustomerUserServiceImpl.java

@@ -0,0 +1,95 @@
+package com.linkwechat.service.impl;
+
+import cn.hutool.core.collection.CollectionUtil;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.linkwechat.common.core.page.PageDomain;
+import com.linkwechat.common.exception.CustomException;
+import com.linkwechat.common.utils.StringUtils;
+import com.linkwechat.common.utils.bean.BeanUtils;
+import com.linkwechat.domain.WeCustomerUser;
+import com.linkwechat.domain.WeUser;
+import com.linkwechat.domain.customer.query.WeCustomerUserQuery;
+import com.linkwechat.domain.customer.vo.WeCustomerUserDetailInfoVo;
+import com.linkwechat.domain.customer.vo.WeCustomerUserVo;
+import com.linkwechat.domain.customer.vo.WeUserDetailInfoVo;
+import com.linkwechat.domain.customer.vo.WeUserVo;
+import com.linkwechat.mapper.WeCustomerUserMapper;
+import com.linkwechat.service.IWeCustomerUserService;
+import com.linkwechat.service.IWeMessageNotificationService;
+import com.linkwechat.service.IWeUserService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+
+@Slf4j
+@Service
+public class WeCustomerUserServiceImpl extends ServiceImpl<WeCustomerUserMapper, WeCustomerUser> implements IWeCustomerUserService {
+
+    @Resource
+    private IWeUserService weUserService;
+
+    @Override
+    public List<WeCustomerUserVo> findWeCustomerUserList(WeCustomerUserQuery weCustomerUserQuery, PageDomain pageDomain) {
+
+        List<WeCustomerUserVo> weCustomerUserVos = new ArrayList<>();
+        List<String> ids = this.baseMapper.findWeCustomerUserListIds(weCustomerUserQuery, pageDomain);
+
+        if (CollectionUtil.isNotEmpty(ids)) {
+            weCustomerUserVos = this.baseMapper.findWeCustomerUserList(ids);
+        }
+
+        return weCustomerUserVos;
+    }
+
+    @Override
+    public long countWeCustomerUserList(WeCustomerUserQuery weCustomerUserQuery) {
+        return this.baseMapper.countWeCustomerUserList(weCustomerUserQuery);
+    }
+
+    @Override
+    public WeCustomerUserDetailInfoVo findWeCustomerUserBaseInfo(String id) {
+        WeCustomerUserDetailInfoVo weCustomerUserDetailInfoVo = new WeCustomerUserDetailInfoVo();
+        WeCustomerUser weCustomerUser = this.baseMapper.selectById(id);
+        if (Objects.nonNull(weCustomerUser)) {
+            BeanUtils.copyBeanProp(
+                    weCustomerUserDetailInfoVo,
+                    weCustomerUser
+            );
+        }
+
+        return weCustomerUserDetailInfoVo;
+    }
+
+    @Override
+    public void bindUser(String userId, String id) {
+        WeCustomerUser weCustomerUser = this.baseMapper.selectById(id);
+        if(StringUtils.isNotEmpty(weCustomerUser.getUserCode())){
+            throw new CustomException("该用户已经绑定,不允许重复绑定");
+        }
+
+        WeUser user = weUserService.getById(userId);
+        weCustomerUser.setUserId(user.getId());
+        weCustomerUser.setUserCode(user.getUserCode());
+        weCustomerUser.setStatus(1);
+        weCustomerUser.setBindTime(new Date());
+        this.baseMapper.updateById(weCustomerUser);
+    }
+
+    @Override
+    public void unbindUser(String id) {
+        WeCustomerUser weCustomerUser = this.baseMapper.selectById(id);
+        if(StringUtils.isEmpty(weCustomerUser.getUserCode())){
+            throw new CustomException("该用户已经解绑,不允许重复解绑");
+        }
+        weCustomerUser.setUserId(null);
+        weCustomerUser.setUserCode(null);
+        weCustomerUser.setBindTime(null);
+        weCustomerUser.setStatus(0);
+        this.baseMapper.updateById(weCustomerUser);
+    }
+}

+ 63 - 0
linkwe-service/src/main/java/com/linkwechat/service/impl/WeUserServiceImpl.java

@@ -0,0 +1,63 @@
+package com.linkwechat.service.impl;
+
+import cn.hutool.core.collection.CollectionUtil;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.linkwechat.common.core.page.PageDomain;
+import com.linkwechat.common.utils.bean.BeanUtils;
+import com.linkwechat.domain.WeUser;
+import com.linkwechat.domain.customer.query.WeCuUserQuery;
+import com.linkwechat.domain.customer.vo.WeUserDetailInfoVo;
+import com.linkwechat.domain.customer.vo.WeUserVo;
+import com.linkwechat.mapper.WeUserMapper;
+import com.linkwechat.service.IWeUserService;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+@Service
+public class WeUserServiceImpl extends ServiceImpl<WeUserMapper, WeUser> implements IWeUserService {
+
+
+    @Override
+    public List<WeUserVo> findWeUserList(WeCuUserQuery weUserQuery, PageDomain pageDomain) {
+
+        List<WeUserVo> weUserVos = new ArrayList<>();
+        List<String> ids = this.baseMapper.findWeUserListIds(weUserQuery, pageDomain);
+
+        if (CollectionUtil.isNotEmpty(ids)) {
+            weUserVos = this.baseMapper.findWeUserList(ids);
+        }
+
+        return weUserVos;
+    }
+
+    @Override
+    public long countWeUserList(WeCuUserQuery weUserQuery) {
+        return this.baseMapper.countWeUserList(weUserQuery);
+    }
+
+    @Override
+    public void transferOwner(Long id, Long userId) {
+        WeUser weUser = this.baseMapper.selectById(id);
+        weUser.setOwnerUserId(userId);
+        this.baseMapper.updateById(weUser);
+    }
+
+    @Override
+    public WeUserDetailInfoVo findWeUserBaseInfo(String id) {
+
+        WeUserDetailInfoVo weUserDetailInfoVo = new WeUserDetailInfoVo();
+        WeUser weUser = this.baseMapper.selectById(id);
+
+        if (Objects.nonNull(weUser)) {
+            BeanUtils.copyBeanProp(
+                    weUserDetailInfoVo,
+                    weUser
+            );
+        }
+
+        return weUserDetailInfoVo;
+    }
+}

+ 8 - 0
linkwe-service/src/main/resources/mapper/wecom/WeCustomerMapper.xml

@@ -17,6 +17,9 @@
             <if test="weCustomerList.gender !=null">
                 AND wcr.gender=#{weCustomerList.gender}
             </if>
+           <if test="weCustomerList.source !=null">
+               AND wcr.source=#{weCustomerList.source}
+           </if>
             <if test="weCustomerList.trackState !=null">
                 AND wcr.track_state=#{weCustomerList.trackState}
             </if>
@@ -197,6 +200,7 @@
         wc.email,
         wc.address,
         wc.qq,
+        wc.source,
         wc.position,
         wc.corp_name as corpName,
         wc.other_descr as otherDescr,
@@ -239,6 +243,10 @@
                 AND wcr.gender=#{weCustomerList.gender}
             </if>
 
+            <if test="weCustomerList.source !=null">
+                AND wcr.source=#{weCustomerList.source}
+            </if>
+
             <if test="weCustomerList.trackState !=null">
                 AND wcr.track_state=#{weCustomerList.trackState}
             </if>

+ 73 - 0
linkwe-service/src/main/resources/mapper/wecom/WeCustomerUserMapper.xml

@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.linkwechat.mapper.WeCustomerUserMapper">
+
+    <select id="findWeCustomerUserListIds" resultType="java.lang.String">
+        SELECT wcu.id FROM we_customer_user wcu
+        <where>
+            <if test="weCustomerUserList.wxOpenid != null">
+                AND wcu.wx_openid = #{weCustomerUserList.wxOpenid}
+            </if>
+            <if test="weCustomerUserList.userCode != null">
+                AND wcu.user_code = #{weCustomerUserList.userCode}
+            </if>
+            <if test="weCustomerUserList.wxNickname != null">
+                AND wcu.wx_nickname = #{weCustomerUserList.wxNickname}
+            </if>
+            <if test="weCustomerUserList.status != null">
+                AND wcu.status = #{weCustomerUserList.status}
+            </if>
+        </where>
+        ORDER BY wcu.add_time desc
+        <if test="pageDomain !=null">
+            <if test="pageDomain.pageNum !=null and pageDomain.pageSize !=null">
+                limit ${pageDomain.pageSize * (pageDomain.pageNum-1)}, #{pageDomain.pageSize}
+            </if>
+        </if>
+
+    </select>
+
+    <select id="countWeCustomerUserList" resultType="long">
+        SELECT
+        count(0)
+        FROM we_customer_user wcu
+        <where>
+            <if test="weCustomerUserList.wxOpenid != null">
+                AND wcu.wx_openid = #{weCustomerUserList.wxOpenid}
+            </if>
+            <if test="weCustomerUserList.userCode != null">
+                AND wcu.user_code = #{weCustomerUserList.userCode}
+            </if>
+            <if test="weCustomerUserList.wxNickname != null">
+                AND wcu.wx_nickname = #{weCustomerUserList.wxNickname}
+            </if>
+            <if test="weCustomerUserList.status != null">
+                AND wcu.status = #{weCustomerUserList.status}
+            </if>
+        </where>
+
+    </select>
+
+
+    <select id="findWeCustomerUserList" resultType="com.linkwechat.domain.customer.vo.WeCustomerUserVo">
+        SELECT
+        wcu.id,
+        wcu.user_code as userCode,
+        wcu.wx_phone as wxPhone,
+        wcu.wx_nickname as wxNickname,
+        wcu.wx_avator as wxAvatar,
+        wcu.wx_openid as wxOpenid,
+        wcu.bind_time as bindTime,
+        wcu.update_time as updateTime,
+        wcu.status
+        FROM we_customer_user wcu
+        WHERE
+        wcu.id in
+        <foreach collection="ids" index="index" item="id" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        ORDER BY wcu.add_time desc
+    </select>
+</mapper>

+ 92 - 0
linkwe-service/src/main/resources/mapper/wecom/WeUserMapper.xml

@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.linkwechat.mapper.WeUserMapper">
+
+    <select id="findWeUserListIds" resultType="java.lang.String">
+        SELECT wur.id FROM we_user wur
+        <where>
+            <if test="weUserList.userCode != null">
+                AND wur.user_code=#{weUserList.userCode}
+            </if>
+            <if test="weUserList.name != null">
+                AND wur.name=#{weUserList.name}
+            </if>
+            <if test="weUserList.phone != null">
+                AND wur.phone=#{weUserList.phone}
+            </if>
+
+            <if test="weUserList.source != null">
+                AND wur.source=#{weUserList.source}
+            </if>
+            <if test="weUserList.status != null">
+                AND wur.status=#{weUserList.status}
+            </if>
+            <if test="weUserList.deliveredStatus != null">
+                AND wur.delivered_status=#{weUserList.deliveredStatus}
+            </if>
+        </where>
+        ORDER BY wur.create_time desc
+        <if test="pageDomain !=null">
+            <if test="pageDomain.pageNum !=null and pageDomain.pageSize !=null">
+                limit ${pageDomain.pageSize * (pageDomain.pageNum-1)}, #{pageDomain.pageSize}
+            </if>
+        </if>
+
+    </select>
+
+    <select id="countWeUserList" resultType="long">
+        SELECT
+        count(0)
+        FROM we_user wur
+        <where>
+            <if test="weUserList.userCode != null">
+                AND wur.user_code=#{weUserList.userCode}
+            </if>
+            <if test="weUserList.name != null">
+                AND wur.name=#{weUserList.name}
+            </if>
+            <if test="weUserList.phone != null">
+                AND wur.phone=#{weUserList.phone}
+            </if>
+
+            <if test="weUserList.source != null">
+                AND wur.source=#{weUserList.source}
+            </if>
+            <if test="weUserList.status != null">
+                AND wur.status=#{weUserList.status}
+            </if>
+            <if test="weUserList.deliveredStatus != null">
+                AND wur.delivered_status=#{weUserList.deliveredStatus}
+            </if>
+        </where>
+
+    </select>
+
+
+    <select id="findWeUserList" resultType="com.linkwechat.domain.customer.vo.WeUserVo">
+        SELECT
+            wu.id,
+            wu.user_code as userCode,
+            wu.name ,
+            wu.sex ,
+            wu.birthday,
+            wu.phone,
+            wu.source,
+            wu.status,
+            wu.delivered_status as deliveredStatus,
+            wu.type,
+            wu.owner_user_id as ownerUserId,
+            wu.update_time as updateTime,
+            wu.register_time as registerTime
+        FROM
+            we_user wu
+        WHERE
+            wu.id in
+            <foreach collection="ids" index="index" item="id" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        ORDER BY wu.create_time desc
+    </select>
+</mapper>