dcs 5 月之前
父节点
当前提交
8982a1acd7

+ 2 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/dao/PaymentInvoiceDao.java

@@ -23,6 +23,8 @@ public interface PaymentInvoiceDao {
 
     List<PaymentInvoice> getPaymentId(long paymentId);
 
+    List<PaymentInvoice> getPaymentIds(List<Long> ids);
+
     PaymentInvoice get(long id);
 
     List<PaymentInvoice> getPaymentOrdinaryId(long id);

+ 2 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/dao/PaymentRecordDao.java

@@ -18,6 +18,8 @@ public interface PaymentRecordDao {
 
     List<PaymentRecord> getPaymentId(long paymentId);
 
+    List<PaymentRecord> getPaymentIds(List<Long> ids);
+
     PaymentRecord get(long id);
 
     List<PaymentRecord> getPaymentOrdinaryId(long paymentOrdinaryId);

+ 16 - 1
virgo.api/src/main/java/com/bosshand/virgo/api/service/PaymentService.java

@@ -156,7 +156,22 @@ public class PaymentService {
 
     public List<Payment> getLimit(Payment payment, int currPage, int pageSize) {
         int currIndex = (currPage - 1) * pageSize;
-        return paymentDao.getLimit(payment, currIndex, pageSize);
+        List<Payment> list = paymentDao.getLimit(payment, currIndex, pageSize);
+        if (list.size() > 0) {
+            List<Long> ids = new ArrayList<>();
+            list.forEach(ls -> ids.add(ls.getId()));
+
+            List<PaymentInvoice> paymentInvoiceList = paymentInvoiceDao.getPaymentIds(ids);
+            Map<Long, List<PaymentInvoice>> groupedByPaymentInvoice = paymentInvoiceList.stream().collect(Collectors.groupingBy(PaymentInvoice::getPaymentId));
+            List<PaymentRecord> paymentRecordList = paymentRecordDao.getPaymentIds(ids);
+            Map<Long, List<PaymentRecord>> groupedByPaymentRecord = paymentRecordList.stream().collect(Collectors.groupingBy(PaymentRecord::getPaymentId));
+
+            for (Payment po : list) {
+                po.setPaymentInvoiceList(groupedByPaymentInvoice.get(po.getId()));
+                po.setPaymentRecordList(groupedByPaymentRecord.get(po.getId()));
+            }
+        }
+        return list;
     }
 
     public Payment get(long id) {

+ 8 - 0
virgo.api/src/main/resources/mapper/PaymentInvoiceMapper.xml

@@ -197,6 +197,14 @@
         SELECT * FROM  payment_invoice where paymentId = #{paymentId}
     </select>
 
+    <select id="getPaymentIds" resultMap="result">
+        SELECT * FROM  payment_invoice where paymentId in (
+        <foreach collection="list" item="item" index="index" separator=",">
+            #{item}
+        </foreach>
+        )
+    </select>
+
     <select id="getPaymentOrdinaryId" resultMap="result">
         SELECT * FROM  payment_invoice where paymentOrdinaryId = #{paymentOrdinaryId}
     </select>

+ 8 - 0
virgo.api/src/main/resources/mapper/PaymentRecordMapper.xml

@@ -52,6 +52,14 @@
         SELECT * FROM  payment_record where paymentId = #{paymentId}
     </select>
 
+    <select id="getPaymentIds" resultMap="result">
+        SELECT * FROM  payment_record where paymentId in (
+        <foreach collection="list" item="item" index="index" separator=",">
+            #{item}
+        </foreach>
+        )
+    </select>
+
     <select id="getPaymentOrdinaryId" resultMap="result">
         SELECT * FROM  payment_record where paymentOrdinaryId = #{paymentOrdinaryId}
     </select>