Commit d01d96f7 by jianan

分公司和营业部分开2

parent 3d2a9787
......@@ -328,17 +328,64 @@
and YEAR(o.underwriting_date) = YEAR(now())
</otherwise>
</choose>
<choose>
<when test="type.equalsIgnoreCase('B')">
and p.insurer_branch_id is not null
group by p.insurer_branch_id
union all
<include refid="statisticsSalesYDShangHaiDept" />
order by 4 desc
</select>
<sql id="statisticsSalesYDShangHaiDept">
select
'上海营业部' as typeName,
b.id as typeId,
'' as level,
if(GROUP_CONCAT(DISTINCT o.id) is null, 0,
(select sum(t.order_price) from ag_po_order t where FIND_IN_SET(t.id, GROUP_CONCAT(DISTINCT o.id SEPARATOR ',')))
) as fyp,
concat(ifnull(sum(o.fyc_amount*lip.achievements_rate/100),0),'') as fyc,
ifnull(count(DISTINCT o.id),0) as pieces
from ag_acl_practitioner p
INNER JOIN ag_acl_life_insurance_practitioner lip ON lip.practitioner_id= p.id
INNER JOIN ag_po_order o ON o.policy_no = lip.policy_no
left join ag_product prd on prd.id = o.product_id
left join ag_product_category c1 on c1.id = prd.product_category_id
left join ag_product_plan a on o.plan_id = a.id
left join ag_product aa on aa.id = a.product_id
left join ag_product_category c2 on c2.id = aa.product_category_id
left join ag_acl_insurer_branch b on b.id = p.insurer_branch_id
left join ag_acl_practitioner_subordinate_system s on s.id = p.subordinate_system_id
where o.status = 3 and o.payment_status=3
and p.is_active = 1
and p.dept_id = (SELECT id from ag_acl_insurer_branch_dept where insurer_id=888 and name='上海营业部')
<choose>
<when test="category.equalsIgnoreCase('life')">
and (c1.id in (2,5,8) or c2.id in (2,5,8))
</when>
<when test="category.equalsIgnoreCase('pc')">
and (c1.id not in (2,5,8) or c2.id not in (2,5,8))
</when>
</choose>
<choose>
<when test="time.equalsIgnoreCase('D')">
and TO_DAYS(o.underwriting_date) = TO_DAYS(now())
</when>
<when test="time.equalsIgnoreCase('W')">
and YEARWEEK(DATE_FORMAT(o.underwriting_date,'%Y-%m-%d')) = YEARWEEK(NOW())
</when>
<when test="time.equalsIgnoreCase('M')">
and DATE_FORMAT(o.underwriting_date, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
</when>
<when test="time.equalsIgnoreCase('Q')">
and QUARTER(o.underwriting_date) = QUARTER(NOW()) AND year(o.underwriting_date)=year(now())
</when>
<otherwise>
and p.subordinate_system_id is not null
group by p.subordinate_system_id
and YEAR(o.underwriting_date) = YEAR(now())
</otherwise>
</choose>
order by 4 desc
</select>
</sql>
<select id="statisticsSalesTeam" resultType="com.yd.api.agms.vo.dashboard.StatisticsSalesInfo">
<foreach collection="list" item="item" index="index" separator=" union all " >
......
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