From 841a600e7928a6795d9e68350d5b5a18e4b7c3a3 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Wed, 03 Jun 2020 18:56:32 +0800 Subject: [PATCH] modify --- src/main/java/com/xcong/excoin/modules/contract/parameter/vo/ContractEntrustVo.java | 2 +- src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractHoldOrderServiceImpl.java | 4 ++-- src/main/resources/mapper/contract/ContractEntrustOrderDao.xml | 1 + src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java | 12 +++++++++--- src/main/java/com/xcong/excoin/configurations/RabbitMqConfig.java | 33 +++++++++++++++++++++++---------- 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/xcong/excoin/configurations/RabbitMqConfig.java b/src/main/java/com/xcong/excoin/configurations/RabbitMqConfig.java index 7be7a45..633305d 100644 --- a/src/main/java/com/xcong/excoin/configurations/RabbitMqConfig.java +++ b/src/main/java/com/xcong/excoin/configurations/RabbitMqConfig.java @@ -31,26 +31,25 @@ // 开多止盈队列 - public static final String QUEUE_MOREPRO = "QUEUE_MOREPRO"; + public static final String QUEUE_MOREPRO = "QUEUE_MOREPRO_NEW"; // 开空止盈队列 - public static final String QUEUE_LESSPRO = "QUEUE_LESSPRO"; + public static final String QUEUE_LESSPRO = "QUEUE_LESSPRO_NEW"; // 开多止损队列 - public static final String QUEUE_MORELOSS = "QUEUE_MORELOSS"; + public static final String QUEUE_MORELOSS = "QUEUE_MORELOSS_NEW"; // 开空止损队列 - public static final String QUEUE_LESSLOSS = "QUEUE_LESSLOSS"; + public static final String QUEUE_LESSLOSS = "QUEUE_LESSLOSS_NEW"; // 限价委托 public static final String QUEUE_LIMIT = "QUEUE_LIMIT_NEW"; // 爆仓队列 - public static final String QUEUE_COINOUT = "QUEUE_COINOUT"; + public static final String QUEUE_COINOUT = "QUEUE_COINOUT_NEW"; //价格操作 - public static final String QUEUE_PRICEOPERATE = "QUEUE_PRICEOPERATE"; + public static final String QUEUE_PRICEOPERATE = "QUEUE_PRICEOPERATE_NEW"; // 平仓队列 - public static final String QUEUE_CLOSETRADE = "QUEUE_CLOSETRADE"; - + public static final String QUEUE_CLOSETRADE = "QUEUE_CLOSETRADE_NEW"; // 开多止盈路由键 @@ -118,9 +117,9 @@ } - /** * 开多止盈队列 + * * @return */ @Bean @@ -131,6 +130,7 @@ /** * 开空止盈队列 + * * @return */ @Bean @@ -141,6 +141,7 @@ /** * 开多止损 + * * @return */ @Bean @@ -151,6 +152,7 @@ /** * 开空止损 + * * @return */ @Bean @@ -161,6 +163,7 @@ /** * 限价委托 + * * @return */ @Bean @@ -171,6 +174,7 @@ /** * 爆仓 + * * @return */ @Bean @@ -180,6 +184,7 @@ /** * 价格操作 + * * @return */ @Bean @@ -189,6 +194,7 @@ /** * 价格操作 + * * @return */ @Bean @@ -197,9 +203,9 @@ } - /** * 开多止盈 + * * @return */ @Bean @@ -209,6 +215,7 @@ /** * 开空止盈 + * * @return */ @Bean @@ -218,6 +225,7 @@ /** * 开多止损 + * * @return */ @Bean @@ -227,6 +235,7 @@ /** * 开空止损 + * * @return */ @Bean @@ -237,6 +246,7 @@ /** * 委托 + * * @return */ @Bean @@ -247,6 +257,7 @@ /** * 爆仓 + * * @return */ @Bean @@ -257,6 +268,7 @@ /** * 价格操作 + * * @return */ @Bean @@ -266,6 +278,7 @@ /** * 平仓绑定 + * * @return */ @Bean diff --git a/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/ContractEntrustVo.java b/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/ContractEntrustVo.java index ff930c9..261688a 100644 --- a/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/ContractEntrustVo.java +++ b/src/main/java/com/xcong/excoin/modules/contract/parameter/vo/ContractEntrustVo.java @@ -22,7 +22,7 @@ private BigDecimal entrustPrice; @ApiModelProperty(value = "委托数量") - private int symbolsCnt; + private int symbolCnt; @ApiModelProperty(value = "保证金") private BigDecimal bondAmount; diff --git a/src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractHoldOrderServiceImpl.java b/src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractHoldOrderServiceImpl.java index 2a02836..f8fbd37 100644 --- a/src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractHoldOrderServiceImpl.java +++ b/src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractHoldOrderServiceImpl.java @@ -366,10 +366,10 @@ if (ContractHoldOrderEntity.OPENING_TYPE_MORE == holdOrderEntity.getOpeningType()) { // 开多止盈 if (ProfitOrLessDto.TYPE_PROFIT == profitOrLessDto.getType()) { - model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_MORE_STOP_PROFIT.getValue(), price.toPlainString(), holdOrderEntity.getSymbol()); + model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_MORE_STOP_PROFIT.getValue(), price.setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol()); // 开多止损 } else { - model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_MORE_STOP_LESS.getValue(), price.toPlainString(), holdOrderEntity.getSymbol()); + model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_MORE_STOP_LESS.getValue(), price.setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol()); } } else { // 开空止盈 diff --git a/src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java b/src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java index cb215e9..2bac5d2 100644 --- a/src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java +++ b/src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java @@ -23,8 +23,11 @@ import com.xcong.excoin.rabbit.producer.OrderProducer; import com.xcong.excoin.utils.CacheSettingUtils; import com.xcong.excoin.utils.CalculateUtil; +import com.xcong.excoin.utils.ThreadPoolUtils; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; @@ -34,6 +37,7 @@ /** * @author helius */ +@Slf4j @Service public class OrderWebsocketServiceImpl { @@ -122,6 +126,7 @@ /** * 开多止盈 */ + @Transactional(rollbackFor = Exception.class) public void dealForMoreStopPro(List<ContractHoldOrderEntity> orderList, List<OrderModel> list) { if (CollectionUtils.isNotEmpty(orderList)) { Map<Long, BigDecimal> modelMap = new HashMap<Long, BigDecimal>(); @@ -177,7 +182,7 @@ } } //回报率 - BigDecimal returnRate = profitLossPrice.divide((order.getPrePaymentAmount().subtract(contractOrderEntity.getClosingFeeAmount())), 8, BigDecimal.ROUND_DOWN); + BigDecimal returnRate = profitLossPrice.divide((order.getPrePaymentAmount().subtract(contractOrderEntity.getOpeningFeeAmount())), 8, BigDecimal.ROUND_DOWN); contractOrderEntity.setRewardAmount(profitLossPrice); contractOrderEntity.setRewardRatio(returnRate); contractOrderEntity.setClosingFeeAmount(order.getOpeningFeeAmount()); @@ -185,11 +190,12 @@ contractOrderEntity.setClosingType(6); BigDecimal totalReturn = BigDecimal.ZERO; contractOrderService.save(contractOrderEntity); + + contractEntrustOrderService.removeById(order.getId()); // 将需要退回的减去手续费 BigDecimal needReturn = prePrice.add(profitLossPrice); //总退回金额=保证金+收益-手续费 totalReturn = needReturn.subtract(contractOrderEntity.getClosingFeeAmount()); - // 更新钱包 // 总的是收益-平仓手续费 BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount()); memberWalletContractService.increaseWalletContractBalanceById(totalBalance, totalReturn, null, wallet.getId()); @@ -198,7 +204,7 @@ insertAccountFlow(order, wallet, profitLossPrice, "止盈平仓"); //返佣 - calYj(order.getMemberId(), order.getOpeningFeeAmount(), contractOrderEntity, 2); + ThreadPoolUtils.calReturnMoney(order.getMemberId(), order.getOpeningFeeAmount(), contractOrderEntity, AgentReturnEntity.ORDER_TYPE_CLOSE); } } } diff --git a/src/main/resources/mapper/contract/ContractEntrustOrderDao.xml b/src/main/resources/mapper/contract/ContractEntrustOrderDao.xml index ebb0698..0ba1be1 100644 --- a/src/main/resources/mapper/contract/ContractEntrustOrderDao.xml +++ b/src/main/resources/mapper/contract/ContractEntrustOrderDao.xml @@ -18,6 +18,7 @@ <if test="symbol != null and symbol !=''"> and symbol=#{symbol} </if> + order by create_time desc </select> <select id="selectEntrustOrderListByIds" resultType="com.xcong.excoin.modules.contract.entity.ContractEntrustOrderEntity"> select * from contract_entrust_order -- Gitblit v1.9.1