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
766455de
authored
Jul 30, 2025
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'ysx-魔方售价组支持来源和分类-20250729' into dev
parents
7f61b493
840591bc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
105 deletions
model/activity.go
service/service_activity.go
service/service_ly.go
service/service_price.go
model/activity.go
View file @
766455de
...
...
@@ -42,10 +42,12 @@ type Activity struct {
StandardBrandIdList
[]
string
ExcludeStandardBrandIds
string
`json:"exclude_standard_brand_ids"`
ExcludeStandardBrandIdList
[]
string
CurrencyRmb
int
`json:"currency_rmb"`
CurrencyUs
int
`json:"currency_us"`
UseType
int
`json:"use_type"`
SignUrl
string
`json:"sign_url"`
CurrencyRmb
int
`json:"currency_rmb"`
CurrencyUs
int
`json:"currency_us"`
UseType
int
`json:"use_type"`
SignUrl
string
`json:"sign_url"`
Source
string
`json:"source"`
SourceList
[]
string
`json:"source_list"`
}
type
ActivityItem
struct
{
...
...
@@ -70,4 +72,5 @@ type ActivityCheckData struct {
Canal
string
ClassId
int
OrgId
int
Source
int
}
service/service_activity.go
View file @
766455de
...
...
@@ -49,74 +49,6 @@ func (as *ActivityService) GetActivityData(checkData model.ActivityCheckData) (p
return
}
// 获取满赠活动信息
func
(
as
*
ActivityService
)
GetGiftActivity
(
checkData
model
.
ActivityCheckData
,
activities
[]
model
.
Activity
)
(
giftActivity
model
.
GiftActivity
)
{
var
hasActivity
bool
nowTimestamp
:=
int
(
time
.
Now
()
.
Unix
())
for
_
,
activity
:=
range
activities
{
if
activity
.
Status
!=
1
{
continue
}
//判断时间是否过期
if
activity
.
StartTime
>
nowTimestamp
||
activity
.
EndTime
<
nowTimestamp
{
continue
}
//如果是整个供应商搞活动,则直接返回系数
if
activity
.
EntireSupplierActivity
{
hasActivity
=
true
goto
INFO
}
//判断是否是排除的sku或者品牌,如果是的话,直接返回没活动
if
as
.
CheckExcludeSku
(
checkData
.
GoodsId
,
activity
)
||
as
.
CheckExcludeBrand
(
checkData
.
BrandId
,
activity
)
{
continue
}
//判断是否是搞活动的品牌
if
as
.
CheckBrand
(
checkData
.
BrandId
,
activity
)
{
hasActivity
=
true
goto
INFO
}
//如果是专卖,则要去判断canal,如果是自营,则去判断分类
if
checkData
.
SupplierId
==
17
{
if
as
.
CheckCanal
(
checkData
.
Canal
,
activity
)
{
hasActivity
=
true
goto
INFO
}
}
else
{
if
as
.
CheckClass
(
checkData
.
ClassId
,
activity
)
{
hasActivity
=
true
goto
INFO
}
}
INFO
:
if
hasActivity
{
for
key
,
item
:=
range
activity
.
ItemList
{
activity
.
ItemList
[
key
]
.
Content
=
"订单满"
+
gconv
.
String
(
item
.
Amount
)
+
"元赠"
+
gconv
.
String
(
item
.
ItemName
)
+
"X"
+
gconv
.
String
(
item
.
Num
)
+
""
+
item
.
Remark
}
giftActivity
.
ActivityName
=
activity
.
ActivityName
giftActivity
.
ActivityId
=
activity
.
ActivityId
giftActivity
=
model
.
GiftActivity
{
CanAdminOrder
:
activity
.
CanAdminOrder
,
ItemList
:
activity
.
ItemList
,
ActivityCommon
:
model
.
ActivityCommon
{
HasActivity
:
hasActivity
,
ActivityId
:
activity
.
ActivityId
,
ActivityName
:
activity
.
ActivityName
,
AllowCoupon
:
activity
.
AllowCoupon
,
UserScope
:
activity
.
UserScope
,
},
}
break
}
}
return
}
func
(
as
*
ActivityService
)
GetPriceActivity
(
checkData
model
.
ActivityCheckData
,
activities
[]
model
.
Activity
)
(
priceActivity
model
.
PriceActivity
)
{
redisConn
:=
gredis
.
Conn
(
"default_r"
)
defer
redisConn
.
Close
()
...
...
@@ -140,6 +72,10 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
if
as
.
CheckExcludeSku
(
checkData
.
GoodsId
,
activity
)
||
as
.
CheckExcludeStandardBrand
(
checkData
.
StandardBrandId
,
activity
)
{
continue
}
//checkSource
if
!
as
.
CheckSource
(
checkData
.
Source
,
activity
)
{
continue
}
//如果是专卖,则要去判断canal,如果是自营,则去判断分类
if
checkData
.
SupplierId
==
17
{
...
...
@@ -175,8 +111,6 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
}
else
if
checkData
.
SupplierId
==
10000
{
//自营活动特殊判断
//fmt.Println(activity.ClassIds)
//fmt.Println(activity.UseType)
if
activity
.
ClassIds
!=
""
{
if
!
as
.
CheckClass
(
checkData
.
ClassId
,
activity
)
{
continue
...
...
@@ -275,10 +209,7 @@ func (as *ActivityService) CheckExcludeBrand(brandId int, activity model.Activit
activity
.
ExcludeBrandIdList
=
strings
.
Split
(
activity
.
ExcludeBrandIds
,
","
)
brandIdStr
:=
gconv
.
String
(
brandId
)
//如果存在于有活动价的品牌,就是有折扣活动了
if
php2go
.
InArray
(
brandIdStr
,
activity
.
ExcludeBrandIdList
)
{
return
true
}
return
false
return
php2go
.
InArray
(
brandIdStr
,
activity
.
ExcludeBrandIdList
)
}
// 检查是否属于被排除的标准品牌
...
...
@@ -290,10 +221,7 @@ func (as *ActivityService) CheckExcludeStandardBrand(standardBrandId int, activi
activity
.
ExcludeStandardBrandIdList
=
strings
.
Split
(
activity
.
ExcludeStandardBrandIds
,
","
)
standardBrandIdStr
:=
gconv
.
String
(
standardBrandId
)
//如果存在于有活动价的品牌,就是有折扣活动了
if
php2go
.
InArray
(
standardBrandIdStr
,
activity
.
ExcludeStandardBrandIdList
)
{
return
true
}
return
false
return
php2go
.
InArray
(
standardBrandIdStr
,
activity
.
ExcludeStandardBrandIdList
)
}
// 检查是否属于被排除的sku
...
...
@@ -304,10 +232,7 @@ func (as *ActivityService) CheckExcludeSku(skuId string, activity model.Activity
//先去判断品牌
activity
.
ExcludeSkuIdList
=
strings
.
Split
(
activity
.
ExcludeSkuIds
,
","
)
//如果存在于有活动价的品牌,就是有折扣活动了
if
php2go
.
InArray
(
skuId
,
activity
.
ExcludeSkuIdList
)
{
return
true
}
return
false
return
php2go
.
InArray
(
skuId
,
activity
.
ExcludeSkuIdList
)
}
// 检查是否属于活动分类(只有自营需要判断)
...
...
@@ -319,10 +244,7 @@ func (as *ActivityService) CheckClass(classId int, activity model.Activity) bool
activity
.
ClassIdList
=
strings
.
Split
(
activity
.
ClassIds
,
","
)
classIdStr
:=
gconv
.
String
(
classId
)
//如果存在于有活动价的品牌,就是有折扣活动了
if
php2go
.
InArray
(
classIdStr
,
activity
.
ClassIdList
)
{
return
true
}
return
false
return
php2go
.
InArray
(
classIdStr
,
activity
.
ClassIdList
)
}
// 检查是否属于活动品牌
...
...
@@ -334,10 +256,7 @@ func (as *ActivityService) CheckBrand(brandId int, activity model.Activity) bool
activity
.
BrandIdList
=
strings
.
Split
(
activity
.
BrandIds
,
","
)
brandIdStr
:=
gconv
.
String
(
brandId
)
//如果存在于有活动价的品牌,就是有折扣活动了
if
php2go
.
InArray
(
brandIdStr
,
activity
.
BrandIdList
)
{
return
true
}
return
false
return
php2go
.
InArray
(
brandIdStr
,
activity
.
BrandIdList
)
}
// 检测是否属于活动标准品牌
...
...
@@ -349,10 +268,7 @@ func (as *ActivityService) CheckStandardBrand(standardBrandId int, activity mode
activity
.
StandardBrandIdList
=
strings
.
Split
(
activity
.
StandardBrandIds
,
","
)
standardBrandIdStr
:=
gconv
.
String
(
standardBrandId
)
//如果存在于有活动价的品牌,就是有折扣活动了
if
php2go
.
InArray
(
standardBrandIdStr
,
activity
.
StandardBrandIdList
)
{
return
true
}
return
false
return
php2go
.
InArray
(
standardBrandIdStr
,
activity
.
StandardBrandIdList
)
}
// 检查是否属于供应商渠道
...
...
@@ -363,8 +279,23 @@ func (as *ActivityService) CheckCanal(canal string, activity model.Activity) boo
//先去判断品牌
activity
.
CanalList
=
strings
.
Split
(
activity
.
Canals
,
","
)
//如果存在于有活动价的品牌,就是有折扣活动了
if
php2go
.
InArray
(
canal
,
activity
.
CanalList
)
{
return
php2go
.
InArray
(
canal
,
activity
.
CanalList
)
}
// 检查来源是否有配置,有配置的话是否符合
func
(
as
*
ActivityService
)
CheckSource
(
source
int
,
activity
model
.
Activity
)
bool
{
if
source
==
0
{
source
=
1
}
//如果source为空,则默认为所有来源
if
activity
.
Source
==
""
{
return
true
}
return
false
//先去判断品牌
activity
.
SourceList
=
strings
.
Split
(
activity
.
Source
,
","
)
sourceStr
:=
gconv
.
String
(
source
)
// fmt.Println(sourceStr)
// fmt.Println(activity.SourceList)
//如果存在于有活动价的品牌,就是有折扣活动了
return
php2go
.
InArray
(
sourceStr
,
activity
.
SourceList
)
}
service/service_ly.go
View file @
766455de
...
...
@@ -79,7 +79,8 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
}
sku
=
ls
.
GetGoodsImages
(
sku
,
spu
)
sku
=
ls
.
GetPdf
(
sku
,
spu
)
//用spuInfo补全信息
sku
=
ls
.
CombineSup
(
sku
,
spu
)
// 2023.11.20 DGK商品的包装若为“Tape & Reel (TR)”,则递增量=起订量
if
sku
.
SupplierId
==
7
&&
sku
.
Packing
==
"Tape & Reel (TR)"
{
sku
.
Multiple
=
sku
.
Moq
...
...
@@ -270,8 +271,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
//获取关税以及价格转换
sku
=
ls
.
GetTariffAndPrice
(
sku
)
//用spuInfo补全信息
sku
=
ls
.
CombineSup
(
sku
,
spu
)
//最后一步,将sku的全部信息放到有序map里面
GoodsRes
.
Store
(
goodsId
,
sku
)
//(*goodsRes)[goodsId] = A
...
...
@@ -292,6 +291,7 @@ func (ls *LyService) GetActivity(sku model.LySku) model.LySku {
GoodsName
:
sku
.
GoodsName
,
ClassId
:
sku
.
ClassID2
,
OrgId
:
sku
.
OrgId
,
Source
:
sku
.
Source
,
}
var
activityService
ActivityService
priceActivity
,
giftActivity
:=
activityService
.
GetActivityData
(
checkData
)
...
...
service/service_price.go
View file @
766455de
...
...
@@ -60,7 +60,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
//拿出里面的所有排序
priceRatioSortMap
:=
gjson
.
Get
(
priceRatioCache
,
ratioDataKey
)
.
Map
()
var
sortNumbers
[]
int
for
sortNumberString
,
_
:=
range
priceRatioSortMap
{
for
sortNumberString
:=
range
priceRatioSortMap
{
sortNumber
,
_
:=
strconv
.
Atoi
(
sortNumberString
)
sortNumbers
=
append
(
sortNumbers
,
sortNumber
)
}
...
...
@@ -109,6 +109,19 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
}
}
//判断是否有符合的分类ID
classIds
:=
gjson
.
Get
(
priceRatioCache
,
"class_ids."
+
sortString
)
.
String
()
if
classIds
!=
""
{
hasSpecialCheck
=
true
classIdList
:=
strings
.
Split
(
classIds
,
","
)
classId
:=
strconv
.
Itoa
(
sku
.
ClassID2
)
//找到有对应的分类ID,那么优先级肯定是最高的了
if
php2go
.
InArray
(
classId
,
classIdList
)
{
foundRatio
=
true
break
}
}
//判断是否有符合的eccn
eccns
:=
gjson
.
Get
(
priceRatioCache
,
"eccn."
+
sortString
)
.
String
()
if
eccns
!=
""
{
...
...
@@ -534,7 +547,7 @@ func (ps PriceService) GetPriceRatio(sku model.LySku) (model.LySku, []model.Pric
//拿出里面的所有排序
priceRatioSortMap
:=
gjson
.
Get
(
priceRatioCache
,
"ladder_price"
)
.
Map
()
var
sortNumbers
[]
int
for
sortNumberString
,
_
:=
range
priceRatioSortMap
{
for
sortNumberString
:=
range
priceRatioSortMap
{
sortNumber
,
_
:=
strconv
.
Atoi
(
sortNumberString
)
sortNumbers
=
append
(
sortNumbers
,
sortNumber
)
}
...
...
@@ -581,6 +594,19 @@ func (ps PriceService) GetPriceRatio(sku model.LySku) (model.LySku, []model.Pric
}
}
//判断是否有符合的分类ID
classIds
:=
gjson
.
Get
(
priceRatioCache
,
"class_ids."
+
sortString
)
.
String
()
if
classIds
!=
""
{
hasSpecialCheck
=
true
classIdList
:=
strings
.
Split
(
classIds
,
","
)
classId
:=
strconv
.
Itoa
(
sku
.
ClassID2
)
//找到有对应的分类ID,那么优先级肯定是最高的了
if
php2go
.
InArray
(
classId
,
classIdList
)
{
foundRatio
=
true
break
}
}
//判断是否有符合的eccn
eccns
:=
gjson
.
Get
(
priceRatioCache
,
"eccn."
+
sortString
)
.
String
()
if
eccns
!=
""
{
...
...
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