java110
2020-09-24 cdd60f8c16d96d19b7bdf0ff548afee9dd767f7f
加入 托收
9个文件已修改
746 ■■■■■ 已修改文件
java110-bean/src/main/java/com/java110/dto/feeManualCollection/FeeManualCollectionDto.java 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-bean/src/main/java/com/java110/dto/feeManualCollectionDetail/FeeManualCollectionDetailDto.java 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-core/src/main/java/com/java110/core/smo/IComputeFeeSMO.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-core/src/main/java/com/java110/core/smo/impl/ComputeFeeSMOImpl.java 123 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-db/src/main/resources/mapper/fee/FeeManualCollectionServiceDaoImplMapper.xml 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-generator/src/main/resources/web/template_1.json 124 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-fee/src/main/java/com/java110/fee/api/FeeManualCollectionApi.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-fee/src/main/java/com/java110/fee/bmo/feeManualCollection/impl/SaveFeeManualCollectionBMOImpl.java 139 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-fee/src/main/java/com/java110/fee/bmo/impl/QueryOweFeeImpl.java 168 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-bean/src/main/java/com/java110/dto/feeManualCollection/FeeManualCollectionDto.java
@@ -1,6 +1,7 @@
package com.java110.dto.feeManualCollection;
import com.java110.dto.PageDto;
import java.io.Serializable;
import java.util.Date;
@@ -13,18 +14,21 @@
 * add by wuxw 2019/4/24
 **/
public class FeeManualCollectionDto extends PageDto implements Serializable {
    //状态 1010 托收中 2020 托收结束,3030 托收失败
    public static final String STATE_COLLECTION = "1010";
    public static final String STATE_FINISH = "2020";
    public static final String STATE_FAIL = "3030";
    private String squarePrice;
private String ownerName;
private String link;
private String roomArea;
private String remark;
private String state;
private String ownerId;
private String communityId;
private String collectionId;
private String roomId;
private String roomName;
    private String ownerName;
    private String link;
    private String roomArea;
    private String remark;
    private String state;
    private String ownerId;
    private String communityId;
    private String collectionId;
    private String roomId;
    private String roomName;
    private Date createTime;
@@ -35,67 +39,88 @@
    public String getSquarePrice() {
        return squarePrice;
    }
public void setSquarePrice(String squarePrice) {
    public void setSquarePrice(String squarePrice) {
        this.squarePrice = squarePrice;
    }
public String getOwnerName() {
    public String getOwnerName() {
        return ownerName;
    }
public void setOwnerName(String ownerName) {
    public void setOwnerName(String ownerName) {
        this.ownerName = ownerName;
    }
public String getLink() {
    public String getLink() {
        return link;
    }
public void setLink(String link) {
    public void setLink(String link) {
        this.link = link;
    }
public String getRoomArea() {
    public String getRoomArea() {
        return roomArea;
    }
public void setRoomArea(String roomArea) {
    public void setRoomArea(String roomArea) {
        this.roomArea = roomArea;
    }
public String getRemark() {
    public String getRemark() {
        return remark;
    }
public void setRemark(String remark) {
    public void setRemark(String remark) {
        this.remark = remark;
    }
public String getState() {
    public String getState() {
        return state;
    }
public void setState(String state) {
    public void setState(String state) {
        this.state = state;
    }
public String getOwnerId() {
    public String getOwnerId() {
        return ownerId;
    }
public void setOwnerId(String ownerId) {
    public void setOwnerId(String ownerId) {
        this.ownerId = ownerId;
    }
public String getCommunityId() {
    public String getCommunityId() {
        return communityId;
    }
public void setCommunityId(String communityId) {
    public void setCommunityId(String communityId) {
        this.communityId = communityId;
    }
public String getCollectionId() {
    public String getCollectionId() {
        return collectionId;
    }
public void setCollectionId(String collectionId) {
    public void setCollectionId(String collectionId) {
        this.collectionId = collectionId;
    }
public String getRoomId() {
    public String getRoomId() {
        return roomId;
    }
public void setRoomId(String roomId) {
    public void setRoomId(String roomId) {
        this.roomId = roomId;
    }
public String getRoomName() {
    public String getRoomName() {
        return roomName;
    }
public void setRoomName(String roomName) {
    public void setRoomName(String roomName) {
        this.roomName = roomName;
    }
java110-bean/src/main/java/com/java110/dto/feeManualCollectionDetail/FeeManualCollectionDetailDto.java
@@ -1,6 +1,7 @@
package com.java110.dto.feeManualCollectionDetail;
import com.java110.dto.PageDto;
import java.io.Serializable;
import java.util.Date;
@@ -14,15 +15,20 @@
 **/
public class FeeManualCollectionDetailDto extends PageDto implements Serializable {
    //1010 托收中,2020 已缴费 3030 作废
    public static final String STATE_COLLECTION ="1010";
    public static final String STATE_PAY_FEE ="2020";
    public static final String STATE_DELETE ="3030";
    private String amount;
private String feeName;
private String detailId;
private String startTime;
private String endTime;
private String state;
private String communityId;
private String collectionId;
private String feeId;
    private String feeName;
    private String detailId;
    private String startTime;
    private String endTime;
    private String state;
    private String communityId;
    private String collectionId;
    private String feeId;
    private Date createTime;
@@ -33,55 +39,72 @@
    public String getAmount() {
        return amount;
    }
public void setAmount(String amount) {
    public void setAmount(String amount) {
        this.amount = amount;
    }
public String getFeeName() {
    public String getFeeName() {
        return feeName;
    }
public void setFeeName(String feeName) {
    public void setFeeName(String feeName) {
        this.feeName = feeName;
    }
public String getDetailId() {
    public String getDetailId() {
        return detailId;
    }
public void setDetailId(String detailId) {
    public void setDetailId(String detailId) {
        this.detailId = detailId;
    }
public String getStartTime() {
    public String getStartTime() {
        return startTime;
    }
public void setStartTime(String startTime) {
    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }
public String getEndTime() {
    public String getEndTime() {
        return endTime;
    }
public void setEndTime(String endTime) {
    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }
public String getState() {
    public String getState() {
        return state;
    }
public void setState(String state) {
    public void setState(String state) {
        this.state = state;
    }
public String getCommunityId() {
    public String getCommunityId() {
        return communityId;
    }
public void setCommunityId(String communityId) {
    public void setCommunityId(String communityId) {
        this.communityId = communityId;
    }
public String getCollectionId() {
    public String getCollectionId() {
        return collectionId;
    }
public void setCollectionId(String collectionId) {
    public void setCollectionId(String collectionId) {
        this.collectionId = collectionId;
    }
public String getFeeId() {
    public String getFeeId() {
        return feeId;
    }
public void setFeeId(String feeId) {
    public void setFeeId(String feeId) {
        this.feeId = feeId;
    }
java110-core/src/main/java/com/java110/core/smo/IComputeFeeSMO.java
@@ -24,7 +24,15 @@
    Date getFeeEndTime();
    /**
     * 计算欠费金额
     *
     * @param tmpFeeDto
     */
    public void computeOweFee(FeeDto tmpFeeDto);
    /**
     * 刷新
     *
     * @param feeDto
     * @param feeReceiptDetailPo
     */
@@ -32,6 +40,7 @@
    /**
     * 根据周期 计算费用状态
     *
     * @param feeDto
     * @param cycles
     * @return
@@ -40,12 +49,15 @@
    /**
     * 查询费用对象名称
     *
     * @param feeDto
     * @return
     */
    public String getFeeObjName(FeeDto feeDto);
    /**
     * 根据缴费周期计算 结束时间
     *
     * @param feeDto
     * @param cycles 缴费周期
     * @return
java110-core/src/main/java/com/java110/core/smo/impl/ComputeFeeSMOImpl.java
@@ -2,6 +2,9 @@
import com.java110.core.smo.IComputeFeeSMO;
import com.java110.dto.RoomDto;
import com.java110.dto.fee.BillDto;
import com.java110.dto.fee.BillOweFeeDto;
import com.java110.dto.fee.FeeConfigDto;
import com.java110.dto.fee.FeeDto;
import com.java110.dto.owner.OwnerCarDto;
import com.java110.dto.parking.ParkingSpaceDto;
@@ -15,11 +18,14 @@
import com.java110.utils.util.Assert;
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.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.ParseException;
import java.util.*;
/**
@@ -32,6 +38,9 @@
@Service
public class ComputeFeeSMOImpl implements IComputeFeeSMO {
    protected static final Logger logger = LoggerFactory.getLogger(ComputeFeeSMOImpl.class);
    @Autowired
    private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
@@ -49,9 +58,123 @@
        return null;
    }
    /**
     * 计算欠费金额
     *
     * @param tmpFeeDto
     */
    public void computeOweFee(FeeDto tmpFeeDto) {
        String billType = tmpFeeDto.getBillType();
        if (FeeConfigDto.BILL_TYPE_EVERY.equals(billType)) {
            computeFeePrice(tmpFeeDto);
            return;
        }
        BillDto billDto = new BillDto();
        billDto.setCommunityId(tmpFeeDto.getCommunityId());
        billDto.setConfigId(tmpFeeDto.getConfigId());
        billDto.setCurBill("T");
        List<BillDto> billDtos = feeInnerServiceSMOImpl.queryBills(billDto);
        if (billDtos == null || billDtos.size() < 1) {
            tmpFeeDto.setFeePrice(0.00);
            return;
        }
        BillOweFeeDto billOweFeeDto = new BillOweFeeDto();
        billOweFeeDto.setCommunityId(tmpFeeDto.getCommunityId());
        billOweFeeDto.setFeeId(tmpFeeDto.getFeeId());
        billOweFeeDto.setState(BillOweFeeDto.STATE_WILL_FEE);
        billOweFeeDto.setBillId(billDtos.get(0).getBillId());
        List<BillOweFeeDto> billOweFeeDtos = feeInnerServiceSMOImpl.queryBillOweFees(billOweFeeDto);
        if (billOweFeeDtos == null || billOweFeeDtos.size() < 1) {
            tmpFeeDto.setFeePrice(0.00);
            return;
        }
        try {
            tmpFeeDto.setDeadlineTime(DateUtil.getDateFromString(billOweFeeDtos.get(0).getDeadlineTime(), DateUtil.DATE_FORMATE_STRING_A));
        } catch (ParseException e) {
            logger.error("获取结束时间失败", e);
        }
        tmpFeeDto.setFeePrice(Double.parseDouble(billOweFeeDtos.get(0).getAmountOwed()));
    }
    private void computeFeePrice(FeeDto feeDto) {
        if (FeeDto.PAYER_OBJ_TYPE_ROOM.equals(feeDto.getPayerObjType())) { //房屋相关
            computeFeePriceByRoom(feeDto);
        } else if (FeeDto.PAYER_OBJ_TYPE_CAR.equals(feeDto.getPayerObjType())) {//车位相关
            computeFeePriceByParkingSpace(feeDto);
        }
    }
    private void computeFeePriceByParkingSpace(FeeDto feeDto) {
        Map<String, Object> targetEndDateAndOweMonth = getTargetEndDateAndOweMonth(feeDto);
        Date targetEndDate = (Date) targetEndDateAndOweMonth.get("targetEndDate");
        double oweMonth = (double) targetEndDateAndOweMonth.get("oweMonth");
        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 = getFeePrice(feeDto);
        feeDto.setFeePrice(feePrice);
        double month = dayCompare(feeDto.getEndTime(), DateUtil.getCurrentDate());
        BigDecimal price = new BigDecimal(feeDto.getFeePrice());
        price = price.multiply(new BigDecimal(oweMonth));
        feeDto.setFeePrice(price.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
        feeDto.setDeadlineTime(targetEndDate);
        //动态费用
        if ("4004".equals(computingFormula)) {
            feeDto.setAmountOwed(feeDto.getFeePrice() + "");
            feeDto.setDeadlineTime(DateUtil.getCurrentDate());
        }
    }
    /**
     * 根据房屋来算单价
     *
     * @param feeDto
     */
    private void computeFeePriceByRoom(FeeDto feeDto) {
        Map<String, Object> targetEndDateAndOweMonth = getTargetEndDateAndOweMonth(feeDto);
        Date targetEndDate = (Date) targetEndDateAndOweMonth.get("targetEndDate");
        double oweMonth = (double) targetEndDateAndOweMonth.get("oweMonth");
        RoomDto roomDto = new RoomDto();
        roomDto.setCommunityId(feeDto.getCommunityId());
        roomDto.setRoomId(feeDto.getPayerObjId());
        List<RoomDto> roomDtos = roomInnerServiceSMOImpl.queryRooms(roomDto);
        if (roomDtos == null || roomDtos.size() < 1) { //数据有问题
            return;
        }
        String computingFormula = feeDto.getComputingFormula();
        double feePrice = getFeePrice(feeDto);
        feeDto.setFeePrice(feePrice);
        //double month = dayCompare(feeDto.getEndTime(), DateUtil.getCurrentDate());
        BigDecimal price = new BigDecimal(feeDto.getFeePrice());
        price = price.multiply(new BigDecimal(oweMonth));
        feeDto.setFeePrice(price.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
        feeDto.setDeadlineTime(targetEndDate);
        //动态费用
        if ("4004".equals(computingFormula)) {
            feeDto.setAmountOwed(feeDto.getFeePrice() + "");
            feeDto.setDeadlineTime(DateUtil.getCurrentDate());
        }
    }
    /**
     * 刷新 收据明细
     *
     * @param feeDto
     * @param feeReceiptDetailPo
     */
java110-db/src/main/resources/mapper/fee/FeeManualCollectionServiceDaoImplMapper.xml
@@ -8,25 +8,23 @@
    <!-- 保存人工托收信息 add by wuxw 2018-07-03 -->
    <insert id="saveFeeManualCollectionInfo" parameterType="Map">
        insert into fee_manual_collection(
        square_price,owner_name,link,room_area,remark,state,owner_id,community_id,collection_id,room_id,room_name
        owner_name,link,room_area,remark,state,owner_id,community_id,collection_id,room_id,room_name
        ) values (
        #{squarePrice},#{ownerName},#{link},#{roomArea},#{remark},#{state},#{ownerId},#{communityId},#{collectionId},#{roomId},#{roomName}
        #{ownerName},#{link},#{roomArea},#{remark},#{state},#{ownerId},#{communityId},#{collectionId},#{roomId},#{roomName}
        )
    </insert>
    <!-- 查询人工托收信息 add by wuxw 2018-07-03 -->
    <select id="getFeeManualCollectionInfo" parameterType="Map" resultType="Map">
        select t.square_price,t.square_price squarePrice,t.owner_name,t.owner_name
        select t.owner_name,t.owner_name
        ownerName,t.link,t.room_area,t.room_area roomArea,t.remark,t.status_cd,t.status_cd
        statusCd,t.state,t.owner_id,t.owner_id ownerId,t.community_id,t.community_id
        communityId,t.collection_id,t.collection_id collectionId,t.room_id,t.room_id roomId,t.room_name,t.room_name
        roomName
        from fee_manual_collection t
        where 1 =1
        <if test="squarePrice !=null and squarePrice != ''">
            and t.square_price= #{squarePrice}
        </if>
        <if test="ownerName !=null and ownerName != ''">
            and t.owner_name= #{ownerName}
        </if>
@@ -74,9 +72,6 @@
        <if test="newBId != null and newBId != ''">
            ,t.b_id = #{newBId}
        </if>
        <if test="squarePrice !=null and squarePrice != ''">
            , t.square_price= #{squarePrice}
        </if>
        <if test="ownerName !=null and ownerName != ''">
            , t.owner_name= #{ownerName}
        </if>
@@ -115,9 +110,6 @@
        select count(1) count
        from fee_manual_collection t
        where 1 =1
        <if test="squarePrice !=null and squarePrice != ''">
            and t.square_price= #{squarePrice}
        </if>
        <if test="ownerName !=null and ownerName != ''">
            and t.owner_name= #{ownerName}
        </if>
java110-generator/src/main/resources/web/template_1.json
@@ -1,59 +1,103 @@
{
  "templateName": "打印配置",
  "templateName": "人工托收",
  "directories": "property",
  "templateCode": "feePrintSpec",
  "templateKey": "specCd",
  "templateKeyName": "规格",
  "searchCode": "specCd",
  "searchName": "规格",
  "templateCode": "feeManualCollection",
  "templateKey": "collectionId",
  "templateKeyName": "托收ID",
  "searchCode": "collectionId",
  "searchName": "托收ID",
  "conditions": [
    {
      "name": "规格",
      "inputType": "select",
      "selectValue": "1010",
      "selectValueName": "催缴打印说明",
      "code": "specCd",
      "name": "房屋编号",
      "inputType": "input",
      "code": "roomName",
      "whereCondition": "equal"
    },
    {
      "name": "业主名称",
      "inputType": "input",
      "code": "ownerName",
      "whereCondition": "equal"
    },
    {
      "name": "业主电话",
      "inputType": "input",
      "code": "link",
      "whereCondition": "equal"
    }
  ],
  "columns": [
    {
      "code": "specCd",
      "code": "roomName",
      "cnCode": "规格",
      "desc": "必填,请填写规格名称",
      "required": true,
      "hasDefaultValue": false,
      "inputType": "select",
      "selectValue": "1010",
      "selectValueName": "催缴打印说明",
      "limit": "num",
      "limitParam": "",
      "limitErrInfo": "规格不是有效数字",
      "show": true
    },
    {
      "code": "content",
      "cnCode": "内容",
      "desc": "必填,请填写必填内容",
      "required": true,
      "hasDefaultValue": false,
      "inputType": "input",
      "limit": "maxLength",
      "limitParam": "1000",
      "limitErrInfo": "说明不能超过1000位",
      "show": false
    },
    {
      "code": "qrImg",
      "cnCode": "必填",
      "desc": "必填,请填写二维码",
      "desc": "必填,请填写房屋,如楼栋-单元-房屋",
      "required": true,
      "hasDefaultValue": false,
      "inputType": "input",
      "limit": "maxLength",
      "limitParam": "100",
      "limitErrInfo": "模板格式错误",
      "limitErrInfo": "房屋错误",
      "show": true
    },
    {
      "code": "ownerName",
      "cnCode": "业主名称",
      "desc": "必填,请填写业主名称",
      "required": true,
      "hasDefaultValue": false,
      "inputType": "input",
      "limit": "maxLength",
      "limitParam": "100",
      "limitErrInfo": "业主名称超过100位",
      "show": true
    },
    {
      "code": "link",
      "cnCode": "业主电话",
      "desc": "必填,请填写业主电话",
      "required": true,
      "hasDefaultValue": false,
      "inputType": "input",
      "limit": "phone",
      "limitParam": "",
      "limitErrInfo": "业主电话格式错误",
      "show": true
    },
    {
      "code": "roomArea",
      "cnCode": "房屋面积",
      "desc": "必填,请填写房屋面积",
      "required": true,
      "hasDefaultValue": false,
      "inputType": "input",
      "limit": "money",
      "limitParam": "",
      "limitErrInfo": "房屋面积格式错误",
      "show": true
    },
    {
      "code": "squarePrice",
      "cnCode": "房屋单价",
      "desc": "必填,请填写房屋单价",
      "required": true,
      "hasDefaultValue": false,
      "inputType": "input",
      "limit": "money",
      "limitParam": "",
      "limitErrInfo": "房屋单价格式错误",
      "show": true
    },
    {
      "code": "remark",
      "cnCode": "备注",
      "desc": "选填,请填写备注",
      "required": false,
      "hasDefaultValue": false,
      "inputType": "input",
      "limit": "maxLength",
      "limitParam": "200",
      "limitErrInfo": "备注超过200位",
      "show": false
    }
  ]
}
service-fee/src/main/java/com/java110/fee/api/FeeManualCollectionApi.java
@@ -61,7 +61,7 @@
        Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId");
        Assert.hasKeyAndValue(reqJson, "roomId", "请求报文中未包含roomId");
        Assert.hasKeyAndValue(reqJson, "ownerId", "请求报文中未包含ownerId");
        //Assert.hasKeyAndValue(reqJson, "ownerId", "请求报文中未包含ownerId");
        FeeManualCollectionPo feeManualCollectionPo = BeanConvertUtil.covertBean(reqJson, FeeManualCollectionPo.class);
service-fee/src/main/java/com/java110/fee/bmo/feeManualCollection/impl/SaveFeeManualCollectionBMOImpl.java
@@ -2,19 +2,51 @@
import com.java110.core.annotation.Java110Transactional;
import com.java110.core.factory.GenerateCodeFactory;
import com.java110.core.smo.IComputeFeeSMO;
import com.java110.dto.fee.FeeDto;
import com.java110.dto.feeManualCollection.FeeManualCollectionDto;
import com.java110.dto.feeManualCollectionDetail.FeeManualCollectionDetailDto;
import com.java110.dto.owner.OwnerCarDto;
import com.java110.dto.owner.OwnerDto;
import com.java110.fee.bmo.feeManualCollection.ISaveFeeManualCollectionBMO;
import com.java110.intf.IFeeManualCollectionDetailInnerServiceSMO;
import com.java110.intf.fee.IFeeInnerServiceSMO;
import com.java110.intf.fee.IFeeManualCollectionInnerServiceSMO;
import com.java110.intf.user.IOwnerCarInnerServiceSMO;
import com.java110.intf.user.IOwnerInnerServiceSMO;
import com.java110.po.feeManualCollection.FeeManualCollectionPo;
import com.java110.po.feeManualCollectionDetail.FeeManualCollectionDetailPo;
import com.java110.utils.util.Assert;
import com.java110.utils.util.DateUtil;
import com.java110.utils.util.StringUtil;
import com.java110.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service("saveFeeManualCollectionBMOImpl")
public class SaveFeeManualCollectionBMOImpl implements ISaveFeeManualCollectionBMO {
    @Autowired
    private IFeeManualCollectionInnerServiceSMO feeManualCollectionInnerServiceSMOImpl;
    @Autowired
    private IFeeManualCollectionDetailInnerServiceSMO feeManualCollectionDetailInnerServiceSMOImpl;
    @Autowired
    private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
    @Autowired
    private IComputeFeeSMO computeFeeSMOImpl;
    @Autowired
    private IOwnerInnerServiceSMO ownerInnerServiceSMOImpl;
    @Autowired
    private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl;
    /**
     * 添加小区信息
@@ -25,14 +57,115 @@
    @Java110Transactional
    public ResponseEntity<String> save(FeeManualCollectionPo feeManualCollectionPo) {
        FeeDto feeDto = new FeeDto();
        feeDto.setPayerObjId(feeManualCollectionPo.getRoomId());
        feeDto.setPayerObjType(FeeDto.PAYER_OBJ_TYPE_ROOM);
        feeDto.setCommunityId(feeManualCollectionPo.getCommunityId());
        //查询费用信息arrearsEndTime
        feeDto.setArrearsEndTime(DateUtil.getCurrentDate());
        feeDto.setState(FeeDto.STATE_DOING);
        List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
        if (feeDtos == null || feeDtos.size() < 1) {
            feeDtos = new ArrayList<>();
            return ResultVo.createResponseEntity(feeDtos);
        }
        List<FeeDto> tmpFeeDtos = new ArrayList<>();
        for (FeeDto tmpFeeDto : feeDtos) {
            computeFeeSMOImpl.computeOweFee(tmpFeeDto);//计算欠费金额
            //如果金额为0 就排除
            if (tmpFeeDto.getFeePrice() > 0) {
                tmpFeeDtos.add(tmpFeeDto);
            }
        }
        //查询停车费
        OwnerDto ownerDto = new OwnerDto();
        ownerDto.setCommunityId(feeManualCollectionPo.getCommunityId());
        ownerDto.setRoomId(feeManualCollectionPo.getRoomId());
        List<OwnerDto> ownerDtos = ownerInnerServiceSMOImpl.queryOwnersByRoom(ownerDto);
        Assert.listOnlyOne(ownerDtos, "业主信息 存在多条或者不存在");
        OwnerCarDto ownerCarDto = new OwnerCarDto();
        ownerCarDto.setCommunityId(feeManualCollectionPo.getCommunityId());
        ownerCarDto.setOwnerId(ownerDtos.get(0).getOwnerId());
        List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
        addOwnerCarFee(ownerCarDtos, tmpFeeDtos);
        if (tmpFeeDtos.size() < 1) {
            return ResultVo.createResponseEntity(ResultVo.CODE_ERROR, "当前房屋不存在托收费用");
        }
        feeManualCollectionPo.setOwnerId(ownerDtos.get(0).getOwnerId());
        feeManualCollectionPo.setLink(ownerCarDtos.get(0).getLink());
        feeManualCollectionPo.setOwnerName(ownerCarDtos.get(0).getOwnerName());
        feeManualCollectionPo.setState(FeeManualCollectionDto.STATE_COLLECTION);
        feeManualCollectionPo.setCollectionId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_receiptId));
        int flag = feeManualCollectionInnerServiceSMOImpl.saveFeeManualCollection(feeManualCollectionPo);
        if (flag > 0) {
            return ResultVo.createResponseEntity(ResultVo.CODE_OK, "保存成功");
        if (flag < 1) {
            return ResultVo.createResponseEntity(ResultVo.CODE_ERROR, "保存失败");
        }
        return ResultVo.createResponseEntity(ResultVo.CODE_ERROR, "保存失败");
        for (FeeDto tmpFeeDto : tmpFeeDtos) {
            saveFeeManualCollectionDetailInfo(tmpFeeDto, feeManualCollectionPo);
        }
        return ResultVo.createResponseEntity(ResultVo.CODE_OK, "保存成功");
    }
    private void saveFeeManualCollectionDetailInfo(FeeDto tmpFeeDto, FeeManualCollectionPo feeManualCollectionPo) {
        FeeManualCollectionDetailPo feeManualCollectionDetailPo = new FeeManualCollectionDetailPo();
        feeManualCollectionDetailPo.setAmount(tmpFeeDto.getFeePrice() + "");
        feeManualCollectionDetailPo.setCollectionId(feeManualCollectionPo.getCollectionId());
        feeManualCollectionDetailPo.setCommunityId(feeManualCollectionPo.getCommunityId());
        feeManualCollectionDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId));
        feeManualCollectionDetailPo.setFeeId(tmpFeeDto.getFeeId());
        feeManualCollectionDetailPo.setEndTime(DateUtil.getFormatTimeString(tmpFeeDto.getDeadlineTime(), DateUtil.DATE_FORMATE_STRING_A));
        feeManualCollectionDetailPo.setFeeName(StringUtil.isEmpty(tmpFeeDto.getImportFeeName()) ? tmpFeeDto.getFeeName() : tmpFeeDto.getImportFeeName());
        feeManualCollectionDetailPo.setStartTime(DateUtil.getFormatTimeString(tmpFeeDto.getEndTime(), DateUtil.DATE_FORMATE_STRING_A));
        feeManualCollectionDetailPo.setState(FeeManualCollectionDetailDto.STATE_COLLECTION);
        feeManualCollectionDetailInnerServiceSMOImpl.saveFeeManualCollectionDetail(feeManualCollectionDetailPo);
    }
    /**
     * 添加车位费
     *
     * @param ownerCarDtos
     * @param tmpFeeDtos
     */
    private void addOwnerCarFee(List<OwnerCarDto> ownerCarDtos, List<FeeDto> tmpFeeDtos) {
        if (ownerCarDtos == null || ownerCarDtos.size() < 1) {
            return;
        }
        for (OwnerCarDto ownerCarDto : ownerCarDtos) {
            FeeDto feeDto = new FeeDto();
            feeDto.setPayerObjId(ownerCarDto.getCarId());
            feeDto.setPayerObjType(FeeDto.PAYER_OBJ_TYPE_PARKING_SPACE);
            feeDto.setCommunityId(ownerCarDto.getCommunityId());
            //查询费用信息arrearsEndTime
            feeDto.setArrearsEndTime(DateUtil.getCurrentDate());
            feeDto.setState(FeeDto.STATE_DOING);
            List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
            if (feeDtos == null || feeDtos.size() < 1) {
                return;
            }
            for (FeeDto tmpFeeDto : feeDtos) {
                computeFeeSMOImpl.computeOweFee(tmpFeeDto);//计算欠费金额
                //如果金额为0 就排除
                if (tmpFeeDto.getFeePrice() > 0) {
                    tmpFeeDtos.add(tmpFeeDto);
                }
            }
        }
    }
}
service-fee/src/main/java/com/java110/fee/bmo/impl/QueryOweFeeImpl.java
@@ -1,6 +1,7 @@
package com.java110.fee.bmo.impl;
import com.alibaba.fastjson.JSONArray;
import com.java110.core.smo.IComputeFeeSMO;
import com.java110.dto.RoomDto;
import com.java110.dto.fee.BillDto;
import com.java110.dto.fee.BillOweFeeDto;
@@ -55,6 +56,9 @@
    @Autowired
    private IOwnerInnerServiceSMO ownerInnerServiceSMOImpl;
    @Autowired
    private IComputeFeeSMO computeFeeSMOImpl;
    @Override
    public ResponseEntity<String> query(FeeDto feeDto) {
@@ -70,7 +74,7 @@
        }
        List<FeeDto> tmpFeeDtos = new ArrayList<>();
        for (FeeDto tmpFeeDto : feeDtos) {
            computeOweFee(tmpFeeDto);//计算欠费金额
            computeFeeSMOImpl.computeOweFee(tmpFeeDto);//计算欠费金额
            //如果金额为0 就排除
            if (tmpFeeDto.getFeePrice() > 0) {
@@ -392,172 +396,10 @@
    }
    /**
     * 计算欠费金额
     *
     * @param tmpFeeDto
     */
    private void computeOweFee(FeeDto tmpFeeDto) {
        String billType = tmpFeeDto.getBillType();
        if (FeeConfigDto.BILL_TYPE_EVERY.equals(billType)) {
            computeFeePrice(tmpFeeDto);
            return;
        }
        BillDto billDto = new BillDto();
        billDto.setCommunityId(tmpFeeDto.getCommunityId());
        billDto.setConfigId(tmpFeeDto.getConfigId());
        billDto.setCurBill("T");
        List<BillDto> billDtos = feeInnerServiceSMOImpl.queryBills(billDto);
        if (billDtos == null || billDtos.size() < 1) {
            tmpFeeDto.setFeePrice(0.00);
            return;
        }
        BillOweFeeDto billOweFeeDto = new BillOweFeeDto();
        billOweFeeDto.setCommunityId(tmpFeeDto.getCommunityId());
        billOweFeeDto.setFeeId(tmpFeeDto.getFeeId());
        billOweFeeDto.setState(BillOweFeeDto.STATE_WILL_FEE);
        billOweFeeDto.setBillId(billDtos.get(0).getBillId());
        List<BillOweFeeDto> billOweFeeDtos = feeInnerServiceSMOImpl.queryBillOweFees(billOweFeeDto);
        if (billOweFeeDtos == null || billOweFeeDtos.size() < 1) {
            tmpFeeDto.setFeePrice(0.00);
            return;
        }
        try {
            tmpFeeDto.setDeadlineTime(DateUtil.getDateFromString(billOweFeeDtos.get(0).getDeadlineTime(), DateUtil.DATE_FORMATE_STRING_A));
        } catch (ParseException e) {
            logger.error("获取结束时间失败", e);
        }
        tmpFeeDto.setFeePrice(Double.parseDouble(billOweFeeDtos.get(0).getAmountOwed()));
    }
    private void computeFeePrice(FeeDto feeDto) {
        if ("3333".equals(feeDto.getPayerObjType())) { //房屋相关
            computeFeePriceByRoom(feeDto);
        } else if ("6666".equals(feeDto.getPayerObjType())) {//车位相关
            computeFeePriceByParkingSpace(feeDto);
        }
    }
    private void computeFeePriceByParkingSpace(FeeDto feeDto) {
        Map<String, Object> targetEndDateAndOweMonth = getTargetEndDateAndOweMonth(feeDto);
        Date targetEndDate = (Date) targetEndDateAndOweMonth.get("targetEndDate");
        double oweMonth = (double) targetEndDateAndOweMonth.get("oweMonth");
        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 if ("4004".equals(computingFormula)) {
            feePrice = Double.parseDouble(feeDto.getAmount());
        } else if ("5005".equals(computingFormula)) {
            if (StringUtil.isEmpty(feeDto.getCurDegrees())) {
                feePrice = -1.00;
            } else {
                BigDecimal curDegree = new BigDecimal(Double.parseDouble(feeDto.getCurDegrees()));
                BigDecimal preDegree = new BigDecimal(Double.parseDouble(feeDto.getPreDegrees()));
                BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getSquarePrice()));
                BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
                BigDecimal sub = curDegree.subtract(preDegree);
                feePrice = sub.multiply(squarePrice)
                        .add(additionalAmount)
                        .setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
            }
        } else {
            feePrice = 0.00;
        }
        feeDto.setFeePrice(feePrice);
        double month = dayCompare(feeDto.getEndTime(), DateUtil.getCurrentDate());
        BigDecimal price = new BigDecimal(feeDto.getFeePrice());
        price = price.multiply(new BigDecimal(oweMonth));
        feeDto.setFeePrice(price.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
        feeDto.setDeadlineTime(targetEndDate);
        //动态费用
        if ("4004".equals(computingFormula)) {
            feeDto.setAmountOwed(feeDto.getFeePrice() + "");
            feeDto.setDeadlineTime(DateUtil.getCurrentDate());
        }
    }
    /**
     * 根据房屋来算单价
     *
     * @param feeDto
     */
    private void computeFeePriceByRoom(FeeDto feeDto) {
        Map<String, Object> targetEndDateAndOweMonth = getTargetEndDateAndOweMonth(feeDto);
        Date targetEndDate = (Date) targetEndDateAndOweMonth.get("targetEndDate");
        double oweMonth = (double) targetEndDateAndOweMonth.get("oweMonth");
        RoomDto roomDto = new RoomDto();
        roomDto.setCommunityId(feeDto.getCommunityId());
        roomDto.setRoomId(feeDto.getPayerObjId());
        List<RoomDto> roomDtos = roomInnerServiceSMOImpl.queryRooms(roomDto);
        if (roomDtos == null || roomDtos.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(roomDtos.get(0).getBuiltUpArea()));
            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 if ("4004".equals(computingFormula)) {
            feePrice = Double.parseDouble(feeDto.getAmount());
        } else if ("5005".equals(computingFormula)) {
            if (StringUtil.isEmpty(feeDto.getCurDegrees())) {
                feePrice = -1.00;
            } else {
                BigDecimal curDegree = new BigDecimal(Double.parseDouble(feeDto.getCurDegrees()));
                BigDecimal preDegree = new BigDecimal(Double.parseDouble(feeDto.getPreDegrees()));
                BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getSquarePrice()));
                BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
                BigDecimal sub = curDegree.subtract(preDegree);
                feePrice = sub.multiply(squarePrice)
                        .add(additionalAmount)
                        .setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
            }
        } else {
            feePrice = 0.00;
        }
        feeDto.setFeePrice(feePrice);
        //double month = dayCompare(feeDto.getEndTime(), DateUtil.getCurrentDate());
        BigDecimal price = new BigDecimal(feeDto.getFeePrice());
        price = price.multiply(new BigDecimal(oweMonth));
        feeDto.setFeePrice(price.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
        feeDto.setDeadlineTime(targetEndDate);
        //动态费用
        if ("4004".equals(computingFormula)) {
            feeDto.setAmountOwed(feeDto.getFeePrice() + "");
            feeDto.setDeadlineTime(DateUtil.getCurrentDate());
        }
    }
    /**