Helius
2020-08-13 1356cf874d0fac038269d4277afea86d285dd623
src/main/java/com/xcong/excoin/modules/contract/service/impl/RabbitOrderServiceImpl.java
@@ -11,9 +11,11 @@
import com.xcong.excoin.modules.contract.mapper.ContractHoldOrderEntityMapper;
import com.xcong.excoin.modules.contract.service.RabbitOrderService;
import com.xcong.excoin.modules.member.dao.MemberDao;
import com.xcong.excoin.modules.member.dao.MemberSettingDao;
import com.xcong.excoin.modules.member.dao.MemberWalletContractDao;
import com.xcong.excoin.modules.member.entity.AgentReturnEntity;
import com.xcong.excoin.modules.member.entity.MemberEntity;
import com.xcong.excoin.modules.member.entity.MemberSettingEntity;
import com.xcong.excoin.modules.member.entity.MemberWalletContractEntity;
import com.xcong.excoin.modules.platform.entity.PlatformTradeSettingEntity;
import com.xcong.excoin.utils.*;
@@ -57,6 +59,8 @@
    @Resource
    private RedisUtils redisUtils;
    @Resource
    private MemberSettingDao memberSettingDao;
    @Transactional(rollbackFor = Exception.class)
    @Override
@@ -93,16 +97,18 @@
            BigDecimal profitOrLoss = BigDecimal.ZERO;
            Integer orderType = null;
            Integer closingType = null;
            MemberSettingEntity memberSettingEntity = memberSettingDao.selectMemberSettingByMemberId(memberEntity.getId());
            // 开多
            if (ContractHoldOrderEntity.OPENING_TYPE_MORE == holdOrderEntity.getOpeningType()) {
                newPrice = newPrice.multiply(BigDecimal.ONE.subtract(memberEntity.getClosingSpread().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_DOWN)));
                newPrice = newPrice.multiply(BigDecimal.ONE.subtract(memberSettingEntity.getClosingSpread().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_DOWN)));
                // (最新价-开仓价)*规格*张数
                profitOrLoss = newPrice.subtract(holdOrderEntity.getOpeningPrice()).multiply(lotNumber).multiply(new BigDecimal(holdOrderEntity.getSymbolCnt()));
                orderType = ContractOrderEntity.ORDER_TYPE_CLOSE_MORE;
                closingType = OrderClosingTypeEnum.CLOSE_MORE.getValue();
                // 开空
            } else {
                newPrice = newPrice.multiply(BigDecimal.ONE.add(memberEntity.getClosingSpread().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_DOWN)));
                newPrice = newPrice.multiply(BigDecimal.ONE.add(memberSettingEntity.getClosingSpread().divide(BigDecimal.valueOf(10000), 4, BigDecimal.ROUND_DOWN)));
                // (开仓价-最新价)*规格*张数
                profitOrLoss = holdOrderEntity.getOpeningPrice().subtract(newPrice).multiply(lotNumber).multiply(new BigDecimal(holdOrderEntity.getSymbolCnt()));
                orderType = ContractOrderEntity.ORDER_TYPE_CLOSE_LESS;