瀏覽代碼

热门拍品

linhui.li 2 周之前
父節點
當前提交
b15ba316b6

+ 41 - 0
bid/src/main/java/cn/hobbystocks/auc/web/LotController.java

@@ -0,0 +1,41 @@
+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.domain.Lot;
+import cn.hobbystocks.auc.service.ILotService;
+import io.swagger.annotations.Api;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@Api(tags = "客户端拍品查询")
+@RequestMapping("/lot")
+@RestController
+public class LotController extends BaseController {
+
+    @Autowired
+    ILotService lotService;
+    /**
+     * 热门拍品查询:查询正在竞拍中的拍品
+     */
+    @PostMapping("/hot/list")
+    public AjaxResult hotLot(Lot lot){
+        if (lot.getPageSize()==null)
+            lot.setPageSize(20);
+        startPage(lot);
+        //查询正在竞价中的拍品,按开始时间排序
+        // todo 按计算的热度值排序;
+        List<Lot> lots = lotService.selectBiddingLotList();
+
+
+        return AjaxResult.success(lots);
+    }
+
+    /**
+     * 根据分类查询拍品
+     */
+}

+ 2 - 0
lot/src/main/java/cn/hobbystocks/auc/domain/LotFans.java

@@ -1,6 +1,7 @@
 package cn.hobbystocks.auc.domain;
 
 import cn.hobbystocks.auc.common.core.domain.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.*;
 
 import java.util.Date;
@@ -10,6 +11,7 @@ import java.util.Date;
 @AllArgsConstructor
 @NoArgsConstructor
 @Builder
+@TableName("lot_fans")
 public class LotFans extends BaseEntity
 {
     private static final long serialVersionUID = 1L;

+ 2 - 1
lot/src/main/java/cn/hobbystocks/auc/mapper/LotFansMapper.java

@@ -2,11 +2,12 @@ package cn.hobbystocks.auc.mapper;
 
 
 import cn.hobbystocks.auc.domain.LotFans;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
-public interface LotFansMapper {
+public interface LotFansMapper extends BaseMapper<LotFans> {
 
     public LotFans selectLotFansById(Long id);
 

+ 2 - 0
lot/src/main/java/cn/hobbystocks/auc/mapper/LotMapper.java

@@ -56,4 +56,6 @@ public interface LotMapper extends BaseMapper<Lot> {
      */
     List<Lot> selectNotEndLotList(Long auctionId);
 
+    List<Lot> selectBiddingLotList();
+
 }

+ 2 - 1
lot/src/main/java/cn/hobbystocks/auc/service/ILotFansService.java

@@ -3,10 +3,11 @@ package cn.hobbystocks.auc.service;
 
 import cn.hobbystocks.auc.domain.LotFans;
 import cn.hobbystocks.auc.vo.FansVO;
+import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;
 
-public interface ILotFansService {
+public interface ILotFansService extends IService<LotFans> {
     public LotFans selectLotFansById(Long id);
 
     public List<LotFans> selectLotFansList(LotFans lotFans);

+ 7 - 0
lot/src/main/java/cn/hobbystocks/auc/service/ILotService.java

@@ -107,4 +107,11 @@ public interface ILotService extends IService<Lot> {
     void updateSoldAndPaid(LotFans fans, Long groupId);
 
     List<Lot> selectLotListByAucId(Long aucId);
+
+    /**
+     * 计算并更新拍品热度
+     */
+    void calculatorAndUpdateLotHot();
+
+    List<Lot> selectBiddingLotList();
 }

+ 2 - 1
lot/src/main/java/cn/hobbystocks/auc/service/impl/LotFansServiceImpl.java

@@ -6,6 +6,7 @@ import cn.hobbystocks.auc.domain.LotFans;
 import cn.hobbystocks.auc.mapper.LotFansMapper;
 import cn.hobbystocks.auc.service.ILotFansService;
 import cn.hobbystocks.auc.vo.FansVO;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
@@ -17,7 +18,7 @@ import java.util.List;
 
 
 @Service
-public class LotFansServiceImpl implements ILotFansService
+public class LotFansServiceImpl extends ServiceImpl<LotFansMapper,LotFans> implements ILotFansService
 {
     @Autowired
     private LotFansMapper lotFansMapper;

+ 30 - 0
lot/src/main/java/cn/hobbystocks/auc/service/impl/LotServiceImpl.java

@@ -606,4 +606,34 @@ public class LotServiceImpl extends ServiceImpl<LotMapper,Lot> implements ILotSe
     public List<Lot> selectLotListByAucId(Long aucId) {
         return getBaseMapper().selectLotByAucId(aucId);
     }
+
+    @Override
+    public void calculatorAndUpdateLotHot() {
+        //查询正在竞价中的拍品
+        List<Lot> lots = lotMapper.selectBidding();
+        lots.forEach(lot -> {
+            //计算出价权重
+            double bidWeight = lot.getBidCount() * 0.5;
+            //计算收藏权重
+            LambdaQueryWrapper<LotFans> lotFansLambdaQueryWrapper = new LambdaQueryWrapper<>();
+            Long lotFansCount = lotFansMapper.selectCount(lotFansLambdaQueryWrapper.eq(LotFans::getLotId, lot.getId()));
+            double lotFansWeight = lotFansCount * 0.2;
+            //计算时间权重,竞拍结束时间-当前时间=剩余时间
+            Date endTime = lot.getEndTime();
+            int timeWeight;
+            Date date = new Date();
+            Date date1 = DateUtils.addHours(date, 2);
+            if (date1.after(endTime)){
+
+            }
+            //计算涨价幅度权重
+            Long currentBid = bidMapper.getCurrentBid(lot.getId());
+        });
+    }
+
+    @Override
+    public List<Lot> selectBiddingLotList() {
+
+        return getBaseMapper().selectBiddingLotList();
+    }
 }

+ 3 - 0
lot/src/main/java/cn/hobbystocks/auc/vo/LotVO.java

@@ -7,6 +7,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 
 
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 
@@ -17,6 +18,8 @@ public class LotVO extends Lot implements InData {
 
     private List<Bid> bids;
 
+    private BigDecimal currentPrice;
+
     public LotVO() {
     }
 

+ 11 - 0
lot/src/main/resources/mapper/LotMapper.xml

@@ -466,4 +466,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="countLotByAucId" resultType="long" parameterType="long">
         select count(*)  from lot where auction_id=#{auctionId} and del_flag &lt;&gt; 1
     </select>
+    <select id="selectBiddingLotList" resultMap="LotResult">
+        select id, goods_id, auction_id, name, num, unit, imgs, detail, pub_status, pub_time, status, start_time, end_time, real_end_time, rule_type, rule_content, last_price, last_price_time, deal_price, deal_time, deal_account_id, deal_account, paid,  bid_count, bid_persion_count, del_flag, create_by, create_time, update_by, update_time, sort,
+        carousel_imgs,merchant_id,merchant_name,merchant_avatar,goods_name,goods_type,private_domain,delay_publish,pub_status,group_id,deposit,service_tariff,pay_time_limit
+        from
+        lot
+        where
+        status in ('Waiting','Starting','Bidding') and del_flag &lt;&gt; 1 and pub_status = 1
+        and start_time is not null and end_time is not null
+        order by start_time
+    </select>
+
 </mapper>