dcs 3 hónapja
szülő
commit
5d93a2fe02

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

@@ -1,5 +1,6 @@
 package com.bosshand.virgo.api.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.bosshand.virgo.api.model.Payment;
 import com.bosshand.virgo.api.model.PaymentInvoice;
 import com.bosshand.virgo.api.model.PaymentOrdinary;
@@ -11,6 +12,7 @@ import com.bosshand.virgo.core.response.Response;
 import com.bosshand.virgo.core.utils.StringUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -235,4 +237,19 @@ public class PaymentController {
         return Response.ok(paymentService.getMonthCount(projectId));
     }
 
+    /**
+     * type:1房租,2物业,3水电
+     * data:{"projectId":9,"status":1,"type":1,"currPage":1,"pageSize":10}
+     */
+    @ApiOperation("项目工作台-本月费用列表-分页查询")
+    @RequestMapping(value = "/monthCount", method = RequestMethod.POST)
+    public Response getMonthCount(@RequestBody JSONObject data) {
+        int totalCount = paymentService.getTotalCount(data);
+        List<T> dataList = paymentService.getLimit(data);
+        Map<String, Object> result = new HashMap<>();
+        result.put("dataList", dataList);
+        result.put("totalCount", totalCount);
+        return Response.ok(result);
+    }
+
 }

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

@@ -41,4 +41,9 @@ public interface PaymentDao {
 
     Map<String, BigDecimal> getAccumulate(long projectId, long contractId);
 
+    int getMonth(Payment payment);
+
+    List<Payment> getMonthCountLimit(@Param("p") Payment p, @Param("currIndex") int currIndex, @Param("pageSize") int pageSize);
+
+
 }

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

@@ -34,4 +34,8 @@ public interface PaymentOrdinaryDao {
 
     Map<String, BigDecimal> getAccumulate(long projectId, long payMerchantId, long payClientId, int type);
 
+    int getMonth(PaymentOrdinary paymentOrdinary);
+
+    List<PaymentOrdinary> getMonthCountLimit(@Param("p") PaymentOrdinary p, @Param("currIndex") int currIndex, @Param("pageSize") int pageSize);
+
 }

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

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.bosshand.virgo.api.dao.*;
 import com.bosshand.virgo.api.model.*;
 import com.bosshand.virgo.core.utils.StringUtil;
+import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -362,7 +363,6 @@ public class PaymentService {
         return paymentOrdinaryDao.update(paymentOrdinary);
     }
 
-
     public Map<String, Object> getCount(long projectId) {
         Map<String, Object> m = new HashMap<>();
 
@@ -429,6 +429,84 @@ public class PaymentService {
         return list;
     }
 
+    //=============================================================================================
+
+    public int getTotalCount(JSONObject data) {
+        if (data.getIntValue("type") == 1) {
+            Payment p = new Payment();
+            p.setProjectId(data.getLongValue("projectId"));
+            if (data.containsKey("status")) {
+                p.setStatus(data.getIntValue("status"));
+            }
+            return paymentDao.getMonth(p);
+        }
+        if (data.getIntValue("type") == 2) {
+            return getTotalCountResult(data, 1);
+        }
+        if (data.getIntValue("type") == 3) {
+            return getTotalCountResult(data, 2);
+        }
+        return 0;
+    }
+
+    private int getTotalCountResult(JSONObject data, int type) {
+        PaymentOrdinary po = new PaymentOrdinary();
+        po.setProjectId(data.getLongValue("projectId"));
+        if (data.containsKey("status")) {
+            po.setStatus(data.getIntValue("status"));
+        }
+        po.setType(type);
+        return paymentOrdinaryDao.getMonth(po);
+    }
+
+    public List<T> getLimit(JSONObject data) {
+        if (data.getIntValue("type") == 1) {
+            long projectId = data.getLongValue("projectId");
+            Payment p = new Payment();
+            p.setProjectId(projectId);
+            if (data.containsKey("status")) {
+                p.setStatus(data.getIntValue("status"));
+            }
+            int currIndex = (data.getIntValue("currPage") - 1) * data.getIntValue("pageSize");
+            List<Payment> list = paymentDao.getMonthCountLimit(p, currIndex, data.getIntValue("pageSize"));
+            if (list.size() > 0) {
+                for (Payment pp : list) {
+                    Map<String, BigDecimal> accumulate = paymentDao.getAccumulate(projectId, pp.getContractId());
+                    pp.setReceived(accumulate.get("received"));
+                }
+            }
+            return new ArrayList(list);
+        }
+        if (data.getIntValue("type") == 2) {
+            return new ArrayList(getLimitResult(data, 1));
+        }
+        if (data.getIntValue("type") == 3) {
+            return new ArrayList(getLimitResult(data, 2));
+        }
+        return new ArrayList();
+    }
+
+    private List<PaymentOrdinary> getLimitResult(JSONObject data, int type) {
+        long projectId = data.getLongValue("projectId");
+        PaymentOrdinary po = new PaymentOrdinary();
+        po.setProjectId(projectId);
+        if (data.containsKey("status")) {
+            po.setStatus(data.getIntValue("status"));
+        }
+        po.setType(type);
+        int currIndex = (data.getIntValue("currPage") - 1) * data.getIntValue("pageSize");
+        List<PaymentOrdinary> list = paymentOrdinaryDao.getMonthCountLimit(po, currIndex, data.getIntValue("pageSize"));
+        if (list.size() > 0) {
+            for (PaymentOrdinary pp : list) {
+                Map<String, BigDecimal> accumulate = paymentOrdinaryDao.getAccumulate(projectId, po.getPayMerchantId(), pp.getPayClientId(), type);
+                pp.setReceived(accumulate.get("received"));
+            }
+        }
+        return list;
+    }
+
+
+
 
 
 }

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

@@ -200,4 +200,32 @@
         <include refid="query"/> WHERE a.projectId = #{projectId} and MONTH(a.startDate) = MONTH(NOW())
     </select>
 
+    <!--分页查询-->
+    <select id="getMonth" parameterType="com.bosshand.virgo.api.model.Payment" resultType="Integer">
+        SELECT count(*) FROM payment
+        <where>
+            <if test="status != null">
+                and status = #{status}
+            </if>
+            <if test="projectId != 0">
+                and projectId = #{projectId}
+                and MONTH(startDate) = MONTH(NOW())
+            </if>
+        </where>
+    </select>
+
+    <select id="getMonthCountLimit" resultMap="paymentResult">
+        <include refid="query"/>
+        <where>
+            <if test="p.status != null">
+                and a.status = #{p.status}
+            </if>
+            <if test="p.projectId != 0">
+                and a.projectId = #{p.projectId}
+                and MONTH(a.startDate) = MONTH(NOW())
+            </if>
+        </where>
+        limit #{currIndex} , #{pageSize}
+    </select>
+
 </mapper>

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

@@ -183,4 +183,38 @@
         </where>
     </select>
 
+    <!--分页查询-->
+    <select id="getMonth" parameterType="com.bosshand.virgo.api.model.PaymentOrdinary" resultType="Integer">
+        SELECT count(*) FROM payment_ordinary
+        <where>
+            <if test="type != null">
+                and type = #{type}
+            </if>
+            <if test="status != null">
+                and status = #{status}
+            </if>
+            <if test="projectId != 0">
+                and projectId = #{projectId}
+                and MONTH(reminderDate) = MONTH(NOW())
+            </if>
+        </where>
+    </select>
+
+    <select id="getMonthCountLimit" resultMap="result">
+        <include refid="query"/>
+        <where>
+            <if test="p.type != null">
+                and a.type = #{p.type}
+            </if>
+            <if test="p.status != null">
+                and a.status = #{p.status}
+            </if>
+            <if test="p.projectId != 0">
+                and a.projectId = #{p.projectId}
+                and MONTH(a.reminderDate) = MONTH(NOW())
+            </if>
+        </where>
+        limit #{currIndex} , #{pageSize}
+    </select>
+
 </mapper>