luodangjia
2024-12-09 5728732f45cc45f3c5cbde0abe7a7c5efee605b9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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("修改订单状态失败");
            }
        }
 
    }
}