From 4ba5a3ee3263d329b3395c855df6123366a16660 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Tue, 20 Jun 2023 16:02:58 +0800
Subject: [PATCH] IM后台

---
 src/main/java/cc/mrbird/febs/mall/service/impl/AdminChatServiceImpl.java |   16 +++++++
 src/test/java/cc/mrbird/febs/ProfitTest.java                             |   32 +++++++++++-----
 src/main/java/cc/mrbird/febs/mall/entity/ChatAmountFlow.java             |   53 ++++++++++++++++++++++++++
 src/main/java/cc/mrbird/febs/mall/mapper/ChatAmountFlowMapper.java       |    7 +++
 4 files changed, 97 insertions(+), 11 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/mall/entity/ChatAmountFlow.java b/src/main/java/cc/mrbird/febs/mall/entity/ChatAmountFlow.java
new file mode 100644
index 0000000..bcfb5ec
--- /dev/null
+++ b/src/main/java/cc/mrbird/febs/mall/entity/ChatAmountFlow.java
@@ -0,0 +1,53 @@
+package cc.mrbird.febs.mall.entity;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+@TableName("chat_amount_flow")
+public class ChatAmountFlow {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @TableId
+    private Long id;
+    /**
+     * 1:充值 2:提现 3:红包 4:转账 5:创建群聊
+     */
+    private Integer type;
+    /**
+     * 金额
+     */
+    private BigDecimal amount;
+    /**
+     * 用户ID
+     */
+    private Long userId;
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+    /**
+     * 当前余额
+     */
+    private BigDecimal avaAmount;
+    /**
+     * 1 :成功 2:失败 3:进行中
+     */
+    private Integer state;
+    /**
+     * 关联ID
+     */
+    private Long relationId;
+    /**
+     * 说明
+     */
+    private String remark;
+}
diff --git a/src/main/java/cc/mrbird/febs/mall/mapper/ChatAmountFlowMapper.java b/src/main/java/cc/mrbird/febs/mall/mapper/ChatAmountFlowMapper.java
new file mode 100644
index 0000000..dfc3c75
--- /dev/null
+++ b/src/main/java/cc/mrbird/febs/mall/mapper/ChatAmountFlowMapper.java
@@ -0,0 +1,7 @@
+package cc.mrbird.febs.mall.mapper;
+
+import cc.mrbird.febs.mall.entity.ChatAmountFlow;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+public interface ChatAmountFlowMapper extends BaseMapper<ChatAmountFlow> {
+}
diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/AdminChatServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/AdminChatServiceImpl.java
index cd559c9..6e218ca 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/AdminChatServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/AdminChatServiceImpl.java
@@ -4,16 +4,18 @@
 import cc.mrbird.febs.common.entity.QueryRequest;
 import cc.mrbird.febs.mall.YesOrNoEnum;
 import cc.mrbird.febs.mall.dto.AdminSystemPayDto;
+import cc.mrbird.febs.mall.entity.ChatAmountFlow;
 import cc.mrbird.febs.mall.entity.ChatUser;
 import cc.mrbird.febs.mall.entity.MemberCoinWithdraw;
+import cc.mrbird.febs.mall.mapper.ChatAmountFlowMapper;
 import cc.mrbird.febs.mall.mapper.ChatUserMapper;
 import cc.mrbird.febs.mall.service.IAdminChatService;
 import cc.mrbird.febs.mall.vo.AdminChatAmountFlowVo;
 import cc.mrbird.febs.mall.vo.AdminChatCahrgeVo;
 import cc.mrbird.febs.mall.vo.AdminChatUserVo;
 import cc.mrbird.febs.mall.vo.AdminChatWithDrawVo;
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.ObjectUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -29,6 +31,8 @@
 @RequiredArgsConstructor
 @Transactional
 public class AdminChatServiceImpl extends ServiceImpl<ChatUserMapper, ChatUser> implements IAdminChatService {
+
+    private final ChatAmountFlowMapper chatAmountFlowMapper;
 
     @Override
     public IPage<AdminChatUserVo> getUserList(ChatUser chatUser, QueryRequest request) {
@@ -74,6 +78,16 @@
         }
         //增加用户的余额
         this.baseMapper.updateBalanceByUserId(adminSystemPayDto.getId(),addBalance);
+
+        ChatAmountFlow chatAmountFlow = new ChatAmountFlow();
+        chatAmountFlow.setAmount(addBalance);
+        chatAmountFlow.setAvaAmount(balance);
+        chatAmountFlow.setCreateTime(DateUtil.date());
+        chatAmountFlow.setRemark("系统拨付");
+        chatAmountFlow.setType(6);
+        chatAmountFlow.setUserId(chatUser.getUserId());
+        chatAmountFlow.setState(1);
+        chatAmountFlowMapper.insert(chatAmountFlow);
         return new FebsResponse().success();
     }
 
diff --git a/src/test/java/cc/mrbird/febs/ProfitTest.java b/src/test/java/cc/mrbird/febs/ProfitTest.java
index 4b8e7e2..34e1c21 100644
--- a/src/test/java/cc/mrbird/febs/ProfitTest.java
+++ b/src/test/java/cc/mrbird/febs/ProfitTest.java
@@ -5,6 +5,8 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 
+import java.math.BigDecimal;
+
 /**
  * @author wzy
  * @date 2022-06-02
@@ -12,20 +14,30 @@
 @SpringBootTest
 public class ProfitTest {
 
+    public static void main(String[] args) {
+        BigDecimal bigDecimal = new BigDecimal("624377928.99960000");
+        BigDecimal bigDecimal1 = new BigDecimal("975728618.82800000");
+        BigDecimal add = bigDecimal.add(bigDecimal1);
+        BigDecimal price = new BigDecimal("0.000243745811");
+        BigDecimal bigDecimal2 = add.multiply(price).setScale(2, BigDecimal.ROUND_DOWN);
+//        BigDecimal divide = bigDecimal.divide(bigDecimal1, 8, BigDecimal.ROUND_DOWN);
+        System.out.println(bigDecimal2);
+    }
+
 //    @Autowired
 //    private AgentConsumer agentConsumer;
 //
-    @Autowired
-    private IAgentService agentService;
-//
 //    @Autowired
-//    private IMemberProfitService memberProfitService;
-//
-    @Test
-    public void dynamicProfit() {
-        agentService.returnMoneyToAgent(3323L);
-//        agentService.autoUpAgentLevel(640L);
-    }
+//    private IAgentService agentService;
+////
+////    @Autowired
+////    private IMemberProfitService memberProfitService;
+////
+//    @Test
+//    public void dynamicProfit() {
+//        agentService.returnMoneyToAgent(3323L);
+////        agentService.autoUpAgentLevel(640L);
+//    }
 //    @Test
 //    public void agentProfit() {
 //        memberProfitService.agentProfit(null);

--
Gitblit v1.9.1