From 22d199559342c1ccb3a0a8a5b5ee50e973819e16 Mon Sep 17 00:00:00 2001
From: chenjiahe <763432473@qq.com>
Date: 星期五, 19 一月 2024 11:31:19 +0800
Subject: [PATCH] Merge branch 'master-prod-new' into chenjiahe-再生俱乐部

---
 phi_platform_user/src/main/java/com/hx/phip/service/user/impl/UserMergeLogServiceImpl.java |  141 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 139 insertions(+), 2 deletions(-)

diff --git a/phi_platform_user/src/main/java/com/hx/phip/service/user/impl/UserMergeLogServiceImpl.java b/phi_platform_user/src/main/java/com/hx/phip/service/user/impl/UserMergeLogServiceImpl.java
index e92f181..81582da 100644
--- a/phi_platform_user/src/main/java/com/hx/phip/service/user/impl/UserMergeLogServiceImpl.java
+++ b/phi_platform_user/src/main/java/com/hx/phip/service/user/impl/UserMergeLogServiceImpl.java
@@ -5,8 +5,10 @@
 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;
@@ -39,6 +41,7 @@
 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;
@@ -171,6 +174,8 @@
     @Resource
     private ConsultationNeededProjectMapper consultationNeededProjectMapper;
     @Resource
+    private ConsultationTreatProjectMapper consultationTreatProjectMapper;
+    @Resource
     private VGuideLogMapper vGuideLogMapper;
     @Resource
     private UserStatisticsMapper userStatisticsMapper;
@@ -218,6 +223,10 @@
     private KoapOrderTotalMapper koapOrderTotalMapper;
     @Resource
     private UserMoneyLogMapper userMoneyLogMapper;
+    @Resource
+    private ConstantBean constantBean;
+    @Resource
+    private UserMergeCommonMapper userMergeCommonMapper;
 
     /**
      * 鍚堝苟璐﹀彿
@@ -400,9 +409,90 @@
         //澶勭悊娑堣垂鎽樿
         timeConsumeHandler(user, delUser, userMergeLog, sqlSentence, sqlMap);
 
+        //澶勭悊鍚敞瑙g殑
+        annotationHandler(user,delUser,userMergeLog, sqlSentence, sqlMap);
+
+
         //淇敼鐘舵��
         otherService.logStatusUpdate(userMergeLog.getId(),1);
         logger.info("------------------------------------缁撴潫澶勭悊璐﹀彿鍚堝苟-------------------------------------");
+    }
+
+    /**
+     * 澶勭悊鍚敞瑙g殑琛�
+     * */
+    private void annotationHandler(User user, User delUser, UserMergeLog userMergeLog, SqlSentence sqlSentence, Map<String, Object> sqlMap) {
+        logger.info("<-鎵弿鍚敞瑙g殑琛ㄥ悎骞跺紑濮�->");
+        List<MerUserFileDto> merUserFileUtilList = null;
+        try {
+            merUserFileUtilList = MerUserFileUtil.getMerUserFileUtilList(constantBean);
+        }catch (Exception e){
+            logger.error("鍚堝苟璐﹀彿鎵弿鍚敞瑙g殑琛ㄩ敊璇�,淇濈暀{},浣滃簾{}"+user.getId(),delUser.getId());
+        }
+        if (merUserFileUtilList == null || merUserFileUtilList.size() < 1){
+            logger.info("<-鎵弿鍚敞瑙g殑琛ㄦ棤鎵�灞�,缁撴潫->");
+            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){
+                logger.info("浣滃簾鐢ㄦ埛鏃犳暟鎹�,琛▄},瀛楁{}",merUserFileDto.getTableName(),merUserFileDto.getFileName());
+                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(merUserFileDto.getType());
+            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("<-鎵弿鍚敞瑙g殑琛ㄥ悎骞剁粨鏉�->");
     }
 
     /**
@@ -426,7 +516,7 @@
             dUserLog.setOpManType(UserMergeLogItem.OP_MAN_TYPE_DEL);
             dUserLog.setOpType(UserMergeLogItem.OP_TYPE_UPDATE);
 
-            dUserLog.setType(UserMergeLogItem.TYPE_USER_ADDRESS);
+            dUserLog.setType(UserMergeLogItem.TYPE_USER_INTERESTS);
             dUserLog.setTableName("user_interests");
             dUserLog.setFieldId("userId");
             dUserLog.setFieldName("鐢ㄦ埛鏍囪瘑");
@@ -2423,7 +2513,7 @@
                 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);
@@ -2479,6 +2569,53 @@
             }
         }
         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("<-鍚堝苟鐢ㄦ埛鍜ㄨ璁板綍-娌荤枟椤圭洰璁板綍缁撴潫->");
+
     }
 
     /**

--
Gitblit v1.8.0