xiaoyong931011
2022-12-22 70cd2aec8a55e222070d4dd6d816dcb3231a1217
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
package cc.mrbird.febs;
 
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.common.enumerates.MallMoneyFlowTypeEnum;
import cc.mrbird.febs.common.enumerates.OrderStatusEnum;
import cc.mrbird.febs.common.exception.FebsException;
import cc.mrbird.febs.common.utils.AppContants;
import cc.mrbird.febs.common.utils.LoginUserUtil;
import cc.mrbird.febs.common.utils.MallUtils;
import cc.mrbird.febs.mall.entity.MallMember;
import cc.mrbird.febs.mall.entity.MallMoneyFlow;
import cc.mrbird.febs.mall.entity.MallOrderInfo;
import cc.mrbird.febs.mall.entity.MallOrderItem;
import cc.mrbird.febs.mall.mapper.MallMemberMapper;
import cc.mrbird.febs.mall.mapper.MallMoneyFlowMapper;
import cc.mrbird.febs.mall.mapper.MallOrderInfoMapper;
import cc.mrbird.febs.mall.mapper.MallOrderItemMapper;
import cc.mrbird.febs.mall.quartz.OrderSettlementJob;
import cc.mrbird.febs.mall.service.IAgentService;
import cc.mrbird.febs.mall.service.IApiMallMemberWalletService;
import cc.mrbird.febs.mall.service.IMallAchieveService;
import cc.mrbird.febs.mall.service.IMemberProfitService;
import cc.mrbird.febs.mall.vo.ApiMallSubsidyAmountInfoVo;
import cc.mrbird.febs.pay.model.*;
import cc.mrbird.febs.pay.service.UnipayService;
import cc.mrbird.febs.rabbit.consumer.AgentConsumer;
import cc.mrbird.febs.rabbit.producter.AgentProducer;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSON;
import cn.hutool.json.JSONUtil;
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.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * @author wzy
 * @date 2022-06-02
 **/
@SpringBootTest
public class ProfitTest {
 
    @Autowired
    private AgentConsumer agentConsumer;
 
    @Autowired
    private IAgentService agentService;
 
    @Autowired
    private IMemberProfitService memberProfitService;
 
    @Test
    public void dynamicProfit() {
        memberProfitService.dynamicProfit(21L);
    }
    @Test
    public void agentProfit() {
        memberProfitService.agentProfit(null);
    }
 
 
//    @Test
//    public void staticProfit() {
//        memberProfitService.staticProfit(new Date());
//    }
 
    @Test
    public void thankfulProfit() {
        memberProfitService.thankfulProfit(new Date());
    }
 
    @Test
    public void rankProfit() {
        memberProfitService.rankProfit();
    }
 
    @Autowired
    private MallOrderInfoMapper mallOrderInfoMapper;
 
    @Autowired
    private MallMemberMapper mallMemberMapper;
 
    @Autowired
    private MallMoneyFlowMapper mallMoneyFlowMapper;
 
    @Autowired
    private IApiMallMemberWalletService memberWalletService;
 
    @Autowired
    private AgentProducer agentProducer;
 
    @Test
    public void directorProfitTest() {
        MallMember member = mallMemberMapper.selectById(633L);
        ApiMallSubsidyAmountInfoVo apiMallSubsidyAmountInfoVo = new ApiMallSubsidyAmountInfoVo();
        DateTime today = DateUtil.date();
        DateTime yesterday = DateUtil.yesterday();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String yyyyMMddToday = sdf.format(today);
        String yyyyMMddYesterday = sdf.format(yesterday);
        //今日补贴
        BigDecimal todayAmount = mallOrderInfoMapper.selectTodayAmountByCreateTimeAndMemberId(yyyyMMddToday,member.getId());
        apiMallSubsidyAmountInfoVo.setTodayAmount(todayAmount);
        //今日累计接单
        Integer todayTotalCnt = mallOrderInfoMapper.selectCountByCreateTimeAndMemberId(yyyyMMddToday,member.getId());
        apiMallSubsidyAmountInfoVo.setTodayTotalCnt(todayTotalCnt);
        //昨日补贴
        BigDecimal yesterdayAmount = mallOrderInfoMapper.selectTodayAmountByCreateTimeAndMemberId(yyyyMMddYesterday,member.getId());
        apiMallSubsidyAmountInfoVo.setYesterdayAmount(yesterdayAmount);
        //昨日累计接单
        Integer totalYesterdayCnt = mallOrderInfoMapper.selectCountByCreateTimeAndMemberId(yyyyMMddYesterday,member.getId());
        apiMallSubsidyAmountInfoVo.setTotalYesterdayCnt(totalYesterdayCnt);
        //获得总额
        BigDecimal totalAmount = mallOrderInfoMapper.selectTodayAmountByCreateTimeAndMemberId(null,member.getId());
        apiMallSubsidyAmountInfoVo.setTotalAmount(totalAmount);
        JSON parse = JSONUtil.parse(apiMallSubsidyAmountInfoVo);
        System.out.println(parse.toString());
    }
 
    @Autowired
    private MallOrderItemMapper mallOrderItemMapper;
 
    @Autowired
    private IMallAchieveService mallAchieveService;
 
    @Test
    public void achieveTest() {
        List<MallOrderItem> items = mallOrderItemMapper.selectList(null);
        for (MallOrderItem item : items) {
            mallAchieveService.add(item.getId());
        }
    }
//
//    @Test
//    public void paramTest() {
//        Map<String, Integer> map = new HashMap<>();
//        BigDecimal amount = new BigDecimal("100");
//        map.put("amount", 1);
//        changeAmount(map);
//        System.out.println(map.get("amount"));
//    }
//
//    public void changeAmount(Map<String, Integer> amount) {
//        amount.put("amount", 2);
//    }
//
//    @Test
//    public void scorePool(){
//        memberProfitService.scorePool();
//    }
//
//    @Test
//    public void staticProfit(){
//        memberProfitService.staticProfit(null);
//    }
//
//    @Autowired
//    private OrderSettlementJob orderSettlementJob;
//
//    @Test
//    public void orderSettlementJobTest() {
////        orderSettlementJob.normalGoodsSettlementJob();
//
//        mallAchieveService.add(83L);
//    }
//
//
//    @Autowired
//    private UnipayService unipayService;
//    @Test
//    public void unipay(){
//        UnipayDto unipayDto = new UnipayDto();
//        unipayDto.setAmount(new BigDecimal("0.01"));
//        unipayDto.setFrpCode("ALIPAY_H5");
//        unipayDto.setTradeMerchantNo("777180800385820");
////        unipayDto.setFrpCode("WEIXIN_APP3");
//        unipayDto.setOrderNo("2022082316415386395");
//        unipayDto.setProductName("洗护套装");
//        unipayService.unipay(unipayDto);
//    }
//    @Test
//    public void getAgreeMentPaySms(){
//        AgreeMentPaySmsDto agreeMentPaySmsDto = new AgreeMentPaySmsDto();
//        agreeMentPaySmsDto.setOrderNo("2022082617305930328");
//
//        BigDecimal value = new BigDecimal("0.1").setScale(2, BigDecimal.ROUND_DOWN);
//        DecimalFormat decimalFormat = new DecimalFormat("0.00#");
//        String strVal = decimalFormat.format(value);
//        agreeMentPaySmsDto.setOrderAmount(new BigDecimal(strVal));
//        agreeMentPaySmsDto.setName("肖永");
//        agreeMentPaySmsDto.setCreatedTime(DateUtil.now());
//        agreeMentPaySmsDto.setIdType("1");
//        agreeMentPaySmsDto.setIdCardNum("430321199310113713");
//        agreeMentPaySmsDto.setBankNo("6222031901002389639");
//        agreeMentPaySmsDto.setPhone("15274802129");
//        String agreeMentPaySms = unipayService.getAgreeMentPaySms(agreeMentPaySmsDto);
//        if("JS000000".equals(agreeMentPaySms)){
//            System.out.println("获取成功");
//        }else{
//            System.out.println(agreeMentPaySms);
//        }
//    }
//
//    @Test
//    public void agreementSign(){
//        AgreementSignDto agreementSignDto = new AgreementSignDto();
//        agreementSignDto.setOrderNo("2022082614465345250");
//        agreementSignDto.setSmsCode("841243");
//        unipayService.agreementSign(agreementSignDto);
//    }
//
//    @Test
//    public void agreementPay(){
//        AgreementPayDto agreementPayDto = new AgreementPayDto();
//        agreementPayDto.setOrderNo("2022082614465345250");
//
//        BigDecimal value = new BigDecimal("0.1").setScale(2, BigDecimal.ROUND_DOWN);
//        DecimalFormat decimalFormat = new DecimalFormat("0.00#");
//        String strVal = decimalFormat.format(value);
//        agreementPayDto.setOrderAmount(new BigDecimal(strVal));
//        agreementPayDto.setOrderTime(DateUtil.now());
//        agreementPayDto.setOrderDesc("测试");
//        agreementPayDto.setBankNo("6222031901002389639");
//        unipayService.agreementPay(agreementPayDto);
//    }
//
//    @Test
//    public void singlePay(){
//        /**
//         * 调用汇聚代付
//         */
//        String orderNo = MallUtils.getOrderNum("W");
//        SinglePayDto singlePayDto = new SinglePayDto();
//        singlePayDto.setMerchantOrderNo(orderNo);
//        singlePayDto.setReceiverAccountNoEncBankNo("6222031903210023839639");
//        singlePayDto.setReceiverAccountNoEncName("肖永");
//        singlePayDto.setReceiverAccountType("201");
//        BigDecimal paidAmount = new BigDecimal(1.00);
//        singlePayDto.setPaidAmount(paidAmount);
//        singlePayDto.setCurrency("201");
//        singlePayDto.setIsChecked("202");
//        singlePayDto.setPaidDesc("用户提现");
//        singlePayDto.setPaidUse("202");
//        String singlePayRep = unipayService.singlePay(singlePayDto);
//
//        System.out.println(singlePayRep);
//    }
}