UserExamGoodsMapper.xml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.zhongzheng.modules.user.mapper.UserExamGoodsMapper">
  6. <resultMap type="com.zhongzheng.modules.user.domain.UserExamGoods" id="UserExamGoodsResult">
  7. <result property="userExamGoodsId" column="user_exam_goods_id"/>
  8. <result property="userId" column="user_id"/>
  9. <result property="goodsId" column="goods_id"/>
  10. <result property="examNumber" column="exam_number"/>
  11. <result property="doNumber" column="do_number"/>
  12. <result property="orderGoodsId" column="order_goods_id"/>
  13. </resultMap>
  14. <resultMap type="com.zhongzheng.modules.user.vo.UserExamGoodsVo" id="UserExamGoodsVo">
  15. <result property="userExamGoodsId" column="user_exam_goods_id"/>
  16. <result property="userId" column="user_id"/>
  17. <result property="goodsId" column="goods_id"/>
  18. <result property="examNumber" column="exam_number"/>
  19. <result property="doNumber" column="do_number"/>
  20. <result property="createTime" column="create_time"/>
  21. <result property="updateTime" column="update_time"/>
  22. <result property="expendNumber" column="expend_number"/>
  23. <result property="expendBefore" column="expend_before"/>
  24. <result property="goodsCode" column="goods_code"/>
  25. <result property="goodsName" column="goods_name"/>
  26. <result property="standPrice" column="stand_price"/>
  27. <result property="projectName" column="project_name"/>
  28. <result property="businessName" column="business_name"/>
  29. <result property="educationName" column="education_name"/>
  30. <result property="orderGoodsId" column="order_goods_id"/>
  31. </resultMap>
  32. <resultMap type="com.zhongzheng.modules.user.vo.UserExamGoodsSupplementVo" id="UserExamGoodsSupplementVo">
  33. <result property="userExamGoodsId" column="user_exam_goods_id"/>
  34. <result property="goodsId" column="goods_id"/>
  35. <result property="examNumber" column="exam_number"/>
  36. <result property="doNumber" column="do_number"/>
  37. <result property="createTime" column="create_time"/>
  38. <result property="updateTime" column="update_time"/>
  39. <result property="code" column="goods_code"/>
  40. <result property="goodsName" column="goods_name"/>
  41. <result property="standPrice" column="stand_price"/>
  42. <result property="status" column="status"/>
  43. <result property="timeStatus" column="time_status"/>
  44. <result property="makeStartTime" column="make_start_time"/>
  45. <result property="makeEndTime" column="make_end_time"/>
  46. <result property="timeStatus" column="time_status"/>
  47. <result property="projectName" column="project_name"/>
  48. <result property="businessName" column="business_name"/>
  49. <result property="educationName" column="education_name"/>
  50. </resultMap>
  51. <resultMap type="com.zhongzheng.modules.exam.domain.ExamNumber" id="ExamNumberResult">
  52. <result property="examNumberId" column="exam_number_id"/>
  53. <result property="code" column="code"/>
  54. <result property="examNumber" column="exam_number"/>
  55. <result property="doNumber" column="do_number"/>
  56. <result property="status" column="status"/>
  57. <result property="createTime" column="create_time"/>
  58. <result property="updateTime" column="update_time"/>
  59. <result property="goodsType" column="goods_type"/>
  60. <result property="educationTypeId" column="education_type_id"/>
  61. <result property="businessId" column="business_id"/>
  62. <result property="projectId" column="project_id"/>
  63. </resultMap>
  64. <select id="listUserExam" parameterType="com.zhongzheng.modules.user.bo.UserExamGoodsQueryBo" resultMap="UserExamGoodsVo">
  65. SELECT
  66. *,
  67. (SELECT g.goods_name FROM goods g where ueg.goods_id = g.goods_id) as goods_name,
  68. (SELECT g.code FROM goods g where ueg.goods_id = g.goods_id) as goods_code,
  69. (SELECT g.stand_price FROM goods g where ueg.goods_id = g.goods_id) as stand_price,
  70. (SELECT cet.education_name FROM goods g LEFT JOIN course_education_type cet on cet.id = g.education_type_id where ueg.goods_id = g.goods_id) as education_name,
  71. (SELECT cpt.project_name FROM goods g LEFT JOIN course_project_type cpt on cpt.id = g.project_id where ueg.goods_id = g.goods_id) as project_name,
  72. (SELECT cb.business_name FROM goods g LEFT JOIN course_business cb on cb.id = g.business_id where ueg.goods_id = g.goods_id) as business_name
  73. FROM
  74. user_exam_goods ueg
  75. WHERE
  76. ueg.user_id = #{userId}
  77. <if test="goodsId != null and goodsId != '' ">
  78. and ueg.goods_id = #{goodsId}
  79. </if>
  80. ORDER BY ueg.create_time DESC
  81. </select>
  82. <select id="getUserExam" parameterType="map" resultMap="UserExamGoodsSupplementVo">
  83. SELECT
  84. *,
  85. (SELECT g.goods_name FROM goods g where uegs.goods_id = g.goods_id) as goods_name,
  86. (SELECT g.code FROM goods g where uegs.goods_id = g.goods_id) as goods_code,
  87. (SELECT g.stand_price FROM goods g where uegs.goods_id = g.goods_id) as stand_price,
  88. (SELECT g.make_start_time FROM goods g where uegs.goods_id = g.goods_id) as make_start_time,
  89. (SELECT g.make_end_time FROM goods g where uegs.goods_id = g.goods_id) as make_end_time,
  90. (case WHEN (SELECT COUNT(g.goods_id) FROM goods g where uegs.goods_id = g.goods_id and unix_timestamp(now()) BETWEEN g.make_start_time and g.make_end_time) >0 then 1 ELSE 0 end) as time_status,
  91. (SELECT cet.education_name FROM goods g LEFT JOIN course_education_type cet on cet.id = g.education_type_id where uegs.goods_id = g.goods_id) as education_name,
  92. (SELECT cpt.project_name FROM goods g LEFT JOIN course_project_type cpt on cpt.id = g.project_id where uegs.goods_id = g.goods_id) as project_name,
  93. (SELECT cb.business_name FROM goods g LEFT JOIN course_business cb on cb.id = g.business_id where uegs.goods_id = g.goods_id) as business_name
  94. FROM
  95. user_exam_goods_supplement uegs
  96. WHERE
  97. uegs.user_exam_goods_id = #{userExamGoodsId}
  98. and uegs.`status`=#{status}
  99. </select>
  100. <select id="queryExamGoods" parameterType="map" resultType="Long">
  101. SELECT
  102. count(1)
  103. FROM
  104. exam_number en
  105. LEFT JOIN exam_number_goods eng on eng.exam_number_id = en.exam_number_id
  106. LEFT JOIN user_exam_goods ueg on ueg.goods_id = eng.goods_id
  107. where ueg.user_id = #{userId}
  108. AND ueg.goods_id = #{goodsId}
  109. </select>
  110. <select id="queryExamGoodsVo" parameterType="map" resultMap="ExamNumberResult">
  111. SELECT
  112. en.*
  113. FROM
  114. exam_number en
  115. LEFT JOIN exam_number_goods eng on eng.exam_number_id = en.exam_number_id
  116. where 1=1
  117. AND eng.goods_id = #{goodsId}
  118. </select>
  119. <select id="selectSellGoods" parameterType="com.zhongzheng.modules.exam.bo.ExamNumberQueryBo" resultMap="UserExamGoodsVo">
  120. SELECT * from user_exam_goods ueg where goods_id in
  121. <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
  122. #{item}
  123. </foreach>
  124. </select>
  125. </mapper>