| | |
| | | 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; |
| | |
| | | /** |
| | | * @author helius |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class OrderWebsocketServiceImpl { |
| | | |
| | |
| | | /** |
| | | * 开多止盈 |
| | | */ |
| | | @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>(); |
| | |
| | | } |
| | | } |
| | | //回报率 |
| | | 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()); |
| | |
| | | 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()); |
| | |
| | | insertAccountFlow(order, wallet, profitLossPrice, "止盈平仓"); |
| | | |
| | | //返佣 |
| | | calYj(order.getMemberId(), order.getOpeningFeeAmount(), contractOrderEntity, 2); |
| | | ThreadPoolUtils.calReturnMoney(order.getMemberId(), order.getOpeningFeeAmount(), contractOrderEntity, AgentReturnEntity.ORDER_TYPE_CLOSE); |
| | | } |
| | | } |
| | | } |