zyy
2026-03-15 35ececb0d9959e010f1ac160f20afd4dba27de57
理财
6 files modified
117 ■■■■ changed files
trading-order-admin/src/main/java/com/yami/trading/admin/controller/finance/FinanceOrderController.java 5 ●●●● patch | view | raw | blame | history
trading-order-admin/src/main/java/com/yami/trading/api/controller/ApiAssetsController.java 10 ●●●●● patch | view | raw | blame | history
trading-order-bean/src/main/java/com/yami/trading/bean/finance/FinanceOrder.java 5 ●●●● patch | view | raw | blame | history
trading-order-service/src/main/java/com/yami/trading/dao/finance/FinanceOrderMapper.java 1 ●●●● patch | view | raw | blame | history
trading-order-service/src/main/java/com/yami/trading/service/finance/service/impl/FinanceOrderServiceImpl.java 85 ●●●●● patch | view | raw | blame | history
trading-order-service/src/main/resources/mapper/finance/FinanceOrderMapper.xml 11 ●●●●● patch | view | raw | blame | history
trading-order-admin/src/main/java/com/yami/trading/admin/controller/finance/FinanceOrderController.java
@@ -254,6 +254,7 @@
            String session_token = request.getParameter("session_token");
            String financeId = request.getParameter("financeId");
            String amount = request.getParameter("amount");
            String buyCurrency  = request.getParameter("buyCurrency");
            Object object = this.sessionTokenService.cacheGet(session_token);
            this.sessionTokenService.del(session_token);
@@ -273,6 +274,7 @@
            order.setPartyId(partyId);
            order.setFinanceId(financeId);
            order.setAmount(Double.valueOf(amount));
            order.setBuyCurrency(buyCurrency);
            order.setOrderNo(DateUtil.getToday("yyMMddHHmmss") + RandomUtil.getRandomNum(8));
            order.setState("1");
@@ -307,6 +309,7 @@
            String financeId = request.getParameter("financeId");
            String amount_temp = request.getParameter("amount");
            String buyCurrency  = request.getParameter("buyCurrency");
            Finance finance = financeService.findById(financeId);
@@ -370,7 +373,7 @@
            map.put("profit_may", Arith.mul(amount, Arith.mul(rate, finance.getCycle())) + "~"
                    + Arith.mul(amount, Arith.mul(rateMax, finance.getCycle())));
            map.put("order_no", DateUtil.getToday("yyMMddHHmmss") + RandomUtil.getRandomNum(8));
            map.put("buyCurrency", finance.getBuyCurrency());
            map.put("buyCurrency", buyCurrency != null && !buyCurrency.isEmpty() ? buyCurrency : finance.getBuyCurrency());
            map.put("outputCurrency", finance.getOutputCurrency());
            resultObject.setData(map);
trading-order-admin/src/main/java/com/yami/trading/api/controller/ApiAssetsController.java
@@ -11,11 +11,15 @@
import com.yami.trading.common.util.StringUtils;
import com.yami.trading.common.util.UTCDateUtils;
import com.yami.trading.common.web.ResultObject;
import com.yami.trading.dao.finance.FinanceMapper;
import com.yami.trading.dao.finance.FinanceOrderMapper;
import com.yami.trading.security.common.util.SecurityUtils;
import com.yami.trading.service.MoneyLogService;
import com.yami.trading.service.RealNameAuthRecordService;
import com.yami.trading.service.WalletService;
import com.yami.trading.service.exchange.ExchangeApplyOrderService;
import com.yami.trading.service.finance.service.FinanceOrderService;
import com.yami.trading.service.finance.service.FinanceService;
import com.yami.trading.service.impl.ContractAndFutureProfit;
import com.yami.trading.service.user.UserDataService;
import io.swagger.annotations.Api;
@@ -51,6 +55,9 @@
    MoneyLogService moneyLogService;
    @Autowired
    ExchangeApplyOrderService exchangeApplyOrderService;
    @Autowired
    FinanceOrderMapper financeOrderMapper;
    /**
     * 交易栏 顶部数据统计
@@ -92,6 +99,9 @@
        // 当日盈亏
        data.put("profitToday", String.format("%.2f", profitToday));
        data.put("profitTotal", String.format("%.2f", profitTotal));
        Double xautProfit = financeOrderMapper.sumVolumeByBuyCurrency(partyId, "xaut");
        data.put("xautProfit", String.format("%.2f", xautProfit));
        return Result.ok(data);
    }
trading-order-bean/src/main/java/com/yami/trading/bean/finance/FinanceOrder.java
@@ -149,8 +149,11 @@
    /**
     * 理财购买币种
     */
    @TableField(exist = false)
    //@TableField(exist = false)
    private String buyCurrency = "usdt";
    //赎回币种数量
    private double volume = 0;
    
    /**
     * 理财购买币种
trading-order-service/src/main/java/com/yami/trading/dao/finance/FinanceOrderMapper.java
@@ -22,4 +22,5 @@
//    public Page pagedQuery(int pageNo, int pageSize, String name_para, String finance_para, String status_para,
//                           String partyId, String orderNo, String rolename_para) {
    Double sumVolumeByBuyCurrency(@Param("partyId") String partyId, @Param("buyCurrency") String buyCurrency);
}
trading-order-service/src/main/java/com/yami/trading/service/finance/service/impl/FinanceOrderServiceImpl.java
@@ -4,12 +4,10 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yami.trading.bean.constans.WalletConstants;
import com.yami.trading.bean.data.domain.Realtime;
import com.yami.trading.bean.finance.Finance;
import com.yami.trading.bean.finance.FinanceOrder;
import com.yami.trading.bean.model.MoneyLog;
import com.yami.trading.bean.model.User;
import com.yami.trading.bean.model.UserRecom;
import com.yami.trading.bean.model.Wallet;
import com.yami.trading.bean.model.*;
import com.yami.trading.common.constants.Constants;
import com.yami.trading.common.exception.BusinessException;
import com.yami.trading.common.util.Arith;
@@ -19,6 +17,7 @@
import com.yami.trading.dao.finance.FinanceOrderMapper;
import com.yami.trading.service.MoneyLogService;
import com.yami.trading.service.WalletService;
import com.yami.trading.service.data.DataService;
import com.yami.trading.service.finance.service.FinanceOrderService;
import com.yami.trading.service.finance.service.FinanceService;
import com.yami.trading.service.syspara.SysparaService;
@@ -53,6 +52,8 @@
    protected UserDataService userDataService;
    @Autowired
    protected UserRecomService userRecomService;
    @Autowired
    protected DataService dataService;
    public void saveCreate(FinanceOrder entity) {
@@ -151,27 +152,43 @@
        }
        if (get_amount > 0) {
            Wallet wallet = this.walletService.saveWalletByPartyId((String) entity.getPartyId());
            double amount_before = wallet.getMoney().doubleValue();
//            wallet.setMoney(Arith.add(wallet.getMoney(), get_amount));
//            this.walletService.update(wallet);
            this.walletService.update(wallet.getUserId(), get_amount);
            String symbol = entity.getBuyCurrency().toLowerCase();
            double amount_before;
            double amount_after;
            double amount;
            if (symbol.equals("usdt")) {
                Wallet wallet = this.walletService.saveWalletByPartyId(entity.getPartyId());
                amount_before = wallet.getMoney().doubleValue();
                amount_after = Arith.add(amount_before, get_amount);
                amount = get_amount;
                this.walletService.update(wallet.getUserId(), get_amount);
            } else {
                //USDT转对应symbol
                Realtime realtime = this.dataService.realtime(symbol).get(0);
                amount = Arith.div(get_amount, realtime.getClose(), 8);
                WalletExtend walletExtend = walletService.saveExtendByPara(entity.getPartyId(), symbol);
                amount_before = walletExtend.getAmount();
                amount_after = Arith.add(amount_before, get_amount);
                this.walletService.updateExtend(walletExtend.getPartyId(), walletExtend.getWallettype(), amount);
            }
            /**
             * 保存资金日志
             */
            MoneyLog moneylog = new MoneyLog();
            moneylog.setCategory(Constants.MONEYLOG_CATEGORY_FINANCE);
            moneylog.setAmountBefore(BigDecimal.valueOf(amount_before));
            moneylog.setAmount(BigDecimal.valueOf(Arith.add(0, get_amount)));
            moneylog.setAmountAfter(BigDecimal.valueOf(Arith.add(amount_before, get_amount)));
            moneylog.setAmount(BigDecimal.valueOf(Arith.add(0, amount)));
            moneylog.setAmountAfter(BigDecimal.valueOf(amount_after));
            moneylog.setLog("赎回理财产品,订单号[" + entity.getOrderNo() + "]");
            moneylog.setUserId((String) entity.getPartyId());
            moneylog.setWalletType(Constants.WALLET);
            moneylog.setUserId(entity.getPartyId());
            moneylog.setWalletType(symbol.toUpperCase());
            moneylog.setContentType(WalletConstants.MONEYLOG_CONTENT_FINANCE_BACK);
            moneylog.setCreateTime(systemTime != null ? systemTime : new Date());
            moneylog.setCreateTime(new Date());
            moneyLogService.save(moneylog);
            entity.setVolume(amount);
        }
        entity.setCloseTime(new Date());// 赎回时间
@@ -189,27 +206,43 @@
        }
        if (get_amount > 0) {
            Wallet wallet = this.walletService.saveWalletByPartyId(entity.getPartyId().toString());
            double amount_before = wallet.getMoney().doubleValue();
//            wallet.setMoney(Arith.add(wallet.getMoney(), get_amount));
//            this.walletService.update(wallet);
            this.walletService.update(wallet.getUserId(), get_amount);
            String symbol = entity.getBuyCurrency().toLowerCase();
            double amount_before;
            double amount_after;
            double amount;
            if (symbol.equals("usdt")) {
                Wallet wallet = this.walletService.saveWalletByPartyId(entity.getPartyId());
                amount_before = wallet.getMoney().doubleValue();
                amount_after = Arith.add(amount_before, get_amount);
                amount = get_amount;
                this.walletService.update(wallet.getUserId(), get_amount);
            } else {
                //USDT转对应symbol
                Realtime realtime = this.dataService.realtime(symbol).get(0);
                amount = Arith.div(get_amount, realtime.getClose(), 8);
                WalletExtend walletExtend = walletService.saveExtendByPara(entity.getPartyId(), symbol);
                amount_before = walletExtend.getAmount();
                amount_after = Arith.add(amount_before, amount);
                this.walletService.updateExtend(walletExtend.getPartyId(), walletExtend.getWallettype(), amount);
            }
            /**
             * 保存资金日志
             */
            MoneyLog moneylog = new MoneyLog();
            moneylog.setCategory(Constants.MONEYLOG_CATEGORY_FINANCE);
            moneylog.setAmountBefore(BigDecimal.valueOf(amount_before));
            moneylog.setAmount(BigDecimal.valueOf(Arith.add(0, get_amount)));
            moneylog.setAmountAfter(BigDecimal.valueOf(Arith.add(wallet.getMoney().doubleValue(), get_amount)));
            moneylog.setAmount(BigDecimal.valueOf(Arith.add(0, amount)));
            moneylog.setAmountAfter(BigDecimal.valueOf(amount_after));
            moneylog.setLog("赎回理财产品,订单号[" + entity.getOrderNo() + "]");
            moneylog.setUserId(entity.getPartyId().toString());
            moneylog.setWalletType(Constants.WALLET);
            moneylog.setUserId(entity.getPartyId());
            moneylog.setWalletType(symbol.toUpperCase());
            moneylog.setContentType(WalletConstants.MONEYLOG_CONTENT_FINANCE_BACK);
            moneylog.setCreateTime(new Date());
            moneyLogService.save(moneylog);
            entity.setVolume(amount);
        }
        entity.setCloseTime(new Date());// 赎回时间
@@ -776,8 +809,6 @@
        if (get_amount > 0) {
            Wallet wallet = this.walletService.saveWalletByPartyId(entity.getPartyId().toString());
            double amount_before = wallet.getMoney().doubleValue();
//            wallet.setMoney(Arith.add(wallet.getMoney(), get_amount));
//            this.walletService.update(wallet);
            this.walletService.update(wallet.getUserId().toString(), get_amount);
            /**
             * 保存资金日志
trading-order-service/src/main/resources/mapper/finance/FinanceOrderMapper.xml
@@ -34,6 +34,17 @@
        order by create_time desc
    </select>
    <select id="sumVolumeByBuyCurrency" resultType="java.lang.Double">
        SELECT IFNULL(sum(volume),0) FROM t_finance_order
        WHERE 1=1
        <if test="partyId!=null and partyId!=''">
            and party_id=#{partyId}
        </if>
        <if test="buyCurrency!=null and buyCurrency!=''">
            and buy_currency=#{buyCurrency}
        </if>
    </select>
    <select id="pagedQuery1" resultType="java.util.HashMap">
        SELECT financeOrder.uuid id,financeOrder.order_no order_no  ,financeOrder.finance_id financeId  ,