|
@@ -19,6 +19,7 @@ import com.yonge.cooleshow.biz.dal.vo.UserAccountVo;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.UserBankCardVo;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.res.WithdrawalInfoRes;
|
|
|
import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
+import com.yonge.cooleshow.common.service.IdGeneratorService;
|
|
|
import com.yonge.toolset.base.exception.BizException;
|
|
|
import com.yonge.toolset.base.string.StringPool;
|
|
|
import com.yonge.toolset.base.util.StringUtil;
|
|
@@ -57,6 +58,8 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
private SysMessageService sysMessageService;
|
|
|
@Autowired
|
|
|
private SysUserContractRecordDao userContractRecordDao;
|
|
|
+ @Autowired
|
|
|
+ private IdGeneratorService idGeneratorService;
|
|
|
|
|
|
@Override
|
|
|
public UserWithdrawalVo detail(Long id) {
|
|
@@ -65,6 +68,12 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public UserWithdrawalVo detailByTransNo(String transNo) {
|
|
|
+ UserWithdrawalVo detail = baseMapper.detailByTransNo(transNo);
|
|
|
+ return detail;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public IPage<UserWithdrawalVo> selectPage(IPage<UserWithdrawalVo> page, TeacherWithdrawalSearch query) {
|
|
|
List<UserWithdrawalVo> withdrawalVoList = baseMapper.selectPage(page, query);
|
|
|
withdrawalVoList.forEach(o -> o.setBankCard(ValueUtil.fuzzyBankCard(o.getBankCard())));
|
|
@@ -145,13 +154,17 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
if (accountChange.getStatus()) {
|
|
|
if (YesOrNoEnum.NO.getCode().toString().equals(withdrawalAuthSwitch)
|
|
|
|| new BigDecimal(withdrawalAuthFee).compareTo(withdrawalReq.getAmountWithdrawal()) > 0) {
|
|
|
- //不用审核的,需要请求三方
|
|
|
+ //不用审核的,直接请求三方
|
|
|
+ //交易流水号生成
|
|
|
+ Long transNo = idGeneratorService.generatorId("withdrawNo");
|
|
|
+
|
|
|
HttpResponseResult<Boolean> withdraw = withdrawSdk.withdraw(
|
|
|
- userWithdrawal.getId().toString(), bankCardVo.getName(), bankCardVo.getPhone(), user.getIdCardNo(),
|
|
|
+ transNo.toString(), bankCardVo.getName(), bankCardVo.getPhone(), user.getIdCardNo(),
|
|
|
userWithdrawal.getActualAmount().multiply(new BigDecimal("100")).intValue(), bankCardVo.getBankCard(), null
|
|
|
);
|
|
|
if (withdraw.getStatus() && withdraw.getData()) {
|
|
|
userWithdrawal.setTradeStatus(TradeStatusEnum.pending);
|
|
|
+ userWithdrawal.setTransNo(transNo.toString());
|
|
|
updateById(userWithdrawal);
|
|
|
} else {
|
|
|
log.error("结算调用三方接口失败:user is {}, param is {}, res is {}", user.getId(), JSONObject.toJSONString(withdrawalReq), withdraw);
|
|
@@ -184,14 +197,19 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
Boolean flag = false;
|
|
|
if (authOperaReq.getPass()) {
|
|
|
//请求三方接口
|
|
|
+
|
|
|
+ //交易流水号生成
|
|
|
+ Long transNo = idGeneratorService.generatorId("withdrawNo");
|
|
|
+
|
|
|
HttpResponseResult<Boolean> withdraw = withdrawSdk.withdraw(
|
|
|
- build.getId().toString(), build.getRealName(), build.getPhone(), withdrawalUser.getIdCardNo(),
|
|
|
+ transNo.toString(), build.getRealName(), build.getPhone(), withdrawalUser.getIdCardNo(),
|
|
|
build.getActualAmount().multiply(new BigDecimal("100")).intValue(), build.getBankCard(), null
|
|
|
);
|
|
|
if (withdraw.getStatus() && withdraw.getData()) {
|
|
|
build.setTradeStatus(TradeStatusEnum.pending);
|
|
|
+ build.setTransNo(transNo.toString());
|
|
|
flag = true;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
build.setTradeStatus(TradeStatusEnum.failed);
|
|
|
build.setErrorMsg("请求三方接口返回失败");
|
|
|
}
|
|
@@ -225,13 +243,17 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
return HttpResponseResult.failed("提现已经交易成功");
|
|
|
}
|
|
|
|
|
|
+ //交易流水号生成
|
|
|
+ Long transNo = idGeneratorService.generatorId("withdrawNo");
|
|
|
+
|
|
|
//不用审核的,需要请求三方
|
|
|
HttpResponseResult<Boolean> withdraw = withdrawSdk.withdraw(
|
|
|
- detail.getId().toString(), detail.getRealName(), detail.getPhone(), user.getIdCardNo(),
|
|
|
+ transNo.toString(), detail.getRealName(), detail.getPhone(), user.getIdCardNo(),
|
|
|
detail.getActualAmount().multiply(new BigDecimal("100")).intValue(), detail.getBankCard(), null
|
|
|
);
|
|
|
if (withdraw.getStatus() && withdraw.getData()) {
|
|
|
detail.setTradeStatus(TradeStatusEnum.pending);
|
|
|
+ detail.setTransNo(transNo.toString());
|
|
|
updateById(detail);
|
|
|
return HttpResponseResult.succeed(true);
|
|
|
} else {
|
|
@@ -246,11 +268,13 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
public void callback(UserWithdrawalCallback callback, String jsonStr) {
|
|
|
if (StringUtil.isEmpty(callback.getOuterOrderNo()) ||
|
|
|
StringUtil.isEmpty(callback.getStatus())) {
|
|
|
- throw new BizException("参数异常,参数缺失,param is {}", jsonStr);
|
|
|
+ log.error("参数异常,参数缺失,param is {}", jsonStr);
|
|
|
+ return;
|
|
|
}
|
|
|
- UserWithdrawalVo detail = detail(Long.parseLong(callback.getOuterOrderNo().trim()));
|
|
|
+ UserWithdrawalVo detail = detailByTransNo(callback.getOuterOrderNo().trim());
|
|
|
if (null == detail) {
|
|
|
- throw new BizException("参数异常,未找到交易记录,param is {}", jsonStr);
|
|
|
+ log.error("参数异常,未找到交易记录,param is {}", jsonStr);
|
|
|
+ return;
|
|
|
}
|
|
|
if (!TradeStatusEnum.pending.equals(detail.getTradeStatus())) {
|
|
|
return;
|
|
@@ -258,7 +282,7 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
if ("1".equals(callback.getStatus())) {
|
|
|
//交易成功
|
|
|
detail.setTradeStatus(TradeStatusEnum.succeeded);
|
|
|
- detail.setTransNo(callback.getOrderNo());
|
|
|
+ detail.setTradeNo(callback.getOrderNo());
|
|
|
BigDecimal actualAmount = new BigDecimal(callback.getActualAmount());
|
|
|
detail.setActualAmount(actualAmount.divide(new BigDecimal("100")));
|
|
|
detail.setTransferTime(callback.getEndTime());
|
|
@@ -276,17 +300,9 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
} else if ("2".equals(callback.getStatus())) {
|
|
|
//交易失败
|
|
|
detail.setTradeStatus(TradeStatusEnum.failed);
|
|
|
+ detail.setTradeNo(callback.getOrderNo());
|
|
|
detail.setErrorCode(callback.getErrorCode());
|
|
|
detail.setErrorMsg(callback.getErrorMsg());
|
|
|
-
|
|
|
- //结算失败,账户解冻
|
|
|
- /*UserAccountRecordDto accountRecordDto = new UserAccountRecordDto(
|
|
|
- detail.getUserId(), detail.getAmount(), InOrOutEnum.OUT, AccountBizTypeEnum.WITHDRAWAL,
|
|
|
- detail.getId(), "老师结算", null
|
|
|
- );
|
|
|
- accountRecordDto.setFrozenType(FrozenTypeEnum.FROZEN_BACK);
|
|
|
- accountRecordDto.setSaveRecord(false);
|
|
|
- userAccountService.accountChange(accountRecordDto);*/
|
|
|
} else {
|
|
|
return;
|
|
|
}
|