mitao
2024-07-08 022a7ff7abf82cd2546e18071ade5228b4e2339f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?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.sinata.modular.member.dao.MemMerchantMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.sinata.modular.member.model.MemMerchant">
        <id column="id" property="id"/>
        <result column="create_time" property="createTime"/>
        <result column="merchant_name" property="merchantName"/>
        <result column="linkman" property="linkman"/>
        <result column="link_phone" property="linkPhone"/>
        <result column="user_id" property="userId"/>
        <result column="business_license" property="businessLicense"/>
        <result column="other_details" property="otherDetails"/>
        <result column="head_picture" property="headPicture"/>
        <result column="apply_des" property="applyDes"/>
        <result column="state" property="state"/>
        <result column="lock_time" property="lockTime"/>
        <result column="unlock_time" property="unlockTime"/>
        <result column="audit_state" property="auditState"/>
        <result column="audit_time" property="auditTime"/>
        <result column="audit_mark" property="auditMark"/>
        <result column="is_delete" property="isDelete"/>
        <result column="grade_id" property="gradeId"/>
        <result column="logo" property="logo"/>
        <result column="im_account" property="imAccount"/>
        <result column="im_password" property="imPassword"/>
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, create_time, merchant_name, linkman, link_phone, user_id, business_license, other_details, head_picture, apply_des, state, lock_time, unlock_time, audit_state, audit_time, audit_mark, is_delete, grade_id, logo, im_account, im_password
    </sql>
 
    <select id="findMerchantGoodsCount" resultType="int">
        SELECT SUM(num)
        FROM ((SELECT COUNT(1) num FROM mall_goods WHERE merchant_id = #{merchantId} AND is_delete = 0)
              UNION
              (SELECT COUNT(1) num FROM mall_goods WHERE merchant_id = #{merchantId} AND is_delete = 0)) allNum
    </select>
 
    <select id="queryMerchantList" resultType="com.sinata.modular.member.model.MemMerchant">
        SELECT *,
        ( SELECT GROUP_CONCAT( NAME ) FROM my_store_service WHERE FIND_IN_SET( id, mem_merchant.service_ids ) ) serviceName,
        ( SELECT CONCAT( province_name, city_name, county_name ) FROM sys_area_city WHERE id = mem_merchant.city_id ) cityName,
        ( SELECT COUNT( DISTINCT goods_id ) FROM mall_goods_sku WHERE merchant_id = mem_merchant.id) number
        FROM
            mem_merchant
        <where> is_delete = 0
        <if test="merchantName !=null and merchantName !=''">
            and merchant_name like CONCAT('%',#{merchantName},'%')
        </if>
        <if test="cityCode1 != null and cityCode1 != -1 and (cityCode2 == null or cityCode2 == -1)">
            AND city_id in ( SELECT id FROM sys_area_city WHERE is_open = 1 AND is_delete = 0 AND province_code = #{cityCode1} )
        </if>
        <if test="cityCode2 != null and cityCode2 != -1 and (cityCode3 == null or cityCode3 == -1)">
            AND city_id in ( SELECT id FROM sys_area_city WHERE is_open = 1 AND is_delete = 0 AND city_code = #{cityCode2} )
        </if>
        <if test="cityCode3 != null and cityCode3 != -1">
            AND city_id in ( SELECT id FROM sys_area_city WHERE is_open = 1 AND is_delete = 0 AND county_code = #{cityCode3} )
        </if>
        <if test="beginTime != null and beginTime != ''">
            and start_time <![CDATA[ >= ]]> #{beginTime}
        </if>
        <if test="endTime != null and endTime != ''">
            and start_time <![CDATA[ <= ]]> #{endTime}
        </if>
        </where>
        ORDER BY id desc
    </select>
 
 
</mapper>