123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543 |
- <?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.caimei.modules.user.dao.CmUserDao">
- <sql id="cmUserColumns">
- a.userID AS "userID",
- a.mobile AS "mobile",
- a.userOrganizeID AS "userOrganizeID",
- a.bindMobile AS "bindMobile",
- a.email AS "email",
- a.account AS "account",
- a.realName AS "realName",
- a.userIdentity AS "userIdentity",
- a.userName AS "userName",
- a.source AS "source",
- a.image AS "image",
- a.password AS "password",
- a.name AS "name",
- a.registerUserTypeID AS "registerUserTypeID",
- a.manufacturerStatus AS "manufacturerStatus",
- a.shopID AS "shopID",
- a.auditStatus AS "auditStatus",
- a.auditTime AS "auditTime",
- a.auditNote AS "auditNote",
- a.registerTime AS "registerTime",
- a.registerIP AS "registerIP",
- a.loginTime AS "loginTime",
- a.loginIP AS "loginIP",
- a.validFlag AS "validFlag",
- a.clubID AS "clubID",
- a.agreeFlag AS "agreeFlag",
- a.serviceProviderStatus AS "serviceProviderStatus",
- a.serviceProviderID AS "serviceProviderID",
- a.userMoney AS "userMoney",
- a.ableUserMoney as "ableUserMoney",
- a.scanFlag AS "scanFlag",
- a.userBeans AS "userBeans",
- a.guideFlag AS "guideFlag"
- </sql>
- <select id="get" resultType="CmUser">
- SELECT
- <include refid="cmUserColumns"/>
- FROM user a
- WHERE a.userID = #{id}
- </select>
- <select id="findList" resultType="CmUser">
- SELECT
- <include refid="cmUserColumns"/>
- FROM user a
- <where>
- <if test="userID != null and userID != ''">
- AND a.userID = #{userID}
- </if>
- <if test="mobile != null and mobile != ''">
- AND (a.mobile LIKE
- <if test="dbName == 'oracle'">'%'||#{mobile}||'%'</if>
- <if test="dbName == 'mssql'">'%'+#{mobile}+'%'</if>
- <if test="dbName == 'mysql'">concat('%',#{mobile},'%')</if>
- OR a.bindMobile LIKE
- <if test="dbName == 'oracle'">'%'||#{mobile}||'%'</if>
- <if test="dbName == 'mssql'">'%'+#{mobile}+'%'</if>
- <if test="dbName == 'mysql'">concat('%',#{mobile},'%')</if>
- )
- </if>
- <if test="email != null and email != ''">
- AND a.email LIKE
- <if test="dbName == 'oracle'">'%'||#{email}||'%'</if>
- <if test="dbName == 'mssql'">'%'+#{email}+'%'</if>
- <if test="dbName == 'mysql'">concat('%',#{email},'%')</if>
- </if>
- <if test="userName != null and userName != ''">
- AND a.userName LIKE
- <if test="dbName == 'oracle'">'%'||#{userName}||'%'</if>
- <if test="dbName == 'mssql'">'%'+#{userName}+'%'</if>
- <if test="dbName == 'mysql'">concat('%',#{userName},'%')</if>
- </if>
- <if test="startTime != null and startTime != ''">
- AND (a.registerTime > #{startTime} OR a.registerTime = #{startTime})
- </if>
- <if test="endTime != null and endTime != ''">
- AND (a.registerTime < #{endTime} OR a.registerTime = #{endTime})
- </if>
- <if test="userOrganizeID != null and userOrganizeID != ''">
- AND a.userOrganizeID = #{userOrganizeID}
- </if>
- <choose>
- <when test="registerUserTypeID != null and registerUserTypeID != ''">
- AND a.registerUserTypeID = #{registerUserTypeID}
- </when>
- <otherwise>
- AND a.registerUserTypeID IN (0,10,1,24,34,2,32,3,23,33)
- </otherwise>
- </choose>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY a.userID DESC
- </otherwise>
- </choose>
- </select>
- <!--适用于企业通过手机号码查询用户-->
- <select id="findListBuyBindMobile" resultType="com.caimei.modules.user.entity.CmUser">
- SELECT
- *
- FROM user a
- <where>
- a.bindMobile = #{bindMobile}
- <if test="clubID != null and clubID != ''">
- AND a.clubID != #{clubID}
- </if>
- </where>
- </select>
- <!--星范商城查询会所-->
- <select id="findListBuyUserInfo" resultType="com.caimei.modules.user.entity.CmUser">
- SELECT
- a.*
- ,c.linkMan AS "linkMan"
- ,t.name as "town"
- ,ci.name as "city"
- ,p.name as "province"
- ,c.address AS "address"
- FROM user a
- LEFT JOIN club c on c.userID = a.userID
- LEFT JOIN town t on t.townID = c.townID
- LEFT JOIN city ci ON ci.cityID = c.cityID
- LEFT JOIN province p ON p.provinceID = c.provinceID
- <where>
- a.userOrganizeID = #{userOrganizeID}
- <if test="bindMobile != null and bindMobile != ''">
- AND a.bindMobile LIKE concat('%',#{bindMobile},'%')
- </if>
- <if test="name != null and name != ''">
- AND a.name LIKE concat('%',#{name},'%')
- </if>
- <if test="linkMan != null and linkMan != ''">
- AND c.linkMan LIKE concat('%',#{linkMan},'%')
- </if>
- <if test="startTime != null and startTime != ''">
- AND a.registerTime <![CDATA[ >= ]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND a.registerTime <![CDATA[ <= ]]> #{endTime}
- </if>
- </where>
- ORDER BY a.registerTime DESC
- </select>
- <select id="findAllList" resultType="CmUser">
- SELECT
- <include refid="cmUserColumns"/>
- FROM user a
- <where>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY a.userID DESC
- </otherwise>
- </choose>
- </select>
- <insert id="insert" parameterType="CmUser" keyProperty="userID" useGeneratedKeys="true">
- INSERT INTO user(
- userOrganizeID,
- account,
- realName,
- userIdentity,
- mobile,
- bindMobile,
- email,
- userName,
- source,
- image,
- password,
- name,
- registerUserTypeID,
- manufacturerStatus,
- shopID,
- auditStatus,
- auditTime,
- auditNote,
- registerTime,
- registerIP,
- loginTime,
- loginIP,
- validFlag,
- <if test="clubID != null and clubID != ''">
- clubID,
- </if>
- agreeFlag,
- serviceProviderStatus,
- serviceProviderID,
- userMoney,
- ableUserMoney,
- scanFlag,
- userBeans
- ) VALUES (
- #{userOrganizeID},
- #{account},
- #{realName},
- #{userIdentity},
- #{mobile},
- #{bindMobile},
- #{email},
- #{userName},
- #{source},
- #{image},
- #{password},
- #{name},
- #{registerUserTypeID},
- #{manufacturerStatus},
- #{shopID},
- #{auditStatus},
- #{auditTime},
- #{auditNote},
- #{registerTime},
- #{registerIP},
- #{loginTime},
- #{loginIP},
- #{validFlag},
- <if test="clubID != null and clubID != ''">
- #{clubID},
- </if>
- #{agreeFlag},
- #{serviceProviderStatus},
- #{serviceProviderID},
- #{userMoney},
- #{ableUserMoney},
- #{scanFlag},
- #{userBeans}
- )
- </insert>
- <update id="update">
- UPDATE user SET
- <if test="account != null and account != ''">
- account = #{account},
- </if>
- <if test="bindMobile != null and bindMobile != ''">
- bindMobile = #{bindMobile},
- </if>
- <if test="realName != null">
- realName = #{realName},
- </if>
- <if test="userIdentity != null and userIdentity != ''">
- userIdentity = #{userIdentity},
- </if>
- <if test="mobile != null and mobile != ''">
- mobile = #{mobile},
- </if>
- <if test="email != null and email != ''">
- email = #{email},
- </if>
- <if test="userName != null and userName != ''">
- userName = #{userName},
- </if>
- <if test="image != null and image != ''">
- image = #{image},
- </if>
- <if test="password != null and password != ''">
- password = #{password},
- </if>
- <if test="name != null and name != ''">
- name = #{name},
- </if>
- <if test="registerUserTypeID != null and registerUserTypeID != ''">
- registerUserTypeID = #{registerUserTypeID},
- </if>
- <if test="manufacturerStatus != null and manufacturerStatus != ''">
- manufacturerStatus = #{manufacturerStatus},
- </if>
- <if test="shopID != null and shopID != ''">
- shopID = #{shopID},
- </if>
- <if test="auditStatus != null and auditStatus != ''">
- auditStatus = #{auditStatus},
- </if>
- <if test="auditTime != null">
- auditTime = #{auditTime},
- </if>
- <if test="auditNote != null and auditNote != ''">
- auditNote = #{auditNote},
- </if>
- <if test="registerTime != null ">
- registerTime = #{registerTime},
- </if>
- <if test="registerIP != null and registerIP != ''">
- registerIP = #{registerIP},
- </if>
- <if test="loginTime != null and loginTime != ''">
- loginTime = #{loginTime},
- </if>
- <if test="loginIP != null and loginIP != ''">
- loginIP = #{loginIP},
- </if>
- <if test="validFlag != null and validFlag != ''">
- validFlag = #{validFlag},
- </if>
- <if test="clubID != null and clubID != ''">
- clubID = #{clubID},
- </if>
- <if test="agreeFlag != null and agreeFlag != ''">
- agreeFlag = #{agreeFlag},
- </if>
- <if test="serviceProviderStatus != null and serviceProviderStatus != ''">
- serviceProviderStatus = #{serviceProviderStatus},
- </if>
- <if test="serviceProviderID != null and serviceProviderID != ''">
- serviceProviderID = #{serviceProviderID},
- </if>
- <if test="userMoney != null and userMoney != ''">
- userMoney = #{userMoney},
- </if>
- <if test="userBeans != null and userBeans != ''">
- userBeans = #{userBeans},
- </if>
- <if test="guideFlag != null and guideFlag != ''">
- guideFlag = #{guideFlag},
- </if>
- userID = #{userID}
- WHERE userID = #{userID}
- </update>
- <delete id="delete">
- DELETE
- FROM user
- WHERE userID = #{userID}
- </delete>
- <select id="findUserByRegisterType" resultType="CmUser">
- SELECT
- <include refid="cmUserColumns"/>
- FROM user
- <where>
- registerUserTypeID = #{registerUserTypeID}
- </where>
- </select>
- <select id="findAllPersonalUser" resultType="CmUser">
- SELECT
- <include refid="cmUserColumns"/>
- FROM user
- <where>
- registerUserTypeID IN (0,5,10,24,34,2,32,23,33)
- </where>
- </select>
- <select id="findByCompanyUserID" resultType="CmUser">
- SELECT
- <include refid="cmUserColumns"/>
- FROM user a
- WHERE a.userID != #{companyUserID}
- ORDER BY case when registerUserTypeID in (1,2,3) then 1 else 0 end ,
- case when registerUserTypeID in (24,23) then 1 else 0 end ,
- case when auditStatus = 0 then 1 else 0 end ,
- auditTime DESC
- </select>
- <update id="updateUserStatus">
- UPDATE user
- <set>
- <if test="manufacturerStatus != null and manufacturerStatus != ''">
- manufacturerStatus = #{manufacturerStatus},
- </if>
- <if test="validFlag != null and validFlag != ''">
- validFlag = #{validFlag},
- </if>
- </set>
- WHERE userID = #{userID}
- </update>
- <update id="updateShopStatus">
- UPDATE shop
- <set>
- <if test="status != null and status != ''">
- status = #{status},
- </if>
- </set>
- WHERE userID = #{userID}
- </update>
- <update id="updateUserAudit">
- UPDATE user
- <set>
- <if test="auditStatus != null and auditStatus != ''">
- auditStatus = #{auditStatus},
- </if>
- <if test="auditNote != null and auditNote != ''">
- auditNote = #{auditNote},
- </if>
- <if test="manufacturerStatus != null and manufacturerStatus != ''">
- manufacturerStatus = #{manufacturerStatus},
- </if>
- <if test="auditTime != null and auditTime != ''">
- auditTime = #{auditTime},
- </if>
- <if test="validFlag != null and validFlag != ''">
- validFlag = #{validFlag},
- </if>
- </set>
- WHERE userID = #{userId}
- </update>
- <update id="updateShopAudit">
- UPDATE shop
- <set>
- <if test="auditStatus != null and auditStatus != ''">
- auditStatus = #{auditStatus},
- </if>
- <if test="auditNote != null and auditNote != ''">
- auditNote = #{auditNote},
- </if>
- <if test="manufacturerStatus != null and manufacturerStatus != ''">
- status = #{manufacturerStatus},
- </if>
- <if test="auditTime != null and auditTime != ''">
- auditTime = #{auditTime},
- </if>
- <if test="name != null and name != ''">
- checkMan = #{name},
- </if>
- </set>
- WHERE shopID = #{shopId}
- </update>
- <update id="updateUserInfo">
- UPDATE user
- SET realName = #{realName},
- name = #{name},
- userName = #{userName},
- bindMobile = #{bindMobile},
- email = #{email}
- WHERE userID = #{userID}
- </update>
- <update id="updateAbleUserMoney">
- UPDATE user
- SET ableUserMoney = #{ableUserMoney}
- WHERE userID = #{userId}
- </update>
- <update id="updateMoney">
- UPDATE user
- SET userMoney = #{userMoney},
- ableUserMoney = #{ableUserMoney}
- WHERE userID = #{userID}
- </update>
- <select id="findUserByMobile" resultType="com.caimei.modules.user.entity.CmUser">
- SELECT
- <include refid="cmUserColumns"/>
- FROM user a
- WHERE a.bindMobile=#{mobile}
- <if test="oldUserId !=null and oldUserId !=''">
- and a.userId!=#{oldUserId}
- </if>
- <if test="userIdentity !=null">
- and a.userIdentity=#{userIdentity}
- </if>
- limit 0,1
- </select>
- <select id="getUserPayOrder" resultType="com.caimei.po.neworder.CmShopOrder">
- select *
- from cm_shop_order
- where userID = #{userId}
- </select>
- <select id="selectByMobileOrEmail" resultType="com.caimei.modules.user.entity.CmUser">
- select u.*,cu.mobile as operatorMobile from user u
- left join cm_mall_operation_user cu on cu.userID = u.userID
- where (u.bindMobile = #{mobileOrEmail} or u.email = #{mobileOrEmail})
- AND u.userIdentity IN (1,2,3,4)
- AND u.userOrganizeID = 0
- <if test="source == 'www'">
- AND u.registerUserTypeID IN (1,3,4)
- </if>
- <if test="source == 'crm'">
- AND u.registerUserTypeID IN (1,2,3,32,4)
- </if>
- UNION
- select u.*,cu.mobile as operatorMobile from user u
- left join cm_mall_operation_user cu on cu.userID = u.userID
- where cu.mobile = #{mobileOrEmail}
- AND cu.delFlag != 1
- AND u.userIdentity IN (1,2,3,4)
- AND u.userOrganizeID = 0
- <if test="source == 'www'">
- AND u.registerUserTypeID IN (1,3,4)
- </if>
- <if test="source == 'crm'">
- AND u.registerUserTypeID IN (1,2,3,32,4)
- </if>
- </select>
- <update id="updateUserBeans">
- UPDATE USER
- SET userBeans = #{userBeans}
- WHERE userID = #{userID}
- </update>
- <select id="findUserByOrganizeId" resultType="com.caimei.modules.user.entity.CmUser">
- SELECT
- <include refid="cmUserColumns"/>
- FROM user a
- WHERE a.userOrganizeID=#{organizeId}
- limit 1
- </select>
- <select id="findUserBeans" resultType="java.lang.Integer">
- select userBeans
- from user
- where userID = #{userId}
- </select>
- <select id="selOrgan" resultType="com.caimei.modules.user.entity.CmOrganValueSystem">
- select *
- from cm_organ_value_system
- where userID = #{userId}
- and stage = 0
- limit 1
- </select>
- <select id="findUserIdentity" resultType="Integer">
- SELECT
- a.userIdentity AS "userIdentity"
- FROM user a
- WHERE a.userID = #{userID}
- </select>
- <insert id="insertOrgan">
- INSERT INTO cm_organ_value_system
- (userID, stage, delType)
- VALUES (#{userId}, 0, 1)
- </insert>
- </mapper>
|