xiaoyong931011
2020-06-05 411814a852dd16cd634b79eceeff5d5aa9483d96
Merge branch 'master' of https://gitee.com/chonggaoxiao/new_excoin.git
6 files modified
45 ■■■■ changed files
src/main/java/com/xcong/excoin/modules/contract/dao/ContractOrderDao.java 4 ●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/contract/parameter/dto/OrderListDto.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractEntrustOrderServiceImpl.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractHoldOrderServiceImpl.java 5 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java 18 ●●●● patch | view | raw | blame | history
src/main/resources/mapper/contract/ContractOrderDao.xml 12 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/contract/dao/ContractOrderDao.java
@@ -4,6 +4,8 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xcong.excoin.modules.contract.entity.ContractOrderEntity;
import com.xcong.excoin.modules.contract.parameter.dto.OrderListDto;
import com.xcong.excoin.modules.contract.parameter.vo.OrderListVo;
import org.apache.ibatis.annotations.Param;
/**
@@ -11,7 +13,7 @@
 */
public interface ContractOrderDao extends BaseMapper<ContractOrderEntity> {
    public IPage<ContractOrderEntity> selectContractOrderInPage(Page<ContractOrderEntity> page, Long memberId);
    public IPage<ContractOrderEntity> selectContractOrderInPage(Page<ContractOrderEntity> page, @Param("record") ContractOrderEntity contractOrderEntity);
    public ContractOrderEntity selectOrderDetailByIdAndMemberId(@Param("id") Long id, @Param("memberId") Long memberId);
}
src/main/java/com/xcong/excoin/modules/contract/parameter/dto/OrderListDto.java
@@ -24,4 +24,8 @@
    @ApiModelProperty(value = "每页数量", example = "10")
    private int pageSize;
    @NotNull
    @ApiModelProperty(value = "币种", example = "BTC/USDT")
    private String symbol;
}
src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractEntrustOrderServiceImpl.java
@@ -168,7 +168,7 @@
        MemberWalletContractEntity walletContractEntity = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberEntity.getId(), MemberWalletCoinEnum.WALLETCOINCODE.getValue());
        BigDecimal total = entrustOrderEntity.getEntrustAmount();
        memberWalletContractDao.increaseWalletContractBalanceById(total, null, total.negate(), walletContractEntity.getId());
        memberWalletContractDao.increaseWalletContractBalanceById(total, null, entrustOrderEntity.getBondAmount().negate(), walletContractEntity.getId());
        ContractOrderEntity orderEntity = ContractEntrustOrderEntityMapper.INSTANCE.entrustOrderToOrder(entrustOrderEntity);
        orderEntity.setTradeType(ContractOrderEntity.TRADE_TYPE_MARK_PRICE);
src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractHoldOrderServiceImpl.java
@@ -542,7 +542,10 @@
    public Result findOrderList(OrderListDto orderListDto) {
        MemberEntity memberEntity = LoginUserUtils.getAppLoginUser();
        Page<ContractOrderEntity> page = new Page<>(orderListDto.getPageNum(), orderListDto.getPageSize());
        IPage<ContractOrderEntity> list = contractOrderDao.selectContractOrderInPage(page, memberEntity.getId());
        ContractOrderEntity contractOrderEntity = new ContractOrderEntity();
        contractOrderEntity.setMemberId(memberEntity.getId());
        contractOrderEntity.setSymbol(orderListDto.getSymbol());
        IPage<ContractOrderEntity> list = contractOrderDao.selectContractOrderInPage(page, contractOrderEntity);
        Page<OrderListVo> result = ContractOrderEntityMapper.INSTANCE.pageEntityToPageVo(list);
        return Result.ok(result);
    }
src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java
@@ -191,14 +191,14 @@
                        BigDecimal totalReturn = BigDecimal.ZERO;
                        contractOrderService.save(contractOrderEntity);
                        contractEntrustOrderService.removeById(order.getId());
                        contractHoldOrderService.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());
                        memberWalletContractService.increaseWalletContractBalanceById(totalReturn, totalBalance, null, wallet.getId());
                        // 流水记录 TODO 531e
                        insertAccountFlow(order, wallet, profitLossPrice, "止盈平仓");
@@ -287,7 +287,7 @@
                        // 更新钱包
                        // 总的是收益-平仓手续费
                        BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount());
                        memberWalletContractService.increaseWalletContractBalanceById(totalBalance, totalReturn, null, wallet.getId());
                        memberWalletContractService.increaseWalletContractBalanceById(totalReturn, totalBalance, null, wallet.getId());
                        insertAccountFlow(order, wallet, profitLossPrice, "止盈平仓");
@@ -369,14 +369,19 @@
                        contractOrderEntity.setClosingType(8);
                        BigDecimal totalReturn = BigDecimal.ZERO;
                        contractOrderService.save(contractOrderEntity);
                        contractHoldOrderService.removeById(order.getId());
                        log.info("保证金:{}", prePrice);
                        log.info("盈亏:{}", profitLossPrice);
                        // 将需要退回的减去手续费
                        BigDecimal needReturn = prePrice.add(profitLossPrice);
                        log.info("退回的钱:{}", needReturn);
                        //总退回金额=保证金+收益-手续费
                        totalReturn = needReturn.subtract(contractOrderEntity.getClosingFeeAmount());
                        // 更新钱包
                        // 总的是收益-平仓手续费
                        BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount());
                        memberWalletContractService.increaseWalletContractBalanceById(totalBalance, totalReturn, null, wallet.getId());
                        memberWalletContractService.increaseWalletContractBalanceById(totalReturn, totalBalance, null, wallet.getId());
                        insertAccountFlow(order, wallet, profitLossPrice, "开多止损平仓");
@@ -456,6 +461,9 @@
                        contractOrderEntity.setClosingType(9);
                        BigDecimal totalReturn = BigDecimal.ZERO;
                        contractOrderService.save(contractOrderEntity);
                        contractHoldOrderService.removeById(order.getId());
                        // 将需要退回的减去手续费
                        BigDecimal needReturn = prePrice.add(profitLossPrice);
                        //总退回金额=保证金+收益-手续费
@@ -463,7 +471,7 @@
                        // 更新钱包
                        // 总的是收益-平仓手续费
                        BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount());
                        memberWalletContractService.increaseWalletContractBalanceById(totalBalance, totalReturn, null, wallet.getId());
                        memberWalletContractService.increaseWalletContractBalanceById(totalReturn, totalBalance, null, wallet.getId());
                        insertAccountFlow(order, wallet, profitLossPrice, "开空止损平仓");
src/main/resources/mapper/contract/ContractOrderDao.xml
@@ -4,7 +4,17 @@
    <select id="selectContractOrderInPage" resultType="com.xcong.excoin.modules.contract.entity.ContractOrderEntity">
        select * from contract_order where member_id=#{memberId}
        select * from contract_order
        <if test="record != null">
            <where>
                <if test="record.memberId != null" >
                    and member_id=#{record.memberId}
                </if>
                <if test="record.symbol != null and record.symbol != ''">
                    and symbol = #{record.symbol}
                </if>
            </where>
        </if>
        order by create_time desc
    </select>