package com.java110.fee.feeMonth;
|
|
import com.java110.core.smo.IComputeFeeSMO;
|
import com.java110.dto.RoomDto;
|
import com.java110.dto.fee.FeeAttrDto;
|
import com.java110.dto.fee.FeeDto;
|
import com.java110.dto.payFeeDetailMonth.PayFeeMonthOwnerDto;
|
import com.java110.intf.community.IRoomInnerServiceSMO;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.math.BigDecimal;
|
import java.util.List;
|
import java.util.Map;
|
|
@Service
|
public class PayFeeMonthHelp implements IPayFeeMonthHelp {
|
|
@Autowired
|
private IRoomInnerServiceSMO roomInnerServiceSMOImpl;
|
|
@Autowired
|
private IComputeFeeSMO computeFeeSMOImpl;
|
|
|
public PayFeeMonthOwnerDto generatorOwnerRoom(FeeDto feeDto) {
|
|
PayFeeMonthOwnerDto payFeeMonthOwnerDto = new PayFeeMonthOwnerDto();
|
payFeeMonthOwnerDto.setOwnerId(FeeAttrDto.getFeeAttrValue(feeDto, FeeAttrDto.SPEC_CD_OWNER_ID));
|
payFeeMonthOwnerDto.setOwnerName(FeeAttrDto.getFeeAttrValue(feeDto, FeeAttrDto.SPEC_CD_OWNER_NAME));
|
payFeeMonthOwnerDto.setLink(FeeAttrDto.getFeeAttrValue(feeDto, FeeAttrDto.SPEC_CD_OWNER_LINK));
|
payFeeMonthOwnerDto.setObjName(FeeAttrDto.getFeeAttrValue(feeDto, FeeAttrDto.SPEC_CD_PAY_OBJECT_NAME));
|
payFeeMonthOwnerDto.setObjId(feeDto.getPayerObjId());
|
return payFeeMonthOwnerDto;
|
}
|
|
/**
|
* 计算每月单价
|
*
|
* @param feeDto
|
* @return
|
*/
|
public Double getMonthFeePrice(FeeDto feeDto) {
|
Map feePriceAll = computeFeeSMOImpl.getFeePrice(feeDto);
|
|
Double feePrice = Double.parseDouble(feePriceAll.get("feePrice").toString());
|
//todo 如果是一次性费用 除以
|
if (!FeeDto.FEE_FLAG_ONCE.equals(feeDto.getPayerObjType())) {
|
return feePrice;
|
}
|
double maxMonth = Math.ceil(computeFeeSMOImpl.dayCompare(feeDto.getStartTime(), feeDto.getEndTime()));
|
if (maxMonth <= 0) {
|
return feePrice;
|
|
}
|
BigDecimal feePriceDec = new BigDecimal(feePrice).divide(new BigDecimal(maxMonth), 2, BigDecimal.ROUND_HALF_UP);
|
feePrice = feePriceDec.doubleValue();
|
return feePrice;
|
}
|
|
|
}
|