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, "四川省成都市武侯区石羊街道天府新谷成都高新技术产业开发区(南区)", "");
|
}
|
}
|