Browse Source

提现拒绝

skyfffire 1 month ago
parent
commit
a5628eefb7

+ 1 - 1
src/main/java/common/utils/hyg/HygSDK.java

@@ -170,7 +170,7 @@ public class HygSDK {
             // 一次至少提现1000分
             // {"data":{"valueAddedTax":"0","distributeStatus":75,"incomeActualAmount":0,"constructionTax":"0","localEducationSupplementaryTax":"0","educationSurchargeTax":"0","remark":"计费标准超出范围","requestNo":"17588687904896652","individualIncomeTax":"0","incomeTaxAmount":0,"serviceCharge":"0","distributeId":"BL1421144242402639872","createTime":"2025-09-26 14:39:51","useCouponAmount":0,"distributeAmount":"100"},"statusText":"success","statusCode":"000000"}
             // {"data":{"valueAddedTax":"0","distributeStatus":60,"incomeActualAmount":1000,"constructionTax":"0","localEducationSupplementaryTax":"0","payTime":"2025-09-26 14:44:55","educationSurchargeTax":"0","remark":"","requestNo":"17588690942918042","individualIncomeTax":"0","incomeTaxAmount":0,"serviceCharge":"75","distributeId":"BL1421145516409892864","createTime":"2025-09-26 14:44:55","useCouponAmount":0,"bankSerialNo":"2011000420250926143698976426","distributeAmount":"1000"},"statusText":"success","statusCode":"000000"}
-            // AppConfig.LOGGER.info(HygSDK.signalQuery("DLTBH_WD_17588741472336835").toString());
+            // AppConfig.LOGGER.info(HygSDK.signalQuery("DLTBH_WD_17588746359625898").toString());
         } catch (Exception e) {
             e.printStackTrace();
         }

+ 35 - 2
src/main/java/modules/withdraw/WithdrawController.java

@@ -67,15 +67,48 @@ public class WithdrawController extends MyController {
             renderJson(MyRet.fail("withdraw_sn 不能为空"));
             return;
         }
-        Withdraw withdraw = Withdraw.dao.findFirst("SELECT * FROM t_withdraw WHERE withdraw_sn=?", withdraw_sn);
+        Withdraw withdraw = service.findByWithdrawSn(withdraw_sn);
         if (withdraw == null) {
             renderJson(MyRet.fail("withdraw_sn 找不到对应的单据"));
             return;
         }
         
+        // 订单状态过滤
+        if (withdraw.getState() != 10) {
+            renderJson(MyRet.fail("只有未审批的才能进行打款"));
+            return;
+        }
+
         // 获取操作人的id
         long approverId = userService.findUserByMobileNumber(getSessionAttr("mobile_number")).getId();
-        
+
         renderJson(service.pass(withdraw, approverId));
     }
+
+    @Before(LoginInterceptor.class)
+    @RequiredRoleInterface({UserController.ROLE_SUPER_ADMIN})
+    @EmptyInterface({"withdraw_sn", "reason"})
+    public void refuse() {
+        JSONObject requestBodyJson = MyController.getJsonModelByRequestAndType(getRequest(), JSONObject.class);
+
+        String withdraw_sn = requestBodyJson.getString("withdraw_sn");
+        String reason = requestBodyJson.getString("reason");
+
+        Withdraw withdraw = service.findByWithdrawSn(withdraw_sn);
+        if (withdraw == null) {
+            renderJson(MyRet.fail("withdraw_sn 找不到对应的单据"));
+            return;
+        }
+
+        // 订单状态过滤
+        if (withdraw.getState() != 10) {
+            renderJson(MyRet.fail("只有未审批的才能进行拒绝"));
+            return;
+        }
+
+        // 获取操作人的id
+        long approverId = userService.findUserByMobileNumber(getSessionAttr("mobile_number")).getId();
+
+        renderJson(service.refuse(withdraw, reason, approverId));
+    }
 }

+ 36 - 3
src/main/java/modules/withdraw/WithdrawService.java

@@ -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);
+    }
 }

+ 11 - 0
src/test/rest/WithdrawControllerTest.http

@@ -19,3 +19,14 @@ dl-token: {{dl_token_var}}
 {
   "withdraw_sn": "DLTBH_WD_17588746359625898"
 }
+
+### 【超级管理员】 拒绝该用户的提现申请
+### 对接之前一定要让管理员多确认一次,不要点pass就直接提交到后台来了,确认给他放款(amount/100)元
+POST {{ baseUrl }}/withdraw/refuse
+Content-Type: application/json
+dl-token: {{dl_token_var}}
+
+{
+  "withdraw_sn": "DLTBH_WD_17588820871315418",
+  "reason": "你提的太多了"
+}