| @@ -307,22 +307,24 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| if (shopidlist.isEmpty()) { | if (shopidlist.isEmpty()) { | ||||
| return new ResultData(ErrorCode.SHOP_NOT_SELECTED); | return new ResultData(ErrorCode.SHOP_NOT_SELECTED); | ||||
| } | } | ||||
| //先检查是否存在已出租的商铺 | |||||
| //更新商铺 | |||||
| for (long shopid : shopidlist) { | for (long shopid : shopidlist) { | ||||
| WxShop shop = wxShopMapper.selectByPrimaryKey(shopid); | WxShop shop = wxShopMapper.selectByPrimaryKey(shopid); | ||||
| if (shop.getStatus().equals(EnumShopStatus.RENT.getCode())) { | if (shop.getStatus().equals(EnumShopStatus.RENT.getCode())) { | ||||
| return new ResultData(ErrorCode.SHOP_IS_RENT.getCode(), "店铺 " + shop.getShopNumber() + " 已出租"); | return new ResultData(ErrorCode.SHOP_IS_RENT.getCode(), "店铺 " + shop.getShopNumber() + " 已出租"); | ||||
| } | } | ||||
| } | |||||
| //更新商铺 | |||||
| for (long shopid : shopidlist) { | |||||
| WxMerchantShop wxMerchantShop = new WxMerchantShop(); | |||||
| wxMerchantShop.setShopId(shopid); | |||||
| wxMerchantShop.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | |||||
| int count = wxMerchantShopMapper.selectCount(wxMerchantShop); | |||||
| if (count > 0) { | |||||
| return new ResultData(ErrorCode.SHOP_IS_RENT.getCode(), "店铺 " + shop.getShopNumber() + " 已出租"); | |||||
| } | |||||
| //更新商铺状态 | //更新商铺状态 | ||||
| WxShop shop = new WxShop(); | |||||
| shop.setId(shopid); | |||||
| shop.setStatus(EnumShopStatus.RENT.getCode()); | shop.setStatus(EnumShopStatus.RENT.getCode()); | ||||
| wxShopMapper.updateByPrimaryKeySelective(shop); | wxShopMapper.updateByPrimaryKeySelective(shop); | ||||
| //关联表插入 | //关联表插入 | ||||
| WxMerchantShop wxMerchantShop = new WxMerchantShop(); | |||||
| wxMerchantShop.setId(idWorker.nextId()); | wxMerchantShop.setId(idWorker.nextId()); | ||||
| wxMerchantShop.setMerchantId(merchantId); | wxMerchantShop.setMerchantId(merchantId); | ||||
| wxMerchantShop.setTenantId(wxMerchant.getTenantId()); | wxMerchantShop.setTenantId(wxMerchant.getTenantId()); | ||||
| @@ -376,7 +378,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| return new ResultData(Result.SUCCESS, "商户创建成功", merchantId); | return new ResultData(Result.SUCCESS, "商户创建成功", merchantId); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("db failed: 商户创建失败, e:" + e.getMessage()); | logger.error("db failed: 商户创建失败, e:" + e.getMessage()); | ||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "商户创建失败"); | |||||
| } | } | ||||
| } | } | ||||