1
zj
5 days ago effab9619e17b97ac98b035eaa64ba99b27f5dc6
trading-order-service/src/main/java/com/yami/trading/service/impl/RechargeBlockchainOrderServiceImpl.java
@@ -17,6 +17,7 @@
import com.yami.trading.common.util.RandomUtil;
import com.yami.trading.dao.user.RechargeBlockchainOrderMapper;
import com.yami.trading.service.*;
import com.yami.trading.service.notify.WalletTransactionMailNotificationService;
import com.yami.trading.service.c2c.C2cOrderService;
import com.yami.trading.service.data.DataService;
import com.yami.trading.service.syspara.SysparaService;
@@ -75,6 +76,9 @@
    @Autowired
    DataService dataService;
    @Autowired
    private WalletTransactionMailNotificationService walletTransactionMailNotificationService;
    @Override
    public Page pageRecord(Page page, String roleName, String orderNo, String userName, Date startTime, Date endTime, String status,
@@ -89,7 +93,10 @@
//        Date now = new Date();
        RechargeBlockchainOrder recharge = getById(id);
        if (recharge == null) {
            throw new YamiShopBindException("参数错误!");
            recharge = findByOrderNo(id);
            if (recharge == null) {
                throw new YamiShopBindException("参数错误!");
            }
        }
        User party = userService.getById(recharge.getPartyId());
        if (party == null) {
@@ -119,8 +126,25 @@
         * 如果是usdt则加入wallet,否则寻找walletExtend里相同币种
         */
        Syspara user_recom_bonus_open = sysparaService.find("user_recom_bonus_open");
        if ("usdt".equals(recharge.getSymbol())) {
        if ("usdt".equals(recharge.getSymbol()) || "usdc".equals(recharge.getSymbol())) {
            double amount1 = recharge.getVolume();
            if ("usdc".equals(recharge.getSymbol())) {
                List<Realtime> realtime_list = this.dataService.realtime(recharge.getSymbol());
                log.info("充值usdc转为usdt::" + realtime_list);
                Realtime realtime = null;
                if (realtime_list.size() > 0) {
                    realtime = realtime_list.get(0);
                } else {
                    throw new YamiShopBindException("系统错误,请稍后重试");
                }
                // 对应usdt价格
                double transfer_usdt = realtime.getClose();
                double volume = recharge.getVolume();
                // 币种usdt价格= 币种价格×充值数量
                amount1 = Arith.mul(recharge.getVolume(), transfer_usdt);
                log.info("充值usdc转为usdt::" + amount1);
            }
            Wallet wallet = new Wallet();
            wallet = walletService.saveWalletByPartyId(recharge.getPartyId());
            double amount_before = wallet.getMoney().doubleValue();
@@ -212,6 +236,10 @@
                }
            }
            userService.updateById(party);
            BigDecimal mailAmount = BigDecimal.valueOf(amount1);
            String mailAsset = "usdc".equalsIgnoreCase(recharge.getSymbol()) ? "USDT (from USDC)" : "USDT";
            walletTransactionMailNotificationService.sendRechargeSuccess(
                    party, recharge.getOrderNo(), mailAmount, mailAsset);
        } else {
            List<Realtime> realtime_list = this.dataService.realtime(recharge.getSymbol());
@@ -268,7 +296,7 @@
                double baseAmount = Double.parseDouble(recharges[1]);
                // 用户已完成USDT订单
                long number = moneyLogService.getMoneyLogByFirstRecharge(recharge.getPartyId()) == null ? 0 : 1;
                        //this.findByPartyIdAndLargerVolume(recharge.getPartyId(), 1,baseAmount);
                //this.findByPartyIdAndLargerVolume(recharge.getPartyId(), 1,baseAmount);
                rechargeBonusService.saveFirstUsdtBounsHandle(recharge,transfer_usdt,number,recharges);
            }
            /**
@@ -331,6 +359,11 @@
                }
            }
            userService.updateById(party);
            walletTransactionMailNotificationService.sendRechargeSuccess(
                    party,
                    recharge.getOrderNo(),
                    BigDecimal.valueOf(recharge.getVolume()),
                    recharge.getSymbol().toUpperCase());
        }
        Log log = new Log();
        log.setCategory(Constants.LOG_CATEGORY_OPERATION);
@@ -426,7 +459,7 @@
        if ("".equals(recharge.getOrderNo()) || recharge.getOrderNo() == null) {
            recharge.setOrderNo(DateUtil.getToday("yyMMddHHmmss") + RandomUtil.getRandomNum(8));
        }
        save(recharge);
        saveOrUpdate(recharge);
        // 保存资金日志
        WalletLog walletLog = new WalletLog();
        walletLog.setCategory(Constants.MONEYLOG_CATEGORY_RECHARGE);