123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.ydd.module.mapper.ShopMapper">
- <resultMap type="Shop" id="ShopResult">
- <result property="id" column="id" />
- <result property="merchantId" column="merchant_id" />
- <result property="name" column="name" />
- <result property="code" column="code" />
- <result property="categoryId" column="category_id" />
- <result property="provinceId" column="province_id" />
- <result property="cityId" column="city_id" />
- <result property="districtId" column="district_id" />
- <result property="address" column="address" />
- <result property="lng" column="lng" />
- <result property="lat" column="lat" />
- <result property="type" column="type" />
- <result property="tag" column="tag" />
- <result property="doorHeadPhoto" column="door_head_photo" />
- <result property="photoAlbum" column="photo_album" />
- <result property="openingHours" column="opening_hours" />
- <result property="contactName" column="contact_name" />
- <result property="mobile" column="mobile" />
- <result property="startDate" column="start_date" />
- <result property="endDate" column="end_date" />
- <result property="startTime" column="start_time" />
- <result property="endTime" column="end_time" />
- <result property="status" column="status" />
- </resultMap>
- <select id="findList" resultType="com.ydd.module.dto.ShopDto">
- select
- *
- from
- lb_shop
- where
- merchant_id = #{merchantId}
- <if test="shopId != null">
- and id = #{shopId}
- </if>
- and deleted = 0 and status = 1
- </select>
- <select id="findDeliveryList" resultType="com.ydd.module.dto.DeliveryDto">
- select
- sd.*,d.name,d.logo,d.type,d.id DspDeliveryId
- from
- lb_shop_delivery as sd
- left join lb_dsp_delivery as d
- on d.id = sd.delivery_id
- where
- sd.shop_id = #{shopId}
- </select>
- <select id="findDetail" resultType="com.ydd.module.dto.ShopDto">
- select
- *
- from
- lb_shop
- where
- id = #{shopId} and deleted = 0
- </select>
- <select id="getShopNameById" resultType="java.lang.String">
- select
- `name`
- from
- lb_shop
- where
- id = #{shopId}
- </select>
- <select id="findByMerchantIds" resultType="java.lang.Integer">
- SELECT id FROM lb_shop WHERE 1 = 1
- AND deleted = 0
- AND merchant_id IN
- <foreach collection="merchantIds" index="index" item="merchantId" open="(" separator="," close=")">
- #{merchantId}
- </foreach>
- </select>
- <select id="findByMerchantId" resultType="java.lang.Integer">
- select id from lb_shop where 1=1
- and merchant_id = #{merchantId}
- </select>
- <select id="getByCode" resultType="com.ydd.module.domain.Shop">
- select * from lb_shop where code = #{code} and deleted = 0
- </select>
- <select id="getAddress" resultType="com.ydd.module.domain.Shop">
- SELECT
- id,
- `name`,
- `code`,
- province_name,
- city_name,
- district_name,
- address,
- street,
- lng,
- lat,
- city_code,
- contact_name contact,
- mobile phone
- FROM
- lb_shop
- WHERE
- deleted = 0
- AND `status` = 1
- AND merchant_id = #{merchantId}
- <if test="shopId != null">
- AND id = #{shopId}
- </if>
- </select>
- <select id="getShopByMerchantId" resultType="java.lang.Long">
- SELECT id FROM lb_shop WHERE merchant_id = #{merchantId} and deleted = 0
- <if test="shopId != null">
- and id != #{shopId}
- </if>
- </select>
- <select id="getByDeliveryId" resultType="com.ydd.module.domain.Shop">
- SELECT
- id
- FROM
- lb_shop
- WHERE
- deleted = 0
- AND id NOT IN (
- SELECT shop_id FROM lb_shop_delivery WHERE delivery_id = #{deliveryId} AND id <4422 AND shop_id IN ( SELECT id FROM lb_shop WHERE deleted = 0 )
- )
- </select>
- <select id="getOpenQrCode" resultType="java.lang.Integer">
- SELECT open_qr_code
- FROM lb_shop
- WHERE id = #{shopId}
- AND deleted = 0
- </select>
- <select id="findListByMerchantId" resultType="com.ydd.module.dto.ShopBindDto">
- select
- id as shopId,
- name as shopName
- from
- lb_shop
- where
- merchant_id = #{merchantId} and deleted = 0
- </select>
- <select id="findListById" resultType="com.ydd.module.dto.ShopBindDto">
- select
- id as shopId,
- name as shopName
- from
- lb_shop
- where
- id = #{shopId} and deleted = 0
- </select>
- <select id="getIdListByFreightPackageId" resultType="java.lang.Long">
- SELECT id FROM lb_shop
- WHERE freight_package_id = #{freightPackageId} AND deleted = 0
- </select>
- <select id="queryShopListByMerchantId" resultType="com.ydd.module.dto.DadaDspMerchantShopInfoDto">
- select
- id,
- name as shopName,
- contact_name,
- mobile as contactMobile,
- province_name,
- city_name,
- district_name,
- address,
- street,
- create_time,
- status
- from lb_shop
- where merchant_id = #{params.merchantId}
- <if test="params.name != null and params.name != ''">
- and name like concat('%', #{params.name}, '%')
- </if>
- <if test="params.contactName != null and params.contactName != ''">
- and contact_name like concat('%', #{params.contactName}, '%')
- </if>
- <if test="params.mobile != null and params.mobile != ''">
- and mobile like concat('%', #{params.mobile}, '%')
- </if>
- <if test="params.startTime != null and params.startTime != ''">
- AND create_time >= #{params.startTime}
- </if>
- <if test="params.endTime != null and params.startTime != ''">
- AND #{params.endTime} >= create_time
- </if>
- order by id desc
- </select>
- <select id="queryDadaShopList" resultType="com.ydd.module.dto.DadaShopListDto">
- select
- s.id,
- s.name,
- s.code,
- s.type,
- s.contact_name,
- s.mobile,
- s.create_time,
- s.status,
- s.freight_package_id,
- m.freight_package_id as merchantFreightPackageId,
- m.merchant_name,
- ifnull(lm.amount, 0) as amount,
- mc.name as categoryName
- from lb_shop s
- left join lb_merchant m on s.merchant_id = m.id
- left join lb_member lm on lm.merchant_id = m.id and member_type = 2
- left join lb_merchant_category mc on s.category_id = mc.id
- where 1 = 1 and m.dada_dsp_id is not null
- <if test="params.dadaDspId != null and params.dadaDspId != ''">
- and lm.dada_dsp_id = #{params.dadaDspId}
- </if>
- <if test="params.name != null and params.name != ''">
- and s.name like concat('%', #{params.name}, '%')
- </if>
- <if test="params.mobile != null and params.mobile != ''">
- and s.mobile like concat('%', #{params.mobile}, '%')
- </if>
- <if test="params.merchantId != null and params.merchantId != ''">
- AND s.merchant_id = #{params.merchantId}
- </if>
- <if test="params.categoryId != null and params.categoryId != ''">
- AND s.category_id = #{params.categoryId}
- </if>
- <if test="params.startTime != null and params.startTime != ''">
- AND s.create_time >= #{params.startTime}
- </if>
- <if test="params.endTime != null and params.startTime != ''">
- AND #{params.endTime} >= s.create_time
- </if>
- <if test="params.amountStart != null and params.amountStart != ''">
- AND lm.amount >= #{params.amountStart}
- </if>
- <if test="params.amountEnd != null and params.amountEnd != ''">
- AND #{params.amountEnd} >= lm.amount
- </if>
- <if test="params.freightPackageId != null and params.freightPackageId != ''">
- <if test="params.dimension != null">
- <if test="params.dimension == 0">
- AND s.freight_package_id is null AND m.freight_package_id is null
- </if>
- <if test="params.dimension == 1">
- AND m.freight_package_id = #{params.freightPackageId} AND s.freight_package_id is null
- </if>
- <if test="params.dimension == 2">
- AND s.freight_package_id = #{params.freightPackageId}
- </if>
- </if>
- </if>
- order by s.id desc
- </select>
- <select id="getDiscountPackageList" resultType="com.ydd.module.dto.ShopDiscountPackageStatisticsDto">
- SELECT
- s.city_name,
- s.district_name,
- s.name as shopName,
- d.name as packageName,
- a.name as agentName
- FROM
- lb_shop s
- JOIN lb_package_discount d ON s.package_discount_id = d.id
- JOIN lb_merchant m ON s.merchant_id = m.id
- JOIN lb_agent a ON m.agent_id = a.id
- WHERE 1 = 1
- <if test="params.shopName != null and params.shopName != ''">
- AND s.name like concat('%', #{params.shopName}, '%')
- </if>
- <if test="params.packageName != null and params.packageName != ''">
- AND d.name like concat('%', #{params.packageName}, '%')
- </if>
- </select>
- <select id="findShopIdByMerchantId" resultType="java.lang.Long">
- SELECT id FROM lb_shop WHERE 1 = 1
- AND deleted = 0
- <if test="merchantIds != null and merchantIds.size > 0">
- AND merchant_id IN
- <foreach collection="merchantIds" index="index" item="merchantId" open="(" separator="," close=")">
- #{merchantId}
- </foreach>
- </if>
- </select>
- <select id="getShopByMerchantIds" resultType="com.ydd.module.domain.Shop">
- SELECT id, merchant_id
- FROM lb_shop
- WHERE deleted = 0
- <if test="merchantIds != null and merchantIds.size > 0">
- AND merchant_id IN
- <foreach collection="merchantIds" index="index" item="merchantId" open="(" separator="," close=")">
- #{merchantId}
- </foreach>
- </if>
- </select>
- <select id="findShopSelectList" resultType="com.ydd.module.dto.ShopSelectDto">
- select id, name
- from lb_shop
- where deleted = 0 and status = 1
- and merchant_id = #{params.merchantId}
- <if test="params.memberType == 3 and params.shopId != null">
- and id = #{shopId}
- </if>
- </select>
- </mapper>
|