| | |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.YwContractBillMapper; |
| | | import com.doumee.dao.business.YwContractRoomMapper; |
| | | import com.doumee.dao.business.model.YwContract; |
| | | import com.doumee.dao.business.model.YwContractBill; |
| | | import com.doumee.dao.business.model.YwContractRoom; |
| | | import com.doumee.dao.business.model.YwCustomer; |
| | | import com.doumee.dao.system.MultifileMapper; |
| | | import com.doumee.dao.system.model.Multifile; |
| | | import com.doumee.service.business.YwContractBillService; |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | @Override |
| | | public void updateById(YwContractBill ywContractBill) { |
| | | if(Objects.isNull(ywContractBill) |
| | | || Objects.isNull(ywContractBill.getId()) |
| | | || Objects.isNull(ywContractBill.getContractId()) |
| | | || Objects.isNull(ywContractBill.getTotleFee()) |
| | | || Objects.isNull(ywContractBill.getPlanPayData()) |
| | | || Objects.isNull(ywContractBill.getCostType()) |
| | | || Objects.isNull(ywContractBill.getBillType()) |
| | | || Objects.isNull(ywContractBill.getCompanyId()) |
| | | || Objects.isNull(ywContractBill.getStartDate()) |
| | | || Objects.isNull(ywContractBill.getEndDate()) |
| | | || ywContractBill.getTotleFee().compareTo(BigDecimal.ZERO)<=Constants.ZERO |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | LoginUserInfo loginUserInfo = ywContractBill.getLoginUserInfo(); |
| | | ywContractBill.setEditDate(new Date()); |
| | | ywContractBill.setEditor(loginUserInfo.getId()); |
| | | if(Constants.equalsInteger(ywContractBill.getBillType(),Constants.ZERO)){ |
| | | ywContractBill.setPayStatus(Constants.ZERO); |
| | | }else{ |
| | | ywContractBill.setPayStatus(Constants.THREE); |
| | | } |
| | | ywContractBillMapper.insert(ywContractBill); |
| | | |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractBill.getYwContractRoomList())){ |
| | | for (YwContractRoom ywContractRoom:ywContractBill.getYwContractRoomList()) { |
| | | if(Objects.isNull(ywContractRoom) |
| | | || Objects.isNull(ywContractRoom.getRoomId())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"请选择房源数据"); |
| | | } |
| | | ywContractRoom.setCreateDate(new Date()); |
| | | ywContractRoom.setCreator(loginUserInfo.getId()); |
| | | ywContractRoom.setIsdeleted(Constants.ZERO); |
| | | ywContractRoom.setContractId(ywContractBill.getId()); |
| | | ywContractRoom.setType(Constants.ONE); |
| | | |
| | | } |
| | | ywContractRoomMapper.insert(ywContractBill.getYwContractRoomList()); |
| | | } |
| | | |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractBill.getMultifileList())){ |
| | | for (Multifile multifile:ywContractBill.getMultifileList()) { |
| | | if(Objects.isNull(multifile) |
| | | || StringUtils.isBlank(multifile.getFileurl()) |
| | | || StringUtils.isBlank(multifile.getName())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"附件信息错误"); |
| | | } |
| | | multifile.setCreator(loginUserInfo.getId()); |
| | | multifile.setCreateDate(new Date()); |
| | | multifile.setIsdeleted(Constants.ZERO); |
| | | multifile.setObjType(Constants.MultiFile.FN_PATROL_POINT_FILE.getKey()); |
| | | multifile.setObjId(ywContractBill.getId()); |
| | | } |
| | | multifileMapper.insert(ywContractBill.getMultifileList()); |
| | | } |
| | | ywContractBillMapper.updateById(ywContractBill); |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public PageData<YwContractBill> findPage(PageWrap<YwContractBill> pageWrap) { |
| | | IPage<YwContractBill> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | QueryWrapper<YwContractBill> queryWrapper = new QueryWrapper<>(); |
| | | MPJLambdaWrapper<YwContractBill> queryWrapper = new MPJLambdaWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | if (pageWrap.getModel().getId() != null) { |
| | | queryWrapper.lambda().eq(YwContractBill::getId, pageWrap.getModel().getId()); |
| | | } |
| | | if (pageWrap.getModel().getCreator() != null) { |
| | | queryWrapper.lambda().eq(YwContractBill::getCreator, pageWrap.getModel().getCreator()); |
| | | } |
| | | if (pageWrap.getModel().getCreateDate() != null) { |
| | | queryWrapper.lambda().ge(YwContractBill::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())); |
| | | queryWrapper.lambda().le(YwContractBill::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate())); |
| | | } |
| | | if (pageWrap.getModel().getEditor() != null) { |
| | | queryWrapper.lambda().eq(YwContractBill::getEditor, pageWrap.getModel().getEditor()); |
| | | } |
| | | if (pageWrap.getModel().getEditDate() != null) { |
| | | queryWrapper.lambda().ge(YwContractBill::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate())); |
| | | queryWrapper.lambda().le(YwContractBill::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate())); |
| | | } |
| | | if (pageWrap.getModel().getIsdeleted() != null) { |
| | | queryWrapper.lambda().eq(YwContractBill::getIsdeleted, pageWrap.getModel().getIsdeleted()); |
| | | } |
| | | if (pageWrap.getModel().getRemark() != null) { |
| | | queryWrapper.lambda().eq(YwContractBill::getRemark, pageWrap.getModel().getRemark()); |
| | | } |
| | | if (pageWrap.getModel().getStatus() != null) { |
| | | queryWrapper.lambda().eq(YwContractBill::getStatus, pageWrap.getModel().getStatus()); |
| | | } |
| | | if (pageWrap.getModel().getStartDate() != null) { |
| | | queryWrapper.lambda().ge(YwContractBill::getStartDate, Utils.Date.getStart(pageWrap.getModel().getStartDate())); |
| | | queryWrapper.lambda().le(YwContractBill::getStartDate, Utils.Date.getEnd(pageWrap.getModel().getStartDate())); |
| | | } |
| | | if (pageWrap.getModel().getEndDate() != null) { |
| | | queryWrapper.lambda().ge(YwContractBill::getEndDate, Utils.Date.getStart(pageWrap.getModel().getEndDate())); |
| | | queryWrapper.lambda().le(YwContractBill::getEndDate, Utils.Date.getEnd(pageWrap.getModel().getEndDate())); |
| | | } |
| | | if (pageWrap.getModel().getDetailId() != null) { |
| | | queryWrapper.lambda().eq(YwContractBill::getDetailId, pageWrap.getModel().getDetailId()); |
| | | } |
| | | if (pageWrap.getModel().getContractId() != null) { |
| | | queryWrapper.lambda().eq(YwContractBill::getContractId, pageWrap.getModel().getContractId()); |
| | | } |
| | | if (pageWrap.getModel().getSortnum() != null) { |
| | | queryWrapper.lambda().eq(YwContractBill::getSortnum, pageWrap.getModel().getSortnum()); |
| | | } |
| | | if (pageWrap.getModel().getTotleFee() != null) { |
| | | queryWrapper.lambda().eq(YwContractBill::getTotleFee, pageWrap.getModel().getTotleFee()); |
| | | } |
| | | for(PageWrap.SortData sortData: pageWrap.getSorts()) { |
| | | if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { |
| | | queryWrapper.orderByDesc(sortData.getProperty()); |
| | | } else { |
| | | queryWrapper.orderByAsc(sortData.getProperty()); |
| | | } |
| | | } |
| | | queryWrapper.selectAll(YwContractBill.class) |
| | | .leftJoin(YwContract.class,YwContract::getId,YwContractBill::getContractId) |
| | | .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId) |
| | | ; |
| | | |
| | | return PageData.from(ywContractBillMapper.selectPage(page, queryWrapper)); |
| | | } |
| | | |