xiaoyong931011
2021-07-15 bf9a238e4b6db75c28ee9efae265f36f33301d83
gc-user/src/main/resources/mapper/user/AccountMapper.xml
@@ -191,6 +191,9 @@
            <if test="record.phone != null and record.phone != ''">
                and b.mobile_phone like concat('%',#{record.phone},'%')
            </if>
            <if test="record.phone != null and record.phone != ''">
                and  a.is_prohibit = #{record.isProhibit}
            </if>
            <if test="record.reserveTimeStart != null">
                and b.regist_time >= #{record.reserveTimeStart}
            </if>
@@ -237,7 +240,8 @@
            a.order_no orderNo,
            a.score scoreReward,
            a.amount amountReward,
            sum(c.score) amount
            sum(c.score) score,
            sum(c.score/40) amount
        FROM
            xzx_user_head_details a
                LEFT JOIN xzx_jhy_order b on a.order_no = b.order_no
@@ -256,38 +260,112 @@
    </select>
    <select id="distribDataList" resultType="com.xzx.gc.user.vo.DistribDataListVo">
    SELECT
    a.account_id id,
    b.nick_name nickname,
    b.mobile_phone phone,
    b.regist_time registTime,
    a.is_head isHead,
    (select IFNULL(count(1), 0) from xzx_user_head_relate where head_user_id = a.user_id) cnt,
    (select IFNULL(count(1), 0) from xzx_user_head_details where head_user_id = a.user_id) orderCnt,
    (select IFNULL(sum(amount), 0) from xzx_user_head_relate where head_user_id = a.user_id) amount,
    (select IFNULL(sum(score), 0) from xzx_user_head_relate where head_user_id = a.user_id ) score,
    a.is_prohibit isProhibit
    FROM
    xzx_account_info a
    LEFT JOIN xzx_user_info b on a.user_id = b.user_id
    <where>
        1=1
        and a.is_head = 1
        <if test="record.name != null and record.name != ''">
            and b.nick_name like concat('%',#{record.name},'%')
        </if>
        <if test="record.phone != null and record.phone != ''">
            and b.mobile_phone like concat('%',#{record.phone},'%')
        </if>
        <if test="record.reserveTimeStart != null">
            and b.regist_time >= #{record.reserveTimeStart}
        </if>
        SELECT
        a.account_id id,
        b.nick_name nickname,
        b.mobile_phone phone,
        b.regist_time registTime,
        a.is_head isHead,
        (select IFNULL(count(1), 0) from xzx_user_head_relate where head_user_id = a.user_id) cnt,
        (select IFNULL(count(1), 0) from xzx_user_head_details where head_user_id = a.user_id) orderCnt,
        (select IFNULL(sum(amount), 0) from xzx_user_head_relate where head_user_id = a.user_id) amount,
        (select IFNULL(sum(score), 0) from xzx_user_head_relate where head_user_id = a.user_id ) score,
        a.is_prohibit isProhibit
        FROM
        xzx_account_info a
        LEFT JOIN xzx_user_info b on a.user_id = b.user_id
        <where>
            1=1
            and a.is_head = 1
            <if test="record.name != null and record.name != ''">
                and b.nick_name like concat('%',#{record.name},'%')
            </if>
            <if test="record.phone != null and record.phone != ''">
                and b.mobile_phone like concat('%',#{record.phone},'%')
            </if>
            <if test="record.reserveTimeStart != null">
                and b.regist_time >= #{record.reserveTimeStart}
            </if>
        <if test="record.reserveTimeEnd != null">
            and b.regist_time &lt;= #{record.reserveTimeEnd}
        </if>
    </where>
    order by id desc
</select>
            <if test="record.reserveTimeEnd != null">
                and b.regist_time &lt;= #{record.reserveTimeEnd}
            </if>
        </where>
        order by id desc
    </select>
    <select id="selectOrderByHeadUserId" resultType="java.lang.String">
        SELECT
            IFNULL(SUM(weight),0) as kg
        FROM
            xzx_jhy_order_items
        WHERE
                order_id in (
                SELECT
                    id
                FROM
                    xzx_jhy_order
                WHERE
                        order_no in (
                        SELECT
                            order_no
                        FROM
                            xzx_user_head_details
                        WHERE
                                head_user_id = (
                                SELECT
                                    user_id
                                FROM
                                    xzx_account_info
                                WHERE
                                    account_id =  #{accountId}
                            )
                    )
            )
    </select>
    <select id="selectJDSLByHeadUserId" resultType="java.lang.String">
        SELECT
            IFNULL(SUM(a.weight),0) as jdsl
        FROM
            xzx_jhy_order_items a
                left join xzx_sys_environmental_info b on a.item_type = b.id
        WHERE
            b.item_unit = '台' and
                a.order_id in (
                SELECT
                    id
                FROM
                    xzx_jhy_order
                WHERE
                        order_no in (
                        SELECT
                            order_no
                        FROM
                            xzx_user_head_details
                        WHERE
                                head_user_id = (
                                SELECT
                                    user_id
                                FROM
                                    xzx_account_info
                                WHERE
                                    account_id = #{accountId}
                            )
                    )
            )
    </select>
    <select id="selectDistribDataInfoVo" resultType="com.xzx.gc.user.vo.DistribDataInfoVo">
        SELECT
        IFNULL(count(1), 0) cnt,
        SUM((select IFNULL(count(1), 0) from xzx_user_head_details where head_user_id = a.user_id) ) orderCnt,
        SUM((select IFNULL(sum(amount), 0) from xzx_user_head_details where head_user_id = a.user_id) ) amount
        FROM
        xzx_account_info a
        where
            1=1
            and a.is_head = 1
    </select>
</mapper>