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
77e2a838
authored
Mar 15, 2023
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修复价格获取的问题
parent
9d0b9c9e
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
101 additions
and
73 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 @
77e2a838
...
...
@@ -45,6 +45,7 @@ require (
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/yaml.v2 v2.4.0 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
github.com/shopspring/decimal v1.0.1
)
...
...
model/activity.go
View file @
77e2a838
package
model
type
Activity
struct
{
Id
int64
`json:"id"`
SupplierIds
string
`json:"supplier_ids"`
SupplierIdList
[]
string
SupplierType
int
`json:"supplier_type"`
UserScope
int
`json:"user_scope"`
CanAdminOrder
interface
{}
`json:"can_admin_order"`
SignText
string
`json:"sign_text"`
BrandIds
string
`json:"brand_ids"`
BrandIdList
[]
string
ClassIds
string
`json:"class_ids"`
ClassIdList
[]
string
Canals
string
`json:"canals"`
CanalList
[]
string
Ratio
float64
`json:"ratio"`
RatioUs
float64
`json:"ratio_us"`
StartTime
int
`json:"start_time"`
EndTime
int
`json:"end_time"`
AddTime
int
`json:"add_time"`
UpdateTime
int
`json:"update_time"`
Status
int
`json:"status"`
AllowCoupon
int
`json:"allow_coupon"`
ActivityName
string
`json:"activity_name"`
ShowName
string
`json:"show_name"`
Sign
string
`json:"sign"`
ActivityType
int
`json:"activity_type"`
GoodsScope
int
`json:"goods_scope"`
ExcludeBrandIds
string
`json:"exclude_brand_ids"`
ExcludeBrandIdList
[]
string
ExcludeSkuIds
string
`json:"exclude_sku_ids"`
ExcludeSkuIdList
[]
string
SkuIds
string
`json:"sku_ids"`
SkuIdList
[]
string
AdminId
int
`json:"admin_id"`
AdminName
string
`json:"admin_name"`
ActivityId
int
`json:"activity_id"`
ItemList
[]
ActivityItem
`json:"item_list"`
EntireSupplierActivity
bool
`json:"entire_supplier_activity"`
Id
int64
`json:"id"`
SupplierIds
string
`json:"supplier_ids"`
SupplierIdList
[]
string
SupplierType
int
`json:"supplier_type"`
UserScope
int
`json:"user_scope"`
CanAdminOrder
interface
{}
`json:"can_admin_order"`
SignText
string
`json:"sign_text"`
BrandIds
string
`json:"brand_ids"`
BrandIdList
[]
string
ClassIds
string
`json:"class_ids"`
ClassIdList
[]
string
Canals
string
`json:"canals"`
CanalList
[]
string
Ratio
float64
`json:"ratio"`
RatioUs
float64
`json:"ratio_us"`
StartTime
int
`json:"start_time"`
EndTime
int
`json:"end_time"`
AddTime
int
`json:"add_time"`
UpdateTime
int
`json:"update_time"`
Status
int
`json:"status"`
AllowCoupon
int
`json:"allow_coupon"`
ActivityName
string
`json:"activity_name"`
ShowName
string
`json:"show_name"`
Sign
string
`json:"sign"`
ActivityType
int
`json:"activity_type"`
GoodsScope
int
`json:"goods_scope"`
ExcludeBrandIds
string
`json:"exclude_brand_ids"`
ExcludeBrandIdList
[]
string
ExcludeSkuIds
string
`json:"exclude_sku_ids"`
ExcludeSkuIdList
[]
string
SkuIds
string
`json:"sku_ids"`
SkuIdList
[]
string
AdminId
int
`json:"admin_id"`
AdminName
string
`json:"admin_name"`
ActivityId
int
`json:"activity_id"`
ItemList
[]
ActivityItem
`json:"item_list"`
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
{
...
...
@@ -54,9 +58,10 @@ type ActivityItem struct {
//用于检查是否有活动情况的结构体
type
ActivityCheckData
struct
{
SupplierId
int
BrandId
int
GoodsId
string
Canal
string
ClassId
int
SupplierId
int
BrandId
int
StandardBrandId
int
GoodsId
string
Canal
string
ClassId
int
}
service/service_activity.go
View file @
77e2a838
...
...
@@ -21,21 +21,8 @@ func (as *ActivityService) GetActivityData(checkData model.ActivityCheckData) (p
supplierId
:=
checkData
.
SupplierId
redisCon
:=
gredis
.
Conn
(
"default_r"
)
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
!=
""
{
var
activities
[]
model
.
Activity
err
:=
json
.
Unmarshal
([]
byte
(
activityStr
),
&
activities
)
...
...
@@ -135,7 +122,7 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
}
//判断是否是排除的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
}
...
...
@@ -145,7 +132,7 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
//品牌不为空,还要去判断品牌,是同时满足的关系
if
activity
.
BrandIds
!=
""
{
//判断是否是搞活动的品牌
if
as
.
Check
Brand
(
checkData
.
BrandId
,
activity
)
{
if
as
.
Check
StandardBrand
(
checkData
.
Standard
BrandId
,
activity
)
{
hasActivity
=
true
goto
INFO
}
...
...
@@ -165,7 +152,7 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
//品牌不为空,还要去判断品牌,是同时满足的关系
if
activity
.
BrandIds
!=
""
{
//判断是否是搞活动的品牌
if
as
.
Check
Brand
(
checkData
.
BrandId
,
activity
)
{
if
as
.
Check
StandardBrand
(
checkData
.
Standard
BrandId
,
activity
)
{
hasActivity
=
true
goto
INFO
}
...
...
@@ -175,8 +162,9 @@ func (as *ActivityService) GetPriceActivity(checkData model.ActivityCheckData, a
}
}
}
else
{
fmt
.
Println
(
activity
)
//判断是否是搞活动的品牌
if
as
.
Check
Brand
(
checkData
.
BrandId
,
activity
)
{
if
as
.
Check
StandardBrand
(
checkData
.
Standard
BrandId
,
activity
)
{
hasActivity
=
true
goto
INFO
}
...
...
@@ -226,6 +214,21 @@ func (as *ActivityService) CheckExcludeBrand(brandId int, activity model.Activit
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
func
(
as
*
ActivityService
)
CheckExcludeSku
(
skuId
string
,
activity
model
.
Activity
)
bool
{
if
skuId
==
""
{
...
...
@@ -270,6 +273,21 @@ func (as *ActivityService) CheckBrand(brandId int, activity model.Activity) bool
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
{
if
canal
==
""
{
...
...
service/service_ly.go
View file @
77e2a838
...
...
@@ -205,11 +205,12 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
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
,
SupplierId
:
int
(
sku
.
SupplierId
),
BrandId
:
int
(
sku
.
BrandId
),
StandardBrandId
:
int
(
sku
.
StandardBrand
.
StandardBrandId
),
GoodsId
:
sku
.
GoodsId
,
Canal
:
sku
.
Canal
,
ClassId
:
sku
.
ClassID2
,
}
var
activityService
ActivityService
priceActivity
,
giftActivity
:=
activityService
.
GetActivityData
(
checkData
)
...
...
service/service_ly_common.go
View file @
77e2a838
...
...
@@ -278,10 +278,11 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
}
cnDiscountRatio
+=
1
usDiscountRatio
+=
1
cnDiscountRatio
=
common
.
MyRound
(
cnDiscountRatio
+
1
,
3
)
usDiscountRatio
=
common
.
MyRound
(
usDiscountRatio
+
1
,
3
)
sku
.
DiscountRatio
.
Ratio
=
cnDiscountRatio
sku
.
DiscountRatio
.
RatioUsd
=
usDiscountRatio
fmt
.
Println
(
"折扣系数 : "
,
cnDiscountRatio
,
usDiscountRatio
)
//再去找售价组系数
//找一个标志位,因为默认的全局折扣系数的数据格式和非全局的是不一样的
...
...
@@ -362,6 +363,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
sku
.
PriceRatio
=
priceRatioList
sku
.
PriceRatioSort
=
priceRatioSort
fmt
.
Println
(
"售价组系数 : "
,
priceRatioList
)
//这里是供应商系数,先保留这块逻辑
ratio
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"pool_supplier_ratio"
,
sku
.
SupplierId
))
...
...
@@ -414,6 +416,8 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
coefficient
=
defaultCoefficient
}
fmt
.
Println
(
"供应商系数 : "
,
coefficient
)
//下面是计算价格
//价格计算文档 https://docs.qq.com/doc/DR3RJcnNPeUNkWHRk
// 为何是固定的1.13,关税基本不会变,有变的话跟产品沟通手动修改即可
...
...
@@ -448,7 +452,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
//处理人民币
data
[
key
]
.
PriceCn
=
common
.
MyRound
(
priceCn
,
4
)
data
[
key
]
.
PriceCostCn
=
common
.
MyRound
(
priceCostCn
,
4
)
fmt
.
Println
(
data
[
key
])
//处理mouser的成本价
//mouser成本价是什么,斌哥同步过来的成本价
//sku.LadderPrice[key].CostPrice是专门针对贸泽(mouser)的
...
...
@@ -461,7 +464,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
continue
}
//处理活动价和原价相同的情况
if
(
sku
.
GoodsType
==
1
||
sku
.
GoodsType
==
2
)
&&
sku
.
AcType
>
1
&&
sku
.
Ratio
>
0
{
priceAc
:=
common
.
MyRound
(
data
[
key
]
.
PriceCn
*
(
sku
.
Ratio
/
100
),
4
)
...
...
service/service_zy_common.go
View file @
77e2a838
...
...
@@ -51,10 +51,11 @@ func (qs *ZiyingService) ActivityPrice(ctx *gin.Context, SkuInfo string) *ordere
func
(
qs
*
ZiyingService
)
GetActivity
(
skuInfo
string
)
(
priceActivity
model
.
PriceActivity
,
giftActivity
model
.
GiftActivity
)
{
//去判断是否有活动(促销打折活动和满赠活动)
checkData
:=
model
.
ActivityCheckData
{
SupplierId
:
10000
,
BrandId
:
int
(
gjson
.
Get
(
skuInfo
,
"brand_id"
)
.
Int
()),
GoodsId
:
gjson
.
Get
(
skuInfo
,
"goods_id"
)
.
String
(),
ClassId
:
int
(
gjson
.
Get
(
skuInfo
,
"class_id2"
)
.
Int
()),
SupplierId
:
10000
,
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
(),
ClassId
:
int
(
gjson
.
Get
(
skuInfo
,
"class_id2"
)
.
Int
()),
}
var
activityService
ActivityService
priceActivity
,
giftActivity
=
activityService
.
GetActivityData
(
checkData
)
...
...
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