| | |
| | | package com.yeshi.fanli.service.impl.user;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.scheduling.annotation.Async;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.user.UserInfoModifyRecordMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.BindingAccount;
|
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoModifyRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoModifyRecord.ModifyTypeEnum;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralGetService;
|
| | | import com.yeshi.fanli.service.inter.money.extract.BindingAccountService;
|
| | | import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoModifyRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Service
|
| | | public class UserInfoModifyRecordServiceImpl implements UserInfoModifyRecordService {
|
| | |
|
| | | @Resource
|
| | | private UserInfoModifyRecordMapper userInfoModifyRecordMapper;
|
| | |
|
| | | @Resource
|
| | | private IntegralGetService integralGetService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | |
|
| | | @Resource
|
| | | private BindingAccountService bindingAccountService;
|
| | |
|
| | | @Resource
|
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
|
| | |
|
| | | @Async()
|
| | | @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);
|
| | | }
|
| | | }
|
| | |
|
| | | 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);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | @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());
|
| | | }
|
| | |
|
| | | 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 (user.getNickName() != null && !user.getNickName().startsWith("返利券")) {
|
| | | addModifyRecord(uid, ModifyTypeEnum.nickName, user.getNickName() + "");
|
| | | }
|
| | |
|
| | | if (!Constant.systemCommonConfig.getDefaultPortrait().equalsIgnoreCase(user.getPortrait())) {
|
| | | addModifyRecord(uid, ModifyTypeEnum.portrait, user.getPortrait());
|
| | | }
|
| | |
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra != null) {
|
| | | if (userInfoExtra.getSex() != null)
|
| | | addModifyRecord(uid, ModifyTypeEnum.gender, userInfoExtra.getSex() + "");
|
| | |
|
| | | 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());
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | | package com.yeshi.fanli.service.impl.user; |
| | | |
| | | import java.util.Date; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import com.aliyun.openservices.ons.api.Message; |
| | | import com.aliyun.openservices.ons.api.Producer; |
| | | import com.google.gson.Gson; |
| | | import com.yeshi.fanli.dao.mybatis.user.UserInfoModifyRecordMapper; |
| | | import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum; |
| | | import com.yeshi.fanli.dto.mq.user.body.UserAccountBindingMQMsg; |
| | | import com.yeshi.fanli.dto.mq.user.body.UserInfoUpdateMQMsg; |
| | | import com.yeshi.fanli.dto.mq.user.body.UserInfoUpdateMQMsg.UserInfoUpdateTypeEnum; |
| | | import com.yeshi.fanli.entity.bus.user.BindingAccount; |
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo; |
| | | import com.yeshi.fanli.entity.bus.user.UserInfo; |
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra; |
| | | import com.yeshi.fanli.entity.bus.user.UserInfoModifyRecord; |
| | | import com.yeshi.fanli.entity.bus.user.UserInfoModifyRecord.ModifyTypeEnum; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.money.extract.BindingAccountService; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoModifyRecordService; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoService; |
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralGetService; |
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService; |
| | | import com.yeshi.fanli.service.manger.msg.RocketMQManager; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory; |
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName; |
| | | |
| | | @Service |
| | | public class UserInfoModifyRecordServiceImpl implements UserInfoModifyRecordService { |
| | | |
| | | @Resource |
| | | private UserInfoModifyRecordMapper userInfoModifyRecordMapper; |
| | | |
| | | @Resource |
| | | private IntegralGetService integralGetService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private UserInfoExtraService userInfoExtraService; |
| | | |
| | | @Resource |
| | | private BindingAccountService bindingAccountService; |
| | | |
| | | @Resource |
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; |
| | | |
| | | @Resource |
| | | private RocketMQManager rocketMQManager; |
| | | |
| | | @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); |
| | | } |
| | | } |
| | | |
| | | 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 (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); |
| | | } |
| | | } |
| | | |
| | | @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()); |
| | | } |
| | | |
| | | 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()); |
| | | } |
| | | |
| | | String defaultNickName = userInfoService.getDefaultNickName(user.getSystem(), uid); |
| | | |
| | | if (user.getNickName() != null && !user.getNickName().startsWith("返利券") |
| | | && !user.getNickName().startsWith(defaultNickName)) { |
| | | addModifyRecord(uid, ModifyTypeEnum.nickName, user.getNickName() + ""); |
| | | } |
| | | |
| | | String defaultPortrait = userInfoService.getDefaultPortrait(user.getSystem()); |
| | | if (!defaultPortrait.equalsIgnoreCase(user.getPortrait())) { |
| | | addModifyRecord(uid, ModifyTypeEnum.portrait, user.getPortrait()); |
| | | } |
| | | |
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); |
| | | if (userInfoExtra != null) { |
| | | if (userInfoExtra.getSex() != null) |
| | | addModifyRecord(uid, ModifyTypeEnum.gender, userInfoExtra.getSex() + ""); |
| | | |
| | | 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()); |
| | | } |
| | | |
| | | } |
| | | } |