|
|
|
@@ -1,13 +1,16 @@ |
|
|
|
package com.iformall.service.impl; |
|
|
|
|
|
|
|
import java.io.*; |
|
|
|
import java.util.*; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import com.iformall.common.ErrorCode; |
|
|
|
import com.iformall.common.IdWorker; |
|
|
|
import com.iformall.common.Result; |
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.domain.po.WxMerchantShop; |
|
|
|
import com.iformall.domain.po.WxShop; |
|
|
|
import com.iformall.enums.*; |
|
|
|
import com.iformall.exception.MallinkException; |
|
|
|
import com.iformall.mapper.WxMerchantShopMapper; |
|
|
|
import com.iformall.mapper.WxShopMapper; |
|
|
|
import com.iformall.service.WxShopService; |
|
|
|
import com.iformall.utils.Constant; |
|
|
|
@@ -21,9 +24,12 @@ import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import com.iformall.common.IdWorker; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.File; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class WxShopServiceImpl implements WxShopService { |
|
|
|
@@ -32,6 +38,9 @@ public class WxShopServiceImpl implements WxShopService { |
|
|
|
@Autowired |
|
|
|
WxShopMapper wxShopMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxMerchantShopMapper wxMerchantShopMapper; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageInfo<WxShop> listAsPage(WxShop record, Integer pageIndex, Integer pageSize) { |
|
|
|
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxShopMapper.findList(record)); |
|
|
|
@@ -69,7 +78,20 @@ public class WxShopServiceImpl implements WxShopService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void deleteById(Long id) { |
|
|
|
public void deleteById(Long id, Integer isAdmin) { |
|
|
|
//1、已出租不让删除 |
|
|
|
WxShop wxShop = wxShopMapper.selectByPrimaryKey(id); |
|
|
|
if (wxShop.getStatus().equals(EnumShopStatus.RENT.getCode())) { |
|
|
|
throw new MallinkException(ErrorCode.SHOP_BAN_DELETED); |
|
|
|
} |
|
|
|
//2、是否关联过商户 |
|
|
|
WxMerchantShop wxMerchantShop = new WxMerchantShop(); |
|
|
|
wxMerchantShop.setShopId(wxShop.getId()); |
|
|
|
int count = wxMerchantShopMapper.selectCount(wxMerchantShop); |
|
|
|
//有关联过商户必须是管理员才能删除 |
|
|
|
if (count > 0 && !isAdmin.equals(EnumUserAdmin.ADMIN.getCode())) { |
|
|
|
throw new MallinkException(ErrorCode.SHOP_DELETED_BY_ADMIN); |
|
|
|
} |
|
|
|
wxShopMapper.deleteByPrimaryKey(id); |
|
|
|
} |
|
|
|
|
|
|
|
|