java110 hace 5 años
padre
commit
84d4c6a039

+ 9 - 0
java110-bean/src/main/java/com/java110/dto/fee/BillDto.java

@@ -20,6 +20,7 @@ public class BillDto extends PageDto implements Serializable {
     private String curReceivable;
     private String receipts;
     private String billTime;
+    private String curBillTime;
     private String communityId;
     private String configId;
     private String createTime;
@@ -113,4 +114,12 @@ public class BillDto extends PageDto implements Serializable {
     public void setCurReceivable(String curReceivable) {
         this.curReceivable = curReceivable;
     }
+
+    public String getCurBillTime() {
+        return curBillTime;
+    }
+
+    public void setCurBillTime(String curBillTime) {
+        this.curBillTime = curBillTime;
+    }
 }

+ 3 - 0
java110-db/src/main/resources/mapper/community/UnitServiceDaoImplMapper.xml

@@ -47,6 +47,7 @@
         <if test="userId !=null and userId != ''">
             and t.user_id= #{userId}
         </if>
+        order by unitNum asc
 
     </select>
 
@@ -128,6 +129,7 @@
         <if test="userId !=null and userId != ''">
             and t.user_id= #{userId}
         </if>
+        order by unitNum asc
        <!-- <if test="page != -1 and page != null ">
             limit #{page}, #{row}
         </if>limit 10;-->
@@ -244,6 +246,7 @@
         <if test="page != -1 and page != null">
             limit #{page}, #{row}
         </if>
+        order by unitNum asc
     </select>
 
     <select id="getFloorAndUnitInfo" parameterType="Map" resultType="Map">

+ 3 - 0
java110-db/src/main/resources/mapper/fee/FeeServiceDaoImplMapper.xml

@@ -382,6 +382,9 @@
         <if test="billTime !=null">
             and t.bill_time= #{billTime}
         </if>
+        <if test="curBillTime !=null">
+            and t.bill_time &gt; #{curBillTime}
+        </if>
         <if test="communityId !=null and communityId != ''">
             and t.community_id= #{communityId}
         </if>

+ 3 - 0
service-fee/src/main/java/com/java110/fee/dao/IFeeServiceDao.java

@@ -125,4 +125,7 @@ public interface IFeeServiceDao {
      */
     int insertBill(Map info) throws DAOException;
 
+
+
+
 }

+ 1 - 0
service-fee/src/main/java/com/java110/fee/smo/impl/FeeInnerServiceSMOImpl.java

@@ -176,6 +176,7 @@ public class FeeInnerServiceSMOImpl extends BaseServiceSMO implements IFeeInnerS
         return feeServiceDaoImpl.insertBill(BeanConvertUtil.beanCovertMap(billDto));
     }
 
+
     public IFeeServiceDao getFeeServiceDaoImpl() {
         return feeServiceDaoImpl;
     }

+ 55 - 7
service-job/src/main/java/com/java110/job/task/fee/GenerateBillTemplate.java

@@ -1,13 +1,13 @@
 package com.java110.job.task.fee;
 
 import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.core.smo.community.IParkingSpaceInnerServiceSMO;
+import com.java110.core.smo.community.IRoomInnerServiceSMO;
 import com.java110.core.smo.fee.IFeeConfigInnerServiceSMO;
 import com.java110.core.smo.fee.IFeeDetailInnerServiceSMO;
 import com.java110.core.smo.fee.IFeeInnerServiceSMO;
 import com.java110.core.smo.user.IOwnerCarInnerServiceSMO;
 import com.java110.core.smo.user.IOwnerRoomRelInnerServiceSMO;
-import com.java110.core.smo.community.IParkingSpaceInnerServiceSMO;
-import com.java110.core.smo.community.IRoomInnerServiceSMO;
 import com.java110.dto.RoomDto;
 import com.java110.dto.community.CommunityDto;
 import com.java110.dto.fee.BillDto;
@@ -118,12 +118,13 @@ public class GenerateBillTemplate extends TaskSystemQuartz {
      */
     private void GenerateBillByFeeConfig(TaskDto taskDto, FeeConfigDto feeConfigDto) throws Exception {
 
-
         //当前费用项是否
         BillDto tmpBillDto = new BillDto();
         tmpBillDto.setCurBill("T");
         tmpBillDto.setConfigId(feeConfigDto.getConfigId());
         tmpBillDto.setCommunityId(feeConfigDto.getCommunityId());
+        Date startTime = getDefaultStartTime(feeConfigDto.getBillType());
+        tmpBillDto.setCurBillTime(DateUtil.getFormatTimeString(startTime, DateUtil.DATE_FORMATE_STRING_A));
         List<BillDto> billDtos = feeInnerServiceSMOImpl.queryBills(tmpBillDto);
 
         //Assert.listOnlyOne(billDtos, "当前存在多个有效账单" + feeConfigDto.getConfigId());
@@ -139,8 +140,15 @@ public class GenerateBillTemplate extends TaskSystemQuartz {
         billDto.setCommunityId(feeConfigDto.getCommunityId());
         billDto.setConfigId(feeConfigDto.getConfigId());
         billDto.setCurBill("T");
+        //查询历史有效账单
+        tmpBillDto = new BillDto();
+        tmpBillDto.setCurBill("T");
+        tmpBillDto.setConfigId(feeConfigDto.getConfigId());
+        tmpBillDto.setCommunityId(feeConfigDto.getCommunityId());
+        billDtos = feeInnerServiceSMOImpl.queryBills(tmpBillDto);
 
-        Date startTime = billDtos == null ? getDefaultStartTime(feeConfigDto.getBillType()) : DateUtil.getDateFromString(billDtos.get(0).getBillTime(), DateUtil.DATE_FORMATE_STRING_A);
+        startTime = (billDtos == null || billDtos.size() < 1) ? getDefaultStartTime(feeConfigDto.getBillType())
+                : DateUtil.getDateFromString(billDtos.get(0).getBillTime(), DateUtil.DATE_FORMATE_STRING_A);
 
         FeeDto feeDto = new FeeDto();
         feeDto.setConfigId(feeConfigDto.getConfigId());
@@ -156,10 +164,11 @@ public class GenerateBillTemplate extends TaskSystemQuartz {
             generateFee(startTime, tmpFeeDto, billDto);
         }
 
+
         //生成本次账单
         Date billEndTime = DateUtil.getCurrentDate();
-        billDto.setRemark(DateUtil.getFormatTimeString(startTime,DateUtil.DATE_FORMATE_STRING_A) +
-                "-"+DateUtil.getFormatTimeString(billEndTime,DateUtil.DATE_FORMATE_STRING_A) + "账单数据");
+        billDto.setRemark(DateUtil.getFormatTimeString(startTime, DateUtil.DATE_FORMATE_STRING_A) +
+                "-" + DateUtil.getFormatTimeString(billEndTime, DateUtil.DATE_FORMATE_STRING_A) + "账单数据");
         feeInnerServiceSMOImpl.insertBill(billDto);
 
     }
@@ -192,7 +201,14 @@ public class GenerateBillTemplate extends TaskSystemQuartz {
             return;
         }
 
-        computeFeePriceByRoom(feeDto);
+        if ("3333".equals(feeDto.getPayerObjType())) {
+            computeFeePriceByRoom(feeDto);
+        } else if ("6666".equals(feeDto.getPayerObjType())) {
+            computeFeePriceByParkingSpace(feeDto);
+        } else {
+            return;//这个没有欠费可算
+            //throw new IllegalArgumentException("暂不支持该类型出账" + feeDto.getFeeId());
+        }
 
         if (feeDto.getFeePrice() <= 0) {
             return;//这个没有欠费可算
@@ -407,6 +423,38 @@ public class GenerateBillTemplate extends TaskSystemQuartz {
         feeDto.setFeePrice(feePrice);
     }
 
+    /**
+     * 根据车位来算单价
+     *
+     * @param feeDto
+     */
+    private void computeFeePriceByParkingSpace(FeeDto feeDto) {
+        ParkingSpaceDto parkingSpaceDto = new ParkingSpaceDto();
+        parkingSpaceDto.setCommunityId(feeDto.getCommunityId());
+        parkingSpaceDto.setPsId(feeDto.getPayerObjId());
+        List<ParkingSpaceDto> parkingSpaceDtos = parkingSpaceInnerServiceSMOImpl.queryParkingSpaces(parkingSpaceDto);
+
+        if (parkingSpaceDtos == null || parkingSpaceDtos.size() < 1) { //数据有问题
+            return;
+        }
+
+        String computingFormula = feeDto.getComputingFormula();
+        double feePrice = 0.00;
+        if ("1001".equals(computingFormula)) { //面积*单价+附加费
+            BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getSquarePrice()));
+            BigDecimal builtUpArea = new BigDecimal(Double.parseDouble(parkingSpaceDtos.get(0).getArea()));
+            BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
+            feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+        } else if ("2002".equals(computingFormula)) { // 固定费用
+            BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
+            feePrice = additionalAmount.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+        } else {
+            feePrice = -1.00;
+        }
+
+        feeDto.setFeePrice(feePrice);
+    }
+
     /**
      * 计算2个日期之间相差的  以年、月、日为单位,各自计算结果是多少
      * 比如:2011-02-02 到  2017-03-02