| @@ -188,22 +188,7 @@ public class WxRentContractController extends WxContractBaseController { | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | 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") | @PostMapping("update") | ||||
| @SystemControllerLog(description = "租赁合同-更新") | @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") | @GetMapping("/merchantShops") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @ApiImplicitParam(name = "merchantId", value = "merchantId", dataType = "Long", paramType = "query", required = true), | @ApiImplicitParam(name = "merchantId", value = "merchantId", dataType = "Long", paramType = "query", required = true), | ||||
| @@ -311,25 +292,7 @@ public class WxRentContractController extends WxContractBaseController { | |||||
| } | } | ||||
| return new ResultData(shops); | 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<Integer> statuss = new ArrayList<Integer>(); | |||||
| 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(); | 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<String,Integer> 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<Integer> statuss = new ArrayList<Integer>(); | |||||
| 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") | @GetMapping("getMerchantList") | ||||
| @SystemControllerLog(description = "获取商户列表") | @SystemControllerLog(description = "获取商户列表") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @@ -396,20 +479,6 @@ public class WxRentContractController extends WxContractBaseController { | |||||
| return new ResultData(); | 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<String,Integer> 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 | * @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") | // @GetMapping("/getRentContractStatusInfo") | ||||
| // @SystemControllerLog(description = "租赁合同-获取合同状态信息") | // @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") | @PostMapping("updateRentContractStatus") | ||||
| @SystemControllerLog(description = "租赁合同-更新合同状态") | @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") | @GetMapping("/getContractByContractNumber") | ||||
| @SystemControllerLog(description = "租赁合同-通过合同编号查询信息") | @SystemControllerLog(description = "租赁合同-通过合同编号查询信息") | ||||
| public ResultData getContractByContractNumber(@ModelAttribute WxRentContract wxRentContract) { | public ResultData getContractByContractNumber(@ModelAttribute WxRentContract wxRentContract) { | ||||
| @@ -62,7 +62,9 @@ public class WxPropertyContract extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="合同进度状态1待签约2已签约未记租3计租中4提前终止5合同到期",name="status") | @io.swagger.annotations.ApiModelProperty(value="合同进度状态1待签约2已签约未记租3计租中4提前终止5合同到期",name="status") | ||||
| private Integer status; | private Integer status; | ||||
| @TableField(exist = false) | |||||
| private List<Integer> statuss; | |||||
| @io.swagger.annotations.ApiModelProperty(value="合同编号",name="contractNumber") | @io.swagger.annotations.ApiModelProperty(value="合同编号",name="contractNumber") | ||||
| private String contractNumber; | private String contractNumber; | ||||
| @@ -87,9 +89,6 @@ public class WxPropertyContract extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="店铺类型:1直营店2加盟店3个体店4旗舰店",name="shopType") | @io.swagger.annotations.ApiModelProperty(value="店铺类型:1直营店2加盟店3个体店4旗舰店",name="shopType") | ||||
| private Integer shopType; | private Integer shopType; | ||||
| @io.swagger.annotations.ApiModelProperty(value="商铺ID",name="shopId") | |||||
| private Long shopId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updatetime") | @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updatetime") | ||||
| private Date updatetime; | private Date updatetime; | ||||
| @@ -9,6 +9,8 @@ import com.iformall.domain.po.WxRentContract; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| import org.apache.ibatis.annotations.Param; | |||||
| /** | /** | ||||
| * @author gongbiao | * @author gongbiao | ||||
| */ | */ | ||||
| @@ -53,4 +55,6 @@ public interface WxPropertyContractMapper extends CommonMapper<WxPropertyContrac | |||||
| WxPropertyContract findOneByRentId(WxRentContract wxRentContract); | WxPropertyContract findOneByRentId(WxRentContract wxRentContract); | ||||
| WxPropertyContract getByBill(WxBillProperty billRent); | WxPropertyContract getByBill(WxBillProperty billRent); | ||||
| void endContract(WxRentContract wxRentContract); | |||||
| } | } | ||||
| @@ -80,4 +80,6 @@ public interface WxRentContractMapper extends CommonMapper<WxRentContract, Long> | |||||
| List<WxRentContract> getAllContractBymerchantId(WxRentContract wxRentContract); | List<WxRentContract> getAllContractBymerchantId(WxRentContract wxRentContract); | ||||
| List<WxRentContract> getContractByMerchant(WxRentContract wxRentContract); | List<WxRentContract> getContractByMerchant(WxRentContract wxRentContract); | ||||
| Integer getCanApplyCount(@Param("id") Long id); | |||||
| } | } | ||||
| @@ -60,9 +60,7 @@ public interface WxRentContractService { | |||||
| //Object getRentContractStatusInfo(WxRentContract record); | //Object getRentContractStatusInfo(WxRentContract record); | ||||
| ResultData endRentContract(Long id, Integer status); | |||||
| ResultData updateMerchant(WxRentContract wxRentContract); | |||||
| ResultData updateRentContract(WxRentContract wxRentContract); | |||||
| PageInfo<WxRentContract> getRentContractList(WxRentContract rentContract, Integer pageNum, Integer pageSize); | PageInfo<WxRentContract> getRentContractList(WxRentContract rentContract, Integer pageNum, Integer pageSize); | ||||
| @@ -90,7 +88,7 @@ public interface WxRentContractService { | |||||
| //Integer getShopType(WxRentContract wxRentContract); | //Integer getShopType(WxRentContract wxRentContract); | ||||
| void endContract(WxRentContract wxRentContract); | |||||
| ResultData endContract(WxRentContract wxRentContract); | |||||
| void updatePropertyPreviewBill(WxRentContract record); | void updatePropertyPreviewBill(WxRentContract record); | ||||
| @@ -186,6 +186,7 @@ public class WxFlowServiceImpl implements WxFlowService { | |||||
| rent.setBusinessType(flowType); | rent.setBusinessType(flowType); | ||||
| WxRentContract record = wxRentContractMapper.selectById(businessId); | WxRentContract record = wxRentContractMapper.selectById(businessId); | ||||
| //合并的合同-审批时 物业合同的状态肯定不在 签约中 避免更新物业合同时提示店铺存在 | //合并的合同-审批时 物业合同的状态肯定不在 签约中 避免更新物业合同时提示店铺存在 | ||||
| if(record.getOperationType().equals(EnumContractOperationType.WHOLE.getCode())){ | if(record.getOperationType().equals(EnumContractOperationType.WHOLE.getCode())){ | ||||
| WxPropertyContract wxPropertyContract = new WxPropertyContract(); | WxPropertyContract wxPropertyContract = new WxPropertyContract(); | ||||
| @@ -199,7 +200,10 @@ public class WxFlowServiceImpl implements WxFlowService { | |||||
| //如果是提交审批 , 审批驳回状态不变 | //如果是提交审批 , 审批驳回状态不变 | ||||
| if (EnumRentContractAppStatus.APPLYING.getCode().intValue() == applyStatus.intValue()) { | 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()) { | }else if (EnumRentContractAppStatus.FINISH.getCode().intValue() == applyStatus.intValue()) { | ||||
| wxRentContractService.updateRentContractStatus(businessId); | wxRentContractService.updateRentContractStatus(businessId); | ||||
| @@ -160,15 +160,6 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| } else { | } else { | ||||
| result.put("wxMerchant", null); | result.put("wxMerchant", null); | ||||
| } | } | ||||
| //关联的店铺 | |||||
| if (wxPropertyContract.getShopId() != null) { | |||||
| WxShop record = new WxShop(); | |||||
| record.setId(wxPropertyContract.getShopId()); | |||||
| List<Map<String, Object>> list = wxShopMapper.findListMap(record); | |||||
| result.put("wxShops", list); | |||||
| } else { | |||||
| result.put("wxShops", Collections.EMPTY_LIST); | |||||
| } | |||||
| //租赁费用欠缴 | //租赁费用欠缴 | ||||
| WxRentContract wxRentContract = new WxRentContract(); | WxRentContract wxRentContract = new WxRentContract(); | ||||
| @@ -187,6 +178,19 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| if (!select.isEmpty()) { | if (!select.isEmpty()) { | ||||
| result.put("depositStatus", select.get(0).getStatus()); | 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<Map<String, Object>> list = wxShopMapper.findListMap(record); | |||||
| result.put("wxShops", list); | |||||
| }else { | |||||
| result.put("wxShops", Collections.EMPTY_LIST); | |||||
| } | |||||
| } | |||||
| //发起人备注 | //发起人备注 | ||||
| WxFlowRecord wxFlowRecord = new WxFlowRecord(); | WxFlowRecord wxFlowRecord = new WxFlowRecord(); | ||||
| wxFlowRecord.setBusinessId(id); | wxFlowRecord.setBusinessId(id); | ||||
| @@ -239,7 +243,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| bill.setLatePayRatio(0); | bill.setLatePayRatio(0); | ||||
| bill.setPay(0L); | bill.setPay(0L); | ||||
| bill.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | bill.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | ||||
| bill.setShopId(record.getShopId()); | |||||
| //bill.setShopId(record.getShopId()); | |||||
| bill.setExpiredDay(0L); | bill.setExpiredDay(0L); | ||||
| setExpiredDay(bill,Calendar.MONTH,record.getReceivePeriod()); | setExpiredDay(bill,Calendar.MONTH,record.getReceivePeriod()); | ||||
| if (bill.getReceivePay().equals(0L)) { | if (bill.getReceivePay().equals(0L)) { | ||||
| @@ -264,9 +268,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| haspreview = true; | 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()); | WxRentContract wxRentContract = wxRentContractMapper.selectById(record.getRentContractId()); | ||||
| if (wxRentContract != null) { | if (wxRentContract != null) { | ||||
| @@ -489,7 +493,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| wxBillDeposit.updateTenantInfo(wxPropertyContract); | wxBillDeposit.updateTenantInfo(wxPropertyContract); | ||||
| wxBillDeposit.setIsDel(0); | wxBillDeposit.setIsDel(0); | ||||
| wxBillDeposit.setMerchantId(record.getMerchantId()); | wxBillDeposit.setMerchantId(record.getMerchantId()); | ||||
| wxBillDeposit.setShopId(wxPropertyContract.getShopId()); | |||||
| //wxBillDeposit.setShopId(wxPropertyContract.getShopId()); | |||||
| wxBillDeposit.setCreatetime(date); | wxBillDeposit.setCreatetime(date); | ||||
| wxBillDeposit.setUpdatetime(date); | wxBillDeposit.setUpdatetime(date); | ||||
| wxBillDeposit.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | wxBillDeposit.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | ||||
| @@ -688,7 +692,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| wxBillProperty.setIsDel(0); | wxBillProperty.setIsDel(0); | ||||
| wxBillProperty.setMerchantId(wxPropertyContract.getMerchantId()); | wxBillProperty.setMerchantId(wxPropertyContract.getMerchantId()); | ||||
| wxBillProperty.setUserId(userId); | wxBillProperty.setUserId(userId); | ||||
| wxBillProperty.setShopId(wxPropertyContract.getShopId()); | |||||
| //wxBillProperty.setShopId(wxPropertyContract.getShopId()); | |||||
| wxBillProperty.setCreatetime(date); | wxBillProperty.setCreatetime(date); | ||||
| wxBillProperty.setUpdatetime(date); | wxBillProperty.setUpdatetime(date); | ||||
| wxBillProperty.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | wxBillProperty.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | ||||
| @@ -976,9 +980,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { | if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { | ||||
| wxPropertyContract.setMerchantId(wxRentContract.getMerchantId()); | 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<WxPropertyContract> select = wxPropertyContractMapper.selectList(new QueryWrapper(wxPropertyContract)); | List<WxPropertyContract> select = wxPropertyContractMapper.selectList(new QueryWrapper(wxPropertyContract)); | ||||
| @@ -1474,52 +1474,66 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| @Transactional(rollbackFor = {Exception.class}) | @Transactional(rollbackFor = {Exception.class}) | ||||
| @Override | @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); | 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<Map<String, Object>> contractData = wxPropertyContractMapper.queryPropertyContractData(wxPropertyContract); | |||||
| if (contractData.size() > 0) { | |||||
| Map<String, Object> 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<Integer> validstatuss = new ArrayList<Integer>(); | |||||
| 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<Integer> unvalidstatuss = new ArrayList<Integer>(); | |||||
| 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}) | @Transactional(rollbackFor = {Exception.class}) | ||||
| @Override | @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 { | try { | ||||
| wxRentContractMapper.updateById(record); | |||||
| wxRentContractMapper.updateById(wxRentContract); | |||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.info("关联合同商户失败:" + e.getMessage()); | logger.info("关联合同商户失败:" + e.getMessage()); | ||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + 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) { | if (record == null) { | ||||
| return new ResultData(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND); | 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 wxRentContract = new WxRentContract(); | ||||
| wxRentContract.setId(id); | wxRentContract.setId(id); | ||||
| @@ -2380,32 +2401,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| return list; | 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 | @Override | ||||
| public WxRentContract getByBill(WxBillRent billRent) { | public WxRentContract getByBill(WxBillRent billRent) { | ||||
| @@ -2457,6 +2452,12 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| @Override | @Override | ||||
| public ResultData apply(WxRentContract wxRentContract,MallUserInfo user) { | 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()); | WxRentContract rentContract = wxRentContractMapper.selectById(wxRentContract.getId()); | ||||
| if (null == rentContract) { | if (null == rentContract) { | ||||
| return new ResultData(Result.ERROR, "编号["+wxRentContract.getId()+"]未找到租金合同"); | return new ResultData(Result.ERROR, "编号["+wxRentContract.getId()+"]未找到租金合同"); | ||||
| @@ -386,4 +386,15 @@ | |||||
| select property_contract_id from wx_bill_property id = #{id} | select property_contract_id from wx_bill_property id = #{id} | ||||
| ) | ) | ||||
| </select> | </select> | ||||
| <update id="endContract" parameterType="com.iformall.domain.po.WxPropertyContract"> | |||||
| update wx_property_contract set status=#{status},updatetime = #{updatetime} where rent_contract_id =#{rentContractId} | |||||
| <if test=" null != statuss "> | |||||
| and status in | |||||
| <foreach collection="statuss" index="index" item="statusItem" open="(" separator="," close=")"> | |||||
| #{statusItem} | |||||
| </foreach> | |||||
| </if> | |||||
| </update> | |||||
| </mapper> | </mapper> | ||||
| @@ -671,5 +671,10 @@ | |||||
| <select id="getContractByMerchant" resultType="com.iformall.domain.po.WxRentContract" parameterType="com.iformall.domain.po.WxRentContract"> | <select id="getContractByMerchant" resultType="com.iformall.domain.po.WxRentContract" parameterType="com.iformall.domain.po.WxRentContract"> | ||||
| select * from wx_rent_contract where merchant_id = #{merchantId} and status=3 | select * from wx_rent_contract where merchant_id = #{merchantId} and status=3 | ||||
| </select> | </select> | ||||
| <select id="getCanApplyCount" resultType="Integer" parameterType="Long"> | |||||
| select count(1) from wx_rent_contract where id != #{id} and (status=1 or (status=10 and apply_status=3) ) | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||