StoreReadMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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.slodon.b2b2c.dao.read.seller.StoreReadMapper">
  4. <resultMap id="resultMap" type="com.slodon.b2b2c.seller.pojo.Store">
  5. <id column="store_id" property="storeId" />
  6. <result column="store_name" property="storeName" />
  7. <result column="store_logo" property="storeLogo" />
  8. <result column="store_grade_id" property="storeGradeId" />
  9. <result column="store_grade_name" property="storeGradeName" />
  10. <result column="store_seo_keyword" property="storeSeoKeyword" />
  11. <result column="store_seo_desc" property="storeSeoDesc" />
  12. <result column="service_score" property="serviceScore" />
  13. <result column="deliver_score" property="deliverScore" />
  14. <result column="description_score" property="descriptionScore" />
  15. <result column="goods_number" property="goodsNumber" />
  16. <result column="follow_number" property="followNumber" />
  17. <result column="create_time" property="createTime" />
  18. <result column="store_expire_time" property="storeExpireTime" />
  19. <result column="store_total_sale" property="storeTotalSale" />
  20. <result column="order_total_count" property="orderTotalCount" />
  21. <result column="order_finished_count" property="orderFinishedCount" />
  22. <result column="state" property="state" />
  23. <result column="business_state" property="businessState" />
  24. <result column="is_own_store" property="isOwnStore" />
  25. <result column="store_category_id" property="storeCategoryId" />
  26. <result column="store_category_name" property="storeCategoryName" />
  27. <result column="main_business" property="mainBusiness" />
  28. <result column="service_phone" property="servicePhone" />
  29. <result column="open_time" property="openTime" />
  30. <result column="is_recommend" property="isRecommend" />
  31. <result column="service_detail" property="serviceDetail" />
  32. <result column="store_banner_pc" property="storeBannerPc" />
  33. <result column="store_banner_mobile" property="storeBannerMobile" />
  34. <result column="store_backdrop" property="storeBackdrop" />
  35. <result column="province_code" property="provinceCode" />
  36. <result column="city_code" property="cityCode" />
  37. <result column="area_code" property="areaCode" />
  38. <result column="area_info" property="areaInfo" />
  39. <result column="address" property="address" />
  40. <result column="bill_type" property="billType" />
  41. <result column="bill_day" property="billDay" />
  42. <result column="free_freight_limit" property="freeFreightLimit" />
  43. <result column="store_sales_volume" property="storeSalesVolume" />
  44. <result column="store_look_volume" property="storeLookVolume" />
  45. <result column="store_map_info" property="storeMapInfo" />
  46. <result column="store_map_info_w" property="storeMapInfoW" />
  47. <result column="email" property="email" />
  48. </resultMap>
  49. <!--按照主键值进行操作-->
  50. <sql id="pkWhere">
  51. WHERE `store_id` = #{primaryKey}
  52. </sql>
  53. <!--操作条件-->
  54. <sql id="whereCondition">
  55. <if test="example != null">
  56. <trim prefix="WHERE" prefixOverrides="AND|OR">
  57. <if test="example.storeIdNotEquals != null">
  58. AND `store_id` != #{example.storeIdNotEquals}
  59. </if>
  60. <if test="example.storeIdIn != null">
  61. AND `store_id` in (${example.storeIdIn})
  62. </if>
  63. <if test="example.storeName != null">
  64. AND `store_name` = #{example.storeName}
  65. </if>
  66. <if test="example.storeNameLike != null">
  67. AND `store_name` like concat('%',#{example.storeNameLike},'%')
  68. </if>
  69. <if test="example.storeLogo != null">
  70. AND `store_logo` = #{example.storeLogo}
  71. </if>
  72. <if test="example.storeGradeId != null">
  73. AND `store_grade_id` = #{example.storeGradeId}
  74. </if>
  75. <if test="example.storeGradeName != null">
  76. AND `store_grade_name` = #{example.storeGradeName}
  77. </if>
  78. <if test="example.storeGradeNameLike != null">
  79. AND `store_grade_name` like concat('%',#{example.storeGradeNameLike},'%')
  80. </if>
  81. <if test="example.storeSeoKeyword != null">
  82. AND `store_seo_keyword` = #{example.storeSeoKeyword}
  83. </if>
  84. <if test="example.storeSeoDesc != null">
  85. AND `store_seo_desc` = #{example.storeSeoDesc}
  86. </if>
  87. <if test="example.serviceScore != null">
  88. AND `service_score` = #{example.serviceScore}
  89. </if>
  90. <if test="example.deliverScore != null">
  91. AND `deliver_score` = #{example.deliverScore}
  92. </if>
  93. <if test="example.descriptionScore != null">
  94. AND `description_score` = #{example.descriptionScore}
  95. </if>
  96. <if test="example.goodsNumber != null">
  97. AND `goods_number` = #{example.goodsNumber}
  98. </if>
  99. <if test="example.goodsNumberNotNull != null">
  100. AND `goods_number` > 0
  101. </if>
  102. <if test="example.goodsNumber != null">
  103. AND `goods_number` = #{example.goodsNumber}
  104. </if>
  105. <if test="example.followNumber != null">
  106. AND `follow_number` = #{example.followNumber}
  107. </if>
  108. <if test="example.createTimeAfter != null">
  109. AND `create_time` <![CDATA[ >= ]]> #{example.createTimeAfter}
  110. </if>
  111. <if test="example.createTimeBefore != null">
  112. AND `create_time` <![CDATA[ <= ]]> #{example.createTimeBefore}
  113. </if>
  114. <if test="example.storeExpireTimeAfter != null">
  115. AND `store_expire_time` <![CDATA[ >= ]]> #{example.storeExpireTimeAfter}
  116. </if>
  117. <if test="example.storeExpireTimeBefore != null">
  118. AND `store_expire_time` <![CDATA[ <= ]]> #{example.storeExpireTimeBefore}
  119. </if>
  120. <if test="example.storeTotalSale != null">
  121. AND `store_total_sale` = #{example.storeTotalSale}
  122. </if>
  123. <if test="example.orderTotalCount != null">
  124. AND `order_total_count` = #{example.orderTotalCount}
  125. </if>
  126. <if test="example.orderFinishedCount != null">
  127. AND `order_finished_count` = #{example.orderFinishedCount}
  128. </if>
  129. <if test="example.state != null">
  130. AND `state` = #{example.state}
  131. </if>
  132. <if test="example.businessState != null">
  133. AND `business_state` = #{example.businessState}
  134. </if>
  135. <if test="example.stateNotEquals != null">
  136. AND `state` != #{example.stateNotEquals}
  137. </if>
  138. <if test="example.isOwnStore != null">
  139. AND `is_own_store` = #{example.isOwnStore}
  140. </if>
  141. <if test="example.storeCategoryId != null">
  142. AND `store_category_id` = #{example.storeCategoryId}
  143. </if>
  144. <if test="example.storeCategoryName != null">
  145. AND `store_category_name` = #{example.storeCategoryName}
  146. </if>
  147. <if test="example.storeCategoryNameLike != null">
  148. AND `store_category_name` like concat('%',#{example.storeCategoryNameLike},'%')
  149. </if>
  150. <if test="example.mainBusiness != null">
  151. AND `main_business` = #{example.mainBusiness}
  152. </if>
  153. <if test="example.servicePhone != null">
  154. AND `service_phone` = #{example.servicePhone}
  155. </if>
  156. <if test="example.openTime != null">
  157. AND `open_time` = #{example.openTime}
  158. </if>
  159. <if test="example.isRecommend != null">
  160. AND `is_recommend` = #{example.isRecommend}
  161. </if>
  162. <if test="example.serviceDetail != null">
  163. AND `service_detail` = #{example.serviceDetail}
  164. </if>
  165. <if test="example.storeBannerPc != null">
  166. AND `store_banner_pc` = #{example.storeBannerPc}
  167. </if>
  168. <if test="example.storeBannerMobile != null">
  169. AND `store_banner_mobile` = #{example.storeBannerMobile}
  170. </if>
  171. <if test="example.storeBackdrop != null">
  172. AND `store_backdrop` = #{example.storeBackdrop}
  173. </if>
  174. <if test="example.provinceCode != null">
  175. AND `province_code` = #{example.provinceCode}
  176. </if>
  177. <if test="example.cityCode != null">
  178. AND `city_code` = #{example.cityCode}
  179. </if>
  180. <if test="example.areaCode != null">
  181. AND `area_code` = #{example.areaCode}
  182. </if>
  183. <if test="example.areaInfo != null">
  184. AND `area_info` = #{example.areaInfo}
  185. </if>
  186. <if test="example.address != null">
  187. AND `address` = #{example.address}
  188. </if>
  189. <if test="example.billType != null">
  190. AND `bill_type` = #{example.billType}
  191. </if>
  192. <if test="example.billDay != null">
  193. AND FIND_IN_SET(#{example.billDay}, `bill_day`)
  194. </if>
  195. <if test="example.vendorNameLike != null">
  196. AND `store_id` in (select `store_id` from `vendor` where `vendor_name` like concat('%',#{example.vendorNameLike},'%'))
  197. </if>
  198. <if test="example.freeFreightLimit != null">
  199. AND `free_freight_limit` = #{example.freeFreightLimit}
  200. </if>
  201. <if test="example.storeSalesVolume != null">
  202. AND `store_sales_volume` = #{example.storeSalesVolume}
  203. </if>
  204. <if test="example.storeLookVolume != null">
  205. AND `store_look_volume` = #{example.storeLookVolume}
  206. </if>
  207. <if test="example.storeMapInfo != null">
  208. AND `store_map_info` = #{example.storeMapInfo}
  209. </if>
  210. <if test="example.storeMapInfoW != null">
  211. AND `store_map_info_w` = #{example.storeMapInfoW}
  212. </if>
  213. <if test="example.orStoreIdIn != null and example.orStoreNameLike != null">
  214. AND (`store_name` like concat('%',#{example.orStoreNameLike},'%') or `store_id` in (${example.orStoreIdIn}))
  215. </if>
  216. </trim>
  217. </if>
  218. </sql>
  219. <!--排序条件-->
  220. <sql id="orderBy">
  221. ORDER BY `create_time` DESC
  222. </sql>
  223. <sql id="orderByOther">
  224. order by ${example.orderBy}
  225. </sql>
  226. <!--分组条件-->
  227. <sql id="groupBy">
  228. group by ${example.groupBy}
  229. </sql>
  230. <!--分页条件-->
  231. <sql id="limit">
  232. <if test="size != null and size &gt; 0">
  233. limit #{startRow},#{size}
  234. </if>
  235. </sql>
  236. <!--查询符合条件的记录数-->
  237. <select id="countByExample" parameterType="com.slodon.b2b2c.seller.example.StoreExample" resultType="java.lang.Integer">
  238. SELECT
  239. COUNT(*)
  240. FROM `store`
  241. <include refid="whereCondition" />
  242. </select>
  243. <!--根据主键查询记录-->
  244. <select id="getByPrimaryKey" resultMap="resultMap">
  245. SELECT
  246. *
  247. FROM `store`
  248. <include refid="pkWhere" />
  249. </select>
  250. <!--查询符合条件的记录(所有字段)-->
  251. <select id="listByExample" resultMap="resultMap">
  252. SELECT
  253. *
  254. FROM `store`
  255. <include refid="whereCondition" />
  256. <if test="example.groupBy != null">
  257. <include refid="groupBy" />
  258. </if>
  259. <choose>
  260. <when test="example.orderBy != null">
  261. <include refid="orderByOther" />
  262. </when>
  263. <otherwise>
  264. <include refid="orderBy" />
  265. </otherwise>
  266. </choose>
  267. </select>
  268. <!--分页查询符合条件的记录(所有字段)-->
  269. <select id="listPageByExample" resultMap="resultMap">
  270. SELECT
  271. *
  272. FROM `store`
  273. <include refid="whereCondition" />
  274. <if test="example.groupBy != null">
  275. <include refid="groupBy" />
  276. </if>
  277. <choose>
  278. <when test="example.orderBy != null">
  279. <include refid="orderByOther" />
  280. </when>
  281. <otherwise>
  282. <include refid="orderBy" />
  283. </otherwise>
  284. </choose>
  285. <include refid="limit" />
  286. </select>
  287. <!--查询符合条件的记录(指定字段)-->
  288. <select id="listFieldsByExample" resultMap="resultMap">
  289. SELECT
  290. ${fields}
  291. FROM `store`
  292. <include refid="whereCondition" />
  293. <if test="example.groupBy != null">
  294. <include refid="groupBy" />
  295. </if>
  296. <choose>
  297. <when test="example.orderBy != null">
  298. <include refid="orderByOther" />
  299. </when>
  300. <otherwise>
  301. <include refid="orderBy" />
  302. </otherwise>
  303. </choose>
  304. </select>
  305. <!--分页查询符合条件的记录(指定字段)-->
  306. <select id="listFieldsPageByExample" resultMap="resultMap">
  307. SELECT
  308. ${fields}
  309. FROM `store`
  310. <include refid="whereCondition" />
  311. <if test="example.groupBy != null">
  312. <include refid="groupBy" />
  313. </if>
  314. <choose>
  315. <when test="example.orderBy != null">
  316. <include refid="orderByOther" />
  317. </when>
  318. <otherwise>
  319. <include refid="orderBy" />
  320. </otherwise>
  321. </choose>
  322. <include refid="limit" />
  323. </select>
  324. <select id="getStoreStatisticList" resultType="com.slodon.b2b2c.seller.dto.StoreStatisticsDTO">
  325. select
  326. province_code AS provinceCode,
  327. COUNT( store_id ) AS storeNum
  328. FROM `store`
  329. <include refid="whereCondition"/>
  330. group by provinceCode
  331. <choose>
  332. <when test="example.orderBy != null">
  333. <include refid="orderByOther" />
  334. </when>
  335. <otherwise>
  336. <include refid="orderBy" />
  337. </otherwise>
  338. </choose>
  339. </select>
  340. <select id="countCnByExample" resultType="java.lang.Integer">
  341. select COUNT(store_name.store_name)
  342. from store
  343. left join store_name on store.store_id = store_name.store_id
  344. left join store_site_info on store_name.store_id = store_site_info.store_id
  345. <where>
  346. <if test="example.state != null">
  347. and store.state = #{example.state}
  348. </if>
  349. <if test="example.stateNotEquals != null">
  350. and store.state != #{example.stateNotEquals}
  351. </if>
  352. <if test="example.isOwnStore != null">
  353. and store.is_own_store = #{example.isOwnStore}
  354. </if>
  355. <if test="example.storeNameLike != null">
  356. and store_name.store_name like concat('%',#{example.storeNameLike},'%')
  357. </if>
  358. <if test="example.businessState != null">
  359. and store_site_info.business_state = #{example.businessState}
  360. </if>
  361. <if test="example.storeGradeId != null">
  362. and store.site_info.store_grade_id = #{example.storeGradeId}
  363. </if>
  364. </where>
  365. </select>
  366. <select id="listCnPageByExample" resultType="com.slodon.b2b2c.seller.pojo.Store">
  367. select store.store_id as storeId,
  368. store_name.store_name as storeName,
  369. store_site_info.store_logo as storeLogo,
  370. store.state as state,
  371. case
  372. when store_site_info.business_state is null then 2
  373. else store_site_info.business_state
  374. end as businessState,
  375. store_site_info.store_grade_name as storeGradeName,
  376. store_site_info.create_time as createTime,
  377. store_site_info.store_expire_time as storeExpireTime,
  378. store.bill_type as billType,
  379. store.bill_day as billDay,
  380. store.service_score as serviceScore,
  381. store.deliver_score as deliverScore,
  382. store.follow_number as followNumber,
  383. store.store_sales_volume as storeSalesVolume,
  384. store.is_own_store as isOwnStore,
  385. store.store_backdrop as storeBackdrop,
  386. store.store_banner_mobile as storeBannerMobile
  387. from store
  388. left join store_name on store.store_id = store_name.store_id
  389. left join store_site_info on store_name.store_id = store_site_info.store_id
  390. <where>
  391. <if test="example.state != null">
  392. and store.state = #{example.state}
  393. </if>
  394. <if test="example.stateNotEquals != null">
  395. and store.state != #{example.stateNotEquals}
  396. </if>
  397. <if test="example.isOwnStore != null">
  398. and store.is_own_store = #{example.isOwnStore}
  399. </if>
  400. <if test="example.storeNameLike != null">
  401. and store_name.store_name like concat('%',#{example.storeNameLike},'%')
  402. </if>
  403. <if test="example.businessState != null">
  404. and store_site_info.business_state = #{example.businessState}
  405. </if>
  406. <if test="example.storeGradeId != null">
  407. and store.site_info.store_grade_id = #{example.storeGradeId}
  408. </if>
  409. </where>
  410. order by store_site_info.update_time desc
  411. <include refid="limit"/>
  412. </select>
  413. </mapper>