TOrderBonusMapper.xml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  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.TOrderBonusMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.TOrderBonus">
  5. <!--
  6. WARNING - @mbggenerated
  7. This element is automatically generated by MyBatis Generator, do not modify.
  8. This element was generated on Fri Nov 23 16:33:27 CST 2018.
  9. -->
  10. <id column="id" jdbcType="VARCHAR" property="id" />
  11. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  12. <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
  13. <result column="bonus_subject" jdbcType="INTEGER" property="bonusSubject" />
  14. <result column="grant_status" jdbcType="INTEGER" property="grantStatus" />
  15. <result column="grant_target" jdbcType="VARCHAR" property="grantTarget" />
  16. <result column="grant_by" jdbcType="VARCHAR" property="grantBy" />
  17. <result column="grant_time" jdbcType="DATE" property="grantTime" />
  18. </resultMap>
  19. <sql id="Example_Where_Clause">
  20. <!--
  21. WARNING - @mbggenerated
  22. This element is automatically generated by MyBatis Generator, do not modify.
  23. This element was generated on Fri Nov 23 16:33:27 CST 2018.
  24. -->
  25. <where>
  26. <foreach collection="oredCriteria" item="criteria" separator="or">
  27. <if test="criteria.valid">
  28. <trim prefix="(" prefixOverrides="and" suffix=")">
  29. <foreach collection="criteria.criteria" item="criterion">
  30. <choose>
  31. <when test="criterion.noValue">
  32. and ${criterion.condition}
  33. </when>
  34. <when test="criterion.singleValue">
  35. and ${criterion.condition} #{criterion.value}
  36. </when>
  37. <when test="criterion.betweenValue">
  38. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  39. </when>
  40. <when test="criterion.listValue">
  41. and ${criterion.condition}
  42. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  43. #{listItem}
  44. </foreach>
  45. </when>
  46. </choose>
  47. </foreach>
  48. </trim>
  49. </if>
  50. </foreach>
  51. </where>
  52. </sql>
  53. <sql id="Update_By_Example_Where_Clause">
  54. <!--
  55. WARNING - @mbggenerated
  56. This element is automatically generated by MyBatis Generator, do not modify.
  57. This element was generated on Fri Nov 23 16:33:27 CST 2018.
  58. -->
  59. <where>
  60. <foreach collection="example.oredCriteria" item="criteria" separator="or">
  61. <if test="criteria.valid">
  62. <trim prefix="(" prefixOverrides="and" suffix=")">
  63. <foreach collection="criteria.criteria" item="criterion">
  64. <choose>
  65. <when test="criterion.noValue">
  66. and ${criterion.condition}
  67. </when>
  68. <when test="criterion.singleValue">
  69. and ${criterion.condition} #{criterion.value}
  70. </when>
  71. <when test="criterion.betweenValue">
  72. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  73. </when>
  74. <when test="criterion.listValue">
  75. and ${criterion.condition}
  76. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  77. #{listItem}
  78. </foreach>
  79. </when>
  80. </choose>
  81. </foreach>
  82. </trim>
  83. </if>
  84. </foreach>
  85. </where>
  86. </sql>
  87. <sql id="Base_Column_List">
  88. <!--
  89. WARNING - @mbggenerated
  90. This element is automatically generated by MyBatis Generator, do not modify.
  91. This element was generated on Fri Nov 23 16:33:27 CST 2018.
  92. -->
  93. id, create_time, order_no, bonus_subject, grant_status, grant_target, grant_by, grant_time
  94. </sql>
  95. <select id="selectByExample" parameterType="com.goafanti.common.model.TOrderBonusExample" resultMap="BaseResultMap">
  96. <!--
  97. WARNING - @mbggenerated
  98. This element is automatically generated by MyBatis Generator, do not modify.
  99. This element was generated on Fri Nov 23 16:33:27 CST 2018.
  100. -->
  101. select
  102. <if test="distinct">
  103. distinct
  104. </if>
  105. <include refid="Base_Column_List" />
  106. from t_order_bonus
  107. <if test="_parameter != null">
  108. <include refid="Example_Where_Clause" />
  109. </if>
  110. <if test="orderByClause != null">
  111. order by ${orderByClause}
  112. </if>
  113. </select>
  114. <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
  115. <!--
  116. WARNING - @mbggenerated
  117. This element is automatically generated by MyBatis Generator, do not modify.
  118. This element was generated on Fri Nov 23 16:33:27 CST 2018.
  119. -->
  120. select
  121. <include refid="Base_Column_List" />
  122. from t_order_bonus
  123. where id = #{id,jdbcType=VARCHAR}
  124. </select>
  125. <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
  126. <!--
  127. WARNING - @mbggenerated
  128. This element is automatically generated by MyBatis Generator, do not modify.
  129. This element was generated on Fri Nov 23 16:33:27 CST 2018.
  130. -->
  131. delete from t_order_bonus
  132. where id = #{id,jdbcType=VARCHAR}
  133. </delete>
  134. <delete id="deleteByExample" parameterType="com.goafanti.common.model.TOrderBonusExample">
  135. <!--
  136. WARNING - @mbggenerated
  137. This element is automatically generated by MyBatis Generator, do not modify.
  138. This element was generated on Fri Nov 23 16:33:27 CST 2018.
  139. -->
  140. delete from t_order_bonus
  141. <if test="_parameter != null">
  142. <include refid="Example_Where_Clause" />
  143. </if>
  144. </delete>
  145. <insert id="insert" parameterType="com.goafanti.common.model.TOrderBonus">
  146. <!--
  147. WARNING - @mbggenerated
  148. This element is automatically generated by MyBatis Generator, do not modify.
  149. This element was generated on Fri Nov 23 16:33:27 CST 2018.
  150. -->
  151. insert into t_order_bonus (id, create_time, order_no,
  152. bonus_subject, grant_status, grant_target,
  153. grant_by, grant_time)
  154. values (#{id,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{orderNo,jdbcType=VARCHAR},
  155. #{bonusSubject,jdbcType=INTEGER}, #{grantStatus,jdbcType=INTEGER}, #{grantTarget,jdbcType=VARCHAR},
  156. #{grantBy,jdbcType=VARCHAR}, #{grantTime,jdbcType=DATE})
  157. </insert>
  158. <insert id="insertSelective" parameterType="com.goafanti.common.model.TOrderBonus">
  159. <!--
  160. WARNING - @mbggenerated
  161. This element is automatically generated by MyBatis Generator, do not modify.
  162. This element was generated on Fri Nov 23 16:33:27 CST 2018.
  163. -->
  164. insert into t_order_bonus
  165. <trim prefix="(" suffix=")" suffixOverrides=",">
  166. <if test="id != null">
  167. id,
  168. </if>
  169. <if test="createTime != null">
  170. create_time,
  171. </if>
  172. <if test="orderNo != null">
  173. order_no,
  174. </if>
  175. <if test="bonusSubject != null">
  176. bonus_subject,
  177. </if>
  178. <if test="grantStatus != null">
  179. grant_status,
  180. </if>
  181. <if test="grantTarget != null">
  182. grant_target,
  183. </if>
  184. <if test="grantBy != null">
  185. grant_by,
  186. </if>
  187. <if test="grantTime != null">
  188. grant_time,
  189. </if>
  190. </trim>
  191. <trim prefix="values (" suffix=")" suffixOverrides=",">
  192. <if test="id != null">
  193. #{id,jdbcType=VARCHAR},
  194. </if>
  195. <if test="createTime != null">
  196. #{createTime,jdbcType=TIMESTAMP},
  197. </if>
  198. <if test="orderNo != null">
  199. #{orderNo,jdbcType=VARCHAR},
  200. </if>
  201. <if test="bonusSubject != null">
  202. #{bonusSubject,jdbcType=INTEGER},
  203. </if>
  204. <if test="grantStatus != null">
  205. #{grantStatus,jdbcType=INTEGER},
  206. </if>
  207. <if test="grantTarget != null">
  208. #{grantTarget,jdbcType=VARCHAR},
  209. </if>
  210. <if test="grantBy != null">
  211. #{grantBy,jdbcType=VARCHAR},
  212. </if>
  213. <if test="grantTime != null">
  214. #{grantTime,jdbcType=DATE},
  215. </if>
  216. </trim>
  217. </insert>
  218. <select id="countByExample" parameterType="com.goafanti.common.model.TOrderBonusExample" resultType="java.lang.Integer">
  219. <!--
  220. WARNING - @mbggenerated
  221. This element is automatically generated by MyBatis Generator, do not modify.
  222. This element was generated on Fri Nov 23 16:33:27 CST 2018.
  223. -->
  224. select count(*) from t_order_bonus
  225. <if test="_parameter != null">
  226. <include refid="Example_Where_Clause" />
  227. </if>
  228. </select>
  229. <update id="updateByExampleSelective" parameterType="map">
  230. <!--
  231. WARNING - @mbggenerated
  232. This element is automatically generated by MyBatis Generator, do not modify.
  233. This element was generated on Fri Nov 23 16:33:27 CST 2018.
  234. -->
  235. update t_order_bonus
  236. <set>
  237. <if test="record.id != null">
  238. id = #{record.id,jdbcType=VARCHAR},
  239. </if>
  240. <if test="record.createTime != null">
  241. create_time = #{record.createTime,jdbcType=TIMESTAMP},
  242. </if>
  243. <if test="record.orderNo != null">
  244. order_no = #{record.orderNo,jdbcType=VARCHAR},
  245. </if>
  246. <if test="record.bonusSubject != null">
  247. bonus_subject = #{record.bonusSubject,jdbcType=INTEGER},
  248. </if>
  249. <if test="record.grantStatus != null">
  250. grant_status = #{record.grantStatus,jdbcType=INTEGER},
  251. </if>
  252. <if test="record.grantTarget != null">
  253. grant_target = #{record.grantTarget,jdbcType=VARCHAR},
  254. </if>
  255. <if test="record.grantBy != null">
  256. grant_by = #{record.grantBy,jdbcType=VARCHAR},
  257. </if>
  258. <if test="record.grantTime != null">
  259. grant_time = #{record.grantTime,jdbcType=DATE},
  260. </if>
  261. </set>
  262. <if test="_parameter != null">
  263. <include refid="Update_By_Example_Where_Clause" />
  264. </if>
  265. </update>
  266. <update id="updateByExample" parameterType="map">
  267. <!--
  268. WARNING - @mbggenerated
  269. This element is automatically generated by MyBatis Generator, do not modify.
  270. This element was generated on Fri Nov 23 16:33:27 CST 2018.
  271. -->
  272. update t_order_bonus
  273. set id = #{record.id,jdbcType=VARCHAR},
  274. create_time = #{record.createTime,jdbcType=TIMESTAMP},
  275. order_no = #{record.orderNo,jdbcType=VARCHAR},
  276. bonus_subject = #{record.bonusSubject,jdbcType=INTEGER},
  277. grant_status = #{record.grantStatus,jdbcType=INTEGER},
  278. grant_target = #{record.grantTarget,jdbcType=VARCHAR},
  279. grant_by = #{record.grantBy,jdbcType=VARCHAR},
  280. grant_time = #{record.grantTime,jdbcType=DATE}
  281. <if test="_parameter != null">
  282. <include refid="Update_By_Example_Where_Clause" />
  283. </if>
  284. </update>
  285. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.TOrderBonus">
  286. <!--
  287. WARNING - @mbggenerated
  288. This element is automatically generated by MyBatis Generator, do not modify.
  289. This element was generated on Fri Nov 23 16:33:27 CST 2018.
  290. -->
  291. update t_order_bonus
  292. <set>
  293. <if test="createTime != null">
  294. create_time = #{createTime,jdbcType=TIMESTAMP},
  295. </if>
  296. <if test="orderNo != null">
  297. order_no = #{orderNo,jdbcType=VARCHAR},
  298. </if>
  299. <if test="bonusSubject != null">
  300. bonus_subject = #{bonusSubject,jdbcType=INTEGER},
  301. </if>
  302. <if test="grantStatus != null">
  303. grant_status = #{grantStatus,jdbcType=INTEGER},
  304. </if>
  305. <if test="grantTarget != null">
  306. grant_target = #{grantTarget,jdbcType=VARCHAR},
  307. </if>
  308. <if test="grantBy != null">
  309. grant_by = #{grantBy,jdbcType=VARCHAR},
  310. </if>
  311. <if test="grantTime != null">
  312. grant_time = #{grantTime,jdbcType=DATE},
  313. </if>
  314. </set>
  315. where id = #{id,jdbcType=VARCHAR}
  316. </update>
  317. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.TOrderBonus">
  318. <!--
  319. WARNING - @mbggenerated
  320. This element is automatically generated by MyBatis Generator, do not modify.
  321. This element was generated on Fri Nov 23 16:33:27 CST 2018.
  322. -->
  323. update t_order_bonus
  324. set create_time = #{createTime,jdbcType=TIMESTAMP},
  325. order_no = #{orderNo,jdbcType=VARCHAR},
  326. bonus_subject = #{bonusSubject,jdbcType=INTEGER},
  327. grant_status = #{grantStatus,jdbcType=INTEGER},
  328. grant_target = #{grantTarget,jdbcType=VARCHAR},
  329. grant_by = #{grantBy,jdbcType=VARCHAR},
  330. grant_time = #{grantTime,jdbcType=DATE}
  331. where id = #{id,jdbcType=VARCHAR}
  332. </update>
  333. <!-- 财务专员统计技术员的奖金 -->
  334. <select id="technicianBonusList" parameterType="Map" resultType="com.goafanti.order.bo.TOrderBonusBo">
  335. select b.id, t.id as tid, b.order_no as orderNo, t.task_receiver as taskReceiver, t.task_status as taskStatus,
  336. t.commodity_quantity as commodityQuantity, t.project_status as projectStatus,
  337. accept_time as acceptTime, review_time as reviewTime, licence_time as licenceTime,
  338. o.liquidation_status as liquidationStatus, ga.name as byName,
  339. bonus_subject as bonusSubject, grant_status as grantStatus, a.name as targetName
  340. from t_order_bonus b
  341. left join t_order_new o on o.order_no = b.order_no
  342. left join t_order_task t on t.order_no = b.order_no and t.main=1
  343. left join admin a on a.id = t.task_receiver
  344. left join admin oa on oa.id = o.salesman_id
  345. left join admin ga on ga.id = b.grant_by
  346. where b.bonus_subject &gt;= 20
  347. <if test="b.grantBy != null">
  348. and b.grant_by = #{b.grantBy,jdbcType=VARCHAR}
  349. </if>
  350. <if test='b.targetName != null and b.targetName != ""'>
  351. <bind name="tn" value="'%' + b.targetName + '%'"/>
  352. and a.name like #{tn,jdbcType=VARCHAR}
  353. </if>
  354. <if test='b.salesName != null and b.salesName != ""'>
  355. <bind name="sn" value="'%' + b.salesName + '%'"/>
  356. and oa.name like #{sn,jdbcType=VARCHAR}
  357. </if>
  358. <if test='b.departmentId != null and b.departmentId !=""'>
  359. and a.department_id = #{b.departmentId,jdbcType=VARCHAR}
  360. </if>
  361. <if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
  362. <bind name="a" value="b.startTime + ' 00:00:00'"/>
  363. <bind name="e" value="b.endTime + ' 23:59:59'"/>
  364. and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
  365. </if>
  366. order by b.grant_status ,b.create_time
  367. <if test="page_sql != null">
  368. ${page_sql}
  369. </if>
  370. </select>
  371. <select id="technicianBonusCount" parameterType="Map" resultType="java.lang.Integer">
  372. select count(*)
  373. from t_order_bonus b
  374. left join t_order_new o on o.order_no = b.order_no
  375. left join t_order_task t on t.order_no = b.order_no and t.main=1
  376. left join admin a on a.id = t.task_receiver
  377. left join admin oa on oa.id = o.salesman_id
  378. where b.bonus_subject &gt;= 20
  379. <if test="b.grantBy != null">
  380. and b.grant_by = #{b.grantBy,jdbcType=VARCHAR}
  381. </if>
  382. <if test='b.targetName != null and b.targetName != ""'>
  383. <bind name="tn" value="'%' + b.targetName + '%'"/>
  384. and a.name like #{tn,jdbcType=VARCHAR}
  385. </if>
  386. <if test='b.salesName != null and b.salesName != ""'>
  387. <bind name="sn" value="'%' + b.salesName + '%'"/>
  388. and oa.name like #{sn,jdbcType=VARCHAR}
  389. </if>
  390. <if test='b.departmentId != null and b.departmentId !=""'>
  391. and a.department_id = #{b.departmentId,jdbcType=VARCHAR}
  392. </if>
  393. <if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
  394. <bind name="a" value="b.startTime + ' 00:00:00'"/>
  395. <bind name="e" value="b.endTime + ' 23:59:59'"/>
  396. and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
  397. </if>
  398. </select>
  399. <!-- 财务专员统计营销员奖金 -->
  400. <select id="saleBonusList" parameterType="Map" resultType="com.goafanti.order.bo.TOrderBonusBo">
  401. select b.id, o.order_no as orderNo, o.salesman_id as salesmanId, o.sign_time as signTime,
  402. o.buyer_id as buyerId, u.nickname as buyName, o.total_amount as totalAmount,
  403. o.first_amount as firstAmount, o.settlement_amount as settlementAmount, o.refund_amount as refundAmount,
  404. o.order_status as orderStatus, o.project_status as projectStatus, b.bonus_subject as bonusSubject,
  405. o.proof_count as proofCount, b.grant_status as grant_status, a.name as salesName
  406. from t_order_bonus b
  407. left join t_order_new o on o.order_no = b.order_no
  408. left join admin a on o.salesman_id = a.id
  409. left join `user` u on o.buyer_id = u.id
  410. where b.bonus_subject &lt;20
  411. <if test="b.grantBy != null">
  412. and b.grant_by = #{b.grantBy,jdbcType=VARCHAR}
  413. </if>
  414. <if test='b.salesName != null and b.salesName != ""'>
  415. <bind name="sn" value="'%' + b.salesName + '%'"/>
  416. and a.name like #{sn,jdbcType=VARCHAR}
  417. </if>
  418. <if test='b.departmentId != null and b.departmentId !=""'>
  419. and a.department_id = #{b.departmentId,jdbcType=VARCHAR}
  420. </if>
  421. <if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
  422. <bind name="a" value="b.startTime + ' 00:00:00'"/>
  423. <bind name="e" value="b.endTime + ' 23:59:59'"/>
  424. and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
  425. </if>
  426. order by b.grant_status , b.create_time
  427. <if test="page_sql != null">
  428. ${page_sql}
  429. </if>
  430. </select>
  431. <select id="saleBonusCount" parameterType="Map" resultType="java.lang.Integer">
  432. select count(*)
  433. from t_order_bonus b
  434. left join t_order_new o on o.order_no = b.order_no
  435. left join admin a on o.salesman_id = a.id
  436. left join `user` u on o.buyer_id = u.id
  437. where b.bonus_subject &lt;20
  438. <if test="b.grantBy != null">
  439. and b.grant_by = #{b.grantBy,jdbcType=VARCHAR}
  440. </if>
  441. <if test='b.salesName != null and b.salesName != ""'>
  442. <bind name="sn" value="'%' + b.salesName + '%'"/>
  443. and a.name like #{sn,jdbcType=VARCHAR}
  444. </if>
  445. <if test='b.departmentId != null and b.departmentId !=""'>
  446. and a.department_id = #{b.departmentId,jdbcType=VARCHAR}
  447. </if>
  448. <if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
  449. <bind name="a" value="b.startTime + ' 00:00:00'"/>
  450. <bind name="e" value="b.endTime + ' 23:59:59'"/>
  451. and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
  452. </if>
  453. </select>
  454. <!-- 获得技术员有奖金数据的部门 -->
  455. <select id="getDeptBySome" parameterType="com.goafanti.order.bo.TOrderBonusBo" resultType="com.goafanti.order.bo.TOrderBonusBo">
  456. select distinct
  457. d.id as departmentId, d.name as departmentName
  458. from t_order_bonus b
  459. left join t_order_new o on o.order_no = b.order_no
  460. left join admin a on b.grant_target = a.id
  461. left join `user` u on o.buyer_id = u.id
  462. left join department d on d.id = a.department_id
  463. where b.bonus_subject &lt;20
  464. <if test="grantBy != null">
  465. and b.grant_by = #{grantBy,jdbcType=VARCHAR}
  466. </if>
  467. <if test='salesName != null and salesName != ""'>
  468. <bind name="sn" value="'%' + salesName + '%'"/>
  469. and a.name like #{sn,jdbcType=VARCHAR}
  470. </if>
  471. <if test='departmentId != null and departmentId !=""'>
  472. and a.department_id = #{departmentId,jdbcType=VARCHAR}
  473. </if>
  474. <if test='startTime != null and startTime != "" and endTime != null and endTime != ""'>
  475. <bind name="a" value="startTime + ' 00:00:00'"/>
  476. <bind name="e" value="endTime + ' 23:59:59'"/>
  477. and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
  478. </if>
  479. </select>
  480. <!-- 获得及技术员奖金数据 -->
  481. <select id="getBonusData" parameterType="com.goafanti.order.bo.TOrderBonusBo" resultType="com.goafanti.order.bo.TOrderBonusBo">
  482. select b.id, t.id as tid, b.order_no as orderNo, t.task_receiver as taskReceiver, t.task_status as taskStatus,
  483. t.commodity_quantity as commodityQuantity, t.project_status as projectStatus,
  484. accept_time as acceptTime, review_time as reviewTime, licence_time as licenceTime,
  485. o.liquidation_status as liquidationStatus, ga.name as byName,
  486. bonus_subject as bonusSubject, grant_status as grantStatus, a.name as targetName
  487. from t_order_bonus b
  488. left join t_order_new o on o.order_no = b.order_no
  489. left join t_order_task t on t.order_no = b.order_no and t.main=1
  490. left join admin a on a.id = t.task_receiver
  491. left join admin oa on oa.id = o.salesman_id
  492. left join admin ga on ga.id = b.grant_by
  493. where b.bonus_subject &gt;= 20
  494. <if test="grantBy != null">
  495. and b.grant_by = #{grantBy,jdbcType=VARCHAR}
  496. </if>
  497. <if test='targetName != null and targetName != ""'>
  498. <bind name="tn" value="'%' + targetName + '%'"/>
  499. and a.name like #{tn,jdbcType=VARCHAR}
  500. </if>
  501. <if test='salesName != null and salesName != ""'>
  502. <bind name="sn" value="'%' + salesName + '%'"/>
  503. and oa.name like #{sn,jdbcType=VARCHAR}
  504. </if>
  505. <if test='departmentId != null and departmentId !=""'>
  506. and a.department_id = #{departmentId,jdbcType=VARCHAR}
  507. </if>
  508. <if test='startTime != null and startTime != "" and endTime != null and endTime != ""'>
  509. <bind name="a" value="b.startTime + ' 00:00:00'"/>
  510. <bind name="e" value="b.endTime + ' 23:59:59'"/>
  511. and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
  512. </if>
  513. order by b.grant_status ,b.create_time
  514. </select>
  515. </mapper>