123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550 |
- <?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">
- <!-- 命名,每一个映射对象不一样
- namespace:必须与对应的接口全类名一致
- -->
- <mapper namespace="com.iamberry.wechat.service.mapper.PlaceInfoMapper">
- <!-- palceInfo活动所有字段映射 -->
- <sql id="palceInfoAllField">
- PLACE_ID id,
- PLACE_SUPPER_ID supperId,
- PLACE_NAME name,
- PLACE_ADDR addr,
- PLACE_USERNAME userName,
- PLACE_TEL tel,
- PLACE_AMOUNT amount,
- PLACE_CREATE_DATE createDate,
- PLACE_STATUS status,
- PLACE_OPENID openid,
- PLACE_ROLE_ID roleId,
- PLACE_PID placePid ,
- PLACE_AREA areaName,
- PLACE_INIT_CODE initCode,
- PLACE_REMARK remark
- </sql>
-
- <!-- 商户申请修改信息页面 -->
- <sql id="applyLogsAllField">
- APPLY_ID applyID, APPLY_OPENID applyOpenID, APPLY_TO_PLACEID applyToPlaceID,
- APPLY_NAME applyName, APPLY_USERNAME applyUserName, APPLY_TEL applyTel,
- APPLY_AREA applyArea, APPLY_DATE applyDate, APPLY_STATUS applyStatus, APPLY_ADDR applyAddr
- </sql>
-
- <select id="getOnePlaceInfo" parameterType="integer" resultType="PlaceInfo">
- SELECT
- <include refid="palceInfoAllField"/>,
- PLACE_PIDS placeIds ,
- PLACE_HAS_QRCODE hasQrcode,
- PLACE_TEMPLATE_ID templateId,
- (select role_name from tb_iamberry_place_role where role_id=roleId ) as roleName,
- (select template_name from tb_iamberry_template where template_id=templateId) templateName
- FROM tb_iamberry_place_info WHERE place_id = #{appid} and PLACE_STATUS=1
- </select>
- <select id="getOnePlaceInfo2" parameterType="string" resultType="PlaceInfo">
- SELECT
- <include refid="palceInfoAllField"/>,
- PLACE_PIDS placeIds ,
- PLACE_HAS_QRCODE hasQrcode,
- PLACE_TEMPLATE_ID templateId,
- PLACE_INFO_STATUS placeInfoStus,
- ROLE_NAME roleName
- FROM TB_IAMBERRY_PLACE_INFO
- JOIN TB_IAMBERRY_PLACE_ROLE ON ROLE_ID = PLACE_ROLE_ID
- WHERE PLACE_OPENID=#{openid} AND PLACE_STATUS=1
- </select>
- <select id="getOnePlaceInfoByInitcode" resultType="PlaceInfo">
- SELECT
- <include refid="palceInfoAllField"/>,
- PLACE_PIDS placeIds ,
- PLACE_HAS_QRCODE hasQrcode,
- PLACE_TEMPLATE_ID templateId
- FROM tb_iamberry_place_info
- WHERE
- PLACE_STATUS=1
- <if test="initCode!=null and initCode!=''">
- and PLACE_INIT_CODE=#{initCode}
- </if>
- <if test="id!=null and id!=''">
- and PLACE_ID=${id}
- </if>
- <if test="name!=null and name!=''">
- and PLACE_Name=#{name}
- </if>
- </select>
-
- <select id="getPlaceInfosForDownLoad" resultType="PlaceInfo">
- select
- PLACE_ID id,
- PLACE_NAME name,
- PLACE_ADDR addr,
- PLACE_USERNAME userName,
- PLACE_TEL tel,
- PLACE_ROLE_ID roleId,
- PLACE_PID placePid ,
- PLACE_AREA areaName,
- PLACE_HAS_QRCODE hasQrcode,
- PLACE_INIT_CODE initCode,
- PLACE_REMARK remark
- FROM tb_iamberry_place_info
- WHERE
- PLACE_STATUS=1
- <if test="beginNum!=null and beginNum!=''">
- <![CDATA[ and PLACE_ID >= #{beginNum} ]]>
- </if>
- <if test="num!=null and num!=''">
- limit #{num}
- </if>
- </select>
-
- <select id="getUnderling" parameterType="PlaceInfo" resultType="string">
- select t.PLACE_OPENID openid
- from tb_iamberry_place_info t
- <where>
- t.PLACE_PID=(select PLACE_ID from tb_iamberry_place_info where PLACE_OPENID=#{openid})
- <if test="roleId>0" >
- and t.PLACE_ROLE_ID=${roleId}
- </if>
- and t.PLACE_OPENID is not null
- </where>
- </select>
-
- <select id="selectAll" resultType="PlaceInfo" parameterType="PlaceInfo">
- select
- <include refid="palceInfoAllField"/>,
- (select role_name from tb_iamberry_place_role where role_id=roleId ) as roleName,
- (SELECT Q.QRCODE_URL FROM TB_IAMBERRY_USER_QRCODE Q WHERE (Q.QRCODE_REPLACE_OPENID = id OR Q.QRCODE_REPLACE_OPENID = openid) AND Q.QRCODE_STATUS = 1 limit 1) qrcodeUrl
- from tb_iamberry_place_info
- <where>
- PLACE_STATUS=1
- <if test="name!=null and name!=''">
- and PLACE_NAME like CONCAT('%',#{name},'%')
- </if>
- <if test="userName!=null and userName!=''" >
- and PLACE_USERNAME like CONCAT('%',#{userName},'%')
- </if>
- <if test="roleId!=null and roleId!=''" >
- and PLACE_ROLE_ID=#{roleId}
- </if>
- <if test="tel!=null and tel!=''">
- AND PLACE_TEL LIKE CONCAT('%',#{tel},'%')
- </if>
- <if test="userNickname != null and userNickname != ''">
- AND PLACE_OPENID IN (SELECT T.USER_OPENID FROM TB_IAMBERRY_USER_USERINFO T WHERE T.USER_NICKNAME LIKE CONCAT('%',#{userNickname},'%'))
- </if>
- <if test="placePid!=null and placePid!=''" >
- and PLACE_PID=#{placePid}
- </if>
- <if test="supperId>0" >
- and PLACE_SUPPER_ID =#{supperId}
- </if>
- <if test="parentName!=null and parentName!=''" >
- and PLACE_PID in
- (select PLACE_ID from tb_iamberry_place_info where
- PLACE_NAME like CONCAT('%',#{parentName},'%')
- )
- </if>
- </where>
- order by place_create_date desc
- <if test="page!=null and page.recordBegin>0 and page.pageSize>0 ">
- limit ${page.recordBegin},${page.pageSize}
- </if>
- <if test="page!=null and page.recordBegin==0 and page.pageSize>0 ">
- limit ${page.pageSize}
- </if>
- </select>
-
- <!-- 根据条件获取placeId -->
- <select id="getPlaceId" resultType="PlaceInfo" parameterType="PlaceInfo">
- SELECT
- PLACE_ID id,
- PLACE_OPENID openid,
- (SELECT Q.QRCODE_URL FROM TB_IAMBERRY_USER_QRCODE Q WHERE (Q.QRCODE_REPLACE_OPENID = id OR Q.QRCODE_REPLACE_OPENID = openid) AND Q.QRCODE_STATUS = 1 limit 1) qrcodeUrl
- FROM
- TB_IAMBERRY_PLACE_INFO
- <where>
- PLACE_STATUS=1
- <if test="name!=null and name!=''">
- and PLACE_NAME like CONCAT('%',#{name},'%')
- </if>
- <if test="userName!=null and userName!=''" >
- and PLACE_USERNAME like CONCAT('%',#{userName},'%')
- </if>
- <if test="roleId!=null and roleId!=''" >
- and PLACE_ROLE_ID=#{roleId}
- </if>
- <if test="placePid!=null and placePid!=''" >
- and PLACE_PID=#{placePid}
- </if>
- <if test="supperId>0" >
- and PLACE_SUPPER_ID =#{supperId}
- </if>
- <if test="parentName!=null and parentName!=''" >
- and PLACE_PID in
- (select PLACE_ID from tb_iamberry_place_info where
- PLACE_NAME like CONCAT('%',#{parentName},'%')
- )
- </if>
- </where>
- order by place_create_date desc
- </select>
-
- <select id="getAllCount" resultType="integer">
- select count(PLACE_ID) from tb_iamberry_place_info
- <where>
- PLACE_STATUS=1
- <if test="name!=null and name!=''">
- and PLACE_NAME like CONCAT('%',#{name},'%')
- </if>
- <if test="userName!=null and userName!=''" >
- and PLACE_USERNAME like CONCAT('%',#{userName},'%')
- </if>
- <if test="supperId!=null and supperId!=''" >
- and PLACE_SUPPER_ID =${supperId}
- </if>
- <if test="roleId!=null and roleId!=''" >
- and PLACE_ROLE_Id=#{roleId}
- </if>
- <if test="placePid!=null and placePid!=''" >
- and PLACE_PID=#{placePid}
- </if>
- <if test="parentName!=null and parentName!=''" >
- and PLACE_PID in
- (select PLACE_ID from tb_iamberry_place_info where
- PLACE_NAME like CONCAT('%',#{parentName},'%')
- )
- </if>
- </where>
- </select>
-
- <select id="testNameExist" resultType="Integer">
- select count(PLACE_ID) from tb_iamberry_place_info
- where
- PLACE_NAME= #{name}
- and PLACE_STATUS=1
- </select>
-
- <insert id="insert" >
- insert into
- tb_iamberry_place_info(
- PLACE_SUPPER_ID ,
- PLACE_NAME ,
- PLACE_ADDR ,
- PLACE_USERNAME ,
- PLACE_TEL ,
- PLACE_AMOUNT ,
- PLACE_CREATE_DATE ,
- PLACE_STATUS ,
- PLACE_OPENID ,
- PLACE_ROLE_ID ,
- PLACE_PID ,
- PLACE_HAS_QRCODE ,
- PLACE_TEMPLATE_ID ,
- PLACE_AREA ,
- PLACE_INIT_CODE,
- PLACE_REMARK)
- values(#{supperId},#{name},#{addr},#{userName},#{tel},#{amount},
- #{createDate},#{status},#{openid},${roleId},${placePid},#{hasQrcode},#{templateId},#{areaName},
- #{initCode},#{remark})
- </insert>
- <!-- 插入对象,并返回带有主键的对象 -->
- <insert id="insertObj" useGeneratedKeys="true" keyProperty="id" >
- <selectKey keyProperty="id" resultType="int">
- select LAST_INSERT_ID()
- </selectKey>
- insert into
- tb_iamberry_place_info(
- PLACE_SUPPER_ID ,
- PLACE_NAME ,
- PLACE_ADDR ,
- PLACE_USERNAME ,
- PLACE_TEL ,
- PLACE_AMOUNT ,
- PLACE_CREATE_DATE ,
- PLACE_STATUS ,
- PLACE_OPENID ,
- PLACE_ROLE_ID ,
- PLACE_PID ,
- PLACE_HAS_QRCODE ,
- PLACE_TEMPLATE_ID ,
- PLACE_AREA ,
- PLACE_INIT_CODE,
- PLACE_REMARK,
- PLACE_INFO_STATUS)
- values(#{supperId},#{name},#{addr},#{userName},#{tel},#{amount},
- #{createDate},#{status},#{openid},${roleId},${placePid},#{hasQrcode},#{templateId},#{areaName},
- #{initCode},#{remark},#{placeInfoStus})
- </insert>
-
- <insert id="batchInsert" parameterType="ArrayList">
- insert into
- tb_iamberry_place_info(
- PLACE_SUPPER_ID ,
- PLACE_NAME ,
- PLACE_ADDR ,
- PLACE_USERNAME ,
- PLACE_TEL ,
- PLACE_AMOUNT ,
- PLACE_CREATE_DATE ,
- PLACE_STATUS ,
- PLACE_OPENID ,
- PLACE_TEMPLATE_ID ,
- PLACE_INIT_CODE)
- values
- <foreach collection="list" item="obj" index="index" separator="," >
- (#{supperId},#{name},#{addr},#{userName},#{tel},#{amount},
- #{createDate},#{status},#{openid},#{templateId}, #{initCode})
- </foreach>
- </insert>
-
- <update id="update" >
- update tb_iamberry_place_info
- <set>
- <if test="templateId!=null and templateId!=''">
- PLACE_TEMPLATE_ID =#{templateId},
- </if>
- <if test="name!=null and name!=''">
- PLACE_NAME =#{name},
- </if>
- <if test="addr!=null and addr!=''">
- PLACE_ADDR =#{addr},
- </if>
- <if test="userName!=null and userName!=''">
- PLACE_USERNAME =#{userName},
- </if>
- <if test="tel!=null and tel!=''">
- PLACE_TEL =#{tel},
- </if>
- <if test="amount!=null and amount!=''">
- PLACE_AMOUNT =#{amount},
- </if>
- <if test="status!=null and status!=''">
- PLACE_STATUS =#{status},
- </if>
- <if test="openid!=null and openid!=''">
- PLACE_OPENID =#{openid},
- </if>
- <if test="roleId!=null and roleId!=''">
- PLACE_ROLE_ID =#{roleId},
- </if>
- <if test="placePid!=null and placePid!=''">
- PLACE_PID =#{placePid},
- </if>
- <if test="placeIds!=null and placeIds!=''">
- PLACE_PIDS =#{placeIds},
- </if>
- <if test="areaName!=null and areaName!=''">
- PLACE_AREA =#{areaName},
- </if>
- <if test="hasQrcode!=null and hasQrcode!=''">
- PLACE_HAS_QRCODE =#{hasQrcode},
- </if>
- <if test="remark!=null and remark!=''">
- PLACE_REMARK =#{remark}
- </if>
- </set>
- where PLACE_ID = #{id}
- </update>
-
- <update id="batchUpdate" parameterType="java.util.List">
- <foreach collection="list" item="item" index="index" separator=";" open="" close="">
- update tb_iamberry_place_info
- <set>
- <if test="item.name!=null and item.name!=''">
- PLACE_NAME =#{item.name,jdbcType=VARCHAR},
- </if>
- <if test="item.addr!=null and item.addr!=''">
- PLACE_ADDR =#{item.addr,jdbcType=VARCHAR},
- </if>
- <if test="item.userName!=null and item.userName!=''">
- PLACE_USERNAME =#{item.userName,jdbcType=VARCHAR},
- </if>
- <if test="item.tel!=null and item.tel!=''">
- PLACE_TEL =#{item.tel,jdbcType=VARCHAR},
- </if>
- <if test="item.areaName!=null and item.areaName!=''">
- PLACE_AREA =#{item.areaName,jdbcType=VARCHAR},
- </if>
- <if test="item.hasQrcode!=null and item.hasQrcode!=''">
- PLACE_HAS_QRCODE =#{item.hasQrcode,jdbcType=INTEGER},
- </if>
- <if test="item.remark!=null and item.remark!=''">
- PLACE_REMARK =#{item.remark,jdbcType=VARCHAR}
- </if>
- </set>
- where PLACE_ID = #{item.id,jdbcType=INTEGER}
- </foreach>
- </update>
-
- <delete id="delete" parameterType="string">
- delete from tb_iamberry_place_info
- where PLACE_ID = #{appid}
- </delete>
-
- <!-- 根据code获取代理商信息 -->
- <select id="selectOnePlaceInfoByCode" parameterType="String" resultType="PlaceInfo">
- SELECT
- PLACE_ID id, PLACE_OPENID openid,
- (select r.role_name from tb_iamberry_place_role r where r.role_id=place_role_id ) as roleName
- FROM
- TB_IAMBERRY_PLACE_INFO
- WHERE
- PLACE_INIT_CODE = #{code}
- </select>
-
- <!-- 更新微代理的微信openid -->
- <update id="updateOpenidById" parameterType="PlaceInfo">
- UPDATE
- TB_IAMBERRY_PLACE_INFO
- SET
- PLACE_OPENID = #{openid}
- WHERE
- PLACE_ID = #{id}
- </update>
-
- <!-- 根据ID,获取顶级代理商ID -->
- <select id="selectPlaceInfobyId" parameterType="Integer" resultType="PlaceInfo">
- SELECT
- PLACE_ID id, PLACE_PIDS placeIds,PLACE_TEMPLATE_ID templateId, PLACE_OPENID openid
- FROM
- TB_IAMBERRY_PLACE_INFO
- WHERE
- PLACE_ID = #{appid}
- </select>
-
- <!-- 根据用户openid,获取对应的代理商ID -->
- <select id="selectPlaceIdByOpenId" parameterType="String" resultType="Integer">
- SELECT
- PLACE_ID id
- FROM
- TB_IAMBERRY_PLACE_INFO
- WHERE
- PLACE_OPENID = #{openid}
- </select>
-
- <!-- 根据代理商ID,获取完善信息的状态 -->
- <select id="selectPlaceInfoStatusByPlaceId" parameterType="Integer" resultType="Integer">
- SELECT
- PLACE_INFO_STATUS
- FROM
- TB_IAMBERRY_PLACE_INFO
- WHERE
- PLACE_ID = #{id}
- </select>
-
- <!-- 获取某一页的商户申请记录 -->
- <select id="selectApplyPlaceLogs" parameterType="PaperBean" resultType="ApplyPlaceLogs">
- SELECT
- <include refid="applyLogsAllField"/>
- FROM
- TB_IAMBERRY_PLACE_APPLY_LOGS
- ORDER BY
- APPLY_ID
- LIMIT
- #{minNum}, #{maxNum}
- </select>
-
- <!-- 获取待处理的总记录条数 -->
- <select id="getCount" resultType="int">
- SELECT
- COUNT(APPLY_ID)
- FROM
- TB_IAMBERRY_PLACE_APPLY_LOGS
- </select>
-
- <!-- 修改状态 -->
- <update id="updateApplyStatus" parameterType="ApplyPlaceLogs">
- UPDATE
- TB_IAMBERRY_PLACE_APPLY_LOGS
- SET
- APPLY_STATUS = #{applyStatus}
- WHERE
- APPLY_ID = #{applyID}
- </update>
-
- <!-- 获取某一个商户最近的申请记录 -->
- <select id="selectApplyLogsByPlaceID" parameterType="int" resultType="ApplyPlaceLogs">
- SELECT
- <include refid="applyLogsAllField"/>
- FROM
- TB_IAMBERRY_PLACE_APPLY_LOGS
- WHERE
- APPLY_TO_PLACEID = #{applyToPlaceID}
- ORDER BY
- APPLY_ID DESC
- LIMIT
- 0, 1
- </select>
-
- <!-- 获取某一个商户最近的申请记录 -->
- <select id="selectApplyLogsByOpenID" parameterType="String" resultType="ApplyPlaceLogs">
- SELECT
- <include refid="applyLogsAllField"/>
- FROM
- TB_IAMBERRY_PLACE_APPLY_LOGS
- WHERE
- APPLY_OPENID = #{applyOpenID}
- ORDER BY
- APPLY_ID DESC
- LIMIT
- 0, 1
- </select>
-
- <!-- 根据apply_id获取申请记录 -->
- <select id="selectApplyLogsByID" parameterType="int" resultType="ApplyPlaceLogs">
- SELECT
- <include refid="applyLogsAllField"/>
- FROM
- TB_IAMBERRY_PLACE_APPLY_LOGS
- WHERE
- APPLY_ID = #{applyID}
- </select>
-
- <!-- 修改代理商信息 -->
- <update id="updatePlaceInfo" parameterType="PlaceInfo">
- UPDATE
- TB_IAMBERRY_PLACE_INFO
- SET
- PLACE_NAME = #{name},
- PLACE_AREA = #{areaName},
- PLACE_USERNAME = #{userName},
- PLACE_TEL = #{tel},
- PLACE_INFO_STATUS = 2,
- PLACE_ADDR = #{addr}
- WHERE
- PLACE_ID = #{id}
- </update>
-
- <!-- 保存申请记录信息 -->
- <insert id="insertApplyLogs" parameterType="ApplyPlaceLogs">
- INSERT INTO
- TB_IAMBERRY_PLACE_APPLY_LOGS
- (
- APPLY_OPENID , APPLY_TO_PLACEID ,
- APPLY_NAME , APPLY_USERNAME , APPLY_TEL ,
- APPLY_AREA , APPLY_DATE, APPLY_STATUS, APPLY_ADDR
- )
- VALUES
- (
- #{applyOpenID}, #{applyToPlaceID}, #{applyName},
- #{applyUserName}, #{applyTel}, #{applyArea}, NOW(),
- 1, #{applyAddr}
- )
- </insert>
-
- <!-- 获取商户详情 -->
- <select id="selectPlaceInfoDetailByOpenId" resultType="PlaceInfo" parameterType="String">
- SELECT
- p.PLACE_ID id,
- u.USER_HEAD userHead,
- u.USER_NICKNAME userNickname,
- (select role_name from tb_iamberry_place_role where role_id=Place_role_id ) as roleName,
- p.PLACE_USERNAME userName,
- p.PLACE_TEL tel,
- p.PLACE_NAME name,
- p.PLACE_AREA areaName,
- p.PLACE_ADDR addr,
- p.PLACE_INFO_STATUS placeInfoStus
- FROM TB_IAMBERRY_PLACE_INFO p JOIN tb_iamberry_user_userinfo u ON p.place_openid=u.user_openid
- WHERE p.PLACE_OPENID = #{openid} and p.PLACE_STATUS=1
- </select>
- </mapper>
|