commit
9e43d186d7
@ -28,7 +28,6 @@ import org.springframework.web.context.request.async.DeferredResult;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
@ -96,7 +95,7 @@ public class MemberBuyerController {
|
||||
deferredResult.setResult(new ResponseEntity<>(ResultUtil.error(ResultCode.ERROR), HttpStatus.OK));
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}, Executors.newCachedThreadPool());
|
||||
});
|
||||
return deferredResult;
|
||||
}
|
||||
|
||||
|
@ -64,6 +64,9 @@ public class CouponBuyerController {
|
||||
@GetMapping("/activity")
|
||||
@ApiOperation(value = "自动领取优惠券")
|
||||
public ResultMessage<List<MemberCoupon>> activity() {
|
||||
if (UserContext.getCurrentUser() == null) {
|
||||
return ResultUtil.success();
|
||||
}
|
||||
return ResultUtil.data(couponActivityService.trigger(
|
||||
CouponActivityTrigger.builder()
|
||||
.couponActivityTypeEnum(CouponActivityTypeEnum.AUTO_COUPON)
|
||||
|
@ -322,8 +322,6 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
|
||||
for (int i = 0; i < skuStocks.size(); i++) {
|
||||
goodsSkus.get(i).setQuantity(Convert.toInt(skuStocks.get(i).toString()));
|
||||
}
|
||||
//批量修改商品库存
|
||||
goodsSkuService.updateBatchById(goodsSkus);
|
||||
|
||||
//促销库存处理
|
||||
if (!promotionKey.isEmpty()) {
|
||||
@ -336,7 +334,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
|
||||
promotionGoodsService.updatePromotionGoodsStock(promotionGoods);
|
||||
}
|
||||
//商品库存,包含sku库存集合,批量更新商品库存相关
|
||||
goodsSkuService.updateGoodsStuck(goodsSkus);
|
||||
goodsSkuService.updateGoodsStock(goodsSkus);
|
||||
|
||||
log.info("订单确认,库存同步:商品信息--{};促销信息---{}", goodsSkus, promotionGoods);
|
||||
|
||||
@ -369,8 +367,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
|
||||
}
|
||||
log.info("订单取消,库存还原:{}", goodsSkus);
|
||||
//批量修改商品库存
|
||||
goodsSkuService.updateBatchById(goodsSkus);
|
||||
goodsSkuService.updateGoodsStuck(goodsSkus);
|
||||
goodsSkuService.updateGoodsStock(goodsSkus);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -492,7 +492,7 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
}
|
||||
int buyCount = goodsSku.getBuyCount() + goodsCompleteMessage.getBuyNum();
|
||||
goodsSku.setBuyCount(buyCount);
|
||||
goodsSkuService.update(goodsSku);
|
||||
goodsSkuService.updateGoodsSkuBuyCount(goodsSku.getId(), buyCount);
|
||||
|
||||
this.goodsIndexService.updateIndex(MapUtil.builder(new HashMap<String, Object>()).put("id", goodsCompleteMessage.getSkuId()).build(), MapUtil.builder(new HashMap<String, Object>()).put("buyCount", buyCount).build());
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.modules.goods.entity.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ -32,4 +33,18 @@ public class CategorySearchParams {
|
||||
@ApiModelProperty(value = "父节点名称")
|
||||
private String parentTitle;
|
||||
|
||||
@ApiModelProperty(value = "是否禁用")
|
||||
private Boolean deleteFlag;
|
||||
|
||||
public <T > QueryWrapper<T> queryWrapper() {
|
||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.like(name != null, "name", name);
|
||||
queryWrapper.like(parentTitle != null, "parent_title", parentTitle);
|
||||
queryWrapper.eq(parentId != null, "parent_id", parentId);
|
||||
queryWrapper.eq(level != null, "level", level);
|
||||
queryWrapper.eq(sortOrder != null, "sort_order", sortOrder);
|
||||
queryWrapper.eq(commissionRate != null, "commission_rate", commissionRate);
|
||||
queryWrapper.eq(deleteFlag != null, "delete_flag", deleteFlag);
|
||||
return queryWrapper;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package cn.lili.modules.goods.entity.dto;
|
||||
|
||||
import cn.lili.common.validation.EnumValue;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsTypeEnum;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
@ -96,7 +95,8 @@ public class GoodsOperationDTO implements Serializable {
|
||||
@ApiModelProperty(value = "是否有规格", hidden = true)
|
||||
private String haveSpec;
|
||||
|
||||
@ApiModelProperty(value = "销售模式", required = true)
|
||||
@ApiModelProperty(value = "商品单位", required = true)
|
||||
@NotEmpty(message = "商品单位不能为空")
|
||||
private String goodsUnit;
|
||||
|
||||
@ApiModelProperty(value = "商品描述")
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.modules.goods.entity.dto;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
|
||||
@ -9,6 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品查询条件
|
||||
@ -34,6 +36,9 @@ public class GoodsSearchParams extends PageVO {
|
||||
@ApiModelProperty(value = "商品编号")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "商品编号")
|
||||
private List<String> ids;
|
||||
|
||||
@ApiModelProperty(value = "商家ID")
|
||||
private String storeId;
|
||||
|
||||
@ -133,6 +138,8 @@ public class GoodsSearchParams extends PageVO {
|
||||
queryWrapper.eq("sales_model", salesModel);
|
||||
}
|
||||
|
||||
queryWrapper.in(CollUtil.isNotEmpty(ids), "id", ids);
|
||||
|
||||
queryWrapper.eq("delete_flag", false);
|
||||
this.betweenWrapper(queryWrapper);
|
||||
return queryWrapper;
|
||||
|
@ -12,6 +12,9 @@ import lombok.Data;
|
||||
@Data
|
||||
public class GoodsSkuStockDTO {
|
||||
|
||||
@ApiModelProperty(value = "商品id")
|
||||
private String goodsId;
|
||||
|
||||
@ApiModelProperty(value = "商品skuId")
|
||||
private String skuId;
|
||||
|
||||
|
@ -2,6 +2,7 @@ package cn.lili.modules.goods.mapper;
|
||||
|
||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsSkuDTO;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsSkuStockDTO;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@ -114,4 +115,6 @@ public interface GoodsSkuMapper extends BaseMapper<GoodsSku> {
|
||||
@Select("SELECT *,g.params as params FROM li_goods_sku gs inner join li_goods g on gs.goods_id = g.id ${ew.customSqlSegment}")
|
||||
IPage<GoodsSkuDTO> queryByParams(IPage<GoodsSkuDTO> page, @Param(Constants.WRAPPER) Wrapper<GoodsSkuDTO> queryWrapper);
|
||||
|
||||
@Select("SELECT id as sku_id, quantity, goods_id FROM li_goods_sku ${ew.customSqlSegment}")
|
||||
List<GoodsSkuStockDTO> queryStocks(@Param(Constants.WRAPPER) Wrapper<GoodsSku> queryWrapper);
|
||||
}
|
@ -2,6 +2,7 @@ package cn.lili.modules.goods.service;
|
||||
|
||||
|
||||
import cn.lili.modules.goods.entity.dos.Category;
|
||||
import cn.lili.modules.goods.entity.dto.CategorySearchParams;
|
||||
import cn.lili.modules.goods.entity.vos.CategoryVO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
@ -69,9 +70,10 @@ public interface CategoryService extends IService<Category> {
|
||||
* 查询所有的分类,父子关系
|
||||
* 数据库获取
|
||||
*
|
||||
* @param categorySearchParams 查询参数
|
||||
* @return 所有的分类,父子关系
|
||||
*/
|
||||
List<CategoryVO> listAllChildren();
|
||||
List<CategoryVO> listAllChildren(CategorySearchParams categorySearchParams);
|
||||
|
||||
/**
|
||||
* 获取指定分类的分类名称
|
||||
|
@ -209,7 +209,7 @@ public interface GoodsSkuService extends IService<GoodsSku> {
|
||||
*
|
||||
* @param goodsSkus
|
||||
*/
|
||||
void updateGoodsStuck(List<GoodsSku> goodsSkus);
|
||||
void updateGoodsStock(List<GoodsSku> goodsSkus);
|
||||
|
||||
/**
|
||||
* 更新SKU评价数量
|
||||
@ -249,4 +249,21 @@ public interface GoodsSkuService extends IService<GoodsSku> {
|
||||
* @param goodsOperationDTO 商品操作信息
|
||||
*/
|
||||
void renderGoodsSkuList(List<GoodsSku> goodsSkuList, GoodsOperationDTO goodsOperationDTO);
|
||||
|
||||
/**
|
||||
* 更新商品sku购买数量
|
||||
*
|
||||
* @param skuId skuId
|
||||
* @param buyCount 购买数量
|
||||
*/
|
||||
void updateGoodsSkuBuyCount(String skuId, int buyCount);
|
||||
|
||||
/**
|
||||
* 更新商品sku评分
|
||||
*
|
||||
* @param skuId skuId
|
||||
* @param grade 评分
|
||||
* @param commentNum 评论数量
|
||||
*/
|
||||
void updateGoodsSkuGrade(String skuId, double grade,int commentNum);
|
||||
}
|
@ -8,6 +8,7 @@ import cn.lili.common.event.TransactionCommitSendMQEvent;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.properties.RocketmqCustomProperties;
|
||||
import cn.lili.modules.goods.entity.dos.Category;
|
||||
import cn.lili.modules.goods.entity.dto.CategorySearchParams;
|
||||
import cn.lili.modules.goods.entity.vos.CategoryVO;
|
||||
import cn.lili.modules.goods.mapper.CategoryMapper;
|
||||
import cn.lili.modules.goods.service.CategoryBrandService;
|
||||
@ -165,10 +166,10 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CategoryVO> listAllChildren() {
|
||||
public List<CategoryVO> listAllChildren(CategorySearchParams categorySearchParams) {
|
||||
|
||||
//获取全部分类
|
||||
List<Category> list = this.list();
|
||||
List<Category> list = this.list(categorySearchParams.queryWrapper());
|
||||
|
||||
//构造分类树
|
||||
List<CategoryVO> categoryVOList = new ArrayList<>();
|
||||
|
@ -26,7 +26,7 @@ import cn.lili.modules.goods.entity.vos.GoodsSkuVO;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsVO;
|
||||
import cn.lili.modules.goods.mapper.GoodsMapper;
|
||||
import cn.lili.modules.goods.service.*;
|
||||
import cn.lili.modules.member.entity.dos.MemberEvaluation;
|
||||
import cn.lili.modules.member.entity.dto.EvaluationQueryParams;
|
||||
import cn.lili.modules.member.entity.enums.EvaluationGradeEnum;
|
||||
import cn.lili.modules.member.service.MemberEvaluationService;
|
||||
import cn.lili.modules.store.entity.dos.FreightTemplate;
|
||||
@ -446,19 +446,19 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
|
||||
//获取商品信息
|
||||
Goods goods = this.getById(goodsId);
|
||||
//修改商品评价数量
|
||||
goods.setCommentNum(goods.getCommentNum() + 1);
|
||||
|
||||
//修改商品好评率
|
||||
LambdaQueryWrapper<MemberEvaluation> goodEvaluationQueryWrapper = new LambdaQueryWrapper<>();
|
||||
goodEvaluationQueryWrapper.eq(MemberEvaluation::getId, goodsId);
|
||||
goodEvaluationQueryWrapper.eq(MemberEvaluation::getGrade, EvaluationGradeEnum.GOOD.name());
|
||||
//修改商品评价数量
|
||||
long commentNum = memberEvaluationService.getEvaluationCount(EvaluationQueryParams.builder().goodsId(goodsId).build());
|
||||
goods.setCommentNum((int) (commentNum));
|
||||
|
||||
//好评数量
|
||||
long highPraiseNum = memberEvaluationService.count(goodEvaluationQueryWrapper);
|
||||
long highPraiseNum = memberEvaluationService.getEvaluationCount(EvaluationQueryParams.builder().goodsId(goodsId).grade(EvaluationGradeEnum.GOOD.name()).build());
|
||||
//好评率
|
||||
double grade = NumberUtil.mul(NumberUtil.div(highPraiseNum, goods.getCommentNum().doubleValue(), 2), 100);
|
||||
goods.setGrade(grade);
|
||||
this.updateById(goods);
|
||||
|
||||
cache.remove(CachePrefix.GOODS.getPrefix() + goodsId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,7 +3,6 @@ package cn.lili.modules.goods.serviceimpl;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.cache.Cache;
|
||||
@ -148,7 +147,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
|
||||
if (!goodsSkus.isEmpty()) {
|
||||
this.saveOrUpdateBatch(goodsSkus);
|
||||
this.updateStock(goodsSkus);
|
||||
this.updateGoodsStock(goodsSkus);
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,7 +198,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
skuList.stream().map(BaseEntity::getId).collect(Collectors.toList()));
|
||||
this.remove(unnecessarySkuIdsQuery);
|
||||
this.saveOrUpdateBatch(skuList);
|
||||
this.updateStock(skuList);
|
||||
this.updateGoodsStock(skuList);
|
||||
}
|
||||
}
|
||||
|
||||
@ -385,7 +384,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
List<GoodsSku> goodsSkus = this.getGoodsSkuListByGoodsId(goods.getId());
|
||||
for (GoodsSku sku : goodsSkus) {
|
||||
cache.remove(GoodsSkuService.getCacheKeys(sku.getId()));
|
||||
cache.put(GoodsSkuService.getCacheKeys(sku.getId()), sku);
|
||||
if (GoodsStatusEnum.UPPER.name().equals(goods.getMarketEnable()) && GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag())) {
|
||||
cache.put(GoodsSkuService.getCacheKeys(sku.getId()), sku);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -520,8 +521,23 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateStocks(List<GoodsSkuStockDTO> goodsSkuStockDTOS) {
|
||||
for (GoodsSkuStockDTO goodsSkuStockDTO : goodsSkuStockDTOS) {
|
||||
this.updateStock(goodsSkuStockDTO.getSkuId(), goodsSkuStockDTO.getQuantity());
|
||||
List<String> skuIds = goodsSkuStockDTOS.stream().map(GoodsSkuStockDTO::getSkuId).collect(Collectors.toList());
|
||||
List<GoodsSkuStockDTO> goodsSkuStockList = this.baseMapper.queryStocks(GoodsSearchParams.builder().ids(skuIds).build().queryWrapper());
|
||||
Map<String, List<GoodsSkuStockDTO>> groupByGoodsIds = goodsSkuStockList.stream().collect(Collectors.groupingBy(GoodsSkuStockDTO::getGoodsId));
|
||||
|
||||
//统计每个商品的库存
|
||||
for (Map.Entry<String, List<GoodsSkuStockDTO>> entry : groupByGoodsIds.entrySet()) {
|
||||
//库存
|
||||
Integer quantity = 0;
|
||||
for (GoodsSkuStockDTO goodsSku : entry.getValue()) {
|
||||
goodsSkuStockDTOS.stream().filter(i -> i.getSkuId().equals(goodsSku.getSkuId())).findFirst().ifPresent(i -> goodsSku.setQuantity(i.getQuantity()));
|
||||
if (entry.getKey().equals(goodsSku.getGoodsId())) {
|
||||
quantity += goodsSku.getQuantity();
|
||||
}
|
||||
this.updateStock(goodsSku.getSkuId(), goodsSku.getQuantity());
|
||||
}
|
||||
//保存商品库存结果
|
||||
goodsService.updateStock(entry.getKey(), quantity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -531,28 +547,23 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
GoodsSku goodsSku = getGoodsSkuByIdFromCache(skuId);
|
||||
if (goodsSku != null) {
|
||||
//判断商品sku是否已经下架(修改商品库存为0时 会自动下架商品),再次更新商品库存时 需更新商品索引
|
||||
Boolean isFlag = goodsSku.getQuantity()<= 0;
|
||||
boolean isFlag = goodsSku.getQuantity() <= 0;
|
||||
|
||||
goodsSku.setQuantity(quantity);
|
||||
boolean update =
|
||||
this.update(new LambdaUpdateWrapper<GoodsSku>().eq(GoodsSku::getId, skuId).set(GoodsSku::getQuantity, quantity));
|
||||
boolean update = this.update(new LambdaUpdateWrapper<GoodsSku>().eq(GoodsSku::getId, skuId).set(GoodsSku::getQuantity, quantity));
|
||||
if (update) {
|
||||
cache.remove(CachePrefix.GOODS.getPrefix() + goodsSku.getGoodsId());
|
||||
}
|
||||
cache.put(GoodsSkuService.getCacheKeys(skuId), goodsSku);
|
||||
cache.put(GoodsSkuService.getStockCacheKey(skuId), quantity);
|
||||
|
||||
//更新商品库存
|
||||
List<GoodsSku> goodsSkus = new ArrayList<>();
|
||||
goodsSkus.add(goodsSku);
|
||||
this.updateGoodsStuck(goodsSkus);
|
||||
this.promotionGoodsService.updatePromotionGoodsStock(goodsSku.getId(), quantity);
|
||||
//商品库存为0是删除商品索引
|
||||
if (quantity <= 0) {
|
||||
goodsIndexService.deleteIndexById(goodsSku.getId());
|
||||
}
|
||||
//商品SKU库存为0并且商品sku状态为上架时更新商品库存
|
||||
if(isFlag && StrUtil.equals(goodsSku.getMarketEnable(),GoodsStatusEnum.UPPER.name())) {
|
||||
if (isFlag && CharSequenceUtil.equals(goodsSku.getMarketEnable(), GoodsStatusEnum.UPPER.name())) {
|
||||
List<String> goodsIds = new ArrayList<>();
|
||||
goodsIds.add(goodsSku.getGoodsId());
|
||||
applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("更新商品", rocketmqCustomProperties.getGoodsTopic(), GoodsTagsEnum.UPDATE_GOODS_INDEX.name(), goodsIds));
|
||||
@ -575,22 +586,18 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateGoodsStuck(List<GoodsSku> goodsSkus) {
|
||||
Map<String, List<GoodsSku>> groupByGoodsIds =
|
||||
goodsSkus.stream().collect(Collectors.groupingBy(GoodsSku::getGoodsId));
|
||||
//获取相关的sku集合
|
||||
LambdaQueryWrapper<GoodsSku> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.in(GoodsSku::getGoodsId, groupByGoodsIds.keySet());
|
||||
List<GoodsSku> goodsSkuList = this.list(lambdaQueryWrapper);
|
||||
public void updateGoodsStock(List<GoodsSku> goodsSkus) {
|
||||
Map<String, List<GoodsSku>> groupByGoodsIds = goodsSkus.stream().collect(Collectors.groupingBy(GoodsSku::getGoodsId));
|
||||
|
||||
//统计每个商品的库存
|
||||
for (String goodsId : groupByGoodsIds.keySet()) {
|
||||
//库存
|
||||
Integer quantity = 0;
|
||||
for (GoodsSku goodsSku : goodsSkuList) {
|
||||
for (GoodsSku goodsSku : goodsSkus) {
|
||||
if (goodsId.equals(goodsSku.getGoodsId())) {
|
||||
quantity += goodsSku.getQuantity();
|
||||
}
|
||||
this.updateStock(goodsSku.getId(), goodsSku.getQuantity());
|
||||
}
|
||||
//保存商品库存结果
|
||||
goodsService.updateStock(goodsId, quantity);
|
||||
@ -605,20 +612,18 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
//获取商品信息
|
||||
GoodsSku goodsSku = this.getGoodsSkuByIdFromCache(skuId);
|
||||
|
||||
EvaluationQueryParams queryParams = new EvaluationQueryParams();
|
||||
queryParams.setGrade(EvaluationGradeEnum.GOOD.name());
|
||||
queryParams.setSkuId(goodsSku.getId());
|
||||
//好评数量
|
||||
long highPraiseNum = memberEvaluationService.getEvaluationCount(queryParams);
|
||||
long highPraiseNum = memberEvaluationService.getEvaluationCount(EvaluationQueryParams.builder().grade(EvaluationGradeEnum.GOOD.name()).skuId(skuId).build());
|
||||
|
||||
//更新商品评价数量
|
||||
goodsSku.setCommentNum(goodsSku.getCommentNum() != null ? goodsSku.getCommentNum() + 1 : 1);
|
||||
long commentNum = memberEvaluationService.getEvaluationCount(EvaluationQueryParams.builder().skuId(skuId).build());
|
||||
goodsSku.setCommentNum((int) commentNum);
|
||||
|
||||
//好评率
|
||||
double grade = NumberUtil.mul(NumberUtil.div(highPraiseNum, goodsSku.getCommentNum().doubleValue(), 2), 100);
|
||||
goodsSku.setGrade(grade);
|
||||
//修改规格
|
||||
this.update(goodsSku);
|
||||
this.updateGoodsSkuGrade(skuId, grade, goodsSku.getCommentNum());
|
||||
|
||||
|
||||
//修改规格索引,发送mq消息
|
||||
@ -633,6 +638,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
|
||||
//修改商品的评价数量
|
||||
goodsService.updateGoodsCommentNum(goodsSku.getGoodsId());
|
||||
clearCache(skuId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -667,22 +673,6 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
return this.count(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改库存
|
||||
*
|
||||
* @param goodsSkus 商品SKU
|
||||
*/
|
||||
private void updateStock(List<GoodsSku> goodsSkus) {
|
||||
//总库存数量
|
||||
Integer quantity = 0;
|
||||
for (GoodsSku sku : goodsSkus) {
|
||||
this.updateStock(sku.getId(), sku.getQuantity());
|
||||
quantity += sku.getQuantity();
|
||||
}
|
||||
//修改商品库存
|
||||
goodsService.updateStock(goodsSkus.get(0).getGoodsId(), quantity);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量渲染商品sku
|
||||
@ -700,6 +690,23 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateGoodsSkuBuyCount(String skuId, int buyCount) {
|
||||
LambdaUpdateWrapper<GoodsSku> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(GoodsSku::getId, skuId);
|
||||
updateWrapper.set(GoodsSku::getBuyCount, buyCount);
|
||||
this.update(updateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateGoodsSkuGrade(String skuId, double grade, int commentNum) {
|
||||
LambdaUpdateWrapper<GoodsSku> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(GoodsSku::getId, skuId);
|
||||
updateWrapper.set(GoodsSku::getGrade, grade);
|
||||
updateWrapper.set(GoodsSku::getCommentNum, commentNum);
|
||||
this.update(updateWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染商品sku
|
||||
*
|
||||
|
@ -0,0 +1,47 @@
|
||||
package cn.lili.modules.im.entity.dto;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.modules.im.entity.dos.ImTalk;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author paulG
|
||||
* @since 2023/2/6
|
||||
**/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class IMTalkQueryParams {
|
||||
|
||||
@ApiModelProperty("用户1 id")
|
||||
private String userId1;
|
||||
|
||||
@ApiModelProperty("用户2 id")
|
||||
private String userId2;
|
||||
|
||||
@ApiModelProperty("用户1 name")
|
||||
private String name1;
|
||||
|
||||
@ApiModelProperty("用户2 name")
|
||||
private String name2;
|
||||
|
||||
@ApiModelProperty("关键字")
|
||||
private String userName;
|
||||
|
||||
|
||||
public QueryWrapper<ImTalk> queryWrapper() {
|
||||
QueryWrapper<ImTalk> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(CharSequenceUtil.isNotEmpty(userId1), "user_id1", this.userId1);
|
||||
queryWrapper.eq(CharSequenceUtil.isNotEmpty(userId2), "user_id2", this.userId2);
|
||||
queryWrapper.eq(CharSequenceUtil.isNotEmpty(name1), "name1", this.name1);
|
||||
queryWrapper.eq(CharSequenceUtil.isNotEmpty(name2), "name2", this.name2);
|
||||
queryWrapper.nested(CharSequenceUtil.isNotEmpty(userName), i -> i.like("name1", userName).or().like("name2", userName));
|
||||
return queryWrapper;
|
||||
}
|
||||
}
|
@ -6,15 +6,19 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author chc
|
||||
* @since 2022/6/2114:46
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@ApiModel
|
||||
public class ImQueryParams extends PageVO {
|
||||
|
||||
private static final long serialVersionUID = 5792718094087541134L;
|
||||
|
||||
@ApiModelProperty("用户Id")
|
||||
private String memberId;
|
||||
|
||||
@ -29,7 +33,7 @@ public class ImQueryParams extends PageVO {
|
||||
if (CharSequenceUtil.isNotEmpty(storeId)) {
|
||||
queryWrapper.eq("store_id", storeId);
|
||||
}
|
||||
queryWrapper.eq("delete_flag",false);
|
||||
queryWrapper.eq("delete_flag", false);
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
return queryWrapper;
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
package cn.lili.modules.im.entity.dto;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.im.entity.dos.ImMessage;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* MessageQueryParams
|
||||
@ -15,8 +16,12 @@ import lombok.Data;
|
||||
* @version v1.0
|
||||
* 2022-01-20 17:16
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class MessageQueryParams extends PageVO {
|
||||
|
||||
private static final long serialVersionUID = 3504156704697214077L;
|
||||
|
||||
/**
|
||||
* 聊天窗口
|
||||
*/
|
||||
@ -31,7 +36,7 @@ public class MessageQueryParams extends PageVO {
|
||||
private Integer num;
|
||||
|
||||
public LambdaQueryWrapper<ImMessage> initQueryWrapper() {
|
||||
if (StringUtils.isEmpty(talkId)) {
|
||||
if (CharSequenceUtil.isEmpty(talkId)) {
|
||||
throw new ServiceException(ResultCode.ERROR);
|
||||
}
|
||||
if (num == null || num > 50) {
|
||||
@ -40,7 +45,7 @@ public class MessageQueryParams extends PageVO {
|
||||
|
||||
LambdaQueryWrapper<ImMessage> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(ImMessage::getTalkId, talkId);
|
||||
if (StringUtils.isNotEmpty(lastMessageId)) {
|
||||
if (CharSequenceUtil.isNotEmpty(lastMessageId)) {
|
||||
lambdaQueryWrapper.lt(ImMessage::getId, lastMessageId);
|
||||
}
|
||||
lambdaQueryWrapper.orderByDesc(ImMessage::getCreateTime);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.lili.modules.im.service;
|
||||
|
||||
import cn.lili.modules.im.entity.dos.ImTalk;
|
||||
import cn.lili.modules.im.entity.dto.IMTalkQueryParams;
|
||||
import cn.lili.modules.im.entity.vo.ImTalkVO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
@ -45,13 +46,13 @@ public interface ImTalkService extends IService<ImTalk> {
|
||||
|
||||
/**
|
||||
* 获取用户聊天列表
|
||||
* @return
|
||||
* @return 用户聊天列表
|
||||
*/
|
||||
List<ImTalkVO> getUserTalkList();
|
||||
List<ImTalkVO> getUserTalkList(IMTalkQueryParams imTalkQueryParams);
|
||||
|
||||
/**
|
||||
* 获取商家聊天列表
|
||||
* @return
|
||||
* @return 商家聊天列表
|
||||
*/
|
||||
List<ImTalkVO> getStoreTalkList();
|
||||
List<ImTalkVO> getStoreTalkList(IMTalkQueryParams imTalkQueryParams);
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.modules.im.serviceimpl;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
@ -7,6 +8,7 @@ import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.modules.im.entity.dos.ImMessage;
|
||||
import cn.lili.modules.im.entity.dos.ImTalk;
|
||||
import cn.lili.modules.im.entity.dto.IMTalkQueryParams;
|
||||
import cn.lili.modules.im.entity.vo.ImTalkVO;
|
||||
import cn.lili.modules.im.mapper.ImTalkMapper;
|
||||
import cn.lili.modules.im.service.ImMessageService;
|
||||
@ -51,35 +53,35 @@ public class ImTalkServiceImpl extends ServiceImpl<ImTalkMapper, ImTalk> impleme
|
||||
//登录用户的Id
|
||||
String selfId = "";
|
||||
//查看当前用户角色对Id进行赋值
|
||||
if(UserEnums.STORE.equals(currentUser.getRole())){
|
||||
if (UserEnums.STORE.equals(currentUser.getRole())) {
|
||||
selfId = currentUser.getStoreId();
|
||||
}else if(UserEnums.MEMBER.equals(currentUser.getRole())){
|
||||
} else if (UserEnums.MEMBER.equals(currentUser.getRole())) {
|
||||
selfId = currentUser.getId();
|
||||
}
|
||||
//小数在前保证永远是同一个对话
|
||||
String finalSelfId = selfId;
|
||||
queryWrapper.and(wq-> wq.eq(ImTalk::getUserId2, userId).eq(ImTalk::getUserId1, finalSelfId).or().eq(ImTalk::getUserId2, finalSelfId).eq(ImTalk::getUserId1, userId));
|
||||
queryWrapper.and(wq -> wq.eq(ImTalk::getUserId2, userId).eq(ImTalk::getUserId1, finalSelfId).or().eq(ImTalk::getUserId2, finalSelfId).eq(ImTalk::getUserId1, userId));
|
||||
ImTalk imTalk = this.getOne(queryWrapper);
|
||||
//如果没有聊天,则创建聊天
|
||||
if (imTalk == null) {
|
||||
//当自己为店铺时
|
||||
if(UserEnums.STORE.equals(currentUser.getRole())){
|
||||
if (UserEnums.STORE.equals(currentUser.getRole())) {
|
||||
Store selfStore = storeService.getById(selfId);
|
||||
//没有这个用户信息
|
||||
Member other = memberService.getById(userId);
|
||||
if(other == null){
|
||||
if (other == null) {
|
||||
return null;
|
||||
}
|
||||
//自己为店铺其他人必定为用户
|
||||
imTalk = new ImTalk(other,selfStore);
|
||||
}else if(UserEnums.MEMBER.equals(currentUser.getRole())){
|
||||
imTalk = new ImTalk(other, selfStore);
|
||||
} else if (UserEnums.MEMBER.equals(currentUser.getRole())) {
|
||||
//没有这个店铺信息
|
||||
Member self = memberService.getById(selfId);
|
||||
Member otherMember = memberService.getById(userId);
|
||||
Store otherStore = storeService.getById(userId);
|
||||
if(otherStore != null){
|
||||
if (otherStore != null) {
|
||||
imTalk = new ImTalk(self, otherStore);
|
||||
}else if (otherMember != null){
|
||||
} else if (otherMember != null) {
|
||||
imTalk = new ImTalk(self, otherMember);
|
||||
}
|
||||
}
|
||||
@ -95,41 +97,41 @@ public class ImTalkServiceImpl extends ServiceImpl<ImTalkMapper, ImTalk> impleme
|
||||
//登录用户的Id
|
||||
String selfId = "";
|
||||
//查看当前用户角色对Id进行赋值
|
||||
if(UserEnums.STORE.equals(currentUser.getRole())){
|
||||
if (UserEnums.STORE.equals(currentUser.getRole())) {
|
||||
selfId = currentUser.getStoreId();
|
||||
}else if(UserEnums.MEMBER.equals(currentUser.getRole())){
|
||||
} else if (UserEnums.MEMBER.equals(currentUser.getRole())) {
|
||||
selfId = currentUser.getId();
|
||||
}
|
||||
//小数在前保证永远是同一个对话
|
||||
String finalSelfId = selfId;
|
||||
queryWrapper.and(wq-> wq.eq(ImTalk::getUserId2, userId).eq(ImTalk::getUserId1, finalSelfId).or().eq(ImTalk::getUserId2, finalSelfId).eq(ImTalk::getUserId1, userId));
|
||||
queryWrapper.and(wq -> wq.eq(ImTalk::getUserId2, userId).eq(ImTalk::getUserId1, finalSelfId).or().eq(ImTalk::getUserId2, finalSelfId).eq(ImTalk::getUserId1, userId));
|
||||
ImTalk imTalk = this.getOne(queryWrapper);
|
||||
//如果没有聊天,则创建聊天
|
||||
if (imTalk == null) {
|
||||
//当自己为店铺时
|
||||
if(UserEnums.STORE.equals(currentUser.getRole())){
|
||||
if (UserEnums.STORE.equals(currentUser.getRole())) {
|
||||
Store selfStore = storeService.getById(selfId);
|
||||
//没有这个用户信息
|
||||
Member other = memberService.getById(userId);
|
||||
if(other == null){
|
||||
if (other == null) {
|
||||
return null;
|
||||
}
|
||||
//自己为店铺其他人必定为用户
|
||||
imTalk = new ImTalk(other,selfStore);
|
||||
}else if(UserEnums.MEMBER.equals(currentUser.getRole())){
|
||||
imTalk = new ImTalk(other, selfStore);
|
||||
} else if (UserEnums.MEMBER.equals(currentUser.getRole())) {
|
||||
//没有这个店铺信息
|
||||
Member self = memberService.getById(selfId);
|
||||
Member otherMember = memberService.getById(userId);
|
||||
Store otherStore = storeService.getById(userId);
|
||||
if(otherStore != null){
|
||||
if (otherStore != null) {
|
||||
imTalk = new ImTalk(self, otherStore);
|
||||
}else if (otherMember != null){
|
||||
} else if (otherMember != null) {
|
||||
imTalk = new ImTalk(self, otherMember);
|
||||
}
|
||||
}
|
||||
this.save(imTalk);
|
||||
}
|
||||
return new ImTalkVO(imTalk,currentUser.getId());
|
||||
return new ImTalkVO(imTalk, currentUser.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,13 +175,16 @@ public class ImTalkServiceImpl extends ServiceImpl<ImTalkMapper, ImTalk> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ImTalkVO> getUserTalkList() {
|
||||
public List<ImTalkVO> getUserTalkList(IMTalkQueryParams imTalkQueryParams) {
|
||||
AuthUser authUser = UserContext.getCurrentUser();
|
||||
if(authUser == null){
|
||||
if (authUser == null) {
|
||||
throw new ServiceException(ResultCode.USER_NOT_LOGIN);
|
||||
}
|
||||
LambdaQueryWrapper<ImTalk> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.and(wq-> wq.eq(ImTalk::getUserId1, authUser.getId()).or().eq(ImTalk::getUserId2,authUser.getId()));
|
||||
queryWrapper.and(wq -> wq.eq(ImTalk::getUserId1, authUser.getId()).or().eq(ImTalk::getUserId2, authUser.getId()));
|
||||
if (CharSequenceUtil.isNotEmpty(imTalkQueryParams.getUserName())) {
|
||||
queryWrapper.and(wq -> wq.ne(ImTalk::getUserId1, authUser.getId()).like(ImTalk::getName1, imTalkQueryParams.getUserName()).or().ne(ImTalk::getUserId2, authUser.getId()).like(ImTalk::getName2, imTalkQueryParams.getUserName()));
|
||||
}
|
||||
queryWrapper.orderByDesc(ImTalk::getLastTalkTime);
|
||||
List<ImTalk> imTalks = this.list(queryWrapper);
|
||||
List<ImTalkVO> imTalkVOList = imTalks.stream().map(imTalk -> new ImTalkVO(imTalk, authUser.getId())).collect(Collectors.toList());
|
||||
@ -188,33 +193,33 @@ public class ImTalkServiceImpl extends ServiceImpl<ImTalkMapper, ImTalk> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ImTalkVO> getStoreTalkList() {
|
||||
public List<ImTalkVO> getStoreTalkList(IMTalkQueryParams imTalkQueryParams) {
|
||||
AuthUser authUser = UserContext.getCurrentUser();
|
||||
if(authUser == null){
|
||||
if (authUser == null) {
|
||||
throw new ServiceException(ResultCode.STORE_NOT_LOGIN_ERROR);
|
||||
}
|
||||
LambdaQueryWrapper<ImTalk> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.and(wq->{
|
||||
wq.eq(ImTalk::getUserId1, authUser.getStoreId()).or().eq(ImTalk::getUserId2,authUser.getStoreId());
|
||||
});
|
||||
queryWrapper.and(wq -> wq.eq(ImTalk::getUserId1, authUser.getStoreId()).or().eq(ImTalk::getUserId2, authUser.getStoreId()));
|
||||
if (CharSequenceUtil.isNotEmpty(imTalkQueryParams.getUserName())) {
|
||||
queryWrapper.and(wq -> wq.ne(ImTalk::getUserId1, authUser.getStoreId()).like(ImTalk::getName1, imTalkQueryParams.getUserName()).or().ne(ImTalk::getUserId2, authUser.getStoreId()).like(ImTalk::getName2, imTalkQueryParams.getUserName()));
|
||||
}
|
||||
queryWrapper.orderByDesc(ImTalk::getLastTalkTime);
|
||||
List<ImTalk> imTalks = this.list(queryWrapper);
|
||||
|
||||
List<ImTalkVO> imTalkVOList = imTalks.stream().map(imTalk -> {
|
||||
return new ImTalkVO(imTalk, authUser.getStoreId());
|
||||
}).collect(Collectors.toList());
|
||||
List<ImTalkVO> imTalkVOList = imTalks.stream().map(imTalk -> new ImTalkVO(imTalk, authUser.getStoreId())).collect(Collectors.toList());
|
||||
getUnread(imTalkVOList);
|
||||
return imTalkVOList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取未读消息数量
|
||||
*
|
||||
* @param imTalkVOList 消息列表
|
||||
*/
|
||||
private void getUnread(List<ImTalkVO> imTalkVOList){
|
||||
if(!imTalkVOList.isEmpty()){
|
||||
private void getUnread(List<ImTalkVO> imTalkVOList) {
|
||||
if (!imTalkVOList.isEmpty()) {
|
||||
for (ImTalkVO imTalkVO : imTalkVOList) {
|
||||
long count = imMessageService.count(new LambdaQueryWrapper<ImMessage>().eq(ImMessage::getFromUser, imTalkVO.getUserId()).eq(ImMessage::getTalkId,imTalkVO.getId()).eq(ImMessage::getIsRead, false));
|
||||
long count = imMessageService.count(new LambdaQueryWrapper<ImMessage>().eq(ImMessage::getFromUser, imTalkVO.getUserId()).eq(ImMessage::getTalkId, imTalkVO.getId()).eq(ImMessage::getIsRead, false));
|
||||
imTalkVO.setUnread(count);
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,7 @@ import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 评价查询条件
|
||||
@ -15,8 +14,13 @@ import lombok.EqualsAndHashCode;
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class EvaluationQueryParams extends PageVO {
|
||||
|
||||
private static final long serialVersionUID = 2038158669175297129L;
|
||||
|
||||
@ApiModelProperty(value = "ID")
|
||||
private String id;
|
||||
|
||||
|
@ -6,6 +6,7 @@ import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.SwitchEnum;
|
||||
import cn.lili.common.event.TransactionCommitSendMQEvent;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.properties.RocketmqCustomProperties;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
@ -31,7 +32,6 @@ import cn.lili.modules.order.order.entity.enums.CommentStatusEnum;
|
||||
import cn.lili.modules.order.order.service.OrderItemService;
|
||||
import cn.lili.modules.order.order.service.OrderService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
|
||||
import cn.lili.rocketmq.tags.GoodsTagsEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@ -40,8 +40,8 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@ -77,17 +77,15 @@ public class MemberEvaluationServiceImpl extends ServiceImpl<MemberEvaluationMap
|
||||
*/
|
||||
@Autowired
|
||||
private GoodsSkuService goodsSkuService;
|
||||
/**
|
||||
* rocketMq
|
||||
*/
|
||||
@Autowired
|
||||
private RocketMQTemplate rocketMQTemplate;
|
||||
/**
|
||||
* rocketMq配置
|
||||
*/
|
||||
@Autowired
|
||||
private RocketmqCustomProperties rocketmqCustomProperties;
|
||||
|
||||
@Autowired
|
||||
private ApplicationEventPublisher applicationEventPublisher;
|
||||
|
||||
@Override
|
||||
public IPage<MemberEvaluation> managerQuery(EvaluationQueryParams queryParams) {
|
||||
//获取评价分页
|
||||
@ -133,8 +131,8 @@ public class MemberEvaluationServiceImpl extends ServiceImpl<MemberEvaluationMap
|
||||
//修改订单货物评价状态为已评价
|
||||
orderItemService.updateCommentStatus(orderItem.getSn(), CommentStatusEnum.FINISHED);
|
||||
//发送商品评价消息
|
||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GOODS_COMMENT_COMPLETE.name();
|
||||
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(memberEvaluation), RocketmqSendCallbackBuilder.commonCallback());
|
||||
applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("同步商品评价消息",
|
||||
rocketmqCustomProperties.getGoodsTopic(), GoodsTagsEnum.GOODS_COMMENT_COMPLETE.name(), JSONUtil.toJsonStr(memberEvaluation)));
|
||||
return memberEvaluationDTO;
|
||||
}
|
||||
|
||||
|
@ -16,14 +16,6 @@ public enum ComplaintStatusEnum {
|
||||
* 已撤销
|
||||
*/
|
||||
CANCEL("已撤销"),
|
||||
/**
|
||||
* 待申诉
|
||||
*/
|
||||
WAIT_APPEAL("待申诉"),
|
||||
/**
|
||||
* 对话中
|
||||
*/
|
||||
COMMUNICATION("对话中"),
|
||||
/**
|
||||
* 等待仲裁
|
||||
*/
|
||||
|
@ -22,6 +22,11 @@ import java.util.Date;
|
||||
@Data
|
||||
public class AfterSaleSearchParams extends PageVO {
|
||||
|
||||
private static final long serialVersionUID = 28604026820923515L;
|
||||
|
||||
@ApiModelProperty(value = "关键字")
|
||||
private String keywords;
|
||||
|
||||
@ApiModelProperty(value = "售后服务单号")
|
||||
private String sn;
|
||||
|
||||
@ -71,6 +76,10 @@ public class AfterSaleSearchParams extends PageVO {
|
||||
|
||||
public <T> QueryWrapper<T> queryWrapper() {
|
||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||
if (CharSequenceUtil.isNotEmpty(keywords)) {
|
||||
queryWrapper.and(wrapper -> wrapper.like("sn", keywords).or().like("order_sn", keywords).or().like("goods_name", keywords));
|
||||
}
|
||||
|
||||
if (CharSequenceUtil.isNotEmpty(sn)) {
|
||||
queryWrapper.like("sn", sn);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package cn.lili.modules.order.order.entity.vo;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.modules.order.aftersale.entity.enums.ComplaintStatusEnum;
|
||||
import cn.lili.modules.order.order.entity.dos.OrderComplaint;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@ -39,22 +39,22 @@ public class OrderComplaintSearchParams {
|
||||
|
||||
public LambdaQueryWrapper<OrderComplaint> lambdaQueryWrapper() {
|
||||
LambdaQueryWrapper<OrderComplaint> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (StrUtil.isNotEmpty(status)) {
|
||||
if (CharSequenceUtil.isNotEmpty(status)) {
|
||||
queryWrapper.eq(OrderComplaint::getComplainStatus, status);
|
||||
}
|
||||
if (StrUtil.isNotEmpty(orderSn)) {
|
||||
queryWrapper.eq(OrderComplaint::getOrderSn, orderSn);
|
||||
if (CharSequenceUtil.isNotEmpty(orderSn)) {
|
||||
queryWrapper.like(OrderComplaint::getOrderSn, orderSn);
|
||||
}
|
||||
if (StrUtil.isNotEmpty(storeName)) {
|
||||
if (CharSequenceUtil.isNotEmpty(storeName)) {
|
||||
queryWrapper.like(OrderComplaint::getStoreName, storeName);
|
||||
}
|
||||
if (StrUtil.isNotEmpty(storeId)) {
|
||||
if (CharSequenceUtil.isNotEmpty(storeId)) {
|
||||
queryWrapper.eq(OrderComplaint::getStoreId, storeId);
|
||||
}
|
||||
if (StrUtil.isNotEmpty(memberName)) {
|
||||
if (CharSequenceUtil.isNotEmpty(memberName)) {
|
||||
queryWrapper.like(OrderComplaint::getMemberName, memberName);
|
||||
}
|
||||
if (StrUtil.isNotEmpty(memberId)) {
|
||||
if (CharSequenceUtil.isNotEmpty(memberId)) {
|
||||
queryWrapper.eq(OrderComplaint::getMemberId, memberId);
|
||||
}
|
||||
queryWrapper.eq(OrderComplaint::getDeleteFlag, false);
|
||||
|
@ -255,12 +255,6 @@ public class OrderComplaintServiceImpl extends ServiceImpl<OrderComplaintMapper,
|
||||
throw new ServiceException(ResultCode.COMPLAINT_ARBITRATION_RESULT_ERROR);
|
||||
}
|
||||
orderComplaint.setArbitrationResult(operationParam.getArbitrationResult());
|
||||
} else if (complaintStatusEnum == ComplaintStatusEnum.COMMUNICATION) {
|
||||
if (CharSequenceUtil.isEmpty(operationParam.getAppealContent()) || operationParam.getImages() == null) {
|
||||
throw new ServiceException(ResultCode.COMPLAINT_APPEAL_CONTENT_ERROR);
|
||||
}
|
||||
orderComplaint.setContent(operationParam.getAppealContent());
|
||||
orderComplaint.setImages(operationParam.getImages().get(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ public interface PageDataMapper extends BaseMapper<PageData> {
|
||||
* @return 页面数量
|
||||
*/
|
||||
@Select("SELECT COUNT(id) FROM li_page_data ${ew.customSqlSegment}")
|
||||
Integer getPageDataNum(@Param(Constants.WRAPPER) Wrapper<Integer> queryWrapper);
|
||||
Integer getPageDataNum(@Param(Constants.WRAPPER) Wrapper<PageData> queryWrapper);
|
||||
|
||||
/**
|
||||
* 获取页面数据分页
|
||||
|
@ -6,6 +6,7 @@ import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.SwitchEnum;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.properties.SystemSettingProperties;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
@ -27,6 +28,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 楼层装修管理业务层实现
|
||||
*
|
||||
@ -63,21 +66,17 @@ public class PageDataServiceImpl extends ServiceImpl<PageDataMapper, PageData> i
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public PageData addPageData(PageData pageData) {
|
||||
|
||||
|
||||
AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser());
|
||||
//演示站点判定
|
||||
if (systemSettingProperties.getDemoSite()) {
|
||||
//如果开启页面,并且是平台楼层装修
|
||||
if (pageData.getPageShow().equals(SwitchEnum.OPEN.name()) && pageData.getPageType().equals(PageEnum.INDEX.name())) {
|
||||
if (Boolean.TRUE.equals(systemSettingProperties.getDemoSite()) && (pageData.getPageShow().equals(SwitchEnum.OPEN.name()) && pageData.getPageType().equals(PageEnum.INDEX.name()))) {
|
||||
pageData.setPageShow(SwitchEnum.CLOSE.name());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//如果页面为发布,则关闭其他页面,开启此页面
|
||||
if (pageData.getPageShow().equals(SwitchEnum.OPEN.name())) {
|
||||
LambdaUpdateWrapper<PageData> lambdaUpdateWrapper = Wrappers.lambdaUpdate();
|
||||
lambdaUpdateWrapper.eq(CharSequenceUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name()), PageData::getNum
|
||||
lambdaUpdateWrapper.eq(CharSequenceUtil.equals(currentUser.getRole().name(), UserEnums.STORE.name()), PageData::getNum
|
||||
, UserContext.getCurrentUser().getStoreId());
|
||||
lambdaUpdateWrapper.eq(PageData::getPageType, pageData.getPageType());
|
||||
lambdaUpdateWrapper.eq(PageData::getPageClientType, pageData.getPageClientType());
|
||||
@ -93,6 +92,7 @@ public class PageDataServiceImpl extends ServiceImpl<PageDataMapper, PageData> i
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public PageData updatePageData(PageData pageData) {
|
||||
AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser());
|
||||
//如果页面为发布,则关闭其他页面,开启此页面
|
||||
if (pageData.getPageShow() != null && pageData.getPageShow().equals(SwitchEnum.OPEN.name())) {
|
||||
LambdaUpdateWrapper<PageData> lambdaUpdateWrapper = Wrappers.lambdaUpdate();
|
||||
@ -101,7 +101,7 @@ public class PageDataServiceImpl extends ServiceImpl<PageDataMapper, PageData> i
|
||||
pageData.getPageClientType());
|
||||
|
||||
//如果是管理员,则判定页面num为null
|
||||
if (UserContext.getCurrentUser().getRole().name().equals(UserEnums.MANAGER.name())) {
|
||||
if (currentUser.getRole().name().equals(UserEnums.MANAGER.name())) {
|
||||
lambdaUpdateWrapper.isNull(PageData::getNum);
|
||||
} else {
|
||||
lambdaUpdateWrapper.eq(PageData::getNum, pageData.getNum());
|
||||
@ -127,12 +127,7 @@ public class PageDataServiceImpl extends ServiceImpl<PageDataMapper, PageData> i
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public PageData releasePageData(String id) {
|
||||
PageData pageData = this.getOne(new LambdaQueryWrapper<PageData>()
|
||||
.eq(CharSequenceUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name()), PageData::getPageType,
|
||||
PageEnum.STORE.name())
|
||||
.eq(CharSequenceUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name()), PageData::getNum,
|
||||
UserContext.getCurrentUser().getStoreId())
|
||||
.eq(PageData::getId, id));
|
||||
PageData pageData = this.getCurrentPageData(id);
|
||||
if (pageData == null) {
|
||||
throw new ServiceException(ResultCode.PAGE_NOT_EXIST);
|
||||
}
|
||||
@ -164,12 +159,7 @@ public class PageDataServiceImpl extends ServiceImpl<PageDataMapper, PageData> i
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean removePageData(String id) {
|
||||
PageData pageData = this.getOne(new LambdaQueryWrapper<PageData>()
|
||||
.eq(CharSequenceUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name()), PageData::getPageType,
|
||||
PageEnum.STORE.name())
|
||||
.eq(CharSequenceUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name()), PageData::getNum,
|
||||
UserContext.getCurrentUser().getStoreId())
|
||||
.eq(PageData::getId, id));
|
||||
PageData pageData = this.getCurrentPageData(id);
|
||||
if (pageData == null) {
|
||||
throw new ServiceException(ResultCode.PAGE_NOT_EXIST);
|
||||
}
|
||||
@ -183,12 +173,12 @@ public class PageDataServiceImpl extends ServiceImpl<PageDataMapper, PageData> i
|
||||
throw new ServiceException(ResultCode.PAGE_OPEN_DELETE_ERROR);
|
||||
}
|
||||
//判断是否有其他页面,如果没有其他的页面则无法进行删除
|
||||
QueryWrapper<Integer> queryWrapper = Wrappers.query();
|
||||
queryWrapper.eq(pageData.getPageType() != null, "page_type", pageData.getPageType());
|
||||
queryWrapper.eq(pageData.getPageClientType() != null, "page_client_type", pageData.getPageClientType());
|
||||
LambdaQueryWrapper<PageData> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(PageData::getPageType, pageData.getPageType());
|
||||
queryWrapper.eq(pageData.getPageClientType() != null, PageData::getPageClientType, pageData.getPageClientType());
|
||||
//如果为店铺页面需要设置店铺ID
|
||||
if (pageData.getPageType().equals(PageEnum.STORE.name())) {
|
||||
queryWrapper.eq(pageData.getNum() != null, "num", pageData.getNum());
|
||||
queryWrapper.eq(pageData.getNum() != null, PageData::getNum, pageData.getNum());
|
||||
}
|
||||
//判断是否为唯一的页面
|
||||
if (this.baseMapper.getPageDataNum(queryWrapper) == 1) {
|
||||
@ -205,7 +195,7 @@ public class PageDataServiceImpl extends ServiceImpl<PageDataMapper, PageData> i
|
||||
throw new ServiceException(ResultCode.PAGE_NOT_EXIST);
|
||||
}
|
||||
QueryWrapper<PageDataVO> queryWrapper = Wrappers.query();
|
||||
queryWrapper.eq(pageDataDTO.getPageType() != null, "page_type", pageDataDTO.getPageType());
|
||||
queryWrapper.eq("page_type", pageDataDTO.getPageType());
|
||||
queryWrapper.eq(pageDataDTO.getNum() != null, "num", pageDataDTO.getNum());
|
||||
queryWrapper.eq("page_show", SwitchEnum.OPEN.name());
|
||||
|
||||
@ -229,4 +219,13 @@ public class PageDataServiceImpl extends ServiceImpl<PageDataMapper, PageData> i
|
||||
public PageData getSpecial(String id) {
|
||||
return this.getById(id);
|
||||
}
|
||||
|
||||
private PageData getCurrentPageData(String id) {
|
||||
AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser());
|
||||
return this.getOne(new LambdaQueryWrapper<PageData>()
|
||||
.eq(CharSequenceUtil.equals(currentUser.getRole().name(), UserEnums.STORE.name()), PageData::getPageType, PageEnum.STORE.name())
|
||||
.eq(CharSequenceUtil.equals(currentUser.getRole().name(), UserEnums.STORE.name()), PageData::getNum, UserContext.getCurrentUser().getStoreId())
|
||||
.eq(PageData::getId, id), false);
|
||||
|
||||
}
|
||||
}
|
@ -71,7 +71,11 @@ public class BasePromotionsSearchParams {
|
||||
queryWrapper.eq("scope_type", scopeType);
|
||||
}
|
||||
if (CharSequenceUtil.isNotEmpty(storeId)) {
|
||||
queryWrapper.in("store_id", Arrays.asList(storeId.split(",")));
|
||||
if ("store".equals(storeId)) {
|
||||
queryWrapper.ne("store_id", PromotionTools.PLATFORM_ID);
|
||||
} else {
|
||||
queryWrapper.in("store_id", Arrays.asList(storeId.split(",")));
|
||||
}
|
||||
}
|
||||
queryWrapper.eq("delete_flag", false);
|
||||
return queryWrapper;
|
||||
|
@ -213,6 +213,9 @@ public class PintuanServiceImpl extends AbstractPromotionsServiceImpl<PintuanMap
|
||||
*/
|
||||
private void setPintuanOrderInfo(List<Order> orders, PintuanShareVO pintuanShareVO, String skuId) {
|
||||
for (Order order : orders) {
|
||||
if (pintuanShareVO.getPintuanMemberVOS().stream().anyMatch(i -> i.getMemberId().equals(order.getMemberId()))) {
|
||||
continue;
|
||||
}
|
||||
Member member = memberService.getById(order.getMemberId());
|
||||
PintuanMemberVO memberVO = new PintuanMemberVO(member);
|
||||
if (CharSequenceUtil.isEmpty(order.getParentOrderSn())) {
|
||||
|
@ -245,6 +245,9 @@ public class SeckillServiceImpl extends AbstractPromotionsServiceImpl<SeckillMap
|
||||
if (promotions.getStartTime() != null && promotions.getEndTime() == null) {
|
||||
promotions.setEndTime(DateUtil.endOfDay(promotions.getStartTime()));
|
||||
}
|
||||
if (promotions.getApplyEndTime() == null && promotions.getStartTime() != null) {
|
||||
promotions.setApplyEndTime(promotions.getStartTime());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,9 +55,9 @@ public class PromotionTools {
|
||||
DateTime now = DateUtil.date();
|
||||
|
||||
//如果活动起始时间小于现在时间
|
||||
if (now.after(startTime)) {
|
||||
throw new ServiceException(ResultCode.PROMOTION_START_TIME_ERROR);
|
||||
}
|
||||
// if (now.after(startTime)) {
|
||||
// throw new ServiceException(ResultCode.PROMOTION_START_TIME_ERROR);
|
||||
// }
|
||||
//如果活动结束时间小于现在时间
|
||||
if (endTime != null && now.after(endTime)) {
|
||||
throw new ServiceException(ResultCode.PROMOTION_END_TIME_ERROR);
|
||||
|
@ -3,8 +3,6 @@ package cn.lili.modules.store.entity.dto;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* 店铺设置
|
||||
*
|
||||
@ -29,7 +27,6 @@ public class StoreSettingDTO {
|
||||
@ApiModelProperty(value = "详细地址")
|
||||
private String storeAddressDetail;
|
||||
|
||||
@NotEmpty
|
||||
@ApiModelProperty(value = "经纬度")
|
||||
private String storeCenter;
|
||||
|
||||
|
@ -4,6 +4,7 @@ import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.im.entity.dos.ImTalk;
|
||||
import cn.lili.modules.im.entity.dto.IMTalkQueryParams;
|
||||
import cn.lili.modules.im.entity.vo.ImTalkVO;
|
||||
import cn.lili.modules.im.service.ImTalkService;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -58,14 +59,14 @@ public class ImTalkController {
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation(value = "分页获取用户聊天")
|
||||
public ResultMessage<List<ImTalkVO>> getUserTalkList() {
|
||||
return ResultUtil.data(imTalkService.getUserTalkList());
|
||||
public ResultMessage<List<ImTalkVO>> getUserTalkList(IMTalkQueryParams imTalkQueryParams) {
|
||||
return ResultUtil.data(imTalkService.getUserTalkList(imTalkQueryParams));
|
||||
}
|
||||
|
||||
@GetMapping("/store/list")
|
||||
@ApiOperation(value = "分页获取商家聊天")
|
||||
public ResultMessage<List<ImTalkVO>> getStoreTalkList() {
|
||||
return ResultUtil.data(imTalkService.getStoreTalkList());
|
||||
public ResultMessage<List<ImTalkVO>> getStoreTalkList(IMTalkQueryParams imTalkQueryParams) {
|
||||
return ResultUtil.data(imTalkService.getStoreTalkList(imTalkQueryParams));
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/{id}")
|
||||
|
@ -6,6 +6,7 @@ import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.goods.entity.dos.Category;
|
||||
import cn.lili.modules.goods.entity.dto.CategorySearchParams;
|
||||
import cn.lili.modules.goods.entity.vos.CategoryVO;
|
||||
import cn.lili.modules.goods.service.CategoryService;
|
||||
import cn.lili.modules.goods.service.GoodsService;
|
||||
@ -54,8 +55,8 @@ public class CategoryManagerController {
|
||||
|
||||
@ApiOperation(value = "查询全部分类列表")
|
||||
@GetMapping(value = "/allChildren")
|
||||
public ResultMessage<List<CategoryVO>> list() {
|
||||
return ResultUtil.data(this.categoryService.listAllChildren());
|
||||
public ResultMessage<List<CategoryVO>> list(CategorySearchParams categorySearchParams) {
|
||||
return ResultUtil.data(this.categoryService.listAllChildren(categorySearchParams));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
|
@ -117,7 +117,7 @@ public class GoodsStoreController {
|
||||
|
||||
@ApiOperation(value = "修改商品")
|
||||
@PutMapping(value = "/update/{goodsId}", consumes = "application/json", produces = "application/json")
|
||||
public ResultMessage<GoodsOperationDTO> update(@RequestBody GoodsOperationDTO goodsOperationDTO, @PathVariable String goodsId) {
|
||||
public ResultMessage<GoodsOperationDTO> update(@Valid @RequestBody GoodsOperationDTO goodsOperationDTO, @PathVariable String goodsId) {
|
||||
goodsService.editGoods(goodsOperationDTO, goodsId);
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user