|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int i = contractEntrustOrderDao.insert(entrustOrderEntity); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | walletContract.setFrozenBalance(walletContract.getFrozenBalance().add(entrustTotalAmount)); | 
|---|
|  |  |  | walletContract.setAvailableBalance(walletContract.getAvailableBalance().subtract(entrustTotalAmount)); | 
|---|
|  |  |  | memberWalletContractDao.updateById(walletContract); | 
|---|
|  |  |  | memberWalletContractDao.increaseWalletContractBalanceById(entrustTotalAmount.negate(), null, entrustOrderEntity.getBondAmount(), walletContract.getId()); | 
|---|
|  |  |  | if (i > 0) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 发送委托单队列消息 | 
|---|
|  |  |  | if (submitEntrustDto.getEntrustType() == ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_MORE) { | 
|---|
|  |  |  | OrderModel model = new OrderModel(entrustOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_MORE.getValue(), submitEntrustDto.getEntrustPrice().toPlainString(), submitEntrustDto.getSymbol()); | 
|---|
|  |  |  | OrderModel model = new OrderModel(entrustOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_MORE.getValue(), submitEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), submitEntrustDto.getSymbol()); | 
|---|
|  |  |  | producer.sendPriceOperate(JSONObject.toJSONString(model)); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | OrderModel model = new OrderModel(entrustOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_LESS.getValue(), submitEntrustDto.getEntrustPrice().toPlainString(), submitEntrustDto.getSymbol()); | 
|---|
|  |  |  | OrderModel model = new OrderModel(entrustOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_LESS.getValue(), submitEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), submitEntrustDto.getSymbol()); | 
|---|
|  |  |  | producer.sendPriceOperate(JSONObject.toJSONString(model)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return Result.ok("委托成功"); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Result findEntrustOrderList() { | 
|---|
|  |  |  | public Result findEntrustOrderList(String symbol) { | 
|---|
|  |  |  | MemberEntity memberEntity = LoginUserUtils.getAppLoginUser(); | 
|---|
|  |  |  | List<ContractEntrustOrderEntity> list = contractEntrustOrderDao.selectEntrustOrderListByMemberId(memberEntity.getId()); | 
|---|
|  |  |  | List<ContractEntrustOrderEntity> list = contractEntrustOrderDao.selectEntrustOrderListByMemberIdAndSymbol(memberEntity.getId(), symbol); | 
|---|
|  |  |  | List<ContractEntrustVo> resultList = ContractEntrustOrderEntityMapper.INSTANCE.entityListToVoList(list); | 
|---|
|  |  |  | return Result.ok(resultList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | MemberWalletContractEntity walletContractEntity = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberEntity.getId(), MemberWalletCoinEnum.WALLETCOINCODE.getValue()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BigDecimal total = entrustOrderEntity.getEntrustAmount(); | 
|---|
|  |  |  | walletContractEntity.setAvailableBalance(walletContractEntity.getAvailableBalance().add(total)); | 
|---|
|  |  |  | walletContractEntity.setFrozenBalance(walletContractEntity.getFrozenBalance().subtract(total)); | 
|---|
|  |  |  | memberWalletContractDao.updateById(walletContractEntity); | 
|---|
|  |  |  | memberWalletContractDao.increaseWalletContractBalanceById(total, null, entrustOrderEntity.getBondAmount().negate(), walletContractEntity.getId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ContractOrderEntity orderEntity = ContractEntrustOrderEntityMapper.INSTANCE.entrustOrderToOrder(entrustOrderEntity); | 
|---|
|  |  |  | orderEntity.setTradeType(ContractOrderEntity.TRADE_TYPE_MARK_PRICE); | 
|---|
|  |  |  | orderEntity.setOrderType(ContractOrderEntity.ORDER_TYPE_CANCEL); | 
|---|
|  |  |  | orderEntity.setOrderStatus(ContractOrderEntity.ORDER_STATUS_CANCEL); | 
|---|
|  |  |  | int i = contractOrderDao.insert(orderEntity); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | contractEntrustOrderDao.deleteById(entrustOrderEntity.getId()); | 
|---|