浏览代码

机构编辑资料操作日志

huangzhiguo 2 年之前
父节点
当前提交
47e05408f6

+ 20 - 0
src/main/java/com/caimei365/user/mapper/ClubMapper.java

@@ -2,6 +2,7 @@ package com.caimei365.user.mapper;
 
 import com.caimei365.user.model.dto.ClubUpdateDto;
 import com.caimei365.user.model.po.ClubRemarksPo;
+import com.caimei365.user.model.po.OperationalLogsPo;
 import com.caimei365.user.model.po.UserPo;
 import com.caimei365.user.model.vo.*;
 import org.apache.ibatis.annotations.Mapper;
@@ -35,6 +36,25 @@ public interface ClubMapper {
      */
     void updateClubUserByUpdateInfo(UserPo user);
 
+    /**
+     * 查询机构信息
+     * @return
+     */
+    ClubVo selClubData(Integer clubId);
+
+
+    /**
+     * 查询协销信息
+     * @param serviceProviderId
+     * @return
+     */
+    String selSpName(Integer serviceProviderId);
+
+    /**
+     * 插入操作记录
+     * @param operationalLogsPo
+     */
+    void insertOpLogs(OperationalLogsPo operationalLogsPo);
     /**
      * 修改机构信息保存机构
      *

+ 11 - 0
src/main/java/com/caimei365/user/model/dto/ClubUpdateDto.java

@@ -25,6 +25,11 @@ public class ClubUpdateDto implements Serializable {
      */
     @ApiModelProperty("用户Id")
     private Integer userId;
+    /**
+     * 协销id
+     */
+    @ApiModelProperty("协销Id")
+    private Integer serviceProviderId;
     /**
      * 机构名称
      */
@@ -124,4 +129,10 @@ public class ClubUpdateDto implements Serializable {
      */
     @ApiModelProperty("公司简介(info)")
     private String profile;
+
+    /**
+     * 最后修改时间
+     */
+    @ApiModelProperty("最后修改时间")
+    private String lastModify;
 }

+ 39 - 0
src/main/java/com/caimei365/user/model/po/OperationalLogsPo.java

@@ -0,0 +1,39 @@
+package com.caimei365.user.model.po;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/3/9
+ */
+@Data
+public class OperationalLogsPo {
+    /**
+     * 机构名称
+     */
+    private String institutionName;
+    /**
+     * 联系人
+     */
+    private String contact;
+    /**
+     * 操作类型
+     */
+    private String operationType;
+    /**
+     * 操作内容
+     */
+    private String actionContent;
+    /**
+     * 操作人
+     */
+    private String operator;
+    /**
+     * 操作时间
+     */
+    private Date operationTime;
+}

+ 382 - 4
src/main/java/com/caimei365/user/service/impl/ClubServiceImpl.java

@@ -7,11 +7,8 @@ import com.caimei365.user.mapper.*;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.ClubUpdateDto;
 import com.caimei365.user.model.dto.SuperVipDto;
-import com.caimei365.user.model.po.SuperVipPo;
+import com.caimei365.user.model.po.*;
 import com.caimei365.user.model.dto.JsonParamsDto;
-import com.caimei365.user.model.po.ClubRemarksPo;
-import com.caimei365.user.model.po.UserBeansHistoryPo;
-import com.caimei365.user.model.po.UserPo;
 import com.caimei365.user.model.vo.*;
 import com.caimei365.user.service.ClubService;
 import com.caimei365.user.service.SellerService;
@@ -205,6 +202,12 @@ public class ClubServiceImpl implements ClubService {
         }
         // 更新机构用户信息
         clubMapper.updateClubUserByUpdateInfo(user);
+        //添加操作日志
+        int type = insertOperationalLogs(club);
+
+        if (type == 1) {
+            club.setLastModify(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+        }
         // 更新机构信息
         clubMapper.updateClubByUpdateInfo(club);
 
@@ -240,6 +243,381 @@ public class ClubServiceImpl implements ClubService {
         return ResponseJson.success("修改机构资料成功", club);
     }
 
+    private int insertOperationalLogs(ClubUpdateDto club) {
+        int type = 0;
+        log.info("====开始操作记录====");
+        List<String> list = new ArrayList<>();
+        OperationalLogsPo operationalLogsPo = new OperationalLogsPo();
+        ClubVo clubVo = clubMapper.selClubData(club.getClubId());
+        // 判断修改的内容
+        if (club.getClubId() != null) {
+
+            if (clubVo != null) {
+                if (StringUtils.isNotBlank(clubVo.getName())) {
+                    if (StringUtils.isNotBlank(club.getName())) {
+                        if (!club.getName().equals(clubVo.getName())) {
+                            list.add("修改了机构名称");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了机构名称");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getName())) {
+                        list.add("新增了机构名称");
+                        type = 1;
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getLinkMan())) {
+                    if (StringUtils.isNotBlank(club.getLinkMan())) {
+                        if (!club.getLinkMan().equals(clubVo.getLinkMan())) {
+                            list.add("修改了联系人");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了联系人");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getLinkMan())) {
+                        list.add("新增了联系人");
+                        type = 1;
+                    }
+                }
+
+                if (clubVo.getLinkManIdentity() != null) {
+                    if (club.getLinkManIdentity() != null ) {
+                        if (club.getLinkManIdentity().equals(clubVo.getLinkManIdentity())) {
+                            list.add("修改了联系人身份");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了联系人身份");
+                        type = 1;
+                    }
+                } else {
+                    if (club.getLinkManIdentity() != null ) {
+                        list.add("新增了联系人身份");
+                        type = 1;
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getContractEmail())) {
+                    if (StringUtils.isNotBlank(club.getContractEmail())) {
+                        if (!club.getContractEmail().equals(clubVo.getContractEmail())) {
+                            list.add("修改了联系邮箱");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了联系邮箱");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getContractEmail())) {
+                        list.add("新增了联系邮箱");
+                        type = 1;
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getShortName())) {
+                    if (StringUtils.isNotBlank(club.getShortName())) {
+                        if (!club.getShortName().equals(clubVo.getShortName())) {
+                            list.add("修改了机构简称");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了机构简称");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getShortName())) {
+                        list.add("新增了机构简称");
+                        type = 1;
+                    }
+                }
+
+                if (clubVo.getProvinceId() != null || clubVo.getCityId() != null || clubVo.getTownId() != null || StringUtils.isNotBlank(clubVo.getAddress())) {
+                    if (club.getProvinceId() != null || club.getCityId() != null || club.getTownId() != null || StringUtils.isNotBlank(club.getAddress())) {
+                        if (!club.getProvinceId().equals(clubVo.getProvinceId()) || !club.getCityId().equals(clubVo.getCityId()) || !club.getTownId().equals(clubVo.getTownId()) || !club.getAddress().equals(clubVo.getAddress())) {
+                            list.add("修改了详细地址");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了详细地址");
+                        type = 1;
+                    }
+                } else {
+                    if (club.getProvinceId() != null || club.getCityId() != null || club.getTownId() != null || StringUtils.isNotBlank(club.getAddress())) {
+                        list.add("新增了详细地址");
+                        type = 1;
+                    }
+                }
+/*
+                if (clubVo.getCityId() != null) {
+                    if (club.getCityId() != null) {
+                        if (!club.getCityId().equals(clubVo.getCityId())) {
+                            list.add("修改了详细地址");
+                        }
+                    } else {
+                        list.add("删除了详细地址");
+                    }
+                } else {
+                    if (club.getCityId() != null) {
+                        list.add("新增了详细地址");
+                    }
+                }
+
+                if (clubVo.getTownId() != null) {
+                    if (club.getTownId() != null) {
+                        if (!club.getTownId().equals(clubVo.getTownId())) {
+                            list.add("修改了详细地址");
+                        }
+                    } else {
+                        list.add("删除了详细地址");
+                    }
+                } else {
+                    if (club.getTownId() != null) {
+                        list.add("新增了详细地址");
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getAddress())) {
+                    if (StringUtils.isNotBlank(club.getAddress())) {
+                        if (!club.getAddress().equals(clubVo.getAddress())) {
+                            list.add("修改了详细地址");
+                        }
+                    } else {
+                        list.add("删除了详细地址");
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getAddress())) {
+                        list.add("新增了详细地址");
+                    }
+                }*/
+
+                if (StringUtils.isNotBlank(clubVo.getSocialCreditCode())) {
+                    if (StringUtils.isNotBlank(club.getSocialCreditCode())) {
+                        if (!club.getSocialCreditCode().equals(clubVo.getSocialCreditCode())) {
+                            list.add("修改了营业执照编号");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了营业执照编号");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getSocialCreditCode())) {
+                        list.add("新增了营业执照编号");
+                        type = 1;
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getBusinessLicense())) {
+                    if (StringUtils.isNotBlank(club.getBusinessLicense())) {
+                        if (!club.getBusinessLicense().equals(clubVo.getBusinessLicense())) {
+                            list.add("修改了营业执照");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了营业执照");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getBusinessLicense())) {
+                        list.add("新增了营业执照");
+                        type = 1;
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getShopPhoto())) {
+                    if (StringUtils.isNotBlank(club.getShopPhoto())) {
+                        if (!club.getShopPhoto().equals(clubVo.getShopPhoto())) {
+                            list.add("修改了门头照");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了门头照");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getShopPhoto())) {
+                        list.add("新增了门头照");
+                        type = 1;
+                    }
+                }
+
+                if (clubVo.getFirstClubType() != null) {
+                    if (club.getFirstClubType() != null) {
+                        if (!club.getFirstClubType().equals(clubVo.getFirstClubType())) {
+                            list.add("修改了机构类型分类");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了机构类型分类");
+                        type = 1;
+                    }
+                } else {
+                    if (club.getFirstClubType() != null) {
+                        list.add("新增了机构类型分类");
+                        type = 1;
+                    }
+                }
+
+                if (clubVo.getSecondClubType() != null) {
+                    if (club.getSecondClubType() != null) {
+                        if (!club.getSecondClubType().equals(clubVo.getSecondClubType())) {
+                            list.add("修改了机构类型二级分类");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了机构类型二级分类");
+                        type = 1;
+                    }
+                } else {
+                    if (club.getSecondClubType() != null) {
+                        list.add("新增了机构类型二级分类");
+                        type = 1;
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getDepartment())) {
+                    if (StringUtils.isNotBlank(club.getDepartment())) {
+                        if (!club.getDepartment().equals(clubVo.getDepartment())) {
+                            list.add("修改了科室");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了科室");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getDepartment())) {
+                        list.add("新增了科室");
+                        type = 1;
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getMedicalPracticeLicense())) {
+                    if (StringUtils.isNotBlank(club.getMedicalPracticeLicense())) {
+                        if (!club.getMedicalPracticeLicense().equals(clubVo.getMedicalPracticeLicense())) {
+                            list.add("修改了医美分类必须上传医疗执业许可证");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了医美分类必须上传医疗执业许可证");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getMedicalPracticeLicense())) {
+                        list.add("新增了医美分类必须上传医疗执业许可证");
+                        type = 1;
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getMainProduct())) {
+                    if (StringUtils.isNotBlank(club.getMainProduct())) {
+                        if (!club.getMainProduct().equals(clubVo.getMainProduct())) {
+                            list.add("修改了主打项目");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了主打项目");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getMainProduct())) {
+                        list.add("新增了主打项目");
+                        type = 1;
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getFax())) {
+                    if (StringUtils.isNotBlank(club.getFax())) {
+                        if (!club.getFax().equals(clubVo.getFax())) {
+                            list.add("修改了传真");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了传真");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getFax())) {
+                        list.add("新增了传真");
+                        type = 1;
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getContractPhone())) {
+                    if (StringUtils.isNotBlank(club.getContractPhone())) {
+                        if (!club.getContractPhone().equals(clubVo.getContractPhone())) {
+                            list.add("修改了固定电话");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了固定电话");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getContractPhone())) {
+                        list.add("新增了固定电话");
+                        type = 1;
+                    }
+                }
+
+                if (StringUtils.isNotBlank(clubVo.getProfile())) {
+                    if (StringUtils.isNotBlank(club.getProfile())) {
+                        if (!club.getProfile().equals(clubVo.getProfile())) {
+                            list.add("修改了公司简介");
+                            type = 1;
+                        }
+                    } else {
+                        list.add("删除了公司简介");
+                        type = 1;
+                    }
+                } else {
+                    if (StringUtils.isNotBlank(club.getProfile())) {
+                        list.add("新增了公司简介");
+                        type = 1;
+                    }
+                }
+            }
+        }
+
+        operationalLogsPo.setInstitutionName(club.getName());
+
+        if (StringUtils.isNotBlank(club.getLinkMan())) {
+            operationalLogsPo.setContact(club.getLinkMan());
+        } else {
+            if (StringUtils.isNotBlank(clubVo.getLinkMan())) {
+                operationalLogsPo.setContact(club.getLinkMan());
+            }
+        }
+        operationalLogsPo.setOperationType("编辑");
+        operationalLogsPo.setActionContent(StringUtils.strip(list.toString(),"[]"));
+
+        // 机构修改 机构联系人 为操作人
+        if (StringUtils.isNotBlank(club.getLinkMan())) {
+            operationalLogsPo.setOperator(club.getLinkMan());
+        } else {
+            if (StringUtils.isNotBlank(clubVo.getLinkMan())) {
+                operationalLogsPo.setOperator(clubVo.getLinkMan());
+            }
+        }
+        // 协销帮忙修改 取协销人员
+        if (club.getServiceProviderId() != null) {
+            String spName = clubMapper.selSpName(club.getServiceProviderId());
+            operationalLogsPo.setOperator(spName);
+        }
+        operationalLogsPo.setOperationTime(new Date());
+
+        log.info("operationalLogsPo====="+operationalLogsPo);
+        clubMapper.insertOpLogs(operationalLogsPo);
+        return type;
+    }
+
     private void saveUserBeans(UserVo user) {
         //机构完善资料,送500采美豆
         UserBeansHistoryPo beansHistory = new UserBeansHistoryPo();

+ 49 - 2
src/main/resources/mapper/ClubMapper.xml

@@ -74,6 +74,51 @@
         userName = #{userName}
         where userID = #{userId}
     </update>
+    <select id="selClubData" resultType="com.caimei365.user.model.vo.ClubVo">
+        select
+        userId,
+        clubId,
+        name,
+        linkMan,
+        linkManIdentity,
+        contractEmail,
+        sname as shortName,
+        provinceId,
+        cityId,
+        townId,
+        address,
+        socialCreditCode,
+        businessLicenseImage as businessLicense,
+        headpic as shopPhoto,
+        firstClubType,
+        secondClubType,
+        department,
+        medicalPracticeLicenseImg as medicalPracticeLicense,
+        mainpro as mainProduct,
+        fax,
+        contractPhone,
+        info as profile
+        from club where clubID = #{clubID}
+    </select>
+    <select id="selSpName" resultType="java.lang.String">
+        select case status when 91 then '采美默认协销经理(官方账号)' else linkMan end AS spName
+               from serviceprovider where serviceProviderID = #{serviceProviderId}
+    </select>
+    <insert id="insertOpLogs">
+        INSERT INTO operational_logs
+        (institutionName,
+         Contact,
+         operationtype,
+         Actioncontent,
+         Operator,
+         Operationtime)
+        VALUES (#{institutionName},
+                #{contact},
+                #{operationType},
+                #{actionContent},
+                #{operator},
+                #{operationTime})
+    </insert>
     <update id="updateClubByUpdateInfo">
         update club set
         <if test="name != null and name != ''">
@@ -114,9 +159,11 @@
         <if test="mainProduct != null and mainProduct != ''">
             mainpro = #{mainProduct},
         </if>
+        <if test="lastModify != null and lastModify != ''">
+            lastModify = #{lastModify},
+        </if>
         fax = #{fax},
-        info = #{profile},
-        lastModify = NOW()
+        info = #{profile}
         where clubID = #{clubId}
     </update>
     <delete id="clearRemarksFiles">