From 6fff9ddba2486cbc3ffb6cecf9beac5fcea63cae Mon Sep 17 00:00:00 2001
From: lidongdong <1459917685@qq.com>
Date: 星期三, 20 三月 2024 17:25:08 +0800
Subject: [PATCH] 修改党员双报到 列表积分不显示5
---
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopFlowerGoodsServiceImpl.java | 53 ++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 40 insertions(+), 13 deletions(-)
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopFlowerGoodsServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopFlowerGoodsServiceImpl.java
index 0b079cf..79f80b0 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopFlowerGoodsServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopFlowerGoodsServiceImpl.java
@@ -1,6 +1,7 @@
package com.panzhihua.service_community.service.impl;
import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.NumberUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -15,7 +16,6 @@
import com.panzhihua.common.model.vos.shop.*;
import com.panzhihua.common.utlis.DifferentLongListUtil;
import com.panzhihua.common.utlis.Snowflake;
-import com.panzhihua.common.utlis.StringUtils;
import com.panzhihua.service_community.dao.*;
import com.panzhihua.service_community.model.dos.*;
import com.panzhihua.service_community.service.ComShopFlowerGoodsAttrService;
@@ -23,12 +23,15 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
+import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import java.util.Map;
import java.util.stream.Collectors;
import static java.util.Objects.isNull;
@@ -60,6 +63,7 @@
private ComShopFlowerGoodsViewStatisticsDAO comShopFlowerGoodsViewStatisticsDAO;
@Override
+ @Transactional(rollbackFor = Exception.class)
public R saveShopFlowerGoods(AddShopFlowerGoodsVO addShopFlowerGoodsVO) {
if (addShopFlowerGoodsVO == null) {
return R.ok("500", "数据为空!");
@@ -133,16 +137,26 @@
shopFlowerGoodsAttrDAO.selectList(new QueryWrapper<ComShopFlowerGoodsAttrDO>().lambda()
.eq(ComShopFlowerGoodsAttrDO::getGoodsId, shopGoods.getId()));
ArrayList<AddShopFlowerGoodsAttrVO> goodsAttrVOList = Lists.newArrayList();
+ StringBuilder sbr = new StringBuilder();
+ int stock = 0;
for (ComShopFlowerGoodsAttrDO oneGoodsAttrDO : goodsAttrDOs) {
AddShopFlowerGoodsAttrVO goodsAttrVO = new AddShopFlowerGoodsAttrVO();
BeanUtils.copyProperties(oneGoodsAttrDO, goodsAttrVO);
- goodsAttrVO.setGoodsAttrId(oneGoodsAttrDO.getId());
+ goodsAttrVO.setId(oneGoodsAttrDO.getId());
goodsAttrVOList.add(goodsAttrVO);
+ stock = stock +oneGoodsAttrDO.getStock();
+ sbr.append(oneGoodsAttrDO.getGoodsAttrName()).append(" ");
}
+ shopGoods.setGoodsAttrName(sbr.toString());
shopGoods.setGoodsAttrs(goodsAttrVOList);
if (CollUtil.isNotEmpty(goodsAttrDOs)){
shopGoods.setGoodsPic(goodsAttrDOs.get(0).getAttrPic());
}
+ //设置商品总浏览量
+ shopGoods.setViewNum(comShopFlowerGoodsViewStatisticsDAO.selectTotalViewNum(shopGoods.getId()));
+ String categoryNames = convenientGoodsCategoryDAO.selectCategoryScopeByGoodsId(shopGoods.getId());
+ shopGoods.setCategoryName(categoryNames);
+ shopGoods.setStock(stock);
});
}
return R.ok(comShopStoreVOIPage);
@@ -185,21 +199,21 @@
if (goodsDO == null || goodsDO.getDeleteStatus().equals(ComShopFlowerGoodsDO.deleteStatus.yes)) {
return R.fail(403, "商品不存在");
}
- if (!goodsDO.getStatus().equals(ComShopFlowerGoodsDO.status.sell)) {
- return R.fail(405, "商品已下架");
- }
+// if (!goodsDO.getStatus().equals(ComShopFlowerGoodsDO.status.sell)) {
+// return R.fail(405, "商品已下架");
+// }
// 根据商品id查询商品规格信息
List<ComShopFlowerGoodsAttrVO> goodsAttrList = new ArrayList<>();
List<ComShopFlowerGoodsAttrDO> goodsAttrDOS =
shopFlowerGoodsAttrDAO.selectList(new QueryWrapper<ComShopFlowerGoodsAttrDO>().eq("goods_id", goodsId));
- List<String> images = new ArrayList<>();
+// List<String> images = new ArrayList<>();
int stock = 0;
for (ComShopFlowerGoodsAttrDO attrDO : goodsAttrDOS) {
ComShopFlowerGoodsAttrVO goodsAttrVO = new ComShopFlowerGoodsAttrVO();
BeanUtils.copyProperties(attrDO, goodsAttrVO);
String attrPic = attrDO.getAttrPic();
- images.add(attrPic);
+// images.add(attrPic);
goodsAttrList.add(goodsAttrVO);
stock = stock +attrDO.getStock();
}
@@ -207,17 +221,20 @@
ConvenientMerchantDO convenientMerchantDO = convenientMerchantDAO.selectById(goodsDO.getStoreId());
ConvenientMerchantVO convenientMerchantVO = new ConvenientMerchantVO();
BeanUtils.copyProperties(convenientMerchantDO, convenientMerchantVO);
-
+ BigDecimal score = comShopFlowerEvaluateDAO.statisticsScore(convenientMerchantDO.getId());
+ convenientMerchantVO.setScore(null == score ? BigDecimal.ZERO : NumberUtil.round(score, 1));
// 设置值
ComShopFlowerGoodsVO shopGoods = new ComShopFlowerGoodsVO();
BeanUtils.copyProperties(goodsDO, shopGoods);
shopGoods.setGoodsAttrList(goodsAttrList);
shopGoods.setConvenientMerchantVO(convenientMerchantVO);
- shopGoods.setImages(StringUtils.join(images,","));
+// shopGoods.setImages(StringUtils.join(images,","));
Integer orderNum = comShopFlowerOrderGoodsDAO.selectCount(new LambdaQueryWrapper<ComShopFlowerOrderGoodsDO>().eq(ComShopFlowerOrderGoodsDO::getGoodsId, goodsId));
shopGoods.setOrderNum(orderNum);
List<ComShopFlowerEvaluateVO> comShopFlowerEvaluateVOList = comShopFlowerEvaluateDAO.selectListLimit(goodsId);
shopGoods.setShopFlowerEvaluateVOList(comShopFlowerEvaluateVOList);
+ Integer evaluateNum = comShopFlowerEvaluateDAO.selectCountByGoodsId(goodsId);
+ shopGoods.setEvaluateNum(evaluateNum);
List<Long> categoryIds = convenientGoodsCategoryDAO.selectCategoryIdsForGoods(goodsId);
shopGoods.setCategoryIds(categoryIds);
@@ -232,6 +249,7 @@
}
@Override
+ @Transactional(rollbackFor = Exception.class)
public R editFlowerShopGoods(Long id, AddShopFlowerGoodsVO addShopFlowerGoodsVO) {
if (addShopFlowerGoodsVO == null) {
return R.ok("500", "数据为空!");
@@ -253,7 +271,7 @@
.delete(new LambdaQueryWrapper<ComShopFlowerGoodsAttrDO>().eq(ComShopFlowerGoodsAttrDO::getGoodsId, id));
ComShopFlowerGoodsAttrDO comShopFlowerGoodsAttrDO = new ComShopFlowerGoodsAttrDO();
comShopFlowerGoodsAttrDO.setGoodsId(id);
- comShopFlowerGoodsAttrDO.setStoreId(addShopFlowerGoodsVO.getStoreId());
+ comShopFlowerGoodsAttrDO.setStoreId(shopGoodsDO.getStoreId());
comShopFlowerGoodsAttrDO.setGoodsName(addShopFlowerGoodsVO.getName());
comShopFlowerGoodsAttrDO.setGoodsAttrName("默认");
comShopFlowerGoodsAttrDO.setAttrPic(addShopFlowerGoodsVO.getGoodsPic());
@@ -263,7 +281,7 @@
} else {
List<Long> attrIds =
comShopFlowerGoodsAttrDOS.stream().map(ComShopFlowerGoodsAttrDO::getId).collect(Collectors.toList());
- List<Long> voAttrIds = addShopFlowerGoodsVO.getGoodsAttrVOList().stream().map(AddShopFlowerGoodsAttrVO::getGoodsAttrId)
+ List<Long> voAttrIds = addShopFlowerGoodsVO.getGoodsAttrVOList().stream().map(AddShopFlowerGoodsAttrVO::getId)
.collect(Collectors.toList());
// 需要删除的规格ID——针对编辑时删除了规格的情况
List<Long> deleteIds = DifferentLongListUtil.getDiffrent(attrIds, voAttrIds);
@@ -271,7 +289,7 @@
shopFlowerGoodsAttrDAO.deleteBatchIds(deleteIds);
}
addShopFlowerGoodsVO.getGoodsAttrVOList().forEach(goodsAttr -> {
- ComShopFlowerGoodsAttrDO comShopGoodsAttrDO = shopFlowerGoodsAttrDAO.selectById(goodsAttr.getGoodsAttrId());
+ ComShopFlowerGoodsAttrDO comShopGoodsAttrDO = shopFlowerGoodsAttrDAO.selectById(goodsAttr.getId());
if (comShopGoodsAttrDO != null) {
comShopGoodsAttrDO.setPrice(goodsAttr.getPrice());
comShopGoodsAttrDO.setCollatePrice(goodsAttr.getCollatePrice());
@@ -301,6 +319,7 @@
}
@Override
+ @Transactional(rollbackFor = Exception.class)
public R deleteShopFlowerGoods(Long id) {
ComShopFlowerGoodsDO comShopFlowerGoodsDO = this.baseMapper.selectById(id);
comShopFlowerGoodsDO.setDeleteStatus(ComShopFlowerGoodsDO.deleteStatus.yes);
@@ -309,6 +328,7 @@
}
@Override
+ @Transactional(rollbackFor = Exception.class)
public R changeStatus(Long id, Integer status) {
ComShopFlowerGoodsDO shopGoodsDO = this.baseMapper.selectById(id);
if (shopGoodsDO == null) {
@@ -330,10 +350,17 @@
ComShopFlowerGoodsViewStatisticsDO statisticsDO = comShopFlowerGoodsViewStatisticsDAO.selectOne(new LambdaQueryWrapper<ComShopFlowerGoodsViewStatisticsDO>()
.eq(ComShopFlowerGoodsViewStatisticsDO::getGoodsId, goodsId).eq(ComShopFlowerGoodsViewStatisticsDO::getStatisticDate, nowDate));
if (isNull(statisticsDO)) {
- comShopFlowerGoodsViewStatisticsDAO.createTodayStatistic(goodsId);
+ comShopFlowerGoodsViewStatisticsDAO.createTodayStatistic(goodsId,nowDate);
} else {
comShopFlowerGoodsViewStatisticsDAO.incrViewNum(goodsId, nowDate);
}
return R.ok();
}
+
+ @Override
+ public R countSaleByUserId(Long userId){
+ List<ComShopOrderStoreIdCountVO> comShopOrderStoreIdCountVOS = this.baseMapper.countSaleByUserId(userId);
+ Map<String, Integer> collect = comShopOrderStoreIdCountVOS.stream().collect(Collectors.toMap(ComShopOrderStoreIdCountVO::getCountName, ComShopOrderStoreIdCountVO::getCountNum));
+ return R.ok(collect);
+ }
}
--
Gitblit v1.7.1