Commit d80ffb4d authored by libin's avatar libin

提现app

parent 79a67856
......@@ -51,6 +51,8 @@ public class WalletCathListDTO {
@ApiModelProperty("提现单号")
private String orderNo;
@ApiModelProperty(value = "用户账号")
@ApiModelProperty(value = "")
private String accountNumber;
private String accountName;
}
......@@ -123,4 +123,7 @@ public class MyWalletCath implements Serializable {
@Column(name = "order_no")
@ApiModelProperty(value = "第三方订单号:如微信,支付宝,银行卡等")
private String orderNo;
@Column(name = "account_name")
private String accountName;
}
......@@ -43,4 +43,7 @@ public class ApplyCathVo {
@ApiModelProperty(value = "支付类型")
private Integer cathType;
@ApiModelProperty(value = "账号名称")
private String accountName;
}
......@@ -21,9 +21,11 @@ public class PayAccountVo {
@ApiModelProperty(value = "微信用户名 | 支付宝帐号")
private String accountDesc;
@ApiModelProperty("微信用户名 | 支付宝账号")
@ApiModelProperty("微信用openid | 支付宝账号userid")
private String account;
@ApiModelProperty(value = "帐户类型 0:微信 1:支付宝 2:银行卡")
private Integer accountType;
private String nickName;
}
......@@ -53,4 +53,5 @@ public class WalletCathAdminVo {
@ApiModelProperty(value = "用户账号描述")
private String accountNumberDesc;
private String accountName;
}
......@@ -63,4 +63,9 @@ public class WalletCathVo {
@ApiModelProperty(value = "审核日期")
private Long finishTime;
@ApiModelProperty(value = "用户账号描述")
private String accountNumberDesc;
private String accountName;
}
......@@ -45,6 +45,7 @@ import tk.mybatis.mapper.entity.Example;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.Instant;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
......@@ -93,6 +94,9 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> implements In
private DateTimeFormatter dateTimeFormatter;
private static final Integer WITHDRAW_ONLINE_WAY=1;
private static final Integer WITHDRAW_OFFLINE_WAY=2;
private BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(12);
......@@ -301,6 +305,12 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> implements In
if (sumDto == null) {
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数不能为空");
}
MyWalletCath walletCath = new MyWalletCath();
walletCath.setCrtTime(Instant.now().toEpochMilli());
WithDrawRuleVo withDrawRule = configFeign.getWithDrawRule();
Integer withdrawWay = withDrawRule.getWithdrawWay();
BigDecimal commission = amount.multiply(sumDto.getProceduReates()).divide(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP);
BigDecimal balnece = sumDto.getBalance();
//到账金额
......@@ -309,9 +319,35 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> implements In
realAmount = balnece.subtract(commission);
}
log.info("-----提现申请-----proceduReates===" + sumDto.getProceduReates() + "----commission====" + commission + "---realAmount===" + realAmount);
//添加账号
// alipayBiz.addAlipay(userId,accountNumber);
MyWalletCath walletCath = new MyWalletCath();
//线上自动提现
if (WITHDRAW_ONLINE_WAY.equals(withdrawWay)){
String pay_no;
String cono = OrderUtil.GetOrderNumber("");
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String host = StringUtils.defaultIfBlank(request.getHeader("userHost"), ClientUtil.getClientIp(request));
FundPayVo fundPayVo = FundPayVo.builder()
.amount(applyCathVo.getCathType() == 0 ? String.valueOf(realAmount.multiply(new BigDecimal(100)).doubleValue()) : String.format("%.2f", realAmount.doubleValue()))
.outBizNo(cono)
.payeeAccount(applyCathVo.getAccountNumber())
.payerShowName("欣新房车网络科技(广东)股份有限公司")
.remark("提现转账")
.type(applyCathVo.getCathType())
.creatIp(host)
.build();
try {
//商户订单号
pay_no = thirdFeign.transferAccount(fundPayVo);
walletCath.setStauts(1);
walletCath.setCono(pay_no);
walletCath.setFinishTime(Instant.now().toEpochMilli());
}catch (BaseException baex){
throw new BaseException(baex.getMessage(),400);
}catch (Exception ex){
throw new BaseException((applyCathVo.getCathType() == 0?"微信提现":applyCathVo.getCathType() == 1?"支付宝提现":"银行提现")+"转账失败",ex);
}
}
//提现单号
String orderNo = snowflake.nextIdStr();
orderNo = String.format("%s%s", dateTimeFormatter.format(LocalDate.now()), orderNo);
......@@ -319,6 +355,7 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> implements In
walletCath.setUserId(userId);
walletCath.setBalance(balnece);
walletCath.setCathType(cathType);
walletCath.setAccountName(applyCathVo.getAccountName());
walletCath.setAccountNumber(accountNumber);
walletCath.setAmount(amount);
walletCath.setCommission(commission);
......@@ -335,6 +372,24 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> implements In
myWallet.setWithdrawals(withdrawals);
myWallet.setVersion(sumDto.getVersion());
mapper.updMyWater(myWallet);
//线上提现
if (WITHDRAW_ONLINE_WAY.equals(applyCathVo.getCathType())){
MyWalletDetail detail = new MyWalletDetail();
detail.setUserId(userId);
detail.setItype(1);
//设置提现单号
detail.setWithDrawOrderNo(orderNo);
detail.setCono(walletCath.getId().intValue());
detail.setBalance(balnece.add(withdrawals));
detail.setAmount(realAmount);
detail.setSource(10);
myWalletDetailBiz.insertSelective(detail);
detail.setId(null);
detail.setSource(13);
detail.setBalance(balnece.add(commission));
detail.setAmount(commission);
myWalletDetailBiz.insertSelective(detail);
}
return ObjectRestResponse.succ(walletCath.getId());
}
......@@ -362,7 +417,7 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> implements In
BigDecimal realAmount = cath.getRealAmount();
BigDecimal commission = cath.getCommission();
if (status == 1) {
String cono = StringUtil.isEmpty(cath.getCono()) ? OrderUtil.GetOrderNumber("TX"):cath.getCono();
String cono = StringUtil.isEmpty(cath.getCono()) ? OrderUtil.GetOrderNumber(""):cath.getCono();
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String host = StringUtils.defaultIfBlank(request.getHeader("userHost"), ClientUtil.getClientIp(request));
FundPayVo fundPayVo = FundPayVo.builder()
......@@ -444,6 +499,7 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> implements In
PayAccountVo alipayAccount = PayAccountVo.builder()
.account(appUserAlipay.getTxAlipay())
.accountType(1)
.nickName(appUserAlipay.getNickname())
.accountDesc(String.format("%s%s%s", "支付宝余额(", appUserAlipay.getTxAlipay(), ")"))
.build();
payAccountVos.add(alipayAccount);
......@@ -453,7 +509,8 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> implements In
if (!org.springframework.util.StringUtils.isEmpty(appUserLogin.getOpenid())) {
PayAccountVo wxAccount = PayAccountVo.builder()
.account(appUserLogin.getOpenid())
.accountType(0)
.accountType(2)
.nickName(appUserDetail.getWxNickname())
.accountDesc(String.format("%s%s%s", "微信零钱(", appUserDetail.getNickname(), ")"))
.build();
payAccountVos.add(wxAccount);
......
......@@ -63,6 +63,14 @@ public class MyWalletCathBiz extends BaseBiz<MyWalletCathMapper, MyWalletCath> {
walletCathVo = new WalletCathVo();
BeanUtils.copyProperties(walletCath, walletCathVo);
totalWithdraw = totalWithdraw.add(walletCathVo.getAmount());
//微信
if (walletCath.getCathType()==0){
walletCathVo.setAccountNumberDesc(String.format("%s%s%s","提现到微信(",walletCath.getAccountName(),")"));
}
//支付宝
if (walletCath.getCathType()==1){
walletCathVo.setAccountNumberDesc(String.format("%s%s%s","提现到支付宝(",walletCath.getAccountName(),")"));
}
walletCatchPageVos.add(walletCathVo);
}
walletCathPageVo.setPageNum(walletCathPage.getPageNum());
......@@ -105,14 +113,7 @@ public class MyWalletCathBiz extends BaseBiz<MyWalletCathMapper, MyWalletCath> {
BeanUtils.copyProperties(walletCathListDTO, walletCathAdminVo);
walletCathAdminVo.setUsername(StringUtils.isEmpty(walletCathListDTO.getRealname()) ? walletCathListDTO.getNickname() : walletCathListDTO.getRealname());
walletCathAdminVo.setPhone(walletCathListDTO.getUsername());
//微信
if (walletCathListDTO.getCathType()==0){
walletCathAdminVo.setAccountNumberDesc(String.format("%s%s%s","提现到微信(",walletCathListDTO.getAccountNumber(),")"));
}
//支付宝
if (walletCathListDTO.getCathType()==1){
walletCathAdminVo.setAccountNumberDesc(String.format("%s%s%s","提现到支付宝(",walletCathListDTO.getAccountNumber(),")"));
}
walletCathAdminVos.add(walletCathAdminVo);
}
walletCathAdminVos.sort(Comparator.comparing(WalletCathAdminVo::getCrtTime).reversed());
......@@ -141,4 +142,9 @@ public class MyWalletCathBiz extends BaseBiz<MyWalletCathMapper, MyWalletCath> {
criteria.andIn("userId", userIds);
mapper.deleteByExample(example);
}
@Override
public void insertSelective(MyWalletCath entity) {
mapper.insertSelective(entity);
}
}
......@@ -16,7 +16,8 @@
wc.finish_time AS `finishTime`,
wc.cono,
wc.order_no AS `orderNo`,
wc.account_number AS `accountNumber`
wc.account_number AS `accountNumber`,
wc.account_name AS `accountName`
FROM
(SELECT * FROM `my_wallet_cath` <if test="state != null">
WHERE `stauts`=#{state}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment