From 676638d7b8b53baf66fcde3d626c74801c776210 Mon Sep 17 00:00:00 2001 From: phpcjl <phpcjl@gmail.com> Date: 星期一, 09 十二月 2024 15:06:12 +0800 Subject: [PATCH] 1. --- ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/Order.java | 2 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java | 5 -- ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/RemoteOrderGoodsFallbackFactory.java | 5 ++ ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java | 16 +++++++- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsEvaluateServiceImpl.java | 30 +++++++++++++++ ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/GoodsEvaluateService.java | 4 + ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/RemoteOrderGoodsClient.java | 6 +++ 7 files changed, 60 insertions(+), 8 deletions(-) diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/RemoteOrderGoodsFallbackFactory.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/RemoteOrderGoodsFallbackFactory.java index 7187b29..f719fcb 100644 --- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/RemoteOrderGoodsFallbackFactory.java +++ b/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("更新订单状态失败"); + } }; } diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/RemoteOrderGoodsClient.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/RemoteOrderGoodsClient.java index caa5034..8a341d2 100644 --- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/RemoteOrderGoodsClient.java +++ b/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); } diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/Order.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/Order.java index 33c9844..6e0a0fe 100644 --- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/model/Order.java +++ b/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; diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java index ecd3255..f295ec5 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java +++ b/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(); + } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java index 29fcdc5..a7e2962 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java +++ b/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(); } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/GoodsEvaluateService.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/GoodsEvaluateService.java index 94d3a87..f701cd7 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/GoodsEvaluateService.java +++ b/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); } 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 index 04203e5..943bb2c 100644 --- 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 @@ -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("修改订单状态失败"); + } + } + + } } -- Gitblit v1.7.1