Compare commits
No commits in common. "eb414749c332ee0494fbe04b939f7986dc16557f" and "6f6943f295fb3f60057118e40539baeb10fb2f65" have entirely different histories.
eb414749c3
...
6f6943f295
@ -236,12 +236,14 @@ func (l *PurchaseLogic) Purchase(req *types.PurchaseOrderRequest) (resp *types.P
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// query user is new purchase or renewal
|
// query user is new purchase or renewal
|
||||||
// 注意:SingleModel 下 orderType 会被路由成 2(续费),但仍需正确判断是否首购以发佣金
|
isNew := false
|
||||||
isNew, err := l.svcCtx.OrderModel.IsUserEligibleForNewOrder(l.ctx, u.Id)
|
if orderType == 1 {
|
||||||
|
isNew, err = l.svcCtx.OrderModel.IsUserEligibleForNewOrder(l.ctx, u.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Errorw("[Purchase] Database query error", logger.Field("error", err.Error()), logger.Field("user_id", u.Id))
|
l.Errorw("[Purchase] Database query error", logger.Field("error", err.Error()), logger.Field("user_id", u.Id))
|
||||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "find user order error: %v", err.Error())
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "find user order error: %v", err.Error())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// create order
|
// create order
|
||||||
orderInfo := &order.Order{
|
orderInfo := &order.Order{
|
||||||
UserId: u.Id,
|
UserId: u.Id,
|
||||||
|
|||||||
@ -41,7 +41,7 @@ func (m *customUserModel) QueryDevicePageList(ctx context.Context, userId, subsc
|
|||||||
var list []*Device
|
var list []*Device
|
||||||
var total int64
|
var total int64
|
||||||
err := m.QueryNoCacheCtx(ctx, &list, func(conn *gorm.DB, v interface{}) error {
|
err := m.QueryNoCacheCtx(ctx, &list, func(conn *gorm.DB, v interface{}) error {
|
||||||
return conn.Model(&Device{}).Where("`user_id` = ?", userId).Count(&total).Limit(size).Offset((page - 1) * size).Find(&list).Error
|
return conn.Model(&Device{}).Where("`user_id` = ? and `subscribe_id` = ?", userId, subscribeId).Count(&total).Limit(size).Offset((page - 1) * size).Find(&list).Error
|
||||||
})
|
})
|
||||||
return list, total, err
|
return list, total, err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,7 +54,7 @@ func UseLatest(header string, threshold string) bool {
|
|||||||
thresholdVersion, _ = Parse(DefaultThreshold)
|
thresholdVersion, _ = Parse(DefaultThreshold)
|
||||||
}
|
}
|
||||||
|
|
||||||
return compare(currentVersion, thresholdVersion) >= 0
|
return compare(currentVersion, thresholdVersion) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func compare(left Version, right Version) int {
|
func compare(left Version, right Version) int {
|
||||||
|
|||||||
@ -3,13 +3,11 @@ package traffic
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/perfect-panel/server/internal/model/node"
|
"github.com/perfect-panel/server/internal/model/node"
|
||||||
"github.com/perfect-panel/server/pkg/logger"
|
"github.com/perfect-panel/server/pkg/logger"
|
||||||
"github.com/perfect-panel/server/pkg/speedlimit"
|
|
||||||
|
|
||||||
"github.com/hibiken/asynq"
|
"github.com/hibiken/asynq"
|
||||||
"github.com/perfect-panel/server/internal/model/traffic"
|
"github.com/perfect-panel/server/internal/model/traffic"
|
||||||
@ -128,21 +126,6 @@ func (l *TrafficStatisticsLogic) ProcessTask(ctx context.Context, task *asynq.Ta
|
|||||||
logger.Field("error", err.Error()),
|
logger.Field("error", err.Error()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 写完流量后检查是否触发按量限速,若触发则清除节点缓存使限速立即生效
|
|
||||||
if planSub, planErr := l.svc.SubscribeModel.FindOne(ctx, sub.SubscribeId); planErr == nil &&
|
|
||||||
(planSub.SpeedLimit > 0 || planSub.TrafficLimit != "") {
|
|
||||||
throttle := speedlimit.Calculate(ctx, l.svc.DB, sub.UserId, sub.Id, planSub.SpeedLimit, planSub.TrafficLimit)
|
|
||||||
if throttle.IsThrottled {
|
|
||||||
cacheKey := fmt.Sprintf("%s%d", node.ServerUserListCacheKey, payload.ServerId)
|
|
||||||
if delErr := l.svc.Redis.Del(ctx, cacheKey).Err(); delErr != nil {
|
|
||||||
logger.WithContext(ctx).Error("[TrafficStatistics] Clear server user cache failed",
|
|
||||||
logger.Field("serverId", payload.ServerId),
|
|
||||||
logger.Field("error", delErr.Error()),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user