|  |  | 
 |  |  | package com.xcong.excoin; | 
 |  |  |  | 
 |  |  | import cn.hutool.core.collection.CollUtil; | 
 |  |  | import com.alibaba.fastjson.JSONObject; | 
 |  |  | import com.xcong.excoin.common.contants.AppContants; | 
 |  |  | import com.xcong.excoin.common.enumerates.CoinTypeEnum; | 
 |  |  | import com.xcong.excoin.common.enumerates.RabbitPriceTypeEnum; | 
 |  |  | import com.xcong.excoin.modules.contract.dao.ContractHoldOrderDao; | 
 |  |  | import com.xcong.excoin.modules.contract.entity.ContractHoldOrderEntity; | 
 |  |  | import com.xcong.excoin.modules.contract.service.RabbitOrderService; | 
 |  |  | 
 |  |  | import com.xcong.excoin.modules.member.dao.MemberWalletContractDao; | 
 |  |  | import com.xcong.excoin.modules.member.entity.MemberEntity; | 
 |  |  | import com.xcong.excoin.modules.member.entity.MemberWalletContractEntity; | 
 |  |  | import com.xcong.excoin.rabbit.pricequeue.OrderModel; | 
 |  |  | import com.xcong.excoin.rabbit.producer.OrderProducer; | 
 |  |  | import com.xcong.excoin.utils.CalculateUtil; | 
 |  |  | import com.xcong.excoin.utils.RedisUtils; | 
 |  |  | import com.xcong.excoin.utils.ThreadPoolUtils; | 
 |  |  | import org.junit.jupiter.api.Test; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | 
 |  |  | import javax.annotation.Resource; | 
 |  |  | import java.math.BigDecimal; | 
 |  |  | import java.util.ArrayList; | 
 |  |  | import java.util.HashMap; | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.Map; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * @author wzy | 
 |  |  | 
 |  |  |         System.out.println(CalculateUtil.getBondAmount(openPrice, BigDecimal.valueOf(6), 1, 5)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private OrderProducer orderProducer; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     // 面值*(多单张数*多单开仓价-空单张数*空单开仓价)-余额-已实现盈亏 / 面值*(多单张数-空单张数)-(维持保证金率+TAKER手续费)*面值*(开多张数+开空张数) | 
 |  |  |  | 
 |  |  |     /* | 
 |  |  |     面值 : 0.1000 * 678 | 
 |  |  |     多单张数 : 300  开仓价 : 11400.53000000   -> 3420159 | 
 |  |  |     空单张数 : 300  开仓价 : 11398.27000000   -> 3419481 | 
 |  |  |     余额 : 562.92683993    -495.12 | 
 |  |  |  | 
 |  |  |     手续费率 : 0.0460 | 
 |  |  |  | 
 |  |  |  | 
 |  |  |      */ | 
 |  |  |     @Test | 
 |  |  |     public void forceSetPriceTest() { | 
 |  |  |         MemberEntity memberEntity = memberDao.selectById(5L); | 
 |  |  |         CalculateUtil.getForceSetPriceForWhole("BTC/USDT", memberEntity); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Test | 
 |  |  |     public void initOrderTest() { | 
 |  |  |         List<HashMap<String, Object>> wholeHoldOrders = contractHoldOrderDao.selectAllWholeOrderMemberIdAndSymbol(); | 
 |  |  |         if (CollUtil.isNotEmpty(wholeHoldOrders)) { | 
 |  |  |             MemberEntity memberEntity = null; | 
 |  |  |             for (HashMap<String, Object> wholeHoldOrder : wholeHoldOrders) { | 
 |  |  |                 Long memberId = (Long) wholeHoldOrder.get("member_id"); | 
 |  |  |                 String symbol = (String) wholeHoldOrder.get("symbol"); | 
 |  |  |                 if (memberEntity == null || !memberId.equals(memberEntity.getId())) { | 
 |  |  |                     memberEntity = memberDao.selectById(memberId); | 
 |  |  |                 } | 
 |  |  |                 System.out.println(memberId + "-----" + symbol); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Resource | 
 |  |  |     private RedisUtils redisUtils; | 
 |  |  |  | 
 |  |  |     @Test | 
 |  |  |     public void redisTest() { | 
 |  |  |         for (int i = 827; i < 999; i++) { | 
 |  |  |             redisUtils.del(AppContants.CLOSING_ORDER_PREFIX + i); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } |