CommonMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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="websitName != null and websitName != ''">
  78. AND a.name LIKE CONCAT('%', #{websitName},'%')
  79. </if>
  80. <if test="websitIds != null and websitIds.size > 0">
  81. AND a.websit_id IN
  82. <foreach item="item" index="index" collection="websitIds" open="(" separator="," close=")">
  83. #{item}
  84. </foreach>
  85. </if>
  86. <if test="websitIdsQuchu != null and websitIdsQuchu.size > 0">
  87. AND a.websit_id not IN
  88. <foreach item="item" index="index" collection="websitIdsQuchu" open="(" separator="," close=")">
  89. #{item}
  90. </foreach>
  91. </if>
  92. and a.company_wechat_id = #{companyWechatId}
  93. <if test="websitIdsQuchu != null and websitIdsQuchu.size > 0 and lng != '0'.toString() and lat != '0'.toString()">
  94. HAVING distance &lt; #{rice}
  95. </if>
  96. ORDER BY distance
  97. </select>
  98. <select id="queryUserSettle" resultType="com.gree.mall.miniapp.bean.user.SettleMonthWagesWorkerBean">
  99. SELECT
  100. a.*,
  101. b.send_date
  102. FROM
  103. settle_month_wages_worker a LEFT JOIN settle_month_wages_detail b ON a.settle_month_wages_detail_id = b.id
  104. WHERE
  105. a.company_wechat_id = #{companyWechatId}
  106. AND a.worker_name = #{userId}
  107. ORDER BY b.send_date DESC
  108. </select>
  109. <select id="goodsLeaseCategoryList" resultType="com.gree.mall.miniapp.plus.entity.GoodsCategory">
  110. SELECT * FROM (
  111. SELECT
  112. a.*
  113. FROM
  114. goods_category a JOIN goods_lease b ON a.category_id = b.category_id
  115. WHERE
  116. a.company_wechat_id = #{companyWechatId}
  117. AND b.del = 0
  118. AND b.status = 1
  119. AND a.type = 2
  120. <if test="categoryName != null and categoryName != ''">
  121. AND a.name LIKE CONCAT('%', #{categoryName},'%')
  122. </if>
  123. GROUP BY a.category_id
  124. ) a
  125. ORDER BY a.sort_num, a.create_time DESC
  126. </select>
  127. <select id="leaseOrderList" resultType="com.gree.mall.miniapp.bean.order.LeaseOrderVO">
  128. SELECT
  129. a.*,
  130. b.category_name,
  131. b.category_url,
  132. b.goods_lease_name,
  133. b.repair_remark,
  134. b.qty,
  135. b.end_date,
  136. b.start_date,
  137. b.real_end_date
  138. FROM
  139. lease_order a LEFT JOIN lease_order_item b ON a.id = b.lease_order_id
  140. WHERE
  141. a.user_id = #{userId}
  142. <if test="keyword != null and keyword != ''">
  143. AND (a.id LIKE CONCAT('%', #{keyword}, '%') OR b.goods_lease_name LIKE CONCAT('%', #{keyword}, '%'))
  144. </if>
  145. <if test="payStatus != null">
  146. AND a.pay_status = #{payStatus}
  147. </if>
  148. <if test="status != null and status != '' and isEndDate == false">
  149. AND a.status = #{status}
  150. </if>
  151. <if test="status != null and status != '' and isEndDate == true">
  152. AND a.status IN ('OVER', 'RECOVER')
  153. </if>
  154. ORDER BY a.create_time DESC
  155. </select>
  156. <select id="partsApplyCount" resultType="com.gree.mall.miniapp.bean.material.MyDataCountBean">
  157. SELECT
  158. SUM(IF(a.status = 'ING', 1, 0)) AS partsIngCount,
  159. SUM(IF(a.status = 'END', 1, 0)) AS partsEndCount,
  160. SUM(IF(a.status = 'CANCEL', 1, 0)) AS partsCancelCount
  161. FROM
  162. websit_parts_apply a
  163. WHERE
  164. a.create_by_id = #{userId}
  165. </select>
  166. <select id="promotionActivity" resultType="com.gree.mall.miniapp.bean.activity.PromotionActivityBean">
  167. SELECT
  168. a.*,
  169. b.name,
  170. b.detail_imgs
  171. FROM
  172. promotion_activity a LEFT JOIN promotion_questionnaire b ON a.promotion_questionnaire_id = b.id
  173. <where>
  174. <if test="companyWechatId != null and companyWechatId != ''">
  175. AND a.company_wechat_id = #{companyWechatId}
  176. </if>
  177. <if test="userId != null and userId != ''">
  178. AND a.user_id = #{userId}
  179. </if>
  180. <if test="promotionQuestionnaireId != null and promotionQuestionnaireId != ''">
  181. AND a.promotion_questionnaire_id = #{promotionQuestionnaireId}
  182. </if>
  183. </where>
  184. ORDER BY a.create_time DESC
  185. </select>
  186. <select id="esGoodsList" resultType="com.gree.mall.miniapp.bean.es.ESGoodsBean">
  187. SELECT
  188. a.*
  189. FROM
  190. es_goods a
  191. WHERE
  192. a.del = 0
  193. <if test="companyWechatId != null and companyWechatId != ''">
  194. AND a.company_wechat_id = #{companyWechatId}
  195. </if>
  196. <if test="goodsName != null and goodsName != ''">
  197. AND (
  198. a.goods_name LIKE CONCAT('%', #{goodsName}, '%') OR
  199. a.brand LIKE CONCAT('%', #{goodsName}, '%') OR
  200. a.power LIKE CONCAT('%', #{goodsName}, '%') OR
  201. a.mark LIKE CONCAT('%', #{goodsName}, '%')
  202. )
  203. </if>
  204. <if test="categoryId != null and categoryId != ''">
  205. AND a.category_id = #{categoryId}
  206. </if>
  207. <if test="userId != null and userId != ''">
  208. AND a.user_id = #{userId}
  209. </if>
  210. <if test="brand != null and brand != ''">
  211. AND a.brand = #{brand}
  212. </if>
  213. <if test="power != null and power != ''">
  214. AND a.power = #{power}
  215. </if>
  216. <if test="mark != null and mark != ''">
  217. AND a.mark = #{mark}
  218. </if>
  219. <if test="statusList != null and statusList.size > 0">
  220. AND a.status IN
  221. <foreach item="item" index="index" collection="statusList" open="(" separator="," close=")">
  222. #{item}
  223. </foreach>
  224. </if>
  225. <!-- <if test="sortType != null and sortType != '' and sortType == 'A'.toString">-->
  226. <!-- AND a.sort <![CDATA[ >= ]]> 0 AND a.status IN ('ON','SALE')-->
  227. <!-- </if>-->
  228. <!-- <if test="sortType != null and sortType != '' and sortType == 'B'.toString">-->
  229. <!-- AND a.status = 'ON'-->
  230. <!-- </if>-->
  231. ORDER BY
  232. <if test="sortType != null and sortType != '' and sortType != 'C'.toString">
  233. a.is_top DESC,
  234. a.top_time DESC,
  235. a.status,
  236. </if>
  237. <if test="sortType != null and sortType != '' and sortType == 'C'.toString">
  238. a.like_count DESC,
  239. </if>
  240. a.update_time DESC
  241. </select>
  242. <select id="esGoodsTopList" resultType="com.gree.mall.miniapp.bean.es.ESGoodsBean">
  243. SELECT
  244. a.*
  245. FROM
  246. es_goods a
  247. WHERE
  248. a.company_wechat_id = #{companyWechatId}
  249. AND a.is_top = 1
  250. AND a.del = 0
  251. ORDER BY a.top_time
  252. </select>
  253. <select id="guessList" resultType="java.lang.String">
  254. SELECT
  255. <choose>
  256. <when test="typeName != null and typeName != '' and typeName == 'brand'.toString">
  257. a.brand
  258. </when>
  259. <when test="typeName != null and typeName != '' and typeName == 'power'.toString">
  260. a.power
  261. </when>
  262. <otherwise>
  263. a.mark
  264. </otherwise>
  265. </choose>
  266. FROM
  267. es_goods a
  268. WHERE
  269. a.company_wechat_id = #{companyWechatId}
  270. AND a.del = 0
  271. GROUP BY
  272. <choose>
  273. <when test="typeName != null and typeName != '' and typeName == 'brand'.toString">
  274. a.brand
  275. </when>
  276. <when test="typeName != null and typeName != '' and typeName == 'power'.toString">
  277. a.power
  278. </when>
  279. <otherwise>
  280. a.mark
  281. </otherwise>
  282. </choose>
  283. </select>
  284. </mapper>