TbBusinessMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.huike.business.mapper.TbBusinessMapper">
  6. <resultMap type="TbBusiness" id="TbBusinessResult">
  7. <result property="id" column="id" />
  8. <result property="name" column="name" />
  9. <result property="phone" column="phone" />
  10. <result property="channel" column="channel" />
  11. <result property="activityId" column="activity_id" />
  12. <result property="provinces" column="provinces" />
  13. <result property="city" column="city" />
  14. <result property="sex" column="sex" />
  15. <result property="age" column="age" />
  16. <result property="weixin" column="weixin" />
  17. <result property="qq" column="qq" />
  18. <result property="level" column="level" />
  19. <result property="subject" column="subject" />
  20. <result property="courseId" column="course_id" />
  21. <result property="createBy" column="create_by" />
  22. <result property="createTime" column="create_time" />
  23. <result property="occupation" column="occupation" />
  24. <result property="education" column="education" />
  25. <result property="job" column="job" />
  26. <result property="salary" column="salary" />
  27. <result property="major" column="major" />
  28. <result property="expectedSalary" column="expected_salary" />
  29. <result property="reasons" column="reasons" />
  30. <result property="plan" column="plan" />
  31. <result property="planTime" column="plan_time" />
  32. <result property="otherIntention" column="other_intention" />
  33. <result property="nextTime" column="next_time" />
  34. <result property="status" column="status" />
  35. <result property="clue_id" column="clueId" />
  36. </resultMap>
  37. <resultMap type="TbBusiness" id="TbBusinessAssignResult">
  38. <result property="id" column="id" />
  39. <result property="name" column="name" />
  40. <result property="phone" column="phone" />
  41. <result property="channel" column="channel" />
  42. <result property="activityId" column="activity_id" />
  43. <result property="provinces" column="provinces" />
  44. <result property="city" column="city" />
  45. <result property="sex" column="sex" />
  46. <result property="age" column="age" />
  47. <result property="weixin" column="weixin" />
  48. <result property="qq" column="qq" />
  49. <result property="level" column="level" />
  50. <result property="subject" column="subject" />
  51. <result property="courseId" column="course_id" />
  52. <result property="createBy" column="create_by" />
  53. <result property="createTime" column="create_time" />
  54. <result property="occupation" column="occupation" />
  55. <result property="education" column="education" />
  56. <result property="job" column="job" />
  57. <result property="salary" column="salary" />
  58. <result property="major" column="major" />
  59. <result property="expectedSalary" column="expected_salary" />
  60. <result property="reasons" column="reasons" />
  61. <result property="plan" column="plan" />
  62. <result property="planTime" column="plan_time" />
  63. <result property="otherIntention" column="other_intention" />
  64. <result property="nextTime" column="next_time" />
  65. <result property="status" column="status" />
  66. <result property="assignBy" column="assign_by" />
  67. <result property="owner" column="owner" />
  68. <result property="ownerTime" column="owner_time" />
  69. <result property="clue_id" column="clueId" />
  70. </resultMap>
  71. <sql id="selectTbBusinessVo">
  72. select id, name, phone, channel, activity_id, provinces, city, sex, age, weixin, qq, level, subject, course_id, create_by, create_time, occupation, education, job, salary, major,
  73. expected_salary, reasons, plan, plan_time, other_intention, next_time, status from tb_business
  74. </sql>
  75. <sql id="selectTbBusinesAssignVo">
  76. select b.id, b.name, b.phone, b.channel, b.activity_id, b.provinces, b.city, b.sex, b.age, b.weixin, b.qq, b.level, b.subject,
  77. b.course_id, b.create_by, b.create_time, b.occupation, b.education, b.job, b.salary, b.major,
  78. b.expected_salary, b.reasons, b.plan, b.plan_time, b.other_intention, b.next_time, b.status,
  79. r.create_by as assign_by, r.user_name as owner,r.create_time as owner_time from tb_business b
  80. left join tb_assign_record r on b.id=r.assign_id
  81. </sql>
  82. <select id="selectTbBusinessPool" parameterType="TbBusiness" resultMap="TbBusinessResult">
  83. <include refid="selectTbBusinessVo"/>
  84. <where>
  85. <if test="id != null and id != ''"> and id = #{id}</if>
  86. <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
  87. <if test="phone != null and phone != ''"> and phone = #{phone}</if>
  88. <if test="channel != null and channel != ''"> and channel = #{channel}</if>
  89. <if test="activityId != null "> and activity_id = #{activityId}</if>
  90. <if test="provinces != null and provinces != ''"> and provinces = #{provinces}</if>
  91. <if test="city != null and city != ''"> and city = #{city}</if>
  92. <if test="sex != null and sex != ''"> and sex = #{sex}</if>
  93. <if test="age != null "> and age = #{age}</if>
  94. <if test="weixin != null and weixin != ''"> and weixin = #{weixin}</if>
  95. <if test="qq != null and qq != ''"> and qq = #{qq}</if>
  96. <if test="level != null and level != ''"> and level = #{level}</if>
  97. <if test="subject != null and subject != ''"> and subject = #{subject}</if>
  98. <if test="courseId != null "> and course_id = #{courseId}</if>
  99. <if test="params.beginCreateTime != null and params.endCreateTime != null"> and create_time between #{beginCreateTime} and #{endCreateTime}</if>
  100. <if test="occupation != null and occupation != ''"> and occupation = #{occupation}</if>
  101. <if test="education != null and education != ''"> and education = #{education}</if>
  102. <if test="job != null and job != ''"> and job = #{job}</if>
  103. <if test="salary != null and salary != ''"> and salary = #{salary}</if>
  104. <if test="major != null and major != ''"> and major = #{major}</if>
  105. <if test="expectedSalary != null and expectedSalary != ''"> and expected_salary = #{expectedSalary}</if>
  106. <if test="reasons != null and reasons != ''"> and reasons = #{reasons}</if>
  107. <if test="plan != null and plan != ''"> and plan = #{plan}</if>
  108. <if test="planTime != null "> and plan_time = #{planTime}</if>
  109. <if test="otherIntention != null and otherIntention != ''"> and other_intention = #{otherIntention}</if>
  110. <if test="nextTime != null "> and next_time = #{nextTime}</if>
  111. and status IN ('3','4')
  112. </where>
  113. </select>
  114. <select id="selectTbBusinessList" parameterType="TbBusiness" resultMap="TbBusinessAssignResult">
  115. <include refid="selectTbBusinesAssignVo"/>
  116. <where>
  117. <if test="id != null and id != ''"> and b.id like concat('%', #{id}, '%')</if>
  118. <if test="name != null and name != ''"> and b.name like concat('%', #{name}, '%')</if>
  119. <if test="phone != null and phone != ''"> and b.phone like concat('%', #{phone}, '%')</if>
  120. <if test="channel != null and channel != ''"> and b.channel = #{channel}</if>
  121. <if test="activityId != null "> and b.activity_id = #{activityId}</if>
  122. <if test="provinces != null and provinces != ''"> and b.provinces = #{provinces}</if>
  123. <if test="city != null and city != ''"> and b.city = #{city}</if>
  124. <if test="sex != null and sex != ''"> and b.sex = #{sex}</if>
  125. <if test="age != null "> and b.age = #{age}</if>
  126. <if test="weixin != null and weixin != ''"> and b.weixin = #{weixin}</if>
  127. <if test="qq != null and qq != ''"> and b.qq = #{qq}</if>
  128. <if test="level != null and level != ''"> and b.level = #{level}</if>
  129. <if test="subject != null and subject != ''"> and b.subject = #{subject}</if>
  130. <if test="courseId != null "> and b.course_id = #{courseId}</if>
  131. <if test="occupation != null and occupation != ''"> and b.occupation = #{occupation}</if>
  132. <if test="education != null and education != ''"> and b.education = #{education}</if>
  133. <if test="job != null and job != ''"> and b.job = #{job}</if>
  134. <if test="salary != null and salary != ''"> and b.salary = #{salary}</if>
  135. <if test="major != null and major != ''"> and b.major = #{major}</if>
  136. <if test="expectedSalary != null and expectedSalary != ''"> and b.expected_salary = #{expectedSalary}</if>
  137. <if test="reasons != null and reasons != ''"> and b.reasons = #{reasons}</if>
  138. <if test="plan != null and plan != ''"> and b.plan = #{plan}</if>
  139. <if test="planTime != null "> and b.plan_time = #{planTime}</if>
  140. <if test="otherIntention != null and otherIntention != ''"> and b.other_intention = #{otherIntention}</if>
  141. <if test="nextTime != null "> and b.next_time = #{nextTime}</if>
  142. <if test="status != null and status != ''"> and status=#{status}</if>
  143. <if test="beginCreateTime != null and endCreateTime != null "> and DATE_FORMAT(b.create_time,'%Y-%m-%d') BETWEEN #{beginCreateTime} AND #{endCreateTime}</if>
  144. AND (r.latest = '1' OR r.id IS NULL)
  145. AND (r.type = '1' OR r.id IS NULL)
  146. </where>
  147. <!-- 数据范围过滤 -->
  148. <if test="params.dataScope != null and params.dataScope != ''">
  149. AND (${params.dataScope} OR r.id IS NULL)
  150. </if>
  151. ORDER BY b.`create_time` DESC
  152. </select>
  153. <select id="selectTbBusinessById" parameterType="Long" resultMap="TbBusinessResult">
  154. <include refid="selectTbBusinessVo"/>
  155. where id = #{id}
  156. </select>
  157. <insert id="insertTbBusiness" parameterType="TbBusiness" useGeneratedKeys="true" keyProperty="id">
  158. insert into tb_business
  159. <trim prefix="(" suffix=")" suffixOverrides=",">
  160. <if test="name != null">name,</if>
  161. <if test="phone != null">phone,</if>
  162. <if test="channel != null">channel,</if>
  163. <if test="activityId != null">activity_id,</if>
  164. <if test="provinces != null">provinces,</if>
  165. <if test="city != null">city,</if>
  166. <if test="sex != null and sex != ''">sex,</if>
  167. <if test="age != null">age,</if>
  168. <if test="weixin != null">weixin,</if>
  169. <if test="qq != null">qq,</if>
  170. <if test="level != null">level,</if>
  171. <if test="subject != null">subject,</if>
  172. <if test="courseId != null">course_id,</if>
  173. <if test="createBy != null">create_by,</if>
  174. <if test="createTime != null">create_time,</if>
  175. <if test="occupation != null">occupation,</if>
  176. <if test="education != null">education,</if>
  177. <if test="job != null">job,</if>
  178. <if test="salary != null">salary,</if>
  179. <if test="major != null">major,</if>
  180. <if test="expectedSalary != null">expected_salary,</if>
  181. <if test="reasons != null">reasons,</if>
  182. <if test="plan != null">plan,</if>
  183. <if test="planTime != null">plan_time,</if>
  184. <if test="otherIntention != null">other_intention,</if>
  185. <if test="nextTime != null">next_time,</if>
  186. <if test="status != null">status,</if>
  187. <if test="clueId != null">clue_id,</if>
  188. <if test="transfer != null">transfer,</if>
  189. </trim>
  190. <trim prefix="values (" suffix=")" suffixOverrides=",">
  191. <if test="name != null">#{name},</if>
  192. <if test="phone != null">#{phone},</if>
  193. <if test="channel != null">#{channel},</if>
  194. <if test="activityId != null">#{activityId},</if>
  195. <if test="provinces != null">#{provinces},</if>
  196. <if test="city != null">#{city},</if>
  197. <if test="sex != null and sex != ''">#{sex},</if>
  198. <if test="age != null">#{age},</if>
  199. <if test="weixin != null">#{weixin},</if>
  200. <if test="qq != null">#{qq},</if>
  201. <if test="level != null">#{level},</if>
  202. <if test="subject != null">#{subject},</if>
  203. <if test="courseId != null">#{courseId},</if>
  204. <if test="createBy != null">#{createBy},</if>
  205. <if test="createTime != null">#{createTime},</if>
  206. <if test="occupation != null">#{occupation},</if>
  207. <if test="education != null">#{education},</if>
  208. <if test="job != null">#{job},</if>
  209. <if test="salary != null">#{salary},</if>
  210. <if test="major != null">#{major},</if>
  211. <if test="expectedSalary != null">#{expectedSalary},</if>
  212. <if test="reasons != null">#{reasons},</if>
  213. <if test="plan != null">#{plan},</if>
  214. <if test="planTime != null">#{planTime},</if>
  215. <if test="otherIntention != null">#{otherIntention},</if>
  216. <if test="nextTime != null">#{nextTime},</if>
  217. <if test="status != null">#{status},</if>
  218. <if test="clueId != null">#{clueId},</if>
  219. <if test="transfer != null">#{transfer},</if>
  220. </trim>
  221. </insert>
  222. <update id="updateTbBusiness" parameterType="TbBusiness">
  223. update tb_business
  224. <trim prefix="SET" suffixOverrides=",">
  225. <if test="name != null">name = #{name},</if>
  226. <if test="phone != null">phone = #{phone},</if>
  227. <if test="channel != null">channel = #{channel},</if>
  228. <if test="activityId != null">activity_id = #{activityId},</if>
  229. <if test="provinces != null">provinces = #{provinces},</if>
  230. <if test="city != null">city = #{city},</if>
  231. <if test="sex != null and sex != ''">sex = #{sex},</if>
  232. <if test="age != null">age = #{age},</if>
  233. <if test="weixin != null">weixin = #{weixin},</if>
  234. <if test="qq != null">qq = #{qq},</if>
  235. <if test="level != null">level = #{level},</if>
  236. <if test="subject != null">subject = #{subject},</if>
  237. <if test="courseId != null">course_id = #{courseId},</if>
  238. <if test="createBy != null">create_by = #{createBy},</if>
  239. <if test="createTime != null">create_time = #{createTime},</if>
  240. <if test="occupation != null">occupation = #{occupation},</if>
  241. <if test="education != null">education = #{education},</if>
  242. <if test="job != null">job = #{job},</if>
  243. <if test="salary != null">salary = #{salary},</if>
  244. <if test="major != null">major = #{major},</if>
  245. <if test="expectedSalary != null">expected_salary = #{expectedSalary},</if>
  246. <if test="reasons != null">reasons = #{reasons},</if>
  247. <if test="plan != null">plan = #{plan},</if>
  248. <if test="planTime != null">plan_time = #{planTime},</if>
  249. <if test="otherIntention != null">other_intention = #{otherIntention},</if>
  250. <if test="nextTime != null">next_time = #{nextTime},</if>
  251. <if test="status != null">status = #{status},</if>
  252. </trim>
  253. where id = #{id}
  254. </update>
  255. <delete id="deleteTbBusinessById" parameterType="Long">
  256. delete from tb_business where id = #{id}
  257. </delete>
  258. <delete id="deleteTbBusinessByIds" parameterType="String">
  259. delete from tb_business where id in
  260. <foreach item="id" collection="array" open="(" separator="," close=")">
  261. #{id}
  262. </foreach>
  263. </delete>
  264. <update id="resetNextTimeAndStatus">
  265. update tb_business set next_time=null, status=#{status} where id = #{id}
  266. </update>
  267. <update id="setTransfer">
  268. update tb_business set next_time=null, status=#{status}, transfer='1' where id = #{id}
  269. </update>
  270. <update id="updateBusinessEndTimeById">
  271. update tb_business set end_time=#{endTime},next_time = null where id = #{id}
  272. </update>
  273. </mapper>