CashDao.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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="query.dateType=='day'">
  174. and date_format(create_time,'%Y-%m-%d')=date_format(#{query.date},'%Y-%m-%d')
  175. </if>
  176. <if test="query.dateType=='month'">
  177. and date_format(create_time,'%Y-%m')=date_format(#{query.date},'%Y-%m')
  178. </if>
  179. <if test="query.dateType=='year'">
  180. and date_format(create_time,'%Y')=date_format(#{query.date},'%Y')
  181. </if>
  182. <if test="query.startTime!=null and query.startTime!=''">
  183. and create_time>=#{query.startTime}
  184. </if>
  185. <if test="query.endTime!=null and query.endTime!=''">
  186. and create_time <![CDATA[<=]]> #{query.endTime}
  187. </if>
  188. and indent_state =6
  189. </select>
  190. <select id="MoneySumByIndentType" resultType="java.math.BigDecimal">
  191. select ifnull(sum(platform_money), 0) from tb_indent where 1 = 1
  192. <if test="query.dateType=='day'">
  193. and date_format(create_time,'%Y-%m-%d')=date_format(#{query.date},'%Y-%m-%d')
  194. </if>
  195. <if test="query.dateType=='month'">
  196. and date_format(create_time,'%Y-%m')=date_format(#{query.date},'%Y-%m')
  197. </if>
  198. <if test="query.dateType=='year'">
  199. and date_format(create_time,'%Y')=date_format(#{query.date},'%Y')
  200. </if>
  201. <if test="query.startTime!=null and query.startTime!=''">
  202. and create_time>=#{query.startTime}
  203. </if>
  204. <if test="query.endTime!=null and query.endTime!=''">
  205. and create_time <![CDATA[<=]]> #{query.endTime}
  206. </if>
  207. and indent_state = 6 and indent_type = #{indentType}
  208. </select>
  209. <select id="cashDepositMoney" resultType="java.math.BigDecimal">
  210. select ifnull(sum(money), 0) from pay_details where 1 = 1
  211. <if test="query.dateType=='day'">
  212. and date_format(create_time,'%Y-%m-%d')=date_format(#{query.date},'%Y-%m-%d')
  213. </if>
  214. <if test="query.dateType=='month'">
  215. and date_format(create_time,'%Y-%m')=date_format(#{query.date},'%Y-%m')
  216. </if>
  217. <if test="query.dateType=='year'">
  218. and date_format(create_time,'%Y')=date_format(#{query.date},'%Y')
  219. </if>
  220. <if test="query.startTime!=null and query.startTime!=''">
  221. and create_time>=#{query.startTime}
  222. </if>
  223. <if test="query.endTime!=null and query.endTime!=''">
  224. and create_time <![CDATA[<=]]> #{query.endTime}
  225. </if>
  226. and type = 3 and state = 1
  227. </select>
  228. <sql id="cashOutQueryCondition">
  229. <where>
  230. <if test="params.zhifubaoName != null and params.zhifubaoName != '' and params.zhifubaoName != 'null'">
  231. and co.zhifubao_name = #{params.zhifubaoName}
  232. </if>
  233. <if test="params.zhifubao != null and params.zhifubao != '' and params.zhifubao != 'null'">
  234. and co.zhifubao = #{params.zhifubao}
  235. </if>
  236. <if test="params.userId != null">
  237. and co.user_id = #{params.userId}
  238. </if>
  239. <if test="params.type != null and params.type != '' and params.type != 'null'">
  240. and co.type = #{params.type}
  241. </if>
  242. <if test="params.state != null">
  243. and co.state = #{params.state}
  244. </if>
  245. <if test="params.phone != null and params.phone != '' and params.phone != 'null'">
  246. and co.phone like concat('%',#{params.phone},'%')
  247. </if>
  248. <if test="params.classify == 1 || params.classify == 5 || params.classify == 6">
  249. and co.classify = #{params.classify}
  250. </if>
  251. <if test="params.classify == 2">
  252. and co.classify in (2, 3, 4)
  253. </if>
  254. <if test="params.startTime != null and params.startTime != '' and params.startTime != 'null'">
  255. and co.create_at <![CDATA[ >= ]]> #{params.startTime}
  256. </if>
  257. <if test="params.endTime != null and params.endTime != '' and params.endTime != 'null'">
  258. and co.create_at <![CDATA[ <= ]]> #{params.endTime}
  259. </if>
  260. <if test="params.outStartTime != null and params.outStartTime != '' and params.outStartTime != 'null'">
  261. and co.out_at <![CDATA[ >= ]]> #{params.outStartTime}
  262. </if>
  263. <if test="params.outEndTime != null and params.outEndTime != '' and params.outEndTime != 'null'">
  264. and co.out_at <![CDATA[ <= ]]> #{params.outEndTime}
  265. </if>
  266. <if test="params.shopName != null and params.shopName != '' and params.shopName != 'null'">
  267. and gh.shop_name like concat('%',#{params.shopName},'%')
  268. </if>
  269. <if test="params.bankCardNo != null and params.bankCardNo != '' and params.bankCardNo != 'null'">
  270. and co.bank_card_no = #{params.bankCardNo}
  271. </if>
  272. <if test="params.bankRealName != null and params.bankRealName != '' and params.bankRealName != 'null'">
  273. and co.bank_real_name = #{params.bankRealName}
  274. </if>
  275. <if test="params.openBank != null and params.openBank != '' and params.openBank != 'null'">
  276. and co.open_bank = #{params.openBank}
  277. </if>
  278. <if test="params.riderStationId != null and params.riderStationId != '' ">
  279. and tu.rider_station_id = #{params.riderStationId}
  280. </if>
  281. </where>
  282. </sql>
  283. <select id="selectCashOutList" resultType="com.sqx.modules.pay.vo.CashOutVO">
  284. select gh.shop_name, co.*,rs.station_name as stationName,tu.user_name as userName, gh.mch_id as mchId, tu.phone as phoneNumber
  285. from cash_out co
  286. left join goods_shop gh on gh.shop_id = co.shop_id
  287. left join tb_user tu on tu.user_id=co.user_id
  288. left join rider_station rs on tu.rider_station_id=rs.id
  289. <include refid="cashOutQueryCondition"></include>
  290. order by id desc
  291. </select>
  292. <select id="selectRiderCashOutList" resultType="com.sqx.modules.pay.vo.CashOutVO">
  293. select co.*, rs.station_name as stationName, tu.user_name as userName, rbci.mch_id as mchId
  294. from cash_out co
  295. left join tb_user tu on tu.user_id = co.user_id
  296. left join rider_bank_card_info rbci on rbci.user_id = co.user_id
  297. left join rider_station rs on tu.rider_station_id=rs.id
  298. <include refid="cashOutQueryCondition"></include>
  299. order by co.id desc
  300. </select>
  301. <select id="selectCashOutTotal" resultType="java.lang.Double">
  302. select ifnull(sum(co.money), 0.0) as totalMoney
  303. from cash_out co
  304. left join goods_shop gh on gh.shop_id = co.shop_id
  305. <include refid="cashOutQueryCondition"></include>
  306. </select>
  307. <select id="selectCommissionTotal" resultType="java.lang.Double">
  308. select ifnull(sum(co.rate), 0.0) as totalMoney
  309. from cash_out co
  310. left join goods_shop gh on gh.shop_id = co.shop_id
  311. <include refid="cashOutQueryCondition"></include>
  312. </select>
  313. <select id="excelPayDetails" resultType="com.sqx.modules.pay.vo.CashOutVO">
  314. select gh.shop_name, co.*,rs.station_name as stationName
  315. from cash_out co
  316. left join goods_shop gh on gh.shop_id = co.shop_id
  317. left join tb_user tu on tu.user_id=co.user_id
  318. left join rider_station rs on tu.rider_station_id=rs.id
  319. <include refid="cashOutQueryCondition"></include>
  320. order by id desc
  321. </select>
  322. </mapper>