| @@ -15,7 +15,7 @@ public interface WxMerchantShopMapper extends CommonMapper<WxMerchantShop, Strin | |||||
| void delShops(@Param("merchantId") Long merchantId,@Param("shopList") List<Long> shopIds); | void delShops(@Param("merchantId") Long merchantId,@Param("shopList") List<Long> shopIds); | ||||
| void realDelByMerchantId(@Param("merchantId") Long merchantId); | |||||
| void realDelByMerchantId(@Param("merchantId") Long merchantId,@Param("shopList") List<Long> shopIds); | |||||
| } | } | ||||
| @@ -463,26 +463,30 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| List<Long> shopIds = wxMerchant.getShopids(); | List<Long> shopIds = wxMerchant.getShopids(); | ||||
| //如果原来店铺在商户里面有有效的合同,则不能操作 | //如果原来店铺在商户里面有有效的合同,则不能操作 | ||||
| List<Long> oldShopIds = wxMerchantShopMapper.findShopIds(wxMerchant.getId()); | List<Long> oldShopIds = wxMerchantShopMapper.findShopIds(wxMerchant.getId()); | ||||
| List<Long> coldShopIds = new ArrayList<Long>(); | |||||
| if (null != oldShopIds && oldShopIds.size() > 0) { | if (null != oldShopIds && oldShopIds.size() > 0) { | ||||
| for (Long osid : oldShopIds) { | |||||
| WxRentContract wrc = new WxRentContract(); | |||||
| wrc.setMerchantId(wxMerchant.getId()); | |||||
| wrc.setQueryShopId(osid); | |||||
| wrc.setStatuss(EnumRentContractStatus.getValidStatus()); | |||||
| wrc.updateTenantInfo(wxMerchant); | |||||
| List<WxRentContract> clist = wxRentContractService.findList(wrc); | |||||
| if (null != clist && clist.size() > 0 ) { | |||||
| return new ResultData(ErrorCode.MERCHANT_HASRENTCONTRACT.getCode(),"店铺["+osid+"]存在有效的合同,不能解除绑定."); | |||||
| } | |||||
| } | |||||
| coldShopIds.addAll(oldShopIds); | |||||
| oldShopIds.removeAll(shopIds); | |||||
| if (null != oldShopIds && oldShopIds.size() > 0 ) { | |||||
| for (Long osid : oldShopIds) { | |||||
| WxRentContract wrc = new WxRentContract(); | |||||
| wrc.setMerchantId(wxMerchant.getId()); | |||||
| wrc.setQueryShopId(osid); | |||||
| wrc.setStatuss(EnumRentContractStatus.getValidStatus()); | |||||
| wrc.updateTenantInfo(wxMerchant); | |||||
| List<WxRentContract> clist = wxRentContractService.findList(wrc); | |||||
| if (null != clist && clist.size() > 0 ) { | |||||
| return new ResultData(ErrorCode.MERCHANT_HASRENTCONTRACT.getCode(),"店铺["+osid+"]存在有效的合同,不能解除绑定."); | |||||
| } | |||||
| } | |||||
| //都验证过了之后,先把之前的商铺释放,删除关系 | |||||
| wxShopMapper.updateUnRentByIds(oldShopIds); | |||||
| wxMerchantShopMapper.realDelByMerchantId(wxMerchant.getId(),oldShopIds); | |||||
| } | |||||
| } | } | ||||
| //都验证过了之后,先把之前的商铺释放,删除关系 | |||||
| if (null != oldShopIds && oldShopIds.size() > 0 ) { | |||||
| wxShopMapper.updateUnRentByIds(oldShopIds); | |||||
| } | |||||
| wxMerchantShopMapper.realDelByMerchantId(wxMerchant.getId()); | |||||
| if (null != shopIds) { | if (null != shopIds) { | ||||
| shopIds.removeAll(coldShopIds); | |||||
| List<Long> currSIds = new ArrayList<Long>(); | List<Long> currSIds = new ArrayList<Long>(); | ||||
| for (Long sid: shopIds) { | for (Long sid: shopIds) { | ||||
| if (!currSIds.contains(sid)) { | if (!currSIds.contains(sid)) { | ||||
| @@ -2462,7 +2462,17 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| wrq.setStatus(EnumRentContractStatus.PERFORMANCE.getCode()); | wrq.setStatus(EnumRentContractStatus.PERFORMANCE.getCode()); | ||||
| List<WxRentContract> clist = wxRentContractMapper.findList(wrq); | List<WxRentContract> clist = wxRentContractMapper.findList(wrq); | ||||
| if (null != clist && clist.size() > 0 ) { | if (null != clist && clist.size() > 0 ) { | ||||
| return new ResultData(Result.ERROR, "当前存在其他审批中的合同。请先作完成。"); | |||||
| return new ResultData(Result.ERROR, "当前存在其他审批中的租金合同。请先作完成。"); | |||||
| } | |||||
| //如果该合同是租金+物业合同,则还要判断物业合同 | |||||
| if(rentContract.getOperationType().intValue() == EnumContractOperationType.WHOLE.getCode().intValue()) { | |||||
| WxPropertyContract wpc = new WxPropertyContract(); | |||||
| wpc.updateTenantInfo(user); | |||||
| wpc.setStatus(EnumRentContractStatus.PERFORMANCE.getCode()); | |||||
| List<WxPropertyContract> plist = wxPropertyContractMapper.findList(wpc); | |||||
| if (null != plist && plist.size() > 0 ) { | |||||
| return new ResultData(Result.ERROR, "当前存在其他审批中的物业合同。请先作完成。"); | |||||
| } | |||||
| } | } | ||||
| // Integer count = wxRentContractMapper.getCanApplyCount(rentContract.getId()); | // Integer count = wxRentContractMapper.getCanApplyCount(rentContract.getId()); | ||||
| // if (null != count && count.intValue()>0) { | // if (null != count && count.intValue()>0) { | ||||
| @@ -83,8 +83,11 @@ | |||||
| </foreach> | </foreach> | ||||
| </update> | </update> | ||||
| <delete id="realDelByMerchantId" parameterType="Long"> | |||||
| delete from wx_merchant_shop where merchant_id = #{merchantId} | |||||
| <delete id="realDelByMerchantId" parameterType="java.util.Map"> | |||||
| delete from wx_merchant_shop where merchant_id = #{merchantId} and shop_id in | |||||
| <foreach collection="shopList" index="index" item="shopItem" open="(" separator="," close=")"> | |||||
| #{shopItem} | |||||
| </foreach> | |||||
| </delete> | </delete> | ||||