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
5003b2fe
authored
Jan 12, 2021
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'ysx-价格体系修改-20210106' into dev
parents
07aab597
76b494a9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
135 additions
and
54 deletions
model/activity.go
model/ly_sku.go
service/service_activity.go
service/service_ly.go
service/service_price.go
service/service_zy.go
service/service_zy_common.go
model/activity.go
View file @
5003b2fe
...
...
@@ -35,6 +35,7 @@ type Activity struct {
AdminName
string
`json:"admin_name"`
ActivityId
int
`json:"activity_id"`
ItemList
[]
ActivityItem
`json:"item_list"`
EntireSupplierActivity
bool
`json:"entire_supplier_activity"`
}
type
ActivityItem
struct
{
...
...
model/ly_sku.go
View file @
5003b2fe
...
...
@@ -32,7 +32,6 @@ type LySku struct {
SupplierName
string
`json:"supplier_name"`
Attrs
interface
{}
`json:"attrs"`
ScmBrand
interface
{}
`json:"scm_brand"`
AcType
int
`json:"ac_type"`
AllowCoupon
int
`json:"allow_coupon"`
BrandId
int64
`json:"brand_id"`
//系数相关
...
...
@@ -61,23 +60,32 @@ type LySku struct {
Ratio
float64
`json:"ratio,omitempty"`
SpuDetail
string
`json:"spu_detail,omitempty"`
AcType
int
`json:"ac_type"`
//活动信息
HasGiftActivity
int
`json:"has_gift_activity"`
GiftActivity
GiftActivity
`json:"gift_activity"`
ActivityInfo
PriceActivity
`json:"activity_info"`
}
type
PriceActivity
struct
{
HasActivity
bool
`json:"-"`
ActivityId
int
`json:"activity_id,omitempty"`
ActivityCommon
Ratio
float64
`json:"ratio"`
}
type
GiftActivity
struct
{
HasActivity
bool
`json:"-"`
ActivityId
int
`json:"activity_id,omitempty"`
ActivityCommon
ItemList
[]
ActivityItem
`json:"items,omitempty"`
}
type
ActivityCommon
struct
{
HasActivity
bool
`json:"-"`
ActivityId
int
`json:"activity_id,omitempty"`
ActivityName
string
`json:"activity_name,omitempty"`
AllowCoupon
int
`json:"-"`
SignText
string
`json:"sign_text"`
Sign
string
`json:"sign"`
ShowName
string
`json:"show_name"`
}
//为什么不直接映射到结构,而要用gjson,因为redis存的数据结构不一定正常,可能类型不一致
func
InitSkuData
(
sku
string
)
(
data
LySku
)
{
...
...
service/service_activity.go
View file @
5003b2fe
...
...
@@ -9,6 +9,7 @@ import (
"go_sku_server/model"
"go_sku_server/pkg/gredis"
"strings"
"time"
)
type
ActivityService
struct
{
...
...
@@ -49,72 +50,142 @@ func (as *ActivityService) GetActivityData(checkData model.ActivityCheckData) (p
//获取满赠活动信息
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
.
StartTime
>
nowTimestamp
||
activity
.
EndTime
<
nowTimestamp
{
return
}
//如果是整个供应商搞活动,则直接返回系数
if
activity
.
EntireSupplierActivity
{
hasActivity
=
true
goto
INFO
}
//判断是否是排除的sku或者品牌,如果是的话,直接返回没活动
if
as
.
CheckExcludeSku
(
checkData
.
GoodsId
,
activity
)
||
as
.
CheckExcludeBrand
(
checkData
.
BrandId
,
activity
)
{
hasActivity
=
false
goto
INFO
}
//判断是否是搞活动的品牌
if
as
.
CheckBrand
(
checkData
.
BrandId
,
activity
)
{
hasActivity
=
true
giftActivity
.
ItemList
=
activity
.
ItemList
giftActivity
.
ActivityId
=
activity
.
ActivityId
goto
INFO
}
//如果是专卖,则要去判断canal,如果是自营,则去判断分类
if
checkData
.
SupplierId
==
17
{
if
as
.
CheckCanal
(
checkData
.
Canal
,
activity
)
{
hasActivity
=
true
giftActivity
.
ItemList
=
activity
.
ItemList
giftActivity
.
ActivityId
=
activity
.
ActivityId
goto
INFO
}
}
else
{
if
as
.
CheckClass
(
checkData
.
ClassId
,
activity
)
{
hasActivity
=
true
giftActivity
.
ItemList
=
activity
.
ItemList
goto
INFO
}
}
INFO
:
if
hasActivity
{
giftActivity
.
ActivityName
=
activity
.
ActivityName
giftActivity
.
ActivityId
=
activity
.
ActivityId
giftActivity
=
model
.
GiftActivity
{
ItemList
:
activity
.
ItemList
,
ActivityCommon
:
model
.
ActivityCommon
{
HasActivity
:
hasActivity
,
ActivityId
:
activity
.
ActivityId
,
ActivityName
:
activity
.
ActivityName
,
AllowCoupon
:
activity
.
AllowCoupon
,
SignText
:
activity
.
SignText
,
Sign
:
activity
.
Sign
,
ShowName
:
activity
.
ShowName
,
},
}
}
}
giftActivity
.
HasActivity
=
hasActivity
return
}
func
(
as
*
ActivityService
)
GetPriceActivity
(
checkData
model
.
ActivityCheckData
,
activities
[]
model
.
Activity
)
(
priceActivity
model
.
PriceActivity
)
{
var
hasActivity
bool
nowTimestamp
:=
int
(
time
.
Now
()
.
Unix
())
for
_
,
activity
:=
range
activities
{
//判断时间是否过期
if
activity
.
StartTime
>
nowTimestamp
||
activity
.
EndTime
<
nowTimestamp
{
return
}
//如果是整个供应商搞活动,则直接返回系数
if
activity
.
EntireSupplierActivity
{
hasActivity
=
true
goto
INFO
}
//判断是否是排除的sku或者品牌,如果是的话,直接返回没活动
if
as
.
CheckExcludeSku
(
checkData
.
GoodsId
,
activity
)
||
as
.
CheckExcludeBrand
(
checkData
.
BrandId
,
activity
)
{
hasActivity
=
false
}
//判断是否是搞活动的品牌
if
as
.
CheckBrand
(
checkData
.
BrandId
,
activity
)
{
hasActivity
=
true
priceActivity
.
Ratio
=
activity
.
Ratio
goto
INFO
}
//如果是专卖,则要去判断canal,如果是自营,则去判断分类
if
checkData
.
SupplierId
==
17
{
if
as
.
CheckCanal
(
checkData
.
Canal
,
activity
)
{
//品牌不为空,还要去判断品牌,是同时满足的关系
if
activity
.
BrandIds
!=
""
{
//判断是否是搞活动的品牌
if
as
.
CheckBrand
(
checkData
.
BrandId
,
activity
)
{
hasActivity
=
true
priceActivity
.
Ratio
=
activity
.
Ratio
goto
INFO
}
}
else
{
hasActivity
=
true
goto
INFO
}
}
}
else
if
checkData
.
SupplierId
==
10000
{
if
as
.
CheckClass
(
checkData
.
ClassId
,
activity
)
{
//品牌不为空,还要去判断品牌,是同时满足的关系
if
activity
.
BrandIds
!=
""
{
//判断是否是搞活动的品牌
if
as
.
CheckBrand
(
checkData
.
BrandId
,
activity
)
{
hasActivity
=
true
goto
INFO
}
}
else
{
hasActivity
=
true
priceActivity
.
Ratio
=
activity
.
Ratio
goto
INFO
}
}
}
else
{
//判断是否是搞活动的品牌
if
as
.
CheckSkuId
(
checkData
.
Goods
Id
,
activity
)
{
if
as
.
CheckBrand
(
checkData
.
Brand
Id
,
activity
)
{
hasActivity
=
true
priceActivity
.
Ratio
=
activity
.
Ratio
goto
INFO
}
}
INFO
:
if
hasActivity
{
priceActivity
.
ActivityName
=
activity
.
ActivityName
priceActivity
.
ActivityId
=
activity
.
ActivityId
priceActivity
=
model
.
PriceActivity
{
Ratio
:
activity
.
Ratio
,
ActivityCommon
:
model
.
ActivityCommon
{
HasActivity
:
hasActivity
,
ActivityId
:
activity
.
ActivityId
,
ActivityName
:
activity
.
ActivityName
,
AllowCoupon
:
activity
.
AllowCoupon
,
SignText
:
activity
.
SignText
,
Sign
:
activity
.
Sign
,
ShowName
:
activity
.
ShowName
,
},
}
}
}
priceActivity
.
HasActivity
=
hasActivity
return
}
...
...
@@ -191,18 +262,3 @@ func (as *ActivityService) CheckCanal(canal string, activity model.Activity) boo
}
return
false
}
//检查是否属于活动sku_id
func
(
as
*
ActivityService
)
CheckSkuId
(
skuId
string
,
activity
model
.
Activity
)
bool
{
if
skuId
==
""
{
return
false
}
//先去判断品牌
activity
.
SkuIdList
=
strings
.
Split
(
activity
.
SkuIds
,
","
)
skuIdStr
:=
gconv
.
String
(
skuId
)
//如果存在于有活动价的品牌,就是有折扣活动了
if
php2go
.
InArray
(
skuIdStr
,
activity
.
SkuIdList
)
{
return
true
}
return
false
}
service/service_ly.go
View file @
5003b2fe
...
...
@@ -118,23 +118,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku
.
AllowCoupon
=
1
sku
.
BrandId
=
brandId
//去判断是否有活动(促销打折活动和满赠活动)
checkData
:=
model
.
ActivityCheckData
{
SupplierId
:
int
(
sku
.
SupplierId
),
BrandId
:
int
(
sku
.
BrandId
),
GoodsId
:
sku
.
GoodsId
,
Canal
:
sku
.
Canal
,
ClassId
:
sku
.
ClassID2
,
}
var
activityService
ActivityService
priceActivity
,
giftActivity
:=
activityService
.
GetActivityData
(
checkData
)
if
priceActivity
.
HasActivity
{
sku
.
AcType
=
9
}
if
giftActivity
.
HasActivity
{
sku
.
HasGiftActivity
=
gconv
.
Int
(
giftActivity
.
HasActivity
)
sku
.
GiftActivity
=
giftActivity
}
sku
=
ls
.
GetActivity
(
sku
)
//处理阶梯价数据
if
len
(
sku
.
LadderPrice
)
>
0
{
...
...
@@ -188,3 +172,32 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
}
ch
<-
GoodsRes
}
//获取活动
func
(
ls
*
LyService
)
GetActivity
(
sku
model
.
LySku
)
model
.
LySku
{
//去判断是否有活动(促销打折活动和满赠活动)
checkData
:=
model
.
ActivityCheckData
{
SupplierId
:
int
(
sku
.
SupplierId
),
BrandId
:
int
(
sku
.
BrandId
),
GoodsId
:
sku
.
GoodsId
,
Canal
:
sku
.
Canal
,
ClassId
:
sku
.
ClassID2
,
}
var
activityService
ActivityService
priceActivity
,
giftActivity
:=
activityService
.
GetActivityData
(
checkData
)
if
priceActivity
.
HasActivity
{
sku
.
AcType
=
10
sku
.
Ratio
=
priceActivity
.
Ratio
sku
.
ActivityInfo
=
priceActivity
}
if
giftActivity
.
HasActivity
{
sku
.
HasGiftActivity
=
gconv
.
Int
(
giftActivity
.
HasActivity
)
sku
.
GiftActivity
=
giftActivity
}
//获取是否能使用优惠券
if
giftActivity
.
AllowCoupon
!=
1
||
priceActivity
.
AllowCoupon
!=
1
{
sku
.
AllowCoupon
=
0
}
return
sku
}
service/service_price.go
View file @
5003b2fe
...
...
@@ -11,6 +11,9 @@ import (
"time"
)
type
PriceService
struct
{
}
//获取联营活动价
func
(
ls
*
LyService
)
GetActivityPrice
(
sku
model
.
LySku
,
suffix
string
,
power
Power
)
model
.
LySku
{
//没价格,直接返回
...
...
service/service_zy.go
View file @
5003b2fe
This diff is collapsed.
Click to expand it.
service/service_zy_common.go
View file @
5003b2fe
This diff is collapsed.
Click to expand it.
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