KxsMachineMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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.kxs.product.biz.mapper.KxsMachineMapper">
  4. <resultMap type="com.kxs.product.api.model.KxsMachine" id="KxsMachineMap">
  5. <result column="id" property="id"/>
  6. <result column="create_time" property="createTime"/>
  7. <result column="update_time" property="updateTime"/>
  8. <result column="del_flag" property="delFlag"/>
  9. <result column="version" property="version"/>
  10. <result column="pos_sn" property="posSn"/>
  11. <result column="warehouse_id" property="warehouseId"/>
  12. <result column="warehouse_name" property="warehouseName"/>
  13. <result column="user_id" property="userId"/>
  14. <result column="merchant_id" property="merchantId"/>
  15. <result column="brand_id" property="brandId"/>
  16. <result column="recycle_status" property="recycleStatus"/>
  17. <result column="recycle_end_time" property="recycleEndTime"/>
  18. <result column="machine_type" property="machineType"/>
  19. <result column="cash_pledge" property="cashPledge"/>
  20. <result column="source_pledge" property="sourcePledge"/>
  21. <result column="allot_path" property="allotPath"/>
  22. <result column="bind_time" property="bindTime"/>
  23. <result column="act_time" property="actTime"/>
  24. <result column="delivery_time" property="deliveryTime"/>
  25. <result column="box_sn" property="boxSn"/>
  26. <result column="machine_ratio" property="machineRatio"/>
  27. <result column="is_act" property="isAct"/>
  28. <result column="bind_status" property="bindStatus"/>
  29. <result column="status" property="status"/>
  30. <result column="is_first" property="isFirst"/>
  31. <result column="up_fee_flag" property="upFeeFlag"/>
  32. <result column="down_fee_flag" property="downFeeFlag"/>
  33. <result column="is_supply" property="isSupply"/>
  34. <result column="is_op_act" property="isOpAct"/>
  35. <result column="return_status" property="returnStatus"/>
  36. <result column="pre_user_id" property="preUserId"/>
  37. <result column="batch_no" property="batchNo"/>
  38. <result column="credit_trade" property="creditTrade"/>
  39. <result column="debit_card_trade" property="debitCardTrade"/>
  40. <result column="scan_qr_trade" property="scanQrTrade"/>
  41. <result column="source_pos_sn" property="sourcePosSn"/>
  42. <result column="dev_location" property="devLocation"/>
  43. <result column="second_fee" property="secondFee"/>
  44. </resultMap>
  45. <select id="machineStoreList" resultType="com.kxs.product.api.vo.kxsapp.machine.MachineStoreListVO">
  46. select create_time, pos_sn from kxs_machine
  47. <where>
  48. and del_flag = 0
  49. and status = 0
  50. and pre_user_id = 0
  51. <if test="query.warehouseId != null">
  52. and warehouse_id = #{query.warehouseId}
  53. </if>
  54. <if test="query.brandId != null">
  55. and brand_id = #{query.brandId}
  56. </if>
  57. <if test="query.boxSn != null and query.boxSn != ''">
  58. and box_sn = #{query.boxSn}
  59. </if>
  60. <if test="query.posSn != null and query.posSn != ''">
  61. and pos_sn like concat('%', #{query.posSn}, '%')
  62. </if>
  63. </where>
  64. </select>
  65. <select id="recycleMachinesPage" resultType="com.kxs.product.api.vo.kxsapp.machine.RecycleMachinesVO">
  66. select id,create_time, pos_sn, machine_type, recycle_end_time from kxs_machine
  67. <where>
  68. and del_flag = 0
  69. and recycle_status = 1
  70. and user_id = #{userId}
  71. AND brand_id IN
  72. <foreach collection="brandIds" item="item" open="(" separator="," close=")">
  73. #{item}
  74. </foreach>
  75. </where>
  76. </select>
  77. <select id="machineUnBindListPage" resultType="com.kxs.product.api.vo.kxsapp.machine.MachineUnBindListVO">
  78. select id,cash_pledge, pos_sn, machine_type, recycle_end_time from kxs_machine
  79. <where>
  80. and del_flag = 0
  81. and bind_status = 0
  82. and user_id = #{query.userId}
  83. <if test="query.brandId != null">
  84. and brand_id = #{query.brandId}
  85. </if>
  86. <if test="query.keyword != null and query.keyword != ''">
  87. and pos_sn like concat('%', #{query.keyword}, '%')
  88. </if>
  89. </where>
  90. </select>
  91. <select id="machineBindList" resultType="com.kxs.product.api.vo.kxsapp.machine.MachineBindListVO">
  92. select is_act, pos_sn, machine_type, cash_pledge from kxs_machine
  93. <where>
  94. and del_flag = 0
  95. and bind_status = 1
  96. and user_id = #{query.userId}
  97. <if test="query.brandId != null">
  98. and brand_id = #{query.brandId}
  99. </if>
  100. <if test="query.keyword != null and query.keyword != ''">
  101. and pos_sn like concat('%', #{query.keyword}, '%')
  102. </if>
  103. </where>
  104. </select>
  105. <select id="getByPage" resultType="com.kxs.product.api.vo.kxsapp.machine.MachineUserListVO">
  106. select a.is_act, a.pos_sn, a.machine_type, a.cash_pledge, a.delivery_time, a.warehouse_name,
  107. b.name as brand
  108. from kxs_machine a
  109. left join kxs_brand b on a.brand_id = b.id
  110. <where>
  111. and a.del_flag = 0
  112. and a.user_id = #{query.userId}
  113. <if test="query.brandId != null">
  114. and a.brand_id = #{query.brandId}
  115. </if>
  116. <if test="query.keyword != null and query.keyword != ''">
  117. and a.pos_sn like concat('%', #{query.keyword}, '%')
  118. </if>
  119. </where>
  120. </select>
  121. <select id="searchUserMachine" resultType="com.kxs.product.api.vo.kxsapp.machine.SearchUserMachineVO">
  122. select create_time, pos_sn from kxs_machine
  123. <where>
  124. <if test="query.userId != null">
  125. and user_id = #{query.userId}
  126. </if>
  127. <if test="query.boxSn != null and query.boxSn != ''">
  128. and box_sn = #{query.boxSn}
  129. </if>
  130. <if test="query.posSn != null and query.posSn != ''">
  131. and pos_sn like concat('%', #{query.posSn}, '%')
  132. </if>
  133. </where>
  134. </select>
  135. <select id="recyclePageList" resultType="com.kxs.product.api.vo.kxsapp.machine.MachineRecycleListVO">
  136. select recycle_end_time, pos_sn, brand_id from kxs_machine
  137. where del_flag = 0
  138. and bind_status = 0
  139. and is_act = 0
  140. and recycle_end_time &lt; #{query.endDay}
  141. and user_id = #{query.userId}
  142. <if test="query.posSn != null and query.posSn != ''">
  143. and pos_sn like concat('%', #{query.posSn}, '%')
  144. </if>
  145. <if test="query.brandId != null and query.brandId != ''">
  146. and brand_id = #{query.brandId}
  147. </if>
  148. <if test="query.sns != null and query.sns.size() > 0">
  149. and pos_sn not in
  150. <foreach collection="query.sns" item="item" open="(" separator="," close=")">
  151. #{item}
  152. </foreach>
  153. </if>
  154. order by recycle_end_time desc
  155. </select>
  156. <select id="selectDeductList" resultMap="KxsMachineMap">
  157. select a.id, a.user_id, a.pos_sn, a.brand_id, a.recycle_end_time
  158. from kxs_machine a
  159. left join kxs_machine_deduct b on a.pos_sn = b.pos_sn
  160. where b.pos_sn is null
  161. and a.del_flag = 0
  162. and a.user_id = #{query.userId}
  163. and a.status = #{query.status}
  164. and a.bind_status = #{query.bindStatus}
  165. and a.recycle_end_time &lt; #{query.recycleEndTime}
  166. </select>
  167. <select id="selectExpireDeductList" resultMap="KxsMachineMap">
  168. select a.id, a.pos_sn, recycle_end_time
  169. from kxs_machine a
  170. left join kxs_machine_deduct b on a.pos_sn = b.pos_sn
  171. where b.pos_sn is null
  172. and a.del_flag = 0
  173. and a.status = 1
  174. and a.user_id > 0
  175. and a.bind_status = 0
  176. and a.recycle_end_time &lt; #{endDay}
  177. order by recycle_end_time desc limit 1000
  178. </select>
  179. <select id="recycleBrandList" resultType="com.kxs.system.api.vo.kxsapp.RecycleBrandListVO">
  180. select DISTINCT kb.id, kb.name
  181. from kxs_machine km
  182. left join kxs_brand kb on km.brand_id = kb.id
  183. where km.del_flag = 0
  184. and km.is_act = 0
  185. and km.bind_status = 0
  186. and km.recycle_end_time &lt; #{endDay}
  187. and km.user_id = #{userId}
  188. <if test="sns != null and sns.size() > 0">
  189. and km.pos_sn not in
  190. <foreach collection="sns" item="item" open="(" separator="," close=")">
  191. #{item}
  192. </foreach>
  193. </if>
  194. </select>
  195. <select id="getActivityMachineByIdAndTime" resultType="java.lang.Integer">
  196. select
  197. count(id) as number
  198. from kxs_machine
  199. where del_flag != 1
  200. and bind_time between #{param.startTime} and #{param.endTime}
  201. and act_time between #{param.startTime} and #{param.endTime}
  202. and user_id = #{param.userId}
  203. <if test="brandId == 14">
  204. and brand_id = 14
  205. </if>
  206. <if test="brandId == 0">
  207. and brand_id != 14
  208. </if>
  209. </select>
  210. <select id="machinePage" resultMap="KxsMachineMap">
  211. SELECT
  212. km.*
  213. FROM
  214. kxs_machine km
  215. <where>
  216. and km.del_flag = 0
  217. <if test="query.posSn != null and query.posSn != ''">
  218. <bind name="posSnLike" value="'%'+query.posSn+'%'"/>
  219. AND km.pos_sn LIKE #{posSnLike}
  220. </if>
  221. <if test="query.brandId != null and query.brandId != ''">
  222. <bind name="brandIdLike" value="'%'+query.brandId+'%'"/>
  223. AND km.brand_id LIKE #{brandIdLike}
  224. </if>
  225. <if test="query.isAct != null">
  226. AND km.is_act = #{query.isAct}
  227. </if>
  228. <if test="query.bindStatus != null">
  229. AND km.bind_status = #{query.bindStatus}
  230. </if>
  231. <if test="query.status != null">
  232. AND km.status = #{query.status}
  233. </if>
  234. <if test="query.userIds != null and query.userIds.size()>0">
  235. and km.user_id in
  236. <foreach collection="query.userIds" item="item" open="(" separator="," close=")">
  237. #{item}
  238. </foreach>
  239. </if>
  240. <if test="query.warehouseIds != null and query.warehouseIds.size()>0">
  241. and km.warehouse_id in
  242. <foreach collection="query.warehouseIds" item="item" open="(" separator="," close=")">
  243. #{item}
  244. </foreach>
  245. </if>
  246. <if test="query.bindTime != null and query.bindTime.length > 1">
  247. and (
  248. DATE_FORMAT(km.bind_time,'%Y-%m-%d') >= DATE_FORMAT(#{query.bindTime.[0]},'%Y-%m-%d') and
  249. DATE_FORMAT(#{query.bindTime.[1]},'%Y-%m-%d') >= DATE_FORMAT(km.bind_time,'%Y-%m-%d')
  250. )
  251. </if>
  252. <if test="query.actTime != null and query.actTime.length > 1">
  253. and (
  254. DATE_FORMAT(km.act_time,'%Y-%m-%d') >= DATE_FORMAT(#{query.actTime.[0]},'%Y-%m-%d') and
  255. DATE_FORMAT(#{query.actTime.[1]},'%Y-%m-%d') >= DATE_FORMAT(km.act_time,'%Y-%m-%d')
  256. )
  257. </if>
  258. <if test="query.deliveryTime != null and query.deliveryTime.length > 1">
  259. and (
  260. DATE_FORMAT(km.delivery_time,'%Y-%m-%d') >= DATE_FORMAT(#{query.deliveryTime.[0]},'%Y-%m-%d') and
  261. DATE_FORMAT(#{query.deliveryTime.[1]},'%Y-%m-%d') >= DATE_FORMAT(km.delivery_time,'%Y-%m-%d')
  262. )
  263. </if>
  264. </where>
  265. order by km.create_time desc
  266. </select>
  267. </mapper>