CustomerMapper.xml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.goafanti.common.dao.CustomerMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.Customer">
  5. <!--
  6. WARNING - @mbg.generated
  7. This element is automatically generated by MyBatis Generator, do not modify.
  8. This element was generated on Mon Nov 06 08:45:21 CST 2017.
  9. -->
  10. <id column="id" jdbcType="VARCHAR" property="id" />
  11. <result column="aid" jdbcType="VARCHAR" property="aid" />
  12. <result column="paid" jdbcType="VARCHAR" property="paid" />
  13. <result column="share_type" jdbcType="INTEGER" property="shareType" />
  14. <result column="customer_type" jdbcType="INTEGER" property="customerType" />
  15. <result column="customer_status" jdbcType="INTEGER" property="customerStatus" />
  16. <result column="company_intention" jdbcType="CHAR" property="companyIntention" />
  17. <result column="follow_situation" jdbcType="INTEGER" property="followSituation" />
  18. <result column="tag" jdbcType="VARCHAR" property="tag" />
  19. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  20. <result column="follow_id" jdbcType="VARCHAR" property="followId" />
  21. <result column="effective" jdbcType="INTEGER" property="effective" />
  22. <result column="company_name" jdbcType="VARCHAR" property="companyName" />
  23. <result column="location_province" jdbcType="CHAR" property="locationProvince" />
  24. <result column="location_city" jdbcType="CHAR" property="locationCity" />
  25. <result column="location_area" jdbcType="CHAR" property="locationArea" />
  26. <result column="address" jdbcType="VARCHAR" property="address" />
  27. <result column="company_industry" jdbcType="VARCHAR" property="companyIndustry" />
  28. <result column="remarks" jdbcType="VARCHAR" property="remarks" />
  29. </resultMap>
  30. <sql id="Example_Where_Clause">
  31. <!--
  32. WARNING - @mbg.generated
  33. This element is automatically generated by MyBatis Generator, do not modify.
  34. This element was generated on Mon Nov 06 08:45:21 CST 2017.
  35. -->
  36. <where>
  37. <foreach collection="oredCriteria" item="criteria" separator="or">
  38. <if test="criteria.valid">
  39. <trim prefix="(" prefixOverrides="and" suffix=")">
  40. <foreach collection="criteria.criteria" item="criterion">
  41. <choose>
  42. <when test="criterion.noValue">
  43. and ${criterion.condition}
  44. </when>
  45. <when test="criterion.singleValue">
  46. and ${criterion.condition} #{criterion.value}
  47. </when>
  48. <when test="criterion.betweenValue">
  49. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  50. </when>
  51. <when test="criterion.listValue">
  52. and ${criterion.condition}
  53. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  54. #{listItem}
  55. </foreach>
  56. </when>
  57. </choose>
  58. </foreach>
  59. </trim>
  60. </if>
  61. </foreach>
  62. </where>
  63. </sql>
  64. <sql id="Update_By_Example_Where_Clause">
  65. <!--
  66. WARNING - @mbg.generated
  67. This element is automatically generated by MyBatis Generator, do not modify.
  68. This element was generated on Mon Nov 06 08:45:21 CST 2017.
  69. -->
  70. <where>
  71. <foreach collection="example.oredCriteria" item="criteria" separator="or">
  72. <if test="criteria.valid">
  73. <trim prefix="(" prefixOverrides="and" suffix=")">
  74. <foreach collection="criteria.criteria" item="criterion">
  75. <choose>
  76. <when test="criterion.noValue">
  77. and ${criterion.condition}
  78. </when>
  79. <when test="criterion.singleValue">
  80. and ${criterion.condition} #{criterion.value}
  81. </when>
  82. <when test="criterion.betweenValue">
  83. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  84. </when>
  85. <when test="criterion.listValue">
  86. and ${criterion.condition}
  87. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  88. #{listItem}
  89. </foreach>
  90. </when>
  91. </choose>
  92. </foreach>
  93. </trim>
  94. </if>
  95. </foreach>
  96. </where>
  97. </sql>
  98. <sql id="Base_Column_List">
  99. <!--
  100. WARNING - @mbg.generated
  101. This element is automatically generated by MyBatis Generator, do not modify.
  102. This element was generated on Mon Nov 06 08:45:21 CST 2017.
  103. -->
  104. id, aid, paid, share_type, customer_type, customer_status, company_intention, follow_situation,
  105. tag, create_time, follow_id, effective, company_name, location_province, location_city,
  106. location_area, address, company_industry, remarks
  107. </sql>
  108. <select id="selectByExample" parameterType="com.goafanti.common.model.CustomerExample" resultMap="BaseResultMap">
  109. <!--
  110. WARNING - @mbg.generated
  111. This element is automatically generated by MyBatis Generator, do not modify.
  112. This element was generated on Mon Nov 06 08:45:21 CST 2017.
  113. -->
  114. select
  115. <if test="distinct">
  116. distinct
  117. </if>
  118. <include refid="Base_Column_List" />
  119. from customer
  120. <if test="_parameter != null">
  121. <include refid="Example_Where_Clause" />
  122. </if>
  123. <if test="orderByClause != null">
  124. order by ${orderByClause}
  125. </if>
  126. </select>
  127. <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
  128. <!--
  129. WARNING - @mbg.generated
  130. This element is automatically generated by MyBatis Generator, do not modify.
  131. This element was generated on Mon Nov 06 08:45:21 CST 2017.
  132. -->
  133. select
  134. <include refid="Base_Column_List" />
  135. from customer
  136. where id = #{id,jdbcType=VARCHAR}
  137. </select>
  138. <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
  139. <!--
  140. WARNING - @mbg.generated
  141. This element is automatically generated by MyBatis Generator, do not modify.
  142. This element was generated on Mon Nov 06 08:45:21 CST 2017.
  143. -->
  144. delete from customer
  145. where id = #{id,jdbcType=VARCHAR}
  146. </delete>
  147. <delete id="deleteByExample" parameterType="com.goafanti.common.model.CustomerExample">
  148. <!--
  149. WARNING - @mbg.generated
  150. This element is automatically generated by MyBatis Generator, do not modify.
  151. This element was generated on Mon Nov 06 08:45:21 CST 2017.
  152. -->
  153. delete from customer
  154. <if test="_parameter != null">
  155. <include refid="Example_Where_Clause" />
  156. </if>
  157. </delete>
  158. <insert id="insert" parameterType="com.goafanti.common.model.Customer">
  159. <!--
  160. WARNING - @mbg.generated
  161. This element is automatically generated by MyBatis Generator, do not modify.
  162. This element was generated on Mon Nov 06 08:45:21 CST 2017.
  163. -->
  164. insert into customer (id, aid, paid,
  165. share_type, customer_type, customer_status,
  166. company_intention, follow_situation, tag,
  167. create_time, follow_id, effective,
  168. company_name, location_province, location_city,
  169. location_area, address, company_industry,
  170. remarks)
  171. values (#{id,jdbcType=VARCHAR}, #{aid,jdbcType=VARCHAR}, #{paid,jdbcType=VARCHAR},
  172. #{shareType,jdbcType=INTEGER}, #{customerType,jdbcType=INTEGER}, #{customerStatus,jdbcType=INTEGER},
  173. #{companyIntention,jdbcType=CHAR}, #{followSituation,jdbcType=INTEGER}, #{tag,jdbcType=VARCHAR},
  174. #{createTime,jdbcType=TIMESTAMP}, #{followId,jdbcType=VARCHAR}, #{effective,jdbcType=INTEGER},
  175. #{companyName,jdbcType=VARCHAR}, #{locationProvince,jdbcType=CHAR}, #{locationCity,jdbcType=CHAR},
  176. #{locationArea,jdbcType=CHAR}, #{address,jdbcType=VARCHAR}, #{companyIndustry,jdbcType=VARCHAR},
  177. #{remarks,jdbcType=VARCHAR})
  178. </insert>
  179. <insert id="insertSelective" parameterType="com.goafanti.common.model.Customer">
  180. <!--
  181. WARNING - @mbg.generated
  182. This element is automatically generated by MyBatis Generator, do not modify.
  183. This element was generated on Mon Nov 06 08:45:21 CST 2017.
  184. -->
  185. insert into customer
  186. <trim prefix="(" suffix=")" suffixOverrides=",">
  187. <if test="id != null">
  188. id,
  189. </if>
  190. <if test="aid != null">
  191. aid,
  192. </if>
  193. <if test="paid != null">
  194. paid,
  195. </if>
  196. <if test="shareType != null">
  197. share_type,
  198. </if>
  199. <if test="customerType != null">
  200. customer_type,
  201. </if>
  202. <if test="customerStatus != null">
  203. customer_status,
  204. </if>
  205. <if test="companyIntention != null">
  206. company_intention,
  207. </if>
  208. <if test="followSituation != null">
  209. follow_situation,
  210. </if>
  211. <if test="tag != null">
  212. tag,
  213. </if>
  214. <if test="createTime != null">
  215. create_time,
  216. </if>
  217. <if test="followId != null">
  218. follow_id,
  219. </if>
  220. <if test="effective != null">
  221. effective,
  222. </if>
  223. <if test="companyName != null">
  224. company_name,
  225. </if>
  226. <if test="locationProvince != null">
  227. location_province,
  228. </if>
  229. <if test="locationCity != null">
  230. location_city,
  231. </if>
  232. <if test="locationArea != null">
  233. location_area,
  234. </if>
  235. <if test="address != null">
  236. address,
  237. </if>
  238. <if test="companyIndustry != null">
  239. company_industry,
  240. </if>
  241. <if test="remarks != null">
  242. remarks,
  243. </if>
  244. </trim>
  245. <trim prefix="values (" suffix=")" suffixOverrides=",">
  246. <if test="id != null">
  247. #{id,jdbcType=VARCHAR},
  248. </if>
  249. <if test="aid != null">
  250. #{aid,jdbcType=VARCHAR},
  251. </if>
  252. <if test="paid != null">
  253. #{paid,jdbcType=VARCHAR},
  254. </if>
  255. <if test="shareType != null">
  256. #{shareType,jdbcType=INTEGER},
  257. </if>
  258. <if test="customerType != null">
  259. #{customerType,jdbcType=INTEGER},
  260. </if>
  261. <if test="customerStatus != null">
  262. #{customerStatus,jdbcType=INTEGER},
  263. </if>
  264. <if test="companyIntention != null">
  265. #{companyIntention,jdbcType=CHAR},
  266. </if>
  267. <if test="followSituation != null">
  268. #{followSituation,jdbcType=INTEGER},
  269. </if>
  270. <if test="tag != null">
  271. #{tag,jdbcType=VARCHAR},
  272. </if>
  273. <if test="createTime != null">
  274. #{createTime,jdbcType=TIMESTAMP},
  275. </if>
  276. <if test="followId != null">
  277. #{followId,jdbcType=VARCHAR},
  278. </if>
  279. <if test="effective != null">
  280. #{effective,jdbcType=INTEGER},
  281. </if>
  282. <if test="companyName != null">
  283. #{companyName,jdbcType=VARCHAR},
  284. </if>
  285. <if test="locationProvince != null">
  286. #{locationProvince,jdbcType=CHAR},
  287. </if>
  288. <if test="locationCity != null">
  289. #{locationCity,jdbcType=CHAR},
  290. </if>
  291. <if test="locationArea != null">
  292. #{locationArea,jdbcType=CHAR},
  293. </if>
  294. <if test="address != null">
  295. #{address,jdbcType=VARCHAR},
  296. </if>
  297. <if test="companyIndustry != null">
  298. #{companyIndustry,jdbcType=VARCHAR},
  299. </if>
  300. <if test="remarks != null">
  301. #{remarks,jdbcType=VARCHAR},
  302. </if>
  303. </trim>
  304. </insert>
  305. <select id="countByExample" parameterType="com.goafanti.common.model.CustomerExample" resultType="java.lang.Long">
  306. <!--
  307. WARNING - @mbg.generated
  308. This element is automatically generated by MyBatis Generator, do not modify.
  309. This element was generated on Mon Nov 06 08:45:21 CST 2017.
  310. -->
  311. select count(*) from customer
  312. <if test="_parameter != null">
  313. <include refid="Example_Where_Clause" />
  314. </if>
  315. </select>
  316. <update id="updateByExampleSelective" parameterType="map">
  317. <!--
  318. WARNING - @mbg.generated
  319. This element is automatically generated by MyBatis Generator, do not modify.
  320. This element was generated on Mon Nov 06 08:45:21 CST 2017.
  321. -->
  322. update customer
  323. <set>
  324. <if test="record.id != null">
  325. id = #{record.id,jdbcType=VARCHAR},
  326. </if>
  327. <if test="record.aid != null">
  328. aid = #{record.aid,jdbcType=VARCHAR},
  329. </if>
  330. <if test="record.paid != null">
  331. paid = #{record.paid,jdbcType=VARCHAR},
  332. </if>
  333. <if test="record.shareType != null">
  334. share_type = #{record.shareType,jdbcType=INTEGER},
  335. </if>
  336. <if test="record.customerType != null">
  337. customer_type = #{record.customerType,jdbcType=INTEGER},
  338. </if>
  339. <if test="record.customerStatus != null">
  340. customer_status = #{record.customerStatus,jdbcType=INTEGER},
  341. </if>
  342. <if test="record.companyIntention != null">
  343. company_intention = #{record.companyIntention,jdbcType=CHAR},
  344. </if>
  345. <if test="record.followSituation != null">
  346. follow_situation = #{record.followSituation,jdbcType=INTEGER},
  347. </if>
  348. <if test="record.tag != null">
  349. tag = #{record.tag,jdbcType=VARCHAR},
  350. </if>
  351. <if test="record.createTime != null">
  352. create_time = #{record.createTime,jdbcType=TIMESTAMP},
  353. </if>
  354. <if test="record.followId != null">
  355. follow_id = #{record.followId,jdbcType=VARCHAR},
  356. </if>
  357. <if test="record.effective != null">
  358. effective = #{record.effective,jdbcType=INTEGER},
  359. </if>
  360. <if test="record.companyName != null">
  361. company_name = #{record.companyName,jdbcType=VARCHAR},
  362. </if>
  363. <if test="record.locationProvince != null">
  364. location_province = #{record.locationProvince,jdbcType=CHAR},
  365. </if>
  366. <if test="record.locationCity != null">
  367. location_city = #{record.locationCity,jdbcType=CHAR},
  368. </if>
  369. <if test="record.locationArea != null">
  370. location_area = #{record.locationArea,jdbcType=CHAR},
  371. </if>
  372. <if test="record.address != null">
  373. address = #{record.address,jdbcType=VARCHAR},
  374. </if>
  375. <if test="record.companyIndustry != null">
  376. company_industry = #{record.companyIndustry,jdbcType=VARCHAR},
  377. </if>
  378. <if test="record.remarks != null">
  379. remarks = #{record.remarks,jdbcType=VARCHAR},
  380. </if>
  381. </set>
  382. <if test="_parameter != null">
  383. <include refid="Update_By_Example_Where_Clause" />
  384. </if>
  385. </update>
  386. <update id="updateByExample" parameterType="map">
  387. <!--
  388. WARNING - @mbg.generated
  389. This element is automatically generated by MyBatis Generator, do not modify.
  390. This element was generated on Mon Nov 06 08:45:21 CST 2017.
  391. -->
  392. update customer
  393. set id = #{record.id,jdbcType=VARCHAR},
  394. aid = #{record.aid,jdbcType=VARCHAR},
  395. paid = #{record.paid,jdbcType=VARCHAR},
  396. share_type = #{record.shareType,jdbcType=INTEGER},
  397. customer_type = #{record.customerType,jdbcType=INTEGER},
  398. customer_status = #{record.customerStatus,jdbcType=INTEGER},
  399. company_intention = #{record.companyIntention,jdbcType=CHAR},
  400. follow_situation = #{record.followSituation,jdbcType=INTEGER},
  401. tag = #{record.tag,jdbcType=VARCHAR},
  402. create_time = #{record.createTime,jdbcType=TIMESTAMP},
  403. follow_id = #{record.followId,jdbcType=VARCHAR},
  404. effective = #{record.effective,jdbcType=INTEGER},
  405. company_name = #{record.companyName,jdbcType=VARCHAR},
  406. location_province = #{record.locationProvince,jdbcType=CHAR},
  407. location_city = #{record.locationCity,jdbcType=CHAR},
  408. location_area = #{record.locationArea,jdbcType=CHAR},
  409. address = #{record.address,jdbcType=VARCHAR},
  410. company_industry = #{record.companyIndustry,jdbcType=VARCHAR},
  411. remarks = #{record.remarks,jdbcType=VARCHAR}
  412. <if test="_parameter != null">
  413. <include refid="Update_By_Example_Where_Clause" />
  414. </if>
  415. </update>
  416. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.Customer">
  417. <!--
  418. WARNING - @mbg.generated
  419. This element is automatically generated by MyBatis Generator, do not modify.
  420. This element was generated on Mon Nov 06 08:45:21 CST 2017.
  421. -->
  422. update customer
  423. <set>
  424. <if test="aid != null">
  425. aid = #{aid,jdbcType=VARCHAR},
  426. </if>
  427. <if test="paid != null">
  428. paid = #{paid,jdbcType=VARCHAR},
  429. </if>
  430. <if test="shareType != null">
  431. share_type = #{shareType,jdbcType=INTEGER},
  432. </if>
  433. <if test="customerType != null">
  434. customer_type = #{customerType,jdbcType=INTEGER},
  435. </if>
  436. <if test="customerStatus != null">
  437. customer_status = #{customerStatus,jdbcType=INTEGER},
  438. </if>
  439. <if test="companyIntention != null">
  440. company_intention = #{companyIntention,jdbcType=CHAR},
  441. </if>
  442. <if test="followSituation != null">
  443. follow_situation = #{followSituation,jdbcType=INTEGER},
  444. </if>
  445. <if test="tag != null">
  446. tag = #{tag,jdbcType=VARCHAR},
  447. </if>
  448. <if test="createTime != null">
  449. create_time = #{createTime,jdbcType=TIMESTAMP},
  450. </if>
  451. <if test="followId != null">
  452. follow_id = #{followId,jdbcType=VARCHAR},
  453. </if>
  454. <if test="effective != null">
  455. effective = #{effective,jdbcType=INTEGER},
  456. </if>
  457. <if test="companyName != null">
  458. company_name = #{companyName,jdbcType=VARCHAR},
  459. </if>
  460. <if test="locationProvince != null">
  461. location_province = #{locationProvince,jdbcType=CHAR},
  462. </if>
  463. <if test="locationCity != null">
  464. location_city = #{locationCity,jdbcType=CHAR},
  465. </if>
  466. <if test="locationArea != null">
  467. location_area = #{locationArea,jdbcType=CHAR},
  468. </if>
  469. <if test="address != null">
  470. address = #{address,jdbcType=VARCHAR},
  471. </if>
  472. <if test="companyIndustry != null">
  473. company_industry = #{companyIndustry,jdbcType=VARCHAR},
  474. </if>
  475. <if test="remarks != null">
  476. remarks = #{remarks,jdbcType=VARCHAR},
  477. </if>
  478. </set>
  479. where id = #{id,jdbcType=VARCHAR}
  480. </update>
  481. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.Customer">
  482. <!--
  483. WARNING - @mbg.generated
  484. This element is automatically generated by MyBatis Generator, do not modify.
  485. This element was generated on Mon Nov 06 08:45:21 CST 2017.
  486. -->
  487. update customer
  488. set aid = #{aid,jdbcType=VARCHAR},
  489. paid = #{paid,jdbcType=VARCHAR},
  490. share_type = #{shareType,jdbcType=INTEGER},
  491. customer_type = #{customerType,jdbcType=INTEGER},
  492. customer_status = #{customerStatus,jdbcType=INTEGER},
  493. company_intention = #{companyIntention,jdbcType=CHAR},
  494. follow_situation = #{followSituation,jdbcType=INTEGER},
  495. tag = #{tag,jdbcType=VARCHAR},
  496. create_time = #{createTime,jdbcType=TIMESTAMP},
  497. follow_id = #{followId,jdbcType=VARCHAR},
  498. effective = #{effective,jdbcType=INTEGER},
  499. company_name = #{companyName,jdbcType=VARCHAR},
  500. location_province = #{locationProvince,jdbcType=CHAR},
  501. location_city = #{locationCity,jdbcType=CHAR},
  502. location_area = #{locationArea,jdbcType=CHAR},
  503. address = #{address,jdbcType=VARCHAR},
  504. company_industry = #{companyIndustry,jdbcType=VARCHAR},
  505. remarks = #{remarks,jdbcType=VARCHAR}
  506. where id = #{id,jdbcType=VARCHAR}
  507. </update>
  508. <select id="selectCustomer" resultType="com.goafanti.customer.bo.CustomerOut">
  509. select a.id,a.aid,a.customer_type as customerType,a.share_type as shareType,a.company_intention as CompanyIntention,
  510. a.tag,a.follow_situation as followSituation,a.customer_status as customerStatus,
  511. a.company_name as companyName,a.location_province as locationProvince,
  512. b.follow_date as followDate,
  513. c.name as contactName ,c.mobile,c.tel_num as telNum,
  514. e.name as adminName,
  515. b.follow_date as followDate
  516. from customer a
  517. left join follow_up_record b on a.follow_id = b.id
  518. left join customer_user_info c on b.cuid = c.id
  519. left join admin e on a.aid = e.id
  520. where a.effective = 0
  521. <if test="aid != null and aid != ''">
  522. and (a.aid = #{aid,jdbcType=VARCHAR}
  523. </if>
  524. <if test="aid == null or aid == ''">
  525. and (1=1
  526. </if>
  527. <if test="paid != null and paid != ''">
  528. or a.paid like concat('%',#{paid,jdbcType=VARCHAR},'%'))
  529. </if>
  530. <if test="paid == null or paid == ''">
  531. )
  532. </if>
  533. <if test="shareType != null">
  534. and a.share_type = #{shareType,jdbcType=INTEGER}
  535. </if>
  536. <if test="customerType != null">
  537. and a.customer_type = #{customerType,jdbcType=INTEGER}
  538. </if>
  539. <if test="customerStauts != null">
  540. and a.customer_status = #{customerStauts,jdbcType=INTEGER}
  541. </if>
  542. <if test="companyIntention != null">
  543. and a.company_intention = #{companyIntention,jdbcType=INTEGER}
  544. </if>
  545. <if test="followSituation != null">
  546. and a.follow_situation = #{followSituation,jdbcType=INTEGER}
  547. </if>
  548. <if test="locationProvince != null">
  549. and a.location_province = #{locationProvince,jdbcType=VARCHAR}
  550. </if>
  551. <if test="companyName != null and companyName != ''">
  552. and a.company_name like concat('%',#{companyName,jdbcType=VARCHAR},'%')
  553. </if>
  554. <if test="contactName != null">
  555. and c.name = #{contactName,jdbcType=VARCHAR}
  556. </if>
  557. <if test="contactTel != null">
  558. and c.tel_num = #{contactTel,jdbcType=VARCHAR}
  559. </if>
  560. <if test="adminName != null and adminName != ''">
  561. and e.name like concat('%',#{adminName,jdbcType=VARCHAR},'%')
  562. </if>
  563. <if test="startDate != null and startDate != ''">
  564. and b.follow_date &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  565. </if>
  566. <if test="endDate != null and endDate != ''">
  567. and b.follow_date &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  568. </if>
  569. order by a.create_time desc
  570. <if test="page_sql!=null">
  571. ${page_sql}
  572. </if>
  573. </select>
  574. <select id="selectCustomerCount" resultType="java.lang.Integer">
  575. select count(0)
  576. from customer a
  577. left join follow_up_record b on a.follow_id = b.id
  578. left join customer_user_info c on b.cuid = c.id
  579. left join admin e on a.aid = e.id
  580. where a.effective = 0
  581. <if test="aid != null and aid != ''">
  582. and (a.aid = #{aid,jdbcType=VARCHAR}
  583. </if>
  584. <if test="aid == null or aid == ''">
  585. and (1=1
  586. </if>
  587. <if test="paid != null and paid != ''">
  588. or a.paid like concat('%',#{paid,jdbcType=VARCHAR},'%'))
  589. </if>
  590. <if test="paid == null or paid == ''">
  591. )
  592. </if>
  593. <if test="shareType != null">
  594. and a.share_type = #{shareType,jdbcType=INTEGER}
  595. </if>
  596. <if test="customerType != null">
  597. and a.customer_type = #{customerType,jdbcType=INTEGER}
  598. </if>
  599. <if test="customerStauts != null">
  600. and a.customer_status = #{customerStauts,jdbcType=INTEGER}
  601. </if>
  602. <if test="companyIntention != null">
  603. and a.company_intention = #{companyIntention,jdbcType=INTEGER}
  604. </if>
  605. <if test="followSituation != null">
  606. and a.follow_situation = #{followSituation,jdbcType=INTEGER}
  607. </if>
  608. <if test="companyName != null and companyName != ''">
  609. and a.company_name like concat('%',#{companyName,jdbcType=VARCHAR},'%')
  610. </if>
  611. <if test="locationProvince != null">
  612. and a.location_province = #{locationProvince,jdbcType=VARCHAR}
  613. </if>
  614. <if test="contactName != null">
  615. and c.name = #{contactName,jdbcType=VARCHAR}
  616. </if>
  617. <if test="contactTel != null">
  618. and c.tel_num = #{contactTel,jdbcType=VARCHAR}
  619. </if>
  620. <if test="adminName != null and adminName != ''">
  621. and e.name like concat('%',#{adminName,jdbcType=VARCHAR},'%')
  622. </if>
  623. <if test="startDate != null and startDate != ''">
  624. and b.follow_date &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  625. </if>
  626. <if test="endDate != null and endDate != ''">
  627. and b.follow_date &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  628. </if>
  629. </select>
  630. <select id="selectCustomerById" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerOut">
  631. select
  632. a.id as cid,
  633. a.tag,
  634. a.customer_type as customerType,
  635. a.share_type as shareType,
  636. a.company_intention as companyIntention,
  637. a.create_time as createTime,
  638. a.follow_situation as followSituation,
  639. a.customer_status as customerStatus,
  640. a.company_name as companyName,
  641. a.location_province as locationProvince,
  642. a.company_industry as companyIndustry,
  643. a.address,
  644. a.remarks,
  645. d.name as adminName
  646. from customer a
  647. left join admin d on a.aid=d.id
  648. where a.id = #{id,jdbcType=VARCHAR}
  649. </select>
  650. <select id="selectByLadderId" parameterType="java.lang.String" resultMap="BaseResultMap">
  651. select
  652. <include refid="Base_Column_List" />
  653. from customer
  654. where aid = #{ladderId} or paid like concat('%',#{ladderId},'%')
  655. </select>
  656. <select id="findCustomerHistory" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerOut">
  657. select
  658. a.id as cid,a.aid, a.create_time as createTime,
  659. a.follow_situation as followSituation,a.customer_status as customerStatus,
  660. a.company_name as customerName,
  661. c.followCount,
  662. d.follow_date as followDate,
  663. e.name as contactName,
  664. f.operatorTime,
  665. g.name as adminName
  666. from customer a
  667. left join (select ifnull(0,count(0)) as followCount,r.aid,r.cid from follow_up_record r group by r.aid,r.cid) c
  668. on a.id = c.cid and a.aid = c.aid
  669. left join follow_up_record d on a.follow_id = d.id
  670. left join customer_user_info e on d.cuid = e.id
  671. left join (select l1.cid,l1.operator_time as operatorTime from customer_log l1 ,
  672. (select cid, max(operator_time) as operator_time from customer_log group by cid ) l2
  673. where l1.cid = l2.cid and l1.operator_time = l2.operator_time)f
  674. on a.id = f.cid
  675. left join admin g on a.aid = g.id
  676. where a.id = #{id,jdbcType=VARCHAR}
  677. </select>
  678. <select id="findCustomerByName" parameterType="java.lang.String" resultType="java.lang.Integer">
  679. select count(0) from customer where company_name = #{companyName,jdbcType=VARCHAR}
  680. </select>
  681. </mapper>