Helius
2020-06-03 841a600e7928a6795d9e68350d5b5a18e4b7c3a3
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);
                    }
                }
            }