2
0

feat: 余额计费

This commit is contained in:
caiyuchao
2025-01-07 10:30:41 +08:00
parent e8a0ad3356
commit 9b902bfd84
20 changed files with 589 additions and 26 deletions

View File

@@ -0,0 +1,5 @@
<?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="org.wfc.user.mapper.UBillMapper">
</mapper>

View File

@@ -0,0 +1,5 @@
<?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="org.wfc.user.mapper.UBillRuleMapper">
</mapper>

View File

@@ -133,4 +133,41 @@
ORDER BY
ch.start_time DESC
</select>
<select id="getLatestHistory" resultType="org.wfc.user.domain.vo.UCdrLatestHistoryVo">
SELECT
h.*,
c.user_id
FROM
u_cdr_history h
LEFT JOIN u_cdr c ON h.cdr_id = c.id
AND c.del_flag = 0
WHERE
h.del_flag = 0
<if test="userIds != null and userIds.size() > 0">
AND c.user_id in
<foreach collection="userIds" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</if>
<if test="endTime != null">
AND h.create_time > #{endTime}
</if>
</select>
<select id="getCurrentTraffic" resultType="long">
SELECT
sum(
ifnull( c.traffic_down, 0 )) + sum(
ifnull( c.traffic_up, 0 )) traffic
FROM
u_cdr c
LEFT JOIN ( SELECT h.cdr_id, max( h.end_time ) end_time FROM u_cdr_history h WHERE h.del_flag = 0 GROUP BY h.cdr_id ) h ON c.id = h.cdr_id
WHERE
c.del_flag = 0
AND c.last_seen_time != ifnull( h.end_time, 0 )
AND c.user_id = #{userId}
GROUP BY
c.user_id
</select>
</mapper>