a.id as "id",
a.orderno as "orderno",
a.policyno as "policyno",
a.dept_id as "deptId",
a.riskcode as "riskcode",
a.pay_date as "payDate",
a.signdate as "signdate",
a.company_id as "companyId",
a.agreement_id as "agreementId",
a.licenseno as "licenseno",
a.taxamount as "taxamount",
a.no_tax_premium as "noTaxPremium",
a.commission_feerate as "commissionFeerate",
a.other_feerate as "otherFeerate",
a.commission_feevalue as "commissionFeevalue",
a.other_feevalue as "otherFeevalue",
a.all_fee_value as "allFeeValue",
a.final_fee_value as "finalFeeValue",
a.doing_fee_value as "doingFeeValue",
a.voucher_number as "voucherNumber",
a.contract_id as "contractId",
a.contract_file_id as "contractFileId",
a.handling_fees_status as "handlingFeesStatus",
a.no_policyno as "noPolicyno",
a.sy_policyno as "syPolicyno",
a.documentary_fees_status as "documentaryFeesStatus",
a.is_not_car as "isNotCar",
a.is_not_documentary as "isNotDocumentary",
a.invoic_amount as "invoicAmount",
a.invoic_id as "invoicId",
a.tax_premium as "taxPremium",
a.jq_supervise_costs_premiums as "jqSuperviseCostsPremiums",
a.jq_supervise_costs_proportion as "jqSuperviseCostsProportion",
a.sy_supervise_costs_premiums as "sySuperviseCostsPremiums",
a.sy_supervise_costs_proportion as "sySuperviseCostsProportion",
a.no_supervise_costs_premiums as "noSuperviseCostsPremiums",
a.no_supervise_costs_proportion as "noSuperviseCostsProportion",
a.partner_companies_id as "partnerCompaniesId",
a.jq_premium as "jqPremium",
a.sy_premium as "syPremium",
a.no_premium as "noPremium",
a.jq_no_tax_premium as "jqNoTaxPremium",
a.sy_no_tax_premium as "syNoTaxPremium",
a.no_no_tax_premium as "noNoTaxPremium",
a.jq_receivable_proportion as "jqReceivableProportion",
a.sy_receivable_proportion as "syReceivableProportion",
a.no_receivable_proportion as "noReceivableProportion",
a.jq_other_costs_proportion as "jqOtherCostsProportion",
a.sy_other_costs_proportion as "syOtherCostsProportion",
a.no_other_costs_proportion as "noOtherCostsProportion",
a.settlement_time as "settlementTime",
a.update_time as "updateTime",
a.settlement_user_id as "settlementUserId",
a.update_user_id as "updateUserId",
a.jq_other_costs_premium as "jqOtherCostsPremium",
a.sy_other_costs_premium as "syOtherCostsPremium",
a.no_other_costs_premium as "noOtherCostsPremium",
a.partner_companies_name as "partnerCompaniesName",
a.company_name as "companyName",
a.receivable_amount as "receivableAmount",
a.invoic_time as "invoicTime",
a.insured_name as "insuredName",
a.remarks as "remarks",
a.jq_start_date as "jqStartDate",
a.jq_end_date as "jqEndDate",
a.sy_start_date as "syStartDate",
a.sy_end_date as "syEndDate",
a.settle_other_status as "settleOtherStatus",
a.user_id as "userId",
a.invoicing_method as "invoicingMethod",
a.settlement_image_id as "settlementImageId",
a.task_id as "taskId",
a.create_time as "createTime"
select
su1.name as "settlementUserName",
su2.name as "updateUserName",
CONCAT_WS( '-', pa.agreement_abbreviation, NULLIF( pa.business_description, '' ), NULLIF( pa.job_description, '' ) ) AS agreementName,
pa.agreement_type as "agreementType",
pa.docking_person as "dockingPerson",
pa.is_external as "isExternal",
upf.url as "imageUrl",
su.name as "userName",
b.name as "deptName",
from ins_ply_income a
LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
LEFT JOIN sys_user su on su.id=a.user_id
LEFT JOIN sys_user su1 on su1.id=a.settlement_user_id
LEFT JOIN sys_user su2 on su2.id=a.update_user_id
LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
LEFT JOIN sys_dept b on pa.dept_id=b.id
and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
and pa.agreement_type =#{agreementType}
and a.signdate between #{signDateStart} and #{signDateEnd}
and a.handling_fees_status =#{handlingFeesStatus}
and a.jq_receivable_proportion =#{jqReceivableProportion}
and a.sy_receivable_proportion =#{syReceivableProportion}
and a.no_receivable_proportion =#{noReceivableProportion}
and a.id =#{id}
AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
and pa.docking_person =#{dockingPerson}
and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
and pa.dept_id LIKE CONCAT(#{cityId}, '%')
and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
and pa.dept_id LIKE CONCAT(#{countyId}, '%')
and a.task_id = #{taskId}
and a.orderno =#{orderno}
and a.company_id =#{companyName}
and a.policyno =#{policyno}
and a.documentary_fees_status =#{documentaryFeesStatus}
and a.is_not_car =#{isNotCar}
and pa.dept_id =#{deptId}
and a.id in
#{item}
and a.id in
#{item}
and a.id in
#{item}
and a.partner_companies_id in
#{item}
and a.is_not_documentary =#{isOther}
and a.licenseno =#{licenseno}
and a.sy_policyno =#{syPolicyno}
and a.no_policyno =#{noPolicyno}
AND a.signdate =#{signdate}
AND a.partner_companies_id =#{partnerCompaniesId}
AND a.partner_companies_name =#{partnerCompaniesName}
AND a.create_time =#{createTime}
AND a.settlement_time =#{settlementTime}
AND a.settlement_time =#{settlementDate}
and a.userId =#{userId}
and a.company_id =#{companyId}
and a.riskcode =#{riskcode}
AND YEAR(a.signdate) =#{year}
AND month(a.signdate) =#{month}
AND day(a.signdate) =#{day}
AND a.insured_name =#{insuredName}
AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
AND pa.is_external =#{isExternal}
ORDER BY a.create_time desc
select
pa.agreement_name as "agreementName",
pa.agreement_type as "agreementType",
su.name as "userName",
from ins_ply_income a
LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
LEFT JOIN sys_user su on su.id=a.user_id
a.id=#{id}
select
count(MONTH(a.signdate)) as "totalorders",
MONTH(a.signdate) as "monthSigdate",
sum(a.other_feevalue) as "allLOtherFeevalue",
GROUP_CONCAT(a.id) as "ids"
from ins_ply_income a
LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
a.is_not_car =#{isNotCar}
and a.is_not_documentary =#{isOther}
and pa.agreement_type =#{agreementType}
and a.documentary_fees_status =#{documentaryFeesStatus}
and a.company_id =#{companyId}
and YEAR(a.signdate) =#{year}
AND pa.is_external =#{isExternal}
group by MONTH(a.signdate)
update ins_ply_income
contract_id = #{contractId},
voucher_number = #{voucherNumber},
contract_file_id = #{contractFileId},
handling_fees_status = #{handlingFeesStatus}
documentary_fees_status = #{documentaryFeesStatus}
where orderno =#{orderno}
SELECT
a.companyId as "companyId",
a.totalorders as "totalorders",
a.ids as "ids",
a.allLOtherFeevalue as "allLOtherFeevalue"
FROM
(
SELECT
a.company_id AS "companyId",
count(a.orderno) as "totalorders",
sum( a.other_feevalue ) AS "allLOtherFeevalue",
GROUP_CONCAT(a.id) as "ids"
FROM
ins_ply_income a
LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
WHERE
pa.agreement_type = '2'
and a.is_not_car =#{isNotCar}
AND a.documentary_fees_status = #{documentaryFeesStatus}
and a.is_not_documentary =#{isOther}
and a.company_id =#{companyId}
and YEAR(a.signdate) =#{year}
and month(a.signdate) =#{month}
GROUP BY
a.company_id
) a
LEFT JOIN ptl_agreement pa ON a.companyId = pa.association_companies_id
select
from ins_ply_income a
LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
LEFT JOIN sys_user su on su.id=a.user_id
LEFT JOIN sys_user su1 on su1.id=a.settlement_user_id
LEFT JOIN sys_user su2 on su2.id=a.update_user_id
LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
LEFT JOIN sys_dept b on pa.dept_id=b.id
1=1
AND a.licenseno=#{licenseno}
AND a.policyno=#{policyno}
AND a.sy_policyno=#{syPolicyno}
AND a.no_policyno=#{noPolicyno}
and a.is_not_documentary =#{isOther}
and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
and pa.agreement_type =#{agreementType}
and a.signdate between #{signDateStart} and #{signDateEnd}
and a.handling_fees_status =#{handlingFeesStatus}
and a.jq_receivable_proportion =#{jqReceivableProportion}
and a.sy_receivable_proportion =#{syReceivableProportion}
and a.no_receivable_proportion =#{noReceivableProportion}
AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
and a.id =#{id}
AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
and pa.docking_person =#{dockingPerson}
and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
and pa.dept_id LIKE CONCAT(#{cityId}, '%')
and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
and pa.dept_id LIKE CONCAT(#{countyId}, '%')
and a.task_id = #{taskId}
and a.orderno =#{orderno}
and a.company_id =#{companyName}
and a.documentary_fees_status =#{documentaryFeesStatus}
and a.is_not_car =#{isNotCar}
and pa.dept_id =#{deptId}
and a.id in
#{item}
and a.id in
#{item}
and a.id in
#{item}
and a.partner_companies_id in
#{item}
AND a.signdate =#{signdate}
AND a.partner_companies_id =#{partnerCompaniesId}
AND a.partner_companies_name =#{partnerCompaniesName}
AND a.create_time =#{createTime}
AND a.settlement_time =#{settlementTime}
AND a.settlement_time =#{settlementDate}
and a.userId =#{userId}
and a.company_id =#{companyId}
and a.riskcode =#{riskcode}
AND YEAR(a.signdate) =#{year}
AND month(a.signdate) =#{month}
AND day(a.signdate) =#{day}
AND a.insured_name =#{insuredName}
AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
select
from ins_ply_income a
1=1
AND a.licenseno=#{licenseno}
AND a.policyno=#{policyno}
AND a.sy_policyno=#{syPolicyno}
AND a.no_policyno=#{noPolicyno}
and a.is_not_documentary =#{isOther}
and a.is_not_car =#{isNotCar}
and a.handling_fees_status =#{handlingFeesStatus}
and a.jq_supervise_costs_premiums =#{jqSuperviseCostsPremiums}
and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
and a.jq_supervise_costs_proportion =#{jqSuperviseCostsProportion}
and a.jq_other_costs_proportion =#{jqOtherCostsProportion}
and a.sy_other_costs_proportion =#{syOtherCostsProportion}
and a.sy_supervise_costs_premiums =#{sySuperviseCostsPremiums}
and a.no_other_costs_proportion =#{noOtherCostsProportion}
and a.sy_supervise_costs_proportion =#{sySuperviseCostsProportion}
and a.no_supervise_costs_premiums =#{noSuperviseCostsPremiums}
and a.no_supervise_costs_proportion =#{noSuperviseCostsProportion}
and a.jq_premium =#{jqPremium}
and a.sy_premium =#{jqPremium}
AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
and a.no_premium =#{noPremium}
limit 1
select
COALESCE( sum(a.commission_feevalue),0) as "commissionFeevalue",
COALESCE(sum(a.other_feevalue),0) as "otherFeevalue",
COALESCE(SUM(COALESCE(a.commission_feevalue, 0) + COALESCE(a.other_feevalue, 0)), 0) AS "totalFeevalue"
from ins_ply_income a
LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
1=1
and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
and pa.agreement_type =#{agreementType}
and a.signdate between #{signDateStart} and #{signDateEnd}
and a.handling_fees_status =#{handlingFeesStatus}
and a.orderno =#{orderno}
and a.policyno =#{policyno}
and a.documentary_fees_status =#{documentaryFeesStatus}
and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
and a.id in
#{item}
and a.is_not_car =#{isNotCar}
and a.is_not_documentary =#{isOther}
and a.licenseno in
#{item}
and a.policyno =#{policyno}
and a.sy_policyno =#{syPolicyno}
and a.no_policyno =#{noPolicyno}
and a.signdate =#{signdate}
and a.partner_companies_id =#{partnerCompaniesId}
a.create_time =#{createTime}
a.settlement_time =#{settlementTime}
and a.userId =#{userId}
and a.company_id =#{companyId}
and a.riskcode =#{riskcode}
AND YEAR(a.signdate) =#{year}
AND month(a.signdate) =#{month}
AND day(a.signdate) =#{day}
AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
SELECT
SUM(a.commission_feevalue) AS commissionFeevalue,
SUM(CASE WHEN a.handling_fees_status = '2' THEN a.commission_feevalue ELSE 0 END) AS "invoicCommissionFeevalue",
SUM( CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END ) AS "noInvoicCommissionFeevalue",
SUM(CASE WHEN a.handling_fees_status = '1' THEN a.commission_feevalue ELSE 0 END) AS "readyCommissionFeevalue",
SUM( CASE WHEN ( a.handling_fees_status = '2' or a.handling_fees_status = '1' ) THEN a.commission_feevalue ELSE 0 END ) AS "allInvoicCommissionFeevalue",
SUM( CASE WHEN ( a.handling_fees_status = '2' or a.handling_fees_status = '0' ) THEN a.commission_feevalue ELSE 0 END ) AS "unSettledAmount"
FROM
ins_ply_income a
LEFT JOIN
ptl_agreement pa ON pa.id = a.agreement_id
1=1
and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
and pa.agreement_type =#{agreementType}
and a.orderno =#{orderno}
and a.company_id =#{companyName}
and a.signdate between #{signDateStart} and #{signDateEnd}
and a.policyno =#{policyno}
AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
and a.handling_fees_status =#{handlingFeesStatus}
and a.documentary_fees_status =#{documentaryFeesStatus}
and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
and a.is_not_car =#{isNotCar}
AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
and a.is_not_documentary =#{isOther}
and a.licenseno =#{licenseno}
and pa.dept_id =#{deptId}
and a.id in
#{item}
and a.id in
#{item}
and a.sy_policyno =#{syPolicyno}
and a.no_policyno =#{noPolicyno}
AND a.signdate =#{signdate}
AND a.partner_companies_id =#{partnerCompaniesId}
AND a.create_time =#{createTime}
AND a.settlement_time =#{settlementTime}
AND a.partner_companies_name =#{partnerCompaniesName}
and a.userId =#{userId}
and a.company_id =#{companyId}
and a.riskcode =#{riskcode}
AND YEAR(a.signdate) =#{year}
AND month(a.signdate) =#{month}
AND day(a.signdate) =#{day}
AND a.insured_name =#{insuredName}
and a.partner_companies_id in
#{item}
SELECT
SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 )) AS commissionFeevalue,
SUM(CASE WHEN a.handling_fees_status = '0' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END ) AS "noInvoicCommissionFeevalue",
SUM(CASE WHEN a.handling_fees_status = '1' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END) AS "readyCommissionFeevalue"
FROM
ins_ply_income a
LEFT JOIN
ptl_agreement pa ON pa.id = a.agreement_id
1=1
and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
and pa.agreement_type =#{agreementType}
and a.orderno =#{orderno}
and a.company_id =#{companyName}
and a.signdate between #{signDateStart} and #{signDateEnd}
and a.policyno =#{policyno}
and pa.docking_person =#{dockingPerson}
and a.handling_fees_status =#{handlingFeesStatus}
AND pa.is_external =#{isExternal}
and a.documentary_fees_status =#{documentaryFeesStatus}
and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
and a.is_not_car =#{isNotCar}
AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
and a.is_not_documentary =#{isOther}
and a.licenseno =#{licenseno}
and pa.dept_id =#{deptId}
and a.id in
#{item}
and a.id in
#{item}
and a.sy_policyno =#{syPolicyno}
and a.no_policyno =#{noPolicyno}
AND a.signdate =#{signdate}
AND a.partner_companies_id =#{partnerCompaniesId}
AND a.create_time =#{createTime}
AND a.settlement_time =#{settlementTime}
AND a.partner_companies_name =#{partnerCompaniesName}
and a.userId =#{userId}
and a.company_id =#{companyId}
and a.riskcode =#{riskcode}
AND YEAR(a.signdate) =#{year}
AND month(a.signdate) =#{month}
AND day(a.signdate) =#{day}
AND a.insured_name =#{insuredName}
and a.partner_companies_id in
#{item}
select
a.partner_companies_id as "partnerCompaniesId",
MAX( ec.name ) AS "companyName",
sum( a.commission_feevalue ) AS "commissionFeevalue",
sum( a.other_feevalue ) AS "otherFeevalue",
SUM( IFNULL(a.commission_feevalue,0) + IFNULL (a.other_feevalue,0) ) AS "totalFeevalue",
MAX( a.partner_companies_name) as "partnerCompaniesName",
MAX(pa.docking_person) as "dockingPerson"
from ins_ply_income a
LEFT JOIN esm_ins_company ec on ec.id= a.company_id
LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
1=1
AND pa.agreement_type =#{agreementType}
AND a.documentary_fees_status = #{documentaryFeesStatus}
AND a.handling_fees_status = #{handlingFeesStatus}
AND YEAR(a.signdate) =#{year}
and a.company_id =#{companyName}
AND a.partner_companies_name =#{partnerCompaniesName}
and pa.docking_person =#{dockingPerson}
AND month(a.signdate) =#{month}
AND day(a.signdate) =#{day}
GROUP BY a.partner_companies_id,pa.insurance_company_id,pa.docking_person
select
sum(a.commission_feevalue) as "commissionFeevalue",
sum(a.invoic_amount) as "invoicAmount"
from ins_ply_income a
LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
1=1
and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
and pa.agreement_type =#{agreementType}
and a.handling_fees_status =#{handlingFeesStatus}
and a.orderno =#{orderno}
and a.policyno =#{policyno}
and a.documentary_fees_status =#{documentaryFeesStatus}
and a.is_not_car =#{isNotCar}
and a.is_not_documentary =#{isOther}
and a.licenseno =#{licenseno}
and a.sy_policyno =#{syPolicyno}
and a.no_policyno =#{noPolicyno}
and a.signdate =#{signdate}
and a.partner_companies_id =#{partnerCompaniesId}
and a.create_time =#{createTime}
and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
and a.settlement_time =#{settlementTime}
AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
and a.userId =#{userId}
and a.company_id =#{companyId}
and a.riskcode =#{riskcode}
AND YEAR(a.signdate) =#{year}
AND month(a.signdate) =#{month}
AND day(a.signdate) =#{day}
SELECT
a.partner_companies_id AS "partnerCompaniesId",
MAX( a.company_name ) AS "companyName",
MAX( a.company_id ) AS "companyId",
MAX( a.partner_companies_name ) AS "partnerCompaniesName"
FROM
ins_ply_income a
LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
1=1
and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
and pa.agreement_type =#{agreementType}
and a.signdate between #{signDateStart} and #{signDateEnd}
and a.handling_fees_status =#{handlingFeesStatus}
AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
and pa.docking_person =#{dockingPerson}
and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
and pa.dept_id LIKE CONCAT(#{cityId}, '%')
and pa.dept_id LIKE CONCAT(#{countyId}, '%')
and a.task_id = #{taskId}
and a.orderno =#{orderno}
and a.company_id =#{companyName}
AND pa.is_external =#{isExternal}
and a.policyno =#{policyno}
and a.documentary_fees_status =#{documentaryFeesStatus}
and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
and a.is_not_car =#{isNotCar}
and pa.dept_id =#{deptId}
and a.id in
#{item}
and a.id in
#{item}
and a.id in
#{item}
and a.partner_companies_id in
#{item}
and a.is_not_documentary =#{isOther}
and a.licenseno =#{licenseno}
and a.sy_policyno =#{syPolicyno}
and a.no_policyno =#{noPolicyno}
AND a.signdate =#{signdate}
AND a.partner_companies_id =#{partnerCompaniesId}
AND a.partner_companies_name =#{partnerCompaniesName}
AND a.create_time =#{createTime}
AND a.settlement_time =#{settlementTime}
and a.userId =#{userId}
and a.company_id =#{companyId}
and a.riskcode =#{riskcode}
AND YEAR(a.signdate) =#{year}
AND month(a.signdate) =#{month}
AND day(a.signdate) =#{day}
AND a.insured_name =#{insuredName}
AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
GROUP BY a.partner_companies_id
select
a.partner_companies_id AS "partnerCompaniesId",
a.id as "id"
from ins_ply_income a
LEFT JOIN ptl_agreement pa on pa.id= a.agreement_id
1=1
and a.handling_fees_status ='2'
AND pa.agreement_type =#{agreementType}
AND YEAR(a.signdate) =#{year}
AND pa.is_external =#{isExternal}
and a.is_not_documentary =#{isOther}
and a.is_not_car =#{isNotCar}
AND month(a.signdate) =#{month}
AND day(a.signdate) =#{day}
SELECT
a.partner_companies_id AS "partnerCompaniesId",
MAX( a.company_name ) AS "companyName",
MAX( a.company_id ) AS "companyId",
MAX( a.partner_companies_name ) AS "partnerCompaniesName",
IFNULL(max(f.settleMentAmount) , 0.00) +IFNULL ( max(d.settleMentAmount),0.00)-IFNULL(max(f.settleMentAmount) , 0.00) AS "allInvoicCommissionFeevalue",
IFNULL(max(f.settleMentAmount) , 0.00) + IFNULL(max(d.settleMentAmount) , 0.00) as "readyCommissionFeevalue",
IFNULL(max(d.settleMentAmount) , 0.00) as "invoicCommissionFeevalue",
sum(COALESCE( a.other_feevalue,0.00) )-IFNULL ( max(d.settleMentAmount),0.00) as "noInvoicCommissionFeevalue",
sum(COALESCE( a.other_feevalue,0.00) )-COALESCE(max(c.settleMentAmount),0.00)+IFNULL ( max(d.settleMentAmount),0.00) AS "unSettledAmount",
IFNULL(max(f.taxesFees) , 0.00) as "taxesFees",
IFNULL(max(f.expendAmount),0) as "expendAmount",
sum( a.other_feevalue ) AS "otherFeevalue"
FROM
ins_ply_income a
LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
WHERE ( a.settlement_status = '1' or a.settlement_status = '2')
and a.handling_fees_status ='1'
and a.is_not_car =#{isNotCar}
GROUP BY partner_companies_id
) c ON c.partnerCompaniesId = a.partner_companies_id
LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
WHERE a.settlement_status = '1'
and a.handling_fees_status ='1'
and a.is_not_car =#{isNotCar}
GROUP BY partner_companies_id
) d ON d.partnerCompaniesId = a.partner_companies_id
LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId",sum(
settlement_amount ) AS "settleMentAmount",
sum(a.settlement_amount * (1 -a.tax_points/100) ) as 'expendAmount',
sum(a.settlement_amount * (a.tax_points/100) ) as 'taxesFees',
SUM(a.tax_points) as "taxPoints"
FROM settlement_documentary_fees a
WHERE a.settlement_status = '2'
and a.handling_fees_status ='1'
and a.is_not_car =#{isNotCar}
GROUP BY partner_companies_id
) f ON f.partnerCompaniesId = a.partner_companies_id
1=1
and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
and pa.agreement_type =#{agreementType}
and a.signdate between #{signDateStart} and #{signDateEnd}
and a.handling_fees_status =#{handlingFeesStatus}
and pa.docking_person =#{dockingPerson}
and a.orderno =#{orderno}
and a.company_id =#{companyName}
and a.policyno =#{policyno}
and a.documentary_fees_status =#{documentaryFeesStatus}
and a.is_not_car =#{isNotCar}
and a.is_not_documentary =#{isOther}
AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
and a.licenseno =#{licenseno}
and a.sy_policyno =#{syPolicyno}
and a.no_policyno =#{noPolicyno}
AND a.signdate =#{signdate}
AND a.partner_companies_id =#{partnerCompaniesId}
AND a.partner_companies_name =#{partnerCompaniesName}
AND a.create_time =#{createTime}
AND a.settlement_time =#{settlementTime}
and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
and a.userId =#{userId}
and a.company_id =#{companyId}
and a.riskcode =#{riskcode}
AND YEAR(a.signdate) =#{year}
AND month(a.signdate) =#{month}
AND day(a.signdate) =#{day}
AND a.insured_name =#{insuredName}
GROUP BY
a.partner_companies_id
SELECT
a.id as "id",
a.partner_companies_id AS "partnerCompaniesId"
FROM
ins_ply_income a
LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
1=1
AND pa.agreement_type =#{agreementType}
AND YEAR(a.signdate) =#{year}
and a.is_not_documentary =#{isOther}
and a.is_not_car =#{isNotCar}
AND month(a.signdate) =#{month}
AND day(a.signdate) =#{day}
AND a.documentary_fees_status = #{documentaryFeesStatus}
select
pa.agreement_name as "agreementName",
su.name as "userName",
from ins_ply_income a
LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
LEFT JOIN sys_user su on su.id=a.user_id
a.id=#{id}
select
sum(a.commission_feevalue) as "invoicCommissionFeevalue",
MAX(invoic_id) as "invoicId",
MAX(invoic_time) as "invoicTime",
GROUP_CONCAT(a.id) as "ids"
from ins_ply_income a
LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
LEFT JOIN sys_user su on su.id=a.user_id
1=1
AND a.invoic_id is not null
a.id IN
#{item}
AND pa.agreement_type =#{agreementType}
AND YEAR(a.signdate) =#{year}
and a.is_not_documentary =#{isOther}
and a.is_not_car =#{isNotCar}
AND pa.is_external =#{isExternal}
and a.handling_fees_status =#{handlingFeesStatus}
AND month(a.signdate) =#{month}
AND day(a.signdate) =#{day}
AND a.partner_companies_id =#{partnerCompaniesId}
group by a.invoic_id
update ins_ply_income
set handling_fees_status ='1',
settlement_time =NOW()
1=1
and id in
#{item}
SELECT
i.YEAR as "year",
LPAD(i.monthNumber, 2, '0') as "monthNumber",
i.allTotalOtherFeevalue as "allTotalOtherFeevalue",
IFNULL(s.invoicCommissionFeevalue,0) AS invoicCommissionFeevalue,
CONCAT(i.YEAR, '-', LPAD(i.monthNumber, 2, '0')) AS "monthYear",
IFNULL(i.allTotalOtherFeevalue ,0) - IFNULL(s.invoicCommissionFeevalue,0) AS noInvoicCommissionFeevalue
FROM (
SELECT
YEAR(a.signdate) AS YEAR,
MONTH(a.signdate) AS monthNumber,
SUM(IFNULL(a.other_feevalue, 0)) AS allTotalOtherFeevalue
FROM ins_ply_income a
LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
YEAR(a.signdate) BETWEEN YEAR(CURDATE()) AND YEAR(CURDATE()) + 1
and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
and pa.agreement_type =#{agreementType}
and a.signdate between #{signDateStart} and #{signDateEnd}
and DATE_FORMAT( a.signdate, '%Y') between #{yeartsStart} and #{yeartsEnd}
and a.handling_fees_status =#{handlingFeesStatus}
and pa.docking_person =#{dockingPerson}
and a.dept_id LIKE CONCAT(#{cityId}, '%')
and a.dept_id LIKE CONCAT(#{countyId}, '%')
and a.orderno =#{orderno}
and a.company_id =#{companyName}
and a.policyno =#{policyno}
and a.documentary_fees_status =#{documentaryFeesStatus}
and a.is_not_car =#{isNotCar}
and pa.dept_id =#{deptId}
and a.id in
#{item}
and a.id in
#{item}
and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
and a.partner_companies_id in
#{item}
and a.is_not_documentary =#{isOther}
and a.licenseno =#{licenseno}
and a.sy_policyno =#{syPolicyno}
and a.no_policyno =#{noPolicyno}
AND a.signdate =#{signdate}
AND a.partner_companies_id =#{partnerCompaniesId}
AND a.partner_companies_name =#{partnerCompaniesName}
AND a.create_time =#{createTime}
AND a.settlement_time =#{settlementTime}
and a.userId =#{userId}
and a.company_id =#{companyId}
and a.riskcode =#{riskcode}
AND YEAR(a.signdate) =#{year}
AND month(a.signdate) =#{month}
AND day(a.signdate) =#{day}
AND a.insured_name =#{insuredName}
AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
GROUP BY YEAR(a.signdate), MONTH(a.signdate)
) i
LEFT JOIN (
SELECT
YEAR(a.signing_time) AS YEAR,
MONTH(a.signing_time) AS monthNumber,
SUM(CASE WHEN a.settlement_status = '1' THEN IFNULL(a.settlement_amount, 0) ELSE 0 END) AS invoicCommissionFeevalue
FROM settlement_documentary_fees a
YEAR(a.signing_time) BETWEEN YEAR(CURDATE()) AND YEAR(CURDATE()) + 1
and a.is_not_car =#{isNotCar}
and a.partner_companies_id in
#{item}
AND a.partner_companies_id =#{partnerCompaniesId}
and a.company_id =#{companyName}
and a.handling_fees_status =#{handlingFeesStatus}
and DATE_FORMAT( a.signing_time, '%Y') between #{yeartsStart} and #{yeartsEnd}
GROUP BY YEAR(a.signing_time), MONTH(a.signing_time)
) s ON i.YEAR = s.YEAR AND i.monthNumber = s.monthNumber
ORDER BY i.YEAR, i.monthNumber;
SELECT
DATE_FORMAT(a.settlement_time, '%Y-%m-%d %H:%i:%s') as "settlementTime",
MAX(upf.url) as "imageUrl",
sum(a.commission_feevalue + a.other_feevalue) AS "settlementAmount"
FROM
ins_ply_income a
LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
pa.agreement_type ='1'
AND a.partner_companies_id =#{partnerCompaniesId}
and a.handling_fees_status =#{handlingFeesStatus}
and pa.docking_person =#{dockingPerson}
group by a.settlement_time
select
pa.agreement_type as "agreementType",
sum(a.all_fee_value) as "allFeeValue"
from ins_ply_income a
LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
LEFT JOIN sys_user su on su.id=a.user_id
LEFT JOIN sys_user su1 on su1.id=a.settlement_user_id
LEFT JOIN sys_user su2 on su2.id=a.update_user_id
LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
LEFT JOIN sys_dept b on pa.dept_id=b.id
and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
and pa.agreement_type =#{agreementType}
AND pa.is_external =#{isExternal}
and a.signdate between #{signDateStart} and #{signDateEnd}
and a.handling_fees_status =#{handlingFeesStatus}
and a.jq_receivable_proportion =#{jqReceivableProportion}
and a.sy_receivable_proportion =#{syReceivableProportion}
and a.no_receivable_proportion =#{noReceivableProportion}
and a.id =#{id}
AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
and pa.docking_person =#{dockingPerson}
and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
and pa.dept_id LIKE CONCAT(#{cityId}, '%')
and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
and pa.dept_id LIKE CONCAT(#{countyId}, '%')
and a.task_id = #{taskId}
and a.orderno =#{orderno}
and a.company_id =#{companyName}
and a.policyno =#{policyno}
and a.documentary_fees_status =#{documentaryFeesStatus}
and a.is_not_car =#{isNotCar}
and pa.dept_id =#{deptId}
AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
and a.id in
#{item}
and a.id in
#{item}
and a.id in
#{item}
and a.partner_companies_id in
#{item}
and a.is_not_documentary =#{isOther}
and a.licenseno =#{licenseno}
and a.sy_policyno =#{syPolicyno}
and a.no_policyno =#{noPolicyno}
AND a.signdate =#{signdate}
AND a.partner_companies_id =#{partnerCompaniesId}
AND a.partner_companies_name =#{partnerCompaniesName}
AND a.create_time =#{createTime}
AND a.settlement_time =#{settlementTime}
AND a.settlement_time =#{settlementDate}
and a.userId =#{userId}
and a.company_id =#{companyId}
and a.riskcode =#{riskcode}
AND YEAR(a.signdate) =#{year}
AND month(a.signdate) =#{month}
AND day(a.signdate) =#{day}
AND a.insured_name =#{insuredName}
AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
group by pa.agreement_type
SELECT
DATE_FORMAT( a.signdate, '%m') as "month",
sum(a.all_fee_value) as "commissionFeevalue"
FROM
ins_ply_income a
LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
LEFT JOIN sys_user su ON su.id = a.user_id
LEFT JOIN sys_user su1 ON su1.id = a.settlement_user_id
LEFT JOIN sys_user su2 ON su2.id = a.update_user_id
LEFT JOIN ins_upload_files upf ON a.settlement_image_id = upf.id
LEFT JOIN esm_ins_company eic ON eic.id = a.partner_companies_id
LEFT JOIN sys_dept b ON pa.dept_id = b.id
1=1
and DATE_FORMAT( a.signdate, '%Y-%m-%d') between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
and pa.agreement_type =#{agreementType}
and a.signdate between #{signDateStart} and #{signDateEnd}
and a.handling_fees_status =#{handlingFeesStatus}
and a.jq_receivable_proportion =#{jqReceivableProportion}
and a.sy_receivable_proportion =#{syReceivableProportion}
and a.no_receivable_proportion =#{noReceivableProportion}
and a.id =#{id}
AND eic.parent_id LIKE CONCAT(#{allPartnerCompaniesId}, '%')
and eic.parent_id LIKE CONCAT(#{provincePartnerCompaniesId}, '%')
and pa.docking_person =#{dockingPerson}
and pa.dept_id LIKE CONCAT(#{provinceId}, '%')
and pa.dept_id LIKE CONCAT(#{cityId}, '%')
and DATE_FORMAT( a.create_time, '%Y-%m-%d') =#{createTimeQuery}
and pa.dept_id LIKE CONCAT(#{countyId}, '%')
and a.task_id = #{taskId}
and a.orderno =#{orderno}
and a.company_id =#{companyName}
AND pa.is_external =#{isExternal}
and a.policyno =#{policyno}
and a.documentary_fees_status =#{documentaryFeesStatus}
and a.is_not_car =#{isNotCar}
and pa.dept_id =#{deptId}
AND DATE(a.create_time) BETWEEN #{createTimeStart} AND #{createTimeEnd}
and a.id in
#{item}
and a.id in
#{item}
and a.id in
#{item}
and a.partner_companies_id in
#{item}
and a.is_not_documentary =#{isOther}
and a.licenseno =#{licenseno}
and a.sy_policyno =#{syPolicyno}
and a.no_policyno =#{noPolicyno}
AND a.signdate =#{signdate}
AND a.partner_companies_id =#{partnerCompaniesId}
AND a.partner_companies_name =#{partnerCompaniesName}
AND a.create_time =#{createTime}
AND a.settlement_time =#{settlementTime}
AND a.settlement_time =#{settlementDate}
and a.userId =#{userId}
and a.company_id =#{companyId}
and a.riskcode =#{riskcode}
AND YEAR(a.signdate) =#{year}
AND month(a.signdate) =#{month}
AND day(a.signdate) =#{day}
AND a.insured_name =#{insuredName}
AND DATE(a.jq_start_date) BETWEEN #{jqStartDate} AND #{jqEndDate}
AND DATE(a.sy_start_date) BETWEEN #{syStartDate} AND #{syEndDate}
AND DATE(a.signdate) BETWEEN #{yearStrat} AND #{yearEnd}
GROUP BY
DATE_FORMAT( a.signdate, '%m')
SELECT
c.years AS yearAndMonth,
c.sumpremium AS sumpremium,
IFNULL( a.sumcount, 0 ) AS sumcount,
IFNULL( a.paid, 0 ) AS paid,
IFNULL( a.unpaid, 0 ) AS unpaid,
(IFNULL( a.sumcount, 0 ) - IFNULL( a.paid, 0 )) grossProfit,
IFNULL( b.labor_cost, 0 ) AS laborCost,
IFNULL( b.fixed_cost, 0 ) AS fixedCost,
IFNULL( b.variable_cost, 0 ) AS variableCost,
IFNULL( b.operating_profit, 0 ) AS operatingProfit,
IFNULL( b.taxation, 0 ) AS taxation,
IFNULL( b.net_profit, 0 ) AS netProfit
FROM
(
SELECT
DATE_FORMAT( createtime, '%Y-%m' ) AS years,
sum( sumpremium ) AS sumpremium
FROM
ins_area_company
AND signing_time BETWEEN #{vo.beginDate} AND #{vo.endDate}
and signing_time >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
GROUP BY
DATE_FORMAT( signing_time, '%Y-%m' )
ORDER BY
DATE_FORMAT( signing_time, '%Y-%m' )
) c
LEFT JOIN (
SELECT
DATE_FORMAT( create_time, '%Y-%m' ) AS years,
sum( all_fee_value ) AS sumcount,
SUM( CASE WHEN handling_fees_status = '2' THEN ifnull( invoic_amount, 0 ) ELSE 0 END ) AS paid,
SUM( CASE WHEN handling_fees_status != '2' THEN ifnull(( all_fee_value - ifnull( invoic_amount, 0 )), 0 ) ELSE 0 END ) AS unpaid
FROM
ins_ply_income
AND signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
and signdate >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
GROUP BY
DATE_FORMAT( signdate, '%Y-%m' )
) a ON c.years = a.years
LEFT JOIN ins_labor_cost b ON a.years = b.year_and_month
SELECT
SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ))
FROM
ins_ply_income a
LEFT JOIN
ptl_agreement pa ON pa.id = a.agreement_id
and pa.agreement_type =#{vo.type}
and a.is_not_car =#{vo.isNotCar}
and DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
SELECT
a.subSigndate as "yearAndMonth",
a.allAmount as "commissionFeevalue",
IFNULL(c.settAmountOther,0) +IFNULL(b.settCommAmount ,0) as "noInvoicCommissionFeevalue",
IFNULL(b.remainingAmount,0) +IFNULL(c.invoicNotOther,0) as "settlementAmount",
(a.allAmount-(IFNULL(b.invoicComm,0) + IFNULL(c.otherInvoic,0))) as "noSettlementAmount",
a.allAmount-(IFNULL(c.settAmountOther,0) +IFNULL(b.settCommAmount ,0)) as "readyCommissionFeevalue"
FROM
(
SELECT
DATE_FORMAT( a.signdate, '%Y-%m' ) AS subSigndate,
IFNULL( sum( a.commission_feevalue ), 0 ) + IFNULL( sum( a.other_feevalue ), 0 ) AS "allAmount"
FROM
ins_ply_income a
LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
pa.agreement_type = '2'
and DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
GROUP BY
DATE_FORMAT( a.signdate, '%Y-%m' )
) a
LEFT JOIN (
SELECT
DATE_FORMAT( a.signing_time, '%Y-%m' ) AS "subSigndate",
sum( a.settlement_amount ) AS "settCommAmount",
sum(a.remaining_amount) as "remainingAmount",
sum(a.total_amount) as "invoicComm"
FROM
sys_insurance_handling_settlement_month a
DATE_FORMAT( a.signing_time, '%Y' ) =#{vo.year}
GROUP BY
DATE_FORMAT( a.signing_time, '%Y-%m' )
) b ON a.subSigndate = b.subSigndate
left join (
select DATE_FORMAT( a.signing_time, '%Y-%m' ) as "subSigndate" , sum(settlement_amount) as "otherInvoic", sum(invoiced_settled_amount) as "settAmountOther", sum(Invoiced_not_settled_amount) as "invoicNotOther"
from
settlement_documentary_fees a
a.settlement_status='1'
and handling_fees_status ='1'
and DATE_FORMAT( a.signing_time, '%Y' ) =#{vo.year}
GROUP BY DATE_FORMAT( a.signing_time, '%Y-%m' )
) c on c.subSigndate=a.subSigndate
SELECT
SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ))
FROM
ins_ply_income a
LEFT JOIN
ptl_agreement pa ON pa.id = a.agreement_id
and pa.agreement_type =#{vo.type}
AND a.create_time BETWEEN #{vo.beginDate} AND #{vo.endDate}
SELECT
SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 )) AS ysSumAmount,
SUM(CASE WHEN a.handling_fees_status = '0' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END ) AS "yisSumAmount",
SUM(CASE WHEN a.handling_fees_status = '1' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END) AS "wsSumAmount"
FROM
ins_ply_income a
LEFT JOIN
ptl_agreement pa ON pa.id = a.agreement_id
1=1
and pa.agreement_type =#{vo.type}
AND a.signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
AND DATE_FORMAT(a.signdate, '%Y-%m') =#{vo.yearAndMonth}
SELECT
a.subPathner,
sa.area_cname as "areaName",
eic.namesimple as "companyName",
a.partnerCompaniesId as "partnerCompaniesId",
IFNULL(a.allAmount,0) as "commissionFeevalue",
a.companyId as "companyId",
IFNULL(b.noSettHandlingFee,0) as "settlementAmount",
IFNULL(a.allAmount,0) - IFNULL( b.settAmount,0) as "noSettlementAmount",
(IFNULL(a.allAmount,0) - IFNULL( b.settAmount,0)) +IFNULL(b.noSettHandlingFee,0) as "noInvoicCommissionFeevalue",
"手续费" as "isHand",
IFNULL( b.settAmount,0) as "readyCommissionFeevalue"
FROM
(
SELECT
SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
a.company_id AS "companyId",
a.partner_companies_id AS "partnerCompaniesId" ,
sum(a.commission_feevalue) as "allAmount"
FROM
ins_ply_income a
LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
pa.agreement_type = '2'
AND a.is_not_documentary = '0'
and a.is_not_car =#{vo.isNoCar}
and DATE_FORMAT( a.signdate, '%Y-%m' ) =#{vo.yearAndMonth}
GROUP BY
a.partner_companies_id,
a.company_id
) a
LEFT JOIN (
SELECT
sum( a.total_amount ) AS "invoicAmount",
sum( a.remaining_amount ) AS "noSettHandlingFee",
sum( a.settlement_amount ) AS "settAmount",
a.task_id AS "taskId",
DATE_FORMAT( a.signing_time, '%Y-%m' ) AS "subSigne",
a.partner_companies_id AS "subPathner"
FROM
sys_insurance_handling_settlement_month a
and a.is_not_car =#{vo.isNoCar}
and DATE_FORMAT( a.signing_time, '%Y-%m' ) =#{vo.yearAndMonth}
GROUP BY
a.partner_companies_id,
DATE_FORMAT( a.signing_time, '%Y-%m' ),
a.task_id
) b ON b.subPathner = a.partnerCompaniesId
LEFT JOIN esm_ins_company eic on eic.id = a.companyId
LEFT JOIN sys_area sa on sa.area_code = a.subPathner
SELECT
a.partner_companies_id,
sa.area_cname as "areaName",
eic.namesimple as "companyName",
sum(a.other_feevalue) as "commissionFeevalue",
IFNULL(max(b.invoicedSettledAmount) ,0 ) as "readyCommissionFeevalue",
sum(a.other_feevalue) -IFNULL(max(b.invoicedSettledAmount) ,0 ) as "noInvoicCommissionFeevalue",
IFNULL(max(b.invoicedNotSettledAmount) ,0 ) as "settlementAmount",
sum(a.other_feevalue) -IFNULL(max(b.invoicedSettledAmount) ,0 )-IFNULL(max(b.invoicedNotSettledAmount) ,0 ) as "noSettlementAmount",
SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
"跟单费" as "isHand",
a.company_id AS "companyId"
FROM
ins_ply_income a
LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
LEFT JOIN (
SELECT
a.partner_companies_id,
sum(a.invoiced_settled_amount) as "invoicedSettledAmount",
sum(a.Invoiced_not_settled_amount) as "invoicedNotSettledAmount"
FROM
settlement_documentary_fees a
a.handling_fees_status ='1'
AND settlement_status = '1'
and DATE_FORMAT( a.signing_time, '%Y-%m' ) =#{vo.yearAndMonth}
and a.is_not_car =#{vo.isNoCar}
GROUP BY
a.partner_companies_id
) b on b.partner_companies_id =a.partner_companies_id
LEFT JOIN esm_ins_company eic on eic.id = a.company_Id
LEFT JOIN sys_area sa on sa.area_code = SUBSTRING( a.partner_companies_id, 6, 11 )
pa.agreement_type = '2'
AND a.is_not_documentary = '1'
and DATE_FORMAT( a.signdate, '%Y-%m' ) =#{vo.yearAndMonth}
and a.is_not_car =#{vo.isNoCar}
group by
a.partner_companies_id,a.company_id,sa.area_cname
SELECT
1 as orderNumber,
'手续费' AS isHand,
sa.area_cname AS areaName,
eic.namesimple AS companyName,
a.partner_companies_id AS partnerCompaniesId,
SUM(a.commission_feevalue) AS commissionFeevalue,
SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
SUM(CASE WHEN a.handling_fees_status = '1' THEN a.commission_feevalue ELSE 0 END) AS "readyCommissionFeevalue",
SUM(CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END) AS "noInvoicCommissionFeevalue",
SUM(CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END) AS "noSettlementAmount"
FROM
ins_ply_income a
LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
LEFT JOIN sys_area sa ON sa.area_code = SUBSTRING(a.partner_companies_id, 6, 11)
LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
pa.agreement_type = '1'
AND a.signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
and a.is_not_car =#{vo.isNoCar}
GROUP BY
a.partner_companies_id, eic.namesimple, sa.area_cname
UNION ALL
SELECT
2 as orderNumber,
'跟单费' AS isHand,
sa.area_cname AS areaName,
eic.namesimple AS companyName,
a.partner_companies_id AS partnerCompaniesId,
SUM(a.other_feevalue) AS commissionFeevalue,
SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
SUM(CASE WHEN a.handling_fees_status = '1' THEN a.other_feevalue ELSE 0 END) AS "readyCommissionFeevalue",
SUM(CASE WHEN a.handling_fees_status = '0' THEN a.other_feevalue ELSE 0 END) AS "noInvoicCommissionFeevalue",
SUM(CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END) AS "noSettlementAmount"
FROM
ins_ply_income a
LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
LEFT JOIN sys_area sa ON sa.area_code = SUBSTRING(a.partner_companies_id, 6, 11)
LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
pa.agreement_type = '1'
AND a.signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
and a.is_not_car =#{vo.isNoCar}
GROUP BY
a.partner_companies_id, eic.namesimple, sa.area_cname
UNION ALL
SELECT
3 as orderNumber,
'合计' AS isHand,
sa.area_cname AS areaName,
eic.namesimple AS companyName,
a.partner_companies_id AS partnerCompaniesId,
SUM(a.all_fee_value) AS commissionFeevalue,
SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
SUM(CASE WHEN a.handling_fees_status = '1' THEN a.all_fee_value ELSE 0 END) AS "readyCommissionFeevalue",
SUM(CASE WHEN a.handling_fees_status = '0' THEN a.all_fee_value ELSE 0 END) AS "noInvoicCommissionFeevalue",
SUM(CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END) AS "noSettlementAmount"
FROM
ins_ply_income a
LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
LEFT JOIN sys_area sa ON sa.area_code = SUBSTRING(a.partner_companies_id, 6, 11)
LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
pa.agreement_type = '1'
AND a.signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
and a.is_not_car =#{vo.isNoCar}
GROUP BY
a.partner_companies_id, eic.namesimple, sa.area_cname
ORDER BY
companyName,
areaName,
orderNumber;
SELECT
a.subSigndate as "yearAndMonth",
a.allAmount as "commissionFeevalue",
IFNULL(c.settAmountOther,0) +IFNULL(b.settCommAmount ,0) as "noInvoicCommissionFeevalue",
IFNULL(b.remainingAmount,0) +IFNULL(c.invoicNotOther,0) as "settlementAmount",
(a.allAmount-(IFNULL(b.invoicComm,0) + IFNULL(c.otherInvoic,0))) as "noSettlementAmount",
a.allAmount-(IFNULL(c.settAmountOther,0) +IFNULL(b.settCommAmount ,0)) as "readyCommissionFeevalue"
FROM
(
SELECT
DATE_FORMAT( a.signdate, '%Y-%m' ) AS subSigndate,
IFNULL( sum( a.commission_feevalue ), 0 ) + IFNULL( sum( a.other_feevalue ), 0 ) AS "allAmount"
FROM
ins_ply_income a
LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
pa.agreement_type = '2'
and a.is_not_car =#{vo.isNotCar}
GROUP BY
DATE_FORMAT( a.signdate, '%Y-%m' )
) a
LEFT JOIN (
SELECT
DATE_FORMAT( a.signing_time, '%Y-%m' ) AS "subSigndate",
sum( a.settlement_amount ) AS "settCommAmount",
sum(a.remaining_amount) as "remainingAmount",
sum(a.total_amount) as "invoicComm"
FROM
sys_insurance_handling_settlement_month a
1=1
and a.is_not_car =#{vo.isNotCar}
GROUP BY
DATE_FORMAT( a.signing_time, '%Y-%m' )
) b ON a.subSigndate = b.subSigndate
left join (
select DATE_FORMAT( a.signing_time, '%Y-%m' ) as "subSigndate" , sum(settlement_amount) as "otherInvoic", sum(invoiced_settled_amount) as "settAmountOther", sum(Invoiced_not_settled_amount) as "invoicNotOther"
from
settlement_documentary_fees a
where a.settlement_status='1'
and handling_fees_status ='1'
and a.is_not_car =#{vo.isNotCar}
GROUP BY DATE_FORMAT( a.signing_time, '%Y-%m' )
) c on c.subSigndate=a.subSigndate
SELECT
SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ))
FROM
ins_ply_income a
LEFT JOIN
ptl_agreement pa ON pa.id = a.agreement_id
and pa.agreement_type =#{vo.type}
AND a.create_time BETWEEN #{vo.beginDate} AND #{vo.endDate}
SELECT
SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 )) AS ysSumAmount,
SUM(CASE WHEN a.handling_fees_status = '0' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END ) AS "yisSumAmount",
SUM(CASE WHEN a.handling_fees_status = '1' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END) AS "wsSumAmount"
FROM
ins_ply_income a
LEFT JOIN
ptl_agreement pa ON pa.id = a.agreement_id
1=1
and pa.agreement_type =#{vo.type}
AND a.signdate BETWEEN #{vo.beginDate} AND #{vo.endDate}
AND DATE_FORMAT(a.signdate, '%Y-%m') =#{vo.yearAndMonth}
SELECT
a.signingTime as "yearAndMonth",
IFNULL(a.sumpremium,0) as "sumpremium",
IFNULL(b.allAmount,0) as "sumcount",
IFNULL(d.settlement,0) as "meet",
IFNULL(c.actualPayment,0) as "paid",
ifnull(d.settlement,0) - IFNULL(c.actualPayment,0) as "unpaid",
IFNULL(b.allAmount,0)- IFNULL (d.settlement,0) as "grossProfit",
IFNULL(e.applyAmount,0) as "laborCost",
IFNULL(f.applyAmount,0) as "fixedCost",
IFNULL(j.applyAmount,0) as "variableCost",
(IFNULL (b.allAmount,0) - IFNULL(d.settlement,0) ) -( IFNULL(e.applyAmount,0) + IFNULL(f.applyAmount,0) + IFNULL(j.applyAmount,0) ) as "operatingProfit",
IFNULL(g.applyAmount,0) as "taxation",
(IFNULL(b.allAmount,0)- IFNULL(d.settlement,0) ) -( IFNULL(e.applyAmount,0) + IFNULL(f.applyAmount,0) + IFNULL(j.applyAmount,0) ) - IFNULL(g.applyAmount,0) as "netProfit"
FROM
(
SELECT
IFNULL(sum( iac.jqpremium ),0) +IFNULL(sum( iac.sypremium ),0) + IFNULL(sum(iac.jypremium),0) as "sumpremium",
DATE_FORMAT( iac.signing_time, '%Y-%m' ) AS "signingTime"
FROM
`ins_fee_audit` ifa
LEFT JOIN ins_area_company iac ON iac.id = ifa.ins_order_no
ifa.auditstatus = '1'
AND iac.signing_time IS NOT NULL
and DATE_FORMAT( iac.signing_time, '%Y') =#{vo.year}
and iac.signing_time >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
GROUP BY
DATE_FORMAT( iac.signing_time, '%Y-%m' )
) a
LEFT JOIN (
SELECT
sum( ipi.commission_feevalue) + sum(ipi.other_feevalue ) as "allAmount",
DATE_FORMAT( ipi.signdate, '%Y-%m' ) AS "signingTime"
FROM
ins_ply_income ipi
1=1
GROUP BY
DATE_FORMAT( ipi.signdate, '%Y-%m' )
) b ON a.signingTime = b.signingTime
left join (
select
sum(a.amount) as "actualPayment",DATE_FORMAT( a.auditing_time, '%Y-%m' ) as "auditingTime"
from sys_amount_auditing a
left join sys_user_account_history b on a.id = b.auditiing_id
left join sys_user su on su.id =a.user_id
a.auditing_status= '3'
GROUP BY DATE_FORMAT( a.auditing_time, '%Y-%m' )
) c on c.auditingTime =a.signingTime
left join (
SELECT
sum(
ifo.jq_export_supervise_costs_premiums + ifo.sy_export_supervise_costs_premiums + ifo.no_export_supervise_costs_premiums + ifo.jq_export_other_costs_premiums + ifo.sy_export_other_costs_premiums + ifo.no_export_other_costs_premiums + ifo.first_detail_premiums + ifo.second_detail_premiums + ifo.third_detail_premiums
) AS "settlement",
DATE_FORMAT( iac.signing_time, '%Y-%m' ) as "signingTime"
FROM
ins_fee_order_new ifo
LEFT JOIN ins_fee_audit ifa ON ifo.ins_order_no = ifa.ins_order_no
LEFT JOIN ins_area_company iac ON ifa.ins_order_no = iac.id
LEFT JOIN ins_orders io ON iac.orderno = io.orderno
ifa.auditstatus = '1'
AND iac.orderstatus = '3'
AND io.orderstatus = '3'
GROUP BY
DATE_FORMAT( iac.signing_time, '%Y-%m' )
) d on d.signingTime =a.signingTime
left join (
SELECT
sum( CAST(a.apply_amount AS DECIMAL(10, 2))) as "applyAmount",
DATE_FORMAT( a.create_time, '%Y-%m' ) as "createTime",
b.expenditureDetails
FROM
inv_account_operate a
left join (
select a.category as "aCategory",b. category as "bCategory",a.expenditure_details as "expenditureDetails" from inv_account_expenses a
left join inv_account_expenses b on a.parent_id =b.expenses_id
where b.category is not null
) b on a.fund_use = b.bCategory and a.fund_fen = b.aCategory
a.out_card_num IN (
SELECT
bank_card_num
FROM
inv_account_card iac
LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
WHERE
ia.del_flag = '0'
AND ia.outer_flag LIKE concat( '%', '0', '%' )
)
AND a.revenue_outlay = '1'
AND a.del_flag = '0'
AND b.expenditureDetails = '1'
GROUP BY DATE_FORMAT( a.create_time, '%Y-%m' ) , b.expenditureDetails
) e on e.createTime =a.signingTime
left join (
SELECT
sum( CAST(a.apply_amount AS DECIMAL(10, 2))) as "applyAmount",
DATE_FORMAT( a.create_time, '%Y-%m' ) as "createTime",
b.expenditureDetails
FROM
inv_account_operate a
left join (
select a.category as "aCategory",b. category as "bCategory",a.expenditure_details as "expenditureDetails" from inv_account_expenses a
left join inv_account_expenses b on a.parent_id =b.expenses_id
where b.category is not null
) b on a.fund_use = b.bCategory and a.fund_fen = b.aCategory
a.out_card_num IN (
SELECT
bank_card_num
FROM
inv_account_card iac
LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
WHERE
ia.del_flag = '0'
AND ia.outer_flag LIKE concat( '%', '0', '%' )
)
AND a.revenue_outlay = '1'
AND a.del_flag = '0'
AND b.expenditureDetails = '2'
GROUP BY DATE_FORMAT( a.create_time, '%Y-%m' ) , b.expenditureDetails
) f on f.createTime =a.signingTime
left join (
SELECT
sum( CAST(a.apply_amount AS DECIMAL(10, 2))) as "applyAmount",
DATE_FORMAT( a.create_time, '%Y-%m' ) as "createTime",
b.expenditureDetails
FROM
inv_account_operate a
left join (
select a.category as "aCategory",b. category as "bCategory",a.expenditure_details as "expenditureDetails" from inv_account_expenses a
left join inv_account_expenses b on a.parent_id =b.expenses_id
where b.category is not null
) b on a.fund_use = b.bCategory and a.fund_fen = b.aCategory
a.out_card_num IN (
SELECT
bank_card_num
FROM
inv_account_card iac
LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
WHERE
ia.del_flag = '0'
AND ia.outer_flag LIKE concat( '%', '0', '%' )
)
AND a.revenue_outlay = '1'
AND a.del_flag = '0'
AND b.expenditureDetails = '3'
GROUP BY DATE_FORMAT( a.create_time, '%Y-%m' ) , b.expenditureDetails
) j on j.createTime =a.signingTime
left join (
SELECT
sum( CAST(a.apply_amount AS DECIMAL(10, 2))) as "applyAmount",
DATE_FORMAT( a.create_time, '%Y-%m' ) as "createTime",
b.expenditureDetails
FROM
inv_account_operate a
left join (
select a.category as "aCategory",b. category as "bCategory",a.expenditure_details as "expenditureDetails" from inv_account_expenses a
left join inv_account_expenses b on a.parent_id =b.expenses_id
where b.category is not null
) b on a.fund_use = b.bCategory and a.fund_fen = b.aCategory
a.out_card_num IN (
SELECT
bank_card_num
FROM
inv_account_card iac
LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
WHERE
ia.del_flag = '0'
AND ia.outer_flag LIKE concat( '%', '0', '%' )
)
AND a.revenue_outlay = '1'
AND a.del_flag = '0'
AND b.expenditureDetails = '4'
GROUP BY DATE_FORMAT( a.create_time, '%Y-%m' ) , b.expenditureDetails
) g on g.createTime =a.signingTime
select
DATE_FORMAT( a.signdate, '%Y-%m' ) as "incomeSigningTime",
a.task_id as "taskId",
sum(a.commission_feevalue) as "totalAmount"
from ins_ply_income a
LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
LEFT JOIN sys_user su on su.id=a.user_id
LEFT JOIN sys_user su1 on su1.id=a.settlement_user_id
LEFT JOIN sys_user su2 on su2.id=a.update_user_id
LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
LEFT JOIN sys_dept b on pa.dept_id=b.id
1=1
and a.is_not_car =#{vo.isNotCar}
and a.is_not_documentary =#{vo.isNotDocumentary}
and a.task_id = #{vo.taskId}
group by a.task_id , DATE_FORMAT( a.signdate, '%Y-%m' )
SELECT IFNULL(a.signingTime, 0) as "yearAndMonth",
IFNULL(a.allAmount, 0) as "commissionFeevalue",
IFNULL(c.settAmount, 0) as "noInvoicCommissionFeevalue",
IFNULL(b.notInvoicAmount, 0) as "noSettlementAmount",
IFNULL(c.settAmount, 0) as "readyCommissionFeevalue"
FROM (SELECT sum(a.commission_feevalue) + sum(a.other_feevalue) AS "allAmount",
DATE_FORMAT(a.signdate, '%Y-%m') as "signingTime"
FROM ins_ply_income a
LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
pa.agreement_type = '1'
and DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
GROUP BY DATE_FORMAT(a.signdate, '%Y-%m')) a
left join (SELECT sum(a.commission_feevalue) + sum(a.other_feevalue) AS "notInvoicAmount",
DATE_FORMAT(a.signdate, '%Y-%m') as "signingTime"
FROM ins_ply_income a
LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
pa.agreement_type = '1'
and a.handling_fees_status = '0'
and DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
GROUP BY DATE_FORMAT(a.signdate, '%Y-%m')) b on a.signingTime = b.signingTime
left join (SELECT sum(a.commission_feevalue) + sum(a.other_feevalue) AS "settAmount",
DATE_FORMAT(a.signdate, '%Y-%m') as "signingTime"
FROM ins_ply_income a
LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
pa.agreement_type = '1'
and a.handling_fees_status = '1'
and DATE_FORMAT( a.signdate, '%Y' ) =#{vo.year}
GROUP BY DATE_FORMAT(a.signdate, '%Y-%m')) c on c.signingTime = a.signingTime
SELECT
sa.area_cname as "areaName",
eic.namesimple as "companyName",
SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
a.company_id AS "companyId",
a.partner_companies_id AS "partnerCompaniesId"
FROM
ins_ply_income a
LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
LEFT JOIN esm_ins_company eic on eic.id = a.company_id
LEFT JOIN sys_area sa on sa.area_code = SUBSTRING( a.partner_companies_id, 6, 11 )
pa.agreement_type =#{vo.type}
and a.is_not_car =#{vo.isNoCar}
and DATE_FORMAT( a.signdate, '%Y-%m' ) =#{vo.yearAndMonth}
GROUP BY
a.partner_companies_id,
a.company_id,
eic.namesimple,
sa.area_cname