luodangjia
2025-01-14 f6bd8d2355a37d3fd72f23494db4661f3983b32c
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java
@@ -9,6 +9,8 @@
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.order.feignClient.OrderClient;
import com.ruoyi.order.model.Order;
import com.ruoyi.other.api.domain.Goods;
import com.ruoyi.other.api.domain.GoodsEvaluate;
import com.ruoyi.other.service.GoodsEvaluateService;
@@ -46,6 +48,8 @@
    private GoodsService goodsService;
    @Resource
    private TokenService tokenService;
    @Resource
    private OrderClient orderClient;
@@ -53,7 +57,8 @@
    @GetMapping("/goodsList")
    @ApiOperation(value = "获取商品评价", tags = {"小程序-获取商品评价"})
    public R<List<GoodsEvaluate>> goodsList(@ApiParam("商品id") Integer goodsId){
        List<GoodsEvaluate> list = goodsEvaluateService.lambdaQuery().eq(GoodsEvaluate::getGoodsId, goodsId).eq(GoodsEvaluate::getDelFlag, 0).eq(GoodsEvaluate::getStatus, 2).list();
        List<GoodsEvaluate> list = goodsEvaluateService.lambdaQuery().eq(GoodsEvaluate::getGoodsId, goodsId).eq(GoodsEvaluate::getDelFlag, 0)
                .eq(GoodsEvaluate::getStatus, 2).isNotNull(GoodsEvaluate::getComment).ne(GoodsEvaluate::getComment, "").orderByDesc(GoodsEvaluate::getCreateTime).list();
        for (GoodsEvaluate goodsEvaluate : list) {
            AppUser appUserById = appUserClient.getAppUserById(goodsEvaluate.getAppUserId());
            if(null != appUserById){
@@ -85,6 +90,7 @@
        List<GoodsEvaluate> list = goodsEvaluateService.list(new LambdaQueryWrapper<GoodsEvaluate>()
                .eq(GoodsEvaluate::getStatus, 2)
                .eq(GoodsEvaluate::getAppUserId,loginUserApplet.getUserid())
                .eq(GoodsEvaluate::getDelFlag, 0)
                .eq(GoodsEvaluate::getOrderId, orderId));
        for (GoodsEvaluate goodsEvaluate : list) {
            Goods goods = goodsService.getById(goodsEvaluate.getGoodsId());
@@ -101,7 +107,13 @@
    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "删除评论", tags = {"管理后台-商品管理-评价管理"})
    public R<Void> delete(@PathVariable("id") Long id){
        goodsEvaluateService.removeById(id);
        GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(id);
        goodsEvaluate.setDelFlag(1);
        goodsEvaluateService.updateById(goodsEvaluate);
        //修改订单为待评价
        Order data = orderClient.getOrderById(goodsEvaluate.getOrderId()).getData();
        data.setOrderStatus(data.getOldOrderStatus());
        orderClient.editOrder(data);
        return R.ok();
    }
@@ -145,6 +157,7 @@
                .in(!goodsIds.isEmpty(), GoodsEvaluate::getGoodsId, goodsIds)
                .in(!usersNameList.isEmpty(), GoodsEvaluate::getAppUserId, usersNameList)
                .eq(goodsEvaluate.getStatus() != null, GoodsEvaluate::getStatus, goodsEvaluate.getStatus())
                .eq(GoodsEvaluate::getDelFlag, 0)
                .orderByDesc(GoodsEvaluate::getCreateTime));
@@ -160,7 +173,9 @@
            item.setUserName(appUser.getName());
        }
        Goods goods = goodsService.getById(item.getGoodsId());
        item.setGoodsName(goods.getName());
        if(null != goods){
            item.setGoodsName(goods.getName());
        }
    }
    /**