UserDao.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  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.app.dao.UserDao">
  4. <select id="selectUserPage" resultType="com.sqx.modules.app.entity.UserEntity">
  5. select * from tb_user
  6. where 1=1
  7. <if test="search!=null and search!=''">
  8. and (user_id=#{search} or phone = #{search} or user_name =#{search} )
  9. </if>
  10. <if test="sex!=null and sex!=0">
  11. and sex=#{sex}
  12. </if>
  13. <if test="platform!=null and platform!=''">
  14. and platform=#{platform}
  15. </if>
  16. <if test="sysPhone!=null and sysPhone!=''">
  17. and sys_phone=#{sysPhone}
  18. </if>
  19. <if test="type!=null and type!=''">
  20. <if test="type==1">
  21. and (open_id is not null or wx_open_id is not null)
  22. </if>
  23. <if test="type==2">
  24. and (rider_open_id is not null or rider_wx_open_id is not null)
  25. </if>
  26. </if>
  27. <if test="status!=null and status!=0">
  28. and status=#{status}
  29. </if>
  30. <if test="userName!=null and userName!=''">
  31. and user_name = #{userName}
  32. </if>
  33. <if test="nickName!=null and nickName!=''">
  34. and nick_name = #{nickName}
  35. </if>
  36. <if test="isVip!=null">
  37. and is_vip = #{isVip}
  38. </if>
  39. <if test="shopAdminFlag!=null and shopAdminFlag==1">
  40. and admin_user_id is not null
  41. </if>
  42. order by create_time desc
  43. </select>
  44. <select id="queryRider" resultType="com.sqx.modules.app.entity.queryRiderVo">
  45. select u.user_id,u.clientid,u.open_id,u.rider_open_id,u.user_name,u.phone,u.cash_deposit,u.check_certification,r.station_name
  46. from tb_user u
  47. left join rider_station r on r.id = u.rider_station_id
  48. where u.user_id != #{userId}
  49. </select>
  50. <select id="queryRiders" resultType="com.sqx.modules.app.entity.queryRidersVo">
  51. select u.user_id,u.user_name,u.phone,u.avatar,r.station_name
  52. from tb_user u
  53. left join rider_station r on r.id = u.rider_station_id
  54. where u.rider_open_id is not null and u.on_line_flag = 1
  55. and u.rider_station_id = #{riderStationId} and u.user_id != #{userId}
  56. <if test="keyword != null and keyword != ''">
  57. and (u.phone like concat('%',#{keyword},'%') or u.user_name like concat('%',#{keyword},'%'))
  58. </if>
  59. </select>
  60. <select id="queryInviterCount" resultType="int">
  61. select count(*) from tb_user
  62. where inviter_code=#{inviterCode}
  63. </select>
  64. <select id="queryUserCount" resultType="int">
  65. select count(*)from tb_user where 1=1
  66. <if test="type==1">
  67. and date_format(create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
  68. </if>
  69. <if test="type==2">
  70. and date_format(create_time,'%Y-%m')=date_format(#{date},'%Y-%m')
  71. </if>
  72. <if test="type==3">
  73. and date_format(create_time,'%Y')=date_format(#{date},'%Y')
  74. </if>
  75. </select>
  76. <select id="queryPayMoney" resultType="Double">
  77. select sum(money) from pay_details where `state`=1
  78. <if test="type==1">
  79. and date_format(create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
  80. </if>
  81. <if test="type==2">
  82. and date_format(create_time,'%Y-%m')=date_format(#{date},'%Y-%m')
  83. </if>
  84. <if test="type==3">
  85. and date_format(create_time,'%Y')=date_format(#{date},'%Y')
  86. </if>
  87. </select>
  88. <select id="queryCourseOrder" resultType="com.sqx.modules.app.response.CourseOrderResponse">
  89. select * from (
  90. select c.course_id as courseId,sum(o.pay_money) as 'coursemoney' ,count(*) as 'coursenum',any_value(c.title) as
  91. 'coursename' from orders o , course c where o.course_id=c.course_id and o.status=1 and o.orders_type=1
  92. <if test="type==1">
  93. and date_format(o.create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
  94. </if>
  95. <if test="type==2">
  96. and date_format(o.create_time,'%Y-%m')=date_format(#{date},'%Y-%m')
  97. </if>
  98. <if test="type==3">
  99. and date_format(o.create_time,'%Y')=date_format(#{date},'%Y')
  100. </if>
  101. group by c.course_id
  102. ) a
  103. order by a.coursenum desc
  104. </select>
  105. <select id="userMessage" resultType="int">
  106. select count(*) from tb_user t ,user_vip v where t.user_id=v.user_id and is_vip=1
  107. <if test="type==1">
  108. and date_format(t.create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
  109. </if>
  110. <if test="type==2">
  111. and date_format(t.create_time,'%Y-%m')=date_format(#{date},'%Y-%m')
  112. </if>
  113. <if test="type==3">
  114. and date_format(t.create_time,'%Y')=date_format(#{date},'%Y')
  115. </if>
  116. </select>
  117. <insert id="insertUser" parameterType="com.sqx.modules.app.entity.UserEntity" useGeneratedKeys="true"
  118. keyProperty="userId">
  119. INSERT INTO tb_user
  120. <trim prefix="(" suffix=")" suffixOverrides=",">
  121. <if test="null != userName and '' != userName">
  122. user_name,
  123. </if>
  124. <if test="null != phone and '' != phone">
  125. phone,
  126. </if>
  127. <if test="null != avatar and '' != avatar">
  128. avatar,
  129. </if>
  130. <if test="null != sex and '' != sex">
  131. sex,
  132. </if>
  133. <if test="null != age and '' != age">
  134. age,
  135. </if>
  136. <if test="null != openId and '' != openId">
  137. open_id,
  138. </if>
  139. <if test="null != wxOpenId and '' != wxOpenId">
  140. wx_open_id,
  141. </if>
  142. <if test="null != password and '' != password">
  143. password,
  144. </if>
  145. <if test="null != createTime and '' != createTime">
  146. create_time,
  147. </if>
  148. <if test="null != updateTime and '' != updateTime">
  149. update_time,
  150. </if>
  151. <if test="null != appleId and '' != appleId">
  152. apple_id,
  153. </if>
  154. <if test="null != sysPhone and '' != sysPhone">
  155. sys_phone,
  156. </if>
  157. <if test="null != status and '' != status">
  158. status,
  159. </if>
  160. <if test="null != platform and '' != platform">
  161. platform,
  162. </if>
  163. <if test="null != jifen and '' != jifen">
  164. jifen,
  165. </if>
  166. <if test="null != invitationCode and '' != invitationCode">
  167. invitation_code,
  168. </if>
  169. <if test="null != inviterCode and '' != inviterCode">
  170. inviter_code,
  171. </if>
  172. <if test="null != clientid and '' != clientid">
  173. clientid,
  174. </if>
  175. <if test="null != zhiFuBaoName and '' != zhiFuBaoName">
  176. zhi_fu_bao_name,
  177. </if>
  178. <if test="null != zhiFuBao and '' != zhiFuBao">
  179. zhi_fu_bao,
  180. </if>
  181. <if test="null != isVip">
  182. is_vip,
  183. </if>
  184. <if test="null != userType">
  185. user_type,
  186. </if>
  187. <if test="null != nickName and '' != nickName">
  188. nick_name,
  189. </if>
  190. <if test="null != cashDeposit">
  191. cash_deposit,
  192. </if>
  193. <if test="null != balance">
  194. balance,
  195. </if>
  196. <if test="null != riderWxOpenId and '' != riderWxOpenId">
  197. rider_wx_open_id,
  198. </if>
  199. <if test="null != newUserFlag">
  200. new_user_flag,
  201. </if>
  202. <if test="null != newUserFlagWm">
  203. new_user_flag_wm
  204. </if>
  205. </trim>
  206. <trim prefix="values (" suffix=")" suffixOverrides=",">
  207. <if test="null != userName and '' != userName">
  208. #{userName},
  209. </if>
  210. <if test="null != phone and '' != phone">
  211. #{phone},
  212. </if>
  213. <if test="null != avatar and '' != avatar">
  214. #{avatar},
  215. </if>
  216. <if test="null != sex and '' != sex">
  217. #{sex},
  218. </if>
  219. <if test="null != age and '' != age">
  220. #{age},
  221. </if>
  222. <if test="null != openId and '' != openId">
  223. #{openId},
  224. </if>
  225. <if test="null != wxOpenId and '' != wxOpenId">
  226. #{wxOpenId},
  227. </if>
  228. <if test="null != password and '' != password">
  229. #{password},
  230. </if>
  231. <if test="null != createTime and '' != createTime">
  232. #{createTime},
  233. </if>
  234. <if test="null != updateTime and '' != updateTime">
  235. #{updateTime},
  236. </if>
  237. <if test="null != appleId and '' != appleId">
  238. #{appleId},
  239. </if>
  240. <if test="null != sysPhone and '' != sysPhone">
  241. #{sysPhone},
  242. </if>
  243. <if test="null != status and '' != status">
  244. #{status},
  245. </if>
  246. <if test="null != platform and '' != platform">
  247. #{platform},
  248. </if>
  249. <if test="null != jifen and '' != jifen">
  250. #{jifen},
  251. </if>
  252. <if test="null != invitationCode and '' != invitationCode">
  253. #{invitationCode},
  254. </if>
  255. <if test="null != inviterCode and '' != inviterCode">
  256. #{inviterCode},
  257. </if>
  258. <if test="null != clientid and '' != clientid">
  259. #{clientid},
  260. </if>
  261. <if test="null != zhiFuBaoName and '' != zhiFuBaoName">
  262. #{zhiFuBaoName},
  263. </if>
  264. <if test="null != zhiFuBao and '' != zhiFuBao">
  265. #{zhiFuBao},
  266. </if>
  267. <if test="null != isVip">
  268. #{isVip},
  269. </if>
  270. <if test="null != userType">
  271. #{userType},
  272. </if>
  273. <if test="null != nickName and '' != nickName">
  274. #{nickName},
  275. </if>
  276. <if test="null != cashDeposit">
  277. #{cashDeposit},
  278. </if>
  279. <if test="null != balance">
  280. #{balance},
  281. </if>
  282. <if test="null != riderWxOpenId and '' != riderWxOpenId">
  283. #{riderWxOpenId},
  284. </if>
  285. <if test="null != newUserFlag">
  286. #{newUserFlag},
  287. </if>
  288. <if test="null != newUserFlagWm">
  289. #{newUserFlagWm}
  290. </if>
  291. </trim>
  292. </insert>
  293. <select id="takingOrdersMessage" resultType="com.sqx.modules.app.response.TakingOrderResponse">
  294. SELECT
  295. SUM( o.order_number ) AS orderNumber,
  296. g.game_name,
  297. SUM( o.pay_money ) AS payMoney
  298. FROM
  299. ( orders o LEFT JOIN order_taking t ON o.order_taking_id = t.id )
  300. LEFT JOIN game g ON g.id = t.game_id
  301. WHERE
  302. o.state = 1
  303. <if test="type==1">
  304. and date_format("o.create_time",'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
  305. </if>
  306. <if test="type==2">
  307. and date_format("o.create_time",'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
  308. </if>
  309. <if test="type==3">
  310. and date_format("o.create_time",'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
  311. </if>
  312. GROUP BY
  313. g.game_name
  314. </select>
  315. <update id="updateCashDeposit">
  316. update tb_user set
  317. cash_deposit = cash_deposit+#{cashDeposit}
  318. where user_id = #{userId}
  319. </update>
  320. <!--<select id="selectUserList" resultType="com.sqx.modules.app.entity.UserEntity">
  321. select * from tb_user
  322. where 1=1
  323. <if test="userName!=null and userName!''">
  324. and user_name =#{userName}
  325. </if>
  326. order by create_time desc
  327. </select>-->
  328. <select id="selectAllUser" resultType="com.sqx.modules.app.entity.UserEntity">
  329. select tu.*, um.sex as umSex from tb_user tu left join user_message um on tu.user_id = um.user_id where 1 = 1
  330. <if test="phone!=null and phone!=''">
  331. and phone = #{phone}
  332. </if>
  333. <if test="userType!=null">
  334. and type = #{userType}
  335. </if>
  336. order by tu.create_time desc
  337. </select>
  338. <select id="findUserMessage" resultType="com.sqx.modules.app.entity.UserEntity">
  339. select tu.*, um.birthday as birthday, um.height as height, um.weight as weight, um.occupation as occupation, um.individual_resume as individualResume,
  340. um.picture_list as pictureList, um.sex as umSex
  341. from tb_user tu left join user_message um on tu.user_id = um.user_id where tu.user_id = #{userId}
  342. </select>
  343. <select id="selectUser" resultType="com.sqx.modules.app.entity.UserEntity">
  344. select * from tb_user where 1 = 1
  345. <if test="userName!=null and userName!=''">
  346. and user_name like concat('%',#{userName},'%')
  347. </if>
  348. <if test="phone!=null and phone!=''">
  349. and phone like concat('%',#{phone},'%')
  350. </if>
  351. </select>
  352. <select id="selectUserById" resultType="com.sqx.modules.app.entity.UserEntity">
  353. select tu.*, um.money as money, ui.integral_num as integralNum
  354. from tb_user tu
  355. left join user_money um on tu.user_id = um.user_id
  356. left join user_integral ui on tu.user_id = ui.user_id
  357. where tu.user_id = #{userId}
  358. </select>
  359. <insert id="topUpMoney">
  360. insert into pay_details (classify, order_id, money, user_id, state, create_time, pay_time, type)
  361. values (#{classify}, #{orderId}, #{money}, #{userId}, #{state}, #{date}, #{date1}, #{type})
  362. </insert>
  363. <update id="certification">
  364. update tb_user set user_name = #{userName}, audit_time = #{format}, identity_card_number = #{identityCardNumber}, identity_card_front = #{identityCardFront},
  365. identity_card_verso = #{identityCardVerso}, self_identity_card = #{selfIdentityCard}, check_certification = "0", cash_deposit=#{cashDeposit}, check_number=#{checkNumber} where user_id = #{userId}
  366. </update>
  367. <insert id="userFeedback">
  368. insert into sys_feedback (feedback_type, user_id, user_email, feedback_score, feedback_message, feedback_time)
  369. values
  370. (#{feedbackType}, #{userId}, #{userEmail}, #{feedbackScore}, #{feedbackMessage}, #{format})
  371. </insert>
  372. <insert id="addRedPacket">
  373. insert into errand_user_red_packet (user_id, red_packet_type, minimum_amount, red_packet_amount, red_packet_title, expiration_time, delete_flag, create_time)
  374. values (#{userId}, #{redPacketType}, #{minimumAmount}, #{redPacketAmount}, #{redPacketTitle}, #{expirationTime}, "0", #{createTime})
  375. </insert>
  376. <update id="updateOldUser">
  377. update tb_user set new_user_flag = "2" where user_id = #{userId}
  378. </update>
  379. <select id="selectUserMessage" resultType="com.sqx.modules.app.entity.UserEntity">
  380. select tu.*, gs.status as shopStatus from tb_user tu left join sys_user_shop sus on tu.admin_user_id = sus.user_id
  381. left join goods_shop gs on sus.shop_id = gs.shop_id
  382. where tu.user_id = #{userId}
  383. </select>
  384. <select id="selectVipOverdue" resultType="com.sqx.modules.app.entity.UserEntity">
  385. select * from tb_user where is_vip = 1 and vip_expiration_time &lt; #{date}
  386. </select>
  387. <update id="updateUserClientIdIsNull">
  388. update tb_user set clientid='' where clientid=#{clientid}
  389. </update>
  390. <update id="updateUserRiderClientIdIsNull">
  391. update tb_user set rider_clientid='' where rider_clientid=#{clientid}
  392. </update>
  393. <update id="updateUserShopClientIdIsNull">
  394. update tb_user set shop_client_id='' where shop_client_id=#{clientid}
  395. </update>
  396. <select id="selectRiderUserByOnLineFlag" resultType="com.sqx.modules.app.entity.UserEntity">
  397. select * from (select (st_distance (point (r.lng, r.lat),point(#{lng},#{lat}) ) *111195) as distance,t.*
  398. from rider_location r
  399. left join tb_user t on t.user_id=r.user_id
  400. where t.on_line_flag=1
  401. ) a where distance&lt;=#{distance}
  402. </select>
  403. </mapper>