提交 48f02ca8 authored 作者: huyufan's avatar huyufan

资金管理

上级 2bc243a9
......@@ -13,7 +13,10 @@ public enum IdTypeEnum {
@AllArgsConstructor
public enum Type {
TOP_UP(1L, "充值"),
CASE_OUT(2L, "提现")
CASE_OUT(2L, "提现"),
CASE_OUT_FROZEN(3L, "提现冻结"),
CASE_OUT_SUCCESS(4L, "提现成功"),
TOP_UP_SUCCESS(5L, "充值成功"),
;
private final Long code;
private final String msg;
......
......@@ -7,6 +7,8 @@ import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import java.math.BigDecimal;
@ApiModel(description = "提现审批")
@Getter
@Setter
......@@ -26,4 +28,7 @@ public class OwnerCaseOutApproveParam {
@ApiModelProperty(value = "付款凭证", example = "a.png")
private String paymentProof;
@ApiModelProperty(value = "平台付款金额", example = "11.21")
private BigDecimal platformPayBalance;
}
......@@ -19,6 +19,9 @@ public class OwnerAccountRunningWaterRecordVO {
*/
@ApiModelProperty("id")
private Integer id;
@ApiModelProperty("流水号")
private Long runningWaterNo;
/**
* 货主编码
*/
......
......@@ -20,6 +20,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.util.List;
@Slf4j
......@@ -79,6 +80,14 @@ public class OwnerAccountController {
return Result.ok(id);
}
@ApiOperation(value = "货主付款确认", notes = "<br>By:胡宇帆")
@PostMapping("/accountBalanceConfirm")
@UnitCovert(param = false)
public void accountBalanceConfirm(@RequestParam @NotNull(message = "编号不能为空") Integer id) {
ownerAccountService.accountBalanceConfirm(id);
}
@ApiOperation(value = "货主账户流水列表", notes = "<br>By:胡宇帆")
@PostMapping("/ownerAccountRunningWaterPageList")
@UnitCovert(param = false)
......
......@@ -86,6 +86,12 @@ public class OwnerCaseOut implements HasKey<Integer> {
*/
@TableField("platform_payment_bank_number")
private String platformPaymentBankNumber;
/**
* 平台付款金额
*/
@TableField("platform_pay_balance")
private BigDecimal platformPayBalance;
/**
* 付款人
*/
......
......@@ -30,6 +30,12 @@ public class OwnerRunningWaterRecord implements HasKey<Integer> {
*/
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
* 流水号
*/
@TableField("running_water_no")
private Long runningWaterNo;
/**
* 货主编码
*/
......@@ -52,10 +58,10 @@ public class OwnerRunningWaterRecord implements HasKey<Integer> {
private Integer accountType;
/**
* 关联数据主键ID
* 关联数据编号
*/
@TableField("relation_id")
private Integer relationId;
private Long relationId;
/**
* 流水类型
*/
......
......@@ -30,4 +30,10 @@ public interface OwnerAccountService {
* @param param
*/
void accountCaseOutApprove(OwnerCaseOutApproveParam param);
/**
* 货主付款确认
* @param id
*/
void accountBalanceConfirm(Integer id);
}
......@@ -81,6 +81,7 @@ public class OwnerAccountServiceImpl implements OwnerAccountService {
}
@Override
@Transactional(rollbackFor = Exception.class)
public Long accountCaseOut(OwnerCaseOutParam param) {
//提现记录
OwnerCaseOut entity = new OwnerCaseOut();
......@@ -93,6 +94,27 @@ public class OwnerAccountServiceImpl implements OwnerAccountService {
entity.setCaseOutBankNumber(param.getCaseOutBankNumber());
ownerCaseOutDao.saveEntity(entity);
//插入冻结流水
OwnerRunningWaterRecord runningWaterRecord = new OwnerRunningWaterRecord();
BigDecimal caseOutBalance = param.getCaseOutBalance();
runningWaterRecord.setOwnerName("测试");
runningWaterRecord.setMobile("11111111111");
runningWaterRecord.setCreateBy("操作人测试");
runningWaterRecord.setRelationId(entity.getCaseOutNo());
runningWaterRecord.setAccountBalance(caseOutBalance);
runningWaterRecord.setOwnerUserNo(param.getOwnerUserNo());
runningWaterRecord.setAccountType(param.getAccountType());
runningWaterRecord.setRunningWaterType(OwnerAccountEnum.RunningWaterStatus.FROZEN.getCode());
runningWaterRecord.setRunningWaterNo(idGenerateSnowFlake.nextId(IdTypeEnum.Type.CASE_OUT_FROZEN.getCode()));
ownerRunningWaterRecordDao.saveEntity(runningWaterRecord);
//冻结账户可用金额
OwnerAccount account = ownerAccountDao.getAccountByOwnerUserNoAndAccountType(param.getOwnerUserNo(), param.getAccountType());
OwnerAccount update = new OwnerAccount();
update.setUsableBalance(account.getUsableBalance().subtract(caseOutBalance));
update.setFrozenBalance(account.getFrozenBalance().add(caseOutBalance));
update.setId(account.getId());
ownerAccountDao.updateEntityByKey(update);
return entity.getCaseOutNo();
}
......@@ -124,12 +146,13 @@ public class OwnerAccountServiceImpl implements OwnerAccountService {
runningWaterRecord.setMobile("11111111111");
runningWaterRecord.setCreateBy("操作人测试");
runningWaterRecord.setRelationId(ownerTopUp.getId());
runningWaterRecord.setRelationId(ownerTopUp.getTopUpNo());
runningWaterRecord.setAccountBalance(topUpBalance);
runningWaterRecord.setOwnerUserNo(param.getOwnerUserNo());
runningWaterRecord.setAccountType(param.getAccountType());
runningWaterRecord.setRunningWaterType(OwnerAccountEnum.RunningWaterStatus.TOP_UP.getCode());
runningWaterRecord.setRunningWaterNo(idGenerateSnowFlake.nextId(IdTypeEnum.Type.TOP_UP_SUCCESS.getCode()));
ownerRunningWaterRecordDao.saveEntity(runningWaterRecord);
//给对应账户增加金额
......@@ -153,6 +176,45 @@ public class OwnerAccountServiceImpl implements OwnerAccountService {
entity.setPaymentProof(param.getPaymentProof());
entity.setPlatformPaymentBank(entity.getPlatformPaymentBank());
entity.setPlatformPaymentBankNumber(param.getPlatformPaymentBankNumber());
entity.setPlatformPayBalance(param.getPlatformPayBalance());
entity.setStatus(OwnerAccountEnum.CaseOutStatus.TO_BE_CONFIRMED.getCode());
ownerCaseOutDao.updateEntityByKey(entity);
}
@Override
public void accountBalanceConfirm(Integer id) {
Optional<OwnerCaseOut> optional = ownerCaseOutDao.getEntityByKey(id);
if (!optional.isPresent()) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "当前ID未查询到有效记录");
}
OwnerCaseOut ownerCaseOut = optional.get();
BigDecimal caseOutBalance = ownerCaseOut.getCaseOutBalance();
BigDecimal platformPayBalance = ownerCaseOut.getPlatformPayBalance();
if (platformPayBalance.compareTo(caseOutBalance) != 0) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "货主提现金额和平台支付金额不一致");
}
//插入提现成功流水
OwnerRunningWaterRecord runningWaterRecord = new OwnerRunningWaterRecord();
runningWaterRecord.setOwnerName("测试");
runningWaterRecord.setMobile("11111111111");
runningWaterRecord.setCreateBy("操作人");
runningWaterRecord.setRelationId(ownerCaseOut.getCaseOutNo());
runningWaterRecord.setAccountBalance(caseOutBalance);
runningWaterRecord.setOwnerUserNo(ownerCaseOut.getOwnerUserNo());
runningWaterRecord.setAccountType(ownerCaseOut.getAccountType());
runningWaterRecord.setRunningWaterType(OwnerAccountEnum.RunningWaterStatus.CASE_OUT_SUCCESS.getCode());
runningWaterRecord.setRunningWaterNo(idGenerateSnowFlake.nextId(IdTypeEnum.Type.CASE_OUT_SUCCESS.getCode()));
ownerRunningWaterRecordDao.saveEntity(runningWaterRecord);
//给对应账户减少金额
OwnerAccount account = ownerAccountDao.getAccountByOwnerUserNoAndAccountType(ownerCaseOut.getOwnerUserNo(), ownerCaseOut.getAccountType());
OwnerAccount update = new OwnerAccount();
update.setAccountBalance(account.getAccountBalance().subtract(caseOutBalance));
update.setUsableBalance(account.getUsableBalance().subtract(caseOutBalance));
update.setFrozenBalance(account.getFrozenBalance().subtract(caseOutBalance));
update.setId(account.getId());
ownerAccountDao.updateEntityByKey(update);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论