123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367 |
- <?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.MerchantMapper">
- <resultMap type="Merchant" id="MerchantResult">
- <result property="id" column="id"/>
- <result property="merchantName" column="merchant_name"/>
- <result property="agentId" column="agent_id"/>
- <result property="provinceId" column="province_id"/>
- <result property="cityId" column="city_id"/>
- <result property="districtId" column="district_id"/>
- <result property="merchantType" column="merchant_type"/>
- <result property="licenseType" column="license_type"/>
- <result property="categoryId" column="category_id"/>
- <result property="logo" column="logo"/>
- <result property="contactName" column="contact_name"/>
- <result property="mobile" column="mobile"/>
- <result property="intro" column="intro"/>
- <result property="photoAlbum" column="photo_album"/>
- <result property="bizLicense" column="biz_license"/>
- <result property="bizLicenseNo" column="biz_license_no"/>
- <result property="legalPerson" column="legal_person"/>
- <result property="idcardNo" column="idcard_no"/>
- <result property="idcardFront" column="idcard_front"/>
- <result property="idcardBack" column="idcard_back"/>
- <result property="lng" column="lng"/>
- <result property="lat" column="lat"/>
- <result property="address" column="address"/>
- <result property="errorMsg" column="error_msg"/>
- <result property="status" column="status"/>
- </resultMap>
- <update id="updatePersonnelId">
- update lb_merchant set personnel_id = null where id = #{id}
- </update>
- <select id="findIdsByAgentId" resultType="java.lang.Integer">
- SELECT id
- FROM lb_merchant
- WHERE agent_id = #{agentId}
- </select>
- <select id="findIdsByAgentIds" resultType="java.lang.Integer">
- SELECT id FROM lb_merchant WHERE 1 = 1
- AND agent_id IN
- <foreach collection="agentIds" index="index" item="agentId" open="(" separator="," close=")">
- #{agentId}
- </foreach>
- </select>
- <select id="findIdsByAgentIdLists" resultType="java.lang.Integer">
- SELECT id FROM lb_merchant WHERE 1 = 1
- AND agent_id IN
- <foreach collection="agentIds" index="index" item="agentId" open="(" separator="," close=")">
- #{agentId}
- </foreach>
- </select>
- <select id="listMerchan" resultType="com.ydd.module.domain.Merchant" >
- SELECT *
- FROM lb_merchant
- WHERE agent_Id IN
- (SELECT id FROM lb_agent WHERE pid in (SELECT id FROM lb_agent WHERE id = #{id}) OR id = #{id})
- </select>
- <select id="getMerchantNum" resultType="java.lang.Integer">
- SELECT count(id) FROM lb_merchant WHERE deleted = 0
- <if test="agentIds != null and agentIds.size() > 0">
- AND agent_id in
- <foreach collection="agentIds" index="index" item="agentId" open="(" separator="," close=")">
- #{agentId}
- </foreach>
- </if>
- <if test="startDate != null and startDate != ''">
- AND create_time >= #{startDate}
- </if>
- </select>
- <select id="findByMobile" resultType="com.ydd.module.domain.Merchant">
- select *
- from lb_merchant
- where mobile = #{mobile} and deleted = 0
- </select>
- <select id="selectExportList" resultType="com.ydd.module.dto.MerchantExportDto">
- select
- mc.logo,
- mc.merchant_name,
- mc.agent_id,
- mc.province_name,
- mc.city_name,
- mc.district_name,
- mc.merchant_type,
- mc.license_type,
- mc.category_id,
- mc.contact_name,
- mc.mobile,
- mc.legal_person,
- mc.idcard_no,
- mc.create_time,
- mc.status,
- mb.nickname as memberName,
- mb.mobile as memberMobile
- from lb_merchant mc
- left join lb_member mb on mc.id = mb.merchant_id
- left join lb_personnel p on mc.personnel_id = p.id
- where mc.deleted = 0 and mb.member_type = 2
- <if test="agentIds != null and agentIds.size > 0">
- and mc.agent_id in
- <foreach collection="agentIds" index="index" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="params.personnelId != null">
- and mc.personnel_id = #{params.personnelId}
- </if>
- <if test="params.merchantName != null and params.merchantName != ''">
- and mc.merchant_name like concat('%', #{params.merchantName} ,'%')
- </if>
- <if test="params.merchantType != null">
- and mc.merchant_type = #{params.merchantType}
- </if>
- <if test="params.licenseType != null">
- and mc.license_type = #{params.licenseType}
- </if>
- <if test="params.contactName != null and params.contactName != ''">
- and mc.contact_name like concat('%', #{params.contactName}, '%')
- </if>
- <if test="params.mobile != null and params.mobile != ''">
- and mc.mobile like concat('%', #{params.mobile}, '%')
- </if>
- <if test="params.startTime != null">
- AND mc.create_time >= #{params.startTime}
- </if>
- <if test="params.endTime != null">
- AND #{params.endTime} >= mc.create_time
- </if>
- <if test="params.memberName != null and params.memberName != ''">
- and mb.nickname like concat('%', #{params.memberName}, '%')
- </if>
- <if test="params.memberMobile != null and params.memberMobile != ''">
- and mb.mobile like concat('%', #{params.memberMobile}, '%')
- </if>
- <if test="params.personnelName != null and params.personnelName != ''">
- AND p.`name` like concat('%', #{params.personnelName}, '%')
- </if>
- order by create_time desc
- </select>
- <select id="selectMerchantList" resultType="com.ydd.module.domain.Merchant">
- select
- mc.*,
- mb.nickname as memberName,
- mb.mobile as memberMobile
- from lb_merchant mc
- left join lb_member mb on mc.id = mb.merchant_id
- left join lb_personnel p on mc.personnel_id = p.id
- where mb.member_type = 2
- <if test="params.merchantName != null and params.merchantName != ''">
- and mc.merchant_name like concat('%', #{params.merchantName}, '%')
- </if>
- <if test="agentIds != null and agentIds.size > 0">
- and mc.agent_id in
- <foreach collection="agentIds" index="index" item="agentId" open="(" separator="," close=")">
- #{agentId}
- </foreach>
- </if>
- <if test="params.packageDiscountId != null">
- and mc.agent_id in
- <foreach collection="agentList" index="index" item="agentId" open="(" separator="," close=")">
- #{agentId}
- </foreach>
- </if>
- <if test="params.personnelId != null">
- and mc.personnel_id = #{params.personnelId}
- </if>
- <if test="params.merchantType != null">
- and mc.merchant_type = #{params.merchantType}
- </if>
- <if test="params.licenseType != null">
- and mc.license_type = #{params.licenseType}
- </if>
- <if test="params.contactName != null and params.contactName != ''">
- and mc.contact_name like concat('%', #{params.contactName}, '%')
- </if>
- <if test="params.mobile != null and params.mobile != ''">
- and mc.mobile like concat('%', #{params.mobile}, '%')
- </if>
- <if test="params.provinceName != null and params.provinceName != ''">
- and mc.province_name like concat('%', #{params.provinceName}, '%')
- </if>
- <if test="params.cityName != null and params.cityName != ''">
- and mc.city_name like concat('%', #{params.cityName}, '%')
- </if>
- <if test="params.districtName != null and params.districtName != ''">
- and mc.district_name like concat('%', #{params.districtName}, '%')
- </if>
- <if test="params.startTime != null">
- AND mc.create_time >= #{params.startTime}
- </if>
- <if test="params.endTime != null">
- AND #{params.endTime} >= mc.create_time
- </if>
- <if test="params.memberName != null and params.memberName != ''">
- and mb.nickname like concat('%', #{params.memberName}, '%')
- </if>
- <if test="params.memberMobile != null and params.memberMobile != ''">
- and mb.mobile like concat('%', #{params.memberMobile}, '%')
- </if>
- <!-- <if test="params.aId != null">-->
- <!-- ANd mc.agent_id = #{params.aId}-->
- <!-- </if>-->
- <if test="params.personnelName != null and params.personnelName != ''">
- AND p.`name` like concat('%', #{params.personnelName}, '%')
- </if>
- order by create_time desc
- </select>
- <select id="listMerchantIds" resultType="java.lang.Long">
- SELECT id FROM lb_merchant WHERE 1 = 1
- AND agent_id IN
- <foreach collection="agentIds" index="index" item="agentId" open="(" separator="," close=")">
- #{agentId}
- </foreach>
- </select>
- <select id="getIdListByFreightPackageId" resultType="java.lang.Long">
- SELECT id FROM lb_merchant
- WHERE freight_package_id = #{freightPackageId} AND deleted = 0
- </select>
- <select id="queryListByDadaDspId" resultType="com.ydd.module.dto.DadaDspMerchantInfoDto">
- select
- mc.id,
- mc.merchant_name,
- mc.contact_name,
- mc.mobile as contactMobile,
- mc.create_time,
- mc.merchant_type,
- mc.freight_package_id,
- mc.open_qr_code,
- dd.name as dspName,
- lm.amount as accountAmount,
- pf.name as freightPackageName
- from lb_merchant mc
- left join lb_dada_dsp dd on mc.dada_dsp_id = dd.id
- left join lb_member lm on lm.merchant_id = mc.id and lm.member_type = 2
- left join lb_package_freight pf on mc.freight_package_id = pf.id
- where mc.dada_dsp_id is not null
- <if test="params.dadaDspId != null and params.dadaDspId != ''">
- and mc.dada_dsp_id = #{params.dadaDspId}
- </if>
- <if test="params.merchantName != null and params.merchantName != ''">
- and mc.merchant_name like concat('%', #{params.merchantName}, '%')
- </if>
- <if test="params.contactName != null and params.contactName != ''">
- and mc.contact_name l ike concat('%', #{params.contactName}, '%')
- </if>
- <if test="params.mobile != null and params.mobile != ''">
- and mc.mobile like concat('%', #{params.mobile}, '%')
- </if>
- <if test="params.startTime != null and params.startTime != ''">
- AND mc.create_time >= #{params.startTime}
- </if>
- <if test="params.endTime != null and params.startTime != ''">
- AND #{params.endTime} >= mc.create_time
- </if>
- <if test="params.merchantType != null and params.merchantType != ''">
- AND mc.merchant_type = #{params.merchantType}
- </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 mc.freight_package_id is null
- </if>
- <if test="params.dimension == 1">
- AND mc.freight_package_id = #{params.freightPackageId}
- </if>
- </if>
- </if>
- order by mc.id desc
- </select>
- <select id="queryDadaMerchantInfo" resultType="com.ydd.module.dto.DadaDspMerchantInfoDto">
- select
- mc.id,
- mc.merchant_name,
- mc.province_id,
- mc.city_id,
- mc.district_id,
- mc.province_name,
- mc.city_name,
- mc.district_name,
- mc.address,
- mc.street,
- mc.contact_name,
- mc.mobile as contactMobile,
- mc.dada_dsp_id,
- mc.freight_package_id,
- mc.category_id,
- mc.merchant_type,
- mc.license_type,
- mc.legal_person,
- mc.idcard_no
- from lb_merchant mc
- where mc.id = #{merchantId}
- </select>
- <select id="selectIdByName" resultType="java.lang.Long">
- SELECT id FROM lb_merchant WHERE deleted = 0 AND merchant_name like concat('%', #{merchantName}, '%')
- </select>
- <select id="findMerchantIdByAgentId" resultType="java.lang.Long">
- SELECT id FROM lb_merchant WHERE 1 = 1
- <if test="agentIds != null and agentIds.size > 0">
- AND agent_id IN
- <foreach collection="agentIds" index="index" item="agentId" open="(" separator="," close=")">
- #{agentId}
- </foreach>
- </if>
- </select>
- <select id="selectListByDadaDspId" resultType="com.ydd.module.domain.Merchant">
- SELECT
- id,
- code,
- merchant_name,
- create_time,
- dada_dsp_id
- FROM lb_merchant
- WHERE deleted = 0
- AND dada_dsp_id = #{dadaDspId}
- </select>
- <select id="selectCustomerList" resultType="com.ydd.module.dto.OpenCustomerDto">
- SELECT
- ai.create_time,
- m.city_name,
- m.merchant_name AS businessName,
- m.contact_name,
- m.mobile AS contactMobile,
- ai.end_time,
- ai.earnest_money,
- m.status
- FROM lb_merchant m
- LEFT JOIN lb_app_info ai ON m.app_id = ai.id
- WHERE m.deleted = 0
- <if test="cityName != null and cityName != ''">
- AND m.city_name = #{cityName}
- </if>
- <if test="businessName != null and businessName != ''">
- AND m.merchant_name = #{businessName}
- </if>
- <if test="contactName != null and contactName != ''">
- AND m.contact_name = #{contactName}
- </if>
- </select>
- </mapper>
|