diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WxPropertyContractController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WxPropertyContractController.java index a1dec55b3..5470e6d1f 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/WxPropertyContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/WxPropertyContractController.java @@ -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"); diff --git a/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java b/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java index f9e666102..f812decc2 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java @@ -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 buildBill(WxRentContract wxRentContract); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java index d639a45dd..2223d9e66 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java @@ -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 buildRent(WxMerchant wxMerchant, Long userId,WxRentContract rentContract); + List buildRent(WxMerchant wxMerchant, Long userId,WxRentContract rentContract,Integer isPreview); void buildDeposit(WxMerchant wxMerchant, Long userId); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java index a5094fdf0..f7f7e17fd 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java @@ -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); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java index fb339bd8c..919b433f6 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java @@ -125,7 +125,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService if(wxPropertyContract.getReceivePeriod() != null && wxPropertyContract.getLease()!=null) { wxBillPropertyMapper.deletePreviewBill(wxPropertyContract); //重新生成 - List billList = buildProperty(new WxMerchant(),wxPropertyContract); + List 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 buildProperty(WxMerchant wxMerchant,WxPropertyContract propertyContract) { + public List buildProperty(WxMerchant wxMerchant,WxPropertyContract propertyContract,Integer isPreview) { List 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 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 billList = buildProperty(new WxMerchant(),propertyContract); - resultMap.put("billList",billList); - } - resultMap.put("hasRent",false); - return new ResultData(resultMap); + return new ResultData(false); } public Map updateStatus(WxPropertyContract record) { @@ -734,5 +724,17 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService } } - + @Override + public List buildBill(WxRentContract wxRentContract) { + //生成预览账单 + //根据租赁合同找到对应的物业合同,生成物业账单 + WxPropertyContract propertyContract = wxPropertyContractMapper.findOneByRentId(wxRentContract); + if(propertyContract!=null && propertyContract.getReceivePeriod() != null && propertyContract.getLease()!=null) { + wxBillPropertyMapper.deletePreviewBill(propertyContract); + //重新生成 + List billList = buildProperty(new WxMerchant(),propertyContract,EnumIsPreview.YES.getCode()); + return billList; + } + return new ArrayList<>(); + } } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java index a0b3c8221..70ebcd6cb 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -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 resultList = buildRent(new WxMerchant(),null,wxRentContract); + List 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 resultList = buildRent(new WxMerchant(),null,record); + List 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 buildRent(WxMerchant wxMerchant, Long userId,WxRentContract rentContract) { + public List buildRent(WxMerchant wxMerchant, Long userId,WxRentContract rentContract,Integer isPreview) { List 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;