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
1f8683b1
Commit
1f8683b1
authored
Nov 06, 2020
by
jianan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
来佣比对列表查询优化
parent
18c5cfc0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
220 deletions
+36
-220
yd-api/src/main/java/com/yd/api/commission/vo/lifecommission/ComeCommissionVO.java
+8
-0
yd-api/src/main/resources/mapper/lifecommission/LifeCommissionMapper.xml
+28
-220
No files found.
yd-api/src/main/java/com/yd/api/commission/vo/lifecommission/ComeCommissionVO.java
View file @
1f8683b1
...
...
@@ -12,7 +12,11 @@ public class ComeCommissionVO {
* 来佣率
* 来用金额
* 来佣状态
* 下单时间
* 缴费年限
* 保障期间
*/
private
Long
orderId
;
private
String
insurerName
;
private
String
planName
;
private
String
policyNo
;
...
...
@@ -20,4 +24,8 @@ public class ComeCommissionVO {
private
String
commissionRate
;
private
String
commissionAmount
;
private
String
commissionCheckStatus
;
private
String
orderDate
;
private
String
payTerm
;
private
String
coverageTerm
;
}
yd-api/src/main/resources/mapper/lifecommission/LifeCommissionMapper.xml
View file @
1f8683b1
<?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=
"com.yd.dal.mapper.lifecommission.LifeCommissionMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.yd.dal.entity.order.PoOrder"
>
<!--@mbg.generated-->
<!--@Table ag_po_order-->
<id
column=
"id"
jdbcType=
"BIGINT"
property=
"id"
/>
<result
column=
"config_level"
jdbcType=
"INTEGER"
property=
"configLevel"
/>
<result
column=
"product_id"
jdbcType=
"BIGINT"
property=
"productId"
/>
<result
column=
"plan_id"
jdbcType=
"BIGINT"
property=
"planId"
/>
<result
column=
"order_no"
jdbcType=
"VARCHAR"
property=
"orderNo"
/>
<result
column=
"order_date"
jdbcType=
"TIMESTAMP"
property=
"orderDate"
/>
<result
column=
"order_price"
jdbcType=
"DECIMAL"
property=
"orderPrice"
/>
<result
column=
"quotation_id"
jdbcType=
"BIGINT"
property=
"quotationId"
/>
<result
column=
"quote_no"
jdbcType=
"BIGINT"
property=
"quoteNo"
/>
<result
column=
"product_category_id"
jdbcType=
"BIGINT"
property=
"productCategoryId"
/>
<result
column=
"destination"
jdbcType=
"VARCHAR"
property=
"destination"
/>
<result
column=
"destination_continent_id"
jdbcType=
"BIGINT"
property=
"destinationContinentId"
/>
<result
column=
"destination_region_id"
jdbcType=
"BIGINT"
property=
"destinationRegionId"
/>
<result
column=
"destination_country_id"
jdbcType=
"BIGINT"
property=
"destinationCountryId"
/>
<result
column=
"effective_start_date"
jdbcType=
"TIMESTAMP"
property=
"effectiveStartDate"
/>
<result
column=
"effective_end_date"
jdbcType=
"TIMESTAMP"
property=
"effectiveEndDate"
/>
<result
column=
"cover_length"
jdbcType=
"INTEGER"
property=
"coverLength"
/>
<result
column=
"cover_adult_qty"
jdbcType=
"INTEGER"
property=
"coverAdultQty"
/>
<result
column=
"cover_underage_qty"
jdbcType=
"INTEGER"
property=
"coverUnderageQty"
/>
<result
column=
"payment_method_id"
jdbcType=
"BIGINT"
property=
"paymentMethodId"
/>
<result
column=
"pay_url"
jdbcType=
"VARCHAR"
property=
"payUrl"
/>
<result
column=
"pay_from"
jdbcType=
"INTEGER"
property=
"payFrom"
/>
<result
column=
"insurer_pdf_url"
jdbcType=
"VARCHAR"
property=
"insurerPdfUrl"
/>
<result
column=
"is_msg_sent"
jdbcType=
"INTEGER"
property=
"isMsgSent"
/>
<result
column=
"is_car_tax"
jdbcType=
"INTEGER"
property=
"isCarTax"
/>
<result
column=
"commission_rate"
jdbcType=
"DECIMAL"
property=
"commissionRate"
/>
<result
column=
"commission_amount"
jdbcType=
"DECIMAL"
property=
"commissionAmount"
/>
<result
column=
"fyc_rate"
jdbcType=
"DECIMAL"
property=
"fycRate"
/>
<result
column=
"fyc_amount"
jdbcType=
"DECIMAL"
property=
"fycAmount"
/>
<result
column=
"b2c_rate"
jdbcType=
"DECIMAL"
property=
"b2cRate"
/>
<result
column=
"grade_commission_rate"
jdbcType=
"DECIMAL"
property=
"gradeCommissionRate"
/>
<result
column=
"referral_rate"
jdbcType=
"DECIMAL"
property=
"referralRate"
/>
<result
column=
"referral_amount"
jdbcType=
"DECIMAL"
property=
"referralAmount"
/>
<result
column=
"policy_id"
jdbcType=
"BIGINT"
property=
"policyId"
/>
<result
column=
"policy_no"
jdbcType=
"VARCHAR"
property=
"policyNo"
/>
<result
column=
"mkt_campaign"
jdbcType=
"VARCHAR"
property=
"mktCampaign"
/>
<result
column=
"mkt_task"
jdbcType=
"VARCHAR"
property=
"mktTask"
/>
<result
column=
"is_converted"
jdbcType=
"INTEGER"
property=
"isConverted"
/>
<result
column=
"status"
jdbcType=
"INTEGER"
property=
"status"
/>
<result
column=
"payment_status"
jdbcType=
"INTEGER"
property=
"paymentStatus"
/>
<result
column=
"flag"
jdbcType=
"VARCHAR"
property=
"flag"
/>
<result
column=
"customer_id"
jdbcType=
"BIGINT"
property=
"customerId"
/>
<result
column=
"referral_customer_id"
jdbcType=
"BIGINT"
property=
"referralCustomerId"
/>
<result
column=
"share_code"
jdbcType=
"VARCHAR"
property=
"shareCode"
/>
<result
column=
"insurer_id"
jdbcType=
"BIGINT"
property=
"insurerId"
/>
<result
column=
"data_source"
jdbcType=
"VARCHAR"
property=
"dataSource"
/>
<result
column=
"is_social_insured"
jdbcType=
"INTEGER"
property=
"isSocialInsured"
/>
<result
column=
"cover_term"
jdbcType=
"INTEGER"
property=
"coverTerm"
/>
<result
column=
"payment_term"
jdbcType=
"INTEGER"
property=
"paymentTerm"
/>
<result
column=
"payment_term_unit"
jdbcType=
"VARCHAR"
property=
"paymentTermUnit"
/>
<result
column=
"pay_interval"
jdbcType=
"INTEGER"
property=
"payInterval"
/>
<result
column=
"view_flag"
jdbcType=
"VARCHAR"
property=
"viewFlag"
/>
<result
column=
"dynamic_field_a"
jdbcType=
"VARCHAR"
property=
"dynamicFieldA"
/>
<result
column=
"dynamic_field_b"
jdbcType=
"VARCHAR"
property=
"dynamicFieldB"
/>
<result
column=
"dynamic_field_c"
jdbcType=
"VARCHAR"
property=
"dynamicFieldC"
/>
<result
column=
"dynamic_field_d"
jdbcType=
"VARCHAR"
property=
"dynamicFieldD"
/>
<result
column=
"plate_no"
jdbcType=
"VARCHAR"
property=
"plateNo"
/>
<result
column=
"memo"
jdbcType=
"LONGVARCHAR"
property=
"memo"
/>
<result
column=
"product_table_request_json"
jdbcType=
"LONGVARCHAR"
property=
"productTableRequestJson"
/>
<result
column=
"verified_seats"
jdbcType=
"INTEGER"
property=
"verifiedSeats"
/>
<result
column=
"frame_no"
jdbcType=
"VARCHAR"
property=
"frameNo"
/>
<result
column=
"subject_province_id"
jdbcType=
"BIGINT"
property=
"subjectProvinceId"
/>
<result
column=
"subject_city_id"
jdbcType=
"BIGINT"
property=
"subjectCityId"
/>
<result
column=
"subject_address"
jdbcType=
"VARCHAR"
property=
"subjectAddress"
/>
<result
column=
"room_qty"
jdbcType=
"VARCHAR"
property=
"roomQty"
/>
<result
column=
"created_at"
jdbcType=
"TIMESTAMP"
property=
"createdAt"
/>
<result
column=
"created_by"
jdbcType=
"BIGINT"
property=
"createdBy"
/>
<result
column=
"updated_at"
jdbcType=
"TIMESTAMP"
property=
"updatedAt"
/>
<result
column=
"updated_by"
jdbcType=
"BIGINT"
property=
"updatedBy"
/>
<result
column=
"source_channel"
jdbcType=
"VARCHAR"
property=
"sourceChannel"
/>
<result
column=
"source_plan_name"
jdbcType=
"VARCHAR"
property=
"sourcePlanName"
/>
<result
column=
"source_publishdate"
jdbcType=
"VARCHAR"
property=
"sourcePublishdate"
/>
<result
column=
"source_article"
jdbcType=
"VARCHAR"
property=
"sourceArticle"
/>
<result
column=
"ip_address"
jdbcType=
"VARCHAR"
property=
"ipAddress"
/>
<result
column=
"ip_region"
jdbcType=
"VARCHAR"
property=
"ipRegion"
/>
<result
column=
"renew_order_id"
jdbcType=
"BIGINT"
property=
"renewOrderId"
/>
<result
column=
"is_renew_complete"
jdbcType=
"INTEGER"
property=
"isRenewComplete"
/>
<result
column=
"is_pay_to_yd"
jdbcType=
"INTEGER"
property=
"isPayToYd"
/>
<result
column=
"auto_pay_flag"
jdbcType=
"VARCHAR"
property=
"autoPayFlag"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
<!--@mbg.generated-->
id, config_level, product_id, plan_id, order_no, order_date, order_price, quotation_id,
quote_no, product_category_id, destination, destination_continent_id, destination_region_id,
destination_country_id, effective_start_date, effective_end_date, cover_length, cover_adult_qty,
cover_underage_qty, payment_method_id, pay_url, pay_from, insurer_pdf_url, is_msg_sent,
is_car_tax, commission_rate, commission_amount, fyc_rate, fyc_amount,
b2c_rate, grade_commission_rate, referral_rate, referral_amount, policy_id, policy_no,
mkt_campaign, mkt_task, is_converted, `status`, payment_status, flag, customer_id,
referral_customer_id, share_code, insurer_id, data_source, is_social_insured, cover_term,
payment_term, payment_term_unit, pay_interval, view_flag, dynamic_field_a, dynamic_field_b,
dynamic_field_c, dynamic_field_d, plate_no, memo, product_table_request_json, verified_seats,
frame_no, subject_province_id, subject_city_id, subject_address, room_qty, created_at,
created_by, updated_at, updated_by, source_channel, source_plan_name, source_publishdate,
source_article, ip_address, ip_region, renew_order_id, is_renew_complete, is_pay_to_yd,
auto_pay_flag
</sql>
<select
id=
"selectByPrimaryKey"
parameterType=
"java.lang.Long"
resultMap=
"BaseResultMap"
>
<!--@mbg.generated-->
select
<include
refid=
"Base_Column_List"
/>
from ag_po_order
where id = #{id,jdbcType=BIGINT}
</select>
<resultMap
id=
"ComeCommissionVO"
type=
"com.yd.api.commission.vo.lifecommission.ComeCommissionVO"
>
<result
column=
"insurer_name"
jdbcType=
"INTEGER"
property=
"insurerName"
/>
<result
column=
"product_id"
jdbcType=
"BIGINT"
property=
"planName"
/>
<result
column=
"plan_id"
jdbcType=
"BIGINT"
property=
"policyNo"
/>
<result
column=
"order_no"
jdbcType=
"VARCHAR"
property=
"orderPrice"
/>
<result
column=
"order_date"
jdbcType=
"TIMESTAMP"
property=
"commissionRate"
/>
<result
column=
"order_price"
jdbcType=
"DECIMAL"
property=
"commissionAmount"
/>
<result
column=
"quotation_id"
jdbcType=
"BIGINT"
property=
"commissionCheckStatus"
/>
</resultMap>
<!-- 查询来佣比对列表 -->
<select
id=
"queryComeCommissionList"
resultType=
"com.yd.api.commission.vo.lifecommission.ComeCommissionVO"
>
select
p.insurer_name insurerName,
a.name planName,
o.id orderId,
i.name insurerName,
IFNULL(a.name,p.name) planName,
o.policy_no policyNo,
o.order_price orderPrice,
o.commission_rate commissionRate,
o.commission_amount commissionAmount,
o.commission_check_status commissionCheckStatus
from ag_acl_customer_fortune f
left join ag_po_order o on f.order_id = o.id
o.commission_check_status commissionCheckStatus,
o.created_at orderDate,
e.coverageTerm,
e.payTerm
from (SELECT id, policy_no, order_price, commission_rate, commission_amount, commission_check_status, commission_check_id, product_id, plan_id, insurer_id, created_at
from ag_po_order t
where t.status = 3
and t.plan_id not in (424,453,464)
and t.broker_customer_id in
(SELECT customer_id from ag_acl_practitioner pr LEFT JOIN ag_acl_practitioner_setting s on pr.id = s.practitioner_id
where s.practitioner_type_id = 28
)
) o
left join ag_po_order_commission_check c on o.commission_check_id = c.id
left join ag_product p on o.product_id = p.id
left join ag_product_plan a on o.plan_id = a.id
left join ag_acl_insurer i on a.insurer_id = i.id
left join ag_acl_insurer i on o.insurer_id = i.id
left join (select order_id,withdrawable_date from ag_acl_customer_fortune group by order_id,withdrawable_date) f on o.id = f.order_id
left join (SELECT
order_id,
CASE WHEN factor_name = '保险期间' THEN element_text END coverageTerm,
CASE WHEN factor_name = '交费年限' THEN element_text END payTerm
FROM ag_po_order_life_product_elements t
GROUP BY order_id
) e on e.order_id = o.id
where 1=1
<if
test=
"compareDate != null"
>
and date_format(f.withdrawable_date, '%Y-%m')
<
= #{compareDate}
and
o.commission_check_id is null or
date_format(f.withdrawable_date, '%Y-%m')
<
= #{compareDate}
</if>
<if
test=
"insurerId != null"
>
and a.insurer_id = #{insurerId}
...
...
@@ -144,100 +48,5 @@
</if>
</select>
<select
id=
"findByStatusAndShareCodeInGroupByCustomerId"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from ag_po_order
where
status = #{status}
<if
test=
"customerShareCodes != null"
>
and share_code in
<foreach
close=
")"
collection=
"customerShareCodes"
index=
"index"
item=
"item"
open=
"("
separator=
","
>
#{item}
</foreach>
</if>
</select>
<select
id=
"findPolicyInfoByCustomerId"
resultType=
"com.yd.dal.entity.order.CustomerPolicyInfo"
>
SELECT
o.id as orderId,
o.order_no as orderNo ,
o.policy_no as policyNo ,
p.name as holderName,
o.destination as destination,
date_format(o.order_date, '%Y-%m-%d %H:%i:%s') as orderDate,
date_format(o.effective_start_date, '%Y-%m-%d %H:%i:%s') as startDate,
date_format(o.effective_end_date, '%Y-%m-%d %H:%i:%s') as endDate,
f.referral_amount as referralAmount,
f.order_price as orderPrice,
o.plan_id as planId,
o.product_id as productId ,
f.id as fortuneId
FROM ag_acl_customer_fortune f INNER JOIN ag_po_order o ON f.order_id = o.id and o.status = 3 and o.order_price
>
0 and o.insurer_id != 888
inner JOIN ag_acl_policyholder p ON o.id = p.order_id and p.type = 2
WHERE f.drop_option_code = 'S01' AND f.customer_id = #{customerId,jdbcType=BIGINT}
<choose>
<when
test=
"time == 1"
>
and DATE_FORMAT(f.order_date, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
</when>
<when
test=
"time == 3"
>
and QUARTER(f.order_date) = QUARTER(NOW()) AND year(f.order_date)=year(now())
</when>
<when
test=
"time == 2"
>
and YEAR(f.order_date) = YEAR(now())
</when>
<otherwise>
</otherwise>
</choose>
</select>
<select
id=
"findPolicyInfoByMobileNoE"
resultType=
"com.yd.dal.entity.order.CustomerPolicyInfo"
>
SELECT
policy.INS_MST_ID as orderNo ,
policy.INS_MST_POLICY_NUM as policyNo ,
c.CUS_MST_NAME as holderName,
date_format(policy.INS_MST_ACCEPT_DATE, '%Y-%m-%d %H:%i:%s') as orderDate,
date_format(policy.INS_MST_EFFECT_DATE, '%Y-%m-%d %H:%i:%s') as startDate,
date_format(policy.INS_MST_INVALID_DATE, '%Y-%m-%d %H:%i:%s') as endDate,
sum(m.MON025_405) as referralAmount,
sum(m.MON025_401) as orderPrice,
m.MON025_004 as productName
FROM sal001 p INNER JOIN MON025 m on m.MON025_007 = p.SAL_MST_ID AND m.MON025_303 = 1 AND m.mon025_108 = 'S01'
inner JOIN ins001 policy on m.MON025_002 = policy.INS_MST_ID -- 保单id
inner join cus001 c on policy.FK_CUS_PRO_ID = c.CUS_MST_ID
WHERE p.SAL_MST_MOBILE like concat(concat('%',#{mobileNo,jdbcType=VARCHAR}),'%')
<choose>
<when
test=
"time == 1"
>
and DATE_FORMAT(policy.INS_MST_ACCEPT_DATE, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
</when>
<when
test=
"time == 3"
>
and QUARTER(policy.INS_MST_ACCEPT_DATE) = QUARTER(NOW()) AND
year(policy.INS_MST_ACCEPT_DATE)=year(now())
</when>
<when
test=
"time == 2"
>
and YEAR(policy.INS_MST_ACCEPT_DATE) = YEAR(now())
</when>
<otherwise>
</otherwise>
</choose>
group by policy.ins_mst_id
</select>
<select
id=
"findOrderNoByPolicyNo"
resultType=
"java.lang.String"
>
select
INS_MST_ID
from ins001
where INS_MST_POLICY_NUM = #{policyNo,jdbcType=VARCHAR};
</select>
<select
id=
"findPolicyFactorByOrderNosE"
resultType=
"com.yd.dal.entity.order.PolicyFactorInfoE"
>
SELECT policy2.FK_INS_MST_ID as orderNo, -- 保单id
policy2.FK_PRD_MST_ID as productId, -- 产品ID
policy2.INS_IND_RELATIONSHIP as relationship,-- 与被保人关系
policy2.INS_IND_INSURED_AMOUNT as insuredAmount, -- 保费
policy2.INS_IND_AMOUNT_UNIT as amountUnit, -- 保费单位
policy2.INS_IND_PERIOD as period -- 缴费年限
from ins002 policy2 where policy2.FK_INS_MST_ID in
<foreach
close=
")"
collection=
"orderNoList"
index=
"index"
item=
"item"
open=
"("
separator=
","
>
#{item}
</foreach>
</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