KKSU
2023-11-07 86d405a84645893cffd72934dc8e35a8b59e2fcf
src/test/java/cc/mrbird/febs/ProfitTest.java
@@ -1,11 +1,17 @@
package cc.mrbird.febs;
import cc.mrbird.febs.mall.mapper.ChatUserMapper;
import cc.mrbird.febs.mall.service.IAgentService;
import cc.mrbird.febs.rabbit.producter.AgentProducer;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.math.BigDecimal;
import java.util.List;
/**
 * @author wzy
@@ -15,33 +21,57 @@
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);
        BigDecimal bigDecimal = new BigDecimal("290000");
        BigDecimal bigDecimal1 = new BigDecimal("0.000244427982");
        BigDecimal bigDecimal2 = bigDecimal.multiply(bigDecimal1).setScale(2, BigDecimal.ROUND_DOWN);
        BigDecimal divide = bigDecimal.divide(bigDecimal1, 8, BigDecimal.ROUND_DOWN);
        System.out.println(bigDecimal2);
        System.out.println(divide);
    }
    /**
     * 22977.21   回流的30%
     *
     * 344,632.0667 实际入金
     */
//    @Autowired
//    private AgentConsumer agentConsumer;
//
//    @Autowired
//    private IAgentService agentService;
    @Autowired
    private AgentProducer agentProducer;
//
    @Autowired
    private ChatUserMapper chatUserMapper;
////
////    @Autowired
////    private IMemberProfitService memberProfitService;
////
//    @Test
//    public void dynamicProfit() {
//        agentService.returnMoneyToAgent(3323L);
////        agentService.autoUpAgentLevel(640L);
//    }
//    @Test
//    public void agentProfit() {
//        memberProfitService.agentProfit(null);
//    }
    @Test
    public void dynamicProfit() {
        for(int i =0;i<75;i++){
            agentProducer.sendAddRobotMsg("32074345");
        }
//        agentService.autoUpAgentLevel(640L);
    }
    @Test
    public void agentProfit() {
        DateTime date = DateUtil.date();
        DateTime dateTime = DateUtil.offsetHour(date, -26);
        System.out.println("dateTime:"+dateTime);
        chatUserMapper.deleteMsgByCreateTime(dateTime);
        List<Long> ids = chatUserMapper.selectChatRedBagByCreateTime(dateTime);
        if(CollUtil.isNotEmpty(ids)){
            Long aLong = ids.get(0);
            chatUserMapper.deleteChatRedBagById(aLong);
            List<Long> recordIds = chatUserMapper.selectChatRedBagRecordByRebBagId(aLong);
            if(CollUtil.isNotEmpty(recordIds)){
                Long aLong1 = recordIds.get(0);
                chatUserMapper.deleteChatRedBagRecordById(aLong1);
            }
        }
    }
//
//
////    @Test