| | |
| | | String phone = memberEntity.getPhone();
|
| | | if (!"13632989240".equals(phone) && !"15158130575".equals(phone)) {
|
| | | if (OrderCoinsEntity.ORDERTYPE_BUY.equals(type)) {
|
| | | // 禁止挂卖
|
| | | String string = redisUtils.getString("BUY_LIMIT_KEY_PHONE");
|
| | | if (StringUtils.isNotBlank(string) && StringUtils.isNotBlank(phone) && string.contains(phone)) {
|
| | | return Result.fail("买入受限");
|
| | | }
|
| | |
|
| | | if (StringUtils.isNotBlank(string) && StringUtils.isNotBlank(memberEntity.getEmail()) && string.contains(memberEntity.getEmail())) {
|
| | | return Result.fail("买入受限");
|
| | | }
|
| | | // 不能超过800个
|
| | |
|
| | | // if (amount != null && amount.compareTo(new BigDecimal("800")) > 0) {
|
| | |
| | | // return Result.fail("买入额度受限");
|
| | | // }
|
| | | } else {
|
| | | return Result.fail("卖出受限");
|
| | | // 判断redis开关
|
| | | //String string = redisUtils.getString("SELL_LIMIT_KEY");
|
| | | String string = redisUtils.getString("SELL_LIMIT_KEY_PHONE");
|
| | | if (StringUtils.isNotBlank(string) && StringUtils.isNotBlank(phone) && string.contains(phone)) {
|
| | | return Result.fail("卖出受限");
|
| | | }
|
| | |
|
| | | if (StringUtils.isNotBlank(string) && StringUtils.isNotBlank(memberEntity.getEmail()) && string.contains(memberEntity.getEmail())) {
|
| | | return Result.fail("卖出受限");
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | totalPayPrice = price.multiply(amount).add(closingPrice);
|
| | | entrustAmount = price.multiply(amount);
|
| | | // 限价买不能高于当前10%
|
| | | if (OrderCoinsEntity.ORDERTYPE_BUY == type) {
|
| | | BigDecimal multiply = nowPrice.multiply(new BigDecimal("1.2"));
|
| | | if(price.compareTo(multiply)>0){
|
| | | return Result.fail("不能高于当前价的120%");
|
| | | }
|
| | | }else{
|
| | | // 卖不能小于当前90
|
| | | BigDecimal multiply = nowPrice.multiply(new BigDecimal("0.8"));
|
| | | if(price.compareTo(multiply)<0){
|
| | | return Result.fail("不能低于当前价的80%");
|
| | | }
|
| | | BigDecimal multiply = nowPrice.multiply(new BigDecimal("1.2"));
|
| | | if (price.compareTo(multiply) > 0) {
|
| | | return Result.fail("不能高于当前价的120%");
|
| | | }
|
| | | multiply= nowPrice.multiply(new BigDecimal("0.8"));
|
| | | if (price.compareTo(multiply) < 0) {
|
| | | return Result.fail("不能低于当前价的80%");
|
| | | }
|
| | |
|
| | | } else {
|
| | | // 市价
|
| | | if (OrderCoinsEntity.ORDERTYPE_BUY == type) {
|
| | |
| | | OrderCoinsEntity coinsEntityCancel = trader.cancelOrder(orderCoinsEntity);
|
| | | if (coinsEntityCancel == null) {
|
| | | // 此时说明撮合系统已经没这个单了 不需要继续处理
|
| | | // 直接更新状态先
|
| | | OrderCoinsEntity update = new OrderCoinsEntity();
|
| | | update.setId(Long.valueOf(orderId));
|
| | | update.setOrderStatus(OrderCoinsEntity.ORDERSTATUS_CANCEL);
|
| | | //orderCoinsEntity.setOrderStatus(OrderCoinsEntity.ORDERSTATUS_CANCEL);
|
| | | orderCoinsDao.updateById(update);
|
| | | return null;
|
| | | }
|
| | |
|
| | |
| | |
|
| | | @Override
|
| | | public Result findAllWalletCoinOrder() {
|
| | | List<OrderCoinsDealEntity> orderCoinsDealEntities = orderCoinDealDao.selectAllCoinDealsOrderBySymbol(CoinTypeEnum.ROC.toString());
|
| | | List<OrderCoinsDealEntity> orderCoinsDealEntities = orderCoinDealDao.selectAllCoinDealsOrderBySymbol(CoinTypeEnum.BEA.toString());
|
| | | return Result.ok(orderCoinsDealEntities);
|
| | | }
|
| | |
|
| | |
| | | if (CollectionUtils.isNotEmpty(trades)) {
|
| | | for (OrderCoinsEntity trade : trades) {
|
| | | if (trade != null) {
|
| | | if (trade.getOrderType()==2 && trade.getEntrustCnt().compareTo(trade.getDealCnt())!=0){
|
| | | System.out.println("问题卖单:"+ JSON.toJSONString(trade));
|
| | | if (trade.getOrderType() == 2 && trade.getEntrustCnt().compareTo(trade.getDealCnt()) != 0) {
|
| | | System.out.println("问题卖单:" + JSON.toJSONString(trade));
|
| | | }
|
| | | //orderCoinsDao.updateStatus(trade.getId(),OrderCoinsEntity.ORDERSTATUS_DONE);
|
| | | ids.add(trade.getId());
|
| | | // 买单 实际成交金额小于委托的 这一部分从冻结扣除
|
| | | if(OrderCoinsEntity.ORDERTYPE_BUY==trade.getOrderType()){
|
| | | if(trade.getEntrustAmount().compareTo(trade.getDealAmount())>0){
|
| | | if (OrderCoinsEntity.ORDERTYPE_BUY == trade.getOrderType()) {
|
| | | if (trade.getEntrustAmount().compareTo(trade.getDealAmount()) > 0) {
|
| | | // 此时退回这部分的差额
|
| | | BigDecimal subtract = trade.getEntrustAmount().subtract(trade.getDealAmount());
|
| | | MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(trade.getMemberId(), CoinTypeEnum.USDT.name());
|
| | | if(memberWalletCoinEntity!=null){
|
| | | coinService.updateWalletBalance(memberWalletCoinEntity.getId(),subtract,null,subtract.negate());
|
| | | if (memberWalletCoinEntity != null) {
|
| | | coinService.updateWalletBalance(memberWalletCoinEntity.getId(), subtract, null, subtract.negate());
|
| | | }
|
| | | }
|
| | | }
|