Browse Source

志愿者去哪儿小程序初次提交

feature/screenDataPush
songyunpeng 4 years ago
parent
commit
1c63d1909e
  1. 16
      esua-epdc/epdc-commons/epdc-commons-tools-wx-ma/src/main/java/com/elink/esua/epdc/utils/WxMaServiceUtils.java
  2. 5
      esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppSaveWxFormIdFormDTO.java
  3. 7
      esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppUserMaInfoFormDTO.java
  4. 7
      esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppUserMaTokenFormDTO.java
  5. 7
      esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppUserRegisterFormDTO.java
  6. 6
      esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppUserTokenFormDTO.java
  7. 6
      esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcCompleteUserInfoFormDTO.java
  8. 6
      esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/v2/EpdcCompleteUserInfoFormV2DTO.java
  9. 4
      esua-epdc/epdc-module/epdc-api/epdc-api-server/pom.xml
  10. 34
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/AppUserServiceImpl.java
  11. 7
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/resources/application.yml
  12. 15
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/PointsLogsController.java
  13. 9
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/dao/PointsLogsDao.java
  14. 10
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/PointsLogsService.java
  15. 7
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/impl/PointsLogsServiceImpl.java
  16. 8
      esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/PointsLogsDao.xml
  17. 11
      esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/CachingUserInfoDTO.java
  18. 46
      esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/PointsLogsBindUnIdDTO.java
  19. 6
      esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcUserRegistFormDTO.java
  20. 17
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/dao/UserGridRelationDao.java
  21. 32
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/feign/PointsFeignClient.java
  22. 21
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/feign/fallback/PointsFeignClientFallback.java
  23. 16
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/UserGridRelationService.java
  24. 12
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserGridRelationServiceImpl.java
  25. 115
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserServiceImpl.java
  26. 4
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/UserDao.xml
  27. 22
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/UserGridRelationDao.xml

16
esua-epdc/epdc-commons/epdc-commons-tools-wx-ma/src/main/java/com/elink/esua/epdc/utils/WxMaServiceUtils.java

@ -23,6 +23,9 @@ public class WxMaServiceUtils {
@Value("${wx.ma.appId.analysis}")
private String APPID_ANALYSIS;
@Value("${wx.ma.appId.volunteer}")
private String APPID_VOLUNTEER;
/**
* 获取党群e家 普通居民端配置
*
@ -60,4 +63,17 @@ public class WxMaServiceUtils {
final WxMaService wxMaService = WxMaConfig.getMaService(APPID_ANALYSIS);
return wxMaService;
}
/**
*
* 获取党群e家 数据分析端配置
*
* @params []
* @return cn.binarywang.wx.miniapp.api.WxMaService
* @author liuchuang
* @since 2021/4/8 10:44
*/
public final WxMaService volunteerWxMaService() {
final WxMaService wxMaService = WxMaConfig.getMaService(APPID_VOLUNTEER);
return wxMaService;
}
}

5
esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppSaveWxFormIdFormDTO.java

@ -19,4 +19,9 @@ public class EpdcAppSaveWxFormIdFormDTO implements Serializable {
@NotBlank(message = "wxFormId不能为空")
private String wxFormId;
/**
* 小程序类型
*/
private String type;
}

7
esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppUserMaInfoFormDTO.java

@ -33,4 +33,11 @@ public class EpdcAppUserMaInfoFormDTO implements Serializable {
*/
@NotBlank(message = "初始向量不能为空")
private String iv;
/**
* 小程序类型
*/
private String type;
}

7
esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppUserMaTokenFormDTO.java

@ -23,6 +23,13 @@ public class EpdcAppUserMaTokenFormDTO implements Serializable {
@NotBlank(message = "微信code不能为空")
private String wxCode;
/**
* 小程序类型
*/
private String type;
/*@NotBlank(message = "用户信息不能为空")
private String encryptedData;

7
esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppUserRegisterFormDTO.java

@ -33,4 +33,11 @@ public class EpdcAppUserRegisterFormDTO implements Serializable {
* 邀请人ID
*/
private String inviteUserId;
/**
* 小程序类型
*/
private String type;
}

6
esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppUserTokenFormDTO.java

@ -22,4 +22,10 @@ public class EpdcAppUserTokenFormDTO implements Serializable {
*/
@NotBlank(message = "微信code不能为空")
private String wxCode;
/**
* 小程序类型
*/
private String type;
}

6
esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcCompleteUserInfoFormDTO.java

@ -77,4 +77,10 @@ public class EpdcCompleteUserInfoFormDTO implements Serializable {
* 居住网格id
*/
private Long gridId;
/**
* 小程序类型
*/
private String type;
}

6
esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/v2/EpdcCompleteUserInfoFormV2DTO.java

@ -3,7 +3,6 @@ package com.elink.esua.epdc.dto.form.v2;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.io.Serializable;
/**
@ -99,4 +98,9 @@ public class EpdcCompleteUserInfoFormV2DTO implements Serializable {
* 自我介绍
*/
private String introduce;
/**
* 小程序类型
*/
private String type;
}

4
esua-epdc/epdc-module/epdc-api/epdc-api-server/pom.xml

@ -188,6 +188,10 @@
<!--数据分析端小程序-->
<analysis.wx.ma.appId>wx3ea0a6fb71ddf659</analysis.wx.ma.appId>
<analysis.wx.ma.secret>2154e86d56df9fae4224c93a17e01bb3</analysis.wx.ma.secret>
<!--志愿者去哪儿小程序-->
<volunteer.wx.ma.appId>wxc4fe0ea629aaa309</volunteer.wx.ma.appId>
<volunteer.wx.ma.secret>34fa86621c3c1dcebd39db333e746d88</volunteer.wx.ma.secret>
<!--RocketMQ-->
<rocketmq.name.server>47.104.85.99:9876;114.215.125.123:9876</rocketmq.name.server>
<rocketmq.consumer.group>jinshui-organizationGroup</rocketmq.consumer.group>

34
esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/AppUserServiceImpl.java

@ -124,12 +124,12 @@ public class AppUserServiceImpl implements AppUserService {
@Override
public Result<EpdcAppAuthorizationDTO> getMpToken(EpdcAppUserTokenFormDTO formDto) {
return this.getTokenByOpenId(this.getWxMaUser(formDto.getWxCode()));
return this.getTokenByOpenId(this.getWxMaUser(formDto.getWxCode(), formDto.getType()));
}
@Override
public Result<EpdcAppAuthorizationDTO> getMaToken(EpdcAppUserMaTokenFormDTO formDto) {
return this.getTokenByOpenId(this.getWxMaUser(formDto.getWxCode()));
return this.getTokenByOpenId(this.getWxMaUser(formDto.getWxCode(),formDto.getType()));
}
@Override
@ -144,7 +144,7 @@ public class AppUserServiceImpl implements AppUserService {
EpdcUserSaveWxFormIdFormDTO saveFormId = new EpdcUserSaveWxFormIdFormDTO();
saveFormId.setWxFormId(formDto.getWxFormId());
saveFormId.setWxOpenId(this.getWxMaUser(formDto.getWxCode()).getOpenid());
saveFormId.setWxOpenId(this.getWxMaUser(formDto.getWxCode(), formDto.getType()).getOpenid());
return this.userFeignClient.saveWxFormId(saveFormId);
}
@ -267,7 +267,7 @@ public class AppUserServiceImpl implements AppUserService {
this.verifyUserRegisterData(formDto);
WxMaJscode2SessionResult wxMaUser = this.getWxMaUser(formDto.getWxCode());
WxMaJscode2SessionResult wxMaUser = this.getWxMaUser(formDto.getWxCode(), formDto.getType());
UserDTO userDto = this.packageUserDto(formDto, null, wxMaUser);
// IP地址
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
@ -342,7 +342,7 @@ public class AppUserServiceImpl implements AppUserService {
*/
private EpdcGridLeaderRegisterDTO packageGridLeaderWhileRegister(SysUserDTO sysUser, String wxCode) {
WxMaJscode2SessionResult wxMaUser = this.getWxMaUser(wxCode);
WxMaJscode2SessionResult wxMaUser = this.getWxMaUser(wxCode, formDto.getType());
Date now = new Date();
String mobile = sysUser.getMobile();
@ -569,14 +569,19 @@ public class AppUserServiceImpl implements AppUserService {
* 解析微信code获取小程序用户信息
*
* @param wxCode
* @param type
* @return cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult
* @author work@yujt.net.cn
* @date 2019/9/19 19:32
*/
private WxMaJscode2SessionResult getWxMaUser(String wxCode) {
private WxMaJscode2SessionResult getWxMaUser(String wxCode, String type) {
WxMaJscode2SessionResult wxMaJscode2SessionResult = null;
try {
if(StringUtils.isNotBlank(type) && "volunteer".equals(type)){
wxMaJscode2SessionResult = wxMaServiceUtils.volunteerWxMaService().jsCode2SessionInfo(wxCode);
} else {
wxMaJscode2SessionResult = wxMaServiceUtils.normalWxMaService().jsCode2SessionInfo(wxCode);
}
} catch (WxErrorException e) {
log.error("->[getMaOpenId]::error[{}]", "解析微信code失败");
}
@ -680,7 +685,7 @@ public class AppUserServiceImpl implements AppUserService {
@Override
public Result<EpdcAppAuthorizationDTO> getMaV2Token(EpdcAppUserRegisterFormDTO formDto) {
WxMaJscode2SessionResult wxMaResult = this.getWxMaUser(formDto.getWxCode());
WxMaJscode2SessionResult wxMaResult = this.getWxMaUser(formDto.getWxCode(), formDto.getType());
String openId = wxMaResult.getOpenid();
String unionId = wxMaResult.getUnionid();
// if (null == formDto.getGridId()) {
@ -804,7 +809,7 @@ public class AppUserServiceImpl implements AppUserService {
userDto.setId(tokenDto.getUserId());
if (StringUtils.isNotBlank(infoDto.getWxCode())) {
String sessionKey = this.getUserSessionKey(infoDto.getWxCode());
String sessionKey = this.getUserSessionKey(infoDto.getWxCode(),infoDto.getType());
WxMaUserInfo wxMaUserInfo = wxMaServiceUtils.normalWxMaService().getUserService().getUserInfo(sessionKey, infoDto.getEncryptedData(), infoDto.getIv());
if (StringUtils.isBlank(wxMaUserInfo.getUnionId())) {
return new Result().error("解析微信开放平台ID失败");
@ -1008,7 +1013,7 @@ public class AppUserServiceImpl implements AppUserService {
if (null == userDetail || StringUtils.isEmpty(userDetail.getUserId())) {
return new Result().error("获取用户信息失败");
}
String sessionKey = this.getUserSessionKey(formDto.getWxCode());
String sessionKey = this.getUserSessionKey(formDto.getWxCode(), formDto.getType());
WxMaUserInfo wxMaUserInfo = wxMaServiceUtils.normalWxMaService().getUserService().getUserInfo(sessionKey, formDto.getEncryptedData(), formDto.getIv());
// 是否需要unionId,0 否 1 是
Object requireUnionid = redisUtils.get("epdc:unionid:require");
@ -1062,9 +1067,14 @@ public class AppUserServiceImpl implements AppUserService {
* @author liuchuang
* @since 2019/10/25 16:31
*/
private String getUserSessionKey(String code) {
private String getUserSessionKey(String code, String type) {
try {
WxMaJscode2SessionResult wxMaJscode2SessionResult = wxMaServiceUtils.normalWxMaService().jsCode2SessionInfo(code);
WxMaJscode2SessionResult wxMaJscode2SessionResult;
if(StringUtils.isNotBlank(type) && "volunteer".equals(type)){
wxMaJscode2SessionResult = wxMaServiceUtils.volunteerWxMaService().jsCode2SessionInfo(code);
} else {
wxMaJscode2SessionResult = wxMaServiceUtils.normalWxMaService().jsCode2SessionInfo(code);
}
if (wxMaJscode2SessionResult != null) {
return wxMaJscode2SessionResult.getSessionKey();
}
@ -1348,7 +1358,7 @@ public class AppUserServiceImpl implements AppUserService {
String encryptedData = infoDto.getEncryptedData();
if (StringUtils.isNotBlank(wxCode)) {
// 解析微信用户openid
WxMaJscode2SessionResult maJscode2SessionResult = getWxMaUser(wxCode);
WxMaJscode2SessionResult maJscode2SessionResult = getWxMaUser(wxCode, infoDto.getType());
userDto.setWxOpenId(maJscode2SessionResult.getOpenid());
// 解析微信用户加密数据
if (StringUtils.isNotBlank(iv) && StringUtils.isNotBlank(encryptedData)) {

7
esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/resources/application.yml

@ -119,6 +119,11 @@ wx:
token: #微信小程序消息服务器配置的token
aesKey: #微信小程序消息服务器配置的EncodingAESKey
msgDataFormat: JSON
- appid: @volunteer.wx.ma.appId@
secret: @volunteer.wx.ma.secret@
token: #微信小程序消息服务器配置的token
aesKey: #微信小程序消息服务器配置的EncodingAESKey
msgDataFormat: JSON
appId:
# 普通居民端的appId
normal: @wx.ma.appId@
@ -126,6 +131,8 @@ wx:
work: @work.wx.ma.appId@
# 数据分析端的appId
analysis: @analysis.wx.ma.appId@
# 志愿者去哪儿的appId
volunteer: @volunteer.wx.ma.appId@

15
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/PointsLogsController.java

@ -26,6 +26,7 @@ import com.elink.esua.epdc.commons.tools.validator.group.AddGroup;
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup;
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup;
import com.elink.esua.epdc.dto.EpdcAdjustUserPointsDTO;
import com.elink.esua.epdc.dto.PointsLogsBindUnIdDTO;
import com.elink.esua.epdc.dto.PointsLogsDTO;
import com.elink.esua.epdc.dto.UserPointResultDTO;
import com.elink.esua.epdc.dto.epdc.result.EpdcAdjustVolunteerPointsDTO;
@ -166,4 +167,18 @@ public class PointsLogsController {
}
/**
* 更新过时的积分记录
*
* @param formDto
* @return com.elink.esua.epdc.commons.tools.utils.Result
* @author zhy
* @date 2020/8/12 16:16
*/
@PostMapping("maBindUnIdLogs")
public Result maBindUnIdLogs(@RequestBody PointsLogsBindUnIdDTO formDto) {
ValidatorUtils.validateEntity(formDto);
return pointsLogsService.maBindUnIdLogs(formDto);
}
}

9
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/dao/PointsLogsDao.java

@ -24,6 +24,7 @@ import com.elink.esua.epdc.dto.form.*;
import com.elink.esua.epdc.dto.result.*;
import com.elink.esua.epdc.entity.PointsLogsEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@ -189,4 +190,12 @@ public interface PointsLogsDao extends BaseDao<PointsLogsEntity> {
* @since 2021/1/20 9:49
*/
Integer selectCountOfVerificationLogs(EpdcWorkVerificationLogsFormDTO formDto);
/**
* @Description 更新过时的积分记录
* @Author songyunpeng
* @Date 2021/4/8
* @Param [userId, id, faceImg]
* @return void
**/
void maBindUnIdLogs(@Param("oldUserId") String oldUserId, @Param("newUserId") String newUserId, @Param("faceImg") String faceImg);
}

10
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/PointsLogsService.java

@ -21,10 +21,10 @@ import com.elink.esua.epdc.commons.mybatis.service.BaseService;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.EpdcAdjustUserPointsDTO;
import com.elink.esua.epdc.dto.PointsLogsBindUnIdDTO;
import com.elink.esua.epdc.dto.PointsLogsDTO;
import com.elink.esua.epdc.dto.UserPointResultDTO;
import com.elink.esua.epdc.dto.epdc.result.EpdcAdjustVolunteerPointsDTO;
import com.elink.esua.epdc.dto.epdc.result.EpdcUserPointsVerificationResultDTO;
import com.elink.esua.epdc.dto.form.*;
import com.elink.esua.epdc.dto.result.*;
import com.elink.esua.epdc.entity.PointsLogsEntity;
@ -235,4 +235,12 @@ public interface PointsLogsService extends BaseService<PointsLogsEntity> {
* @since 2021/1/19 17:45
*/
EpdcVerificationLogsResultDTO listOfVerificationLogs(EpdcWorkVerificationLogsFormDTO formDto);
/**
* @Description 更新过时的积分记录
* @Author songyunpeng
* @Date 2021/4/8
* @Param [formDto]
* @return com.elink.esua.epdc.commons.tools.utils.Result
**/
Result maBindUnIdLogs(PointsLogsBindUnIdDTO formDto);
}

7
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/impl/PointsLogsServiceImpl.java

@ -39,7 +39,6 @@ import com.elink.esua.epdc.dto.constant.PointsNoticeConstant;
import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO;
import com.elink.esua.epdc.dto.epdc.form.EpdcUserPointsFormDTO;
import com.elink.esua.epdc.dto.epdc.result.EpdcAdjustVolunteerPointsDTO;
import com.elink.esua.epdc.dto.epdc.result.EpdcUserPointsVerificationResultDTO;
import com.elink.esua.epdc.dto.form.*;
import com.elink.esua.epdc.dto.result.*;
import com.elink.esua.epdc.entity.PointsLogsEntity;
@ -469,6 +468,12 @@ public class PointsLogsServiceImpl extends BaseServiceImpl<PointsLogsDao, Points
return data;
}
@Override
public Result maBindUnIdLogs(PointsLogsBindUnIdDTO formDto) {
baseDao.maBindUnIdLogs(formDto.getUserId(), formDto.getUser().getId(), formDto.getUser().getFaceImg());
return new Result();
}
/**
* 组装积分日志信息
*

8
esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/resources/mapper/PointsLogsDao.xml

@ -343,4 +343,12 @@
AND GRID_ID = #{deptId}
</if>
</select>
<update id="maBindUnIdLogs">
UPDATE epdc_points_logs
SET FACE_IMG = #{faceImg},
USER_ID = #{newUserId}
WHERE
id = #{oldUserId}
</update>
</mapper>

11
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;
}

46
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

6
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;
}

17
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<UserGridRelationEntity> {
* @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<java.lang.String>
**/
List<String> selectRepeatRelation(String userId);
}

32
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/feign/PointsFeignClient.java

@ -0,0 +1,32 @@
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 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 = NewsFeignClientFallback.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_UTF8_VALUE)
Result maBindUnIdLogs(@RequestBody PointsLogsBindUnIdDTO formDto);
}

21
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);
}
}

16
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<UserGridRelationEnt
* @return com.elink.esua.epdc.dto.UserGridRelationDTO
**/
UserGridRelationDTO getUserFirstScanGird(String userId);
/**
* @Description 把小程序用户的userID全部替换为UidUser的ID
* @Author songyunpeng
* @Date 2021/4/8
* @Param [userId, userId1]
* @return void
**/
void maBindUnId(String userId, String userId1);
/**
* @Description 查询重复的网格关系数据
* @Author songyunpeng
* @Date 2021/4/8
* @Param [userId]
* @return java.util.List<java.lang.String>
**/
List<String> selectRepeatRelation(String userId);
}

12
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<UserGridRelatio
return baseDao.getUserFirstScanGrid(userId);
}
@Override
public void maBindUnId(String openUserId,String unionUserId) {
baseDao.maBindUnId(openUserId,unionUserId);
}
@Override
public List<String> selectRepeatRelation(String userId) {
return baseDao.selectRepeatRelation(userId);
}
/**
*
* 组织机构信息处理

115
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/UserServiceImpl.java

@ -38,28 +38,19 @@ 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;
@ -100,6 +91,8 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
private PartyAuthenticationFailedDao partyAuthenticationFailedDao;
@Autowired
private UserTagRelationService userTagRelationService;
@Autowired
private PointsFeignClient pointsFeignClient;
@Override
public PageData<UserDTO> page(Map<String, Object> params) {
@ -1024,16 +1017,98 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> 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());
//接口匹配志愿者小程序 - start
CachingUserInfoDTO uIdUser = this.baseDao.selectCachingUserInfoDTO(null, formDTO.getUnionId());
CachingUserInfoDTO oIdUser = this.baseDao.selectCachingUserInfoDTO(formDTO.getOpenId(), null);
if(uIdUser != null && oIdUser == null){
return new Result<CachingUserInfoDTO>().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<CachingUserInfoDTO>().ok(oIdUser);
}
if (null == cachingUserInfoDTO) {
//根据openId查询
cachingUserInfoDTO = this.baseDao.selectCachingUserInfoDTO(formDTO.getOpenId(), null);
//合并用户
if(oIdUser != null && uIdUser != null){
//如果相同,则查出的用户为同一个
if(uIdUser.getUserId().equals(oIdUser.getUserId())){
return new Result<CachingUserInfoDTO>().ok(oIdUser);
}
return new Result<CachingUserInfoDTO>().ok(cachingUserInfoDTO);
this.combineUsers(oIdUser,uIdUser,formDTO.getOpenId());
}
return new Result<CachingUserInfoDTO>().ok(uIdUser);
}
/**
* @Description 合并用户
* @Author songyunpeng
* @Date 2021/4/8
* @Param [oIdUser, uIdUser]
* @return void
**/
private void combineUsers(CachingUserInfoDTO oIdUser, CachingUserInfoDTO uIdUser, String openId) {
// 处理user表积分,删除小程序用户
updateUserInfo(oIdUser, uIdUser,openId);
// 处理网格关系表
updateUerGridRelation(oIdUser, uIdUser);
// 处理积分日志
updatePointLogs(oIdUser, uIdUser);
}
/**
* @Description 处理积分日志
* @Author songyunpeng
* @Date 2021/4/8
* @Param [oIdUser, uIdUser]
* @return void
**/
private void updatePointLogs(CachingUserInfoDTO oIdUser, CachingUserInfoDTO uIdUser) {
// 把原有积分日志中的userid替换为新的userid,同时更新其中的用户信息
PointsLogsBindUnIdDTO pointsLogsBindAppDTO = new PointsLogsBindUnIdDTO();
UserDTO userDTO = ConvertUtils.sourceToTarget(uIdUser, UserDTO.class);
pointsLogsBindAppDTO.setUserId(oIdUser.getUserId());
pointsLogsBindAppDTO.setUser(userDTO);
pointsFeignClient.maBindUnIdLogs(pointsLogsBindAppDTO);
}
/**
* @Description 处理网格关系表
* @Author songyunpeng
* @Date 2021/4/8
* @Param [oIdUser, uIdUser]
* @return void
**/
private void updateUerGridRelation(CachingUserInfoDTO oIdUser, CachingUserInfoDTO uIdUser) {
// 把小程序用户的userID全部替换为UidUser的ID
userGridRelationService.maBindUnId(oIdUser.getUserId(), uIdUser.getUserId());
// 修改完成后查询重复的网格关系数据,把重复并且createTime比较新的数据删除
List<String> repeatUser = userGridRelationService.selectRepeatRelation(uIdUser.getUserId());
userGridRelationService.deleteBatchIds(repeatUser);
}
/**
* @Description 处理user表积分删除小程序用户
* @Author songyunpeng
* @Date 2021/4/8
* @Param [oIdUser, uIdUser]
* @return void
**/
private void updateUserInfo(CachingUserInfoDTO oIdUser, CachingUserInfoDTO uIdUser, String openId) {
// 求出两个账户的积分和
Integer pointSum = oIdUser.getPoints() + uIdUser.getPoints();
Integer pointsTotleSum = oIdUser.getPointsTotle() + uIdUser.getPointsTotle();
UserEntity updateUser = new UserEntity();
updateUser.setId(uIdUser.getUserId());
updateUser.setPoints(pointSum);
updateUser.setPointsTotle(pointsTotleSum);
updateUser.setWxOpenId(openId);
// 更新app账户的积分信息
baseDao.updateById(updateUser);
// 删除当前小程序用户
baseDao.deleteById(oIdUser.getUserId());
}
@Override

4
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/UserDao.xml

@ -460,6 +460,8 @@
<result property="remark" column="REMARK"/>
<result property="gridId" column="gridId"/>
<result property="grid" column="grid"/>
<result property="pointsTotle" column="POINTS_TOTLE"/>
<result property="points" column="POINTS"/>
<collection property="userTagInfos" select="com.elink.esua.epdc.dao.UserTagDao.selectByUserId"
column="id">
</collection>
@ -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

22
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/UserGridRelationDao.xml

@ -32,6 +32,9 @@
<update id="updateGridByDeptId">
UPDATE epdc_user_grid_relation SET GRID = #{newDeptName}, UPDATED_TIME = NOW() WHERE GRID_ID = #{deptId}
</update>
<update id="maBindUnId">
UPDATE epdc_user_grid_relation SET USER_ID = #{unionUserId}, UPDATED_TIME = NOW() WHERE USER_ID = #{openUserId}
</update>
<select id="selectListUserIdByDeptId" resultType="String">
SELECT
@ -60,6 +63,25 @@
CREATED_TIME
LIMIT 1
</select>
<select id="selectRepeatRelation" resultType="java.lang.String">
SELECT
t.ID
FROM
(
SELECT
ID,GRID_ID,USER_ID
FROM
epdc_user_grid_relation
WHERE
USER_ID = #{userId}
ORDER BY
CREATED_TIME DESC
) t
GROUP BY
t.GRID_ID
HAVING
COUNT(t.USER_ID) > 1
</select>
</mapper>

Loading…
Cancel
Save