Helius
2021-08-09 00a8e2f76d02cfc17ca9ff156aa97f85bae5897d
gc-shop/src/main/resources/mapper/shop/JhyOrderMapper.xml
@@ -8,17 +8,20 @@
        a.order_no orderNo,
        a.area area,
        a.address address,
        date_format(reserve_date,'%Y-%m-%d') reserveDate,
        a.reserve_time reserveTime,
        a.status status,
        a.remark remark,
        b.name name,
        a.username name,
        b.mobile_phone mobilePhone,
               (select ifnull(sum(price),0) from xzx_jhy_order_items where order_id = a.id) totalPrice,
        d.mobile jhyMobilePhone,
               (select ifnull(sum(score),0) from xzx_jhy_order_items where order_id = a.id) totalPrice,
                (select ifnull(sum(weight),0) from xzx_jhy_order_items where order_id = a.id) totalWeight,
        d.username username
        FROM
        xzx_jhy_order a
        left join xzx_user_info b on b.user_id = a.user_id
        left join xzx_jhy_info d on d.id = a.jhy_id
        left join xzx_jhy_info d on d.user_id = a.jhy_id
        WHERE 1 = 1
        <if test="record.orderNo != null and record.orderNo != ''">
            and a.order_no like concat('%',#{record.orderNo},'%')
@@ -26,20 +29,78 @@
        <if test="record.status != null and record.status != ''">
            and a.status = #{record.status}
        </if>
        <if test="record.jwyName != null and record.jwyName != ''">
            and d.username like concat('%',#{record.jwyName},'%')
        </if>
        <if test="record.account != null and record.account != ''">
            and ( b.name like concat('%',#{record.account},'%')
                      or b.mobile_phone like concat('%',#{record.account},'%') )
            and ( a.username like concat('%',#{record.account},'%')
                      or b.mobile_phone like concat('%',#{record.accountPhone},'%') )
        </if>
        <if test="record.reserveTimeStart != null">
            and a.reserve_time >= #{record.reserveTimeStart}
            and a.reserve_date >= #{record.reserveTimeStart}
        </if>
        <if test="record.reserveTimeEnd != null">
            and a.reserve_time &lt;= #{record.reserveTimeEnd}
            and a.reserve_date &lt;= #{record.reserveTimeEnd}
        </if>
        order by a.CREATED_TIME desc
    </select>
    <select id="viewJhyOrder" resultType="com.xzx.gc.shop.vo.ViewJhyOrderVo">
        SELECT
        a.id id,
        a.order_no orderNo,
        b.nick_name nickName,
        b.mobile_phone mobilePhone,
        a.area area,
        a.address address,
        date_format(a.reserve_date,'%Y-%m-%d') reserveDate,
        a.reserve_time reserveTime,
        a.status status,
        d.username username,
        d.mobile mobile,
        date_format(a.receiving_time,'%Y-%m-%d %H:%i:%S') receivingTime,
        a.remark remark,
        a. COMMENT comments,
        a.score score,
        a.is_anonymous isAnonymous
        FROM
        xzx_jhy_order a
        left join xzx_user_info b on b.user_id = a.user_id
        left join xzx_jhy_info d on d.user_id = a.jhy_id
        WHERE a.id=#{id}
    </select>
    <select id="selectJhyOrderTitleStatistics" resultType="java.util.Map">
        select d.title title, sum(b.weight) weight
        from xzx_jhy_order a
           inner join xzx_jhy_order_items b on a.id=b.order_id
           inner join xzx_sys_environmental_info c on b.item_type=c.id
           inner join xzx_sys_environmental_info d on c.parent_id = d.id
        where a.status in (3, 4)
        <if test="userId != null and userId != ''">
            and a.user_id=#{userId}
        </if>
        group by d.title
    </select>
    <select id="selectJhyOrderCnt" resultType="java.lang.Integer">
        select IFNULL(count(1),0) from xzx_jhy_order
        where status in (3, 4)
        <if test="userId != null and userId != ''">
            and user_id=#{userId}
        </if>
    </select>
    <select id="selectTotalScoreHasGet" resultType="java.math.BigDecimal">
        select IFNULL(SUM(b.score), 0) from xzx_jhy_order a
        inner join xzx_jhy_order_items b on a.id=b.order_id
        where a.user_id=#{userId}
    </select>
    <select id="selectJhyInfoByUserId" resultType="com.xzx.gc.entity.JhyInfo">
        select * from xzx_jhy_info where id = #{jhyId}
    </select>
</mapper>