提交 498001ad 作者: 张小凤

RepoCash

上级 fbdd250f
......@@ -131,4 +131,17 @@ public class RepoCashController extends BaseController {
public RepoCashDTO feignRefundInfo(@RequestParam String refundNo) {
return repoCashService.getRefundInfo(refundNo);
}
@ApiOperation(value = "退款金额---用户后台内部调用前端不使用")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("amountOfRefund")
public ResultBody amountOfRefund(HttpServletRequest request, @RequestParam(value = "orderNo") String orderNo,
@RequestParam(value = "actualPay") BigDecimal actualPay,
@RequestParam(value = "repoAccountId") Integer repoAccountId,
@RequestParam(value = "refundNo") String refundNo) {
return repoCashService.amountOfRefund(this.getCurrentAccount(request), orderNo, actualPay, repoAccountId, refundNo);
}
}
......@@ -172,6 +172,66 @@ public class RepoCashServiceImpl implements RepoCashService {
return ResultBody.success();
}
@Override
public ResultBody amountOfRefund(BaseAccountDTO cuser, String orderNo, BigDecimal actualPay, Integer repoAccountId, String refundNo) {
if (cuser.getPortType().equals(PortTypeEnum.CLIENTS_AND_APPLETS.getCode())) {
return ResultBody.error(ResultEnum.FAILED_TO_CHARGE_MONEY);
}
// 金额范围验证
/*if (!AmtUtil.vertifyRepoAmt(cash.getAmtPaid())) {
return ResultBody.error(ResultEnum.AMT_PAID_VERITY_ERROR);
}*/
// 密码认证
/* ResultBody body = passwordAuthentication(cuser, cash);
if (body != null) {
return body;
}*/
/**
* 用户信息
*/
ResponseEntity<String> responseEntity = UserId(repoAccountId);
UserAccountSimpleDTO account = JSON.parseObject(responseEntity.getBody(), UserAccountSimpleDTO.class);
if (account == null) {
return ResultBody.error(ResultEnum.FEIGN_REPOUSER_SERVLET_ERROR);
}
RepoWalletDO wallet = repoCashDao.getRepoWalletInfo(repoAccountId);
if (wallet == null) {
return ResultBody.error(ResultEnum.WALLET_NOT_FIND_ERROR);
}
// 扣除的金额不能大于余额
BigDecimal amtPaid = actualPay;
if (amtPaid.compareTo(BigDecimal.ZERO) < 0) {
BigDecimal negate = new BigDecimal(String.valueOf(amtPaid)).negate();
if (negate.compareTo(wallet.getCashAmt()) > 0) {
return ResultBody.error(ResultEnum.WALLET_CASH_NOT_ENOUGH_ERROR);
}
}
Date cdate = new Date();
RepoCashDO rc = new RepoCashDO();
rc.setRepoAccountId(account.getId());
rc.setUid(account.getUid());
rc.setAccountName(account.getUserName());
rc.setPayNo(CodeUtil.createRepoCashNo());
rc.setPayMethod(RepoCashMethod.REG.getCode());
rc.setAmtPaid(actualPay);
BigDecimal newCashAmt =
(wallet.getCashAmt().add(actualPay)).setScale(2, BigDecimal.ROUND_DOWN);
rc.setCashAmt(newCashAmt);
rc.setPayTime(cdate);
/* String voucher =
Collections.isEmpty(cash.getVoucher()) ? null : String.join(",", cash.getVoucher());*/
rc.setCreateTime(cdate);
rc.setCreateUser(cuser.getUserAccountId());
rc.setRefundNo(refundNo);
repoCashDao.insertRepoCash(rc);
Integer id = account.getId();
BigDecimal amtPaid1 = rc.getAmtPaid();
repoCashDao.updateRepoWalletAmt(account.getId(), rc.getAmtPaid());
return ResultBody.success();
}
/**
* 密码认证
*
......
......@@ -31,6 +31,8 @@ public interface RepoCashService {
*/
ResultBody reqCash(BaseAccountDTO cuser, RepoCashVO cash);
ResultBody amountOfRefund(BaseAccountDTO cuser, String orderNo, BigDecimal actualPay, Integer repoAccountId, String refundNo);
ResultBody dedCash(BaseAccountDTO cuser, RepoCashVO cash);
RepoCashDTO getRefundInfo(String refundNo);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论