|
@@ -2,11 +2,11 @@ package cn.iocoder.yudao.module.trade.controller.app.order;
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
-import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
|
|
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
|
|
import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO;
|
|
|
import cn.iocoder.yudao.module.product.api.property.ProductPropertyValueApi;
|
|
|
import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO;
|
|
|
+import cn.iocoder.yudao.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO;
|
|
|
import cn.iocoder.yudao.module.trade.controller.app.order.vo.*;
|
|
|
import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert;
|
|
|
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
|
|
@@ -21,7 +21,11 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
@@ -40,12 +44,78 @@ public class AppTradeOrderController {
|
|
|
@Resource
|
|
|
private ProductPropertyValueApi productPropertyValueApi;
|
|
|
|
|
|
- @GetMapping("/get-create-info")
|
|
|
- @Operation(summary = "基于商品,确认创建订单")
|
|
|
+ @GetMapping("/settlement")
|
|
|
+ @Operation(summary = "获得订单结算信息")
|
|
|
@PreAuthenticated
|
|
|
- public CommonResult<AppTradeOrderGetCreateInfoRespVO> getOrderCreateInfo(AppTradeOrderCreateReqVO createReqVO) {
|
|
|
+ public CommonResult<AppTradeOrderSettlementRespVO> settlementOrder(
|
|
|
+ @Valid AppTradeOrderSettlementReqVO settlementReqVO) {
|
|
|
// return success(tradeOrderService.getOrderConfirmCreateInfo(UserSecurityContextHolder.getUserId(), skuId, quantity, couponCardId));
|
|
|
- return null;
|
|
|
+ AppTradeOrderSettlementRespVO settlement = new AppTradeOrderSettlementRespVO();
|
|
|
+
|
|
|
+ AppTradeOrderSettlementRespVO.Price price = new AppTradeOrderSettlementRespVO.Price();
|
|
|
+ price.setOriginalPrice(1000);
|
|
|
+ price.setDeliveryPrice(200);
|
|
|
+ price.setCouponPrice(100);
|
|
|
+ price.setPointPrice(50);
|
|
|
+ price.setPayPrice(950);
|
|
|
+
|
|
|
+ List<AppTradeOrderSettlementRespVO.Item> skus = new ArrayList<>();
|
|
|
+
|
|
|
+ AppTradeOrderSettlementRespVO.Item item1 = new AppTradeOrderSettlementRespVO.Item();
|
|
|
+ item1.setCartId(1L);
|
|
|
+ item1.setSpuId(2048L);
|
|
|
+ item1.setSpuName("Apple iPhone 12");
|
|
|
+ item1.setSkuId(1024);
|
|
|
+ item1.setPrice(500);
|
|
|
+ item1.setPicUrl("https://pro.crmeb.net/uploads/attach/2022/10/12/0c56f9abb80d2775fc1e80dbe4f8826a.jpg");
|
|
|
+ item1.setCount(2);
|
|
|
+ List<AppProductPropertyValueDetailRespVO> properties1 = new ArrayList<>();
|
|
|
+ AppProductPropertyValueDetailRespVO property1 = new AppProductPropertyValueDetailRespVO();
|
|
|
+ property1.setPropertyId(1L);
|
|
|
+ property1.setPropertyName("尺寸");
|
|
|
+ property1.setValueId(2L);
|
|
|
+ property1.setValueName("大");
|
|
|
+ properties1.add(property1);
|
|
|
+ item1.setProperties(properties1);
|
|
|
+
|
|
|
+ AppTradeOrderSettlementRespVO.Item item2 = new AppTradeOrderSettlementRespVO.Item();
|
|
|
+ item2.setCartId(2L);
|
|
|
+ item2.setSpuId(3072L);
|
|
|
+ item2.setSpuName("Samsung Galaxy S21");
|
|
|
+ item2.setSkuId(2048);
|
|
|
+ item2.setPrice(800);
|
|
|
+ item2.setPicUrl("https://pro.crmeb.net/uploads/attach/2022/10/12/0c56f9abb80d2775fc1e80dbe4f8826a.jpg");
|
|
|
+ item2.setCount(1);
|
|
|
+ List<AppProductPropertyValueDetailRespVO> properties2 = new ArrayList<>();
|
|
|
+ AppProductPropertyValueDetailRespVO property2 = new AppProductPropertyValueDetailRespVO();
|
|
|
+ property2.setPropertyId(10L);
|
|
|
+ property2.setPropertyName("颜色");
|
|
|
+ property2.setValueId(20L);
|
|
|
+ property2.setValueName("白色");
|
|
|
+ properties2.add(property2);
|
|
|
+ item2.setProperties(properties2);
|
|
|
+
|
|
|
+ skus.add(item1);
|
|
|
+ skus.add(item2);
|
|
|
+
|
|
|
+ settlement.setItems(skus);
|
|
|
+ settlement.setPrice(price);
|
|
|
+
|
|
|
+ AppTradeOrderSettlementRespVO.Address address = new AppTradeOrderSettlementRespVO.Address();
|
|
|
+ address.setId(1L);
|
|
|
+ address.setName("John");
|
|
|
+ address.setMobile("18888888888");
|
|
|
+ address.setProvinceId(1L);
|
|
|
+ address.setProvinceName("Beijing");
|
|
|
+ address.setCityId(1L);
|
|
|
+ address.setCityName("Beijing");
|
|
|
+ address.setDistrictId(1L);
|
|
|
+ address.setDistrictName("Chaoyang Distripct");
|
|
|
+ address.setDetailAddress("No. 10, Xinzhong Street, Chaoyang District");
|
|
|
+ address.setDefaulted(true);
|
|
|
+ settlement.setAddress(address);
|
|
|
+
|
|
|
+ return success(settlement);
|
|
|
}
|
|
|
|
|
|
@PostMapping("/create")
|
|
@@ -53,12 +123,13 @@ public class AppTradeOrderController {
|
|
|
@PreAuthenticated
|
|
|
public CommonResult<Long> createOrder(@RequestBody AppTradeOrderCreateReqVO createReqVO,
|
|
|
HttpServletRequest servletRequest) {
|
|
|
- // 获取登录用户、用户 IP 地址
|
|
|
- Long loginUserId = getLoginUserId();
|
|
|
- String clientIp = ServletUtils.getClientIP(servletRequest);
|
|
|
- // 创建交易订单,预支付记录
|
|
|
- Long orderId = tradeOrderService.createOrder(loginUserId, clientIp, createReqVO);
|
|
|
- return success(orderId);
|
|
|
+ return success(1L);
|
|
|
+// // 获取登录用户、用户 IP 地址
|
|
|
+// Long loginUserId = getLoginUserId();
|
|
|
+// String clientIp = ServletUtils.getClientIP(servletRequest);
|
|
|
+// // 创建交易订单,预支付记录
|
|
|
+// Long orderId = tradeOrderService.createOrder(loginUserId, clientIp, createReqVO);
|
|
|
+// return success(orderId);
|
|
|
}
|
|
|
|
|
|
@PostMapping("/update-paid")
|
|
@@ -85,7 +156,7 @@ public class AppTradeOrderController {
|
|
|
}
|
|
|
|
|
|
@GetMapping("/page")
|
|
|
- @Operation(summary = "获得订单交易分页")
|
|
|
+ @Operation(summary = "获得交易订单分页")
|
|
|
public CommonResult<PageResult<AppTradeOrderPageItemRespVO>> getOrderPage(AppTradeOrderPageReqVO reqVO) {
|
|
|
// 查询订单
|
|
|
PageResult<TradeOrderDO> pageResult = tradeOrderService.getOrderPage(getLoginUserId(), reqVO);
|
|
@@ -99,4 +170,18 @@ public class AppTradeOrderController {
|
|
|
return success(TradeOrderConvert.INSTANCE.convertPage02(pageResult, orderItems, propertyValueDetails));
|
|
|
}
|
|
|
|
|
|
+ // TODO 芋艿:后续实现
|
|
|
+ @GetMapping("/get-count")
|
|
|
+ @Operation(summary = "获得交易订单数量")
|
|
|
+ public CommonResult<Map<String, Integer>> getOrderCount() {
|
|
|
+ Map<String, Integer> orderCount = new HashMap<>();
|
|
|
+ orderCount.put("allCount", 10);
|
|
|
+ orderCount.put("unpaidCount", 5);
|
|
|
+ orderCount.put("undeliveredCount", 2);
|
|
|
+ orderCount.put("deliveredCount", 1);
|
|
|
+ orderCount.put("uncommentedCount", 3);
|
|
|
+ orderCount.put("allPrice", 300);
|
|
|
+ return success(orderCount);
|
|
|
+ }
|
|
|
+
|
|
|
}
|