dcs пре 1 година
родитељ
комит
6c9e73bc68

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

@@ -33,6 +33,12 @@ public class PaymentController {
 
     }
 
+    @ApiOperation("详情")
+    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
+    public Response get(@PathVariable long id) {
+        return Response.ok(paymentService.get(id));
+    }
+
     @ApiOperation("更新状态")
     @RequestMapping(value = "/updateStatus/{id}/{status}", method = RequestMethod.PUT)
     public Response update(@PathVariable long id, @PathVariable Integer status) {

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

@@ -22,4 +22,7 @@ public interface PaymentDao {
     int getTotalCount(Payment payment);
 
     List<Payment> getLimit(@Param("p") Payment p, @Param("currIndex") int currIndex, @Param("pageSize") int pageSize);
+
+    Payment get(long id);
+
 }

+ 3 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/model/Contract.java

@@ -13,6 +13,9 @@ public class Contract {
 
     private long id;
 
+    /**
+     * 编码
+     */
     private String code;
 
     /**

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

@@ -9,6 +9,21 @@ public class Payment {
 
     private long id;
 
+    /**
+     * 提醒时间
+     */
+    private String reminderDate;
+
+    /**
+     * 项目id
+     */
+    private long projectId;
+
+    /**
+     * 合同编码
+     */
+    private String contractCode;
+
     /**
      * 合同id
      */
@@ -73,6 +88,30 @@ public class Payment {
         this.id = id;
     }
 
+    public String getReminderDate() {
+        return reminderDate;
+    }
+
+    public void setReminderDate(String reminderDate) {
+        this.reminderDate = reminderDate;
+    }
+
+    public long getProjectId() {
+        return projectId;
+    }
+
+    public void setProjectId(long projectId) {
+        this.projectId = projectId;
+    }
+
+    public String getContractCode() {
+        return contractCode;
+    }
+
+    public void setContractCode(String contractCode) {
+        this.contractCode = contractCode;
+    }
+
     public long getContractId() {
         return contractId;
     }

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

@@ -13,8 +13,10 @@ import org.springframework.stereotype.Service;
 import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.temporal.ChronoUnit;
+import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
 
 @Service
 public class PaymentService {
@@ -32,6 +34,12 @@ public class PaymentService {
         Contract contract = contractDao.get(clauseId);
         List<Clause> clauseList = contract.getClauseList();
 
+        // 1:当天, 2:提前1天, 3:提前3天, 4:提前5天
+        Map<String, Integer> map = new HashMap<>();
+        map.put("1", 0);map.put("2", 1);map.put("3", 3);map.put("4", 5);
+        // 提醒值
+        long reminder = 0;
+
         // 开始时间
         String start = null;
         // 结束时间
@@ -43,7 +51,8 @@ public class PaymentService {
         // 单价租金
         BigDecimal unitPrice = null;
 
-        JSONArray array = new JSONArray();
+        JSONArray earnestMoneyArray = new JSONArray();
+
         // 计数
         int a = 0;
         for (Clause clause : clauseList) {
@@ -51,6 +60,7 @@ public class PaymentService {
             if (clause.getType() == 1) {
                 start = clause.getStartTime();
                 end = clause.getEndTime();
+                reminder = map.get(clause.getPayTime());
                 payCycle = Long.parseLong(clause.getPayCycle());
                 unitPrice = new BigDecimal(clause.getUnitPrice());
             } else {
@@ -59,13 +69,13 @@ public class PaymentService {
                 if (a > 0) {
                     json.put("earnestMoneyType", clause.getEarnestMoneyType());
                     json.put("earnestMoney", clause.getEarnestMoney());
-                    array.add(json);
+                    earnestMoneyArray.add(json);
                     BigDecimal bigDecimal = new BigDecimal(clause.getEarnestMoney());
                     earnestMoney.add(bigDecimal);
                 } else {
                     json.put("earnestMoneyType", clause.getEarnestMoneyType());
                     json.put("earnestMoney", clause.getEarnestMoney());
-                    array.add(json);
+                    earnestMoneyArray.add(json);
                     earnestMoney = new BigDecimal(clause.getEarnestMoney());
                     a = a + 1;
                 }
@@ -82,37 +92,40 @@ public class PaymentService {
         int b = 1;
         for (int i = 0; i < in; i++) {
             Payment payment = new Payment();
+            payment.setProjectId(contract.getProjectId());
+            payment.setContractCode(contract.getCode());
+            payment.setContractId(clauseId);
+            payment.setPayMerchantId(contract.getMerchantId());
+            payment.setOrganizationId(contract.getOrganizationId());
+            payment.setPayClientId(contract.getClientId());
+
+            JSONArray unitPriceArray = new JSONArray();
             JSONObject json = new JSONObject();
             if (i == 0) {
+                payment.setReminderDate(startDate.minusDays(reminder).toString());
                 payment.setStartDate(start);
                 // 计算指定日期后几个月的日期
                 payment.setEndDate(startDate.plusMonths(payCycle).toString());
-                payment.setContractId(clauseId);
-                payment.setPayMerchantId(contract.getMerchantId());
-                payment.setOrganizationId(contract.getOrganizationId());
-                payment.setPayClientId(contract.getClientId());
                 BigDecimal cycle = new BigDecimal(payCycle);
                 payment.setAmount(unitPrice.multiply(cycle).add(earnestMoney));
                 json.put("payCycle",payCycle);
                 json.put("unitPrice", unitPrice);
-                array.add(json);
-                payment.setData(array.toJSONString());
+                earnestMoneyArray.add(json);
+                payment.setData(earnestMoneyArray.toJSONString());
                 payment.setPhase(b + i);
                 list.add(payment);
                 continue;
             }
             int c = i - 1;
+            payment.setReminderDate(LocalDate.parse(list.get(c).getEndDate()).minusDays(reminder).toString());
             payment.setStartDate(list.get(c).getEndDate());
             payment.setEndDate(LocalDate.parse(list.get(c).getEndDate()).plusMonths(payCycle).toString());
-            payment.setContractId(clauseId);
-            payment.setPayMerchantId(contract.getMerchantId());
-            payment.setOrganizationId(contract.getOrganizationId());
-            payment.setPayClientId(contract.getClientId());
             BigDecimal cycle = new BigDecimal(payCycle);
             payment.setAmount(unitPrice.multiply(cycle));
             json.put("payCycle",payCycle);
             json.put("unitPrice", unitPrice);
-            payment.setData(json.toJSONString());
+            unitPriceArray.add(json);
+            payment.setData(unitPriceArray.toJSONString());
             payment.setPhase(b + i);
             list.add(payment);
         }
@@ -141,4 +154,8 @@ public class PaymentService {
         return paymentDao.getLimit(payment, currIndex, pageSize);
     }
 
+    public Payment get(long id) {
+        return paymentDao.get(id);
+    }
+
 }

+ 36 - 2
virgo.api/src/main/resources/mapper/PaymentMapper.xml

@@ -6,6 +6,9 @@
 
     <resultMap type="com.bosshand.virgo.api.model.Payment" id="paymentResult">
         <id column="id" property="id"/>
+        <result column="reminderDate" property="reminderDate"/>
+        <result column="projectId" property="projectId"/>
+        <result column="contractCode" property="contractCode"/>
         <result column="contractId" property="contractId"/>
         <result column="organizationId" property="organizationId"/>
         <result column="organizationName" property="organizationName"/>
@@ -22,10 +25,10 @@
     </resultMap>
 
     <insert id="batchInsert" parameterType="com.bosshand.virgo.api.model.Payment" useGeneratedKeys="true" keyProperty="id">
-        INSERT INTO payment(`contractId`, `organizationId`, `payMerchantId`, `payClientId`, `startDate`, `endDate`, `phase`, `amount`, `status`, `data`)
+        INSERT INTO payment(`reminderDate`, `projectId`, `contractCode`, `contractId`, `organizationId`, `payMerchantId`, `payClientId`, `startDate`, `endDate`, `phase`, `amount`, `status`, `data`)
         VALUES
         <foreach collection="list" item="item" index="index" separator=",">
-               (#{item.contractId}, #{item.organizationId}, #{item.payMerchantId}, #{item.payClientId}, #{item.startDate}, #{item.endDate}, #{item.phase}, #{item.amount}, #{item.status}, #{item.data})
+               (#{item.reminderDate}, #{item.projectId}, #{item.contractCode}, #{item.contractId}, #{item.organizationId}, #{item.payMerchantId}, #{item.payClientId}, #{item.startDate}, #{item.endDate}, #{item.phase}, #{item.amount}, #{item.status}, #{item.data})
         </foreach>
     </insert>
 
@@ -48,6 +51,15 @@
     <select id="getList" resultMap="paymentResult">
         SELECT * FROM payment
         <where>
+            <if test="reminderDate != null">
+                and reminderDate = #{reminderDate}
+            </if>
+            <if test="projectId != 0">
+                and projectId = #{projectId}
+            </if>
+            <if test="contractCode != null">
+                and contractCode = #{contractCode}
+            </if>
             <if test="contractId != 0">
                 and contractId = #{contractId}
             </if>
@@ -75,6 +87,15 @@
     <select id="getTotalCount" parameterType="com.bosshand.virgo.api.model.Payment" resultType="Integer">
         SELECT count(*) FROM payment
         <where>
+            <if test="reminderDate != null">
+                and reminderDate = #{reminderDate}
+            </if>
+            <if test="projectId != 0">
+                and projectId = #{projectId}
+            </if>
+            <if test="contractCode != null">
+                and contractCode = #{contractCode}
+            </if>
             <if test="contractId != 0">
                 and contractId = #{contractId}
             </if>
@@ -106,9 +127,22 @@
         LEFT JOIN mgr_client d ON a.payClientId = d.id
     </sql>
 
+    <select id="get" resultMap="paymentResult">
+        <include refid="query"/> where a.id = #{id}
+    </select>
+
     <select id="getLimit" resultMap="paymentResult">
         <include refid="query"/>
         <where>
+            <if test="p.reminderDate != null">
+                and a.reminderDate = #{p.reminderDate}
+            </if>
+            <if test="p.projectId != 0">
+                and a.projectId = #{p.projectId}
+            </if>
+            <if test="p.contractCode != null">
+                and a.contractCode = #{p.contractCode}
+            </if>
             <if test="p.contractId != 0">
                 and a.contractId = #{p.contractId}
             </if>