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
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
package com.stylefeng.guns.modular.account.controller;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.CharteredCar.server.IOrderCharteredCarService;
import com.stylefeng.guns.modular.account.model.TBank;
import com.stylefeng.guns.modular.account.model.TBankNext;
import com.stylefeng.guns.modular.account.model.TUserBankAccount;
import com.stylefeng.guns.modular.account.server.ITBankNextService;
import com.stylefeng.guns.modular.account.server.ITBankService;
import com.stylefeng.guns.modular.account.server.UserBankAccountService;
import com.stylefeng.guns.modular.account.server.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.cloudPayment.req.WithdrawalReq;
import com.stylefeng.guns.modular.system.model.User;
import com.stylefeng.guns.modular.system.model.UserBankAccount;
import com.stylefeng.guns.modular.system.model.UserInfo;
import com.stylefeng.guns.modular.system.model.UserWithdrawal;
import com.stylefeng.guns.modular.system.service.IUserInfoService;
import com.stylefeng.guns.modular.system.service.IUserService;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.unionpay.upyzt.exception.UpyztException;
import com.unionpay.upyzt.resp.BalanceAcctListResp;
import com.unionpay.upyzt.resp.CusApplicationResp;
import com.unionpay.upyzt.resp.SettleAcctListResp;
import com.unionpay.upyzt.resp.SettleAcctResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
 
@Api(tags = "用户绑卡-提现")
@RestController
@RequestMapping("/api/userAccount")
public class AccountController {
 
    @Resource
    private UserBankAccountService bankAccountService;
 
    @Autowired
    private ITBankService bankService;
 
    @Resource
    private UserWithdrawalService userWithdrawalService;
 
 
 
    @Autowired
    private ITBankNextService itBankNextService;
    @ResponseBody
    @RequestMapping(value = "/bindCard", method = RequestMethod.POST)
    @ApiOperation(value = "用户添加银行卡", tags = {"用户端-用户添加银行卡"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
    })
    @Transactional(propagation = Propagation.REQUIRES_NEW)
    public ResultUtil bindCard(TUserBankAccount userBankAccount,HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            UserInfo user = userInfoService.selectById(uid);
            int count = bankAccountService.selectCount(new EntityWrapper<UserBankAccount>().eq("userId", uid)
                    .eq("userType", 1).eq("bankCardCode", userBankAccount.getBankCardCode())
                    .eq("status", 1));
            if(count > 0){
                return ResultUtil.error("不能重复添加银行卡");
            }
 
            List<UserWithdrawal> userId = userWithdrawalService.selectList(new EntityWrapper<UserWithdrawal>().eq("phone", user.getPhone()).eq("userType",1));
            if(userId.size()==0){
                return ResultUtil.error("请先进行个人用户进件信息填写");
            }
            userBankAccount.setUserId(uid);
            UserBankAccount userBankAccount1 = new UserBankAccount();
            BeanUtils.copyProperties(userBankAccount,userBankAccount1);
            userBankAccount1.setCreateTime(new Date());
            userBankAccount1.setUserType(1);
            userBankAccount1.setOutRequestNo(ToolUtil.getRandomString(32));
            userBankAccount1.setBankAcctType("1");
            bankAccountService.insert(userBankAccount1);
            UserBankAccountReq userBankAccountReq = new UserBankAccountReq();
            BeanUtils.copyProperties(userBankAccount1,userBankAccountReq);
            userBankAccountReq.setCusId(userId.get(0).getCusId());
//            SettleAcctResp settleAcctResp = SettleAcctExample.create(userBankAccountReq);
//            userBankAccount1.setOutRequestNo(settleAcctResp.getOutRequestNo());
//            userBankAccount1.setVerifyStatus(settleAcctResp.getVerifyStatus());
//            userBankAccount1.setAcctValidationFailureMsg(settleAcctResp.getAcctValidationFailureMsg());
//            userBankAccount1.setAcctValidationFinishedAt(settleAcctResp.getAcctValidationFinishedAt().toString());
//            userBankAccount1.setSettleAcctId(settleAcctResp.getSettleAcctId());
            bankAccountService.updateById(userBankAccount1);
            return ResultUtil.success();
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    @ResponseBody
    @RequestMapping(value = "/getCode", method = RequestMethod.POST)
    @ApiOperation(value = "获取验证码", tags = {"用户端-获取验证码"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
    })
    public ResultUtil getCode(String phone){
        try {
            CusApplicationExample.smsCode(phone);
            return ResultUtil.success();
        }catch (UpyztException e){
            e.printStackTrace();
            return ResultUtil.error(e.getMessage());
        }
    }
 
    @Autowired
    private IUserInfoService userInfoService;
 
    @ResponseBody
    @RequestMapping(value = "/getBindCardList", method = RequestMethod.POST)
    @ApiOperation(value = "获取银行卡", tags = {"用户端-获取银行卡"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(value = "pageNumber", name = "pageNumber", required = true, dataType = "int"),
            @ApiImplicitParam(value = "pageSize", name = "pageSize", required = true, dataType = "int"),
    })
    public ResultUtil getBindCardList(int pageNumber,int pageSize,HttpServletRequest request){
        try {
            Integer id = userInfoService.getUserIdFormRedis(request);
            if(null == id){
                return ResultUtil.tokenErr();
            }
            UserInfo userInfo = userInfoService.selectById(id);
            Page<UserBankAccount> userBankAccountPage = new Page<>(pageNumber, pageSize);
            Page<UserBankAccount> userBankAccountPage1 = bankAccountService.selectPage(userBankAccountPage, new EntityWrapper<UserBankAccount>().eq("phone", userInfo.getPhone()).eq("userType", 1).eq("status", true));
            return ResultUtil.success(userBankAccountPage1.getRecords());
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
 
    @ResponseBody
    @RequestMapping(value = "/deleteBindCard", method = RequestMethod.POST)
    @ApiOperation(value = "删除银行卡", tags = {"用户端-删除银行卡"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(value = "卡id", name = "id", required = true, dataType = "int"),
    })
    @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW)
    public ResultUtil getBindCardList(int id){
        try {
            UserBankAccount userBankAccount = bankAccountService.selectById(id);
            userBankAccount.setStatus(false);
            bankAccountService.updateById(userBankAccount);
//            SettleAcctExample.removeById(userBankAccount.getSettleAcctId());
            return ResultUtil.success();
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
 
    @ResponseBody
    @RequestMapping(value = "/getAllCard", method = RequestMethod.POST)
    @ApiOperation(value = "获取所有银行卡信息--第一级", tags = {"用户端-获取所有银行卡信息--第一级"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(value = "name", name = "name", required = true, dataType = "String"),
    })
    public ResultUtil getAllCard(String name){
        try {
            EntityWrapper<TBank> tBankEntityWrapper = new EntityWrapper<>();
            if(name!=null && !"".equals(name)){
                tBankEntityWrapper.like("bankName",name);
            }
            List<TBank> tBanks = bankService.selectList(tBankEntityWrapper);
            return ResultUtil.success(tBanks);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
    @ResponseBody
    @RequestMapping(value = "/getAllCardTwo", method = RequestMethod.POST)
    @ApiOperation(value = "获取所有银行卡信息--第二级", tags = {"用户端-获取所有银行卡信息--第二级"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(value = "pageNumber", name = "pageNumber", required = true, dataType = "int"),
            @ApiImplicitParam(value = "pageSize", name = "pageSize", required = true, dataType = "int"),
            @ApiImplicitParam(value = "code", name = "code", required = true, dataType = "String"),
            @ApiImplicitParam(value = "name", name = "name", required = false, dataType = "String"),
    })
    public ResultUtil getAllCardTwo(int pageNumber,int pageSize,String code,String name ){
        try {
            Page<TBankNext> tBankNextPage = new Page<>(pageNumber, pageSize);
            EntityWrapper<TBankNext> tBankNextEntityWrapper = new EntityWrapper<>();
            tBankNextEntityWrapper.eq("drecCode",code);
            if(ToolUtil.isNotEmpty(name)){
                tBankNextEntityWrapper.like("bankName",name);
            }
            Page<TBankNext> tBankNextPage1 = itBankNextService.selectPage(tBankNextPage, tBankNextEntityWrapper);
            return ResultUtil.success(tBankNextPage1.getRecords());
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
}