hr~ 3 долоо хоног өмнө
parent
commit
65a348bc51

+ 23 - 0
bid/src/main/java/cn/hobbystocks/auc/web/AuctionController.java

@@ -2,6 +2,7 @@ package cn.hobbystocks.auc.web;
 
 import cn.hobbystocks.auc.common.core.controller.BaseController;
 import cn.hobbystocks.auc.common.core.domain.AjaxResult;
+import cn.hobbystocks.auc.common.constant.Constants;
 import cn.hobbystocks.auc.domain.Auction;
 import cn.hobbystocks.auc.domain.Lot;
 import cn.hobbystocks.auc.service.IAuctionService;
@@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.Comparator;
 import java.util.List;
 
 /**
@@ -48,6 +50,27 @@ public class AuctionController extends BaseController {
         Auction dbAuction = auctionService.selectAuctionById(auction.getId());
         startPage(auction);
         List<Lot> lots = lotService.selectLotListByAucId(auction.getId());
+        sortLotsByStatusTier(lots);
         return AjaxResult.success().put("auction",dbAuction).put("lotList",lots);
     }
+
+    private void sortLotsByStatusTier(List<Lot> lots) {
+        if (lots == null) {
+            return;
+        }
+        lots.sort(Comparator.comparingInt(lot -> lotStatusTier(lot.getStatus())));
+    }
+
+    private int lotStatusTier(String status) {
+        if (Constants.LOT_STATUS_BIDDING.equals(status) || Constants.LOT_STATUS_STARTING.equals(status)) {
+            return 1;
+        }
+        if (Constants.LOT_STATUS_WAITING.equals(status)) {
+            return 2;
+        }
+        if (Constants.LOT_STATUS_SOLD.equals(status) || Constants.LOT_STATUS_PASS.equals(status)) {
+            return 3;
+        }
+        return 4;
+    }
 }

+ 6 - 1
lot/src/main/resources/mapper/LotMapper.xml

@@ -115,7 +115,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectLotByAucId" parameterType="Long" resultMap="LotResult">
         <include refid="selectLotVo"/>
         where auction_id = #{id} and del_flag  &lt;&gt; 1 and pub_status!=0
-        order by last_price_time desc
+        order by case
+            when status in ('Bidding', 'Starting') then 1
+            when status = 'Waiting' then 2
+            when status in ('Sold', 'Pass') then 3
+            else 4
+        end, last_price_time desc
     </select>
 
     <insert id="insertLot" parameterType="cn.hobbystocks.auc.domain.Lot" useGeneratedKeys="true" keyProperty="id">