Commit cf0cae88 by gonglei

加入框架代码

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