GoodsShopMapper.xml 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823
  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.sqx.modules.goods.dao.GoodsShopDao">
  4. <select id="selectAllShop" resultType="com.sqx.modules.goods.entity.GoodsShop">
  5. select gs.*, (SELECT GROUP_CONCAT(st1.shop_type_name SEPARATOR ',')
  6. FROM shop_type st1 WHERE FIND_IN_SET(st1.id,gs.shop_type_id) ) as shopTypeName,
  7. (select user_id from sys_user where user_id in (select s.user_id from sys_user_shop s where
  8. s.shop_id=gs.shop_id) and user_type=2) as adminUserId
  9. from goods_shop gs
  10. left join shop_type st on gs.shop_type_id = st.id
  11. where 1 = 1 and status = 1
  12. <if test="shopName!=null and shopName!=''">
  13. and shop_name like concat('%',#{shopName},'%')
  14. </if>
  15. <if test="region!=null and region!=''">
  16. and (province like concat('%',#{region},'%') or
  17. city like concat('%',#{region},'%') or
  18. district like concat('%',#{region},'%') )
  19. </if>
  20. <if test="isActivity!=null">
  21. <if test="isActivity==0">
  22. and gs.activity_id is null
  23. </if>
  24. <if test="isActivity==1">
  25. and gs.activity_id is not null
  26. </if>
  27. </if>
  28. <if test="vipPromotion != null and vipPromotion != ''">
  29. and gs.vip_promotion = #{vipPromotion}
  30. </if>
  31. order by create_time desc
  32. </select>
  33. <select id="selectAllShopByAdmin" resultType="com.sqx.modules.goods.entity.GoodsShop">
  34. select gs.* from goods_shop gs left join sys_user_shop sus on sus.shop_id = gs.shop_id where 1 = 1
  35. and sus.user_id = #{userId}
  36. <if test="shopName!=null and shopName!=''">
  37. and shop_name like concat('%',#{shopName},'%')
  38. </if>
  39. </select>
  40. <select id="selectListByAdmin" resultType="com.sqx.modules.goods.entity.GoodsShop">
  41. select gs.*
  42. from goods_shop gs
  43. left join sys_user_shop sus on sus.shop_id = gs.shop_id
  44. where 1 = 1
  45. and sus.user_id = #{userId}
  46. </select>
  47. <select id="selectAdminGoodsList" resultType="com.sqx.modules.goods.entity.Goods">
  48. select g.*, gc.classify_name as classifyName,gsr.sales as sales, gs.shop_name as shopName, gsr.inventory as inventory,
  49. IF(gsr.inventory = 0,2,gsr.status) AS gsrStatus
  50. from goods g
  51. left join goods_classify gc on g.classify_id = gc.classify_id
  52. left join goods_shop gs on g.shop_id = gs.shop_id
  53. left join goods_shop_relevancy gsr on g.goods_id = gsr.goods_id
  54. where 1 = 1
  55. <if test="classifyId!=null">
  56. and g.classify_id = #{classifyId}
  57. </if>
  58. <if test="goodsName!=null and goodsName!=''">
  59. and g.goods_name like concat('%',#{goodsName},'%')
  60. </if>
  61. <if test="status!=null">
  62. and g.status = #{status}
  63. </if>
  64. <if test="shopId!=null">
  65. and g.shop_id = #{shopId}
  66. </if>
  67. <if test="shopName!=null and shopName!=''">
  68. and gs.shop_name like concat('%',#{shopName},'%')
  69. </if>
  70. order by g.create_time desc
  71. </select>
  72. <select id="selectGoodsByShopId" resultType="com.sqx.modules.goods.entity.Goods">
  73. select g.*,gc.classify_name as classifyName,gsr.sales, gsr.inventory as inventory, IF(gsr.inventory =
  74. 0,2,gsr.status) AS gsrStatus
  75. from goods g
  76. left join goods_shop_relevancy gsr on gsr.goods_id = g.goods_id
  77. left join goods_classify gc on g.classify_id = gc.classify_id
  78. where gsr.shop_id = #{shopId}
  79. <if test="goodsName!=null and goodsName!=''">
  80. and g.goods_name like concat('%',#{goodsName},'%')
  81. </if>
  82. <if test="classifyId!=null">
  83. and g.classify_id = #{classifyId}
  84. </if>
  85. <if test="status!=null">
  86. <if test="status!=2">
  87. and g.status = #{status}
  88. </if>
  89. <if test="status==2">
  90. AND gsr.inventory = 0
  91. </if>
  92. </if>
  93. order by LPAD(g.sort, 10, '0') ASC,gsr.create_time desc
  94. </select>
  95. <select id="selectGoodsByNotShopId" resultType="com.sqx.modules.goods.entity.Goods">
  96. select g.*, gc.classify_name as classifyName from goods g
  97. left join goods_classify gc on g.classify_id = gc.classify_id
  98. where g.goods_id not in (select gsr.goods_id from goods_shop_relevancy gsr where gsr.shop_id = #{shopId})
  99. and g.status = 0
  100. <if test="goodsName!=null and goodsName!=''">
  101. and g.goods_name like concat('%',#{goodsName},'%')
  102. </if>
  103. </select>
  104. <insert id="addGoodsByShopId" parameterType="com.sqx.modules.goods.entity.GoodsShopRelevancy">
  105. insert into goods_shop_relevancy (shop_id, goods_id, status, create_time, sales, inventory) values
  106. <foreach item="item" collection="goodsShopRelevancyList" separator=",">
  107. (#{item.shopId}, #{item.goodsId}, 0, #{date}, 0, 999)
  108. </foreach>
  109. </insert>
  110. <delete id="deleteGoodsByShopId">
  111. delete
  112. from goods_shop_relevancy
  113. where shop_id = #{shopId}
  114. and goods_id = #{goodsId}
  115. </delete>
  116. <delete id="deleteGoods">
  117. delete
  118. from goods
  119. where shop_id = #{shopId}
  120. and goods_id = #{goodsId}
  121. </delete>
  122. <delete id="cancelActivityShop">
  123. update goods_shop
  124. set activity_id =null
  125. where shop_id = #{shopId}
  126. </delete>
  127. <update id="updateShopSales">
  128. update goods_shop
  129. <if test="type==1">
  130. set shop_sales = shop_sales + #{goodsNum}
  131. </if>
  132. <if test="type==2">
  133. set shop_sales = shop_sales - #{goodsNum}
  134. </if>
  135. where shop_id = #{shopId}
  136. </update>
  137. <update id="updateCashDeposit">
  138. update goods_shop
  139. set cash_deposit = cash_deposit + #{money}
  140. where shop_id = #{shopId}
  141. </update>
  142. <update id="updateShopCashDeposit">
  143. update goods_shop set
  144. <if test="type==1">
  145. cash_deposit = cash_deposit+#{money}
  146. </if>
  147. <if test="type==2">
  148. cash_deposit = cash_deposit-#{money}
  149. </if>
  150. where shop_id = #{shopId}
  151. </update>
  152. <update id="soldOutOrPutaway">
  153. update goods_shop_relevancy
  154. set status = #{status}
  155. where shop_id = #{shopId}
  156. and goods_id = #{goodsId}
  157. </update>
  158. <select id="selectStoreCount" resultType="int">
  159. select count(*) from tb_order where shop_id = #{shopId} and status = 4
  160. <if test="(endTime!=null and endTime!='') or (startTime!=null and startTime!='')">
  161. and date_format(pay_time,'%Y-%m-%d') &gt;= date_format(#{startTime},'%Y-%m-%d')
  162. and date_format(pay_time,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d')
  163. </if>
  164. </select>
  165. <select id="selectStoreMoney" resultType="java.math.BigDecimal">
  166. select ifnull(sum(pay_money), 0) from tb_order where shop_id = #{shopId} and status = 4
  167. <if test="(endTime!=null and endTime!='') or (startTime!=null and startTime!='')">
  168. and date_format(pay_time,'%Y-%m-%d') &gt;= date_format(#{startTime},'%Y-%m-%d')
  169. and date_format(pay_time,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d')
  170. </if>
  171. </select>
  172. <select id="selectStoreMessage" resultType="com.sqx.modules.order.entity.TbOrder">
  173. select
  174. tor.*,
  175. gs.shop_name as shopName
  176. from
  177. tb_order tor
  178. left join goods_shop gs on tor.shop_id = gs.shop_id
  179. where
  180. tor.status in (3, 4, 6, 7)
  181. <if test="shopId != null">
  182. and tor.shop_id = #{shopId}
  183. </if>
  184. <if test="(endTime != null and endTime != '') and (startTime != null and startTime != '')">
  185. and date_format(tor.pay_time, '%Y-%m-%d') &gt;= date_format(#{startTime}, '%Y-%m-%d')
  186. and date_format(tor.pay_time, '%Y-%m-%d') &lt;= date_format(#{endTime}, '%Y-%m-%d')
  187. </if>
  188. order by tor.pay_time desc
  189. </select>
  190. <select id="selectSearch" resultType="com.sqx.modules.goods.entity.GoodsShop">
  191. select gs.*,
  192. (st_distance(point(shop_lng, shop_lat), point(#{lng}, #{lat})) * 111195) AS distance,
  193. st.shop_type_name as shopTypeName
  194. from goods_shop gs
  195. left join shop_type st on gs.shop_type_id = st.id
  196. where gs.status = 1
  197. and gs.city = #{city}
  198. and ((gs.shop_name like concat('%', #{impotr}, '%')) or
  199. (st.shop_type_name like concat('%', #{impotr}, '%')) or (gs.shop_lable like concat('%', #{impotr}, '%')))
  200. order by distance asc
  201. </select>
  202. <select id="selectShop" resultType="com.sqx.modules.goods.entity.GoodsShop">
  203. select
  204. *
  205. from
  206. (
  207. select
  208. gs.*,
  209. (st_distance (point (gs.shop_lng,gs.shop_lat),point(#{lng}, #{lat}) ) * 111195) AS distance
  210. from
  211. goods_shop gs
  212. left join shop_type st on gs.shop_type_id = st.id
  213. where
  214. gs.status = 1
  215. and gs.city = #{city}
  216. and gs.putaway_flag = 0
  217. and gs.is_supplier=1
  218. and (gs.is_conceal =0 or gs.is_conceal is NULL)
  219. <if test="impotr!=null and impotr!=''">
  220. AND (
  221. gs.shop_name LIKE concat('%',#{impotr},'%')
  222. or st.shop_type_name like concat('%',#{impotr},'%')
  223. or gs.shop_lable LIKE concat('%',#{impotr},'%')
  224. or gs.shop_id in (
  225. select shop_id from goods where goods_name like concat('%',#{impotr},'%')
  226. )
  227. )
  228. </if>
  229. <if test="activityId!=null">
  230. and gs.activity_id = #{activityId}
  231. </if>
  232. <if test="shopTypeId!=null">
  233. and FIND_IN_SET(#{shopTypeId},gs.shop_type_id)
  234. </if>
  235. <if test="vipPromotion !=null and vipPromotion != ''">
  236. and gs.vip_promotion = #{vipPromotion}
  237. </if>
  238. order by
  239. gs.is_recommend desc
  240. <if test="screen == 1">
  241. ,gs.sort,gs.shop_score desc, gs.shop_sales desc, gs.create_time desc
  242. </if>
  243. <if test="screen == 2">
  244. ,gs.shop_score desc
  245. </if>
  246. <if test="screen == 3">
  247. ,gs.shop_sales desc
  248. </if>
  249. <if test="screen == 4">
  250. ,gs.create_time desc
  251. </if>
  252. ) a
  253. where
  254. distribution_distance >= distance
  255. </select>
  256. <select id="selectEvaluate" resultType="com.sqx.modules.order.entity.Evaluate">
  257. select e.*, tu.nick_name as userName, tu.avatar as avatar from evaluate e
  258. left join tb_user tu on e.user_id = tu.user_id
  259. where e.shop_id = #{shopId}
  260. <if test="grade==1">
  261. and e.score = 5
  262. </if>
  263. <if test="grade==2">
  264. and e.score in (4, 3)
  265. </if>
  266. <if test="grade==3">
  267. and e.score in (2, 1)
  268. </if>
  269. <if test="goodsId!=null and goodsId!=''">
  270. and e.goods_id like concat("%",#{goodsId},"%")
  271. </if>
  272. order by e.create_time desc
  273. </select>
  274. <select id="selectEvaluateByGoodsId" resultType="com.sqx.modules.order.entity.Evaluate">
  275. select e.*, tu.nick_name as nickName, tu.avatar as avatar
  276. from evaluate e
  277. left join tb_user tu on e.user_id = tu.user_id
  278. where goods_id =#{goodsId}
  279. <if test="grade!=null and grade ==0">
  280. and e.score in (1,2,3,4,5)
  281. </if>
  282. <if test="grade!=null and grade ==1">
  283. and e.score =5
  284. </if>
  285. <if test="grade!=null and grade ==2">
  286. and e.score in (4,3)
  287. </if>
  288. <if test="grade!=null and grade ==3">
  289. and e.score in (2,1)
  290. </if>
  291. order by create_time desc
  292. </select>
  293. <select id="selectShopList" resultType="com.sqx.modules.goods.entity.GoodsShop">
  294. select gs.*, st.shop_type_name as shopTypeName from goods_shop gs left join shop_type st on gs.shop_type_id =
  295. st.id where 1 = 1
  296. <if test="shopName!=null and shopName!=''">
  297. and shop_name like concat('%',#{shopName},'%')
  298. </if>
  299. <if test="status!=null">
  300. and status = #{status}
  301. </if>
  302. <if test="shopType!=null">
  303. and shop_type_id = #{shopType}
  304. </if>
  305. order by create_time desc
  306. </select>
  307. <insert id="addGoodsShopRelevancy" parameterType="com.sqx.modules.goods.entity.GoodsShopRelevancy">
  308. insert into goods_shop_relevancy (shop_id, goods_id, status, create_time, sales, inventory)
  309. values (#{shopId}, #{goodsId}, #{status}, #{createTime}, #{sales}, #{inventory})
  310. </insert>
  311. <select id="shopAllEarnings" resultType="java.math.BigDecimal">
  312. select ifnull(sum(shop_income_money), 0)
  313. from tb_order
  314. where shop_id = #{shopId}
  315. and is_pay = 1
  316. and status = 4
  317. </select>
  318. <select id="shopEarningsDay" resultType="java.math.BigDecimal">
  319. select ifnull(sum(shop_income_money), 0)
  320. from tb_order
  321. where shop_id = #{shopId}
  322. and is_pay = 1
  323. and status = 4
  324. and date_format(pay_time, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d')
  325. </select>
  326. <select id="shopEarningsMonth" resultType="java.math.BigDecimal">
  327. select ifnull(sum(shop_income_money), 0)
  328. from tb_order
  329. where shop_id = #{shopId}
  330. and is_pay = 1
  331. and status = 4
  332. and date_format(pay_time, '%Y-%m') = date_format(#{date}, '%Y-%m')
  333. </select>
  334. <select id="allMoney" resultType="java.math.BigDecimal">
  335. select ifnull(sum(shop_income_money), 0) from tb_order where shop_id = #{shopId} and is_pay = 1 and status = 4
  336. <if test="startTime!=null and startTime!=''and endTime!=null and endTime!='' ">
  337. and str_to_date(pay_time, '%Y-%m-%d') between str_to_date(#{startTime}, '%Y-%m-%d') AND
  338. str_to_date(#{endTime}, '%Y-%m-%d')
  339. </if>
  340. </select>
  341. <select id="selectCountOrder" resultType="int">
  342. select count(*) from tb_order where 1 = 1 and status = #{status} and shop_id = #{shopId}
  343. <if test="startTime!=null and startTime!=''and endTime!=null and endTime!='' ">
  344. and str_to_date(pay_time, '%Y-%m-%d') between str_to_date(#{startTime}, '%Y-%m-%d') AND
  345. str_to_date(#{endTime}, '%Y-%m-%d')
  346. </if>
  347. </select>
  348. <select id="allCount" resultType="int">
  349. select ifnull(sum(og.goods_num), 0) from tb_order tor left join order_goods og on tor.order_id = og.order_id
  350. where 1 = 1 and tor.shop_id = #{shopId} and tor.is_pay = 1 and tor.status = 4
  351. <if test="startTime!=null and startTime!=''and endTime!=null and endTime!='' ">
  352. and str_to_date(tor.pay_time, '%Y-%m-%d') between str_to_date(#{startTime}, '%Y-%m-%d') AND
  353. str_to_date(#{endTime}, '%Y-%m-%d')
  354. </if>
  355. </select>
  356. <select id="orderMoney" resultType="java.math.BigDecimal">
  357. select ifnull(sum(pay_money), 0) from tb_order where 1 = 1 and shop_id = #{shopId} and is_pay = 1 and status = 4
  358. <if test="startTime!=null and startTime!=''and endTime!=null and endTime!='' ">
  359. and str_to_date(pay_time, '%Y-%m-%d') between str_to_date(#{startTime}, '%Y-%m-%d') AND
  360. str_to_date(#{endTime}, '%Y-%m-%d')
  361. </if>
  362. </select>
  363. <select id="sumCountOrder" resultType="int">
  364. select count(*) from tb_order where 1 = 1 and shop_id = #{shopId} and is_pay = 1
  365. <if test="startTime!=null and startTime!=''and endTime!=null and endTime!='' ">
  366. and str_to_date(pay_time, '%Y-%m-%d') between str_to_date(#{startTime}, '%Y-%m-%d') AND
  367. str_to_date(#{endTime}, '%Y-%m-%d')
  368. </if>
  369. </select>
  370. <select id="refundMoney" resultType="java.math.BigDecimal">
  371. select ifnull(sum(pay_money), 0) from tb_order where 1 = 1 and is_pay = 1 and shop_id = #{shopId} and status in
  372. (5, 8)
  373. <if test="startTime!=null and startTime!=''and endTime!=null and endTime!='' ">
  374. and str_to_date(pay_time, '%Y-%m-%d') between str_to_date(#{startTime}, '%Y-%m-%d') AND
  375. str_to_date(#{endTime}, '%Y-%m-%d')
  376. </if>
  377. </select>
  378. <select id="putawayCount" resultType="int">
  379. select count(*)
  380. from goods
  381. where shop_id = #{shopId}
  382. and status = 0
  383. </select>
  384. <select id="soldoutCount" resultType="int">
  385. select count(*)
  386. from goods
  387. where shop_id = #{shopId}
  388. and status = 1
  389. </select>
  390. <select id="selectGoodsList" resultType="com.sqx.modules.goods.entity.GoodsShop">
  391. select *,
  392. (st_distance(point(shop_lng, shop_lat), point(#{lng}, #{lat})) * 111195) AS distance,
  393. st.shop_type_name as shopTypeName
  394. from goods_shop gs
  395. left join shop_type st on gs.shop_type_id = st.id
  396. where shop_id = #{shopId}
  397. </select>
  398. <select id="selectGoodShopByPhone" resultType="com.sqx.modules.goods.entity.GoodsShop">
  399. select *,
  400. st.shop_type_name as shopTypeName
  401. from goods_shop gs
  402. left join shop_type st on gs.shop_type_id = st.id
  403. where phone = #{phone}
  404. </select>
  405. <select id="selectGoodReputation" resultType="int">
  406. select count(*)
  407. from evaluate
  408. where 1=1
  409. <if test="shopId!=null">
  410. and shop_id = #{shopId}
  411. </if>
  412. <if test="goodsId!=null and goodsId!=''">
  413. and goods_id like concat("%",#{goodsId},"%")
  414. </if>
  415. and score = 5
  416. </select>
  417. <select id="selectMediumReview" resultType="int">
  418. select count(*)
  419. from evaluate
  420. where 1=1
  421. <if test="shopId!=null">
  422. and shop_id = #{shopId}
  423. </if>
  424. <if test="goodsId!=null and goodsId!=''">
  425. and goods_id like concat("%",#{goodsId},"%")
  426. </if>
  427. and score in (4, 3)
  428. </select>
  429. <select id="selectNegativeComment" resultType="int">
  430. select count(*)
  431. from evaluate
  432. where 1=1
  433. <if test="shopId!=null">
  434. and shop_id = #{shopId}
  435. </if>
  436. <if test="goodsId!=null and goodsId!=''">
  437. and goods_id like concat("%",#{goodsId},"%")
  438. </if>
  439. and score in (2, 1)
  440. </select>
  441. <select id="getShoActivityShopList" resultType="com.sqx.modules.goods.entity.GoodsShop">
  442. select * from ( SELECT
  443. s.*,
  444. (st_distance(POINT(s.shop_lng, s.shop_lat),POINT(#{goodsShop.shopLng}, #{goodsShop.shopLat})) * 111195) AS distance,
  445. (SELECT shop_type_name FROM shop_type t WHERE t.id = s.shop_type_id) AS shopTypeName
  446. FROM
  447. goods_shop s
  448. WHERE 1 = 1
  449. and s.status=1 and s.putaway_flag=0 and s.banned_flag=0
  450. <if test="goodsShop.activityId!=null">
  451. and s.activity_id = #{goodsShop.activityId}
  452. </if>
  453. <if test="goodsShop.city!=null and goodsShop.city!=''">
  454. and s.city = #{goodsShop.city}
  455. </if>
  456. ) t1
  457. WHERE t1.distribution_distance >= distance
  458. order by t1.sort,distance asc
  459. </select>
  460. <select id="getAdminShoActivityShopList" resultType="com.sqx.modules.goods.entity.GoodsShop">
  461. select * from ( SELECT
  462. s.*,
  463. (st_distance(POINT(s.shop_lng, s.shop_lat),POINT(#{goodsShop.shopLng}, #{goodsShop.shopLat})) * 111195) AS distance,
  464. (SELECT shop_type_name FROM shop_type t WHERE t.id = s.shop_type_id) AS shopTypeName
  465. FROM
  466. goods_shop s
  467. WHERE 1 = 1
  468. <if test="goodsShop.activityId!=null">
  469. and s.activity_id = #{goodsShop.activityId}
  470. </if>
  471. <if test="goodsShop.city!=null and goodsShop.city!=''">
  472. and s.city = #{goodsShop.city}
  473. </if>
  474. ) t1
  475. order by distance asc
  476. </select>
  477. <select id="selectSupplierShop" resultType="com.sqx.modules.goods.entity.GoodsShop">
  478. select * from (select gs.*,(st_distance (point (gs.shop_lng,gs.shop_lat),point(#{lng},#{lat}) ) *111195) AS
  479. distance
  480. from goods_shop gs
  481. left join shop_type st on gs.shop_type_id = st.id
  482. where gs.status = 1 and gs.city = #{city} and gs.putaway_flag = 0 and gs.is_supplier=0
  483. <if test="impotr!=null and impotr!=''">
  484. AND (gs.shop_name LIKE concat('%',#{impotr},'%') or
  485. st.shop_type_name like concat('%',#{impotr},'%') or
  486. gs.shop_lable LIKE concat('%',#{impotr},'%') or
  487. gs.shop_id in (
  488. select shop_id from goods where goods_name like concat('%',#{impotr},'%')
  489. )
  490. )
  491. </if>
  492. <if test="activityId!=null">
  493. and gs.activity_id = #{activityId}
  494. </if>
  495. <if test="shopTypeId!=null">
  496. and FIND_IN_SET(#{shopTypeId},gs.shop_type_id)
  497. </if>
  498. order by gs.is_recommend desc
  499. <if test="screen==1">
  500. ,gs.sort,gs.shop_score desc, distance asc
  501. </if>
  502. <if test="screen==3">
  503. ,distance asc
  504. </if>
  505. <if test="screen==4">
  506. ,gs.shop_sales desc
  507. </if>
  508. ) a
  509. where distribution_distance >= distance
  510. </select>
  511. <select id="getByAdminUserId" resultType="com.sqx.modules.goods.entity.GoodsShop">
  512. select
  513. gs.*
  514. from
  515. goods_shop gs
  516. left join sys_user_shop sus on sus.shop_id = gs.shop_id
  517. where sus.user_id = #{adminUserId}
  518. </select>
  519. <insert id="insertGoodsShop" useGeneratedKeys="true" keyProperty="shopId"
  520. parameterType="com.sqx.modules.goods.entity.GoodsShop">
  521. INSERT INTO goods_shop
  522. <trim prefix="(" suffix=")" suffixOverrides=",">
  523. <if test="null != shopName and '' != shopName">
  524. shop_name,
  525. </if>
  526. <if test="null != userId and '' != userId">
  527. user_id,
  528. </if>
  529. <if test="null != shopTypeId and '' != shopTypeId">
  530. shop_type_id,
  531. </if>
  532. <if test="null != shopLable and '' != shopLable">
  533. shop_lable,
  534. </if>
  535. <if test="null != detailedAddress and '' != detailedAddress">
  536. detailed_address,
  537. </if>
  538. <if test="null != shopLng and '' != shopLng">
  539. shop_lng,
  540. </if>
  541. <if test="null != shopLat and '' != shopLat">
  542. shop_lat,
  543. </if>
  544. <if test="null != province and '' != province">
  545. province,
  546. </if>
  547. <if test="null != city and '' != city">
  548. city,
  549. </if>
  550. <if test="null != district and '' != district">
  551. district,
  552. </if>
  553. <if test="null != accessNumber and '' != accessNumber">
  554. access_number,
  555. </if>
  556. <if test="null != shopNotice and '' != shopNotice">
  557. shop_notice,
  558. </if>
  559. <if test="null != shopScore and '' != shopScore">
  560. shop_score,
  561. </if>
  562. <if test="null != shopSales and '' != shopSales">
  563. shop_sales,
  564. </if>
  565. <if test="null != businessHours and '' != businessHours">
  566. business_hours,
  567. </if>
  568. <if test="null != lockHours and '' != lockHours">
  569. lock_hours,
  570. </if>
  571. <if test="null != shopCover and '' != shopCover">
  572. shop_cover,
  573. </if>
  574. <if test="null != shopBanner and '' != shopBanner">
  575. shop_banner,
  576. </if>
  577. <if test="null != createTime and '' != createTime">
  578. create_time,
  579. </if>
  580. <if test="null != realName and '' != realName">
  581. real_name,
  582. </if>
  583. <if test="null != identitycardNumber and '' != identitycardNumber">
  584. identitycard_number,
  585. </if>
  586. <if test="null != phone and '' != phone">
  587. phone,
  588. </if>
  589. <if test="null != businessLicense and '' != businessLicense">
  590. business_license,
  591. </if>
  592. <if test="null != identitycardPro and '' != identitycardPro">
  593. identitycard_pro,
  594. </if>
  595. <if test="null != identitycardCon and '' != identitycardCon">
  596. identitycard_con,
  597. </if>
  598. <if test="null != auditReason and '' != auditReason">
  599. audit_reason,
  600. </if>
  601. <if test="null != cashDeposit and '' != cashDeposit">
  602. cash_deposit,
  603. </if>
  604. <if test="null != auditTime and '' != auditTime">
  605. audit_time,
  606. </if>
  607. <if test="null != status and '' != status">
  608. status,
  609. </if>
  610. <if test="null != errandMoney and '' != errandMoney">
  611. errand_money,
  612. </if>
  613. <if test="null != distributionDistance and '' != distributionDistance">
  614. distribution_distance,
  615. </if>
  616. <if test="null != exemptErrandFlag ">
  617. exempt_errand_flag,
  618. </if>
  619. <if test="null != exemptMinMoney and '' != exemptMinMoney">
  620. exempt_min_money,
  621. </if>
  622. <if test="null != minimumDelivery ">
  623. minimum_delivery,
  624. </if>
  625. <if test="null != putawayFlag ">
  626. putaway_flag,
  627. </if>
  628. <if test="null != autoSendOrder and '' != autoSendOrder">
  629. auto_send_order,
  630. </if>
  631. <if test="null != bannedFlag ">
  632. banned_flag,
  633. </if>
  634. <if test="null != snCode and '' != snCode">
  635. sn_code,
  636. </if>
  637. <if test="null != value and '' != value">
  638. `value`,
  639. </if>
  640. <if test="null != facility ">
  641. facility,
  642. </if>
  643. <if test="null != autoAcceptOrder ">
  644. auto_accept_order
  645. </if>
  646. </trim>
  647. <trim prefix="values (" suffix=")" suffixOverrides=",">
  648. <if test="null != shopName and '' != shopName">
  649. #{shopName},
  650. </if>
  651. <if test="null != userId and '' != userId">
  652. #{userId},
  653. </if>
  654. <if test="null != shopTypeId and '' != shopTypeId">
  655. #{shopTypeId},
  656. </if>
  657. <if test="null != shopLable and '' != shopLable">
  658. #{shopLable},
  659. </if>
  660. <if test="null != detailedAddress and '' != detailedAddress">
  661. #{detailedAddress},
  662. </if>
  663. <if test="null != shopLng and '' != shopLng">
  664. #{shopLng},
  665. </if>
  666. <if test="null != shopLat and '' != shopLat">
  667. #{shopLat},
  668. </if>
  669. <if test="null != province and '' != province">
  670. #{province},
  671. </if>
  672. <if test="null != city and '' != city">
  673. #{city},
  674. </if>
  675. <if test="null != district and '' != district">
  676. #{district},
  677. </if>
  678. <if test="null != accessNumber and '' != accessNumber">
  679. #{accessNumber},
  680. </if>
  681. <if test="null != shopNotice and '' != shopNotice">
  682. #{shopNotice},
  683. </if>
  684. <if test="null != shopScore and '' != shopScore">
  685. #{shopScore},
  686. </if>
  687. <if test="null != shopSales and '' != shopSales">
  688. #{shopSales},
  689. </if>
  690. <if test="null != businessHours and '' != businessHours">
  691. #{businessHours},
  692. </if>
  693. <if test="null != lockHours and '' != lockHours">
  694. #{lockHours},
  695. </if>
  696. <if test="null != shopCover and '' != shopCover">
  697. #{shopCover},
  698. </if>
  699. <if test="null != shopBanner and '' != shopBanner">
  700. #{shopBanner},
  701. </if>
  702. <if test="null != createTime and '' != createTime">
  703. #{createTime},
  704. </if>
  705. <if test="null != realName and '' != realName">
  706. #{realName},
  707. </if>
  708. <if test="null != identitycardNumber and '' != identitycardNumber">
  709. #{identitycardNumber},
  710. </if>
  711. <if test="null != phone and '' != phone">
  712. #{phone},
  713. </if>
  714. <if test="null != businessLicense and '' != businessLicense">
  715. #{businessLicense},
  716. </if>
  717. <if test="null != identitycardPro and '' != identitycardPro">
  718. #{identitycardPro},
  719. </if>
  720. <if test="null != identitycardCon and '' != identitycardCon">
  721. #{identitycardCon},
  722. </if>
  723. <if test="null != auditReason and '' != auditReason">
  724. #{auditReason},
  725. </if>
  726. <if test="null != cashDeposit and '' != cashDeposit">
  727. #{cashDeposit},
  728. </if>
  729. <if test="null != auditTime and '' != auditTime">
  730. #{auditTime},
  731. </if>
  732. <if test="null != status and '' != status">
  733. #{status},
  734. </if>
  735. <if test="null != errandMoney and '' != errandMoney">
  736. #{errandMoney},
  737. </if>
  738. <if test="null != distributionDistance and '' != distributionDistance">
  739. #{distributionDistance},
  740. </if>
  741. <if test="null != exemptErrandFlag ">
  742. #{exemptErrandFlag},
  743. </if>
  744. <if test="null != exemptMinMoney and '' != exemptMinMoney">
  745. #{exemptMinMoney},
  746. </if>
  747. <if test="null != minimumDelivery ">
  748. #{minimumDelivery},
  749. </if>
  750. <if test="null != putawayFlag ">
  751. #{putawayFlag},
  752. </if>
  753. <if test="null != autoSendOrder and '' != autoSendOrder">
  754. #{autoSendOrder},
  755. </if>
  756. <if test="null != bannedFlag">
  757. #{bannedFlag},
  758. </if>
  759. <if test="null != snCode and '' != snCode">
  760. #{snCode},
  761. </if>
  762. <if test="null != value and '' != value">
  763. #{value},
  764. </if>
  765. <if test="null != facility ">
  766. #{facility},
  767. </if>
  768. <if test="null != autoAcceptOrder ">
  769. #{autoAcceptOrder}
  770. </if>
  771. </trim>
  772. </insert>
  773. </mapper>