Pu Zhibing
4 天以前 0cc73a9ffcdd356e0b797e458b400acfb660da94
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
package com.stylefeng.guns.modular.account.server.impl;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.modular.account.dao.UserWithdrawalMapper;
import com.stylefeng.guns.modular.account.model.ElectronicLedger;
import com.stylefeng.guns.modular.account.server.ElectronicLedgerService;
import com.stylefeng.guns.modular.account.server.UserWithdrawalService;
import com.stylefeng.guns.modular.system.model.Company;
import com.stylefeng.guns.modular.system.model.UserWithdrawal;
import com.stylefeng.guns.modular.system.service.ICompanyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.Objects;
 
@Slf4j
@Service
public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalMapper, UserWithdrawal> implements UserWithdrawalService {
 
    @Autowired
    private ICompanyService companyService;
    @Autowired
    private ElectronicLedgerService electronicLedgerService;
 
    @Override
    public Boolean withdrawDeposit(Integer amount, String bankAcctNo, String password) {
        // 查询当前操作电子用户
        UserWithdrawal userWithdrawal = this.selectOne(new EntityWrapper<UserWithdrawal>()
                .eq("userId", Objects.requireNonNull(ShiroKit.getUser()).getId())
                .eq("userType", 1)
                .last("LIMIT 1"));
    
        // 先从平台进行分账到用户电子账簿
        // 查询平台账户
        Company company = companyService.selectOne(new EntityWrapper<Company>()
                .eq("type", 1));
        // 查询平台开户信息
        ElectronicLedger electronicLedger = electronicLedgerService.selectOne(new EntityWrapper<ElectronicLedger>()
                .eq("userId", company.getId())
                .eq("userType", 3)
                .last("LIMIT 1"));
//        try {
//            // 进行平台分账到用户电子账簿
//            log.info("平台分账到用户电子账簿=========");
//            AllocationResp allocationResp = AllocationExample.create(this.createAllocationReq(userWithdrawal.getBalanceAcctId(), electronicLedger.getBalanceAcctId(), amount,password));
//            log.info("平台分账到用户电子账簿完成=========:{}",allocationResp);
//
//            // 用户电子账簿进行提现操作
//            WithdrawalResp withdrawalResp = WithdrawalExample.create(this.createWithdrawalReq(userWithdrawal.getBalanceAcctId(), amount, password, bankAcctNo));
//            log.info("用户电子账簿提现完成=========:{}",withdrawalResp);
//            return true;
//        }catch (Exception e){
//            log.info("用户提现失败=========:{}",e.getMessage());
//            e.printStackTrace();
//            return false;
//        }
        return true;
    }
}