You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

599 lines
21 KiB

  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.iformall.mapper.WxShopMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxShop">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  7. <result column="shop_number" jdbcType="VARCHAR" property="shopNumber"/>
  8. <result column="build_area" jdbcType="VARCHAR" property="buildArea"/>
  9. <result column="operation_area" jdbcType="VARCHAR" property="operationArea"/>
  10. <result column="building" jdbcType="BIGINT" property="building"/>
  11. <result column="floor" jdbcType="BIGINT" property="floor"/>
  12. <result column="status" jdbcType="INTEGER" property="status"/>
  13. <result column="x" jdbcType="DECIMAL" property="x"/>
  14. <result column="y" jdbcType="DECIMAL" property="y"/>
  15. <result column="addr" jdbcType="VARCHAR" property="addr"/>
  16. <result column="baidu_poi" jdbcType="VARCHAR" property="baiduPoi"/>
  17. <result column="longitude" jdbcType="DECIMAL" property="longitude"/>
  18. <result column="latitude" jdbcType="DECIMAL" property="latitude"/>
  19. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  20. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  21. <result column="img_url" jdbcType="VARCHAR" property="imgUrl"/>
  22. <result column="manager" jdbcType="VARCHAR" property="manager"/>
  23. <result column="manager_phone" jdbcType="VARCHAR" property="managerPhone"/>
  24. <result column="type" jdbcType="INTEGER" property="type"/>
  25. <result column="point_type" jdbcType="INTEGER" property="pointType"/>
  26. <result column="comments" jdbcType="VARCHAR" property="comments"/>
  27. <result column="is_del" jdbcType="INTEGER" property="isDel"/>
  28. <result column="freeDay" property="freeDay"/>
  29. <result column="rent" property="rent"/>
  30. <result column="rent_unit" property="rentUnit"/>
  31. <result column="business_id" property="businessId"/>
  32. </resultMap>
  33. <sql id="allColumns">
  34. `id`,`tenant_id`,`shop_number`,`build_area`,`operation_area`,`building`,`floor`,`status`,`x`,`y`,`addr`,
  35. `baidu_poi`,`longitude`,`latitude`,`create_date`,`update_date`,`img_url`,`manager`,`manager_phone`,
  36. `type`,`point_type`,`comments`,`is_del`,DATEDIFF(now(),create_date) freeDay,rent,rent_unit,business_id
  37. </sql>
  38. <sql id="dynamicWhereConditions">
  39. where is_del=0
  40. <if test=" null != id ">
  41. and `id` = #{id}
  42. </if>
  43. <if test=" null != tenantId ">
  44. and `tenant_id` = #{tenantId}
  45. </if>
  46. <if test=" null != shopNumber and ''!=shopNumber">
  47. and `shop_number` like concat('%', #{shopNumber},'%')
  48. </if>
  49. <if test=" null != buildArea ">
  50. and `build_area` like concat('%', #{buildArea},'%')
  51. </if>
  52. <if test=" null != operationArea ">
  53. and `operation_area` like concat('%', #{operationArea},'%')
  54. </if>
  55. <if test=" null != building ">
  56. and `building` like concat('%', #{building},'%')
  57. </if>
  58. <if test=" null != floor ">
  59. and `floor` = #{floor}
  60. </if>
  61. <if test=" null != status ">
  62. and `status` = #{status}
  63. </if>
  64. <if test=" null != x ">
  65. and `x` = #{x}
  66. </if>
  67. <if test=" null != y ">
  68. and `y` = #{y}
  69. </if>
  70. <if test=" null != addr ">
  71. and `addr` like concat('%', #{addr},'%')
  72. </if>
  73. <if test=" null != baiduPoi ">
  74. and `baidu_poi` like concat('%', #{baiduPoi},'%')
  75. </if>
  76. <if test=" null != longitude ">
  77. and `longitude` = #{longitude}
  78. </if>
  79. <if test=" null != latitude ">
  80. and `latitude` = #{latitude}
  81. </if>
  82. <if test=" null != createDate ">
  83. and `create_date` = #{createDate}
  84. </if>
  85. <if test=" null != updateDate ">
  86. and `update_date` = #{updateDate}
  87. </if>
  88. <if test=" null != manager ">
  89. and `manager` = #{manager}
  90. </if>
  91. <if test=" null != managerPhone ">
  92. and `manager_phone` = #{managerPhone}
  93. </if>
  94. <if test=" null != type ">
  95. and `type` = #{type}
  96. </if>
  97. <if test=" null != pointType ">
  98. and `point_type` = #{pointType}
  99. </if>
  100. <if test=" null != ids ">
  101. and id in
  102. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  103. #{idItem}
  104. </foreach>
  105. </if>
  106. <if test=" null != sortColumns">order by ${sortColumns}</if>
  107. </sql>
  108. <select id="findList" parameterType="com.iformall.domain.po.WxShop" resultMap="BaseResultMap">
  109. select
  110. <include refid="allColumns"/>
  111. from wx_shop
  112. <include refid="dynamicWhereConditions"/>
  113. </select>
  114. <select id="findListMap" parameterType="com.iformall.domain.po.WxShop" resultType="hashmap">
  115. select s.id,s.shop_number shopNumber,CONVERT(s.build_area,DECIMAL(10,2)) buildArea,
  116. s.img_url imgUrl,CONVERT(s.operation_area,DECIMAL(10,2)) operationArea,
  117. s.status,b.building_name building,f.floor_name floor,m.`name` merchantName,m.id merchantId,
  118. m.link_person linkPerson,m.link_phone linkPhone,s.manager,s.manager_phone managerPhone,
  119. s.type,s.point_type pointType,s.addr,DATEDIFF(now(),s.create_date) freeDay,rent,rent_unit,business_id as
  120. businessId
  121. from wx_shop s left join wx_merchant_shop ms on ms.shop_id=s.id and ms.is_del=0
  122. left join wx_merchant m on ms.merchant_id=m.id
  123. left join wx_mall_building b on s.building=b.id
  124. left join wx_mall_floor f on s.floor=f.id
  125. where s.is_del=0
  126. <if test=" null != type ">
  127. and s.`type` = #{type}
  128. </if>
  129. <if test=" null != status">
  130. and s.`status` = #{status}
  131. </if>
  132. <if test=" null != building ">
  133. and s.`building`= #{building}
  134. </if>
  135. <if test=" null != floor ">
  136. and s.`floor` = #{floor}
  137. </if>
  138. <if test=" null != id ">
  139. and s.`id` = #{id}
  140. </if>
  141. <if test=" null != shopNumber and ''!=shopNumber">
  142. and s.`shop_number` like concat('%', #{shopNumber},'%')
  143. </if>
  144. <if test=" null != buildArea ">
  145. and s.`build_area` like concat('%', #{buildArea},'%')
  146. </if>
  147. <if test=" null != operationArea ">
  148. and s.`operation_area` like concat('%', #{operationArea},'%')
  149. </if>
  150. <if test=" null != x ">
  151. and s.`x` = #{x}
  152. </if>
  153. <if test=" null != y ">
  154. and s.`y` = #{y}
  155. </if>
  156. <if test=" null != addr ">
  157. and s.`addr` like concat('%', #{addr},'%')
  158. </if>
  159. <if test=" null != baiduPoi ">
  160. and s.`baidu_poi` like concat('%', #{baiduPoi},'%')
  161. </if>
  162. <if test=" null != longitude ">
  163. and s.`longitude` = #{longitude}
  164. </if>
  165. <if test=" null != latitude ">
  166. and s.`latitude` = #{latitude}
  167. </if>
  168. <if test=" null != createDate ">
  169. and s.`create_date` = #{createDate}
  170. </if>
  171. <if test=" null != updateDate ">
  172. and s.`update_date` = #{updateDate}
  173. </if>
  174. <if test=" null != manager ">
  175. and s.`manager` = #{manager}
  176. </if>
  177. <if test=" null != managerPhone ">
  178. and s.`manager_phone` = #{managerPhone}
  179. </if>
  180. <if test=" null != pointType ">
  181. and s.`point_type` = #{pointType}
  182. </if>
  183. <if test=" null != ids ">
  184. and s.id in
  185. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  186. #{idItem}
  187. </foreach>
  188. </if>
  189. <if test=" null != sortColumns">order by ${sortColumns}</if>
  190. </select>
  191. <select id="notRentListMapAsPage" parameterType="com.iformall.domain.po.WxShop" resultType="hashmap">
  192. select s.id,s.shop_number shopNumber,CONVERT(s.build_area,SIGNED)buildArea,
  193. s.img_url imgUrl,CONVERT(s.operation_area,SIGNED) operationArea,
  194. s.status,b.building_name building,f.floor_name floor,s.manager,s.manager_phone managerPhone,
  195. s.type,s.point_type pointType,s.addr,DATEDIFF(now(),s.create_date) freeDay
  196. from wx_shop s
  197. left join wx_mall_building b on s.building=b.id
  198. left join wx_mall_floor f on s.floor=f.id
  199. where s.is_del=0
  200. <if test=" null != id ">
  201. and s.`id` = #{id}
  202. </if>
  203. <if test=" null != tenantId ">
  204. and s.`tenant_id`= #{tenantId}
  205. </if>
  206. <if test=" null != shopNumber and ''!=shopNumber">
  207. and s.`shop_number` like concat('%', #{shopNumber},'%')
  208. </if>
  209. <if test=" null != status">
  210. and s.`status` = #{status}
  211. </if>
  212. <if test=" null != type ">
  213. and s.`type` = #{type}
  214. </if>
  215. <if test=" null != pointType ">
  216. and s.`point_type` = #{pointType}
  217. </if>
  218. <if test="null != sortColumn">
  219. order by ${sortColumn} ${sortOrder}
  220. </if>
  221. <if test="null == sortColumn">
  222. <if test=" null != sortColumns">order by ${sortColumns}</if>
  223. </if>
  224. </select>
  225. <resultMap id="VoResultMap" type="com.iformall.domain.vo.WxShopVo">
  226. <id column="id" jdbcType="BIGINT" property="id"/>
  227. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  228. <result column="shop_number" jdbcType="VARCHAR" property="shopNumber"/>
  229. <result column="build_area" jdbcType="VARCHAR" property="buildArea"/>
  230. <result column="operation_area" jdbcType="VARCHAR" property="operationArea"/>
  231. <result column="building" jdbcType="BIGINT" property="building"/>
  232. <result column="floor" jdbcType="BIGINT" property="floor"/>
  233. <result column="status" jdbcType="INTEGER" property="status"/>
  234. <result column="x" jdbcType="DECIMAL" property="x"/>
  235. <result column="y" jdbcType="DECIMAL" property="y"/>
  236. <result column="addr" jdbcType="VARCHAR" property="addr"/>
  237. <result column="baidu_poi" jdbcType="VARCHAR" property="baiduPoi"/>
  238. <result column="longitude" jdbcType="DECIMAL" property="longitude"/>
  239. <result column="latitude" jdbcType="DECIMAL" property="latitude"/>
  240. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  241. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  242. <result column="img_url" jdbcType="VARCHAR" property="imgUrl"/>
  243. <result column="manager" jdbcType="VARCHAR" property="manager"/>
  244. <result column="manager_phone" jdbcType="VARCHAR" property="managerPhone"/>
  245. <result column="type" jdbcType="INTEGER" property="type"/>
  246. <result column="point_type" jdbcType="INTEGER" property="pointType"/>
  247. <result column="comments" jdbcType="VARCHAR" property="comments"/>
  248. <result column="building_name" jdbcType="VARCHAR" property="buildingName"/>
  249. <result column="floor_name" jdbcType="VARCHAR" property="floorName"/>
  250. <result column="merchantId" jdbcType="VARCHAR" property="merchantId"/>
  251. <result column="merchantName" jdbcType="VARCHAR" property="merchantName"/>
  252. <result column="link_phone" jdbcType="VARCHAR" property="linkPhone"/>
  253. <result column="link_person" jdbcType="VARCHAR" property="linkPerson"/>
  254. <result column="business" jdbcType="VARCHAR" property="business"/>
  255. <result column="brandName" jdbcType="VARCHAR" property="brandName"/>
  256. </resultMap>
  257. <select id="findListWithMerchantMap" parameterType="com.iformall.domain.vo.WxShopVo" resultMap="VoResultMap">
  258. select
  259. s.id,s.shop_number,s.build_area,s.img_url,s.operation_area,s.status,s.manager,s.manager_phone,s.addr,s.type,s.point_type,
  260. b.building_name,f.floor_name,
  261. m.id merchantId,m.name merchantName,m.link_person,m.link_phone,
  262. brand.name brandName,
  263. bus.title business
  264. from wx_shop s left join wx_merchant_shop ms on ms.shop_id=s.id and ms.is_del=0
  265. left join wx_merchant m on ms.merchant_id=m.id
  266. left join wx_mall_building b on s.building=b.id
  267. left join wx_mall_floor f on s.floor=f.id
  268. left join wx_business bus on m.business_id = bus.id
  269. left join wx_brand brand on m.brand = brand.id
  270. where s.is_del=0
  271. <if test=" null != id ">
  272. and s.`id` = #{id}
  273. </if>
  274. <if test=" null != tenantId ">
  275. and s.`tenant_id`= #{tenantId}
  276. </if>
  277. <if test=" null != shopNumber and ''!=shopNumber">
  278. and s.`shop_number` like concat('%', #{shopNumber},'%')
  279. </if>
  280. <if test=" null != buildArea ">
  281. and s.`build_area` like concat('%', #{buildArea},'%')
  282. </if>
  283. <if test=" null != operationArea ">
  284. and s.`operation_area` like concat('%', #{operationArea},'%')
  285. </if>
  286. <if test=" null != building ">
  287. and s.`building`= #{building}
  288. </if>
  289. <if test=" null != floor ">
  290. and s.`floor` = #{floor}
  291. </if>
  292. <if test=" null != status">
  293. and s.`status` = #{status}
  294. </if>
  295. <if test=" null != x ">
  296. and s.`x` = #{x}
  297. </if>
  298. <if test=" null != y ">
  299. and s.`y` = #{y}
  300. </if>
  301. <if test=" null != addr ">
  302. and s.`addr` like concat('%', #{addr},'%')
  303. </if>
  304. <if test=" null != baiduPoi ">
  305. and s.`baidu_poi` like concat('%', #{baiduPoi},'%')
  306. </if>
  307. <if test=" null != longitude ">
  308. and s.`longitude` = #{longitude}
  309. </if>
  310. <if test=" null != latitude ">
  311. and s.`latitude` = #{latitude}
  312. </if>
  313. <if test=" null != createDate ">
  314. and s.`create_date` = #{createDate}
  315. </if>
  316. <if test=" null != updateDate ">
  317. and s.`update_date` = #{updateDate}
  318. </if>
  319. <if test=" null != manager ">
  320. and s.`manager` = #{manager}
  321. </if>
  322. <if test=" null != managerPhone ">
  323. and s.`manager_phone` = #{managerPhone}
  324. </if>
  325. <if test=" null != type ">
  326. and s.`type` = #{type}
  327. </if>
  328. <if test=" null != pointType ">
  329. and s.`point_type` = #{pointType}
  330. </if>
  331. <if test="null != businessId">
  332. and s.business_id = #{businessId}
  333. </if>
  334. <if test=" null != ids ">
  335. and s.id in
  336. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  337. #{idItem}
  338. </foreach>
  339. </if>
  340. <if test=" null != sortColumns">order by ${sortColumns}</if>
  341. </select>
  342. <select id="getbshoplist" resultType="hashmap" parameterType="hashmap">
  343. select id,shop_number shopNumber from wx_shop
  344. where tenant_id=#{tenantId} and shop_number = #{shopNumber} and is_del=0
  345. </select>
  346. <select id="getMerchantShopByShopId" resultType="hashmap" parameterType="hashmap">
  347. select m.`name` merchantName,s.build_area buildArea,s.operation_area operationArea,
  348. c.price,c.receive_period receivePeriod,s.shop_number shopNumber,m.link_person linkPerson,
  349. m.link_phone linkPhone
  350. from wx_merchant_shop ms inner join wx_merchant m on ms.merchant_id=m.id
  351. inner join wx_shop s on ms.shop_id=s.id
  352. inner join wx_rent_contract c on ms.merchant_id=c.merchant_id
  353. where ms.tenant_id=#{tenantId} and ms.shop_id=#{shopId} and ms.is_del=0 and s.is_del=0
  354. </select>
  355. <select id="queryShopLeftInfo" resultType="hashmap" parameterType="hashmap">
  356. select count(id) shopcount,IFNULL(sum(build_area),0) area from wx_shop
  357. where tenant_id=#{tenantId} and status=#{status} and is_del=0
  358. </select>
  359. <select id="listShopFromContract" parameterType="com.iformall.domain.po.WxShop" resultType="hashmap">
  360. select s.id,s.shop_number shopNumber,s.build_area buildArea,
  361. s.img_url imgUrl,s.operation_area operationArea,
  362. s.status,b.building_name building,f.floor_name floor,m.`name` merchantName,m.id merchantId,
  363. m.link_person linkPerson,m.link_phone linkPhone,s.manager,s.manager_phone managerPhone,
  364. m.brand,m.business_id businessId,m.shop_type shopType
  365. from wx_shop s left join wx_merchant_shop ms on ms.shop_id=s.id
  366. left join wx_merchant m on ms.merchant_id=m.id
  367. left join wx_mall_building b on s.building=b.id
  368. left join wx_mall_floor f on s.floor=f.id
  369. where s.is_del=0 and ms.is_del=0
  370. and s.tenant_id=#{tenantId}
  371. <if test=" null != status">
  372. and s.`status` = #{status}
  373. </if>
  374. <if test="null!=status and status==1 and type!=null and type==2">
  375. and s.id not in(
  376. SELECT shop_id FROM wx_rent_contract WHERE tenant_id = #{tenantId} and status in(1,2,3,4)
  377. and rent_shop_type=2
  378. )
  379. </if>
  380. <if test=" null != type ">
  381. and s.`type` = #{type}
  382. </if>
  383. <if test=" null != pointType ">
  384. and s.`point_type` = #{pointType}
  385. </if>
  386. <if test=" null != sortColumns">order by ${sortColumns}</if>
  387. </select>
  388. <select id="hasShopNumber" parameterType="com.iformall.domain.po.WxShop" resultType="Integer">
  389. select count(*) from wx_shop where tenant_id=#{tenantId} and shop_number=#{shopNumber} and `type`=#{type} and
  390. is_del=0
  391. <if test=" null != id">
  392. and id != #{id}
  393. </if>
  394. </select>
  395. <resultMap id="ShopVoResultMap" type="com.iformall.domain.vo.WxShopVo">
  396. <id column="id" jdbcType="BIGINT" property="id"/>
  397. <result column="addr" jdbcType="VARCHAR" property="addr"/>
  398. <result column="shop_number" jdbcType="VARCHAR" property="shopNumber"/>
  399. <result column="building_name" jdbcType="VARCHAR" property="buildingName"/>
  400. <result column="floor_name" jdbcType="VARCHAR" property="floorName"/>
  401. <result column="baidu_poi" jdbcType="VARCHAR" property="baiduPoi"/>
  402. <result column="manager_phone" jdbcType="VARCHAR" property="linkPhone"/>
  403. </resultMap>
  404. <resultMap id="rentRate" type="com.iformall.domain.vo.WxShopRentRateVo">
  405. <result column="xTime" property="xTime"/>
  406. <result column="rate" property="rate"/>
  407. </resultMap>
  408. <select id="findShopVoList" parameterType="java.util.Map" resultMap="ShopVoResultMap">
  409. select s.id,s.shop_number,b.building_name,f.floor_name,s.addr,s.baidu_poi,s.manager_phone
  410. from wx_shop s left join wx_merchant_shop ms on ms.shop_id=s.id
  411. left join wx_merchant m on ms.merchant_id=m.id
  412. left join wx_mall_building b on s.building=b.id
  413. left join wx_mall_floor f on s.floor=f.id
  414. where s.is_del=0 and ms.is_del=0
  415. and m.id=#{merchantId}
  416. </select>
  417. <select id="getCountByWxShop" parameterType="com.iformall.domain.po.WxShop" resultType="Long">
  418. select count(*) from wx_shop w where w.is_del=0
  419. <if test="null != type">
  420. and `type`=#{type}
  421. </if>
  422. <if test="null != status">
  423. and status = #{status}
  424. </if>
  425. <if test="null != building">
  426. and building = #{building}
  427. </if>
  428. <if test="null != floor">
  429. and floor = #{floor}
  430. </if>
  431. <if test="null != startdate">
  432. and `create_date` >= #{startdate}
  433. </if>
  434. <if test="null != enddate">
  435. and `create_date` &lt;= #{enddate}
  436. </if>
  437. <if test="null != businessId">
  438. and business_id = #{businessId}
  439. </if>
  440. </select>
  441. <select id="rentRateHistory" resultType="hashmap" parameterType="hashmap">
  442. select
  443. <if test="1 == dateType">
  444. DATE_FORMAT(w.create_date,'%Y/%m/%d') xTime
  445. </if>
  446. <if test="2 == dateType">
  447. DATE_FORMAT(w.create_date,'%Y/%m') xTime
  448. </if>
  449. ,count(distinct w.shop_id) xCount
  450. from wx_merchant_shop w left join wx_shop s on w.shop_id=s.id
  451. where w.is_del=0
  452. and w.tenant_id = #{tenantId}
  453. <if test="building!=null">
  454. and s.building=#{building}
  455. </if>
  456. <if test="floor!=null">
  457. and s.floor=#{floor}
  458. </if>
  459. <if test="businessId!=null">
  460. and s.business_id=#{businessId}
  461. </if>
  462. group by xTime
  463. order by xTime
  464. </select>
  465. </mapper>