初始化项目
This commit is contained in:
1 parent
45a1702948
commit
934b8aad40
155 files changed
+2649
-68
No files matched your search
@@ -0,0 +1,141 @@
|
||||
<?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="customer_id" property="customerId"/>
|
||||
<result column="description" property="description"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="reject_reason" property="rejectReason"/>
|
||||
<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"/>
|
||||
<result column="customer_name" property="customerName"/>
|
||||
<result column="customer_phone" property="customerPhone"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectById" resultMap="BaseResultMap">
|
||||
SELECT r.*,
|
||||
d.name AS dealer_name,
|
||||
c.name AS customer_name,
|
||||
c.phone AS customer_phone
|
||||
FROM crm_report r
|
||||
LEFT JOIN crm_dealer d ON r.dealer_id = d.id
|
||||
LEFT JOIN crm_customer c ON r.customer_id = c.id
|
||||
WHERE r.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectValidByCustomerId" resultMap="BaseResultMap">
|
||||
SELECT * FROM crm_report
|
||||
WHERE customer_id = #{customerId}
|
||||
AND status IN (0, 1)
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectPage" resultMap="BaseResultMap">
|
||||
SELECT r.*,
|
||||
d.name AS dealer_name,
|
||||
c.name AS customer_name,
|
||||
c.phone AS customer_phone
|
||||
FROM crm_report r
|
||||
LEFT JOIN crm_dealer d ON r.dealer_id = d.id
|
||||
LEFT JOIN crm_customer c ON r.customer_id = c.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 c.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
|
||||
LEFT JOIN crm_customer c ON r.customer_id = c.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 c.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, customer_id, description, status, protect_start_date, protect_end_date)
|
||||
VALUES (#{dealerId}, #{customerId}, #{description}, #{status}, #{protectStartDate}, #{protectEndDate})
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="com.bycrm.entity.Report">
|
||||
UPDATE crm_report
|
||||
<set>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="rejectReason != null">reject_reason = #{rejectReason},</if>
|
||||
<if test="protectStartDate != null">protect_start_date = #{protectStartDate},</if>
|
||||
<if test="protectEndDate != null">protect_end_date = #{protectEndDate},</if>
|
||||
</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>
|
||||
Reference in new issue
Block a user