|
@@ -0,0 +1,62 @@
|
|
|
+package org.springblade.modules.api.controller;
|
|
|
+
|
|
|
+import cn.hutool.core.lang.Assert;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.common.constant.CommonConstant;
|
|
|
+import org.springblade.core.mp.support.Condition;
|
|
|
+import org.springblade.core.mp.support.Query;
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.modules.finance.entity.Order;
|
|
|
+import org.springblade.modules.finance.entity.OrderGoods;
|
|
|
+import org.springblade.modules.finance.service.IOrderGoodsService;
|
|
|
+import org.springblade.modules.finance.service.IOrderService;
|
|
|
+import org.springblade.modules.finance.vo.OrderGoodsVO;
|
|
|
+import org.springblade.modules.finance.wrapper.OrderGoodsWrapper;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Author pangqijun
|
|
|
+ * Date 2024/7/18
|
|
|
+ * Description
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@AllArgsConstructor
|
|
|
+@RequestMapping(CommonConstant.API_URL + "/orderGoods")
|
|
|
+@Api(value = "商品订单接口", tags = "商品订单接口")
|
|
|
+public class ApiOrderGoodsController {
|
|
|
+
|
|
|
+ private final IOrderGoodsService iOrderGoodsService;
|
|
|
+ private final IOrderService iOrderService;
|
|
|
+
|
|
|
+ @GetMapping("/user")
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
+ @ApiOperation(value = "获取用户订单")
|
|
|
+ public R<IPage<OrderGoodsVO>> getUserOrder(Query query, OrderGoodsVO orderGoodsVO) {
|
|
|
+ orderGoodsVO.setUserId(AuthUtil.getUserId());
|
|
|
+ IPage<OrderGoodsVO> orderGoodsVOIPage = iOrderGoodsService.selectUserOrder(Condition.getPage(query), orderGoodsVO);
|
|
|
+ return R.data(orderGoodsVOIPage);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/detail")
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
+ @ApiOperation(value = "获取订单详情")
|
|
|
+ public R<OrderGoodsVO> detail(Long orderId) {
|
|
|
+ Order order = iOrderService.getById(orderId);
|
|
|
+ Assert.notNull(order, "未查询到订单信息");
|
|
|
+ OrderGoods orderGoods = iOrderGoodsService.getOne(Wrappers.lambdaQuery(OrderGoods.class)
|
|
|
+ .eq(OrderGoods::getOrderId, orderId));
|
|
|
+ Assert.notNull(orderGoods, "未查询到商品订单信息");
|
|
|
+ OrderGoodsVO orderGoodsVO = OrderGoodsWrapper.build().entityVO(orderGoods);
|
|
|
+ orderGoodsVO.setOrderState(order.getOrderState());
|
|
|
+ return R.data(orderGoodsVO);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|