10 changed files with 416 additions and 13 deletions
@ -0,0 +1,27 @@ |
|||
package com.qs.serve.modules.check.service; |
|||
|
|||
import com.qs.serve.modules.check.common.DataSupplierSo; |
|||
import com.qs.serve.modules.check.entity.DataCheckApplyDetailInfo; |
|||
import com.qs.serve.modules.check.entity.DataCheckApplyMainInfo; |
|||
|
|||
/** |
|||
* @author YenHex |
|||
* @since 2023/6/2 |
|||
*/ |
|||
public interface DateCheckApplyService { |
|||
|
|||
/** |
|||
* 获取明细帐 |
|||
* @param param |
|||
* @return |
|||
*/ |
|||
DataCheckApplyDetailInfo getDataCheckApplyDetailInfo(DataSupplierSo param); |
|||
|
|||
/** |
|||
* 汇总单 |
|||
* @param param |
|||
* @return |
|||
*/ |
|||
DataCheckApplyMainInfo getDataCheckApplyMainInfo(DataSupplierSo param); |
|||
|
|||
} |
@ -0,0 +1,251 @@ |
|||
package com.qs.serve.modules.check.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.qs.serve.modules.bms.entity.BmsSupplier; |
|||
import com.qs.serve.modules.bms.entity.BmsSupplierContacts; |
|||
import com.qs.serve.modules.bms.mapper.BmsSupplierContactsMapper; |
|||
import com.qs.serve.modules.bms.mapper.BmsSupplierMapper; |
|||
import com.qs.serve.modules.bms.service.BmsSupplierContactsService; |
|||
import com.qs.serve.modules.check.common.DataSupplierSo; |
|||
import com.qs.serve.modules.check.entity.DataCheckApplyDetailInfo; |
|||
import com.qs.serve.modules.check.entity.DataCheckApplyDetailItem; |
|||
import com.qs.serve.modules.check.entity.DataCheckApplyMainInfo; |
|||
import com.qs.serve.modules.check.service.DateCheckApplyService; |
|||
import com.qs.serve.modules.pay.common.PaymentType; |
|||
import com.qs.serve.modules.pay.entity.PayPayment; |
|||
import com.qs.serve.modules.pay.entity.PayPaymentItem; |
|||
import com.qs.serve.modules.pay.mapper.PayPaymentItemMapper; |
|||
import com.qs.serve.modules.pay.mapper.PayPaymentMapper; |
|||
import com.qs.serve.modules.tbs.entity.TbsActivity; |
|||
import com.qs.serve.modules.tbs.entity.TbsCostApply; |
|||
import com.qs.serve.modules.tbs.mapper.TbsActivityMapper; |
|||
import com.qs.serve.modules.tbs.mapper.TbsCostApplyMapper; |
|||
import com.qs.serve.modules.vtb.common.VtbVerificationState; |
|||
import com.qs.serve.modules.vtb.entity.VtbVerification; |
|||
import com.qs.serve.modules.vtb.mapper.VtbVerificationMapper; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.time.LocalDate; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* @author YenHex |
|||
* @since 2023/6/2 |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
@AllArgsConstructor |
|||
public class DateCheckApplyServiceImpl implements DateCheckApplyService { |
|||
|
|||
private final TbsActivityMapper activityMapper; |
|||
private final TbsCostApplyMapper costApplyMapper; |
|||
private final VtbVerificationMapper verificationMapper; |
|||
//private final PayPaymentMapper paymentMapper;
|
|||
private final PayPaymentItemMapper payPaymentItemMapper; |
|||
private final BmsSupplierMapper supplierMapper; |
|||
private final BmsSupplierContactsService supplierContactsService; |
|||
|
|||
@Override |
|||
public DataCheckApplyDetailInfo getDataCheckApplyDetailInfo(DataSupplierSo param) { |
|||
String supplierId = param.getSupplierId(); |
|||
BmsSupplier supplier = supplierMapper.selectById(supplierId); |
|||
LambdaQueryWrapper<BmsSupplierContacts> conLqw = new LambdaQueryWrapper<>(); |
|||
conLqw.eq(BmsSupplierContacts::getSupplierId,supplierId); |
|||
BmsSupplierContacts contacts = supplierContactsService.getOne(conLqw,false); |
|||
DataCheckApplyDetailInfo detailInfo = new DataCheckApplyDetailInfo(); |
|||
detailInfo.setCusName(supplier.getName()); |
|||
detailInfo.setCusAddress(supplier.getAddress()); |
|||
detailInfo.setCusCode(supplier.getCode()); |
|||
if(contacts!=null){ |
|||
detailInfo.setContactUser(contacts.getContactsName()); |
|||
detailInfo.setContactMobile(contacts.getContactsNumber()); |
|||
} |
|||
detailInfo.setStartDate(param.getStartDate()); |
|||
detailInfo.setEndDate(param.getEndDate()); |
|||
|
|||
LambdaQueryWrapper<TbsActivity> actLqw = new LambdaQueryWrapper<>(); |
|||
actLqw.eq(TbsActivity::getSupplierId,supplierId); |
|||
actLqw.eq(TbsActivity::getCostPassFlag,1); |
|||
//暂未定义时间区间
|
|||
List<TbsActivity> activityList = activityMapper.selectList(actLqw); |
|||
List<DataCheckApplyDetailItem> detailItemList = new ArrayList<>(); |
|||
for (TbsActivity activity : activityList) { |
|||
TbsCostApply costApply = costApplyMapper.selectById(activity.getCostApplyId()); |
|||
DataCheckApplyDetailItem detailItem = new DataCheckApplyDetailItem(); |
|||
detailItem.setActivityCode(activity.getActivityCode()); |
|||
detailItem.setActivityDate(costApply.getSubmitTime().toLocalDate().toString()); |
|||
detailItem.setActivityTheme(activity.getActTitle()); |
|||
detailItem.setCostApplyAmt(activity.getTotalAmount()); |
|||
|
|||
LambdaQueryWrapper<VtbVerification> veriLqw = new LambdaQueryWrapper<>(); |
|||
veriLqw.select(VtbVerification::getVerificationState,VtbVerification::getAmount); |
|||
veriLqw.eq(VtbVerification::getActivityId,activity.getId()); |
|||
veriLqw.in(VtbVerification::getVerificationState, |
|||
VtbVerificationState.Finished.getCode(), |
|||
VtbVerificationState.Rollback.getCode(), |
|||
VtbVerificationState.Commiting.getCode()); |
|||
List<VtbVerification> vtbVerificationList = verificationMapper.selectList(veriLqw); |
|||
List<VtbVerification> finishedVeriList= vtbVerificationList.stream() |
|||
.filter(a->a.getVerificationState().equals(VtbVerificationState.Finished.getCode())).collect(Collectors.toList()); |
|||
List<VtbVerification> unFinishVeriList= vtbVerificationList.stream() |
|||
.filter(a->!a.getVerificationState().equals(VtbVerificationState.Finished.getCode())).collect(Collectors.toList()); |
|||
|
|||
BigDecimal checkedAmt = BigDecimal.ZERO; |
|||
for (VtbVerification verification : finishedVeriList) { |
|||
checkedAmt = checkedAmt.add(verification.getAmount()); |
|||
} |
|||
|
|||
BigDecimal notCheckAmt = BigDecimal.ZERO; |
|||
for (VtbVerification verification : unFinishVeriList) { |
|||
notCheckAmt = notCheckAmt.add(verification.getAmount()); |
|||
} |
|||
|
|||
detailItem.setCheckedAmt(checkedAmt); |
|||
detailItem.setCheckingAmt(notCheckAmt); |
|||
detailItem.setDontCheckAmt(activity.getReleaseAmount()); |
|||
BigDecimal notCheckedAmt = activity.getTotalAmount().subtract(detailItem.getCheckedAmt()) |
|||
.subtract(detailItem.getCheckingAmt()) |
|||
.subtract(detailItem.getDontCheckAmt()); |
|||
detailItem.setNotCheckAmt(notCheckedAmt); |
|||
|
|||
if(checkedAmt.compareTo(BigDecimal.ZERO)==0){ |
|||
detailItem.setPayAmt(BigDecimal.ZERO); |
|||
detailItem.setUnPayAmt(BigDecimal.ZERO); |
|||
detailItem.setNotPayAmt(BigDecimal.ZERO); |
|||
}else { |
|||
//已支付
|
|||
PayPaymentItem payItemQuery = new PayPaymentItem(); |
|||
payItemQuery.setCancelFlag(0); |
|||
payItemQuery.setActivityId(activity.getId()); |
|||
List<PayPaymentItem> allPayList = payPaymentItemMapper.selectPayPaymentItemList(payItemQuery); |
|||
List<PayPaymentItem> payList = allPayList.stream().filter(a->a.getPayType().equals(PaymentType.PAYMENT)).collect(Collectors.toList()); |
|||
List<PayPaymentItem> unPayList = allPayList.stream().filter(a->a.getPayType().equals(PaymentType.UN_PAYMENT)).collect(Collectors.toList()); |
|||
|
|||
//不再支付
|
|||
BigDecimal notPayAmt = BigDecimal.ZERO; |
|||
for (PayPaymentItem paymentItem : unPayList) { |
|||
notPayAmt = notPayAmt.add(paymentItem.getItemPayAmount()); |
|||
} |
|||
|
|||
BigDecimal payAmt = BigDecimal.ZERO; |
|||
for (PayPaymentItem paymentItem : payList) { |
|||
payAmt = payAmt.add(paymentItem.getItemPayAmount()); |
|||
} |
|||
//未支付
|
|||
BigDecimal unPayAmt = checkedAmt.subtract(payAmt).subtract(notPayAmt); |
|||
|
|||
detailItem.setPayAmt(payAmt); |
|||
detailItem.setUnPayAmt(unPayAmt); |
|||
detailItem.setNotPayAmt(notPayAmt); |
|||
} |
|||
detailItemList.add(detailItem); |
|||
} |
|||
detailInfo.setDetailList(detailItemList); |
|||
return detailInfo; |
|||
} |
|||
|
|||
@Override |
|||
public DataCheckApplyMainInfo getDataCheckApplyMainInfo(DataSupplierSo param) { |
|||
String supplierId = param.getSupplierId(); |
|||
BmsSupplier supplier = supplierMapper.selectById(supplierId); |
|||
LambdaQueryWrapper<BmsSupplierContacts> conLqw = new LambdaQueryWrapper<>(); |
|||
conLqw.eq(BmsSupplierContacts::getSupplierId,supplierId); |
|||
BmsSupplierContacts contacts = supplierContactsService.getOne(conLqw,false); |
|||
DataCheckApplyMainInfo mainInfo = new DataCheckApplyMainInfo(); |
|||
mainInfo.setCusName(supplier.getName()); |
|||
mainInfo.setCusAddress(supplier.getAddress()); |
|||
mainInfo.setCusCode(supplier.getCode()); |
|||
if(contacts!=null){ |
|||
mainInfo.setContactUser(contacts.getContactsName()); |
|||
mainInfo.setContactMobile(contacts.getContactsNumber()); |
|||
} |
|||
mainInfo.setStartDate(null); |
|||
mainInfo.setEndDate(LocalDate.now()); |
|||
|
|||
//申请总金额
|
|||
BigDecimal totalAmount = activityMapper.sumSupplierActivityCost(supplierId); |
|||
mainInfo.setCostApplyAmt(totalAmount); |
|||
if(totalAmount.compareTo(BigDecimal.ZERO)==0){ |
|||
mainInfo.setCostApplyAmt(totalAmount); |
|||
mainInfo.setCheckedAmt(totalAmount); |
|||
mainInfo.setCheckingAmt(totalAmount); |
|||
mainInfo.setNotCheckAmt(totalAmount); |
|||
mainInfo.setDontCheckAmt(totalAmount); |
|||
mainInfo.setPayAmt(totalAmount); |
|||
mainInfo.setUnPayAmt(totalAmount); |
|||
mainInfo.setNotPayAmt(totalAmount); |
|||
}else { |
|||
LambdaQueryWrapper<VtbVerification> veriLqw = new LambdaQueryWrapper<>(); |
|||
veriLqw.select(VtbVerification::getVerificationState,VtbVerification::getAmount); |
|||
veriLqw.eq(VtbVerification::getSupplierId,supplierId); |
|||
veriLqw.in(VtbVerification::getVerificationState, |
|||
VtbVerificationState.Finished.getCode(), |
|||
VtbVerificationState.Rollback.getCode(), |
|||
VtbVerificationState.Commiting.getCode()); |
|||
List<VtbVerification> vtbVerificationList = verificationMapper.selectList(veriLqw); |
|||
List<VtbVerification> finishedVeriList= vtbVerificationList.stream() |
|||
.filter(a->a.getVerificationState().equals(VtbVerificationState.Finished.getCode())).collect(Collectors.toList()); |
|||
List<VtbVerification> unFinishVeriList= vtbVerificationList.stream() |
|||
.filter(a->!a.getVerificationState().equals(VtbVerificationState.Finished.getCode())).collect(Collectors.toList()); |
|||
|
|||
BigDecimal checkedAmt = BigDecimal.ZERO; |
|||
for (VtbVerification verification : finishedVeriList) { |
|||
checkedAmt = checkedAmt.add(verification.getAmount()); |
|||
} |
|||
|
|||
BigDecimal notCheckAmt = BigDecimal.ZERO; |
|||
for (VtbVerification verification : unFinishVeriList) { |
|||
notCheckAmt = notCheckAmt.add(verification.getAmount()); |
|||
} |
|||
//不再支付统计
|
|||
BigDecimal dontCheckAmt = activityMapper.sumSupplierNotCheckCost(supplierId); |
|||
|
|||
mainInfo.setCheckedAmt(checkedAmt); |
|||
mainInfo.setCheckingAmt(notCheckAmt); |
|||
mainInfo.setDontCheckAmt(dontCheckAmt); |
|||
BigDecimal notCheckedAmt = mainInfo.getCostApplyAmt().subtract(mainInfo.getCheckedAmt()) |
|||
.subtract(mainInfo.getCheckingAmt()) |
|||
.subtract(mainInfo.getDontCheckAmt()); |
|||
mainInfo.setNotCheckAmt(notCheckedAmt); |
|||
|
|||
if(checkedAmt.compareTo(BigDecimal.ZERO)>0){ |
|||
|
|||
//已支付
|
|||
PayPaymentItem payItemQuery = new PayPaymentItem(); |
|||
payItemQuery.setCancelFlag(0); |
|||
payItemQuery.setSupplierId(Long.parseLong(supplierId)); |
|||
List<PayPaymentItem> allPayList = payPaymentItemMapper.selectPayPaymentItemList(payItemQuery); |
|||
List<PayPaymentItem> payList = allPayList.stream().filter(a->a.getPayType().equals(PaymentType.PAYMENT)).collect(Collectors.toList()); |
|||
List<PayPaymentItem> unPayList = allPayList.stream().filter(a->a.getPayType().equals(PaymentType.UN_PAYMENT)).collect(Collectors.toList()); |
|||
|
|||
//不再支付
|
|||
BigDecimal notPayAmt = BigDecimal.ZERO; |
|||
for (PayPaymentItem paymentItem : unPayList) { |
|||
notPayAmt = notPayAmt.add(paymentItem.getItemPayAmount()); |
|||
} |
|||
|
|||
BigDecimal payAmt = BigDecimal.ZERO; |
|||
for (PayPaymentItem paymentItem : payList) { |
|||
payAmt = payAmt.add(paymentItem.getItemPayAmount()); |
|||
} |
|||
//未支付
|
|||
BigDecimal unPayAmt = checkedAmt.subtract(payAmt).subtract(notPayAmt); |
|||
|
|||
mainInfo.setPayAmt(payAmt); |
|||
mainInfo.setUnPayAmt(unPayAmt); |
|||
mainInfo.setNotPayAmt(notPayAmt); |
|||
}else { |
|||
mainInfo.setPayAmt(BigDecimal.ZERO); |
|||
mainInfo.setUnPayAmt(BigDecimal.ZERO); |
|||
mainInfo.setNotPayAmt(BigDecimal.ZERO); |
|||
} |
|||
|
|||
} |
|||
return mainInfo; |
|||
} |
|||
} |
@ -0,0 +1,85 @@ |
|||
<?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.pay.mapper.PayPaymentItemMapper"> |
|||
|
|||
<resultMap id="payPaymentItemMap" type="com.qs.serve.modules.pay.entity.PayPaymentItem" > |
|||
<result property="id" column="id"/> |
|||
<result property="payType" column="pay_type"/> |
|||
<result property="paymentId" column="payment_id"/> |
|||
<result property="supplierId" column="supplier_id"/> |
|||
<result property="itemPayAmount" column="item_pay_amount"/> |
|||
<result property="verificationId" column="verification_id"/> |
|||
<result property="verificationSubjectId" column="verification_subject_id"/> |
|||
<result property="costApplyId" column="cost_apply_id"/> |
|||
<result property="activityId" column="activity_id"/> |
|||
<result property="activityCode" column="activity_code"/> |
|||
<result property="subjectId" column="subject_id"/> |
|||
<result property="subjectCode" column="subject_code"/> |
|||
<result property="subjectName" column="subject_name"/> |
|||
<result property="remark" column="remark"/> |
|||
<result property="createTime" column="create_time"/> |
|||
<result property="updateTime" column="update_time"/> |
|||
<result property="tenantId" column="tenant_id"/> |
|||
<result property="createBy" column="create_by"/> |
|||
<result property="updateBy" column="update_by"/> |
|||
<result property="delFlag" column="del_flag"/> |
|||
<result property="policyItemId" column="policy_item_id"/> |
|||
<result property="policyItemCode" column="policy_item_code"/> |
|||
</resultMap> |
|||
|
|||
<sql id="payPaymentItemSql"> |
|||
pay_payment_item.`id`, |
|||
pay_payment_item.`pay_type`, |
|||
pay_payment_item.`payment_id`, |
|||
pay_payment_item.`supplier_id`, |
|||
pay_payment_item.`item_pay_amount`, |
|||
pay_payment_item.`verification_id`, |
|||
pay_payment_item.`verification_subject_id`, |
|||
pay_payment_item.`cost_apply_id`, |
|||
pay_payment_item.`activity_id`, |
|||
pay_payment_item.`activity_code`, |
|||
pay_payment_item.`subject_id`, |
|||
pay_payment_item.`subject_code`, |
|||
pay_payment_item.`subject_name`, |
|||
pay_payment_item.`remark`, |
|||
pay_payment_item.`create_time`, |
|||
pay_payment_item.`update_time`, |
|||
pay_payment_item.`tenant_id`, |
|||
pay_payment_item.`create_by`, |
|||
pay_payment_item.`update_by`, |
|||
pay_payment_item.`del_flag`, |
|||
pay_payment_item.`policy_item_id`, |
|||
pay_payment_item.`policy_item_code` </sql> |
|||
|
|||
<select id="selectPayPaymentItemList" parameterType="com.qs.serve.modules.pay.entity.PayPaymentItem" resultMap="payPaymentItemMap"> |
|||
SELECT <include refid="payPaymentItemSql"/> FROM `pay_payment_item` `pay_payment_item` |
|||
left join pay_payment on pay_payment_item.payment_id = pay_payment.id |
|||
<where> |
|||
<if test="query.cancelFlag != null"> and `pay_payment`.`cancel_flag` = #{query.cancelFlag}</if> |
|||
<if test="query.id != null"> and `pay_payment_item`.`id` = #{query.id}</if> |
|||
<if test="query.payType != null and query.payType != ''"> and `pay_payment_item`.`pay_type` = #{query.payType}</if> |
|||
<if test="query.paymentId != null"> and `pay_payment_item`.`payment_id` = #{query.paymentId}</if> |
|||
<if test="query.supplierId != null"> and `pay_payment_item`.`supplier_id` = #{query.supplierId}</if> |
|||
<if test="query.itemPayAmount != null"> and `pay_payment_item`.`item_pay_amount` = #{query.itemPayAmount}</if> |
|||
<if test="query.verificationId != null"> and `pay_payment_item`.`verification_id` = #{query.verificationId}</if> |
|||
<if test="query.verificationSubjectId != null"> and `pay_payment_item`.`verification_subject_id` = #{query.verificationSubjectId}</if> |
|||
<if test="query.costApplyId != null"> and `pay_payment_item`.`cost_apply_id` = #{query.costApplyId}</if> |
|||
<if test="query.activityId != null"> and `pay_payment_item`.`activity_id` = #{query.activityId}</if> |
|||
<if test="query.activityCode != null and query.activityCode != ''"> and `pay_payment_item`.`activity_code` = #{query.activityCode}</if> |
|||
<if test="query.subjectId != null"> and `pay_payment_item`.`subject_id` = #{query.subjectId}</if> |
|||
<if test="query.subjectCode != null and query.subjectCode != ''"> and `pay_payment_item`.`subject_code` = #{query.subjectCode}</if> |
|||
<if test="query.subjectName != null and query.subjectName != ''"> and `pay_payment_item`.`subject_name` = #{query.subjectName}</if> |
|||
<if test="query.createTime != null"> and `pay_payment_item`.`create_time` = #{query.createTime}</if> |
|||
<if test="query.updateTime != null"> and `pay_payment_item`.`update_time` = #{query.updateTime}</if> |
|||
<if test="query.tenantId != null and query.tenantId != ''"> and `pay_payment_item`.`tenant_id` = #{query.tenantId}</if> |
|||
<if test="query.createBy != null and query.createBy != ''"> and `pay_payment_item`.`create_by` = #{query.createBy}</if> |
|||
<if test="query.updateBy != null and query.updateBy != ''"> and `pay_payment_item`.`update_by` = #{query.updateBy}</if> |
|||
<if test="query.delFlag != null and query.delFlag != ''"> and `pay_payment_item`.`del_flag` = #{query.delFlag}</if> |
|||
<if test="query.policyItemId != null"> and `pay_payment_item`.`policy_item_id` = #{query.policyItemId}</if> |
|||
<if test="query.policyItemCode != null and query.policyItemCode != ''"> and `pay_payment_item`.`policy_item_code` = #{query.policyItemCode}</if> |
|||
</where> |
|||
</select> |
|||
|
|||
</mapper> |
Loading…
Reference in new issue