|
@@ -123,6 +123,115 @@
|
|
|
order by bus.created DESC ,bus.orderCreated DESC
|
|
|
</select>
|
|
|
|
|
|
+ <sql id="majorMarketDeclarePageByDepartmentSql">
|
|
|
+ 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_MARKET') ) 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_MARKET') ) 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_MARKET') ) 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.client_manager_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_MARKET'
|
|
|
+ ) 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 = client_manager_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>
|
|
|
+
|
|
|
+ <select id="majorMarketDeclarePageByDepartment" resultType="com.dayou.vo.CommissionDeclareVO">
|
|
|
+ <include refid="majorMarketDeclarePageByDepartmentSql" />
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="majorMarketDeclarePageByDepartmentExport" resultType="com.dayou.vo.CommissionDeclareVO">
|
|
|
+ <include refid="majorMarketDeclarePageByDepartmentSql" />
|
|
|
+ </select>
|
|
|
|
|
|
<select id="majorEvaluateDeclarePage" parameterType="com.dayou.vo.CommissionDeclareVO" resultType="com.dayou.vo.CommissionDeclareVO">
|
|
|
select
|