mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-12 19:29:52 +08:00
update 保存提现信息
This commit is contained in:
@@ -110,6 +110,9 @@ public class AdapayMemberController extends BaseController {
|
|||||||
try {
|
try {
|
||||||
AdapayAccountBalanceVO vo = adapayMemberService.queryAdapayAccountBalance(dto.getMerchantId());
|
AdapayAccountBalanceVO vo = adapayMemberService.queryAdapayAccountBalance(dto.getMerchantId());
|
||||||
result = AjaxResult.success(vo);
|
result = AjaxResult.success(vo);
|
||||||
|
} catch (BusinessException e) {
|
||||||
|
logger.error("查询汇付账户余额error", e);
|
||||||
|
result = AjaxResult.error(e.getMessage());
|
||||||
} catch (BaseAdaPayException e) {
|
} catch (BaseAdaPayException e) {
|
||||||
logger.error("查询汇付账户余额error", e);
|
logger.error("查询汇付账户余额error", e);
|
||||||
result = AjaxResult.error();
|
result = AjaxResult.error();
|
||||||
@@ -163,8 +166,11 @@ public class AdapayMemberController extends BaseController {
|
|||||||
try {
|
try {
|
||||||
adapayMemberService.drawCash(dto);
|
adapayMemberService.drawCash(dto);
|
||||||
result = AjaxResult.success();
|
result = AjaxResult.success();
|
||||||
|
} catch (BusinessException e) {
|
||||||
|
logger.error("申请取现接口error", e);
|
||||||
|
result = AjaxResult.error(e.getMessage());
|
||||||
} catch (BaseAdaPayException e) {
|
} catch (BaseAdaPayException e) {
|
||||||
logger.error("提现接口 error", e);
|
logger.error("申请取现接口 error", e);
|
||||||
result = AjaxResult.error();
|
result = AjaxResult.error();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.jsowell.common.core.domain.entity.SysDictData;
|
|||||||
import com.jsowell.common.core.domain.ykc.LoginRequestData;
|
import com.jsowell.common.core.domain.ykc.LoginRequestData;
|
||||||
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
|
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
|
||||||
import com.jsowell.common.core.redis.RedisCache;
|
import com.jsowell.common.core.redis.RedisCache;
|
||||||
|
import com.jsowell.common.enums.DelFlagEnum;
|
||||||
import com.jsowell.common.enums.ykc.*;
|
import com.jsowell.common.enums.ykc.*;
|
||||||
import com.jsowell.common.exception.BusinessException;
|
import com.jsowell.common.exception.BusinessException;
|
||||||
import com.jsowell.common.util.*;
|
import com.jsowell.common.util.*;
|
||||||
@@ -56,7 +57,6 @@ import com.jsowell.thirdparty.lianlian.util.Encodes;
|
|||||||
import com.jsowell.thirdparty.lianlian.util.GBSignUtils;
|
import com.jsowell.thirdparty.lianlian.util.GBSignUtils;
|
||||||
import com.jsowell.wxpay.common.WeChatPayParameter;
|
import com.jsowell.wxpay.common.WeChatPayParameter;
|
||||||
import com.jsowell.wxpay.dto.AppletTemplateMessageSendDTO;
|
import com.jsowell.wxpay.dto.AppletTemplateMessageSendDTO;
|
||||||
import com.jsowell.pile.dto.ApplyRefundDTO;
|
|
||||||
import com.jsowell.wxpay.response.WechatPayRefundRequest;
|
import com.jsowell.wxpay.response.WechatPayRefundRequest;
|
||||||
import com.jsowell.wxpay.service.WxAppletRemoteService;
|
import com.jsowell.wxpay.service.WxAppletRemoteService;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
@@ -186,6 +186,22 @@ public class SpringBootTestController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IMemberBasicInfoService memberBasicInfoService;
|
private IMemberBasicInfoService memberBasicInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ClearingWithdrawInfoService clearingWithdrawInfoService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testClearingWithdraw() {
|
||||||
|
// 保存提现记录
|
||||||
|
ClearingWithdrawInfo record = new ClearingWithdrawInfo();
|
||||||
|
record.setWithdrawCode("132321354");
|
||||||
|
record.setWithdrawStatus(Constants.ZERO);
|
||||||
|
Date now = new Date();
|
||||||
|
record.setApplicationTime(now);
|
||||||
|
record.setCreateTime(now);
|
||||||
|
record.setDelFlag(DelFlagEnum.NORMAL.getValue());
|
||||||
|
clearingWithdrawInfoService.insertOrUpdate(record);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetPileTypeNum() {
|
public void testGetPileTypeNum() {
|
||||||
Long stationId = 1L;
|
Long stationId = 1L;
|
||||||
|
|||||||
@@ -104,6 +104,8 @@ public enum ReturnCodeEnum {
|
|||||||
|
|
||||||
CODE_ADAPAY_CALLBACK_IS_NULL_ERROR("00100048", "未查询到订单支付记录回调"),
|
CODE_ADAPAY_CALLBACK_IS_NULL_ERROR("00100048", "未查询到订单支付记录回调"),
|
||||||
|
|
||||||
|
CODE_INSUFFICIENT_BALANCE_ERROR("00100049", "余额不足"),
|
||||||
|
|
||||||
/* 个人桩 start */
|
/* 个人桩 start */
|
||||||
|
|
||||||
CODE_PILE_HAS_BEEN_BINDING_ERROR("00400001", "此桩已被绑定,请联系管理员!"),
|
CODE_PILE_HAS_BEEN_BINDING_ERROR("00400001", "此桩已被绑定,请联系管理员!"),
|
||||||
|
|||||||
@@ -16,12 +16,16 @@ import com.jsowell.adapay.vo.AdapayCorpMemberVO;
|
|||||||
import com.jsowell.adapay.vo.AdapayMemberInfoVO;
|
import com.jsowell.adapay.vo.AdapayMemberInfoVO;
|
||||||
import com.jsowell.adapay.vo.AdapaySettleAccountVO;
|
import com.jsowell.adapay.vo.AdapaySettleAccountVO;
|
||||||
import com.jsowell.common.constant.Constants;
|
import com.jsowell.common.constant.Constants;
|
||||||
|
import com.jsowell.common.enums.DelFlagEnum;
|
||||||
|
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||||
import com.jsowell.common.exception.BusinessException;
|
import com.jsowell.common.exception.BusinessException;
|
||||||
import com.jsowell.common.util.AdapayUtil;
|
import com.jsowell.common.util.AdapayUtil;
|
||||||
import com.jsowell.common.util.StringUtils;
|
import com.jsowell.common.util.StringUtils;
|
||||||
import com.jsowell.common.util.ZipUtil;
|
import com.jsowell.common.util.ZipUtil;
|
||||||
import com.jsowell.common.util.id.IdUtils;
|
import com.jsowell.common.util.id.IdUtils;
|
||||||
import com.jsowell.pile.domain.AdapayMemberAccount;
|
import com.jsowell.pile.domain.AdapayMemberAccount;
|
||||||
|
import com.jsowell.pile.domain.ClearingWithdrawInfo;
|
||||||
|
import com.jsowell.pile.service.ClearingWithdrawInfoService;
|
||||||
import com.jsowell.pile.service.IAdapayMemberAccountService;
|
import com.jsowell.pile.service.IAdapayMemberAccountService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
@@ -33,6 +37,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -51,6 +56,9 @@ public class AdapayMemberService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IAdapayMemberAccountService adapayMemberAccountService;
|
private IAdapayMemberAccountService adapayMemberAccountService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ClearingWithdrawInfoService clearingWithdrawInfoService;
|
||||||
|
|
||||||
public void createSettleAccount(SettleAccountDTO dto) throws BaseAdaPayException, BusinessException {
|
public void createSettleAccount(SettleAccountDTO dto) throws BaseAdaPayException, BusinessException {
|
||||||
String bankAcctType = dto.getBankAcctType();
|
String bankAcctType = dto.getBankAcctType();
|
||||||
if (StringUtils.equals(bankAcctType, Constants.ONE)) {
|
if (StringUtils.equals(bankAcctType, Constants.ONE)) {
|
||||||
@@ -323,8 +331,7 @@ public class AdapayMemberService {
|
|||||||
// 通过merchantId 查询出汇付会员id 和 结算账户id,用来查询余额
|
// 通过merchantId 查询出汇付会员id 和 结算账户id,用来查询余额
|
||||||
AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService.selectByMerchantId(merchantId);
|
AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService.selectByMerchantId(merchantId);
|
||||||
if (adapayMemberAccount == null) {
|
if (adapayMemberAccount == null) {
|
||||||
log.error("通过merchantId:{}, 没有查询到结算账户配置", merchantId);
|
throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_MEMBER_IS_NULL_ERROR);
|
||||||
return vo;
|
|
||||||
}
|
}
|
||||||
String settle_account_id = adapayMemberAccount.getSettleAccountId();
|
String settle_account_id = adapayMemberAccount.getSettleAccountId();
|
||||||
String member_id = adapayMemberAccount.getAdapayMemberId();
|
String member_id = adapayMemberAccount.getAdapayMemberId();
|
||||||
@@ -340,6 +347,8 @@ public class AdapayMemberService {
|
|||||||
vo.setAcctBalance(new BigDecimal((String) settleCount.get("acct_balance")));
|
vo.setAcctBalance(new BigDecimal((String) settleCount.get("acct_balance")));
|
||||||
vo.setAvlBalance(new BigDecimal((String) settleCount.get("avl_balance")));
|
vo.setAvlBalance(new BigDecimal((String) settleCount.get("avl_balance")));
|
||||||
vo.setLastAvlBalance(new BigDecimal((String) settleCount.get("last_avl_balance")));
|
vo.setLastAvlBalance(new BigDecimal((String) settleCount.get("last_avl_balance")));
|
||||||
|
vo.setAdapayMemberId(adapayMemberAccount.getAdapayMemberId());
|
||||||
|
vo.setSettleAccountId(adapayMemberAccount.getSettleAccountId());
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,25 +441,54 @@ public class AdapayMemberService {
|
|||||||
* @throws BaseAdaPayException
|
* @throws BaseAdaPayException
|
||||||
*/
|
*/
|
||||||
public void drawCash(WithdrawDTO dto) throws BaseAdaPayException {
|
public void drawCash(WithdrawDTO dto) throws BaseAdaPayException {
|
||||||
// 通过merchantId 查询出汇付会员id 和 结算账户id,用来查询余额
|
// 查询余额
|
||||||
AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService.selectByMerchantId(dto.getMerchantId());
|
AdapayAccountBalanceVO adapayAccountBalanceVO = queryAdapayAccountBalance(dto.getMerchantId());
|
||||||
if (adapayMemberAccount == null) {
|
if (adapayAccountBalanceVO == null) {
|
||||||
log.error("通过merchantId:{}, 没有查询到结算账户配置", dto.getMerchantId());
|
throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_MEMBER_IS_NULL_ERROR);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Map<String, Object> settleCountParams = Maps.newHashMap();
|
|
||||||
|
|
||||||
|
// 提现手续费 每笔固定10元
|
||||||
|
BigDecimal feeAmt = new BigDecimal("10");
|
||||||
|
|
||||||
|
// 实际提现到账金额
|
||||||
|
BigDecimal cashAmt = adapayAccountBalanceVO.getAvlBalance().subtract(feeAmt);
|
||||||
|
|
||||||
|
// 可提现金额减去手续费后需大于0
|
||||||
|
if (cashAmt.compareTo(BigDecimal.ZERO) < 0) {
|
||||||
|
throw new BusinessException(ReturnCodeEnum.CODE_INSUFFICIENT_BALANCE_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送提现申请
|
||||||
|
Map<String, Object> settleCountParams = Maps.newHashMap();
|
||||||
settleCountParams.put("order_no", "drawcash_" + System.currentTimeMillis());
|
settleCountParams.put("order_no", "drawcash_" + System.currentTimeMillis());
|
||||||
settleCountParams.put("cash_amt", AdapayUtil.formatAmount(dto.getCashAmt()));
|
settleCountParams.put("cash_amt", AdapayUtil.formatAmount(cashAmt));
|
||||||
settleCountParams.put("member_id", adapayMemberAccount.getAdapayMemberId());
|
settleCountParams.put("member_id", adapayAccountBalanceVO.getAdapayMemberId());
|
||||||
settleCountParams.put("app_id", ADAPAY_APP_ID);
|
settleCountParams.put("app_id", ADAPAY_APP_ID);
|
||||||
settleCountParams.put("settle_account_id", adapayMemberAccount.getSettleAccountId());
|
settleCountParams.put("settle_account_id", adapayAccountBalanceVO.getSettleAccountId());
|
||||||
settleCountParams.put("cash_type", "T1");
|
settleCountParams.put("cash_type", "T1");
|
||||||
settleCountParams.put("notify_url", ADAPAY_CALLBACK_URL);
|
settleCountParams.put("notify_url", ADAPAY_CALLBACK_URL);
|
||||||
|
log.info("申请取现接口,请求参数:{}", JSON.toJSONString(settleCountParams));
|
||||||
log.info("取现接口,请求参数:{}", JSON.toJSONString(settleCountParams));
|
|
||||||
Map<String, Object> settleCount = Drawcash.create(settleCountParams);
|
Map<String, Object> settleCount = Drawcash.create(settleCountParams);
|
||||||
log.info("取现接口返回参数{}", JSON.toJSONString(settleCount));
|
log.info("申请取现接口,返回参数:{}", JSON.toJSONString(settleCount));
|
||||||
|
|
||||||
|
if (settleCount == null) {
|
||||||
|
throw new BusinessException("", "申请取现接口发生异常");
|
||||||
|
}
|
||||||
|
|
||||||
|
String id = (String) settleCount.get("id");
|
||||||
|
|
||||||
|
// 发起支付手续费请求 inMemberId为0表示本商户
|
||||||
|
createBalancePaymentRequest(adapayAccountBalanceVO.getAdapayMemberId(), Constants.ZERO, feeAmt.toString());
|
||||||
|
|
||||||
|
// 保存提现记录
|
||||||
|
ClearingWithdrawInfo record = new ClearingWithdrawInfo();
|
||||||
|
record.setWithdrawCode(id);
|
||||||
|
record.setWithdrawStatus(Constants.ZERO);
|
||||||
|
Date now = new Date();
|
||||||
|
record.setApplicationTime(now);
|
||||||
|
record.setCreateTime(now);
|
||||||
|
record.setDelFlag(DelFlagEnum.NORMAL.getValue());
|
||||||
|
clearingWithdrawInfoService.insertOrUpdate(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import lombok.*;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 汇付会员余额
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@@ -22,4 +25,10 @@ public class AdapayAccountBalanceVO {
|
|||||||
// 昨日日终余额。
|
// 昨日日终余额。
|
||||||
private BigDecimal lastAvlBalance;
|
private BigDecimal lastAvlBalance;
|
||||||
|
|
||||||
|
// 汇付会员id
|
||||||
|
private String adapayMemberId;
|
||||||
|
|
||||||
|
// 汇付结算账户id
|
||||||
|
private String settleAccountId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user