Commit cf0cae88 by gonglei

加入框架代码

1 parent 6f317b09
......@@ -62,22 +62,12 @@ public class WithdrawBean {
private AuditState auditState;
@ExcelProperty("付款单号")
private String transferBillNo;
@ExcelProperty("已退款金额")
private Double refundAmount;
@ExcelProperty(value = "付款状态", converter = WithdrawStateConverter.class)
private String state;
@ExcelProperty("失败原因")
private String failReason;
@ExcelProperty("付款金额")
private Double paymentAmount;
@ExcelProperty("发起付款时间")
private LocalDateTime paymentTime;
// @ExcelProperty("发起付款时间")
// private LocalDateTime paymentTime;
@ExcelProperty("转账成功时间")
private LocalDateTime transferTime;
......@@ -96,11 +86,8 @@ public class WithdrawBean {
this.auditTime = withdraw.getAuditTime();
this.amount = withdraw.getAmount();
this.auditState = withdraw.getAuditState();
this.transferBillNo = withdraw.getTransferBillNo();
this.state = withdraw.getState();
this.failReason = withdraw.getFailReason();
this.paymentAmount = withdraw.getPaymentAmount();
this.paymentTime = withdraw.getPaymentTime();
this.refundAmount = withdraw.getRefundAmount();
// this.paymentTime = withdraw.getPaymentTime();
this.transferTime = withdraw.getTransferTime();
this.transferRemark = withdraw.getTransferRemark();
}
......
......@@ -71,10 +71,10 @@ public class WithdrawController {
return withdrawService.addWithdraw(withdraw);
}
@GetMapping("getWithdrawsByWaitUserConfirm")
public List<Withdraw> getWithdrawsByWaitUserConfirm(@RequestAttribute(LOGIN_ACCOUNT) Account account) {
return withdrawService.getWithdrawsByWaitUserConfirm(account);
}
// @GetMapping("getWithdrawsByWaitUserConfirm")
// public List<Withdraw> getWithdrawsByWaitUserConfirm(@RequestAttribute(LOGIN_ACCOUNT) Account account) {
// return withdrawService.getWithdrawsByWaitUserConfirm(account);
// }
@GetMapping("getWxPayMchId")
public String getWxPayMchId() {
......@@ -82,9 +82,9 @@ public class WithdrawController {
}
@PostMapping("updateWithdrawStateById")
public int updateWithdrawStateById(@RequestParam int withdrawId) {
withdrawService.updateWithdrawStateById(withdrawId);
return withdrawId;
}
// @PostMapping("updateWithdrawStateById")
// public int updateWithdrawStateById(@RequestParam int withdrawId) {
// withdrawService.updateWithdrawStateById(withdrawId);
// return withdrawId;
// }
}
\ No newline at end of file
......@@ -36,13 +36,12 @@ public interface WithdrawDao extends BaseRepository<Withdraw, Integer>, JpaSpeci
* @param auditState
* @return
*/
@Query("select sum(w.amount) from Withdraw w where w.account.accountId =?1 and w.auditState =?2 or (w.auditState =com.glsx.usedcar.module.meta.AuditState.AUDITED and w.state not in ('SUCCESS','FAIL'))")
@Query("select sum(w.amount) from Withdraw w where w.account.accountId =?1 and w.auditState =?2")
Optional<Double> sumWithdrawByAccountAuditState(int accountId, AuditState auditState);
List<Withdraw> findByAuditStateAndAuditTimeIsAfterAndStateNotIn(AuditState auditState, LocalDateTime auditTime, List<String> status);
@EntityGraph(attributePaths = {"account"})
List<Withdraw> findByAccountAndStateOrderByPaymentTimeDesc(Account account, String state);
// @EntityGraph(attributePaths = {"account"})
// List<Withdraw> findByAccountAndStateOrderByPaymentTimeDesc(Account account, String state);
List<Withdraw> findByAccount_AccountIdAndAuditStateOrderByCreateTimeDesc(int accountId, AuditState auditState);
......
......@@ -97,10 +97,10 @@ public class WithdrawService {
return withdrawDao.findByWithdrawId(withdrawId).orElseThrow(() -> new ObjectNotFoundException(withdrawId, Withdraw.class.getSimpleName()));
}
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public Withdraw updateWithdrawStateById(int withdrawId) {
return withdrawDao.updateById(withdrawId, UpdateField.of(Withdraw_.state, "TRANSFERING"), UpdateField.of(Withdraw_.confirmTime, LocalDateTime.now()));
}
// @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
// public Withdraw updateWithdrawStateById(int withdrawId) {
// return withdrawDao.updateById(withdrawId, UpdateField.of(Withdraw_.state, "TRANSFERING"), UpdateField.of(Withdraw_.confirmTime, LocalDateTime.now()));
// }
/**
* 分页查询
......@@ -133,7 +133,6 @@ public class WithdrawService {
withdraw.setWithdrawCode(CoderGenerator.generateCode(6));
withdraw.setApplyWithdrawTime(LocalDateTime.now());
withdraw.setAuditState(AuditState.UNAUDITED);
withdraw.setState(AuditState.UNAUDITED.name());
return withdrawDao.save(withdraw);
}
......@@ -171,7 +170,6 @@ public class WithdrawService {
totalRefundAmount = totalRefundAmount - refundAmount;
}
}
withdraw.setPaymentTime(LocalDateTime.now());
// withdraw.setPaymentTime(DateTimeUtils.attemptParseLocalDateTime(result.getCreateTime()));
}
withdraw.setRejectReason(approveHistory.getRejectReason());
......@@ -266,25 +264,22 @@ public class WithdrawService {
// return wxPayRefundV3Result;
// }
public List<Withdraw> getWithdrawsByWaitUserConfirm(Account account) {
return withdrawDao.findByAccountAndStateOrderByPaymentTimeDesc(account, "WAIT_USER_CONFIRM");
}
// public List<Withdraw> getWithdrawsByWaitUserConfirm(Account account) {
// return withdrawDao.findByAccountAndStateOrderByPaymentTimeDesc(account, "WAIT_USER_CONFIRM");
// }
public List<Withdraw> getAuditedWithdraws(LocalDateTime auditTime) {
return withdrawDao.findByAuditStateAndAuditTimeIsAfterAndStateNotIn(AuditState.AUDITED, auditTime, List.of("SUCCESS", "FAIL"));
}
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void updateWithdrawStatus(TransferBillsGetResult result) {
Optional<Withdraw> withdrawOptional = withdrawDao.findByWithdrawCode(result.getOutBillNo());
if (withdrawOptional.isPresent()) {
Withdraw withdraw = withdrawOptional.get();
if ("SUCCESS".equals(result.getState()) && !"SUCCESS".equals(withdraw.getState())) {
Account account = withdraw.getAccount();
account.setSurplus(account.getSurplus() - withdraw.getAmount());
}
withdraw.setPayResult(result);
}
// Optional<Withdraw> withdrawOptional = withdrawDao.findByWithdrawCode(result.getOutBillNo());
// if (withdrawOptional.isPresent()) {
// Withdraw withdraw = withdrawOptional.get();
// if ("SUCCESS".equals(result.getState()) && !"SUCCESS".equals(withdraw.getState())) {
// Account account = withdraw.getAccount();
// account.setSurplus(account.getSurplus() - withdraw.getAmount());
// }
// withdraw.setPayResult(result);
// }
}
/**
......
......@@ -28,29 +28,29 @@ public class FinanceSchedule {
* @return
* @throws WxPayException
*/
@Scheduled(fixedDelay = 1000 * 10, initialDelay = 1000 * 50)
public void queryEntPay() {
LocalDateTime now = LocalDateTime.now();
List<Withdraw> auditedWithdraws = withdrawService.getAuditedWithdraws(now.minusDays(2));
for (Withdraw withdraw : auditedWithdraws) {
String outBillNo = withdraw.getWithdrawCode();
// 查询企业付款到零钱的结果
try {
TransferBillsGetResult result = wxService.getTransferService().getBillsByOutBillNo(outBillNo);
log.debug("=== 查询转账结果(商户单号)===");
log.debug("商户单号: " + result.getOutBillNo());
log.debug("微信转账单号: " + result.getTransferBillNo());
log.debug("状态: " + result.getState());
log.debug("转账金额: " + result.getTransferAmount() + "分");
log.debug("用户openid: " + result.getOpenid());
log.debug("转账备注: " + result.getTransferRemark());
log.debug("查询企业付款到零钱的结果:{}", result);
withdrawService.updateWithdrawStatus(result);
} catch (Exception e) {
// 处理异常
e.printStackTrace();
log.error("查询企业付款到零钱的结果失败:{}", e.getMessage());
}
}
}
// @Scheduled(fixedDelay = 1000 * 10, initialDelay = 1000 * 50)
// public void queryEntPay() {
// LocalDateTime now = LocalDateTime.now();
// List<Withdraw> auditedWithdraws = withdrawService.getAuditedWithdraws(now.minusDays(2));
// for (Withdraw withdraw : auditedWithdraws) {
// String outBillNo = withdraw.getWithdrawCode();
// // 查询企业付款到零钱的结果
// try {
// TransferBillsGetResult result = wxService.getTransferService().getBillsByOutBillNo(outBillNo);
// log.debug("=== 查询转账结果(商户单号)===");
// log.debug("商户单号: " + result.getOutBillNo());
// log.debug("微信转账单号: " + result.getTransferBillNo());
// log.debug("状态: " + result.getState());
// log.debug("转账金额: " + result.getTransferAmount() + "分");
// log.debug("用户openid: " + result.getOpenid());
// log.debug("转账备注: " + result.getTransferRemark());
// log.debug("查询企业付款到零钱的结果:{}", result);
// withdrawService.updateWithdrawStatus(result);
// } catch (Exception e) {
// // 处理异常
// e.printStackTrace();
// log.error("查询企业付款到零钱的结果失败:{}", e.getMessage());
// }
// }
// }
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!