mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 19:15:35 +08:00
update 保存提现信息
This commit is contained in:
@@ -16,12 +16,16 @@ import com.jsowell.adapay.vo.AdapayCorpMemberVO;
|
||||
import com.jsowell.adapay.vo.AdapayMemberInfoVO;
|
||||
import com.jsowell.adapay.vo.AdapaySettleAccountVO;
|
||||
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.util.AdapayUtil;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.ZipUtil;
|
||||
import com.jsowell.common.util.id.IdUtils;
|
||||
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 lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@@ -33,6 +37,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -51,6 +56,9 @@ public class AdapayMemberService {
|
||||
@Autowired
|
||||
private IAdapayMemberAccountService adapayMemberAccountService;
|
||||
|
||||
@Autowired
|
||||
private ClearingWithdrawInfoService clearingWithdrawInfoService;
|
||||
|
||||
public void createSettleAccount(SettleAccountDTO dto) throws BaseAdaPayException, BusinessException {
|
||||
String bankAcctType = dto.getBankAcctType();
|
||||
if (StringUtils.equals(bankAcctType, Constants.ONE)) {
|
||||
@@ -323,8 +331,7 @@ public class AdapayMemberService {
|
||||
// 通过merchantId 查询出汇付会员id 和 结算账户id,用来查询余额
|
||||
AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService.selectByMerchantId(merchantId);
|
||||
if (adapayMemberAccount == null) {
|
||||
log.error("通过merchantId:{}, 没有查询到结算账户配置", merchantId);
|
||||
return vo;
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_MEMBER_IS_NULL_ERROR);
|
||||
}
|
||||
String settle_account_id = adapayMemberAccount.getSettleAccountId();
|
||||
String member_id = adapayMemberAccount.getAdapayMemberId();
|
||||
@@ -340,6 +347,8 @@ public class AdapayMemberService {
|
||||
vo.setAcctBalance(new BigDecimal((String) settleCount.get("acct_balance")));
|
||||
vo.setAvlBalance(new BigDecimal((String) settleCount.get("avl_balance")));
|
||||
vo.setLastAvlBalance(new BigDecimal((String) settleCount.get("last_avl_balance")));
|
||||
vo.setAdapayMemberId(adapayMemberAccount.getAdapayMemberId());
|
||||
vo.setSettleAccountId(adapayMemberAccount.getSettleAccountId());
|
||||
return vo;
|
||||
}
|
||||
|
||||
@@ -432,25 +441,54 @@ public class AdapayMemberService {
|
||||
* @throws BaseAdaPayException
|
||||
*/
|
||||
public void drawCash(WithdrawDTO dto) throws BaseAdaPayException {
|
||||
// 通过merchantId 查询出汇付会员id 和 结算账户id,用来查询余额
|
||||
AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService.selectByMerchantId(dto.getMerchantId());
|
||||
if (adapayMemberAccount == null) {
|
||||
log.error("通过merchantId:{}, 没有查询到结算账户配置", dto.getMerchantId());
|
||||
return;
|
||||
// 查询余额
|
||||
AdapayAccountBalanceVO adapayAccountBalanceVO = queryAdapayAccountBalance(dto.getMerchantId());
|
||||
if (adapayAccountBalanceVO == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_MEMBER_IS_NULL_ERROR);
|
||||
}
|
||||
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("cash_amt", AdapayUtil.formatAmount(dto.getCashAmt()));
|
||||
settleCountParams.put("member_id", adapayMemberAccount.getAdapayMemberId());
|
||||
settleCountParams.put("cash_amt", AdapayUtil.formatAmount(cashAmt));
|
||||
settleCountParams.put("member_id", adapayAccountBalanceVO.getAdapayMemberId());
|
||||
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("notify_url", ADAPAY_CALLBACK_URL);
|
||||
|
||||
log.info("取现接口,请求参数:{}", JSON.toJSONString(settleCountParams));
|
||||
log.info("申请取现接口,请求参数:{}", JSON.toJSONString(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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user