Helius
2020-09-08 1fc98d66589965b5b10e09334f715b28ed5ab455
src/main/java/com/xcong/excoin/rabbit/pricequeue/WebsocketPriceService.java
@@ -1,6 +1,7 @@
package com.xcong.excoin.rabbit.pricequeue;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.xcong.excoin.common.contants.AppContants;
import com.xcong.excoin.common.enumerates.CoinTypeEnum;
@@ -298,20 +299,26 @@
                        }
                        BigDecimal lotNumber = cacheSettingUtils.getSymbolSku(holdOrderEntity.getSymbol());
                        BigDecimal profitOrLess = CalculateUtil.calOrderProfitOrLess(holdOrderEntity.getOpeningType(), new BigDecimal(currentPrice), holdOrderEntity.getOpeningPrice(), lotNumber, holdOrderEntity.getSymbolCntSale(), memberEntity.getIsProfit());
                        log.info("profitOrLess : {}, id : {}, symbol : {}, price : {}", profitOrLess, holdOrderEntity.getId(), holdOrderEntity.getSymbol(), currentPrice);
                        totalProfitOrLess = totalProfitOrLess.add(profitOrLess);
                    }
                    log.info("totalProfitOrLess : {}", totalProfitOrLess);
                    MemberWalletContractEntity wallet = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, CoinTypeEnum.USDT.name());
                    BigDecimal sub = wallet.getTotalBalance().add(totalProfitOrLess);
                    log.info("sub : {}, memberId : {}", sub, memberId);
//                    log.info("sub : {}, memberId : {}", sub, memberId);
                    if (sub.compareTo(BigDecimal.ZERO) <= 0) {
                        List<OrderModel> list = new ArrayList<>();
                        OrderModel orderModel = new OrderModel(null, 0, price, symbol, memberId);
                        list.add(orderModel);
                        String content = JSONObject.toJSONString(list);
//                        orderProducer.sendWholeBomb(content);
                        String key = AppContants.WHOLE_BOMB_PREFIX + memberId;
                        String value = redisUtils.getString(key);
                        if (StrUtil.isBlank(value)) {
                            orderProducer.sendWholeBomb(content);
                            contractHoldOrderDao.updateMemberAllHoldOrderClosingStatus(memberId);
                            redisUtils.set(key, memberId);
                        }
                    }
                }
            }