|
@@ -11,6 +11,7 @@ import com.jy.business.contract.model.table.ContractInfoTable;
|
|
|
import com.jy.business.contract.model.vo.ContractInfoVo;
|
|
|
import com.jy.business.contract.model.vo.ContractStatisticsVo;
|
|
|
import com.jy.business.contract.model.vo.TransactionVo;
|
|
|
+import com.jy.business.payment.model.entity.PaymentRequestsDetail;
|
|
|
import com.jy.business.payment.model.table.PaymentRemitTable;
|
|
|
import com.jy.business.payment.model.table.PaymentRequestsDetailTable;
|
|
|
import com.jy.business.payment.model.table.PaymentRequestsTable;
|
|
@@ -23,9 +24,12 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class ContractInfoDao extends BaseDao<ContractInfoMapper, ContractInfo> {
|
|
|
|
|
|
- public List<ContractStatisticsVo> getStatistics() {
|
|
|
+ public List<ContractStatisticsVo> getStatistics(ContractInfoSelectDto dto) {
|
|
|
ContractInfoTable ci = ContractInfoTable.ci;
|
|
|
CapitalTransactionsTable ct = CapitalTransactionsTable.ct;
|
|
|
+ PaymentRequestsDetailTable prd = PaymentRequestsDetailTable.prd;
|
|
|
+ PaymentRequestsTable pr = PaymentRequestsTable.pr;
|
|
|
+ PaymentRemitTable pre = PaymentRemitTable.payment_remit;
|
|
|
|
|
|
TempTable t = sql().select(
|
|
|
_ifNull(_sum(ct.amount), 0).as(ContractStatisticsVo::getFundReceivedAmount),
|
|
@@ -36,15 +40,33 @@ public class ContractInfoDao extends BaseDao<ContractInfoMapper, ContractInfo> {
|
|
|
.groupBy(ci.sellerCompany)
|
|
|
.toTable("t");
|
|
|
|
|
|
+ TempTable t2 = sql().select(
|
|
|
+ _ifNull(_sum(prd.amount), 0).as("amount"),
|
|
|
+ ci.sellerCompany
|
|
|
+ )
|
|
|
+ .from(prd)
|
|
|
+ .innerJoin(ci).on(ci.id.eq(prd.contractId))
|
|
|
+ .innerJoin(pr).on(prd.paymentRequestsId.eq(pr.id))
|
|
|
+ .innerJoin(pre).on(pre.paymentRequestsId.eq(pr.id))
|
|
|
+ .groupBy(ci.sellerCompany)
|
|
|
+ .toTable("t2");
|
|
|
+
|
|
|
return sql(ContractStatisticsVo.class)
|
|
|
.select(
|
|
|
ci.sellerCompany,
|
|
|
_count(0).as(ContractStatisticsVo::getContractQuantity),
|
|
|
_sum(ci.amount).as(ContractStatisticsVo::getContractAmount),
|
|
|
- t.field(ContractStatisticsVo::getFundReceivedAmount)
|
|
|
+ t.field(ContractStatisticsVo::getFundReceivedAmount),
|
|
|
+ column("t.fund_received_amount - t2.amount").as(ContractStatisticsVo::getProfit)
|
|
|
)
|
|
|
.from(ci)
|
|
|
.leftJoin(t).on(ci.sellerCompany.eq(t.field(ContractInfo::getSellerCompany)))
|
|
|
+ .leftJoin(t2).on(ci.sellerCompany.eq(t2.field(ContractInfo::getSellerCompany)))
|
|
|
+ .where(
|
|
|
+ ci.contractNo.like(dto.getContractNo()),
|
|
|
+ ci.status.eq(dto.getStatus()),
|
|
|
+ ci.signingDate.between(dto.getStartDate(), dto.getEndDate())
|
|
|
+ )
|
|
|
.groupBy(ci.sellerCompany)
|
|
|
.list();
|
|
|
}
|
|
@@ -86,7 +108,9 @@ public class ContractInfoDao extends BaseDao<ContractInfoMapper, ContractInfo> {
|
|
|
)
|
|
|
.from(ci)
|
|
|
.where(
|
|
|
- ci.contractNo.like(dto.getContractNo())
|
|
|
+ ci.contractNo.like(dto.getContractNo()),
|
|
|
+ ci.status.eq(dto.getStatus()),
|
|
|
+ ci.signingDate.between(dto.getStartDate(), dto.getEndDate())
|
|
|
)
|
|
|
.orderBy(
|
|
|
ci.id.desc()
|
|
@@ -118,7 +142,6 @@ public class ContractInfoDao extends BaseDao<ContractInfoMapper, ContractInfo> {
|
|
|
PaymentRequestsTable pr = PaymentRequestsTable.pr;
|
|
|
PaymentRemitTable pre = PaymentRemitTable.payment_remit;
|
|
|
|
|
|
-
|
|
|
// 请款
|
|
|
TempTable t = sql()
|
|
|
.select(
|
|
@@ -170,4 +193,25 @@ public class ContractInfoDao extends BaseDao<ContractInfoMapper, ContractInfo> {
|
|
|
.list();
|
|
|
}
|
|
|
|
|
|
+ public List<PaymentRequestsDetail> getPaymentList(List<Long> idList) {
|
|
|
+ PaymentRequestsDetailTable prd = PaymentRequestsDetailTable.prd;
|
|
|
+ PaymentRequestsTable pr = PaymentRequestsTable.pr;
|
|
|
+ PaymentRemitTable pre = PaymentRemitTable.payment_remit;
|
|
|
+
|
|
|
+ return sql(PaymentRequestsDetail.class).select(
|
|
|
+ prd.contractId,
|
|
|
+ _ifNull(_sum(prd.amount), 0).as(PaymentRequestsDetail::getAmount)
|
|
|
+ )
|
|
|
+ .from(prd)
|
|
|
+ .innerJoin(pr).on(prd.paymentRequestsId.eq(pr.id))
|
|
|
+ .innerJoin(pre).on(pre.paymentRequestsId.eq(pr.id))
|
|
|
+ .where(
|
|
|
+ prd.contractId.in(idList)
|
|
|
+ )
|
|
|
+ .groupBy(
|
|
|
+ prd.contractId
|
|
|
+ )
|
|
|
+ .list();
|
|
|
+ }
|
|
|
+
|
|
|
}
|