Selaa lähdekoodia

订单详情增加订单编码查询

yubin 5 päivää sitten
vanhempi
sitoutus
5defb28ad3

+ 1 - 1
mall-service/src/main/java/com/txz/mall/business/OrderServiceBusiness.java

@@ -17,7 +17,7 @@ public interface OrderServiceBusiness {
      *
      * @return 订单列表
      */
-    StoreOrderVO orderDetail(Long id);
+    StoreOrderVO orderDetail(Long id,String orderNo);
 
     /**
      * 排行榜

+ 10 - 2
mall-service/src/main/java/com/txz/mall/business/impl/OrderServiceBusinessImpl.java

@@ -47,12 +47,19 @@ public class OrderServiceBusinessImpl implements OrderServiceBusiness {
     private final RedisUtil redisUtil;
 
     @Override
-    public StoreOrderVO orderDetail(Long id) {
+    public StoreOrderVO orderDetail(Long id ,String orderNo) {
         StoreOrderVO vo = new StoreOrderVO();
-        StoreOrder storeOrder = storeOrderService.findById(id);
+        StoreOrder storeOrder = null;
+        if(!ObjectUtils.isEmpty(id)){
+            storeOrder =   storeOrderService.findById(id);
+        }else if(!ObjectUtils.isEmpty(orderNo)){
+            storeOrder =  storeOrderService.findBy("orderId",orderNo);
+        }
+
         if(ObjectUtils.isEmpty(storeOrder)){
             throw new ServiceException("订单不存在 ID:"+id);
         }
+        id =storeOrder.getId();
         Condition infoCondition = new Condition(StoreOrderInfo.class);
         Example.Criteria infoCriteria = infoCondition.createCriteria();
         infoCriteria.andEqualTo("isDelete", 0);
@@ -170,6 +177,7 @@ public class OrderServiceBusinessImpl implements OrderServiceBusiness {
         List<Map.Entry<Long, Long>> topCombinations = combinationCountMap.entrySet()
                 .stream()
                 .sorted(Map.Entry.<Long, Long>comparingByValue().reversed())
+                .limit(10)
                 .collect(Collectors.toList());
 
         List<StoreCombination> combinationList = storeCombinationService.findByIds(String.join(",", topCombinations.stream().map(Map.Entry::getKey).map(Object::toString).collect(Collectors.toList())));

+ 6 - 3
mall-service/src/main/java/com/txz/mall/controller/OrderController.java

@@ -16,6 +16,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.util.ObjectUtils;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -98,11 +99,13 @@ public class OrderController {
 
     @GetMapping("/detail")
     @ApiOperation(value = "订单获取详情")
-    public Result<StoreOrderVO> detail(@RequestParam Long id) {
-        if (id == null) {
+    public Result<StoreOrderVO> detail(@RequestParam(value = "id", required = false) Long id
+            ,@RequestParam(value = "orderNo", required = false) String orderNo) {
+
+        if (ObjectUtils.isEmpty(id) && ObjectUtils.isEmpty(orderNo) ) {
             return Result.fail(ResultCode.ID_IS_NULL);
         }
-        StoreOrderVO vo = orderServiceBusiness.orderDetail(id);
+        StoreOrderVO vo = orderServiceBusiness.orderDetail(id,orderNo);
         return Result.success(vo);
     }
 

+ 1 - 1
mall-service/src/main/java/com/txz/mall/controller/appcontroller/AppOrderController.java

@@ -117,7 +117,7 @@ public class AppOrderController {
         if (id == null) {
             return Result.fail(ResultCode.ID_IS_NULL);
         }
-        StoreOrderVO vo = orderServiceBusiness.orderDetail(id);
+        StoreOrderVO vo = orderServiceBusiness.orderDetail(id,null);
         return Result.success(vo);
     }