package com.ruoyi.test.business;

import com.ruoyi.cai.domain.Gift;
import com.ruoyi.cai.domain.User;
import com.ruoyi.cai.mq.handle.dto.WindowRechargeDTO;
import com.ruoyi.cai.notice.YunxinHttpService;
import com.ruoyi.cai.notice.data.child.SendGiftWindowsAmountNoticeData;
import com.ruoyi.cai.service.GiftService;
import com.ruoyi.cai.service.UserService;
import lombok.extern.slf4j.Slf4j;
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.time.LocalDateTime;
import java.util.Collections;

@SpringBootTest
@Slf4j
public class NoticeTest {

    @Autowired
    private YunxinHttpService yunxinHttpService;

    /**
     * 注册赠送消息
     */
    @Test
    public void registerRewardCoin(){
        yunxinHttpService.registerRewardCoin(33497L,88L,88L);
    }

    /**
     * 充值云贝成功消息
     */
    @Test
    public void rechargeCoinSendMessage(){
        yunxinHttpService.rechargeCoinSendMessage(33497L,188L,1000L);
    }

    @Autowired
    private GiftService giftService;

    /**
     * 收到礼物发送消息
     */
    @Test
    public void getGiftSendMessage(){
        Gift gift = giftService.getById(1);
        yunxinHttpService.getGiftSendMessage(33497L,gift,50L,100L);
    }


    /**
     * 用户充值，邀请人返现
     */
    @Test
    public void inviteCashbackSendMessage(){
        BigDecimal rate = new BigDecimal("0.30");
        yunxinHttpService.inviteCashbackSendMessage(33497L,10166L,rate,1000L,30L);
    }


    /**
     * 提现审核转账发送消息【提现审核成功】
     */
    @Test
    public void cashSuccessSendMessage(){
        LocalDateTime cashTime = LocalDateTime.now().plusDays(-1);
        BigDecimal cashMoney = new BigDecimal("78.00");
        LocalDateTime verifyTime = LocalDateTime.now();
        yunxinHttpService.cashSuccessSendMessage(33497L,
                cashTime,cashMoney,cashMoney,"张总",verifyTime);
    }

    /**
     * 提现审核转账发送消息【提现审核失败】
     */
    @Test
    public void cashFailSendMessage(){
        LocalDateTime cashTime = LocalDateTime.now().plusDays(-1);
        BigDecimal cashMoney = new BigDecimal("78.00");
        yunxinHttpService.cashFailSendMessage(33497L,
                cashTime,cashMoney,"账户有问题，打不了款");
    }

    /**
     * 举报发送消息
     */
    @Test
    public void reportSendMessage(){
        yunxinHttpService.reportSendMessage(33497L);
    }

    @Autowired
    private UserService userService;

    /**
     * 关注发送消息
     */
    @Test
    public void followedSendMessage(){
        User followUser = userService.getById(10166L);
        yunxinHttpService.followedSendMessage(33497L,followUser,LocalDateTime.now());
    }

    /**
     * 通过女神认证发送消息
     */
    @Test
    public void passAnchorSendMessage(){
        yunxinHttpService.passAnchorSendMessage(33497L);
    }

    /**
     * 发送礼物自定义消息 (发送方和接收方的消息)
     */
    @Test
    public void sendGiftMessage(){
        Gift gift = giftService.getById(1);
        yunxinHttpService.sendGiftMessage(10166L,33497L,gift,20);
    }

    /**
     * 收到守护符通知
     */
    @Test
    public void getGuardMessage(){
        yunxinHttpService.getGuardMessage(33497L,1L,1314L,520L,1233L);
    }

    /**
     * 发送上线了批量自定义消息
     */
    @Test
    public void sendOnlineAttentionNotice(){
        User loginUser = userService.getById(10166L);
        yunxinHttpService.sendOnlineAttentionNotice(Collections.singletonList(33497L),loginUser);
    }

    /**
     * 取消女神通知
     */
    @Test
    public void cancelAnchorMessage(){
        yunxinHttpService.cancelAnchorMessage(33497L);
    }

    /**
     * 动态审核通知
     */
    @Test
    public void dynamicAuditMessage(){
        yunxinHttpService.dynamicAuditMessage(33497L);
    }

    /**
     * 昵称重置审核通知
     */
    @Test
    public void nickAuditMessage(){
        yunxinHttpService.nickAuditMessage(33497L);
    }

    /**
     * 发送充值飘窗提醒
     */
    @Test
    public void sendRechargeWindowsAmount(){
        User followUser = userService.getById(10166L);
        WindowRechargeDTO dto = new WindowRechargeDTO();
        dto.setId(10166L);
        dto.setNickname(followUser.getNickname());
        dto.setAvatar(followUser.getAvatar());
        dto.setAmount(882L);
        yunxinHttpService.sendRechargeWindowsAmount(Collections.singletonList(33497L),dto);
    }

    /**
     * 发送充值礼物提醒
     */
    @Test
    public void sendGiftWindowsAmount(){
        User fromUser = userService.getById(33497L);
        User toUser = userService.getById(10166L);
        Gift gift = giftService.getById(1);
        SendGiftWindowsAmountNoticeData data = new SendGiftWindowsAmountNoticeData();
        data.setId(fromUser.getId());
        data.setNickname(fromUser.getNickname());
        data.setAvatar(fromUser.getAvatar());
        data.setToid(toUser.getId());
        data.setTonickname(toUser.getNickname());
        data.setToavatar(toUser.getAvatar());
        data.setAmount(gift.getPrice());
        data.setGiftname(gift.getName());
        data.setGiftimg(gift.getImg());
        data.setGifttotal(2L);
        yunxinHttpService.sendGiftWindowsAmount(Collections.singletonList(33497L),data);
    }
}
