zhijiezhao 2 роки тому
батько
коміт
ed3ca3dbe6
1 змінених файлів з 153 додано та 78 видалено
  1. 153 78
      src/main/resources/mapper/SellerMapper.xml

+ 153 - 78
src/main/resources/mapper/SellerMapper.xml

@@ -2,85 +2,85 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei365.user.mapper.SellerMapper">
     <select id="getLoginSellerByMobile" resultType="com.caimei365.user.model.vo.UserLoginVo">
-        select u.userID as userId,
-            u.clubID as clubId,
-            u.shopID as shopId,
-            u.userName as userName,u.name as name,
-            u.mobile as mobile,
-            u.bindMobile as bindMobile,
-            u.email as email,
-            u.guideFlag as guideFlag,
-            u.userPermission as userPermission,
-            u.userIdentity as userIdentity,
-            u.password as password
+        select u.userID         as userId,
+               u.clubID         as clubId,
+               u.shopID         as shopId,
+               u.userName       as userName,
+               u.name           as name,
+               u.mobile         as mobile,
+               u.bindMobile     as bindMobile,
+               u.email          as email,
+               u.guideFlag      as guideFlag,
+               u.userPermission as userPermission,
+               u.userIdentity   as userIdentity,
+               u.password       as password
         from user u
-        where
-          u.mobile = #{mobile}
+        where u.mobile = #{mobile}
           and u.userIdentity = 1
           and u.userPermission = 4
           and u.validFlag = 1
     </select>
     <update id="updateServiceProviderByUserId">
         update serviceprovider
-        set openid = #{openId}, unionId = #{unionId}
+        set openid  = #{openId},
+            unionId = #{unionId}
         where userID = #{userId}
     </update>
 
     <select id="findClubTemporary" resultType="com.caimei365.user.model.vo.ClubTemporaryVo">
         SELECT
-          `id`,
-          `userId`,
-          `name`,
-          `shortName`,
-          `bindMobile`,
-          `contractEmail`,
-          `linkMan`,
-          `provinceId`,
-          `cityId`,
-          `townId`,
-          `address`,
-          `shopPhoto`,
-          `businessLicense`,
-          `socialCreditCode`,
-          `firstClubType`,
-          `secondClubType`,
-          `department`,
-          `medicalPracticeLicense`,
-          `mainProduct`,
-          `isAgreed`
+        `id`,
+        `userId`,
+        `name`,
+        `shortName`,
+        `bindMobile`,
+        `contractEmail`,
+        `linkMan`,
+        `provinceId`,
+        `cityId`,
+        `townId`,
+        `address`,
+        `shopPhoto`,
+        `businessLicense`,
+        `socialCreditCode`,
+        `firstClubType`,
+        `secondClubType`,
+        `department`,
+        `medicalPracticeLicense`,
+        `mainProduct`,
+        `isAgreed`
         FROM
-          club_temporary
+        club_temporary
         WHERE
-          userId = #{userId}
-          <if test="searchName != null and searchName != ''">
-              AND (name LIKE CONCAT('%',#{searchName},'%') OR linkMan LIKE CONCAT('%',#{searchName},'%'))
-          </if>
+        userId = #{userId}
+        <if test="searchName != null and searchName != ''">
+            AND (name LIKE CONCAT('%',#{searchName},'%') OR linkMan LIKE CONCAT('%',#{searchName},'%'))
+        </if>
         ORDER BY
-          id DESC
+        id DESC
     </select>
 
     <update id="updateClubTemporary">
         UPDATE
-          `club_temporary`
-        SET
-          `name` = #{name},
-          `shortName` = #{shortName},
-          `bindMobile` = #{bindMobile},
-          `contractEmail` = #{contractEmail},
-          `linkMan` = #{linkMan},
-          `provinceId` = #{provinceId},
-          `cityId` = #{cityId},
-          `townId` = #{townId},
-          `address` = #{address},
-          `shopPhoto` = #{shopPhoto},
-          `businessLicense` = #{businessLicense},
-          `socialCreditCode` = #{socialCreditCode},
-          `firstClubType` = #{firstClubType},
-          `secondClubType` = #{secondClubType},
-          `department` = #{department},
-          `medicalPracticeLicense` = #{medicalPracticeLicense},
-          `mainProduct` = #{mainProduct},
-          `isAgreed` = #{isAgreed}
+            `club_temporary`
+        SET `name`                   = #{name},
+            `shortName`              = #{shortName},
+            `bindMobile`             = #{bindMobile},
+            `contractEmail`          = #{contractEmail},
+            `linkMan`                = #{linkMan},
+            `provinceId`             = #{provinceId},
+            `cityId`                 = #{cityId},
+            `townId`                 = #{townId},
+            `address`                = #{address},
+            `shopPhoto`              = #{shopPhoto},
+            `businessLicense`        = #{businessLicense},
+            `socialCreditCode`       = #{socialCreditCode},
+            `firstClubType`          = #{firstClubType},
+            `secondClubType`         = #{secondClubType},
+            `department`             = #{department},
+            `medicalPracticeLicense` = #{medicalPracticeLicense},
+            `mainProduct`            = #{mainProduct},
+            `isAgreed`               = #{isAgreed}
         WHERE `id` = #{id}
     </update>
 
@@ -104,11 +104,13 @@
     </select>
 
     <select id="findClubs" resultType="com.caimei365.user.model.vo.ClubVo">
-        select DISTINCT c.clubID as clubId, c.userID as userId, c.name, c.sname as shortName, c.contractMobile, c.contractEmail as contractEmail,
+        select DISTINCT c.clubID as clubId, c.userID as userId, c.name, c.sname as shortName, c.contractMobile,
+        c.contractEmail as contractEmail,
         c.contractPhone, c.linkMan, c.provinceID as proviceId, c.cityID as cityId, c.townID as townId,
         c.address, c.headpic as shopPhoto, c.businessLicenseImage as businessLicense, c.socialCreditCode,
         c.firstClubType, c.secondClubType, c.department, c.medicalPracticeLicenseImg as medicalPracticeLicense,
-        c.mainpro as mainProduct, c.fax, c.info as profile, c.spID as serviceProviderId, c.addTime, c.status, c.lastCheckOrderDate,
+        c.mainpro as mainProduct, c.fax, c.info as profile, c.spID as serviceProviderId, c.addTime, c.status,
+        c.lastCheckOrderDate,
         u.userIdentity,c.newDeal as newDeal,IF(r.id IS NOT NULL,1,0) AS recordCount,
         covs.activeState AS activeState,
         covs.customerValue AS customerValue
@@ -116,7 +118,20 @@
         left join user u on c.userID = u.userID
         LEFT JOIN record_link r ON r.`clubId`=c.`clubID`
         LEFT JOIN cm_organ_value_system covs ON covs.userID = u.userID
-        where c.spID = #{serviceProviderId}
+        where
+        <if test="1 == type">
+            c.spID = #{serviceProviderId}
+        </if>
+        <if test="2 == type">
+            c.spID in
+            <foreach collection="serviceIds" item="id" index="index" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
+        <if test="3 == type">
+            r.clubId IS NOT NULL
+            AND c.spId=1342
+        </if>
         <if test="status != null and status != 66">
             AND c.status = #{status}
         </if>
@@ -132,11 +147,13 @@
         order by c.clubID desc
     </select>
     <select id="getAllClubList" resultType="com.caimei365.user.model.vo.ClubVo">
-        SELECT DISTINCT c.clubID as clubId, c.userID as userId, c.name, c.sname as shortName, c.contractMobile, c.contractEmail as contractEmail,
+        SELECT DISTINCT c.clubID as clubId, c.userID as userId, c.name, c.sname as shortName, c.contractMobile,
+        c.contractEmail as contractEmail,
         c.contractPhone, c.linkMan, c.provinceID as proviceId, c.cityID as cityId, c.townID as townId,
         c.address, c.headpic as shopPhoto, c.businessLicenseImage as businessLicense, c.socialCreditCode,
         c.firstClubType, c.secondClubType, c.department, c.medicalPracticeLicenseImg as medicalPracticeLicense,
-        c.mainpro as mainProduct, c.fax, c.info as profile, c.spID as serviceProviderId, c.addTime, c.status, c.lastCheckOrderDate,
+        c.mainpro as mainProduct, c.fax, c.info as profile, c.spID as serviceProviderId, c.addTime, c.status,
+        c.lastCheckOrderDate,
         u.userIdentity
         FROM club c
         LEFT JOIN user u ON c.userID=u.userID
@@ -150,26 +167,84 @@
         </if>
     </select>
     <select id="getSellerByUserId" resultType="com.caimei365.user.model.po.ServiceProviderPo">
-        select serviceProviderID AS serviceProviderId, status, userID AS userId, openid, unionId, name, contractMobile,
-               linkMan, duty, contractEmail, auditStatus, auditTime, auditNote, validFlag, addTime,
+        select serviceProviderID     AS serviceProviderId,
+               status,
+               userID                AS userId,
+               openid,
+               unionId,
+               name,
+               contractMobile,
+               linkMan,
+               duty,
+               contractEmail,
+               auditStatus,
+               auditTime,
+               auditNote,
+               validFlag,
+               addTime,
                mainServiceProviderID AS mainServiceProviderId
-        from serviceprovider where userID = #{userId}
+        from serviceprovider
+        where userID = #{userId}
     </select>
     <select id="findManager" resultType="java.lang.Integer">
-        SELECT IF(csm.serviceProviderId IS NULL,2,1) AS manager FROM  cm_serviceteam_manager csm
-        LEFT JOIN serviceprovider s ON csm.serviceProviderId = s.serviceProviderId
-        LEFT JOIN USER u ON s.userId = u.userId
-        WHERE u.bindmobile = #{mobile} OR u.mobile = #{mobile}
+        SELECT IF(csm.serviceProviderId IS NULL, 2, 1) AS manager
+        FROM cm_serviceteam_manager csm
+                 LEFT JOIN serviceprovider s ON csm.serviceProviderId = s.serviceProviderId
+                 LEFT JOIN USER u ON s.userId = u.userId
+        WHERE u.bindmobile = #{mobile}
+           OR u.mobile = #{mobile}
     </select>
     <select id="findManagerByUser" resultType="java.lang.Integer">
-        SELECT IF(csm.serviceProviderId IS NULL,2,1) AS manager
-        FROM  cm_serviceteam_manager csm
-        LEFT JOIN serviceprovider s ON csm.serviceProviderId = s.serviceProviderId
-        WHERE s.userID  = #{userId}
+        SELECT IF(csm.serviceProviderId IS NULL, 2, 1) AS manager
+        FROM cm_serviceteam_manager csm
+                 LEFT JOIN serviceprovider s ON csm.serviceProviderId = s.serviceProviderId
+        WHERE s.userID = #{userId}
     </select>
     <select id="findLeaderId" resultType="java.lang.Integer">
-        SELECT leaderId FROM cm_serviceteam_role csr
-        LEFT JOIN serviceprovider s ON s.serviceProviderId=csr.leaderId
+        SELECT leaderId
+        FROM cm_serviceteam_role csr
+                 LEFT JOIN serviceprovider s ON s.serviceProviderId = csr.leaderId
         WHERE s.userId = #{userId}
     </select>
+    <select id="findLeaderIdByServiceId" resultType="java.lang.Integer">
+        select leaderId
+        FROM cm_serviceteam_role
+        WHERE leaderId = #{serviceProviderId}
+    </select>
+    <select id="findmanagerIdByServiceId" resultType="java.lang.Integer">
+        SELECT serviceProviderId
+        FROM cm_serviceteam_manager
+        where serviceProviderId = #{serviceProviderId}
+    </select>
+    <select id="findServiceIds" resultType="java.lang.Integer">
+        SELECT csg.serviceId
+        FROM cm_serviceteam_group csg
+                 LEFT JOIN cm_serviceteam_role csr ON csr.id = csg.teamId
+        WHERE csr.leaderId = #{serviceProviderId}
+          AND csg.serviceId != #{serviceProviderId}
+    </select>
+    <select id="findAllServiceIds" resultType="java.lang.Integer">
+        SELECT csg.serviceId
+        FROM cm_serviceteam_group csg
+        WHERE csg.serviceId != #{serviceProviderId}
+    </select>
+    <select id="findServices" resultType="com.caimei365.user.model.vo.ServiceProviderVo">
+        SELECT csg.serviceId as serviceProviderId,s.linkMan as name
+        FROM cm_serviceteam_group csg
+        LEFT JOIN cm_serviceteam_role csr ON csr.id=csg.teamId
+        left join serviceprovider s on csg.serviceId=s.serviceProviderID
+        WHERE csr.leaderId = #{spId}
+        <if test="status == 1">
+            AND csg.serviceId != #{spId}
+        </if>
+    </select>
+    <select id="findAllServices" resultType="com.caimei365.user.model.vo.ServiceProviderVo">
+        SELECT csg.serviceId AS serviceProviderId,s.linkMan AS NAME
+        FROM cm_serviceteam_group csg
+        LEFT JOIN serviceprovider s ON csg.serviceId=s.serviceProviderID
+        <if test="status == 1">
+            WHERE csg.serviceId != #{spId}
+        </if>
+    </select>
+
 </mapper>