From dea3719f30249ee52646f8a0767731be3599fb36 Mon Sep 17 00:00:00 2001 From: xiaohanzi Date: Tue, 18 Aug 2020 13:33:53 +0800 Subject: [PATCH 1/3] fix contract --- .../contract/WxRentContractController.java | 230 ++++++++++-------- .../domain/po/WxPropertyContract.java | 7 +- .../mapper/WxPropertyContractMapper.java | 4 + .../iformall/mapper/WxRentContractMapper.java | 2 + .../service/WxRentContractService.java | 6 +- .../service/impl/WxFlowServiceImpl.java | 6 +- .../impl/WxPropertyContractServiceImpl.java | 40 +-- .../impl/WxRentContractServiceImpl.java | 129 +++++----- .../mapper/WxPropertyContractMapper.xml | 11 + .../resources/mapper/WxRentContractMapper.xml | 5 + 10 files changed, 253 insertions(+), 187 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java index 870d2cf69..b394a7e5a 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java @@ -188,22 +188,7 @@ public class WxRentContractController extends WxContractBaseController { return new ResultData(e.getErrorCode(), e.getMessage()); } } - - @GetMapping("/hasRentStatus") - @SystemControllerLog(description = "查询店铺租赁状态") - public ResultData hasRentStatus(@ModelAttribute WxRentContract wxRentContract) { - logger.debug("[" + getIpAddr() + "] WxRentContractController::hasRentStatus"); - wxRentContract.updateTenantInfo(getTenantInfo()); - return wxRentContractService.hasRentStatus(wxRentContract); - } - - @GetMapping("/hasContractNumber") - @SystemControllerLog(description = "租赁合同-检查合同编号是否存在") - public ResultData hasContractNumber(@ModelAttribute WxRentContract wxRentContract) { - logger.debug("[" + getIpAddr() + "] WxRentContractController::hasContractNumber"); - wxRentContract.updateTenantInfo(getTenantInfo()); - return wxRentContractService.hasContractNumber(wxRentContract); - } + @PostMapping("update") @SystemControllerLog(description = "租赁合同-更新") @@ -241,16 +226,12 @@ public class WxRentContractController extends WxContractBaseController { } } - @GetMapping("/endRentContract") - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true), - @ApiImplicitParam(name = "status", value = "status", dataType = "int", paramType = "query", required = true)}) - @SystemControllerLog(description = "租赁合同-终结合同") - public ResultData endRentContract(Long id,Integer status) { - logger.debug("[" + getIpAddr() + "] WxRentContractController::endRentContract"); - return wxRentContractService.endRentContract(id,status); - } - + /** + * 查询商户可用商铺 + * @param merchantId + * @param contractId + * @return + */ @GetMapping("/merchantShops") @ApiImplicitParams({ @ApiImplicitParam(name = "merchantId", value = "merchantId", dataType = "Long", paramType = "query", required = true), @@ -311,25 +292,7 @@ public class WxRentContractController extends WxContractBaseController { } return new ResultData(shops); - } - - @GetMapping("getRentContractList") - @ApiImplicitParams({ - @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), - @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) - @SystemControllerLog(description = "租赁合同-列表") - public ResultData getRentContractList(@ModelAttribute WxRentContract wxRentContract, Integer validStatus, Integer pageNum, Integer pageSize) { - logger.debug("[" + getIpAddr() + "] WxRentContractController::getRentContractList"); - if (null == wxRentContract) wxRentContract = new WxRentContract(); - wxRentContract.updateTenantInfo(getTenantInfo()); - if (1 == validStatus) { - List statuss = new ArrayList(); - statuss.add(EnumRentContractStatus.PAING.getCode()); - statuss.add(EnumRentContractStatus.READY_FOR_PAING.getCode()); - wxRentContract.setStatuss(statuss); - } - return new ResultData(wxRentContractService.getRentContractList(wxRentContract, pageNum, pageSize)); - } + } /** * 一个商户只能存在一个续签合同。如果有计租中的,则取计租中最新的一条,如果没有计租中的,则取正常到期最近的一条 @@ -364,9 +327,129 @@ public class WxRentContractController extends WxContractBaseController { } } return new ResultData(); + } + + /** + * 作废 + * @param wxRentContract + * @return + */ + @GetMapping("/unvalid") + @SystemControllerLog(description = "作废合同") + public ResultData unvalid(@ModelAttribute WxRentContract wxRentContract) { + //wxRentContract.updateTenantInfo(getTenantInfo()); + WxRentContract contract = wxRentContractService.getSimpleDeatil(wxRentContract.getId()); + if (null == contract) { + return new ResultData(Result.ERROR, "合同不存在."); + } + if (contract.getStatus().intValue() == EnumRentContractStatus.DRAFT.getCode().intValue() || + (contract.getStatus().intValue() == EnumRentContractStatus.PERFORMANCE.getCode().intValue() + && contract.getApplyStatus().intValue() == EnumRentContractAppStatus.REJECT.getCode().intValue())) { + contract.setStatus(EnumRentContractStatus.INVALID.getCode()); + contract.setUpdatetime(new Date()); + return wxRentContractService.updateRentContract(contract); + }else { + return new ResultData(Result.ERROR, "合同状态不允许作废.只能作废草稿或者履约拒绝的合同。"); + } + } + + /** + * 终止 + * @param id + * @param status + * @return + */ + @PostMapping("endContract") + @SystemControllerLog(description = "租赁合同-终止合同") + public ResultData endContract(@RequestBody WxRentContract wxRentContract) { + logger.debug("[" + getIpAddr() + "] WxRentContractController::endContract"); + wxRentContract.updateTenantInfo(getTenantInfo()); + wxRentContractService.endContract(wxRentContract); + return new ResultData(); } + @RequestMapping("/download") + public void download(HttpServletRequest request, HttpServletResponse response){ + logger.debug("[" + getIpAddr() + "] WxRentContractController::download"); + wxRentContractService.download(request,response); + } + + @GetMapping("getDateDiff") + @ApiImplicitParams({ + @ApiImplicitParam(name = "startDate", value = "开始时间", dataType = "string", paramType = "query", required = true), + @ApiImplicitParam(name = "endtDate", value = "结束时间", dataType = "string", paramType = "query", required = true)}) + @SystemControllerLog(description = "获取两个时间相差,返回n月零n天") + public ResultData getDateDiff(String startDate, String endDate) throws Exception{ + SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); + Map map = new HashMap<>(); + int[] array = DateUtils.getDiff(sd.parse(startDate),sd.parse(endDate)); + map.put("month",array[0]); + map.put("day",array[1]); + return new ResultData(map); + } + + @GetMapping("exportContract") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)}) + @SystemControllerLog(description = "租赁合同-导出合同") + public void exportContract(Long id,HttpServletRequest request, HttpServletResponse response){ + wxRentContractService.exportContract(request,response,id); + } + + @GetMapping("getRentContractList") + @ApiImplicitParams({ + @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), + @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) + @SystemControllerLog(description = "租赁合同-列表") + public ResultData getRentContractList(@ModelAttribute WxRentContract wxRentContract, Integer validStatus, Integer pageNum, Integer pageSize) { + logger.debug("[" + getIpAddr() + "] WxRentContractController::getRentContractList"); + if (null == wxRentContract) wxRentContract = new WxRentContract(); + wxRentContract.updateTenantInfo(getTenantInfo()); + if (1 == validStatus) { + List statuss = new ArrayList(); + statuss.add(EnumRentContractStatus.PAING.getCode()); + statuss.add(EnumRentContractStatus.READY_FOR_PAING.getCode()); + wxRentContract.setStatuss(statuss); + } + return new ResultData(wxRentContractService.getRentContractList(wxRentContract, pageNum, pageSize)); + } + + + + + + + + + + + +// @GetMapping("/del") +// @ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true) +// @SystemControllerLog(description = "租赁合同-删除") +// public ResultData delete(String id) { +// logger.debug("[" + getIpAddr() + "] WxRentContractController::delete"); +// return wxRentContractService.deleteById(id); +// } + + + @GetMapping("/hasRentStatus") + @SystemControllerLog(description = "查询店铺租赁状态") + public ResultData hasRentStatus(@ModelAttribute WxRentContract wxRentContract) { + logger.debug("[" + getIpAddr() + "] WxRentContractController::hasRentStatus"); + wxRentContract.updateTenantInfo(getTenantInfo()); + return wxRentContractService.hasRentStatus(wxRentContract); + } + + @GetMapping("/hasContractNumber") + @SystemControllerLog(description = "租赁合同-检查合同编号是否存在") + public ResultData hasContractNumber(@ModelAttribute WxRentContract wxRentContract) { + logger.debug("[" + getIpAddr() + "] WxRentContractController::hasContractNumber"); + wxRentContract.updateTenantInfo(getTenantInfo()); + return wxRentContractService.hasContractNumber(wxRentContract); + } + @GetMapping("getMerchantList") @SystemControllerLog(description = "获取商户列表") @ApiImplicitParams({ @@ -396,20 +479,6 @@ public class WxRentContractController extends WxContractBaseController { return new ResultData(); } - @GetMapping("getDateDiff") - @ApiImplicitParams({ - @ApiImplicitParam(name = "startDate", value = "开始时间", dataType = "string", paramType = "query", required = true), - @ApiImplicitParam(name = "endtDate", value = "结束时间", dataType = "string", paramType = "query", required = true)}) - @SystemControllerLog(description = "获取两个时间相差,返回n月零n天") - public ResultData getDateDiff(String startDate, String endDate) throws Exception{ - SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); - Map map = new HashMap<>(); - int[] array = DateUtils.getDiff(sd.parse(startDate),sd.parse(endDate)); - map.put("month",array[0]); - map.put("day",array[1]); - return new ResultData(map); - } - /** * 预览账单展示,编辑账期,后端生成账单金额 * @param wxRentContract @@ -450,21 +519,7 @@ public class WxRentContractController extends WxContractBaseController { } - @GetMapping("/del") - @ApiImplicitParam(name = "id", value = "id", dataType = "String", paramType = "query", required = true) - @SystemControllerLog(description = "租赁合同-删除") - public ResultData delete(String id) { - logger.debug("[" + getIpAddr() + "] WxRentContractController::delete"); - return wxRentContractService.deleteById(id); - } - - - @RequestMapping("/download") - public void download(HttpServletRequest request, HttpServletResponse response){ - logger.debug("[" + getIpAddr() + "] WxRentContractController::download"); - wxRentContractService.download(request,response); - } // @GetMapping("/getRentContractStatusInfo") // @SystemControllerLog(description = "租赁合同-获取合同状态信息") @@ -476,21 +531,13 @@ public class WxRentContractController extends WxContractBaseController { - @PostMapping("updateMerchant") - @SystemControllerLog(description = "租赁合同-更新商户") - public ResultData updateMerchant(@RequestBody WxRentContract wxRentContract) { - logger.debug("[" + getIpAddr() + "] WxRentContractController::updateMerchant"); - return wxRentContractService.updateMerchant(wxRentContract); - } - +// @PostMapping("updateMerchant") +// @SystemControllerLog(description = "租赁合同-更新商户") +// public ResultData updateMerchant(@RequestBody WxRentContract wxRentContract) { +// logger.debug("[" + getIpAddr() + "] WxRentContractController::updateMerchant"); +// return wxRentContractService.updateMerchant(wxRentContract); +// } - @GetMapping("exportContract") - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)}) - @SystemControllerLog(description = "租赁合同-导出合同") - public void exportContract(Long id,HttpServletRequest request, HttpServletResponse response){ - wxRentContractService.exportContract(request,response,id); - } @PostMapping("updateRentContractStatus") @SystemControllerLog(description = "租赁合同-更新合同状态") @@ -547,15 +594,6 @@ public class WxRentContractController extends WxContractBaseController { } - @PostMapping("endContract") - @SystemControllerLog(description = "租赁合同-终止合同") - public ResultData endContract(@RequestBody WxRentContract wxRentContract) { - logger.debug("[" + getIpAddr() + "] WxRentContractController::endContract"); - wxRentContract.updateTenantInfo(getTenantInfo()); - wxRentContractService.endContract(wxRentContract); - return new ResultData(); - } - @GetMapping("/getContractByContractNumber") @SystemControllerLog(description = "租赁合同-通过合同编号查询信息") public ResultData getContractByContractNumber(@ModelAttribute WxRentContract wxRentContract) { diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java b/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java index cfaf9b636..c90a3968e 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java @@ -62,7 +62,9 @@ public class WxPropertyContract extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value="合同进度状态1待签约2已签约未记租3计租中4提前终止5合同到期",name="status") private Integer status; - + @TableField(exist = false) + private List statuss; + @io.swagger.annotations.ApiModelProperty(value="合同编号",name="contractNumber") private String contractNumber; @@ -87,9 +89,6 @@ public class WxPropertyContract extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value="店铺类型:1直营店2加盟店3个体店4旗舰店",name="shopType") private Integer shopType; - @io.swagger.annotations.ApiModelProperty(value="商铺ID",name="shopId") - private Long shopId; - @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updatetime") private Date updatetime; diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxPropertyContractMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxPropertyContractMapper.java index 7071ad175..c971b56b4 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxPropertyContractMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxPropertyContractMapper.java @@ -9,6 +9,8 @@ import com.iformall.domain.po.WxRentContract; import java.util.List; import java.util.Map; +import org.apache.ibatis.annotations.Param; + /** * @author gongbiao */ @@ -53,4 +55,6 @@ public interface WxPropertyContractMapper extends CommonMapper List getAllContractBymerchantId(WxRentContract wxRentContract); List getContractByMerchant(WxRentContract wxRentContract); + + Integer getCanApplyCount(@Param("id") Long id); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java index c88adbec0..3410ac32e 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java @@ -60,9 +60,7 @@ public interface WxRentContractService { //Object getRentContractStatusInfo(WxRentContract record); - ResultData endRentContract(Long id, Integer status); - - ResultData updateMerchant(WxRentContract wxRentContract); + ResultData updateRentContract(WxRentContract wxRentContract); PageInfo getRentContractList(WxRentContract rentContract, Integer pageNum, Integer pageSize); @@ -90,7 +88,7 @@ public interface WxRentContractService { //Integer getShopType(WxRentContract wxRentContract); - void endContract(WxRentContract wxRentContract); + ResultData endContract(WxRentContract wxRentContract); void updatePropertyPreviewBill(WxRentContract record); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java index 587855a21..697c2e876 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java @@ -186,6 +186,7 @@ public class WxFlowServiceImpl implements WxFlowService { rent.setBusinessType(flowType); WxRentContract record = wxRentContractMapper.selectById(businessId); + //合并的合同-审批时 物业合同的状态肯定不在 签约中 避免更新物业合同时提示店铺存在 if(record.getOperationType().equals(EnumContractOperationType.WHOLE.getCode())){ WxPropertyContract wxPropertyContract = new WxPropertyContract(); @@ -199,7 +200,10 @@ public class WxFlowServiceImpl implements WxFlowService { //如果是提交审批 , 审批驳回状态不变 if (EnumRentContractAppStatus.APPLYING.getCode().intValue() == applyStatus.intValue()) { - rent.setStatus(EnumRentContractStatus.PERFORMANCE.getCode()); + //如果合同的状态非正常,则不处理 + if (EnumRentContractStatus.DRAFT.getCode().intValue() == record.getStatus().intValue()) { + rent.setStatus(EnumRentContractStatus.PERFORMANCE.getCode()); + } //如果审批完成 }else if (EnumRentContractAppStatus.FINISH.getCode().intValue() == applyStatus.intValue()) { wxRentContractService.updateRentContractStatus(businessId); 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 ccd538a7a..0af3d1120 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java @@ -160,15 +160,6 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService } else { result.put("wxMerchant", null); } - //关联的店铺 - if (wxPropertyContract.getShopId() != null) { - WxShop record = new WxShop(); - record.setId(wxPropertyContract.getShopId()); - List> list = wxShopMapper.findListMap(record); - result.put("wxShops", list); - } else { - result.put("wxShops", Collections.EMPTY_LIST); - } //租赁费用欠缴 WxRentContract wxRentContract = new WxRentContract(); @@ -187,6 +178,19 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService if (!select.isEmpty()) { result.put("depositStatus", select.get(0).getStatus()); } + + //关联的店铺 + if (wxRentContract != null) { + WxShop record = new WxShop(); + if (null != wxRentContract.shopIdsByRentInfo() && wxRentContract.shopIdsByRentInfo().size()>0) { + record.setIds(wxRentContract.shopIdsByRentInfo()); + List> list = wxShopMapper.findListMap(record); + result.put("wxShops", list); + }else { + result.put("wxShops", Collections.EMPTY_LIST); + } + } + //发起人备注 WxFlowRecord wxFlowRecord = new WxFlowRecord(); wxFlowRecord.setBusinessId(id); @@ -239,7 +243,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService bill.setLatePayRatio(0); bill.setPay(0L); bill.setIsDel(EnumDelStatus.NOT_DEL.getCode()); - bill.setShopId(record.getShopId()); + //bill.setShopId(record.getShopId()); bill.setExpiredDay(0L); setExpiredDay(bill,Calendar.MONTH,record.getReceivePeriod()); if (bill.getReceivePay().equals(0L)) { @@ -264,9 +268,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService haspreview = true; } - if (record.getRentShopType().equals(EnumRentShopType.POINT.getCode()) && null == record.getShopId()) { - return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "shopId不能为空"); - } +// if (record.getRentShopType().equals(EnumRentShopType.POINT.getCode()) && null == record.getShopId()) { +// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "shopId不能为空"); +// } WxRentContract wxRentContract = wxRentContractMapper.selectById(record.getRentContractId()); if (wxRentContract != null) { @@ -489,7 +493,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService wxBillDeposit.updateTenantInfo(wxPropertyContract); wxBillDeposit.setIsDel(0); wxBillDeposit.setMerchantId(record.getMerchantId()); - wxBillDeposit.setShopId(wxPropertyContract.getShopId()); + //wxBillDeposit.setShopId(wxPropertyContract.getShopId()); wxBillDeposit.setCreatetime(date); wxBillDeposit.setUpdatetime(date); wxBillDeposit.setIsDel(EnumDelStatus.NOT_DEL.getCode()); @@ -688,7 +692,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService wxBillProperty.setIsDel(0); wxBillProperty.setMerchantId(wxPropertyContract.getMerchantId()); wxBillProperty.setUserId(userId); - wxBillProperty.setShopId(wxPropertyContract.getShopId()); + //wxBillProperty.setShopId(wxPropertyContract.getShopId()); wxBillProperty.setCreatetime(date); wxBillProperty.setUpdatetime(date); wxBillProperty.setIsDel(EnumDelStatus.NOT_DEL.getCode()); @@ -976,9 +980,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { wxPropertyContract.setMerchantId(wxRentContract.getMerchantId()); } - if (wxRentContract.shopIdsByRentInfo().size()==0) { - wxPropertyContract.setShopId(wxRentContract.shopIdsByRentInfo().get(0)); - } +// if (wxRentContract.shopIdsByRentInfo().size()==0) { +// wxPropertyContract.setShopId(wxRentContract.shopIdsByRentInfo().get(0)); +// } List select = wxPropertyContractMapper.selectList(new QueryWrapper(wxPropertyContract)); 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 dc45663ce..d8e886a5d 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -1474,52 +1474,66 @@ public class WxRentContractServiceImpl implements WxRentContractService { @Transactional(rollbackFor = {Exception.class}) @Override - public ResultData endRentContract(Long id, Integer status) { - - WxRentContract wxRentContract = wxRentContractMapper.selectById(id); - if (wxRentContract == null) { + public ResultData endContract(WxRentContract wxRentContract) { + + WxRentContract contract = wxRentContractMapper.selectById(wxRentContract.getId()); + if (contract == null) { return new ResultData(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND); } - wxRentContract.setStatus(EnumRentContractStatus.TERMINATE.getCode()); - try { - wxRentContract.setUpdatetime(new Date()); - wxRentContractMapper.updateById(wxRentContract); - //不停用商户 - //wxMerchantService.disable(wxRentContract.getMerchantId()); - //物业合同终止 - if (status == 1) { - WxPropertyContract wxPropertyContract = new WxPropertyContract(); - wxRentContract.updateTenantInfo(wxRentContract); - wxPropertyContract.setRentContractId(id); - List> contractData = wxPropertyContractMapper.queryPropertyContractData(wxPropertyContract); - if (contractData.size() > 0) { - Map propertyContract = contractData.get(0); - Long propertyContractId = (Long) propertyContract.get("id"); - if (propertyContract != null && propertyContractId != null) { - WxPropertyContract propertyContractUpdate = wxPropertyContractMapper.selectById(propertyContractId); - propertyContractUpdate.setStatus(EnumRentContractStatus.TERMINATE.getCode()); - propertyContractUpdate.setUpdatetime(new Date()); - wxPropertyContractMapper.updateById(propertyContractUpdate); - } - } - } - } catch (MallinkException e) { - logger.info("终止合同失败:" + e.getMessage()); - throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); + contract.setStatus(EnumRentContractStatus.TERMINATE.getCode()); + contract.setUpdatetime(new Date()); + wxRentContractMapper.updateById(contract); + + //终止租赁合同,同时终止物业合同 + if(EnumEndProperty.END_RENT_AND_PROPERTY.getCode().equals(wxRentContract.getEndProperty())){ +// WxPropertyContract wxPropertyContract = new WxPropertyContract(); +// wxPropertyContract.setRentContractId(wxRentContract.getId()); +// wxPropertyContract.setStatus(EnumRentContractStatus.TERMINATE.getCode()); +// wxPropertyContractMapper.updateStatusByRentContractId(wxPropertyContract); + WxPropertyContract wxPropertyContract = new WxPropertyContract(); + wxRentContract.updateTenantInfo(wxRentContract); + wxPropertyContract.setRentContractId(wxRentContract.getId()); + //终止有效的合同 + List validstatuss = new ArrayList(); + validstatuss.add(EnumRentContractStatus.PAING.getCode()); + validstatuss.add(EnumRentContractStatus.READY_FOR_PAING.getCode()); + wxPropertyContract.setStatuss(validstatuss); + wxPropertyContract.setUpdatetime(new Date()); + wxPropertyContract.setStatus(EnumRentContractStatus.TERMINATE.getCode()); + wxPropertyContractMapper.endContract(wxRentContract); + //作废未生效的合同 + List unvalidstatuss = new ArrayList(); + unvalidstatuss.add(EnumRentContractStatus.DRAFT.getCode()); + unvalidstatuss.add(EnumRentContractStatus.PERFORMANCE.getCode()); + wxPropertyContract.setStatuss(unvalidstatuss); + wxPropertyContract.setStatus(EnumRentContractStatus.INVALID.getCode()); + wxPropertyContractMapper.endContract(wxRentContract); + + //物业账单失效 + wxBillPropertyMapper.updateInvalidStatusByRent(wxRentContract); } - return new ResultData(Result.SUCCESS, "操作成功"); + //租赁账单失效 + WxBillRent wxBillRent = new WxBillRent(); + wxBillRent.setRentContractId(wxRentContract.getId()); + wxBillRentMapper.updateInvalidStatus(wxBillRent); + return new ResultData(Result.SUCCESS,"终止成功"); + //解绑商户和商铺关系 +// WxRentContract rentContract = wxRentContractMapper.selectById(wxRentContract.getId()); +// if(rentContract != null && rentContract.getMerchantId() != null){ +// wxMerchantService.disable(rentContract.getMerchantId()); +// } } @Transactional(rollbackFor = {Exception.class}) @Override - public ResultData updateMerchant(WxRentContract wxRentContract) { - WxRentContract record = wxRentContractMapper.selectById(wxRentContract); - if (wxRentContract == null) { - return new ResultData(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND); - } - record.setMerchantId(wxRentContract.getMerchantId()); + public ResultData updateRentContract(WxRentContract wxRentContract) { +// WxRentContract record = wxRentContractMapper.selectById(wxRentContract); +// if (wxRentContract == null) { +// return new ResultData(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND); +// } +// record.setMerchantId(wxRentContract.getMerchantId()); try { - wxRentContractMapper.updateById(record); + wxRentContractMapper.updateById(wxRentContract); } catch (MallinkException e) { logger.info("关联合同商户失败:" + e.getMessage()); throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); @@ -1625,6 +1639,13 @@ public class WxRentContractServiceImpl implements WxRentContractService { if (record == null) { return new ResultData(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND); } + //如果合同状态为非正常状态,则不更新合同状态,并删除账单 + if(record.getStatus().intValue() == EnumRentContractStatus.INVALID.getCode().intValue() + || record.getStatus().intValue() == EnumRentContractStatus.TERMINATE.getCode().intValue()) { + return new ResultData(ErrorCode.RENT_CONTRACT_IS_TERMINATED.getCode(),"合同状态已作废或者已终止."); + } + + //更新合同状态为签约 WxRentContract wxRentContract = new WxRentContract(); wxRentContract.setId(id); @@ -2380,32 +2401,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { return list; } - @Override - public void endContract(WxRentContract wxRentContract) { - wxRentContract.setStatus(EnumRentContractStatus.TERMINATE.getCode()); - wxRentContractMapper.updateStatus(wxRentContract); - - //终止租赁合同,同时终止物业合同 - if(EnumEndProperty.END_RENT_AND_PROPERTY.getCode().equals(wxRentContract.getEndProperty())){ - WxPropertyContract wxPropertyContract = new WxPropertyContract(); - wxPropertyContract.setRentContractId(wxRentContract.getId()); - wxPropertyContract.setStatus(EnumRentContractStatus.TERMINATE.getCode()); - wxPropertyContractMapper.updateStatusByRentContractId(wxPropertyContract); - - //物业账单失效 - wxBillPropertyMapper.updateInvalidStatusByRent(wxRentContract); - } - //租赁账单失效 - WxBillRent wxBillRent = new WxBillRent(); - wxBillRent.setRentContractId(wxRentContract.getId()); - wxBillRentMapper.updateInvalidStatus(wxBillRent); - - //解绑商户和商铺关系 - WxRentContract rentContract = wxRentContractMapper.selectById(wxRentContract.getId()); - if(rentContract != null && rentContract.getMerchantId() != null){ - wxMerchantService.disable(rentContract.getMerchantId()); - } - } @Override public WxRentContract getByBill(WxBillRent billRent) { @@ -2457,6 +2452,12 @@ public class WxRentContractServiceImpl implements WxRentContractService { @Override public ResultData apply(WxRentContract wxRentContract,MallUserInfo user) { + //如果存在其他的草稿状态或者履约驳回状态的合同,不允许提交审批 + Integer count = wxRentContractMapper.getCanApplyCount(wxRentContract.getId()); + if (null != count && count.intValue()>0) { + return new ResultData(Result.ERROR, "当前存在其他草稿状态或者履约驳回的合同。清作废再提交审批。"); + } + WxRentContract rentContract = wxRentContractMapper.selectById(wxRentContract.getId()); if (null == rentContract) { return new ResultData(Result.ERROR, "编号["+wxRentContract.getId()+"]未找到租金合同"); diff --git a/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml b/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml index 836ce21ef..86779455a 100644 --- a/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml @@ -386,4 +386,15 @@ select property_contract_id from wx_bill_property id = #{id} ) + + + update wx_property_contract set status=#{status},updatetime = #{updatetime} where rent_contract_id =#{rentContractId} + + and status in + + #{statusItem} + + + + diff --git a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml index c35fbaed7..5486128e2 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml @@ -671,5 +671,10 @@ + + + From 5a3d36e17a9c3f781a7998f947ad88f3be5b4af3 Mon Sep 17 00:00:00 2001 From: xiaohanzi Date: Tue, 18 Aug 2020 14:00:27 +0800 Subject: [PATCH 2/3] fix contract --- .../WxPropertyContractController.java | 28 +- .../contract/WxRentContractController.java | 16 +- .../java/com/iformall/domain/po/WxShop.java | 11 + .../mapper/WxPropertyContractMapper.java | 8 +- .../service/WxPropertyContractService.java | 6 +- .../service/WxRentContractService.java | 2 +- .../impl/WxPropertyContractServiceImpl.java | 205 +++--- .../impl/WxRentContractServiceImpl.java | 606 +++++++++--------- .../mapper/WxPropertyContractMapper.xml | 20 +- 9 files changed, 456 insertions(+), 446 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java index 63ea0d89a..e3648ed9d 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java @@ -136,13 +136,13 @@ public class WxPropertyContractController extends WxContractBaseController { wxPropertyContractService.download(request, response); } - @GetMapping("/getPropertyContractStatusInfo") - @SystemControllerLog(description = "物业合同-状态信息") - public ResultData getPropertyContractStatusInfo(@ModelAttribute WxPropertyContract wxPropertyContract) { - logger.debug("[" + getIpAddr() + "] WxPropertyContractController::getPropertyContractStatusInfo"); - wxPropertyContract.updateTenantInfo(getTenantInfo()); - return new ResultData(Result.SUCCESS, "查询成功", wxPropertyContractService.getRentContractStatusInfo(wxPropertyContract)); - } +// @GetMapping("/getPropertyContractStatusInfo") +// @SystemControllerLog(description = "物业合同-状态信息") +// public ResultData getPropertyContractStatusInfo(@ModelAttribute WxPropertyContract wxPropertyContract) { +// logger.debug("[" + getIpAddr() + "] WxPropertyContractController::getPropertyContractStatusInfo"); +// wxPropertyContract.updateTenantInfo(getTenantInfo()); +// return new ResultData(Result.SUCCESS, "查询成功", wxPropertyContractService.getRentContractStatusInfo(wxPropertyContract)); +// } @GetMapping("/endPropertyContract") @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) @@ -152,13 +152,13 @@ public class WxPropertyContractController extends WxContractBaseController { return wxPropertyContractService.endRentContract(id); } - @GetMapping("/getRentContractList") - @SystemControllerLog(description = "物业合同-查询列表") - public ResultData getRentContractList(@ModelAttribute WxPropertyContract wxPropertyContract) { - logger.debug("[" + getIpAddr() + "] WxPropertyContractController::getRentContractList"); - wxPropertyContract.updateTenantInfo(getTenantInfo()); - return new ResultData(Result.SUCCESS, "查询成功", wxPropertyContractService.getRentContractList(wxPropertyContract)); - } +// @GetMapping("/getRentContractList") +// @SystemControllerLog(description = "物业合同-查询列表") +// public ResultData getRentContractList(@ModelAttribute WxPropertyContract wxPropertyContract) { +// logger.debug("[" + getIpAddr() + "] WxPropertyContractController::getRentContractList"); +// wxPropertyContract.updateTenantInfo(getTenantInfo()); +// return new ResultData(Result.SUCCESS, "查询成功", wxPropertyContractService.getRentContractList(wxPropertyContract)); +// } @GetMapping("/endPropertyContractByRentContractId") @ApiImplicitParam(name = "rentContractId", value = "rentContractId", dataType = "Long", paramType = "query", required = true) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java index b394a7e5a..af48b8d52 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java @@ -389,13 +389,7 @@ public class WxRentContractController extends WxContractBaseController { return new ResultData(map); } - @GetMapping("exportContract") - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)}) - @SystemControllerLog(description = "租赁合同-导出合同") - public void exportContract(Long id,HttpServletRequest request, HttpServletResponse response){ - wxRentContractService.exportContract(request,response,id); - } + @GetMapping("getRentContractList") @ApiImplicitParams({ @@ -518,7 +512,13 @@ public class WxRentContractController extends WxContractBaseController { return wxRentContractService.update(rentContract, user.getId(),user.getName(), EnumFromType.SWITCH.getCode(),oldDate); } - +// @GetMapping("exportContract") +// @ApiImplicitParams({ +// @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)}) +// @SystemControllerLog(description = "租赁合同-导出合同") +// public void exportContract(Long id,HttpServletRequest request, HttpServletResponse response){ +// wxRentContractService.exportContract(request,response,id); +// } // @GetMapping("/getRentContractStatusInfo") diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxShop.java b/mallinkService/src/main/java/com/iformall/domain/po/WxShop.java index 9a895495e..7cf17a279 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxShop.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxShop.java @@ -131,6 +131,17 @@ public class WxShop extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value = "租金单位", name = "rentUnit") private Integer rentUnit; + + @TableField(exist = false) + private Integer rent_unit; + + public Integer getRent_unit() { + return rentUnit; + } + + public void setRent_unit() { + this.rent_unit = rentUnit; + } } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxPropertyContractMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxPropertyContractMapper.java index c971b56b4..8f1d06b2d 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxPropertyContractMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxPropertyContractMapper.java @@ -18,7 +18,7 @@ public interface WxPropertyContractMapper extends CommonMapper findList(WxPropertyContract wxPropertyContract); - List> queryPropertyContractData(WxPropertyContract wxRentContract); + //List> queryPropertyContractData(WxPropertyContract wxRentContract); int queryRentContractWaitSignStatus(WxPropertyContract wxRentContract); @@ -36,11 +36,11 @@ public interface WxPropertyContractMapper extends CommonMapper getRentContractListByShop(Map params); + //List getRentContractListByShop(Map params); - List getRentContractListByPoint(Map params); + //List getRentContractListByPoint(Map params); void updateApplyStatus(WxPropertyContract wxPropertyContract); diff --git a/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java b/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java index 028eee46c..066b94346 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java @@ -52,11 +52,11 @@ public interface WxPropertyContractService { void download(HttpServletRequest request, HttpServletResponse response); - Object getRentContractStatusInfo(WxPropertyContract record); + //Object getRentContractStatusInfo(WxPropertyContract record); ResultData endRentContract(Long id); - Object getRentContractList(WxPropertyContract record); + //Object getRentContractList(WxPropertyContract record); ResultData endPropertyContractByRentContractId(Long rentContractId); @@ -71,7 +71,7 @@ public interface WxPropertyContractService { List getWxBillPropertyPreview(Long id); - Map updateStatus(WxPropertyContract record); + //Map updateStatus(WxPropertyContract record); List buildProperty(WxMerchant wxMerchant, Long userId, WxPropertyContract propertyContract, Integer isPreview,boolean saveDb); diff --git a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java index 3410ac32e..9b15bf8b9 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java @@ -64,7 +64,7 @@ public interface WxRentContractService { PageInfo getRentContractList(WxRentContract rentContract, Integer pageNum, Integer pageSize); - void exportContract(HttpServletRequest request, HttpServletResponse response, Long id); + //void exportContract(HttpServletRequest request, HttpServletResponse response, Long id); ResultData updateFile(WxRentContract wxRentContract, Long userId,String userName,Date oldRentStartDate); 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 0af3d1120..3615ffaea 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java @@ -79,14 +79,14 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService @Override public Map listAsPage(WxPropertyContract record, Integer pageIndex, Integer pageSize) { //Object rentContractStatusInfo = getRentContractStatusInfo(record); - PageHelper.startPage(pageIndex, pageSize); - List> rentContractData = wxPropertyContractMapper.queryPropertyContractData(record); - PageInfo> pageInfo = new PageInfo<>(rentContractData); - Map result = new HashMap<>(); - //result.put("rentContractStatusInfo", rentContractStatusInfo); - result.put("pageInfo", pageInfo); - return result; - +// PageHelper.startPage(pageIndex, pageSize); +// List> rentContractData = wxPropertyContractMapper.queryPropertyContractData(record); +// PageInfo> pageInfo = new PageInfo<>(rentContractData); +// Map result = new HashMap<>(); +// //result.put("rentContractStatusInfo", rentContractStatusInfo); +// result.put("pageInfo", pageInfo); +// return result; + return null; } @Override @@ -886,32 +886,32 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService } } - @Override - @Transactional(rollbackFor = {Exception.class}) - public Object getRentContractStatusInfo(WxPropertyContract record) { - - Map resultData = new HashMap(); - //商铺信息 - WxShop wxShop = new WxShop(); - wxShop.updateTenantInfo(record); - wxShop.setType(record.getRentShopType()); - wxShop.setStatus(EnumShopStatus.RENT.getCode()); - List rentedList = wxShopMapper.findList(wxShop); - wxShop.setStatus(EnumShopStatus.NOT_RENT.getCode()); - List unrentedList = wxShopMapper.findList(wxShop); - - HashMap shopMap = new HashMap<>(3); - int rentedCount = rentedList.size(); - int unrentedCount = unrentedList.size(); - shopMap.put("rentedCount",rentedCount); - shopMap.put("unrentedCount",unrentedCount); - shopMap.put("allCount",rentedCount+unrentedCount); - resultData.put("shopCountInfo", shopMap); - - //需要更新的状态 - resultData.putAll(updateStatus(record)); - return resultData; - } +// @Override +// @Transactional(rollbackFor = {Exception.class}) +// public Object getRentContractStatusInfo(WxPropertyContract record) { +// +// Map resultData = new HashMap(); +// //商铺信息 +// WxShop wxShop = new WxShop(); +// wxShop.updateTenantInfo(record); +// wxShop.setType(record.getRentShopType()); +// wxShop.setStatus(EnumShopStatus.RENT.getCode()); +// List rentedList = wxShopMapper.findList(wxShop); +// wxShop.setStatus(EnumShopStatus.NOT_RENT.getCode()); +// List unrentedList = wxShopMapper.findList(wxShop); +// +// HashMap shopMap = new HashMap<>(3); +// int rentedCount = rentedList.size(); +// int unrentedCount = unrentedList.size(); +// shopMap.put("rentedCount",rentedCount); +// shopMap.put("unrentedCount",unrentedCount); +// shopMap.put("allCount",rentedCount+unrentedCount); +// resultData.put("shopCountInfo", shopMap); +// +// //需要更新的状态 +// resultData.putAll(updateStatus(record)); +// return resultData; +// } @Transactional(rollbackFor = {Exception.class}) @Override @@ -933,37 +933,38 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService } - @Override - public Object getRentContractList(WxPropertyContract record) { - Map params = new HashMap<>(); - params.put("tenantId", record.getTenantId()); - params.put("rentShopType", record.getRentShopType()); - List contractList; - if (record.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { - contractList = wxPropertyContractMapper.getRentContractListByShop(params); - } else { - contractList = wxPropertyContractMapper.getRentContractListByPoint(params); - } - return contractList; - } +// @Override +// public Object getRentContractList(WxPropertyContract record) { +// Map params = new HashMap<>(); +// params.put("tenantId", record.getTenantId()); +// params.put("rentShopType", record.getRentShopType()); +// List contractList; +// if (record.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { +// contractList = wxPropertyContractMapper.getRentContractListByShop(params); +// } else { +// contractList = wxPropertyContractMapper.getRentContractListByPoint(params); +// } +// return contractList; +// } @Override public ResultData endPropertyContractByRentContractId(Long rentContractId) { - WxPropertyContract wxPropertyContractParam = new WxPropertyContract(); - wxPropertyContractParam.setRentContractId(rentContractId); - List> contractData = wxPropertyContractMapper.queryPropertyContractData(wxPropertyContractParam); - if (contractData.size() == 0) { - return new ResultData(ErrorCode.PROPERTY_CONTRACT_IS_NOT_FOUND); - } - Map contractMap = contractData.get(0); - WxPropertyContract wxPropertyContract = wxPropertyContractMapper.selectById((Long) contractMap.get("id")); - wxPropertyContract.setStatus(EnumRentContractStatus.TERMINATE.getCode()); - try { - wxPropertyContractMapper.updateById(wxPropertyContract); - } catch (MallinkException e) { - logger.info("终止合同失败:" + e.getMessage()); - throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); - } +// WxPropertyContract wxPropertyContractParam = new WxPropertyContract(); +// wxPropertyContractParam.setRentContractId(rentContractId); +// wxPropertyContractMapper.findList(wxPropertyContractParam); +// //List> contractData = wxPropertyContractMapper.queryPropertyContractData(wxPropertyContractParam); +// if (contractData.size() == 0) { +// return new ResultData(ErrorCode.PROPERTY_CONTRACT_IS_NOT_FOUND); +// } +// Map contractMap = contractData.get(0); +// WxPropertyContract wxPropertyContract = wxPropertyContractMapper.selectById((Long) contractMap.get("id")); +// wxPropertyContract.setStatus(EnumRentContractStatus.TERMINATE.getCode()); +// try { +// wxPropertyContractMapper.updateById(wxPropertyContract); +// } catch (MallinkException e) { +// logger.info("终止合同失败:" + e.getMessage()); +// throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); +// } return new ResultData(Result.SUCCESS, "操作成功"); } @@ -1001,46 +1002,46 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService return new ResultData(false); } - @Override - public Map updateStatus(WxPropertyContract record) { - Map resultData = new HashMap(); - WxPropertyContract wxPropertyContract = new WxPropertyContract(); - wxPropertyContract.updateTenantInfo(record); - wxPropertyContract.setRentShopType(record.getRentShopType()); - - int allCount = wxPropertyContractMapper.selectCount(new QueryWrapper(wxPropertyContract)); - resultData.put("allCount", allCount); - - //作废合同 - wxPropertyContract.setStatus(EnumRentContractStatus.INVALID.getCode()); - wxPropertyContractMapper.updateRentInvalidStatus(wxPropertyContract); - - //待签约 - //wxPropertyContract.setStatus(EnumRentContractStatus.WAIT_SIGN.getCode()); - //wxPropertyContractMapper.updateRentWaitSignStatus(wxPropertyContract); - //int waitSignCount = wxPropertyContractMapper.queryRentContractWaitSignStatus(wxPropertyContract); - resultData.put("waitSignCount", 0); - - //计租中 - wxPropertyContract.setStatus(EnumRentContractStatus.PAING.getCode()); - wxPropertyContractMapper.updateRentContractPaidStatus(wxPropertyContract); - int rendPaidCount = wxPropertyContractMapper.queryRentContractPaidStatus(wxPropertyContract); - resultData.put("rendPaidCount", rendPaidCount); - - //将到期 - //wxPropertyContract.setStatus(EnumRentContractStatus.CONTRACT_END_SOON.getCode()); - //wxPropertyContractMapper.updateRentContractEndSoonStatus(wxPropertyContract); - //int endSoonCount = wxPropertyContractMapper.queryRentContractEndSoonStatus(wxPropertyContract); - resultData.put("endSoonCount", 0); - - //到期 - wxPropertyContract.setStatus(EnumRentContractStatus.OUT_DATE.getCode()); - int endCount = wxPropertyContractMapper.queryRentContractEndStatus(wxPropertyContract); - wxPropertyContractMapper.updateRentContractEndStatus(wxPropertyContract); - resultData.put("endCount", endCount); - - return resultData; - } +// @Override +// public Map updateStatus(WxPropertyContract record) { +// Map resultData = new HashMap(); +// WxPropertyContract wxPropertyContract = new WxPropertyContract(); +// wxPropertyContract.updateTenantInfo(record); +// wxPropertyContract.setRentShopType(record.getRentShopType()); +// +// int allCount = wxPropertyContractMapper.selectCount(new QueryWrapper(wxPropertyContract)); +// resultData.put("allCount", allCount); +// +// //作废合同 +// wxPropertyContract.setStatus(EnumRentContractStatus.INVALID.getCode()); +// wxPropertyContractMapper.updateRentInvalidStatus(wxPropertyContract); +// +// //待签约 +// //wxPropertyContract.setStatus(EnumRentContractStatus.WAIT_SIGN.getCode()); +// //wxPropertyContractMapper.updateRentWaitSignStatus(wxPropertyContract); +// //int waitSignCount = wxPropertyContractMapper.queryRentContractWaitSignStatus(wxPropertyContract); +// resultData.put("waitSignCount", 0); +// +// //计租中 +// wxPropertyContract.setStatus(EnumRentContractStatus.PAING.getCode()); +// wxPropertyContractMapper.updateRentContractPaidStatus(wxPropertyContract); +// int rendPaidCount = wxPropertyContractMapper.queryRentContractPaidStatus(wxPropertyContract); +// resultData.put("rendPaidCount", rendPaidCount); +// +// //将到期 +// //wxPropertyContract.setStatus(EnumRentContractStatus.CONTRACT_END_SOON.getCode()); +// //wxPropertyContractMapper.updateRentContractEndSoonStatus(wxPropertyContract); +// //int endSoonCount = wxPropertyContractMapper.queryRentContractEndSoonStatus(wxPropertyContract); +// resultData.put("endSoonCount", 0); +// +// //到期 +// wxPropertyContract.setStatus(EnumRentContractStatus.OUT_DATE.getCode()); +// int endCount = wxPropertyContractMapper.queryRentContractEndStatus(wxPropertyContract); +// wxPropertyContractMapper.updateRentContractEndStatus(wxPropertyContract); +// resultData.put("endCount", endCount); +// +// return resultData; +// } public static void downLoadFromUrl(String urlStr, String fileName, String savePath) throws IOException { URL url = new URL(urlStr); 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 d8e886a5d..b134f9470 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -1589,32 +1589,32 @@ public class WxRentContractServiceImpl implements WxRentContractService { // return resultData; // } - @Override - public void exportContract(HttpServletRequest request, HttpServletResponse response, Long id) { - String contracType = "0"; - String templatePath = null; - Map result = null; - if (EnumContractType.ALL.getCode().toString().equals(contracType)) { - logger.info("获取租赁及物业合同数据"); - result = getRentAndPropertyInfo(id); - result.put("contractType", EnumContractType.ALL.getMessage()); - if (EnumRentContractType.RENT_BY_AREA.getCode().equals(result.get("type"))) { - templatePath = "contract-word-template/contract_rent_property.docx"; - } else { - templatePath = "contract-word-template/contract_rent_property_by_ratio.docx"; - } - logger.info("租赁及物业合同数据结果:" + result); - } - - if (templatePath == null) { - logger.info("没有租赁及物业合同模板"); - return; - } - String filepath = fmUploadDir; - String filename = UUID.randomUUID() + ".docx"; - String exportFileName = result.get("merchantName").toString() + "合同.docx"; - WordUtil.exportWord(templatePath, filepath, filename, exportFileName, result, request, response,null); - } +// @Override +// public void exportContract(HttpServletRequest request, HttpServletResponse response, Long id) { +// String contracType = "0"; +// String templatePath = null; +// Map result = null; +// if (EnumContractType.ALL.getCode().toString().equals(contracType)) { +// logger.info("获取租赁及物业合同数据"); +// result = getRentAndPropertyInfo(id); +// result.put("contractType", EnumContractType.ALL.getMessage()); +// if (EnumRentContractType.RENT_BY_AREA.getCode().equals(result.get("type"))) { +// templatePath = "contract-word-template/contract_rent_property.docx"; +// } else { +// templatePath = "contract-word-template/contract_rent_property_by_ratio.docx"; +// } +// logger.info("租赁及物业合同数据结果:" + result); +// } +// +// if (templatePath == null) { +// logger.info("没有租赁及物业合同模板"); +// return; +// } +// String filepath = fmUploadDir; +// String filename = UUID.randomUUID() + ".docx"; +// String exportFileName = result.get("merchantName").toString() + "合同.docx"; +// WordUtil.exportWord(templatePath, filepath, filename, exportFileName, result, request, response,null); +// } @Override @Transactional(rollbackFor = {Exception.class}) @@ -1699,283 +1699,283 @@ public class WxRentContractServiceImpl implements WxRentContractService { } } - public Map getRentAndPropertyInfo(Long id) { - logger.info("获取租赁物业合同数据>>>>>>id:" + id); - Map result = new HashMap<>(); - WxRentContract wxRentContract = wxRentContractMapper.selectById(id); - if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { - JSONArray jsonArray = JSONArray.parseArray(wxRentContract.getRentInfo()); - StringBuffer shopNumberStr = new StringBuffer(); - StringBuffer floorNameStr = new StringBuffer(); - StringBuffer buildingNameStr = new StringBuffer(); - StringBuffer buildAreaStr = new StringBuffer(); - StringBuffer operationAreaStr = new StringBuffer(); - for (int i = 0, size = jsonArray.size(); i < size; i++) { - JSONObject jsonObject = jsonArray.getJSONObject(i); - shopNumberStr.append("[").append(jsonObject.getString("shopNumber")).append("]"); - floorNameStr.append("[").append(jsonObject.getString("floor")).append("]"); - buildingNameStr.append("[").append(jsonObject.getString("building")).append("]"); - buildAreaStr.append("[").append(jsonObject.getString("buildArea")).append("]"); - operationAreaStr.append("[").append(jsonObject.getString("operationArea")).append("]"); - } - result.put("shopNumber", shopNumberStr); - result.put("floorName", floorNameStr); - result.put("buildingName", buildingNameStr); - result.put("buildArea", buildAreaStr); - result.put("operationArea", operationAreaStr); - } else { - //record.setId(wxRentContract.getShopId()); - if (wxRentContract.shopIdsByRentInfo().size() == 0) { - result.put("shopNumber", " "); - result.put("floorName", " "); - result.put("buildingName", " "); - result.put("buildArea", " "); - result.put("operationArea", " "); - }else { - WxShop record = new WxShop(); - record.setIds(wxRentContract.shopIdsByRentInfo()); - List> wxShops = wxShopMapper.findListMap(record); - if (!wxShops.isEmpty()) { - //店铺信息 - Map wxShop = wxShops.get(0); - result.put("shopNumber", wxShop.get("shopNumber")); - result.put("floorName", wxShop.get("floor")); - result.put("buildingName", wxShop.get("building")); - result.put("buildArea", wxShop.get("buildArea")); - result.put("operationArea", wxShop.get("operationArea")); - } - } - } - //MALL信息 - WxMall wxMall = new WxMall(); - wxMall.setTenantInfo(wxRentContract); - wxMall = wxMallMapper.findList(wxMall).get(0); - result.put("mallName", wxMall.getName()); - result.put("province", wxMall.getProvince()); - result.put("city", wxMall.getCity()); - - //商户信息 - WxMerchant merchant = wxMerchantService.getById(wxRentContract.getMerchantId()); - //经营业态 - wxRentContract.getMerchantId(); - WxBusiness wxBusiness = wxBusinessMapper.selectById(merchant.getBusinessId()); - result.put("business", wxBusiness.getTitle()); - - if (merchant != null) { - result.put("merchantName", merchant.getName()); - //法人信息 - WxMerchantCorp wxMerchantCorp = merchant.getWxMerchantCorp(); - result.put("corpPapersNumber", StringUtils.isNotEmpty(wxMerchantCorp.getCorpPapersNumber()) ? wxMerchantCorp.getCorpPapersNumber() : " "); - result.put("corpPapersType", wxMerchantCorp.getCorpPapersType() != null ? EnumPapersType.getEnum(wxMerchantCorp.getCorpPapersType()).getMessage() : " "); - result.put("corpPapersPerson", StringUtils.isNotEmpty(wxMerchantCorp.getCorpPapersPerson()) ? wxMerchantCorp.getCorpPapersPerson() : " "); - //税务信息 - WxMerchantTax wxMerchantTax = merchant.getWxMerchantTax(); - result.put("taxPapersType", wxMerchantTax.getTaxPapersType() != null ? EnumTaxpayerType.getEnum(wxMerchantTax.getTaxPapersType()).getMessage() : " "); - result.put("bankName", StringUtils.isNotEmpty(wxMerchantTax.getBankName()) ? wxMerchantTax.getBankName() : " "); - result.put("bankAccount", StringUtils.isNotEmpty(wxMerchantTax.getBankAccount()) ? wxMerchantTax.getBankAccount() : " "); - result.put("invoiceAddressPhone", StringUtils.isNotEmpty(wxMerchantTax.getInvoiceAddressPhone()) ? wxMerchantTax.getInvoiceAddressPhone() : " "); - } else { - result.put("merchantName", ""); - //法人信息 - result.put("corpPapersNumber", " "); - result.put("corpPapersType", " "); - result.put("corpPapersPerson", " "); - //税务信息 - result.put("taxPapersType", " "); - result.put("bankName", " "); - result.put("bankAccount", " "); - result.put("invoiceAddressPhone", " "); - } - //租赁合同信息 - String rentalStartDate = DateUtils.date2String(wxRentContract.getRentalStartDate(), "yyyy-MM-dd"); - result.put("rentalStartDate", rentalStartDate); - result.put("rentalStartDateYear", rentalStartDate.substring(0, 4)); - result.put("rentalStartDateMonth", rentalStartDate.substring(5, 7)); - result.put("rentalStartDateDay", rentalStartDate.substring(8)); - String rentalEndDate = DateUtils.date2String(wxRentContract.getRentalEndDate(), "yyyy-MM-dd"); - result.put("rentalEndDate", rentalEndDate); - result.put("rentalEndDateYear", rentalEndDate.substring(0, 4)); - result.put("rentalEndDateMonth", rentalEndDate.substring(5, 7)); - result.put("rentalEndDateDay", rentalEndDate.substring(8)); - result.put("price", wxRentContract.getPrice()); - result.put("contractNumber", wxRentContract.getContractNumber()); - Integer lease = wxRentContract.getLease(); - Integer receivePeriod = wxRentContract.getReceivePeriod(); - result.put("lease", lease); - result.put("receivePeriod", receivePeriod); - String payAccountStr = " "; - if(wxRentContract.getPayAccount() != null && !wxRentContract.getPayAccount().equals("")) { - payAccountStr = wxRentContract.getPayAccount(); - } - result.put("payAccount", payAccountStr); - result.put("signDate", DateUtils.date2String(wxRentContract.getSignDate(), "yyyy-MM-dd")); - //主体名称-乙方 - if (StringUtils.isNotEmpty(wxRentContract.getSubjectName())) { - result.put("corpPapersPerson", wxRentContract.getSubjectName()); - } else { - result.put("corpPapersPerson", " "); - } - - //品牌 - Long brandId = merchant.getBrand(); - String brand = " "; - if (brandId != null) { - WxBrand wxBrand = WxBrandMapper.selectById(brandId); - if (wxBrand != null) { - brand = wxBrand.getName(); - } - } - result.put("brand", brand); - // TODO - //double adjustRatio = wxRentContract.getAdjustRatio() != null ? wxRentContract.getAdjustRatio() / 100.0 : 0; - result.put("adjustRatio", 0); - double priceRent = new BigDecimal(wxRentContract.getPrice()) - .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); - result.put("priceRent", priceRent); - if (!wxRentContract.getRentArea().equals("0")) { - double unitPrice = new BigDecimal(wxRentContract.getPrice()) - .divide(new BigDecimal(wxRentContract.getRentArea()), 2, RoundingMode.HALF_EVEN) - .divide(new BigDecimal(100)) - .setScale(2, RoundingMode.HALF_EVEN).doubleValue(); - result.put("unitPriceRent", unitPrice); - result.put("priceRentUpper", PriceUtil.digitUppercase(priceRent)); - result.put("unitPriceRentUpper", PriceUtil.digitUppercase(unitPrice)); - } else { - result.put("unitPriceRent", 0); - result.put("priceRentUpper", PriceUtil.digitUppercase(0)); - result.put("unitPriceRentUpper", PriceUtil.digitUppercase(0)); - } - - //租赁保证金 - int cashDepositMonthRent = 3; - double cashDepositRent = new BigDecimal(wxRentContract.getPrice()).multiply(new BigDecimal(cashDepositMonthRent)) - .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); - result.put("cashDepositMonthRent", cashDepositMonthRent); - result.put("cashDepositRent", cashDepositRent); - result.put("cashDepositRentUpper", PriceUtil.digitUppercase(cashDepositRent)); - result.put("type", wxRentContract.getType()); - int extralease = lease % 12; - int extracount = extralease > 0 ? 1 : 0; - int paycount = lease / 12 + extracount; - int index = 10 - paycount; - int count = paycount - 1; - BigDecimal rentPrice = new BigDecimal(priceRent); - //保底 - if (wxRentContract.getRevenue() != null) { - double revenue = new BigDecimal(wxRentContract.getRevenue()) - .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); - result.put("revenue", revenue); - result.put("revenueUpper", PriceUtil.digitUppercase(revenue)); - } else { - result.put("revenue", 0); - result.put("revenueUpper", PriceUtil.digitUppercase(0)); - } - if (!wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { - areaWay(wxRentContract, result, lease, extralease, extracount, paycount, index, count, rentPrice); - } else { - ratioWay(wxRentContract, result, lease, extralease, extracount, paycount, index, count, rentPrice); - } - //物业合同信息 - WxPropertyContract propertyContract = new WxPropertyContract(); - propertyContract.updateTenantInfo(wxRentContract); - propertyContract.setRentContractId(wxRentContract.getId()); -// Optional> first = wxPropertyContractMapper.queryPropertyContractData(propertyContract) -// .stream().filter(rc -> !rc.get("status").equals(EnumRentContractStatus.CONTRACT_TERMINATE.getCode()) -// && !rc.get("status").equals(EnumRentContractStatus.WAIT_SIGN.getCode()) -// && !rc.get("status").equals(EnumRentContractStatus.INVALID.getCode()) -// && !rc.get("status").equals(EnumRentContractStatus.CONTRACT_END.getCode()) -// && !rc.get("status").equals(EnumRentContractStatus.INTENTION.getCode())).findFirst(); - Optional> first = wxPropertyContractMapper.queryPropertyContractData(propertyContract) - .stream().filter(rc -> !rc.get("status").equals(EnumRentContractStatus.TERMINATE.getCode()) - && !rc.get("status").equals(EnumRentContractStatus.INVALID.getCode()) - && !rc.get("status").equals(EnumRentContractStatus.OUT_DATE.getCode())).findFirst(); - Map wxPropertyContract = null; - if (first.isPresent()) { - wxPropertyContract = first.get(); - } - if (wxPropertyContract != null) { - Integer receivePeriodProperty = (Integer) wxPropertyContract.get("receivePeriod"); - result.put("receivePeriodProperty", receivePeriodProperty); - double priceProperty = new BigDecimal(wxPropertyContract.get("price").toString()) - .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); - result.put("priceProperty", priceProperty); - if (!wxRentContract.getRentArea().equals("0")) { - double unitPriceProperty = new BigDecimal(wxPropertyContract.get("price").toString()) - .divide(new BigDecimal(wxRentContract.getRentArea()), 2, RoundingMode.HALF_EVEN) - .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); - result.put("unitPriceProperty", unitPriceProperty); - result.put("pricePropertyUpper", PriceUtil.digitUppercase(priceProperty)); - result.put("unitPricePropertyUpper", PriceUtil.digitUppercase(unitPriceProperty)); - } else { - result.put("unitPriceProperty", 0); - result.put("pricePropertyUpper", PriceUtil.digitUppercase(0)); - result.put("unitPricePropertyUpper", PriceUtil.digitUppercase(0)); - } - - //首期物业费 - Calendar instance = Calendar.getInstance(); - instance.setTime(wxRentContract.getRentalStartDate()); - instance.add(Calendar.MONTH, 0); - Date starttime = instance.getTime(); - String startdate = DateUtils.date2String(starttime, "yyyy-MM-dd"); - result.put("rentalStartDateProperty", startdate); - result.put("rentalStartDateYearProperty", startdate.substring(0, 4)); - result.put("rentalStartDateMonthProperty", startdate.substring(5, 7)); - result.put("rentalStartDateDayProperty", startdate.substring(8)); - //结束时间 - instance.clear(); - instance.setTime(starttime); - instance.add(Calendar.MONTH, receivePeriodProperty); - instance.add(Calendar.DAY_OF_MONTH, -1); - Date endtime = instance.getTime(); - String enddate = DateUtils.date2String(endtime, "yyyy-MM-dd"); - result.put("rentalEndDateProperty", enddate); - result.put("rentalEndDateYearProperty", enddate.substring(0, 4)); - result.put("rentalEndDateMonthProperty", enddate.substring(5, 7)); - result.put("rentalEndDateDayProperty", enddate.substring(8)); - double pricePropertyFirst = new BigDecimal(priceProperty) - .multiply(new BigDecimal(receivePeriodProperty)) - .setScale(2, RoundingMode.HALF_EVEN).doubleValue(); - result.put("pricePropertyFirst", pricePropertyFirst); - result.put("pricePropertyFirstUpper", PriceUtil.digitUppercase(pricePropertyFirst)); - - - //物业保证金 - int cashDepositMonthProperty = 3; - double cashDepositProperty = new BigDecimal(wxPropertyContract.get("price").toString()).multiply(new BigDecimal(cashDepositMonthProperty)) - .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); - result.put("cashDepositMonthProperty", cashDepositMonthProperty); - result.put("cashDepositProperty", cashDepositProperty); - result.put("cashDepositPropertyUpper", PriceUtil.digitUppercase(cashDepositProperty)); - - - } else { - result.put("receivePeriodProperty", " "); - result.put("priceProperty", " "); - result.put("unitPriceProperty", " "); - result.put("pricePropertyUpper", " "); - result.put("unitPricePropertyUpper", " "); - //首期物业费 - result.put("rentalStartDateProperty", " "); - result.put("rentalStartDateYearProperty", " "); - result.put("rentalStartDateMonthProperty", " "); - result.put("rentalStartDateDayProperty", " "); - //结束时间 - result.put("rentalEndDateProperty", " "); - result.put("rentalEndDateYearProperty", " "); - result.put("rentalEndDateMonthProperty", " "); - result.put("rentalEndDateDayProperty", " "); - result.put("pricePropertyFirst", " "); - result.put("pricePropertyFirstUpper", " "); - //物业保证金 - result.put("cashDepositMonthProperty", " "); - result.put("cashDepositProperty", " "); - result.put("cashDepositPropertyUpper", " "); - } - - - return result; - } +// public Map getRentAndPropertyInfo(Long id) { +// logger.info("获取租赁物业合同数据>>>>>>id:" + id); +// Map result = new HashMap<>(); +// WxRentContract wxRentContract = wxRentContractMapper.selectById(id); +// if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { +// JSONArray jsonArray = JSONArray.parseArray(wxRentContract.getRentInfo()); +// StringBuffer shopNumberStr = new StringBuffer(); +// StringBuffer floorNameStr = new StringBuffer(); +// StringBuffer buildingNameStr = new StringBuffer(); +// StringBuffer buildAreaStr = new StringBuffer(); +// StringBuffer operationAreaStr = new StringBuffer(); +// for (int i = 0, size = jsonArray.size(); i < size; i++) { +// JSONObject jsonObject = jsonArray.getJSONObject(i); +// shopNumberStr.append("[").append(jsonObject.getString("shopNumber")).append("]"); +// floorNameStr.append("[").append(jsonObject.getString("floor")).append("]"); +// buildingNameStr.append("[").append(jsonObject.getString("building")).append("]"); +// buildAreaStr.append("[").append(jsonObject.getString("buildArea")).append("]"); +// operationAreaStr.append("[").append(jsonObject.getString("operationArea")).append("]"); +// } +// result.put("shopNumber", shopNumberStr); +// result.put("floorName", floorNameStr); +// result.put("buildingName", buildingNameStr); +// result.put("buildArea", buildAreaStr); +// result.put("operationArea", operationAreaStr); +// } else { +// //record.setId(wxRentContract.getShopId()); +// if (wxRentContract.shopIdsByRentInfo().size() == 0) { +// result.put("shopNumber", " "); +// result.put("floorName", " "); +// result.put("buildingName", " "); +// result.put("buildArea", " "); +// result.put("operationArea", " "); +// }else { +// WxShop record = new WxShop(); +// record.setIds(wxRentContract.shopIdsByRentInfo()); +// List> wxShops = wxShopMapper.findListMap(record); +// if (!wxShops.isEmpty()) { +// //店铺信息 +// Map wxShop = wxShops.get(0); +// result.put("shopNumber", wxShop.get("shopNumber")); +// result.put("floorName", wxShop.get("floor")); +// result.put("buildingName", wxShop.get("building")); +// result.put("buildArea", wxShop.get("buildArea")); +// result.put("operationArea", wxShop.get("operationArea")); +// } +// } +// } +// //MALL信息 +// WxMall wxMall = new WxMall(); +// wxMall.setTenantInfo(wxRentContract); +// wxMall = wxMallMapper.findList(wxMall).get(0); +// result.put("mallName", wxMall.getName()); +// result.put("province", wxMall.getProvince()); +// result.put("city", wxMall.getCity()); +// +// //商户信息 +// WxMerchant merchant = wxMerchantService.getById(wxRentContract.getMerchantId()); +// //经营业态 +// wxRentContract.getMerchantId(); +// WxBusiness wxBusiness = wxBusinessMapper.selectById(merchant.getBusinessId()); +// result.put("business", wxBusiness.getTitle()); +// +// if (merchant != null) { +// result.put("merchantName", merchant.getName()); +// //法人信息 +// WxMerchantCorp wxMerchantCorp = merchant.getWxMerchantCorp(); +// result.put("corpPapersNumber", StringUtils.isNotEmpty(wxMerchantCorp.getCorpPapersNumber()) ? wxMerchantCorp.getCorpPapersNumber() : " "); +// result.put("corpPapersType", wxMerchantCorp.getCorpPapersType() != null ? EnumPapersType.getEnum(wxMerchantCorp.getCorpPapersType()).getMessage() : " "); +// result.put("corpPapersPerson", StringUtils.isNotEmpty(wxMerchantCorp.getCorpPapersPerson()) ? wxMerchantCorp.getCorpPapersPerson() : " "); +// //税务信息 +// WxMerchantTax wxMerchantTax = merchant.getWxMerchantTax(); +// result.put("taxPapersType", wxMerchantTax.getTaxPapersType() != null ? EnumTaxpayerType.getEnum(wxMerchantTax.getTaxPapersType()).getMessage() : " "); +// result.put("bankName", StringUtils.isNotEmpty(wxMerchantTax.getBankName()) ? wxMerchantTax.getBankName() : " "); +// result.put("bankAccount", StringUtils.isNotEmpty(wxMerchantTax.getBankAccount()) ? wxMerchantTax.getBankAccount() : " "); +// result.put("invoiceAddressPhone", StringUtils.isNotEmpty(wxMerchantTax.getInvoiceAddressPhone()) ? wxMerchantTax.getInvoiceAddressPhone() : " "); +// } else { +// result.put("merchantName", ""); +// //法人信息 +// result.put("corpPapersNumber", " "); +// result.put("corpPapersType", " "); +// result.put("corpPapersPerson", " "); +// //税务信息 +// result.put("taxPapersType", " "); +// result.put("bankName", " "); +// result.put("bankAccount", " "); +// result.put("invoiceAddressPhone", " "); +// } +// //租赁合同信息 +// String rentalStartDate = DateUtils.date2String(wxRentContract.getRentalStartDate(), "yyyy-MM-dd"); +// result.put("rentalStartDate", rentalStartDate); +// result.put("rentalStartDateYear", rentalStartDate.substring(0, 4)); +// result.put("rentalStartDateMonth", rentalStartDate.substring(5, 7)); +// result.put("rentalStartDateDay", rentalStartDate.substring(8)); +// String rentalEndDate = DateUtils.date2String(wxRentContract.getRentalEndDate(), "yyyy-MM-dd"); +// result.put("rentalEndDate", rentalEndDate); +// result.put("rentalEndDateYear", rentalEndDate.substring(0, 4)); +// result.put("rentalEndDateMonth", rentalEndDate.substring(5, 7)); +// result.put("rentalEndDateDay", rentalEndDate.substring(8)); +// result.put("price", wxRentContract.getPrice()); +// result.put("contractNumber", wxRentContract.getContractNumber()); +// Integer lease = wxRentContract.getLease(); +// Integer receivePeriod = wxRentContract.getReceivePeriod(); +// result.put("lease", lease); +// result.put("receivePeriod", receivePeriod); +// String payAccountStr = " "; +// if(wxRentContract.getPayAccount() != null && !wxRentContract.getPayAccount().equals("")) { +// payAccountStr = wxRentContract.getPayAccount(); +// } +// result.put("payAccount", payAccountStr); +// result.put("signDate", DateUtils.date2String(wxRentContract.getSignDate(), "yyyy-MM-dd")); +// //主体名称-乙方 +// if (StringUtils.isNotEmpty(wxRentContract.getSubjectName())) { +// result.put("corpPapersPerson", wxRentContract.getSubjectName()); +// } else { +// result.put("corpPapersPerson", " "); +// } +// +// //品牌 +// Long brandId = merchant.getBrand(); +// String brand = " "; +// if (brandId != null) { +// WxBrand wxBrand = WxBrandMapper.selectById(brandId); +// if (wxBrand != null) { +// brand = wxBrand.getName(); +// } +// } +// result.put("brand", brand); +// // TODO +// //double adjustRatio = wxRentContract.getAdjustRatio() != null ? wxRentContract.getAdjustRatio() / 100.0 : 0; +// result.put("adjustRatio", 0); +// double priceRent = new BigDecimal(wxRentContract.getPrice()) +// .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); +// result.put("priceRent", priceRent); +// if (!wxRentContract.getRentArea().equals("0")) { +// double unitPrice = new BigDecimal(wxRentContract.getPrice()) +// .divide(new BigDecimal(wxRentContract.getRentArea()), 2, RoundingMode.HALF_EVEN) +// .divide(new BigDecimal(100)) +// .setScale(2, RoundingMode.HALF_EVEN).doubleValue(); +// result.put("unitPriceRent", unitPrice); +// result.put("priceRentUpper", PriceUtil.digitUppercase(priceRent)); +// result.put("unitPriceRentUpper", PriceUtil.digitUppercase(unitPrice)); +// } else { +// result.put("unitPriceRent", 0); +// result.put("priceRentUpper", PriceUtil.digitUppercase(0)); +// result.put("unitPriceRentUpper", PriceUtil.digitUppercase(0)); +// } +// +// //租赁保证金 +// int cashDepositMonthRent = 3; +// double cashDepositRent = new BigDecimal(wxRentContract.getPrice()).multiply(new BigDecimal(cashDepositMonthRent)) +// .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); +// result.put("cashDepositMonthRent", cashDepositMonthRent); +// result.put("cashDepositRent", cashDepositRent); +// result.put("cashDepositRentUpper", PriceUtil.digitUppercase(cashDepositRent)); +// result.put("type", wxRentContract.getType()); +// int extralease = lease % 12; +// int extracount = extralease > 0 ? 1 : 0; +// int paycount = lease / 12 + extracount; +// int index = 10 - paycount; +// int count = paycount - 1; +// BigDecimal rentPrice = new BigDecimal(priceRent); +// //保底 +// if (wxRentContract.getRevenue() != null) { +// double revenue = new BigDecimal(wxRentContract.getRevenue()) +// .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); +// result.put("revenue", revenue); +// result.put("revenueUpper", PriceUtil.digitUppercase(revenue)); +// } else { +// result.put("revenue", 0); +// result.put("revenueUpper", PriceUtil.digitUppercase(0)); +// } +// if (!wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { +// areaWay(wxRentContract, result, lease, extralease, extracount, paycount, index, count, rentPrice); +// } else { +// ratioWay(wxRentContract, result, lease, extralease, extracount, paycount, index, count, rentPrice); +// } +// //物业合同信息 +// WxPropertyContract propertyContract = new WxPropertyContract(); +// propertyContract.updateTenantInfo(wxRentContract); +// propertyContract.setRentContractId(wxRentContract.getId()); +//// Optional> first = wxPropertyContractMapper.queryPropertyContractData(propertyContract) +//// .stream().filter(rc -> !rc.get("status").equals(EnumRentContractStatus.CONTRACT_TERMINATE.getCode()) +//// && !rc.get("status").equals(EnumRentContractStatus.WAIT_SIGN.getCode()) +//// && !rc.get("status").equals(EnumRentContractStatus.INVALID.getCode()) +//// && !rc.get("status").equals(EnumRentContractStatus.CONTRACT_END.getCode()) +//// && !rc.get("status").equals(EnumRentContractStatus.INTENTION.getCode())).findFirst(); +// Optional> first = wxPropertyContractMapper.queryPropertyContractData(propertyContract) +// .stream().filter(rc -> !rc.get("status").equals(EnumRentContractStatus.TERMINATE.getCode()) +// && !rc.get("status").equals(EnumRentContractStatus.INVALID.getCode()) +// && !rc.get("status").equals(EnumRentContractStatus.OUT_DATE.getCode())).findFirst(); +// Map wxPropertyContract = null; +// if (first.isPresent()) { +// wxPropertyContract = first.get(); +// } +// if (wxPropertyContract != null) { +// Integer receivePeriodProperty = (Integer) wxPropertyContract.get("receivePeriod"); +// result.put("receivePeriodProperty", receivePeriodProperty); +// double priceProperty = new BigDecimal(wxPropertyContract.get("price").toString()) +// .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); +// result.put("priceProperty", priceProperty); +// if (!wxRentContract.getRentArea().equals("0")) { +// double unitPriceProperty = new BigDecimal(wxPropertyContract.get("price").toString()) +// .divide(new BigDecimal(wxRentContract.getRentArea()), 2, RoundingMode.HALF_EVEN) +// .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); +// result.put("unitPriceProperty", unitPriceProperty); +// result.put("pricePropertyUpper", PriceUtil.digitUppercase(priceProperty)); +// result.put("unitPricePropertyUpper", PriceUtil.digitUppercase(unitPriceProperty)); +// } else { +// result.put("unitPriceProperty", 0); +// result.put("pricePropertyUpper", PriceUtil.digitUppercase(0)); +// result.put("unitPricePropertyUpper", PriceUtil.digitUppercase(0)); +// } +// +// //首期物业费 +// Calendar instance = Calendar.getInstance(); +// instance.setTime(wxRentContract.getRentalStartDate()); +// instance.add(Calendar.MONTH, 0); +// Date starttime = instance.getTime(); +// String startdate = DateUtils.date2String(starttime, "yyyy-MM-dd"); +// result.put("rentalStartDateProperty", startdate); +// result.put("rentalStartDateYearProperty", startdate.substring(0, 4)); +// result.put("rentalStartDateMonthProperty", startdate.substring(5, 7)); +// result.put("rentalStartDateDayProperty", startdate.substring(8)); +// //结束时间 +// instance.clear(); +// instance.setTime(starttime); +// instance.add(Calendar.MONTH, receivePeriodProperty); +// instance.add(Calendar.DAY_OF_MONTH, -1); +// Date endtime = instance.getTime(); +// String enddate = DateUtils.date2String(endtime, "yyyy-MM-dd"); +// result.put("rentalEndDateProperty", enddate); +// result.put("rentalEndDateYearProperty", enddate.substring(0, 4)); +// result.put("rentalEndDateMonthProperty", enddate.substring(5, 7)); +// result.put("rentalEndDateDayProperty", enddate.substring(8)); +// double pricePropertyFirst = new BigDecimal(priceProperty) +// .multiply(new BigDecimal(receivePeriodProperty)) +// .setScale(2, RoundingMode.HALF_EVEN).doubleValue(); +// result.put("pricePropertyFirst", pricePropertyFirst); +// result.put("pricePropertyFirstUpper", PriceUtil.digitUppercase(pricePropertyFirst)); +// +// +// //物业保证金 +// int cashDepositMonthProperty = 3; +// double cashDepositProperty = new BigDecimal(wxPropertyContract.get("price").toString()).multiply(new BigDecimal(cashDepositMonthProperty)) +// .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); +// result.put("cashDepositMonthProperty", cashDepositMonthProperty); +// result.put("cashDepositProperty", cashDepositProperty); +// result.put("cashDepositPropertyUpper", PriceUtil.digitUppercase(cashDepositProperty)); +// +// +// } else { +// result.put("receivePeriodProperty", " "); +// result.put("priceProperty", " "); +// result.put("unitPriceProperty", " "); +// result.put("pricePropertyUpper", " "); +// result.put("unitPricePropertyUpper", " "); +// //首期物业费 +// result.put("rentalStartDateProperty", " "); +// result.put("rentalStartDateYearProperty", " "); +// result.put("rentalStartDateMonthProperty", " "); +// result.put("rentalStartDateDayProperty", " "); +// //结束时间 +// result.put("rentalEndDateProperty", " "); +// result.put("rentalEndDateYearProperty", " "); +// result.put("rentalEndDateMonthProperty", " "); +// result.put("rentalEndDateDayProperty", " "); +// result.put("pricePropertyFirst", " "); +// result.put("pricePropertyFirstUpper", " "); +// //物业保证金 +// result.put("cashDepositMonthProperty", " "); +// result.put("cashDepositProperty", " "); +// result.put("cashDepositPropertyUpper", " "); +// } +// +// +// return result; +// } public void ratioWay(WxRentContract wxRentContract, Map result, Integer lease, int extralease, int extracount, int paycount, int index, int count, BigDecimal rentPrice) { String adjustRatio = wxRentContract.getAdjustRatio(); diff --git a/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml b/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml index 86779455a..6fb615cbb 100644 --- a/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml @@ -21,7 +21,6 @@ - @@ -53,7 +52,7 @@ `id`,`merchant_id`,`price`,`rental_start_date`,`rental_end_date`, `sign_date`,`receive_period`,`tenant_id`,`parent_tenant_id`,`filepath`,`status`,`contract_number`, `deposit`,`pay_date`,`is_del`,`merchant_name`,`brand`,`business_id`, - `shop_type`,`shop_id`,`updatetime`,`createtime`,`rent_area`, + `shop_type`,`updatetime`,`createtime`,`rent_area`, `link_person`,`link_phone`,`pay_account`,`filename`,`lease`,`rent_contract_id`, `start_date`,`end_date`,`apply_status`,`adjust_period`,`business_type`,adjust_ratio,`rent_info`, `file_names`,price_unit,rent_price,subject_name,rent_start_type,`operation_type`,late_pay_ratio,late_pay_day @@ -84,7 +83,6 @@ and `brand` = #{brand} and `business_id` = #{businessId} and `shop_type` = #{shopType} - and `shop_id` = #{shopId} and `updatetime` = #{updatetime} and `createtime` = #{createtime} and `rent_area` = #{rentArea} @@ -115,7 +113,7 @@ - @@ -285,7 +283,7 @@ and merchant_id is null - + - + From 2e0cea6bb4f86996d8c0e36ab7e216a27da66a92 Mon Sep 17 00:00:00 2001 From: xiaohanzi Date: Tue, 18 Aug 2020 14:30:23 +0800 Subject: [PATCH 3/3] fix contract --- .../WxPropertyContractController.java | 14 ++-- .../service/WxPropertyContractService.java | 2 +- .../impl/WxPropertyContractServiceImpl.java | 67 +++++++------------ 3 files changed, 33 insertions(+), 50 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java index e3648ed9d..9845468a4 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java @@ -160,13 +160,13 @@ public class WxPropertyContractController extends WxContractBaseController { // return new ResultData(Result.SUCCESS, "查询成功", wxPropertyContractService.getRentContractList(wxPropertyContract)); // } - @GetMapping("/endPropertyContractByRentContractId") - @ApiImplicitParam(name = "rentContractId", value = "rentContractId", dataType = "Long", paramType = "query", required = true) - @SystemControllerLog(description = "物业合同-根据租赁合同终止") - public ResultData endPropertyContractByRentContractId(Long rentContractId) { - logger.debug("[" + getIpAddr() + "] WxPropertyContractController::endPropertyContractByRentContractId"); - return wxPropertyContractService.endPropertyContractByRentContractId(rentContractId); - } +// @GetMapping("/endPropertyContractByRentContractId") +// @ApiImplicitParam(name = "rentContractId", value = "rentContractId", dataType = "Long", paramType = "query", required = true) +// @SystemControllerLog(description = "物业合同-根据租赁合同终止") +// public ResultData endPropertyContractByRentContractId(Long rentContractId) { +// logger.debug("[" + getIpAddr() + "] WxPropertyContractController::endPropertyContractByRentContractId"); +// return wxPropertyContractService.endPropertyContractByRentContractId(rentContractId); +// } @GetMapping("/hasRentContract") @ApiImplicitParam(name = "rentContractId", value = "rentContractId", dataType = "Long", paramType = "query", required = true) diff --git a/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java b/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java index 066b94346..0060b5e97 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java @@ -59,7 +59,7 @@ public interface WxPropertyContractService { //Object getRentContractList(WxPropertyContract record); - ResultData endPropertyContractByRentContractId(Long rentContractId); + //ResultData endPropertyContractByRentContractId(Long rentContractId); ResultData hasRentContract(Long rentContractId); 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 3615ffaea..df4c57149 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java @@ -79,14 +79,13 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService @Override public Map listAsPage(WxPropertyContract record, Integer pageIndex, Integer pageSize) { //Object rentContractStatusInfo = getRentContractStatusInfo(record); -// PageHelper.startPage(pageIndex, pageSize); -// List> rentContractData = wxPropertyContractMapper.queryPropertyContractData(record); -// PageInfo> pageInfo = new PageInfo<>(rentContractData); -// Map result = new HashMap<>(); -// //result.put("rentContractStatusInfo", rentContractStatusInfo); -// result.put("pageInfo", pageInfo); -// return result; - return null; + PageHelper.startPage(pageIndex, pageSize); + //List> rentContractData = wxPropertyContractMapper.queryPropertyContractData(record); + Map result = new HashMap<>(); + PageInfo pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxPropertyContractMapper.findList(record)); + //result.put("rentContractStatusInfo", rentContractStatusInfo); + result.put("pageInfo", pageInfo); + return result; } @Override @@ -307,18 +306,18 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "物业费要大于0"); } - WxPropertyContract propertyContract = new WxPropertyContract(); - propertyContract.updateTenantInfo(wxRentContract); - propertyContract.setRentContractId(record.getRentContractId()); - long count = wxPropertyContractMapper.findList(propertyContract) -// .stream().filter(p -> p.getStatus().equals(EnumRentContractStatus.READY_FOR_PAING.getCode()) || -// p.getStatus().equals(EnumRentContractStatus.RENT_PAID.getCode()) || -// p.getStatus().equals(EnumRentContractStatus.CONTRACT_END_SOON.getCode())).count(); - .stream().filter(p -> p.getStatus().equals(EnumRentContractStatus.READY_FOR_PAING.getCode()) || - p.getStatus().equals(EnumRentContractStatus.PAING.getCode())).count(); - if (count > 1) { - return new ResultData(ErrorCode.RENT_CONTRACT_WITH_SHOP_IS_FOUND); - } +// WxPropertyContract propertyContract = new WxPropertyContract(); +// propertyContract.updateTenantInfo(wxRentContract); +// propertyContract.setRentContractId(record.getRentContractId()); +// long count = wxPropertyContractMapper.findList(propertyContract) +//// .stream().filter(p -> p.getStatus().equals(EnumRentContractStatus.READY_FOR_PAING.getCode()) || +//// p.getStatus().equals(EnumRentContractStatus.RENT_PAID.getCode()) || +//// p.getStatus().equals(EnumRentContractStatus.CONTRACT_END_SOON.getCode())).count(); +// .stream().filter(p -> p.getStatus().equals(EnumRentContractStatus.READY_FOR_PAING.getCode()) || +// p.getStatus().equals(EnumRentContractStatus.PAING.getCode())).count(); +// if (count > 1) { +// return new ResultData(ErrorCode.RENT_CONTRACT_WITH_SHOP_IS_FOUND); +// } //保存物业合同信息 String message; boolean hasFlow = true; @@ -916,7 +915,6 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService @Transactional(rollbackFor = {Exception.class}) @Override public ResultData endRentContract(Long id) { - WxPropertyContract wxPropertyContract = wxPropertyContractMapper.selectById(id); if (wxPropertyContract == null) { return new ResultData(ErrorCode.PROPERTY_CONTRACT_IS_NOT_FOUND); @@ -925,6 +923,12 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService try { wxPropertyContract.setUpdatetime(new Date()); wxPropertyContractMapper.updateById(wxPropertyContract); + + //物业账单失效 + WxBillProperty billProperty = new WxBillProperty(); + billProperty.setPropertyContractId(id); + wxBillPropertyMapper.updateInvalidStatus(billProperty); + } catch (MallinkException e) { logger.info("终止合同失败:" + e.getMessage()); throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); @@ -947,27 +951,6 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService // return contractList; // } - @Override - public ResultData endPropertyContractByRentContractId(Long rentContractId) { -// WxPropertyContract wxPropertyContractParam = new WxPropertyContract(); -// wxPropertyContractParam.setRentContractId(rentContractId); -// wxPropertyContractMapper.findList(wxPropertyContractParam); -// //List> contractData = wxPropertyContractMapper.queryPropertyContractData(wxPropertyContractParam); -// if (contractData.size() == 0) { -// return new ResultData(ErrorCode.PROPERTY_CONTRACT_IS_NOT_FOUND); -// } -// Map contractMap = contractData.get(0); -// WxPropertyContract wxPropertyContract = wxPropertyContractMapper.selectById((Long) contractMap.get("id")); -// wxPropertyContract.setStatus(EnumRentContractStatus.TERMINATE.getCode()); -// try { -// wxPropertyContractMapper.updateById(wxPropertyContract); -// } catch (MallinkException e) { -// logger.info("终止合同失败:" + e.getMessage()); -// throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); -// } - return new ResultData(Result.SUCCESS, "操作成功"); - } - @Override public ResultData hasRentContract(Long rentContractId) { if (null == rentContractId) {