From fbcab0b620a393bc89e3760dd702aab874d94269 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Tue, 15 Jun 2021 15:40:59 +0800 Subject: [PATCH] modify --- src/main/java/com/xcong/excoin/modules/coin/controller/GbzOrderController.java | 20 +++++++--- pom.xml | 69 +++++++++++++++++++++++++++++++--- src/main/resources/application.yml | 10 ++-- 3 files changed, 82 insertions(+), 17 deletions(-) diff --git a/pom.xml b/pom.xml index 548b59a..949ddab 100644 --- a/pom.xml +++ b/pom.xml @@ -2,17 +2,17 @@ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <groupId>com.xcong</groupId> + <artifactId>excoin</artifactId> + <version>gbz</version> + <name>excoin</name> + <description>Demo project for Spring Boot</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.6.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> - <groupId>com.xcong</groupId> - <artifactId>excoin</artifactId> - <version>gbz</version> - <name>excoin</name> - <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> @@ -108,13 +108,22 @@ <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> - <scope>test</scope> +<!-- <scope>test</scope>--> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> + <exclusion> + <artifactId>asm</artifactId> + <groupId>org.ow2.asm</groupId> + </exclusion> </exclusions> + </dependency> + + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-test</artifactId> </dependency> <dependency> @@ -126,6 +135,16 @@ <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>${mybatis-plus.version}</version> + <exclusions> + <exclusion> + <artifactId>mybatis</artifactId> + <groupId>org.mybatis</groupId> + </exclusion> + <exclusion> + <artifactId>mybatis-spring</artifactId> + <groupId>org.mybatis</groupId> + </exclusion> + </exclusions> </dependency> <dependency> @@ -150,6 +169,12 @@ <groupId>org.web3j</groupId> <artifactId>parity</artifactId> <version>4.5.10</version> + <exclusions> + <exclusion> + <artifactId>core</artifactId> + <groupId>org.web3j</groupId> + </exclusion> + </exclusions> </dependency> <!-- 参数校验 start --> @@ -171,6 +196,20 @@ <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>${swagger.version}</version> + <exclusions> + <exclusion> + <artifactId>mapstruct</artifactId> + <groupId>org.mapstruct</groupId> + </exclusion> + <exclusion> + <artifactId>swagger-annotations</artifactId> + <groupId>io.swagger</groupId> + </exclusion> + <exclusion> + <artifactId>swagger-models</artifactId> + <groupId>io.swagger</groupId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>io.swagger</groupId> @@ -275,6 +314,24 @@ <artifactId>json-lib</artifactId> <version>2.2.3</version> <classifier>jdk15</classifier> + <exclusions> + <exclusion> + <artifactId>commons-logging</artifactId> + <groupId>commons-logging</groupId> + </exclusion> + <exclusion> + <artifactId>commons-collections</artifactId> + <groupId>commons-collections</groupId> + </exclusion> + <exclusion> + <artifactId>commons-lang</artifactId> + <groupId>commons-lang</groupId> + </exclusion> + <exclusion> + <artifactId>ezmorph</artifactId> + <groupId>net.sf.ezmorph</groupId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> diff --git a/src/main/java/com/xcong/excoin/modules/coin/controller/GbzOrderController.java b/src/main/java/com/xcong/excoin/modules/coin/controller/GbzOrderController.java index 73d6f78..13677f2 100644 --- a/src/main/java/com/xcong/excoin/modules/coin/controller/GbzOrderController.java +++ b/src/main/java/com/xcong/excoin/modules/coin/controller/GbzOrderController.java @@ -14,6 +14,7 @@ import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao; import com.xcong.excoin.modules.member.entity.MemberEntity; import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity; +import com.xcong.excoin.utils.LogRecordUtils; import com.xcong.excoin.utils.RedisUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -21,6 +22,7 @@ import io.swagger.annotations.ApiResponses; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -44,6 +46,7 @@ @ApiOperation(value = "新增订单", notes = "新增订单") @PostMapping(value = "/add") + @Transactional(rollbackFor = Exception.class) public Result add(@RequestBody GbzAddDto gbzAddDto) { String status = redisUtils.getString("bzz_order_status"); if ("1".equals(status)) { @@ -53,6 +56,12 @@ MemberEntity loginUser = LoginUserUtils.getAppLoginUser(); BigDecimal price = new BigDecimal(66); BigDecimal amount = BigDecimal.valueOf(gbzAddDto.getCount()).multiply(price); + + MemberWalletCoinEntity wallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(loginUser.getId(), CoinTypeEnum.USDT.name()); + if (amount.compareTo(wallet.getAvailableBalance()) > 0) { + return Result.fail("可用金额不足"); + } + GbzOrderEntity gbzOrder = new GbzOrderEntity(); gbzOrder.setPrice(price); gbzOrder.setAmount(amount); @@ -63,12 +72,9 @@ gbzOrderDao.insert(gbzOrder); - MemberWalletCoinEntity wallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(loginUser.getId(), CoinTypeEnum.USDT.name()); - if (amount.compareTo(wallet.getAvailableBalance()) < 0) { - return Result.fail("可用金额不足"); - } - memberWalletCoinDao.updateBlockBalance(wallet.getId(), amount.negate(), BigDecimal.ZERO, 0); + + LogRecordUtils.insertMemberAccountMoneyChange(loginUser.getId(), "购买BZZ", amount, "USDT", 1, 1); return Result.ok("购买成功"); } @@ -115,8 +121,10 @@ return Result.fail("无可提取金额"); } - MemberWalletCoinEntity wallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(member.getId(), CoinTypeEnum.BZZ.name()); + MemberWalletCoinEntity wallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(member.getId(), CoinTypeEnum + .BZZ.name()); memberWalletCoinDao.updateBlockBalance(wallet.getId(), totalAmount, BigDecimal.ZERO, 0); + LogRecordUtils.insertMemberAccountMoneyChange(member.getId(), "提取BZZ到资产", totalAmount, "BZZ", 1, 1); return Result.ok("提取成功"); } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 7743f81..93780de 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -91,16 +91,16 @@ app: - debug: false + debug: true redis_expire: 3000 kline-update-job: false - newest-price-update-job: true - exchange-trade: true + newest-price-update-job: false + exchange-trade: false day-line: false - other-job: true + other-job: false loop-job: false rabbit-consumer: false - block-job: true + block-job: false aliyun: oss: -- Gitblit v1.9.1