| @@ -326,55 +326,16 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); | return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); | ||||
| } | } | ||||
| //删除当前商户关联的所有商铺然后再插入 | |||||
| //更新商户商铺关联表 | |||||
| WxMerchantShop wxMerchantShopQuery = new WxMerchantShop(); | WxMerchantShop wxMerchantShopQuery = new WxMerchantShop(); | ||||
| wxMerchantShopQuery.setTenantId(wxMerchant.getTenantId()); | wxMerchantShopQuery.setTenantId(wxMerchant.getTenantId()); | ||||
| wxMerchantShopQuery.setMerchantId(wxMerchant.getId()); | wxMerchantShopQuery.setMerchantId(wxMerchant.getId()); | ||||
| wxMerchantShopQuery.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | wxMerchantShopQuery.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | ||||
| List<WxMerchantShop> wxMerchantShopList = wxMerchantShopMapper.findList(wxMerchantShopQuery); | List<WxMerchantShop> wxMerchantShopList = wxMerchantShopMapper.findList(wxMerchantShopQuery); | ||||
| for (WxMerchantShop merchantShop : wxMerchantShopList) { | |||||
| merchantShop.setIsDel(EnumDelStatus.DEL.getCode()); | |||||
| wxMerchantShopMapper.updateByPrimaryKeySelective(merchantShop); | |||||
| //更新商铺状态 | |||||
| WxShop wxShop = new WxShop(); | |||||
| wxShop.setId(merchantShop.getShopId()); | |||||
| wxShop.setStatus(EnumShopStatus.NOT_RENT.getCode()); | |||||
| wxShopMapper.updateByPrimaryKeySelective(wxShop); | |||||
| } | |||||
| //保存商户商铺的关联 | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| List<Long> shopidlist = wxMerchant.getShopids(); | |||||
| for (Long shopid : shopidlist) { | |||||
| WxMerchantShop wxMerchantShop = new WxMerchantShop(); | |||||
| wxMerchantShop.setTenantId(wxMerchant.getTenantId()); | |||||
| wxMerchantShop.setShopId(shopid); | |||||
| wxMerchantShop.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | |||||
| long count = wxMerchantShopMapper.findList(wxMerchantShop).size(); | |||||
| if(count>0){ | |||||
| return new ResultData(ErrorCode.SHOP_IS_RENT); | |||||
| } | |||||
| WxMerchantShop wxMerchantShop = wxMerchantShopList.get(0); | |||||
| wxMerchantShop.setUpdateDate(new Date()); | |||||
| wxMerchantShopMapper.updateByPrimaryKeySelective(wxMerchantShop); | |||||
| WxShop shop = wxShopMapper.selectByPrimaryKey(shopid); | |||||
| if (shop == null) { | |||||
| return new ResultData(ErrorCode.SHOP_IS_NOT_FOUND); | |||||
| } | |||||
| if (shop.getStatus().equals(EnumShopStatus.RENT.getCode())) { | |||||
| return new ResultData(ErrorCode.SHOP_IS_RENT); | |||||
| } | |||||
| wxMerchantShop.setId(idWorker.nextId()); | |||||
| wxMerchantShop.setMerchantId(wxMerchant.getId()); | |||||
| Date shopdate = new Date(); | |||||
| wxMerchantShop.setUpdateDate(shopdate); | |||||
| wxMerchantShop.setCreateDate(shopdate); | |||||
| wxMerchantShop.setRentalStartDate(wxMerchant.getRentalStartDate()); | |||||
| wxMerchantShop.setRentalEndDate(wxMerchant.getRentalEndDate()); | |||||
| //更新商铺状态 | |||||
| WxShop wxShop = new WxShop(); | |||||
| wxShop.setId(shopid); | |||||
| wxShop.setStatus(EnumShopStatus.RENT.getCode()); | |||||
| wxMerchantShopMapper.insertSelective(wxMerchantShop); | |||||
| wxShopMapper.updateByPrimaryKeySelective(wxShop); | |||||
| } | |||||
| //更新商户 | //更新商户 | ||||
| Date date = new Date(); | Date date = new Date(); | ||||
| wxMerchant.setUpdateDate(date); | wxMerchant.setUpdateDate(date); | ||||