| @@ -3,11 +3,15 @@ package com.iformall.controller; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxBillProperty; | |||
| import com.iformall.domain.po.WxFlowRecord; | |||
| import com.iformall.domain.po.WxPropertyContract; | |||
| import com.iformall.domain.po.WxRentContract; | |||
| import com.iformall.enums.EnumFlowRecordStatus; | |||
| import com.iformall.service.WxBillPropertyService; | |||
| import com.iformall.service.WxPropertyContractService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -76,6 +80,16 @@ public class WxPropertyContractController extends BaseController { | |||
| return wxPropertyContractService.getById(id); | |||
| } | |||
| /** | |||
| * 生成账单 | |||
| */ | |||
| @ApiOperation("生成账单") | |||
| @GetMapping(value = "/buildBill") | |||
| public ResultData buildBill(@ModelAttribute WxRentContract wxRentContract) { | |||
| logger.debug("[" + getIpAddr() + "] WxPropertyContractController::buildBill"); | |||
| return new ResultData(wxPropertyContractService.buildBill(wxRentContract)); | |||
| } | |||
| @RequestMapping("/download") | |||
| public void download(HttpServletRequest request, HttpServletResponse response){ | |||
| logger.debug("[" + getIpAddr() + "] WxPropertyContractController::download"); | |||
| @@ -1,10 +1,13 @@ | |||
| package com.iformall.service; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxBillProperty; | |||
| import com.iformall.domain.po.WxPropertyContract; | |||
| import com.iformall.domain.po.WxRentContract; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| /** | |||
| @@ -60,4 +63,6 @@ public interface WxPropertyContractService { | |||
| ResultData hasRentContract(Long rentContractId); | |||
| ResultData updatePropertyContractStatus(Long id); | |||
| List<WxBillProperty> buildBill(WxRentContract wxRentContract); | |||
| } | |||
| @@ -4,6 +4,7 @@ import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxBillRent; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxRentContract; | |||
| import io.swagger.models.auth.In; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| @@ -70,7 +71,7 @@ public interface WxRentContractService { | |||
| void updateApplyStatus(WxRentContract wxRentContract); | |||
| List<WxBillRent> buildRent(WxMerchant wxMerchant, Long userId,WxRentContract rentContract); | |||
| List<WxBillRent> buildRent(WxMerchant wxMerchant, Long userId,WxRentContract rentContract,Integer isPreview); | |||
| void buildDeposit(WxMerchant wxMerchant, Long userId); | |||
| @@ -316,7 +316,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| wxRentContract.setStatus(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()); | |||
| wxRentContractMapper.updateByPrimaryKeySelective(wxRentContract); | |||
| //创建账单 | |||
| wxRentContractService.buildRent(wxMerchant, userId,null); | |||
| wxRentContractService.buildRent(wxMerchant, userId,null,EnumIsPreview.NO.getCode()); | |||
| //创建押金 | |||
| wxRentContractService.buildDeposit(wxMerchant, userId); | |||
| } | |||
| @@ -125,7 +125,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| if(wxPropertyContract.getReceivePeriod() != null && wxPropertyContract.getLease()!=null) { | |||
| wxBillPropertyMapper.deletePreviewBill(wxPropertyContract); | |||
| //重新生成 | |||
| List<WxBillProperty> billList = buildProperty(new WxMerchant(),wxPropertyContract); | |||
| List<WxBillProperty> billList = buildProperty(new WxMerchant(),wxPropertyContract,EnumIsPreview.YES.getCode()); | |||
| wxPropertyContract.setPreviewBillRentList(billList); | |||
| } | |||
| @@ -377,7 +377,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| * @return | |||
| */ | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| public List<WxBillProperty> buildProperty(WxMerchant wxMerchant,WxPropertyContract propertyContract) { | |||
| public List<WxBillProperty> buildProperty(WxMerchant wxMerchant,WxPropertyContract propertyContract,Integer isPreview) { | |||
| List<WxBillProperty> result = new ArrayList<>(); | |||
| WxPropertyContract wxPropertyContract; | |||
| @@ -404,6 +404,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| for (int i = 0; i < paycount; i++) { | |||
| WxBillProperty wxBillProperty = new WxBillProperty(); | |||
| wxBillProperty.setIsPreview(isPreview); | |||
| wxBillProperty.setId(idWorker.nextId()); | |||
| wxBillProperty.setPropertyContractId(wxPropertyContract.getId()); | |||
| wxBillProperty.setPay(0); | |||
| @@ -596,7 +597,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| if (null == rentContractId) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "rentContractId不能为空"); | |||
| } | |||
| Map<String,Object> resultMap = new HashedMap(); | |||
| WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(rentContractId); | |||
| if (wxRentContract != null) { | |||
| WxPropertyContract wxPropertyContract = new WxPropertyContract(); | |||
| @@ -608,22 +609,11 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| propertyContract.getStatus().equals(EnumRentContractStatus.RENT_PAID.getCode()) || | |||
| propertyContract.getStatus().equals(EnumRentContractStatus.CONTRACT_END_SOON.getCode())).count(); | |||
| if (count > 0) { | |||
| resultMap.put("hasRent",true); | |||
| return new ResultData(true); | |||
| } | |||
| } | |||
| } | |||
| //生成预览账单 | |||
| //根据租赁合同找到对应的物业合同,生成物业账单 | |||
| WxPropertyContract propertyContract = wxPropertyContractMapper.findOneByRentId(wxRentContract); | |||
| if(propertyContract!=null && propertyContract.getReceivePeriod() != null && propertyContract.getLease()!=null) { | |||
| wxBillPropertyMapper.deletePreviewBill(propertyContract); | |||
| //重新生成 | |||
| List<WxBillProperty> billList = buildProperty(new WxMerchant(),propertyContract); | |||
| resultMap.put("billList",billList); | |||
| } | |||
| resultMap.put("hasRent",false); | |||
| return new ResultData(resultMap); | |||
| return new ResultData(false); | |||
| } | |||
| public Map<String, Object> updateStatus(WxPropertyContract record) { | |||
| @@ -734,5 +724,17 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| } | |||
| } | |||
| @Override | |||
| public List<WxBillProperty> buildBill(WxRentContract wxRentContract) { | |||
| //生成预览账单 | |||
| //根据租赁合同找到对应的物业合同,生成物业账单 | |||
| WxPropertyContract propertyContract = wxPropertyContractMapper.findOneByRentId(wxRentContract); | |||
| if(propertyContract!=null && propertyContract.getReceivePeriod() != null && propertyContract.getLease()!=null) { | |||
| wxBillPropertyMapper.deletePreviewBill(propertyContract); | |||
| //重新生成 | |||
| List<WxBillProperty> billList = buildProperty(new WxMerchant(),propertyContract,EnumIsPreview.YES.getCode()); | |||
| return billList; | |||
| } | |||
| return new ArrayList<>(); | |||
| } | |||
| } | |||
| @@ -150,7 +150,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| if(wxRentContract.getReceivePeriod() != null && wxRentContract.getLease()!=null && wxRentContract.getRentalStartDate()!=null && wxRentContract.getPrice()!= null){ | |||
| wxBillRentMapper.deletePreviewBill(wxRentContract); | |||
| //重新生成 | |||
| List<WxBillRent> resultList = buildRent(new WxMerchant(),null,wxRentContract); | |||
| List<WxBillRent> resultList = buildRent(new WxMerchant(),null,wxRentContract,EnumIsPreview.YES.getCode()); | |||
| wxRentContract.setPreviewBillRentList(resultList); | |||
| } | |||
| @@ -270,7 +270,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| if(record.getReceivePeriod() != null && record.getLease()!=null && record.getRentalStartDate()!=null && record.getPrice()!= null){ | |||
| wxBillRentMapper.deletePreviewBill(record); | |||
| //重新生成 | |||
| List<WxBillRent> resultList = buildRent(new WxMerchant(),null,record); | |||
| List<WxBillRent> resultList = buildRent(new WxMerchant(),null,record,EnumIsPreview.YES.getCode()); | |||
| wxRentContract.setPreviewBillRentList(resultList); | |||
| } | |||
| return new ResultData(wxRentContract); | |||
| @@ -404,7 +404,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| @Override | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| public List<WxBillRent> buildRent(WxMerchant wxMerchant, Long userId,WxRentContract rentContract) { | |||
| public List<WxBillRent> buildRent(WxMerchant wxMerchant, Long userId,WxRentContract rentContract,Integer isPreview) { | |||
| List<WxBillRent> rentList = new ArrayList<>(); | |||
| //根据商户ID找出合同 | |||
| WxRentContract wxRentContract; | |||
| @@ -425,10 +425,10 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| Integer price = wxRentContract.getPrice(); | |||
| //按月计租 | |||
| if (wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode())) { | |||
| rentList = buildRentMonth(wxMerchant, userId, wxRentContract, receivePeriod, lease, rentalStartDate, price,EnumIsPreview.NO.getCode()); | |||
| rentList = buildRentMonth(wxMerchant, userId, wxRentContract, receivePeriod, lease, rentalStartDate, price,isPreview); | |||
| } else { | |||
| //按日计租 | |||
| rentList = buildRent(lease, receivePeriod, price, rentalStartDate, Calendar.DAY_OF_MONTH, wxRentContract, userId, wxMerchant, 0,EnumIsPreview.NO.getCode()); | |||
| rentList = buildRent(lease, receivePeriod, price, rentalStartDate, Calendar.DAY_OF_MONTH, wxRentContract, userId, wxMerchant, 0,isPreview); | |||
| } | |||
| } | |||
| return rentList; | |||