| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xcong.excoin.common.LoginUserUtils; |
| | | import com.xcong.excoin.common.contants.AppContants; |
| | | import com.xcong.excoin.common.enumerates.CoinTypeEnum; |
| | | import com.xcong.excoin.common.response.Result; |
| | | import com.xcong.excoin.modules.coin.dao.GbzOrderDao; |
| | |
| | | @PostMapping(value = "/add") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Result add(@RequestBody GbzAddDto gbzAddDto) { |
| | | String status = redisUtils.getString("bea_order_status"); |
| | | if ("1".equals(status)) { |
| | | return Result.fail("无法购买"); |
| | | } |
| | | // String status = redisUtils.getString("bea_order_status"); |
| | | // if ("1".equals(status)) { |
| | | // return Result.fail("无法购买"); |
| | | // } |
| | | |
| | | String start = redisUtils.getString("bea_start"); |
| | | if ("2".equals(start)) { |
| | | return Result.fail("暂无法购买"); |
| | | } |
| | | String total = redisUtils.getString("bea_coin_total"); |
| | | |
| | | if (gbzAddDto.getCount() < 10) { |
| | | return Result.fail("最少购买数量为10个"); |
| | | } |
| | | |
| | | String total = redisUtils.getString("bea_coin_total"); |
| | | MemberEntity loginUser = LoginUserUtils.getAppLoginUser(); |
| | | BigDecimal price = new BigDecimal(redisUtils.getString("bea_order_new_price")); |
| | | BigDecimal amount = BigDecimal.valueOf(gbzAddDto.getCount()).multiply(price); |
| | |
| | | } |
| | | |
| | | if (Integer.parseInt(total) < gbzAddDto.getCount()) { |
| | | return Result.fail("BEA数量不足"); |
| | | return Result.fail("GRICE数量不足"); |
| | | } |
| | | |
| | | GbzOrderEntity gbzOrder = new GbzOrderEntity(); |
| | |
| | | gbzOrder.setAmount(amount); |
| | | gbzOrder.setCnt(gbzAddDto.getCount()); |
| | | gbzOrder.setMemberId(loginUser.getId()); |
| | | gbzOrder.setSymbol(CoinTypeEnum.BEA.name()); |
| | | gbzOrder.setSymbol(CoinTypeEnum.GRICE.name()); |
| | | gbzOrder.setStatus(1); |
| | | |
| | | gbzOrderDao.insert(gbzOrder); |
| | | |
| | | memberWalletCoinDao.updateBlockBalance(wallet.getId(), amount.negate(), BigDecimal.ZERO, 0); |
| | | redisUtils.set("bea_coin_total", Integer.parseInt(total) - gbzAddDto.getCount()); |
| | | LogRecordUtils.insertMemberAccountMoneyChange(loginUser.getId(), "购买BEA", amount, "USDT", 1, 1); |
| | | LogRecordUtils.insertMemberAccountMoneyChange(loginUser.getId(), "购买GRICE", amount, "USDT", 1, 1); |
| | | return Result.ok("购买成功"); |
| | | } |
| | | |
| | |
| | | public Result findPrice() { |
| | | PriceVo priceVo = new PriceVo(); |
| | | String newPriceStr = redisUtils.getString("bea_order_new_price"); |
| | | priceVo.setNewPrice(StrUtil.isNotBlank(newPriceStr) ? new BigDecimal(newPriceStr) : BigDecimal.valueOf(66)); |
| | | priceVo.setNewPrice(StrUtil.isNotBlank(newPriceStr) ? new BigDecimal(newPriceStr) : AppContants.DEFAULT_PRICE); |
| | | |
| | | String status = redisUtils.getString("bea_order_status"); |
| | | priceVo.setStatus(StrUtil.isNotBlank(status) ? Integer.parseInt(status) : 2); |
| | | |
| | | |
| | | String remain = redisUtils.getString("bea_coin_total"); |
| | | priceVo.setRemainCnt(Integer.parseInt(remain)); |
| | | priceVo.setRemainCnt(280000); |
| | | |
| | | BigDecimal totalAmount = gbzOrderDao.selectOrderTotalAmount(LoginUserUtils.getAppLoginUser().getId()); |
| | | priceVo.setTotalAmount(totalAmount); |
| | |
| | | } |
| | | |
| | | MemberWalletCoinEntity wallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(member.getId(), CoinTypeEnum |
| | | .BEA.name()); |
| | | .GRICE.name()); |
| | | memberWalletCoinDao.updateBlockBalance(wallet.getId(), totalAmount, BigDecimal.ZERO, 0); |
| | | |
| | | gbzOrderDao.updateStatus(member.getId()); |
| | | LogRecordUtils.insertMemberAccountMoneyChange(member.getId(), "提取BEA到资产", totalAmount, "BEA", 1, 1); |
| | | LogRecordUtils.insertMemberAccountMoneyChange(member.getId(), "提取GRICE到资产", totalAmount, "GRICE", 1, 1); |
| | | return Result.ok("提取成功"); |
| | | } |
| | | } |