|
@@ -2,72 +2,85 @@
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="com.fjhx.customer.mapper.customer.CustomerMapper">
|
|
|
<update id="customerAllocation">
|
|
|
- update customer set user_id = #{userId},update_time = now(),allocation_time = now() where id = #{id}
|
|
|
+ update customer
|
|
|
+ set user_id = #{userId},
|
|
|
+ update_time = now(),
|
|
|
+ allocation_time = now()
|
|
|
+ where id = #{id}
|
|
|
</update>
|
|
|
- <select id="getList" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
|
|
|
- select
|
|
|
- c.id,
|
|
|
- c.customer_code,
|
|
|
- c.code,
|
|
|
- c.country_id,
|
|
|
- c.province_id,
|
|
|
- c.city_id,
|
|
|
- c.address,
|
|
|
- c.zip_code,
|
|
|
- c.name,
|
|
|
- c.status,
|
|
|
- c.source,
|
|
|
- c.user_id,
|
|
|
- c.create_user,
|
|
|
- c.create_time,
|
|
|
- c.update_user,
|
|
|
- c.update_time,
|
|
|
- c.tag
|
|
|
+
|
|
|
+ <sql id="listOrPage">
|
|
|
+ select c.id,
|
|
|
+ c.customer_code,
|
|
|
+ c.code,
|
|
|
+ c.country_id,
|
|
|
+ c.province_id,
|
|
|
+ c.city_id,
|
|
|
+ c.address,
|
|
|
+ c.zip_code,
|
|
|
+ c.name,
|
|
|
+ c.status,
|
|
|
+ c.source,
|
|
|
+ c.user_id,
|
|
|
+ c.create_user,
|
|
|
+ c.create_time,
|
|
|
+ c.update_user,
|
|
|
+ c.update_time,
|
|
|
+ c.tag,
|
|
|
+ c.main_part,
|
|
|
+ c.minor_part,
|
|
|
+ c.dept_id,
|
|
|
+ c.main_categories,
|
|
|
+ c.company_size,
|
|
|
+ c.settlement_mode,
|
|
|
+ c.level,
|
|
|
+ c.maintain_level,
|
|
|
+ c.new_old,
|
|
|
+ c.annual_quantity,
|
|
|
+ c.follow_up_ask,
|
|
|
+ c.remind,
|
|
|
+ c.create_group_time,
|
|
|
+ c.state,
|
|
|
+ c.invoice_type,
|
|
|
+ c.cooperate_status,
|
|
|
+ c.account_name,
|
|
|
+ c.account_address,
|
|
|
+ c.account_tel,
|
|
|
+ c.account_bank,
|
|
|
+ c.account_number,
|
|
|
+ c.priv_account_name,
|
|
|
+ c.priv_account_bank,
|
|
|
+ c.priv_account_number,
|
|
|
+ t1.followCount,
|
|
|
+ t1.lastSaleDate,
|
|
|
+ t1.lastSaleDay,
|
|
|
+ t1.orderCount,
|
|
|
+ t1.orderAmountSum
|
|
|
from customer c
|
|
|
- ${ew.customSqlSegment}
|
|
|
+ LEFT JOIN (SELECT c.id,
|
|
|
+ count(cfr.id) AS followCount,
|
|
|
+ max(co.sale_date) AS lastSaleDate,
|
|
|
+ IFNULL(DATEDIFF(NOW(), max(co.sale_date)), 0) AS lastSaleDay,
|
|
|
+ count(co.id) AS orderCount,
|
|
|
+ IFNULL(sum(co.amount), 0) AS orderAmountSum
|
|
|
+ FROM customer c
|
|
|
+ LEFT JOIN customer_follow_records cfr ON cfr.customer_id = c.id
|
|
|
+ LEFT JOIN contract co ON co.buy_corporation_id = c.id
|
|
|
+ GROUP BY c.id) t1 ON t1.id = c.id
|
|
|
+ </sql>
|
|
|
+ <select id="getList" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
|
|
|
+ <include refid="listOrPage"/>
|
|
|
+ ${ew.customSqlSegment}
|
|
|
</select>
|
|
|
|
|
|
<select id="getPage" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
|
|
|
- select
|
|
|
- c.id,
|
|
|
- c.customer_code,
|
|
|
- c.code,
|
|
|
- c.country_id,
|
|
|
- c.province_id,
|
|
|
- c.city_id,
|
|
|
- c.address,
|
|
|
- c.zip_code,
|
|
|
- c.name,
|
|
|
- c.status,
|
|
|
- c.source,
|
|
|
- c.user_id,
|
|
|
- c.create_user,
|
|
|
- c.create_time,
|
|
|
- c.update_user,
|
|
|
- c.update_time,
|
|
|
- c.tag,
|
|
|
- c.main_part,
|
|
|
- c.minor_part,
|
|
|
- c.dept_id,
|
|
|
- c.main_categories,
|
|
|
- c.company_size,
|
|
|
- c.settlement_mode,
|
|
|
- c.level,
|
|
|
- c.maintain_level,
|
|
|
- c.new_old,
|
|
|
- c.annual_quantity,
|
|
|
- c.follow_up_ask,
|
|
|
- c.remind,
|
|
|
- c.create_group_time,
|
|
|
- c.state
|
|
|
- from customer c
|
|
|
- ${ew.customSqlSegment}
|
|
|
+ <include refid="listOrPage"/>
|
|
|
+ ${ew.customSqlSegment}
|
|
|
</select>
|
|
|
|
|
|
|
|
|
<select id="sourceStock" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
|
|
|
- SELECT
|
|
|
- COUNT(*) count,
|
|
|
+ SELECT COUNT(*) count,
|
|
|
ifnull(c.source,-1) source,
|
|
|
ifnull(DATE_FORMAT(c.create_time,'%Y-%m'),-1) time
|
|
|
FROM
|