ShiShiYiBan/yudao-module-mall/yudao-module-trade-biz/src/main/resources/mapper/brokerage/BrokerageUserMapper.xml

42 lines
1.9 KiB
XML
Raw Normal View History

2023-09-22 22:12:15 +08:00
<?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="cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageUserMapper">
<select id="selectSummaryPageByUserId"
resultType="cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO">
2023-09-29 22:47:04 +08:00
SELECT bu.id, bu.bind_user_time AS brokerageTime,
2023-09-22 22:12:15 +08:00
(SELECT SUM(price) FROM trade_brokerage_record r
2023-09-29 22:47:04 +08:00
WHERE r.user_id = bu.id AND biz_type = #{bizType} AND r.status = #{status} AND r.deleted = FALSE) AS brokeragePrice,
2023-09-22 22:12:15 +08:00
(SELECT COUNT(1) FROM trade_brokerage_record r
2023-09-29 22:47:04 +08:00
WHERE r.user_id = bu.id AND biz_type = #{bizType} AND r.status = #{status} AND r.deleted = FALSE) AS brokerageOrderCount,
2023-09-22 22:12:15 +08:00
(SELECT COUNT(1) FROM trade_brokerage_user c
2023-09-29 22:47:04 +08:00
WHERE c.bind_user_id = bu.id AND c.deleted = FALSE) AS brokerageUserCount
FROM trade_brokerage_user AS bu
<where>
bu.deleted = false
<if test="ids != null and ids.size() > 0">
and bu.id in
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
2023-09-29 22:47:04 +08:00
</foreach>
2023-09-22 22:12:15 +08:00
</if>
</where>
<choose>
2023-09-29 22:47:04 +08:00
<when test="sortingField.field == 'userCount'">
ORDER BY brokerageUserCount ${sortingField.order}
2023-09-22 22:12:15 +08:00
</when>
2023-09-29 22:47:04 +08:00
<when test="sortingField.field == 'orderCount'">
ORDER BY brokerageOrderCount ${sortingField.order}
2023-09-22 22:12:15 +08:00
</when>
2023-09-29 22:47:04 +08:00
<when test="sortingField.field == 'price'">
ORDER BY brokeragePrice ${sortingField.order}
2023-09-22 22:12:15 +08:00
</when>
<otherwise>
ORDER BY bu.bind_user_time DESC
</otherwise>
</choose>
</select>
2023-09-24 11:56:00 +08:00
2023-09-22 22:12:15 +08:00
</mapper>