| | |
| | | import com.hx.guide.model.VLatelyLog; |
| | | import com.hx.guide.model.VisitOrder; |
| | | import com.hx.guide.model.VisitRecord; |
| | | import com.hx.mybatis.aes.springbean.ConstantBean; |
| | | import com.hx.mybatisTool.SqlSentence; |
| | | import com.hx.phiappt.common.OperationReasonConstants; |
| | | import com.hx.phiappt.dto.MerUserFileDto; |
| | | import com.hx.phiappt.model.*; |
| | | import com.hx.phiappt.model.aliyun.call.AliyunSecretCallRecord; |
| | | import com.hx.phiappt.model.appearancePlan.AppearanceTotal; |
| | |
| | | import com.hx.phiappt.model.user.*; |
| | | import com.hx.phiappt.model.userMoney.UserMoneyUnclaimed; |
| | | import com.hx.phiappt.model.wechat.gzh.GzhMsg; |
| | | import com.hx.phiappt.util.MerUserFileUtil; |
| | | import com.hx.phip.config.CustomParameter; |
| | | import com.hx.phip.dao.mapper.*; |
| | | import com.hx.phip.dto.user.UserMergeConsumeDto; |
| | |
| | | @Resource |
| | | private ConsultationNeededProjectMapper consultationNeededProjectMapper; |
| | | @Resource |
| | | private ConsultationTreatProjectMapper consultationTreatProjectMapper; |
| | | @Resource |
| | | private VGuideLogMapper vGuideLogMapper; |
| | | @Resource |
| | | private UserStatisticsMapper userStatisticsMapper; |
| | |
| | | private KoapOrderTotalMapper koapOrderTotalMapper; |
| | | @Resource |
| | | private UserMoneyLogMapper userMoneyLogMapper; |
| | | @Resource |
| | | private ConstantBean constantBean; |
| | | @Resource |
| | | private UserMergeCommonMapper userMergeCommonMapper; |
| | | |
| | | /** |
| | | * 合并账号 |
| | |
| | | //处理消费摘要 |
| | | timeConsumeHandler(user, delUser, userMergeLog, sqlSentence, sqlMap); |
| | | |
| | | //处理含注解的 |
| | | annotationHandler(user,delUser,userMergeLog, sqlSentence, sqlMap); |
| | | |
| | | |
| | | //修改状态 |
| | | otherService.logStatusUpdate(userMergeLog.getId(),1); |
| | | logger.info("------------------------------------结束处理账号合并-------------------------------------"); |
| | | } |
| | | |
| | | /** |
| | | * 处理含注解的表 |
| | | * */ |
| | | private void annotationHandler(User user, User delUser, UserMergeLog userMergeLog, SqlSentence sqlSentence, Map<String, Object> sqlMap) { |
| | | logger.info("<-扫描含注解的表合并开始->"); |
| | | List<MerUserFileDto> merUserFileUtilList = null; |
| | | try { |
| | | merUserFileUtilList = MerUserFileUtil.getMerUserFileUtilList(constantBean); |
| | | }catch (Exception e){ |
| | | logger.error("合并账号扫描含注解的表错误,保留{},作废{}"+user.getId(),delUser.getId()); |
| | | } |
| | | if (merUserFileUtilList == null || merUserFileUtilList.size() < 1){ |
| | | logger.info("<-扫描含注解的表无所属,结束->"); |
| | | return; |
| | | } |
| | | StringBuilder sql = new StringBuilder(); |
| | | List<Map<String, Object>> delUserDataList = null; |
| | | UserMergeLogItem dUserLog = null; |
| | | for (MerUserFileDto merUserFileDto : merUserFileUtilList) { |
| | | logger.info("扫描注解处理,表{},字段{}",merUserFileDto.getTableName(),merUserFileDto.getFileName()); |
| | | //获取旧用户数据 |
| | | if (sql.length() > 0){ |
| | | sql.delete(0,sql.length()); |
| | | } |
| | | sql.append(" SELECT * FROM ").append(merUserFileDto.getTableName()).append(" WHERE isDel = #{m.isDel} "); |
| | | sql.append(" AND ").append(merUserFileDto.getFileName()).append(" = #{m.delUserId} "); |
| | | sqlSentence.sqlSentence(sql.toString(), sqlMap); |
| | | delUserDataList = userMergeCommonMapper.selectListMap(sqlSentence); |
| | | if (delUserDataList == null || delUserDataList.size() < 1){ |
| | | continue; |
| | | } |
| | | |
| | | int sortNum = 0; |
| | | dUserLog = new UserMergeLogItem(); |
| | | dUserLog.setMergeLogId(userMergeLog.getId()); |
| | | dUserLog.setMergeLogNo(userMergeLog.getMergeNo()); |
| | | dUserLog.setPersistUserId(userMergeLog.getPersistUserId()); |
| | | dUserLog.setRepealUserId(userMergeLog.getRepealUserId()); |
| | | |
| | | dUserLog.setIsHaveOther(0); |
| | | dUserLog.setOpManType(UserMergeLogItem.OP_MAN_TYPE_DEL); |
| | | dUserLog.setOpType(UserMergeLogItem.OP_TYPE_UPDATE); |
| | | |
| | | dUserLog.setType(UserMergeLogItem.TYPE_USER_ADDRESS); |
| | | dUserLog.setTableName(merUserFileDto.getTableName()); |
| | | dUserLog.setFieldId(merUserFileDto.getFileName()); |
| | | dUserLog.setFieldName("用户标识"); |
| | | dUserLog.setBeforeValue(delUser.getId()); |
| | | dUserLog.setAfterValue(user.getId()); |
| | | for (Map<String, Object> map : delUserDataList) { |
| | | logger.info("当前处理,表{},字段{},记录标识{}",merUserFileDto.getTableName(),merUserFileDto.getFileName(),map.get("id")); |
| | | dUserLog.setSortNum(sortNum); |
| | | dUserLog.setOpContent(JSON.toJSONString(map)); |
| | | |
| | | sqlMap.put("id", map.get("id")); |
| | | if (sql.length() > 0){ |
| | | sql.delete(0,sql.length()); |
| | | } |
| | | sql.append(" UPDATE ").append(merUserFileDto.getTableName()).append(" SET "); |
| | | sql.append(merUserFileDto.getFileName()).append(" = #{m.userId} WHERE id = #{m.id} "); |
| | | sqlSentence.sqlUpdate(sql.toString(), sqlMap); |
| | | if (userMergeCommonMapper.updateWhere(sqlSentence) != 1) { |
| | | logger.info("合并失败,当前处理,表{},字段{},记录标识{}",merUserFileDto.getTableName(),merUserFileDto.getFileName(),map.get("id")); |
| | | dUserLog.setStatus(0); |
| | | otherService.logAdd(dUserLog); |
| | | otherService.logStatusUpdate(userMergeLog.getId(),0); |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "合并失败!"); |
| | | } |
| | | dUserLog.setStatus(1); |
| | | otherService.logAdd(dUserLog); |
| | | sortNum = sortNum + 1; |
| | | } |
| | | } |
| | | logger.info("<-扫描含注解的表合并结束->"); |
| | | } |
| | | |
| | | /** |
| | |
| | | sqlMap.put("id", record.getId()); |
| | | sqlSentence.sqlUpdate(" userId = #{m.userId} WHERE id = #{m.id} ", sqlMap); |
| | | if (consultationPotentialProjectMapper.updateWhere(sqlSentence) != 1) { |
| | | logger.error("合并用户咨询记录-关注活动记录失败" + JSON.toJSONString(record)); |
| | | logger.error("合并用户咨询记录-潜在项目记录失败" + JSON.toJSONString(record)); |
| | | dUserLog.setStatus(0); |
| | | otherService.logAdd(dUserLog); |
| | | otherService.logStatusUpdate(userMergeLog.getId(),0); |
| | |
| | | } |
| | | } |
| | | logger.info("<-合并用户咨询记录-推荐项目记录结束->"); |
| | | |
| | | |
| | | //治疗项目consultation_treat_project |
| | | logger.info("<-合并用户咨询记录-治疗项目记录开始->"); |
| | | //要作废账号的咨询记录-治疗项目列表 |
| | | sqlSentence.sqlSentence("SELECT * FROM consultation_treat_project WHERE userId = #{m.delUserId} AND isDel = #{m.isDel}", sqlMap); |
| | | List<ConsultationTreatProject> consultationTreatProjectList = consultationTreatProjectMapper.selectList(sqlSentence); |
| | | if (consultationTreatProjectList != null && consultationTreatProjectList.size() > 0) { |
| | | logger.info("<-当前作废账号存在咨询记录-治疗项目记录->"); |
| | | UserMergeLogItem dUserLog = new UserMergeLogItem(); |
| | | dUserLog.setMergeLogId(userMergeLog.getId()); |
| | | dUserLog.setMergeLogNo(userMergeLog.getMergeNo()); |
| | | dUserLog.setPersistUserId(userMergeLog.getPersistUserId()); |
| | | dUserLog.setRepealUserId(userMergeLog.getRepealUserId()); |
| | | |
| | | dUserLog.setIsHaveOther(0); |
| | | dUserLog.setOpManType(UserMergeLogItem.OP_MAN_TYPE_DEL); |
| | | dUserLog.setOpType(UserMergeLogItem.OP_TYPE_UPDATE); |
| | | |
| | | dUserLog.setType(UserMergeLogItem.TYPE_CONSULT); |
| | | dUserLog.setTableName("consultation_treat_project"); |
| | | dUserLog.setFieldId("userId"); |
| | | dUserLog.setFieldName("用户标识"); |
| | | dUserLog.setBeforeValue(delUser.getId()); |
| | | dUserLog.setAfterValue(user.getId()); |
| | | |
| | | for (ConsultationTreatProject record : consultationTreatProjectList) { |
| | | logger.info("当前处理咨询记录-治疗项目记录,标识" + record.getId()); |
| | | dUserLog.setSortNum(sortNum); |
| | | dUserLog.setOpContent(JSON.toJSONString(record)); |
| | | |
| | | sqlMap.put("id", record.getId()); |
| | | sqlSentence.sqlUpdate(" userId = #{m.userId} WHERE id = #{m.id} ", sqlMap); |
| | | if (consultationTreatProjectMapper.updateWhere(sqlSentence) != 1) { |
| | | logger.error("合并用户咨询记录-治疗项目记录失败" + JSON.toJSONString(record)); |
| | | dUserLog.setStatus(0); |
| | | otherService.logAdd(dUserLog); |
| | | otherService.logStatusUpdate(userMergeLog.getId(),0); |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS, "合并用户咨询记录-治疗项目记录失败!"); |
| | | } |
| | | dUserLog.setStatus(1); |
| | | otherService.logAdd(dUserLog); |
| | | sortNum = sortNum + 1; |
| | | } |
| | | } |
| | | logger.info("<-合并用户咨询记录-治疗项目记录结束->"); |
| | | |
| | | } |
| | | |
| | | /** |