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">
|
|
|
|
|
2023-09-30 23:30:06 +08:00
|
|
|
<sql id="selectSummaryListByUserId">
|
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="bindUserIds != null and bindUserIds.size() > 0">
|
|
|
|
and bu.bind_user_id in
|
|
|
|
<foreach collection="bindUserIds" open="(" item="bindUserId" separator="," close=")">
|
|
|
|
#{bindUserId}
|
|
|
|
</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>
|
2023-09-30 23:30:06 +08:00
|
|
|
</sql>
|
|
|
|
|
|
|
|
<select id="selectSummaryPageByUserId"
|
|
|
|
resultType="cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO">
|
|
|
|
<include refid="selectSummaryListByUserId" />
|
|
|
|
</select>
|
|
|
|
<select id="selectSummaryListByUserId"
|
|
|
|
resultType="cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO">
|
|
|
|
<include refid="selectSummaryListByUserId" />
|
2023-09-22 22:12:15 +08:00
|
|
|
</select>
|
2023-09-24 11:56:00 +08:00
|
|
|
|
2023-09-22 22:12:15 +08:00
|
|
|
</mapper>
|