CommonMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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.gree.mall.miniapp.commonmapper.CommonMapper">
  4. <select id="queryChargingStandrdList" resultType="com.gree.mall.miniapp.bean.chargingstandard.ChargingStandardBean">
  5. select
  6. a.* ,
  7. b.name as 'typeName',
  8. c.brand_name,
  9. (select name from goods_category where type=2 and category_id = a.one_category_id) as 'oneCategoryName',
  10. (select name from goods_category where type=2 and category_id = a.two_category_id) as 'twoCategoryName'
  11. from charging_standard a
  12. left join charging_standard_type b on a.charging_standard_type_id = b.id and b.status=1
  13. join brand c on c.id = a.brand_id
  14. where a.status=1 and c.status=1
  15. <if test="id != null and id !=''">
  16. and a.id = #{id}
  17. </if>
  18. <if test="type != null">
  19. and a.type = #{type}
  20. </if>
  21. <if test="brandId != null and brandId !=''">
  22. and a.brand_id = #{brandId}
  23. </if>
  24. <if test="chargingStandardTypeId != null and chargingStandardTypeId != ''">
  25. and a.charging_standard_type_id = #{chargingStandardTypeId}
  26. </if>
  27. <if test="twoCategoryId != null and twoCategoryId !=''">
  28. and a.two_category_id = #{twoCategoryId}
  29. </if>
  30. <if test="companyWechatId != null and companyWechatId !=''">
  31. and a.company_wechat_id = #{companyWechatId}
  32. </if>
  33. group by concat(a.brand_id,a.one_category_id,a.two_category_id,content1)
  34. order by a.create_time desc
  35. </select>
  36. <select id="queryChargingStandrdDetailList" resultType="com.gree.mall.miniapp.bean.chargingstandard.ChargingStandardBean">
  37. select
  38. a.* ,
  39. b.name as 'typeName',
  40. c.brand_name,
  41. (select name from goods_category where type=2 and category_id = a.one_category_id) as 'oneCategoryName',
  42. (select name from goods_category where type=2 and category_id = a.two_category_id) as 'twoCategoryName'
  43. from charging_standard a
  44. left join charging_standard_type b on a.charging_standard_type_id = b.id and b.status=1
  45. join brand c on c.id = a.brand_id
  46. where a.status=1 and c.status=1
  47. <if test="type != null">
  48. and a.type = #{type}
  49. </if>
  50. <if test="brandId != null and brandId !=''">
  51. and a.brand_id = #{brandId}
  52. </if>
  53. <if test="chargingStandardTypeId != null and chargingStandardTypeId != ''">
  54. and a.charging_standard_type_id = #{chargingStandardTypeId}
  55. </if>
  56. <if test="twoCategoryId != null and twoCategoryId !=''">
  57. and a.two_category_id = #{twoCategoryId}
  58. </if>
  59. <if test="content1 != null and content1 !=''">
  60. and a.content1 = #{content1}
  61. </if>
  62. order by a.create_time desc
  63. </select>
  64. <select id="websitList" resultType="com.gree.mall.miniapp.bean.websit.WebsitVO">
  65. SELECT
  66. a.*,
  67. ST_DISTANCE_SPHERE(
  68. POINT(#{lng}, #{lat}),
  69. POINT(lng, lat)
  70. ) AS distance
  71. FROM
  72. admin_websit a
  73. where a.type='C'
  74. <if test="isIncre != null">
  75. and a.is_incre = #{isIncre}
  76. </if>
  77. <if test="websitIds != null and websitIds.size > 0">
  78. AND a.websit_id IN
  79. <foreach item="item" index="index" collection="websitIds" open="(" separator="," close=")">
  80. #{item}
  81. </foreach>
  82. </if>
  83. and a.company_wechat_id = #{companyWechatId}
  84. HAVING distance &lt; 50000
  85. ORDER BY distance
  86. </select>
  87. <select id="queryUserSettle" resultType="com.gree.mall.miniapp.bean.user.SettleMonthWagesWorkerBean">
  88. SELECT
  89. a.*,
  90. b.send_date
  91. FROM
  92. settle_month_wages_worker a LEFT JOIN settle_month_wages_detail b ON a.settle_month_wages_detail_id = b.id
  93. WHERE
  94. a.company_wechat_id = #{companyWechatId}
  95. AND a.worker_name = #{userId}
  96. ORDER BY b.send_date DESC
  97. </select>
  98. <select id="goodsLeaseCategoryList" resultType="com.gree.mall.miniapp.plus.entity.GoodsCategory">
  99. SELECT * FROM (
  100. SELECT
  101. a.*
  102. FROM
  103. goods_category a JOIN goods_lease b ON a.category_id = b.category_id
  104. WHERE
  105. a.company_wechat_id = #{companyWechatId}
  106. AND b.del = 0
  107. AND b.status = 1
  108. AND a.type = 2
  109. <if test="categoryName != null and categoryName != ''">
  110. AND a.name LIKE CONCAT('%', #{categoryName},'%')
  111. </if>
  112. GROUP BY a.category_id
  113. ) a
  114. ORDER BY a.sort_num, a.create_time DESC
  115. </select>
  116. <select id="leaseOrderList" resultType="com.gree.mall.miniapp.bean.order.LeaseOrderVO">
  117. SELECT
  118. a.*,
  119. b.category_name,
  120. b.category_url,
  121. b.goods_lease_name,
  122. b.repair_remark,
  123. b.qty,
  124. b.end_date,
  125. b.start_date,
  126. b.real_end_date
  127. FROM
  128. lease_order a LEFT JOIN lease_order_item b ON a.id = b.lease_order_id
  129. WHERE
  130. a.user_id = #{userId}
  131. <if test="keyword != null and keyword != ''">
  132. AND (a.id LIKE CONCAT('%', #{keyword}, '%') OR b.goods_lease_name LIKE CONCAT('%', #{keyword}, '%'))
  133. </if>
  134. <if test="payStatus != null">
  135. AND a.pay_status = #{payStatus}
  136. </if>
  137. <if test="status != null and status != '' and isEndDate == false">
  138. AND a.status = #{status}
  139. </if>
  140. <if test="status != null and status != '' and isEndDate == true">
  141. AND a.status IN ('OVER', 'RECOVER')
  142. </if>
  143. ORDER BY a.create_time DESC
  144. </select>
  145. <select id="partsApplyCount" resultType="com.gree.mall.miniapp.bean.material.MyDataCountBean">
  146. SELECT
  147. SUM(IF(a.status = 'ING', 1, 0)) AS partsIngCount,
  148. SUM(IF(a.status = 'END', 1, 0)) AS partsEndCount,
  149. SUM(IF(a.status = 'CANCEL', 1, 0)) AS partsCancelCount
  150. FROM
  151. websit_parts_apply a
  152. WHERE
  153. a.create_by_id = #{userId}
  154. </select>
  155. <select id="promotionActivity" resultType="com.gree.mall.miniapp.bean.activity.PromotionActivityBean">
  156. SELECT
  157. a.*,
  158. b.name,
  159. b.detail_imgs
  160. FROM
  161. promotion_activity a LEFT JOIN promotion_questionnaire b ON a.promotion_questionnaire_id = b.id
  162. <where>
  163. <if test="companyWechatId != null and companyWechatId != ''">
  164. AND a.company_wechat_id = #{companyWechatId}
  165. </if>
  166. <if test="userId != null and userId != ''">
  167. AND a.user_id = #{userId}
  168. </if>
  169. <if test="promotionQuestionnaireId != null and promotionQuestionnaireId != ''">
  170. AND a.promotion_questionnaire_id = #{promotionQuestionnaireId}
  171. </if>
  172. </where>
  173. ORDER BY a.create_time DESC
  174. </select>
  175. <select id="esGoodsList" resultType="com.gree.mall.miniapp.bean.es.ESGoodsBean">
  176. SELECT
  177. a.*
  178. FROM
  179. es_goods a
  180. WHERE
  181. a.del = 0
  182. <if test="companyWechatId != null and companyWechatId != ''">
  183. AND a.company_wechat_id = #{companyWechatId}
  184. </if>
  185. <if test="goodsName != null and goodsName != ''">
  186. AND (
  187. a.goods_name LIKE CONCAT('%', #{goodsName}, '%') OR
  188. a.brand LIKE CONCAT('%', #{goodsName}, '%') OR
  189. a.power LIKE CONCAT('%', #{goodsName}, '%') OR
  190. a.mark LIKE CONCAT('%', #{goodsName}, '%')
  191. )
  192. </if>
  193. <if test="categoryId != null and categoryId != ''">
  194. AND a.category_id = #{categoryId}
  195. </if>
  196. <if test="userId != null and userId != ''">
  197. AND a.user_id = #{userId}
  198. </if>
  199. <if test="brand != null and brand != ''">
  200. AND a.brand = #{brand}
  201. </if>
  202. <if test="power != null and power != ''">
  203. AND a.power = #{power}
  204. </if>
  205. <if test="mark != null and mark != ''">
  206. AND a.mark = #{mark}
  207. </if>
  208. <if test="statusList != null and statusList.size > 0">
  209. AND a.status IN
  210. <foreach item="item" index="index" collection="statusList" open="(" separator="," close=")">
  211. #{item}
  212. </foreach>
  213. </if>
  214. <!-- <if test="sortType != null and sortType != '' and sortType == 'A'.toString">-->
  215. <!-- AND a.sort <![CDATA[ >= ]]> 0 AND a.status IN ('ON','SALE')-->
  216. <!-- </if>-->
  217. <!-- <if test="sortType != null and sortType != '' and sortType == 'B'.toString">-->
  218. <!-- AND a.status = 'ON'-->
  219. <!-- </if>-->
  220. ORDER BY
  221. <if test="sortType != null and sortType != '' and sortType != 'C'.toString">
  222. a.is_top DESC,
  223. a.top_time DESC,
  224. a.status,
  225. </if>
  226. <if test="sortType != null and sortType != '' and sortType == 'C'.toString">
  227. a.like_count DESC,
  228. </if>
  229. a.update_time DESC
  230. </select>
  231. <select id="esGoodsTopList" resultType="com.gree.mall.miniapp.bean.es.ESGoodsBean">
  232. SELECT
  233. a.*
  234. FROM
  235. es_goods a
  236. WHERE
  237. a.company_wechat_id = #{companyWechatId}
  238. AND a.is_top = 1
  239. AND a.del = 0
  240. ORDER BY a.top_time
  241. </select>
  242. <select id="guessList" resultType="java.lang.String">
  243. SELECT
  244. <choose>
  245. <when test="typeName != null and typeName != '' and typeName == 'brand'.toString">
  246. a.brand
  247. </when>
  248. <when test="typeName != null and typeName != '' and typeName == 'power'.toString">
  249. a.power
  250. </when>
  251. <otherwise>
  252. a.mark
  253. </otherwise>
  254. </choose>
  255. FROM
  256. es_goods a
  257. WHERE
  258. a.company_wechat_id = #{companyWechatId}
  259. AND a.del = 0
  260. GROUP BY
  261. <choose>
  262. <when test="typeName != null and typeName != '' and typeName == 'brand'.toString">
  263. a.brand
  264. </when>
  265. <when test="typeName != null and typeName != '' and typeName == 'power'.toString">
  266. a.power
  267. </when>
  268. <otherwise>
  269. a.mark
  270. </otherwise>
  271. </choose>
  272. </select>
  273. </mapper>