|
@@ -128,11 +128,11 @@
|
|
|
select
|
|
|
(@i := @i + 1) AS id,bus.*,dd.name as commissionType from (SELECT
|
|
|
IFNULL(cd.id,(SELECT id from commission_declare where deleted = 0 and business_id= major.businessId and production_id is null
|
|
|
- AND business_type ='COMMISSION_DECLARE_MAJOR_EVALUATE' and declare_user_id =#{evaluateUserId}) ) cId,
|
|
|
+ AND business_type ='COMMISSION_DECLARE_MAJOR_EVALUATE') ) cId,
|
|
|
IFNULL(cd.commission_rate_id,(SELECT commission_rate_id from commission_declare where deleted = 0 and business_id= major.businessId and production_id is null
|
|
|
- AND business_type ='COMMISSION_DECLARE_MAJOR_EVALUATE' and declare_user_id = #{evaluateUserId}) ) commission_rate_id,
|
|
|
+ AND business_type ='COMMISSION_DECLARE_MAJOR_EVALUATE') ) commission_rate_id,
|
|
|
IFNULL(cd.declare_result,(SELECT declare_result from commission_declare where deleted = 0 and business_id= major.businessId and production_id is null
|
|
|
- AND business_type ='COMMISSION_DECLARE_MAJOR_EVALUATE' and declare_user_id = #{evaluateUserId}) ) declare_result,
|
|
|
+ AND business_type ='COMMISSION_DECLARE_MAJOR_EVALUATE') ) declare_result,
|
|
|
major.*
|
|
|
FROM
|
|
|
(
|
|
@@ -154,7 +154,8 @@
|
|
|
mp.NAME,
|
|
|
mp.report_no ,
|
|
|
mp.created,
|
|
|
- (case mp.production when 'STATEMENT' THEN '意见书' when 'LETTER' THEN '复评函' else '报告' end ) production
|
|
|
+ (case mp.production when 'STATEMENT' THEN '意见书' when 'LETTER' THEN '复评函' else '报告' end ) production,
|
|
|
+ m.principal_id
|
|
|
FROM (SELECT @i := 0) AS sort,
|
|
|
major m
|
|
|
LEFT JOIN ( SELECT id, NAME, major_id, report_no,created,production FROM major_production WHERE deleted = 0 ) mp ON m.id = mp.major_id
|
|
@@ -164,13 +165,13 @@
|
|
|
LEFT JOIN customer_company cc2 ON cc2.id = m.clientele_sub_id
|
|
|
WHERE
|
|
|
m.deleted = 0
|
|
|
- AND m.principal_id = #{evaluateUserId}
|
|
|
) major
|
|
|
LEFT JOIN ( SELECT id, ifnull( production_id, business_id ) AS xId, commission_rate_id,declare_result FROM commission_declare
|
|
|
- WHERE deleted = 0 and declare_user_id = #{evaluateUserId}
|
|
|
+ WHERE deleted = 0
|
|
|
AND business_type='COMMISSION_DECLARE_MAJOR_EVALUATE'
|
|
|
- ) cd ON major.mId = cd.xId) bus left join business_commission_rate bcr on
|
|
|
+ ) cd ON major.mId = cd.xId) bus left join business_commission_rate bcr on
|
|
|
bus.commission_rate_id = bcr.id left join dict_data dd on dd.id = bcr.business_cate_id
|
|
|
+ LEFT JOIN (SELECT DISTINCT department.id, department.name, user_post.user_id FROM user_post,post,department WHERE user_post.post_id = post.id AND post.department_id = department.id AND department.`name` IN ('评估一部','评估二部','评估三部')) AS department ON department.user_id = principal_id
|
|
|
<where>
|
|
|
<if test="declare!=null and declare.orderId!=null and declare.orderId!=''">
|
|
|
and bus.order_id like concat ('%',#{declare.orderId},'%')
|
|
@@ -206,6 +207,102 @@
|
|
|
order by bus.created DESC ,bus.orderCreated DESC
|
|
|
</select>
|
|
|
|
|
|
+ <sql id="majorEvaluateDeclarePageByDepartmentSql">
|
|
|
+ select
|
|
|
+ (@i := @i + 1) AS id,bus.*,dd.name as commissionType from (SELECT
|
|
|
+ IFNULL(cd.id,(SELECT id from commission_declare where deleted = 0 and business_id= major.businessId and production_id is null
|
|
|
+ AND business_type ='COMMISSION_DECLARE_MAJOR_EVALUATE') ) cId,
|
|
|
+ IFNULL(cd.commission_rate_id,(SELECT commission_rate_id from commission_declare where deleted = 0 and business_id= major.businessId and production_id is null
|
|
|
+ AND business_type ='COMMISSION_DECLARE_MAJOR_EVALUATE') ) commission_rate_id,
|
|
|
+ IFNULL(cd.declare_result,(SELECT declare_result from commission_declare where deleted = 0 and business_id= major.businessId and production_id is null
|
|
|
+ AND business_type ='COMMISSION_DECLARE_MAJOR_EVALUATE') ) declare_result,
|
|
|
+ major.*,
|
|
|
+ cd.created AS cdCreated
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ m.id AS businessId,
|
|
|
+ mp.id AS productionId,
|
|
|
+ ifnull( mp.id, m.id ) AS mId,
|
|
|
+ m.NAME AS orderName,
|
|
|
+ m.order_id,
|
|
|
+ m.business_object_type,
|
|
|
+ m.bailor_contact_name,
|
|
|
+ m.bailor_contact_tel,
|
|
|
+ m.bailor,
|
|
|
+ m.created AS orderCreated,
|
|
|
+ u.NAME AS clientManager,
|
|
|
+ u1.NAME AS principal,
|
|
|
+ cc1.NAME AS clienteleName,
|
|
|
+ cc2.NAME AS clienteleSubName,
|
|
|
+ mp.NAME,
|
|
|
+ mp.report_no ,
|
|
|
+ mp.created,
|
|
|
+ (case mp.production when 'STATEMENT' THEN '意见书' when 'LETTER' THEN '复评函' else '报告' end ) production,
|
|
|
+ m.principal_id
|
|
|
+ FROM (SELECT @i := 0) AS sort,
|
|
|
+ major m
|
|
|
+ LEFT JOIN ( SELECT id, NAME, major_id, report_no,created,production FROM major_production WHERE deleted = 0 ) mp ON m.id = mp.major_id
|
|
|
+ LEFT JOIN user u ON u.id = m.client_manager_id
|
|
|
+ LEFT JOIN user u1 ON u1.id = m.principal_id
|
|
|
+ LEFT JOIN customer_company cc1 ON cc1.id = m.clientele_id
|
|
|
+ LEFT JOIN customer_company cc2 ON cc2.id = m.clientele_sub_id
|
|
|
+ WHERE
|
|
|
+ m.deleted = 0
|
|
|
+ ) major
|
|
|
+ LEFT JOIN ( SELECT id, ifnull( production_id, business_id ) AS xId, commission_rate_id,declare_result,created FROM commission_declare
|
|
|
+ WHERE deleted = 0
|
|
|
+ AND business_type='COMMISSION_DECLARE_MAJOR_EVALUATE'
|
|
|
+ ) cd ON major.mId = cd.xId) bus left join business_commission_rate bcr on
|
|
|
+ bus.commission_rate_id = bcr.id left join dict_data dd on dd.id = bcr.business_cate_id
|
|
|
+ LEFT JOIN (SELECT DISTINCT department.id, department.name, user_post.user_id FROM user_post,post,department WHERE user_post.post_id = post.id AND post.department_id = department.id AND department.`name` IN ('评估一部','评估二部','评估三部')) AS department ON department.user_id = principal_id
|
|
|
+ WHERE department.id = #{departmentId}
|
|
|
+ <if test="declare != null and declare.startTime != null and declare.endTime!= null">
|
|
|
+ AND cdCreated BETWEEN #{declare.startTime} AND #{declare.endTime}
|
|
|
+ </if>
|
|
|
+ <if test="declare!=null and declare.orderId!=null and declare.orderId!=''">
|
|
|
+ and bus.order_id like concat ('%',#{declare.orderId},'%')
|
|
|
+ </if>
|
|
|
+ <if test="declare!=null and declare.name!=null and declare.name!=''">
|
|
|
+ and (bus.orderName like concat ('%',#{declare.name},'%') or bus.name like concat ('%',#{declare.name},'%') )
|
|
|
+ </if>
|
|
|
+ <if test="declare!=null and declare.reportNo!=null and declare.reportNo!=''">
|
|
|
+ and bus.report_no like concat ('%',#{declare.reportNo},'%')
|
|
|
+ </if>
|
|
|
+ <if test="declare!=null and declare.commissionRateId!=null ">
|
|
|
+ and bus.commission_rate_id = #{declare.commissionRateId}
|
|
|
+ </if>
|
|
|
+ <if test="declare!=null and declare.declareType!=null and declare.declareType==true">
|
|
|
+ and bus.productionId is not null
|
|
|
+ </if>
|
|
|
+ <if test="declare!=null and declare.declareType!=null and declare.declareType==false">
|
|
|
+ and bus.productionId is null
|
|
|
+ </if>
|
|
|
+ <if test="declare!=null and declare.declareResult!=null and declare.declareResult=='待申报'">
|
|
|
+ and bus.declare_result is null
|
|
|
+ </if>
|
|
|
+ <if test="declare!=null and declare.declareResult!=null and declare.declareResult=='审核中'">
|
|
|
+ and bus.declare_result = #{declare.declareResult}
|
|
|
+ </if>
|
|
|
+ <if test="declare!=null and declare.declareResult!=null and declare.declareResult=='审核通过'">
|
|
|
+ and bus.declare_result = #{declare.declareResult}
|
|
|
+ </if>
|
|
|
+ <if test="declare!=null and declare.declareResult!=null and declare.declareResult=='审核拒绝'">
|
|
|
+ and bus.declare_result = #{declare.declareResult}
|
|
|
+ </if>
|
|
|
+ order by bus.created DESC ,bus.orderCreated DESC
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!--根据部门id查询大中型提成申报信息-->
|
|
|
+ <select id="majorEvaluateDeclarePageByDepartment" resultType="com.dayou.vo.CommissionDeclareVO">
|
|
|
+ <include refid="majorEvaluateDeclarePageByDepartmentSql" />
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!--根据部门id查询大中型提成申报信息导出excel-->
|
|
|
+ <select id="majorEvaluateDeclarePageByDepartmentExport" resultType="com.dayou.vo.CommissionDeclareVO">
|
|
|
+ <include refid="majorEvaluateDeclarePageByDepartmentSql" />
|
|
|
+ </select>
|
|
|
+
|
|
|
<select id="detail" parameterType="java.lang.Long" resultType="com.dayou.vo.CommissionDeclareVO">
|
|
|
SELECT
|
|
|
cd.id,
|