Sfoglia il codice sorgente

加入 金额临时计算

wuxw 6 anni fa
parent
commit
860e16e20c

+ 27 - 11
Api/src/main/java/com/java110/api/listener/fee/PayFeeListener.java

@@ -129,12 +129,12 @@ public class PayFeeListener extends AbstractServiceApiDataFlowListener {
         feeDto.setCommunityId(paramInJson.getString("communityId"));
         List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
 
-        if (feeDtos == null || feeDtos.size() != 1){
+        if (feeDtos == null || feeDtos.size() != 1) {
             throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, "查询费用信息失败,未查到数据或查到多条数据");
         }
 
         feeDto = feeDtos.get(0);
-        paramInJson.put("feeInfo",feeDto);
+        paramInJson.put("feeInfo", feeDto);
 
         BigDecimal feePrice = new BigDecimal("0.00");
 
@@ -161,7 +161,7 @@ public class PayFeeListener extends AbstractServiceApiDataFlowListener {
             } else {
                 throw new IllegalArgumentException("暂不支持该类公式");
             }
-        } else if("6666".equals(feeDto.getPayerObjType())) {//车位相关
+        } else if ("6666".equals(feeDto.getPayerObjType())) {//车位相关
             String computingFormula = feeDto.getComputingFormula();
             if ("1001".equals(computingFormula)) { //面积*单价+附加费
                 ParkingSpaceDto parkingSpaceDto = new ParkingSpaceDto();
@@ -185,12 +185,20 @@ public class PayFeeListener extends AbstractServiceApiDataFlowListener {
                 throw new IllegalArgumentException("暂不支持该类公式");
             }
         }
+        BigDecimal cycles = null;
+        //BigDecimal receivableAmount = feePrice;
+        if ("-101".equals(paramInJson.getString("cycles"))) {//自定义缴费
+            BigDecimal receivedAmount = new BigDecimal(Double.parseDouble(paramInJson.getString("receivedAmount")));
+            cycles = receivedAmount.divide(feePrice,2,BigDecimal.ROUND_HALF_EVEN);
+            paramInJson.put("tmpCycles", cycles);
+            businessFeeDetail.put("cycles", cycles.doubleValue());
+            businessFeeDetail.put("receivableAmount", receivedAmount.doubleValue());
+        } else {
+            cycles = new BigDecimal(Double.parseDouble(paramInJson.getString("cycles")));
+            double tmpReceivableAmount = cycles.multiply(feePrice).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+            businessFeeDetail.put("receivableAmount", tmpReceivableAmount);
+        }
 
-        BigDecimal receivableAmount = feePrice;
-        BigDecimal cycles = new BigDecimal(Double.parseDouble(paramInJson.getString("cycles")));
-        double tmpReceivableAmount = cycles.multiply(receivableAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
-
-        businessFeeDetail.put("receivableAmount", tmpReceivableAmount);
         business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessFeeDetail", businessFeeDetail);
 
         return business;
@@ -209,14 +217,20 @@ public class PayFeeListener extends AbstractServiceApiDataFlowListener {
 
         JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
         business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_FEE_INFO);
-        business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ+1);
+        business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ + 1);
         business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
         JSONObject businessFee = new JSONObject();
-        FeeDto feeInfo = (FeeDto)paramInJson.get("feeInfo");
+        FeeDto feeInfo = (FeeDto) paramInJson.get("feeInfo");
         Date endTime = feeInfo.getEndTime();
         Calendar endCalender = Calendar.getInstance();
         endCalender.setTime(endTime);
-        endCalender.add(Calendar.MONTH, Integer.parseInt(paramInJson.getString("cycles")));
+        int hours = 0;
+        if ("-101".equals(paramInJson.getString("cycles"))) {
+            hours = new Double(Double.parseDouble(paramInJson.getString("tmpCycles")) * DateUtil.getCurrentMonthDay() * 24).intValue();
+            endCalender.add(Calendar.HOUR, hours);
+        } else {
+            endCalender.add(Calendar.MONTH, Integer.parseInt(paramInJson.getString("cycles")));
+        }
         feeInfo.setEndTime(endCalender.getTime());
         Map feeMap = BeanConvertUtil.beanCovertMap(feeInfo);
         feeMap.put("startTime", DateUtil.getFormatTimeString(feeInfo.getStartTime(), DateUtil.DATE_FORMATE_STRING_A));
@@ -278,4 +292,6 @@ public class PayFeeListener extends AbstractServiceApiDataFlowListener {
     public void setRoomInnerServiceSMOImpl(IRoomInnerServiceSMO roomInnerServiceSMOImpl) {
         this.roomInnerServiceSMOImpl = roomInnerServiceSMOImpl;
     }
+
+
 }

+ 10 - 3
Api/src/test/java/com/java110/api/listener/floor/QueryFloorsListenerTest.java

@@ -1,15 +1,22 @@
 package com.java110.api.listener.floor;
 
+import com.java110.utils.util.DateUtil;
 import org.junit.Test;
 
+import java.util.Calendar;
+import java.util.Date;
+
 import static org.junit.Assert.*;
 
 public class QueryFloorsListenerTest {
 
     @Test
     public void soService() {
-        int a = 16;
-        int b = 16;
-        System.out.println(Math.ceil((double) a/(double) b));
+        Date endTime = new Date();
+        Calendar endCalender = Calendar.getInstance();
+        endCalender.setTime(endTime);
+        endCalender.add(Calendar.HOUR, 365*24*10+3);
+
+        System.out.printf("time "+ DateUtil.getFormatTimeString(endCalender.getTime(),DateUtil.DATE_FORMATE_STRING_A));
     }
 }

+ 13 - 5
FeeService/src/main/java/com/java110/fee/listener/fee/UpdateFeeInfoListener.java

@@ -15,10 +15,13 @@ import com.java110.core.annotation.Java110Listener;
 import com.java110.core.context.DataFlowContext;
 import com.java110.entity.center.Business;
 import com.java110.fee.dao.IFeeServiceDao;
+import com.java110.utils.util.DateUtil;
+import com.java110.utils.util.StringUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.NumberUtils;
 
 import java.util.*;
 
@@ -126,8 +129,8 @@ public class UpdateFeeInfoListener extends AbstractFeeBusinessServiceDataFlowLis
         feeDetailInfo.put("operate", "ADD");
         List<Map> feeDetails = feeDetailServiceDaoImpl.getBusinessFeeDetailInfo(feeDetailInfo);
         Assert.listOnlyOne(feeDetails, "business表中存在多条缴费记录或没有");
-
-        int cycles = Integer.parseInt(feeDetails.get(0).get("cycles").toString());
+        String cyclesStr = feeDetails.get(0).get("cycles").toString();
+        double cycles = Double.parseDouble(cyclesStr);
 
         Map feeMap = null;
         if (businessFeeInfos != null && businessFeeInfos.size() > 0) {
@@ -147,10 +150,15 @@ public class UpdateFeeInfoListener extends AbstractFeeBusinessServiceDataFlowLis
                     Assert.listOnlyOne(feeInfo, "查询到多条数据或未查询到数据" + feeMap);
                     //根据当前的结束时间 修改
                     Date endTime = (Date) feeInfo.get(0).get("end_time");
-                    Calendar endCalender = Calendar.getInstance();
-                    endCalender.setTime(endTime);
-                    endCalender.add(Calendar.MONTH, cycles);
                     if(cycles > 0) {
+                        Calendar endCalender = Calendar.getInstance();
+                        endCalender.setTime(endTime);
+                        if(StringUtil.isNumber(cyclesStr)) {
+                            endCalender.add(Calendar.MONTH, new Double(cycles).intValue());
+                        }else{
+                            int hours = new Double(cycles * DateUtil.getCurrentMonthDay() * 24).intValue();
+                            endCalender.add(Calendar.HOUR, hours);
+                        }
                         businessFeeInfo.put("end_time", endCalender.getTime());
                     }
                     flushBusinessFeeInfo(businessFeeInfo, StatusConstant.STATUS_CD_VALID);

+ 6 - 1
WebService/src/main/resources/components/feePackage/payFeeOrder/payFeeOrder.js

@@ -96,7 +96,12 @@
                      });
             },
             _changeMonth:function(_cycles){
-                vc.component.payFeeOrderInfo.totalFeePrice = parseFloat(_cycles)*parseFloat(vc.component.payFeeOrderInfo.feePrice);
+                if('-101' == _cycles){
+                    vc.component.payFeeOrderInfo.totalFeePrice = 0.00;
+                    vc.component.payFeeOrderInfo.receivedAmount = '';
+                    return ;
+                }
+                vc.component.payFeeOrderInfo.totalFeePrice = Math.floor(parseFloat(_cycles)*parseFloat(vc.component.payFeeOrderInfo.feePrice)*100)/100;
                 vc.component.payFeeOrderInfo.receivedAmount = vc.component.payFeeOrderInfo.totalFeePrice ;
             },
             _back:function(){

+ 9 - 0
java110-utils/src/main/java/com/java110/utils/util/DateUtil.java

@@ -387,4 +387,13 @@ public class DateUtil {
         }
         return true;
     }
+
+
+    public static int getCurrentMonthDay() {
+        Calendar a = Calendar.getInstance();
+        a.set(Calendar.DATE, 1);
+        a.roll(Calendar.DATE, -1);
+        int maxDate = a.get(Calendar.DATE);
+        return maxDate;
+    }
 }

+ 1 - 0
java110-utils/src/main/java/com/java110/utils/util/StringUtil.java

@@ -270,6 +270,7 @@ public class StringUtil {
         }
     }
 
+
     /**
      * Description: 获得字符(byte)的实际长度<br>
      * 1、…<br>