dcs 5 hónapja
szülő
commit
6b659be897

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

@@ -27,4 +27,6 @@ public interface PaymentDao {
 
     Payment get(long id);
 
+    List<Payment> getIds(List<Long> ids);
+
 }

+ 24 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/model/PaymentInvoice.java

@@ -1,5 +1,6 @@
 package com.bosshand.virgo.api.model;
 
+import java.math.BigDecimal;
 import java.util.Map;
 
 /**
@@ -19,6 +20,8 @@ public class PaymentInvoice {
      */
     private long paymentId;
 
+    private Payment payment;
+
     private long[] paymentIds;
 
     /**
@@ -104,6 +107,11 @@ public class PaymentInvoice {
      */
     private String data;
 
+    /**
+     * 发票金额
+     */
+    private BigDecimal invoiceAmount;
+
     public long getId() {
         return id;
     }
@@ -128,6 +136,14 @@ public class PaymentInvoice {
         this.paymentId = paymentId;
     }
 
+    public Payment getPayment() {
+        return payment;
+    }
+
+    public void setPayment(Payment payment) {
+        this.payment = payment;
+    }
+
     public long[] getPaymentIds() {
         return paymentIds;
     }
@@ -287,4 +303,12 @@ public class PaymentInvoice {
     public void setData(String data) {
         this.data = data;
     }
+
+    public BigDecimal getInvoiceAmount() {
+        return invoiceAmount;
+    }
+
+    public void setInvoiceAmount(BigDecimal invoiceAmount) {
+        this.invoiceAmount = invoiceAmount;
+    }
 }

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

@@ -212,7 +212,20 @@ public class PaymentService {
 
     public List<PaymentInvoice> getPaymentInvoiceLimit(PaymentInvoice paymentInvoice, int currPage, int pageSize) {
         int currIndex = (currPage - 1) * pageSize;
-        return paymentInvoiceDao.getLimit(paymentInvoice, currIndex, pageSize);
+        List<PaymentInvoice> list = paymentInvoiceDao.getLimit(paymentInvoice, currIndex, pageSize);
+        if (list.size() > 0) {
+            Set<Long> paymentIds = new HashSet<>();
+            list.forEach(ls -> paymentIds.add(ls.getPaymentId()));
+            List<Payment> paymentList = paymentDao.getIds(new ArrayList<>(paymentIds));
+            Map<Long, Payment> groupedByPayment = new HashMap<>();
+            for (Payment pm : paymentList) {
+                groupedByPayment.put(pm.getId(), pm);
+            }
+            for (PaymentInvoice p : list) {
+                p.setPayment(groupedByPayment.get(p.getPaymentId()));
+            }
+        }
+        return list;
     }
 
     public List<PaymentInvoice> getInvoiceList(PaymentInvoice paymentInvoice) {

+ 5 - 2
virgo.api/src/main/resources/mapper/PaymentInvoiceMapper.xml

@@ -25,6 +25,7 @@
         <result column="date" property="date"/>
         <result column="attachment" property="attachment"/>
         <result column="data" property="data"/>
+        <result column="invoiceAmount" property="invoiceAmount"/>
     </resultMap>
 
     <resultMap type="com.bosshand.virgo.api.model.PaymentInvoice" id="paymentInvoiceResult">
@@ -51,15 +52,16 @@
         <result column="date" property="date"/>
         <result column="attachment" property="attachment"/>
         <result column="data" property="data"/>
+        <result column="invoiceAmount" property="invoiceAmount"/>
     </resultMap>
 
     <insert id="insert" parameterType="com.bosshand.virgo.api.model.PaymentInvoice" useGeneratedKeys="true" keyProperty="id">
         INSERT INTO  payment_invoice (`paymentOrdinaryId`, `paymentId`,
                                       `organizationId`, `projectId`, `projectItemTargetRoomIds`, `invoiceType`, `type`, `status`, `code`, `number`, `payMerchantId`, `payClientId`, `cargoName`,
-                                      `name`, `date`, `attachment`, `data`)
+                                      `name`, `date`, `attachment`, `data`, `invoiceAmount`)
         VALUES (#{paymentOrdinaryId}, #{paymentId},
                 #{organizationId}, #{projectId}, #{projectItemTargetRoomIds}, #{invoiceType}, #{type}, #{status}, #{code}, #{number}, #{payMerchantId}, #{payClientId}, #{cargoName},
-                #{name}, #{date}, #{attachment}, #{data})
+                #{name}, #{date}, #{attachment}, #{data}, #{invoiceAmount})
     </insert>
 
     <delete id="delete">
@@ -90,6 +92,7 @@
             <if test="date!=null">date=#{date},</if>
             <if test="attachment!=null">attachment=#{attachment},</if>
             <if test="data!=null">data=#{data},</if>
+            <if test="invoiceAmount!=null">invoiceAmount=#{invoiceAmount},</if>
         </trim>
         WHERE id=#{id}
     </update>

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

@@ -135,6 +135,14 @@
         <include refid="query"/> where a.id = #{id}
     </select>
 
+    <select id="getIds" resultMap="paymentResult">
+        <include refid="query"/> where a.id in (
+        <foreach collection="list" item="item" index="index" separator=",">
+            #{item}
+        </foreach>
+        )
+    </select>
+
     <select id="getLimit" resultMap="paymentResult">
         <include refid="query"/>
         <where>