GoodsShopMapper.xml 30 KB

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