UserLockReleaseMapper.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  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.goafanti.common.dao.UserLockReleaseMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.UserLockRelease">
  5. <!--
  6. WARNING - @mbg.generated
  7. This element is automatically generated by MyBatis Generator, do not modify.
  8. This element was generated on Mon May 07 09:56:32 CST 2018.
  9. -->
  10. <id column="id" jdbcType="VARCHAR" property="id" />
  11. <result column="type" jdbcType="INTEGER" property="type" />
  12. <result column="uid" jdbcType="VARCHAR" property="uid" />
  13. <result column="aid" jdbcType="VARCHAR" property="aid" />
  14. <result column="business_project_id" jdbcType="VARCHAR" property="businessProjectId" />
  15. <result column="status" jdbcType="INTEGER" property="status" />
  16. <result column="lock_time" jdbcType="DATE" property="lockTime" />
  17. <result column="release_time" jdbcType="DATE" property="releaseTime" />
  18. <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
  19. </resultMap>
  20. <sql id="Example_Where_Clause">
  21. <!--
  22. WARNING - @mbg.generated
  23. This element is automatically generated by MyBatis Generator, do not modify.
  24. This element was generated on Mon May 07 09:56:32 CST 2018.
  25. -->
  26. <where>
  27. <foreach collection="oredCriteria" item="criteria" separator="or">
  28. <if test="criteria.valid">
  29. <trim prefix="(" prefixOverrides="and" suffix=")">
  30. <foreach collection="criteria.criteria" item="criterion">
  31. <choose>
  32. <when test="criterion.noValue">
  33. and ${criterion.condition}
  34. </when>
  35. <when test="criterion.singleValue">
  36. and ${criterion.condition} #{criterion.value}
  37. </when>
  38. <when test="criterion.betweenValue">
  39. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  40. </when>
  41. <when test="criterion.listValue">
  42. and ${criterion.condition}
  43. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  44. #{listItem}
  45. </foreach>
  46. </when>
  47. </choose>
  48. </foreach>
  49. </trim>
  50. </if>
  51. </foreach>
  52. </where>
  53. </sql>
  54. <sql id="Update_By_Example_Where_Clause">
  55. <!--
  56. WARNING - @mbg.generated
  57. This element is automatically generated by MyBatis Generator, do not modify.
  58. This element was generated on Mon May 07 09:56:32 CST 2018.
  59. -->
  60. <where>
  61. <foreach collection="example.oredCriteria" item="criteria" separator="or">
  62. <if test="criteria.valid">
  63. <trim prefix="(" prefixOverrides="and" suffix=")">
  64. <foreach collection="criteria.criteria" item="criterion">
  65. <choose>
  66. <when test="criterion.noValue">
  67. and ${criterion.condition}
  68. </when>
  69. <when test="criterion.singleValue">
  70. and ${criterion.condition} #{criterion.value}
  71. </when>
  72. <when test="criterion.betweenValue">
  73. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  74. </when>
  75. <when test="criterion.listValue">
  76. and ${criterion.condition}
  77. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  78. #{listItem}
  79. </foreach>
  80. </when>
  81. </choose>
  82. </foreach>
  83. </trim>
  84. </if>
  85. </foreach>
  86. </where>
  87. </sql>
  88. <sql id="Base_Column_List">
  89. <!--
  90. WARNING - @mbg.generated
  91. This element is automatically generated by MyBatis Generator, do not modify.
  92. This element was generated on Mon May 07 09:56:32 CST 2018.
  93. -->
  94. id, type, uid, aid, business_project_id, status, lock_time, release_time, order_no
  95. </sql>
  96. <select id="selectByExample" parameterType="com.goafanti.common.model.UserLockReleaseExample" resultMap="BaseResultMap">
  97. <!--
  98. WARNING - @mbg.generated
  99. This element is automatically generated by MyBatis Generator, do not modify.
  100. This element was generated on Mon May 07 09:56:32 CST 2018.
  101. -->
  102. select
  103. <if test="distinct">
  104. distinct
  105. </if>
  106. <include refid="Base_Column_List" />
  107. from user_lock_release
  108. <if test="_parameter != null">
  109. <include refid="Example_Where_Clause" />
  110. </if>
  111. <if test="orderByClause != null">
  112. order by ${orderByClause}
  113. </if>
  114. </select>
  115. <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
  116. <!--
  117. WARNING - @mbg.generated
  118. This element is automatically generated by MyBatis Generator, do not modify.
  119. This element was generated on Mon May 07 09:56:32 CST 2018.
  120. -->
  121. select
  122. <include refid="Base_Column_List" />
  123. from user_lock_release
  124. where id = #{id,jdbcType=VARCHAR}
  125. </select>
  126. <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
  127. <!--
  128. WARNING - @mbg.generated
  129. This element is automatically generated by MyBatis Generator, do not modify.
  130. This element was generated on Mon May 07 09:56:32 CST 2018.
  131. -->
  132. delete from user_lock_release
  133. where id = #{id,jdbcType=VARCHAR}
  134. </delete>
  135. <delete id="deleteByExample" parameterType="com.goafanti.common.model.UserLockReleaseExample">
  136. <!--
  137. WARNING - @mbg.generated
  138. This element is automatically generated by MyBatis Generator, do not modify.
  139. This element was generated on Mon May 07 09:56:32 CST 2018.
  140. -->
  141. delete from user_lock_release
  142. <if test="_parameter != null">
  143. <include refid="Example_Where_Clause" />
  144. </if>
  145. </delete>
  146. <insert id="insert" parameterType="com.goafanti.common.model.UserLockRelease">
  147. <!--
  148. WARNING - @mbg.generated
  149. This element is automatically generated by MyBatis Generator, do not modify.
  150. This element was generated on Mon May 07 09:56:32 CST 2018.
  151. -->
  152. insert into user_lock_release (id, type, uid,
  153. aid, business_project_id, status,
  154. lock_time, release_time, order_no
  155. )
  156. values (#{id,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{uid,jdbcType=VARCHAR},
  157. #{aid,jdbcType=VARCHAR}, #{businessProjectId,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER},
  158. #{lockTime,jdbcType=DATE}, #{releaseTime,jdbcType=DATE}, #{orderNo,jdbcType=VARCHAR}
  159. )
  160. </insert>
  161. <insert id="insertSelective" parameterType="com.goafanti.common.model.UserLockRelease">
  162. <!--
  163. WARNING - @mbg.generated
  164. This element is automatically generated by MyBatis Generator, do not modify.
  165. This element was generated on Mon May 07 09:56:32 CST 2018.
  166. -->
  167. insert into user_lock_release
  168. <trim prefix="(" suffix=")" suffixOverrides=",">
  169. <if test="id != null">
  170. id,
  171. </if>
  172. <if test="type != null">
  173. type,
  174. </if>
  175. <if test="uid != null">
  176. uid,
  177. </if>
  178. <if test="aid != null">
  179. aid,
  180. </if>
  181. <if test="businessProjectId != null">
  182. business_project_id,
  183. </if>
  184. <if test="status != null">
  185. status,
  186. </if>
  187. <if test="lockTime != null">
  188. lock_time,
  189. </if>
  190. <if test="releaseTime != null">
  191. release_time,
  192. </if>
  193. <if test="orderNo != null">
  194. order_no,
  195. </if>
  196. </trim>
  197. <trim prefix="values (" suffix=")" suffixOverrides=",">
  198. <if test="id != null">
  199. #{id,jdbcType=VARCHAR},
  200. </if>
  201. <if test="type != null">
  202. #{type,jdbcType=INTEGER},
  203. </if>
  204. <if test="uid != null">
  205. #{uid,jdbcType=VARCHAR},
  206. </if>
  207. <if test="aid != null">
  208. #{aid,jdbcType=VARCHAR},
  209. </if>
  210. <if test="businessProjectId != null">
  211. #{businessProjectId,jdbcType=VARCHAR},
  212. </if>
  213. <if test="status != null">
  214. #{status,jdbcType=INTEGER},
  215. </if>
  216. <if test="lockTime != null">
  217. #{lockTime,jdbcType=DATE},
  218. </if>
  219. <if test="releaseTime != null">
  220. #{releaseTime,jdbcType=DATE},
  221. </if>
  222. <if test="orderNo != null">
  223. #{orderNo,jdbcType=VARCHAR},
  224. </if>
  225. </trim>
  226. </insert>
  227. <select id="countByExample" parameterType="com.goafanti.common.model.UserLockReleaseExample" resultType="java.lang.Long">
  228. <!--
  229. WARNING - @mbg.generated
  230. This element is automatically generated by MyBatis Generator, do not modify.
  231. This element was generated on Mon May 07 09:56:32 CST 2018.
  232. -->
  233. select count(*) from user_lock_release
  234. <if test="_parameter != null">
  235. <include refid="Example_Where_Clause" />
  236. </if>
  237. </select>
  238. <update id="updateByExampleSelective" parameterType="map">
  239. <!--
  240. WARNING - @mbg.generated
  241. This element is automatically generated by MyBatis Generator, do not modify.
  242. This element was generated on Mon May 07 09:56:32 CST 2018.
  243. -->
  244. update user_lock_release
  245. <set>
  246. <if test="record.id != null">
  247. id = #{record.id,jdbcType=VARCHAR},
  248. </if>
  249. <if test="record.type != null">
  250. type = #{record.type,jdbcType=INTEGER},
  251. </if>
  252. <if test="record.uid != null">
  253. uid = #{record.uid,jdbcType=VARCHAR},
  254. </if>
  255. <if test="record.aid != null">
  256. aid = #{record.aid,jdbcType=VARCHAR},
  257. </if>
  258. <if test="record.businessProjectId != null">
  259. business_project_id = #{record.businessProjectId,jdbcType=VARCHAR},
  260. </if>
  261. <if test="record.status != null">
  262. status = #{record.status,jdbcType=INTEGER},
  263. </if>
  264. <if test="record.lockTime != null">
  265. lock_time = #{record.lockTime,jdbcType=DATE},
  266. </if>
  267. <if test="record.releaseTime != null">
  268. release_time = #{record.releaseTime,jdbcType=DATE},
  269. </if>
  270. <if test="record.orderNo != null">
  271. order_no = #{record.orderNo,jdbcType=VARCHAR},
  272. </if>
  273. </set>
  274. <if test="_parameter != null">
  275. <include refid="Update_By_Example_Where_Clause" />
  276. </if>
  277. </update>
  278. <update id="updateByExample" parameterType="map">
  279. <!--
  280. WARNING - @mbg.generated
  281. This element is automatically generated by MyBatis Generator, do not modify.
  282. This element was generated on Mon May 07 09:56:32 CST 2018.
  283. -->
  284. update user_lock_release
  285. set id = #{record.id,jdbcType=VARCHAR},
  286. type = #{record.type,jdbcType=INTEGER},
  287. uid = #{record.uid,jdbcType=VARCHAR},
  288. aid = #{record.aid,jdbcType=VARCHAR},
  289. business_project_id = #{record.businessProjectId,jdbcType=VARCHAR},
  290. status = #{record.status,jdbcType=INTEGER},
  291. lock_time = #{record.lockTime,jdbcType=DATE},
  292. release_time = #{record.releaseTime,jdbcType=DATE},
  293. order_no = #{record.orderNo,jdbcType=VARCHAR}
  294. <if test="_parameter != null">
  295. <include refid="Update_By_Example_Where_Clause" />
  296. </if>
  297. </update>
  298. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.UserLockRelease">
  299. <!--
  300. WARNING - @mbg.generated
  301. This element is automatically generated by MyBatis Generator, do not modify.
  302. This element was generated on Mon May 07 09:56:32 CST 2018.
  303. -->
  304. update user_lock_release
  305. <set>
  306. <if test="type != null">
  307. type = #{type,jdbcType=INTEGER},
  308. </if>
  309. <if test="uid != null">
  310. uid = #{uid,jdbcType=VARCHAR},
  311. </if>
  312. <if test="aid != null">
  313. aid = #{aid,jdbcType=VARCHAR},
  314. </if>
  315. <if test="businessProjectId != null">
  316. business_project_id = #{businessProjectId,jdbcType=VARCHAR},
  317. </if>
  318. <if test="status != null">
  319. status = #{status,jdbcType=INTEGER},
  320. </if>
  321. <if test="lockTime != null">
  322. lock_time = #{lockTime,jdbcType=DATE},
  323. </if>
  324. <if test="releaseTime != null">
  325. release_time = #{releaseTime,jdbcType=DATE},
  326. </if>
  327. <if test="orderNo != null">
  328. order_no = #{orderNo,jdbcType=VARCHAR},
  329. </if>
  330. </set>
  331. where id = #{id,jdbcType=VARCHAR}
  332. </update>
  333. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.UserLockRelease">
  334. <!--
  335. WARNING - @mbg.generated
  336. This element is automatically generated by MyBatis Generator, do not modify.
  337. This element was generated on Mon May 07 09:56:32 CST 2018.
  338. -->
  339. update user_lock_release
  340. set type = #{type,jdbcType=INTEGER},
  341. uid = #{uid,jdbcType=VARCHAR},
  342. aid = #{aid,jdbcType=VARCHAR},
  343. business_project_id = #{businessProjectId,jdbcType=VARCHAR},
  344. status = #{status,jdbcType=INTEGER},
  345. lock_time = #{lockTime,jdbcType=DATE},
  346. release_time = #{releaseTime,jdbcType=DATE},
  347. order_no = #{orderNo,jdbcType=VARCHAR}
  348. where id = #{id,jdbcType=VARCHAR}
  349. </update>
  350. <delete id="deleteLockByOrder">
  351. delete from user_lock_release where order_no = #{orderNo,jdbcType=VARCHAR} and business_project_id = #{businessProjectId,jdbcType=VARCHAR}
  352. </delete>
  353. <update id="updateUserLock">
  354. update user_lock_release set status = #{newStatus} where uid = #{uid} and aid = #{aid} and type = 0 and status = #{oldStatus}
  355. </update>
  356. <update id="updateUsersLock">
  357. update user_lock_release set status = #{newStatus}
  358. where aid = #{aid} and type = 0 and status = #{oldStatus}
  359. and uid in
  360. <foreach item="item" collection="uList" separator="," open="(" close=")" index="">
  361. #{item}
  362. </foreach>
  363. </update>
  364. <update id="updateUserTypeLock">
  365. update user_lock_release set status = #{newStatus} , release_time= #{date}
  366. where uid = #{uid} and aid = #{aid} and type = 0 and type = #{type}
  367. </update>
  368. <update id="updateUserTypeLockList">
  369. update user_lock_release set status = #{newStatus} , release_time= #{date}
  370. where aid = #{aid} and type = 0 and type = #{type} and uid in
  371. <foreach item="item" collection="list" separator="," open="(" close=")" index="">
  372. #{item}
  373. </foreach>
  374. </update>
  375. <select id="selectWaitReleaseCustomer" resultType="com.goafanti.customer.bo.LockingReleaseBo">
  376. select
  377. t0.id,
  378. t0.uid,
  379. t0.aid,
  380. t0.lock_time,
  381. t1.last_follow_time
  382. from
  383. (select id,uid,aid,lock_time from user_lock_release where aid = #{aid} and type = 0 and status = 0)t0
  384. left join
  385. (select uid,aid,max(create_time) as last_follow_time from user_follow where aid = #{aid} group by uid)t1
  386. on t0.uid = t1.uid
  387. where datediff(now(),if(t0.lock_time &lt; t1.last_follow_time,t1.last_follow_time,t1.t0.lock_time))>30 or datediff(now(),t0.lock_time)>270
  388. </select>
  389. <select id="selectWaitReleaseBusiness" resultType="com.goafanti.customer.bo.LockingReleaseBo">
  390. select
  391. t0.id,
  392. t0.uid,
  393. t0.aid,
  394. t0.lock_time,
  395. t1.last_follow_time
  396. from
  397. (select id,uid,aid,lock_time from user_lock_release t0 where aid = #{aid} and type = 1 and status = 0)t0
  398. left join
  399. (select uid,aid,max(create_time) as last_follow_time from user_follow where aid = #{aid} group by uid)t1
  400. on t0.uid = t1.uid
  401. where datediff(t1.last_follow_time,lock_time)>360 or datediff(now(),t0.lock_time)>900
  402. </select>
  403. <update id="updateReleaseLock" parameterType="java.lang.String">
  404. update user_lock_release set status = 2,release_time = #{time} where status=1
  405. </update>
  406. <update id="updatePendingReleaseLock" parameterType="java.lang.String">
  407. update user_lock_release set status = 1 where id in (${lockIds})
  408. </update>
  409. <select id="selectPendinglockUserList" resultType="com.goafanti.customer.bo.LockingReleaseBo">
  410. select id,uid,type from user_lock_release where status=1
  411. </select>
  412. <update id="updateProject" parameterType="java.lang.String">
  413. update user_lock_release set status = 2,release_time=now()
  414. where uid= #{uid,jdbcType=VARCHAR}
  415. and aid= #{aid,jdbcType=VARCHAR}
  416. and business_project_id= #{businessProjectId,jdbcType=VARCHAR}
  417. </update>
  418. <select id="checkTask" resultType="com.goafanti.customer.bo.LockingReleaseBo">
  419. select
  420. id, type, uid, aid, business_project_id as businessProjectId, status
  421. from user_lock_release where type =1
  422. and status=0
  423. and uid=#{buyerId,jdbcType=VARCHAR}
  424. and business_project_id=#{commodityId,jdbcType=VARCHAR}
  425. </select>
  426. <update id="updatePrivateBusinessTransfer">
  427. update user_lock_release set aid=#{inputId} where uid= #{uid} and business_project_id= #{pid} and aid= #{aid};
  428. </update>
  429. <select id="checkUserProject" resultType="com.goafanti.customer.bo.LockingReleaseBo">
  430. select
  431. id, type, uid, aid, business_project_id as businessProjectId, status
  432. from user_lock_release where type =1
  433. and status=0
  434. and uid=#{uid,jdbcType=VARCHAR}
  435. and aid=#{aid,jdbcType=VARCHAR}
  436. and business_project_id=#{pid,jdbcType=VARCHAR}
  437. </select>
  438. <select id="selectUserDays" resultType="com.goafanti.common.bo.userDaysBo">
  439. select
  440. t0.uid,
  441. t0.aid,
  442. u.nickname name
  443. from
  444. (select id,uid,aid,lock_time from user_lock_release where aid = #{aid} and type = 0 and status = 0)t0
  445. left join
  446. (select uid,aid,max(create_time) as last_follow_time from user_follow where aid = #{aid} group by uid)t1
  447. on t0.uid = t1.uid
  448. left join user u on t0.uid=u.id
  449. where datediff(now(),if(t0.lock_time &lt; t1.last_follow_time,t1.last_follow_time,t1.t0.lock_time))> #{x} or datediff(now(),t0.lock_time)> #{y}
  450. </select>
  451. <insert id="insertUserMid">
  452. insert into user_mid (uid,aid,last_sign_time,last_follow_time,create_time)
  453. values (#{uid},#{aid},#{lockTime},#{followTime},now())
  454. </insert>
  455. <update id="updateUserMid" >
  456. update user_mid
  457. set last_sign_time=#{lockTime},last_follow_time=#{followTime}
  458. where uid=#{uid} and aid=#{aid}
  459. </update>
  460. <insert id="insertList" >
  461. insert into user_lock_release (id, type, uid,
  462. aid, business_project_id, status,
  463. lock_time, release_time, order_no
  464. )
  465. values
  466. <foreach item="item" collection="list" separator="," index="">
  467. (#{item.id,jdbcType=VARCHAR}, #{item.type,jdbcType=INTEGER}, #{item.uid,jdbcType=VARCHAR},
  468. #{item.aid,jdbcType=VARCHAR}, #{item.businessProjectId,jdbcType=VARCHAR}, #{item.status,jdbcType=INTEGER},
  469. #{item.lockTime,jdbcType=DATE}, #{item.releaseTime,jdbcType=DATE}, #{item.orderNo,jdbcType=VARCHAR})
  470. </foreach>
  471. </insert>
  472. <select id="checkLock" resultType="java.lang.Integer">
  473. select count(*) from user_lock_release
  474. where aid= #{aid} and uid= #{uid} and business_project_id = #{pid}
  475. </select>
  476. <update id="updateReleaseList" >
  477. update user_lock_release
  478. set release_time =now(),status =2
  479. where id in
  480. <foreach item="item" collection="list" separator="," open="(" close=")" index="">
  481. #{item}
  482. </foreach>
  483. </update>
  484. <select id="selectByUidGetCount" resultType="java.lang.Integer">
  485. select count(*) from user_lock_release
  486. where `type` =1 and aid = #{aid} and uid= #{uid}
  487. </select>
  488. <update id="updateReleaseUser">
  489. update t_order_new a ,user b ,user_business c
  490. set b.share_type =1,b.transfer_time =now(),
  491. c.customer_status =6,c.follow_situation =8
  492. where a.order_no = #{orderNo} and a.buyer_id =b.id
  493. and a.buyer_id =c.uid and a.salesman_id =c.aid and c.follow_situation =5
  494. </update>
  495. </mapper>