| | |
| | | import com.xcong.excoin.modules.platform.entity.PlatformTradeSettingEntity; |
| | | import com.xcong.excoin.rabbit.pricequeue.OrderModel; |
| | | import com.xcong.excoin.rabbit.producer.OrderProducer; |
| | | import com.xcong.excoin.utils.CacheSettingUtils; |
| | | import com.xcong.excoin.utils.CoinTypeConvert; |
| | | import com.xcong.excoin.utils.RedisUtils; |
| | | import com.xcong.excoin.utils.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | // 开多委托价不能大于当前价 |
| | | if (submitEntrustDto.getEntrustType() == ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_MORE) { |
| | | if (submitEntrustDto.getEntrustPrice().compareTo(newPrice) > -1) { |
| | | return Result.fail("委托价不能大于当前价"); |
| | | return Result.fail(MessageSourceUtils.getString("entrust_price_judge_more")); |
| | | } |
| | | } |
| | | |
| | | // 开空委托价不能小于当前价 |
| | | if (submitEntrustDto.getEntrustType() == ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_LESS) { |
| | | if (submitEntrustDto.getEntrustPrice().compareTo(newPrice) < 1) { |
| | | return Result.fail("委托价不能小于当前价"); |
| | | return Result.fail(MessageSourceUtils.getString("entrust_price_judge_less")); |
| | | } |
| | | } |
| | | |
| | |
| | | log.info("预付款:{}", entrustTotalAmount); |
| | | |
| | | if (entrustTotalAmount.compareTo(walletContract.getAvailableBalance()) > -1) { |
| | | return Result.fail("可用余额不足"); |
| | | return Result.fail(MessageSourceUtils.getString("member_service_0085")); |
| | | } |
| | | |
| | | ContractEntrustOrderEntityMapper convert = ContractEntrustOrderEntityMapper.INSTANCE; |
| | |
| | | if (submitEntrustDto.getEntrustType() == ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_MORE) { |
| | | 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)); |
| | | |
| | | LogRecordUtils.insertMemberAccountFlow(memberEntity.getId(), entrustTotalAmount, walletContract.getAvailableBalance().subtract(entrustTotalAmount), submitEntrustDto.getSymbol(), "委托买涨", "买涨:" + submitEntrustDto.getSymbol()); |
| | | } else { |
| | | 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)); |
| | | |
| | | LogRecordUtils.insertMemberAccountFlow(memberEntity.getId(), entrustTotalAmount, walletContract.getAvailableBalance().subtract(entrustTotalAmount), submitEntrustDto.getSymbol(), "委托买跌", "买跌:" + submitEntrustDto.getSymbol()); |
| | | } |
| | | return Result.ok("委托成功"); |
| | | |
| | | return Result.ok(MessageSourceUtils.getString("result_success_msg")); |
| | | } else { |
| | | return Result.fail("委托失败"); |
| | | return Result.fail(MessageSourceUtils.getString("result_fail_msg")); |
| | | } |
| | | } |
| | | |
| | |
| | | return Result.fail("功能暂未开放,敬请期待"); |
| | | } |
| | | |
| | | return Result.fail("未知错误"); |
| | | return Result.fail(MessageSourceUtils.getString("result_fail_msg")); |
| | | } |
| | | |
| | | @Override |
| | |
| | | // 查询该委托单是否为该用户所有 |
| | | ContractEntrustOrderEntity entrustOrderEntity = contractEntrustOrderDao.selectEntrustOrderByIdAndMemberId(id, memberEntity.getId()); |
| | | if (entrustOrderEntity == null) { |
| | | return Result.fail("该委托单不存在"); |
| | | return Result.fail(MessageSourceUtils.getString("entrust_order_not_exist")); |
| | | } |
| | | |
| | | MemberWalletContractEntity walletContractEntity = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberEntity.getId(), MemberWalletCoinEnum.WALLETCOINCODE.getValue()); |
| | |
| | | int i = contractOrderDao.insert(orderEntity); |
| | | |
| | | contractEntrustOrderDao.deleteById(entrustOrderEntity.getId()); |
| | | |
| | | // 插入财务流水 |
| | | LogRecordUtils.insertMemberAccountFlow(memberEntity.getId(), total, walletContractEntity.getAvailableBalance().add(total), entrustOrderEntity.getSymbol(), "撤销委托单", "撤销委托单"); |
| | | if (i > 0) { |
| | | return Result.ok("撤销成功"); |
| | | return Result.ok(MessageSourceUtils.getString("cancellation_success")); |
| | | } |
| | | return Result.fail("撤销失败"); |
| | | return Result.fail(MessageSourceUtils.getString("cancellation_fail")); |
| | | } |
| | | |
| | | @Override |