|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- <?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.iformall.mapper.WxMerchantBUserMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxMerchantBUser">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
- <result column="phone" jdbcType="VARCHAR" property="phone"/>
- <result column="user_pwd" jdbcType="VARCHAR" property="userPwd"/>
- <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
- <result column="app_id" jdbcType="VARCHAR" property="appId"/>
- <result column="token" jdbcType="VARCHAR" property="token"/>
- <result column="expire_time" jdbcType="TIMESTAMP" property="expireTime"/>
- <result column="name" jdbcType="VARCHAR" property="name"/>
- <result column="status" jdbcType="INTEGER" property="status"/>
-
- <result column="is_admin" jdbcType="INTEGER" property="isAdmin"/>
- <result column="other_merchant" jdbcType="VARCHAR" property="otherMerchant"/>
-
- </resultMap>
-
- <sql id="allColumns">
- `id`,`tenant_id`,`parent_tenant_id`,`phone`,`user_pwd`,`merchant_id`,`create_date`,`update_date`,`app_id`,`token`,`expire_time`,`name`,`status`,`is_admin`,`other_merchant`
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1 = 1
-
- <if test=" null != id ">
- and `id` = #{id}
- </if>
-
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
-
- <if test=" null != phone ">
- and `phone` = #{phone}
- </if>
-
- <if test=" null != phoneLike ">
- and `phone` like concat('%', #{phoneLike},'%')
- </if>
-
- <if test=" null != userPwd ">
- and `user_pwd` like concat('%', #{userPwd},'%')
- </if>
-
- <if test=" null != merchantId ">
- and `merchant_id` = #{merchantId}
- </if>
-
- <if test=" null != createDate ">
- and `create_date` = #{createDate}
- </if>
-
- <if test=" null != updateDate ">
- and `update_date` = #{updateDate}
- </if>
-
- <if test=" null != appId ">
- and `app_id` like concat('%', #{appId},'%')
- </if>
-
- <if test=" null != token ">
- and `token` like concat('%', #{token},'%')
- </if>
-
- <if test=" null != expireTime ">
- and `expire_time` = #{expireTime}
- </if>
- <if test=" null != name ">
- and `name` = #{name}
- </if>
- <if test=" null != status ">
- and `status` = #{status}
- </if>
- <if test=" null != isAdmin ">
- and `is_admin` = #{isAdmin}
- </if>
- <if test=" null != otherMerchantId and '' != otherMerchantId">
- and json_search(other_merchant, 'one', #{otherMerchantId}) IS NOT NULL;
- </if>
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
-
- <if test=" null != merchantIds ">
- and merchant_id in
- <foreach collection="merchantIds" index="index" item="merchantIdItem" open="(" separator="," close=")">
- #{merchantIdItem}
- </foreach>
- </if>
-
- <if test=" null != sortColumns">order by ${sortColumns}</if>
-
- </sql>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxMerchantBUser" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_merchant_b_user
- <include refid="dynamicWhereConditions"/>
- </select>
-
- <select id="findMerchantIdListByIds" parameterType="com.iformall.domain.po.WxMerchantBUser" resultMap="BaseResultMap">
- select id, merchant_id
- from wx_merchant_b_user
- where `tenant_id` = #{tenantId}
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- </select>
-
- <select id="findMerchantIdList" parameterType="com.iformall.domain.po.WxMerchantBUser" resultType="Long">
- select distinct merchant_id
- from wx_merchant_b_user
- <include refid="dynamicWhereConditions"/>
- </select>
-
- <select id="findIdList" parameterType="com.iformall.domain.po.WxMerchantBUser" resultType="Long">
- select id
- from wx_merchant_b_user
- <include refid="dynamicWhereConditions"/>
- </select>
-
- <select id="findSimpleList" parameterType="com.iformall.domain.po.WxMerchantBUser" resultMap="BaseResultMap">
- select id,name,phone,merchant_id
- from wx_merchant_b_user
- where `tenant_id` = #{tenantId}
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- </select>
-
- <select id="findSelMerchantList" parameterType="com.iformall.domain.po.WxMerchantBUser" resultType="com.iformall.domain.vo.WxMerchantBuInfoVo">
- select
- mbu.tenant_id, mbu.parent_tenant_id, m.name tenant_name,
- mc.name merchant_name, mbu.id bu_user_id, mbu.merchant_id, mc.img_url
- from wx_merchant_b_user mbu, wx_merchant mc, wx_mall m
- <where> m.tenant_id = mbu.tenant_id
- and mbu.merchant_id = mc.id and mc.status = 1
- <if test=" null != appId ">
- and mbu.`app_id` = #{appId}
- </if>
- <if test=" null != phone ">
- and mbu.`phone` = #{phone}
- </if>
- <if test=" null != status ">
- and mbu.`status` = #{status}
- </if>
- </where>
- </select>
-
- <select id="findByToken" resultMap="BaseResultMap">
- select * from wx_merchant_b_user
- where `token` = #{token}
- </select>
-
- <update id="deleteOtherMerchant" parameterType="hashmap">
- update wx_merchant_b_user set other_merchant = JSON_REMOVE(other_merchant, replace(json_search(other_merchant, 'one', #{otherId}), '"', ''))
- where `tenant_id` = #{tenantId}
- and json_search(other_merchant, 'one', #{otherId}) IS NOT NULL;
- </update>
-
- <update id="addOtherMerchant" parameterType="hashmap">
- update wx_merchant_b_user set other_merchant = json_array_append(coalesce(other_merchant,'[]'), '$', #{otherId})
- where `tenant_id` = #{tenantId}
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- and json_search(other_merchant, 'one', #{otherId}) IS NULL;
- </update>
-
- </mapper>
|