TOrderBonusMapper.xml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  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="b.grantBy != null">
  382. and b.grant_by = #{b.grantBy,jdbcType=VARCHAR}
  383. </if>
  384. <if test='b.targetName != null and b.targetName != ""'>
  385. <bind name="tn" value="'%' + b.targetName + '%'" />
  386. and a.name like #{tn,jdbcType=VARCHAR}
  387. </if>
  388. <if test='b.salesName != null and b.salesName != ""'>
  389. <bind name="sn" value="'%' + b.salesName + '%'" />
  390. and oa.name like #{sn,jdbcType=VARCHAR}
  391. </if>
  392. <if test='b.departmentId != null and b.departmentId != ""'>
  393. and oa.department_id = #{b.departmentId,jdbcType=VARCHAR}
  394. </if>
  395. <if test="b.grantStatus != null">
  396. and b.grant_status = #{b.grantStatus,jdbcType=INTEGER}
  397. </if>
  398. <if test='b.orderNo != null and b.orderNo !=""'>
  399. and b.order_no = #{b.orderNo,jdbcType=VARCHAR}
  400. </if>
  401. <if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
  402. <bind name="a" value="b.startTime +'-01'"/>
  403. <bind name="e" value="b.endTime +'-31'"/>
  404. and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
  405. </if>
  406. <if test='b.startTime1 != null and b.startTime1 != "" and b.endTime1 != null and b.endTime1 != ""'>
  407. <bind name="a1" value="b.startTime1 +' 00:00:00'"/>
  408. <bind name="e1" value="b.endTime1 +' 23:59:59'"/>
  409. and b.create_time between #{a1,jdbcType=VARCHAR} and #{e1,jdbcType=VARCHAR}
  410. </if>
  411. order by b.grant_status ,b.create_time
  412. <if test="page_sql != null">
  413. ${page_sql}
  414. </if>
  415. </select>
  416. <select id="technicianBonusCount" parameterType="Map" resultType="java.lang.Integer">
  417. select count(*)
  418. from t_order_bonus b
  419. left join t_order_task t on b.task_id = t.id
  420. left join t_order_new o on o.order_no = t.order_no
  421. left join admin a on a.id = t.task_receiver
  422. left join admin oa on oa.id = o.salesman_id
  423. where b.grant_type = 1
  424. <if test="b.grantBy != null">
  425. and b.grant_by = #{b.grantBy,jdbcType=VARCHAR}
  426. </if>
  427. <if test='b.targetName != null and b.targetName != ""'>
  428. <bind name="tn" value="'%' + b.targetName + '%'" />
  429. and a.name like #{tn,jdbcType=VARCHAR}
  430. </if>
  431. <if test='b.salesName != null and b.salesName != ""'>
  432. <bind name="sn" value="'%' + b.salesName + '%'" />
  433. and oa.name like #{sn,jdbcType=VARCHAR}
  434. </if>
  435. <if test='b.departmentId != null and b.departmentId != ""'>
  436. and oa.department_id = #{b.departmentId,jdbcType=VARCHAR}
  437. </if>
  438. <if test="b.grantStatus != null">
  439. and b.grant_status = #{b.grantStatus,jdbcType=INTEGER}
  440. </if>
  441. <if test='b.orderNo != null and b.orderNo !=""'>
  442. and b.order_no = #{b.orderNo,jdbcType=VARCHAR}
  443. </if>
  444. <if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
  445. <bind name="a" value="b.startTime +'-01'"/>
  446. <bind name="e" value="b.endTime +'-31'"/>
  447. and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
  448. </if>
  449. <if test='b.startTime1 != null and b.startTime1 != "" and b.endTime1 != null and b.endTime1 != ""'>
  450. <bind name="a1" value="b.startTime1 +' 00:00:00'"/>
  451. <bind name="e1" value="b.endTime1 +' 23:59:59'"/>
  452. and b.create_time between #{a1,jdbcType=VARCHAR} and #{e1,jdbcType=VARCHAR}
  453. </if>
  454. </select>
  455. <!-- 财务专员统计营销员奖金 -->
  456. <select id="saleBonusList" parameterType="Map" resultType="com.goafanti.order.bo.TOrderBonusBo">
  457. select b.id, o.order_no as orderNo, o.salesman_id as salesmanId, o.sign_time as signTime,
  458. o.buyer_id as buyerId, u.nickname as buyName, o.total_amount as totalAmount,
  459. o.first_amount as firstAmount, o.settlement_amount as settlementAmount, o.refund_amount as refundAmount,
  460. o.order_status as orderStatus, o.project_status as projectStatus, b.bonus_subject as bonusSubject,
  461. o.proof_count as proofCount, b.grant_status as grantStatus, a.name as salesName, o.proof_status as proofStatus,
  462. ad.name as byName, b.grant_target as grantTarget, b.create_time as startTime1
  463. from t_order_bonus b
  464. left join t_order_new o on o.order_no = b.order_no
  465. left join admin a on o.salesman_id = a.id
  466. left join `user` u on o.buyer_id = u.id
  467. left join admin ad on b.grant_by = ad.id
  468. where b.grant_type = 0
  469. <if test="b.grantBy != null">
  470. and b.grant_by = #{b.grantBy,jdbcType=VARCHAR}
  471. </if>
  472. <if test='b.salesName != null and b.salesName != ""'>
  473. <bind name="sn" value="'%' + b.salesName + '%'" />
  474. and a.name like #{sn,jdbcType=VARCHAR}
  475. </if>
  476. <if test='b.departmentId != null and b.departmentId !=""'>
  477. and a.department_id = #{b.departmentId,jdbcType=VARCHAR}
  478. </if>
  479. <if test="b.grantStatus != null">
  480. and b.grant_status = #{b.grantStatus,jdbcType=INTEGER}
  481. </if>
  482. <if test='b.orderNo != null and b.orderNo !=""'>
  483. and b.order_no = #{b.orderNo,jdbcType=VARCHAR}
  484. </if>
  485. <if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
  486. <bind name="a" value="b.startTime +'-01'"/>
  487. <bind name="e" value="b.endTime +'-31'"/>
  488. and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
  489. </if>
  490. <if test='b.startTime1 != null and b.startTime1 != "" and b.endTime1 != null and b.endTime1 != ""'>
  491. <bind name="a1" value="b.startTime1 +' 00:00:00'"/>
  492. <bind name="e1" value="b.endTime1 +' 23:59:59'"/>
  493. and b.create_time between #{a1,jdbcType=VARCHAR} and #{e1,jdbcType=VARCHAR}
  494. </if>
  495. order by b.grant_status , b.create_time desc
  496. <if test="page_sql != null">
  497. ${page_sql}
  498. </if>
  499. </select>
  500. <select id="saleBonusCount" parameterType="Map" resultType="java.lang.Integer">
  501. select count(*)
  502. from t_order_bonus b
  503. left join t_order_new o on o.order_no = b.order_no
  504. left join admin a on o.salesman_id = a.id
  505. left join `user` u on o.buyer_id = u.id
  506. where b.grant_type = 0
  507. <if test="b.grantBy != null">
  508. and b.grant_by = #{b.grantBy,jdbcType=VARCHAR}
  509. </if>
  510. <if test='b.salesName != null and b.salesName != ""'>
  511. <bind name="sn" value="'%' + b.salesName + '%'" />
  512. and a.name like #{sn,jdbcType=VARCHAR}
  513. </if>
  514. <if test='b.departmentId != null and b.departmentId !=""'>
  515. and a.department_id = #{b.departmentId,jdbcType=VARCHAR}
  516. </if>
  517. <if test="b.grantStatus != null">
  518. and b.grant_status = #{b.grantStatus,jdbcType=INTEGER}
  519. </if>
  520. <if test='b.orderNo != null and b.orderNo !=""'>
  521. and b.order_no = #{b.orderNo,jdbcType=VARCHAR}
  522. </if>
  523. <if test='b.startTime != null and b.startTime != "" and b.endTime != null and b.endTime != ""'>
  524. <bind name="a" value="b.startTime +'-01'"/>
  525. <bind name="e" value="b.endTime +'-31'"/>
  526. and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
  527. </if>
  528. <if test='b.startTime1 != null and b.startTime1 != "" and b.endTime1 != null and b.endTime1 != ""'>
  529. <bind name="a1" value="b.startTime1 +' 00:00:00'"/>
  530. <bind name="e1" value="b.endTime1 +' 23:59:59'"/>
  531. and b.create_time between #{a1,jdbcType=VARCHAR} and #{e1,jdbcType=VARCHAR}
  532. </if>
  533. </select>
  534. <!-- 获得技术员有奖金数据的部门 -->
  535. <select id="getDeptBySome" parameterType="com.goafanti.order.bo.TOrderBonusBo" resultType="com.goafanti.order.bo.TOrderBonusBo">
  536. select distinct
  537. d.id as departmentId, d.name as departmentName
  538. from t_order_bonus b
  539. left join t_order_new o on o.order_no = b.order_no
  540. left join admin a on b.grant_target = a.id
  541. left join `user` u on o.buyer_id = u.id
  542. left join department d on d.id = a.department_id
  543. where b.grant_type = #{grantType,jdbcType=INTEGER}
  544. <if test="grantBy != null">
  545. and b.grant_by = #{grantBy,jdbcType=VARCHAR}
  546. </if>
  547. <if test='salesName != null and salesName != ""'>
  548. <bind name="sn" value="'%' + salesName + '%'" />
  549. and a.name like #{sn,jdbcType=VARCHAR}
  550. </if>
  551. <if test='departmentId != null and departmentId != ""'>
  552. and a.department_id = #{departmentId,jdbcType=VARCHAR}
  553. </if>
  554. <if test="grantStatus != null">
  555. and b.grant_status = #{grantStatus,jdbcType=INTEGER}
  556. </if>
  557. <if test='startTime != null and startTime != "" and endTime != null and endTime != ""'>
  558. <bind name="a" value="startTime +'-01'"/>
  559. <bind name="e" value="endTime +'-31'"/>
  560. and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
  561. </if>
  562. <if test='startTime1 != null and startTime1 != "" and endTime1 != null and endTime1 != ""'>
  563. <bind name="a1" value="startTime1 +' 00:00:00'"/>
  564. <bind name="e1" value="endTime1 +' 23:59:59'"/>
  565. and b.create_time between #{a1,jdbcType=VARCHAR} and #{e1,jdbcType=VARCHAR}
  566. </if>
  567. </select>
  568. <!-- 获得及技术员奖金数据 -->
  569. <select id="getBonusData" parameterType="com.goafanti.order.bo.TOrderBonusBo" resultType="com.goafanti.order.bo.TOrderBonusBo">
  570. select b.id, t.id as tid, b.order_no as orderNo, t.task_receiver as taskReceiver, t.task_status as taskStatus,
  571. t.commodity_quantity as commodityQuantity, t.project_status as projectStatus, t.commodity_name as commodityName,
  572. accept_time as acceptTime, review_time as reviewTime, licence_time as licenceTime,
  573. o.liquidation_status as liquidationStatus, ga.name as byName,
  574. bonus_subject as bonusSubject, grant_status as grantStatus, a.name as targetName
  575. ,b.create_time as startTime1
  576. from t_order_bonus b
  577. left join t_order_task t on b.task_id = t.id
  578. left join t_order_new o on o.order_no = t.order_no
  579. left join admin a on a.id = t.task_receiver
  580. left join admin oa on oa.id = o.salesman_id
  581. left join admin ga on ga.id = b.grant_by
  582. where b.grant_type = 1
  583. <if test="grantBy != null">
  584. and b.grant_by = #{grantBy,jdbcType=VARCHAR}
  585. </if>
  586. <if test='targetName != null and targetName != ""'>
  587. <bind name="tn" value="'%' + targetName + '%'" />
  588. and a.name like #{tn,jdbcType=VARCHAR}
  589. </if>
  590. <if test='salesName != null and salesName != ""'>
  591. <bind name="sn" value="'%' + salesName + '%'" />
  592. and oa.name like #{sn,jdbcType=VARCHAR}
  593. </if>
  594. <if test='departmentId != null and departmentId !=""'>
  595. and a.department_id = #{departmentId,jdbcType=VARCHAR}
  596. </if>
  597. <if test="grantStatus != null">
  598. and b.grant_status = #{grantStatus,jdbcType=INTEGER}
  599. </if>
  600. <if test='startTime != null and startTime != "" and endTime != null and endTime != ""'>
  601. <bind name="a" value="startTime +'-01'"/>
  602. <bind name="e" value="endTime +'-31'"/>
  603. and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
  604. </if>
  605. <if test='startTime1 != null and startTime1 != "" and endTime1 != null and endTime1 != ""'>
  606. <bind name="a1" value="startTime1 +' 00:00:00'"/>
  607. <bind name="e1" value="endTime1 +' 23:59:59'"/>
  608. and b.create_time between #{a1,jdbcType=VARCHAR} and #{e1,jdbcType=VARCHAR}
  609. </if>
  610. order by b.grant_status ,b.create_time desc
  611. </select>
  612. <!-- 查看营销员的奖金数据 -->
  613. <select id="getSaleBounsList" parameterType="com.goafanti.order.bo.TOrderBonusBo" resultType="com.goafanti.order.bo.TOrderBonusBo">
  614. select b.id, o.order_no as orderNo, o.salesman_id as salesmanId, o.sign_time as signTime,
  615. o.buyer_id as buyerId, u.nickname as buyName, o.total_amount as totalAmount,
  616. o.first_amount as firstAmount, o.settlement_amount as settlementAmount, o.refund_amount as refundAmount,
  617. o.order_status as orderStatus, o.project_status as projectStatus, b.bonus_subject as bonusSubject,
  618. o.proof_count as proofCount, b.grant_status as grantStatus, a.name as salesName
  619. ,b.create_time as startTime1, b.grant_target as grantTarget
  620. from t_order_bonus b
  621. left join t_order_new o on o.order_no = b.order_no
  622. left join admin a on o.salesman_id = a.id
  623. left join `user` u on o.buyer_id = u.id
  624. where b.grant_type = 0
  625. <if test="grantBy != null">
  626. and b.grant_by = #{grantBy,jdbcType=VARCHAR}
  627. </if>
  628. <if test='salesName != null and salesName != ""'>
  629. <bind name="sn" value="'%' + salesName + '%'" />
  630. and a.name like #{sn,jdbcType=VARCHAR}
  631. </if>
  632. <if test='departmentId != null and departmentId !=""'>
  633. and a.department_id = #{departmentId,jdbcType=VARCHAR}
  634. </if>
  635. <if test="grantStatus != null">
  636. and b.grant_status = #{grantStatus,jdbcType=INTEGER}
  637. </if>
  638. <if test='startTime != null and startTime != "" and endTime != null and endTime != ""'>
  639. <bind name="a" value="startTime +'-01'"/>
  640. <bind name="e" value="endTime +'-31'"/>
  641. and o.sign_time between #{a,jdbcType=VARCHAR} and #{e,jdbcType=VARCHAR}
  642. </if>
  643. <if test='startTime1 != null and startTime1 != "" and endTime1 != null and endTime1 != ""'>
  644. <bind name="a1" value="startTime1 +' 00:00:00'"/>
  645. <bind name="e1" value="endTime1 +' 23:59:59'"/>
  646. and b.create_time between #{a1,jdbcType=VARCHAR} and #{e1,jdbcType=VARCHAR}
  647. </if>
  648. </select>
  649. <!-- 根据订单编号和科目和奖金发放人检查这个奖金是否存在 -->
  650. <select id="checkByOnoAndSub" parameterType="com.goafanti.common.model.TOrderBonus" resultType="java.lang.Integer">
  651. select count(*) from t_order_bonus where order_no = #{orderNo,jdbcType=VARCHAR} and bonus_subject = #{bonusSubject,jdbcType=INTEGER}
  652. and grant_target = #{grantTarget,jdbcType=VARCHAR} and grant_type = #{grantType,jdbcType=INTEGER}
  653. <if test="taskId != null">
  654. and task_id = #{taskId,jdbcType=INTEGER}
  655. </if>
  656. </select>
  657. <!-- 判断当前订单中有没有未发放的数据 -->
  658. <select id="checkNoPay" parameterType="com.goafanti.order.bo.TOrderBonusBo" resultType="java.lang.Integer">
  659. select bonus_subject from t_order_bonus
  660. where id = #{id,jdbcType=VARCHAR} and bonus_subject > (
  661. select min(bonus_subject) from t_order_bonus
  662. where order_no = #{orderNo,jdbcType=VARCHAR} and grant_status = 0 and grant_type = 0)
  663. </select>
  664. </mapper>