|
|
|
@@ -269,28 +269,30 @@ public class WxMerchantServiceImpl implements WxMerchantService { |
|
|
|
long merchantId = idWorker.nextId(); |
|
|
|
//保存商户商铺的关联 |
|
|
|
List<Long> shopidlist = wxMerchant.getShopids(); |
|
|
|
if(null!=shopidlist && !shopidlist.isEmpty()){ |
|
|
|
Long shopid = shopidlist.get(0); |
|
|
|
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); |
|
|
|
} |
|
|
|
//更新商铺状态 |
|
|
|
WxShop wxShop = new WxShop(); |
|
|
|
wxShop.setTenantId(wxMerchant.getTenantId()); |
|
|
|
wxShop.setId(shopid); |
|
|
|
//已出租 |
|
|
|
if (!shopidlist.isEmpty()) { |
|
|
|
return new ResultData(ErrorCode.SHOP_NOT_SELECTED); |
|
|
|
} |
|
|
|
//先检查是否存在已出租的商铺 |
|
|
|
List<WxShop> rentShopList = new ArrayList<>(); |
|
|
|
for (long shopid : shopidlist) { |
|
|
|
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); |
|
|
|
rentShopList.add(shop); |
|
|
|
} |
|
|
|
} |
|
|
|
//已出租的商铺 |
|
|
|
if (!rentShopList.isEmpty()) { |
|
|
|
return new ResultData(ErrorCode.SHOP_IS_RENT, rentShopList); |
|
|
|
} |
|
|
|
//更新商铺 |
|
|
|
for (long shopid : shopidlist) { |
|
|
|
//更新商铺状态 |
|
|
|
WxShop shop = new WxShop(); |
|
|
|
shop.setId(shopid); |
|
|
|
shop.setStatus(EnumShopStatus.RENT.getCode()); |
|
|
|
wxShopMapper.updateByPrimaryKeySelective(shop); |
|
|
|
//关联表插入 |
|
|
|
WxMerchantShop wxMerchantShop = new WxMerchantShop(); |
|
|
|
wxMerchantShop.setId(idWorker.nextId()); |
|
|
|
wxMerchantShop.setMerchantId(merchantId); |
|
|
|
wxMerchantShop.setTenantId(wxMerchant.getTenantId()); |
|
|
|
@@ -298,8 +300,6 @@ public class WxMerchantServiceImpl implements WxMerchantService { |
|
|
|
wxMerchantShop.setUpdateDate(shopdate); |
|
|
|
wxMerchantShop.setCreateDate(shopdate); |
|
|
|
wxMerchantShopMapper.insertSelective(wxMerchantShop); |
|
|
|
wxShop.setStatus(EnumShopStatus.RENT.getCode()); |
|
|
|
wxShopMapper.updateByPrimaryKeySelective(wxShop); |
|
|
|
} |
|
|
|
|
|
|
|
wxMerchant.setId(merchantId); |
|
|
|
@@ -351,17 +351,6 @@ public class WxMerchantServiceImpl implements WxMerchantService { |
|
|
|
if (wxMerchant.getId() == null) { |
|
|
|
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); |
|
|
|
} |
|
|
|
|
|
|
|
//更新商户商铺关联表 |
|
|
|
WxMerchantShop wxMerchantShopQuery = new WxMerchantShop(); |
|
|
|
wxMerchantShopQuery.setTenantId(wxMerchant.getTenantId()); |
|
|
|
wxMerchantShopQuery.setMerchantId(wxMerchant.getId()); |
|
|
|
wxMerchantShopQuery.setIsDel(EnumDelStatus.NOT_DEL.getCode()); |
|
|
|
List<WxMerchantShop> wxMerchantShopList = wxMerchantShopMapper.findList(wxMerchantShopQuery); |
|
|
|
WxMerchantShop wxMerchantShop = wxMerchantShopList.get(0); |
|
|
|
wxMerchantShop.setUpdateDate(new Date()); |
|
|
|
wxMerchantShopMapper.updateByPrimaryKeySelective(wxMerchantShop); |
|
|
|
|
|
|
|
//更新商户 |
|
|
|
Date date = new Date(); |
|
|
|
wxMerchant.setUpdateDate(date); |
|
|
|
|