peternameyakj
2024-08-29 ca8e89d46a92b567aa9af2c32ea2951d1e60ca6c
合并ICO
4 files modified
1 files added
143 ■■■■ changed files
pom.xml 10 ●●●● patch | view | raw | blame | history
src/main/java/org/example/ssmico/demos/web/controller/IcoNewCurrencyController.java 56 ●●●● patch | view | raw | blame | history
src/main/java/org/example/ssmico/demos/web/controller/IcoOrderController.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/example/ssmico/demos/web/util/DateUtils.java 4 ●●●● patch | view | raw | blame | history
src/main/java/org/example/ssmico/demos/web/vo/IcoNewCurrencyVo.java 66 ●●●●● patch | view | raw | blame | history
pom.xml
@@ -121,11 +121,6 @@
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.beust</groupId>
            <artifactId>jcommander</artifactId>
            <version>1.76</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.76</version>
@@ -145,6 +140,11 @@
            <artifactId>httpclient</artifactId>
            <version>4.5.13</version>
        </dependency>
        <dependency>
            <groupId>org.modelmapper</groupId>
            <artifactId>modelmapper</artifactId>
            <version>2.4.5</version> <!-- 使用最新版本 -->
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
src/main/java/org/example/ssmico/demos/web/controller/IcoNewCurrencyController.java
@@ -5,24 +5,19 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.example.ssmico.demos.web.entity.IcoNewCurrency;
import org.example.ssmico.demos.web.service.IcoNewCurrencySerivce;
import org.example.ssmico.demos.web.service.IcoOrderService;
import org.example.ssmico.demos.web.util.GoogleTranslateUtil;
import org.example.ssmico.demos.web.util.PageList;
import org.example.ssmico.demos.web.util.DateUtils;
import org.example.ssmico.demos.web.util.ResultObject;
import org.example.ssmico.demos.web.util.ServerResponse;
import org.example.ssmico.demos.web.vo.IcoNewCurrencyVo;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import static cn.hutool.json.XMLTokener.entity;
/**
 * @program: dabao
@@ -39,13 +34,23 @@
    /**
     * 新币添加
     * @param icoNewCurrency
     * @param icoNewCurrencyVo
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/add.action", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public ServerResponse add(IcoNewCurrency icoNewCurrency) {
    public ServerResponse add(@RequestBody IcoNewCurrencyVo icoNewCurrencyVo) {
        try {
            IcoNewCurrency icoNewCurrency = new ModelMapper().map(icoNewCurrencyVo, IcoNewCurrency.class);
            if(StringUtils.isNotBlank(icoNewCurrencyVo.getListingTime())){
                icoNewCurrency.setListingTime(DateUtils.toDateHms(icoNewCurrencyVo.getListingTime()));
            }
            if(StringUtils.isNotBlank(icoNewCurrencyVo.getApplicationStartTime())){
                icoNewCurrency.setApplicationStartTime(DateUtils.toDateHms(icoNewCurrencyVo.getApplicationStartTime()));
            }
            if(StringUtils.isNotBlank(icoNewCurrencyVo.getApplicationEndTime())){
                icoNewCurrency.setApplicationEndTime(DateUtils.toDateHms(icoNewCurrencyVo.getApplicationEndTime()));
            }
            long count = icoNewCurrencySerivce.count(new LambdaQueryWrapper<IcoNewCurrency>()
                    .eq(IcoNewCurrency::getTokenCode,icoNewCurrency.getTokenCode()).eq(IcoNewCurrency::getType,icoNewCurrency.getType()));
@@ -130,13 +135,23 @@
    /**
     * 修改ico
     * @param icoNewCurrency
     * @param icoNewCurrencyVo
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/update.action", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public ServerResponse update(IcoNewCurrency icoNewCurrency,HttpServletRequest request) {
    public ServerResponse update(@RequestBody IcoNewCurrencyVo icoNewCurrencyVo) {
        try {
            IcoNewCurrency icoNewCurrency = new ModelMapper().map(icoNewCurrencyVo, IcoNewCurrency.class);
            if(StringUtils.isNotBlank(icoNewCurrencyVo.getListingTime())){
                icoNewCurrency.setListingTime(DateUtils.toDateHms(icoNewCurrencyVo.getListingTime()));
            }
            if(StringUtils.isNotBlank(icoNewCurrencyVo.getApplicationStartTime())){
                icoNewCurrency.setApplicationStartTime(DateUtils.toDateHms(icoNewCurrencyVo.getApplicationStartTime()));
            }
            if(StringUtils.isNotBlank(icoNewCurrencyVo.getApplicationEndTime())){
                icoNewCurrency.setApplicationEndTime(DateUtils.toDateHms(icoNewCurrencyVo.getApplicationEndTime()));
            }
            long count = icoNewCurrencySerivce.count(new LambdaQueryWrapper<IcoNewCurrency>()
                    .eq(IcoNewCurrency::getTokenCode,icoNewCurrency.getTokenCode())
                    .ne(IcoNewCurrency::getId, icoNewCurrency.getId())
@@ -152,6 +167,17 @@
    }
    /**
     * 获取ICO
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/getById.action", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public ServerResponse<IcoNewCurrency> getById(String id) {
        return ServerResponse.createBySuccess(icoNewCurrencySerivce.getById(id));
    }
    /**
     * 删除ico
     * @param id
     * @return
src/main/java/org/example/ssmico/demos/web/controller/IcoOrderController.java
@@ -221,6 +221,10 @@
        if (null == order) {
            return ServerResponse.createByErrorMsg("当前订单不存在");
        }
        IcoNewCurrency icoNewCurrency = icoNewCurrencyMapper.selectById(order.getIcoNewCurrencyId());
        if(new Date().getTime() >= icoNewCurrency.getListingTime().getTime()){
            return ServerResponse.createByErrorMsg("该币已经上市不能操作中签");
        }
        //判断是认购还是配售
        if(order.getOrderType() == 2){
@@ -234,9 +238,6 @@
            if(null == tWallet){
                return ServerResponse.createByErrorMsg("资金账户不存在");
            }
            IcoNewCurrency icoNewCurrency = icoNewCurrencyMapper.selectById(order.getIcoNewCurrencyId());
            //配售总价
            Double totalPlacingPrice = icoNewCurrency.getIssuePrice()*order.getLotteryQuantity();
            //中签总价
src/main/java/org/example/ssmico/demos/web/util/DateUtils.java
@@ -58,6 +58,10 @@
        return toDate(string, DEFAULT_DATE_FORMAT);
    }
    public static Date toDateHms(String string) {
        return toDate(string, NORMAL_DATE_FORMAT);
    }
    public static Date toDate(String string, String pattern) {
        return toDate(string, pattern, TimeZone.getTimeZone(DEFAULT_TIME_ZONE));
    }
src/main/java/org/example/ssmico/demos/web/vo/IcoNewCurrencyVo.java
New file
@@ -0,0 +1,66 @@
package org.example.ssmico.demos.web.vo;
import lombok.Data;
import java.util.Date;
@Data
public class IcoNewCurrencyVo {
    private Integer id;
    /**
     * 新币名称
     */
    private String newCoinName;
    /**
     * 代币代码
     */
    private String tokenCode;
    /**
     * 发行价
     */
    private Double issuePrice;
    /**
     * 上架状态(0.下架 1.上架)
     */
    private Integer listingStatus;
    /**
     * 类型(1.申购,2.配售)
     */
    private Integer type;
    /**
     * 上市时间
     */
    private String listingTime;
    /**
     * 创建时间
     */
    private String createTime;
    /**
     * 修改时间
     */
    private String modifyTime;
    /**
     * 申购开始时间
     */
    private String applicationStartTime;
    /**
     * 申购结束时间
     */
    private String applicationEndTime;
    /**
     * 交易队
     */
    private String tradingPair;
}