wzy
2020-10-30 de9490f5a8a29c79968242461440537949c02244
modify
10 files modified
111 ■■■■■ changed files
src/main/java/com/xcong/excoin/modules/blackchain/service/EthService.java 1 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/blackchain/service/UsdtEthService.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/coin/service/impl/BlockCoinServiceImpl.java 8 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/member/entity/MemberEntity.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java 7 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/processor/DefaultCoinProcessor.java 14 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/quartz/job/CoinTradeInitJob.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/utils/mail/Sms106Send.java 6 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/walletCoinOrder/OrderCoinsDao.xml 27 ●●●● patch | view | raw | blame | history
src/test/java/com/xcong/excoin/TradeTest.java 35 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/blackchain/service/EthService.java
@@ -55,6 +55,7 @@
     * 服务器地址
     */
    //private static final String ETH_UTL = "https://mainnet.infura.io/v3/882c66ebcfc141abbea22b948fa44321";
    //private static final String ETH_UTL = "http://120.55.86.146:8545";
    private static final String ETH_UTL = "http://114.55.250.231:8545";
    public EthService() {
src/main/java/com/xcong/excoin/modules/blackchain/service/UsdtEthService.java
@@ -100,7 +100,7 @@
//                            memberCoinChargeDao.updateById(coinCharge);
//                        }
                    } else {
                        String hash = ethService.ethSend(TOTAL_PRIVATE, TOTAL_ADDRESS, address, ETH_FEE,gasPrice);
                        //String hash = ethService.ethSend(TOTAL_PRIVATE, TOTAL_ADDRESS, address, ETH_FEE,gasPrice);
                        //log.info("转手续费:{}", hash);
                    }
                }
src/main/java/com/xcong/excoin/modules/coin/service/impl/BlockCoinServiceImpl.java
@@ -553,6 +553,13 @@
        if(CollectionUtils.isNotEmpty(memberCoinChargeEntities)){
            return;
        }
        // 校验这个交易是否成功
        EthService ethService  = new EthService();
        boolean b = ethService.checkTransferResult(hash);
        if(!b){
            log.info("#USDT假充值:{}#", hash);
            return;
        }
        MemberCoinAddressEntity coinAddressEntity = memberCoinAddressDao.selectCoinAddressByAddressAndSymbol(address, CoinTypeEnum.USDT.toString());
        if (coinAddressEntity == null) {
            return;
@@ -614,4 +621,5 @@
        memberCoinChargeDao.insert(memberCoinChargeEntity);
        return orderNo;
    }
}
src/main/java/com/xcong/excoin/modules/member/entity/MemberEntity.java
@@ -150,6 +150,11 @@
     */
    private Integer isForce;
    
    /**
     *  shifou xianzhi
     */
    private Integer isTrader;
    /**
     * 滑点
     */
src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java
@@ -469,7 +469,8 @@
    @Transactional
    public Result memberTradersPwd(@Valid MemberForgetPwdDto memberForgetPwdDto) {
        //获取用户ID
        MemberEntity memberEntity = LoginUserUtils.getAppLoginUser();
        Long memberId = LoginUserUtils.getAppLoginUser().getId();
        MemberEntity memberEntity = memberDao.selectById(memberId);
        String code = memberForgetPwdDto.getCode();
        String password = memberForgetPwdDto.getPassword();
@@ -883,6 +884,10 @@
        //获取用户ID
        Long memberId = LoginUserUtils.getAppLoginUser().getId();
        MemberEntity member = memberDao.selectById(memberId);
        // 判断是否限制
        if(1 == member.getIsTrader()){
            return Result.fail("此账号有财务问题,需联系客服");
        }
        if (member.getCertifyStatus() != MemberEntity.CERTIFY_STATUS_Y) {
            return Result.fail(MessageSourceUtils.getString("member_service_0077"));
        }
src/main/java/com/xcong/excoin/processor/DefaultCoinProcessor.java
@@ -339,11 +339,25 @@
        }
        // 如果开盘价为0,则设置为前一个价格
        if(kLine.getOpen().compareTo(BigDecimal.ZERO) == 0) {
            // 查询前一根K线 TODO
            String key = "KINE_" + symbol + "/USDT_" + period;
            Object data = redisUtils.get(key);
            List list = new ArrayList();
            if (data != null) {
                list = (List) data;
                Candlestick o = (Candlestick)list.get(list.size() - 1);
                kLine.setOpen(o.getClose());
                kLine.setClose(o.getClose());
                kLine.setLow(o.getClose());
                kLine.setHigh(o.getClose());
            }else{
            kLine.setOpen(coinThumb.getClose());
            kLine.setClose(coinThumb.getClose());
            kLine.setLow(coinThumb.getClose());
            kLine.setHigh(coinThumb.getClose());
        }
        }
        //logger.info("generate " + range + rangeUnit + " kline in {},data={}", df.format(new Date(kLine.getTimestamp())), JSON.toJSONString(kLine));
        service.saveKLine(symbol,period, kLine);
        // 生成一个对应的新K线 后续的交易会更新这个最新K线数据
src/main/java/com/xcong/excoin/quartz/job/CoinTradeInitJob.java
@@ -87,6 +87,12 @@
        List<OrderCoinsEntity> tradingOrders = new ArrayList<>();
        List<OrderCoinsEntity> completedOrders = new ArrayList<>();
        orders.forEach(order -> {
            if(order.getDealCnt()==null){
                order.setDealCnt(BigDecimal.ZERO);
            }
            if(order.getDealAmount()==null){
                order.setDealAmount(BigDecimal.ZERO);
            }
            tradingOrders.add(order);
        });
        try {
src/main/java/com/xcong/excoin/utils/mail/Sms106Send.java
@@ -39,13 +39,15 @@
    public static boolean sendRechargeMsg(String phone, String time, String orderNo) {
        String msg = "尊敬的用户,您的帐号于{}有一笔成功充值订单,订单编号{}";
        String content = StrUtil.format(msg, time, orderNo);
        return request(phone, content, "充值");
        return true;
        //return request(phone, content, "充值");
    }
    public static boolean sendWithdrawalMsg(String phone, String time, String orderNo) {
        String msg = "尊敬的用户,您的帐号于{}有一笔成功提现订单,订单编号为{}";
        String content = StrUtil.format(msg, time, orderNo);
        return request(phone, content, "提现");
        return true;
        //return request(phone, content, "提现");
    }
    private static boolean request(String phone, String content, String tagName) {
src/main/resources/mapper/walletCoinOrder/OrderCoinsDao.xml
@@ -35,11 +35,30 @@
    </select>
    <select id="selectCoinOrderOnTrade" resultType="com.xcong.excoin.modules.coin.entity.OrderCoinsEntity">
        select *
        from coins_order
        where order_status=1
        select a.id,
        a.deal_price,
        a.entrust_amount,
        a.fee_amount,
        a.entrust_cnt,
        a.mark_price,
        a.member_id,
        a.order_no,
        a.order_status,
        a.order_type,
        a.symbol,
        a.trade_type,
        a.version,
        a.create_by,
        a.create_time,
        a.update_by,
        a.update_time,
        a.entrust_price,
        (select sum(symbol_cnt) from coins_order_deal where order_id = a.id) as deal_cnt,
        (select sum(deal_amount) from coins_order_deal where order_id = a.id) as deal_amount
        from coins_order a
        where a.order_status=1
        <if test="list != null">
            and symbol in
            and a.symbol in
            <foreach collection="list" separator="," item="item" open="(" close=")">
                #{item}
            </foreach>
src/test/java/com/xcong/excoin/TradeTest.java
@@ -1,5 +1,6 @@
package com.xcong.excoin;
import cn.hutool.crypto.SecureUtil;
import com.xcong.excoin.modules.coin.dao.OrderCoinsDao;
import com.xcong.excoin.modules.coin.entity.OrderCoinsEntity;
import com.xcong.excoin.modules.coin.service.OrderCoinService;
@@ -35,37 +36,7 @@
    }
    public static void main(String[] args) throws InterruptedException {
        // 测试两个地方
        List<String> list  = new ArrayList<>();
        list.add("1");
        list.add("2");
        list.add("3");
        list.add("4");
        // 开一个线程
        Thread thread = new Thread(new Runnable() {
            @SneakyThrows
            @Override
            public void run() {
                Thread.sleep(1000);
                synchronized (list){
                    Iterator<String> iterator = list.iterator();
                    while (iterator.hasNext()){
                        System.out.println("线程里"+iterator.next());
                        iterator.remove();
                    }
                }
            }
        });
        thread.start();
        synchronized (list){
            Iterator<String> iterator = list.iterator();
            while (iterator.hasNext()){
                Thread.sleep(1000);
                System.out.println(iterator.next());
            }
        }
        //
        String s = SecureUtil.md5("330021");
        System.out.println(s);
    }
}