Commit 063addbd by jianan

出账检核-增加币种12

parent 897ed66a
......@@ -982,9 +982,12 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
long startTime = System.currentTimeMillis();
try {
// 2. 构建查询条件
// 2. 构建查询条件(不含 ORDER BY,因为 UNION ALL 在 XML 中有单独的 ORDER BY)
QueryWrapper<ExpectedFortune> queryWrapper = this.getQueryWrapper(request);
// 移除 QueryWrapper 中的排序,避免在 UNION ALL 的子查询中出现 ORDER BY
queryWrapper.getExpression().getOrderBy().clear();
// 3. 查询分页列表(UNION ALL 查询,包含预计发佣和实际发佣)
IPage<ApiExpectedFortunePageResponse> iPage = iExpectedFortuneService.queryListNew(
request.getPageNo(),
......
......@@ -46,7 +46,21 @@ public interface ExpectedFortuneMapper extends BaseMapper<ExpectedFortune> {
*/
void updateBatchByBizId(@Param("expectedFortuneBizIdList") List<String> expectedFortuneBizIdList, @Param("status") String status);
IPage<ApiExpectedFortunePageResponse> queryListNew(Integer pageNo, Integer pageSize, @Param("ew") QueryWrapper<ExpectedFortune> queryWrapper);
/**
* 查询预计发佣和实际发佣的分页列表(手动分页)
* @param pageNo 页码(从 1 开始)
* @param pageSize 每页大小
* @param queryWrapper 查询条件
* @return 列表数据
*/
List<ApiExpectedFortunePageResponse> queryListNew(@Param("pageNo") Integer pageNo, @Param("pageSize") Integer pageSize, @Param("ew") QueryWrapper<ExpectedFortune> queryWrapper);
/**
* 查询预计发佣和实际发佣的总记录数
* @param queryWrapper 查询条件
* @return 总记录数
*/
Long queryListNewCount(@Param("ew") QueryWrapper<ExpectedFortune> queryWrapper);
/**
* 查询预计发佣和实际发佣的统计数据(使用 SQL 聚合)
......
......@@ -58,6 +58,13 @@ public interface IExpectedFortuneService extends IService<ExpectedFortune> {
*/
String getPayableNo(String fortuneType);
/**
* 查询预计发佣和实际发佣的分页列表(手动分页)
* @param pageNo 页码(从 1 开始)
* @param pageSize 每页大小
* @param queryWrapper 查询条件
* @return 分页结果
*/
IPage<ApiExpectedFortunePageResponse> queryListNew(Integer pageNo, Integer pageSize, QueryWrapper<ExpectedFortune> queryWrapper);
/**
......
......@@ -214,7 +214,20 @@ public class ExpectedFortuneServiceImpl extends ServiceImpl<ExpectedFortuneMappe
@Override
public IPage<ApiExpectedFortunePageResponse> queryListNew(Integer pageNo, Integer pageSize, QueryWrapper<ExpectedFortune> queryWrapper) {
return this.baseMapper.queryListNew(pageNo, pageSize, queryWrapper);
// 1. 查询列表数据(手动分页)
List<ApiExpectedFortunePageResponse> records = this.baseMapper.queryListNew(pageNo, pageSize, queryWrapper);
// 2. 查询总记录数
Long total = this.baseMapper.queryListNewCount(queryWrapper);
if (total == null) {
total = 0L;
}
// 3. 手动构建分页对象
Page<ApiExpectedFortunePageResponse> page = new Page<>(pageNo, pageSize, total);
page.setRecords(records);
return page;
}
@Override
......
......@@ -221,7 +221,7 @@
f.is_part,
f.payable_no,
f.policy_no,
f.premium,
NULL as premium,
f.policy_currency,
NULL as insurance_company_biz_id,
NULL as product_launch_biz_id,
......@@ -278,31 +278,61 @@
<select id="queryListStatistics" resultType="com.yd.csf.service.vo.ExpectedFortuneStatisticsVO">
SELECT
COALESCE(SUM(ef.hkd_amount), 0) AS totalExpectedAmount,
COALESCE(SUM(ef.paid_amount), 0) AS totalPaidAmount,
COALESCE(SUM(ef.unpaid_amount), 0) AS totalUnpaidAmount,
COALESCE(
(SELECT SUM(p.total_payment_premium) * MAX(ef2.default_exchange_rate)
FROM expected_fortune ef2
LEFT JOIN policy p ON ef2.policy_no = p.policy_no
WHERE ef2.is_deleted = 0 AND ef2.is_part IN (0, 1)
<if test="ew != null">
<if test="ew.sqlSegment != null and ew.sqlSegment != ''">
AND ${ew.sqlSegment}
</if>
</if>
), 0
) AS totalPremiumAmount,
COUNT(DISTINCT ef.policy_no) AS totalPolicyCount
FROM expected_fortune ef
<where>
ef.is_deleted = 0
AND ef.is_part IN (0, 1)
COALESCE(SUM(hkd_amount), 0) AS totalExpectedAmount,
COALESCE(SUM(paid_amount), 0) AS totalPaidAmount,
COALESCE(SUM(unpaid_amount), 0) AS totalUnpaidAmount,
COALESCE(totalPremiumAmount, 0) AS totalPremiumAmount,
COUNT(DISTINCT policy_no) AS totalPolicyCount
FROM (
SELECT
ef.hkd_amount,
ef.paid_amount,
ef.unpaid_amount,
ef.policy_no,
(SELECT SUM(p.total_payment_premium) * MAX(ef.default_exchange_rate)
FROM policy p
WHERE p.policy_no = ef.policy_no
LIMIT 1
) AS totalPremiumAmount
FROM expected_fortune ef
WHERE ef.is_deleted = 0
AND ef.is_part IN (0, 1)
<if test="ew != null">
<if test="ew.sqlSegment != null and ew.sqlSegment != ''">
AND ${ew.sqlSegment}
</if>
</if>
</where>
) AS statistics
</select>
<select id="queryListNewCount" resultType="java.lang.Long">
SELECT COUNT(*)
FROM (
SELECT ef.id
FROM expected_fortune ef
<where>
ef.is_deleted = 0
AND ef.is_part IN (0, 1)
<if test="ew != null">
<if test="ew.sqlSegment != null and ew.sqlSegment != ''">
AND ${ew.sqlSegment}
</if>
</if>
</where>
UNION ALL
SELECT f.id
FROM fortune f
<where>
f.is_deleted = 0
AND f.is_part IN (0, 1)
<if test="ew != null">
<if test="ew.sqlSegment != null and ew.sqlSegment != ''">
AND ${ew.sqlSegment}
</if>
</if>
</where>
) AS combined
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment