123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384 |
- <?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.mapper.cmMapper.ShopMapper">
- <insert id="insertStatementFile" keyColumn="id" keyProperty="id" useGeneratedKeys="true" parameterType="com.caimei.model.po.CmBrandAuthFilePo">
- insert into cm_brand_auth_file (`authUserId`, `brandId`, `name`, `ossName`, `md5Hex`, `uploadTime`)
- values (#{authUserId}, #{brandId}, #{name}, #{ossName}, #{md5Hex}, #{uploadTime})
- </insert>
- <insert id="insertShop" keyColumn="authUserId" keyProperty="authUserId" useGeneratedKeys="true" parameterType="com.caimei.model.po.UserPo">
- insert into cm_brand_auth_user (`name`, `mobile`, `password`, `linkMan`, `userIdentity`, `shopType`, `logo`, `qrCodeImage`, `wxAccountType`, `appId`, `appSecret`, `createTime`,
- `createBy`,`status`)
- values (#{name}, #{mobile}, #{password}, #{linkMan}, #{userIdentity}, #{shopType}, #{logo}, #{qrCodeImage}, #{wxAccountType}, #{appId}, #{appSecret}, #{createTime}, #{createBy}, #{status});
- </insert>
- <insert id="insertShopInfo">
- insert into cm_brand_auth_shop_info
- <trim prefix="(" suffix=")" suffixOverrides=",">
- authUserId,brandId,countryId,securityLink,
- <if test="statementType != null">
- statementType,
- </if>
- <if test="statementContent != null and statementContent != ''">
- statementContent,
- </if>
- <if test="statementLink != null and statementLink != ''">
- statementLink,
- </if>
- <if test="statementImage != null and statementImage != ''">
- statementImage,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- #{authUserId},#{brandId},#{countryId},#{securityLink},
- <if test="statementType != null">
- #{statementType},
- </if>
- <if test="statementContent != null and statementContent != ''">
- #{statementContent},
- </if>
- <if test="statementLink != null and statementLink != ''">
- #{statementLink},
- </if>
- <if test="statementImage != null and statementImage != ''">
- #{statementImage},
- </if>
- </trim>
- </insert>
- <update id="updateShopStatusByUserId">
- update cm_brand_auth_user
- set status = #{status}
- where authUserId = #{authUserId};
- </update>
- <update id="updateBrandAuthLogo">
- update cm_brand
- set authLogo = #{brandAuthLogo}
- where id = #{brandId}
- </update>
- <update id="updateFileUserId">
- update cm_brand_auth_file
- set authUserId =#{authUserId}
- where id = #{statementFileId};
- </update>
- <update id="updateShopByUserId">
- update cm_brand_auth_user
- set `mobile` = #{mobile},
- `linkMan` = #{linkMan},
- `status` = #{status},
- `logo` = #{logo},
- `qrCodeImage` = #{qrCodeImage},
- `wxAccountType` = #{wxAccountType},
- `appId` = #{appId},
- `appSecret` = #{appSecret}
- where authUserId = #{authUserId}
- </update>
- <update id="updateShopInfo">
- update cm_brand_auth_shop_info
- <set>
- countryId=#{countryId},securityLink = #{securityLink},
- <if test="statementType != null">
- statementType = #{statementType},
- </if>
- <if test="statementContent != null and statementContent != ''">
- statementContent = #{statementContent},
- </if>
- <if test="statementLink != null and statementLink != ''">
- statementLink = #{statementLink},
- </if>
- <if test="statementImage != null and statementImage != ''">
- statementImage = #{statementImage},
- </if>
- </set>
- where authUserId = #{authUserId} and brandId = #{brandId}
- </update>
- <update id="handleFeedback">
- update cm_brand_club_feedback
- set handleResult = #{handleResult},
- handleStatus = 1,
- handleTime = NOW()
- where id = #{feedbackId}
- </update>
- <update id="updateShopMobile">
- update cm_brand_auth_user
- set mobile = #{newMobile}
- where authUserId = #{authUserId}
- </update>
- <update id="bindLoginAccount">
- update cm_brand_auth_user
- set loginAccount = #{loginAccount}
- where authUserId = #{authUserId}
- </update>
- <delete id="deleteStatementFile">
- delete from cm_brand_auth_file where id = #{id}
- </delete>
- <delete id="deleteShopInfoById">
- delete from cm_brand_auth_shop_info where id = #{infoId}
- </delete>
- <select id="getShopList" resultType="com.caimei.model.vo.ShopListVo">
- select u.authUserId,u.name,u.loginAccount,u.shopType,group_concat(cb.name) as brandName,group_concat(cb.id) as brandId,
- u.mobile,u.linkMan,u.status as shopStatus,u.createTime,
- (select au.name from cm_brand_auth_user au where au.authUserId = u.createBy) as createBy,
- (ifnull(aw.authWaitNum,0)+ifnull(pw.productWaitNum,0)) as waitAuditNum,
- ifnull(arw.articleWaitNum,0) as articleWaitNum,
- ifnull(iw.imageWaitNum,0) as imageWaitNum,
- ifnull(vw.videoWaitNum,0) as videoWaitNum,
- ifnull(fw.fileWaitNum,0) as fileWaitNum,
- ifnull(zw.zipWaitNum,0) as zipWaitNum,
- ifnull(dw.doctorWaitNum,0) as doctorWaitNum,
- ifnull(tw.productTypeWaitNum,0) as productTypeWaitNum
- from cm_brand_auth_user u
- left join cm_brand_auth_shop_info s on u.authUserId = s.authUserId
- left join cm_brand cb on cb.id = s.brandId
- left join (select authUserId, count(*) as authWaitNum from cm_brand_auth where auditStatus = 2 and shopAuditStatus = 1 group by authUserId) aw on u.authUserId = aw.authUserId
- left join (select a.authUserId, count(*) as productWaitNum from cm_brand_auth_product p left join cm_brand_auth a on p.authId = a.id
- where p.auditStatus = 2 and p.shopAuditStatus = 1 group by a.authUserId) pw on u.authUserId = pw.authUserId
- left join (select authUserId, count(*) as articleWaitNum from cm_brand_article where auditStatus = 2 group by authUserId) arw on u.authUserId = arw.authUserId
- left join (select authUserId, count(*) as imageWaitNum from cm_brand_image where auditStatus = 2 group by authUserId) iw on u.authUserId = iw.authUserId
- left join (select authUserId, count(*) as videoWaitNum from cm_brand_video where auditStatus = 2 group by authUserId) vw on u.authUserId = vw.authUserId
- left join (select authUserId, count(*) as fileWaitNum from cm_brand_file where auditStatus = 2 and fileType = 1 group by authUserId) fw on u.authUserId = fw.authUserId
- left join (select authUserId, count(*) as zipWaitNum from cm_brand_file where auditStatus = 2 and fileType = 2 group by authUserId) zw on u.authUserId = zw.authUserId
- left join (select authUserId, count(*) as doctorWaitNum from cm_brand_doctor where auditStatus = 2 group by authUserId) dw on u.authUserId = dw.authUserId
- left join (select authUserId, count(*) as productTypeWaitNum from cm_brand_product_type where auditStatus = 2 group by authUserId) tw on u.authUserId = tw.authUserId
- left join (select authUserId, count(*) as waitSendNum from cm_brand_auth where auditStatus = 2 and sendStatus = 0 group by authUserId) sw on u.authUserId = sw.authUserId
- where u.userIdentity = 2
- <if test="shopName != null and shopName !=''">
- AND u.name like CONCAT('%',#{shopName},'%')
- </if>
- <if test="listType == 5">
- AND u.status = 1
- </if>
- <if test="loginAccount != null and loginAccount != ''">
- AND u.loginAccount like CONCAT('%',#{loginAccount},'%')
- </if>
- <if test="shopType != null ">
- AND u.shopType = #{shopType}
- </if>
- <if test="brandId != null">
- AND s.brandId = #{brandId}
- </if>
- <if test="mobile != null and mobile !=''">
- AND u.mobile like CONCAT('%',#{mobile},'%')
- </if>
- <if test="linkMan != null and linkMan !=''">
- AND u.linkMan like CONCAT('%',#{linkMan},'%')
- </if>
- <if test="sendStatus != null">
- <if test="0 == sendStatus">
- and ifnull(sw.waitSendNum,0) > 0
- </if>
- <if test="1 == sendStatus">
- and ifnull(sw.waitSendNum,0) = 0
- </if>
- </if>
- <if test="lowerAuditStatus != null">
- <if test="0 == lowerAuditStatus">
- <if test="listType == 2">
- and (ifnull(aw.authWaitNum,0)+ifnull(pw.productWaitNum,0)) > 0
- </if>
- <if test="listType == 3">
- and (ifnull(articleWaitNum,0) + ifnull(imageWaitNum,0) + ifnull(videoWaitNum,0) + ifnull(fileWaitNum,0) + ifnull(zipWaitNum,0)) > 0
- </if>
- <if test="listType == 4">
- and ifnull(dw.doctorWaitNum,0) > 0
- </if>
- <if test="listType == 6">
- and ifnull(tw.productTypeWaitNum,0) > 0
- </if>
- </if>
- <if test="1 == lowerAuditStatus">
- <if test="listType == 2">
- and (ifnull(aw.authWaitNum,0)+ifnull(pw.productWaitNum,0)) = 0
- </if>
- <if test="listType == 3">
- and (ifnull(articleWaitNum,0) + ifnull(imageWaitNum,0) + ifnull(videoWaitNum,0) + ifnull(fileWaitNum,0) + ifnull(zipWaitNum,0)) = 0
- </if>
- <if test="listType == 4">
- and ifnull(dw.doctorWaitNum,0) = 0
- </if>
- <if test="listType == 6">
- and ifnull(tw.productTypeWaitNum,0) = 0
- </if>
- </if>
- </if>
- group by u.authUserId,u.createTime
- <choose>
- <when test="listType == 2">
- ORDER BY waitAuditNum desc, u.createTime DESC
- </when>
- <when test="listType == 3">
- ORDER BY (ifnull(articleWaitNum,0) + ifnull(imageWaitNum,0) + ifnull(videoWaitNum,0) + ifnull(fileWaitNum,0) + ifnull(zipWaitNum,0)) desc, u.createTime DESC
- </when>
- <when test="listType == 4">
- ORDER BY ifnull(dw.doctorWaitNum,0) desc, u.createTime DESC
- </when>
- <when test="listType == 6">
- ORDER BY ifnull(tw.productTypeWaitNum,0) desc, u.createTime DESC
- </when>
- <otherwise>
- ORDER BY u.createTime DESC
- </otherwise>
- </choose>
- </select>
- <select id="getShopMobileByUserId" resultType="java.lang.String">
- select mobile from cm_brand_auth_user where authUserId = #{authUserId}
- </select>
- <select id="getStatementFile" resultType="com.caimei.model.po.CmBrandAuthFilePo">
- select id, authUserId, name, ossName, md5Hex, uploadTime
- from cm_brand_auth_file
- <where>
- <if test="id != null">
- and id = #{id}
- </if>
- <if test="authUserId != null">
- and authUserId = #{authUserId}
- </if>
- <if test="brandId != null">
- and brandId = #{brandId}
- </if>
- <if test="md5Hex != null and md5Hex != ''">
- and md5Hex = #{md5Hex}
- </if>
- </where>
- limit 1
- </select>
- <select id="getFileNumByMd5Hex" resultType="java.lang.Integer">
- select count(*) from cm_brand_auth_file where md5Hex = #{md5Hex}
- </select>
- <select id="getShopByUserId" resultType="com.caimei.model.vo.ShopFormVo">
- select u.authUserId, u.name as shopName, u.loginAccount, u.mobile, u.linkMan, u.status as shopStatus, u.shopType as shopType,
- u.wxAccountType, u.logo, u.qrCodeImage, u.appId, u.appSecret,
- if(avu.id is null, 3, (if(NOW() <![CDATA[<]]> avu.endTime, 1, 0))) as vipStatus
- from cm_brand_auth_user u
- left join auth_vip_user avu on u.authUserId = avu.authUserId
- where u.authUserId = #{authUserId};
- </select>
- <select id="getBrandList" resultType="com.caimei.model.vo.BrandVo">
- select id,name,authLogo from cm_brand
- <where>
- <if test="type == 1">
- id not in (select brandId
- from cm_brand_auth_shop_info i
- left join cm_brand_auth_user u on i.authUserId= u.authUserId
- where u.shopType = 1 and i.brandId is not null);
- </if>
- <if test="type == 3">
- id in (select brandId
- from cm_brand_auth_shop_info
- where authUserId = #{authUserId})
- </if>
- </where>
- </select>
- <select id="getCountryList" resultType="com.caimei.model.vo.CountryVo">
- select countryId, name as countryName
- from country
- where validFlag = 1
- </select>
- <select id="getUserIdByMobile" resultType="java.lang.Integer">
- select authUserId from cm_brand_auth_user where mobile = #{mobile} and userIdentity = 2 limit 1
- </select>
- <select id="getDbInfoBrandList" resultType="com.caimei.model.vo.ShopBrandVo">
- select id, brandId
- from cm_brand_auth_shop_info
- where authUserId = #{authUserId}
- </select>
- <select id="getShopInfoByUserId" resultType="com.caimei.model.vo.ShopInfoVo">
- select i.brandId,
- i.countryId,
- i.securityLink,
- i.statementType,
- i.statementContent,
- i.statementLink,
- i.statementImage,
- f.id as statementFileId,
- f.name as statementFileName,
- b.name as brandName,
- b.authLogo as brandAuthLogo
- from cm_brand_auth_shop_info i
- left join cm_brand b on i.brandId = b.id
- left join cm_brand_auth_file f on i.authUserId = f.authUserId and i.brandId = f.brandId
- where i.authUserId = #{authUserId}
- </select>
- <select id="getUserIdByShopName" resultType="java.lang.Integer">
- select authUserId from cm_brand_auth_user where name = #{shopName} and userIdentity = 2 limit 1
- </select>
- <select id="getAuthWaitAuditNum" resultType="java.lang.Integer">
- select count(*)
- from cm_brand_auth
- where authUserId = #{authUserId}
- and auditStatus = 2
- </select>
- <select id="getProductWaitAuditNum" resultType="java.lang.Integer">
- select count(*)
- from cm_brand_auth_product p
- left join cm_brand_auth a on p.authId = a.id
- where a.authUserId = #{authUserId}
- and p.auditStatus = 2
- </select>
- <select id="getProductCount" resultType="java.lang.Integer">
- select count(*)
- from cm_brand_auth a
- left join cm_brand_auth_product p on p.authId = a.id
- where a.authUserId = #{authUserId} and p.brandId = #{brandId}
- </select>
- <select id="getFeedbackList" resultType="com.caimei.model.vo.FeedbackVo">
- select cf.id as feedbackId, a.authParty as clubName, cu.mobile, content, commitTime, handleStatus, handleResult,
- handleTime
- from cm_brand_club_feedback cf
- join cm_brand_club_user cu on cf.clubUserId = cu.id
- join cm_brand_auth a on cu.authId = a.id
- where a.authUserId = #{authUserId}
- <if test="clubName != null and clubName != ''">
- and a.authParty like concat('%',#{clubName},'%')
- </if>
- <if test="mobile != null and mobile != ''">
- and cu.mobile like concat('%',#{mobile},'%')
- </if>
- <if test="handleStatus != null">
- and cf.handleStatus = #{handleStatus}
- </if>
- </select>
- <select id="getFeedback" resultType="com.caimei.model.vo.FeedbackVo">
- select cf.id as feedbackId, a.authParty as clubName, cu.mobile, content, commitTime, handleStatus, handleResult, handleTime
- from cm_brand_club_feedback cf
- join cm_brand_club_user cu on cf.clubUserId = cu.id
- join cm_brand_auth a on cu.authId = a.id
- where cf.id = #{feedbackId}
- </select>
- <select id="getShopStatus" resultType="java.lang.Integer">
- select status
- from cm_brand_auth_user
- where authUserId = #{authUserId}
- </select>
- <select id="getUserIdByAppId" resultType="java.lang.Integer">
- select authUserId from cm_brand_auth_user where appId = #{appId} and userIdentity = 2 and appId is not null limit 1
- </select>
- <select id="getAppSecretByAppId" resultType="java.lang.String">
- select appSecret from cm_brand_auth_user where appId = #{appId} and status = 1
- </select>
- <select id="getAppId" resultType="java.lang.String">
- select appId from cm_brand_auth_user where authUserId = #{authUserId} and status = 1
- </select>
- <select id="getShopNameByAppId" resultType="java.lang.String">
- select name from cm_brand_auth_user where appId = #{appId} and status = 1
- </select>
- <select id="getShopBrands" resultType="java.lang.String">
- select b.name
- from cm_brand_auth_shop_info i
- left join cm_brand b on i.brandId = b.id
- where i.authUserId = #{authUserId}
- </select>
- <select id="getWxShopInfo" resultType="com.caimei.model.vo.WxShopVo">
- select au.authUserId, au.appId, au.name as shopName, if(au.shopType = 1, cb.authLogo, au.logo) as logo
- from cm_brand_auth_user au
- left join cm_brand_auth_shop_info si on au.authUserId = si.authUserId
- left join cm_brand cb on si.brandId = cb.id
- where au.authUserId = #{authUserId}
- and au.status = 1
- limit 1
- </select>
- <select id="getWxAccountTypeByAppId" resultType="java.lang.Integer">
- select wxAccountType from cm_brand_auth_user where appId = #{appId} and status = 1
- </select>
- <select id="getLoginAccount" resultType="java.lang.String">
- select loginAccount from cm_brand_auth_user where authUserId = #{authUserId}
- </select>
- </mapper>
|