GoodsShopMapper.xml 30 KB

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