Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄成意
/
go_sku_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
69fd239d
authored
Oct 09, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
判断优先级
parent
525fcd95
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
service/service_activity.go
service/sorter/activity.go
service/service_activity.go
View file @
69fd239d
...
...
@@ -5,6 +5,8 @@ import (
"fmt"
"go_sku_server/model"
"go_sku_server/pkg/gredis"
"go_sku_server/service/sorter"
"sort"
"strconv"
"strings"
"time"
...
...
@@ -30,6 +32,8 @@ func (as *ActivityService) GetActivityData(checkData model.ActivityCheckData) (p
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
//对活动进行创建时间逆序排序,因为要以创建时间靠后的优先级最高
sort
.
Sort
(
sorter
.
ActivitySorter
(
activities
))
if
len
(
activities
)
!=
0
{
priceActivity
=
as
.
GetPriceActivity
(
checkData
,
activities
)
}
...
...
service/sorter/activity.go
0 → 100644
View file @
69fd239d
package
sorter
import
"go_sku_server/model"
// 阶梯价格排序算法
type
ActivitySorter
[]
model
.
Activity
func
(
a
ActivitySorter
)
Len
()
int
{
return
len
(
a
)
}
func
(
a
ActivitySorter
)
Swap
(
i
,
j
int
)
{
a
[
i
],
a
[
j
]
=
a
[
j
],
a
[
i
]
}
func
(
a
ActivitySorter
)
Less
(
i
,
j
int
)
bool
{
return
a
[
j
]
.
AddTime
<
a
[
i
]
.
AddTime
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment