| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.core.smo.IComputeFeeSMO; |
| | | import com.java110.dto.contract.ContractDto; |
| | | import com.java110.dto.contract.ContractPartyaDto; |
| | | import com.java110.dto.fee.FeeAttrDto; |
| | | import com.java110.dto.fee.FeeConfigDto; |
| | | import com.java110.dto.fee.FeeDetailDto; |
| | | import com.java110.dto.fee.FeeDto; |
| | | import com.java110.dto.importData.ImportRoomFee; |
| | | import com.java110.dto.log.AssetImportLogDetailDto; |
| | | import com.java110.dto.owner.OwnerCarDto; |
| | | import com.java110.dto.owner.OwnerRoomRelDto; |
| | | import com.java110.dto.room.RoomDto; |
| | | import com.java110.fee.api.FeeDiscountApi; |
| | | import com.java110.intf.community.IRoomInnerServiceSMO; |
| | | import com.java110.intf.fee.*; |
| | | import com.java110.intf.store.IContractInnerServiceSMO; |
| | | import com.java110.intf.store.IContractPartyaInnerServiceSMO; |
| | | import com.java110.intf.user.IOwnerCarInnerServiceSMO; |
| | | import com.java110.intf.user.IOwnerRoomRelV1InnerServiceSMO; |
| | | import com.java110.job.importData.DefaultImportData; |
| | |
| | | import com.java110.po.fee.PayFeeDetailPo; |
| | | import com.java110.po.fee.PayFeePo; |
| | | import com.java110.po.payFee.PayFeeDetailDiscountPo; |
| | | import com.java110.utils.constant.ResponseConstant; |
| | | import com.java110.utils.constant.StatusConstant; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import com.java110.utils.util.DateUtil; |
| | | import com.java110.utils.util.ListUtil; |
| | | import com.java110.utils.util.StringUtil; |
| | | import com.java110.utils.exception.ListenerExecuteException; |
| | | import com.java110.utils.util.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.ParseException; |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 车辆缴费信息导入 适配器 |
| | |
| | | private IRoomInnerServiceSMO roomInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IComputeFeeSMO computeFeeSMOImpl; |
| | | |
| | | @Autowired |
| | | private IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | |
| | | @Autowired |
| | | private IOwnerRoomRelV1InnerServiceSMO ownerRoomRelV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IContractPartyaInnerServiceSMO contractPartyaInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IContractInnerServiceSMO contractInnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public void importData(List<AssetImportLogDetailDto> assetImportLogDetailDtos) { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | public void importCarFeeDetails2(String storeId, String userId, List<ImportRoomFee> importCarFees, String batchId) { |
| | | |
| | | importCarFees = ownerCarInnerServiceSMOImpl.freshCarIds(importCarFees); |
| | | for (ImportRoomFee importCarFee : importCarFees) { |
| | | try { |
| | | if (StringUtil.isEmpty(importCarFee.getCarNum())) { |
| | | if(importCarFee.getObjType() != null && (importCarFee.getObjType().equals("7777"))){ |
| | | importCarFeeDetail(importCarFee, storeId, userId, batchId); |
| | | updateImportLogDetailState(importCarFee.getDetailId()); |
| | | } |
| | | } |
| | | else{ |
| | | OwnerCarDto ownerCarDto = new OwnerCarDto(); |
| | | ownerCarDto.setCommunityId(importCarFee.getCommunityId()); |
| | | ownerCarDto.setCarNum(importCarFee.getCarNum()); |
| | | List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto); |
| | | if (ownerCarDtos != null && ownerCarDtos.size() > 0) { |
| | | importCarFee.setCarId(ownerCarDtos.get(0).getCarId()); |
| | | }else{ |
| | | throw new IllegalStateException("车牌号不存在或存在多辆重复车牌号车"); |
| | | } |
| | | importCarFeeDetail(importCarFee, storeId, userId, batchId); |
| | | updateImportLogDetailState(importCarFee.getDetailId()); |
| | | } |
| | | } catch (Exception e) { |
| | | updateImportLogDetailState(importCarFee.getDetailId(), e); |
| | | throw new IllegalArgumentException(e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 导入 费用历史 |
| | | * |
| | |
| | | } |
| | | List<RoomDto> roomDtos = iRoomInnerServiceSMOImpl.queryRooms(roomDto); |
| | | try { |
| | | importRoomFee.setRoomId(roomDtos.get(0).getRoomId()); |
| | | if (importRoomFee.getPayObjId() != null && importRoomFee.getPayObjId().equals("7777")){ |
| | | ContractPartyaDto contractPartyaDto = new ContractPartyaDto(); |
| | | contractPartyaDto.setCommunityId(importRoomFee.getCommunityId()); |
| | | contractPartyaDto.setPartyA(importRoomFee.getDoorRoomNum()); |
| | | List<ContractPartyaDto> contractPartyaDtos = contractPartyaInnerServiceSMOImpl.queryContractPartyas(contractPartyaDto); |
| | | if (contractPartyaDtos != null && contractPartyaDtos.size() > 0) { |
| | | ContractDto contractDto = new ContractDto(); |
| | | contractDto.setContractCode(importRoomFee.getContractId()); |
| | | List<ContractDto> contractDtos = contractInnerServiceSMOImpl.queryContracts(contractDto); |
| | | if (contractDtos.size() == 0) { |
| | | importRoomFee.setContractId(contractDtos.get(0).getContractId()); |
| | | } |
| | | importRoomFee.setRoomId(contractPartyaDtos.get(0).getPartyaId()); |
| | | }else{ |
| | | throw new RuntimeException(); |
| | | } |
| | | }else{ |
| | | importRoomFee.setRoomId(roomDtos.get(0).getRoomId()); |
| | | } |
| | | }catch (Exception e){ |
| | | if(!(importRoomFee.getPayObjId().equals("7777"))){ |
| | | updateImportLogDetailState(importRoomFee.getDetailId(),new IllegalArgumentException("费用项"+importRoomFee.getFeeName()+"不存在")); |
| | | throw new IllegalArgumentException("门室号"+importRoomFee.getDoorRoomNum()+"未查询到房屋"); |
| | | if (importRoomFee.getPayObjId() != null &&importRoomFee.getPayObjId().equals("7777")){ |
| | | updateImportLogDetailState(importRoomFee.getDetailId(),new IllegalArgumentException("合同主体:"+importRoomFee.getDoorRoomNum()+"未查询到")); |
| | | throw new IllegalArgumentException("合同主体:"+importRoomFee.getDoorRoomNum()+"未查询到"); |
| | | }else { |
| | | updateImportLogDetailState(importRoomFee.getDetailId(), new IllegalArgumentException("门室号:" + importRoomFee.getDoorRoomNum() + "未查询到")); |
| | | throw new IllegalArgumentException("门室号:" + importRoomFee.getDoorRoomNum() + "未查询到"); |
| | | } |
| | | } |
| | | PayFeeDetailPo payFeeDetailPo = new PayFeeDetailPo(); |
| | |
| | | payFeeDetailPo.setCycles(importRoomFee.getCycle()); |
| | | payFeeDetailPo.setCreateTime(importRoomFee.getCreateTime()); |
| | | payFeeDetailPo.setCommunityId(importRoomFee.getCommunityId()); |
| | | payFeeDetailPo.setPayOrderId(importRoomFee.getRoomId()); |
| | | payFeeDetailPo.setStartTime(importRoomFee.getStartTime()); |
| | | payFeeDetailPo.setReceivedAmount(importRoomFee.getAmount()); |
| | | payFeeDetailPo.setContractId(importRoomFee.getContractId()); |
| | | int count = feeDetailInnerServiceSMOImpl.queryFeeDetailsCountByVo(payFeeDetailPo); |
| | | |
| | | if (count > 0) { |
| | | throw new IllegalStateException("重复的缴费记录"); |
| | | throw new IllegalArgumentException("重复的缴费记录"); |
| | | } |
| | | |
| | | |
| | |
| | | feeDto.setConfigId(tmpFeeConfigDto.getConfigId()); |
| | | feeDto.setCommunityId(importRoomFee.getCommunityId()); |
| | | feeDto.setPayerObjId(importRoomFee.getCarId()); |
| | | feeDto.setPayerObjType(FeeDto.PAYER_OBJ_TYPE_CAR); |
| | | feeDto.setPayerObjType(importRoomFee.getObjType() == null ? "6666" : importRoomFee.getObjType()); |
| | | List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto); |
| | | List<PayFeePo> payFeePos = null; |
| | | if (ListUtil.isNull(feeDtos)) { |
| | | throw new IllegalArgumentException("不存在对应的缴费记录"); |
| | | throw new IllegalArgumentException("不存在对应的费用记录"); |
| | | // PayFeePo payFeePo = new PayFeePo(); |
| | | // payFeePo.setCommunityId(importRoomFee.getCommunityId()); |
| | | // payFeePo.setConfigId(feeDto.getConfigId()); |
| | |
| | | PayFeeDetailPo payFeeDetailPo = new PayFeeDetailPo(); |
| | | payFeeDetailPo.setCommunityId(importRoomFee.getCommunityId()); |
| | | payFeeDetailPo.setReceivedAmount(importRoomFee.getAmount()); |
| | | payFeeDetailPo.setReceivableAmount(importRoomFee.getReceivableAmount()); |
| | | payFeeDetailPo.setCycles(importRoomFee.getCycle()); |
| | | payFeeDetailPo.setPrimeRate("1.0"); |
| | | payFeeDetailPo.setFeeId(tmpFeeDto.getFeeId()); |
| | |
| | | ResponseEntity<String> resultVo = null; |
| | | try { |
| | | resultVo = feeDiscountApi.computeFeeDiscount(tmpFeeDto.getFeeId(), tmpFeeDto.getCommunityId(), 105, importRoomFee.getPayObjId(), |
| | | tmpFeeDto.getPayerObjType(), importRoomFee.getEndTime(), importRoomFee.getEndTime(), importRoomFee.getStartTime(), 1, 20); |
| | | tmpFeeDto.getPayerObjType(), importRoomFee.getEndTime(), importRoomFee.getStartTime(), importRoomFee.getEndTime(), 1, 20); |
| | | } catch (ParseException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | |
| | | String discountPrice = o.get("discountPrice").toString(); |
| | | String discountId = o.get("discountId").toString(); |
| | | payFeeDetailPo.setDiscountAmount(discountPrice); |
| | | payFeeDetailPo.setReceivableAmount((Double.parseDouble(payFeeDetailPo.getReceivedAmount()) + Double.parseDouble(payFeeDetailPo.getDiscountAmount()))+""); |
| | | payFeeDetailDiscount.setDiscountId(discountId); |
| | | payFeeDetailDiscount.setDiscountPrice(discountPrice); |
| | | } |
| | | } |
| | | |
| | | payFeeDetailPo.setReceivableAmount(computeFeeByCycle(tmpFeeDto,importRoomFee)+""); |
| | | int saved = feeDetailInnerServiceSMOImpl.saveFeeDetail(payFeeDetailPo); |
| | | |
| | | FeeDetailDto feeDetailDto = new FeeDetailDto(); |
| | |
| | | payFeeDetailDiscount.setCommunityId(feeDtos.get(0).getCommunityId()); |
| | | payFeeDetailDiscount.setFeeId(feeDtos.get(0).getFeeId()); |
| | | payFeeDetailDiscount.setDetailDiscountId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_discountId)); |
| | | payFeeDetailDiscountNewV1InnerServiceSMOImpl.savePayFeeDetailDiscountNew(payFeeDetailDiscount); |
| | | } |
| | | |
| | | payFeeDetailDiscountNewV1InnerServiceSMOImpl.savePayFeeDetailDiscountNew(payFeeDetailDiscount); |
| | | |
| | | if (saved < 1) { |
| | | return; |
| | |
| | | } |
| | | feeInnerServiceSMOImpl.updateFee(payFeePo); |
| | | } |
| | | private double computeFeeByCycle(FeeDto fee,ImportRoomFee importRoomFee) { |
| | | FeeDto feeDto = new FeeDto(); |
| | | feeDto.setFeeId(fee.getFeeId()); |
| | | feeDto.setCommunityId(fee.getCommunityId()); |
| | | List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto); |
| | | if (feeDtos == null || feeDtos.size() != 1) { |
| | | throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, "查询费用信息失败,未查到数据或查到多条数据"); |
| | | } |
| | | feeDto = feeDtos.get(0); |
| | | |
| | | double month = (DateUtil.dayCompare( |
| | | DateUtil.getDateFromStringA(importRoomFee.getStartTime()), |
| | | DateUtil.getDateFromStringA(importRoomFee.getEndTime().split(" ")[0] + " 23:59:59") |
| | | )); |
| | | Map feePriceAll = computeFeeSMOImpl.getFeePrice(feeDto); |
| | | //todo 计算应收 |
| | | BigDecimal receivableAmount = new BigDecimal(feePriceAll.get("feePrice").toString()); |
| | | BigDecimal cycles = new BigDecimal(month); |
| | | double tmpReceivableAmount = cycles.multiply(receivableAmount).setScale(4, BigDecimal.ROUND_HALF_EVEN).doubleValue(); |
| | | return MoneyUtil.computePriceScale(tmpReceivableAmount, feeDto.getScale(), Integer.parseInt(feeDto.getDecimalPlace())); |
| | | } |
| | | |
| | | } |