|
@@ -27,17 +27,23 @@
|
|
id, company_id, name, customer_id, amount_of_money, expected_transaction_date, stage, create_time, creator_id, remark, is_delete, plate1, plate2, plate3, plate4, plate5
|
|
id, company_id, name, customer_id, amount_of_money, expected_transaction_date, stage, create_time, creator_id, remark, is_delete, plate1, plate2, plate3, plate4, plate5
|
|
</sql>
|
|
</sql>
|
|
<select id="selectAllList" resultType="com.management.platform.entity.BusinessOpportunity">
|
|
<select id="selectAllList" resultType="com.management.platform.entity.BusinessOpportunity">
|
|
- select * FROM business_opportunity b
|
|
|
|
|
|
+ select
|
|
|
|
+ b.id,
|
|
|
|
+ b.`name`,
|
|
|
|
+ Sum(ip.total_price),
|
|
|
|
+ b.stage,
|
|
|
|
+ (SELECT GROUP_CONCAT(product_name) from business_item_product i LEFT JOIN product t on i.product_id = t.id WHERE i.business_id = b.id) productName
|
|
|
|
+ FROM business_opportunity b
|
|
left join business_item_product ip ON ip.business_id = b.id
|
|
left join business_item_product ip ON ip.business_id = b.id
|
|
left join product p on p.id = ip.product_id
|
|
left join product p on p.id = ip.product_id
|
|
WHERE b.company_id = #{companyId}
|
|
WHERE b.company_id = #{companyId}
|
|
<if test="name != null and name != ''" >
|
|
<if test="name != null and name != ''" >
|
|
- and b.name = #{name}
|
|
|
|
|
|
+ and b.name = #{bo.name}
|
|
</if>
|
|
</if>
|
|
<if test="stage != null " >
|
|
<if test="stage != null " >
|
|
and b.stage = #{stage}
|
|
and b.stage = #{stage}
|
|
</if>
|
|
</if>
|
|
- <if test="startTime != null and endTime != null " >
|
|
|
|
|
|
+ <if test="startTime != null and bo.endTime != null " >
|
|
and b.expected_transaction_date BETWEEN #{startTime} and #{endTime}
|
|
and b.expected_transaction_date BETWEEN #{startTime} and #{endTime}
|
|
</if>
|
|
</if>
|
|
<if test="productId != null ">
|
|
<if test="productId != null ">
|
|
@@ -46,5 +52,132 @@
|
|
GROUP BY b.id
|
|
GROUP BY b.id
|
|
LIMIT #{pageIndex},#{pageSize}
|
|
LIMIT #{pageIndex},#{pageSize}
|
|
</select>
|
|
</select>
|
|
|
|
+ <select id="selectAllList1" resultType="com.management.platform.entity.BusinessOpportunity">
|
|
|
|
+ select
|
|
|
|
+ b.id,
|
|
|
|
+ b.`name`,
|
|
|
|
+ Sum(ip.total_price),
|
|
|
|
+ b.stage,
|
|
|
|
+ (SELECT GROUP_CONCAT(product_name) from business_item_product i LEFT JOIN product t on i.product_id = t.id WHERE
|
|
|
|
+ i.business_id = b.id) productName
|
|
|
|
+ FROM business_opportunity b
|
|
|
|
+ left join business_item_product ip ON ip.business_id = b.id
|
|
|
|
+ left join product p on p.id = ip.product_id
|
|
|
|
+ WHERE b.company_id = #{bo.companyId}
|
|
|
|
+ and b.incharger_id in
|
|
|
|
+ (SELECT id from `user` WHERE department_id = (SELECT department_id from `user` WHERe id = #{userId}))
|
|
|
|
+ and b.incharger_id is null
|
|
|
|
+ <if test="bo.name != null and bo.name != ''">
|
|
|
|
+ and b.name = #{bo.name}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="bo.stage != null ">
|
|
|
|
+ and b.stage = #{bo.stage}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="bo.startTime != null and bo.endTime != null ">
|
|
|
|
+ and b.expected_transaction_date BETWEEN #{bo.startTime} and #{bo.endTime}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="bo.productId != null ">
|
|
|
|
+ and p.id = #{bo.productId}
|
|
|
|
+ </if>
|
|
|
|
+ GROUP BY b.id
|
|
|
|
+ LIMIT #{bo.pageIndex},#{bo.pageSize}
|
|
|
|
+ </select>
|
|
|
|
+ <select id="selectAllList2" resultType="com.management.platform.entity.BusinessOpportunity">
|
|
|
|
+ select
|
|
|
|
+ b.id,
|
|
|
|
+ b.`name`,
|
|
|
|
+ Sum(ip.total_price),
|
|
|
|
+ b.stage,
|
|
|
|
+ (SELECT GROUP_CONCAT(product_name) from business_item_product i LEFT JOIN product t on i.product_id = t.id WHERE
|
|
|
|
+ i.business_id = b.id) productName
|
|
|
|
+ FROM business_opportunity b
|
|
|
|
+ left join business_item_product ip ON ip.business_id = b.id
|
|
|
|
+ left join product p on p.id = ip.product_id
|
|
|
|
+ WHERE b.company_id = #{companyId}
|
|
|
|
+ and b.incharger_id = #{userId}
|
|
|
|
+ and b.incharger_id is null
|
|
|
|
+ <if test="bo.name != null and bo.name != ''">
|
|
|
|
+ and b.name = #{bo.name}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="bo.stage != null ">
|
|
|
|
+ and b.stage = #{bo.stage}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="bo.startTime != null and bo.endTime != null ">
|
|
|
|
+ and b.expected_transaction_date BETWEEN #{bo.startTime} and #{bo.endTime}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="bo.productId != null ">
|
|
|
|
+ and p.id = #{bo.productId}
|
|
|
|
+ </if>
|
|
|
|
+ GROUP BY b.id
|
|
|
|
+ LIMIT #{bo.pageIndex},#{bo.pageSize}
|
|
|
|
+ </select>
|
|
|
|
+ <select id="getTotal" resultType="java.lang.Integer">
|
|
|
|
+ select
|
|
|
|
+ conut(b.id)
|
|
|
|
+ FROM business_opportunity b
|
|
|
|
+ left join business_item_product ip ON ip.business_id = b.id
|
|
|
|
+ left join product p on p.id = ip.product_id
|
|
|
|
+ WHERE b.company_id = #{bo.companyId}
|
|
|
|
+ <if test="bo.name != null and bo.name != ''" >
|
|
|
|
+ and b.name = #{bo.name}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="bo.stage != null " >
|
|
|
|
+ and b.stage = #{bo.stage}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="bo.startTime != null and bo.endTime != null " >
|
|
|
|
+ and b.expected_transaction_date BETWEEN #{bo.startTime} and #{bo.endTime}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="bo.productId != null ">
|
|
|
|
+ and p.id = #{bo.productId}
|
|
|
|
+ </if>
|
|
|
|
+ GROUP BY b.id
|
|
|
|
+ </select>
|
|
|
|
+ <select id="getTotal1" resultType="java.lang.Integer">
|
|
|
|
+ select
|
|
|
|
+ count(b.id)
|
|
|
|
+ FROM business_opportunity b
|
|
|
|
+ left join business_item_product ip ON ip.business_id = b.id
|
|
|
|
+ left join product p on p.id = ip.product_id
|
|
|
|
+ WHERE b.company_id = #{bo.companyId}
|
|
|
|
+ and b.incharger_id in
|
|
|
|
+ (SELECT id from `user` WHERE department_id = (SELECT department_id from `user` WHERe id = #{userId}))
|
|
|
|
+ and b.incharger_id is null
|
|
|
|
+ <if test="bo.name != null and bo.name != ''">
|
|
|
|
+ and b.name = #{bo.name}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="bo.stage != null ">
|
|
|
|
+ and b.stage = #{bo.stage}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="bo.startTime != null and bo.endTime != null ">
|
|
|
|
+ and b.expected_transaction_date BETWEEN #{bo.startTime} and #{bo.endTime}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="bo.productId != null ">
|
|
|
|
+ and p.id = #{bo.productId}
|
|
|
|
+ </if>
|
|
|
|
+ GROUP BY b.id
|
|
|
|
+ </select>
|
|
|
|
+ <select id="getTotal2" resultType="java.lang.Integer">
|
|
|
|
+ select
|
|
|
|
+ COUNT(b.id)
|
|
|
|
+ FROM business_opportunity b
|
|
|
|
+ left join business_item_product ip ON ip.business_id = b.id
|
|
|
|
+ left join product p on p.id = ip.product_id
|
|
|
|
+ WHERE b.company_id = #{bo.companyId}
|
|
|
|
+ and b.incharger_id = #{userId}
|
|
|
|
+ and b.incharger_id is null
|
|
|
|
+ <if test="bo.name != null and bo.name != ''">
|
|
|
|
+ and b.name = #{name}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="bo.stage != null ">
|
|
|
|
+ and b.stage = #{bo.stage}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="bo.startTime != null and bo.endTime != null ">
|
|
|
|
+ and b.expected_transaction_date BETWEEN #{bo.startTime} and #{bo.endTime}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="bo.productId != null ">
|
|
|
|
+ and p.id = #{bo.productId}
|
|
|
|
+ </if>
|
|
|
|
+ GROUP BY b.id
|
|
|
|
+ </select>
|
|
|
|
|
|
</mapper>
|
|
</mapper>
|