Преглед изворни кода

拍卖会管理,拍品管理

linhui.li пре 3 недеља
родитељ
комит
c2eefac0d0
55 измењених фајлова са 816 додато и 951 уклоњено
  1. 0 37
      auc/src/main/java/cn/hobbystocks/auc/app/AppClient.java
  2. 2 4
      auc/src/main/java/cn/hobbystocks/auc/web/AuctionController.java
  3. 1 1
      auc/src/main/java/cn/hobbystocks/auc/web/BidController.java
  4. 0 63
      auc/src/main/java/cn/hobbystocks/auc/web/LocalController.java
  5. 8 29
      auc/src/main/java/cn/hobbystocks/auc/web/LotController.java
  6. 3 52
      auc/src/main/java/cn/hobbystocks/auc/web/LotGroupController.java
  7. 13 11
      auc/src/main/resources/application-local.yml
  8. 1 1
      auc/src/main/resources/application.yml
  9. 1 4
      bid/pom.xml
  10. 4 183
      bid/src/main/java/cn/hobbystocks/auc/app/AppClient.java
  11. 0 57
      bid/src/main/java/cn/hobbystocks/auc/handle/CouponSoldHandler.java
  12. 16 41
      bid/src/main/java/cn/hobbystocks/auc/handle/SkuSoldHandler.java
  13. 3 0
      bid/src/main/java/cn/hobbystocks/auc/listener/LiveEndListener.java
  14. 105 79
      bid/src/main/java/cn/hobbystocks/auc/task/BidTask.java
  15. 18 120
      bid/src/main/java/cn/hobbystocks/auc/web/BidingController.java
  16. 45 0
      bid/src/main/java/cn/hobbystocks/auc/web/DepositOrderController.java
  17. 4 55
      bid/src/main/java/cn/hobbystocks/auc/web/LocalController.java
  18. 13 11
      bid/src/main/resources/application-local.yml
  19. 6 0
      lot/pom.xml
  20. 2 2
      lot/src/main/java/cn/hobbystocks/auc/common/constant/Constants.java
  21. 8 0
      lot/src/main/java/cn/hobbystocks/auc/common/core/domain/BaseEntity.java
  22. 2 2
      lot/src/main/java/cn/hobbystocks/auc/common/user/UserUtils.java
  23. 3 2
      lot/src/main/java/cn/hobbystocks/auc/domain/Auction.java
  24. 23 0
      lot/src/main/java/cn/hobbystocks/auc/domain/DepositOrder.java
  25. 4 2
      lot/src/main/java/cn/hobbystocks/auc/domain/Lot.java
  26. 6 0
      lot/src/main/java/cn/hobbystocks/auc/domain/Order.java
  27. 2 1
      lot/src/main/java/cn/hobbystocks/auc/dto/AuctionDTO.java
  28. 24 0
      lot/src/main/java/cn/hobbystocks/auc/dto/DepositOrderDTO.java
  29. 0 10
      lot/src/main/java/cn/hobbystocks/auc/dto/PointDTO.java
  30. 28 0
      lot/src/main/java/cn/hobbystocks/auc/dto/SkuOrderDTO.java
  31. 7 7
      lot/src/main/java/cn/hobbystocks/auc/event/SoldEvent.java
  32. 40 0
      lot/src/main/java/cn/hobbystocks/auc/forest/OrderApi.java
  33. 3 0
      lot/src/main/java/cn/hobbystocks/auc/handle/RuleHandlerHolder.java
  34. 9 10
      lot/src/main/java/cn/hobbystocks/auc/handle/impl/tradition/AbstractTraditionRuleHandler.java
  35. 7 1
      lot/src/main/java/cn/hobbystocks/auc/handle/impl/tradition/TraditionRuleHandler.java
  36. 13 0
      lot/src/main/java/cn/hobbystocks/auc/handle/impl/tradition/TraditionRuleV2Handler.java
  37. 34 0
      lot/src/main/java/cn/hobbystocks/auc/handle/impl/tradition/TraditionRuleV3Handler.java
  38. 2 1
      lot/src/main/java/cn/hobbystocks/auc/mapper/AuctionMapper.java
  39. 11 0
      lot/src/main/java/cn/hobbystocks/auc/mapper/DepositOrderMapper.java
  40. 8 1
      lot/src/main/java/cn/hobbystocks/auc/mapper/LotMapper.java
  41. 23 0
      lot/src/main/java/cn/hobbystocks/auc/mapper/OrderMapper.java
  42. 0 18
      lot/src/main/java/cn/hobbystocks/auc/mapper/OrderStatusMapper.java
  43. 32 0
      lot/src/main/java/cn/hobbystocks/auc/service/DepositOrderService.java
  44. 4 0
      lot/src/main/java/cn/hobbystocks/auc/service/ILotService.java
  45. 28 0
      lot/src/main/java/cn/hobbystocks/auc/service/IOrderService.java
  46. 0 29
      lot/src/main/java/cn/hobbystocks/auc/service/IOrderStatusService.java
  47. 5 7
      lot/src/main/java/cn/hobbystocks/auc/service/impl/AuctionServiceImpl.java
  48. 82 0
      lot/src/main/java/cn/hobbystocks/auc/service/impl/DepositOrderServiceImpl.java
  49. 1 0
      lot/src/main/java/cn/hobbystocks/auc/service/impl/LotServiceImpl.java
  50. 88 0
      lot/src/main/java/cn/hobbystocks/auc/service/impl/OrderServiceImpl.java
  51. 0 38
      lot/src/main/java/cn/hobbystocks/auc/service/impl/OrderStatusServiceImpl.java
  52. 20 27
      lot/src/main/resources/mapper/AuctionMapper.xml
  53. 19 0
      lot/src/main/resources/mapper/DepositOrderMapper.xml
  54. 24 33
      lot/src/main/resources/mapper/LotMapper.xml
  55. 11 12
      lot/src/main/resources/mapper/OrderMapper.xml

+ 0 - 37
auc/src/main/java/cn/hobbystocks/auc/app/AppClient.java

@@ -33,41 +33,4 @@ public class AppClient {
         return JSON.parseObject(JSON.toJSONString(response.getResult().getData()), SkuDTO.class);
     }
 
-
-
-    public boolean returnPoint(Bid bid, Long recordId) {
-        ForestResponse<CommonForestClient.Response<Object>> response;
-        try {
-            Map<String, Object> params = new HashMap<>();
-            params.put("userId", bid.getAccountId());
-            List<Map<String, Object>> pointRecords = new ArrayList<>();
-            params.put("pointRecords", pointRecords);
-            pointRecords.add(getReturnPointRecord(bid, recordId));
-            response = client.sendPost(pointUrl, getDefaultHeaderMap(), params);
-            boolean result = Objects.equals(response.getStatusCode(), 200) && Objects.equals(response.getResult().getCode(), 0);
-            if (!result) {
-                log.error("return point error, {} , {}  {}", pointUrl, bid, response.getResult().getMsg());
-            }else {
-                log.info("return point {} {}", bid,  response.getContent());
-            }
-            return result;
-        }catch (Exception e) {
-            log.error("return point error, {} , {}", pointUrl, bid);
-            return false;
-        }
-    }
-
-    private Map<String, Object> getReturnPointRecord(Bid bid, Long recordId) {
-        Map<String, Object> pointRecord = new HashMap<>();
-        pointRecord.put("changePoint", bid.getAmount().longValue() * 100);
-        pointRecord.put("orderId", bid.getLotId());
-        pointRecord.put("refId", bid.getBidNo() + "-" + recordId);
-        return pointRecord;
-    }
-    private Map<String, Object> getDefaultHeaderMap() {
-        Map<String, Object> headerMap = Maps.newHashMap();
-        String traceId = MDC.get("traceId");
-        headerMap.put("traceid", traceId);
-        return headerMap;
-    }
 }

+ 2 - 4
auc/src/main/java/cn/hobbystocks/auc/web/AuctionController.java

@@ -74,7 +74,7 @@ public class AuctionController extends AdminBaseController {
 		auction.setCreateTime(DateUtils.getNowDate());
 		auction.setMerchantId(simpleUserInfo.getMerchantId());
 		auction.setSort(0);
-		return AjaxResult.success(auctionService.save(auction));
+		return AjaxResult.success(auctionService.insertAuction(auction));
 	}
 
 	/**
@@ -130,9 +130,7 @@ public class AuctionController extends AdminBaseController {
 		Auction dbAuc = auctionService.selectAuctionById(auction.getId());
 		if (Objects.isNull(dbAuc))
 			return AjaxResult.error("没有找到拍卖会");
-		if (Objects.equals(Constants.PUB_STATUS_PUBLISHED, dbAuc.getPubStatus())) {
-			return AjaxResult.error("拍卖会已发布不能修改");
-		}
+
 		auction.setUpdateBy(getUsername());
 		auctionService.pubAuction(auction);
 		return AjaxResult.success();

+ 1 - 1
auc/src/main/java/cn/hobbystocks/auc/web/BidController.java

@@ -49,7 +49,7 @@ public class BidController extends AdminBaseController {
             }
             bid.setAccount(SensitiveDataUtils.maskString(bid.getAccount(), 4));
         });
-
+        //将中标出价记录单独放一个字段
         if (!CollectionUtils.isEmpty(bids) && Objects.equals(1, bids.get(0).getStatus())) {
             ajaxResult.put("win", bids.get(0));
         }

+ 0 - 63
auc/src/main/java/cn/hobbystocks/auc/web/LocalController.java

@@ -1,63 +0,0 @@
-package cn.hobbystocks.auc.web;
-
-import cn.hobbystocks.auc.annotation.RequireRoles;
-import cn.hobbystocks.auc.app.AppClient;
-import cn.hobbystocks.auc.common.constant.Constants;
-import cn.hobbystocks.auc.common.core.domain.AjaxResult;
-import cn.hobbystocks.auc.common.user.UserUtils;
-import cn.hobbystocks.auc.common.utils.StringUtils;
-import cn.hobbystocks.auc.common.utils.UserType;
-import cn.hobbystocks.auc.domain.LotGroup;
-import cn.hobbystocks.auc.vo.LotGroupVO;
-import cn.hobbystocks.auc.vo.SkuDTO;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.List;
-import java.util.Objects;
-
-@RestController
-@Api(tags = "本地服务接口")
-@RequestMapping("/api/local")
-public class LocalController extends AdminBaseController{
-    @Autowired
-    private AppClient appClient;
-
-    @ApiOperation(value = "根据businessCode查询商品", notes = "根据商品名称,审核状态查询商品列表", response = LotGroup.class, responseContainer = "List<LotGroup>")
-    @PostMapping("/lot_group/list")
-    public AjaxResult list(@RequestBody LotGroupVO lotGroup) {
-        if (StringUtils.isEmpty(lotGroup.getBusinessCode())){
-            AjaxResult.error("业务系统编码不能为空");
-        }
-        startPage(lotGroup);
-        lotGroup.setDelFlag(Constants.DEL_FLAG_NO_DELETE);
-        if (Objects.nonNull(UserUtils.getSimpleUserInfo()) && Objects.nonNull(UserUtils.getSimpleUserInfo().getMerchantId())) {
-            lotGroup.setMerchantId(UserUtils.getSimpleUserInfo().getMerchantId().longValue());
-        }
-        if (Objects.equals(0, lotGroup.getNewStatus())) {
-            lotGroup.setPubStatus(Constants.PUB_STATUS_NO_PUBLISHED);
-        }else if (Objects.equals(1, lotGroup.getNewStatus())) {
-            lotGroup.setPubStatus(Constants.PUB_STATUS_PUBLISHED);
-        }else if (Objects.equals(2, lotGroup.getNewStatus())) {
-            lotGroup.setPubStatus(Constants.PUB_STATUS_PUBLISHED);
-            lotGroup.setStatus(Constants.GROUP_STATUS_WAITING);
-        }else if (Objects.equals(3, lotGroup.getNewStatus())) {
-            lotGroup.setStatus(Constants.GROUP_STATUS_STARTING);
-        }
-
-        List<LotGroup> data = lotService.selectLotGroupList(lotGroup);
-        data.forEach(group -> {
-            SkuDTO sku = appClient.getSku(Integer.parseInt(group.getGoodsId()));
-            if (Objects.nonNull(sku)) {
-                group.setSkuStock(sku.getSkuStock());
-                group.setSkuCode(sku.getCode());
-            }
-        });
-        return AjaxResult.successPage(data);
-    }
-}

+ 8 - 29
auc/src/main/java/cn/hobbystocks/auc/web/LotController.java

@@ -50,7 +50,7 @@ public class LotController extends AdminBaseController {
 	 */
 	@ApiOperation(value = "查询拍卖会下的拍品列表", notes = "分页查询拍品列表", response = Lot.class, responseContainer = "List<Lot>")
 	@PostMapping("/list")
-	@RequireRoles({UserType.USER_ROLE_ADMIN})
+//	@RequireRoles({UserType.USER_ROLE_ADMIN})
 	public AjaxResult list(@RequestBody LotVO lot) {
 	    if (lot.getAuctionId()==null)
 	        return AjaxResult.error("拍卖会id不能为空");
@@ -75,7 +75,7 @@ public class LotController extends AdminBaseController {
 	 */
 	@ApiOperation(value = "新增保存拍品", notes = "如拍卖会已经结束不可添加", response = AjaxResult.class, responseContainer = "AjaxResult.success")
 	@PostMapping("/add")
-	@RequireRoles({UserType.USER_ROLE_ADMIN})
+//	@RequireRoles({UserType.USER_ROLE_ADMIN})
 	public AjaxResult addSave(@RequestBody @Valid LotVO lot) {
         UserInfo userInfo = UserUtils.getSimpleUserInfo();
         if (Objects.isNull(userInfo))
@@ -83,6 +83,7 @@ public class LotController extends AdminBaseController {
         Auction dbAuction = auctionService.selectAuctionById(lot.getAuctionId());
 		if (Objects.equals(Constants.GROUP_STATUS_FINISH, dbAuction.getStatus()))
 			return AjaxResult.error("拍卖会已经结束");
+		//拍品结束时间不能小于拍卖会结束时间
 		lot.setMerchantId(userInfo.getMerchantId());
 		lot.setMerchantName(userInfo.getMerchantName());
 		lot.setMerchantAvatar(userInfo.getMerchantAvatar());
@@ -101,7 +102,7 @@ public class LotController extends AdminBaseController {
 	 */
 	@ApiOperation(value = "修改保存拍品", notes = "修改保存拍品", response = AjaxResult.class, responseContainer = "AjaxResult.success")
 	@PostMapping("/edit")
-	@RequireRoles({UserType.USER_ROLE_ADMIN})
+//	@RequireRoles({UserType.USER_ROLE_ADMIN})
 	public AjaxResult editSave(@RequestBody @Valid LotVO lot) {
 		Lot dbLot = lotService.selectLotById(lot.getId());
 		lot.setUpdateBy(getUsername());
@@ -119,7 +120,7 @@ public class LotController extends AdminBaseController {
 	 */
 	@ApiOperation(value = "根据拍品编号删除拍品", notes = "拍品已发布不能删除", response = AjaxResult.class, responseContainer = "AjaxResult.success")
 	@PostMapping(value = "/remove")
-	@RequireRoles({UserType.USER_ROLE_ADMIN})
+//	@RequireRoles({UserType.USER_ROLE_ADMIN})
 	public AjaxResult remove(@RequestBody LotVO lot) {
 		Lot dbLot = lotService.selectLotById(lot.getId());
 		if (Objects.equals(Constants.PUB_STATUS_PUBLISHED, dbLot.getPubStatus()))
@@ -135,7 +136,7 @@ public class LotController extends AdminBaseController {
 			"拍卖会还未发布不能发布\n" +
 			"拍卖会已结束不能发布\n", response = AjaxResult.class, responseContainer = "AjaxResult.success")
 	@PostMapping(value = "/pub")
-	@RequireRoles({UserType.USER_ROLE_ADMIN})
+//	@RequireRoles({UserType.USER_ROLE_ADMIN})
 	public AjaxResult pub(@RequestBody LotVO lot) {
 		Lot dbLot = lotService.selectLotById(lot.getId());
 		if (Objects.equals(Constants.PUB_STATUS_PUBLISHED, dbLot.getPubStatus()))
@@ -157,7 +158,7 @@ public class LotController extends AdminBaseController {
 	 */
 	@ApiOperation(value = "根据拍品编号撤回拍品", notes = "拍品未发布不能撤回\n", response = AjaxResult.class, responseContainer = "AjaxResult.success")
 	@PostMapping(value = "/cancel")
-	@RequireRoles({UserType.USER_ROLE_ADMIN})
+//	@RequireRoles({UserType.USER_ROLE_ADMIN})
 	public AjaxResult callback(@RequestBody LotVO lot) {
 		Lot dbLot = lotService.selectLotById(lot.getId());
 		if (Objects.equals(Constants.PUB_STATUS_NO_PUBLISHED, dbLot.getPubStatus()))
@@ -167,27 +168,5 @@ public class LotController extends AdminBaseController {
 		return AjaxResult.success();
 	}
 
-	@ApiOperation(value = "返还积分", notes = "下架不返还积分\n" +
-			"竞价没积分不返还\n" +
-			"竞价为空不返还\n", response = AjaxResult.class, responseContainer = "AjaxResult.success")
-	@PostMapping(value = "/returnPoint")
-	@RequireRoles({UserType.USER_ROLE_ADMIN})
-	public AjaxResult returnPoint(@RequestBody LotVO lot) {
-		Lot l = lotService.selectLotById(lot.getId());
-		if (!Constants.LOT_STATUS_CANCELLED.equals(l.getStatus())) {
-			return AjaxResult.error();
-		}
-		List<Bid> bids = bidService.selectBidList(Bid.builder().lotId(lot.getId()).build());
-		if (!CollectionUtils.isEmpty(bids)) {
-			Bid bid = bids.get(0);
-			if (Objects.nonNull(bid.getManualReturnPoint())) {
-				return AjaxResult.error();
-			}
-			appClient.returnPoint(bid, -1L);
-			bidService.updateBid(Bid.builder().id(bid.getId()).manualReturnPoint(bid.getAmount()).build());
-		}else {
-			return AjaxResult.error();
-		}
-		return AjaxResult.success();
-	}
+
 }

+ 3 - 52
auc/src/main/java/cn/hobbystocks/auc/web/LotGroupController.java

@@ -10,10 +10,8 @@ import cn.hobbystocks.auc.common.utils.StringUtils;
 import cn.hobbystocks.auc.common.utils.UserType;
 import cn.hobbystocks.auc.domain.Bid;
 import cn.hobbystocks.auc.domain.Lot;
-import cn.hobbystocks.auc.domain.LotFans;
 import cn.hobbystocks.auc.domain.LotGroup;
 import cn.hobbystocks.auc.service.ILotFansService;
-import cn.hobbystocks.auc.service.IOrderStatusService;
 import cn.hobbystocks.auc.vo.LotGroupVO;
 import cn.hobbystocks.auc.vo.SkuDTO;
 import io.swagger.annotations.Api;
@@ -27,7 +25,6 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import javax.annotation.Resource;
 import javax.validation.Valid;
 import java.util.Date;
 import java.util.List;
@@ -46,40 +43,7 @@ public class LotGroupController extends AdminBaseController {
 	@Autowired
 	ILotFansService lotFansService;
 
-    //根据businessCode查询拍品组信息
-    @ApiOperation(value = "根据businessCode查询商品", notes = "根据商品名称,审核状态查询商品列表", response = LotGroup.class, responseContainer = "List<LotGroup>")
-    @PostMapping("/list")
-    @RequireRoles({UserType.USER_ROLE_SHIPPING})
-    public AjaxResult list(@RequestBody LotGroupVO lotGroup) {
-        if (StringUtils.isEmpty(lotGroup.getBusinessCode())){
-            AjaxResult.error("业务系统编码不能为空");
-        }
-        startPage(lotGroup);
-        lotGroup.setDelFlag(Constants.DEL_FLAG_NO_DELETE);
-        if (Objects.nonNull(UserUtils.getSimpleUserInfo()) && Objects.nonNull(UserUtils.getSimpleUserInfo().getMerchantId())) {
-            lotGroup.setMerchantId(UserUtils.getSimpleUserInfo().getMerchantId().longValue());
-        }
-        if (Objects.equals(0, lotGroup.getNewStatus())) {
-            lotGroup.setPubStatus(Constants.PUB_STATUS_NO_PUBLISHED);
-        }else if (Objects.equals(1, lotGroup.getNewStatus())) {
-            lotGroup.setPubStatus(Constants.PUB_STATUS_PUBLISHED);
-        }else if (Objects.equals(2, lotGroup.getNewStatus())) {
-            lotGroup.setPubStatus(Constants.PUB_STATUS_PUBLISHED);
-            lotGroup.setStatus(Constants.GROUP_STATUS_WAITING);
-        }else if (Objects.equals(3, lotGroup.getNewStatus())) {
-            lotGroup.setStatus(Constants.GROUP_STATUS_STARTING);
-        }
 
-        List<LotGroup> data = lotService.selectLotGroupList(lotGroup);
-        data.forEach(group -> {
-            SkuDTO sku = appClient.getSku(Integer.parseInt(group.getGoodsId()));
-            if (Objects.nonNull(sku)) {
-                group.setSkuStock(sku.getSkuStock());
-                group.setSkuCode(sku.getCode());
-            }
-        });
-        return AjaxResult.successPage(data);
-    }
 	@ApiOperation(value = "克隆商品", notes = "insertLotGroup with no id", response = AjaxResult.class, responseContainer = "AjaxResult")
 	@PostMapping("/clone")
 	@RequireRoles({UserType.USER_ROLE_SHIPPING})
@@ -269,7 +233,7 @@ public class LotGroupController extends AdminBaseController {
 
 	//此处查询未指定方法,导致swagger会重复
 	@ApiOperation(value = "商家拍品列表", notes = "selectLotList with lotGroupids", response = Lot.class, responseContainer = "List<Lot>")
-	@RequestMapping("/liveLot")
+	@PostMapping("/liveLot")
 	@RequireRoles({UserType.USER_ROLE_ADMIN,UserType.USER_ROLE_SHIPPING})
 	public AjaxResult listLot(@RequestBody LotGroupVO lotGroup){
 		startPage(lotGroup);
@@ -284,18 +248,13 @@ public class LotGroupController extends AdminBaseController {
 			if (!CollectionUtils.isEmpty(bids)) {
 				lot1.setAnonymous(bids.get(0).getAnonymous());
 			}
-			/*LotFans lotFans = lotFansService.selectLotFansByLotIdAndType(lot1.getId(), "pay_expire");
-			if(lotFans != null) {
-				lot1.setLotFansId(lotFans.getId());
-			}*/
-//            List<Order> orderList = orderStatusService.selectOrderStatusList(Order.builder().lotId(lot1.getId()).flag(1).build());
 
         });
 		return AjaxResult.successPage(lotList);
 	}
 
 	public String checkUser(Long merchantId) {
-		Integer merchantIdReq = UserUtils.getSimpleUserInfo().getMerchantId();
+		Long merchantIdReq = UserUtils.getSimpleUserInfo().getMerchantId();
 		if (Objects.nonNull(merchantIdReq) && Objects.nonNull(merchantId)) {
 			if (!Objects.equals(merchantIdReq.longValue(), merchantId)) {
 				return  "您无权新增或者修改此商品";
@@ -304,13 +263,5 @@ public class LotGroupController extends AdminBaseController {
 		return null;
 	}
 
-    /*@ApiOperation(value = "删除订单逾期未支付的用户记录", notes = "delFans with id", response = AjaxResult.class, responseContainer = "AjaxResult.success")
-    @PostMapping("/delFans/{id}")
-	public AjaxResult delExpire(@PathVariable("id") Long id){
-		int rs = lotFansService.updateLotFansDel(id);
-		if(rs == 0) {
-			return AjaxResult.error();
-		}
-		return AjaxResult.success();
-	}*/
+
 }

+ 13 - 11
auc/src/main/resources/application-local.yml

@@ -1,14 +1,16 @@
-redis:
-  database: 9
-  host: ${REDIS_HOST:192.168.50.8}
-  port: ${REDIS_PORT:6379}
-  password: Pass2010    # 密码(默认为空)
-  timeout: 60000  # 连接超时时长(毫秒)
-  pool:
-    max-active: 1000  # 连接池最大连接数(使用负值表示没有限制)
-    max-wait: -1ms    # 连接池最大阻塞等待时间(使用负值表示没有限制)
-    max-idle: 10      # 连接池中的最大空闲连接
-    min-idle: 5       # 连接池中的最小空闲连接
+spring:
+  redis:
+    database: 9
+    host: ${REDIS_HOST:192.168.50.8}
+    port: ${REDIS_PORT:6379}
+    password: Pass2010    # 密码(默认为空)
+    timeout: 60000  # 连接超时时长(毫秒)
+    lettuce:
+      pool:
+        max-active: 1000  # 连接池最大连接数(使用负值表示没有限制)
+        max-wait: -1ms    # 连接池最大阻塞等待时间(使用负值表示没有限制)
+        max-idle: 10      # 连接池中的最大空闲连接
+        min-idle: 5       # 连接池中的最小空闲连接
 
 hobbystocks:
   host:

+ 1 - 1
auc/src/main/resources/application.yml

@@ -2,7 +2,7 @@ spring:
   profiles:
     active: local
   application:
-    name: auction-hk
+    name: auction-ahx
   datasource:
     url: ${DB_URL:jdbc:postgresql://192.168.50.8:5432/ahx_auction}
     username: ${DB_USERNAME:postgres}

+ 1 - 4
bid/pom.xml

@@ -63,10 +63,7 @@
 			<groupId>org.apache.commons</groupId>
 			<artifactId>commons-lang3</artifactId>
 		</dependency>
-		<dependency>
-			<groupId>com.github.pagehelper</groupId>
-			<artifactId>pagehelper-spring-boot-starter</artifactId>
-		</dependency>
+
 		<!-- 阿里JSON解析器 -->
 		<dependency>
 			<groupId>com.alibaba</groupId>

+ 4 - 183
bid/src/main/java/cn/hobbystocks/auc/app/AppClient.java

@@ -1,19 +1,17 @@
 package cn.hobbystocks.auc.app;
 
-import cn.hobbystocks.auc.common.utils.CloneUtils;
 import cn.hobbystocks.auc.common.utils.DateUtils;
-import cn.hobbystocks.auc.common.utils.StringUtils;
 import cn.hobbystocks.auc.domain.Bid;
 import cn.hobbystocks.auc.domain.Lot;
 import cn.hobbystocks.auc.domain.LotFans;
 import cn.hobbystocks.auc.domain.LotFansPushRecord;
-import cn.hobbystocks.auc.dto.PointDTO;
 import cn.hobbystocks.auc.event.SoldEvent;
 import cn.hobbystocks.auc.forest.CommonForestClient;
 import cn.hobbystocks.auc.handle.context.Live;
 import cn.hobbystocks.auc.mapper.LotFansMapper;
 import cn.hobbystocks.auc.mapper.LotFansPushRecordMapper;
-import cn.hobbystocks.auc.vo.*;
+import cn.hobbystocks.auc.vo.AuctionJPushDTO;
+import cn.hobbystocks.auc.vo.OrderVO;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.dtflys.forest.http.ForestResponse;
@@ -35,12 +33,10 @@ import java.util.stream.Collectors;
 public class AppClient {
     @Autowired
     private CommonForestClient client;
-    @Value("${hobbystocks.host.pointUrl}")
-    private String pointUrl;
+
     @Value("${hobbystocks.host.orderUrl}")
     private String orderUrl;
-    @Value("${hobbystocks.host.couponUrl}")
-    private String couponUrl;
+
     @Value("${hobbystocks.host.noticeUrl}")
     private String noticeUrl;
     @Value("${hobbystocks.host.jPushUrl}")
@@ -109,60 +105,8 @@ public class AppClient {
         }
     }
 
-    @Async
-    public void noticeLive(Live live) {
-        log.info("notice live {}", live.getLot().getId());
-        Map<String, Object> data = new HashMap<>();
-        data.put("code", "chat");
-        data.put("messageType", "no_record");
-        Map<String, Object> messageParam = new HashMap<>();
-        data.put("messageParam", messageParam);
-        messageParam.put("receiver", "LOT-" + live.getLot().getId());
-        Map<String, Object> payload = new HashMap<>();
-        payload.put("contentType", "TEXT");
-        payload.put("sender", 1L);
-        try {
-//            String content = new ObjectMapper().writeValueAsString(SensitiveDataUtils.handleViewDataSafe(live));
-            payload.put("content", live.getLot().getId());
-            payload.put("extra", "{}");
-            messageParam.put("payload", payload);
-            data.put("messageParam", messageParam);
-            ForestResponse<CommonForestClient.Response<Map<String, Object>>> response = client.sendPost(liveWebSocketUrl, getDefaultHeaderMap(), data);
-            if (Objects.isNull(response) || !Objects.equals(response.getStatusCode(), 200)) {
-                log.error("notice live error. {}", live);
-            }
-        } catch (Exception e) {
-            log.error("notice live error. {}", live, e);
-        }
-    }
 
-    @Async
-    public void noticeLiveLot(Long lotId) {
-        log.info("notice live {}", lotId);
-        Map<String, Object> data = new HashMap<>();
-        data.put("code", "chat");
-        data.put("messageType", "no_record");
-        Map<String, Object> messageParam = new HashMap<>();
-        data.put("messageParam", messageParam);
-        messageParam.put("receiver", "LOT-" + lotId);
-        Map<String, Object> payload = new HashMap<>();
-        payload.put("contentType", "TEXT");
-        payload.put("sender", 1L);
-        try {
-//            String content = new ObjectMapper().writeValueAsString(SensitiveDataUtils.handleViewDataSafe(live));
-            payload.put("content", lotId);
-            payload.put("extra", "{}");
-            messageParam.put("payload", payload);
-            data.put("messageParam", messageParam);
-            ForestResponse<CommonForestClient.Response<Map<String, Object>>> response = client.sendPost(liveWebSocketUrl, getDefaultHeaderMap(), data);
-            if (Objects.isNull(response) || !Objects.equals(response.getStatusCode(), 200)) {
-                log.error("notice live error. {}", lotId);
-            }
-        } catch (Exception e) {
-            log.error("notice live error. {}", lotId, e);
-        }
 
-    }
 
     /**
      * 最新出价产生,拍品状态变化,发送通知
@@ -197,31 +141,6 @@ public class AppClient {
         }
     }
 
-    public String createCoupon(SoldEvent soldEvent) {
-        Map<String, Object> params = Maps.newHashMap();
-        params.put("userId", soldEvent.getUserId());
-        params.put("couponId", soldEvent.getGoodsId());
-        params.put("point", soldEvent.getPoint() * 100);
-        params.put("auctionId", soldEvent.getLotId());
-        params.put("startTime", soldEvent.getStartTime());
-        params.put("type", "point");
-        ForestResponse<CommonForestClient.Response<Map<String, Object>>> response = null;
-        try {
-            response = client.sendPost(couponUrl, getDefaultHeaderMap(), params);
-        } catch (Exception e) {
-            log.error("create coupon fail", e);
-            throw new RuntimeException("create coupon fail, " + soldEvent.toString());
-        }
-        if (Objects.nonNull(response) && Objects.equals(response.getStatusCode(), 200) && Objects.equals(response.getResult().getCode(), 200)) {
-            log.info("create coupon {} {}", soldEvent, response.getContent());
-            return soldEvent.getGoodsId().toString();
-        } else if (Objects.nonNull(response) && !Objects.equals(response.getStatusCode(), 200)) {
-            log.error("create coupon fail {} {}", soldEvent, response.getResult().getMsg());
-            throw new RuntimeException("create coupon fail, " + soldEvent);
-        } else {
-            throw new RuntimeException("create coupon fail, " + soldEvent);
-        }
-    }
 
 
     public OrderVO createOrder(SoldEvent soldEvent) {
@@ -297,102 +216,4 @@ public class AppClient {
         headerMap.put("traceid", traceId);
         return headerMap;
     }
-
-    /**
-     * 操作积分构建请求参数
-     *
-     * @param bid         出价记录
-     * @param operateType 操作类型:CONFIRMED:确认,FROZEN:冻结,CANCELED:
-     * @return
-     */
-    private Map<String, Object> operatePointParam(Bid bid, String operateType, String orderNo) {
-        Map<String, Object> map = new HashMap<>();
-        map.put("type", "common");//积分类型:商家积分:merchant,商城积分:goods,平台积分:common
-        map.put("userId", Long.valueOf(bid.getAccountId()));//用户id
-        map.put("changePoint", bid.getAmount().longValue() * -100);//积分
-        map.put("orderId", bid.getId());
-        map.put("orderNo", orderNo);
-        map.put("bizId", "AUCTION_RECORD:" + bid.getId());
-        map.put("status", operateType);//
-        map.put("bizParentId", bid.getLotId());
-        map.put("lockTime", new Date());
-        return map;
-    }
-
-    /**
-     * 冻结积分
-     *
-     * @return
-     */
-    public boolean frozenPoint(Bid bid) {
-        Map<String, Object> frozen = operatePointParam(bid,"FROZEN", "");
-
-        try {
-            String response = client.sendPost(pointUrl, frozen);
-            PointDTO pointDTO = JSON.parseObject(response, PointDTO.class);
-            if (pointDTO.getCode()==200){
-                return pointDTO.isData();
-            }
-            return false;
-        } catch (Exception e) {
-            return false;
-        }
-
-    }
-
-    /**
-     * 解冻出价用户积分
-     *
-     * @param bid
-     * @return
-     */
-    public boolean canceledPoint(Bid bid) {
-        Map<String, Object> canceled = operatePointParam(bid,"CANCELED", "");
-
-        try {
-            String response = client.sendPost(pointUrl, canceled);
-            PointDTO pointDTO = JSON.parseObject(response, PointDTO.class);
-            if (pointDTO.getCode()==200){
-                return pointDTO.isData();
-            }
-            return false;
-        } catch (Exception e) {
-            return false;
-        }
-    }
-
-    public boolean confirmPoint(Bid bid, String orderNo) {
-        Map<String, Object> confirmed = operatePointParam(bid,"CONFIRMED", orderNo);
-        try {
-            String response = client.sendPost(pointUrl, confirmed);
-            PointDTO pointDTO = JSON.parseObject(response, PointDTO.class);
-            if (pointDTO.getCode()==200){
-                return pointDTO.isData();
-            }
-            return false;
-        } catch (Exception e) {
-            return false;
-        }
-    }
-
-    /**
-     * @param nowBid     当前出价
-     * @param lastBid    上一个出价
-     * @return 是否操作成功
-     */
-    public boolean operatePoint(Bid nowBid, Bid lastBid) {
-        if (Objects.isNull(lastBid)) {
-            //第一个出价人,冻结当前出价用户积分
-            return frozenPoint(nowBid);
-        } else {
-            //冻结当前出价积分,解冻上一次出价积分
-            if (frozenPoint(nowBid)) {
-                if (canceledPoint(lastBid)) {
-                    return true;
-                }
-            }
-            return false;
-        }
-
-    }
 }

+ 0 - 57
bid/src/main/java/cn/hobbystocks/auc/handle/CouponSoldHandler.java

@@ -1,57 +0,0 @@
-package cn.hobbystocks.auc.handle;
-
-import cn.hobbystocks.auc.app.AppClient;
-import cn.hobbystocks.auc.common.constant.Constants;
-import cn.hobbystocks.auc.common.utils.StringUtils;
-import cn.hobbystocks.auc.domain.Bid;
-import cn.hobbystocks.auc.event.SoldEvent;
-import cn.hobbystocks.auc.mapper.LotMapper;
-import com.google.common.collect.Sets;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.List;
-import java.util.Set;
-
-@Component
-@Slf4j
-public class CouponSoldHandler implements SoldHandler {
-
-    @Autowired
-    private LotMapper lotMapper;
-    @Autowired
-    private AppClient appClient;
-
-    public static final String noticeUrl = "/pageC/myCoupon/couponList";
-
-    @Override
-    public boolean match(SoldEvent soldEvent) {
-        return Constants.LOT_FROM_TYPE_COUPON.equals(soldEvent.getGoodsType());
-    }
-
-    @Override
-    public boolean handle(SoldEvent soldEvent) {
-        final String coupon = appClient.createCoupon(soldEvent);
-        if (!StringUtils.isEmpty(coupon) &&
-                lotMapper.updateOrder(soldEvent.getLotId() , coupon) > 0 ) {
-            Set<String> bidAccount = Sets.newHashSet();
-            //确认扣减积分
-            List<Bid> bids = soldEvent.getBids();
-
-            appClient.confirmPoint(bids.get(0),null);
-            soldEvent.getBids().forEach(bid -> {
-                if (!bidAccount.contains(bid.getAccountId())) {
-                    //发送站内信,暂不发送
-                    appClient.notice(soldEvent.getName(), bid, noticeUrl);
-                    bidAccount.add(bid.getAccountId());
-                }
-            });
-            soldEvent.setOrderId(coupon);
-            return true;
-        }else {
-            log.error("coupon sold fail  {}", soldEvent);
-            return false;
-        }
-    }
-}

+ 16 - 41
bid/src/main/java/cn/hobbystocks/auc/handle/SkuSoldHandler.java

@@ -7,13 +7,12 @@ import cn.hobbystocks.auc.domain.Bid;
 import cn.hobbystocks.auc.domain.Order;
 import cn.hobbystocks.auc.event.SoldEvent;
 import cn.hobbystocks.auc.mapper.LotMapper;
-import cn.hobbystocks.auc.service.IOrderStatusService;
+import cn.hobbystocks.auc.service.IOrderService;
 import cn.hobbystocks.auc.task.DynamicTaskService;
 import cn.hobbystocks.auc.vo.OrderVO;
 import com.alibaba.fastjson.JSON;
 import com.google.common.collect.Sets;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Isolation;
@@ -37,7 +36,7 @@ public class SkuSoldHandler implements SoldHandler {
     private DynamicTaskService dynamicTaskService;
 
     @Autowired
-    IOrderStatusService orderStatusService;
+    IOrderService orderService;
 
     public static final String noticeUrl = "/pageA/20241111/auctionInfo?id=%s";
 
@@ -49,50 +48,26 @@ public class SkuSoldHandler implements SoldHandler {
     @Override
     @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
     public boolean handle(SoldEvent soldEvent) {
-        OrderVO orderVO = appClient.createOrder(soldEvent);
-        String order = JSON.toJSONString(orderVO);
-        log.info("submit order {}"+order);
-        soldEvent.getLot().setOrderId(order);
+        Order order =new Order();
+        order.setLotId(soldEvent.getLotId());
+        order.setSkuId(soldEvent.getGoodsId());
+        //创建订单并保存数据库
+        OrderVO orderVO = orderService.createSkuOrder(order);
         if (Objects.nonNull(orderVO.getExpireTime())) {
-            //确认扣减积分
-            List<Bid> bids = soldEvent.getBids();
-            Long merchantId = soldEvent.getLot().getMerchantId();
-            if (1L == soldEvent.getLot().getAuctionId()){
-                //如果为积分抢拍
-                appClient.confirmPoint(bids.get(0),orderVO.getOrderNo());
-            }
 
             lotMapper.updatePay(soldEvent.getLotId(), -1);
             soldEvent.getLot().setPaid(-1L);
-
-            //保存订单相关信息
-            Order dbOrder = new Order();
-            BeanUtils.copyProperties(orderVO,dbOrder);
-            dbOrder.setFlag(0);
-            dbOrder.setLotId(soldEvent.getLotId());
-            dbOrder.setUserId(soldEvent.getUserId().longValue());
-            dbOrder.setMerchantId(merchantId);
-            orderStatusService.addOrder(dbOrder);
         }
-        if (!StringUtils.isEmpty(order) &&
-                lotMapper.updateOrder(soldEvent.getLotId() , order) > 0 ) {
-            //积分抢拍
-            if (!Objects.equals(2L, soldEvent.getLot().getAuctionId())) {
 
-                Set<String> bidAccount = Sets.newHashSet();
-                soldEvent.getBids().forEach(bid -> {
-                    if (!bidAccount.contains(bid.getAccountId())) {
-                        //发送站内信
-                        appClient.notice(soldEvent.getName(), bid, String.format(noticeUrl, bid.getLotId()));
-                        bidAccount.add(bid.getAccountId());
-                    }
-                });
+        Set<String> bidAccount = Sets.newHashSet();
+        soldEvent.getBids().forEach(bid -> {
+            if (!bidAccount.contains(bid.getAccountId())) {
+                //发送站内信
+                appClient.notice(soldEvent.getName(), bid, String.format(noticeUrl, bid.getLotId()));
+                bidAccount.add(bid.getAccountId());
             }
-            soldEvent.setOrderId(order);
-            return true;
-        } else {
-            log.error("sku sold fail  {}", soldEvent);
-            return false;
-        }
+        });
+        return true;
+
     }
 }

+ 3 - 0
bid/src/main/java/cn/hobbystocks/auc/listener/LiveEndListener.java

@@ -43,6 +43,7 @@ public class LiveEndListener {
         final String status = live.getLot().getStatus();
         Long groupId = live.getLot().getGroupId();
         if (Objects.nonNull(groupId)) {
+            //拍品组
             lotService.handleEndLotGroup(LotGroup.builder().id(groupId).build(), status);
 
             try {
@@ -69,6 +70,8 @@ public class LiveEndListener {
             }catch (Exception e) {
                 log.error("lot_auction group fail {}" ,  live.getLot().getId(), e);
             }
+        }else{
+            //拍卖会
         }
     }
 

+ 105 - 79
bid/src/main/java/cn/hobbystocks/auc/task/BidTask.java

@@ -12,15 +12,17 @@ import cn.hobbystocks.auc.domain.*;
 import cn.hobbystocks.auc.handle.RuleHandlerHolder;
 import cn.hobbystocks.auc.handle.context.Live;
 import cn.hobbystocks.auc.mapper.*;
+import cn.hobbystocks.auc.service.DepositOrderService;
 import cn.hobbystocks.auc.service.IAuctionService;
 import cn.hobbystocks.auc.service.ILotService;
-import cn.hobbystocks.auc.service.IOrderStatusService;
-import cn.hobbystocks.auc.vo.CardGroupLivesConfigVO;
+import cn.hobbystocks.auc.service.IOrderService;
 import cn.hobbystocks.auc.vo.OrderVO;
-import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.google.common.collect.Lists;
 import io.micrometer.core.instrument.util.NamedThreadFactory;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.Strings;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.scheduling.annotation.Scheduled;
@@ -30,7 +32,6 @@ import org.springframework.util.CollectionUtils;
 import javax.annotation.PostConstruct;
 import java.util.*;
 import java.util.concurrent.*;
-import java.util.stream.Collectors;
 
 @Component
 @Slf4j
@@ -50,7 +51,10 @@ public class BidTask implements CacheMap {
 
 	@Autowired
 	private IAuctionService auctionService;
-
+	@Autowired
+    private DepositOrderService depositOrderService;
+    @Autowired
+    private IOrderService orderService;
 	@Value("${auction.thread.corePoolSize:50}")
 	private Integer corePoolSize;
 	@Value("${auction.thread.maximumPoolSize:100}")
@@ -62,20 +66,17 @@ public class BidTask implements CacheMap {
 	private String userUrl;
 
 	private ThreadPoolExecutor threadPool;
-	@Autowired
-	private LotFansMapper lotFansMapper;
+
 	@Autowired
 	private AppClient appClient;
-	@Autowired
-	private LotGroupMapper lotGroupMapper;
+
     @Autowired
     private LotMapper lotMapper;
     @Autowired
     private BidMapper bidMapper;
     @Autowired
     private BidRecordMapper bidRecordMapper;
-    @Autowired
-    IOrderStatusService orderStatusService;
+
 
     // endregion
 
@@ -164,32 +165,15 @@ public class BidTask implements CacheMap {
 
     // region schedule tasks
 
-    /// 5s一次检查并处理即将过期的订单
-	/*@Scheduled(fixedRate = 5000)
-	public void expire() {
-		lotFansMapper.selectLotFansList(LotFans.builder().type("pre_pay_expire").build()).forEach(fans -> {
-			Lot lot = lotService.selectLotById(fans.getLotId());
-			/// 如果当前时间大于 fans 对象的过期时间
-            if (System.currentTimeMillis() > fans.getExpire().getTime()) {
-                ///更新过期未支付
-                lotService.updateExpire(fans);
-                /// 通知直播平台更新商品状态
-                appClient.noticeLiveLot(lot.getId());
-            }else {
-                lotService.updateSoldAndPaid(fans, lot.getGroupId());
-                // 通知app更新商品
-                appClient.noticeLiveLot(lot.getId());
-			}
-		});
-	}*/
+
 
     /**
-     * 每5秒检查下订单状态,如订单已过期则更新拍品状态为
+     * 每5秒检查下订单状态,如订单已过期则更新拍品状态为流拍
      */
     @Scheduled(fixedRate = 5000)
     public void expireOrder(){
         //查询所有订单状态,如果订单超时未支付,更新拍品状态为流拍
-        List<Order> orderList = orderStatusService.list();
+        List<Order> orderList = orderService.list();
         for (Order order : orderList) {
             Lot lot = lotMapper.selectLotById(order.getLotId());
             if (System.currentTimeMillis() > order.getExpireTime().getTime()) {
@@ -205,12 +189,12 @@ public class BidTask implements CacheMap {
                     //更新拍品状态为流拍
                     lotMapper.updateLot(Lot.builder().id(order.getLotId()).status(Constants.LOT_STATUS_PASS).build());
                     //更新订单标识为已处理
-                    orderStatusService.modifyOrder(Order.builder().orderNo(order.getOrderNo()).flag(1).expireTime(DateUtils.addDays(new Date(),1)).build());
+                    orderService.modifyOrder(Order.builder().orderNo(order.getOrderNo()).flag(1).expireTime(DateUtils.addDays(new Date(),1)).build());
                 }else{
                     //订单状态已支付,更新拍品为成交状态
                     lotMapper.updatePay(order.getLotId(), 1);
-                    lotGroupMapper.addSold(lot.getGroupId());
-                    orderStatusService.modifyOrder(Order.builder().orderNo(order.getOrderNo()).flag(2).build());
+
+                    orderService.modifyOrder(Order.builder().orderNo(order.getOrderNo()).flag(2).build());
                     // 通知更新拍品信息
                 }
                 appClient.notice(lot.getId().toString(),"","{}","lot_auction","");
@@ -218,39 +202,12 @@ public class BidTask implements CacheMap {
 
         }
     }
-    /// 每5s检查一次order_status查询flag=1,订单超时未支付状态并且已超过过期的时间的orderStatus然后将其移除
-	@Scheduled(fixedRate = 5000)
-	public void expirePay() {
-        orderStatusService.orderStatusCheck();
-	}
 
-    /**
-     * 每5秒检查一次直播状态,并更新数据库中的直播信息
-     */
-	/*@Scheduled(fixedDelay = 5000)
-	private void liveCheck(){
-        // 查询需要检查直播状态为结束的直播ID列表
-		List<Long> ids = lotGroupMapper.selectLiveCheck().stream().mapToLong(LotGroup::getLiveId).distinct().boxed().collect(Collectors.toList());
-        if (!CollectionUtils.isEmpty(ids)) {
-            // 通过App获取直播状态信息
-			List<CardGroupLivesConfigVO> list = appClient.getLive(ids);
-			if (!CollectionUtils.isEmpty(list)) {
-                // 过滤出有效的直播ID
-				List<Long> liveIds = list.stream()
-						.filter(cardGroupLivesConfigVO -> Objects.nonNull(cardGroupLivesConfigVO.getId()))
-						.mapToLong(CardGroupLivesConfigVO::getId)
-						.boxed()
-						.collect(Collectors.toList());
-				if (!CollectionUtils.isEmpty(liveIds)) {
-                    // 更新数据库中的直播信息
-					lotGroupMapper.updateClearLive(liveIds);
-				}
-			}
-		}
-	}*/
+
+
 
     /**
-     * 每1秒检查一次正在竞拍的拍品,并更新直播状态
+     * 每1秒检查一次正在竞拍的拍品,并更新拍卖状态
      */
 	@Scheduled(fixedRate = 1000)
 	public void live() {
@@ -258,19 +215,19 @@ public class BidTask implements CacheMap {
 		lotService.selectBidding().forEach(lot -> {
             // 根据拍品的拍卖ID生成Redis缓存键
 			String aucKey = String.format(Constants.REDIS_MAP_AUC_LOT_TEMPLATE, lot.getAuctionId());
-            // 从Redis缓存中获取对应拍品的直播数据
+            // 从Redis缓存中获取对应拍品的数据
 			Live live = redisCache.getCacheMapValue(aucKey, lot.getId().toString());
 			if (Objects.nonNull(live)) {
-                // 将直播数据放入本地缓存中
+                // 将拍卖数据放入本地缓存中
 				liveCacheMap.computeIfAbsent(aucKey, s -> new ConcurrentHashMap<>())
 						.put(live.getLot().getId().toString(), live);
-                // 将直播任务提交到线程池中执行
+                // 将拍卖任务提交到线程池中执行
 				threadPool.submit(() -> {
 					String currentStatus = ruleHandlerHolder.getCurrentStatus(live);
-                    // 如果当前状态是拍品状态未开始,则返回
+                    // 如果当前状态是拍品状态未开始,则返回
 					if (Objects.equals(Constants.LOT_STATUS_WAITING, currentStatus))
 						return;
-                    // 尝试获取锁,并执行直播服务
+                    // 尝试获取锁,并执行拍卖计算服务
 					locker.tryLock(String.format(Constants.REDIS_LOCK_LOT_TEMPLATE, live.getLot().getId()), () -> lotService.live(live));
 				});
 			}
@@ -279,36 +236,36 @@ public class BidTask implements CacheMap {
 		lotService.selectCancel().forEach(lot -> {
             // 根据拍品的拍卖ID生成Redis缓存键
 			String aucKey = String.format(Constants.REDIS_MAP_AUC_LOT_TEMPLATE, lot.getAuctionId());
-            // 从本地缓存中移除已取消的拍品的直播数据
+            // 从本地缓存中移除已取消的拍品的拍卖数据
 			liveCacheMap.computeIfAbsent(aucKey, s -> new ConcurrentHashMap<>())
 					.remove(lot.getId().toString());
 		});
-        // 遍历本地缓存中的所有直播数据
+        // 遍历本地缓存中的所有拍卖数据
 		for (String aucKey : liveCacheMap.keySet()) {
 			ConcurrentHashMap<String, Live> map = liveCacheMap.get(aucKey);
 			List<String> lotIds = Lists.newArrayList();
-            // 遍历所有直播数据,检查是否有过期的直播
+            // 遍历所有拍卖数据,检查是否有过期的拍卖
 			map.values().forEach(live -> {
-                // 如果当前时间超过直播结束时间3秒,则将该拍品ID添加到移除列表中
+                // 如果当前时间超过拍卖结束时间3秒,则将该拍品ID添加到移除列表中
 				if (live.getCurrentEndTime() + 3000 < System.currentTimeMillis()) {
 					lotIds.add(live.getLot().getId().toString());
 				}
 			});
-            // 移除过期的直播数据
+            // 移除过期的拍卖数据
 			lotIds.forEach(map::remove);
 		}
 	}
 
     /**
-     * 每5分钟检查一次已结束的直播,并清理相关数据
+     * 每5分钟检查一次已结束的拍卖,并移除缓存
      */
 	@Scheduled(fixedRate = 5 * 60 * 1000)
 	public void delFinishLive() {
-        // 遍历所有正在直播的拍卖
+        // 遍历所有正在拍卖的拍卖会
 		auctionService.live().forEach(auction -> {
             // 根据拍卖ID生成Redis缓存键
 			String aucKey = String.format(Constants.REDIS_MAP_AUC_LOT_TEMPLATE, auction.getId());
-            // 从Redis缓存中获取对应拍卖的直播数据Map
+            // 从Redis缓存中获取对应拍卖的数据Map
 			Map<String, Live> auctionMap = redisCache.getCacheMap(aucKey);
             // 遍历所有直播数据
 			auctionMap.values().forEach(live -> {
@@ -331,12 +288,18 @@ public class BidTask implements CacheMap {
 		});
 	}
 
-
+    /**
+     * 每秒更新拍卖会状态
+     */
+	@Scheduled(fixedRate = 1000)
+    public void auction(){
+	    auctionService.auctionLive();
+	}
 
     /**
      * 每1秒检查一次拍卖状态,并将缓存中未写入数据库的bid数据写入数据库
      */
-    @Scheduled(fixedDelay = 1 * 1 * 1000)
+    @Scheduled(fixedDelay = 1000)
     private void auctionLotCheck(){
         lotService.selectBidding().forEach(lot -> {
             List<Bid> bidList = redisCache.getCacheList(String.format(Constants.REDIS_MAP_AUC_LOT_BID_LIST_PREFIX, lot.getId()));
@@ -366,5 +329,68 @@ public class BidTask implements CacheMap {
         });
     }
 
+    //拍卖会结束发起退保证金,每五分钟执行一次
+    @Scheduled(fixedRate = 1000*60*5)
+    public void depositOrderRefund(){
+        //查询已支付待退款的保证金订单
+        DepositOrder depositOrder = new DepositOrder();
+        depositOrder.setStatus(1);
+        List<DepositOrder> depositOrderList = depositOrderService.selectDepositOrder(depositOrder);
+        for (DepositOrder order : depositOrderList) {
+            Long userId = order.getUserId();
+            //判断拍卖会是否已结束
+            Auction auction = auctionService.selectAuctionById(order.getAuctionId());
+            if (!Constants.GROUP_STATUS_FINISH.equals(auction.getStatus())){
+                //如果拍卖会未结束,处理下一个保证金订单
+                continue;
+            }
+            if (StringUtils.equals("拍卖会",order.getDepositType())){
+
+                //判断是否有未结束的未设置单独保证金的拍品
+                List<Lot> lots = lotMapper.selectNotEndLotList(order.getAuctionId());
+                if (!CollectionUtils.isEmpty(lots))
+                    continue;
+                //拍卖会保证金,查询用户在该拍卖会下是否有非单独保证金的拍品中标未支付订单
+                List<Order> orderList = orderService.getOrderListByUserAndAuction(order.getAuctionId(), userId);
+                if (CollectionUtils.isEmpty(orderList)){
+                    //todo 没有待支付订单,或没中标,或已支付,执行退保证金操作
+                    OrderVO orderVO = depositOrderService.refundDepositOrder(order.getOrderNo());
+                    // todo 更新保证金订单状态
+
+                    depositOrderService.lambdaUpdate().eq(DepositOrder::getId,order.getId()).set(DepositOrder::getStatus,orderVO.getStatus());
+                    continue;
+                }
+                //有待支付的订单列表,判断订单是否已过期,并更新订单记录表状态,
+                for (Order order1 : orderList) {
+                  if (order1.getFlag()==2){
+                      //todo 订单待支付已过期,调用扣除保证金接口,更新订单记录表状态
+
+                      // todo 更新保证金订单状态
+                  }
+                }
+            }else{
+                Long lotId = order.getLotId();
+                //查询拍品是否已结束,未结束则跳过
+                Lot lot = lotMapper.selectLotById(lotId);
+                if (StringUtils.equalsAny(lot.getStatus(), Constants.LOT_STATUS_WAITING, Constants.LOT_STATUS_STARTING, Constants.LOT_STATUS_BIDDING))
+                    continue;
+
+                //已结束,查询用户是否有该拍品的订单,
+                LambdaQueryWrapper<Order> queryWrapper = new LambdaQueryWrapper<>();
+                queryWrapper.eq(Order::getLotId,lotId).eq(Order::getUserId,order.getUserId());
+                Order order1 = orderService.getOne(queryWrapper);
+
+                if (order1==null){
+                    //todo 未中标,退拍品保证金
+
+                    continue;
+                }
+                if (order1.getFlag()==2){
+                    //todo 订单已过期 调用接口扣除保证金
+
+                }
+            }
+        }
+    }
     // endregion
 }

+ 18 - 120
bid/src/main/java/cn/hobbystocks/auc/web/BidingController.java

@@ -7,8 +7,6 @@ import cn.hobbystocks.auc.common.core.controller.BaseController;
 import cn.hobbystocks.auc.common.core.domain.AjaxResult;
 import cn.hobbystocks.auc.common.core.redis.RedisCache;
 import cn.hobbystocks.auc.common.core.text.Convert;
-import cn.hobbystocks.auc.common.exception.AddPriceException;
-import cn.hobbystocks.auc.common.exception.LockException;
 import cn.hobbystocks.auc.common.user.UserInfo;
 import cn.hobbystocks.auc.common.user.UserUtils;
 import cn.hobbystocks.auc.common.utils.CloneUtils;
@@ -23,13 +21,10 @@ import cn.hobbystocks.auc.handle.context.LiveContext;
 import cn.hobbystocks.auc.mapper.BidRecordMapper;
 import cn.hobbystocks.auc.service.IBidService;
 import cn.hobbystocks.auc.service.ILotService;
-import cn.hobbystocks.auc.service.IOrderStatusService;
 import cn.hobbystocks.auc.vo.BidVO;
 import com.alibaba.fastjson.JSON;
-import com.dtflys.forest.http.ForestResponse;
 import com.github.pagehelper.Page;
 import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -76,8 +71,7 @@ public class BidingController extends BaseController {
     private RuleHandlerHolder ruleHandlerHolder;
 
 
-    @Autowired
-    private IOrderStatusService orderStatusService;
+
     // endregion
 
     // region Controllers
@@ -89,67 +83,11 @@ public class BidingController extends BaseController {
         return AjaxResult.success();
     }
 
-    @ApiOperation("调用积分接口处理积分变动")
-    @PostMapping("/point")
-    public AjaxResult point(@RequestBody Map<String, Object> map) {
-        ForestResponse<CommonForestClient.Response<Map<String, Object>>>  response =
-            client.sendPost(pointUrl, Maps.newHashMap(), map);
-        if (Objects.nonNull(response) && Objects.equals(response.getStatusCode(), 200) && Objects.equals(response.getResult().getCode(), 0)) {
-            return AjaxResult.success();
-        }else {
-            throw new RuntimeException();
-        }
-    }
-
-    @ApiOperation("积分拍卖增加价格")
-    @PostMapping("/addPrice")
-    public AjaxResult addPrice(@RequestBody BidVO bid) {
-        log.info("add price {}", bid);
-
-        UserInfo userInfo = UserUtils.getUserInfo();
-
-        // 创建bidRecord
-        bid.setCreateBy(userInfo.getSub());
-        bid.setAccount(userInfo.getAccount());
-        String accountId = String.valueOf(userInfo.getId());
-        bid.setAccountId(accountId);
-        bid.setAvatar(userInfo.getAvatar());
-        bid.setBidNo(UUID.randomUUID().toString());
-        Long recordId = createBidRecord(bid);
-        Lot lot = lotService.selectLotById(bid.getLotId());
-        // 判断拍卖状态
-        String error = checkLotStatus(bid);
-        if (StringUtils.hasLength(error)) {
-            return AjaxResult.error(error);
-        }
-
-        if(!userInfo.isHasAddress()) {
-            return AjaxResult.error("请先添加地址");
-        }
-
-        try {
-            bidService.addPrice(bid,
-                () -> point(bid) // 这里处理积分相关的
-            );
-        }catch (RuntimeException e) {
-            log.error("addPrice error {}", bid, e);
-            if (e instanceof LockException) {
-                return AjaxResult.error("商品当前积分已变动");
-            }else if (e instanceof AddPriceException) {
-                return AjaxResult.error(e.getMessage());
-            }else {
-                return AjaxResult.error("出价失败");
-            }
-        }
-        return AjaxResult.success();
-    }
-
-
-
     @ApiOperation("出价拍卖增加价格")
-    @PostMapping({"/v2/addPrice"})
+    @PostMapping({"/addPrice"})
     public AjaxResult addPriceV2(@RequestBody BidVO bid) {
-        bid.setAuctionId(2L);
+        //todo 判断用户是否已缴纳保证金
+
         log.info("add price {}", bid);
         // 创建bidRecord
         UserInfo userInfo = UserUtils.getUserInfo();
@@ -160,9 +98,10 @@ public class BidingController extends BaseController {
         bid.setAccountId(accountId);
         bid.setAvatar(userInfo.getAvatar());
         bid.setBidNo(UUID.randomUUID().toString());
+        //用户出价记录日志,无论是否出价成功都记录
         Long recordId = createBidRecord(bid);
 
-        if (Objects.equals(2, userInfo.getAccountStatus())) {
+        /*if (Objects.equals(2, userInfo.getAccountStatus())) {
             return AjaxResult.error("暂时无法参与当前竞价");
         }
         if (!Objects.equals(1, userInfo.getFaceVerify()) && !bid.getTest()) {
@@ -171,7 +110,7 @@ public class BidingController extends BaseController {
 
         if(!userInfo.isHasAddress()) {
             return AjaxResult.error("请先添加地址");
-        }
+        }*/
 
         // 判断拍卖状态
         String error = checkLotStatus(bid);
@@ -180,18 +119,11 @@ public class BidingController extends BaseController {
             return AjaxResult.error("出价失败");
         }
         Lot lot = cacheMap.viewLot(bid.getAuctionId(), bid.getLotId()).getLot();
-        if (Objects.equals(lot.getMerchantId().intValue(), userInfo.getMerchantId())) {
+        /*if (Objects.equals(lot.getMerchantId().intValue(), userInfo.getMerchantId())) {
             log.warn("出价失败,商家无法参与自己的竞价拍卖");
             return AjaxResult.error("出价失败,商家无法参与自己的竞价拍卖");
-        }
-        List<Order> orderList = orderStatusService.selectOrderStatusList(Order.builder().flag(1).merchantId(lot.getMerchantId()).userId(userInfo.getId().longValue()).build());
-        /*if (!CollectionUtils.isEmpty(orderList)) {
-            return AjaxResult.error("因您存在超时支付,暂时无法参与当前竞价");
-        }
-        orderList=orderStatusService.selectOrderStatusList(Order.builder().flag(0).merchantId(lot.getMerchantId()).status(100L).userId(userInfo.getId().longValue()).build());
-        if (!CollectionUtils.isEmpty(orderList)) {
-            return AjaxResult.error("支付当前待支付订单才可继续参与竞价");
         }*/
+
         try {
             bidService.addPrice(bid,() ->{ });
         }catch (RuntimeException e) {
@@ -281,9 +213,9 @@ public class BidingController extends BaseController {
     }
 
     @ApiOperation("从 Redis 缓存中获取id对应的 Live 对象,并将其返回")
-    @GetMapping("/viewEx/{id}")
-    public AjaxResult viewEx(@PathVariable Long id) {
-        Live live = redisCache.getCacheMapValue(String.format(Constants.REDIS_AUC_TEMPLATE, 2), id.toString());
+    @GetMapping("/viewEx/{auctionId}/{id}")
+    public AjaxResult viewEx(@PathVariable Long auctionId,@PathVariable Long id) {
+        Live live = redisCache.getCacheMapValue(String.format(Constants.REDIS_AUC_TEMPLATE, auctionId), id.toString());
         return AjaxResult.success(JSON.toJSON(live));
     }
 
@@ -326,16 +258,7 @@ public class BidingController extends BaseController {
 
             Long merchantId = lot.getMerchantId();
             Long userId = Long.valueOf(getUserId());
-            List<Order> orderList = orderStatusService.selectOrderStatusList(Order.builder().flag(1).merchantId(merchantId).userId(userId).build());
-            if (!CollectionUtils.isEmpty(orderList)) {
-                isForbiddenUser = true;
-                forbiddenReason = "因您存在超时支付,暂时无法参与当前竞价";
-            }
-            orderList=orderStatusService.selectOrderStatusList(Order.builder().flag(0).merchantId(lot.getMerchantId()).userId(userId).build());
-            if (!CollectionUtils.isEmpty(orderList)) {
-                isForbiddenUser = true;
-                forbiddenReason = "支付当前待支付订单才可继续参与竞价";
-            }
+
             if(isForbiddenUser){
                 redisCache.setCacheMapValue(String.format(Constants.REDIS_MAP_AUC_LOT_BID_USER_TEMPLATE, lot.getId()), curruserInfo.getId().toString(), forbiddenReason);
             }
@@ -574,22 +497,7 @@ public class BidingController extends BaseController {
             }
         }
     }
-    // endregion
-
-
-    // region Methods
 
-    private void point(BidVO bid) {
-        List<Bid> bids = redisCache.getCacheList(String.format(Constants.REDIS_MAP_AUC_LOT_BID_TEMPLATE, bid.getLotId()));
-        Bid lastBid = null;
-        if (!CollectionUtils.isEmpty(bids)) {
-            lastBid = bids.get(0);
-        }
-        log.info("currBid {} lastBid {}",JSON.toJSONString(bid),JSON.toJSONString(lastBid));
-        if (!appClient.operatePoint(bid, lastBid)) {
-            throw new AddPriceException("积分校验失败");
-        }
-    }
 
     private String checkLotStatus(BidVO bid) {
         log.info("checkLotStatus cacheMap {}",cacheMap);
@@ -607,21 +515,11 @@ public class BidingController extends BaseController {
             log.info("sync liveContext {}",liveContext);
             live = liveContext.getLive();
             live.setLot(lot);
-            if (Objects.equals(bid.getAuctionId(), 2L)) {
-                Long groupId = lot.getGroupId();
-                LotGroup lotGroup = lotService.selectLotGroupById(groupId);
-                if (lotGroup.getFinishNum() >= lotGroup.getNum()) {
-                    live.setFinish(1);
-                    log.info("cacheMap putLive {}","未找到正在进行中的拍卖");
-                    return "未找到正在进行中的拍卖";
-                }else {
-                    live.setFinish(0);
-                    cacheMap.putLive(live);
-                    log.info("cacheMap putLive {}",live);
-                    return null;
-                }
-            }
-            return "未找到正在进行中的拍卖";
+
+            live.setFinish(0);
+            cacheMap.putLive(live);
+            log.info("cacheMap putLive {}",live);
+            return null;
         }
         if (Constants.LOT_STATUS_WAITING.equals(live.getLot().getStatus())) {
             return "拍卖还未开始";

+ 45 - 0
bid/src/main/java/cn/hobbystocks/auc/web/DepositOrderController.java

@@ -0,0 +1,45 @@
+package cn.hobbystocks.auc.web;
+
+import cn.hobbystocks.auc.common.core.domain.AjaxResult;
+import cn.hobbystocks.auc.common.user.UserInfo;
+import cn.hobbystocks.auc.common.user.UserUtils;
+import cn.hobbystocks.auc.dto.DepositOrderDTO;
+import cn.hobbystocks.auc.service.DepositOrderService;
+import cn.hobbystocks.auc.service.IOrderService;
+import cn.hobbystocks.auc.vo.OrderVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+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.Objects;
+
+/**
+ * 保证金订单接口
+ */
+@RestController
+@RequestMapping("/order")
+@Slf4j
+@Api(tags = "保证金订单")
+public class DepositOrderController {
+
+    @Autowired
+    DepositOrderService orderService;
+
+
+    //创建保证金订单接口
+    @PostMapping("/deposit/create")
+    @ApiOperation(value = "创建保证金订单接口",notes = "")
+    public AjaxResult createDepositOrder(DepositOrderDTO depositOrderDTO){
+        UserInfo simpleUserInfo = UserUtils.getSimpleUserInfo();
+        if (Objects.isNull(simpleUserInfo))
+            return AjaxResult.error("请先登录");
+        //todo 判断是否已经缴纳保证金,需要查询订单记录,
+        depositOrderDTO.setUserId(Long.valueOf(simpleUserInfo.getId()));
+        OrderVO depositOrder = orderService.createDepositOrder(depositOrderDTO);
+        return AjaxResult.success();
+    }
+}

+ 4 - 55
bid/src/main/java/cn/hobbystocks/auc/web/LocalController.java

@@ -1,10 +1,7 @@
 package cn.hobbystocks.auc.web;
 
-import cn.hobbystocks.auc.annotation.RequireRoles;
 import cn.hobbystocks.auc.common.constant.Constants;
 import cn.hobbystocks.auc.common.core.domain.AjaxResult;
-import cn.hobbystocks.auc.common.user.UserUtils;
-import cn.hobbystocks.auc.common.utils.UserType;
 import cn.hobbystocks.auc.domain.Bid;
 import cn.hobbystocks.auc.domain.Lot;
 import cn.hobbystocks.auc.domain.LotGroup;
@@ -13,10 +10,8 @@ import cn.hobbystocks.auc.dto.LotDTO;
 import cn.hobbystocks.auc.handle.context.tradition.TraditionRule;
 import cn.hobbystocks.auc.service.IBidService;
 import cn.hobbystocks.auc.service.ILotService;
-import cn.hobbystocks.auc.service.IOrderStatusService;
 import cn.hobbystocks.auc.vo.LotGroupDTO;
 import cn.hobbystocks.auc.vo.LotGroupVO;
-import cn.hobbystocks.auc.vo.OrderVO;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Lists;
@@ -35,8 +30,6 @@ import java.util.Objects;
 @RequestMapping("/api/local/")
 @Api(tags = "本地服务接口")
 public class LocalController {
-    @Autowired
-    IOrderStatusService orderStatusService;
 
     @Autowired
     private ILotService lotService;
@@ -62,35 +55,7 @@ public class LocalController {
         }
     }
 
-    @ApiOperation(value = "拍品组列表查询",notes = "根据请求体中的 LotGroupVO 对象,返回符合条件的拍卖组列表")
-    @PostMapping("lot/list")
-    public AjaxResult list(@RequestBody LotGroupVO lotGroup) {
-        if (Objects.isNull(lotGroup.getLotIds())) {
-            return AjaxResult.error("未查询到相关信息");
-        }
-        List<LotGroupDTO> list = Lists.newArrayList();
-        lotService.findPubbedLotGroupByIds(lotGroup.getLotIds(),lotGroup.getMerchantId()).forEach(group -> {
-            LotGroupDTO lotGroupDTO = new LotGroupDTO();
-            BeanUtils.copyProperties(group, lotGroupDTO);
-            TraditionRule traditionRule = JSON.parseObject(group.getRuleContent(), TraditionRule.class);
-            lotGroupDTO.setGoodsPrice(traditionRule.getStartPrice());
-            Long lotId = lotGroupDTO.getLotId();
-            if (Objects.nonNull(lotId)) {
-                Lot lot = lotService.selectLotById(lotId);
-                if (Objects.nonNull(lot)) {
-                    lotGroupDTO.setName(lot.getName());
-                    String status = lot.getStatus();
-                    if (StringUtils.equals(status, Constants.LOT_STATUS_BIDDING)||StringUtils.equals(status, Constants.LOT_STATUS_STARTING)){
-                        LotDTO lotDTO = new LotDTO();
-                        BeanUtils.copyProperties(lot,lotDTO);
-                        lotGroupDTO.setLot(lotDTO);
-                    }
-                }
-            }
-            list.add(lotGroupDTO);
-        });
-        return new AjaxResult(200, null, list);
-    }
+
 
     @GetMapping("order/callback/{orderNo}/{status}")
     @ApiOperation(value = "订单状态回调",notes = "订单状态回调,竞价成功创建订单,用户订单支付后回调该接口")
@@ -100,10 +65,10 @@ public class LocalController {
     public AjaxResult callback(@PathVariable("orderNo") String orderNo,@PathVariable("status") Long status){
         //根据orderId更新order状态
         Order order = Order.builder().orderNo(orderNo).status(status).build();
-        int num = orderStatusService.modifyOrder(order);
+        /*int num = orderStatusService.modifyOrder(order);
         if (num>0){
             return AjaxResult.success("请求成功");
-        }
+        }*/
         return AjaxResult.error("更新状态失败");
     }
     @ApiOperation(value = "出价记录查询",notes = "根据出价id查询当前出价是否中标")
@@ -119,21 +84,5 @@ public class LocalController {
         jsonObject.put("id",bid.getId());
         return AjaxResult.success(jsonObject);
     }
-    @ApiOperation(value = "开始竞拍",notes = "启动竞拍流程,并发送竞拍开始的通知")
-    @GetMapping("/lot/start/{lotGroupId}")
-    public AjaxResult start(@PathVariable("lotGroupId")Long lotGroupId) {
-        LotGroup lotGroup = lotService.selectLotGroupById(lotGroupId);
-        //校验拍品状态,如果当前拍品为正在竞价中,返回开始竞价失败
-        String status = lotGroup.getStatus();
-        if (StringUtils.equals(status,Constants.GROUP_STATUS_STARTING)||StringUtils.equals(status,Constants.GROUP_STATUS_BIDDING)){
-            return AjaxResult.error("当前有正在竞拍的拍品,无法开始下一轮竞拍");
-        }
-        Long party;
-        try {
-            party = lotService.party(lotGroup);
-        } catch (Exception e) {
-            return AjaxResult.error(e.getMessage());
-        }
-        return AjaxResult.success(party);
-    }
+
 }

+ 13 - 11
bid/src/main/resources/application-local.yml

@@ -1,14 +1,16 @@
-redis:
-  database: 9
-  host: ${REDIS_HOST:192.168.50.10}
-  port: ${REDIS_PORT:26379}
-  password: Pass2010    # 密码(默认为空)
-  timeout: 60000  # 连接超时时长(毫秒)
-  pool:
-    max-active: 1000  # 连接池最大连接数(使用负值表示没有限制)
-    max-wait: -1ms    # 连接池最大阻塞等待时间(使用负值表示没有限制)
-    max-idle: 10      # 连接池中的最大空闲连接
-    min-idle: 5       # 连接池中的最小空闲连接
+spring:
+  redis:
+    database: 9
+    host: ${REDIS_HOST:192.168.50.8}
+    port: ${REDIS_PORT:6379}
+    password: Pass2010    # 密码(默认为空)
+    timeout: 60000  # 连接超时时长(毫秒)
+    lettuce:
+      pool:
+        max-active: 1000  # 连接池最大连接数(使用负值表示没有限制)
+        max-wait: -1ms    # 连接池最大阻塞等待时间(使用负值表示没有限制)
+        max-idle: 10      # 连接池中的最大空闲连接
+        min-idle: 5       # 连接池中的最小空闲连接
 
 hobbystocks:
   host:

+ 6 - 0
lot/pom.xml

@@ -78,6 +78,12 @@
 		<dependency>
 			<groupId>com.github.pagehelper</groupId>
 			<artifactId>pagehelper-spring-boot-starter</artifactId>
+			<exclusions>
+				<exclusion>
+					<groupId>org.mybatis</groupId>
+					<artifactId>mybatis-spring</artifactId>
+				</exclusion>
+			</exclusions>
 		</dependency>
 		<!-- spring security 安全认证 -->
 		<dependency>

+ 2 - 2
lot/src/main/java/cn/hobbystocks/auc/common/constant/Constants.java

@@ -51,6 +51,7 @@ public class Constants {
 
     // 传统拍 + 延迟拍 + v2
     public static final String AUC_RULE_TYPE_TRADITIONAL_DELAY_V2 = "traditional_delay_v2";
+    public static final String AUC_RULE_TYPE_TRADITIONAL_DELAY_V3 = "traditional_delay_v3";
 
 	//拍品状态未开始
 	public static final String LOT_STATUS_WAITING ="Waiting";
@@ -90,8 +91,7 @@ public class Constants {
     // 拍品来源 sku
     public static final String LOT_FROM_TYPE_SKU = "sku";
 
-    // 拍品来源 优惠券
-    public static final String LOT_FROM_TYPE_COUPON = "coupon";
+
 
     // 拍品来源 优惠券
     public static final String LOT_FROM_TYPE_AUCTION = "auction";

+ 8 - 0
lot/src/main/java/cn/hobbystocks/auc/common/core/domain/BaseEntity.java

@@ -6,6 +6,7 @@ import java.util.*;
 import cn.hobbystocks.auc.annotation.Sensitive;
 import cn.hobbystocks.auc.annotation.View;
 import cn.hobbystocks.auc.common.utils.sql.SqlUtil;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.annotation.JsonFormat;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
@@ -22,6 +23,7 @@ public class BaseEntity implements Serializable,Cloneable {
 	/** 搜索值 */
 	@ApiModelProperty(hidden = true)
 	@View(type = 1)
+    @TableField(exist = false)
 	private String searchValue;
 
 	/** 创建者 */
@@ -48,20 +50,26 @@ public class BaseEntity implements Serializable,Cloneable {
 	/** 备注 */
 	@ApiModelProperty("备注")
 	@View(type = 1)
+    @TableField(exist = false)
 	private String remark;
 
 	/** 请求参数 */
 	@ApiModelProperty(hidden = true)
 	@View(type = 1)
+    @TableField(exist = false)
 	private Map<String, Object> params;
 
 	@ApiModelProperty(hidden = true)
+    @TableField(exist = false)
 	private Integer pageNum;
 	@ApiModelProperty(hidden = true)
+    @TableField(exist = false)
 	private Integer pageSize;
 	@ApiModelProperty(hidden = true)
+    @TableField(exist = false)
 	private String orderBy;
 	@ApiModelProperty(hidden = true)
+    @TableField(exist = false)
 	private Boolean reasonable;
 
 	@JsonIgnore

+ 2 - 2
lot/src/main/java/cn/hobbystocks/auc/common/user/UserUtils.java

@@ -49,7 +49,7 @@ public class UserUtils {
 				userInfo.setId(-1);
 				userInfo.setSub("18221327589");
 				userInfo.setRoleCodeList(Arrays.asList("shipping"));
-				userInfo.setMerchantId(182);
+				userInfo.setMerchantId(182L);
 				return userInfo;
 			}
 			return null;
@@ -75,7 +75,7 @@ public class UserUtils {
 				userInfo.setId(-1);
                 userInfo.setSub("18221327589");
                 userInfo.setRoleCodeList(Arrays.asList("shipping"));
-				userInfo.setMerchantId(-1);
+				userInfo.setMerchantId(-1L);
 				return userInfo;
 			}
 			return null;

+ 3 - 2
lot/src/main/java/cn/hobbystocks/auc/domain/Auction.java

@@ -1,5 +1,6 @@
 package cn.hobbystocks.auc.domain;
 
+import java.math.BigDecimal;
 import java.util.Date;
 
 import cn.hobbystocks.auc.common.core.domain.BaseEntity;
@@ -35,10 +36,10 @@ public class Auction extends BaseEntity {
     private String banner;
 //    保证金(元)
     @TableField("deposit")
-    private Integer deposit;
+    private Long deposit;
 //    服务费(%)
     @TableField("service_tariff")
-    private Integer serviceTariff;
+    private BigDecimal serviceTariff;
 //    中拍支付时限(天)
     @TableField("pay_time_limit")
     private Integer payTimeLimit;

+ 23 - 0
lot/src/main/java/cn/hobbystocks/auc/domain/DepositOrder.java

@@ -0,0 +1,23 @@
+package cn.hobbystocks.auc.domain;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+@TableName("deposit_order_record")
+@Data
+public class DepositOrder {
+    @TableId
+    private Long id;
+
+    private Long userId;
+    private Long lotId;
+    private Long auctionId;
+    private String name;
+    private String depositType;
+    //保证金订单状态,0、待支付,1、已支付待退款,2、已退款,3、已扣款
+    private Integer status;
+    private Long amount;//订单金额
+    private String orderNo;
+    private Long merchantId;
+}

+ 4 - 2
lot/src/main/java/cn/hobbystocks/auc/domain/Lot.java

@@ -153,8 +153,10 @@ public class Lot extends BaseEntity
     private Long lotFansId;
     //    保证金(元)
     @TableField("deposit")
-    private Integer deposit;
+    private Long deposit;
     //    服务费(%)
     @TableField("service_tariff")
-    private Integer serviceTariff;
+    private BigDecimal serviceTariff;
+
+    private Integer payTimeLimit;
 }

+ 6 - 0
lot/src/main/java/cn/hobbystocks/auc/domain/Order.java

@@ -1,8 +1,10 @@
 package cn.hobbystocks.auc.domain;
 
+import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.*;
 import org.apache.ibatis.type.Alias;
 
+import java.math.BigDecimal;
 import java.util.Date;
 
 @Data
@@ -11,6 +13,7 @@ import java.util.Date;
 @AllArgsConstructor
 @NoArgsConstructor
 @Alias("order")
+@TableName("order_info")
 public class Order {
 
     private Long id;
@@ -18,6 +21,9 @@ public class Order {
     private Long userId;
     private Long merchantId;
     private Long orderId;
+    private Long amount;
+    private BigDecimal serviceExpense;
+    private Long skuId;
     private String orderNo;
     //支付状态:
     private Long status;

+ 2 - 1
lot/src/main/java/cn/hobbystocks/auc/dto/AuctionDTO.java

@@ -3,6 +3,7 @@ package cn.hobbystocks.auc.dto;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
+import java.math.BigDecimal;
 import java.util.Date;
 
 @Data
@@ -19,7 +20,7 @@ public class AuctionDTO {
     //    保证金(元)
     private Integer deposit;
     //    服务费(%)
-    private Integer serviceTariff;
+    private BigDecimal serviceTariff;
     //    中拍支付时限(天)
     private Integer payTimeLimit;
     //    拍卖会介绍

+ 24 - 0
lot/src/main/java/cn/hobbystocks/auc/dto/DepositOrderDTO.java

@@ -0,0 +1,24 @@
+package cn.hobbystocks.auc.dto;
+
+import lombok.Data;
+
+/**
+ * 保证金订单
+ */
+@Data
+public class DepositOrderDTO {
+    //用户id
+    private Long userId;
+    //拍卖会id
+    private Long auctionId;
+    //保证金名称
+    private String name;
+    //保证金类型
+    private String depositType;
+
+    private Long lotId;
+    //保证金金额
+    private Long amount;
+    //商家id
+    private Long merchantId;
+}

+ 0 - 10
lot/src/main/java/cn/hobbystocks/auc/dto/PointDTO.java

@@ -1,10 +0,0 @@
-package cn.hobbystocks.auc.dto;
-
-import lombok.Data;
-
-@Data
-public class PointDTO {
-    private int code;
-    private String msg;
-    private boolean data;
-}

+ 28 - 0
lot/src/main/java/cn/hobbystocks/auc/dto/SkuOrderDTO.java

@@ -0,0 +1,28 @@
+package cn.hobbystocks.auc.dto;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class SkuOrderDTO {
+    //商品skuId
+    private int skuId;
+    //拍卖服务费
+    private BigDecimal serviceExpense;
+    //用户id
+    private long userId;
+    //拍卖成交价(分)
+    private long amount;
+    //订单过期时间
+    private long expireTime;
+    //拍卖会名称
+    private String auctionName;
+    //拍品id
+    private long lotId;
+    //拍品名称
+    private String lotName;
+    //商家id
+    private long merchantId;
+
+}

+ 7 - 7
lot/src/main/java/cn/hobbystocks/auc/event/SoldEvent.java

@@ -18,16 +18,16 @@ public class SoldEvent {
         this.lotId = live.getLot().getId();
         this.bidId = live.getBidId();
         this.username = bids.get(0).getAccount();
-        this.userId = Integer.parseInt(bids.get(0).getAccountId());
-        this.point = bids.get(0).getAmount().longValue();
+        this.userId = Long.valueOf(bids.get(0).getAccountId());
+        this.amount = bids.get(0).getAmount().longValue();
         this.name = live.getLot().getName();
         this.bids = bids;
         this.lot = live.getLot();
         this.startTime = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", live.getLot().getStartTime());
     }
 
-    public SoldEvent(Long point, Long goodsId, Long lotId, Long bidId, Integer userId, String username, String name, List<Bid> bids) {
-        this.point = point;
+    public SoldEvent(Long amount, Long goodsId, Long lotId, Long bidId, Long userId, String username, String name, List<Bid> bids) {
+        this.amount = amount;
         this.goodsId = goodsId;
         this.lotId = lotId;
         this.bidId = bidId;
@@ -43,7 +43,7 @@ public class SoldEvent {
 
     private String name;
 
-    private Long point;
+    private Long amount;
 
     private Long goodsId;
 
@@ -51,7 +51,7 @@ public class SoldEvent {
 
     private Long bidId;
 
-    private Integer userId;
+    private Long userId;
 
     private String username;
 
@@ -65,7 +65,7 @@ public class SoldEvent {
     public String toString() {
         return "SoldEvent{" +
                 "name='" + name + '\'' +
-                ", point=" + point +
+                ", amount=" + amount +
                 ", goodsId=" + goodsId +
                 ", lotId=" + lotId +
                 ", bidId=" + bidId +

+ 40 - 0
lot/src/main/java/cn/hobbystocks/auc/forest/OrderApi.java

@@ -0,0 +1,40 @@
+package cn.hobbystocks.auc.forest;
+
+import cn.hobbystocks.auc.dto.DepositOrderDTO;
+import cn.hobbystocks.auc.dto.SkuOrderDTO;
+import cn.hobbystocks.auc.vo.OrderVO;
+import com.dtflys.forest.annotation.BaseRequest;
+import com.dtflys.forest.annotation.Body;
+import com.dtflys.forest.annotation.Post;
+
+@BaseRequest(baseURL = "")
+public interface OrderApi {
+
+    /**
+     * 创建sku订单
+     */
+    @Post(url = "")
+    OrderVO createSkuOrder(@Body SkuOrderDTO orderDTO);
+
+    /**
+     * 创建保证金订单
+     */
+    @Post("")
+    OrderVO createDepositOrder(@Body DepositOrderDTO depositOrderDTO);
+
+    /**
+     * 保证金订单退款
+     * @param orderVO
+     * @return 订单状态
+     */
+    @Post("")
+    OrderVO refundDepositOrder(OrderVO orderVO);
+
+    /**
+     * 扣减保证金
+     * @param orderVO 订单号
+     * @return 订单状态
+     */
+    @Post("")
+    OrderVO reduceDeposit(OrderVO orderVO);
+}

+ 3 - 0
lot/src/main/java/cn/hobbystocks/auc/handle/RuleHandlerHolder.java

@@ -11,6 +11,9 @@ import org.springframework.stereotype.Component;
 import java.util.List;
 import java.util.Optional;
 
+/**
+ * 规则处理器holder
+ */
 @Component
 public class RuleHandlerHolder {
 

+ 9 - 10
lot/src/main/java/cn/hobbystocks/auc/handle/impl/tradition/AbstractTraditionRuleHandler.java

@@ -45,15 +45,13 @@ public abstract class AbstractTraditionRuleHandler implements RuleHandler {
         Lot lot = liveContext.getDbLot();
         // 更新商品拍卖结束时间
         TraditionRule traditionRule = JSON.parseObject(lot.getRuleContent(), TraditionRule.class);
-        if (Objects.nonNull(traditionRule.getDuration())) {
-            Date date = DateUtils.addSeconds(lot.getStartTime(), traditionRule.getDuration().intValue());
-            lot.setEndTime(date);
-        }
+
         //更新liveContext对象结束时间
         traditionRule.setEndTime(lot.getEndTime().getTime());
         if (Objects.nonNull(traditionRule.getDuration())) {
-            traditionRule.setEndTime(lot.getStartTime().getTime() + traditionRule.getDuration() * 1000);
-            lot.setEndTime(new Date(lot.getStartTime().getTime() + traditionRule.getDuration() * 1000));
+            Date date = DateUtils.addSeconds(lot.getStartTime(), traditionRule.getDuration().intValue());
+            traditionRule.setEndTime(date.getTime());
+            lot.setEndTime(date);
             liveContext.setLotUpdate(true);
         }
 
@@ -170,7 +168,7 @@ public abstract class AbstractTraditionRuleHandler implements RuleHandler {
         }
     }
 
-    // region 积分拍卖逻辑
+    // 积分拍卖逻辑
     @Override
     public void addPrice(LiveContext liveContext) {
         // 验证当前出价数据
@@ -215,7 +213,7 @@ public abstract class AbstractTraditionRuleHandler implements RuleHandler {
     //计算当前拍卖
     private void calcLive(LiveContext liveContext) {
         TraditionLive traditionLive = (TraditionLive) liveContext.getLive();
-        // same sort here
+        // 从集合中移除,再加入到集合最后
         traditionLive.getAccountList().remove(liveContext.getDbBid().getAccountId());
         traditionLive.getAccountList().add(liveContext.getDbBid().getAccountId());
         //当前价格 最后出价时间
@@ -224,6 +222,7 @@ public abstract class AbstractTraditionRuleHandler implements RuleHandler {
 
         TraditionRule traditionRule =  traditionLive.getTraditionRule();
         List<String> onceAddPriceInterval = traditionRule.getOnceAddPriceInterval();
+        //根据阶梯加价区间和当前出价计算当前单次出价金额
         if (!CollectionUtils.isEmpty(onceAddPriceInterval)) {
             for (int index = 0; index < onceAddPriceInterval.size(); index++) {
                 String interval = onceAddPriceInterval.get(index);
@@ -272,7 +271,7 @@ public abstract class AbstractTraditionRuleHandler implements RuleHandler {
     }
     // endregion
 
-    // region 直播间拍卖逻辑
+    // region 直播间拍卖提速版逻辑
     @Override
     public void addPriceV2(LiveContext liveContext) {
         // 验证当前出价数据
@@ -411,7 +410,7 @@ public abstract class AbstractTraditionRuleHandler implements RuleHandler {
                 // sort?
                 traditionLive.getAccountList().remove(bid.getAccountId());
                 traditionLive.getAccountList().add(bid.getAccountId());
-                BigDecimal price = bids.get(index).getAmount();
+                BigDecimal price = bid.getAmount();
                 List<String> onceAddPriceInterval = traditionRule.getOnceAddPriceInterval();
                 //出价区间
                 if (!CollectionUtils.isEmpty(onceAddPriceInterval)) {

+ 7 - 1
lot/src/main/java/cn/hobbystocks/auc/handle/impl/tradition/TraditionRuleHandler.java

@@ -11,7 +11,7 @@ import java.util.List;
 import java.util.Objects;
 
 /**
- * 传统拍 + 延时拍
+ * 标准延时策略
  * traditional_delay
  */
 @Component
@@ -27,6 +27,7 @@ public class TraditionRuleHandler extends AbstractTraditionRuleHandler {
 
     @Override
     protected void delay(TraditionLive traditionLive) {
+        //计算当前结束时间和剩余总计延时时间
         Long onceDelayTime = Math.min(traditionLive.getRemainingAllDelayTime(), traditionLive.getTraditionRule().getOnceDelayTime());
         if ((System.currentTimeMillis() + onceDelayTime * 1000) > traditionLive.getCurrentEndTime()) {
             traditionLive.setCurrentEndTime(traditionLive.getCurrentEndTime() + onceDelayTime * 1000);
@@ -34,6 +35,11 @@ public class TraditionRuleHandler extends AbstractTraditionRuleHandler {
         }
     }
 
+    /**
+     * 根据出价记录计算当前结束时间和剩余总计延时时间
+     * @param traditionLive
+     * @param bids
+     */
     @Override
     protected void delaySync(TraditionLive traditionLive, List<Bid> bids) {
         Long allDelayTime = traditionLive.getTraditionRule().getAllDelayTime();

+ 13 - 0
lot/src/main/java/cn/hobbystocks/auc/handle/impl/tradition/TraditionRuleV2Handler.java

@@ -10,6 +10,9 @@ import org.springframework.stereotype.Component;
 import java.util.List;
 import java.util.Objects;
 
+/**
+ * 重置延时策略,计算拍卖结束时间
+ */
 @Component
 @Slf4j
 public class TraditionRuleV2Handler extends AbstractTraditionRuleHandler {
@@ -21,13 +24,23 @@ public class TraditionRuleV2Handler extends AbstractTraditionRuleHandler {
         return Objects.equals(lot.getRuleType(), KEY_2);
     }
 
+    /**
+     * 计算当前结束时间
+     * @param traditionLive
+     */
     @Override
     protected void delay(TraditionLive traditionLive) {
+        //单次延迟时间(秒)
         Long onceDelayTime = traditionLive.getTraditionRule().getOnceDelayTime();
         Long currentEndTime = Math.max((System.currentTimeMillis() + onceDelayTime * 1000L), traditionLive.getCurrentEndTime());
         traditionLive.setCurrentEndTime(currentEndTime);
     }
 
+    /**
+     * 根据出价记录计算当前结束时间
+     * @param traditionLive
+     * @param bids
+     */
     @Override
     protected void delaySync(TraditionLive traditionLive, List<Bid> bids) {
         for (int index = bids.size() - 1; index >= 0; index--) {

+ 34 - 0
lot/src/main/java/cn/hobbystocks/auc/handle/impl/tradition/TraditionRuleV3Handler.java

@@ -0,0 +1,34 @@
+package cn.hobbystocks.auc.handle.impl.tradition;
+
+import cn.hobbystocks.auc.common.constant.Constants;
+import cn.hobbystocks.auc.domain.Bid;
+import cn.hobbystocks.auc.domain.Lot;
+import cn.hobbystocks.auc.handle.context.tradition.TraditionLive;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * 增加拍卖方式策略
+ */
+@Component
+@Slf4j
+public class TraditionRuleV3Handler extends AbstractTraditionRuleHandler{
+    private static final String KEY_3= Constants.AUC_RULE_TYPE_TRADITIONAL_DELAY_V3;
+    @Override
+    protected void delay(TraditionLive traditionLive) {
+        //不使用延时
+    }
+
+    @Override
+    protected void delaySync(TraditionLive traditionLive, List<Bid> bids) {
+//不使用延时
+    }
+
+    @Override
+    public boolean match(Lot lot) {
+        return Objects.equals(lot.getRuleType(),KEY_3);
+    }
+}

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

@@ -4,6 +4,7 @@ package cn.hobbystocks.auc.mapper;
 import cn.hobbystocks.auc.domain.Auction;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -13,7 +14,7 @@ public interface AuctionMapper extends BaseMapper<Auction> {
 
     Auction selectAuctionByNo(String no);
 
-    List<Auction> selectAuctionList(IPage<Auction> page, Auction auction);
+    List<Auction> selectAuctionList(IPage<Auction> page,@Param("auction") Auction auction);
 
     int insertAuction(Auction auction);
 

+ 11 - 0
lot/src/main/java/cn/hobbystocks/auc/mapper/DepositOrderMapper.java

@@ -0,0 +1,11 @@
+package cn.hobbystocks.auc.mapper;
+
+import cn.hobbystocks.auc.domain.DepositOrder;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+import java.util.List;
+
+public interface DepositOrderMapper extends BaseMapper<DepositOrder> {
+
+    List<DepositOrder> selectDepositList(DepositOrder depositOrder);
+}

+ 8 - 1
lot/src/main/java/cn/hobbystocks/auc/mapper/LotMapper.java

@@ -15,7 +15,7 @@ public interface LotMapper extends BaseMapper<Lot> {
 
     List<Lot> selectLotByAucId(Long id);
 
-    List<Lot> selectLotList(IPage<Lot> page,Lot lot);
+    List<Lot> selectLotList(IPage<Lot> page,@Param("lot") Lot lot);
 
     List<Lot> selectLotByGroupIds(@Param("lotGroupIds") Long[] lotGroupIds);
 
@@ -49,4 +49,11 @@ public interface LotMapper extends BaseMapper<Lot> {
 
     void updatePay(@Param("lotId") Long lotId, @Param("paid") Integer paid);
 
+    /**
+     * 查询拍卖会下未结束的拍卖
+     * @param auctionId
+     * @return
+     */
+    List<Lot> selectNotEndLotList(Long auctionId);
+
 }

+ 23 - 0
lot/src/main/java/cn/hobbystocks/auc/mapper/OrderMapper.java

@@ -0,0 +1,23 @@
+package cn.hobbystocks.auc.mapper;
+
+import cn.hobbystocks.auc.domain.Order;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface OrderMapper extends BaseMapper<Order> {
+
+    int insertOrderInfo(Order order);
+
+    int updateOrderStatus(Order order);
+
+    List<Order> list();
+
+    List<Order> selectOrderStatusList(Order order);
+
+    List<Order> selectOrderInfoList(Order order);
+
+    //查询用户在指定拍卖会下的未设置单独保证金的未支付拍品订单
+    List<Order> selectOrderByAuctionId(@Param("auctionId")Long auctionId,@Param("userId")Long userId);
+}

+ 0 - 18
lot/src/main/java/cn/hobbystocks/auc/mapper/OrderStatusMapper.java

@@ -1,18 +0,0 @@
-package cn.hobbystocks.auc.mapper;
-
-import cn.hobbystocks.auc.domain.Order;
-
-import java.util.List;
-
-public interface OrderStatusMapper {
-
-    int insertOrderStatus(Order order);
-
-    int updateOrderStatus(Order order);
-
-    List<Order> list();
-
-    List<Order> selectOrderStatusList(Order order);
-
-    int orderStatusCheck();
-}

+ 32 - 0
lot/src/main/java/cn/hobbystocks/auc/service/DepositOrderService.java

@@ -0,0 +1,32 @@
+package cn.hobbystocks.auc.service;
+
+import cn.hobbystocks.auc.domain.DepositOrder;
+import cn.hobbystocks.auc.dto.DepositOrderDTO;
+import cn.hobbystocks.auc.vo.OrderVO;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+ * 保证金订单
+ */
+public interface DepositOrderService extends IService<DepositOrder> {
+
+    OrderVO createDepositOrder(DepositOrderDTO depositOrderDTO);
+
+    /**
+     * 保证金订单退款
+     * @param orderNo 订单号
+     * @return 退款结果
+     */
+    OrderVO refundDepositOrder(String orderNo);
+
+    /**
+     * 扣减保证金
+     * @param orderNo 保证金订单编号
+     * @return
+     */
+    OrderVO reduceDeposit(String orderNo);
+
+    List<DepositOrder> selectDepositOrder(DepositOrder depositOrder);
+}

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

@@ -62,6 +62,10 @@ public interface ILotService extends IService<Lot> {
 
     List<Lot> selectCancel();
 
+    /**
+     * 执行自动续期逻辑
+     * @param id
+     */
     void handleDelay(Long id);
 
     void dynamicTasks();

+ 28 - 0
lot/src/main/java/cn/hobbystocks/auc/service/IOrderService.java

@@ -0,0 +1,28 @@
+package cn.hobbystocks.auc.service;
+
+import cn.hobbystocks.auc.domain.Order;
+import cn.hobbystocks.auc.vo.OrderVO;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+public interface IOrderService extends IService<Order> {
+
+
+
+    OrderVO createSkuOrder(Order order);
+
+
+    int modifyOrder(Order order);
+    /**
+     * 查询用户在指定拍卖会下未设置单独保证金的拍品订单
+     * @param auctionId
+     * @param userId
+     * @return
+     */
+    List<Order> getOrderListByUserAndAuction(Long auctionId,Long userId);
+
+
+
+
+}

+ 0 - 29
lot/src/main/java/cn/hobbystocks/auc/service/IOrderStatusService.java

@@ -1,29 +0,0 @@
-package cn.hobbystocks.auc.service;
-
-import cn.hobbystocks.auc.domain.Order;
-
-import java.util.List;
-
-public interface IOrderStatusService {
-
-    /**
-     * 新增订单状态
-     * @param order
-     * @return
-     */
-    int addOrder(Order order);
-
-    /**
-     * 更新订单状态
-     * @param order
-     * @return
-     */
-    int modifyOrder(Order order);
-
-    List<Order> list();
-
-    List<Order> selectOrderStatusList(Order order);
-
-    int orderStatusCheck();
-
-}

+ 5 - 7
lot/src/main/java/cn/hobbystocks/auc/service/impl/AuctionServiceImpl.java

@@ -87,18 +87,16 @@ public class AuctionServiceImpl extends ServiceImpl<AuctionMapper,Auction> imple
     @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
     public void pubAuction(AuctionVO auction) {
         if (Objects.equals(Constants.PUB_STATUS_PUBLISHED, auction.getPubStatus())) {
-
             auction.setPubTime(new Date());
             auction.setStatus(Constants.LOT_STATUS_WAITING);
+            Auction db = getBaseMapper().selectAuctionById(auction.getId());
+            redisCache.setCacheObject(String.format(Constants.REDIS_AUC_TEMPLATE, auction.getId()), db);
         }else if (Objects.equals(Constants.PUB_STATUS_CANCEL_PUBLISHED, auction.getPubStatus())){
-            auction.setPubTime(new Date());
+            auction.setUpdateTime(new Date());
             auction.setStatus(Constants.LOT_STATUS_CANCELLED);
+            redisCache.deleteObject(String.format(Constants.REDIS_AUC_TEMPLATE, auction.getId()));
         }
         getBaseMapper().updateAuction(auction);
-
-        Auction db = getBaseMapper().selectAuctionById(auction.getId());
-        redisCache.setCacheObject(String.format(Constants.REDIS_AUC_TEMPLATE, auction.getId()), db);
-
         if (auction.getPubLots()) {
             lotService.pubLots(auction);
         }
@@ -107,7 +105,7 @@ public class AuctionServiceImpl extends ServiceImpl<AuctionMapper,Auction> imple
     @Override
     public void auctionLive() {
         getBaseMapper().selectNeedStart().forEach(auction -> updateAuction(auction, Constants.GROUP_STATUS_STARTING));
-//        auctionMapper.selectNeedEnd().forEach(auction -> updateAuction(auction, Constants.AUC_STATUS_FINISH));
+        getBaseMapper().selectNeedEnd().forEach(auction -> updateAuction(auction, Constants.GROUP_STATUS_FINISH));
     }
 
     @Override

+ 82 - 0
lot/src/main/java/cn/hobbystocks/auc/service/impl/DepositOrderServiceImpl.java

@@ -0,0 +1,82 @@
+package cn.hobbystocks.auc.service.impl;
+
+import cn.hobbystocks.auc.domain.Auction;
+import cn.hobbystocks.auc.domain.DepositOrder;
+import cn.hobbystocks.auc.domain.Lot;
+import cn.hobbystocks.auc.dto.DepositOrderDTO;
+import cn.hobbystocks.auc.forest.OrderApi;
+import cn.hobbystocks.auc.mapper.DepositOrderMapper;
+import cn.hobbystocks.auc.service.DepositOrderService;
+import cn.hobbystocks.auc.service.IAuctionService;
+import cn.hobbystocks.auc.service.ILotService;
+import cn.hobbystocks.auc.vo.OrderVO;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Service
+public class DepositOrderServiceImpl extends ServiceImpl<DepositOrderMapper, DepositOrder> implements DepositOrderService {
+
+    @Autowired
+    ILotService lotService;
+    @Autowired
+    IAuctionService auctionService;
+    @Resource
+    OrderApi orderApi;
+
+    @Override
+    @Transactional
+    public OrderVO createDepositOrder(DepositOrderDTO depositOrderDTO) {
+
+        //查询拍品保证金配置
+        Long lotId = depositOrderDTO.getLotId();
+        Lot lot = lotService.selectLotById(lotId);
+        Long deposit = lot.getDeposit();
+        String name= lot.getName();
+        String depositType="拍品";
+        if (deposit ==null){
+            //如果没有拍品保证金配置,创建拍卖会保证金配置
+            Auction auction = auctionService.selectAuctionById(lot.getAuctionId());
+            deposit=auction.getDeposit();
+            name=auction.getName();
+            depositType="拍卖会";
+        }
+        depositOrderDTO.setAmount(deposit);
+        depositOrderDTO.setAuctionId(lot.getAuctionId());
+        depositOrderDTO.setName(name);
+        depositOrderDTO.setDepositType(depositType);
+        depositOrderDTO.setLotId(lotId);
+        depositOrderDTO.setMerchantId(lot.getMerchantId());
+        //todo 调用创建保证金订单接口
+        OrderVO orderVO = orderApi.createDepositOrder(depositOrderDTO);
+        //保存保证金订单记录
+        DepositOrder depositOrder=new DepositOrder();
+        BeanUtils.copyProperties(depositOrderDTO,depositOrder);
+        depositOrder.setStatus(0);
+        getBaseMapper().insert(depositOrder);
+        return orderVO;
+    }
+    @Override
+    public OrderVO refundDepositOrder(String orderNo) {
+        OrderVO orderVO=new OrderVO();
+        orderVO.setOrderNo(orderNo);
+        return orderApi.refundDepositOrder(orderVO);
+    }
+
+    @Override
+    public OrderVO reduceDeposit(String orderNo) {
+        OrderVO orderVO=new OrderVO();
+        orderVO.setOrderNo(orderNo);
+        return orderApi.reduceDeposit(orderVO);
+    }
+
+    @Override
+    public List<DepositOrder> selectDepositOrder(DepositOrder depositOrder) {
+        return getBaseMapper().selectDepositList(depositOrder);
+    }
+}

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

@@ -586,6 +586,7 @@ public class LotServiceImpl extends ServiceImpl<LotMapper,Lot> implements ILotSe
 
     @Override
     public void dynamicTask(Lot lot) {
+        //延时发布时间
         String delayPublish = lot.getDelayPublish();
         if (!StringUtils.isEmpty(delayPublish)) {
             dynamicTaskService.updateTask(lot.getId().toString(), DateUtils.getNextExecutionTime(delayPublish), () -> {

+ 88 - 0
lot/src/main/java/cn/hobbystocks/auc/service/impl/OrderServiceImpl.java

@@ -0,0 +1,88 @@
+package cn.hobbystocks.auc.service.impl;
+
+import cn.hobbystocks.auc.common.utils.DateUtils;
+import cn.hobbystocks.auc.domain.Auction;
+import cn.hobbystocks.auc.domain.Lot;
+import cn.hobbystocks.auc.domain.Order;
+import cn.hobbystocks.auc.dto.SkuOrderDTO;
+import cn.hobbystocks.auc.forest.OrderApi;
+import cn.hobbystocks.auc.mapper.OrderMapper;
+import cn.hobbystocks.auc.service.IAuctionService;
+import cn.hobbystocks.auc.service.ILotService;
+import cn.hobbystocks.auc.service.IOrderService;
+import cn.hobbystocks.auc.vo.OrderVO;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+@Service
+public class OrderServiceImpl extends ServiceImpl<OrderMapper,Order> implements IOrderService {
+
+    @Autowired
+    ILotService lotService;
+    @Autowired
+    IAuctionService auctionService;
+    @Resource
+    OrderApi orderApi;
+
+
+
+
+    @Override
+    @Transactional
+    public OrderVO createSkuOrder(Order order) {
+        //查询拍品服务费
+        Lot lot = lotService.selectLotById(order.getLotId());
+        Auction auction = auctionService.selectAuctionById(lot.getAuctionId());
+        BigDecimal serviceTariff = lot.getServiceTariff();
+        Integer payTimeLimit = lot.getPayTimeLimit();
+        if (serviceTariff==null){
+            //查询拍卖会服务费
+            serviceTariff=auction.getServiceTariff();
+        }
+        if (payTimeLimit==null)
+            payTimeLimit=auction.getPayTimeLimit();
+        //计算服务费
+        long amount = order.getAmount();
+        BigDecimal bigAmount = BigDecimal.valueOf(amount);
+        //费率/100*成交价=服务费
+        BigDecimal serviceExpense = serviceTariff.divide(BigDecimal.valueOf(100)).multiply(bigAmount);
+        order.setServiceExpense(serviceExpense);
+        //根据支付时限计算订单过期时间,
+        Date date = DateUtils.addDays(new Date(), payTimeLimit);
+        order.setExpireTime(date);
+        save(order);
+
+        //todo 调用创建订单接口
+        SkuOrderDTO skuOrderDTO = new SkuOrderDTO();
+        BeanUtils.copyProperties(order,skuOrderDTO);
+        skuOrderDTO.setAuctionName(auction.getName());
+        skuOrderDTO.setLotName(lot.getName());
+        OrderVO orderVO = orderApi.createSkuOrder(skuOrderDTO);
+        //todo 记录订单信息
+        order.setOrderId(orderVO.getOrderId());
+        order.setOrderNo(orderVO.getOrderNo());
+        order.setStatus(orderVO.getStatus());
+        updateById(order);
+        return orderVO;
+    }
+
+    @Override
+    public int modifyOrder(Order order) {
+        return getBaseMapper().updateOrderStatus(order);
+    }
+
+    @Override
+    public List<Order> getOrderListByUserAndAuction(Long auctionId, Long userId) {
+        return getBaseMapper().selectOrderByAuctionId(auctionId,userId);
+    }
+
+
+}

+ 0 - 38
lot/src/main/java/cn/hobbystocks/auc/service/impl/OrderStatusServiceImpl.java

@@ -1,38 +0,0 @@
-package cn.hobbystocks.auc.service.impl;
-
-import cn.hobbystocks.auc.domain.Order;
-import cn.hobbystocks.auc.mapper.OrderStatusMapper;
-import cn.hobbystocks.auc.service.IOrderStatusService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-@Service
-public class OrderStatusServiceImpl implements IOrderStatusService {
-    @Autowired
-    OrderStatusMapper orderStatusMapper;
-    @Override
-    public int addOrder(Order order) {
-        return orderStatusMapper.insertOrderStatus(order);
-    }
-
-    @Override
-    public int modifyOrder(Order order) {
-        return orderStatusMapper.updateOrderStatus(order);
-    }
-
-    public List<Order> list(){
-       return orderStatusMapper.list();
-    }
-
-    @Override
-    public List<Order> selectOrderStatusList(Order order) {
-        return orderStatusMapper.selectOrderStatusList(order);
-    }
-
-    @Override
-    public int orderStatusCheck() {
-        return orderStatusMapper.orderStatusCheck();
-    }
-}

+ 20 - 27
lot/src/main/resources/mapper/AuctionMapper.xml

@@ -11,10 +11,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="site"    column="site"    />
         <result property="imgs"    column="imgs"    />
         <result property="banner"    column="banner"    />
-        <result property="attachment"    column="attachment"    />
-        <result property="detail"    column="detail"    />
-        <result property="desData"    column="des_data"    />
-        <result property="labels"    column="labels"    />
+        <result property="deposit"    column="deposit"    />
+        <result property="serviceTariff"    column="service_tariff"    />
+        <result property="payTimeLimit"    column="pay_time_limit"    />
+        <result property="description"    column="description"    />
         <result property="pubStatus"    column="pub_status"    />
         <result property="pubTime"    column="pub_time"    />
         <result property="status"    column="status"    />
@@ -39,16 +39,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectAuctionList" parameterType="cn.hobbystocks.auc.domain.Auction" resultMap="AuctionResult">
         <include refid="selectAuctionVo"/>
         <where>
-            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
-
-            <if test="imgs != null  and imgs != ''"> and imgs like concat('%', #{imgs}, '%')</if>
-            <if test="banner != null  and banner != ''"> and banner like concat('%', #{banner}, '%')</if>
-
-            <if test="pubStatus != null "> and pub_status = #{pubStatus}</if>
-            <if test="pubTime != null "> and pub_time = #{pubTime}</if>
-            <if test="status != null  and status != ''"> and status = #{status}</if>
-            <if test="startTime != null "> and start_time = #{startTime}</if>
-            <if test="endTime != null "> and end_time = #{endTime}</if>
+            <if test="auction.name != null  and auction.name != ''"> and name like concat('%', #{auction.name}, '%')</if>
+            <if test="auction.pubStatus != null "> and pub_status = #{auction.pubStatus}</if>
             and del_flag &lt;&gt; 1
         </where>
         order by sort asc,id asc
@@ -114,15 +106,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         insert into auction
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="id != null">id,</if>
-            <if test="no != null">no,</if>
             <if test="name != null">name,</if>
-            <if test="site != null">site,</if>
             <if test="imgs != null">imgs,</if>
             <if test="banner != null">banner,</if>
-            <if test="attachment != null">attachment,</if>
-            <if test="detail != null">detail,</if>
-            <if test="desData != null">des_data,</if>
-            <if test="labels != null">labels,</if>
+            <if test="deposit != null">deposit,</if>
+            <if test="description != null">description,</if>
+            <if test="payTimeLimit != null">pay_time_limit,</if>
+            <if test="serviceTariff != null">service_tariff,</if>
             <if test="pubStatus != null">pub_status,</if>
             <if test="pubTime != null">pub_time,</if>
             <if test="status != null">status,</if>
@@ -133,18 +123,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">create_time,</if>
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
+            <if test="merchantId !=null">merchant_id,</if>
+            <if test="sort !=null">sort,</if>
+            <if test="type!=null">type,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null">#{id},</if>
-            <if test="no != null">#{no},</if>
             <if test="name != null">#{name},</if>
-            <if test="site != null">#{site},</if>
             <if test="imgs != null">#{imgs},</if>
             <if test="banner != null">#{banner},</if>
-            <if test="attachment != null">#{attachment},</if>
-            <if test="detail != null">#{detail},</if>
-            <if test="desData != null">#{desData},</if>
-            <if test="labels != null">#{labels},</if>
+            <if test="deposit != null">#{deposit},</if>
+            <if test="description != null">#{description},</if>
+            <if test="payTimeLimit != null">#{payTimeLimit},</if>
+            <if test="serviceTariff != null">#{serviceTariff},</if>
             <if test="pubStatus != null">#{pubStatus},</if>
             <if test="pubTime != null">#{pubTime},</if>
             <if test="status != null">#{status},</if>
@@ -155,13 +146,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">#{createTime},</if>
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
+            <if test="merchantId !=null">#{merchantId},</if>
+            <if test="sort != null">#{sort},</if>
+            <if test="type !=null">#{type},</if>
          </trim>
     </insert>
 
     <update id="updateAuction" parameterType="cn.hobbystocks.auc.domain.Auction">
         update auction
         <trim prefix="SET" suffixOverrides=",">
-            <if test="no != null">no = #{no},</if>
             <if test="name != null">name = #{name},</if>
             <if test="type != null">type = #{type},</if>
             <if test="imgs != null">imgs = #{imgs},</if>

+ 19 - 0
lot/src/main/resources/mapper/DepositOrderMapper.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.hobbystocks.auc.mapper.DepositOrderMapper">
+
+    <sql id="selectDeposit">
+        select id,user_id,lot_id,status,amount,order_no,auction_id,name,deposit_type from deposit_order_record
+    </sql>
+    <select id="selectDepositList" resultType="cn.hobbystocks.auc.domain.DepositOrder">
+    <include refid="selectDeposit"></include>
+    <where>
+        <if test="userId!=null">and user_id=#{userId}</if>
+        <if test="lotId!=null">and lot_id=#{lotId}</if>
+        <if test="auctionId!=null"> and auction_id=#{auctionId}</if>
+        <if test="status!=null">status=#{status}</if>
+    </where>
+    </select>
+</mapper>

+ 24 - 33
lot/src/main/resources/mapper/LotMapper.xml

@@ -46,11 +46,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="privateDomain" column="private_domain"/>
         <result property="delayPublish" column="delay_publish"/>
         <result property="groupId" column="group_id"/>
+        <result property="deposit" column="deposit"/>
+        <result property="serviceTariff" column="service_tariff"/>
     </resultMap>
 
     <sql id="selectLotVo">
         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, order_id, 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
+        carousel_imgs,merchant_id,merchant_name,merchant_avatar,goods_name,goods_type,private_domain,delay_publish,pub_status,group_id,deposit,service_tariff
          from lot
     </sql>
 
@@ -68,36 +70,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectLotList" parameterType="cn.hobbystocks.auc.domain.Lot" resultMap="LotResult">
         <include refid="selectLotVo"/>
         <where>
-            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
-            <if test="num != null  and num != ''"> and num = #{num}</if>
-            <if test="unit != null  and unit != ''"> and unit = #{unit}</if>
-            <if test="detail != null  and detail != ''"> and detail like concat('%', #{detail}, '%')</if>
-            <if test="pubStatus != null "> and pub_status  = #{pubStatus}</if>
-            <if test="pubTime != null "> and pub_time = #{pubTime}</if>
-            <if test="status != null  and status != ''"> and status = #{status}</if>
-            <if test="startTime != null "> and start_time = #{startTime}</if>
-            <if test="endTime != null "> and end_time = #{endTime}</if>
-            <if test="realEndTime != null "> and real_end_time = #{realEndTime}</if>
-            <if test="ruleType != null  and ruleType != ''"> and rule_type = #{ruleType}</if>
-            <if test="ruleContent != null and ruleContent != '' "> and rule_content = #{ruleContent}</if>
-            <if test="lastPrice != null "> and last_price = #{lastPrice}</if>
-            <if test="lastPriceTime != null "> and last_price_time = #{lastPriceTime}</if>
-            <if test="dealPrice != null "> and deal_price = #{dealPrice}</if>
-            <if test="dealTime != null "> and deal_time = #{dealTime}</if>
-            <if test="dealAccountId != null  and dealAccountId != ''"> and deal_account_id = #{dealAccountId}</if>
-            <if test="dealAccount != null  and dealAccount != ''"> and deal_account = #{dealAccount}</if>
-            <if test="paid != null "> and paid = #{paid}</if>
-            <if test="orderId != null  and orderId != ''"> and order_id = #{orderId}</if>
-            <if test="bidCount != null "> and bid_count = #{bidCount}</if>
-            <if test="bidPersionCount != null "> and bid_persion_count = #{bidPersionCount}</if>
-            <if test="sort != null "> and sort = #{sort}</if>
-            <if test="delFlag != null "> and del_flag = #{delFlag}</if>
-            <if test="delay != null and delay == 0 "> and (delay_Publish is NULL or delay_publish = '') </if>
-            <if test="delay != null and delay == 1 "> and (delay_Publish is not NULL and delay_publish &lt;&gt; '') </if>
-            <if test="goodsType != null "> and goods_type = #{goodsType}</if>
-            <if test="groupId != null "> and group_id = #{groupId}</if>
-            <if test="auctionId != null "> and auction_id = #{auctionId}</if>
-            <if test="privateDomain != null "> and private_domain = #{privateDomain}</if>
+            <if test="lot.name != null  and lot.name != ''"> and name like concat('%', #{lot.name}, '%')</if>
+            <if test="lot.pubStatus != null "> and pub_status  = #{lot.pubStatus}</if>
+            and auction_id = #{lot.auctionId}
         </where>
         order by sort asc,id desc
     </select>
@@ -165,6 +140,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="privateDomain != null">private_domain,</if>
             <if test="delayPublish != null">delay_publish,</if>
             <if test="groupId != null ">group_id,</if>
+            <if test="deposit !=null ">deposit,</if>
+            <if test="serviceTariff !=null ">service_tariff,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null">#{id},</if>
@@ -208,6 +185,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="privateDomain != null">#{privateDomain},</if>
             <if test="delayPublish != null">#{delayPublish},</if>
             <if test="groupId != null ">#{groupId},</if>
+            <if test="deposit !=null ">#{deposit},</if>
+            <if test="serviceTariff !=null ">#{serviceTariff},</if>
          </trim>
     </insert>
 
@@ -240,7 +219,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="privateDomain != null">private_domain,</if>
             <if test="delayPublish != null">delay_publish,</if>
             <if test="groupId != null ">group_id,</if>
-
+            <if test="deposit !=null ">deposit,</if>
+            <if test="serviceTariff !=null ">service_tariff,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="goodsId != null">#{goodsId},</if>
@@ -269,7 +249,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="privateDomain != null">#{privateDomain},</if>
             <if test="delayPublish != null">#{delayPublish},</if>
             <if test="groupId != null ">#{groupId},</if>
-
+            <if test="deposit !=null ">#{deposit},</if>
+            <if test="serviceTariff !=null ">#{serviceTariff},</if>
         </trim>
     </insert>
 
@@ -320,6 +301,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="privateDomain != null">private_domain = #{privateDomain},</if>
             <if test="delayPublish != null">delay_publish = #{delayPublish},</if>
             <if test="groupId != null ">group_id = #{groupId},</if>
+            <if test="deposit !=null ">deposit=#{deposit},</if>
+            <if test="serviceTariff !=null ">service_tariff=#{serviceTariff},</if>
         </trim>
         where id = #{id}
     </update>
@@ -466,4 +449,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where delay_publish is not null and delay_publish &lt;&gt; '' and del_flag &lt;&gt; 1
     </select>
 
+    <select id="selectNotEndLotList" resultMap="LotResult">
+        select id, auction_id
+        from
+        lot
+        where
+        status in ('Waiting','Starting','Bidding') and del_flag &lt;&gt; 1 and pub_status = 1
+        and auction_id=#{auctionId}
+    </select>
 </mapper>

+ 11 - 12
lot/src/main/resources/mapper/OrderStatusMapper.xml → lot/src/main/resources/mapper/OrderMapper.xml

@@ -2,7 +2,7 @@
 <!DOCTYPE mapper
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="cn.hobbystocks.auc.mapper.OrderStatusMapper">
+<mapper namespace="cn.hobbystocks.auc.mapper.OrderMapper">
     <resultMap id="orderResultMap" type="cn.hobbystocks.auc.domain.Order">
         <id column="id" property="id"></id>
         <result column="lot_id" property="lotId"/>
@@ -14,12 +14,12 @@
         <result column="user_id" property="userId"/>
         <result column="merchant_id" property="merchantId"/>
     </resultMap>
-    <insert id="insertOrderStatus" parameterType="order">
-    insert into order_status (lot_id,order_id,order_no,expire_time,status,user_id,merchant_id,flag) values
+    <insert id="insertOrderInfo" parameterType="order">
+    insert into order_info (lot_id,order_id,order_no,expire_time,status,user_id,merchant_id,flag) values
         (#{lotId},#{orderId},#{orderNo},#{expireTime},#{status},#{userId},#{merchantId},#{flag})
     </insert>
     <update id="updateOrderStatus" parameterType="order">
-        update order_status
+        update order_info
         <trim prefix="set " suffixOverrides=",">
             <if test="status != null and status!='' ">
                 status = #{status},
@@ -33,11 +33,9 @@
         </trim>
         where order_no = #{orderNo}
     </update>
-    <select id="list" resultMap="orderResultMap">
-        select * from order_status where flag=0
-    </select>
-    <select id="selectOrderStatusList" resultMap="orderResultMap">
-        select lot_id,status from order_status
+
+    <select id="selectOrderInfoList" resultMap="orderResultMap">
+        select lot_id,status from order_info
         <where>
             <if test="flag!='' and flag!= null">
                 flag = #{flag}
@@ -53,7 +51,8 @@
             </if>
         </where>
     </select>
-    <delete id="orderStatusCheck">
-        delete from order_status where flag=1 and expire_time &lt; now()
-    </delete>
+    <select id="selectOrderByAuctionId" resultMap="orderResultMap">
+        select o.* from order_info o left JOIN lot l on o.lot_id=l."id"
+        where l.auction_id=#{auctionId} and l.deposit is null and o.user_id=#{userId} and o.status=102
+    </select>
 </mapper>