dcs пре 3 месеци
родитељ
комит
0b4a7020ac

+ 6 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/controller/PaymentController.java

@@ -229,4 +229,10 @@ public class PaymentController {
         return Response.ok(paymentService.getCount(projectId));
     }
 
+    @ApiOperation("项目工作台-本月费用列表")
+    @RequestMapping(value = "/monthCount/{projectId}", method = RequestMethod.GET)
+    public Response getMonthCount(@PathVariable long projectId) {
+        return Response.ok(paymentService.getMonthCount(projectId));
+    }
+
 }

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

@@ -37,4 +37,8 @@ public interface PaymentDao {
 
     Map<String, BigDecimal> getMonthProjectId(long projectId);
 
+    List<Payment> getMonthCount(long projectId);
+
+    Map<String, BigDecimal> getAccumulate(long projectId, long contractId);
+
 }

+ 3 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/dao/PaymentOrdinaryDao.java

@@ -30,5 +30,8 @@ public interface PaymentOrdinaryDao {
 
     Map<String, BigDecimal> getMonthProjectId(long projectId, int type);
 
+    List<PaymentOrdinary> getMonthCount(long projectId, int type);
+
+    Map<String, BigDecimal> getAccumulate(long projectId, long payMerchantId, long payClientId, int type);
 
 }

+ 13 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/model/Payment.java

@@ -86,6 +86,11 @@ public class Payment {
      */
     private Integer status;
 
+    /**
+     *  DTO-累计已收金额
+     */
+    private BigDecimal received;
+
     List<PaymentInvoice> paymentInvoiceList;
 
     List<PaymentRecord> paymentRecordList;
@@ -249,4 +254,12 @@ public class Payment {
     public void setPaymentRecordList(List<PaymentRecord> paymentRecordList) {
         this.paymentRecordList = paymentRecordList;
     }
+
+    public BigDecimal getReceived() {
+        return received;
+    }
+
+    public void setReceived(BigDecimal received) {
+        this.received = received;
+    }
 }

+ 13 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/model/PaymentOrdinary.java

@@ -93,6 +93,11 @@ public class PaymentOrdinary {
      */
     private Integer type;
 
+    /**
+     *  DTO-累计已收金额
+     */
+    private BigDecimal received;
+
     List<PaymentInvoice> paymentInvoiceList;
 
     List<PaymentRecord> paymentRecordList;
@@ -264,4 +269,12 @@ public class PaymentOrdinary {
     public void setPaymentRecordList(List<PaymentRecord> paymentRecordList) {
         this.paymentRecordList = paymentRecordList;
     }
+
+    public BigDecimal getReceived() {
+        return received;
+    }
+
+    public void setReceived(BigDecimal received) {
+        this.received = received;
+    }
 }

+ 28 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/service/PaymentService.java

@@ -401,6 +401,34 @@ public class PaymentService {
         return m;
     }
 
+    public Map<String, Object> getMonthCount(long projectId) {
+        Map<String, Object> map = new HashMap<>();
+        // 房租
+        List<Payment> rentList = paymentDao.getMonthCount(projectId);
+        if (rentList.size() > 0) {
+            for (Payment p : rentList) {
+                Map<String, BigDecimal> accumulate = paymentDao.getAccumulate(projectId, p.getContractId());
+                p.setReceived(accumulate.get("received"));
+            }
+            map.put("rent", rentList);
+        }
+        // 物业:1, 水电:2
+        map.put("property", getResult(projectId, 1));
+        map.put("hydropower", getResult(projectId, 2));
+        return map;
+    }
+
+    private List<PaymentOrdinary> getResult(long projectId, int type) {
+        List<PaymentOrdinary> list = paymentOrdinaryDao.getMonthCount(projectId, type);
+        if (list.size() > 0) {
+            for (PaymentOrdinary p : list) {
+                Map<String, BigDecimal> accumulate = paymentOrdinaryDao.getAccumulate(projectId, p.getPayMerchantId(), p.getPayClientId(), type);
+                p.setReceived(accumulate.get("received"));
+            }
+        }
+        return list;
+    }
+
 
 
 }

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

@@ -61,6 +61,10 @@
         SELECT SUM(`amount`) as receivable, SUM(if(`status`=2,`amount`,0)) as received, SUM(if(`status`!=2 and startDate &lt; now(),`amount`,0)) as overdue FROM payment WHERE projectId = #{projectId}
     </select>
 
+    <select id="getAccumulate" resultType="map">
+        SELECT SUM(if(`status`=2,`amount`,0)) as received FROM payment WHERE projectId = #{projectId} and contractId = #{contractId}
+    </select>
+
     <select id="getList" resultMap="paymentResult">
         SELECT * FROM payment
         <where>
@@ -192,5 +196,8 @@
         limit #{currIndex} , #{pageSize}
     </select>
 
+    <select id="getMonthCount" resultMap="paymentResult">
+        <include refid="query"/> WHERE a.projectId = #{projectId} and MONTH(a.startDate) = MONTH(NOW())
+    </select>
 
 </mapper>

+ 20 - 0
virgo.api/src/main/resources/mapper/PaymentOrdinaryMapper.xml

@@ -161,6 +161,26 @@
         SELECT SUM(`amount`) as receivable, SUM(if(`status`=2,`amount`,0)) as received, SUM(if(`status`!=2 and reminderDate &lt; now(),`amount`,0)) as overdue FROM payment_ordinary WHERE projectId = #{projectId} and type = #{type}
     </select>
 
+    <select id="getMonthCount" resultMap="result">
+        <include refid="query"/> WHERE a.projectId = #{projectId} and a.type = #{type} and MONTH(a.reminderDate) = MONTH(NOW())
+    </select>
 
+    <select id="getAccumulate" resultType="map">
+        SELECT SUM(if(`status`=2,`amount`,0)) as received FROM payment_ordinary
+        <where>
+            <if test="projectId != 0">
+                and projectId = #{projectId}
+            </if>
+            <if test="type != null">
+                and type = #{type}
+            </if>
+            <if test="payMerchantId != 0">
+                and payMerchantId = #{payMerchantId}
+            </if>
+            <if test="payClientId != 0">
+                and payClientId = #{payClientId}
+            </if>
+        </where>
+    </select>
 
 </mapper>