|
|
@@ -54,7 +54,7 @@ public class WithdrawService {
|
|
|
|
|
|
float amountCNY = (float)amountWithoutFee / (float)100;
|
|
|
float feePercent = (float)WITHDRAW_FEE / (float)100;
|
|
|
- return MyRet.ok(String.format("提现%s火花,实际到账%.2f(元),手续费%s%%,申请已提交", amount, amountCNY, feePercent));
|
|
|
+ return MyRet.ok(String.format("提现%s火花,实际到账%.2f(元),手续费%s%%,申请已提交", amount, amountCNY, feePercent)).setData(findByWithdrawSn(orderSn));
|
|
|
} catch (Exception e) {
|
|
|
return MyRet.fail("提现申请失败: " + e.getMessage());
|
|
|
}
|
|
|
@@ -103,12 +103,45 @@ public class WithdrawService {
|
|
|
withdraw.setHygOrigin(withdrawRst.toString());
|
|
|
withdraw.setState(20);
|
|
|
if (withdraw.update()) {
|
|
|
- return MyRet.ok("打款请求已发起");
|
|
|
+ return MyRet.ok("打款请求已发起").setData(withdraw);
|
|
|
} else {
|
|
|
- return MyRet.ok("单据状态更新失败");
|
|
|
+ return MyRet.fail("单据状态更新失败");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
return MyRet.fail("打款请求已发起失败: " + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public MyRet refuse(Withdraw withdraw, String reason, long approverId) {
|
|
|
+ User user = User.dao.findById(withdraw.getUserId());
|
|
|
+
|
|
|
+ try {
|
|
|
+ Db.tx(() -> {
|
|
|
+ user.setBalance(user.getBalance() + withdraw.getAmount());
|
|
|
+
|
|
|
+ if (!user.update()) {
|
|
|
+ throw new RuntimeException("用户余额扣减失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 记录操作人
|
|
|
+ withdraw.setApproverId(approverId);
|
|
|
+ withdraw.setReason(reason);
|
|
|
+ withdraw.setState(40);
|
|
|
+
|
|
|
+ if (!withdraw.update()) {
|
|
|
+ throw new RuntimeException("提现单据保存失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ });
|
|
|
+
|
|
|
+ return MyRet.ok("该单据已拒绝").setData(withdraw);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return MyRet.fail("拒绝失败:" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public Withdraw findByWithdrawSn(String sn) {
|
|
|
+ return Withdraw.dao.findFirst("SELECT * FROM t_withdraw WHERE withdraw_sn=?", sn);
|
|
|
+ }
|
|
|
}
|