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
package com.stylefeng.guns.modular.account.schedule;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.modular.account.service.UserWithdrawalService;
import com.stylefeng.guns.modular.cloudPayment.example.BalanceAcctExample;
import com.stylefeng.guns.modular.cloudPayment.example.CusApplicationExample;
import com.stylefeng.guns.modular.cloudPayment.example.SettleAcctExample;
import com.stylefeng.guns.modular.cloudPayment.example.WithdrawalExample;
import com.stylefeng.guns.modular.cloudPayment.req.BalanceAcctReq;
import com.stylefeng.guns.modular.cloudPayment.req.UserBankAccountReq;
import com.stylefeng.guns.modular.system.model.ElectronicLedger;
import com.stylefeng.guns.modular.system.model.UserWithdrawal;
import com.unionpay.upyzt.exception.UpyztException;
import com.unionpay.upyzt.resp.BalanceAcctStoreResp;
import com.unionpay.upyzt.resp.CusApplicationResp;
import com.unionpay.upyzt.resp.SettleAcctResp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
 
import java.util.List;
 
@Slf4j
@Component
@EnableScheduling
public class UserWithdrawalSchedule {
 
 
    @Autowired
    private UserWithdrawalService userWithdrawalService;
 
        /**
         * 自动更新开户状态并进行电子账簿开通及绑定银行卡
         * 每分钟执行一次
         */
        @Scheduled(cron = "0 0/1 * * * ? ")
        private void configureTasks() {
            List<UserWithdrawal> userWithdrawals = userWithdrawalService.selectList(new EntityWrapper<UserWithdrawal>()
                    .eq("userType", 2)
                    .ne("applicationStatus", "succeeded"));
            if(!CollectionUtils.isEmpty(userWithdrawals)){
                for (UserWithdrawal userWithdrawal : userWithdrawals) {
                    try {
                        CusApplicationResp cusApplicationResp = CusApplicationExample.retrieveById(userWithdrawal.getCusApplicationId());
                        // 开户将司机进件返回的信息进行保存
                        userWithdrawalService.cusApplicationRespToUserWithdrawal(userWithdrawal,cusApplicationResp);
                        userWithdrawalService.updateById(userWithdrawal);
 
                        // 开户成功,开通电子账户,绑定账户
                        // 开通电子账簿
                        /*BalanceAcctReq balanceAcctReq = electronicLedgerService.createBalanceAcctReq(userWithdrawal.getCusId(),password);
                        BalanceAcctStoreResp balanceAcctStoreResp = BalanceAcctExample.create(balanceAcctReq);
 
                        // 开通电子账簿成功,封装实体
                        ElectronicLedger electronicLedger = electronicLedgerService.createElectronicLedger(balanceAcctStoreResp,userWithdrawal,password);
                        electronicLedgerService.insert(electronicLedger);
 
                        // 绑定银行卡
                        UserBankAccountReq userBankAccountReq = electronicLedgerService.createUserBankAccountReq(bankCard,userWithdrawal.getCusId(),userWithdrawal.getCode());
                        SettleAcctResp settleAcctResp = SettleAcctExample.create(userBankAccountReq);
 
                        // 保存绑定银行卡返回信息
                        bankCard.setVerifyStatus(settleAcctResp.getVerifyStatus());
                        bankCard.setSettleAcctId(settleAcctResp.getSettleAcctId());
                        bankCard.setAcctValidationFailureMsg(settleAcctResp.getAcctValidationFailureMsg());
                        bankCard.setAcctValidationFinishedAt(settleAcctResp.getAcctValidationFinishedAt());
                        bankCardService.updateById(bankCard);*/
                    } catch (UpyztException e) {
                        log.error("个人用户进件状态查询(系统订单号)失败:{}",e.getMessage());
                    }
                }
            }
        }
 
}