+
+
+ UPDATE epdc_points_logs
+ SET FACE_IMG = #{faceImg},
+ USER_ID = #{newUserId}
+ WHERE
+ id = #{oldUserId}
+
diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/CachingUserInfoDTO.java b/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/CachingUserInfoDTO.java
index 896b623b..f5b48815 100644
--- a/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/CachingUserInfoDTO.java
+++ b/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/CachingUserInfoDTO.java
@@ -74,4 +74,15 @@ public class CachingUserInfoDTO {
*/
private String remark;
+ /**
+ * 积分
+ */
+ private Integer points;
+ /**
+ * 积分
+ */
+ private Integer pointsTotle;
+
+
+
}
diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/PointsLogsBindUnIdDTO.java b/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/PointsLogsBindUnIdDTO.java
new file mode 100644
index 00000000..b8152a48
--- /dev/null
+++ b/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/PointsLogsBindUnIdDTO.java
@@ -0,0 +1,46 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.elink.esua.epdc.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+/**
+ * 修改过时积分日志
+ *
+ * @author elink elink@elink-cn.com
+ * @since v1.0.0 2020-04-29
+ */
+@Data
+public class PointsLogsBindUnIdDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 用户ID
+ */
+ private String userId;
+
+ /**
+ * 新用户
+ */
+ private UserDTO user;
+
+}
\ No newline at end of file
diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/CheckRepeatUserFormDTO.java b/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/CheckRepeatUserFormDTO.java
new file mode 100644
index 00000000..ccf1a9ff
--- /dev/null
+++ b/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/CheckRepeatUserFormDTO.java
@@ -0,0 +1,19 @@
+package com.elink.esua.epdc.dto.epdc.form;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @Description
+ * @Author syp
+ * @Date 2019/11/22 13:54
+ */
+@Data
+public class CheckRepeatUserFormDTO implements Serializable {
+ private static final long serialVersionUID = -4267811821756082365L;
+
+ private String openId;
+
+ private String unionId;
+}
diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/CombineVolunteerUserFormDTO.java b/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/CombineVolunteerUserFormDTO.java
new file mode 100644
index 00000000..f54704b7
--- /dev/null
+++ b/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/CombineVolunteerUserFormDTO.java
@@ -0,0 +1,23 @@
+package com.elink.esua.epdc.dto.epdc.form;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author songyunpeng
+ * @Description
+ * @create 2021-04-15
+ */
+@Data
+public class CombineVolunteerUserFormDTO implements Serializable {
+ /**
+ * 新用户ID
+ */
+ private String userId;
+ /**
+ * 手机号
+ */
+ private String mobile;
+
+}
diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcGridLeaderRegisterSubmitFormDTO.java b/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcGridLeaderRegisterSubmitFormDTO.java
index 5dee1d70..9253c5cb 100644
--- a/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcGridLeaderRegisterSubmitFormDTO.java
+++ b/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcGridLeaderRegisterSubmitFormDTO.java
@@ -33,4 +33,9 @@ public class EpdcGridLeaderRegisterSubmitFormDTO implements Serializable {
*/
@NotBlank(message = "微信code不能为空")
private String wxCode;
+
+ /**
+ * 小程序类型
+ */
+ private String type;
}
diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcUserRegistFormDTO.java b/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcUserRegistFormDTO.java
index 97280424..0886d608 100644
--- a/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcUserRegistFormDTO.java
+++ b/esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcUserRegistFormDTO.java
@@ -63,4 +63,10 @@ public class EpdcUserRegistFormDTO implements Serializable {
*/
@NotBlank(message = "微信code不能为空")
private String wxCode;
+
+
+ /**
+ * 小程序类型
+ */
+ private String type;
}
diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/UserController.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/UserController.java
index 95814a60..fe59b8a5 100644
--- a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/UserController.java
+++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/UserController.java
@@ -31,6 +31,8 @@ import com.elink.esua.epdc.dto.PartyMemberModifyFormDTO;
import com.elink.esua.epdc.dto.UserDTO;
import com.elink.esua.epdc.dto.UserPointResultDTO;
import com.elink.esua.epdc.dto.UserPointsDTO;
+import com.elink.esua.epdc.dto.epdc.form.CheckRepeatUserFormDTO;
+import com.elink.esua.epdc.dto.epdc.form.CombineVolunteerUserFormDTO;
import com.elink.esua.epdc.dto.epdc.form.EpdcUserPointsFormDTO;
import com.elink.esua.epdc.enums.AppUserStatesEnum;
import com.elink.esua.epdc.excel.UserExcel;
@@ -340,4 +342,30 @@ public class UserController {
return userService.updateUserPoints(epdcUserPointsFormDTO);
}
+ /**
+ * @return com.elink.esua.epdc.commons.tools.utils.Result
+ * @Description 更新用户积分信息
+ * @Author songyunpeng
+ * @Date 2020/4/29
+ * @Param [dto]
+ **/
+ @PostMapping(value = "checkRepeatUser")
+ Result checkRepeatUser(@RequestBody CheckRepeatUserFormDTO checkRepeatUserFormDTO){
+ return userService.checkRepeatUser(checkRepeatUserFormDTO);
+ }
+ /**
+ * @Description 志愿者注册合并用户
+ * @Author songyunpeng
+ * @Date 2021/4/15
+ * @Param [checkRepeatUserFormDTO]
+ * @return com.elink.esua.epdc.commons.tools.utils.Result
+ **/
+ @PostMapping(value = "combineVolunteerUser")
+ Result combineVolunteerUser(@RequestBody CombineVolunteerUserFormDTO formDTO){
+ return userService.combineVolunteerUser(formDTO);
+ }
+
+
+
+
}
diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/dao/UserGridRelationDao.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/dao/UserGridRelationDao.java
index fe088b38..c78a6e76 100644
--- a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/dao/UserGridRelationDao.java
+++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/dao/UserGridRelationDao.java
@@ -21,6 +21,7 @@ import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.dto.UserGridRelationDTO;
import com.elink.esua.epdc.entity.UserGridRelationEntity;
import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -83,4 +84,20 @@ public interface UserGridRelationDao extends BaseDao {
* @return com.elink.esua.epdc.dto.UserGridRelationDTO
**/
UserGridRelationDTO getUserFirstScanGrid(String userId);
+ /**
+ * @Description 把小程序用户的userID全部替换为UidUser的ID
+ * @Author songyunpeng
+ * @Date 2021/4/8
+ * @Param [openUserId, unionUserId]
+ * @return void
+ **/
+ void maBindUnId(@Param("openUserId") String openUserId, @Param("unionUserId") String unionUserId);
+ /**
+ * @Description 查询重复的网格关系数据
+ * @Author songyunpeng
+ * @Date 2021/4/8
+ * @Param [userId]
+ * @return java.util.List
+ **/
+ List selectRepeatRelation(String userId);
}
diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/feign/PointsFeignClient.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/feign/PointsFeignClient.java
new file mode 100644
index 00000000..3264fb29
--- /dev/null
+++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/feign/PointsFeignClient.java
@@ -0,0 +1,33 @@
+package com.elink.esua.epdc.feign;
+
+import com.elink.esua.epdc.commons.tools.constant.ServiceConstant;
+import com.elink.esua.epdc.commons.tools.utils.Result;
+import com.elink.esua.epdc.dto.PointsLogsBindUnIdDTO;
+import com.elink.esua.epdc.feign.fallback.NewsFeignClientFallback;
+import com.elink.esua.epdc.feign.fallback.PointsFeignClientFallback;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+/**
+ * 积分管理模块
+ *
+ * @author work@yujt.net.cn
+ * @date 2019/9/18 15:37
+ */
+@FeignClient(name = ServiceConstant.EPDC_POINTS_SERVER, fallback = PointsFeignClientFallback.class)
+public interface PointsFeignClient {
+
+ /**
+ * 更新积分日志
+ *
+ * @param formDto
+ * @return com.elink.esua.epdc.commons.tools.utils.Result
+ * @author zhy
+ * @date 2020/8/12 15:55
+ */
+ @PostMapping(value = "points/pointslogs/maBindUnIdLogs", consumes = MediaType.APPLICATION_JSON_VALUE)
+ Result maBindUnIdLogs(@RequestBody PointsLogsBindUnIdDTO formDto);
+
+}
diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/feign/fallback/PointsFeignClientFallback.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/feign/fallback/PointsFeignClientFallback.java
new file mode 100644
index 00000000..810a32dd
--- /dev/null
+++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/feign/fallback/PointsFeignClientFallback.java
@@ -0,0 +1,21 @@
+package com.elink.esua.epdc.feign.fallback;
+
+import com.elink.esua.epdc.commons.tools.constant.ServiceConstant;
+import com.elink.esua.epdc.commons.tools.utils.ModuleUtils;
+import com.elink.esua.epdc.commons.tools.utils.Result;
+import com.elink.esua.epdc.dto.PointsLogsBindUnIdDTO;
+import com.elink.esua.epdc.feign.PointsFeignClient;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author work@yujt.net.cn
+ * @date 2019/9/18 15:38
+ */
+@Component
+public class PointsFeignClientFallback implements PointsFeignClient {
+
+ @Override
+ public Result maBindUnIdLogs(PointsLogsBindUnIdDTO formDto) {
+ return ModuleUtils.feignConError(ServiceConstant.EPDC_POINTS_SERVER, "maBindUnIdLogs", formDto);
+ }
+}
diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/UserGridRelationService.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/UserGridRelationService.java
index 92ca056e..ba6a16d5 100644
--- a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/UserGridRelationService.java
+++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/UserGridRelationService.java
@@ -205,4 +205,20 @@ public interface UserGridRelationService extends BaseService
+ **/
+ List selectRepeatRelation(String userId);
}
diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/UserService.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/UserService.java
index 5f13e93c..f916386d 100644
--- a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/UserService.java
+++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/UserService.java
@@ -417,4 +417,20 @@ public interface UserService extends BaseService {
* @return com.elink.esua.epdc.commons.tools.utils.Result
**/
Result getUserGridIdByUserId(String userId);
+ /**
+ * @Description 检查完善信息 合并重复用户
+ * @Author songyunpeng
+ * @Date 2021/4/9
+ * @Param [checkRepeatUserFormDTO]
+ * @return com.elink.esua.epdc.commons.tools.utils.Result
+ **/
+ Result checkRepeatUser(CheckRepeatUserFormDTO checkRepeatUserFormDTO);
+ /**
+ * @Description 志愿者合并用户
+ * @Author songyunpeng
+ * @Date 2021/4/15
+ * @Param [formDTO]
+ * @return com.elink.esua.epdc.commons.tools.utils.Result
+ **/
+ Result combineVolunteerUser(CombineVolunteerUserFormDTO formDTO);
}
diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserGridRelationServiceImpl.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserGridRelationServiceImpl.java
index 8b54239d..c98486bc 100644
--- a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserGridRelationServiceImpl.java
+++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserGridRelationServiceImpl.java
@@ -21,11 +21,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
+import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.redis.RedisKeys;
import com.elink.esua.epdc.commons.tools.redis.RedisUtils;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
-import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.constant.UserFieldConsant;
import com.elink.esua.epdc.dao.UserGridRelationDao;
@@ -243,6 +243,16 @@ public class UserGridRelationServiceImpl extends BaseServiceImpl selectRepeatRelation(String userId) {
+ return baseDao.selectRepeatRelation(userId);
+ }
+
/**
*
* 组织机构信息处理
diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserServiceImpl.java b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserServiceImpl.java
index 3bac1324..aa4d6966 100644
--- a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserServiceImpl.java
+++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserServiceImpl.java
@@ -38,39 +38,33 @@ import com.elink.esua.epdc.commons.tools.utils.MessageUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.constant.AuthenticatedConsant;
import com.elink.esua.epdc.constant.UserFieldConsant;
-import com.elink.esua.epdc.dao.PartyAuthenticationFailedDao;
-import com.elink.esua.epdc.dao.PartyMembersDao;
-import com.elink.esua.epdc.dao.UserAuthenticateHistoryDao;
-import com.elink.esua.epdc.dao.UserDao;
+import com.elink.esua.epdc.dao.*;
import com.elink.esua.epdc.dto.*;
-import com.elink.esua.epdc.dto.epdc.form.EpdcUserGroupInviteFormDTO;
-import com.elink.esua.epdc.dto.epdc.form.EpdcUserRegistFormDTO;
-import com.elink.esua.epdc.dto.epdc.result.*;
import com.elink.esua.epdc.dto.epdc.EpdcCompleteAppUserDTO;
import com.elink.esua.epdc.dto.epdc.EpdcGridLeaderRegisterDTO;
import com.elink.esua.epdc.dto.epdc.form.*;
-import com.elink.esua.epdc.dto.epdc.result.EpdcResidentDetailResultDTO;
-import com.elink.esua.epdc.dto.epdc.result.EpdcUserRegisterInfoResultDTO;
+import com.elink.esua.epdc.dto.epdc.result.*;
import com.elink.esua.epdc.entity.*;
-import com.elink.esua.epdc.dto.epdc.result.EpdcUserInfoResultDTO;
-import com.elink.esua.epdc.dto.epdc.result.EpdcUserRegisterAuditMsgResultDTO;
-import com.elink.esua.epdc.dto.epdc.result.EpdcWorkUserResultDTO;
import com.elink.esua.epdc.enums.AppUserAuditStateEnum;
import com.elink.esua.epdc.enums.AppUserStatesEnum;
import com.elink.esua.epdc.enums.PartyMemberRegFlagEnum;
import com.elink.esua.epdc.exception.UserModuleErrorCode;
import com.elink.esua.epdc.feign.AdminFeignClient;
+import com.elink.esua.epdc.feign.PointsFeignClient;
import com.elink.esua.epdc.rocketmq.dto.OrganizationModifyDTO;
import com.elink.esua.epdc.service.UserGridRelationService;
import com.elink.esua.epdc.service.UserInvitationRecordService;
import com.elink.esua.epdc.service.UserService;
import com.elink.esua.epdc.service.UserTagRelationService;
+import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
+import java.util.logging.Logger;
/**
* 用户信息表
@@ -80,6 +74,8 @@ import java.util.*;
*/
@Service
public class UserServiceImpl extends BaseServiceImpl implements UserService {
+ private final org.slf4j.Logger logger = LoggerFactory.getLogger(getClass());
+
@Autowired
private PartyMembersDao partyMembersDao;
@@ -100,6 +96,8 @@ public class UserServiceImpl extends BaseServiceImpl implem
private PartyAuthenticationFailedDao partyAuthenticationFailedDao;
@Autowired
private UserTagRelationService userTagRelationService;
+ @Autowired
+ private PointsFeignClient pointsFeignClient;
@Override
public PageData page(Map params) {
@@ -1024,16 +1022,120 @@ public class UserServiceImpl extends BaseServiceImpl implem
if (StringUtils.isBlank(formDTO.getOpenId())) {
throw new RenException("openId不能为空");
}
- CachingUserInfoDTO cachingUserInfoDTO = null;
- if (StringUtils.isNotBlank(formDTO.getUnionId())) {
- //根据unionId查询
- cachingUserInfoDTO = this.baseDao.selectCachingUserInfoDTO(null, formDTO.getUnionId());
- }
- if (null == cachingUserInfoDTO) {
- //根据openId查询
- cachingUserInfoDTO = this.baseDao.selectCachingUserInfoDTO(formDTO.getOpenId(), null);
+ //接口匹配志愿者小程序 - start
+ CachingUserInfoDTO uIdUser = this.baseDao.selectCachingUserInfoDTO(null, formDTO.getUnionId());
+ CachingUserInfoDTO oIdUser = this.baseDao.selectCachingUserInfoDTO(formDTO.getOpenId(), null);
+ if(uIdUser != null && oIdUser != null){
+ //都不为空的话 合并用户
+ //如果相同,则查出的用户为同一个
+ if(uIdUser.getUserId().equals(oIdUser.getUserId())){
+ return new Result().ok(oIdUser);
+ }
+ this.combineUsers(oIdUser,uIdUser,formDTO.getUnionId());
+ //重新获取更新后的unionIdUser
+ uIdUser = this.baseDao.selectCachingUserInfoDTO(null, formDTO.getUnionId());
+ return new Result().ok(uIdUser);
+ }
+ //更新oIdUser的unionId
+ if(uIdUser == null && oIdUser != null){
+ UserEntity userEntity = new UserEntity();
+ userEntity.setId(oIdUser.getUserId());
+ userEntity.setWxUnionId(formDTO.getUnionId());
+ baseDao.updateById(userEntity);
+ return new Result().ok(oIdUser);
+ }
+ return new Result().ok(uIdUser);
+ }
+ /**
+ * @Description 合并用户
+ * @Author songyunpeng
+ * @Date 2021/4/8
+ * @Param [oIdUser, uIdUser]
+ * @return void
+ **/
+ private void combineUsers(CachingUserInfoDTO oIdUser, CachingUserInfoDTO uIdUser, String unionId) {
+
+ //判断以哪个用户为主
+ if(!"0".equals(oIdUser.getState())){
+ // 处理user表积分,删除小程序用户
+ updateUserInfo(uIdUser, oIdUser,unionId);
+ // 处理网格关系表
+ updateUerGridRelation(uIdUser,oIdUser );
+ // 处理积分日志
+ updatePointLogs(uIdUser,oIdUser );
+
+ }else {
+ // 处理user表积分,删除小程序用户
+ updateUserInfo(oIdUser, uIdUser,unionId);
+ // 处理网格关系表
+ updateUerGridRelation(oIdUser, uIdUser);
+ // 处理积分日志
+ updatePointLogs(oIdUser, uIdUser);
}
- return new Result().ok(cachingUserInfoDTO);
+
+
+
+ }
+ /**
+ * @Description 处理积分日志
+ * @Author songyunpeng
+ * @Date 2021/4/8
+ * @Param [oIdUser, uIdUser]
+ * @return void
+ **/
+ private void updatePointLogs(CachingUserInfoDTO ljUser, CachingUserInfoDTO mainUser) {
+ logger.info("处理积分日志");
+ // 把原有积分日志中的userid替换为新的userid,同时更新其中的用户信息
+ PointsLogsBindUnIdDTO pointsLogsBindAppDTO = new PointsLogsBindUnIdDTO();
+ UserDTO userDTO = ConvertUtils.sourceToTarget(mainUser, UserDTO.class);
+ pointsLogsBindAppDTO.setUserId(ljUser.getUserId());
+ pointsLogsBindAppDTO.setUser(userDTO);
+ pointsFeignClient.maBindUnIdLogs(pointsLogsBindAppDTO);
+ }
+
+ /**
+ * @Description 处理网格关系表
+ * @Author songyunpeng
+ * @Date 2021/4/8
+ * @Param [oIdUser, uIdUser]
+ * @return void
+ **/
+ private void updateUerGridRelation(CachingUserInfoDTO ljUser, CachingUserInfoDTO mainUser) {
+ logger.info("替换网格关系,替换者ID:"+mainUser.getUserId() + ",被替换者为:"+ljUser.getUserId());
+ // 把小程序用户的userID全部替换为UidUser的ID
+ userGridRelationService.maBindUnId(ljUser.getUserId(), mainUser.getUserId());
+ // 修改完成后查询重复的网格关系数据,把重复并且createTime比较新的数据删除
+ List repeatUser = userGridRelationService.selectRepeatRelation(mainUser.getUserId());
+ userGridRelationService.deleteBatchIds(repeatUser);
+ }
+
+ /**
+ * @Description 处理user表积分,删除小程序用户
+ * @Author songyunpeng
+ * @Date 2021/4/8
+ * @Param [oIdUser, uIdUser]
+ * @return void
+ **/
+ private void updateUserInfo(CachingUserInfoDTO ljUser, CachingUserInfoDTO mainUser, String unionId) {
+ logger.info("合并积分,删除重复用户操作");
+ // 求出两个账户的积分和
+ int oIdPoints = ljUser.getPoints() == null?0:ljUser.getPoints();
+ int uIdPoints = mainUser.getPoints() == null?0:mainUser.getPoints();
+ int oIdPointsTotle = ljUser.getPointsTotle() == null?0:ljUser.getPointsTotle();
+ int uIdPointsTotle = mainUser.getPointsTotle() == null?0:mainUser.getPointsTotle();
+ Integer pointSum = oIdPoints + uIdPoints;
+ Integer pointsTotleSum = oIdPointsTotle + uIdPointsTotle;
+
+ UserEntity updateUser = new UserEntity();
+ updateUser.setId(mainUser.getUserId());
+ updateUser.setPoints(pointSum);
+ updateUser.setPointsTotle(pointsTotleSum);
+ updateUser.setWxUnionId(unionId);
+ // 更新app账户的积分信息
+ baseDao.updateById(updateUser);
+
+ // 删除当前小程序用户
+ baseDao.deleteById(ljUser.getUserId());
}
@Override
@@ -1390,4 +1492,54 @@ public class UserServiceImpl extends BaseServiceImpl implem
public Result getUserGridIdByUserId(String userId) {
return new Result().ok(baseDao.getUserGridIdByUserId(userId));
}
+
+ @Override
+ public Result checkRepeatUser(CheckRepeatUserFormDTO checkRepeatUserFormDTO) {
+ String unionId = checkRepeatUserFormDTO.getUnionId();
+ String openId = checkRepeatUserFormDTO.getOpenId();
+ //根据unionId获取用户
+ QueryWrapper wrapper = new QueryWrapper<>();
+ wrapper.eq("UNION_ID", unionId);
+ UserEntity unionIdUserEntity = baseDao.selectOne(wrapper);
+ //根据openId获取用户
+ QueryWrapper wrapper2 = new QueryWrapper<>();
+ wrapper2.eq("OPEN_ID", openId);
+ UserEntity openIdUserEntity = baseDao.selectOne(wrapper2);
+ //代表两条用户记录
+ if(unionIdUserEntity!=null && openIdUserEntity!=null && !unionIdUserEntity.getId().equals(openIdUserEntity.getIdentityNo())){
+ CachingUserInfoDTO oIdUser = ConvertUtils.sourceToTarget(openIdUserEntity,CachingUserInfoDTO.class);
+ CachingUserInfoDTO uIdUser = ConvertUtils.sourceToTarget(unionIdUserEntity,CachingUserInfoDTO.class);
+ this.combineUsers(oIdUser,uIdUser,unionId);
+ return new Result().ok(unionIdUserEntity.getId());
+ }
+ return new Result().ok("");
+ }
+
+ @Override
+ public Result combineVolunteerUser(CombineVolunteerUserFormDTO formDTO) {
+ //根据手机号获取用户
+ QueryWrapper queryWrapper = new QueryWrapper();
+ queryWrapper.eq("MOBILE",formDTO.getMobile());
+ UserEntity mobileUser = baseDao.selectOne(queryWrapper);
+ //根据用户ID获取用户
+ UserEntity userIdUser = selectById(formDTO.getUserId());
+ if("0".equals(userIdUser.getState())){
+ CachingUserInfoDTO ljUser = ConvertUtils.sourceToTarget(userIdUser,CachingUserInfoDTO.class);
+ ljUser.setUserId(userIdUser.getId());
+ CachingUserInfoDTO mainUser = ConvertUtils.sourceToTarget(mobileUser,CachingUserInfoDTO.class);
+ mainUser.setUserId(mobileUser.getId());
+ //合并用户
+ // 处理user表积分,删除小程序用户
+ updateUserInfo(ljUser, mainUser,userIdUser.getWxUnionId());
+ // 处理网格关系表
+ updateUerGridRelation(ljUser,mainUser );
+ // 处理积分日志
+ updatePointLogs(ljUser,mainUser );
+ UserEntity userEntity = selectById(mobileUser.getId());
+ logger.info("合并志愿者用户信息完成,返回合并后的用户信息,ID:"+userEntity.getId());
+ UserDTO userDTO = ConvertUtils.sourceToTarget(userEntity,UserDTO.class);
+ return new Result().ok(userDTO);
+ }
+ return new Result<>();
+ }
}
diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/UserDao.xml b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/UserDao.xml
index 281ece22..4bccf4cf 100644
--- a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/UserDao.xml
+++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/UserDao.xml
@@ -460,6 +460,8 @@
+
+
@@ -511,6 +513,8 @@
eu.STATE,
eu.REMARK,
eu.PARTY_FLAG,
+ eu.POINTS,
+ eu.POINTS_TOTLE,
(select r.GRID_ID
from epdc_user_grid_relation r
where r.USER_ID=eu.ID
diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/UserGridRelationDao.xml b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/UserGridRelationDao.xml
index eed9ff01..100c296d 100644
--- a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/UserGridRelationDao.xml
+++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/UserGridRelationDao.xml
@@ -32,6 +32,9 @@
UPDATE epdc_user_grid_relation SET GRID = #{newDeptName}, UPDATED_TIME = NOW() WHERE GRID_ID = #{deptId}
+
+ UPDATE epdc_user_grid_relation SET USER_ID = #{unionUserId}, UPDATED_TIME = NOW() WHERE USER_ID = #{openUserId}
+
+