From cd36cce5ee6db83137b5b0a01131fc3468241b61 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Fri, 14 May 2021 14:36:36 +0800 Subject: [PATCH] modify --- src/main/java/com/xcong/excoin/modules/yunding/service/Impl/YunDingServiceImpl.java | 34 ++++++++++++++++++++++++++++++---- 1 files changed, 30 insertions(+), 4 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..17f2ddc 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() { @@ -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