TOrderBonusMapper.xml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  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 - @mbg.generated
  7. This element is automatically generated by MyBatis Generator, do not modify.
  8. This element was generated on Tue Nov 27 11:15:28 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. <result column="grant_type" jdbcType="INTEGER" property="grantType" />
  19. <result column="task_id" jdbcType="INTEGER" property="taskId" />
  20. </resultMap>
  21. <sql id="Example_Where_Clause">
  22. <!--
  23. WARNING - @mbg.generated
  24. This element is automatically generated by MyBatis Generator, do not modify.
  25. This element was generated on Tue Nov 27 11:15:28 CST 2018.
  26. -->
  27. <where>
  28. <foreach collection="oredCriteria" item="criteria" separator="or">
  29. <if test="criteria.valid">
  30. <trim prefix="(" prefixOverrides="and" suffix=")">
  31. <foreach collection="criteria.criteria" item="criterion">
  32. <choose>
  33. <when test="criterion.noValue">
  34. and ${criterion.condition}
  35. </when>
  36. <when test="criterion.singleValue">
  37. and ${criterion.condition} #{criterion.value}
  38. </when>
  39. <when test="criterion.betweenValue">
  40. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  41. </when>
  42. <when test="criterion.listValue">
  43. and ${criterion.condition}
  44. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  45. #{listItem}
  46. </foreach>
  47. </when>
  48. </choose>
  49. </foreach>
  50. </trim>
  51. </if>
  52. </foreach>
  53. </where>
  54. </sql>
  55. <sql id="Update_By_Example_Where_Clause">
  56. <!--
  57. WARNING - @mbg.generated
  58. This element is automatically generated by MyBatis Generator, do not modify.
  59. This element was generated on Tue Nov 27 11:15:28 CST 2018.
  60. -->
  61. <where>
  62. <foreach collection="example.oredCriteria" item="criteria" separator="or">
  63. <if test="criteria.valid">
  64. <trim prefix="(" prefixOverrides="and" suffix=")">
  65. <foreach collection="criteria.criteria" item="criterion">
  66. <choose>
  67. <when test="criterion.noValue">
  68. and ${criterion.condition}
  69. </when>
  70. <when test="criterion.singleValue">
  71. and ${criterion.condition} #{criterion.value}
  72. </when>
  73. <when test="criterion.betweenValue">
  74. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  75. </when>
  76. <when test="criterion.listValue">
  77. and ${criterion.condition}
  78. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  79. #{listItem}
  80. </foreach>
  81. </when>
  82. </choose>
  83. </foreach>
  84. </trim>
  85. </if>
  86. </foreach>
  87. </where>
  88. </sql>
  89. <sql id="Base_Column_List">
  90. <!--
  91. WARNING - @mbg.generated
  92. This element is automatically generated by MyBatis Generator, do not modify.
  93. This element was generated on Tue Nov 27 11:15:28 CST 2018.
  94. -->
  95. id, create_time, order_no, bonus_subject, grant_status, grant_target, grant_by, grant_time,
  96. grant_type, task_id
  97. </sql>
  98. <select id="selectByExample" parameterType="com.goafanti.common.model.TOrderBonusExample" resultMap="BaseResultMap">
  99. <!--
  100. WARNING - @mbg.generated
  101. This element is automatically generated by MyBatis Generator, do not modify.
  102. This element was generated on Tue Nov 27 11:15:28 CST 2018.
  103. -->
  104. select
  105. <if test="distinct">
  106. distinct
  107. </if>
  108. <include refid="Base_Column_List" />
  109. from t_order_bonus
  110. <if test="_parameter != null">
  111. <include refid="Example_Where_Clause" />
  112. </if>
  113. <if test="orderByClause != null">
  114. order by ${orderByClause}
  115. </if>
  116. </select>
  117. <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
  118. <!--
  119. WARNING - @mbg.generated
  120. This element is automatically generated by MyBatis Generator, do not modify.
  121. This element was generated on Tue Nov 27 11:15:28 CST 2018.
  122. -->
  123. select
  124. <include refid="Base_Column_List" />
  125. from t_order_bonus
  126. where id = #{id,jdbcType=VARCHAR}
  127. </select>
  128. <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
  129. <!--
  130. WARNING - @mbg.generated
  131. This element is automatically generated by MyBatis Generator, do not modify.
  132. This element was generated on Tue Nov 27 11:15:28 CST 2018.
  133. -->
  134. delete from t_order_bonus
  135. where id = #{id,jdbcType=VARCHAR}
  136. </delete>
  137. <delete id="deleteByExample" parameterType="com.goafanti.common.model.TOrderBonusExample">
  138. <!--
  139. WARNING - @mbg.generated
  140. This element is automatically generated by MyBatis Generator, do not modify.
  141. This element was generated on Tue Nov 27 11:15:28 CST 2018.
  142. -->
  143. delete from t_order_bonus
  144. <if test="_parameter != null">
  145. <include refid="Example_Where_Clause" />
  146. </if>
  147. </delete>
  148. <insert id="insert" parameterType="com.goafanti.common.model.TOrderBonus">
  149. <!--
  150. WARNING - @mbg.generated
  151. This element is automatically generated by MyBatis Generator, do not modify.
  152. This element was generated on Tue Nov 27 11:15:28 CST 2018.
  153. -->
  154. insert into t_order_bonus (id, create_time, order_no,
  155. bonus_subject, grant_status, grant_target,
  156. grant_by, grant_time, grant_type, task_id
  157. )
  158. values (#{id,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{orderNo,jdbcType=VARCHAR},
  159. #{bonusSubject,jdbcType=INTEGER}, #{grantStatus,jdbcType=INTEGER}, #{grantTarget,jdbcType=VARCHAR},
  160. #{grantBy,jdbcType=VARCHAR}, #{grantTime,jdbcType=DATE}, #{grantType,jdbcType=INTEGER}, #{taskId,jdbcType=INTEGER}
  161. )
  162. </insert>
  163. <insert id="insertSelective" parameterType="com.goafanti.common.model.TOrderBonus">
  164. <!--
  165. WARNING - @mbg.generated
  166. This element is automatically generated by MyBatis Generator, do not modify.
  167. This element was generated on Tue Nov 27 11:15:28 CST 2018.
  168. -->
  169. insert into t_order_bonus
  170. <trim prefix="(" suffix=")" suffixOverrides=",">
  171. <if test="id != null">
  172. id,
  173. </if>
  174. <if test="createTime != null">
  175. create_time,
  176. </if>
  177. <if test="orderNo != null">
  178. order_no,
  179. </if>
  180. <if test="bonusSubject != null">
  181. bonus_subject,
  182. </if>
  183. <if test="grantStatus != null">
  184. grant_status,
  185. </if>
  186. <if test="grantTarget != null">
  187. grant_target,
  188. </if>
  189. <if test="grantBy != null">
  190. grant_by,
  191. </if>
  192. <if test="grantTime != null">
  193. grant_time,
  194. </if>
  195. <if test="grantType != null">
  196. grant_type,
  197. </if>
  198. <if test="taskId != null">
  199. task_id,
  200. </if>
  201. </trim>
  202. <trim prefix="values (" suffix=")" suffixOverrides=",">
  203. <if test="id != null">
  204. #{id,jdbcType=VARCHAR},
  205. </if>
  206. <if test="createTime != null">
  207. #{createTime,jdbcType=TIMESTAMP},
  208. </if>
  209. <if test="orderNo != null">
  210. #{orderNo,jdbcType=VARCHAR},
  211. </if>
  212. <if test="bonusSubject != null">
  213. #{bonusSubject,jdbcType=INTEGER},
  214. </if>
  215. <if test="grantStatus != null">
  216. #{grantStatus,jdbcType=INTEGER},
  217. </if>
  218. <if test="grantTarget != null">
  219. #{grantTarget,jdbcType=VARCHAR},
  220. </if>
  221. <if test="grantBy != null">
  222. #{grantBy,jdbcType=VARCHAR},
  223. </if>
  224. <if test="grantTime != null">
  225. #{grantTime,jdbcType=DATE},
  226. </if>
  227. <if test="grantType != null">
  228. #{grantType,jdbcType=INTEGER},
  229. </if>
  230. <if test="taskId != null">
  231. #{taskId,jdbcType=INTEGER},
  232. </if>
  233. </trim>
  234. </insert>
  235. <select id="countByExample" parameterType="com.goafanti.common.model.TOrderBonusExample" resultType="java.lang.Long">
  236. <!--
  237. WARNING - @mbg.generated
  238. This element is automatically generated by MyBatis Generator, do not modify.
  239. This element was generated on Tue Nov 27 11:15:28 CST 2018.
  240. -->
  241. select count(*) from t_order_bonus
  242. <if test="_parameter != null">
  243. <include refid="Example_Where_Clause" />
  244. </if>
  245. </select>
  246. <update id="updateByExampleSelective" parameterType="map">
  247. <!--
  248. WARNING - @mbg.generated
  249. This element is automatically generated by MyBatis Generator, do not modify.
  250. This element was generated on Tue Nov 27 11:15:28 CST 2018.
  251. -->
  252. update t_order_bonus
  253. <set>
  254. <if test="record.id != null">
  255. id = #{record.id,jdbcType=VARCHAR},
  256. </if>
  257. <if test="record.createTime != null">
  258. create_time = #{record.createTime,jdbcType=TIMESTAMP},
  259. </if>
  260. <if test="record.orderNo != null">
  261. order_no = #{record.orderNo,jdbcType=VARCHAR},
  262. </if>
  263. <if test="record.bonusSubject != null">
  264. bonus_subject = #{record.bonusSubject,jdbcType=INTEGER},
  265. </if>
  266. <if test="record.grantStatus != null">
  267. grant_status = #{record.grantStatus,jdbcType=INTEGER},
  268. </if>
  269. <if test="record.grantTarget != null">
  270. grant_target = #{record.grantTarget,jdbcType=VARCHAR},
  271. </if>
  272. <if test="record.grantBy != null">
  273. grant_by = #{record.grantBy,jdbcType=VARCHAR},
  274. </if>
  275. <if test="record.grantTime != null">
  276. grant_time = #{record.grantTime,jdbcType=DATE},
  277. </if>
  278. <if test="record.grantType != null">
  279. grant_type = #{record.grantType,jdbcType=INTEGER},
  280. </if>
  281. <if test="record.taskId != null">
  282. task_id = #{record.taskId,jdbcType=INTEGER},
  283. </if>
  284. </set>
  285. <if test="_parameter != null">
  286. <include refid="Update_By_Example_Where_Clause" />
  287. </if>
  288. </update>
  289. <update id="updateByExample" parameterType="map">
  290. <!--
  291. WARNING - @mbg.generated
  292. This element is automatically generated by MyBatis Generator, do not modify.
  293. This element was generated on Tue Nov 27 11:15:28 CST 2018.
  294. -->
  295. update t_order_bonus
  296. set id = #{record.id,jdbcType=VARCHAR},
  297. create_time = #{record.createTime,jdbcType=TIMESTAMP},
  298. order_no = #{record.orderNo,jdbcType=VARCHAR},
  299. bonus_subject = #{record.bonusSubject,jdbcType=INTEGER},
  300. grant_status = #{record.grantStatus,jdbcType=INTEGER},
  301. grant_target = #{record.grantTarget,jdbcType=VARCHAR},
  302. grant_by = #{record.grantBy,jdbcType=VARCHAR},
  303. grant_time = #{record.grantTime,jdbcType=DATE},
  304. grant_type = #{record.grantType,jdbcType=INTEGER},
  305. task_id = #{record.taskId,jdbcType=INTEGER}
  306. <if test="_parameter != null">
  307. <include refid="Update_By_Example_Where_Clause" />
  308. </if>
  309. </update>
  310. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.TOrderBonus">
  311. <!--
  312. WARNING - @mbg.generated
  313. This element is automatically generated by MyBatis Generator, do not modify.
  314. This element was generated on Tue Nov 27 11:15:28 CST 2018.
  315. -->
  316. update t_order_bonus
  317. <set>
  318. <if test="createTime != null">
  319. create_time = #{createTime,jdbcType=TIMESTAMP},
  320. </if>
  321. <if test="orderNo != null">
  322. order_no = #{orderNo,jdbcType=VARCHAR},
  323. </if>
  324. <if test="bonusSubject != null">
  325. bonus_subject = #{bonusSubject,jdbcType=INTEGER},
  326. </if>
  327. <if test="grantStatus != null">
  328. grant_status = #{grantStatus,jdbcType=INTEGER},
  329. </if>
  330. <if test="grantTarget != null">
  331. grant_target = #{grantTarget,jdbcType=VARCHAR},
  332. </if>
  333. <if test="grantBy != null">
  334. grant_by = #{grantBy,jdbcType=VARCHAR},
  335. </if>
  336. <if test="grantTime != null">
  337. grant_time = #{grantTime,jdbcType=DATE},
  338. </if>
  339. <if test="grantType != null">
  340. grant_type = #{grantType,jdbcType=INTEGER},
  341. </if>
  342. <if test="taskId != null">
  343. task_id = #{taskId,jdbcType=INTEGER},
  344. </if>
  345. </set>
  346. where id = #{id,jdbcType=VARCHAR}
  347. </update>
  348. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.TOrderBonus">
  349. <!--
  350. WARNING - @mbg.generated
  351. This element is automatically generated by MyBatis Generator, do not modify.
  352. This element was generated on Tue Nov 27 11:15:28 CST 2018.
  353. -->
  354. update t_order_bonus
  355. set create_time = #{createTime,jdbcType=TIMESTAMP},
  356. order_no = #{orderNo,jdbcType=VARCHAR},
  357. bonus_subject = #{bonusSubject,jdbcType=INTEGER},
  358. grant_status = #{grantStatus,jdbcType=INTEGER},
  359. grant_target = #{grantTarget,jdbcType=VARCHAR},
  360. grant_by = #{grantBy,jdbcType=VARCHAR},
  361. grant_time = #{grantTime,jdbcType=DATE},
  362. grant_type = #{grantType,jdbcType=INTEGER},
  363. task_id = #{taskId,jdbcType=INTEGER}
  364. where id = #{id,jdbcType=VARCHAR}
  365. </update>
  366. <!-- 财务专员统计技术员的奖金 -->
  367. <select id="technicianBonusList" parameterType="Map" resultType="com.goafanti.order.bo.TOrderBonusBo">
  368. select b.id, t.id as tid, b.order_no as orderNo, t.task_receiver as taskReceiver, t.task_status as taskStatus,
  369. t.commodity_quantity as commodityQuantity, t.project_status as projectStatus, t.commodity_name as commodityName,
  370. accept_time as acceptTime, review_time as reviewTime, licence_time as licenceTime,
  371. o.liquidation_status as liquidationStatus, ga.name as byName,
  372. bonus_subject as bonusSubject, grant_status as grantStatus, a.name as targetName
  373. , b.create_time as startTime1
  374. from t_order_bonus b
  375. left join t_order_task t on b.task_id = t.id
  376. left join t_order_new o on o.order_no = t.order_no
  377. left join admin a on a.id = t.task_receiver
  378. left join admin oa on oa.id = o.salesman_id
  379. left join admin ga on ga.id = b.grant_by
  380. where b.grant_type = 1
  381. <if test="fids != null and fids.size > 0">
  382. and b.grant_by in
  383. <foreach collection="fids" item="id" open="(" separator="," close=")">
  384. #{id}
  385. </foreach>
  386. </if>
  387. <if test='b.targetName != null and b.targetName != ""'>
  388. <bind name="tn" value="'%' + b.targetName + '%'" />
  389. and a.name like #{tn,jdbcType=VARCHAR}
  390. </if>
  391. <if test='b.salesName != null and b.salesName != ""'>
  392. <bind name="sn" value="'%' + b.salesName + '%'" />
  393. and oa.name like #{sn,jdbcType=VARCHAR}
  394. </if>
  395. <if test='b.departmentId != null and b.departmentId != ""'>
  396. and oa.department_id = #{b.departmentId,jdbcType=VARCHAR}
  397. </if>
  398. <if test="b.grantStatus != null">
  399. and b.grant_status = #{b.grantStatus,jdbcType=INTEGER}
  400. </if>
  401. <if test='b.orderNo != null and b.orderNo !=""'>
  402. and b.order_no = #{b.orderNo,jdbcType=VARCHAR}
  403. </if>
  404. <if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
  405. <bind name="a" value="b.startTime +'-01'"/>
  406. <bind name="e" value="b.endTime +'-31'"/>
  407. and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
  408. </if>
  409. <if test='b.startTime1 != null and b.startTime1 != "" and b.endTime1 != null and b.endTime1 != ""'>
  410. <bind name="a1" value="b.startTime1 +' 00:00:00'"/>
  411. <bind name="e1" value="b.endTime1 +' 23:59:59'"/>
  412. and b.create_time between #{a1,jdbcType=VARCHAR} and #{e1,jdbcType=VARCHAR}
  413. </if>
  414. order by b.grant_status ,b.create_time
  415. <if test="page_sql != null">
  416. ${page_sql}
  417. </if>
  418. </select>
  419. <select id="technicianBonusCount" parameterType="Map" resultType="java.lang.Integer">
  420. select count(*)
  421. from t_order_bonus b
  422. left join t_order_task t on b.task_id = t.id
  423. left join t_order_new o on o.order_no = t.order_no
  424. left join admin a on a.id = t.task_receiver
  425. left join admin oa on oa.id = o.salesman_id
  426. where b.grant_type = 1
  427. <if test="fids != null">
  428. and b.grant_by in
  429. <foreach collection="fids" item="id" open="(" separator="," close=")">
  430. #{id}
  431. </foreach>
  432. </if>
  433. <if test='b.targetName != null and b.targetName != ""'>
  434. <bind name="tn" value="'%' + b.targetName + '%'" />
  435. and a.name like #{tn,jdbcType=VARCHAR}
  436. </if>
  437. <if test='b.salesName != null and b.salesName != ""'>
  438. <bind name="sn" value="'%' + b.salesName + '%'" />
  439. and oa.name like #{sn,jdbcType=VARCHAR}
  440. </if>
  441. <if test='b.departmentId != null and b.departmentId != ""'>
  442. and oa.department_id = #{b.departmentId,jdbcType=VARCHAR}
  443. </if>
  444. <if test="b.grantStatus != null">
  445. and b.grant_status = #{b.grantStatus,jdbcType=INTEGER}
  446. </if>
  447. <if test='b.orderNo != null and b.orderNo !=""'>
  448. and b.order_no = #{b.orderNo,jdbcType=VARCHAR}
  449. </if>
  450. <if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
  451. <bind name="a" value="b.startTime +'-01'"/>
  452. <bind name="e" value="b.endTime +'-31'"/>
  453. and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
  454. </if>
  455. <if test='b.startTime1 != null and b.startTime1 != "" and b.endTime1 != null and b.endTime1 != ""'>
  456. <bind name="a1" value="b.startTime1 +' 00:00:00'"/>
  457. <bind name="e1" value="b.endTime1 +' 23:59:59'"/>
  458. and b.create_time between #{a1,jdbcType=VARCHAR} and #{e1,jdbcType=VARCHAR}
  459. </if>
  460. </select>
  461. <!-- 财务专员统计营销员奖金 -->
  462. <select id="saleBonusList" parameterType="Map" resultType="com.goafanti.order.bo.TOrderBonusBo">
  463. select b.id, o.order_no as orderNo, o.salesman_id as salesmanId, o.sign_time as signTime,
  464. o.buyer_id as buyerId, u.nickname as buyName, o.total_amount as totalAmount,
  465. o.first_amount as firstAmount, o.settlement_amount as settlementAmount, o.refund_amount as refundAmount,
  466. o.order_status as orderStatus, o.project_status as projectStatus, b.bonus_subject as bonusSubject,
  467. o.proof_count as proofCount, b.grant_status as grantStatus, a.name as salesName, o.proof_status as proofStatus,
  468. ad.name as byName, b.grant_target as grantTarget, b.create_time as startTime1
  469. from t_order_bonus b
  470. left join t_order_new o on o.order_no = b.order_no
  471. left join admin a on o.salesman_id = a.id
  472. left join `user` u on o.buyer_id = u.id
  473. left join admin ad on b.grant_by = ad.id
  474. where b.grant_type = 0
  475. <if test="fids != null and fids.size > 0">
  476. and b.grant_by in
  477. <foreach collection="fids" item="id" open="(" separator="," close=")">
  478. #{id}
  479. </foreach>
  480. </if>
  481. <if test="b.grantBy != null">
  482. and b.grant_by = #{b.grantBy,jdbcType=VARCHAR}
  483. </if>
  484. <if test='b.salesName != null and b.salesName != ""'>
  485. <bind name="sn" value="'%' + b.salesName + '%'" />
  486. and a.name like #{sn,jdbcType=VARCHAR}
  487. </if>
  488. <if test='deps !=null'>
  489. and a.department_id in
  490. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  491. #{depId}
  492. </foreach>
  493. </if>
  494. <if test="b.grantStatus != null">
  495. and b.grant_status = #{b.grantStatus,jdbcType=INTEGER}
  496. </if>
  497. <if test='b.orderNo != null and b.orderNo !=""'>
  498. and b.order_no = #{b.orderNo,jdbcType=VARCHAR}
  499. </if>
  500. <if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
  501. <bind name="a" value="b.startTime +'-01'"/>
  502. <bind name="e" value="b.endTime +'-31'"/>
  503. and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
  504. </if>
  505. <if test='b.startTime1 != null and b.startTime1 != "" and b.endTime1 != null and b.endTime1 != ""'>
  506. <bind name="a1" value="b.startTime1 +' 00:00:00'"/>
  507. <bind name="e1" value="b.endTime1 +' 23:59:59'"/>
  508. and b.create_time between #{a1,jdbcType=VARCHAR} and #{e1,jdbcType=VARCHAR}
  509. </if>
  510. order by b.grant_status , b.create_time desc
  511. <if test="page_sql != null">
  512. ${page_sql}
  513. </if>
  514. </select>
  515. <select id="saleBonusCount" parameterType="Map" resultType="java.lang.Integer">
  516. select count(*)
  517. from t_order_bonus b
  518. left join t_order_new o on o.order_no = b.order_no
  519. left join admin a on o.salesman_id = a.id
  520. left join `user` u on o.buyer_id = u.id
  521. where b.grant_type = 0
  522. <if test="b.grantBy != null">
  523. and b.grant_by = #{b.grantBy,jdbcType=VARCHAR}
  524. </if>
  525. <if test='b.salesName != null and b.salesName != ""'>
  526. <bind name="sn" value="'%' + b.salesName + '%'" />
  527. and a.name like #{sn,jdbcType=VARCHAR}
  528. </if>
  529. <if test='deps !=null'>
  530. and a.department_id in
  531. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  532. #{depId}
  533. </foreach>
  534. </if>
  535. <if test="b.grantStatus != null">
  536. and b.grant_status = #{b.grantStatus,jdbcType=INTEGER}
  537. </if>
  538. <if test='b.orderNo != null and b.orderNo !=""'>
  539. and b.order_no = #{b.orderNo,jdbcType=VARCHAR}
  540. </if>
  541. <if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
  542. <bind name="a" value="b.startTime +'-01'"/>
  543. <bind name="e" value="b.endTime +'-31'"/>
  544. and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
  545. </if>
  546. <if test='b.startTime1 != null and b.startTime1 != "" and b.endTime1 != null and b.endTime1 != ""'>
  547. <bind name="a1" value="b.startTime1 +' 00:00:00'"/>
  548. <bind name="e1" value="b.endTime1 +' 23:59:59'"/>
  549. and b.create_time between #{a1,jdbcType=VARCHAR} and #{e1,jdbcType=VARCHAR}
  550. </if>
  551. </select>
  552. <!-- 获得技术员有奖金数据的部门 -->
  553. <select id="getDeptBySome" parameterType="com.goafanti.order.bo.TOrderBonusBo" resultType="com.goafanti.order.bo.TOrderBonusBo">
  554. select distinct
  555. d.id as departmentId, d.name as departmentName
  556. from t_order_bonus b
  557. left join t_order_new o on o.order_no = b.order_no
  558. left join admin a on b.grant_target = a.id
  559. left join `user` u on o.buyer_id = u.id
  560. left join department d on d.id = a.department_id
  561. where b.grant_type = #{grantType,jdbcType=INTEGER}
  562. <if test="grantBy != null">
  563. and b.grant_by = #{grantBy,jdbcType=VARCHAR}
  564. </if>
  565. <if test='salesName != null and salesName != ""'>
  566. <bind name="sn" value="'%' + salesName + '%'" />
  567. and a.name like #{sn,jdbcType=VARCHAR}
  568. </if>
  569. <if test='departmentId != null and departmentId != ""'>
  570. and a.department_id = #{departmentId,jdbcType=VARCHAR}
  571. </if>
  572. <if test="grantStatus != null">
  573. and b.grant_status = #{grantStatus,jdbcType=INTEGER}
  574. </if>
  575. <if test='startTime != null and startTime != "" and endTime != null and endTime != ""'>
  576. <bind name="a" value="startTime +'-01'"/>
  577. <bind name="e" value="endTime +'-31'"/>
  578. and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
  579. </if>
  580. <if test='startTime1 != null and startTime1 != "" and endTime1 != null and endTime1 != ""'>
  581. <bind name="a1" value="startTime1 +' 00:00:00'"/>
  582. <bind name="e1" value="endTime1 +' 23:59:59'"/>
  583. and b.create_time between #{a1,jdbcType=VARCHAR} and #{e1,jdbcType=VARCHAR}
  584. </if>
  585. </select>
  586. <!-- 获得及技术员奖金数据 -->
  587. <select id="getBonusData" parameterType="com.goafanti.order.bo.TOrderBonusBo" resultType="com.goafanti.order.bo.TOrderBonusBo">
  588. select b.id, t.id as tid, b.order_no as orderNo, t.task_receiver as taskReceiver, t.task_status as taskStatus,
  589. t.commodity_quantity as commodityQuantity, t.project_status as projectStatus, t.commodity_name as commodityName,
  590. accept_time as acceptTime, review_time as reviewTime, licence_time as licenceTime,
  591. o.liquidation_status as liquidationStatus, ga.name as byName,
  592. bonus_subject as bonusSubject, grant_status as grantStatus, a.name as targetName
  593. ,b.create_time as startTime1
  594. from t_order_bonus b
  595. left join t_order_task t on b.task_id = t.id
  596. left join t_order_new o on o.order_no = t.order_no
  597. left join admin a on a.id = t.task_receiver
  598. left join admin oa on oa.id = o.salesman_id
  599. left join admin ga on ga.id = b.grant_by
  600. where b.grant_type = 1
  601. <if test="grantBy != null">
  602. and b.grant_by = #{grantBy,jdbcType=VARCHAR}
  603. </if>
  604. <if test='targetName != null and targetName != ""'>
  605. <bind name="tn" value="'%' + targetName + '%'" />
  606. and a.name like #{tn,jdbcType=VARCHAR}
  607. </if>
  608. <if test='salesName != null and salesName != ""'>
  609. <bind name="sn" value="'%' + salesName + '%'" />
  610. and oa.name like #{sn,jdbcType=VARCHAR}
  611. </if>
  612. <if test='departmentId != null and departmentId !=""'>
  613. and a.department_id = #{departmentId,jdbcType=VARCHAR}
  614. </if>
  615. <if test="grantStatus != null">
  616. and b.grant_status = #{grantStatus,jdbcType=INTEGER}
  617. </if>
  618. <if test='startTime != null and startTime != "" and endTime != null and endTime != ""'>
  619. <bind name="a" value="startTime +'-01'"/>
  620. <bind name="e" value="endTime +'-31'"/>
  621. and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
  622. </if>
  623. <if test='startTime1 != null and startTime1 != "" and endTime1 != null and endTime1 != ""'>
  624. <bind name="a1" value="startTime1 +' 00:00:00'"/>
  625. <bind name="e1" value="endTime1 +' 23:59:59'"/>
  626. and b.create_time between #{a1,jdbcType=VARCHAR} and #{e1,jdbcType=VARCHAR}
  627. </if>
  628. order by b.grant_status ,b.create_time desc
  629. </select>
  630. <!-- 查看营销员的奖金数据 -->
  631. <select id="getSaleBounsList" parameterType="com.goafanti.order.bo.TOrderBonusBo" resultType="com.goafanti.order.bo.TOrderBonusBo">
  632. select b.id, o.order_no as orderNo, o.salesman_id as salesmanId, o.sign_time as signTime,
  633. o.buyer_id as buyerId, u.nickname as buyName, o.total_amount as totalAmount,
  634. o.first_amount as firstAmount, o.settlement_amount as settlementAmount, o.refund_amount as refundAmount,
  635. o.order_status as orderStatus, o.project_status as projectStatus, b.bonus_subject as bonusSubject,
  636. o.proof_count as proofCount, b.grant_status as grantStatus, a.name as salesName
  637. ,b.create_time as startTime1, b.grant_target as grantTarget
  638. from t_order_bonus b
  639. left join t_order_new o on o.order_no = b.order_no
  640. left join admin a on o.salesman_id = a.id
  641. left join `user` u on o.buyer_id = u.id
  642. where b.grant_type = 0
  643. <if test="grantBy != null">
  644. and b.grant_by = #{grantBy,jdbcType=VARCHAR}
  645. </if>
  646. <if test='salesName != null and salesName != ""'>
  647. <bind name="sn" value="'%' + salesName + '%'" />
  648. and a.name like #{sn,jdbcType=VARCHAR}
  649. </if>
  650. <if test='departmentId != null and departmentId !=""'>
  651. and a.department_id = #{departmentId,jdbcType=VARCHAR}
  652. </if>
  653. <if test="grantStatus != null">
  654. and b.grant_status = #{grantStatus,jdbcType=INTEGER}
  655. </if>
  656. <if test='startTime != null and startTime != "" and endTime != null and endTime != ""'>
  657. <bind name="a" value="startTime +'-01'"/>
  658. <bind name="e" value="endTime +'-31'"/>
  659. and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
  660. </if>
  661. <if test='startTime1 != null and startTime1 != "" and endTime1 != null and endTime1 != ""'>
  662. <bind name="a1" value="startTime1 +' 00:00:00'"/>
  663. <bind name="e1" value="endTime1 +' 23:59:59'"/>
  664. and b.create_time between #{a1,jdbcType=VARCHAR} and #{e1,jdbcType=VARCHAR}
  665. </if>
  666. </select>
  667. <!-- 根据订单编号和科目和奖金发放人检查这个奖金是否存在 -->
  668. <select id="checkByOnoAndSub" parameterType="com.goafanti.common.model.TOrderBonus" resultType="java.lang.Integer">
  669. select count(*) from t_order_bonus where order_no = #{orderNo,jdbcType=VARCHAR} and bonus_subject = #{bonusSubject,jdbcType=INTEGER}
  670. and grant_target = #{grantTarget,jdbcType=VARCHAR} and grant_type = #{grantType,jdbcType=INTEGER}
  671. <if test="taskId != null">
  672. and task_id = #{taskId,jdbcType=INTEGER}
  673. </if>
  674. </select>
  675. <!-- 判断当前订单中有没有未发放的数据 -->
  676. <select id="checkNoPay" parameterType="com.goafanti.order.bo.TOrderBonusBo" resultType="java.lang.Integer">
  677. select bonus_subject from t_order_bonus
  678. where id = #{id,jdbcType=VARCHAR} and bonus_subject > (
  679. select min(bonus_subject) from t_order_bonus
  680. where order_no = #{orderNo,jdbcType=VARCHAR} and grant_status = 0 and grant_type = 0)
  681. </select>
  682. </mapper>