调整日志输出方式,更新数据库日志存储结构;首页查询统计数据接口实现
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"log/slog"
|
||||
"math"
|
||||
"math/rand/v2"
|
||||
@@ -217,6 +218,7 @@ func removeShortChannelExternal(proxies []*m.Proxy, channels []*m.Channel) error
|
||||
// region 创建通道
|
||||
|
||||
func (s *channelService) CreateChannel(
|
||||
c *fiber.Ctx,
|
||||
userId int32,
|
||||
resourceId int32,
|
||||
protocol channel2.Protocol,
|
||||
@@ -301,6 +303,18 @@ func (s *channelService) CreateChannel(
|
||||
return nil, core.NewBizErr("提交异步删除通道任务失败", err)
|
||||
}
|
||||
|
||||
// 记录通道创建日志
|
||||
slog.Info("创建通道",
|
||||
slog.Int("user_id", int(userId)),
|
||||
slog.Int("resource_id", int(resourceId)),
|
||||
slog.Int("count", count),
|
||||
slog.String("prov", filter.Prov),
|
||||
slog.String("city", filter.City),
|
||||
slog.String("isp", filter.Isp),
|
||||
slog.String("ip", c.IP()),
|
||||
slog.Time("time", now),
|
||||
)
|
||||
|
||||
return channels, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/shopspring/decimal"
|
||||
wecahtpay_core "github.com/wechatpay-apiv3/wechatpay-go/core"
|
||||
wecahtpaycore "github.com/wechatpay-apiv3/wechatpay-go/core"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
@@ -272,7 +272,7 @@ func (s *tradeService) OnTradeCreated(q *q.Query, data *OnTradeCreateData) (*m.T
|
||||
trade.Status = int32(trade2.StatusSuccess)
|
||||
trade.OuterNo = &transId
|
||||
trade.Payment = payment
|
||||
trade.Acquirer = int32(acquirer)
|
||||
trade.Acquirer = u.P(int32(acquirer))
|
||||
trade.PaidAt = u.P(orm.LocalDateTime(paidAt))
|
||||
trade.PayURL = u.P("")
|
||||
_, err = q.Trade.
|
||||
@@ -401,7 +401,7 @@ func (s *tradeService) VerifyTrade(data *TradeVerifyData) (*TradeSuccessResult,
|
||||
Mchid: &env.WechatPayMchId,
|
||||
})
|
||||
if err != nil {
|
||||
var apiErr *wecahtpay_core.APIError
|
||||
var apiErr *wecahtpaycore.APIError
|
||||
if errors.As(err, &apiErr) {
|
||||
if apiErr.Code == "ORDER_NOT_EXIST" {
|
||||
return nil, ErrTransactionNotPaid
|
||||
|
||||
Reference in New Issue
Block a user