13 changed files with 472 additions and 217 deletions
@ -0,0 +1,65 @@ |
|||
package com.qs.serve.modules.tbs.entity.vo; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonIgnore; |
|||
import com.fasterxml.jackson.annotation.JsonProperty; |
|||
import lombok.Data; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
|
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
import java.time.LocalDateTime; |
|||
|
|||
/** |
|||
* 费用申请 VO |
|||
* @author YenHex |
|||
* @since 2022-11-09 |
|||
*/ |
|||
@Data |
|||
public class TbsCostApplySumAmountVo implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** id */ |
|||
private Long id; |
|||
/** |
|||
* 已批准(费用申请) |
|||
*/ |
|||
private BigDecimal costApplyAmt; |
|||
|
|||
/** |
|||
* 已核销 |
|||
*/ |
|||
private BigDecimal checkedAmt; |
|||
|
|||
/** |
|||
* 申请中 |
|||
*/ |
|||
private BigDecimal checkingAmt; |
|||
|
|||
/** |
|||
* 未申请 |
|||
*/ |
|||
private BigDecimal notCheckAmt; |
|||
|
|||
/** |
|||
* 不予核销 |
|||
*/ |
|||
private BigDecimal dontCheckAmt; |
|||
|
|||
/** |
|||
* 已支付 |
|||
*/ |
|||
private BigDecimal payAmt; |
|||
|
|||
/** |
|||
* 待支付 |
|||
*/ |
|||
private BigDecimal unPayAmt; |
|||
|
|||
/** |
|||
* 不再支付 |
|||
*/ |
|||
private BigDecimal notPayAmt; |
|||
|
|||
} |
|||
|
@ -0,0 +1,27 @@ |
|||
package com.qs.serve.modules.tbs.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.qs.serve.modules.excel.entity.DataCheckApplyDetailItem; |
|||
import com.qs.serve.modules.excel.entity.DataCheckApplyMainInfo; |
|||
import com.qs.serve.modules.tbs.entity.TbsActivity; |
|||
import com.qs.serve.modules.tbs.entity.vo.TbsCostApplySumAmountVo; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.apache.ibatis.annotations.Select; |
|||
import org.springframework.security.core.parameters.P; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 费用活动 Mapper |
|||
* @author YenHex |
|||
* @date 2022-11-08 |
|||
*/ |
|||
public interface TbsCostApplySumAmountMapper { |
|||
|
|||
List<DataCheckApplyDetailItem> selectDataCheckApplyDetailItem(@Param("supplierId")String supplierId, |
|||
@Param("costApplyIds")List<Long> costApplyIds); |
|||
|
|||
DataCheckApplyMainInfo selectDataCheckApplyMainInfo(@Param("supplierId")String supplierId); |
|||
} |
|||
|
@ -0,0 +1,158 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.qs.serve.modules.tbs.mapper.TbsCostApplySumAmountMapper"> |
|||
|
|||
<resultMap id="dataCheckApplyDetailItem" type="com.qs.serve.modules.excel.entity.DataCheckApplyDetailItem" > |
|||
<result property="costApplyId" column="id"/> |
|||
<result property="activityCode" column="activity_code"/> |
|||
<result property="activityDate" column="activity_date"/> |
|||
<result property="activityTheme" column="activity_theme"/> |
|||
<result property="costApplyAmt" column="cost_apply_amt"/> |
|||
<result property="checkedAmt" column="checked_amt"/> |
|||
<result property="checkingAmt" column="checking_amt"/> |
|||
<result property="notCheckAmt" column="not_check_amt"/> |
|||
<result property="dontCheckAmt" column="dont_check_amt"/> |
|||
<result property="payAmt" column="pay_amt"/> |
|||
<result property="unPayAmt" column="not_pay_amt"/> |
|||
<result property="notPayAmt" column="un_pay_amt"/> |
|||
</resultMap> |
|||
|
|||
<select id="selectDataCheckApplyDetailItem" resultMap="dataCheckApplyDetailItem"> |
|||
SELECT |
|||
c.id AS id, |
|||
c.code as activity_code, |
|||
DATE_FORMAT(c.submit_time,'%Y%m%d') as activity_date, |
|||
c.charge_theme as activity_theme, |
|||
IFNULL(activity_totals.cost_apply_amt, 0) AS cost_apply_amt, |
|||
IFNULL(verification_totals.checked_amt, 0) AS checked_amt, |
|||
IFNULL(verification_totals.checking_amt, 0) AS checking_amt, |
|||
IFNULL(activity_totals.dont_check_amt, 0) AS dont_check_amt, |
|||
IFNULL(payment_totals.pay_amt, 0) AS pay_amt, |
|||
IFNULL(payment_totals.not_pay_amt, 0) AS not_pay_amt, |
|||
IFNULL(activity_totals.cost_apply_amt - verification_totals.checked_amt - verification_totals.checking_amt - activity_totals.dont_check_amt,0) as not_check_amt, |
|||
IFNULL(verification_totals.checked_amt - payment_totals.pay_amt - payment_totals.not_pay_amt,0) as un_pay_amt |
|||
FROM |
|||
tbs_cost_apply c |
|||
LEFT JOIN ( |
|||
SELECT |
|||
cost_apply_id, |
|||
SUM(total_amount) AS cost_apply_amt, |
|||
SUM(release_amount) AS dont_check_amt |
|||
FROM |
|||
tbs_activity |
|||
WHERE |
|||
del_flag = 0 |
|||
GROUP BY |
|||
cost_apply_id |
|||
) activity_totals ON activity_totals.cost_apply_id = c.id |
|||
LEFT JOIN ( |
|||
SELECT |
|||
cost_apply_id, |
|||
SUM(CASE WHEN verification_state = 1 THEN amount ELSE 0 END) AS checked_amt, |
|||
SUM(CASE WHEN verification_state IN (0, 3) THEN amount ELSE 0 END) AS checking_amt |
|||
FROM |
|||
vtb_verification |
|||
WHERE |
|||
del_flag = 0 |
|||
GROUP BY |
|||
cost_apply_id |
|||
) verification_totals ON verification_totals.cost_apply_id = c.id |
|||
LEFT JOIN ( |
|||
SELECT |
|||
cost_apply_id, |
|||
SUM(CASE WHEN pay_type = 'pay' THEN item_pay_amount ELSE 0 END) AS pay_amt, |
|||
SUM(CASE WHEN pay_type = 'unPay' THEN item_pay_amount ELSE 0 END) AS not_pay_amt |
|||
FROM |
|||
pay_payment_item |
|||
WHERE |
|||
del_flag = 0 |
|||
GROUP BY |
|||
cost_apply_id |
|||
) payment_totals ON payment_totals.cost_apply_id = c.id |
|||
WHERE |
|||
c.del_flag = 0 |
|||
AND c.charge_state IN (2, 3) |
|||
<if test="costApplyIds !=null and costApplyIds.size > 0"> |
|||
and c.id in |
|||
<foreach collection="costApplyIds" item ="selectId" index="i" open="(" close=")" separator=","> |
|||
#{selectId} |
|||
</foreach> |
|||
</if> |
|||
<if test="supplierId !=null"> |
|||
AND c.supplier_id = #{supplierId}; |
|||
</if> |
|||
order by c.submit_time |
|||
</select> |
|||
|
|||
<resultMap id="dataCheckApplyMainInfo" type="com.qs.serve.modules.excel.entity.DataCheckApplyMainInfo" > |
|||
<result property="costApplyId" column="id"/> |
|||
<result property="activityCode" column="activity_code"/> |
|||
<result property="activityDate" column="activity_date"/> |
|||
<result property="activityTheme" column="activity_theme"/> |
|||
<result property="costApplyAmt" column="cost_apply_amt"/> |
|||
<result property="checkedAmt" column="checked_amt"/> |
|||
<result property="checkingAmt" column="checking_amt"/> |
|||
<result property="notCheckAmt" column="not_check_amt"/> |
|||
<result property="dontCheckAmt" column="dont_check_amt"/> |
|||
<result property="payAmt" column="pay_amt"/> |
|||
<result property="unPayAmt" column="not_pay_amt"/> |
|||
<result property="notPayAmt" column="un_pay_amt"/> |
|||
</resultMap> |
|||
|
|||
<select id="selectDataCheckApplyMainInfo" resultMap="dataCheckApplyMainInfo"> |
|||
SELECT |
|||
IFNULL(SUM(activity_totals.cost_apply_amt), 0) AS cost_apply_amt, |
|||
IFNULL(SUM(verification_totals.checked_amt), 0) AS checked_amt, |
|||
IFNULL(SUM(verification_totals.checking_amt), 0) AS checking_amt, |
|||
IFNULL(SUM(activity_totals.dont_check_amt), 0) AS dont_check_amt, |
|||
IFNULL(SUM(payment_totals.pay_amt), 0) AS pay_amt, |
|||
IFNULL(SUM(payment_totals.not_pay_amt), 0) AS not_pay_amt, |
|||
IFNULL(SUM(activity_totals.cost_apply_amt - verification_totals.checked_amt - verification_totals.checking_amt - activity_totals.dont_check_amt),0) as not_check_amt, |
|||
IFNULL(SUM(verification_totals.checked_amt - payment_totals.pay_amt - payment_totals.not_pay_amt),0) as un_pay_amt |
|||
FROM |
|||
tbs_cost_apply c |
|||
LEFT JOIN ( |
|||
SELECT |
|||
cost_apply_id, |
|||
SUM(total_amount) AS cost_apply_amt, |
|||
SUM(release_amount) AS dont_check_amt |
|||
FROM |
|||
tbs_activity |
|||
WHERE |
|||
del_flag = 0 |
|||
GROUP BY |
|||
cost_apply_id |
|||
) activity_totals ON activity_totals.cost_apply_id = c.id |
|||
LEFT JOIN ( |
|||
SELECT |
|||
cost_apply_id, |
|||
SUM(CASE WHEN verification_state = 1 THEN amount ELSE 0 END) AS checked_amt, |
|||
SUM(CASE WHEN verification_state IN (0, 3) THEN amount ELSE 0 END) AS checking_amt |
|||
FROM |
|||
vtb_verification |
|||
WHERE |
|||
del_flag = 0 |
|||
GROUP BY |
|||
cost_apply_id |
|||
) verification_totals ON verification_totals.cost_apply_id = c.id |
|||
LEFT JOIN ( |
|||
SELECT |
|||
cost_apply_id, |
|||
SUM(CASE WHEN pay_type = 'pay' THEN item_pay_amount ELSE 0 END) AS pay_amt, |
|||
SUM(CASE WHEN pay_type = 'unPay' THEN item_pay_amount ELSE 0 END) AS not_pay_amt |
|||
FROM |
|||
pay_payment_item |
|||
WHERE |
|||
del_flag = 0 |
|||
GROUP BY |
|||
cost_apply_id |
|||
) payment_totals ON payment_totals.cost_apply_id = c.id |
|||
WHERE |
|||
c.del_flag = 0 |
|||
AND c.charge_state IN (2, 3) |
|||
<if test="supplierId !=null"> |
|||
AND c.supplier_id = #{supplierId}; |
|||
</if> |
|||
</select> |
|||
</mapper> |
|||
|
Loading…
Reference in new issue