admin
2022-09-30 ffc56f912da5d6d842142ae4ea1856bc56f8bcb9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package test.goldcorn;
 
import com.ks.lib.common.exception.ParamsException;
import com.yeshi.makemoney.app.Application;
import com.yeshi.makemoney.app.dto.mq.GoldCornSettleMQMsg;
import com.yeshi.makemoney.app.entity.SystemEnum;
import com.yeshi.makemoney.app.entity.goldcorn.*;
import com.yeshi.makemoney.app.exception.goldcorn.*;
import com.yeshi.makemoney.app.exception.user.UserInfoException;
import com.yeshi.makemoney.app.service.inter.goldcorn.*;
import com.yeshi.makemoney.app.service.query.goldcorn.GoldCornConsumeRecordQuery;
import com.yeshi.makemoney.app.utils.mq.CMQManager;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.yeshi.utils.TimeUtil;
 
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
 
/**
 * @author hxh
 * @title: GoldCornTest
 * @description: TODO
 * @date 2022/4/7 10:13
 */
@SpringBootTest(classes = Application.class)
public class GoldCornTest {
 
    @Resource
    private GoldCornGetRecordService goldCornGetRecordService;
 
    @Resource
    private GoldCornConsumeRecordService goldCornConsumeRecordService;
 
    @Resource
    private GoldCornMakeService goldCornMakeService;
 
    @Resource
    private GoldCornSettleService goldCornSettleService;
 
    @Resource
    private GoldCornSettleRecordService goldCornSettleRecordService;
 
    @Test
    public void addGoldRecord() throws GoldCornGetRecordException {
        GoldCornGetRecord record = new GoldCornGetRecord();
        record.setCornNum(10);
        record.setUid(2L);
        record.setType(GoldCornGetType.readNovel);
        record.setLevel(GoldCornGetRecord.LEVEL_OWN);
        record.setDay("2022-04-07");
        record.setEventCount(1L);
        goldCornGetRecordService.add(record);
    }
 
    @Test
    public void statistic() {
        Long count = goldCornGetRecordService.getGoldCornByDay(null, new Date());
        System.out.println(count);
 
        count = goldCornGetRecordService.countUidsByDay("2022-04-07");
        System.out.println(count);
 
        List<Long> uidList = goldCornGetRecordService.getUidsByDay("2022-04-07", 1, 1);
        for (Long id : uidList) {
            System.out.println(id);
        }
        uidList = goldCornGetRecordService.getUidsByDay("2022-04-07", 2, 1);
        for (Long id : uidList) {
            System.out.println(id);
        }
        uidList = goldCornGetRecordService.getUidsByDay("2022-04-07", 3, 1);
        for (Long id : uidList) {
            System.out.println(id);
        }
 
 
    }
 
    @Test
    public void makeGoldCorn() {
        try {
            goldCornMakeService.addGoldCorn(22384L, GoldCornGetType.watchVideo, false, new Date(), null, 1L);
//            goldCornMakeService.addGoldCorn(22380L,GoldCornGetType.readNovel,new Date());
        } catch (UserInfoException e) {
            e.printStackTrace();
        } catch (GoldCornGetFrequencyConfigException e) {
            e.printStackTrace();
        } catch (GoldCornMakeException e) {
            e.printStackTrace();
        }
    }
 
    @Test
    public void settle() {
//        goldCornSettleService.startSettle(new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24 * 1L));
//        CMQManager.getInstance().addGoldCornSettleMsg(new GoldCornSettleMQMsg(record.getId(), uid, day, System.currentTimeMillis()));
        //重新结算
        GoldCornConsumeRecordQuery query = new GoldCornConsumeRecordQuery();
        query.setType(GoldCornConsumeType.changeMoney);
        query.setEventId("2022-06-22-svmm");
        query.setType(GoldCornConsumeType.changeMoney);
        List<GoldCornConsumeRecord> list=  goldCornConsumeRecordService.list(query,1,1000);
        int count=0;
        for(GoldCornConsumeRecord record:list){
           if(record.getCreateTime().getTime()> TimeUtil.convertToTimeTemp("2022-06-29","yyyy-MM-dd")){
               GoldCornConsumeRecord update=new GoldCornConsumeRecord();
               update.setId(record.getId());
               update.setEventId("2022-06-28-svmm");
               goldCornConsumeRecordService.update(update);
           }
        }
 
 
    }
 
 
    @Resource
    private GoldCornGetFrequencyConfigService goldCornGetFrequencyConfigService;
 
    public void getFrequencys() {
        List<GoldCornGetFrequencyConfig> list = goldCornGetFrequencyConfigService.listByTypes(Arrays.asList(new GoldCornGetType[]{GoldCornGetType.watchVideo, GoldCornGetType.readNovel, GoldCornGetType.scanNews}), SystemEnum.svmm, new Date());
    }
 
    @Test
    public void addSettle() throws GoldCornSettleRecordException, ParamsException {
        GoldCornSettleRecord record = new GoldCornSettleRecord();
        goldCornSettleRecordService.add(record);
    }
 
    @Test
    public void sumMoney() {
        GoldCornConsumeRecordQuery query = new GoldCornConsumeRecordQuery();
        query.setType(GoldCornConsumeType.changeMoney);
        BigDecimal money = goldCornConsumeRecordService.sumMoney(query);
        System.out.println(money);
    }
 
}