From 0abd80878ee9045d5317a2dbeff6c20d2dfdabc0 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Fri, 14 May 2021 15:07:32 +0800 Subject: [PATCH] Merge branch 'yunding' of http://120.27.238.55:7000/r/exchange into yunding --- src/main/java/com/xcong/excoin/modules/yunding/service/Impl/YunDingServiceImpl.java | 36 +++++++++++++++++++++++++++++++----- 1 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/xcong/excoin/modules/yunding/service/Impl/YunDingServiceImpl.java b/src/main/java/com/xcong/excoin/modules/yunding/service/Impl/YunDingServiceImpl.java index e902930..5fbb658 100644 --- a/src/main/java/com/xcong/excoin/modules/yunding/service/Impl/YunDingServiceImpl.java +++ b/src/main/java/com/xcong/excoin/modules/yunding/service/Impl/YunDingServiceImpl.java @@ -65,6 +65,8 @@ private MemberDao memberDao; @Autowired private YunDingProducter yunDingProducter; + @Autowired + private RedisUtils redisUtils; @Override public Result findAllInfo() { @@ -107,7 +109,7 @@ for(YdProductVo ydProductVo : records){ ydProductVo.setProfitT(prifitT); - if(ydProductVo.getTotalT().compareTo(BigDecimal.ZERO) < 1) { + if(ydProductVo.getSurplusT().compareTo(BigDecimal.ZERO) < 1) { ydProductVo.setStatus(2); } } @@ -204,6 +206,16 @@ return Result.fail("请重新选择产品"); } + Integer status = ydProductEntity.getStatus(); + if(YdProductEntity.STATUE_WORK != status){ + if(YdProductEntity.STATUE_END == status){ + return Result.fail("产品已售罄"); + } + if(YdProductEntity.STATUE_READY == status){ + return Result.fail("产品未开售"); + } + } + //限购总量 Integer limitedNum = ydProductEntity.getLimitedNum(); //获取目前待生效,已生效的总T数 @@ -219,12 +231,14 @@ quantityOwn = quantityOwn + ydOrderEntity.getQuantity(); } } - if(quantityOwn >= limitedNum){ + int quantityInt = quantity.intValue(); + if(quantityOwn + quantityInt > limitedNum){ return Result.fail("产品限购"+limitedNum); } - if (quantity.compareTo(BigDecimal.valueOf(ydProductEntity.getLimitedNum())) < 1) { - return Result.fail("产品限购" + ydProductEntity.getLimitedNum()); - } + +// if (quantity.compareTo(BigDecimal.valueOf(ydProductEntity.getLimitedNum())) < 1) { +// return Result.fail("产品限购" + ydProductEntity.getLimitedNum()); +// } BigDecimal salePrice = ydProductEntity.getSalePrice(); //剩余产品数量 BigDecimal surplusT = ydProductEntity.getSurplusT(); @@ -564,6 +578,7 @@ YdOrderEntity orderEntity = new YdOrderEntity(); orderEntity.setType(YdOrderEntity.AGENT_ORDER); orderEntity.setMemberId(memberId); + orderEntity.setProductId(id); orderEntity.setAmount(salePrice); ydOrderDao.insert(orderEntity); @@ -577,6 +592,17 @@ return Result.ok("购买成功"); } + @Override + public Result getXchPrice() { + log.info("获取XCH当前价"); + BigDecimal xchNewPrices = BigDecimal.ZERO; + String xchNewPrice = redisUtils.getString("XCH_NEW_PRICE"); + if(StrUtil.isNotEmpty(xchNewPrice)){ + xchNewPrices = new BigDecimal(xchNewPrice); + } + return Result.ok(xchNewPrices); + } + /** * 去加减币币账户余额,减少产品的剩余数目 -- Gitblit v1.9.1