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();
|
}
|
}
|
}
|