|  | @@ -10,7 +10,6 @@ import org.jeecg.common.exception.JeecgBootException;
 | 
	
		
			
				|  |  |  import org.jeecg.common.system.vo.LoginUser;
 | 
	
		
			
				|  |  |  import org.jeecg.modules.system.app.dto.*;
 | 
	
		
			
				|  |  |  import org.jeecg.modules.system.app.entity.AppSite;
 | 
	
		
			
				|  |  | -import org.jeecg.modules.system.app.entity.AppSitePriceRules;
 | 
	
		
			
				|  |  |  import org.jeecg.modules.system.app.mapper.AppSiteMapper;
 | 
	
		
			
				|  |  |  import org.jeecg.modules.system.app.mapper.AppSitePriceRulesMapper;
 | 
	
		
			
				|  |  |  import org.jeecg.modules.system.app.service.IAppSiteService;
 | 
	
	
		
			
				|  | @@ -21,9 +20,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
	
		
			
				|  |  |  import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import javax.annotation.Resource;
 | 
	
		
			
				|  |  | -import java.math.BigDecimal;
 | 
	
		
			
				|  |  | -import java.util.ArrayList;
 | 
	
		
			
				|  |  | -import java.util.List;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import static org.jeecg.common.constant.CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -35,144 +31,91 @@ import static org.jeecg.common.constant.CommonConstant.SC_INTERNAL_SERVER_ERROR_
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  @Service
 | 
	
		
			
				|  |  |  public class AppSiteServiceImpl extends ServiceImpl<AppSiteMapper, AppSite> implements IAppSiteService {
 | 
	
		
			
				|  |  | -//    @Resource
 | 
	
		
			
				|  |  | -//    private AppSitePriceRulesMapper priceRulesMapper;
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//    @Override
 | 
	
		
			
				|  |  | -//    @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | -//    public Boolean saveWitchPriceRules(AppSiteCuDTO appSiteDTO) {
 | 
	
		
			
				|  |  | -//        if (null == appSiteDTO.getType()) throw new JeecgBootException("商户类型不能为空", SC_INTERNAL_SERVER_ERROR_500);
 | 
	
		
			
				|  |  | -//        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 | 
	
		
			
				|  |  | -//        AppSite site = new AppSite();
 | 
	
		
			
				|  |  | -//        BeanUtils.copyProperties(siteCuDTO, site);
 | 
	
		
			
				|  |  | -//        site.setOrgCode(sysUser.getOrgCode());//部门默认登录用户部门
 | 
	
		
			
				|  |  | -//        site.setTenantId(sysUser.getOrgId());
 | 
	
		
			
				|  |  | -//        int saveSiteResult = baseMapper.insert(site);
 | 
	
		
			
				|  |  | -//        // 如果插入失败,抛出自定义异常提示“场地信息保存失败”
 | 
	
		
			
				|  |  | -//        if (saveSiteResult < 1) {
 | 
	
		
			
				|  |  | -//            throw new JeecgBootException("场地信息保存失败", SC_INTERNAL_SERVER_ERROR_500);
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -////        // 获取价格规则列表
 | 
	
		
			
				|  |  | -////        List<AppSiteRuleDTO> priceRulesList = appSiteDTO.getPriceRulesList();
 | 
	
		
			
				|  |  | -////        for (AppSiteRuleDTO rule : priceRulesList) {
 | 
	
		
			
				|  |  | -////            if (rule.getSellingPrice().compareTo(BigDecimal.ZERO)<=0)throw new JeecgBootException("保存失败:价格不能为0", SC_INTERNAL_SERVER_ERROR_500);
 | 
	
		
			
				|  |  | -////            // 设置当前规则对应的场地 ID
 | 
	
		
			
				|  |  | -////            AppSitePriceRules appSitePriceRules = new AppSitePriceRules();
 | 
	
		
			
				|  |  | -////            BeanUtils.copyProperties(rule, appSitePriceRules);
 | 
	
		
			
				|  |  | -////            appSitePriceRules.setSiteId(site.getId());
 | 
	
		
			
				|  |  | -////            appSitePriceRules.setOrgCode(site.getOrgCode());
 | 
	
		
			
				|  |  | -////            appSitePriceRules.setTenantId(site.getTenantId());
 | 
	
		
			
				|  |  | -////            // 调用 priceRulesMapper 插入价格规则
 | 
	
		
			
				|  |  | -////            int savePriceResult = priceRulesMapper.insert(appSitePriceRules);
 | 
	
		
			
				|  |  | -////            // 如果插入失败,抛出自定义异常提示“场地价格规则保存失败”
 | 
	
		
			
				|  |  | -////            if (savePriceResult < 1) {
 | 
	
		
			
				|  |  | -////                throw new JeecgBootException("场地价格规则保存失败", SC_INTERNAL_SERVER_ERROR_500);
 | 
	
		
			
				|  |  | -////            }
 | 
	
		
			
				|  |  | -////        }
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//        // 所有操作成功完成后返回 true
 | 
	
		
			
				|  |  | -//        return Boolean.TRUE;
 | 
	
		
			
				|  |  | -//    }
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//    @Override
 | 
	
		
			
				|  |  | -//    @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | -//    public Boolean editWitchPriceRules(AppSiteDTO appSiteDTO) {
 | 
	
		
			
				|  |  | -//        AppSiteCuDTO siteCuDTO = appSiteDTO.getSite();
 | 
	
		
			
				|  |  | -//        AppSite site = new AppSite();
 | 
	
		
			
				|  |  | -//        BeanUtils.copyProperties(siteCuDTO, site);
 | 
	
		
			
				|  |  | -//        if (null == site.getType()) throw new JeecgBootException("场地类型不能为空", SC_INTERNAL_SERVER_ERROR_500);
 | 
	
		
			
				|  |  | -//        AppSite dbSite = baseMapper.selectById(site.getId());
 | 
	
		
			
				|  |  | -//        if (null==dbSite) throw new JeecgBootException("未找到对应数据", SC_INTERNAL_SERVER_ERROR_500);
 | 
	
		
			
				|  |  | -//        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 | 
	
		
			
				|  |  | -////        checkPermission(dbSite,sysUser);
 | 
	
		
			
				|  |  | -//        site.setOrgCode(sysUser.getOrgCode());//部门默认登录用户部门
 | 
	
		
			
				|  |  | -//        site.setTenantId(sysUser.getOrgId());
 | 
	
		
			
				|  |  | -//        int updateSiteResult = baseMapper.updateById(site);
 | 
	
		
			
				|  |  | -//        if (updateSiteResult < 1) {
 | 
	
		
			
				|  |  | -//            throw new JeecgBootException("场地信息保存失败", SC_INTERNAL_SERVER_ERROR_500);
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//        List<AppSiteRuleDTO> priceRulesList = appSiteDTO.getPriceRulesList();
 | 
	
		
			
				|  |  | -//        for (AppSiteRuleDTO rule : priceRulesList) {
 | 
	
		
			
				|  |  | -//            AppSitePriceRules appSitePriceRules = new AppSitePriceRules();
 | 
	
		
			
				|  |  | -//            BeanUtils.copyProperties(rule, appSitePriceRules);
 | 
	
		
			
				|  |  | -//            appSitePriceRules.setSiteId(site.getId());
 | 
	
		
			
				|  |  | -//            appSitePriceRules.setOrgCode(site.getOrgCode());
 | 
	
		
			
				|  |  | -//            appSitePriceRules.setTenantId(site.getTenantId());
 | 
	
		
			
				|  |  | -//            int savePriceResult = priceRulesMapper.updateById(appSitePriceRules); // 保证每个操作都在事务中
 | 
	
		
			
				|  |  | -//            if (savePriceResult < 1) {
 | 
	
		
			
				|  |  | -//                throw new JeecgBootException("场地价格规则保存失败", SC_INTERNAL_SERVER_ERROR_500);
 | 
	
		
			
				|  |  | -//            }
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//        return Boolean.TRUE;
 | 
	
		
			
				|  |  | -//    }
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//    @Override
 | 
	
		
			
				|  |  | -//    public AppSiteDTO queryWitchPriceRulesById(String id) {
 | 
	
		
			
				|  |  | -//        AppSite dbSite = baseMapper.selectById(id);
 | 
	
		
			
				|  |  | -//        if (null==dbSite) throw new JeecgBootException("未找到对应数据", SC_INTERNAL_SERVER_ERROR_500);
 | 
	
		
			
				|  |  | -//        AppSiteCuDTO appSiteCuDTO = new AppSiteCuDTO();
 | 
	
		
			
				|  |  | -//        BeanUtils.copyProperties(dbSite, appSiteCuDTO);
 | 
	
		
			
				|  |  | -//        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 | 
	
		
			
				|  |  | -////        checkPermission(dbSite,sysUser);
 | 
	
		
			
				|  |  | -//        List<AppSitePriceRules> priceRulesList = priceRulesMapper.selectList(Wrappers.<AppSitePriceRules>lambdaQuery().eq(AppSitePriceRules::getSiteId, id));
 | 
	
		
			
				|  |  | -//        List<AppSiteRuleDTO> priceRulesDTOList = new ArrayList<>();
 | 
	
		
			
				|  |  | -//        priceRulesList.forEach(rule-> {
 | 
	
		
			
				|  |  | -//            AppSiteRuleDTO appSiteRuleDTO = new AppSiteRuleDTO();
 | 
	
		
			
				|  |  | -//            BeanUtils.copyProperties(rule, appSiteRuleDTO);
 | 
	
		
			
				|  |  | -//            priceRulesDTOList.add(appSiteRuleDTO);
 | 
	
		
			
				|  |  | -//        });
 | 
	
		
			
				|  |  | -//        return new AppSiteDTO(appSiteCuDTO,priceRulesDTOList);
 | 
	
		
			
				|  |  | -//    }
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//    @Override
 | 
	
		
			
				|  |  | -//    @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | -//    public Boolean deleteWitchPriceRulesById(String id) {
 | 
	
		
			
				|  |  | -//        AppSite dbSite = baseMapper.selectById(id);
 | 
	
		
			
				|  |  | -//        if (null==dbSite) throw new JeecgBootException("未找到对应数据", SC_INTERNAL_SERVER_ERROR_500);
 | 
	
		
			
				|  |  | -//        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 | 
	
		
			
				|  |  | -////        checkPermission(dbSite,sysUser);
 | 
	
		
			
				|  |  | -//        int deleteSiteResult = baseMapper.deleteById(id);
 | 
	
		
			
				|  |  | -//        if (deleteSiteResult>0){
 | 
	
		
			
				|  |  | -//            int deletePriceResult = priceRulesMapper.delete(Wrappers.<AppSitePriceRules>lambdaQuery().eq(AppSitePriceRules::getSiteId, id));
 | 
	
		
			
				|  |  | -//            if (deletePriceResult<1) throw new JeecgBootException("场地价格规则删除失败", SC_INTERNAL_SERVER_ERROR_500);
 | 
	
		
			
				|  |  | -//        }else{
 | 
	
		
			
				|  |  | -//            throw new JeecgBootException("场地信息删除失败", SC_INTERNAL_SERVER_ERROR_500);
 | 
	
		
			
				|  |  | -//        }
 | 
	
		
			
				|  |  | -//        return Boolean.TRUE;
 | 
	
		
			
				|  |  | -//    }
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//    @Override
 | 
	
		
			
				|  |  | -//    public IPage<AppSiteDTO> queryWitchPriceRulesPage(AppSitePageDTO dto) {
 | 
	
		
			
				|  |  | -//        Page<AppSite> page = new Page<>(dto.getPageNum(), dto.getPageSize());
 | 
	
		
			
				|  |  | -//        LambdaQueryWrapper<AppSite> wrapper = Wrappers.<AppSite>lambdaQuery()
 | 
	
		
			
				|  |  | -//                .like(StringUtils.isNotBlank(dto.getName()), AppSite::getName, dto.getName());
 | 
	
		
			
				|  |  | -//        IPage<AppSite> resultPage = baseMapper.selectPage(page, wrapper);
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//        return resultPage.convert(record -> {
 | 
	
		
			
				|  |  | -//            AppSiteCuDTO cuDTO = new AppSiteCuDTO();
 | 
	
		
			
				|  |  | -//            BeanUtils.copyProperties(record, cuDTO);
 | 
	
		
			
				|  |  | -//            List<AppSitePriceRules> priceRulesList = priceRulesMapper.selectList(
 | 
	
		
			
				|  |  | -//                    Wrappers.<AppSitePriceRules>lambdaQuery().eq(AppSitePriceRules::getSiteId, record.getId()));
 | 
	
		
			
				|  |  | -//            List<AppSiteRuleDTO> priceRulesDTOList = new ArrayList<>();
 | 
	
		
			
				|  |  | -//            priceRulesList.forEach(rule-> {
 | 
	
		
			
				|  |  | -//                AppSiteRuleDTO appSiteRuleDTO = new AppSiteRuleDTO();
 | 
	
		
			
				|  |  | -//                BeanUtils.copyProperties(rule, appSiteRuleDTO);
 | 
	
		
			
				|  |  | -//                priceRulesDTOList.add(appSiteRuleDTO);
 | 
	
		
			
				|  |  | -//            });
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//            return new AppSiteDTO(cuDTO, priceRulesDTOList);
 | 
	
		
			
				|  |  | -//        });
 | 
	
		
			
				|  |  | -//    }
 | 
	
		
			
				|  |  | -//
 | 
	
		
			
				|  |  | -//    /**
 | 
	
		
			
				|  |  | -//     * 权限校验
 | 
	
		
			
				|  |  | -//     * @param site
 | 
	
		
			
				|  |  | -//     * @param sysUser
 | 
	
		
			
				|  |  | -//     */
 | 
	
		
			
				|  |  | -//    private void checkPermission(AppSite site,LoginUser sysUser ){
 | 
	
		
			
				|  |  | -//        if (!sysUser.getOrgCode().equals(site.getOrgCode())) throw new JeecgBootException("无权限操作", SC_INTERNAL_SERVER_ERROR_500);
 | 
	
		
			
				|  |  | -//    }
 | 
	
		
			
				|  |  | +    @Resource
 | 
	
		
			
				|  |  | +    private AppSitePriceRulesMapper priceRulesMapper;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | +    public Boolean saveWitchPriceRules(AppSiteDTO siteCuDTO) {
 | 
	
		
			
				|  |  | +        if (null == siteCuDTO.getType()) throw new JeecgBootException("商户类型不能为空", SC_INTERNAL_SERVER_ERROR_500);
 | 
	
		
			
				|  |  | +        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 | 
	
		
			
				|  |  | +        AppSite site = new AppSite();
 | 
	
		
			
				|  |  | +        BeanUtils.copyProperties(siteCuDTO, site);
 | 
	
		
			
				|  |  | +        site.setOrgCode(sysUser.getOrgCode());//部门默认登录用户部门
 | 
	
		
			
				|  |  | +        site.setTenantId(sysUser.getOrgId());
 | 
	
		
			
				|  |  | +        int saveSiteResult = baseMapper.insert(site);
 | 
	
		
			
				|  |  | +        // 如果插入失败,抛出自定义异常提示“场地信息保存失败”
 | 
	
		
			
				|  |  | +        if (saveSiteResult < 1) {
 | 
	
		
			
				|  |  | +            throw new JeecgBootException("场地信息保存失败", SC_INTERNAL_SERVER_ERROR_500);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        // 所有操作成功完成后返回 true
 | 
	
		
			
				|  |  | +        return Boolean.TRUE;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | +    public Boolean editWitchPriceRules(AppSiteDTO siteCuDTO) {
 | 
	
		
			
				|  |  | +        AppSite site = new AppSite();
 | 
	
		
			
				|  |  | +        BeanUtils.copyProperties(siteCuDTO, site);
 | 
	
		
			
				|  |  | +        if (null == site.getType()) throw new JeecgBootException("场地类型不能为空", SC_INTERNAL_SERVER_ERROR_500);
 | 
	
		
			
				|  |  | +        AppSite dbSite = baseMapper.selectById(site.getId());
 | 
	
		
			
				|  |  | +        if (null==dbSite) throw new JeecgBootException("未找到对应数据", SC_INTERNAL_SERVER_ERROR_500);
 | 
	
		
			
				|  |  | +        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 | 
	
		
			
				|  |  | +//        checkPermission(dbSite,sysUser);
 | 
	
		
			
				|  |  | +        site.setOrgCode(sysUser.getOrgCode());//部门默认登录用户部门
 | 
	
		
			
				|  |  | +        site.setTenantId(sysUser.getOrgId());
 | 
	
		
			
				|  |  | +        int updateSiteResult = baseMapper.updateById(site);
 | 
	
		
			
				|  |  | +        if (updateSiteResult < 1) {
 | 
	
		
			
				|  |  | +            throw new JeecgBootException("场地信息保存失败", SC_INTERNAL_SERVER_ERROR_500);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return Boolean.TRUE;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public AppSiteDTO queryWitchPriceRulesById(String id) {
 | 
	
		
			
				|  |  | +        AppSite dbSite = baseMapper.selectById(id);
 | 
	
		
			
				|  |  | +        if (null==dbSite) throw new JeecgBootException("未找到对应数据", SC_INTERNAL_SERVER_ERROR_500);
 | 
	
		
			
				|  |  | +        AppSiteDTO appSiteDTO = new AppSiteDTO();
 | 
	
		
			
				|  |  | +        BeanUtils.copyProperties(dbSite, appSiteDTO);
 | 
	
		
			
				|  |  | +        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 | 
	
		
			
				|  |  | +//        checkPermission(dbSite,sysUser);
 | 
	
		
			
				|  |  | +        return appSiteDTO;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | +    public Boolean deleteWitchPriceRulesById(String id) {
 | 
	
		
			
				|  |  | +        AppSite dbSite = baseMapper.selectById(id);
 | 
	
		
			
				|  |  | +        if (null==dbSite) throw new JeecgBootException("未找到对应数据", SC_INTERNAL_SERVER_ERROR_500);
 | 
	
		
			
				|  |  | +        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 | 
	
		
			
				|  |  | +//        checkPermission(dbSite,sysUser);
 | 
	
		
			
				|  |  | +        int deleteSiteResult = baseMapper.deleteById(id);
 | 
	
		
			
				|  |  | +        if (deleteSiteResult<1){
 | 
	
		
			
				|  |  | +            throw new JeecgBootException("商户信息删除失败", SC_INTERNAL_SERVER_ERROR_500);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return Boolean.TRUE;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public IPage<AppSiteDTO> queryWitchPriceRulesPage(AppSitePageDTO dto) {
 | 
	
		
			
				|  |  | +        Page<AppSite> page = new Page<>(dto.getPageNum(), dto.getPageSize());
 | 
	
		
			
				|  |  | +        LambdaQueryWrapper<AppSite> wrapper = Wrappers.<AppSite>lambdaQuery()
 | 
	
		
			
				|  |  | +                .like(StringUtils.isNotBlank(dto.getName()), AppSite::getName, dto.getName());
 | 
	
		
			
				|  |  | +        IPage<AppSite> resultPage = baseMapper.selectPage(page, wrapper);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        return resultPage.convert(record -> {
 | 
	
		
			
				|  |  | +            AppSiteDTO cuDTO = new AppSiteDTO();
 | 
	
		
			
				|  |  | +            BeanUtils.copyProperties(record, cuDTO);
 | 
	
		
			
				|  |  | +            return cuDTO;
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 权限校验
 | 
	
		
			
				|  |  | +     * @param site
 | 
	
		
			
				|  |  | +     * @param sysUser
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private void checkPermission(AppSite site,LoginUser sysUser ){
 | 
	
		
			
				|  |  | +        if (!sysUser.getOrgCode().equals(site.getOrgCode())) throw new JeecgBootException("无权限操作", SC_INTERNAL_SERVER_ERROR_500);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |