ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/RemoteOrderGoodsFallbackFactory.java
@@ -30,6 +30,11 @@ public R<List<Order>> getOrderListByUserIdAndGoodsId(Long userId, Integer goodsId) { return R.fail("获取订单列表失败"); } @Override public R<Void> updateOrderStatus(Order order) { return R.fail("更新订单状态失败"); } }; } ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/RemoteOrderGoodsClient.java
@@ -34,4 +34,10 @@ */ @GetMapping("/order/getOrderListByUserIdAndGoodsId") public R<List<Order>> getOrderListByUserIdAndGoodsId(@RequestParam("userId") Long userId, @RequestParam("goodsId") Integer goodsId); /** * 更新订单状态 */ @PostMapping("/order/updateOrderStatus") public R<Void> updateOrderStatus(@RequestBody Order order); } ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/Order.java
@@ -40,7 +40,7 @@ @TableField("order_type") private Integer orderType; @ApiModelProperty(value = "1待发货2待收货3待使用4已完成5已取消6已退款7售后中") @ApiModelProperty(value = "1待发货2待收货3待使用4已完成5已取消6已退款7售后中8已评价") @TableField("order_status") private Integer orderStatus; ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java
@@ -150,8 +150,20 @@ return R.ok(); } /** * 更新订单状态 */ @ApiOperation(value = "更新订单状态", tags = {"后台-订单管理-更新订单状态"}) @ApiImplicitParams({ @ApiImplicitParam(value = "订单对象", name = "order", required = true, dataType = "Order"), }) @PostMapping("/updateOrderStatus") public R<Void> updateOrderStatus(@RequestBody Order order){ Order order1 = orderService.getById(order.getId()); order1.setOrderStatus(order.getOrderStatus()); orderService.updateById(order1); return R.ok(); } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java
@@ -5,9 +5,6 @@ import com.ruoyi.account.api.feignClient.AppUserClient; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.page.TableDataInfo; 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; import com.ruoyi.other.vo.GoodsEvaluateVO; @@ -54,7 +51,7 @@ @PostMapping("/addGoodsEvaluate") @ApiOperation(value = "发布商品评价", tags = {"小程序-发布商品评价"}) public R<Void> addGoodsEvaluate(@RequestBody GoodsEvaluateVO goodsEvaluateVO){ // todo goodsEvaluateService.addGoodsEvaluate(goodsEvaluateVO); return R.ok(); } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/GoodsEvaluateService.java
@@ -2,6 +2,8 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.other.api.domain.GoodsEvaluate; import com.ruoyi.other.vo.GoodsEvaluateVO; import org.springframework.web.bind.annotation.RequestBody; /** * <p> @@ -12,5 +14,5 @@ * @since 2024-11-20 */ public interface GoodsEvaluateService extends IService<GoodsEvaluate> { void addGoodsEvaluate(@RequestBody GoodsEvaluateVO goodsEvaluateVO); } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsEvaluateServiceImpl.java
@@ -1,10 +1,19 @@ 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> @@ -16,5 +25,26 @@ */ @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("修改订单状态失败"); } } } }