From 786a26049ccb950bbfc6d0b74c3d2590afd017f5 Mon Sep 17 00:00:00 2001
From: zyy <zyy@email.com>
Date: Tue, 02 Sep 2025 17:20:23 +0800
Subject: [PATCH] 新币申购修改

---
 trading-order-bean/src/main/java/com/yami/trading/bean/ico/query/IcoQuery.java          |    3 
 trading-order-service/src/main/java/com/yami/trading/service/ico/IcoService.java        |  141 ++++++++++++++++++++++------------------------
 trading-order-admin/src/main/java/com/yami/trading/admin/task/IcoTask.java              |    2 
 trading-order-bean/src/main/java/com/yami/trading/bean/ico/domain/UserSubscription.java |    5 +
 trading-order-sys/src/main/resources/mapper/SysMenuMapper.xml                           |    4 +
 trading-order-service/src/main/resources/mapper/ico/UserSubscriptionMapper.xml          |    1 
 6 files changed, 78 insertions(+), 78 deletions(-)

diff --git a/trading-order-admin/src/main/java/com/yami/trading/admin/task/IcoTask.java b/trading-order-admin/src/main/java/com/yami/trading/admin/task/IcoTask.java
index 56f3cf9..6c295ab 100644
--- a/trading-order-admin/src/main/java/com/yami/trading/admin/task/IcoTask.java
+++ b/trading-order-admin/src/main/java/com/yami/trading/admin/task/IcoTask.java
@@ -35,7 +35,7 @@
     @Scheduled(cron = "0 */5 * * * ?")
     public void icoToItem() {
         QueryWrapper<Ico> query  = new QueryWrapper<>();
-        query.gt("market_date", DateTime.now());
+        query.lt("market_date", DateTime.now());
         List<Ico> icoList = icoService.list(query);
         if (icoList != null && !icoList.isEmpty()) {
             List<String> symbolList = icoList.stream().map(Ico::getSymbol).collect(Collectors.toList());
diff --git a/trading-order-bean/src/main/java/com/yami/trading/bean/ico/domain/UserSubscription.java b/trading-order-bean/src/main/java/com/yami/trading/bean/ico/domain/UserSubscription.java
index 82f6965..64067a8 100644
--- a/trading-order-bean/src/main/java/com/yami/trading/bean/ico/domain/UserSubscription.java
+++ b/trading-order-bean/src/main/java/com/yami/trading/bean/ico/domain/UserSubscription.java
@@ -56,4 +56,9 @@
     @ApiModelProperty("修改时间")
     private String updatedAt;
 
+
+    @TableLogic
+    @TableField(fill = FieldFill.INSERT)
+    private Integer delFlag;
+
 }
diff --git a/trading-order-bean/src/main/java/com/yami/trading/bean/ico/query/IcoQuery.java b/trading-order-bean/src/main/java/com/yami/trading/bean/ico/query/IcoQuery.java
index 68b9a61..44c77bd 100644
--- a/trading-order-bean/src/main/java/com/yami/trading/bean/ico/query/IcoQuery.java
+++ b/trading-order-bean/src/main/java/com/yami/trading/bean/ico/query/IcoQuery.java
@@ -40,7 +40,8 @@
 	private String symbolData;
 
 
-	@ApiModelProperty("状态:1、已认购,2、未中签,3、已中签,4、已缴纳 5.已分发")
+	@ApiParam("状态:1、已认购,2、未中签,3、已中签,4、已缴纳 5.已分发")
+	@Query(type = QueryType.EQ)
 	private Integer status;
 
 	@ApiParam(value = "userId")
diff --git a/trading-order-service/src/main/java/com/yami/trading/service/ico/IcoService.java b/trading-order-service/src/main/java/com/yami/trading/service/ico/IcoService.java
index 6fd54b0..6cebe22 100644
--- a/trading-order-service/src/main/java/com/yami/trading/service/ico/IcoService.java
+++ b/trading-order-service/src/main/java/com/yami/trading/service/ico/IcoService.java
@@ -53,78 +53,71 @@
      * 新币申购
      */
     public Result<String> subscribe(UserSubscription model) {
-        try {
-            if (model == null || model.getIcoProjectId() == null) {
-                throw new YamiShopBindException("参数异常");
-            }
-            String partyId = model.getUserId();
-            Ico ico = this.getById(model.getIcoProjectId());
-            if (ico == null) {
-                throw new YamiShopBindException("新币不存在");
-            }
-
-            User party = userService.getById(partyId);
-            if (!party.isEnabled()) {
-                return Result.succeed("User is locked");
-            }
-            if (Constants.SECURITY_ROLE_TEST.equals(party.getRoleName())) {
-                throw new YamiShopBindException("无权限");
-            }
-            if (!C2cLock.add(partyId)) {
-                throw new YamiShopBindException("Please try again later");
-            }
-
-            if (model.getSubscribeNums() == null || model.getSubscribeNums() == 0) {
-                throw new YamiShopBindException("申请数量不能为空");
-            }
-            //购买金额
-            BigDecimal amount = ico.getUnitAmount().multiply(new BigDecimal(model.getSubscribeNums()));
-            if(amount.compareTo(ico.getMinContribution()) < 0 ){
-                throw new YamiShopBindException("最低投资额: " + ico.getMinContribution());
-            }
-            if(amount.compareTo(ico.getMaxContribution()) > 0 ){
-                throw new YamiShopBindException("最高投资额: " + ico.getMaxContribution());
-            }
-            Date currentDate = new Date();
-            if(currentDate.before(ico.getStartDate())){
-                throw new YamiShopBindException("未开售");
-            }
-            if(currentDate.after(ico.getEndDate())){
-                throw new YamiShopBindException("已结束");
-            }
-
-            model.setStatus(1);
-            model.setUserId(partyId);
-            if (model.getSubscriptionType() == null) { //默认自主申购
-                model.setSubscriptionType(1);
-            }
-
-            //需要先支付
-            if (ico.getIsPayDown() !=null && ico.getIsPayDown() == 1) {
-                Wallet wallet = walletService.saveWalletByPartyId(partyId);
-                if (amount.compareTo(wallet.getMoney()) > 0) {
-                    throw new YamiShopBindException("余额不足");
-                }
-                walletService.update(partyId, Arith.sub(0, amount.doubleValue()));
-
-                // 保存 资金日志
-                MoneyLog moneylog = new MoneyLog();
-                moneylog.setCategory(Constants.MONEYLOG_CONTENT_NEW_COIN);
-                moneylog.setAmountBefore(wallet.getMoney());
-                moneylog.setAmount(amount);
-                moneylog.setAmountAfter(BigDecimal.valueOf(Arith.sub(wallet.getMoney().doubleValue(), amount.doubleValue())));
-                moneylog.setLog("新币购买,申购金额[" + amount + "]");
-                moneylog.setUserId(partyId);
-                moneylog.setSymbol(ico.getSymbol());
-                moneylog.setWalletType(ico.getSymbol());
-                moneylog.setContentType(Constants.MONEYLOG_CONTENT_NEW_COIN_BUY);
-                moneyLogService.save(moneylog);
-            }
-            userSubscriptionService.save(model);
-            return Result.ok("申请成功" );
-        } catch (Exception e) {
-            throw new RuntimeException(e);
+        if (model == null || model.getIcoProjectId() == null) {
+            throw new YamiShopBindException("参数异常");
         }
+        String partyId = model.getUserId();
+        Ico ico = this.getById(model.getIcoProjectId());
+        if (ico == null) {
+            throw new YamiShopBindException("新币不存在");
+        }
+
+        User party = userService.getById(partyId);
+        if (!party.isEnabled()) {
+            throw new YamiShopBindException("User is locked");
+        }
+        if (Constants.SECURITY_ROLE_TEST.equals(party.getRoleName())) {
+            throw new YamiShopBindException("无权限");
+        }
+
+        if (model.getSubscribeNums() == null || model.getSubscribeNums() == 0) {
+            throw new YamiShopBindException("申请数量不能为空");
+        }
+        //购买金额
+        BigDecimal amount = ico.getUnitAmount().multiply(new BigDecimal(model.getSubscribeNums()));
+        if(amount.compareTo(ico.getMinContribution()) < 0 ){
+            throw new YamiShopBindException("最低投资额: " + ico.getMinContribution());
+        }
+        if(amount.compareTo(ico.getMaxContribution()) > 0 ){
+            throw new YamiShopBindException("最高投资额: " + ico.getMaxContribution());
+        }
+        Date currentDate = new Date();
+        if(currentDate.before(ico.getStartDate())){
+            throw new YamiShopBindException("未开售");
+        }
+        if(currentDate.after(ico.getEndDate())){
+            throw new YamiShopBindException("已结束");
+        }
+
+        model.setStatus(1);
+        model.setUserId(partyId);
+        if (model.getSubscriptionType() == null) { //默认自主申购
+            model.setSubscriptionType(1);
+        }
+
+        //需要先支付
+        if (ico.getIsPayDown() !=null && ico.getIsPayDown() == 1) {
+            Wallet wallet = walletService.saveWalletByPartyId(partyId);
+            if (amount.compareTo(wallet.getMoney()) > 0) {
+                throw new YamiShopBindException("余额不足");
+            }
+            walletService.update(partyId, Arith.sub(0, amount.doubleValue()));
+
+            // 保存 资金日志
+            MoneyLog moneylog = new MoneyLog();
+            moneylog.setCategory(Constants.MONEYLOG_CONTENT_NEW_COIN);
+            moneylog.setAmountBefore(wallet.getMoney());
+            moneylog.setAmount(amount);
+            moneylog.setAmountAfter(BigDecimal.valueOf(Arith.sub(wallet.getMoney().doubleValue(), amount.doubleValue())));
+            moneylog.setLog("新币购买,申购金额[" + amount + "]");
+            moneylog.setUserId(partyId);
+            moneylog.setSymbol(ico.getSymbol());
+            moneylog.setWalletType(ico.getSymbol());
+            moneylog.setContentType(Constants.MONEYLOG_CONTENT_NEW_COIN_BUY);
+            moneyLogService.save(moneylog);
+        }
+        userSubscriptionService.save(model);
+        return Result.ok("申请成功" );
     }
 
 
@@ -146,7 +139,7 @@
             if(userSubscription.getStatus() == 3){
                 throw new YamiShopBindException("不能更改申购状态");
             }
-            Ico ico = this.getById(model.getIcoProjectId());
+            Ico ico = this.getById(userSubscription.getIcoProjectId());
             String userId = userSubscription.getUserId();
             if (model.getStatus() == 3 || model.getStatus() == 5) {
                 if(model.getBallotNumber() == null || model.getBallotNumber() == 0){
@@ -216,7 +209,7 @@
                 WalletExtend walletExtend = walletService.saveExtendByPara(userId, ico.getSymbol());
                 walletService.updateExtend(userId, walletExtend.getWallettype(), model.getBallotNumber());
             }
-            userSubscriptionService.save(userSubscription);
+            userSubscriptionService.saveOrUpdate(userSubscription);
             return Result.ok ( "操作成功" );
         } catch (Exception e) {
             throw new RuntimeException(e);
@@ -242,7 +235,7 @@
         item.setShowStatus("1");
         item.setTradeStatus("1");
         item.setQuoteCurrency(ico.getCurrency());
-        item.setCurrencyType(0);
+        item.setCurrencyType(1);  //新币
         item.setStatus(0);
         item.setTradeType(ico.getIsContractTrading().toString());
         return item;
diff --git a/trading-order-service/src/main/resources/mapper/ico/UserSubscriptionMapper.xml b/trading-order-service/src/main/resources/mapper/ico/UserSubscriptionMapper.xml
index 6e404a8..3138ae7 100644
--- a/trading-order-service/src/main/resources/mapper/ico/UserSubscriptionMapper.xml
+++ b/trading-order-service/src/main/resources/mapper/ico/UserSubscriptionMapper.xml
@@ -7,7 +7,6 @@
         SELECT u.*,t.name,t.symbol
         FROM user_subscription_record u
         LEFT JOIN t_ico_project t ON t.id = u.ico_project_id
-        WHERE u.user_id='1'
         ${ew.customSqlSegment}
     </select>
 
diff --git a/trading-order-sys/src/main/resources/mapper/SysMenuMapper.xml b/trading-order-sys/src/main/resources/mapper/SysMenuMapper.xml
index e7c8b2f..55d5778 100644
--- a/trading-order-sys/src/main/resources/mapper/SysMenuMapper.xml
+++ b/trading-order-sys/src/main/resources/mapper/SysMenuMapper.xml
@@ -4,7 +4,9 @@
 <mapper namespace="com.yami.trading.sys.dao.SysMenuMapper">
 
 	<select id="listMenuIdByRoleId" resultType="Long">
-		select menu_id from tz_sys_role_menu where role_id = #{roleId} and is_show = 0
+		select r.menu_id from tz_sys_role_menu r
+		LEFT JOIN tz_sys_menu m ON m.menu_id = r.menu_id
+		where r.role_id = #{roleId} and m.is_show = 0
 	</select>
 
 	<!-- 查询用户的所有菜单 -->

--
Gitblit v1.9.3