CashDao.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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.sqx.modules.pay.dao.CashOutDao">
  4. <select id="selectCashOutLimit3" resultType="com.sqx.modules.pay.entity.CashOut">
  5. select * from cash_out where state=1 order by out_at desc limit 3
  6. </select>
  7. <select id="selectCashOutSum" resultType="Double">
  8. select sum(money) from cash_out where state in (0,1) and user_id=#{userId} and date_format(create_at,'%Y-%m-%d') between #{startTime} and #{endTime}
  9. </select>
  10. <select id="selectCashOutSumsByNowMonth" resultType="Double">
  11. select ifnull(sum(money),0.00) from cash_out where `state` in (0,1) and user_id=#{userId} and date_format(create_at,'%Y-%m')=date_format(now(),'%Y-%m')
  12. </select>
  13. <select id="selectMayMoney" resultType="Double">
  14. select money from user_money where user_id=#{userId}
  15. </select>
  16. <update id="updateMayMoney">
  17. update user_money set
  18. <if test="type==1">
  19. money=money+#{money}
  20. </if>
  21. <if test="type==2">
  22. money=money-#{money}
  23. </if>
  24. where user_id=#{userId}
  25. </update>
  26. <select id="sumMoney" resultType="java.math.BigDecimal">
  27. select ifnull(sum(money), 0) from cash_out where 1 = 1
  28. <if test="dateType=='day'">
  29. and date_format(create_at,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
  30. </if>
  31. <if test="dateType=='month'">
  32. and date_format(create_at,'%Y-%m')=date_format(#{date},'%Y-%m')
  33. </if>
  34. <if test="dateType=='year'">
  35. and date_format(create_at,'%Y')=date_format(#{date},'%Y')
  36. </if>
  37. <if test="state!=null">
  38. and state = #{state}
  39. </if>
  40. <if test="type!=null">
  41. and type = #{type}
  42. </if>
  43. </select>
  44. <select id="countMoney" resultType="Integer">
  45. select count(*) from cash_out where 1 = 1
  46. <if test="dateType=='day'">
  47. and date_format(create_at,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
  48. </if>
  49. <if test="dateType=='month'">
  50. and date_format(create_at,'%Y-%m')=date_format(#{date},'%Y-%m')
  51. </if>
  52. <if test="dateType=='year'">
  53. and date_format(create_at,'%Y')=date_format(#{date},'%Y')
  54. </if>
  55. <if test="state!=null">
  56. and state = #{state}
  57. </if>
  58. <if test="type!=null">
  59. and type = #{type}
  60. </if>
  61. </select>
  62. <select id="stayMoney" resultType="Integer">
  63. select count(*) from cash_out where 1 = 1
  64. <if test="dateType=='day'">
  65. and date_format(create_at,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
  66. </if>
  67. <if test="dateType=='month'">
  68. and date_format(create_at,'%Y-%m')=date_format(#{date},'%Y-%m')
  69. </if>
  70. <if test="dateType=='year'">
  71. and date_format(create_at,'%Y')=date_format(#{date},'%Y')
  72. </if>
  73. and state=0
  74. <if test="type!=null">
  75. and type = #{type}
  76. </if>
  77. </select>
  78. <select id="applyMoneySum" resultType="java.math.BigDecimal">
  79. select ifnull(sum(money), 0) from cash_out where 1 = 1
  80. <if test="dateType=='day'">
  81. and date_format(create_at,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
  82. </if>
  83. <if test="dateType=='month'">
  84. and date_format(create_at,'%Y-%m')=date_format(#{date},'%Y-%m')
  85. </if>
  86. <if test="dateType=='year'">
  87. and date_format(create_at,'%Y')=date_format(#{date},'%Y')
  88. </if>
  89. and state = 0
  90. <if test="type!=null">
  91. and type = #{type}
  92. </if>
  93. </select>
  94. <select id="accomplishMoneySum" resultType="java.math.BigDecimal">
  95. select ifnull(sum(money), 0) from cash_out where 1 = 1
  96. <if test="dateType=='day'">
  97. and date_format(create_at,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
  98. </if>
  99. <if test="dateType=='month'">
  100. and date_format(create_at,'%Y-%m')=date_format(#{date},'%Y-%m')
  101. </if>
  102. <if test="dateType=='year'">
  103. and date_format(create_at,'%Y')=date_format(#{date},'%Y')
  104. </if>
  105. and state = 1
  106. <if test="type!=null">
  107. and type = #{type}
  108. </if>
  109. </select>
  110. <select id="refuseMoneySum" resultType="java.math.BigDecimal">
  111. select ifnull(sum(money), 0) from cash_out where 1 = 1
  112. <if test="dateType=='day'">
  113. and date_format(create_at,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
  114. </if>
  115. <if test="dateType=='month'">
  116. and date_format(create_at,'%Y-%m')=date_format(#{date},'%Y-%m')
  117. </if>
  118. <if test="dateType=='year'">
  119. and date_format(create_at,'%Y')=date_format(#{date},'%Y')
  120. </if>
  121. and state = -1
  122. <if test="type!=null">
  123. and type = #{type}
  124. </if>
  125. </select>
  126. <select id="zhifubaoMoneySum" resultType="java.math.BigDecimal">
  127. select ifnull(sum(money), 0) from cash_out where 1 = 1
  128. <if test="dateType=='day'">
  129. and date_format(create_at,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
  130. </if>
  131. <if test="dateType=='month'">
  132. and date_format(create_at,'%Y-%m')=date_format(#{date},'%Y-%m')
  133. </if>
  134. <if test="dateType=='year'">
  135. and date_format(create_at,'%Y')=date_format(#{date},'%Y')
  136. </if>
  137. and classify = 1 and state = 1
  138. <if test="type!=null">
  139. and type = #{type}
  140. </if>
  141. </select>
  142. <select id="weixinMoneySum" resultType="java.math.BigDecimal">
  143. select ifnull(sum(money), 0) from cash_out where 1 = 1
  144. <if test="dateType=='day'">
  145. and date_format(create_at,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
  146. </if>
  147. <if test="dateType=='month'">
  148. and date_format(create_at,'%Y-%m')=date_format(#{date},'%Y-%m')
  149. </if>
  150. <if test="dateType=='year'">
  151. and date_format(create_at,'%Y')=date_format(#{date},'%Y')
  152. </if>
  153. and classify = 2 and state = 1
  154. <if test="type!=null">
  155. and type = #{type}
  156. </if>
  157. </select>
  158. <select id="cashDepositMoneySum" resultType="java.math.BigDecimal">
  159. select ifnull(sum(money), 0) from cash_out where 1 = 1
  160. <if test="dateType=='day'">
  161. and date_format(create_at,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
  162. </if>
  163. <if test="dateType=='month'">
  164. and date_format(create_at,'%Y-%m')=date_format(#{date},'%Y-%m')
  165. </if>
  166. <if test="dateType=='year'">
  167. and date_format(create_at,'%Y')=date_format(#{date},'%Y')
  168. </if>
  169. and state = 1 and type = 3
  170. </select>
  171. <select id="cargoInsurance" resultType="java.math.BigDecimal">
  172. select ifnull(sum(cargo_insurance), 0) from tb_indent where 1 = 1
  173. <if test="dateType=='day'">
  174. and date_format(create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
  175. </if>
  176. <if test="dateType=='month'">
  177. and date_format(create_time,'%Y-%m')=date_format(#{date},'%Y-%m')
  178. </if>
  179. <if test="dateType=='year'">
  180. and date_format(create_time,'%Y')=date_format(#{date},'%Y')
  181. </if>
  182. and indent_state =6
  183. </select>
  184. <select id="MoneySumByIndentType" resultType="java.math.BigDecimal">
  185. select ifnull(sum(platform_money), 0) from tb_indent where 1 = 1
  186. <if test="dateType=='day'">
  187. and date_format(create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
  188. </if>
  189. <if test="dateType=='month'">
  190. and date_format(create_time,'%Y-%m')=date_format(#{date},'%Y-%m')
  191. </if>
  192. <if test="dateType=='year'">
  193. and date_format(create_time,'%Y')=date_format(#{date},'%Y')
  194. </if>
  195. and indent_state = 6 and indent_type = #{indentType}
  196. </select>
  197. <select id="cashDepositMoney" resultType="java.math.BigDecimal">
  198. select ifnull(sum(money), 0) from pay_details where 1 = 1
  199. <if test="dateType=='day'">
  200. and date_format(create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
  201. </if>
  202. <if test="dateType=='month'">
  203. and date_format(create_time,'%Y-%m')=date_format(#{date},'%Y-%m')
  204. </if>
  205. <if test="dateType=='year'">
  206. and date_format(create_time,'%Y')=date_format(#{date},'%Y')
  207. </if>
  208. and type = 3 and state = 1
  209. </select>
  210. <sql id="cashOutQueryCondition">
  211. <where>
  212. <if test="params.zhifubaoName != null and params.zhifubaoName != '' and params.zhifubaoName != 'null'">
  213. and co.zhifubao_name = #{params.zhifubaoName}
  214. </if>
  215. <if test="params.zhifubao != null and params.zhifubao != '' and params.zhifubao != 'null'">
  216. and co.zhifubao = #{params.zhifubao}
  217. </if>
  218. <if test="params.userId != null and params.userId != '' and params.userId != 'null'">
  219. and co.user_id = #{params.userId}
  220. </if>
  221. <if test="params.type != null and params.type != '' and params.type != 'null'">
  222. and co.type = #{params.type}
  223. </if>
  224. <if test="params.state != null and params.state != '' and params.state != 'null'">
  225. and co.state = #{params.state}
  226. </if>
  227. <if test="params.phone != null and params.phone != '' and params.phone != 'null'">
  228. and co.phone like concat('%',#{params.phone},'%')
  229. </if>
  230. <if test="params.classify == '1'">
  231. and co.classify = #{params.classify}
  232. </if>
  233. <if test="params.classify == '2'">
  234. and co.classify in ("2", "3", "4")
  235. </if>
  236. <if test="params.startTime != null and params.startTime != '' and params.startTime != 'null'">
  237. and co.create_at <![CDATA[ >= ]]> #{params.startTime}
  238. </if>
  239. <if test="params.endTime != null and params.endTime != '' and params.endTime != 'null'">
  240. and co.create_at <![CDATA[ ><= ]]> #{params.endTime}
  241. </if>
  242. <if test="params.shopName != null and params.shopName != '' and params.shopName != 'null'">
  243. and gh.shop_name like concat('%',#{params.shopName},'%')
  244. </if>
  245. </where>
  246. </sql>
  247. <select id="selectCashOutList" resultType="com.sqx.modules.pay.vo.CashOutVO">
  248. select gh.shop_name, co.*
  249. from cash_out co
  250. left join goods_shop gh on gh.shop_id = co.shop_id
  251. <include refid="cashOutQueryCondition"></include>
  252. order by id desc
  253. </select>
  254. <select id="selectCashOutTotal" resultType="java.lang.Double">
  255. select sum(co.money)
  256. from cash_out co
  257. left join goods_shop gh on gh.shop_id = co.shop_id
  258. <include refid="cashOutQueryCondition"></include>
  259. </select>
  260. </mapper>