SmsMessageMapper.xml 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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.tofly.feesapi.sms.mapper.SmsMessageMapper">
  4. <resultMap id="smsMessageMap" type="com.tofly.feesapi.sms.entity.SmsMessage">
  5. <id property="id" column="ID"/>
  6. <result property="lsh" column="LSH"/>
  7. <result property="yhbh" column="YHBH"/>
  8. <result property="yhxm" column="YHXM"/>
  9. <result property="yhdz" column="YHDZ"/>
  10. <result property="lxdh" column="LXDH"/>
  11. <result property="cwyf" column="CWYF"/>
  12. <result property="scds" column="SCDS"/>
  13. <result property="bcds" column="BCDS"/>
  14. <result property="txlx" column="TXLX"/>
  15. <result property="txnr" column="TXNR"/>
  16. <result property="scsj" column="SCSJ"/>
  17. <result property="fszt" column="FSZT"/>
  18. <result property="clry" column="CLRY"/>
  19. <result property="clsj" column="CLSJ"/>
  20. <result property="bz" column="BZ"/>
  21. <result property="sLock" column="S_LOCK"/>
  22. <result property="yssl" column="YSSL"/>
  23. <result property="yssf" column="YSSF"/>
  24. <result property="yswsf" column="YSWSF"/>
  25. <result property="qf" column="QF"/>
  26. <result property="yf" column="YF"/>
  27. <result property="zje" column="ZJE"/>
  28. <result property="count" column="COUNT"/>
  29. <result property="czrybm" column="CZRYBM"/>
  30. <result property="czryxm" column="CZRYXM"/>
  31. <result property="syje" column="SYJE"/>
  32. </resultMap>
  33. <resultMap id="smsMessageYhxxVo" type="com.tofly.feesapi.sms.entity.vo.SmsMessageYhxxVo">
  34. <result property="yhbh" column="YHBH"/>
  35. <result property="yhxm" column="YHXM"/>
  36. <result property="yhdz" column="YHDZ"/>
  37. <result property="lxdh" column="LXDH"/>
  38. </resultMap>
  39. <select id="getSmsMessageYhxxVoList" resultMap="smsMessageYhxxVo">
  40. select a.yhbh,a.yhxm,a.yhdz,case when a.zzdh is null then a.lxdh else a.zzdh end lxdh
  41. from yh_khjbxx a
  42. where 1=1
  43. <!--模糊查询 -->
  44. <if test="smsMessageYhxxDto.searchText!=null">
  45. AND ( a.yhbh like '%${smsMessageYhxxDto.searchText}%'
  46. OR a.yhxm like '%${smsMessageYhxxDto.searchText}%'
  47. OR a.yhdz like '%${smsMessageYhxxDto.searchText}%' )
  48. </if>
  49. <if test="smsMessageYhxxDto.sscbb!=null">
  50. AND a.sscbb = '${smsMessageYhxxDto.sscbb}'
  51. </if>
  52. <if test="smsMessageYhxxDto.sscbpq!=null">
  53. AND a.sscbpq = '${smsMessageYhxxDto.sscbpq}'
  54. </if>
  55. <if test="smsMessageYhxxDto.yhbhs!=null">
  56. AND a.yhbh in(${smsMessageYhxxDto.yhbhs})
  57. </if>
  58. and length(case when a.zzdh is null then a.lxdh else a.zzdh end )=11
  59. and a.yhzt = '1'
  60. </select>
  61. <resultMap id="smsMessageYhqfxxVo" type="com.tofly.feesapi.sms.entity.vo.SmsMessageYhxxVo">
  62. <result property="yhbh" column="YHBH"/>
  63. <result property="yhxm" column="YHXM"/>
  64. <result property="yhdz" column="YHDZ"/>
  65. <result property="lxdh" column="LXDH"/>
  66. <result property="qfje" column="QFJE"/>
  67. <result property="nbsyje" column="NBSYJE"/>
  68. </resultMap>
  69. <select id="getSmsMessageYhqfxxVoList" resultMap="smsMessageYhqfxxVo">
  70. select a.yhbh,a.yhxm,a.yhdz,a.lxdh lxdh,a.sscbpq,a.sscbb,(nvl(b.qfje,0)-nvl(c.nbsyje,0)) qfje
  71. from yh_khjbxx a
  72. left join yy_zjzh c on a.yhbh=c.yhbh
  73. right join ( select yhbh,sum(ysje) as qfje from yy_qfmx where sfbz = 0 and sfbc=0 and chbz = 0 group by yhbh ) b
  74. on a.yhbh = b.yhbh
  75. where 1=1 and nvl(b.qfje,0)-nvl(c.nbsyje,0)>0
  76. <!--模糊查询 -->
  77. <if test="smsMessageYhxxDto.searchText!=null">
  78. AND ( a.yhbh like '%${smsMessageYhxxDto.searchText}%'
  79. OR a.yhxm like '%${smsMessageYhxxDto.searchText}%'
  80. OR a.yhdz like '%${smsMessageYhxxDto.searchText}%' )
  81. </if>
  82. <if test="smsMessageYhxxDto.sscbb!=null">
  83. <choose>
  84. <when test="smsMessageYhxxDto.sscbb.indexOf(',')!=-1">
  85. AND a.sscbb in
  86. <foreach item="item" index="index" collection="smsMessageYhxxDto.sscbb.split(',')" open="("
  87. separator=","
  88. close=")">
  89. #{item}
  90. </foreach>
  91. </when>
  92. <otherwise>
  93. AND a.sscbb=#{smsMessageYhxxDto.sscbb}
  94. </otherwise>
  95. </choose>
  96. </if>
  97. <if test="smsMessageYhxxDto.sscbpq!=null">
  98. AND a.sscbpq = '${smsMessageYhxxDto.sscbpq}'
  99. </if>
  100. <if test="smsMessageYhxxDto.yhbhs!=null">
  101. AND a.yhbh in
  102. <foreach item="yhbh" collection="smsMessageYhxxDto.yhbhs" open="(" separator="," close=")">
  103. #{yhbh}
  104. </foreach>
  105. </if>
  106. <if test="smsMessageYhxxDto.userId!=null">
  107. AND a.sscbb in (select cbbbm from yh_sjqx where user_id=#{smsMessageYhxxDto.userId})
  108. </if>
  109. and length(a.lxdh)=11
  110. and a.yhzt = '1'
  111. <!--排除微信用户 -->
  112. --and b.yhbh not in (select yhbh from wx_user where wxbdbz='1') and qfje>0
  113. <!--排除物联网表用户 -->
  114. and a.yhbh not in (select yhbh from yh_cbkxx where sblb='3')
  115. </select>
  116. <select id="getSmsMessageyffVo" resultMap="smsMessageYhqfxxVo">
  117. select a.yhbh,a.yhxm,a.yhdz,a.lxdh lxdh,c.nbsyje,a.sscbpq,a.sscbb
  118. from yy_zjzh c
  119. left join yh_khjbxx a on a.yhbh=c.yhbh
  120. where 1=1
  121. <!--模糊查询 -->
  122. <if test="smsMessageYhxxDto.searchText!=null">
  123. AND ( a.yhbh like '%${smsMessageYhxxDto.searchText}%'
  124. OR a.yhxm like '%${smsMessageYhxxDto.searchText}%'
  125. OR a.yhdz like '%${smsMessageYhxxDto.searchText}%' )
  126. </if>
  127. <if test="smsMessageYhxxDto.sscbb!=null">
  128. <choose>
  129. <when test="smsMessageYhxxDto.sscbb.indexOf(',')!=-1">
  130. AND a.sscbb in
  131. <foreach item="item" index="index" collection="smsMessageYhxxDto.sscbb.split(',')" open="("
  132. separator=","
  133. close=")">
  134. #{item}
  135. </foreach>
  136. </when>
  137. <otherwise>
  138. AND a.sscbb=#{smsMessageYhxxDto.sscbb}
  139. </otherwise>
  140. </choose>
  141. </if>
  142. <if test="smsMessageYhxxDto.sscbpq!=null">
  143. AND a.sscbpq = '${smsMessageYhxxDto.sscbpq}'
  144. </if>
  145. <if test="smsMessageYhxxDto.userId!=null">
  146. AND a.sscbb in (select cbbbm from yh_sjqx where user_id=#{smsMessageYhxxDto.userId})
  147. </if>
  148. <if test="smsMessageYhxxDto.yhbhs!=null">
  149. AND a.yhbh in
  150. <foreach item="yhbh" collection="smsMessageYhxxDto.yhbhs" open="(" separator="," close=")">
  151. #{yhbh}
  152. </foreach>
  153. </if>
  154. and length(case when a.zzdh is null then a.lxdh else a.zzdh end )=11
  155. and a.yhzt = '1'
  156. and c.nbsyje >= 0 and c.nbsyje &lt; 10
  157. <!--排除微信用户 and a.yhbh not in (select yhbh from wx_user where wxbdbz='1') -->
  158. </select>
  159. <select id="getPage" resultType="com.tofly.feesapi.sms.entity.vo.SmsMessageVo">
  160. select a.*,
  161. c.name as txlxName,
  162. ( case when a.fszt = '0' then '待发'
  163. when a.fszt = '1' then '成功'
  164. when a.fszt = '2' then '失败'
  165. else '待发' end )as fsztName
  166. from sms_message a
  167. left join yh_khjbxx b
  168. on a.yhbh = b.yhbh
  169. left join sms_txlx c on a.txlx = c.code
  170. where c.code > ' '
  171. <if test="dto.searchText!=null">
  172. AND ( a.yhbh like '%${dto.searchText}%'
  173. OR a.yhxm like '%${dto.searchText}%'
  174. OR a.yhdz like '%${dto.searchText}%'
  175. OR a.lxdh like '%${dto.searchText}%')
  176. </if>
  177. <if test="dto.txlx!=null">
  178. AND a.txlx = '${dto.txlx}'
  179. </if>
  180. <if test="dto.fszt!=null">
  181. AND a.fszt = '${dto.fszt}'
  182. </if>
  183. <if test="dto.yhbh!=null">
  184. AND a.yhbh = '${dto.yhbh}'
  185. </if>
  186. <if test="dto.lsh!=null">
  187. AND a.yhbh = '${dto.lsh}'
  188. </if>
  189. <if test="dto.sscbb!=null">
  190. <choose>
  191. <when test="dto.sscbb.indexOf(',')!=-1">
  192. AND b.sscbb in
  193. <foreach item="item" index="index" collection="dto.sscbb.split(',')" open="(" separator=","
  194. close=")">
  195. #{item}
  196. </foreach>
  197. </when>
  198. <otherwise>
  199. AND b.sscbb= #{dto.sscbb}
  200. </otherwise>
  201. </choose>
  202. </if>
  203. <if test="dto.sscbpq!=null">
  204. AND b.sscbpq = '${dto.sscbpq}'
  205. </if>
  206. <choose>
  207. <when test="dto.scsj_s!=null and dto.scsj_e!=null">
  208. AND a.scsj between #{dto.scsj_s} and #{dto.scsj_e}
  209. </when>
  210. <when test="dto.scsj_s!=null">
  211. AND a.scsj >= #{dto.scsj_s}
  212. </when>
  213. <when test="dto.scsj_e!=null">
  214. AND a.scsj &lt;= #{dto.scsj_e}
  215. </when>
  216. </choose>
  217. <choose>
  218. <when test="dto.clsj_s!=null and dto.clsj_e!=null">
  219. AND a.scsj between #{dto.clsj_s} and #{dto.clsj_e}
  220. </when>
  221. <when test="dto.clsj_s!=null">
  222. AND a.scsj >= #{dto.clsj_s}
  223. </when>
  224. <when test="dto.clsj_e!=null">
  225. AND a.scsj &lt;= #{dto.clsj_e}
  226. </when>
  227. </choose>
  228. </select>
  229. </mapper>