xuhy
2025-01-09 712f70b2936079a131ecb1e63c6d337171618cad
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
package com.stylefeng.guns;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.account.dao.TEnterpriseWithdrawalMapper;
import com.stylefeng.guns.modular.account.model.TEnterpriseWithdrawal;
import com.stylefeng.guns.modular.account.service.UserWithdrawalService;
import com.stylefeng.guns.modular.account.util.Base64Util;
import com.stylefeng.guns.modular.cloudPayment.example.AllocationExample;
import com.stylefeng.guns.modular.cloudPayment.req.AllocationReq;
import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService;
import com.stylefeng.guns.modular.system.model.Driver;
import com.stylefeng.guns.modular.system.model.Income;
import com.stylefeng.guns.modular.system.model.UserWithdrawal;
import com.stylefeng.guns.modular.system.service.IDriverService;
import com.stylefeng.guns.modular.system.service.IIncomeService;
import com.unionpay.upyzt.exception.UpyztException;
import com.unionpay.upyzt.resp.AllocationResp;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
 
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
 
@RunWith(SpringRunner.class)
@SpringBootTest
public class GunsApplicationTest {
 
    @Autowired
    private IOrderLogisticsService orderLogisticsService;
    @Autowired
    private UserWithdrawalService userWithdrawalService;
    @Resource
    private TEnterpriseWithdrawalMapper enterpriseWithdrawalMapper;
    @Resource
    private IIncomeService incomeService;
    @Resource
    private IDriverService driverService;
 
    @Test
    public void queryVipLevelList() throws Exception {
        // 平台
        // 转出 电子账簿id
        TEnterpriseWithdrawal enterpriseWithdrawal = enterpriseWithdrawalMapper.selectById(1);
 
        String balanceAcctId = enterpriseWithdrawal.getBalanceAcctId();
        String code = enterpriseWithdrawal.getTransactionAuthorizationCode();
        code = Base64Util.decode(code);
        UserWithdrawal userWithdrawal = userWithdrawalService.selectById(36);
        // 当前司机分账金额
 
 
        Driver tDriver = driverService.selectById(2535);
        // 查询分账金额
        List<Income> state = incomeService.selectList(new EntityWrapper<Income>()
                .eq("id", 26268));
//        List<Income> state = incomeService.selectList(new EntityWrapper<Income>()
//                .eq("objectId", 2535)
//                .eq("userType", 2)
//                .eq("state", 0));
 
        Double sum = state.stream().filter(e ->(e.getUserType() == 2 && tDriver.getId().equals(e.getObjectId()))).mapToDouble(Income::getMoney).sum();
        if(sum==null || sum==0){
            return;
        }
        Double v = sum * 100;
        int money = v.intValue();
        String balanceAcctId1 = userWithdrawal.getBalanceAcctId();
        AllocationReq allocationReq = new AllocationReq();
        allocationReq.setOutOrderNo(ToolUtil.getRandomString(32));
        allocationReq.setPayBalanceAcctId(balanceAcctId);
        allocationReq.setRecvBalanceAcctId(balanceAcctId1);
        allocationReq.setAmount(money);
        allocationReq.setProductName("司机分账");
        allocationReq.setProductCount(1);
        allocationReq.setOrderNo(ToolUtil.getRandomString(32));
        allocationReq.setOrderAmount(1l);
        allocationReq.setPassword(code);
        try {
            AllocationResp allocationResp = AllocationExample.create(allocationReq);
            System.out.println(tDriver.getId()+"::"+tDriver.getName()+"-----分账状态"+allocationResp.getStatus()+"--------------");
            if("processing".equals(allocationResp.getStatus())){
                List<Income> collect1 = state.stream().filter(e -> e.getUserType() == 2 && tDriver.getId().equals(e.getObjectId()) ).collect(Collectors.toList());
                collect1.stream().forEach(e->e.setAllNo(allocationResp.getAllocationId()));
                incomeService.updateBatchById(collect1);
            }
            if("succeeded".equals(allocationResp.getStatus())){
                List<Income> collect1 = state.stream().filter(e -> e.getUserType() == 2 && tDriver.getId().equals(e.getObjectId()) ).collect(Collectors.toList());
                collect1.stream().forEach(e->e.setState(1));
                incomeService.updateBatchById(collect1);
            }
        } catch (UpyztException e) {
            e.printStackTrace();
        }
 
//        orderLogisticsService.process(434, 6, 104.0560028754, 30.5855897352, "四川省成都市武侯区石羊街道天府新谷成都高新技术产业开发区(南区)", "");
    }
}