From cd82e959bc407cc2a62a11b3ef9156cfd21d7e16 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期二, 10 十二月 2024 10:04:14 +0800 Subject: [PATCH] 新增加管理后台接口和优化购物接口 --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsEvaluateServiceImpl.java | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 50 insertions(+), 0 deletions(-) diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsEvaluateServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsEvaluateServiceImpl.java new file mode 100644 index 0000000..943bb2c --- /dev/null +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsEvaluateServiceImpl.java @@ -0,0 +1,50 @@ +package com.ruoyi.other.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.order.feignClient.RemoteOrderGoodsClient; +import com.ruoyi.order.model.Order; +import com.ruoyi.other.mapper.GoodsEvaluateMapper; +import com.ruoyi.other.api.domain.GoodsEvaluate; +import com.ruoyi.other.service.GoodsEvaluateService; +import com.ruoyi.other.vo.GoodsEvaluateVO; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.List; + +/** + * <p> + * 服务实现类 + * </p> + * + * @author luodangjia + * @since 2024-11-20 + */ +@Service +public class GoodsEvaluateServiceImpl extends ServiceImpl<GoodsEvaluateMapper, GoodsEvaluate> implements GoodsEvaluateService { + @Resource + private RemoteOrderGoodsClient remoteOrderGoodsClient; + + @Override + @Transactional + public void addGoodsEvaluate(GoodsEvaluateVO goodsEvaluateVO) { + List<GoodsEvaluate> evaluates = goodsEvaluateVO.getEvaluates(); + for (GoodsEvaluate goodsEvaluate : evaluates) { + goodsEvaluate.setStatus(2); + } + this.saveBatch(evaluates); + if (CollectionUtil.isNotEmpty(evaluates)){ + Order order = new Order(); + order.setId(goodsEvaluateVO.getEvaluates().get(0).getOrderId()); + order.setOrderStatus(8); + R<Void> r = remoteOrderGoodsClient.updateOrderStatus(order); + if (R.isError(r)){ + throw new RuntimeException("修改订单状态失败"); + } + } + + } +} -- Gitblit v1.7.1