From fd575f1971b145088b56c125f9f3ce3bf2429ebc Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Fri, 14 May 2021 18:41:48 +0800
Subject: [PATCH] Merge branch 'yunding' of http://120.27.238.55:7000/r/exchange into yunding

---
 src/main/resources/mapper/yunding/YdOrderDao.xml                                      |    7 +++
 src/test/java/com/xcong/excoin/XchTest.java                                           |   14 +++++++
 src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java         |   16 ++++----
 src/main/java/com/xcong/excoin/rabbit/consumer/YunDingConsumer.java                   |    6 ++
 src/main/resources/mapper/member/MemberDao.xml                                        |    5 +-
 src/main/java/com/xcong/excoin/modules/coin/parameter/vo/CoinInListVo.java            |    2 
 src/main/java/com/xcong/excoin/modules/yunding/dao/YdOrderDao.java                    |    2 +
 src/main/java/com/xcong/excoin/modules/yunding/service/Impl/XchProfitServiceImpl.java |   11 ++++-
 src/main/resources/application.yml                                                    |    2 
 src/main/java/com/xcong/excoin/modules/yunding/service/Impl/YunDingServiceImpl.java   |    8 +---
 10 files changed, 52 insertions(+), 21 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/CoinInListVo.java b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/CoinInListVo.java
index 7c104b9..9d84ccc 100644
--- a/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/CoinInListVo.java
+++ b/src/main/java/com/xcong/excoin/modules/coin/parameter/vo/CoinInListVo.java
@@ -21,7 +21,7 @@
 	 * 金额
 	 */
 	@ApiModelProperty(value = "金额")
-	private BigDecimal amount;
+	private String 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 b91eb96..6dd5b92 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
@@ -93,7 +93,7 @@
     public Result getWalletCoin() {
         //获取用户ID
         Long memberId = LoginUserUtils.getAppLoginUser().getId();
-//        Long memberId = 446L;
+//        Long memberId = 444L;
         PlatformCnyUsdtExchangeEntity cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne();
         BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
 
@@ -107,10 +107,10 @@
                 for (MemberWalletCoinEntity memberWalletCoinEntity : memberWalletCoinlist) {
                     if ("USDT".equals(memberWalletCoinEntity.getWalletCode()) || "XCH".equals(memberWalletCoinEntity.getWalletCode())) {
                         MemberWalletCoinInfoVo memberWalletCoinInfoVo = new MemberWalletCoinInfoVo();
-                        memberWalletCoinInfoVo.setAvailableBalance(memberWalletCoinEntity.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN));
-                        memberWalletCoinInfoVo.setFrozenBalance(memberWalletCoinEntity.getFrozenBalance().setScale(4, BigDecimal.ROUND_DOWN));
+                        memberWalletCoinInfoVo.setAvailableBalance(memberWalletCoinEntity.getAvailableBalance().setScale(8, BigDecimal.ROUND_DOWN));
+                        memberWalletCoinInfoVo.setFrozenBalance(memberWalletCoinEntity.getFrozenBalance().setScale(8, BigDecimal.ROUND_DOWN));
                         memberWalletCoinInfoVo.setMemberId(memberWalletCoinEntity.getMemberId());
-                        memberWalletCoinInfoVo.setTotalBalance(memberWalletCoinEntity.getTotalBalance().setScale(4, BigDecimal.ROUND_DOWN));
+                        memberWalletCoinInfoVo.setTotalBalance(memberWalletCoinEntity.getTotalBalance().setScale(8, BigDecimal.ROUND_DOWN));
                         memberWalletCoinInfoVo.setWalletCode(memberWalletCoinEntity.getWalletCode());
                         memberWalletCoinInfoVolist.add(memberWalletCoinInfoVo);
                     }
@@ -1035,7 +1035,7 @@
     			for(MemberCoinChargeEntity memberCoinChargeEntitys : records) {
     				CoinInListVo coinInListVo = new CoinInListVo();
     				coinInListVo.setSymbol(memberCoinChargeEntitys.getSymbol());
-    				coinInListVo.setAmount(memberCoinChargeEntitys.getAmount());
+    				coinInListVo.setAmount(memberCoinChargeEntitys.getAmount().toPlainString());
     				coinInListVo.setContent("充币");
     				coinInListVo.setStatus(memberCoinChargeEntitys.getStatus());
     				coinInListVo.setUpdateTime(memberCoinChargeEntitys.getUpdateTime());
@@ -1059,7 +1059,7 @@
     			for(MemberCoinWithdrawEntity memberCoinWithdrawEntitys : records) {
     				CoinInListVo coinInListVo = new CoinInListVo();
     				coinInListVo.setSymbol(memberCoinWithdrawEntitys.getSymbol());
-    				coinInListVo.setAmount(memberCoinWithdrawEntitys.getAmount());
+    				coinInListVo.setAmount(memberCoinWithdrawEntitys.getAmount().toPlainString());
     				coinInListVo.setContent("提币");
     				int status = memberCoinWithdrawEntitys.getStatus();
     				int statusOut = 0;
@@ -1095,7 +1095,7 @@
     			for(MemberAccountMoneyChange memberAccountMoneyChanges : records) {
     				CoinInListVo coinInListVo = new CoinInListVo();
     				coinInListVo.setSymbol(memberAccountMoneyChanges.getSymbol());
-    				coinInListVo.setAmount(memberAccountMoneyChanges.getAmount());
+    				coinInListVo.setAmount(memberAccountMoneyChanges.getAmount().toPlainString());
     				coinInListVo.setContent(memberAccountMoneyChanges.getContent());
     				coinInListVo.setStatus(memberAccountMoneyChanges.getStatus());
     				coinInListVo.setUpdateTime(memberAccountMoneyChanges.getUpdateTime());
@@ -1119,7 +1119,7 @@
     			for(MemberAccountMoneyChange memberAccountMoneyChanges : records) {
     				CoinInListVo coinInListVo = new CoinInListVo();
     				coinInListVo.setSymbol(memberAccountMoneyChanges.getSymbol());
-    				coinInListVo.setAmount(memberAccountMoneyChanges.getAmount());
+    				coinInListVo.setAmount(memberAccountMoneyChanges.getAmount().toPlainString());
     				coinInListVo.setContent(memberAccountMoneyChanges.getContent());
     				coinInListVo.setStatus(memberAccountMoneyChanges.getStatus());
     				coinInListVo.setUpdateTime(memberAccountMoneyChanges.getUpdateTime());
diff --git a/src/main/java/com/xcong/excoin/modules/yunding/dao/YdOrderDao.java b/src/main/java/com/xcong/excoin/modules/yunding/dao/YdOrderDao.java
index 3d7d628..3ae4c38 100644
--- a/src/main/java/com/xcong/excoin/modules/yunding/dao/YdOrderDao.java
+++ b/src/main/java/com/xcong/excoin/modules/yunding/dao/YdOrderDao.java
@@ -30,4 +30,6 @@
     IPage<AgentVo> getAgentList(Page<AgentVo> page, @Param("record")  YdBasicLevelSettingEntity ydBasicLevelSettingEntity);
 
     List<YdOrderEntity> selectTeamAllPower(@Param("inviteId") String inviteId);
+
+    int updateOrderProfit(@Param("profit") BigDecimal profit, @Param("id") Long id);
 }
diff --git a/src/main/java/com/xcong/excoin/modules/yunding/service/Impl/XchProfitServiceImpl.java b/src/main/java/com/xcong/excoin/modules/yunding/service/Impl/XchProfitServiceImpl.java
index 8b530e4..e4422bd 100644
--- a/src/main/java/com/xcong/excoin/modules/yunding/service/Impl/XchProfitServiceImpl.java
+++ b/src/main/java/com/xcong/excoin/modules/yunding/service/Impl/XchProfitServiceImpl.java
@@ -16,6 +16,7 @@
 import com.xcong.excoin.modules.yunding.entity.YdOrderEntity;
 import com.xcong.excoin.modules.yunding.entity.YdProductEntity;
 import com.xcong.excoin.modules.yunding.service.XchProfitService;
+import com.xcong.excoin.rabbit.producer.YunDingProducter;
 import com.xcong.excoin.utils.LogRecordUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -44,6 +45,9 @@
     @Autowired
     private YdBasicLevelSettingDao ydBasicLevelSettingDao;
 
+    @Autowired
+    private YunDingProducter yunDingProducter;
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void autoBeAgent(Long id) {
@@ -68,7 +72,7 @@
                         update.setAgentLevel(2);
                         memberDao.updateById(update);
                     }
-                } else if (memberEntity.getAgentLevel() != null && member.getAgentLevel() == 2){
+                } else if (memberEntity.getAgentLevel() != null && memberEntity.getAgentLevel() == 2){
                     // 判断是否达到总代标准
                     if(becomeZd(memberEntity, settings.get(0))) {
                         update.setAgentLevel(1);
@@ -147,6 +151,8 @@
     public void usdtProfitDistributorByOrderId(Long id) {
         YdOrderEntity ydOrderEntity = ydOrderDao.selectById(id);
         usdtProfitDistributor(ydOrderEntity);
+
+        yunDingProducter.sendYunDingAutoAgent(ydOrderEntity.getMemberId());
     }
 
     private void usdtProfitDistributor(YdOrderEntity order) {
@@ -257,11 +263,12 @@
                         }
                     }
 
-                    remainProfit = remainProfit.subtract(orderProfit.subtract(orderProfit.multiply(order.getYdProductEntity().getManageExpense())));
+                    remainProfit = remainProfit.subtract(orderProfit.multiply(order.getYdProductEntity().getManageExpense()));
                     String content = "XCH收益";
                     LogRecordUtils.insertMemberAccountMoneyChangeWithId(order.getMemberId(), content, remainProfit, "XCH", 1, 4, order.getId());
                     MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(order.getMemberId(), "XCH");
 
+                    ydOrderDao.updateOrderProfit(remainProfit, order.getId());
                     memberWalletCoinDao.updateBlockBalance(walletCoin.getId(), remainProfit, BigDecimal.ZERO, 0);
                 }
             }
diff --git a/src/main/java/com/xcong/excoin/modules/yunding/service/Impl/YunDingServiceImpl.java b/src/main/java/com/xcong/excoin/modules/yunding/service/Impl/YunDingServiceImpl.java
index 17f2ddc..12d3ea6 100644
--- a/src/main/java/com/xcong/excoin/modules/yunding/service/Impl/YunDingServiceImpl.java
+++ b/src/main/java/com/xcong/excoin/modules/yunding/service/Impl/YunDingServiceImpl.java
@@ -109,7 +109,7 @@
             for(YdProductVo ydProductVo : records){
                 ydProductVo.setProfitT(prifitT);
 
-                if(ydProductVo.getTotalT().compareTo(BigDecimal.ZERO) < 1) {
+                if(ydProductVo.getSurplusT().compareTo(BigDecimal.ZERO) < 1) {
                     ydProductVo.setStatus(2);
                 }
             }
@@ -148,10 +148,8 @@
         Date endTime = DateUtil.offsetDay(workTime, proCycle);
         ydProductVo.setEndTime(endTime);
 
-        if (ydProductVo.getTotalT().compareTo(BigDecimal.ZERO) < 1) {
+        if (ydProductVo.getSurplusT().compareTo(BigDecimal.ZERO) < 1) {
             ydProductVo.setStatus(2);
-        } else {
-            ydProductVo.setStatus(1);
         }
         return Result.ok(ydProductVo);
     }
@@ -282,7 +280,6 @@
                 "USDT", 1, 3, ydOrderEntity.getId());
 
         yunDingProducter.sendYunDingUsdtProfit(ydOrderEntity.getId());
-        yunDingProducter.sendYunDingAutoAgent(ydOrderEntity.getMemberId());
         return Result.ok("支付成功");
     }
 
@@ -587,7 +584,6 @@
 
         memberEntity.setAgentLevel(id.intValue());
         LoginUserUtils.resetAppLoginUser(memberEntity);
-        yunDingProducter.sendYunDingAutoAgent(memberId);
         yunDingProducter.sendYunDingUsdtProfit(orderEntity.getId());
         return Result.ok("购买成功");
     }
diff --git a/src/main/java/com/xcong/excoin/rabbit/consumer/YunDingConsumer.java b/src/main/java/com/xcong/excoin/rabbit/consumer/YunDingConsumer.java
index 165ef91..7a1ffda 100644
--- a/src/main/java/com/xcong/excoin/rabbit/consumer/YunDingConsumer.java
+++ b/src/main/java/com/xcong/excoin/rabbit/consumer/YunDingConsumer.java
@@ -29,7 +29,11 @@
     public void xchAutoAgent(Message message, Channel channel) {
         String content = new String(message.getBody());
         log.info("自动升级代理消息 : {}", content);
-        xchProfitService.autoBeAgent(Long.parseLong(content));
+        try {
+            xchProfitService.autoBeAgent(Long.parseLong(content));
+        } catch (Exception e) {
+            log.info("错误",e);
+        }
     }
 
 
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 8a1f6b0..caf8860 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -108,7 +108,7 @@
   rabbit-consumer: false
   block-job: false
   xch-job: false
-  yunding-consumer: true
+  yunding-consumer: false
 
 aliyun:
   oss:
diff --git a/src/main/resources/mapper/member/MemberDao.xml b/src/main/resources/mapper/member/MemberDao.xml
index 056f168..7c11538 100644
--- a/src/main/resources/mapper/member/MemberDao.xml
+++ b/src/main/resources/mapper/member/MemberDao.xml
@@ -56,13 +56,14 @@
         <association property="ydBasicLevelSettingEntity" javaType="com.xcong.excoin.modules.yunding.entity.YdBasicLevelSettingEntity">
             <result property="level" column="level"/>
             <result property="usdtRatio" column="usdt_ratio" />
+            <result property="xchRatio" column="xch_ratio" />
         </association>
     </resultMap>
 
     <select id="selectYdParentAgent" resultMap="memberAgentMap">
-        select a.*, b.level, b.usdt_ratio from member a
+        select a.*, b.level, b.usdt_ratio, b.xch_ratio from member a
         inner join yd_basic_level_setting b on a.agent_level=b.id
-        where a.invite_id in
+        where a.invite_id!='rxadr3' and a.invite_id in
         <foreach collection = "list" item = "item"  separator=","  open = "(" close = ")" >
             #{item}
         </foreach >
diff --git a/src/main/resources/mapper/yunding/YdOrderDao.xml b/src/main/resources/mapper/yunding/YdOrderDao.xml
index 3075f61..b74d39f 100644
--- a/src/main/resources/mapper/yunding/YdOrderDao.xml
+++ b/src/main/resources/mapper/yunding/YdOrderDao.xml
@@ -96,4 +96,11 @@
         inner join yd_product c on c.id = a.product_id
         where a.type=1
     </select>
+
+    <update id="updateOrderProfit">
+        update yd_order
+            set total_profit=total_profit+#{profit},
+                today_profit=#{profit}
+        where id=#{id}
+    </update>
 </mapper>
\ No newline at end of file
diff --git a/src/test/java/com/xcong/excoin/XchTest.java b/src/test/java/com/xcong/excoin/XchTest.java
index 611af9d..f7497fa 100644
--- a/src/test/java/com/xcong/excoin/XchTest.java
+++ b/src/test/java/com/xcong/excoin/XchTest.java
@@ -3,6 +3,8 @@
 
 import cn.hutool.core.date.DateUnit;
 import cn.hutool.core.date.DateUtil;
+import com.xcong.excoin.modules.coin.parameter.dto.CoinInListDto;
+import com.xcong.excoin.modules.coin.service.CoinService;
 import com.xcong.excoin.modules.yunding.dao.YdOrderDao;
 import com.xcong.excoin.modules.yunding.entity.YdOrderEntity;
 import com.xcong.excoin.modules.yunding.service.XchProfitService;
@@ -65,4 +67,16 @@
     public void xchProfitTest() {
         xchProfitService.xchProfitDistributor(BigDecimal.valueOf(1));
     }
+
+    @Autowired
+    private CoinService coinService;
+
+    @Test
+    public void coinTest() {
+        CoinInListDto coin = new CoinInListDto();
+        coin.setType(4);
+        coin.setPageNum(1);
+        coin.setPageSize(10);
+        coinService.coinInList(coin);
+    }
 }

--
Gitblit v1.9.1