diff --git a/esua-epdc/epdc-commons/epdc-commons-tools-wx-ma/src/main/java/com/elink/esua/epdc/utils/WxMaServiceUtils.java b/esua-epdc/epdc-commons/epdc-commons-tools-wx-ma/src/main/java/com/elink/esua/epdc/utils/WxMaServiceUtils.java index a58ef3ed..ab8fb551 100644 --- a/esua-epdc/epdc-commons/epdc-commons-tools-wx-ma/src/main/java/com/elink/esua/epdc/utils/WxMaServiceUtils.java +++ b/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; + } } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppSaveWxFormIdFormDTO.java b/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppSaveWxFormIdFormDTO.java index 1e7c5af6..af25b6d8 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppSaveWxFormIdFormDTO.java +++ b/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; } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppUserMaInfoFormDTO.java b/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppUserMaInfoFormDTO.java index 47ecf25c..33ca79d0 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppUserMaInfoFormDTO.java +++ b/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; + + } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppUserMaTokenFormDTO.java b/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppUserMaTokenFormDTO.java index 901255fd..ef4e9d7a 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppUserMaTokenFormDTO.java +++ b/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; diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppUserRegisterFormDTO.java b/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppUserRegisterFormDTO.java index 937dcd47..dc9e225f 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppUserRegisterFormDTO.java +++ b/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; + + } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppUserTokenFormDTO.java b/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppUserTokenFormDTO.java index a486ccb0..1021158e 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcAppUserTokenFormDTO.java +++ b/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; } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcCompleteUserInfoFormDTO.java b/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcCompleteUserInfoFormDTO.java index ca49d2f3..8a4ea7ff 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/EpdcCompleteUserInfoFormDTO.java +++ b/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; } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/v2/EpdcCompleteUserInfoFormV2DTO.java b/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/v2/EpdcCompleteUserInfoFormV2DTO.java index 149c47af..e70b5d53 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/form/v2/EpdcCompleteUserInfoFormV2DTO.java +++ b/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; } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/pom.xml b/esua-epdc/epdc-module/epdc-api/epdc-api-server/pom.xml index 9a5a2b8d..7b9a50c1 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/pom.xml +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/pom.xml @@ -188,6 +188,10 @@ wx3ea0a6fb71ddf659 2154e86d56df9fae4224c93a17e01bb3 + + + wxc4fe0ea629aaa309 + 34fa86621c3c1dcebd39db333e746d88 47.104.85.99:9876;114.215.125.123:9876 jinshui-organizationGroup diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/AppUserServiceImpl.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/AppUserServiceImpl.java index d86d1ab1..b0f3bd34 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/AppUserServiceImpl.java +++ b/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 getMpToken(EpdcAppUserTokenFormDTO formDto) { - return this.getTokenByOpenId(this.getWxMaUser(formDto.getWxCode())); + return this.getTokenByOpenId(this.getWxMaUser(formDto.getWxCode(), formDto.getType())); } @Override public Result 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 { - wxMaJscode2SessionResult = wxMaServiceUtils.normalWxMaService().jsCode2SessionInfo(wxCode); + 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 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)) { diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/resources/application.yml b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/resources/application.yml index e10bf7f1..4c60fcdc 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/resources/application.yml +++ b/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@ diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/PointsLogsController.java b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/PointsLogsController.java index 248ee2fe..dda59d3b 100755 --- a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/controller/PointsLogsController.java +++ b/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); + } + } diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/dao/PointsLogsDao.java b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/dao/PointsLogsDao.java index 4eac7167..19ed3d63 100755 --- a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/dao/PointsLogsDao.java +++ b/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 { * @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); } diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/PointsLogsService.java b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/PointsLogsService.java index 7cd4c617..8e6e4b20 100755 --- a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/PointsLogsService.java +++ b/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 { * @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); } diff --git a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/impl/PointsLogsServiceImpl.java b/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/impl/PointsLogsServiceImpl.java index a428d9fe..87fc6deb 100755 --- a/esua-epdc/epdc-module/epdc-points/epdc-points-server/src/main/java/com/elink/esua/epdc/service/impl/PointsLogsServiceImpl.java +++ b/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 + + + 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/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/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..fecae047 --- /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,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); + +} 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/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..72c7689a 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,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 implem private PartyAuthenticationFailedDao partyAuthenticationFailedDao; @Autowired private UserTagRelationService userTagRelationService; + @Autowired + private PointsFeignClient pointsFeignClient; @Override public PageData page(Map params) { @@ -1024,16 +1017,98 @@ 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){ + 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); + } + //合并用户 + if(oIdUser != null && uIdUser != null){ + //如果相同,则查出的用户为同一个 + if(uIdUser.getUserId().equals(oIdUser.getUserId())){ + return new Result().ok(oIdUser); + } + this.combineUsers(oIdUser,uIdUser,formDTO.getOpenId()); } - return new Result().ok(cachingUserInfoDTO); + 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 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 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 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} + +