- 在 Report、ReportDTO、ReportVO、ReportUpdateDTO 实体类中新增 contactPerson 和 contactPhone 字段 - 在 UserInfoVO 中新增 dealerContactPerson 和 dealerContactPhone 字段以展示经销商联系人信息 - 修改 ReportServiceImpl,在创建报备时自动填充默认的项目负责人信息(取自经销商信息) - 更新 MyBatis 映射文件,确保数据库字段的正确映射和持久化 - 在前端 Report.vue 中添加相应的表单字段和表格列,并在新增时自动填充默认值 - 调整对话框宽度以适配新增字段
157 lines
6.1 KiB
XML
157 lines
6.1 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.bycrm.mapper.ReportMapper">
|
|
|
|
<resultMap id="BaseResultMap" type="com.bycrm.entity.Report">
|
|
<id column="id" property="id"/>
|
|
<result column="dealer_id" property="dealerId"/>
|
|
<result column="school_id" property="schoolId"/>
|
|
<result column="school_name" property="schoolName"/>
|
|
<result column="product" property="product"/>
|
|
<result column="project_type" property="projectType"/>
|
|
<result column="description" property="description"/>
|
|
<result column="contact_person" property="contactPerson"/>
|
|
<result column="contact_phone" property="contactPhone"/>
|
|
<result column="status" property="status"/>
|
|
<result column="reject_reason" property="rejectReason"/>
|
|
<result column="cancel_reason" property="cancelReason"/>
|
|
<result column="protect_start_date" property="protectStartDate"/>
|
|
<result column="protect_end_date" property="protectEndDate"/>
|
|
<result column="created_at" property="createdAt"/>
|
|
<result column="updated_at" property="updatedAt"/>
|
|
<result column="dealer_name" property="dealerName"/>
|
|
</resultMap>
|
|
|
|
<select id="selectById" resultMap="BaseResultMap">
|
|
SELECT r.*,
|
|
d.name AS dealer_name
|
|
FROM crm_report r
|
|
LEFT JOIN crm_dealer d ON r.dealer_id = d.id
|
|
WHERE r.id = #{id}
|
|
</select>
|
|
|
|
<select id="selectValidBySchoolAndProduct" resultMap="BaseResultMap">
|
|
SELECT * FROM crm_report
|
|
WHERE school_id = #{schoolId}
|
|
AND product = #{product}
|
|
AND project_type = #{projectType}
|
|
AND status IN (0, 1)
|
|
LIMIT 1
|
|
</select>
|
|
|
|
<select id="selectValidBySchoolNameAndProduct" resultMap="BaseResultMap">
|
|
SELECT * FROM crm_report
|
|
WHERE school_name = #{schoolName}
|
|
AND product = #{product}
|
|
AND project_type = #{projectType}
|
|
AND status IN (0, 1)
|
|
LIMIT 1
|
|
</select>
|
|
|
|
<select id="selectPage" resultMap="BaseResultMap">
|
|
SELECT r.*,
|
|
d.name AS dealer_name
|
|
FROM crm_report r
|
|
LEFT JOIN crm_dealer d ON r.dealer_id = d.id
|
|
<where>
|
|
<if test="dealerId != null">
|
|
AND r.dealer_id = #{dealerId}
|
|
</if>
|
|
<if test="dealerName != null and dealerName != ''">
|
|
AND d.name LIKE CONCAT('%', #{dealerName}, '%')
|
|
</if>
|
|
<if test="customerName != null and customerName != ''">
|
|
AND r.school_name LIKE CONCAT('%', #{customerName}, '%')
|
|
</if>
|
|
<if test="status != null">
|
|
AND r.status = #{status}
|
|
</if>
|
|
</where>
|
|
ORDER BY r.created_at DESC
|
|
LIMIT #{query.size} OFFSET #{query.offset}
|
|
</select>
|
|
|
|
<select id="countPage" resultType="java.lang.Long">
|
|
SELECT COUNT(*)
|
|
FROM crm_report r
|
|
LEFT JOIN crm_dealer d ON r.dealer_id = d.id
|
|
<where>
|
|
<if test="dealerId != null">
|
|
AND r.dealer_id = #{dealerId}
|
|
</if>
|
|
<if test="dealerName != null and dealerName != ''">
|
|
AND d.name LIKE CONCAT('%', #{dealerName}, '%')
|
|
</if>
|
|
<if test="customerName != null and customerName != ''">
|
|
AND r.school_name LIKE CONCAT('%', #{customerName}, '%')
|
|
</if>
|
|
<if test="status != null">
|
|
AND r.status = #{status}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<insert id="insert" parameterType="com.bycrm.entity.Report" useGeneratedKeys="true" keyProperty="id">
|
|
INSERT INTO crm_report (dealer_id, school_id, school_name, product, project_type, description, contact_person, contact_phone, status, protect_start_date, protect_end_date)
|
|
VALUES (#{dealerId}, #{schoolId}, #{schoolName}, #{product}, #{projectType}, #{description}, #{contactPerson}, #{contactPhone}, #{status}, #{protectStartDate}, #{protectEndDate})
|
|
</insert>
|
|
|
|
<update id="update" parameterType="com.bycrm.entity.Report">
|
|
UPDATE crm_report
|
|
<set>
|
|
<if test="product != null">product = #{product},</if>
|
|
<if test="projectType != null">project_type = #{projectType},</if>
|
|
<if test="description != null">description = #{description},</if>
|
|
<if test="contactPerson != null">contact_person = #{contactPerson},</if>
|
|
<if test="contactPhone != null">contact_phone = #{contactPhone},</if>
|
|
<if test="status != null">status = #{status},</if>
|
|
<if test="rejectReason != null">reject_reason = #{rejectReason},</if>
|
|
<if test="cancelReason != null">cancel_reason = #{cancelReason},</if>
|
|
<if test="protectStartDate != null">protect_start_date = #{protectStartDate},</if>
|
|
<if test="protectEndDate != null">protect_end_date = #{protectEndDate},</if>
|
|
updated_at = NOW()
|
|
</set>
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
<delete id="deleteById">
|
|
DELETE FROM crm_report WHERE id = #{id}
|
|
</delete>
|
|
|
|
<select id="selectExpiringReports" resultMap="BaseResultMap">
|
|
SELECT * FROM crm_report
|
|
WHERE status = 1
|
|
AND protect_end_date <= #{endDate}
|
|
</select>
|
|
|
|
<update id="batchUpdateExpired">
|
|
UPDATE crm_report
|
|
SET status = 3
|
|
WHERE id IN
|
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</update>
|
|
|
|
<select id="countByDealerId" resultType="java.lang.Long">
|
|
SELECT COUNT(*)
|
|
FROM crm_report
|
|
<where>
|
|
<if test="dealerId != null">
|
|
AND dealer_id = #{dealerId}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="countPendingByDealerId" resultType="java.lang.Long">
|
|
SELECT COUNT(*)
|
|
FROM crm_report
|
|
WHERE status = 0
|
|
<if test="dealerId != null">
|
|
AND dealer_id = #{dealerId}
|
|
</if>
|
|
</select>
|
|
|
|
</mapper>
|