package com.xcong.excoin;
|
|
import cn.hutool.crypto.SecureUtil;
|
import com.xcong.excoin.common.system.dto.RegisterDto;
|
import com.xcong.excoin.modules.member.dao.MemberDao;
|
import com.xcong.excoin.modules.member.dao.MemberPaymentMethodDao;
|
import com.xcong.excoin.modules.member.entity.MemberEntity;
|
import com.xcong.excoin.modules.member.entity.MemberPaymentMethodEntity;
|
import com.xcong.excoin.modules.otc.dao.OtcMarketBussinessDao;
|
import com.xcong.excoin.modules.otc.entity.OtcMarketBussiness;
|
import com.xcong.excoin.quartz.job.OtcOrderJob;
|
import com.xcong.excoin.rabbit.consumer.OtcConsumer;
|
import com.xcong.excoin.rabbit.producer.OtcProducter;
|
import lombok.extern.slf4j.Slf4j;
|
import org.junit.jupiter.api.Test;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.math.BigDecimal;
|
import java.util.concurrent.TimeUnit;
|
|
@Slf4j
|
@SpringBootTest
|
public class OtcTest {
|
|
@Autowired
|
private OtcProducter otcProducter;
|
|
@Test
|
public void rabbitTest() {
|
otcProducter.sendDelayOrderMsg("123456");
|
|
while(true){
|
try {
|
TimeUnit.SECONDS.sleep(1);
|
} catch (InterruptedException e) {
|
e.printStackTrace();
|
}
|
|
}
|
}
|
|
@Autowired
|
// private OtcOrderJob otcOrderJob;
|
|
@Test
|
public void jobTest() {
|
// otcOrderJob.marketBussinessJob();
|
}
|
|
@Test
|
public void mbProducterTest() {
|
// otcProducter.sendMarketBussinessMsg(11L, 3);
|
}
|
|
@Autowired
|
private MemberDao memberDao;
|
|
@Autowired
|
private OtcMarketBussinessDao otcMarketBussinessDao;
|
|
@Autowired
|
private MemberPaymentMethodDao memberPaymentMethodDao;
|
|
@Test
|
// @Transactional(rollbackFor = Exception.class)
|
public void mbInsertTest() {
|
for(int i = 0; i < 50; i++) {
|
String phonePrefix = "199999999";
|
if (i < 10) {
|
phonePrefix = phonePrefix + "0" + i;
|
} else {
|
phonePrefix = phonePrefix + i;
|
}
|
|
MemberEntity member = memberDao.selectMemberInfoByAccount(phonePrefix);
|
|
OtcMarketBussiness otcMb = new OtcMarketBussiness();
|
otcMb.setMemberId(member.getId());
|
otcMb.setAvgCoinTime(0);
|
otcMb.setAvgPayTime(0);
|
otcMb.setTotalOrderCnt(0);
|
otcMb.setBuyCnt(0);
|
otcMb.setFinishRatio(BigDecimal.ZERO);
|
otcMb.setStatus(OtcMarketBussiness.CHECK_PASS);
|
|
member.setIsTrader(1);
|
member.setCertifyStatus(2);
|
member.setTradePassword(SecureUtil.md5("123456"));
|
|
memberDao.updateById(member);
|
otcMarketBussinessDao.insert(otcMb);
|
|
MemberPaymentMethodEntity memberPaymentMethodEntity = new MemberPaymentMethodEntity();
|
memberPaymentMethodEntity.setMemberId(member.getId());
|
memberPaymentMethodEntity.setAccount("123456789");
|
memberPaymentMethodEntity.setBank("中国银行");
|
memberPaymentMethodEntity.setName("无名");
|
memberPaymentMethodEntity.setPaymentType(MemberPaymentMethodEntity.PAYMENTTYPE_CARD.toString());
|
memberPaymentMethodEntity.setSubBank("中国银行");
|
memberPaymentMethodEntity.setIsDefualt("1");
|
memberPaymentMethodDao.insert(memberPaymentMethodEntity);
|
}
|
}
|
|
@Test
|
public void bigdecimalTest() {
|
BigDecimal one = BigDecimal.valueOf(6.39);
|
BigDecimal two = BigDecimal.valueOf(3129.860025);
|
BigDecimal three = BigDecimal.valueOf(19999.80);
|
|
BigDecimal cny = one.multiply(two).setScale(2, BigDecimal.ROUND_DOWN);
|
BigDecimal usdt = three.divide(one, 2, BigDecimal.ROUND_DOWN);
|
System.out.println(cny.compareTo(three) != 0 && usdt.compareTo(two) != 0);
|
}
|
|
// @Autowired
|
// private OtcConsumer otcConsumer;
|
|
@Test
|
public void returnMoneyTest() {
|
// otcConsumer.orderReturn("20210605446780002");
|
// otcProducter.sendOrderReturn("20210605446780002");
|
}
|
}
|