|
@@ -8,13 +8,10 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
|
-import org.jeecg.modules.system.app.dto.AppSitePlaceCuDTO;
|
|
|
-import org.jeecg.modules.system.app.dto.AppSitePlaceDTO;
|
|
|
-import org.jeecg.modules.system.app.dto.AppSitePlacePageDTO;
|
|
|
-import org.jeecg.modules.system.app.dto.AppSiteRuleDTO;
|
|
|
-import org.jeecg.modules.system.app.entity.AppSite;
|
|
|
+import org.jeecg.modules.system.app.dto.*;
|
|
|
import org.jeecg.modules.system.app.entity.AppSitePlace;
|
|
|
import org.jeecg.modules.system.app.entity.AppSitePriceRules;
|
|
|
+import org.jeecg.modules.system.app.enums.SitePlaceTypeEnum;
|
|
|
import org.jeecg.modules.system.app.mapper.AppSitePlaceMapper;
|
|
|
import org.jeecg.modules.system.app.mapper.AppSitePriceRulesMapper;
|
|
|
import org.jeecg.modules.system.app.service.IAppSitePlaceService;
|
|
@@ -27,7 +24,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
-import java.util.stream.Stream;
|
|
|
|
|
|
import static org.jeecg.common.constant.CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
|
|
|
|
|
@@ -42,6 +38,8 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
|
|
|
@Resource
|
|
|
private AppSitePriceRulesMapper appSitePriceRulesMapper;
|
|
|
|
|
|
+ //学校 包场 一对多
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean saveWitchPriceRules(AppSitePlaceDTO placeDTO) {
|
|
@@ -177,9 +175,10 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
|
|
|
|
|
|
@Override
|
|
|
public IPage<AppSitePlaceCuDTO> queryWitchPriceRulesPage(AppSitePlacePageDTO dto) {
|
|
|
+ if (null==dto.getType()) throw new JeecgBootException("请选择类型", SC_INTERNAL_SERVER_ERROR_500);
|
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
Page<AppSitePlace> page = new Page<>(dto.getPageNum(), dto.getPageSize());
|
|
|
- LambdaQueryWrapper<AppSitePlace> wrapper = Wrappers.<AppSitePlace>lambdaQuery()
|
|
|
+ LambdaQueryWrapper<AppSitePlace> wrapper = Wrappers.<AppSitePlace>lambdaQuery().eq(AppSitePlace::getType, dto.getType())
|
|
|
.like(StringUtils.isNotBlank(dto.getName()), AppSitePlace::getName, dto.getName());
|
|
|
// .eq(AppSitePlace::getOrgCode, loginUser.getOrgCode());
|
|
|
IPage<AppSitePlace> resultPage = baseMapper.selectPage(page, wrapper);
|
|
@@ -190,6 +189,100 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+// 无固定场
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean addUnfixed(AppSitePlaceUnfixedDTO unsetDTO) {
|
|
|
+ if (null==unsetDTO.getSiteId()) throw new JeecgBootException("请选择商户门店", SC_INTERNAL_SERVER_ERROR_500);
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ AppSitePlace appSitePlace = new AppSitePlace();
|
|
|
+ BeanUtils.copyProperties(unsetDTO, appSitePlace);
|
|
|
+ appSitePlace.setType(SitePlaceTypeEnum.UNFIXED.getCode());
|
|
|
+ appSitePlace.setOrgCode(sysUser.getOrgCode());
|
|
|
+ appSitePlace.setTenantId(sysUser.getOrgId());
|
|
|
+ int insert = baseMapper.insert(appSitePlace);
|
|
|
+ if (insert < 1) throw new JeecgBootException("无固定场添加失败", SC_INTERNAL_SERVER_ERROR_500);
|
|
|
+ AppSitePriceRules appSitePriceRules = new AppSitePriceRules();
|
|
|
+ appSitePriceRules.setSitePlaceId(appSitePlace.getId());
|
|
|
+ appSitePriceRules.setOrgCode(appSitePlace.getOrgCode());
|
|
|
+ appSitePriceRules.setTenantId(appSitePlace.getTenantId());
|
|
|
+ int insert1 = appSitePriceRulesMapper.insert(appSitePriceRules);
|
|
|
+ if (insert1 < 1) throw new JeecgBootException("无固定场价格添加失败", SC_INTERNAL_SERVER_ERROR_500);
|
|
|
+ return Boolean.TRUE;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean updateUnfixed(AppSitePlaceUnfixedDTO unsetDTO) {
|
|
|
+ if (null==unsetDTO.getSiteId()) throw new JeecgBootException("商户门店不能为空", SC_INTERNAL_SERVER_ERROR_500);
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+
|
|
|
+ AppSitePlace dbSitePlace = baseMapper.selectById(unsetDTO.getId());
|
|
|
+ if (null==dbSitePlace) throw new JeecgBootException("数据不存在", SC_INTERNAL_SERVER_ERROR_500);
|
|
|
+// checkPermission(dbSitePlace,sysUser);
|
|
|
+
|
|
|
+ AppSitePlace appSitePlace = new AppSitePlace();
|
|
|
+ BeanUtils.copyProperties(unsetDTO, appSitePlace);
|
|
|
+ //固定
|
|
|
+ appSitePlace.setType(SitePlaceTypeEnum.UNFIXED.getCode());
|
|
|
+ appSitePlace.setOrgCode(sysUser.getOrgCode());
|
|
|
+ appSitePlace.setTenantId(sysUser.getOrgId());
|
|
|
+ int updateById = baseMapper.updateById(appSitePlace);
|
|
|
+ if (updateById < 1) throw new JeecgBootException("无固定场编辑失败", SC_INTERNAL_SERVER_ERROR_500);
|
|
|
+ AppSitePriceRules appSitePriceRules = new AppSitePriceRules();
|
|
|
+ appSitePriceRules.setSitePlaceId(appSitePlace.getId());
|
|
|
+ appSitePriceRules.setOrgCode(appSitePlace.getOrgCode());
|
|
|
+ appSitePriceRules.setTenantId(appSitePlace.getTenantId());
|
|
|
+ int updateById1 = appSitePriceRulesMapper.updateById(appSitePriceRules);
|
|
|
+ if (updateById1 < 1) throw new JeecgBootException("无固定场价格编辑失败", SC_INTERNAL_SERVER_ERROR_500);
|
|
|
+ return Boolean.TRUE;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean deleteUnfixed(String id) {
|
|
|
+ AppSitePlace dbPlace = baseMapper.selectById(id);
|
|
|
+ if (null == dbPlace)throw new JeecgBootException("未找到对应数据", SC_INTERNAL_SERVER_ERROR_500);
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+// dbPlace.setUpdateBy(sysUser.getUsername());
|
|
|
+ int deleteById = baseMapper.deleteById(dbPlace);
|
|
|
+ if (deleteById < 1) throw new JeecgBootException("无固定场删除失败", SC_INTERNAL_SERVER_ERROR_500);
|
|
|
+ int deleteById1 = appSitePriceRulesMapper.delete(Wrappers.<AppSitePriceRules>lambdaQuery().eq(AppSitePriceRules::getSitePlaceId, id));
|
|
|
+ if (deleteById1 < 1) throw new JeecgBootException("固定场价格规则删除失败", SC_INTERNAL_SERVER_ERROR_500);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<AppSitePlaceUnfixedDTO> queryUnfixedPage(AppSitePlaceUnfixedPageDTO dto) {
|
|
|
+ Page<AppSitePlace> page = new Page<>(dto.getPageNum(), dto.getPageSize());
|
|
|
+ LambdaQueryWrapper<AppSitePlace> wrapper = Wrappers.<AppSitePlace>lambdaQuery().eq(AppSitePlace::getType, SitePlaceTypeEnum.UNFIXED.getCode());
|
|
|
+
|
|
|
+ IPage<AppSitePlace> resultPage = baseMapper.selectPage(page, wrapper);
|
|
|
+ return resultPage.convert(record -> {
|
|
|
+ AppSitePlaceUnfixedDTO appSitePlaceUnfixedDTO = new AppSitePlaceUnfixedDTO();
|
|
|
+ BeanUtils.copyProperties(record, appSitePlaceUnfixedDTO);
|
|
|
+ AppSitePriceRules appSitePriceRules = appSitePriceRulesMapper.selectOne(
|
|
|
+ Wrappers.<AppSitePriceRules>lambdaQuery().eq(AppSitePriceRules::getSitePlaceId, record.getId()));
|
|
|
+ appSitePlaceUnfixedDTO.setOriginalPrice(appSitePriceRules.getOriginalPrice());
|
|
|
+ appSitePlaceUnfixedDTO.setSellingPrice(appSitePriceRules.getSellingPrice());
|
|
|
+ return appSitePlaceUnfixedDTO;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AppSitePlaceUnfixedDTO queryUnfixedById(String id) {
|
|
|
+ AppSitePlace dbSitePlace = baseMapper.selectById(id);
|
|
|
+ if (null==dbSitePlace) throw new JeecgBootException("无固定场数据不存在", SC_INTERNAL_SERVER_ERROR_500);
|
|
|
+ AppSitePriceRules appSitePriceRules = appSitePriceRulesMapper.selectOne(
|
|
|
+ Wrappers.<AppSitePriceRules>lambdaQuery().eq(AppSitePriceRules::getSitePlaceId, dbSitePlace.getId()));
|
|
|
+ AppSitePlaceUnfixedDTO appSitePlaceUnfixedDTO = new AppSitePlaceUnfixedDTO();
|
|
|
+ BeanUtils.copyProperties(dbSitePlace, appSitePlaceUnfixedDTO);
|
|
|
+ appSitePlaceUnfixedDTO.setOriginalPrice(appSitePriceRules.getOriginalPrice());
|
|
|
+ appSitePlaceUnfixedDTO.setSellingPrice(appSitePriceRules.getSellingPrice());
|
|
|
+
|
|
|
+ return appSitePlaceUnfixedDTO;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 权限校验
|
|
|
*
|