| | |
| | | @Service |
| | | public class UserInfoModifyRecordServiceImpl implements UserInfoModifyRecordService { |
| | | |
| | | @Resource |
| | | private UserInfoModifyRecordMapper userInfoModifyRecordMapper; |
| | | @Resource |
| | | private UserInfoModifyRecordMapper userInfoModifyRecordMapper; |
| | | |
| | | @Resource |
| | | private IntegralGetService integralGetService; |
| | | @Resource |
| | | private IntegralGetService integralGetService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private UserInfoExtraService userInfoExtraService; |
| | | @Resource |
| | | private UserInfoExtraService userInfoExtraService; |
| | | |
| | | @Resource |
| | | private BindingAccountService bindingAccountService; |
| | | @Resource |
| | | private BindingAccountService bindingAccountService; |
| | | |
| | | @Resource |
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; |
| | | @Resource |
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; |
| | | |
| | | @Resource |
| | | private RocketMQManager rocketMQManager; |
| | | @Resource |
| | | private RocketMQManager rocketMQManager; |
| | | |
| | | @Async() |
| | | @Transactional |
| | | @Override |
| | | public void addModifyRecord(Long uid, ModifyTypeEnum type, String value) { |
| | | try { |
| | | if (uid == null || StringUtil.isNullOrEmpty(value)) |
| | | return; |
| | | @Async() |
| | | @Transactional |
| | | @Override |
| | | public void addModifyRecord(Long uid, ModifyTypeEnum type, String value) { |
| | | try { |
| | | if (uid == null || StringUtil.isNullOrEmpty(value)) |
| | | return; |
| | | |
| | | long count = countByUid(uid, type.name()); |
| | | if (count == 0) { |
| | | if (type == ModifyTypeEnum.bindPhone) { |
| | | integralGetService.addBindPhone(uid); |
| | | } else if (type == ModifyTypeEnum.bindAlipay) { |
| | | integralGetService.addBindAlipay(uid); |
| | | } else if (type == ModifyTypeEnum.bindTaoBao) { |
| | | integralGetService.addBindTaoBao(uid); |
| | | } else if (type == ModifyTypeEnum.bindWeiXin) { |
| | | integralGetService.addBindWeiXin(uid); |
| | | } else if (type == ModifyTypeEnum.gender) { |
| | | integralGetService.addSetGender(uid); |
| | | } else if (type == ModifyTypeEnum.nickName) { |
| | | integralGetService.addSetNickname(uid); |
| | | } else if (type == ModifyTypeEnum.portrait) { |
| | | integralGetService.addSetPortrait(uid); |
| | | } else if (type == ModifyTypeEnum.setWeiXinNum) { |
| | | integralGetService.addSetWeiXinNum(uid); |
| | | } |
| | | } |
| | | long count = countByUid(uid, type.name()); |
| | | if (count == 0) { |
| | | if (type == ModifyTypeEnum.bindPhone) { |
| | | integralGetService.addBindPhone(uid); |
| | | } else if (type == ModifyTypeEnum.bindAlipay) { |
| | | integralGetService.addBindAlipay(uid); |
| | | } else if (type == ModifyTypeEnum.bindTaoBao) { |
| | | integralGetService.addBindTaoBao(uid); |
| | | } else if (type == ModifyTypeEnum.bindWeiXin) { |
| | | integralGetService.addBindWeiXin(uid); |
| | | } else if (type == ModifyTypeEnum.gender) { |
| | | integralGetService.addSetGender(uid); |
| | | } else if (type == ModifyTypeEnum.nickName) { |
| | | integralGetService.addSetNickname(uid); |
| | | } else if (type == ModifyTypeEnum.portrait) { |
| | | integralGetService.addSetPortrait(uid); |
| | | } else if (type == ModifyTypeEnum.setWeiXinNum) { |
| | | integralGetService.addSetWeiXinNum(uid); |
| | | } |
| | | } |
| | | |
| | | UserInfoModifyRecord oldRecord = userInfoModifyRecordMapper.selectLatestByUidAndType(uid, type.name()); |
| | | if (oldRecord == null || !oldRecord.getValue().equalsIgnoreCase(value)) {// 不能修改重复的数据 |
| | | UserInfoModifyRecord record = new UserInfoModifyRecord(); |
| | | record.setUid(uid); |
| | | record.setType(type); |
| | | record.setValue(value); |
| | | record.setCreateTime(new Date()); |
| | | userInfoModifyRecordMapper.insertSelective(record); |
| | | UserInfoModifyRecord oldRecord = userInfoModifyRecordMapper.selectLatestByUidAndType(uid, type.name()); |
| | | if (oldRecord == null || !oldRecord.getValue().equalsIgnoreCase(value)) {// 不能修改重复的数据 |
| | | UserInfoModifyRecord record = new UserInfoModifyRecord(); |
| | | record.setUid(uid); |
| | | record.setType(type); |
| | | record.setValue(value); |
| | | record.setCreateTime(new Date()); |
| | | userInfoModifyRecordMapper.insertSelective(record); |
| | | |
| | | if (oldRecord == null) {// 新建 |
| | | // 发送账号修改消息 |
| | | UserAccountBindingMQMsg mqMsg = null; |
| | | if (type == ModifyTypeEnum.bindPhone) { |
| | | mqMsg = new UserAccountBindingMQMsg(uid, UserAccountBindingMQMsg.TYPE_PHONE, value, new Date()); |
| | | } else if (type == ModifyTypeEnum.bindTaoBao) { |
| | | mqMsg = new UserAccountBindingMQMsg(uid, UserAccountBindingMQMsg.TYPE_TAOBAO, value, |
| | | new Date()); |
| | | } else if (type == ModifyTypeEnum.bindWeiXin) { |
| | | mqMsg = new UserAccountBindingMQMsg(uid, UserAccountBindingMQMsg.TYPE_WX, value, new Date()); |
| | | } else if (type == ModifyTypeEnum.bindAlipay) { |
| | | mqMsg = new UserAccountBindingMQMsg(uid, UserAccountBindingMQMsg.TYPE_ALIPAY, value, |
| | | new Date()); |
| | | } |
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, |
| | | UserTopicTagEnum.userAccountBinding, mqMsg); |
| | | if (!Constant.IS_TEST) |
| | | rocketMQManager.sendNormalMsg(message, null); |
| | | } else {// 修改 |
| | | UserInfoUpdateMQMsg mqMsg = null; |
| | | if (oldRecord == null) {// 新建 |
| | | // 发送账号修改消息 |
| | | UserAccountBindingMQMsg mqMsg = null; |
| | | if (type == ModifyTypeEnum.bindPhone) { |
| | | mqMsg = new UserAccountBindingMQMsg(uid, UserAccountBindingMQMsg.TYPE_PHONE, value, new Date()); |
| | | } else if (type == ModifyTypeEnum.bindTaoBao) { |
| | | mqMsg = new UserAccountBindingMQMsg(uid, UserAccountBindingMQMsg.TYPE_TAOBAO, value, |
| | | new Date()); |
| | | } else if (type == ModifyTypeEnum.bindWeiXin) { |
| | | mqMsg = new UserAccountBindingMQMsg(uid, UserAccountBindingMQMsg.TYPE_WX, value, new Date()); |
| | | } else if (type == ModifyTypeEnum.bindAlipay) { |
| | | mqMsg = new UserAccountBindingMQMsg(uid, UserAccountBindingMQMsg.TYPE_ALIPAY, value, |
| | | new Date()); |
| | | } |
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, |
| | | UserTopicTagEnum.userAccountBinding, mqMsg); |
| | | if (!Constant.IS_TEST) |
| | | rocketMQManager.sendNormalMsg(message, null); |
| | | } else {// 修改 |
| | | UserInfoUpdateMQMsg mqMsg = null; |
| | | |
| | | if (type == ModifyTypeEnum.portrait) { |
| | | mqMsg = new UserInfoUpdateMQMsg(uid, UserInfoUpdateTypeEnum.portrait, value, new Date()); |
| | | } else if (type == ModifyTypeEnum.nickName) |
| | | mqMsg = new UserInfoUpdateMQMsg(uid, UserInfoUpdateTypeEnum.nickName, value, new Date()); |
| | | else if (type == ModifyTypeEnum.setWeiXinNum) |
| | | mqMsg = new UserInfoUpdateMQMsg(uid, UserInfoUpdateTypeEnum.wxId, value, new Date()); |
| | | if (type == ModifyTypeEnum.portrait) { |
| | | mqMsg = new UserInfoUpdateMQMsg(uid, UserInfoUpdateTypeEnum.portrait, value, new Date()); |
| | | } else if (type == ModifyTypeEnum.nickName) |
| | | mqMsg = new UserInfoUpdateMQMsg(uid, UserInfoUpdateTypeEnum.nickName, value, new Date()); |
| | | else if (type == ModifyTypeEnum.setWeiXinNum) |
| | | mqMsg = new UserInfoUpdateMQMsg(uid, UserInfoUpdateTypeEnum.wxId, value, new Date()); |
| | | |
| | | if (mqMsg != null) { |
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, |
| | | UserTopicTagEnum.userInfoUpdate, mqMsg); |
| | | rocketMQManager.sendNormalMsg(message, null); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | } |
| | | if (mqMsg != null) { |
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, |
| | | UserTopicTagEnum.userInfoUpdate, mqMsg); |
| | | rocketMQManager.sendNormalMsg(message, null); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public long countByUid(Long uid, String type) { |
| | | return userInfoModifyRecordMapper.countByUid(uid, type); |
| | | } |
| | | @Override |
| | | public long countByUid(Long uid, String type) { |
| | | return userInfoModifyRecordMapper.countByUid(uid, type); |
| | | } |
| | | |
| | | @Override |
| | | public void syncBeforeInfo(Long uid) { |
| | | // 获取用户基本信息 |
| | | UserInfo user = userInfoService.selectByPKey(uid); |
| | | if (user == null || user.getState() != UserInfo.STATE_NORMAL) {// 用户不正常 |
| | | return; |
| | | } |
| | | if (!StringUtil.isNullOrEmpty(user.getPhone())) { |
| | | addModifyRecord(uid, ModifyTypeEnum.bindPhone, user.getPhone()); |
| | | } |
| | | @Override |
| | | public void syncBeforeInfo(Long uid) { |
| | | // 获取用户基本信息 |
| | | UserInfo user = userInfoService.selectByPKey(uid); |
| | | if (user == null || user.getState() != UserInfo.STATE_NORMAL) {// 用户不正常 |
| | | return; |
| | | } |
| | | if (!StringUtil.isNullOrEmpty(user.getPhone())) { |
| | | addModifyRecord(uid, ModifyTypeEnum.bindPhone, user.getPhone()); |
| | | } |
| | | |
| | | BindingAccount account = bindingAccountService.getBindingAccountByUidAndType(uid, BindingAccount.TYPE_ALIPAY); |
| | | if (account != null) { |
| | | addModifyRecord(uid, ModifyTypeEnum.bindAlipay, account.getAccount()); |
| | | } |
| | | BindingAccount account = bindingAccountService.getBindingAccountByUidAndType(uid, BindingAccount.TYPE_ALIPAY); |
| | | if (account != null) { |
| | | addModifyRecord(uid, ModifyTypeEnum.bindAlipay, account.getAccount()); |
| | | } |
| | | |
| | | if (!StringUtil.isNullOrEmpty(user.getWxUnionId())) { |
| | | addModifyRecord(uid, ModifyTypeEnum.bindWeiXin, user.getWxUnionId()); |
| | | } |
| | | if (!StringUtil.isNullOrEmpty(user.getWxUnionId())) { |
| | | addModifyRecord(uid, ModifyTypeEnum.bindWeiXin, user.getWxUnionId()); |
| | | } |
| | | |
| | | if (user.getNickName() != null && !user.getNickName().startsWith("返利券") |
| | | && !user.getNickName().startsWith(Constant.systemCommonConfig.getDefaultNickName())) { |
| | | addModifyRecord(uid, ModifyTypeEnum.nickName, user.getNickName() + ""); |
| | | } |
| | | String defaultNickName = userInfoService.getDefaultNickName(user.getSystem(), uid); |
| | | |
| | | if (!Constant.systemCommonConfig.getDefaultPortrait().equalsIgnoreCase(user.getPortrait())) { |
| | | addModifyRecord(uid, ModifyTypeEnum.portrait, user.getPortrait()); |
| | | } |
| | | if (user.getNickName() != null && !user.getNickName().startsWith("返利券") |
| | | && !user.getNickName().startsWith(defaultNickName)) { |
| | | addModifyRecord(uid, ModifyTypeEnum.nickName, user.getNickName() + ""); |
| | | } |
| | | |
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); |
| | | if (userInfoExtra != null) { |
| | | if (userInfoExtra.getSex() != null) |
| | | addModifyRecord(uid, ModifyTypeEnum.gender, userInfoExtra.getSex() + ""); |
| | | String defaultPortrait = userInfoService.getDefaultPortrait(user.getSystem()); |
| | | if (!defaultPortrait.equalsIgnoreCase(user.getPortrait())) { |
| | | addModifyRecord(uid, ModifyTypeEnum.portrait, user.getPortrait()); |
| | | } |
| | | |
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin())) |
| | | addModifyRecord(uid, ModifyTypeEnum.setWeiXinNum, userInfoExtra.getWeiXin()); |
| | | } |
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); |
| | | if (userInfoExtra != null) { |
| | | if (userInfoExtra.getSex() != null) |
| | | addModifyRecord(uid, ModifyTypeEnum.gender, userInfoExtra.getSex() + ""); |
| | | |
| | | UserExtraTaoBaoInfo taoBaoExtra = userExtraTaoBaoInfoService.getByUid(uid); |
| | | if (taoBaoExtra != null && !StringUtil.isNullOrEmpty(taoBaoExtra.getRelationId()) |
| | | && !StringUtil.isNullOrEmpty(taoBaoExtra.getSpecialId()) && taoBaoExtra.getRelationValid() |
| | | && taoBaoExtra.getSpecialValid()) { |
| | | addModifyRecord(uid, ModifyTypeEnum.bindTaoBao, taoBaoExtra.getTaoBaoUid()); |
| | | } |
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin())) |
| | | addModifyRecord(uid, ModifyTypeEnum.setWeiXinNum, userInfoExtra.getWeiXin()); |
| | | } |
| | | |
| | | } |
| | | UserExtraTaoBaoInfo taoBaoExtra = userExtraTaoBaoInfoService.getByUid(uid); |
| | | if (taoBaoExtra != null && !StringUtil.isNullOrEmpty(taoBaoExtra.getRelationId()) |
| | | && !StringUtil.isNullOrEmpty(taoBaoExtra.getSpecialId()) && taoBaoExtra.getRelationValid() |
| | | && taoBaoExtra.getSpecialValid()) { |
| | | addModifyRecord(uid, ModifyTypeEnum.bindTaoBao, taoBaoExtra.getTaoBaoUid()); |
| | | } |
| | | |
| | | } |
| | | } |