Commit 90c649e0 by jianan

应付明细16

parent a3a9364c
...@@ -86,7 +86,7 @@ public class ApiExpectedFortunePageResponse { ...@@ -86,7 +86,7 @@ public class ApiExpectedFortunePageResponse {
private BigDecimal exchangeRate; private BigDecimal exchangeRate;
@Schema(description = "保单币种->HKD汇率") @Schema(description = "保单币种->HKD汇率")
private BigDecimal defaultExchangeRate; private BigDecimal originalToHkdRate;
@Schema(description = "HKD->发放币种汇率") @Schema(description = "HKD->发放币种汇率")
private BigDecimal hkdToPayoutRate; private BigDecimal hkdToPayoutRate;
...@@ -139,18 +139,9 @@ public class ApiExpectedFortunePageResponse { ...@@ -139,18 +139,9 @@ public class ApiExpectedFortunePageResponse {
@Schema(description = "剩余发放折合港币金额") @Schema(description = "剩余发放折合港币金额")
private BigDecimal unpaidRuleAmounthHkd; private BigDecimal unpaidRuleAmounthHkd;
@Schema(description = "原币→港币汇率")
private BigDecimal originalToHkdRate;
@Schema(description = "发放币种金额") @Schema(description = "发放币种金额")
private BigDecimal payoutAmount; private BigDecimal payoutAmount;
@Schema(description = "期交保费") @Schema(description = "期交保费")
private BigDecimal premium; private BigDecimal premium;
......
...@@ -156,10 +156,11 @@ public class ExpectedFortuneServiceImpl extends ServiceImpl<ExpectedFortuneMappe ...@@ -156,10 +156,11 @@ public class ExpectedFortuneServiceImpl extends ServiceImpl<ExpectedFortuneMappe
// 查找对应的实际发佣 // 查找对应的实际发佣
List<ApiExpectedFortunePageResponse> matchedList = actualMap.get(expected.getExpectedFortuneBizId()); List<ApiExpectedFortunePageResponse> matchedList = actualMap.get(expected.getExpectedFortuneBizId());
if (CollUtil.isNotEmpty(matchedList)) { if (CollUtil.isNotEmpty(matchedList)) {
// 设置实际出账记录的字段:待出账金额(估)、已出账比例、未出账比例、已出账金额 // 设置实际出账记录的字段:持有比例、保费、关联人员
matchedList.forEach(actual -> { matchedList.forEach(actual -> {
actual.setBrokerRatio(expected.getBrokerRatio()); actual.setBrokerRatio(expected.getBrokerRatio());
actual.setPremium(expected.getPremium()); actual.setPremium(expected.getPremium());
actual.setAmountSourceName(expected.getAmountSourceName());
}); });
sortedList.addAll(matchedList); sortedList.addAll(matchedList);
......
...@@ -387,31 +387,33 @@ ...@@ -387,31 +387,33 @@
</select> </select>
<select id="queryListStatistics" resultType="com.yd.csf.service.vo.ExpectedFortuneStatisticsVO"> <select id="queryListStatistics" resultType="com.yd.csf.service.vo.ExpectedFortuneStatisticsVO">
SELECT WITH filtered_data AS (
COALESCE(SUM(hkd_amount), 0) AS totalExpectedAmount, SELECT *
COALESCE(SUM(paid_amount), 0) AS totalPaidAmount, FROM expected_fortune
COALESCE(SUM(unpaid_amount), 0) AS totalUnpaidAmount, WHERE is_deleted = 0
COALESCE(SUM(totalPremiumAmount), 0) AS totalPremiumAmount, AND is_part IN (0, 1)
COUNT(DISTINCT policy_no) AS totalPolicyCount
FROM (
SELECT
ef.hkd_amount,
ef.paid_amount,
ef.unpaid_amount,
ef.policy_no,
(SELECT p.total_payment_premium * ef.default_exchange_rate
FROM policy p
WHERE p.policy_no = ef.policy_no
) 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 != null">
<if test="ew.sqlSegment != null and ew.sqlSegment != ''"> <if test="ew.sqlSegment != null and ew.sqlSegment != ''">
AND ${ew.sqlSegment} AND ${ew.sqlSegment}
</if> </if>
</if> </if>
) AS statistics ),
policy_premium AS (
SELECT
policy_no,
MIN(p.total_payment_premium * default_exchange_rate) AS premium_amount
FROM filtered_data
INNER JOIN policy p USING(policy_no)
GROUP BY policy_no
)
SELECT
COALESCE(SUM(fd.hkd_amount), 0) AS totalExpectedAmount,
COALESCE(SUM(fd.paid_amount), 0) AS totalPaidAmount,
COALESCE(SUM(fd.unpaid_amount), 0) AS totalUnpaidAmount,
COALESCE(SUM(pp.premium_amount), 0) AS totalPremiumAmount,
COUNT(DISTINCT fd.policy_no) AS totalPolicyCount
FROM filtered_data fd
LEFT JOIN policy_premium pp USING(policy_no)
</select> </select>
<select id="queryListNewCount" resultType="java.lang.Long"> <select id="queryListNewCount" resultType="java.lang.Long">
......
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