| @@ -1,26 +1,75 @@ | |||
| package com.iformall.controller.contract; | |||
| import java.util.ArrayList; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxFlowModel; | |||
| import com.iformall.domain.po.WxPropertyContract; | |||
| import com.iformall.domain.po.WxRentContract; | |||
| import com.iformall.enums.EnumFlowContractType; | |||
| import com.iformall.enums.EnumFlowKey; | |||
| import com.iformall.enums.EnumRentShopType; | |||
| import com.iformall.service.WxFlowService; | |||
| @RestController | |||
| public class WxContractBaseController extends BaseController{ | |||
| @Autowired | |||
| private WxFlowService wxFlowService; | |||
| protected Map<String,Object> generateFlowParams(EnumFlowKey flowType,EnumFlowContractType contractType,String remark,Long contractId) { | |||
| Map<String,Object> map = new HashMap<String,Object>(); | |||
| map.put("businessType", flowType.getCode()); | |||
| map.put("remark", remark); | |||
| map.put("businessId", String.valueOf(contractId)); | |||
| Map variables = new HashMap<String,Object>(); | |||
| variables.put("contractType",contractType.getCode()); | |||
| variables.put("contractNumber", String.valueOf(contractId)); | |||
| map.put("variables", variables); | |||
| List<Map> variablesList = new ArrayList<Map>(); | |||
| Map contractTypeMap = new HashMap<String,Object>(); | |||
| contractTypeMap.put("key","contractType"); | |||
| contractTypeMap.put("value",String.valueOf(contractType.getCode())); | |||
| variablesList.add(contractTypeMap); | |||
| Map contractNumberMap = new HashMap<String,Object>(); | |||
| contractNumberMap.put("key","contractNumber"); | |||
| contractNumberMap.put("value", String.valueOf(contractId)); | |||
| variablesList.add(contractNumberMap); | |||
| map.put("variables", variablesList); | |||
| return map; | |||
| } | |||
| protected boolean rentContractHasWorkFlow(WxRentContract wxRentContract) { | |||
| WxFlowModel wxFlowModel = new WxFlowModel(); | |||
| if (wxRentContract.getRentShopType().intValue() == EnumRentShopType.SHOP.getCode().intValue()) { | |||
| wxFlowModel.setFlowType(EnumFlowContractType.RENT.getCode()); | |||
| }else if (wxRentContract.getRentShopType().intValue() == EnumRentShopType.POINT.getCode().intValue()) { | |||
| wxFlowModel.setFlowType(EnumFlowContractType.RENT_POINT.getCode()); | |||
| } | |||
| wxFlowModel.updateTenantInfo(wxRentContract); | |||
| List<WxFlowModel> flows = wxFlowService.getModelBybusiness(wxFlowModel); | |||
| if (null != flows && flows.size() > 0) { | |||
| return true; | |||
| } | |||
| return false; | |||
| } | |||
| protected boolean propertyContractHasWorkFlow(WxPropertyContract wxPropertyContract) { | |||
| WxFlowModel wxFlowModel = new WxFlowModel(); | |||
| if (wxPropertyContract.getRentShopType().intValue() == EnumRentShopType.SHOP.getCode().intValue()) { | |||
| wxFlowModel.setFlowType(EnumFlowContractType.PROPERTY.getCode()); | |||
| }else if (wxPropertyContract.getRentShopType().intValue() == EnumRentShopType.POINT.getCode().intValue()) { | |||
| wxFlowModel.setFlowType(EnumFlowContractType.PROPERTY_POINT.getCode()); | |||
| } | |||
| wxFlowModel.updateTenantInfo(wxPropertyContract); | |||
| List<WxFlowModel> flows = wxFlowService.getModelBybusiness(wxFlowModel); | |||
| if (null != flows && flows.size() > 0) { | |||
| return true; | |||
| } | |||
| return false; | |||
| } | |||
| } | |||
| @@ -2,6 +2,7 @@ package com.iformall.controller.contract; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.annotation.UserDataRuleAnnotation; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| @@ -9,10 +10,14 @@ import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxBillProperty; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxPropertyContract; | |||
| import com.iformall.domain.po.WxRentContract; | |||
| import com.iformall.enums.EnumContractType; | |||
| import com.iformall.enums.EnumFlowContractType; | |||
| import com.iformall.enums.EnumFlowKey; | |||
| import com.iformall.enums.EnumIsPreview; | |||
| import com.iformall.enums.EnumRentContractAppStatus; | |||
| import com.iformall.enums.EnumRentContractStatus; | |||
| import com.iformall.enums.EnumRentShopType; | |||
| import com.iformall.enums.EnumRentStartType; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.WxPropertyContractMapper; | |||
| @@ -28,6 +33,8 @@ import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @@ -53,7 +60,6 @@ public class WxPropertyContractController extends WxContractBaseController { | |||
| @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 list(@ModelAttribute WxPropertyContract wxPropertyContract, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxPropertyContractController::list"); | |||
| if (null == wxPropertyContract) { | |||
| @@ -102,19 +108,9 @@ public class WxPropertyContractController extends WxContractBaseController { | |||
| return wxPropertyContractService.saveOrUpdate(wxPropertyContract, user.getId(), user.getName()); | |||
| } | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "物业合同-删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxPropertyContractController::delete"); | |||
| wxPropertyContractService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "物业合同-根据ID查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxPropertyContractController::findById"); | |||
| WxBillProperty wxBillProperty = new WxBillProperty(); | |||
| @@ -128,6 +124,106 @@ public class WxPropertyContractController extends WxContractBaseController { | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } | |||
| } | |||
| /** | |||
| * 作废 | |||
| * @param wxRentContract | |||
| * @return | |||
| */ | |||
| @GetMapping("/unvalid") | |||
| @SystemControllerLog(description = "物业合同-作废合同") | |||
| public ResultData unvalid(@ModelAttribute WxPropertyContract proertyContract) { | |||
| WxPropertyContract contract = wxPropertyContractService.getSimpleDetail(proertyContract.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.getApplyStatus().intValue() == EnumRentContractAppStatus.SETBACK.getCode().intValue()))) { | |||
| contract.setStatus(EnumRentContractStatus.INVALID.getCode()); | |||
| contract.setUpdatetime(new Date()); | |||
| try { | |||
| wxPropertyContractService.updatePropertyContract(contract); | |||
| return new ResultData(contract); | |||
| }catch(Exception e) { | |||
| logger.error(" WxPropertyContract unvalid error.",e); | |||
| return new ResultData(Result.ERROR,"系统错误"); | |||
| } | |||
| }else { | |||
| return new ResultData(Result.ERROR, "合同状态不允许作废.只能作废草稿或者履约拒绝的合同。"); | |||
| } | |||
| } | |||
| /** | |||
| * 终止 | |||
| * @param id | |||
| * @param status | |||
| * @return | |||
| */ | |||
| @PostMapping("endContract") | |||
| @SystemControllerLog(description = "物业合同-终止合同") | |||
| public ResultData endContract(@RequestBody WxPropertyContract proertyContract) { | |||
| proertyContract.updateTenantInfo(getTenantInfo()); | |||
| wxPropertyContractService.endContract(proertyContract); | |||
| return new ResultData(proertyContract); | |||
| } | |||
| @GetMapping("effective") | |||
| @ApiImplicitParams({}) | |||
| @SystemControllerLog(description = "物业合同-合同生效") | |||
| public ResultData effective(@ModelAttribute WxPropertyContract proertyContract) { | |||
| WxPropertyContract contract = wxPropertyContractService.getSimpleDetail(proertyContract.getId()); | |||
| if (null == contract) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"物业合同不存在"); | |||
| } | |||
| //查询是否有审批流程 | |||
| if(propertyContractHasWorkFlow(contract)) { | |||
| return new ResultData(ErrorCode.FLOW_FAIL.getCode(),"物业合同存在工作流,不允许直接生效。"); | |||
| } | |||
| if (contract.getStatus().intValue() != EnumRentContractStatus.DRAFT.getCode().intValue()) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"租赁合同状态为草稿才能进行此操作"); | |||
| } | |||
| wxPropertyContractService.updatePropertyContractStatus(proertyContract.getId()); | |||
| return new ResultData(Result.SUCCESS,"合同生效成功!"); | |||
| } | |||
| @PostMapping("apply") | |||
| @SystemControllerLog(description = "物业合同-提交审批") | |||
| public ResultData apply(@ModelAttribute WxPropertyContract proertyContract) { | |||
| MallUserInfo user = getUser(); | |||
| WxPropertyContract contract = wxPropertyContractService.getSimpleDetail(proertyContract.getId()); | |||
| if (null == contract) { | |||
| return new ResultData(Result.ERROR, "编号["+contract.getId()+"]未找到租金合同"); | |||
| } | |||
| //查询是否有审批流程 | |||
| if(propertyContractHasWorkFlow(contract)) { | |||
| return new ResultData(ErrorCode.FLOW_FAIL.getCode(),"租赁合同存在工作流,不允许直接生效。"); | |||
| } | |||
| if (contract.getRentShopType().intValue() == EnumRentShopType.SHOP.getCode().intValue()) { | |||
| contract.setFlowParams(generateFlowParams(EnumFlowKey.NEW_PRO_CONTRACT, EnumFlowContractType.PROPERTY, contract.getRemark(), contract.getId())); | |||
| }else if (contract.getRentShopType().intValue() == EnumRentShopType.POINT.getCode().intValue()) { | |||
| contract.setFlowParams(generateFlowParams(EnumFlowKey.NEW_PRO_POINT_CONTRACT, EnumFlowContractType.PROPERTY_POINT, contract.getRemark(), contract.getId())); | |||
| } | |||
| return wxPropertyContractService.apply(contract,user); | |||
| } | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "物业合同-删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxPropertyContractController::delete"); | |||
| wxPropertyContractService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @RequestMapping("/download") | |||
| @SystemControllerLog(description = "物业合同-下载") | |||
| @@ -144,14 +240,6 @@ public class WxPropertyContractController extends WxContractBaseController { | |||
| // return new ResultData(Result.SUCCESS, "查询成功", wxPropertyContractService.getRentContractStatusInfo(wxPropertyContract)); | |||
| // } | |||
| @GetMapping("/endPropertyContract") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "物业合同-终止") | |||
| public ResultData endRentContract(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxPropertyContractController::endRentContract"); | |||
| return wxPropertyContractService.endRentContract(id); | |||
| } | |||
| // @GetMapping("/getRentContractList") | |||
| // @SystemControllerLog(description = "物业合同-查询列表") | |||
| // public ResultData getRentContractList(@ModelAttribute WxPropertyContract wxPropertyContract) { | |||
| @@ -184,15 +272,6 @@ public class WxPropertyContractController extends WxContractBaseController { | |||
| return wxPropertyContractService.updatePropertyContractStatus(wxPropertyContract.getId()); | |||
| } | |||
| @PostMapping("endContract") | |||
| @SystemControllerLog(description = "物业合同-终止合同") | |||
| public ResultData endContract(@RequestBody WxPropertyContract wxPropertyContract) { | |||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::endContract"); | |||
| wxPropertyContract.updateTenantInfo(getTenantInfo()); | |||
| wxPropertyContractService.endContract(wxPropertyContract); | |||
| return new ResultData(); | |||
| } | |||
| /** | |||
| * 预览账单展示,编辑账期,后端生成账单金额 | |||
| * @param wxPropertyContract | |||
| @@ -210,12 +289,5 @@ public class WxPropertyContractController extends WxContractBaseController { | |||
| List<WxBillProperty> result = wxPropertyContractService.buildProperty(new WxMerchant(),getUserId(),dbRent, EnumIsPreview.YES.getCode(), false); | |||
| return new ResultData(result); | |||
| } | |||
| @PostMapping("apply") | |||
| @SystemControllerLog(description = "物业合同-提交审批") | |||
| public ResultData apply(@RequestBody WxPropertyContract wxPropertyContract) { | |||
| MallUserInfo user = getUser(); | |||
| wxPropertyContract.setFlowParams(generateFlowParams(EnumFlowKey.NEW_PRO_CONTRACT, EnumFlowContractType.PROPERTY, wxPropertyContract.getRemark(), wxPropertyContract.getId())); | |||
| return wxPropertyContractService.apply(wxPropertyContract, user); | |||
| } | |||
| } | |||
| @@ -16,6 +16,7 @@ import com.iformall.enums.EnumFromType; | |||
| import com.iformall.enums.EnumIsPreview; | |||
| import com.iformall.enums.EnumRentContractAppStatus; | |||
| import com.iformall.enums.EnumRentContractStatus; | |||
| import com.iformall.enums.EnumRentShopType; | |||
| import com.iformall.enums.EnumRentStartType; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.WxBillPropertyMapper; | |||
| @@ -71,14 +72,12 @@ public class WxRentContractController extends WxContractBaseController { | |||
| @Autowired | |||
| private WxShopService wxShopService; | |||
| @UserDataRuleAnnotation("rent_contract_list") | |||
| @GetMapping("/list") | |||
| @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 list(@ModelAttribute WxRentContract wxRentContract, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::list"); | |||
| if (null == wxRentContract) { | |||
| @@ -111,7 +110,6 @@ public class WxRentContractController extends WxContractBaseController { | |||
| // } | |||
| MallUserInfo user = getUser(); | |||
| wxRentContract.updateTenantInfo(user); | |||
| //wxRentContract.setTenantId("789"); | |||
| wxRentContract.setAdjustPeriodHandle(); | |||
| Date oldDate = wxRentContract.getRentalStartDate(); | |||
| if(wxRentContract.getRentStartType()!=null &&wxRentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){ | |||
| @@ -170,7 +168,6 @@ public class WxRentContractController extends WxContractBaseController { | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "租赁合同-查找") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::findById"); | |||
| // 同步欠缴状态 | |||
| @@ -199,7 +196,8 @@ public class WxRentContractController extends WxContractBaseController { | |||
| if (cure.getStatus().intValue() == EnumRentContractStatus.DRAFT.getCode().intValue() || | |||
| (cure.getStatus().intValue() == EnumRentContractStatus.PERFORMANCE.getCode().intValue() | |||
| && cure.getApplyStatus().intValue()== EnumRentContractAppStatus.REJECT.getCode().intValue())) { | |||
| && (cure.getApplyStatus().intValue()== EnumRentContractAppStatus.REJECT.getCode().intValue() || | |||
| cure.getApplyStatus().intValue()== EnumRentContractAppStatus.SETBACK.getCode().intValue()))) { | |||
| if(StringUtils.isBlank(rentContract.getBusDiscountRatio())){ | |||
| rentContract.setBusDiscountTime(new Integer(0)); | |||
| } | |||
| @@ -233,7 +231,6 @@ public class WxRentContractController extends WxContractBaseController { | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "merchantId", value = "merchantId", dataType = "Long", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "contractId", value = "contractId", dataType = "Long", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "租赁合同-终结合同") | |||
| public ResultData merchantShops(Long merchantId,Long contractId) { | |||
| List<Long> shopList = wxMerchantService.getMerchantShopIds(merchantId); | |||
| @@ -292,13 +289,12 @@ public class WxRentContractController extends WxContractBaseController { | |||
| } | |||
| /** | |||
| * 一个商户只能存在一个续签合同。如果有计租中的,则取计租中最新的一条,如果没有计租中的,则取正常到期最近的一条 | |||
| * 查询商户计租中的合同 | |||
| * @param wxRentContract | |||
| * @return | |||
| */ | |||
| @GetMapping("getXuQianRentContract") | |||
| @ApiImplicitParams({}) | |||
| @SystemControllerLog(description = "查询续签合同") | |||
| public ResultData getRentContractList(@ModelAttribute WxRentContract wxRentContract) { | |||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::getRentContractList"); | |||
| wxRentContract.updateTenantInfo(getTenantInfo()); | |||
| @@ -332,16 +328,16 @@ public class WxRentContractController extends WxContractBaseController { | |||
| * @return | |||
| */ | |||
| @GetMapping("/unvalid") | |||
| @SystemControllerLog(description = "作废合同") | |||
| @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.getApplyStatus().intValue() == EnumRentContractAppStatus.REJECT.getCode().intValue() || | |||
| contract.getApplyStatus().intValue() == EnumRentContractAppStatus.SETBACK.getCode().intValue()))) { | |||
| contract.setStatus(EnumRentContractStatus.INVALID.getCode()); | |||
| contract.setUpdatetime(new Date()); | |||
| return wxRentContractService.updateRentContract(contract); | |||
| @@ -387,12 +383,58 @@ public class WxRentContractController extends WxContractBaseController { | |||
| } | |||
| @GetMapping("effective") | |||
| @ApiImplicitParams({}) | |||
| @SystemControllerLog(description = "租金合同-合同生效") | |||
| public ResultData effective(@ModelAttribute WxRentContract wxRentContract) { | |||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::getRentContractList"); | |||
| WxRentContract contract = wxRentContractService.getSimpleDeatil(wxRentContract.getId()); | |||
| if (null == contract) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"租赁合同不存在"); | |||
| } | |||
| //查询是否有审批流程 | |||
| if(rentContractHasWorkFlow(contract)) { | |||
| return new ResultData(ErrorCode.FLOW_FAIL.getCode(),"租赁合同存在工作流,不允许直接生效。"); | |||
| } | |||
| if (contract.getStatus().intValue() != EnumRentContractStatus.DRAFT.getCode().intValue()) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"租赁合同状态为草稿才能进行此操作"); | |||
| } | |||
| //店铺是否存在其他有效合同里面 | |||
| boolean result = wxRentContractService.hasOtherValidContractShop(contract); | |||
| if (result) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"店铺已经在其他计租中或者已签约未到期的合同里面了。"); | |||
| } | |||
| wxRentContractService.updateRentContractStatus(wxRentContract.getId()); | |||
| return new ResultData(Result.SUCCESS,"合同生效成功!"); | |||
| } | |||
| @PostMapping("apply") | |||
| @SystemControllerLog(description = "租赁合同-提交审批") | |||
| public ResultData apply(@ModelAttribute WxRentContract wxRentContract) { | |||
| MallUserInfo user = getUser(); | |||
| WxRentContract rentContract = wxRentContractMapper.selectById(wxRentContract.getId()); | |||
| if (null == rentContract) { | |||
| return new ResultData(Result.ERROR, "编号["+wxRentContract.getId()+"]未找到租金合同"); | |||
| } | |||
| //查询是否有审批流程 | |||
| if(rentContractHasWorkFlow(rentContract)) { | |||
| return new ResultData(ErrorCode.FLOW_FAIL.getCode(),"租赁合同存在工作流,不允许直接生效。"); | |||
| } | |||
| if (rentContract.getRentShopType().intValue() == EnumRentShopType.SHOP.getCode().intValue()) { | |||
| rentContract.setFlowParams(generateFlowParams(EnumFlowKey.NEW_RENT_CONTRACT, EnumFlowContractType.RENT, wxRentContract.getRemark(), wxRentContract.getId())); | |||
| }else if (rentContract.getRentShopType().intValue() == EnumRentShopType.POINT.getCode().intValue()) { | |||
| rentContract.setFlowParams(generateFlowParams(EnumFlowKey.NEW_SHOP_CONTRACT, EnumFlowContractType.RENT_POINT, wxRentContract.getRemark(), wxRentContract.getId())); | |||
| } | |||
| return wxRentContractService.apply(rentContract,user); | |||
| } | |||
| @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(); | |||
| @@ -426,7 +468,6 @@ public class WxRentContractController extends WxContractBaseController { | |||
| @GetMapping("/hasRentStatus") | |||
| @SystemControllerLog(description = "查询店铺租赁状态") | |||
| public ResultData hasRentStatus(@ModelAttribute WxRentContract wxRentContract) { | |||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::hasRentStatus"); | |||
| wxRentContract.updateTenantInfo(getTenantInfo()); | |||
| @@ -434,7 +475,6 @@ public class WxRentContractController extends WxContractBaseController { | |||
| } | |||
| @GetMapping("/hasContractNumber") | |||
| @SystemControllerLog(description = "租赁合同-检查合同编号是否存在") | |||
| public ResultData hasContractNumber(@ModelAttribute WxRentContract wxRentContract) { | |||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::hasContractNumber"); | |||
| wxRentContract.updateTenantInfo(getTenantInfo()); | |||
| @@ -442,7 +482,6 @@ public class WxRentContractController extends WxContractBaseController { | |||
| } | |||
| @GetMapping("getMerchantList") | |||
| @SystemControllerLog(description = "获取商户列表") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "shopType", value = "店铺类型 1:店铺 2:多经点位", dataType = "Integer", paramType = "query", required = true)}) | |||
| public ResultData getMerchantList(Integer shopType) throws Exception{ | |||
| @@ -476,7 +515,6 @@ public class WxRentContractController extends WxContractBaseController { | |||
| * @return | |||
| */ | |||
| @PostMapping("buildBillPriceList") | |||
| @SystemControllerLog(description = "租赁合同-生成账单列表金额") | |||
| public ResultData buildBillPriceList(@RequestBody WxRentContract wxRentContract) throws Exception{ | |||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::buildBillPriceList"); | |||
| WxRentContract dbRent = wxRentContractMapper.selectById(wxRentContract.getId()); | |||
| @@ -599,13 +637,7 @@ public class WxRentContractController extends WxContractBaseController { | |||
| return wxRentContractService.getContractByContractNumber(wxRentContract); | |||
| } | |||
| @PostMapping("apply") | |||
| @SystemControllerLog(description = "租赁合同-提交审批") | |||
| public ResultData apply(@ModelAttribute WxRentContract wxRentContract) { | |||
| MallUserInfo user = getUser(); | |||
| wxRentContract.setFlowParams(generateFlowParams(EnumFlowKey.NEW_RENT_CONTRACT, EnumFlowContractType.RENT, wxRentContract.getRemark(), wxRentContract.getId())); | |||
| return wxRentContractService.apply(wxRentContract,user); | |||
| } | |||
| } | |||
| @@ -236,20 +236,6 @@ public class WxFlowAbleController extends BaseController { | |||
| wxFlowModel.updateTenantInfo(getTenantInfo()); | |||
| return new ResultData(wxFlowService.getModelBybusiness(wxFlowModel)); | |||
| } | |||
| @ApiOperation("业务查询是否存在模板") | |||
| @GetMapping(value = "/businessHasFlow") | |||
| @SystemControllerLog(description = "工作流-模板列表") | |||
| public Integer businessHasFlow(@ModelAttribute WxFlowModel wxFlowModel) { | |||
| logger.debug("[" + getIpAddr() + "] FlowAbleController::getModelBybusiness"); | |||
| wxFlowModel.updateTenantInfo(getTenantInfo()); | |||
| List<WxFlowModel> models = wxFlowService.getModelBybusiness(wxFlowModel); | |||
| if (null != models && models.size() > 0 ) { | |||
| return 1; | |||
| }else { | |||
| return 0; | |||
| } | |||
| } | |||
| /** | |||
| * 配置列表 | |||
| @@ -9,6 +9,9 @@ import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxPropertyContract; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @@ -55,7 +58,7 @@ public interface WxPropertyContractService { | |||
| //Object getRentContractStatusInfo(WxPropertyContract record); | |||
| ResultData endRentContract(Long id); | |||
| //ResultData endRentContract(Long id); | |||
| //Object getRentContractList(WxPropertyContract record); | |||
| @@ -81,5 +84,9 @@ public interface WxPropertyContractService { | |||
| ResultData apply(WxPropertyContract wxPropertyContract,MallUserInfo user); | |||
| void outDateContract(WxMall wxMall); | |||
| WxPropertyContract getSimpleDetail(@Param("id") Long id); | |||
| void updatePropertyContract(WxPropertyContract record); | |||
| } | |||
| @@ -112,4 +112,11 @@ public interface WxRentContractService { | |||
| WxRentContract getSimpleDeatil(Long id); | |||
| /** | |||
| * 查询合同的店铺是否已经在其他有效合同里面了 | |||
| * @param wxRentContract | |||
| * @return | |||
| */ | |||
| boolean hasOtherValidContractShop(WxRentContract wxRentContract); | |||
| } | |||
| @@ -912,31 +912,6 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| // return resultData; | |||
| // } | |||
| @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); | |||
| } | |||
| wxPropertyContract.setStatus(EnumRentContractStatus.TERMINATE.getCode()); | |||
| 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()); | |||
| } | |||
| return new ResultData(Result.SUCCESS, "操作成功"); | |||
| } | |||
| // @Override | |||
| // public Object getRentContractList(WxPropertyContract record) { | |||
| // Map<String, Object> params = new HashMap<>(); | |||
| @@ -1128,7 +1103,8 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| if ((EnumRentContractStatus.DRAFT.getCode().intValue() == rentContract.getStatus().intValue() | |||
| && EnumRentContractAppStatus.DEFAULT.getCode().intValue() == rentContract.getApplyStatus().intValue()) | |||
| || (EnumRentContractStatus.PERFORMANCE.getCode().intValue() == rentContract.getStatus().intValue() | |||
| && EnumRentContractAppStatus.REJECT.getCode().intValue() == rentContract.getApplyStatus().intValue()) | |||
| && (EnumRentContractAppStatus.REJECT.getCode().intValue() == rentContract.getApplyStatus().intValue() || | |||
| EnumRentContractAppStatus.SETBACK.getCode().intValue() == rentContract.getApplyStatus().intValue())) | |||
| ) { | |||
| Integer bussinessType = (Integer) rentContract.getFlowParams().get("businessType"); | |||
| if (null == bussinessType) { | |||
| @@ -1166,6 +1142,16 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| } | |||
| } | |||
| @Override | |||
| public WxPropertyContract getSimpleDetail(Long id) { | |||
| return wxPropertyContractMapper.selectById(id); | |||
| } | |||
| @Override | |||
| public void updatePropertyContract(WxPropertyContract record) { | |||
| wxPropertyContractMapper.updateById(record); | |||
| } | |||
| } | |||
| @@ -728,6 +728,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| Date tempDate = record.getRentalStartDate(); | |||
| record.setRentalStartDate(oldRentStartDate); | |||
| record.setShopName(shopName); | |||
| record.setStatus(wxRentContract.getStatus()); | |||
| wxRentContractMapper.updateById(record); | |||
| record.setRentalStartDate(tempDate); | |||
| } catch (Exception e) { | |||
| @@ -1111,15 +1112,15 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| int month = 12; | |||
| int divide = lease / month; | |||
| int mod = lease % month; | |||
| int[] leaseArr = new int[size]; | |||
| for (int i = 0; i < divide; i++) { | |||
| leaseArr[i] = month; | |||
| } | |||
| if (mod > 0) { | |||
| leaseArr[divide] = mod; | |||
| } | |||
| // int divide = lease / month; | |||
| // int mod = lease % month; | |||
| // int[] leaseArr = new int[size]; | |||
| // for (int i = 0; i < divide; i++) { | |||
| // leaseArr[i] = month; | |||
| // } | |||
| // if (mod > 0) { | |||
| // leaseArr[divide] = mod; | |||
| // } | |||
| int billcount = 0; | |||
| List<WxBillRent> resultList = new ArrayList<>(); | |||
| @@ -2451,44 +2452,40 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| @Override | |||
| public ResultData apply(WxRentContract wxRentContract,MallUserInfo user) { | |||
| public ResultData apply(WxRentContract rentContract,MallUserInfo user) { | |||
| //如果存在其他的草稿状态或者履约驳回状态的合同,不允许提交审批 | |||
| Integer count = wxRentContractMapper.getCanApplyCount(wxRentContract.getId()); | |||
| Integer count = wxRentContractMapper.getCanApplyCount(rentContract.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()+"]未找到租金合同"); | |||
| } | |||
| rentContract.setFlowParams(wxRentContract.getFlowParams()); | |||
| if (CollectionUtils.isEmpty(rentContract.getFlowParams())) { | |||
| return new ResultData(Result.ERROR, "编号["+wxRentContract.getId()+"]租金合同没有审批流程."); | |||
| return new ResultData(Result.ERROR, "编号["+rentContract.getId()+"]租金合同没有审批流程."); | |||
| } | |||
| if (rentContract.getMerchantId() == null) { | |||
| return new ResultData(Result.ERROR, "编号["+wxRentContract.getId()+"]租金合同没有绑定商户."); | |||
| return new ResultData(Result.ERROR, "编号["+rentContract.getId()+"]租金合同没有绑定商户."); | |||
| } | |||
| if ((EnumRentContractStatus.DRAFT.getCode().intValue() == rentContract.getStatus().intValue() | |||
| && EnumRentContractAppStatus.DEFAULT.getCode().intValue() == rentContract.getApplyStatus().intValue()) | |||
| || (EnumRentContractStatus.PERFORMANCE.getCode().intValue() == rentContract.getStatus().intValue() | |||
| && EnumRentContractAppStatus.REJECT.getCode().intValue() == rentContract.getApplyStatus().intValue()) | |||
| && (EnumRentContractAppStatus.REJECT.getCode().intValue() == rentContract.getApplyStatus().intValue() || | |||
| EnumRentContractAppStatus.SETBACK.getCode().intValue() == rentContract.getApplyStatus().intValue())) | |||
| ) { | |||
| Integer bussinessType = (Integer) rentContract.getFlowParams().get("businessType"); | |||
| if (null == bussinessType) { | |||
| return new ResultData(Result.ERROR, "编号["+wxRentContract.getId()+"]租金合同FlowParams错误,未找到businessType."); | |||
| return new ResultData(Result.ERROR, "编号["+rentContract.getId()+"]租金合同FlowParams错误,未找到businessType."); | |||
| } | |||
| WxFlowModel flowModle = wxFlowService.getModelByType(bussinessType, rentContract); | |||
| if (null == flowModle) { | |||
| return new ResultData(Result.ERROR, "编号["+wxRentContract.getId()+"]租金合同配置的流程["+String.valueOf(bussinessType)+"]未找到流程模板."); | |||
| return new ResultData(Result.ERROR, "编号["+rentContract.getId()+"]租金合同配置的流程["+String.valueOf(bussinessType)+"]未找到流程模板."); | |||
| } | |||
| rentContract.getFlowParams().put("businessId", rentContract.getId().toString()); | |||
| wxFlowService.start(rentContract.getFlowParams(), user.getId(), user.getName(), rentContract); | |||
| return new ResultData(Result.SUCCESS,"提交审批成功",rentContract); | |||
| }else { | |||
| return new ResultData(Result.ERROR, "编号["+wxRentContract.getId()+"]租金合同状态不能提交审批.允许提交的状态为 [草稿+未提交审批],[履约中+审批驳回]"); | |||
| return new ResultData(Result.ERROR, "编号["+rentContract.getId()+"]租金合同状态不能提交审批.允许提交的状态为 [草稿+未提交审批],[履约中+审批驳回]"); | |||
| } | |||
| } | |||
| @@ -2550,4 +2547,27 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| public WxRentContract getSimpleDeatil(Long id) { | |||
| return wxRentContractMapper.selectById(id); | |||
| } | |||
| @Override | |||
| public boolean hasOtherValidContractShop(WxRentContract wxRentContract) { | |||
| WxRentContract wrc = new WxRentContract(); | |||
| wrc.setMerchantId(wxRentContract.getMerchantId()); | |||
| List<Integer> validstatuss = new ArrayList<Integer>(); | |||
| validstatuss.add(EnumRentContractStatus.PAING.getCode()); | |||
| validstatuss.add(EnumRentContractStatus.READY_FOR_PAING.getCode()); | |||
| wrc.setStatuss(validstatuss); | |||
| List<WxRentContract> contractList = wxRentContractMapper.findList(wrc); | |||
| boolean exists =false; | |||
| for (WxRentContract wc : contractList) { | |||
| if (null != wxRentContract.shopIdsByRentInfo()) { | |||
| for (Long sid : wxRentContract.shopIdsByRentInfo()) { | |||
| if(wc.getRentInfo().indexOf(String.valueOf(sid)) != -1 ) { | |||
| exists = true; | |||
| break; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return exists; | |||
| } | |||
| } | |||