|
|
@@ -2211,38 +2211,42 @@ left join department d on o.order_dep = d.id left join t_order_mid a on o.orde
|
|
|
</select>
|
|
|
<select id="selectExpenseCount" parameterType="com.goafanti.expenseAccount.bo.ExpenseCountsInput" resultType="com.goafanti.expenseAccount.bo.ExpenseCountsBo">
|
|
|
select a.order_no orderNo,a.contract_no contractNo,b.buyer_name buyerName,a.total_amount totalAmount,a.settlement_amount settlementAmount,
|
|
|
- c.expenseCount,c.peopleCount,c.notExamine,c.rejectCount,c.paymentAmount,c.days,c.amount expenseAmount
|
|
|
- from t_order_new a left join t_order_mid b on a.order_no =b.order_no left join (select a.order_no,a.expenseCount,b.peopleCount,c.notExamine,
|
|
|
- c.rejectCount,ifnull(d.paymentAmount,0)paymentAmount,a.days,a.amount
|
|
|
- from (select a.order_no,count(a.id)expenseCount,sum(a.amount) amount,
|
|
|
- sum(ROUND(a.duration/7.5) )days from expense_account a where a.order_no in (select a.order_no from expense_account a
|
|
|
- where a.target_type = #{targetType}
|
|
|
- group by order_no)
|
|
|
+ c.expenseCount,c.peopleCount,c.notExamine,c.rejectCount,d.paymentAmount,c.days,c.amount expenseAmount
|
|
|
+ from t_order_new a left join t_order_mid b on a.order_no =b.order_no
|
|
|
+ left join (select a.order_no,a.expenseCount,b.peopleCount,c.notExamine, c.rejectCount,a.days,a.amount
|
|
|
+ from (select a.order_no,count(a.id)expenseCount,sum(a.amount) amount,sum(ROUND(a.duration/7.5) )days
|
|
|
+ from expense_account a where a.order_no in (select a.order_no from expense_account a
|
|
|
+ where a.target_type = 1 group by order_no)
|
|
|
+ and a.status=2
|
|
|
<if test="startTime !=null and endTime != null">
|
|
|
and a.create_time BETWEEN #{startTime} and #{endTime}
|
|
|
</if>
|
|
|
- group by order_no )a left join (select order_no,count(aid)peopleCount from (select a.order_no,aid from expense_account a where a.order_no in
|
|
|
- (select a.order_no from expense_account a where a.target_type = #{targetType}
|
|
|
+ group by order_no )a
|
|
|
+ left join (select order_no,count(aid)peopleCount from (select a.order_no,aid from expense_account a where a.order_no in
|
|
|
+ (select a.order_no from expense_account a where a.target_type = 1
|
|
|
+ and a.status=2
|
|
|
group by order_no)
|
|
|
<if test="startTime !=null and endTime != null">
|
|
|
and a.create_time BETWEEN #{startTime} and #{endTime}
|
|
|
</if>
|
|
|
- group by order_no,aid )a group by order_no)b on a.order_no=b.order_no left join (select a.order_no,sum(notExamine)notExamine,sum(rejectCount)rejectCount
|
|
|
+ group by order_no,aid )a group by order_no)b on a.order_no=b.order_no
|
|
|
+ left join (select a.order_no,sum(notExamine)notExamine,sum(rejectCount)rejectCount
|
|
|
from (select a.order_no,status ,IF(status=1,1,0)notExamine,IF(status=3,1,0)rejectCount
|
|
|
- from expense_account a where a.order_no in (select a.order_no from expense_account a where a.target_type = #{targetType}
|
|
|
+ from expense_account a where a.order_no in (select a.order_no from expense_account a where a.target_type = 1
|
|
|
group by order_no)
|
|
|
<if test="startTime !=null and endTime != null">
|
|
|
and a.create_time BETWEEN #{startTime} and #{endTime}
|
|
|
</if>
|
|
|
- )a group by order_no)c on a.order_no=c.order_no left join ( select a.order_no ,sum(c.payment_amount) paymentAmount
|
|
|
- from t_order_new a left join t_order_task b on a.order_no =b.order_no left join t_order_payment c on b.id =c.tid
|
|
|
- where c.status =3 and a.order_no in (select a.order_no from expense_account a where a.target_type = #{targetType}
|
|
|
- group by order_no)
|
|
|
- <if test="startTime !=null and endTime != null">
|
|
|
- and a.create_time BETWEEN #{startTime} and #{endTime}
|
|
|
- </if>
|
|
|
- group by order_no )d on a.order_no=d.order_no)c on a.order_no =c.order_no
|
|
|
- where a.order_no in (select a.order_no from expense_account a where a.target_type = #{targetType}
|
|
|
+ )a group by order_no)c on a.order_no=c.order_no )c on a.order_no =c.order_no
|
|
|
+ left join ( select a.order_no ,sum(c.payment_amount) paymentAmount
|
|
|
+ from t_order_new a left join t_order_task b on a.order_no =b.order_no left join t_order_payment c on b.id =c.tid
|
|
|
+ where c.status =3 and a.order_no in (select a.order_no from expense_account a where a.target_type = 1
|
|
|
+ group by order_no)
|
|
|
+ <if test="startTime !=null and endTime != null">
|
|
|
+ and a.create_time BETWEEN #{startTime} and #{endTime}
|
|
|
+ </if>
|
|
|
+ group by order_no )d on a.order_no=d.order_no
|
|
|
+ where a.order_no in (select a.order_no from expense_account a where a.target_type = 1
|
|
|
<if test="startTime !=null and endTime != null">
|
|
|
and a.create_time BETWEEN #{startTime} and #{endTime}
|
|
|
</if>
|