驳回
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Failing after 7m17s

This commit is contained in:
2026-06-26 12:12:15 +09:00
parent 8cf921f11c
commit f4b6a55b27
18 changed files with 119 additions and 431 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"github.com/break/junhong_cmp_fiber/internal/model"
"github.com/break/junhong_cmp_fiber/pkg/constants"
"github.com/redis/go-redis/v9"
"gorm.io/gorm"
)
@@ -74,6 +75,25 @@ func (s *AgentRechargeStore) Update(ctx context.Context, record *model.AgentRech
return s.db.WithContext(ctx).Save(record).Error
}
// UpdateStatusWithRejection 条件更新状态为已驳回并写入驳回原因
// 仅当 status = 1待支付时更新RowsAffected=0 说明订单不存在或状态已变更
func (s *AgentRechargeStore) UpdateStatusWithRejection(ctx context.Context, id uint, rejectionReason string) error {
result := s.db.WithContext(ctx).
Model(&model.AgentRechargeRecord{}).
Where("id = ? AND status = ?", id, constants.RechargeStatusPending).
Updates(map[string]interface{}{
"status": constants.RechargeStatusRejected,
"rejection_reason": rejectionReason,
})
if result.Error != nil {
return result.Error
}
if result.RowsAffected == 0 {
return gorm.ErrRecordNotFound
}
return nil
}
// UpdateWithTx 更新充值记录(带事务)
func (s *AgentRechargeStore) UpdateWithTx(ctx context.Context, tx *gorm.DB, record *model.AgentRechargeRecord) error {
return tx.WithContext(ctx).Save(record).Error

View File

@@ -94,25 +94,6 @@ func (s *RechargeOrderStore) Update(ctx context.Context, order *model.RechargeOr
return s.db.WithContext(ctx).Save(order).Error
}
// UpdateStatusWithRejection 条件更新订单状态为已驳回并写入驳回原因
// 仅当 status = 0待支付时更新RowsAffected=0 说明订单不存在或状态已变更
func (s *RechargeOrderStore) UpdateStatusWithRejection(ctx context.Context, id uint, rejectionReason string) error {
result := s.db.WithContext(ctx).
Model(&model.RechargeOrder{}).
Where("id = ? AND status = ?", id, model.RechargeOrderStatusPending).
Updates(map[string]interface{}{
"status": model.RechargeOrderStatusRejected,
"rejection_reason": rejectionReason,
})
if result.Error != nil {
return result.Error
}
if result.RowsAffected == 0 {
return gorm.ErrRecordNotFound
}
return nil
}
func (s *RechargeOrderStore) ListByCard(ctx context.Context, iotCardID uint, generation int, offset, limit int) ([]*model.RechargeOrder, error) {
var orders []*model.RechargeOrder
query := s.db.WithContext(ctx).