From c58b804688f17bfb97532c8b9da0fcb1b77b58bb Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Fri, 22 May 2020 14:56:00 +0800
Subject: [PATCH] 202020522   修改

---
 src/main/java/com/xcong/excoin/modules/coin/controller/CoinController.java       |   24 ------------
 src/main/java/com/xcong/excoin/modules/coin/entity/MemberAccountMoneyChange.java |    8 ---
 src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletContractDao.java   |    4 +-
 src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java    |   49 +++++++-----------------
 src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletAgentDao.java      |    4 +
 src/main/java/com/xcong/excoin/modules/coin/dao/MemberAccountMoneyChangeDao.java |    6 ++-
 src/main/java/com/xcong/excoin/modules/coin/entity/CnyUsdtExchange.java          |    1 
 src/main/resources/mapper/member/MemberWalletAgentDao.xml                        |    4 +-
 src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletCoinDao.java       |    4 +
 9 files changed, 30 insertions(+), 74 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/modules/coin/controller/CoinController.java b/src/main/java/com/xcong/excoin/modules/coin/controller/CoinController.java
index f1bfdbc..dfeea1f 100644
--- a/src/main/java/com/xcong/excoin/modules/coin/controller/CoinController.java
+++ b/src/main/java/com/xcong/excoin/modules/coin/controller/CoinController.java
@@ -153,35 +153,11 @@
 	 */
 	@ApiOperation(value="代理账户划转到USDT账户", notes="代理账户划转到USDT账户")
 	@PostMapping(value="/agentTransferToWalletCoin")
-	@ApiImplicitParam(name = "token", value = "token", required = true, dataType = "String", paramType = "body")
 	public Result  agentTransferToWalletCoin(@RequestBody @Valid TransferOfBalanceDto transferOfBalanceDto) {
 		BigDecimal balance = transferOfBalanceDto.getBalance();
 		Integer transfertype = transferOfBalanceDto.getTransfertype();
 		return coinService.agentTransferToWalletCoin(balance,transfertype);
 	}
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
 	
 
 }
diff --git a/src/main/java/com/xcong/excoin/modules/coin/dao/MemberAccountMoneyChangeDao.java b/src/main/java/com/xcong/excoin/modules/coin/dao/MemberAccountMoneyChangeDao.java
index ff1c2fc..f85e85b 100644
--- a/src/main/java/com/xcong/excoin/modules/coin/dao/MemberAccountMoneyChangeDao.java
+++ b/src/main/java/com/xcong/excoin/modules/coin/dao/MemberAccountMoneyChangeDao.java
@@ -2,6 +2,8 @@
 
 import java.util.List;
 
+import org.apache.ibatis.annotations.Param;
+
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange;
 
@@ -9,8 +11,8 @@
 
 	List<MemberAccountMoneyChange> selectWalletCoinRecordsByMemIdTypeSymbol(Long memberId);
 
-	List<MemberAccountMoneyChange> selectWalletContractRecordsByMemIdTypeSymbol(String symbol, Long memberId);
+	List<MemberAccountMoneyChange> selectWalletContractRecordsByMemIdTypeSymbol(@Param("symbol")String symbol, @Param("memberId")Long memberId);
 
-	List<MemberAccountMoneyChange> selectWalletAgentRecordByMemIdTypeSymbol(String symbol, Long memberId);
+	List<MemberAccountMoneyChange> selectWalletAgentRecordByMemIdTypeSymbol(@Param("symbol")String symbol, @Param("memberId")Long memberId);
 
 }
diff --git a/src/main/java/com/xcong/excoin/modules/coin/entity/CnyUsdtExchange.java b/src/main/java/com/xcong/excoin/modules/coin/entity/CnyUsdtExchange.java
index 4c3f99d..76089b7 100644
--- a/src/main/java/com/xcong/excoin/modules/coin/entity/CnyUsdtExchange.java
+++ b/src/main/java/com/xcong/excoin/modules/coin/entity/CnyUsdtExchange.java
@@ -16,7 +16,6 @@
 
 	private static final long serialVersionUID = 1L;
 	
-	private Long id;
     /**
      * CNY/USDT
      */
diff --git a/src/main/java/com/xcong/excoin/modules/coin/entity/MemberAccountMoneyChange.java b/src/main/java/com/xcong/excoin/modules/coin/entity/MemberAccountMoneyChange.java
index 8a893f9..5510661 100644
--- a/src/main/java/com/xcong/excoin/modules/coin/entity/MemberAccountMoneyChange.java
+++ b/src/main/java/com/xcong/excoin/modules/coin/entity/MemberAccountMoneyChange.java
@@ -27,8 +27,6 @@
     public static final Integer STATUS_SUCCESS_INTEGER = 1;
     public static final Integer STATUS_FAIL_INTEGER = 2;
     
-    private Long id;
-	
 	private Long memberId;
 	
 	/**
@@ -39,11 +37,7 @@
 	/**
 	 * 金额
 	 */
-	private BigDecimal price;
-	/**
-	 * 时间
-	 */
-	private Date time;
+	private BigDecimal amount;
 	/**
 	 * 记录内容
 	 */
diff --git a/src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java b/src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java
index f5ff2fb..3ddaaeb 100644
--- a/src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java
+++ b/src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java
@@ -16,6 +16,7 @@
 import com.xcong.excoin.common.LoginUserUtils;
 import com.xcong.excoin.common.enumerates.CoinTypeEnum;
 import com.xcong.excoin.common.enumerates.MemberWalletCoinEnum;
+import com.xcong.excoin.common.exception.GlobalException;
 import com.xcong.excoin.common.response.Result;
 import com.xcong.excoin.modules.coin.dao.MemberAccountMoneyChangeDao;
 import com.xcong.excoin.modules.coin.dao.platform.CnyUsdtExchangeDao;
@@ -155,9 +156,8 @@
 	}
 
 	@Override
-	@Transactional
+	@Transactional(rollbackFor = Exception.class)
 	public Result coinWalletTransferToContract(BigDecimal balance, String symbol) {
-		try {
 			if(balance.compareTo(BigDecimal.ZERO) <= 0) {
 				return Result.fail(MessageSourceUtils.getString("member_service_0004"));
 			}
@@ -200,31 +200,25 @@
 				MemberAccountMoneyChange memberAccountRecord = new MemberAccountMoneyChange();
 				memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTTOCONTRACT.getValue());
 				memberAccountRecord.setMemberId(memberId);
-				memberAccountRecord.setPrice(balance.negate().setScale(4, BigDecimal.ROUND_DOWN));
+				memberAccountRecord.setAmount(balance.negate().setScale(4, BigDecimal.ROUND_DOWN));
 				memberAccountRecord.setStatus(MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER);
 				memberAccountRecord.setSymbol(MemberWalletCoinEnum.WALLETCOINCODE.getValue());
 				memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_COIN);
-				memberAccountRecord.setTime(new Date());
 				memberAccountMoneyChangeDao.insert(memberAccountRecord);
 				
 				//添加合约资金划转历史记录
 				memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTFROMWALLETCOIN.getValue());
 				memberAccountRecord.setSymbol(MemberWalletCoinEnum.WALLETCOINCODE.getValue());
-				memberAccountRecord.setPrice(balance.setScale(4, BigDecimal.ROUND_DOWN));
+				memberAccountRecord.setAmount(balance.setScale(4, BigDecimal.ROUND_DOWN));
 				memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_CONTRACT);
 				memberAccountMoneyChangeDao.insert(memberAccountRecord);
 			}
-		} catch (Exception e) {
-			e.printStackTrace();
-			return Result.fail(MessageSourceUtils.getString("member_service_0096"));
-		}
 		return Result.ok(MessageSourceUtils.getString("member_service_0006"));
 	}
 
 	@Override
-	@Transactional
+	@Transactional(rollbackFor = Exception.class)
 	public Result contractTransferToWalletCoin(BigDecimal balance, String symbol) {
-		try {
 			if(balance.compareTo(BigDecimal.ZERO)<=0){
 				return Result.fail(MessageSourceUtils.getString("member_service_0004"));
 			}
@@ -251,12 +245,12 @@
 			// 加币
 			MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, walletCode);
 			BigDecimal walletCoinAvailableBalance = walletCoin.getAvailableBalance();
-			walletCoinAvailableBalance.add(balance);
+			BigDecimal CoinAvailableBalance = walletCoinAvailableBalance.add(balance);
 			BigDecimal walletCoinTotalBalance = walletCoin.getTotalBalance();
-			walletCoinTotalBalance.add(balance);
+			BigDecimal CoinTotalBalance = walletCoinTotalBalance.add(balance);
 			
-			walletCoin.setAvailableBalance(walletCoinAvailableBalance.setScale(4, BigDecimal.ROUND_DOWN));
-			walletCoin.setTotalBalance(walletCoinTotalBalance.setScale(4, BigDecimal.ROUND_DOWN));
+			walletCoin.setAvailableBalance(CoinAvailableBalance.setScale(4, BigDecimal.ROUND_DOWN));
+			walletCoin.setTotalBalance(CoinTotalBalance.setScale(4, BigDecimal.ROUND_DOWN));
 			int updateById = memberWalletCoinDao.updateById(walletCoin);
 			if(updateById < 1) {
 				return Result.fail(MessageSourceUtils.getString("member_service_0096"));
@@ -266,23 +260,18 @@
 			MemberAccountMoneyChange memberAccountRecord = new MemberAccountMoneyChange();
 			memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTTOWALLETCOIN.getValue());
 			memberAccountRecord.setMemberId(memberId);
-			memberAccountRecord.setPrice(balance.negate().setScale(4, BigDecimal.ROUND_DOWN));
+			memberAccountRecord.setAmount(balance.negate().setScale(4, BigDecimal.ROUND_DOWN));
 			memberAccountRecord.setStatus(MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER);
 			memberAccountRecord.setSymbol(walletCode);
 			memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_CONTRACT);
-			memberAccountRecord.setTime(new Date());
 			memberAccountMoneyChangeDao.insert(memberAccountRecord);
 			
 			//添加资金划转历史记录
 			memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTFROMCONTRACT.getValue());
 			memberAccountRecord.setSymbol(walletCode);
 			memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_COIN);
-			memberAccountRecord.setPrice(balance.setScale(4, BigDecimal.ROUND_DOWN));
+			memberAccountRecord.setAmount(balance.setScale(4, BigDecimal.ROUND_DOWN));
 			memberAccountMoneyChangeDao.insert(memberAccountRecord);
-		} catch (Exception e) {
-			e.printStackTrace();
-			return Result.fail(MessageSourceUtils.getString("member_service_0096"));
-		}
 		return Result.ok(MessageSourceUtils.getString("member_service_0006"));
 	}
 
@@ -334,9 +323,8 @@
 	}
 
 	@Override
-	@Transactional
+	@Transactional(rollbackFor = Exception.class)
 	public Result agentTransferToWalletCoin(BigDecimal balance, Integer transfertype) {
-		try {
 			if(balance.compareTo(BigDecimal.ZERO) <= 0) {
 				return Result.fail(MessageSourceUtils.getString("member_service_0004"));
 			}
@@ -386,8 +374,7 @@
 				memberAccountRecord.setSymbol(walletCode);
 				memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTFROMAGENT.getValue());
 				memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_COIN);
-				memberAccountRecord.setTime(new Date());
-				memberAccountRecord.setPrice(balance.setScale(4, BigDecimal.ROUND_DOWN));
+				memberAccountRecord.setAmount(balance.setScale(4, BigDecimal.ROUND_DOWN));
 				memberAccountMoneyChangeDao.insert(memberAccountRecord);
 				memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTTOWALLETCOIN.getValue());
 				
@@ -411,20 +398,14 @@
 				memberAccountRecord.setSymbol(walletCode);
 				memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTFROMAGENT.getValue());
 				memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_CONTRACT);
-				memberAccountRecord.setTime(new Date());
-				memberAccountRecord.setPrice(balance.setScale(4, BigDecimal.ROUND_DOWN));
+				memberAccountRecord.setAmount(balance.setScale(4, BigDecimal.ROUND_DOWN));
 				memberAccountMoneyChangeDao.insert(memberAccountRecord);
 				memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTTOCONTRACT.getValue());
 			}
-			memberAccountRecord.setPrice(balance.negate().setScale(4, BigDecimal.ROUND_DOWN));
+			memberAccountRecord.setAmount(balance.negate().setScale(4, BigDecimal.ROUND_DOWN));
 			memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_AGENT);
-			memberAccountRecord.setTime(new Date());
 			memberAccountMoneyChangeDao.insert(memberAccountRecord);
 			
-		} catch (Exception e) {
-			e.printStackTrace();
-			return Result.fail(MessageSourceUtils.getString("member_service_0096"));
-		}
 		return Result.ok(MessageSourceUtils.getString("member_service_0006"));
 	}
 
diff --git a/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletAgentDao.java b/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletAgentDao.java
index f1b83f5..595a570 100644
--- a/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletAgentDao.java
+++ b/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletAgentDao.java
@@ -1,10 +1,12 @@
 package com.xcong.excoin.modules.member.dao;
 
+import org.apache.ibatis.annotations.Param;
+
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.xcong.excoin.modules.member.entity.MemberWalletAgentEntity;
 
 public interface MemberWalletAgentDao extends BaseMapper<MemberWalletAgentEntity> {
 
-	MemberWalletAgentEntity selectWalletAgentBymIdAndCode(Long memberId, String walletCode);
+	MemberWalletAgentEntity selectWalletAgentBymIdAndCode(@Param("memberId")Long memberId,@Param("walletCode")String walletCode);
 	
 }
diff --git a/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletCoinDao.java b/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletCoinDao.java
index ba65eee..f5f3927 100644
--- a/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletCoinDao.java
+++ b/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletCoinDao.java
@@ -2,6 +2,8 @@
 
 import java.util.List;
 
+import org.apache.ibatis.annotations.Param;
+
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
 
@@ -12,6 +14,6 @@
 
 	List<MemberWalletCoinEntity> selectMemberWalletCoinsByMemberId(Long memberId);
 	
-	MemberWalletCoinEntity selectWalletCoinBymIdAndCode(Long memberId,String walletCode);
+	MemberWalletCoinEntity selectWalletCoinBymIdAndCode(@Param("memberId")Long memberId,@Param("walletCode")String walletCode);
 	
 }
diff --git a/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletContractDao.java b/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletContractDao.java
index ceabe18..72e03bf 100644
--- a/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletContractDao.java
+++ b/src/main/java/com/xcong/excoin/modules/member/dao/MemberWalletContractDao.java
@@ -1,12 +1,12 @@
 package com.xcong.excoin.modules.member.dao;
 
-import org.springframework.transaction.annotation.Transactional;
+import org.apache.ibatis.annotations.Param;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.xcong.excoin.modules.member.entity.MemberWalletContractEntity;
 
 public interface MemberWalletContractDao extends BaseMapper<MemberWalletContractEntity> {
 	
-	MemberWalletContractEntity findWalletContractByMemberIdAndSymbol(Long memberId, String symbol);
+	MemberWalletContractEntity findWalletContractByMemberIdAndSymbol(@Param("memberId")Long memberId, @Param("symbol")String symbol);
 	
 }
diff --git a/src/main/resources/mapper/member/MemberWalletAgentDao.xml b/src/main/resources/mapper/member/MemberWalletAgentDao.xml
index c898b37..a6415ff 100644
--- a/src/main/resources/mapper/member/MemberWalletAgentDao.xml
+++ b/src/main/resources/mapper/member/MemberWalletAgentDao.xml
@@ -2,8 +2,8 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.xcong.excoin.modules.member.dao.MemberWalletAgentDao">
 
-	<select id="selectWalletAgentBymIdAndCode" resultMap="com.xcong.excoin.modules.member.entity.MemberWalletAgentEntity">
-		select * from member_wallet_agent where member_id=#{memberId} and wallet_code = #{walletCode}
+	<select id="selectWalletAgentBymIdAndCode" resultType="com.xcong.excoin.modules.member.entity.MemberWalletAgentEntity">
+		select * from member_wallet_agent where member_id = #{memberId} and wallet_code = #{walletCode}
 	</select>
 
 

--
Gitblit v1.9.1