|
@@ -26,26 +26,26 @@
|
|
|
payer, payer_bank, payer_account, amount, pay_datetime, remark, creator_id
|
|
|
</sql>
|
|
|
|
|
|
- <select id="getPage" parameterType="com.dayou.entity.FinanceRealFund" resultType="com.dayou.vo.FinanceRealFundVO">
|
|
|
+ <sql id="pageListSql">
|
|
|
SELECT
|
|
|
- frf.id,
|
|
|
- frf.created,
|
|
|
- frf.payer,
|
|
|
- frf.payer_bank,
|
|
|
- frf.payer_account,
|
|
|
- frf.amount,
|
|
|
- frf.pay_datetime,
|
|
|
- frf.remark,
|
|
|
- frf.creator_id,
|
|
|
- u.name AS creator,
|
|
|
- ifnull(t.ca,0) AS claimAmount,
|
|
|
- ( frf.amount - ifnull(t.ca,0) ) AS notClaimAmount
|
|
|
+ frf.id,
|
|
|
+ frf.created,
|
|
|
+ frf.payer,
|
|
|
+ frf.payer_bank,
|
|
|
+ frf.payer_account,
|
|
|
+ frf.amount,
|
|
|
+ frf.pay_datetime,
|
|
|
+ frf.remark,
|
|
|
+ frf.creator_id,
|
|
|
+ u.name AS creator,
|
|
|
+ ifnull(t.ca,0) AS claimAmount,
|
|
|
+ ( frf.amount - ifnull(t.ca,0) ) AS notClaimAmount
|
|
|
FROM
|
|
|
- finance_real_fund frf
|
|
|
- LEFT JOIN user u ON u.id = frf.creator_id
|
|
|
- LEFT JOIN ( SELECT real_fund_id, sum(ifnull(claim_amount,0)) ca FROM finance_claim WHERE deleted = 0 GROUP BY real_fund_id ) t ON t.real_fund_id = frf.id
|
|
|
+ finance_real_fund frf
|
|
|
+ LEFT JOIN user u ON u.id = frf.creator_id
|
|
|
+ LEFT JOIN ( SELECT real_fund_id, sum(ifnull(claim_amount,0)) ca FROM finance_claim WHERE deleted = 0 GROUP BY real_fund_id ) t ON t.real_fund_id = frf.id
|
|
|
WHERE
|
|
|
- frf.deleted = 0
|
|
|
+ frf.deleted = 0
|
|
|
<if test="vo!=null and vo.notFinished">
|
|
|
and ifnull(t.ca,0) < frf.amount
|
|
|
</if>
|
|
@@ -76,6 +76,10 @@
|
|
|
</if>
|
|
|
ORDER BY
|
|
|
ifnull(t.ca,0) ASC ,frf.created DESC
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <select id="getPage" parameterType="com.dayou.entity.FinanceRealFund" resultType="com.dayou.vo.FinanceRealFundVO">
|
|
|
+ <include refid="pageListSql" />
|
|
|
</select>
|
|
|
|
|
|
<select id="getNotClaimAmount" parameterType="java.lang.Long" resultType="java.math.BigDecimal">
|
|
@@ -172,6 +176,7 @@
|
|
|
<result property="clientSubName" column="clientSubName" />
|
|
|
<result property="evaluateDepartmentName" column="evaluateDepartmentName" />
|
|
|
<result property="marketDepartmentName" column="marketDepartmentName" />
|
|
|
+ <result property="payDateTime" column="pay_datetime" />
|
|
|
<collection property="invoices" ofType="com.dayou.vo.SettleProInvoiceVo">
|
|
|
<result property="invoiceDate" column="invoiceDate" />
|
|
|
<result property="invoiceUser" column="invoiceUser" />
|
|
@@ -181,7 +186,7 @@
|
|
|
|
|
|
<sql id="majorEvaluatorSettleSql">
|
|
|
SELECT
|
|
|
- mp.id,
|
|
|
+ fc.id,
|
|
|
fc.claim_amount,
|
|
|
m.order_id,
|
|
|
mp.report_no,
|
|
@@ -212,14 +217,17 @@
|
|
|
id IN ( SELECT post_id FROM user_post WHERE user_id = m.client_manager_id ))) AS marketDepartmentName,
|
|
|
invoice.name AS invoiceUser,
|
|
|
invoice.real_make_date AS invoiceDate,
|
|
|
- invoice.tax_no AS invoiceNo
|
|
|
+ invoice.tax_no AS invoiceNo,
|
|
|
+ frf.pay_datetime
|
|
|
FROM
|
|
|
(
|
|
|
SELECT
|
|
|
+ id,
|
|
|
claim_amount,
|
|
|
order_fund_id,
|
|
|
production_fund_id,
|
|
|
- claim_datetime
|
|
|
+ claim_datetime,
|
|
|
+ real_fund_id
|
|
|
FROM
|
|
|
finance_claim
|
|
|
WHERE
|
|
@@ -227,10 +235,21 @@
|
|
|
AND production_fund_id IS NOT NULL
|
|
|
AND claim_datetime >= #{settleVO.startDate}
|
|
|
AND claim_datetime <= #{settleVO.endDate} UNION ALL
|
|
|
- SELECT allot_amount AS claim_amount, order_fund_id, production_fund_id, created AS claim_datetime FROM order_fund_allot WHERE deleted = 0
|
|
|
+ SELECT id, allot_amount AS claim_amount, order_fund_id, production_fund_id, created AS claim_datetime,
|
|
|
+ real_fund_id FROM order_fund_allot WHERE deleted = 0
|
|
|
AND created >= #{settleVO.startDate}
|
|
|
AND created <= #{settleVO.endDate}
|
|
|
) fc
|
|
|
+ inner join (
|
|
|
+ select id,pay_datetime from finance_real_fund
|
|
|
+ where deleted = 0
|
|
|
+ <if test="settleVO!=null and settleVO.payStartDate!=null and settleVO.payStartDate!='' ">
|
|
|
+ AND pay_datetime >= #{settleVO.payStartDate}
|
|
|
+ </if>
|
|
|
+ <if test="settleVO!=null and settleVO.payEndDate!=null and settleVO.payEndDate!='' ">
|
|
|
+ AND pay_datetime <= #{settleVO.payEndDate}
|
|
|
+ </if>
|
|
|
+ ) frf on frf.id = fc.real_fund_id
|
|
|
INNER JOIN ( SELECT id, order_fund_id, business_id, production_no FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id )
|
|
|
INNER JOIN ( SELECT id, major_id, NAME, report_no, production, evaluate_amount, save_file_date FROM major_production WHERE deleted = 0 AND save_file_date IS NOT NULL ) mp ON mp.report_no = pf.production_no
|
|
|
LEFT JOIN major m ON m.id = mp.major_id
|
|
@@ -247,20 +266,16 @@
|
|
|
AND state = '已开票'
|
|
|
) AS invoice ON IF(invoice.production_fund_id IS NOT NULL ,invoice.order_fund_id = pf.order_fund_id AND invoice.production_fund_id = pf.id,invoice.order_fund_id = pf.order_fund_id)
|
|
|
<where>
|
|
|
- <if test="settleVO!=null and settleVO.orderId!=null and settleVO.orderId!='' ">
|
|
|
- and m.order_id = #{settleVO.orderId}
|
|
|
- </if>
|
|
|
- <if test="settleVO!=null and settleVO.reportNo!=null and settleVO.reportNo!='' ">
|
|
|
- and mp.report_no like concat ('%',#{settleVO.reportNo},'%')
|
|
|
- </if>
|
|
|
- <if test="settleVO!=null and settleVO.principal!=null and settleVO.principal!='' ">
|
|
|
- and u.name like concat ('%',#{settleVO.principal},'%')
|
|
|
- </if>
|
|
|
- <if test="settleVO!=null and settleVO.clientManager!=null and settleVO.clientManager!='' ">
|
|
|
- and u1.name like concat ('%',#{settleVO.clientManager},'%')
|
|
|
+ <if test="keyword!=null and keyword!='' ">
|
|
|
+ and (
|
|
|
+ m.order_id = #{keyword}
|
|
|
+ or mp.report_no like concat ('%',#{keyword},'%')
|
|
|
+ or u.name like concat ('%',#{keyword},'%')
|
|
|
+ or u1.name like concat ('%',#{keyword},'%')
|
|
|
+ )
|
|
|
</if>
|
|
|
</where>
|
|
|
- order by settleDate DESC
|
|
|
+ order by fc.claim_datetime ASC
|
|
|
</sql>
|
|
|
<select id="majorEvaluatorSettleProd" parameterType="com.dayou.vo.SettleMajorProductionVO" resultMap="settleeMajorProductionVOMap">
|
|
|
<include refid="majorEvaluatorSettleSql" />
|
|
@@ -272,12 +287,12 @@
|
|
|
|
|
|
<sql id="majorMarketerSettleSql">
|
|
|
SELECT
|
|
|
- mp.id,
|
|
|
+ fc.id,
|
|
|
fc.claim_amount,
|
|
|
m.order_id,
|
|
|
mp.report_no,
|
|
|
- fc.claim_datetime,
|
|
|
- mp.delivery_date,
|
|
|
+ fc.claim_datetime as claimDate,
|
|
|
+ mp.delivery_date as deliveryDate,
|
|
|
IF
|
|
|
( fc.claim_datetime > mp.delivery_date, fc.claim_datetime, mp.delivery_date ) AS settleDate,
|
|
|
mp.NAME,
|
|
@@ -303,14 +318,17 @@
|
|
|
id IN ( SELECT post_id FROM user_post WHERE user_id = m.client_manager_id ))) AS marketDepartmentName,
|
|
|
invoice.name AS invoiceUser,
|
|
|
invoice.real_make_date AS invoiceDate,
|
|
|
- invoice.tax_no AS invoiceNo
|
|
|
+ invoice.tax_no AS invoiceNo,
|
|
|
+ frf.pay_datetime
|
|
|
FROM
|
|
|
(
|
|
|
SELECT
|
|
|
+ id,
|
|
|
claim_amount,
|
|
|
order_fund_id,
|
|
|
production_fund_id,
|
|
|
- claim_datetime
|
|
|
+ claim_datetime,
|
|
|
+ real_fund_id
|
|
|
FROM
|
|
|
finance_claim
|
|
|
WHERE
|
|
@@ -318,10 +336,19 @@
|
|
|
AND production_fund_id IS NOT NULL
|
|
|
AND claim_datetime >= #{settleVO.startDate}
|
|
|
AND claim_datetime <= #{settleVO.endDate} UNION ALL
|
|
|
- SELECT allot_amount AS claim_amount, order_fund_id, production_fund_id, created AS claim_datetime FROM order_fund_allot WHERE deleted = 0
|
|
|
+ SELECT id, allot_amount AS claim_amount, order_fund_id, production_fund_id, created AS claim_datetime ,real_fund_id FROM order_fund_allot WHERE deleted = 0
|
|
|
AND created >= #{settleVO.startDate}
|
|
|
AND created <= #{settleVO.endDate}
|
|
|
- ) fc
|
|
|
+ ) fc inner join (
|
|
|
+ select id,pay_datetime from finance_real_fund
|
|
|
+ where deleted = 0
|
|
|
+ <if test="settleVO!=null and settleVO.payStartDate!=null and settleVO.payStartDate!='' ">
|
|
|
+ AND pay_datetime >= #{settleVO.payStartDate}
|
|
|
+ </if>
|
|
|
+ <if test="settleVO!=null and settleVO.payEndDate!=null and settleVO.payEndDate!='' ">
|
|
|
+ AND pay_datetime <= #{settleVO.payEndDate}
|
|
|
+ </if>
|
|
|
+ ) frf on frf.id = fc.real_fund_id
|
|
|
INNER JOIN ( SELECT id, order_fund_id, business_id, production_no FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id )
|
|
|
INNER JOIN ( SELECT id, major_id, NAME, report_no, production, evaluate_amount, delivery_date FROM major_production WHERE deleted = 0 AND delivery_date IS NOT NULL ) mp ON mp.report_no = pf.production_no
|
|
|
LEFT JOIN major m ON m.id = mp.major_id
|
|
@@ -351,7 +378,7 @@
|
|
|
and u1.name like concat ('%',#{settleVO.clientManager},'%')
|
|
|
</if>
|
|
|
</where>
|
|
|
- order by settleDate DESC
|
|
|
+ order by fc.claim_datetime ASC
|
|
|
</sql>
|
|
|
<select id="majorMarketerSettleProd" parameterType="com.dayou.vo.SettleMajorProductionVO" resultMap="settleeMajorProductionVOMap">
|
|
|
<include refid="majorMarketerSettleSql" />
|
|
@@ -1453,6 +1480,7 @@
|
|
|
<result property="clientSubName" column="clientSubName" />
|
|
|
<result property="evaluateDepartmentName" column="evaluateDepartmentName" />
|
|
|
<result property="marketDepartmentName" column="marketDepartmentName" />
|
|
|
+ <result property="payDateTime" column="pay_datetime" />
|
|
|
<collection property="invoices" ofType="com.dayou.vo.SettleProInvoiceVo">
|
|
|
<result property="invoiceDate" column="invoiceDate" />
|
|
|
<result property="invoiceUser" column="invoiceUser" />
|
|
@@ -1463,7 +1491,7 @@
|
|
|
<!--资产市场人员结算项目Sql-->
|
|
|
<sql id="assetsMarketerSettleSql">
|
|
|
SELECT
|
|
|
- ap.id,
|
|
|
+ fc.id,
|
|
|
fc.claim_amount,
|
|
|
a.order_id,
|
|
|
ap.production_no,
|
|
@@ -1495,14 +1523,17 @@
|
|
|
id IN ( SELECT post_id FROM user_post WHERE user_id = a.client_manager_id ))) AS marketDepartmentName,
|
|
|
invoice.name AS invoiceUser,
|
|
|
invoice.real_make_date AS invoiceDate,
|
|
|
- invoice.tax_no AS invoiceNo
|
|
|
+ invoice.tax_no AS invoiceNo,
|
|
|
+ frf.pay_datetime
|
|
|
FROM
|
|
|
(
|
|
|
SELECT
|
|
|
+ id,
|
|
|
claim_amount,
|
|
|
order_fund_id,
|
|
|
production_fund_id,
|
|
|
- claim_datetime
|
|
|
+ claim_datetime,
|
|
|
+ real_fund_id
|
|
|
FROM
|
|
|
finance_claim
|
|
|
WHERE
|
|
@@ -1510,11 +1541,21 @@
|
|
|
AND production_fund_id IS NOT NULL
|
|
|
AND claim_datetime >= #{settleVO.startDate}
|
|
|
AND claim_datetime <= #{settleVO.endDate} UNION ALL
|
|
|
- SELECT allot_amount AS claim_amount, order_fund_id, production_fund_id, created AS claim_datetime FROM
|
|
|
+ SELECT id,allot_amount AS claim_amount, order_fund_id, production_fund_id, created AS claim_datetime,real_fund_id FROM
|
|
|
order_fund_allot WHERE deleted = 0
|
|
|
AND created >= #{settleVO.startDate}
|
|
|
AND created <= #{settleVO.endDate}
|
|
|
) fc
|
|
|
+ inner join (
|
|
|
+ select id,pay_datetime from finance_real_fund
|
|
|
+ where deleted = 0
|
|
|
+ <if test="settleVO!=null and settleVO.payStartDate!=null and settleVO.payStartDate!='' ">
|
|
|
+ AND pay_datetime >= #{settleVO.payStartDate}
|
|
|
+ </if>
|
|
|
+ <if test="settleVO!=null and settleVO.payEndDate!=null and settleVO.payEndDate!='' ">
|
|
|
+ AND pay_datetime <= #{settleVO.payEndDate}
|
|
|
+ </if>
|
|
|
+ ) frf on frf.id = fc.real_fund_id
|
|
|
INNER JOIN ( SELECT id, order_fund_id, business_id, production_no FROM production_fund WHERE business_type =
|
|
|
'ASSET_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id
|
|
|
)
|
|
@@ -1535,20 +1576,16 @@
|
|
|
AND state = '已开票'
|
|
|
) AS invoice ON IF(invoice.production_fund_id IS NOT NULL ,invoice.order_fund_id = pf.order_fund_id AND invoice.production_fund_id = pf.id,invoice.order_fund_id = pf.order_fund_id)
|
|
|
<where>
|
|
|
- <if test="settleVO!=null and settleVO.orderId!=null and settleVO.orderId!='' ">
|
|
|
- and a.order_id = #{settleVO.orderId}
|
|
|
- </if>
|
|
|
- <if test="settleVO!=null and settleVO.productionNo!=null and settleVO.productionNo!='' ">
|
|
|
- and ap.report_no like concat ('%',#{settleVO.productionNo},'%')
|
|
|
- </if>
|
|
|
- <if test="settleVO!=null and settleVO.principal!=null and settleVO.principal!='' ">
|
|
|
- and u.name like concat ('%',#{settleVO.principal},'%')
|
|
|
- </if>
|
|
|
- <if test="settleVO!=null and settleVO.clientManager!=null and settleVO.clientManager!='' ">
|
|
|
- and u1.name like concat ('%',#{settleVO.clientManager},'%')
|
|
|
+ <if test="keyword!=null and keyword!='' ">
|
|
|
+ and (
|
|
|
+ a.order_id = #{keyword}
|
|
|
+ or ap.production_no like concat ('%',#{keyword},'%')
|
|
|
+ or u.name like concat ('%',#{keyword},'%')
|
|
|
+ or u1.name like concat ('%',#{keyword},'%')
|
|
|
+ )
|
|
|
</if>
|
|
|
</where>
|
|
|
- order by settleDate DESC
|
|
|
+ order by fc.claim_datetime ASC
|
|
|
</sql>
|
|
|
|
|
|
<!--资产结算项目查询-->
|
|
@@ -1564,7 +1601,7 @@
|
|
|
<!--资产评估人员结算项目Sql-->
|
|
|
<sql id="assetsEvaluatorSettleSql">
|
|
|
SELECT
|
|
|
- ap.id,
|
|
|
+ fc.id,
|
|
|
fc.claim_amount,
|
|
|
a.order_id,
|
|
|
ap.production_no,
|
|
@@ -1594,14 +1631,17 @@
|
|
|
id IN ( SELECT post_id FROM user_post WHERE user_id = a.client_manager_id ))) AS marketDepartmentName,
|
|
|
invoice.name AS invoiceUser,
|
|
|
invoice.real_make_date AS invoiceDate,
|
|
|
- invoice.tax_no AS invoiceNo
|
|
|
+ invoice.tax_no AS invoiceNo,
|
|
|
+ frf.pay_datetime
|
|
|
FROM
|
|
|
(
|
|
|
SELECT
|
|
|
+ id,
|
|
|
claim_amount,
|
|
|
order_fund_id,
|
|
|
production_fund_id,
|
|
|
- claim_datetime
|
|
|
+ claim_datetime,
|
|
|
+ real_fund_id
|
|
|
FROM
|
|
|
finance_claim
|
|
|
WHERE
|
|
@@ -1609,10 +1649,21 @@
|
|
|
AND production_fund_id IS NOT NULL
|
|
|
AND claim_datetime >= #{settleVO.startDate}
|
|
|
AND claim_datetime <= #{settleVO.endDate} UNION ALL
|
|
|
- SELECT allot_amount AS claim_amount, order_fund_id, production_fund_id, created AS claim_datetime FROM order_fund_allot WHERE deleted = 0
|
|
|
+ SELECT id, allot_amount AS claim_amount, order_fund_id, production_fund_id, created AS claim_datetime ,real_fund_id FROM order_fund_allot WHERE deleted = 0
|
|
|
AND created >= #{settleVO.startDate}
|
|
|
AND created <= #{settleVO.endDate}
|
|
|
) fc
|
|
|
+
|
|
|
+ inner join (
|
|
|
+ select id,pay_datetime from finance_real_fund
|
|
|
+ where deleted = 0
|
|
|
+ <if test="settleVO!=null and settleVO.payStartDate!=null and settleVO.payStartDate!='' ">
|
|
|
+ AND pay_datetime >= #{settleVO.payStartDate}
|
|
|
+ </if>
|
|
|
+ <if test="settleVO!=null and settleVO.payEndDate!=null and settleVO.payEndDate!='' ">
|
|
|
+ AND pay_datetime <= #{settleVO.payEndDate}
|
|
|
+ </if>
|
|
|
+ ) frf on frf.id = fc.real_fund_id
|
|
|
INNER JOIN ( SELECT id, order_fund_id, business_id, production_no FROM production_fund WHERE business_type = 'ASSET_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id )
|
|
|
INNER JOIN ( SELECT id, business_id, assets_name, production_no, production_type, evaluate_amount, save_file_date FROM assets_production WHERE deleted = 0 AND save_file_date IS NOT NULL ) ap ON ap.production_no = pf.production_no
|
|
|
LEFT JOIN assets a ON a.id = ap.business_id
|
|
@@ -1629,20 +1680,16 @@
|
|
|
AND state = '已开票'
|
|
|
) AS invoice ON IF(invoice.production_fund_id IS NOT NULL ,invoice.order_fund_id = pf.order_fund_id AND invoice.production_fund_id = pf.id,invoice.order_fund_id = pf.order_fund_id)
|
|
|
<where>
|
|
|
- <if test="settleVO!=null and settleVO.orderId!=null and settleVO.orderId!='' ">
|
|
|
- and a.order_id = #{settleVO.orderId}
|
|
|
- </if>
|
|
|
- <if test="settleVO!=null and settleVO.productionNo!=null and settleVO.productionNo!='' ">
|
|
|
- and ap.production_no like concat ('%',#{settleVO.productionNo},'%')
|
|
|
- </if>
|
|
|
- <if test="settleVO!=null and settleVO.principal!=null and settleVO.principal!='' ">
|
|
|
- and u.name like concat ('%',#{settleVO.principal},'%')
|
|
|
- </if>
|
|
|
- <if test="settleVO!=null and settleVO.clientManager!=null and settleVO.clientManager!='' ">
|
|
|
- and u1.name like concat ('%',#{settleVO.clientManager},'%')
|
|
|
+ <if test="keyword!=null and keyword!='' ">
|
|
|
+ and (
|
|
|
+ a.order_id = #{keyword}
|
|
|
+ or ap.production_no like concat ('%',#{keyword},'%')
|
|
|
+ or u.name like concat ('%',#{keyword},'%')
|
|
|
+ or u1.name like concat ('%',#{keyword},'%')
|
|
|
+ )
|
|
|
</if>
|
|
|
</where>
|
|
|
- order by settleDate DESC
|
|
|
+ order by fc.claim_datetime ASC
|
|
|
</sql>
|
|
|
|
|
|
<!--资产评估人员结算项目查询-->
|
|
@@ -1655,4 +1702,7 @@
|
|
|
<include refid="assetsEvaluatorSettleSql" />
|
|
|
</select>
|
|
|
|
|
|
+ <select id="exportList" parameterType="com.dayou.entity.FinanceRealFund" resultType="com.dayou.dto.FinanceRealFundExportDTO">
|
|
|
+ <include refid="pageListSql" />
|
|
|
+ </select>
|
|
|
</mapper>
|