|
|
|
@@ -461,53 +461,56 @@ public class WxMerchantServiceImpl implements WxMerchantService { |
|
|
|
wxMerchant.setUpdateDate(date); |
|
|
|
wxMerchantMapper.updateById(wxMerchant); |
|
|
|
List<Long> shopIds = wxMerchant.getShopids(); |
|
|
|
//如果原来店铺在商户里面有有效的合同,则不能操作 |
|
|
|
List<Long> oldShopIds = wxMerchantShopMapper.findShopIds(wxMerchant.getId()); |
|
|
|
List<Long> coldShopIds = new ArrayList<Long>(); |
|
|
|
if (null != oldShopIds && oldShopIds.size() > 0) { |
|
|
|
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 != shopIds && shopIds.size() > 0){ |
|
|
|
//如果原来店铺在商户里面有有效的合同,则不能操作 |
|
|
|
List<Long> oldShopIds = wxMerchantShopMapper.findShopIds(wxMerchant.getId()); |
|
|
|
List<Long> coldShopIds = new ArrayList<Long>(); |
|
|
|
if (null != oldShopIds && oldShopIds.size() > 0) { |
|
|
|
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 != shopIds) { |
|
|
|
shopIds.removeAll(coldShopIds); |
|
|
|
List<Long> currSIds = new ArrayList<Long>(); |
|
|
|
for (Long sid: shopIds) { |
|
|
|
if (!currSIds.contains(sid)) { |
|
|
|
WxMerchantShop mcs = new WxMerchantShop(); |
|
|
|
mcs.setMerchantId(wxMerchant.getId()); |
|
|
|
mcs.setShopId(sid); |
|
|
|
mcs.setIsDel(EnumDelStatus.NOT_DEL.getCode()); |
|
|
|
mcs.setId(idWorker.nextId()); |
|
|
|
mcs.updateTenantInfo(wxMerchant); |
|
|
|
Date shopdate = new Date(); |
|
|
|
mcs.setUpdateDate(shopdate); |
|
|
|
mcs.setCreateDate(shopdate); |
|
|
|
wxMerchantShopMapper.insert(mcs); |
|
|
|
//更新商铺状态 |
|
|
|
WxShop sh = wxShopMapper.selectById(sid); |
|
|
|
sh.setStatus(EnumShopStatus.RENT.getCode()); |
|
|
|
wxShopMapper.updateById(sh); |
|
|
|
currSIds.add(sid); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (null != shopIds) { |
|
|
|
shopIds.removeAll(coldShopIds); |
|
|
|
List<Long> currSIds = new ArrayList<Long>(); |
|
|
|
for (Long sid: shopIds) { |
|
|
|
if (!currSIds.contains(sid)) { |
|
|
|
WxMerchantShop mcs = new WxMerchantShop(); |
|
|
|
mcs.setMerchantId(wxMerchant.getId()); |
|
|
|
mcs.setShopId(sid); |
|
|
|
mcs.setIsDel(EnumDelStatus.NOT_DEL.getCode()); |
|
|
|
mcs.setId(idWorker.nextId()); |
|
|
|
mcs.updateTenantInfo(wxMerchant); |
|
|
|
Date shopdate = new Date(); |
|
|
|
mcs.setUpdateDate(shopdate); |
|
|
|
mcs.setCreateDate(shopdate); |
|
|
|
wxMerchantShopMapper.insert(mcs); |
|
|
|
//更新商铺状态 |
|
|
|
WxShop sh = wxShopMapper.selectById(sid); |
|
|
|
sh.setStatus(EnumShopStatus.RENT.getCode()); |
|
|
|
wxShopMapper.updateById(sh); |
|
|
|
currSIds.add(sid); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new ResultData(Result.SUCCESS, "商户更新成功"); |
|
|
|
|