| | |
| | | import com.ruoyi.common.core.utils.uuid.IdUtils; |
| | | import com.ruoyi.common.security.utils.CodeFactoryUtil; |
| | | import com.ruoyi.goods.domain.dto.*; |
| | | import com.ruoyi.goods.domain.pojo.activity.Activity; |
| | | import com.ruoyi.system.api.domain.poji.activity.Activity; |
| | | import com.ruoyi.goods.domain.pojo.goods.GoodsTotal; |
| | | import com.ruoyi.goods.domain.vo.*; |
| | | import com.ruoyi.goods.mapper.goods.GoodsMapper; |
| | |
| | | import com.ruoyi.goods.service.goods.ShopGoodsService; |
| | | import com.ruoyi.system.api.constant.AppErrorConstant; |
| | | import com.ruoyi.system.api.domain.dto.AppActivityGoodsPageDto; |
| | | import com.ruoyi.system.api.domain.dto.MerGoodsPriceListDto; |
| | | import com.ruoyi.system.api.domain.dto.MgtBaseGetDto; |
| | | import com.ruoyi.system.api.domain.dto.MgtClassNumDto; |
| | | import com.ruoyi.system.api.domain.poji.activity.ActivityGoods; |
| | | import com.ruoyi.system.api.domain.poji.config.SysClassification; |
| | | import com.ruoyi.system.api.domain.poji.goods.Goods; |
| | |
| | | BigDecimal salesPercent = BigDecimal.ZERO; |
| | | // 计算销售百分比 |
| | | if (activityNumber != 0) { |
| | | salesPercent = BigDecimal.valueOf(salesNumber).multiply(BigDecimal.valueOf(100)).divide(BigDecimal.valueOf(activityNumber), 2, BigDecimal.ROUND_HALF_UP); |
| | | salesPercent = BigDecimal.valueOf(salesNumber).multiply(BigDecimal.valueOf(100)).divide(BigDecimal.valueOf(activityNumber),2, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | // 设置销售百分比和时间戳 |
| | | appSimpleActivityGoodsVo.setSalesPercent(salesPercent); |
| | |
| | | ShopGoods shopGoods = shopGoodsService.getByShopIdAndGoodsId(appGoodsInfoGetDto.getShopId(),goods.getGoodsId()); |
| | | if(shopGoods!=null){ |
| | | appGoodsInfoVo.setSalesPrice(shopGoods.getSalesPrice()); |
| | | appGoodsInfoVo.setSalesNum(shopGoods.getServiceNum()); |
| | | appGoodsInfoVo.setServiceNum(shopGoods.getServiceNum()); |
| | | } |
| | | GoodsTotal goodsTotal = goodsTotalService.getById(goods.getGoodsId()); |
| | | appGoodsInfoVo.setSalesNum(goodsTotal.getBuyNumCount()); |
| | | //活动商品判断 |
| | | if(appGoodsInfoGetDto.getActivityFlag()==1){ |
| | | ActivityGoods activityGoods = activityGoodsService.getByGoodsId(appGoodsInfoGetDto.getActivityId(),goods.getGoodsId()); |
| | | Activity activity = activityService.getById(appGoodsInfoGetDto.getActivityId()); |
| | | //原价取较大值 |
| | | if(shopGoods!=null&&goods.getSalesPrice().compareTo(shopGoods.getSalesPrice())>0){ |
| | | appGoodsInfoVo.setSalesPrice(goods.getSalesPrice()); |
| | |
| | | appGoodsInfoVo.setActivityFlag(1); |
| | | appGoodsInfoVo.setActivityPrice(activityGoods.getActivityPrice()); |
| | | appGoodsInfoVo.setSalesNum(activityGoods.getSalesNumber()); |
| | | appGoodsInfoVo.setActivityDeadline(activityGoods.getActivityDeadline()); |
| | | appGoodsInfoVo.setTimestamp(activityGoods.getActivityDeadline().getTime()); |
| | | appGoodsInfoVo.setActivityStartTime(activity.getActivityStartTime()); |
| | | appGoodsInfoVo.setActivityDeadline(activity.getActivityEndTime()); |
| | | appGoodsInfoVo.setTimestamp(activity.getActivityEndTime().getTime()); |
| | | Integer availableBuyNum = 0; |
| | | //售罄判断 |
| | | if(activityGoods.getActivityNumber().equals(activityGoods.getSalesNumber())){ |
| | |
| | | List<String> bannerList = new ArrayList<>(); |
| | | if(goodsFileList!=null&&!goodsFileList.isEmpty()){ |
| | | for(GoodsFile goodsFile : goodsFileList){ |
| | | if(goodsFile.getFileType()==2){ |
| | | if(goodsFile.getFileType()==1){ |
| | | appGoodsInfoVo.setGoodsPicture(goodsFile.getFileUrl()); |
| | | }else if(goodsFile.getFileType()==2){ |
| | | appGoodsInfoVo.setGoodsVideo(goodsFile.getFileUrl()); |
| | | }else if(goodsFile.getFileType()==3){ |
| | | bannerList.add(goodsFile.getFileUrl()); |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * @description 获取确认次数周期商品 |
| | | * @author jqs |
| | | * @date 2023/7/31 16:49 |
| | | * @param shopId |
| | | * @return List<MerGoodsPageVo> |
| | | */ |
| | | @Override |
| | | public List<MerGoodsPageVo> listMerCycleGoods (Long shopId){ |
| | | List<MerGoodsPageVo> merGoodsPageVoList = goodsMapper.listMerCycleGoods(shopId); |
| | | return merGoodsPageVoList; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 修改商户商品 |
| | |
| | | Boolean newGoods = false; |
| | | String goodsId = mgtGoodsEditDto.getGoodsId(); |
| | | Goods goodsSame = this.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getDelFlag,0).eq(Goods::getGoodsName,mgtGoodsEditDto.getGoodsName())); |
| | | // 创建MgtClassNumDto对象 |
| | | MgtClassNumDto mgtClassNumDto = new MgtClassNumDto(); |
| | | if(mgtGoodsEditDto.getGoodsType()!=1){ |
| | | mgtGoodsEditDto.setCycleNumFlag(1); |
| | | }else{ |
| | | if(mgtGoodsEditDto.getCycleNumFlag()==null){ |
| | | throw new ServiceException("周期商品需选择是否明确次数"); |
| | | } |
| | | } |
| | | // 判断是否有商品ID 没有则新建 |
| | | if (StringUtils.isNotBlank(goodsId)) { |
| | | if(goodsSame!=null&&!Objects.equals(goodsSame.getGoodsId(), goodsId)){ |
| | |
| | | } |
| | | //删除历史数据 |
| | | goodsFileService.deleteByGoodsId(goodsId); |
| | | // 如果类别ID不为空并且文章的类别ID不为空并且类别ID不同,则设置子类别ID和新增类别ID |
| | | if (mgtGoodsEditDto.getGoodsClassId() != null && goods.getGoodsClassId() != null |
| | | && !mgtGoodsEditDto.getGoodsClassId().equals(goods.getGoodsClassId())) { |
| | | mgtClassNumDto.setSubClassId(goods.getGoodsClassId()); |
| | | mgtClassNumDto.setAddClassId(mgtGoodsEditDto.getGoodsClassId()); |
| | | } |
| | | // 如果类别ID不为空并且文章的类别ID为空,则设置新增类别ID |
| | | else if (mgtGoodsEditDto.getGoodsClassId() != null && goods.getGoodsClassId() == null) { |
| | | mgtClassNumDto.setAddClassId(mgtGoodsEditDto.getGoodsClassId()); |
| | | } |
| | | } else { |
| | | if(goodsSame!=null){ |
| | | throw new ServiceException(AppErrorConstant.GOODS_DOUBLE); |
| | |
| | | goods.setCreateTime(new Date()); |
| | | goods.setCreateUserId(mgtGoodsEditDto.getUserId()); |
| | | newGoods = true; |
| | | mgtClassNumDto.setAddClassId(mgtGoodsEditDto.getGoodsClassId()); |
| | | } |
| | | goods.setUpdateTime(new Date()); |
| | | goods.setUpdateUserId(mgtGoodsEditDto.getUserId()); |
| | |
| | | goodsDetail = new String(decodedBytes, StandardCharsets.UTF_8); |
| | | goods.setGoodsDetail(goodsDetail); |
| | | } |
| | | goods.setRecommendFlag(mgtGoodsEditDto.getRecommendFlag()); |
| | | goods.setRecommendFlag(0); |
| | | goods.setGoodsNurses(mgtGoodsEditDto.getGoodsNurses()); |
| | | goods.setGoodsTags(mgtGoodsEditDto.getGoodsTags()); |
| | | this.saveOrUpdate(goods); |
| | |
| | | goodsTotal.setBuyMoneyTotal(new BigDecimal("0.00")); |
| | | goodsTotalService.saveOrUpdate(goodsTotal); |
| | | } |
| | | //更新商品分类统计 |
| | | remoteConfigService.changeClassNum(mgtClassNumDto); |
| | | } |
| | | |
| | | /** |
| | |
| | | goods.setUpdateTime(new Date()); |
| | | goods.setUpdateUserId(userId); |
| | | this.saveOrUpdate(goods); |
| | | if(goods.getGoodsClassId()!=null){ |
| | | MgtClassNumDto mgtClassNumDto = new MgtClassNumDto(); |
| | | mgtClassNumDto.setSubClassId(goods.getGoodsClassId()); |
| | | //更新商品分类统计 |
| | | remoteConfigService.changeClassNum(mgtClassNumDto); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | * @description 通过id获取商品列表 |
| | | * @author jqs |
| | | * @date 2023/7/3 9:58 |
| | | * @param goodsIds |
| | | * @param merGoodsPriceListDto |
| | | * @return List<MerGoodsPriceListVo> |
| | | */ |
| | | @Override |
| | | public List<MerGoodsPriceListVo> listGoodsPriceByGoodsId(String goodsIds){ |
| | | return goodsMapper.listGoodsPriceByGoodsId(goodsIds); |
| | | public List<MerGoodsPriceListVo> listGoodsPriceByGoodsId(MerGoodsPriceListDto merGoodsPriceListDto){ |
| | | return goodsMapper.listGoodsPriceByGoodsId(merGoodsPriceListDto.getShopId(),merGoodsPriceListDto.getGoodsIds()); |
| | | } |
| | | |
| | | |
| | |
| | | BigDecimal salesPercent = BigDecimal.ZERO; |
| | | // 计算销售百分比 |
| | | if (activityNumber != 0) { |
| | | salesPercent = BigDecimal.valueOf(salesNumber).multiply(BigDecimal.valueOf(100)).divide(BigDecimal.valueOf(activityNumber), 2, BigDecimal.ROUND_HALF_UP); |
| | | salesPercent = BigDecimal.valueOf(salesNumber).multiply(BigDecimal.valueOf(100)).divide(BigDecimal.valueOf(activityNumber),2, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | // 设置销售百分比和时间戳 |
| | | appSimpleActivityGoodsVo.setSalesPercent(salesPercent); |
| | | appSimpleActivityGoodsVo.setTimestamp(appSimpleActivityGoodsVo.getEndTime().getTime()); |
| | | //限购判断 |
| | | if(appSimpleActivityGoodsVo.getPurchaseLimitationFlag()==1){ |
| | | Integer buyNum = activityRecordService.getUserActivityGoodsNum(appSimpleActivityGoodsVo.getGoodsId(),appActivityGoodsPageDto.getActivityId(),appActivityGoodsPageDto.getUserId()); |
| | | Integer limitBuyNum = appSimpleActivityGoodsVo.getLimitNumber() - buyNum; |
| | | appSimpleActivityGoodsVo.setAvailableBuyNum(limitBuyNum); |
| | | } |
| | | } |
| | | // 返回结果 |
| | | return appSimpleGoodsVoList; |
| | |
| | | MgtGoodsEditInfoVo mgtGoodsEditInfoVo = new MgtGoodsEditInfoVo(); |
| | | Goods goods = this.getById(mgtBaseGetDto.getId()); |
| | | BeanUtils.copyProperties(goods,mgtGoodsEditInfoVo); |
| | | if(goods.getSubscriptionFlag()==0){ |
| | | mgtGoodsEditInfoVo.setSubscription(null); |
| | | } |
| | | List<GoodsFile> goodsFileList = goodsFileService.listByGoodsId(goods.getGoodsId()); |
| | | if(goodsFileList!=null&&!goodsFileList.isEmpty()){ |
| | | StringJoiner goodsBannersSj = new StringJoiner(","); |
| | |
| | | } |
| | | return mgtGoodsEditInfoVo; |
| | | } |
| | | |
| | | /** |
| | | * @description 获取商品分类名 |
| | | * @author jqs |
| | | * @date 2023/8/12 18:33 |
| | | * @param classId |
| | | * @return List<String> |
| | | */ |
| | | @Override |
| | | public List<String> listGoodsNameByGoodsClass(Long classId){ |
| | | List<String> goodsNameList = goodsMapper.listGoodsNameByGoodsClass(classId); |
| | | return goodsNameList; |
| | | } |
| | | } |