| @@ -45,18 +45,22 @@ public class ContractSchedule { | |||||
| //如果店铺没有有效合同,则释放店铺,不停用商户 | //如果店铺没有有效合同,则释放店铺,不停用商户 | ||||
| List<WxMall> wxMalls = wxMallMapper.findList(null); | List<WxMall> wxMalls = wxMallMapper.findList(null); | ||||
| for (WxMall wxMall : wxMalls) { | for (WxMall wxMall : wxMalls) { | ||||
| TenantEntity tenantEntity = wxMall.getTenantInfo(); | |||||
| WxRentContract wxRentContract = new WxRentContract(); | |||||
| wxRentContract.updateTenantInfo(tenantEntity); | |||||
| wxRentContractService.outDateContract(wxRentContract); | |||||
| try { | |||||
| //租金合同 | |||||
| wxRentContractService.outDateContract(wxMall); | |||||
| }catch(Exception e) { | |||||
| log.error("rentcontract outDate error.",e); | |||||
| } | |||||
| try { | |||||
| //物业合同 | |||||
| wxPropertyContractService.outDateContract(wxMall); | |||||
| }catch(Exception e) { | |||||
| log.error("propertycontract outDate error.",e); | |||||
| } | |||||
| } | } | ||||
| // log.info("合同状态更新开始"); | // log.info("合同状态更新开始"); | ||||
| // List<WxMall> wxMalls = wxMallMapper.findList(null); | // List<WxMall> wxMalls = wxMallMapper.findList(null); | ||||
| // for (WxMall wxMall : wxMalls) { | // for (WxMall wxMall : wxMalls) { | ||||
| @@ -13,7 +13,7 @@ public interface WxMerchantShopMapper extends CommonMapper<WxMerchantShop, Strin | |||||
| List<Long> findShopIds(@Param("merchantId") Long merchantId); | List<Long> findShopIds(@Param("merchantId") Long merchantId); | ||||
| void delShops(@Param("merchantId") Long merchantId,@Param("shopList") List<Long> shopIds); | |||||
| } | } | ||||
| @@ -82,4 +82,6 @@ public interface WxRentContractMapper extends CommonMapper<WxRentContract, Long> | |||||
| List<WxRentContract> getContractByMerchant(WxRentContract wxRentContract); | List<WxRentContract> getContractByMerchant(WxRentContract wxRentContract); | ||||
| Integer getCanApplyCount(@Param("id") Long id); | Integer getCanApplyCount(@Param("id") Long id); | ||||
| List<Long> getMerchantIdsByStatuss(WxRentContract wxRentContract); | |||||
| } | } | ||||
| @@ -4,6 +4,7 @@ import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.MallUserInfo; | import com.iformall.domain.po.MallUserInfo; | ||||
| import com.iformall.domain.po.WxBillProperty; | import com.iformall.domain.po.WxBillProperty; | ||||
| import com.iformall.domain.po.WxBillRent; | import com.iformall.domain.po.WxBillRent; | ||||
| import com.iformall.domain.po.WxMall; | |||||
| import com.iformall.domain.po.WxMerchant; | import com.iformall.domain.po.WxMerchant; | ||||
| import com.iformall.domain.po.WxPropertyContract; | import com.iformall.domain.po.WxPropertyContract; | ||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| @@ -78,5 +79,7 @@ public interface WxPropertyContractService { | |||||
| WxPropertyContract getByBill(WxBillProperty billRent); | WxPropertyContract getByBill(WxBillProperty billRent); | ||||
| ResultData apply(WxPropertyContract wxPropertyContract,MallUserInfo user); | ResultData apply(WxPropertyContract wxPropertyContract,MallUserInfo user); | ||||
| void outDateContract(WxMall wxMall); | |||||
| } | } | ||||
| @@ -110,7 +110,7 @@ public interface WxRentContractService { | |||||
| * 合同正常到期 | * 合同正常到期 | ||||
| * @param wxRentContract | * @param wxRentContract | ||||
| */ | */ | ||||
| void outDateContract(WxRentContract wxRentContract); | |||||
| void outDateContract(WxMall wxMall); | |||||
| WxRentContract getSimpleDeatil(Long id); | WxRentContract getSimpleDeatil(Long id); | ||||
| @@ -1144,6 +1144,28 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| return new ResultData(Result.ERROR, "编号["+record.getId()+"]物业合同状态不能提交审批.允许提交的状态为 [草稿+未提交审批],[履约中+审批驳回]"); | return new ResultData(Result.ERROR, "编号["+record.getId()+"]物业合同状态不能提交审批.允许提交的状态为 [草稿+未提交审批],[履约中+审批驳回]"); | ||||
| } | } | ||||
| } | } | ||||
| @Override | |||||
| public void outDateContract(WxMall wxMall) { | |||||
| //查询有计租合同的商户 | |||||
| WxPropertyContract wr = new WxPropertyContract(); | |||||
| List<Integer> statuss = new ArrayList<Integer>(); | |||||
| statuss.add(EnumRentContractStatus.PAING.getCode()); | |||||
| wr.setStatuss(statuss); | |||||
| List<WxPropertyContract> contractList = wxPropertyContractMapper.findList(wr); | |||||
| for (WxPropertyContract contract: contractList) { | |||||
| try { | |||||
| if (contract.getRentalEndDate().before(new Date())) { | |||||
| contract.setStatus(EnumRentContractStatus.OUT_DATE.getCode()); | |||||
| wxPropertyContractMapper.updateById(contract); | |||||
| } | |||||
| }catch(Exception e) { | |||||
| logger.error("WxPropertyContract["+contract.getId()+"] outDateContract error.",e); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -2502,35 +2502,59 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void outDateContract(WxRentContract wxRentContract) { | |||||
| //只有计租中的合同状态才能正常到期 | |||||
| if (wxRentContract.getStatus().intValue()== EnumRentContractStatus.PAING.getCode().intValue()) { | |||||
| if (wxRentContract.getRentalEndDate().before(new Date())) { | |||||
| wxRentContract.setStatus(EnumRentContractStatus.OUT_DATE.getCode()); | |||||
| //wxRentContractMapper.updateRentContractEndStatus(wxRentContract); | |||||
| //TODO 11111111111111111111 | |||||
| public void outDateContract(WxMall wxMall) { | |||||
| //查询有计租合同的商户 | |||||
| WxRentContract wr = new WxRentContract(); | |||||
| List<Integer> statuss = new ArrayList<Integer>(); | |||||
| statuss.add(EnumRentContractStatus.PAING.getCode()); | |||||
| wr.setStatuss(statuss); | |||||
| List<Long> merchantIds = wxRentContractMapper.getMerchantIdsByStatuss(wr); | |||||
| for (Long mid: merchantIds) { | |||||
| try { | |||||
| //查询商户下计租到期的合同,更新合同状态 | |||||
| WxRentContract wrc = new WxRentContract(); | |||||
| wrc.setMerchantId(mid); | |||||
| wrc.setStatus(EnumRentContractStatus.PAING.getCode()); | |||||
| List<WxRentContract> contractList = wxRentContractMapper.findList(wrc); | |||||
| List<Long> shopIdList = new ArrayList<Long>(); | |||||
| for (WxRentContract contract:contractList) { | |||||
| if (contract.getRentalEndDate().before(new Date())) { | |||||
| contract.setStatus(EnumRentContractStatus.OUT_DATE.getCode()); | |||||
| wxRentContractMapper.updateById(contract); | |||||
| List<Long> shopIds = contract.shopIdsByRentInfo(); | |||||
| for (Long sid: shopIds) { | |||||
| if (!shopIdList.contains(sid)) { | |||||
| shopIdList.add(sid); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| //到期合同中的店铺,如果存在有效合同,则不释放 | |||||
| if (shopIdList.size() > 0 ) { | |||||
| WxRentContract wrcq = new WxRentContract(); | |||||
| wrcq.setMerchantId(mid); | |||||
| wrcq.setStatus(EnumRentContractStatus.PAING.getCode()); | |||||
| List<WxRentContract> contractList0 = wxRentContractMapper.findList(wrc); | |||||
| for (WxRentContract w : contractList0) { | |||||
| List<Long> shopids0 = w.shopIdsByRentInfo(); | |||||
| if (null != shopids0) { | |||||
| shopIdList.removeAll(shopids0); | |||||
| } | |||||
| } | |||||
| } | |||||
| //释放店铺 | |||||
| if (null != shopIdList && shopIdList.size() > 0) { | |||||
| wxMerchantShopMapper.delShops(mid, shopIdList); | |||||
| } | |||||
| }catch(Exception e) { | |||||
| logger.error("merchantId["+mid+"] outDateContract error.",e); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| private void contractEnd(String tenantId) { | |||||
| //查询状态为合同正常到期的数据 | |||||
| WxRentContract wxRentContract = new WxRentContract(); | |||||
| wxRentContract.setTenantId(tenantId); | |||||
| wxRentContract.setStatus(EnumRentContractStatus.OUT_DATE.getCode()); | |||||
| // List<Map<String, Object>> rentContractData = wxRentContractMapper.queryRentContractData(wxRentContract); | |||||
| // for (int i = 0, size = rentContractData.size(); i < size; i++) { | |||||
| // Map<String, Object> contract = rentContractData.get(i); | |||||
| // Object merchantId = contract.get("merchantId"); | |||||
| // if (merchantId != null) { | |||||
| // WxMerchant merchant = wxMerchantMapper.selectById((Long) merchantId); | |||||
| // Integer status = merchant.getStatus(); | |||||
| // if (status.equals(EnumMerchantStatus.VALID.getCode())) { | |||||
| // wxMerchantService.disableMerchat((Long) merchantId); | |||||
| // } | |||||
| // } | |||||
| // } | |||||
| } | |||||
| @Override | @Override | ||||
| public WxRentContract getSimpleDeatil(Long id) { | public WxRentContract getSimpleDeatil(Long id) { | ||||
| return wxRentContractMapper.selectById(id); | return wxRentContractMapper.selectById(id); | ||||
| @@ -75,7 +75,13 @@ | |||||
| select shop_id from wx_merchant_shop where `merchant_id` = #{merchantId} and is_del = 0 | select shop_id from wx_merchant_shop where `merchant_id` = #{merchantId} and is_del = 0 | ||||
| </select> | </select> | ||||
| <update id = "delShops" parameterType="java.util.Map"> | |||||
| update wx_merchant_shop set is_del = 1 where merchant_id = #{merchantId} | |||||
| and shop_id in | |||||
| <foreach collection="shopList" index="index" item="shopItem" open="(" separator="," close=")"> | |||||
| #{shopItem} | |||||
| </foreach> | |||||
| </update> | |||||
| </mapper> | </mapper> | ||||
| @@ -675,6 +675,17 @@ | |||||
| <select id="getCanApplyCount" resultType="Integer" parameterType="Long"> | <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 count(1) from wx_rent_contract where id != #{id} and (status=1 or (status=10 and apply_status=3) ) | ||||
| </select> | </select> | ||||
| <select id="getMerchantIdsByStatuss" resultType="Long" parameterType="com.iformall.domain.po.WxRentContract"> | |||||
| select distinct merchant_id from wx_rent_contract where and `tenant_id` = #{tenantId} | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| and status in | |||||
| <foreach collection="statuss" index="index" item="statusItem" open="(" separator="," close=")"> | |||||
| #{statusItem} | |||||
| </foreach> | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||