TOrderBonusMapper.xml 25 KB

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