Browse Source

fix(daytask): 优化提现审核与打款状态校验及响应

urban 21 hours ago
parent
commit
4f5333cdd4
1 changed files with 19 additions and 6 deletions
  1. 19 6
      service/daytask/dt_finance.go

+ 19 - 6
service/daytask/dt_finance.go

@@ -120,7 +120,7 @@ func (s *DtWithdrawOrderService) Audit(c *gin.Context) {
 	s.SetDbAlias("daytask")
 	type request struct {
 		Id           int64  `json:"id" binding:"required"`
-		Status       int8   `json:"status" binding:"required"` // 1=通过 4=拒绝
+		Status       int8   `json:"status" binding:"required"` // 1=审核通过 4=拒绝
 		RejectReason string `json:"rejectReason"`
 		Remark       string `json:"remark"`
 	}
@@ -130,6 +130,12 @@ func (s *DtWithdrawOrderService) Audit(c *gin.Context) {
 		return
 	}
 
+	// 只允许审核通过(1)或拒绝(4),其他状态视为参数错误
+	if req.Status != 1 && req.Status != 4 {
+		response.Resp(c, response.ResponseCodeParamError)
+		return
+	}
+
 	updates := map[string]interface{}{
 		"status":     req.Status,
 		"remark":     req.Remark,
@@ -144,7 +150,8 @@ func (s *DtWithdrawOrderService) Audit(c *gin.Context) {
 		response.Resp(c, err.Error())
 		return
 	}
-	response.Resp(c, "操作成功")
+	// 使用默认成功响应(code=200,msg=操作成功)
+	response.Resp(c)
 }
 
 // Pay 打款
@@ -170,12 +177,18 @@ func (s *DtWithdrawOrderService) Pay(c *gin.Context) {
 		"pay_time":       c.GetInt64("now"),
 	}
 
-	err := s.DB().Model(&model.DtWithdrawOrder{}).Where("id = ? AND status = 1", req.Id).Updates(updates).Error
-	if err != nil {
-		response.Resp(c, err.Error())
+	db := s.DB().Model(&model.DtWithdrawOrder{}).Where("id = ? AND status = 1", req.Id).Updates(updates)
+	if db.Error != nil {
+		response.Resp(c, db.Error.Error())
+		return
+	}
+	// 如果没有行受影响,说明当前订单不在「审核通过」状态
+	if db.RowsAffected == 0 {
+		response.Resp(c, response.ResponseCodeParamError)
 		return
 	}
-	response.Resp(c, "操作成功")
+	// 使用默认成功响应(code=200,msg=操作成功)
+	response.Resp(c)
 }
 
 // DtBalanceLogService 资金流水服务