Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-backend
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AutogeneralShanghai
yd-backend
Commits
e1c82c82
Commit
e1c82c82
authored
Jan 17, 2022
by
jianan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【线上来佣比对】
查询全部
parent
b030474a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
131 additions
and
138 deletions
+131
-138
yd-api/src/main/resources/mapper/lifecommission/LifeCommissionMapper.xml
+131
-138
No files found.
yd-api/src/main/resources/mapper/lifecommission/LifeCommissionMapper.xml
View file @
e1c82c82
...
...
@@ -5,92 +5,75 @@
<select
id=
"queryComeCommissionList"
parameterType=
"com.yd.api.commission.vo.lifecommission.QueryComeCommissionListRequestVO"
resultType=
"com.yd.api.commission.vo.lifecommission.ComeCommissionVO"
>
select
o.id orderId,
t.*,
ib.insurer_name insurerName,
ib.branch_name insurerBrachName,
c.check_yearmonth checkDate,
IFNULL(i.name_abbre,i.name) insurerName,
IFNULL(a.name,p.name) planName,
o.policy_no policyNo,
f.name,
f.practitioner_type_id practitionerTypeId,
(case t.config_level when 2 then p2.pName2 else p3.pName3 END) categoryName,
(case t.config_level when 2 then p2.cName2 else p3.cName3 END) planCategoryName
from (SELECT o.id orderId,
IFNULL(o.plan_id,b.plan_id) plan_id,
IFNULL(o.product_id,b.product_id) product_id,
IFNULL(o.config_level,b.config_level) config_level,
IFNULL(o.insurer_id,oc.insurer_id) insurer_id,
oc.insurer_branch_id,
oc.commission_check_id,
oc.policy_no policyNo,
o.order_price orderPrice,
o.
commissionRate,
o.
commissionAmount,
o.
commissionCheckStatus,
oc.rate
commissionRate,
oc.amount
commissionAmount,
oc.commission_status
commissionCheckStatus,
o.order_date orderDate,
o.commission_no commissionNo,
o.commissionId,
o.amount ,
date_format(o.commissionYear, '%Y-%m-%d') commissionYear,
o.commissionCheckStatus commissionStatus,
o.commission_time commissionTime,
o.commission_period commissionPeriod,
o.commission_type commissionType,
o.commission_item commissionItem,
oc.commission_no commissionNo,
oc.id commissionId,
b.branch_name insurerBranchName,
date_format(oc.commission_year, '%Y-%m-%d') commissionYear,
oc.commission_status commissionStatus,
oc.commission_time commissionTime,
oc.commission_period commissionPeriod,
oc.commission_type commissionType,
oc.commission_item commissionItem,
oc.practitioner_id practitionerId,
o.ydBranchId,
(case when o.cover_term in ('1','2','3') then o.coverageTerm else e.coverageTerm END) coverageTerm,
IFNULL(o.payTerm,e.payTerm) payTerm,
f.name,
f.practitioner_type_id practitionerTypeId,
(case o.config_level when 2 then p2.pName2 else p3.pName3 END) categoryName,
(case o.config_level when 2 then p2.cName2 else p3.cName3 END) planCategoryName
from (SELECT o.*,
IFNULL(o.insurer_id,orderCommission.insurer_id) insurerId,
orderCommission.insurer_branch_id insurerBranchId,
policyNo, commission_no, amount, commission_time, rate, commission_check_id, commissionId,
commission_year commissionYear,
commission_status commissionCheckStatus,
amount commissionAmount,
rate commissionRate,
commission_category,
commission_type,
commission_item,
commission_period
from
(SELECT id, policy_no, order_price, product_id, commission_rate, commission_amount, commission_check_status,
plan_id, insurer_id, order_date, commission_check_at, config_level, cover_term,
CONCAT(payment_term, (case payment_term_unit when 'Y' then '年' when 'M' then '月' when 'D' then '日' else '年' END)) payTerm,
cover_term_type coverageTerm
o.cover_term_type coverageTerm,
CONCAT(o.payment_term, (case o.payment_term_unit when 'Y' then '年' when 'M' then '月' else '日' END)) payTerm
from ag_po_order_commission oc
left join
(SELECT id, order_price, product_id,
plan_id, insurer_id, order_date, config_level, cover_term, insurer_branch_id ydBranchId,
payment_term, payment_term_unit,
cover_term_type
from ag_po_order t
where t.status in (3,4) and
policy_no is not null
where t.status in (3,4) and t.
policy_no is not null
and (t.plan_id not in (424,453,464) or t.plan_id is null)
) o
RIGHT JOIN
(SELECT id commissionId, policy_no policyNo, commission_no, commission_year, amount, commission_status, commission_time, commission_check_id,
t.commission_type, t.commission_item, insurer_id,
commission_period, rate, order_id, commission_category,t.insurer_branch_id
from ag_po_order_commission t
) orderCommission
ON o.id = orderCommission.order_id
WHERE 1=1
<if
test=
"startDate != null "
>
and date_format(commission_year, '%Y-%m')
>
= #{startDate}
</if>
<if
test=
"endDate != null "
>
and date_format(commission_year, '%Y-%m')
<
= #{endDate}
</if>
<if
test=
"policyNo != null"
>
and policyNo like concat(concat('%',#{policyNo,jdbcType=VARCHAR}),'%')
</if>
) o
left join ag_po_order_commission_check c on o.commission_check_id = c.id
left join ag_product_plan a on o.plan_id = a.id
left join ag_product p on o.product_id = p.id
left join ag_acl_insurer_branch b on o.insurerBranchId = b.id
) o ON o.id = oc.order_id
left join ag_product_life_commission_base b on oc.commission_base_id = b.id
) t
left join ag_acl_insurer_branch ib on t.insurer_branch_id = ib.id
left join ag_po_order_commission_check c on t.commission_check_id = c.id
left join ag_product_plan a on t.plan_id = a.id
left join ag_product p on t.product_id = p.id
left join (select plcl.config_level, plcl.product_id, plc.name cName2, pc.name pName2
from ag_plan_category_list plcl
left join ag_plan_category plc on plcl.plan_category_id = plc.id
left join ag_product_category pc on plc.product_category_id = pc.id
where plcl.config_level = 2
) p2
on
o.config_level = p2.config_level and o
.product_id = p2.product_id
on
t.config_level = p2.config_level and t
.product_id = p2.product_id
left join (select plcl.config_level, plcl.plan_id, plc.name cName3, pc.name pName3
from ag_plan_category_list plcl
left join ag_plan_category plc on plcl.plan_category_id = plc.id
left join ag_product_category pc on plc.product_category_id = pc.id
where plcl.config_level = 3
) p3
on o.config_level = p3.config_level and o.plan_id = p3.plan_id
left join ag_acl_insurer i on o.insurerId = i.id
on t.config_level = p3.config_level and t.plan_id = p3.plan_id
left join (SELECT order_id, name, practitioner_type_id, f.customer_id
from (
select *
...
...
@@ -99,31 +82,34 @@
) f
left join ag_acl_practitioner practitioner on f.customer_id = practitioner.customer_id
left join ag_acl_practitioner_setting setting on setting.practitioner_id = practitioner.id
) f on f.order_id = o.id
left join (SELECT
order_id,
MAX(CASE WHEN factor_code = 'f_coverage_term' THEN element_text END) coverageTerm,
MAX(CASE WHEN factor_code = 'f_pay_term' THEN element_text END) payTerm
FROM ag_po_order_life_product_elements t
GROUP BY order_id
) e on e.order_id = o.id
) f on f.order_id = t.orderId
where 1=1
<if
test=
"startDate != null "
>
and date_format(t.commissionYear, '%Y-%m')
>
= #{startDate}
</if>
<if
test=
"endDate != null "
>
and date_format(t.commissionYear, '%Y-%m')
<
= #{endDate}
</if>
<if
test=
"policyNo != null"
>
and policyNo like concat(concat('%',#{policyNo,jdbcType=VARCHAR}),'%')
</if>
<if
test=
"insurerId != null"
>
and
o.insurerI
d = #{insurerId}
and
t.insurer_i
d = #{insurerId}
</if>
<if
test=
"insurerBranchId != null"
>
and
o.insurerBranchI
d = #{insurerBranchId,jdbcType=BIGINT}
and
t.insurer_branch_i
d = #{insurerBranchId,jdbcType=BIGINT}
</if>
<if
test=
"practitionerTypeId != null"
>
and f.practitioner_type_id = #{practitionerTypeId}
</if>
<if
test=
"commissionCheckStatus != null"
>
and
o
.commissionCheckStatus = #{commissionCheckStatus}
and
t
.commissionCheckStatus = #{commissionCheckStatus}
</if>
<if
test=
"commissionType != null"
>
and
o.commission_t
ype = #{commissionType}
and
t.commissionT
ype = #{commissionType}
<if
test=
"commissionItem != null"
>
and
o.commission_i
tem = #{commissionItem}
and
t.commissionI
tem = #{commissionItem}
</if>
</if>
<choose>
...
...
@@ -131,7 +117,7 @@
and c.check_yearmonth = #{historyDate}
</when>
</choose>
order by
o.order_d
ate desc
order by
t.orderD
ate desc
</select>
...
...
@@ -174,59 +160,60 @@
<select
id=
"getSummaries"
resultType=
"java.util.Map"
>
select
count(1) totalSingular,
IFNULL(sum(CASE WHEN
o
.commissionCheckStatus = '1' THEN 1 ELSE 0 END),0) totalDaiLaiYong,
IFNULL(sum(CASE WHEN
o
.commissionCheckStatus = '2' THEN 1 ELSE 0 END),0) totalYiBiDui,
IFNULL(sum(CASE WHEN
o
.commissionCheckStatus = '3' THEN 1 ELSE 0 END),0) totalYiTuiBao,
IFNULL(sum(
o.order_p
rice),0) totalOrderPrice,
IFNULL(sum(
o
.commissionAmount),0) totalCommission
IFNULL(sum(CASE WHEN
t
.commissionCheckStatus = '1' THEN 1 ELSE 0 END),0) totalDaiLaiYong,
IFNULL(sum(CASE WHEN
t
.commissionCheckStatus = '2' THEN 1 ELSE 0 END),0) totalYiBiDui,
IFNULL(sum(CASE WHEN
t
.commissionCheckStatus = '3' THEN 1 ELSE 0 END),0) totalYiTuiBao,
IFNULL(sum(
t.orderP
rice),0) totalOrderPrice,
IFNULL(sum(
t
.commissionAmount),0) totalCommission
from
<include
refid=
"queryLifecommissionList"
/>
</select>
<sql
id=
"queryLifecommissionList"
>
(SELECT o.*,
IFNULL(o.insurer_id,orderCommission.insurer_id) insurerId,
orderCommission.insurer_branch_id insurerBranchId,
policyNo, commission_no, amount, commission_time, rate, commission_check_id,
commission_year commissionYear,
commission_status commissionCheckStatus,
amount commissionAmount,
rate commissionRate,
commission_category,
commission_type,
commission_item,
commission_period
from
(SELECT id, policy_no, order_price, commission_rate, commission_amount, commission_check_status, product_id,
plan_id, insurer_id, order_date, commission_check_at, config_level,
CONCAT(payment_term, (case payment_term_unit when 'Y' then '年' when 'M' then '月' else '日' END)) payTerm,
CONCAT(cover_term, cover_term_type) coverageTerm
(SELECT o.id orderId,
IFNULL(o.plan_id,b.plan_id) plan_id,
IFNULL(o.product_id,b.product_id) product_id,
IFNULL(o.config_level,b.config_level) config_level,
IFNULL(o.insurer_id,oc.insurer_id) insurer_id,
oc.insurer_branch_id,
oc.commission_check_id,
oc.policy_no policyNo,
o.order_price orderPrice,
oc.rate commissionRate,
oc.amount commissionAmount,
oc.commission_status commissionCheckStatus,
o.order_date orderDate,
oc.commission_no commissionNo,
oc.id commissionId,
date_format(oc.commission_year, '%Y-%m-%d') commissionYear,
oc.commission_status commissionStatus,
oc.commission_time commissionTime,
oc.commission_period commissionPeriod,
oc.commission_type commissionType,
oc.commission_item commissionItem,
oc.practitioner_id practitionerId,
o.ydBranchId,
o.cover_term_type coverageTerm,
CONCAT(o.payment_term, (case o.payment_term_unit when 'Y' then '年' when 'M' then '月' else '日' END)) payTerm
from ag_po_order_commission oc
left join
(SELECT id, order_price, product_id,
plan_id, insurer_id, order_date, config_level, cover_term, insurer_branch_id ydBranchId,
payment_term, payment_term_unit,
cover_term_type
from ag_po_order t
where t.status in (3,4) and
policy_no is not null
where t.status in (3,4) and t.
policy_no is not null
and (t.plan_id not in (424,453,464) or t.plan_id is null)
) o
RIGHT JOIN
(SELECT policy_no policyNo, commission_no, commission_year, amount, commission_status, commission_time, rate, commission_check_id,
t.commission_type,t.commission_item, insurer_id,
commission_period, order_id, commission_category,insurer_branch_id
from ag_po_order_commission t
) orderCommission
ON o.id = orderCommission.order_id
WHERE 1=1
<if
test=
"startDate != null "
>
and date_format(commission_year, '%Y-%m')
>
= #{startDate}
</if>
<if
test=
"endDate != null "
>
and date_format(commission_year, '%Y-%m')
<
= #{endDate}
</if>
<if
test=
"policyNo != null"
>
and policyNo like concat(concat('%',#{policyNo,jdbcType=VARCHAR}),'%')
</if>
) o
left join ag_po_order_commission_check c on o.commission_check_id = c.id
left join ag_acl_insurer i on o.insurerId = i.id
left join ag_product_plan a on o.plan_id = a.id
left join ag_product p on o.product_id = p.id
) o ON o.id = oc.order_id
left join ag_product_life_commission_base b on oc.commission_base_id = b.id
) t
left join ag_acl_insurer_branch ib on t.insurer_branch_id = ib.id
left join ag_po_order_commission_check c on t.commission_check_id = c.id
left join ag_product_plan a on t.plan_id = a.id
left join ag_product p on t.product_id = p.id
left join (SELECT order_id, name, practitioner_type_id, f.customer_id
from (
select *
...
...
@@ -235,24 +222,34 @@
) f
left join ag_acl_practitioner practitioner on f.customer_id = practitioner.customer_id
left join ag_acl_practitioner_setting setting on setting.practitioner_id = practitioner.id
) f on f.order_id =
o.i
d
) f on f.order_id =
t.orderI
d
where 1=1
<if
test=
"startDate != null "
>
and date_format(t.commissionYear, '%Y-%m')
>
= #{startDate}
</if>
<if
test=
"endDate != null "
>
and date_format(t.commissionYear, '%Y-%m')
<
= #{endDate}
</if>
<if
test=
"policyNo != null"
>
and policyNo like concat(concat('%',#{policyNo,jdbcType=VARCHAR}),'%')
</if>
<if
test=
"insurerId != null"
>
and
o.insurerI
d = #{insurerId}
and
t.insurer_i
d = #{insurerId}
</if>
<if
test=
"insurerBranchId != null"
>
and
o.insurerBranchI
d = #{insurerBranchId,jdbcType=BIGINT}
and
t.insurer_branch_i
d = #{insurerBranchId,jdbcType=BIGINT}
</if>
<if
test=
"practitionerTypeId != null"
>
and f.practitioner_type_id = #{practitionerTypeId}
</if>
<if
test=
"commissionCheckStatus != null"
>
and o
.commissionCheckStatus = #{commissionCheckStatus}
and t
.commissionCheckStatus = #{commissionCheckStatus}
</if>
<if
test=
"commissionType != null"
>
and
o.commission_t
ype = #{commissionType}
and
t.commissionT
ype = #{commissionType}
<if
test=
"commissionItem != null"
>
and
o.commission_i
tem = #{commissionItem}
and
t.commissionI
tem = #{commissionItem}
</if>
</if>
<choose>
...
...
@@ -284,7 +281,6 @@
o.policy_no policyNo,
o.premium orderPrice,
ib.branch_name insurerBranchName,
o.commission_status commissionCheckStatus,
o.amount commissionAmount,
...
...
@@ -307,7 +303,7 @@
(case o.config_level when 2 then p2.cName2 else p3.cName3 END) planCategoryName
from
(SELECT t.id commissionId, policy_no, commission_no, commission_year, amount, commission_status, commission_time, commission_check_id,premium,t.insurer_id,
t.commission_type,t.commission_item,
t.insurer_branch_id,
t.commission_type,t.commission_item,
commission_period, rate, order_id, commission_category, t.created_at, b.product_id, b.plan_id, b.config_level
from ag_po_order_commission t left join ag_product_life_commission_base b on t.commission_base_id = b.id
WHERE 1=1
...
...
@@ -324,7 +320,6 @@
left join ag_po_order_commission_check c on o.commission_check_id = c.id
left join ag_product_plan a on o.plan_id = a.id
left join ag_product p on o.product_id = p.id
left join ag_acl_insurer_branch ib on o.insurer_branch_id = ib.id
left join (select plcl.config_level, plcl.product_id, plc.name cName2, pc.name pName2
from ag_plan_category_list plcl
left join ag_plan_category plc on plcl.plan_category_id = plc.id
...
...
@@ -345,7 +340,7 @@
and o.insurer_id = #{insurerId}
</if>
<if
test=
"insurerBranchId != null"
>
and
o
.insurer_branch_id = #{insurerBranchId,jdbcType=BIGINT}
and
p
.insurer_branch_id = #{insurerBranchId,jdbcType=BIGINT}
</if>
<if
test=
"commissionType != null"
>
and o.commission_type = #{commissionType}
...
...
@@ -361,6 +356,5 @@
and c.check_yearmonth = #{historyDate}
</when>
</choose>
order by o.created_at desc
</select>
</mapper>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment