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
66a33cc1
authored
a year ago
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'ysx-魔方改版-20230313' into dev
parents
ee969df6
77e2a838
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
22 deletions
go.mod
model/activity.go
service/service_activity.go
service/service_ly.go
service/service_ly_common.go
service/service_zy_common.go
go.mod
View file @
66a33cc1
...
@@ -45,6 +45,7 @@ require (
...
@@ -45,6 +45,7 @@ require (
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
github.com/shopspring/decimal v1.0.1
)
)
...
...
This diff is collapsed.
Click to expand it.
model/activity.go
View file @
66a33cc1
...
@@ -38,6 +38,10 @@ type Activity struct {
...
@@ -38,6 +38,10 @@ type Activity struct {
ActivityId
int
`json:"activity_id"`
ActivityId
int
`json:"activity_id"`
ItemList
[]
ActivityItem
`json:"item_list"`
ItemList
[]
ActivityItem
`json:"item_list"`
EntireSupplierActivity
bool
`json:"entire_supplier_activity"`
EntireSupplierActivity
bool
`json:"entire_supplier_activity"`
StandardBrandIds
string
`json:"standard_brand_ids"`
StandardBrandIdList
[]
string
ExcludeStandardBrandIds
string
`json:"exclude_standard_brand_ids"`
ExcludeStandardBrandIdList
[]
string
}
}
type
ActivityItem
struct
{
type
ActivityItem
struct
{
...
@@ -56,6 +60,7 @@ type ActivityItem struct {
...
@@ -56,6 +60,7 @@ type ActivityItem struct {
type
ActivityCheckData
struct
{
type
ActivityCheckData
struct
{
SupplierId
int
SupplierId
int
BrandId
int
BrandId
int
StandardBrandId
int
GoodsId
string
GoodsId
string
Canal
string
Canal
string
ClassId
int
ClassId
int
...
...
This diff is collapsed.
Click to expand it.
service/service_activity.go
View file @
66a33cc1
...
@@ -21,21 +21,8 @@ func (as *ActivityService) GetActivityData(checkData model.ActivityCheckData) (p
...
@@ -21,21 +21,8 @@ func (as *ActivityService) GetActivityData(checkData model.ActivityCheckData) (p
supplierId
:=
checkData
.
SupplierId
supplierId
:=
checkData
.
SupplierId
redisCon
:=
gredis
.
Conn
(
"default_r"
)
redisCon
:=
gredis
.
Conn
(
"default_r"
)
defer
redisCon
.
Close
()
defer
redisCon
.
Close
()
//处理满赠活动
activityStr
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"hget"
,
"lie_gift_activity"
,
supplierId
))
if
activityStr
!=
""
{
var
activities
[]
model
.
Activity
err
:=
json
.
Unmarshal
([]
byte
(
activityStr
),
&
activities
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
if
len
(
activities
)
!=
0
{
giftActivity
=
as
.
GetGiftActivity
(
checkData
,
activities
)
}
}
//处理单品促销活动(打折活动)
//处理单品促销活动(打折活动)
activityStr
,
_
=
redis
.
String
(
redisCon
.
Do
(
"hget"
,
"lie_price_activity"
,
supplierId
))
activityStr
,
_
:
=
redis
.
String
(
redisCon
.
Do
(
"hget"
,
"lie_price_activity"
,
supplierId
))
if
activityStr
!=
""
{
if
activityStr
!=
""
{
var
activities
[]
model
.
Activity
var
activities
[]
model
.
Activity
err
:=
json
.
Unmarshal
([]
byte
(
activityStr
),
&
activities
)
err
:=
json
.
Unmarshal
([]
byte
(
activityStr
),
&
activities
)
...
@@ -135,7 +122,7 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
...
@@ -135,7 +122,7 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
}
}
//判断是否是排除的sku或者品牌,如果是的话,直接返回没活动
//判断是否是排除的sku或者品牌,如果是的话,直接返回没活动
if
as
.
CheckExcludeSku
(
checkData
.
GoodsId
,
activity
)
||
as
.
CheckExclude
Brand
(
checkData
.
BrandId
,
activity
)
{
if
as
.
CheckExcludeSku
(
checkData
.
GoodsId
,
activity
)
||
as
.
CheckExclude
StandardBrand
(
checkData
.
Standard
BrandId
,
activity
)
{
continue
continue
}
}
...
@@ -145,7 +132,7 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
...
@@ -145,7 +132,7 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
//品牌不为空,还要去判断品牌,是同时满足的关系
//品牌不为空,还要去判断品牌,是同时满足的关系
if
activity
.
BrandIds
!=
""
{
if
activity
.
BrandIds
!=
""
{
//判断是否是搞活动的品牌
//判断是否是搞活动的品牌
if
as
.
Check
Brand
(
checkData
.
BrandId
,
activity
)
{
if
as
.
Check
StandardBrand
(
checkData
.
Standard
BrandId
,
activity
)
{
hasActivity
=
true
hasActivity
=
true
goto
INFO
goto
INFO
}
}
...
@@ -165,7 +152,7 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
...
@@ -165,7 +152,7 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
//品牌不为空,还要去判断品牌,是同时满足的关系
//品牌不为空,还要去判断品牌,是同时满足的关系
if
activity
.
BrandIds
!=
""
{
if
activity
.
BrandIds
!=
""
{
//判断是否是搞活动的品牌
//判断是否是搞活动的品牌
if
as
.
Check
Brand
(
checkData
.
BrandId
,
activity
)
{
if
as
.
Check
StandardBrand
(
checkData
.
Standard
BrandId
,
activity
)
{
hasActivity
=
true
hasActivity
=
true
goto
INFO
goto
INFO
}
}
...
@@ -175,8 +162,9 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
...
@@ -175,8 +162,9 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
}
}
}
}
}
else
{
}
else
{
fmt
.
Println
(
activity
)
//判断是否是搞活动的品牌
//判断是否是搞活动的品牌
if
as
.
Check
Brand
(
checkData
.
BrandId
,
activity
)
{
if
as
.
Check
StandardBrand
(
checkData
.
Standard
BrandId
,
activity
)
{
hasActivity
=
true
hasActivity
=
true
goto
INFO
goto
INFO
}
}
...
@@ -226,6 +214,21 @@ func (as *ActivityService) CheckExcludeBrand(brandId int, activity model.Activit
...
@@ -226,6 +214,21 @@ func (as *ActivityService) CheckExcludeBrand(brandId int, activity model.Activit
return
false
return
false
}
}
//检查是否属于被排除的标准品牌
func
(
as
*
ActivityService
)
CheckExcludeStandardBrand
(
standardBrandId
int
,
activity
model
.
Activity
)
bool
{
if
standardBrandId
==
0
{
return
false
}
//先去判断品牌
activity
.
ExcludeStandardBrandIdList
=
strings
.
Split
(
activity
.
ExcludeStandardBrandIds
,
","
)
standardBrandIdStr
:=
gconv
.
String
(
standardBrandId
)
//如果存在于有活动价的品牌,就是有折扣活动了
if
php2go
.
InArray
(
standardBrandIdStr
,
activity
.
ExcludeStandardBrandIdList
)
{
return
true
}
return
false
}
//检查是否属于被排除的sku
//检查是否属于被排除的sku
func
(
as
*
ActivityService
)
CheckExcludeSku
(
skuId
string
,
activity
model
.
Activity
)
bool
{
func
(
as
*
ActivityService
)
CheckExcludeSku
(
skuId
string
,
activity
model
.
Activity
)
bool
{
if
skuId
==
""
{
if
skuId
==
""
{
...
@@ -270,6 +273,21 @@ func (as *ActivityService) CheckBrand(brandId int, activity model.Activity) bool
...
@@ -270,6 +273,21 @@ func (as *ActivityService) CheckBrand(brandId int, activity model.Activity) bool
return
false
return
false
}
}
//检测是否属于活动标准品牌
func
(
as
*
ActivityService
)
CheckStandardBrand
(
standardBrandId
int
,
activity
model
.
Activity
)
bool
{
if
standardBrandId
==
0
{
return
false
}
//先去判断品牌
activity
.
StandardBrandIdList
=
strings
.
Split
(
activity
.
StandardBrandIds
,
","
)
standardBrandIdStr
:=
gconv
.
String
(
standardBrandId
)
//如果存在于有活动价的品牌,就是有折扣活动了
if
php2go
.
InArray
(
standardBrandIdStr
,
activity
.
StandardBrandIdList
)
{
return
true
}
return
false
}
//检查是否属于供应商渠道
//检查是否属于供应商渠道
func
(
as
*
ActivityService
)
CheckCanal
(
canal
string
,
activity
model
.
Activity
)
bool
{
func
(
as
*
ActivityService
)
CheckCanal
(
canal
string
,
activity
model
.
Activity
)
bool
{
if
canal
==
""
{
if
canal
==
""
{
...
...
This diff is collapsed.
Click to expand it.
service/service_ly.go
View file @
66a33cc1
...
@@ -207,6 +207,7 @@ func (ls *LyService) GetActivity(sku model.LySku) model.LySku {
...
@@ -207,6 +207,7 @@ func (ls *LyService) GetActivity(sku model.LySku) model.LySku {
checkData
:=
model
.
ActivityCheckData
{
checkData
:=
model
.
ActivityCheckData
{
SupplierId
:
int
(
sku
.
SupplierId
),
SupplierId
:
int
(
sku
.
SupplierId
),
BrandId
:
int
(
sku
.
BrandId
),
BrandId
:
int
(
sku
.
BrandId
),
StandardBrandId
:
int
(
sku
.
StandardBrand
.
StandardBrandId
),
GoodsId
:
sku
.
GoodsId
,
GoodsId
:
sku
.
GoodsId
,
Canal
:
sku
.
Canal
,
Canal
:
sku
.
Canal
,
ClassId
:
sku
.
ClassID2
,
ClassId
:
sku
.
ClassID2
,
...
...
This diff is collapsed.
Click to expand it.
service/service_ly_common.go
View file @
66a33cc1
...
@@ -278,10 +278,11 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
...
@@ -278,10 +278,11 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
}
}
}
cnDiscountRatio
+=
1
cnDiscountRatio
=
common
.
MyRound
(
cnDiscountRatio
+
1
,
3
)
usDiscountRatio
+=
1
usDiscountRatio
=
common
.
MyRound
(
usDiscountRatio
+
1
,
3
)
sku
.
DiscountRatio
.
Ratio
=
cnDiscountRatio
sku
.
DiscountRatio
.
Ratio
=
cnDiscountRatio
sku
.
DiscountRatio
.
RatioUsd
=
usDiscountRatio
sku
.
DiscountRatio
.
RatioUsd
=
usDiscountRatio
fmt
.
Println
(
"折扣系数 : "
,
cnDiscountRatio
,
usDiscountRatio
)
//再去找售价组系数
//再去找售价组系数
//找一个标志位,因为默认的全局折扣系数的数据格式和非全局的是不一样的
//找一个标志位,因为默认的全局折扣系数的数据格式和非全局的是不一样的
...
@@ -362,6 +363,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
...
@@ -362,6 +363,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
}
sku
.
PriceRatio
=
priceRatioList
sku
.
PriceRatio
=
priceRatioList
sku
.
PriceRatioSort
=
priceRatioSort
sku
.
PriceRatioSort
=
priceRatioSort
fmt
.
Println
(
"售价组系数 : "
,
priceRatioList
)
//这里是供应商系数,先保留这块逻辑
//这里是供应商系数,先保留这块逻辑
ratio
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"pool_supplier_ratio"
,
sku
.
SupplierId
))
ratio
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"pool_supplier_ratio"
,
sku
.
SupplierId
))
...
@@ -414,6 +416,8 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
...
@@ -414,6 +416,8 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
coefficient
=
defaultCoefficient
coefficient
=
defaultCoefficient
}
}
fmt
.
Println
(
"供应商系数 : "
,
coefficient
)
//下面是计算价格
//下面是计算价格
//价格计算文档 https://docs.qq.com/doc/DR3RJcnNPeUNkWHRk
//价格计算文档 https://docs.qq.com/doc/DR3RJcnNPeUNkWHRk
// 为何是固定的1.13,关税基本不会变,有变的话跟产品沟通手动修改即可
// 为何是固定的1.13,关税基本不会变,有变的话跟产品沟通手动修改即可
...
@@ -448,7 +452,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
...
@@ -448,7 +452,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
//处理人民币
//处理人民币
data
[
key
]
.
PriceCn
=
common
.
MyRound
(
priceCn
,
4
)
data
[
key
]
.
PriceCn
=
common
.
MyRound
(
priceCn
,
4
)
data
[
key
]
.
PriceCostCn
=
common
.
MyRound
(
priceCostCn
,
4
)
data
[
key
]
.
PriceCostCn
=
common
.
MyRound
(
priceCostCn
,
4
)
fmt
.
Println
(
data
[
key
])
//处理mouser的成本价
//处理mouser的成本价
//mouser成本价是什么,斌哥同步过来的成本价
//mouser成本价是什么,斌哥同步过来的成本价
//sku.LadderPrice[key].CostPrice是专门针对贸泽(mouser)的
//sku.LadderPrice[key].CostPrice是专门针对贸泽(mouser)的
...
@@ -461,7 +464,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
...
@@ -461,7 +464,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
}
continue
continue
}
}
//处理活动价和原价相同的情况
//处理活动价和原价相同的情况
if
(
sku
.
GoodsType
==
1
||
sku
.
GoodsType
==
2
)
&&
sku
.
AcType
>
1
&&
sku
.
Ratio
>
0
{
if
(
sku
.
GoodsType
==
1
||
sku
.
GoodsType
==
2
)
&&
sku
.
AcType
>
1
&&
sku
.
Ratio
>
0
{
priceAc
:=
common
.
MyRound
(
data
[
key
]
.
PriceCn
*
(
sku
.
Ratio
/
100
),
4
)
priceAc
:=
common
.
MyRound
(
data
[
key
]
.
PriceCn
*
(
sku
.
Ratio
/
100
),
4
)
...
...
This diff is collapsed.
Click to expand it.
service/service_zy_common.go
View file @
66a33cc1
...
@@ -53,6 +53,7 @@ func (qs *ZiyingService) GetActivity(skuInfo string) (priceActivity model.PriceA
...
@@ -53,6 +53,7 @@ func (qs *ZiyingService) GetActivity(skuInfo string) (priceActivity model.PriceA
checkData
:=
model
.
ActivityCheckData
{
checkData
:=
model
.
ActivityCheckData
{
SupplierId
:
10000
,
SupplierId
:
10000
,
BrandId
:
int
(
gjson
.
Get
(
skuInfo
,
"brand_id"
)
.
Int
()),
BrandId
:
int
(
gjson
.
Get
(
skuInfo
,
"brand_id"
)
.
Int
()),
StandardBrandId
:
int
(
gjson
.
Get
(
skuInfo
,
"standard_brand.standard_brand_id"
)
.
Int
()),
GoodsId
:
gjson
.
Get
(
skuInfo
,
"goods_id"
)
.
String
(),
GoodsId
:
gjson
.
Get
(
skuInfo
,
"goods_id"
)
.
String
(),
ClassId
:
int
(
gjson
.
Get
(
skuInfo
,
"class_id2"
)
.
Int
()),
ClassId
:
int
(
gjson
.
Get
(
skuInfo
,
"class_id2"
)
.
Int
()),
}
}
...
...
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