| | |
| | | import com.doumee.dao.business.model.dto.PlatGoodsParam; |
| | | import com.doumee.service.business.GoodsService; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import lombok.extern.java.Log; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.poi.ss.usermodel.*; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | |
| | | @Override |
| | | public Integer createPlat(GoodCreatePlatRequest param){ |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(Constants.equalsInteger(user.getType(), Constants.UserType.COMPANY.getKey())){ |
| | | if(!Constants.equalsInteger(user.getType(), Constants.UserType.COMPANY.getKey())){ |
| | | //非企业用户不能操作 |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED); |
| | | } |
| | |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | Category category = categoryMapper.selectById(param.getCategoryId()); |
| | | if(category ==null ||Constants.equalsInteger(category.getIsdeleted(), Constants.ONE) ||Constants.equalsInteger(category.getCompanyId(), user.getCompanyId())){ |
| | | if(category ==null ||Constants.equalsInteger(category.getIsdeleted(), Constants.ONE) ||!Constants.equalsInteger(category.getCompanyId(), user.getCompanyId())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,类别信息不正确,请刷新重试!"); |
| | | } |
| | | if(category.getPlatCateId() == null){ |
| | |
| | | if(p.getGoodsId() == null || p.getPrice() == null){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,请正确选择平台商品并配置入手价!"); |
| | | } |
| | | if(ids == null){ |
| | | ids = new ArrayList<>(); |
| | | } |
| | | ids.add(p.getGoodsId()); |
| | | } |
| | | } |
| | | goodsList = baseGoodsMapper.selectList(new QueryWrapper<>(bp).lambda().in((ids!=null && ids.size()>0),BaseGoods::getId,ids)); |
| | | if(Constants.equalsInteger(Constants.ONE, param.getType()) || goodsList==null || ids.size()!=goodsList.size()){ |
| | | if(Constants.equalsInteger(Constants.ONE, param.getType()) &&( goodsList==null || ids.size()!=goodsList.size())){ |
| | | // 如果选择平台商品和查询结果对不上,提示错误 |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,请正确选择平台商品!"); |
| | | } |
| | |
| | | goods.setStatus(Constants.ZERO); |
| | | goods.setCreateDate(new Date()); |
| | | goods.setCreator(user.getId()); |
| | | goods.setCompanyId(user.getCompanyId()); |
| | | goods.setIsdeleted(Constants.ZERO); |
| | | //处理拼音问题 |
| | | goods.setPinyin(PinYinUtil.getFullSpell(goods.getName())); |
| | |
| | | @Override |
| | | public Goods findById(Integer id) { |
| | | Goods goods = goodsMapper.selectById(id); |
| | | String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.PROJECTS).getCode(); |
| | | String prefixUrl = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_IMG).getCode(); |
| | | goods.setPrefixUrl(prefixUrl); |
| | | Brand brand = brandMapper.selectById(goods.getBrandId()); |
| | | if(!Objects.isNull(brand)){ |
| | |
| | | Goods::getPrice,goods.getSPrice(),goods.getEPrice()); |
| | | queryWrapper.orderByDesc(Goods::getId); |
| | | List<Goods> goodsList = goodsJoinMapper.selectJoinList(Goods.class,queryWrapper); |
| | | String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.PROJECTS).getCode(); |
| | | String prefixUrl = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_IMG).getCode(); |
| | | goodsList.forEach(i->{ |
| | | i.setPrefixUrl(prefixUrl); |
| | | i.setMultifileList(multifileMapper.selectList(new QueryWrapper<Multifile>().eq("OBJ_ID",i.getId()).orderByAsc(" SORTNUM "))); |
| | |
| | | queryWrapper.selectAll(Goods.class); |
| | | |
| | | queryWrapper.selectAs(Category::getName, Goods::getCategoryName); |
| | | queryWrapper.selectAs(BaseGoods::getZdPrice, Goods::getBaseZdPrice); |
| | | queryWrapper.selectAs(BaseGoods::getPrice, Goods::getBasePrice); |
| | | queryWrapper.selectAs(Brand::getName, Goods::getBrandName); |
| | | queryWrapper.selectAs(Category::getAttrFirst, Goods::getAttrFirst); |
| | | queryWrapper.selectAs(Category::getAttrSecond, Goods::getAttrSecond); |
| | | queryWrapper.selectAs(BaseCategory::getPriceRate,Goods::getBasePriceRate); |
| | | queryWrapper.leftJoin(Category.class, Category::getId, Goods::getCategoryId); |
| | | queryWrapper.leftJoin(Brand.class, Brand::getId, Goods::getBrandId); |
| | | queryWrapper.leftJoin(BaseGoods.class,BaseGoods::getId,Goods::getGoodsId); |
| | | queryWrapper.leftJoin(BaseCategory.class,BaseCategory::getId,BaseGoods::getCategoryId); |
| | | |
| | | queryWrapper.eq(Goods::getIsdeleted, Constants.ZERO); |
| | | if (pageWrap.getModel().getId() != null) { |
| | |
| | | } |
| | | queryWrapper.orderByDesc(Goods::getId); |
| | | IPage<Goods> goodsIPage = goodsJoinMapper.selectJoinPage(page, Goods.class, queryWrapper); |
| | | String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.PROJECTS).getCode(); |
| | | String prefixUrl = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_IMG).getCode(); |
| | | goodsIPage.getRecords().forEach(i->{ |
| | | i.setPrefixUrl(prefixUrl); |
| | | if(i.getType().equals(Constants.ONE)){ |
| | | i.setBasePrice(i.getBasePrice().multiply(i.getBasePriceRate())); |
| | | } |
| | | |
| | | }); |
| | | return PageData.from(goodsIPage); |
| | | } |
| | |
| | | @Override |
| | | public void export(HttpServletRequest request, HttpServletResponse response) throws Exception { |
| | | try { |
| | | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | String fileName = "产品导入表"+System.currentTimeMillis()+".xlsx"; |
| | | // 获取文件输入流 |
| | | InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("static/file/goodsExcelTemp.xlsx"); |
| | |
| | | // sheet.getPhysicalNumberOfRows()获取总的行数 |
| | | // 循环读取每一行 |
| | | Row row = sheet.createRow(1); |
| | | List<Category> categoryList = categoryMapper.selectList(new QueryWrapper<Category>().eq("ISDELETED",0)); |
| | | List<Category> categoryList = categoryMapper.selectList( |
| | | new QueryWrapper<Category>().eq("ISDELETED",0) |
| | | .eq("COMPANY_ID",loginUserInfo.getCompanyId()) |
| | | ); |
| | | categoryList.forEach(i->{ |
| | | i.setParamList(cateParamMapper.selectList(new QueryWrapper<CateParam>().eq("ISDELETED",0).eq("CATEGORY_ID",i.getId()))); |
| | | }); |
| | |
| | | .apply(!Objects.isNull(pageWrap.getModel()) && !Objects.isNull(pageWrap.getModel().getEPrice()), " t.PRICE <= "+pageWrap.getModel().getEPrice()+" "); |
| | | queryWrapper.orderByDesc(Goods::getId); |
| | | IPage<Goods> goodsIPage = goodsJoinMapper.selectJoinPage(page, Goods.class, queryWrapper); |
| | | String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.PROJECTS).getCode(); |
| | | String prefixUrl = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_IMG).getCode(); |
| | | goodsIPage.getRecords().forEach(i->{ |
| | | i.setPrefixUrl(prefixUrl); |
| | | i.setMultifileList(multifileMapper.selectList(new QueryWrapper<Multifile>().eq("OBJ_ID",i.getId()).orderByAsc(" SORTNUM "))); |
| | |
| | | |
| | | @Override |
| | | public List<Goods> findListForH5(GoodsRequest goodsRequest) { |
| | | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(!loginUserInfo.getType().equals(Constants.UserType.ZHUBO.getKey())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非主播用户无法使用"); |
| | | } |
| | | MPJLambdaWrapper<Goods> queryWrapper = new MPJLambdaWrapper<>(); |
| | | queryWrapper.selectAll(Goods.class); |
| | | queryWrapper.selectAs(Category::getName, Goods::getCategoryName); |
| | |
| | | queryWrapper.leftJoin(Brand.class, Brand::getId, Goods::getBrandId); |
| | | queryWrapper.eq(Goods::getStatus,Constants.ZERO); |
| | | queryWrapper.eq(Goods::getIsdeleted,Constants.ZERO); |
| | | queryWrapper.eq(Goods::getCompanyId,loginUserInfo.getCompanyId()); |
| | | queryWrapper.eq(!Objects.isNull(goodsRequest) && !Objects.isNull(goodsRequest.getCategoryId()), Goods::getCategoryId, goodsRequest.getCategoryId()) |
| | | .eq(!Objects.isNull(goodsRequest) && !Objects.isNull(goodsRequest.getBrandId()), Goods::getBrandId, goodsRequest.getBrandId()) |
| | | .and(!Objects.isNull(goodsRequest) && StringUtils.isNotBlank(goodsRequest.getKeyword()), |
| | |
| | | .apply(!Objects.isNull(goodsRequest) && !Objects.isNull(goodsRequest.getEPrice()), " t.PRICE <= "+goodsRequest.getEPrice()+" "); |
| | | queryWrapper.orderByDesc(Goods::getId); |
| | | List<Goods> goodsList = goodsJoinMapper.selectJoinList(Goods.class,queryWrapper); |
| | | String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.PROJECTS).getCode(); |
| | | String prefixUrl = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_IMG).getCode(); |
| | | goodsList.forEach(i->{ |
| | | i.setPrefixUrl(prefixUrl); |
| | | i.setMultifileList(multifileMapper.selectList(new QueryWrapper<Multifile>().eq("OBJ_ID",i.getId()).orderByAsc(" SORTNUM "))); |