| | |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.join.GoodsJoinMapper; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.business.model.dto.GoodCreatePlatRequest; |
| | | import com.doumee.dao.business.model.dto.GoodsRequest; |
| | | import com.doumee.service.business.GoodsService; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | |
| | | |
| | | return goods.getId(); |
| | | } |
| | | @Override |
| | | public Integer createPlat(GoodCreatePlatRequest param){ |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(Constants.equalsInteger(user.getType(), Constants.UserType.COMPANY.getKey())){ |
| | | //非企业用户不能操作 |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED); |
| | | } |
| | | if(param.getCategoryId() == null |
| | | || param.getType() == null |
| | | || param.getRate() == null |
| | | || (Constants.equalsInteger(param.getType(), Constants.ONE) |
| | | && (param.getGoodsParamList() == null |
| | | || param.getGoodsParamList().size()==0))){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | Goods goods = new Goods(); |
| | | |
| | | if(goodsMapper.selectCount(new QueryWrapper<Goods>().eq("ISDELETED",Constants.ZERO).eq("name",goods.getName()))>0){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+goods.getName()+"】已存在"); |
| | | } |
| | | goods.setStatus(Constants.ZERO); |
| | | goods.setCreateDate(new Date()); |
| | | goods.setCreator(user.getId()); |
| | | goods.setIsdeleted(Constants.ZERO); |
| | | //处理拼音问题 |
| | | goods.setPinyin(PinYinUtil.getFullSpell(goods.getName())); |
| | | goods.setShortPinyin(PinYinUtil.getFirstSpell(goods.getName())); |
| | | goodsMapper.insert(goods); |
| | | |
| | | List<Multifile> multifileList = goods.getMultifileList(); |
| | | if(!Objects.isNull(multifileList)&&multifileList.size()>Constants.ZERO){ |
| | | for (int i = 0; i < multifileList.size(); i++) { |
| | | Multifile multifile = multifileList.get(i); |
| | | multifile.setCreator(user.getId()); |
| | | multifile.setCreateDate(new Date()); |
| | | multifile.setIsdeleted(Constants.ZERO); |
| | | multifile.setSortnum(i+Constants.ONE); |
| | | multifile.setObjId(goods.getId()); |
| | | multifile.setType(Constants.ZERO); |
| | | multifile.setObjType(Constants.ZERO); |
| | | multifileMapper.insert(multifile); |
| | | } |
| | | } |
| | | List<GoodsParam> goodsParamList = goods.getGoodsParamList(); |
| | | if(!Objects.isNull(goodsParamList)&&goodsParamList.size()>0){ |
| | | for (int i = 0; i < goodsParamList.size(); i++) { |
| | | GoodsParam goodsParam = goodsParamList.get(i); |
| | | goodsParam.setCreator(user.getId()); |
| | | goodsParam.setCreateDate(new Date()); |
| | | goodsParam.setIsdeleted(Constants.ZERO); |
| | | goodsParam.setSortnum(i+Constants.ONE); |
| | | goodsParam.setStatus(Constants.ZERO); |
| | | goodsParam.setGoodsId(goods.getId()); |
| | | goodsParamMapper.insert(goodsParam); |
| | | } |
| | | } |
| | | |
| | | return goods.getId(); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteById(Integer id) { |