123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- <?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.fjhx.customer.mapper.customer.CustomerMapper">
- <update id="customerAllocation">
- 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,
- c.company_id,
- c.short_name,
- c.homepage,
- c.scale_id,
- c.fax,
- c.tel_area_code,
- c.tel,
- c.remark,
- c.xm_country_name
- from customer c
- ${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.company_id,
- c.short_name,
- c.homepage,
- c.scale_id,
- c.fax,
- c.tel_area_code,
- c.tel,
- c.xm_country_name
- from customer c
- ${ew.customSqlSegment}
- </select>
- <select id="sourceStock" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
- SELECT
- COUNT(*) count,
- ifnull(c.source,-1) source,
- ifnull(DATE_FORMAT(c.create_time,'%Y-%m'),-1) time
- FROM
- customer c
- ${ew.customSqlSegment}
- </select>
- <select id="sourceIncrement" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
- SELECT
- COUNT(*) count,
- ifnull(c.source,-1) source,
- ifnull(DATE_FORMAT(c.create_time,'%Y-%m'),-1) time
- FROM
- customer c
- ${ew.customSqlSegment}
- </select>
- <select id="getFollowUp" resultType="com.fjhx.customer.entity.customer.vo.CustomerFollowRecordsVo">
- SELECT t1.*
- FROM ((SELECT id,
- amount,
- create_time `date`,
- NULL AS contractCode,
- code,
- 10 AS type,
- NULL AS content,
- create_user
- FROM bytesailing_sale.sale_quotation sq
- WHERE sq.buy_corporation_id = #{id}
- and sq.tenant_id = #{tenantId}
- and sq.del_flag = 0)
- UNION
- (SELECT id,
- amount,
- create_time `date`,
- CODE AS contractCode,
- null as code,
- 20 AS type,
- NULL AS content,
- create_user
- FROM bytesailing_sale.contract c
- WHERE c.status = 30
- and c.buy_corporation_id = #{id}
- and c.tenant_id = #{tenantId}
- and c.del_flag = 0)
- UNION
- (SELECT id,
- NULL AS amount,
- `date`,
- NULL AS contractCode,
- null as code,
- 30 AS type,
- content,
- create_user
- FROM customer_follow_records cfr
- WHERE cfr.customer_id = #{id})) t1
- ORDER BY t1.date DESC LIMIT 3
- </select>
- <select id="sourceCount" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
- SELECT
- COUNT( 1 ) AS `count`,
- dcd.dict_key AS `source`
- FROM
- customer c
- JOIN bytesailing_base.dict_tenant_data dcd ON FIND_IN_SET( dcd.dict_key, c.source )
- <where>
- ${ew.sqlSegment}
- </where>
- GROUP BY
- dcd.dict_key
- </select>
- </mapper>
|