Commit 034a4594 authored by libin's avatar libin

Merge branch 'master-auto-pay' into dev

# Conflicts:
#	ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/biz/MyWalletBiz.java
parents bce22ba1 6055e6c1
...@@ -11,7 +11,7 @@ import java.util.Set; ...@@ -11,7 +11,7 @@ import java.util.Set;
*/ */
public class BaseException extends RuntimeException { public class BaseException extends RuntimeException {
private int status = 200; private int status = 200;
private String subCode;
public int getStatus() { public int getStatus() {
return status; return status;
} }
...@@ -20,6 +20,14 @@ public class BaseException extends RuntimeException { ...@@ -20,6 +20,14 @@ public class BaseException extends RuntimeException {
this.status = status; this.status = status;
} }
public String getSubCode() {
return subCode;
}
public void setSubCode(String subCode) {
this.subCode = subCode;
}
public BaseException() { public BaseException() {
} }
...@@ -28,6 +36,11 @@ public class BaseException extends RuntimeException { ...@@ -28,6 +36,11 @@ public class BaseException extends RuntimeException {
this.status = status; this.status = status;
} }
public BaseException(String message,String subCode){
super(message);
this.subCode = subCode;
}
public BaseException(String message) { public BaseException(String message) {
super(message); super(message);
} }
......
package com.github.wxiaoqi.security.admin.dto; package com.github.wxiaoqi.security.admin.dto;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -12,6 +14,8 @@ import java.math.BigDecimal; ...@@ -12,6 +14,8 @@ import java.math.BigDecimal;
* @data 2019/7/17 20:40 * @data 2019/7/17 20:40
*/ */
@Data @Data
@NoArgsConstructor
@AllArgsConstructor
public class WalletCathListDTO { public class WalletCathListDTO {
private Long id; private Long id;
...@@ -41,9 +45,12 @@ public class WalletCathListDTO { ...@@ -41,9 +45,12 @@ public class WalletCathListDTO {
@ApiModelProperty(value = "审核日期") @ApiModelProperty(value = "审核日期")
private Long finishTime; private Long finishTime;
@ApiModelProperty("单号") @ApiModelProperty("第三方单号")
private String cono; private String cono;
@ApiModelProperty("提现单号")
private String orderNo;
@ApiModelProperty(value = "用户账号") @ApiModelProperty(value = "用户账号")
private String accountNumber; private String accountNumber;
} }
...@@ -52,8 +52,11 @@ public class WalletDetailListDTO { ...@@ -52,8 +52,11 @@ public class WalletDetailListDTO {
private String activityName; private String activityName;
@ApiModelProperty(value = "单号") @ApiModelProperty(value = "第三方单号")
private Integer cono; private Integer cono;
@ApiModelProperty(value = "提现单号")
private String withDrawOrderNo;
@ApiModelProperty(value = "操作时间", hidden = true ) @ApiModelProperty(value = "操作时间", hidden = true )
private Long crtTime; private Long crtTime;
......
...@@ -47,11 +47,9 @@ public class MyWalletCath implements Serializable { ...@@ -47,11 +47,9 @@ public class MyWalletCath implements Serializable {
@ApiModelProperty(value = "用户账号") @ApiModelProperty(value = "用户账号")
private String accountNumber; private String accountNumber;
/**
* 第三方订单号:如微信,支付宝,银行卡等
*/
@Column(name = "cono") @Column(name = "cono")
@ApiModelProperty(value = "第三方订单号:如微信,支付宝,银行卡等") @ApiModelProperty(value = "提现单号")
private String cono; private String cono;
...@@ -122,5 +120,7 @@ public class MyWalletCath implements Serializable { ...@@ -122,5 +120,7 @@ public class MyWalletCath implements Serializable {
@ApiModelProperty(value = "操作者ID") @ApiModelProperty(value = "操作者ID")
private String updUser; private String updUser;
@Column(name = "order_no")
@ApiModelProperty(value = "第三方订单号:如微信,支付宝,银行卡等")
private String orderNo;
} }
...@@ -81,7 +81,7 @@ public class MyWalletDetail implements Serializable { ...@@ -81,7 +81,7 @@ public class MyWalletDetail implements Serializable {
@Column(name = "activity_name") @Column(name = "activity_name")
private String activityName; private String activityName;
/** /**
* 单号 * 单号
*/ */
@Column(name = "cono") @Column(name = "cono")
...@@ -109,4 +109,8 @@ public class MyWalletDetail implements Serializable { ...@@ -109,4 +109,8 @@ public class MyWalletDetail implements Serializable {
@ApiModelProperty(value = "操作时间", hidden = true ) @ApiModelProperty(value = "操作时间", hidden = true )
private Long crtTime; private Long crtTime;
@ApiModelProperty(value = "提现")
@Column(name = "with_draw_order_no")
private String withDrawOrderNo;
} }
package com.github.wxiaoqi.security.admin.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/10/10 17:52
*/
@Data
@Builder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
public class PayAccountVo {
@ApiModelProperty(value = "微信用户名 | 支付宝帐号")
private String accountDesc;
@ApiModelProperty("微信用户名 | 支付宝账号")
private String account;
@ApiModelProperty(value = "帐户类型 0:微信 1:支付宝 2:银行卡")
private Integer accountType;
}
package com.github.wxiaoqi.security.admin.vo; package com.github.wxiaoqi.security.admin.vo;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -12,6 +14,8 @@ import java.math.BigDecimal; ...@@ -12,6 +14,8 @@ import java.math.BigDecimal;
* @data 2019/7/17 20:22 * @data 2019/7/17 20:22
*/ */
@Data @Data
@NoArgsConstructor
@AllArgsConstructor
public class WalletCathAdminVo { public class WalletCathAdminVo {
private Long id; private Long id;
...@@ -37,10 +41,13 @@ public class WalletCathAdminVo { ...@@ -37,10 +41,13 @@ public class WalletCathAdminVo {
@ApiModelProperty(value = "审核日期") @ApiModelProperty(value = "审核日期")
private Long finishTime; private Long finishTime;
@ApiModelProperty("单号") @ApiModelProperty("提现单号")
private String cono; private String withDrawOrderNo;
@ApiModelProperty(value = "用户账号") @ApiModelProperty(value = "用户账号")
private String accountNumber; private String accountNumber;
@ApiModelProperty(value = "用户账号描述")
private String accountNumberDesc;
} }
...@@ -3,6 +3,8 @@ package com.github.wxiaoqi.security.admin.vo; ...@@ -3,6 +3,8 @@ package com.github.wxiaoqi.security.admin.vo;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
/** /**
* @author libin * @author libin
* @version 1.0 * @version 1.0
...@@ -30,9 +32,24 @@ public class WalletCathDetailVo { ...@@ -30,9 +32,24 @@ public class WalletCathDetailVo {
@ApiModelProperty(value = "审核日期") @ApiModelProperty(value = "审核日期")
private Long finishTime; private Long finishTime;
@ApiModelProperty(value = "帐号") @ApiModelProperty(value = "帐号:支付宝帐号|微信名")
private String accountNumber; private String accountNumber;
@ApiModelProperty("审核失败原因") @ApiModelProperty("审核失败原因")
private String reason; private String reason;
@ApiModelProperty(value = "提现类别,第三方提现类别(0-微信,1-支付宝,2-银行卡)")
private Integer cathType;
@ApiModelProperty(value = "提现单号")
private String orderNo;
@ApiModelProperty(value = "手续费")
private BigDecimal commission;
@ApiModelProperty(value = "提现金额")
private BigDecimal amount;
@ApiModelProperty(value = "到账金额")
private BigDecimal realAmount;
} }
...@@ -46,6 +46,9 @@ public class WalletDetailAdminVo { ...@@ -46,6 +46,9 @@ public class WalletDetailAdminVo {
@ApiModelProperty(value = "单号") @ApiModelProperty(value = "单号")
private Integer cono; private Integer cono;
@ApiModelProperty(value = "提现单号")
private String withDrawOrderNo;
@ApiModelProperty(value = "操作时间", hidden = true ) @ApiModelProperty(value = "操作时间", hidden = true )
private Long crtTime; private Long crtTime;
......
...@@ -184,7 +184,9 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A ...@@ -184,7 +184,9 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
BigDecimal amount = new BigDecimal("0.00"); BigDecimal amount = new BigDecimal("0.00");
Integer userId = 0; Integer userId = 0;
Integer orderType = 0; Integer orderType = 0;
String orderNo = "";
if (list.size() > 0) { if (list.size() > 0) {
orderNo = list.get(0).getOrderNo();
for (AppUserSellingWater sellingWater : list) { for (AppUserSellingWater sellingWater : list) {
Integer id = sellingWater.getId(); Integer id = sellingWater.getId();
orderType = sellingWater.getOrderType(); orderType = sellingWater.getOrderType();
...@@ -204,6 +206,7 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A ...@@ -204,6 +206,7 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
detail.setUserId(userId); detail.setUserId(userId);
detail.setAmount(amount); detail.setAmount(amount);
detail.setCono(orderId); detail.setCono(orderId);
detail.setWithDrawOrderNo(orderNo);
detail.setSource(1); detail.setSource(1);
myWaterBiz.updMyWater(detail); myWaterBiz.updMyWater(detail);
if (orderType == 1 || orderType == 2) { if (orderType == 1 || orderType == 2) {
...@@ -229,7 +232,9 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A ...@@ -229,7 +232,9 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
BigDecimal unbooked = new BigDecimal("0.00"); BigDecimal unbooked = new BigDecimal("0.00");
Integer userId = 0; Integer userId = 0;
Integer orderType = 0; Integer orderType = 0;
String orderNo = "";
if (list.size() > 0) { if (list.size() > 0) {
orderNo = list.get(0).getOrderNo();
for (AppUserSellingWater sellingWater : list) { for (AppUserSellingWater sellingWater : list) {
Integer id = sellingWater.getId(); Integer id = sellingWater.getId();
orderType = sellingWater.getOrderType(); orderType = sellingWater.getOrderType();
...@@ -251,6 +256,7 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A ...@@ -251,6 +256,7 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
detail.setUserId(userId); detail.setUserId(userId);
detail.setAmount(amount); detail.setAmount(amount);
detail.setCono(orderId); detail.setCono(orderId);
detail.setWithDrawOrderNo(orderNo);
detail.setSource(1); detail.setSource(1);
myWaterBiz.updMyWater(detail); myWaterBiz.updMyWater(detail);
} }
...@@ -370,7 +376,7 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A ...@@ -370,7 +376,7 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
sellingWalletVo.setUsername(username); sellingWalletVo.setUsername(username);
if (userIdAndAppUserDetailMap != null) { if (userIdAndAppUserDetailMap != null) {
AppUserDetail appUserDetail = userIdAndAppUserDetailMap.get(sellingWalletVo.getSourceId()); AppUserDetail appUserDetail = userIdAndAppUserDetailMap.get(sellingWalletVo.getSourceId());
sellingWalletVo.setNickName(appUserDetail == null ? "" : appUserDetail.getNickname()); sellingWalletVo.setNickName(appUserDetail == null ? "" : appUserDetail.getRealname());
sellingWalletVo.setHeadUrl(appUserDetail == null ? "" : appUserDetail.getHeadimgurl()); sellingWalletVo.setHeadUrl(appUserDetail == null ? "" : appUserDetail.getHeadimgurl());
} }
//取消单 //取消单
......
package com.github.wxiaoqi.security.admin.biz; package com.github.wxiaoqi.security.admin.biz;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.dto.WalletCathSumDto; import com.github.wxiaoqi.security.admin.dto.WalletCathSumDto;
...@@ -10,29 +11,44 @@ import com.github.wxiaoqi.security.admin.mapper.MyWalletMapper; ...@@ -10,29 +11,44 @@ import com.github.wxiaoqi.security.admin.mapper.MyWalletMapper;
import com.github.wxiaoqi.security.admin.rpc.service.AppPermissionService; import com.github.wxiaoqi.security.admin.rpc.service.AppPermissionService;
import com.github.wxiaoqi.security.admin.vo.AppletWalletVo; import com.github.wxiaoqi.security.admin.vo.AppletWalletVo;
import com.github.wxiaoqi.security.admin.vo.ApplyCathVo; import com.github.wxiaoqi.security.admin.vo.ApplyCathVo;
import com.github.wxiaoqi.security.admin.vo.PayAccountVo;
import com.github.wxiaoqi.security.admin.vo.WalletPageVo; import com.github.wxiaoqi.security.admin.vo.WalletPageVo;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.constant.UserConstant; import com.github.wxiaoqi.security.common.constant.UserConstant;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.ClientUtil;
import com.github.wxiaoqi.security.common.util.OrderUtil;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.app.entity.vo.WithDrawRuleVo; import com.xxfc.platform.app.entity.vo.WithDrawRuleVo;
import com.xxfc.platform.app.feign.ConfigFeign; import com.xxfc.platform.app.feign.ConfigFeign;
import com.xxfc.platform.im.utils.StringUtil;
import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.universal.vo.FundPayVo;
import com.xxfc.platform.universal.weixin.constant.PaySubErrorCodeEnum;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.implementation.bytecode.Throw;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.time.Instant; import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.Executors;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -44,31 +60,40 @@ import java.util.stream.Collectors; ...@@ -44,31 +60,40 @@ import java.util.stream.Collectors;
@Transactional @Transactional
@Service @Service
@Slf4j @Slf4j
public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> { public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> implements InitializingBean {
@Autowired @Autowired
private MyWalletDetailBiz myWalletDetailBiz; private MyWalletDetailBiz myWalletDetailBiz;
@Autowired @Autowired
private MyWalletCathBiz myWalletCathBiz; private MyWalletCathBiz myWalletCathBiz;
@Autowired @Autowired
private AppPermissionService permissionService; private AppPermissionService permissionService;
@Autowired @Autowired
private RedisTemplate userRedisTemplate; private RedisTemplate userRedisTemplate;
@Autowired @Autowired
private ConfigFeign configFeign; private ConfigFeign configFeign;
@Autowired @Autowired
private AppUserAlipayBiz alipayBiz; private AppUserDetailBiz appUserDetailBiz;
@Autowired @Autowired
private AppUserLoginBiz appUserLoginBiz; private AppUserLoginBiz appUserLoginBiz;
@Autowired
private AppUserAlipayBiz appUserAlipayBiz;
private BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(12); @Autowired
private ThirdFeign thirdFeign;
private Snowflake snowflake;
private DateTimeFormatter dateTimeFormatter;
private BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(12);
public AppletWalletVo findMyWallet(Integer userId) { public AppletWalletVo findMyWallet(Integer userId) {
...@@ -81,47 +106,46 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> { ...@@ -81,47 +106,46 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> {
List<MyWallet> wallets = mapper.selectByExample(example); List<MyWallet> wallets = mapper.selectByExample(example);
MyWallet myWallet = wallets.get(0); MyWallet myWallet = wallets.get(0);
appletWalletVo.setBalance(myWallet.getBalance()==null?new BigDecimal(0):myWallet.getBalance()); appletWalletVo.setBalance(myWallet.getBalance() == null ? new BigDecimal(0) : myWallet.getBalance());
appletWalletVo.setTodayAmount(myWallet.getTodayAmount()==null?new BigDecimal(0):myWallet.getTodayAmount()); appletWalletVo.setTodayAmount(myWallet.getTodayAmount() == null ? new BigDecimal(0) : myWallet.getTodayAmount());
appletWalletVo.setTotalAmount(myWallet.getTotalAmount()==null?new BigDecimal(0):myWallet.getTotalAmount()); appletWalletVo.setTotalAmount(myWallet.getTotalAmount() == null ? new BigDecimal(0) : myWallet.getTotalAmount());
appletWalletVo.setUnbooked(myWallet.getUnbooked()==null?new BigDecimal(0):myWallet.getUnbooked()); appletWalletVo.setUnbooked(myWallet.getUnbooked() == null ? new BigDecimal(0) : myWallet.getUnbooked());
appletWalletVo.setUserId(myWallet.getUserId()); appletWalletVo.setUserId(myWallet.getUserId());
return appletWalletVo; return appletWalletVo;
} }
public PageDataVO<WalletPageVo> listWalletWithPage(WalletFindDTO walletFindDTO) { public PageDataVO<WalletPageVo> listWalletWithPage(WalletFindDTO walletFindDTO) {
PageDataVO<WalletPageVo> walletPageVo = new PageDataVO<>(); PageDataVO<WalletPageVo> walletPageVo = new PageDataVO<>();
PageDataVO<WalletListDTO> walletPage = PageDataVO.pageInfo(walletFindDTO.getPage(), walletFindDTO.getLimit(), () -> mapper.selectByPhoneOrUserName(walletFindDTO.getPhone(), walletFindDTO.getUsername())); PageDataVO<WalletListDTO> walletPage = PageDataVO.pageInfo(walletFindDTO.getPage(), walletFindDTO.getLimit(), () -> mapper.selectByPhoneOrUserName(walletFindDTO.getPhone(), walletFindDTO.getUsername()));
List<WalletListDTO> wallets = walletPage.getData(); List<WalletListDTO> wallets = walletPage.getData();
if(CollectionUtils.isEmpty(wallets)){ if (CollectionUtils.isEmpty(wallets)) {
return walletPageVo; return walletPageVo;
} }
List<Integer> userIds = wallets.stream().map(WalletListDTO::getUserId).collect(Collectors.toList()); List<Integer> userIds = wallets.stream().map(WalletListDTO::getUserId).collect(Collectors.toList());
Map<Integer, BigDecimal> userIdAndTotalConsumptionMap = myWalletDetailBiz.finduserIdAndPersonalTotalConsumptionMapByUserIds(userIds); Map<Integer, BigDecimal> userIdAndTotalConsumptionMap = myWalletDetailBiz.finduserIdAndPersonalTotalConsumptionMapByUserIds(userIds);
Map<Integer,BigDecimal> userIdAndWithdrawalingMap = myWalletCathBiz.findUserIdAndWithdrawalingMapByUserIds(userIds); Map<Integer, BigDecimal> userIdAndWithdrawalingMap = myWalletCathBiz.findUserIdAndWithdrawalingMapByUserIds(userIds);
List<WalletPageVo> walletPageVos = new ArrayList<>(); List<WalletPageVo> walletPageVos = new ArrayList<>();
WalletPageVo walletpg ; WalletPageVo walletpg;
for (WalletListDTO wallet : wallets) { for (WalletListDTO wallet : wallets) {
walletpg = new WalletPageVo(); walletpg = new WalletPageVo();
BeanUtils.copyProperties(wallet,walletpg); BeanUtils.copyProperties(wallet, walletpg);
walletpg.setUsername(StringUtils.isEmpty(wallet.getRealname())?wallet.getNickname():wallet.getRealname()); walletpg.setUsername(StringUtils.isEmpty(wallet.getRealname()) ? wallet.getNickname() : wallet.getRealname());
walletpg.setPhone(wallet.getUsername()); walletpg.setPhone(wallet.getUsername());
BigDecimal totalConsumpution = userIdAndTotalConsumptionMap==null?new BigDecimal(0):userIdAndTotalConsumptionMap.get(wallet.getUserId())==null?new BigDecimal(0):userIdAndTotalConsumptionMap.get(wallet.getUserId()); BigDecimal totalConsumpution = userIdAndTotalConsumptionMap == null ? new BigDecimal(0) : userIdAndTotalConsumptionMap.get(wallet.getUserId()) == null ? new BigDecimal(0) : userIdAndTotalConsumptionMap.get(wallet.getUserId());
BigDecimal withDrawaling = userIdAndWithdrawalingMap==null?new BigDecimal(0):userIdAndWithdrawalingMap.get(wallet.getUserId())==null?new BigDecimal(0):userIdAndWithdrawalingMap.get(wallet.getUserId()); BigDecimal withDrawaling = userIdAndWithdrawalingMap == null ? new BigDecimal(0) : userIdAndWithdrawalingMap.get(wallet.getUserId()) == null ? new BigDecimal(0) : userIdAndWithdrawalingMap.get(wallet.getUserId());
walletpg.setWithdrawaling(withDrawaling); walletpg.setWithdrawaling(withDrawaling);
walletpg.setWithdrawals(walletpg.getWithdrawals()==null?new BigDecimal(0):walletpg.getWithdrawals()); walletpg.setWithdrawals(walletpg.getWithdrawals() == null ? new BigDecimal(0) : walletpg.getWithdrawals());
walletpg.setUnbooked(walletpg.getUnbooked()==null?new BigDecimal(0):walletpg.getUnbooked()); walletpg.setUnbooked(walletpg.getUnbooked() == null ? new BigDecimal(0) : walletpg.getUnbooked());
walletpg.setTotalAmount(walletpg.getTodayAmount()==null?new BigDecimal(0):walletpg.getTotalAmount()); walletpg.setTotalAmount(walletpg.getTodayAmount() == null ? new BigDecimal(0) : walletpg.getTotalAmount());
walletpg.setTotalConsumption(totalConsumpution); walletpg.setTotalConsumption(totalConsumpution);
walletPageVos.add(walletpg); walletPageVos.add(walletpg);
} }
walletPageVos.sort(Comparator.comparing(WalletPageVo::getTotalAmount).reversed()); walletPageVos.sort(Comparator.comparing(WalletPageVo::getTotalAmount).reversed());
walletPageVo.setPageNum(walletFindDTO.getPage()); walletPageVo.setPageNum(walletFindDTO.getPage());
walletPageVo.setPageSize(walletFindDTO.getLimit()); walletPageVo.setPageSize(walletFindDTO.getLimit());
...@@ -132,113 +156,113 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> { ...@@ -132,113 +156,113 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> {
} }
//检查手机号码是否正确 //检查手机号码是否正确
public ObjectRestResponse checkCode(String phone,String mobilecod){ public ObjectRestResponse checkCode(String phone, String mobilecod) {
boolean flag=false; boolean flag = false;
String key=permissionService.checkCodeByUsername(phone,mobilecod); String key = permissionService.checkCodeByUsername(phone, mobilecod);
if (StringUtils.isNotBlank(key)){ if (StringUtils.isNotBlank(key)) {
flag=true; flag = true;
} }
return ObjectRestResponse.succ(flag); return ObjectRestResponse.succ(flag);
} }
//设置密码type 1-设置密码;2-修改密码 //设置密码type 1-设置密码;2-修改密码
public ObjectRestResponse setPwd(Integer userId,String phone,String mobilecod,String password,Integer type){ public ObjectRestResponse setPwd(Integer userId, String phone, String mobilecod, String password, Integer type) {
if (StringUtils.isBlank(phone)||StringUtils.isBlank(mobilecod)||StringUtils.isBlank(password)){ if (StringUtils.isBlank(phone) || StringUtils.isBlank(mobilecod) || StringUtils.isBlank(password)) {
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数为空"); return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数为空");
} }
String key=permissionService.checkCodeByUsername(phone,mobilecod); String key = permissionService.checkCodeByUsername(phone, mobilecod);
if (StringUtils.isBlank(key)){ if (StringUtils.isBlank(key)) {
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, "验证码错误"); return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, "验证码错误");
} }
userRedisTemplate.delete(key); userRedisTemplate.delete(key);
MyWallet myWallet=new MyWallet(); MyWallet myWallet = new MyWallet();
myWallet.setUserId(userId); myWallet.setUserId(userId);
myWallet = selectOne(myWallet); myWallet = selectOne(myWallet);
if (myWallet==null){ if (myWallet == null) {
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "钱包不存在"); return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "钱包不存在");
} }
if(type==1&&StringUtils.isNotBlank(myWallet.getPayPassword())){ if (type == 1 && StringUtils.isNotBlank(myWallet.getPayPassword())) {
return ObjectRestResponse.createFailedResult(ResultCode.EXIST_CODE, "密码已存在"); return ObjectRestResponse.createFailedResult(ResultCode.EXIST_CODE, "密码已存在");
} }
password=new BCryptPasswordEncoder(UserConstant.PW_ENCORDER_SALT).encode(password); password = new BCryptPasswordEncoder(UserConstant.PW_ENCORDER_SALT).encode(password);
myWallet.setPayPassword(password); myWallet.setPayPassword(password);
updateSelectiveById(myWallet); updateSelectiveById(myWallet);
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
//检查用户是否设置过密码 //检查用户是否设置过密码
public ObjectRestResponse checkSetPwd(Integer userId){ public ObjectRestResponse checkSetPwd(Integer userId) {
MyWallet myWallet=new MyWallet(); MyWallet myWallet = new MyWallet();
myWallet.setUserId(userId); myWallet.setUserId(userId);
myWallet = selectOne(myWallet); myWallet = selectOne(myWallet);
if (myWallet==null){ if (myWallet == null) {
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "钱包不存在"); return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "钱包不存在");
} }
boolean flag=false; boolean flag = false;
if(StringUtils.isNotBlank(myWallet.getPayPassword())){ if (StringUtils.isNotBlank(myWallet.getPayPassword())) {
flag=true; flag = true;
} }
return ObjectRestResponse.succ(flag); return ObjectRestResponse.succ(flag);
} }
//检查提成下一步操作 //检查提成下一步操作
public ObjectRestResponse checkAmount(Integer userId,BigDecimal amount,String password){ public ObjectRestResponse checkAmount(Integer userId, BigDecimal amount, String password) {
if (amount.compareTo(BigDecimal.ZERO)<1){ if (amount.compareTo(BigDecimal.ZERO) < 1) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现金额不能小于0"); return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现金额不能小于0");
} }
MyWallet myWallet=new MyWallet(); MyWallet myWallet = new MyWallet();
myWallet.setUserId(userId); myWallet.setUserId(userId);
myWallet = selectOne(myWallet); myWallet = selectOne(myWallet);
if (myWallet==null){ if (myWallet == null) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "钱包不存在"); return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "钱包不存在");
} }
if (amount.compareTo(myWallet.getBalance())>0){ if (amount.compareTo(myWallet.getBalance()) > 0) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现金额不能大于钱包金额"); return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现金额不能大于钱包金额");
} }
if (StringUtils.isNotBlank(password)&&!encoder.matches(password,myWallet.getPayPassword())){ if (StringUtils.isNotBlank(password) && !encoder.matches(password, myWallet.getPayPassword())) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "支付密码错误"); return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "支付密码错误");
} }
WithDrawRuleVo ruleVo=configFeign.getWithDrawRule(); WithDrawRuleVo ruleVo = configFeign.getWithDrawRule();
BigDecimal proceduReates=BigDecimal.ZERO; BigDecimal proceduReates = BigDecimal.ZERO;
WalletCathSumDto sumDto=new WalletCathSumDto(); WalletCathSumDto sumDto = new WalletCathSumDto();
if (ruleVo!=null){ if (ruleVo != null) {
proceduReates=ruleVo.getProceduReates(); proceduReates = ruleVo.getProceduReates();
//提现次数 //提现次数
Integer number=1; Integer number = 1;
//最小金额 //最小金额
BigDecimal mimAmount=ruleVo.getMinAmount(); BigDecimal mimAmount = ruleVo.getMinAmount();
if (mimAmount.compareTo(BigDecimal.ZERO)>0&&amount.compareTo(mimAmount)<0){ if (mimAmount.compareTo(BigDecimal.ZERO) > 0 && amount.compareTo(mimAmount) < 0) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现金额不能小于"+mimAmount+"元"); return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现金额不能小于" + mimAmount + "元");
} }
//日额度 //日额度
BigDecimal amountOfDay=ruleVo.getAmountOfDay(); BigDecimal amountOfDay = ruleVo.getAmountOfDay();
//每日次数 //每日次数
Integer maxNumberOfDay=ruleVo.getMaxNumberOfDay()==null?0:ruleVo.getMaxNumberOfDay(); Integer maxNumberOfDay = ruleVo.getMaxNumberOfDay() == null ? 0 : ruleVo.getMaxNumberOfDay();
//查询当日次数和金额 //查询当日次数和金额
sumDto=myWalletCathBiz.sumCathAmount(userId,1); sumDto = myWalletCathBiz.sumCathAmount(userId, 1);
BigDecimal ramount=amount.add(sumDto.getSumAmount()); BigDecimal ramount = amount.add(sumDto.getSumAmount());
if (amountOfDay.compareTo(BigDecimal.ZERO)>0&&ramount.compareTo(amountOfDay)>0){ if (amountOfDay.compareTo(BigDecimal.ZERO) > 0 && ramount.compareTo(amountOfDay) > 0) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现金额超过日额度"+amountOfDay+"元"); return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现金额超过日额度" + amountOfDay + "元");
} }
number+=sumDto.getNumber(); number += sumDto.getNumber();
if (maxNumberOfDay>0&&number>maxNumberOfDay){ if (maxNumberOfDay > 0 && number > maxNumberOfDay) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现当日次数超过"+maxNumberOfDay+"次"); return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现当日次数超过" + maxNumberOfDay + "次");
} }
number=1; number = 1;
//月额度 //月额度
BigDecimal amountOfMonth=ruleVo.getAmountOfMonth(); BigDecimal amountOfMonth = ruleVo.getAmountOfMonth();
//月次数 //月次数
Integer maxNumberOfMonth=ruleVo.getMaxNumberOfMonth(); Integer maxNumberOfMonth = ruleVo.getMaxNumberOfMonth();
//查询当月次数和金额 //查询当月次数和金额
sumDto=myWalletCathBiz.sumCathAmount(userId,2); sumDto = myWalletCathBiz.sumCathAmount(userId, 2);
BigDecimal yamount=amount.add(sumDto.getSumAmount()); BigDecimal yamount = amount.add(sumDto.getSumAmount());
if (amountOfMonth.compareTo(BigDecimal.ZERO)>0&&yamount.compareTo(amountOfMonth)>0){ if (amountOfMonth.compareTo(BigDecimal.ZERO) > 0 && yamount.compareTo(amountOfMonth) > 0) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现金额超过月额度"+amountOfMonth+"元"); return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现金额超过月额度" + amountOfMonth + "元");
} }
number+=sumDto.getNumber(); number += sumDto.getNumber();
if (maxNumberOfMonth>0&&number>maxNumberOfMonth){ if (maxNumberOfMonth > 0 && number > maxNumberOfMonth) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现当月次数超过"+maxNumberOfMonth+"次"); return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "提现当月次数超过" + maxNumberOfMonth + "次");
} }
} }
...@@ -246,128 +270,199 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> { ...@@ -246,128 +270,199 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> {
sumDto.setProceduReates(proceduReates); sumDto.setProceduReates(proceduReates);
sumDto.setWalletId(myWallet.getId()); sumDto.setWalletId(myWallet.getId());
sumDto.setVersion(myWallet.getVersion()); sumDto.setVersion(myWallet.getVersion());
return ObjectRestResponse.succ(sumDto); return ObjectRestResponse.succ(sumDto);
} }
//返回提现规则 //返回提现规则
public ObjectRestResponse getCathRule(){ public ObjectRestResponse getCathRule() {
return ObjectRestResponse.succ(configFeign.getWithDrawRule()); return ObjectRestResponse.succ(configFeign.getWithDrawRule());
} }
//提现申请 //提现申请
public ObjectRestResponse applyCath(ApplyCathVo applyCathVo){ public ObjectRestResponse applyCath(ApplyCathVo applyCathVo) {
if (applyCathVo==null){ if (applyCathVo == null) {
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数不能为空"); return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数不能为空");
} }
Integer userId=applyCathVo.getUserId(); Integer userId = applyCathVo.getUserId();
BigDecimal amount=applyCathVo.getAmount(); BigDecimal amount = applyCathVo.getAmount();
String password=applyCathVo.getPassword(); String password = applyCathVo.getPassword();
String accountNumber=applyCathVo.getAccountNumber(); String accountNumber = applyCathVo.getAccountNumber();
Integer cathType=applyCathVo.getCathType()==null?1:applyCathVo.getCathType(); Integer cathType = applyCathVo.getCathType() == null ? 1 : applyCathVo.getCathType();
if (StringUtils.isBlank(password)||amount.compareTo(BigDecimal.ZERO)<1){ if (StringUtils.isBlank(password) || amount.compareTo(BigDecimal.ZERO) < 1) {
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数不能为空"); return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数不能为空");
} }
ObjectRestResponse restResponse=checkAmount(userId,amount,password); ObjectRestResponse restResponse = checkAmount(userId, amount, password);
if (restResponse.getStatus()!=ResultCode.SUCCESS_CODE){ if (restResponse.getStatus() != ResultCode.SUCCESS_CODE) {
return restResponse; return restResponse;
} }
String data=JSONObject.toJSONString(restResponse.getData()); String data = JSONObject.toJSONString(restResponse.getData());
WalletCathSumDto sumDto=JSONUtil.toBean( data,WalletCathSumDto.class); WalletCathSumDto sumDto = JSONUtil.toBean(data, WalletCathSumDto.class);
if (sumDto==null){ if (sumDto == null) {
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数不能为空"); return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数不能为空");
} }
BigDecimal commission=amount.multiply(sumDto.getProceduReates()).divide(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); BigDecimal commission = amount.multiply(sumDto.getProceduReates()).divide(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP);
BigDecimal balnece=sumDto.getBalance(); BigDecimal balnece = sumDto.getBalance();
//到账金额 //到账金额
BigDecimal realAmount=amount; BigDecimal realAmount = amount;
if ((realAmount.add(commission)).compareTo(balnece)>0){ if ((realAmount.add(commission)).compareTo(balnece) > 0) {
realAmount=balnece.subtract(commission); realAmount = balnece.subtract(commission);
} }
log.info("-----提现申请-----proceduReates==="+sumDto.getProceduReates()+"----commission===="+commission+"---realAmount==="+realAmount); log.info("-----提现申请-----proceduReates===" + sumDto.getProceduReates() + "----commission====" + commission + "---realAmount===" + realAmount);
//添加账号 //添加账号
alipayBiz.addAlipay(userId,accountNumber); // alipayBiz.addAlipay(userId,accountNumber);
MyWalletCath walletCath=new MyWalletCath(); MyWalletCath walletCath = new MyWalletCath();
walletCath.setUserId(userId); //提现单号
walletCath.setBalance(balnece); String orderNo = snowflake.nextIdStr();
walletCath.setCathType(cathType); orderNo = String.format("%s%s", dateTimeFormatter.format(LocalDate.now()), orderNo);
walletCath.setAccountNumber(accountNumber); walletCath.setOrderNo(orderNo);
walletCath.setAmount(amount); walletCath.setUserId(userId);
walletCath.setCommission(commission); walletCath.setBalance(balnece);
walletCath.setRealAmount(realAmount); walletCath.setCathType(cathType);
myWalletCathBiz.insertSelective(walletCath); walletCath.setAccountNumber(accountNumber);
//提现金额 walletCath.setAmount(amount);
BigDecimal withdrawals=realAmount.add(commission); walletCath.setCommission(commission);
balnece=balnece.subtract(withdrawals).setScale(2, RoundingMode.HALF_UP); walletCath.setRealAmount(realAmount);
log.info("------钱包----withdrawals==="+withdrawals+"----balnece===="+balnece); myWalletCathBiz.insertSelective(walletCath);
MyWallet myWallet=new MyWallet(); //提现金额
myWallet.setId(sumDto.getWalletId()); BigDecimal withdrawals = realAmount.add(commission);
myWallet.setUserId(userId); balnece = balnece.subtract(withdrawals).setScale(2, RoundingMode.HALF_UP);
myWallet.setBalance(balnece); log.info("------钱包----withdrawals===" + withdrawals + "----balnece====" + balnece);
myWallet.setWithdrawals(withdrawals); MyWallet myWallet = new MyWallet();
myWallet.setVersion(sumDto.getVersion()); myWallet.setId(sumDto.getWalletId());
mapper.updMyWater(myWallet); myWallet.setUserId(userId);
return ObjectRestResponse.succ(walletCath.getId()); myWallet.setBalance(balnece);
myWallet.setWithdrawals(withdrawals);
myWallet.setVersion(sumDto.getVersion());
mapper.updMyWater(myWallet);
return ObjectRestResponse.succ(walletCath.getId());
} }
//提现审核 //提现审核
public ObjectRestResponse verifyCath(Integer cathId,String cono,String reason,Integer status){ public ObjectRestResponse verifyCath(Integer cathId, String reason, Integer status) {
if ((status==1&&StringUtils.isBlank(cono))||(status==2&&StringUtils.isBlank(reason))||cathId==null||cathId==0){ if (status == 2 && StringUtils.isBlank(reason) || cathId == null || cathId == 0) {
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数不能为空"); return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数不能为空");
} }
MyWalletCath cath=myWalletCathBiz.selectById(cathId); MyWalletCath cath = myWalletCathBiz.selectById(cathId);
if (cath==null){ cath.getUserId();
if (cath == null) {
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, "提现记录不存在"); return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, "提现记录不存在");
} }
cath.setStauts(status);
cath.setCono(cono);
cath.setReason(reason);
cath.setFinishTime(System.currentTimeMillis());
int num=myWalletCathBiz.updateSelectiveByIdRe(cath);
if (num>0){
Integer userId=cath.getUserId();
MyWallet wallet=new MyWallet();
wallet.setUserId(userId);
wallet=selectOne(wallet);
if (wallet!=null){
//当时钱包的余额
BigDecimal balance=cath.getBalance();
BigDecimal realAmount=cath.getRealAmount();
BigDecimal commission=cath.getCommission();
if (status==1){
MyWalletDetail detail=new MyWalletDetail();
detail.setUserId(userId);
detail.setItype(1);
detail.setCono(cathId);
detail.setBalance(balance);
detail.setAmount(realAmount);
detail.setSource(10);
myWalletDetailBiz.insertSelective(detail);
detail.setId(null);
detail.setSource(13);
balance=balance.subtract(realAmount).setScale(2, RoundingMode.HALF_UP);
detail.setBalance(balance);
detail.setAmount(commission);
myWalletDetailBiz.insertSelective(detail);
}else {
BigDecimal amount=realAmount.add(commission);
balance=wallet.getBalance().add(amount);
BigDecimal withdrawals=wallet.getWithdrawals().subtract(amount);
wallet.setBalance(balance);
wallet.setWithdrawals(withdrawals);
mapper.updMyWater(wallet);
}
boolean isContinuePay = false;
String errorMsg = "";
Integer userId = cath.getUserId();
MyWallet wallet = new MyWallet();
wallet.setUserId(userId);
wallet = selectOne(wallet);
if (wallet != null) {
//当时钱包的余额
BigDecimal balance = cath.getBalance();
BigDecimal realAmount = cath.getRealAmount();
BigDecimal commission = cath.getCommission();
if (status == 1) {
String cono = StringUtil.isEmpty(cath.getCono()) ? OrderUtil.GetOrderNumber("TX"):cath.getCono();
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String host = StringUtils.defaultIfBlank(request.getHeader("userHost"), ClientUtil.getClientIp(request));
FundPayVo fundPayVo = FundPayVo.builder()
.amount(cath.getCathType() == 0 ? String.valueOf(cath.getRealAmount().multiply(new BigDecimal(100)).doubleValue()) : String.format("%.2f", cath.getRealAmount().doubleValue()))
.outBizNo(cono)
.payeeAccount(cath.getAccountNumber())
.payerShowName("欣新房车网络科技(广东)股份有限公司")
.remark("提现转账")
.type(cath.getCathType())
.creatIp(host)
.build();
try {
cono = thirdFeign.transferAccount(fundPayVo);
} catch (BaseException bex) {
if (PaySubErrorCodeEnum.PAY_NEED_ERROR.getSubCode().equals(bex.getSubCode())) {
isContinuePay = true;
errorMsg = bex.getMessage();
} else {
throw new BaseException(bex.getMessage(),400);
}
} catch (Exception ex) {
throw new BaseException(ex);
}
cath.setStauts(isContinuePay ? 0 : status);
//设置第三方单号
cath.setCono(cono);
cath.setFinishTime(System.currentTimeMillis());
myWalletCathBiz.updateSelectiveByIdRe(cath);
MyWalletDetail detail = new MyWalletDetail();
detail.setUserId(userId);
detail.setItype(1);
//设置提现单号
detail.setWithDrawOrderNo(cath.getOrderNo());
detail.setBalance(balance);
detail.setAmount(realAmount);
detail.setSource(10);
myWalletDetailBiz.insertSelective(detail);
detail.setId(null);
detail.setSource(13);
balance = balance.subtract(realAmount).setScale(2, RoundingMode.HALF_UP);
detail.setBalance(balance);
detail.setAmount(commission);
myWalletDetailBiz.insertSelective(detail);
} else {
cath.setStauts(status);
cath.setReason(reason);
cath.setFinishTime(System.currentTimeMillis());
myWalletCathBiz.updateSelectiveByIdRe(cath);
BigDecimal amount = realAmount.add(commission);
balance = wallet.getBalance().add(amount);
BigDecimal withdrawals = wallet.getWithdrawals().subtract(amount);
wallet.setBalance(balance);
wallet.setWithdrawals(withdrawals);
mapper.updMyWater(wallet);
} }
} }
return ObjectRestResponse.succ(); if (isContinuePay) {
} return ObjectRestResponse.createFailedResult(10001, errorMsg);
}
return ObjectRestResponse.succ();
}
public void deleteByUserIds(Collection<Integer> userIds) { public void deleteByUserIds(Collection<Integer> userIds) {
Example example =new Example(MyWallet.class); Example example = new Example(MyWallet.class);
Example.Criteria criteria = example.createCriteria(); Example.Criteria criteria = example.createCriteria();
criteria.andIn("userId",userIds); criteria.andIn("userId", userIds);
mapper.deleteByExample(example); mapper.deleteByExample(example);
} }
public List<PayAccountVo> listPayAccountByUserId(Integer userId) {
List<PayAccountVo> payAccountVos = new ArrayList<>();
List<AppUserAlipay> alipayAccounts = appUserAlipayBiz.getListByUserId(userId);
if (CollectionUtils.isNotEmpty(alipayAccounts)) {
AppUserAlipay appUserAlipay = alipayAccounts.get(0);
PayAccountVo alipayAccount = PayAccountVo.builder()
.account(appUserAlipay.getTxAlipay())
.accountType(1)
.accountDesc(String.format("%s%s%s", "支付宝余额(", appUserAlipay.getTxAlipay(), ")"))
.build();
payAccountVos.add(alipayAccount);
}
AppUserDetail appUserDetail = appUserDetailBiz.getUserByUserid(userId);
AppUserLogin appUserLogin = appUserLoginBiz.getUserById(userId);
if (!org.springframework.util.StringUtils.isEmpty(appUserLogin.getOpenid())) {
PayAccountVo wxAccount = PayAccountVo.builder()
.account(appUserLogin.getOpenid())
.accountType(0)
.accountDesc(String.format("%s%s%s", "微信零钱(", appUserDetail.getNickname(), ")"))
.build();
payAccountVos.add(wxAccount);
}
return payAccountVos;
}
@Override
public void afterPropertiesSet() throws Exception {
snowflake = new Snowflake(2, 2, false);
dateTimeFormatter = DateTimeFormatter.ofPattern("YYYYMMdd");
}
} }
...@@ -88,23 +88,31 @@ public class MyWalletCathBiz extends BaseBiz<MyWalletCathMapper, MyWalletCath> { ...@@ -88,23 +88,31 @@ public class MyWalletCathBiz extends BaseBiz<MyWalletCathMapper, MyWalletCath> {
public PageDataVO<WalletCathAdminVo> listWalletCathWithPage(WalletCathFindDTO walletCathFindDTO) { public PageDataVO<WalletCathAdminVo> listWalletCathWithPage(WalletCathFindDTO walletCathFindDTO) {
PageDataVO<WalletCathAdminVo> walletCathAdminVoPage = new PageDataVO<>(); PageDataVO<WalletCathAdminVo> walletCathAdminVoPage = new PageDataVO<>();
PageDataVO<WalletCathListDTO> walletCathListDTOPage = PageDataVO.pageInfo(walletCathFindDTO.getPage(), PageDataVO<WalletCathListDTO> walletCathListDTOPage = PageDataVO.pageInfo(walletCathFindDTO.getPage(),
walletCathFindDTO.getLimit(), walletCathFindDTO.getLimit(),
() -> mapper.selectByUserNameOrPhoneOrWithDrawSate(walletCathFindDTO.getUsername(), walletCathFindDTO.getPhone(), walletCathFindDTO.getState())); () -> mapper.selectByUserNameOrPhoneOrWithDrawSate(walletCathFindDTO.getUsername(), walletCathFindDTO.getPhone(), walletCathFindDTO.getState()));
List<WalletCathListDTO> walletCathListDTOList = walletCathListDTOPage.getData(); List<WalletCathListDTO> walletCathListDTOList = walletCathListDTOPage.getData();
if (CollectionUtils.isEmpty(walletCathListDTOList)){ if (CollectionUtils.isEmpty(walletCathListDTOList)) {
return walletCathAdminVoPage; return walletCathAdminVoPage;
} }
List<WalletCathAdminVo> walletCathAdminVos = new ArrayList<>(); List<WalletCathAdminVo> walletCathAdminVos = new ArrayList<>();
WalletCathAdminVo walletCathAdminVo ; WalletCathAdminVo walletCathAdminVo;
for (WalletCathListDTO walletCathListDTO : walletCathListDTOList) { for (WalletCathListDTO walletCathListDTO : walletCathListDTOList) {
walletCathAdminVo = new WalletCathAdminVo(); walletCathAdminVo = new WalletCathAdminVo();
BeanUtils.copyProperties(walletCathListDTO,walletCathAdminVo); BeanUtils.copyProperties(walletCathListDTO, walletCathAdminVo);
walletCathAdminVo.setUsername(StringUtils.isEmpty(walletCathListDTO.getRealname())?walletCathListDTO.getNickname():walletCathListDTO.getRealname()); walletCathAdminVo.setUsername(StringUtils.isEmpty(walletCathListDTO.getRealname()) ? walletCathListDTO.getNickname() : walletCathListDTO.getRealname());
walletCathAdminVo.setPhone(walletCathListDTO.getUsername()); 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.add(walletCathAdminVo);
} }
walletCathAdminVos.sort(Comparator.comparing(WalletCathAdminVo::getCrtTime).reversed()); walletCathAdminVos.sort(Comparator.comparing(WalletCathAdminVo::getCrtTime).reversed());
...@@ -123,14 +131,14 @@ public class MyWalletCathBiz extends BaseBiz<MyWalletCathMapper, MyWalletCath> { ...@@ -123,14 +131,14 @@ public class MyWalletCathBiz extends BaseBiz<MyWalletCathMapper, MyWalletCath> {
return userIdAndPersonalConsumptionMap; return userIdAndPersonalConsumptionMap;
} }
public WalletCathSumDto sumCathAmount(Integer userId,Integer type){ public WalletCathSumDto sumCathAmount(Integer userId, Integer type) {
return mapper.sumCathAmount(userId,type); return mapper.sumCathAmount(userId, type);
} }
public void deleteByUserIds(Collection<Integer> userIds) { public void deleteByUserIds(Collection<Integer> userIds) {
Example example = new Example(MyWalletCath.class); Example example = new Example(MyWalletCath.class);
Example.Criteria criteria = example.createCriteria(); Example.Criteria criteria = example.createCriteria();
criteria.andIn("userId",userIds); criteria.andIn("userId", userIds);
mapper.deleteByExample(example); mapper.deleteByExample(example);
} }
} }
...@@ -4,6 +4,7 @@ import com.github.wxiaoqi.security.admin.biz.AppUserAlipayBiz; ...@@ -4,6 +4,7 @@ import com.github.wxiaoqi.security.admin.biz.AppUserAlipayBiz;
import com.github.wxiaoqi.security.admin.biz.MyWalletBiz; import com.github.wxiaoqi.security.admin.biz.MyWalletBiz;
import com.github.wxiaoqi.security.admin.vo.AppletWalletVo; import com.github.wxiaoqi.security.admin.vo.AppletWalletVo;
import com.github.wxiaoqi.security.admin.vo.ApplyCathVo; import com.github.wxiaoqi.security.admin.vo.ApplyCathVo;
import com.github.wxiaoqi.security.admin.vo.PayAccountVo;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig; import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil; import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil;
import com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo; import com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo;
...@@ -14,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -14,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List;
/** /**
* @author libin * @author libin
...@@ -125,4 +127,15 @@ public class MyWalletController { ...@@ -125,4 +127,15 @@ public class MyWalletController {
} }
} }
@ApiOperation("获取支付账号(微信|支付宝|银行卡)")
@GetMapping("/pay_account_list")
public ObjectRestResponse listPayAccount(HttpServletRequest request){
try {
Integer userId = Integer.parseInt(userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request)).getId());
List<PayAccountVo> payAccountVos = myWalletBiz.listPayAccountByUserId(userId);
return ObjectRestResponse.succ(payAccountVos);
}catch (Exception ex){
throw new BaseException(ex);
}
}
} }
...@@ -37,11 +37,10 @@ public class WalletCathAdminController { ...@@ -37,11 +37,10 @@ public class WalletCathAdminController {
@ApiOperation("提现审核") @ApiOperation("提现审核")
public ObjectRestResponse verifyCath( public ObjectRestResponse verifyCath(
@RequestParam(value = "cathId",defaultValue = "0") Integer cathId, @RequestParam(value = "cathId",defaultValue = "0") Integer cathId,
@RequestParam(value = "cono",defaultValue = "") String cono,
@RequestParam(value = "reason",defaultValue = "") String reason, @RequestParam(value = "reason",defaultValue = "") String reason,
@RequestParam(value = "status",defaultValue = "1") Integer status){ @RequestParam(value = "status",defaultValue = "1") Integer status){
try { try {
return myWalletBiz.verifyCath(cathId,cono,reason,status); return myWalletBiz.verifyCath(cathId,reason,status);
}catch (Exception e) { }catch (Exception e) {
throw new BaseException(e); throw new BaseException(e);
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
wc.crt_time AS `crtTime`, wc.crt_time AS `crtTime`,
wc.finish_time AS `finishTime`, wc.finish_time AS `finishTime`,
wc.cono, wc.cono,
wc.order_no AS `orderNo`,
wc.account_number AS `accountNumber` wc.account_number AS `accountNumber`
FROM FROM
(SELECT * FROM `my_wallet_cath` <if test="state != null"> (SELECT * FROM `my_wallet_cath` <if test="state != null">
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
wd.source, wd.source,
wd.amount, wd.amount,
wd.cono, wd.cono,
wd.with_draw_order_no AS `withDrawOrderNo`,
wd.itype, wd.itype,
wd.activity_id AS `activityId`, wd.activity_id AS `activityId`,
wd.activity_name AS `activityName`, wd.activity_name AS `activityName`,
......
...@@ -5,10 +5,7 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; ...@@ -5,10 +5,7 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.universal.dto.SmsTemplateDTO; import com.xxfc.platform.universal.dto.SmsTemplateDTO;
import com.xxfc.platform.universal.entity.Dictionary; import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.entity.IdInformation; import com.xxfc.platform.universal.entity.IdInformation;
import com.xxfc.platform.universal.vo.OrderPayVo; import com.xxfc.platform.universal.vo.*;
import com.xxfc.platform.universal.vo.OrderRefundVo;
import com.xxfc.platform.universal.vo.TrafficViolations;
import com.xxfc.platform.universal.vo.ViolationVO;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -83,4 +80,7 @@ public interface ThirdFeign { ...@@ -83,4 +80,7 @@ public interface ThirdFeign {
public ObjectRestResponse<List<ViolationVO>> getRentViolation(@RequestParam(value = "rentViolationDTO") Map<String, Object> rentViolationDTO); public ObjectRestResponse<List<ViolationVO>> getRentViolation(@RequestParam(value = "rentViolationDTO") Map<String, Object> rentViolationDTO);
/*************************************支付***************************************/
@PostMapping("/pay/app/unauth/transfer_account")
String transferAccount(@RequestBody FundPayVo fundPayVo) throws Exception;
} }
package com.xxfc.platform.universal.vo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
public class FundPayVo {
//转账单号
private String outBizNo;
//转账账号
private String payeeAccount;
private String amount;
//转账方单号
private String payerShowName;
//转账备注
private String remark;
//转账类型
private Integer type;
private String creatIp;
private String checkName;
}
...@@ -55,7 +55,7 @@ public class WXSuppToUserPay { ...@@ -55,7 +55,7 @@ public class WXSuppToUserPay {
private String key; private String key;
public static void main(String[] args) throws Exception, IOException { public static void main(String[] args) throws Exception, IOException {
Map<String, String> map = WXSuppToUserPay.WeiXinTiXian("oRhMfwKwjNq2Ce-TxlqfoAqsYfww", "NO_CHECK", 500+"", "活动提现", "192.168.8.109"); Map<String, String> map = WXSuppToUserPay.WeiXinTiXian("oRhMfwKwjNq2Ce-TxlqfoAqsYfww",OrderUtil.GetOrderNumber("TX"),"NO_CHECK", 500+"", "活动提现", "192.168.8.109");
if("SUCCESS".equals(map.get("return_code"))) if("SUCCESS".equals(map.get("return_code")))
{ {
if(!StringUtils.isBlank(map.get("payment_no")) && !StringUtils.isBlank(map.get("partner_trade_no")) ) if(!StringUtils.isBlank(map.get("payment_no")) && !StringUtils.isBlank(map.get("partner_trade_no")) )
...@@ -108,14 +108,14 @@ public class WXSuppToUserPay { ...@@ -108,14 +108,14 @@ public class WXSuppToUserPay {
// System.out.println(map.get("payment_time")); // System.out.println(map.get("payment_time"));
} }
public static Map<String,String> WeiXinTiXian(String openid,String check_name,String amount,String desc,String spbill_create_ip) throws Exception public static Map<String,String> WeiXinTiXian(String openid,String partnerTradeNo,String check_name,String amount,String desc,String spbill_create_ip) throws Exception
{ {
WXSuppToUserPay prePay = new WXSuppToUserPay(); WXSuppToUserPay prePay = new WXSuppToUserPay();
prePay.setMch_appid(SystemConfig.WINXIN_AppID); prePay.setMch_appid(SystemConfig.WINXIN_AppID);
prePay.setMchid(SystemConfig.WINXIN_PARTNER); prePay.setMchid(SystemConfig.WINXIN_PARTNER);
prePay.setNonce_str( OrderUtil.CreateNoncestr()); prePay.setNonce_str( OrderUtil.CreateNoncestr());
prePay.setPartner_trade_no(OrderUtil.GetOrderNumber("TX")); prePay.setPartner_trade_no(partnerTradeNo);
prePay.setOpenid(openid); prePay.setOpenid(openid);
prePay.setCheck_name(check_name); prePay.setCheck_name(check_name);
prePay.setAmount(amount); prePay.setAmount(amount);
...@@ -130,7 +130,7 @@ public class WXSuppToUserPay { ...@@ -130,7 +130,7 @@ public class WXSuppToUserPay {
CloseableHttpClient httpclient = null; CloseableHttpClient httpclient = null;
try { try {
KeyStore keyStore = KeyStore.getInstance("PKCS12"); KeyStore keyStore = KeyStore.getInstance("PKCS12");
//FileInputStream instream = new FileInputStream(new File("E:/apiclient_cert.p12")); // FileInputStream instream = new FileInputStream(new File("E:/cert/apiclient_cert.p12"));
String path = Thread.currentThread().getContextClassLoader().getResource("/").getPath(); String path = Thread.currentThread().getContextClassLoader().getResource("/").getPath();
FileInputStream instream = new FileInputStream(new File(path+"/apiclient_cert.p12")); FileInputStream instream = new FileInputStream(new File(path+"/apiclient_cert.p12"));
try { try {
......
package com.xxfc.platform.universal.weixin.constant;
import lombok.AllArgsConstructor;
/**
* @author libin
* @version 1.0
* @description 以下错误 如需继续打款,要使用原来的订单号
* @data 2019/10/12 9:40
*/
@AllArgsConstructor
public enum AliNeedPayErrorEnum {
SYSTEM_ERROR("系统繁忙","系统繁忙");
private String desc;
private String reason;
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
}
package com.xxfc.platform.universal.weixin.constant;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/10/12 10:22
*/
public enum PaySubErrorCodeEnum {
/**
* 普通付款异常
*/
PAY_ERROR("EPAY_10000"),
/**
* 需要继续付款错误码
*/
PAY_NEED_ERROR("EPAY_10001");
private String subCode;
PaySubErrorCodeEnum(String subCode) {
this.subCode = subCode;
}
public String getSubCode() {
return subCode;
}
public void setSubCode(String subCode) {
this.subCode = subCode;
}
}
package com.xxfc.platform.universal.weixin.constant;
import lombok.AllArgsConstructor;
/**
* @author libin
* @version 1.0
* @description 以下错误 如需继续打款,要使用原来的商户订单号
* @data 2019/10/12 9:11
*/
@AllArgsConstructor
public enum WxNeedPayErrorEnum {
NOTENOUGH("余额不足","付款帐号余额不足或资金未到账"),
SYSTEMERROR("系统繁忙,请稍后再试","微信内部接口调用发生错误"),
NAME_MISMATCH("姓名校验出错","付款人身份校验不通过"),
SIGN_ERROR("签名错误","校验签名错误"),
FREQ_LIMIT("超过频率限制,请稍后再试","接口请求频率超时接口限制"),
MONEY_LIMIT("已经达到今日付款总额上限/已达到付款给此用户额度上限","请关注接口的付款限额条件"),
CA_ERROR("商户API证书校验出错","请求没带商户API证书或者带上了错误的商户API证书"),
V2_ACCOUNT_SIMPLE_BAN("无法给非实名用户付款","用户微信支付账户未知名,无法付款"),
PARAM_IS_NOT_UTF8("请求参数中包含非utf8编码字符","接口规范要求所有请求参数都必须为utf8编码"),
SENDNUM_LIMIT("该用户今日付款次数超过限制","该用户今日付款次数超过限制");
private String desc;
private String reason;
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
}
package com.xxfc.platform.universal.weixin.constant;
/**
* @author libin
* @version 1.0
* @description 微信请求响应字段
* @data 2019/10/12 9:57
*/
public class WxResponseProperties {
public static final String ERROR_CODE = "err_code";
public static final String RETURN_CODE = "return_code";
public static final String RESULT_CODE = "result_code";
public static final String ERR_CODE_DES = "err_code_des";
public static final String PARTNER_TRADE_NO = "partner_trade_no";
}
...@@ -12,6 +12,7 @@ import com.alipay.api.request.*; ...@@ -12,6 +12,7 @@ import com.alipay.api.request.*;
import com.alipay.api.response.*; import com.alipay.api.response.*;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant; import com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.HTTPSUtils; import com.github.wxiaoqi.security.common.util.HTTPSUtils;
import com.github.wxiaoqi.security.common.util.OrderUtil; import com.github.wxiaoqi.security.common.util.OrderUtil;
...@@ -21,12 +22,18 @@ import com.github.wxiaoqi.security.common.util.result.JsonResultUtil; ...@@ -21,12 +22,18 @@ import com.github.wxiaoqi.security.common.util.result.JsonResultUtil;
import com.xxfc.platform.universal.entity.Dictionary; import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.entity.OrderPay; import com.xxfc.platform.universal.entity.OrderPay;
import com.xxfc.platform.universal.mapper.OrderPayMapper; import com.xxfc.platform.universal.mapper.OrderPayMapper;
import com.xxfc.platform.universal.vo.FundPayVo;
import com.xxfc.platform.universal.vo.OrderPayVo; import com.xxfc.platform.universal.vo.OrderPayVo;
import com.xxfc.platform.universal.weixin.api.WXPay; import com.xxfc.platform.universal.weixin.api.*;
import com.xxfc.platform.universal.weixin.constant.AliNeedPayErrorEnum;
import com.xxfc.platform.universal.weixin.constant.PaySubErrorCodeEnum;
import com.xxfc.platform.universal.weixin.constant.WxNeedPayErrorEnum;
import com.xxfc.platform.universal.weixin.constant.WxResponseProperties;
import com.xxfc.platform.universal.weixin.util.HTTPUtils; import com.xxfc.platform.universal.weixin.util.HTTPUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -34,10 +41,8 @@ import tk.mybatis.mapper.entity.Example; ...@@ -34,10 +41,8 @@ import tk.mybatis.mapper.entity.Example;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.HashMap; import java.util.*;
import java.util.Iterator; import java.util.stream.Collectors;
import java.util.List;
import java.util.Map;
import static com.xxfc.platform.universal.constant.DictionaryKey.PAY_DEMOTION; import static com.xxfc.platform.universal.constant.DictionaryKey.PAY_DEMOTION;
import static com.xxfc.platform.universal.constant.DictionaryKey.UNIVERSAL_PAY; import static com.xxfc.platform.universal.constant.DictionaryKey.UNIVERSAL_PAY;
...@@ -51,7 +56,7 @@ import static com.xxfc.platform.universal.constant.DictionaryKey.UNIVERSAL_PAY; ...@@ -51,7 +56,7 @@ import static com.xxfc.platform.universal.constant.DictionaryKey.UNIVERSAL_PAY;
*/ */
@Service @Service
@Slf4j @Slf4j
public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> { public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> implements InitializingBean {
@Autowired @Autowired
DictionaryBiz dictionaryBiz; DictionaryBiz dictionaryBiz;
...@@ -66,8 +71,13 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> { ...@@ -66,8 +71,13 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
@Value("${wx.appid}") @Value("${wx.appid}")
private String wy_appid; private String wy_appid;
@Value("${wx.appSercet}") @Value("${wx.appSercet}")
private String wy_secret; private String wy_secret;
private List<String> wxNeedPayErrorCodes;
private List<String> aliNeedPayErrorCodes;
private static final String SUCCESS = "SUCCESS";
public JSONObject preparepay(OrderPayVo orderPayVo) { public JSONObject preparepay(OrderPayVo orderPayVo) {
...@@ -107,16 +117,16 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> { ...@@ -107,16 +117,16 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
String sellerAccount = null; String sellerAccount = null;
if (type == 2 && payWay == 1) { if (type == 2 && payWay == 1) {
sellerAccount = SystemConfig.APP_PARTNER; sellerAccount = SystemConfig.APP_PARTNER;
jsParam = WXPay.webPay(amount + "", orderPayVo.getBody(), notify_url, trade_no, orderPayVo.getBuyerIp(), orderPayVo.getBuyerAccount(),null); jsParam = WXPay.webPay(amount + "", orderPayVo.getBody(), notify_url, trade_no, orderPayVo.getBuyerIp(), orderPayVo.getBuyerAccount(), null);
} else if (type == 1 && payWay == 1) { } else if (type == 1 && payWay == 1) {
sellerAccount = SystemConfig.APP_PARTNER; sellerAccount = SystemConfig.APP_PARTNER;
jsParam = WXPay.apppay(amount + "", orderPayVo.getBody(), notify_url, trade_no, orderPayVo.getBuyerIp(), 0); jsParam = WXPay.apppay(amount + "", orderPayVo.getBody(), notify_url, trade_no, orderPayVo.getBuyerIp(), 0);
} else if (type == 1 && payWay == 2) { } else if (type == 1 && payWay == 2) {
sellerAccount = SystemConfig.ALIPAY_PID; sellerAccount = SystemConfig.ALIPAY_PID;
jsParam = generateAliPayment(orderPayVo, notifyUrl); jsParam = generateAliPayment(orderPayVo, notifyUrl);
}else if (type == 3 && payWay == 1){ } else if (type == 3 && payWay == 1) {
sellerAccount = SystemConfig.APP_PARTNER; sellerAccount = SystemConfig.APP_PARTNER;
jsParam = WXPay.webPay(amount + "", orderPayVo.getBody(), notify_url, trade_no, orderPayVo.getBuyerIp(), orderPayVo.getBuyerAccount(),wy_appid); jsParam = WXPay.webPay(amount + "", orderPayVo.getBody(), notify_url, trade_no, orderPayVo.getBuyerIp(), orderPayVo.getBuyerAccount(), wy_appid);
} }
log.info("报名费回调路径jsParam:" + jsParam); log.info("报名费回调路径jsParam:" + jsParam);
if (!StringUtils.isBlank(jsParam)) { if (!StringUtils.isBlank(jsParam)) {
...@@ -302,6 +312,7 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> { ...@@ -302,6 +312,7 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
"utf-8", SystemConfig.ALIPAY_PUBLIC_KEY, AlipayConstants.SIGN_TYPE_RSA2); "utf-8", SystemConfig.ALIPAY_PUBLIC_KEY, AlipayConstants.SIGN_TYPE_RSA2);
return alipayClient; return alipayClient;
} }
//balance 余额 //balance 余额
//moneyFund 余额宝 //moneyFund 余额宝
//coupon 红包 //coupon 红包
...@@ -370,6 +381,71 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> { ...@@ -370,6 +381,71 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
} }
} }
/**
* 转账功能 微信 | 支付宝
*
* @param fundPayVo
* @return
* @throws Exception
*/
public String fundTrans(FundPayVo fundPayVo) throws Exception {
if (fundPayVo.getType() == 0) {
//微信
fundPayVo.setCheckName("NO_CHECK");
return wxpayfundTrans(fundPayVo);
}
if (fundPayVo.getType() == 1) {
//支付宝
return alipayfundTrans(getAlipayClient(), fundPayVo);
}
throw new BaseException("提现方式不对");
}
/**
* 支付宝转账功能 单笔最小转账0.1 最大小数点位数前支持13位,实际限额和签约一致
*
* @param alipayClient
* @throws AlipayApiException
*/
public String alipayfundTrans(AlipayClient alipayClient, FundPayVo fundPayVo) throws AlipayApiException {
AlipayFundTransToaccountTransferRequest request = new AlipayFundTransToaccountTransferRequest();
request.setBizContent("{" +
"\"out_biz_no\":\"" + fundPayVo.getOutBizNo() + "\"," +
"\"payee_type\":\"ALIPAY_LOGONID\"," +
"\"payee_account\":\"" + fundPayVo.getPayeeAccount() + "\"," +
"\"amount\":\"" + fundPayVo.getAmount() + "\"," +
"\"payer_show_name\":\"" + fundPayVo.getPayerShowName() + "\"," +
"\"remark\":\"" + fundPayVo.getRemark() + "\"" +
" }");
AlipayFundTransToaccountTransferResponse response = alipayClient.execute(request);
if (response.isSuccess()) {
log.info("转账调用成功");
return fundPayVo.getOutBizNo();
} else {
log.info("转账调用失败");
String subCode = response.getSubCode();
if (aliNeedPayErrorCodes.contains(subCode)) {
throw new BaseException("支付宝账号余额不足",PaySubErrorCodeEnum.PAY_NEED_ERROR.getSubCode());
}
throw new BaseException("支付宝转账失败:【错误码:" + response.getSubCode() + " 错误信息:" + response.getSubMsg() + "】",PaySubErrorCodeEnum.PAY_ERROR.getSubCode());
}
}
public String wxpayfundTrans(FundPayVo fundPayVo) throws Exception {
Map<String, String> map = WXSuppToUserPay.WeiXinTiXian(fundPayVo.getAmount(),fundPayVo.getOutBizNo(),fundPayVo.getCheckName(), fundPayVo.getAmount(), fundPayVo.getRemark(), fundPayVo.getCreatIp());
log.info("微信转账【{}】", map);
if (SUCCESS.equals(map.get(WxResponseProperties.RETURN_CODE)) && SUCCESS.equals(map.get(WxResponseProperties.RESULT_CODE))) {
return map.get(WxResponseProperties.PARTNER_TRADE_NO);
}
String errorCode = map.get(WxResponseProperties.ERROR_CODE);
if (wxNeedPayErrorCodes.contains(errorCode)) {
throw new BaseException(WxNeedPayErrorEnum.valueOf(errorCode).getDesc(), PaySubErrorCodeEnum.PAY_NEED_ERROR.getSubCode());
} else {
throw new BaseException("微信转账失败:【错误码" + errorCode + " 错误信息:" + map.get(WxResponseProperties.ERR_CODE_DES) + "】", PaySubErrorCodeEnum.PAY_ERROR.getSubCode());
}
}
//解冻预授权 //解冻预授权
public void fundAuthOrderUnFreeze(AlipayClient alipayClient) throws AlipayApiException { public void fundAuthOrderUnFreeze(AlipayClient alipayClient) throws AlipayApiException {
AlipayFundAuthOrderUnfreezeRequest request = new AlipayFundAuthOrderUnfreezeRequest(); AlipayFundAuthOrderUnfreezeRequest request = new AlipayFundAuthOrderUnfreezeRequest();
...@@ -453,10 +529,11 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> { ...@@ -453,10 +529,11 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
* @param tradNo 流水号 * @param tradNo 流水号
* @param refundAmount 退款金额 * @param refundAmount 退款金额
* @param refundReason 退款原因 * @param refundReason 退款原因
* outRequestNo 退款请求标示 用于分批退款,每笔退款标示不一样,同样标示不会重复退款 * outRequestNo 退款请求标示 用于分批退款,每笔退款标示不一样,同样标示不会重复退款
* @return * @return
*/ */
public boolean alipayOrderRefund(String outTradeNo, String tradNo, Integer refundAmount, String refundReason, String outRequestNo) { public boolean alipayOrderRefund(String outTradeNo, String tradNo, Integer refundAmount, String
refundReason, String outRequestNo) {
AlipayClient alipayClient = getAlipayClient(); AlipayClient alipayClient = getAlipayClient();
AlipayTradeRefundRequest request = new AlipayTradeRefundRequest(); AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
BigDecimal realAmount = new BigDecimal(refundAmount.toString()).divide(new BigDecimal("100"), 2, BigDecimal.ROUND_UP); BigDecimal realAmount = new BigDecimal(refundAmount.toString()).divide(new BigDecimal("100"), 2, BigDecimal.ROUND_UP);
...@@ -464,7 +541,7 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> { ...@@ -464,7 +541,7 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
"\"out_trade_no\":\"" + outTradeNo + "\"," + "\"out_trade_no\":\"" + outTradeNo + "\"," +
"\"trade_no\":\"" + tradNo + "\"," + "\"trade_no\":\"" + tradNo + "\"," +
"\"refund_amount\":" + realAmount + "," + "\"refund_amount\":" + realAmount + "," +
"\"refund_reason\":\""+ refundReason + "\"," + "\"refund_reason\":\"" + refundReason + "\"," +
"\"out_request_no\":\"" + outRequestNo + "\"" + "\"out_request_no\":\"" + outRequestNo + "\"" +
" }"); " }");
try { try {
...@@ -485,6 +562,23 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> { ...@@ -485,6 +562,23 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
public static void main(String[] args) { public static void main(String[] args) {
OrderPayBiz orderPayBiz = new OrderPayBiz(); OrderPayBiz orderPayBiz = new OrderPayBiz();
orderPayBiz.alipayOrderRefund("20190806134440000001","2019080622001421530542309594", 3, "xxxx", ""); AlipayClient alipayClient = orderPayBiz.getAlipayClient();
FundPayVo fundPayVo = new FundPayVo();
fundPayVo.setAmount("0.50");
fundPayVo.setOutBizNo("2019101015543");
fundPayVo.setPayeeAccount("2724520350@qq.com");
fundPayVo.setPayerShowName("欣欣房车网络科技");
fundPayVo.setRemark("测试转账");
try {
orderPayBiz.alipayfundTrans(alipayClient, fundPayVo);
} catch (AlipayApiException e) {
e.printStackTrace();
}
}
@Override
public void afterPropertiesSet() throws Exception {
wxNeedPayErrorCodes = EnumSet.allOf(WxNeedPayErrorEnum.class).stream().map(WxNeedPayErrorEnum::name).collect(Collectors.toList());
aliNeedPayErrorCodes = EnumSet.allOf(AliNeedPayErrorEnum.class).stream().map(AliNeedPayErrorEnum::name).collect(Collectors.toList());
} }
} }
...@@ -5,6 +5,7 @@ import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken; ...@@ -5,6 +5,7 @@ import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.rest.BaseController; import com.github.wxiaoqi.security.common.rest.BaseController;
import com.xxfc.platform.universal.biz.OrderPayBiz; import com.xxfc.platform.universal.biz.OrderPayBiz;
import com.xxfc.platform.universal.entity.OrderPay; import com.xxfc.platform.universal.entity.OrderPay;
import com.xxfc.platform.universal.vo.FundPayVo;
import com.xxfc.platform.universal.vo.OrderPayVo; import com.xxfc.platform.universal.vo.OrderPayVo;
import com.xxfc.platform.universal.weixin.util.XMLUtil; import com.xxfc.platform.universal.weixin.util.XMLUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -102,4 +103,11 @@ public class OrderPayController extends BaseController<OrderPayBiz,OrderPay> { ...@@ -102,4 +103,11 @@ public class OrderPayController extends BaseController<OrderPayBiz,OrderPay> {
} }
@PostMapping("/app/unauth/transfer_account")
@IgnoreUserToken
public String transferAccount(@RequestBody FundPayVo fundPayVo) throws Exception {
return baseBiz.fundTrans(fundPayVo);
}
} }
\ No newline at end of file
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