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
8e8a68f6
authored
Aug 23, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'ysx-商品活动价逻辑修改-20230823' into dev
parents
91d78a1e
77976452
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
23 deletions
model/activity.go
service/service_activity.go
service/service_ly.go
service/service_ly_common.go
service/service_price.go
service/service_zy_common.go
model/activity.go
View file @
8e8a68f6
...
...
@@ -44,6 +44,7 @@ type Activity struct {
ExcludeStandardBrandIdList
[]
string
CurrencyRmb
int
`json:"currency_rmb"`
CurrencyUs
int
`json:"currency_us"`
UseType
int
`json:"use_type"`
}
type
ActivityItem
struct
{
...
...
@@ -58,9 +59,10 @@ type ActivityItem struct {
AddTime
int
`json:"add_time"`
}
//用于检查是否有活动情况的结构体
//
用于检查是否有活动情况的结构体
type
ActivityCheckData
struct
{
SupplierId
int
GoodsName
string
BrandId
int
StandardBrandId
int
GoodsId
string
...
...
service/service_activity.go
View file @
8e8a68f6
This diff is collapsed.
Click to expand it.
service/service_ly.go
View file @
8e8a68f6
...
...
@@ -58,7 +58,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
sku
.
GoodsId
=
goodsId
spu
:=
spuList
[
sku
.
SpuId
]
//读取包装字段的缓存
if
sku
.
SupplierId
==
7
||
sku
.
SupplierId
==
13
{
if
sku
.
SupplierId
==
7
||
sku
.
SupplierId
==
13
||
sku
.
SupplierId
==
1688
{
//sku_raw_map哪里写入(成意写的)
packing
,
_
:=
redis
.
String
(
redisConnSpu
.
Do
(
"HGET"
,
"sku_raw_map"
,
goodsId
))
sku
.
Packing
=
gjson
.
Get
(
packing
,
"pack"
)
.
String
()
...
...
@@ -211,6 +211,7 @@ func (ls *LyService) GetActivity(sku model.LySku) model.LySku {
GoodsId
:
sku
.
GoodsId
,
Canal
:
sku
.
Canal
,
ClassId
:
sku
.
ClassID2
,
GoodsName
:
sku
.
GoodsName
,
}
var
activityService
ActivityService
priceActivity
,
giftActivity
:=
activityService
.
GetActivityData
(
checkData
)
...
...
service/service_ly_common.go
View file @
8e8a68f6
...
...
@@ -2,7 +2,6 @@ package service
import
(
"encoding/json"
"fmt"
"github.com/gomodule/redigo/redis"
_
"github.com/iancoleman/orderedmap"
"github.com/syyongx/php2go"
...
...
@@ -277,7 +276,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
if
ladderPrice
[
0
]
.
PriceCostUs
==
0
&&
ladderPrice
[
0
]
.
PriceCostCn
==
0
{
sku
=
priceService
.
GenerateLadderPrice
(
sku
)
ladderPrice
=
sku
.
LadderPrice
fmt
.
Println
(
ladderPrice
)
//
fmt.Println(ladderPrice)
}
}
//获取折扣系数
...
...
@@ -433,7 +432,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
priceCostUs
:=
c
.
MulFloat
(
price
.
PriceUs
,
sku
.
DiscountRatio
.
RatioUsd
)
priceCostUs
=
c
.
MyRound
(
priceCostUs
,
4
)
//美金售价
fmt
.
Println
(
"计算美金价的系数"
,
priceRatio
.
RatioUsd
)
//
fmt.Println("计算美金价的系数", priceRatio.RatioUsd)
priceUs
:=
c
.
MulFloat
(
priceCostUs
,
priceRatio
.
RatioUsd
)
//人民币成本价,mro只有人民币,所以人民币价格不是从美金来的,而且人民币是含税的.就它要特殊处理
var
priceCostCn
float64
...
...
@@ -503,7 +502,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
sku
.
LadderPrice
=
data
}
fmt
.
Println
(
sku
.
PriceRatio
,
sku
.
PriceRatioSort
)
//
fmt.Println(sku.PriceRatio, sku.PriceRatioSort)
return
sku
}
service/service_price.go
View file @
8e8a68f6
...
...
@@ -94,6 +94,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
if
brandIds
!=
""
{
hasSpecialCheck
=
true
standardBrandIdList
:=
strings
.
Split
(
brandIds
,
","
)
fmt
.
Println
(
standardBrandIdList
)
standardBrandId
:=
strconv
.
Itoa
(
sku
.
StandardBrand
.
StandardBrandId
)
//找到有对应的品牌,那么优先级肯定是最高的了
if
php2go
.
InArray
(
standardBrandId
,
standardBrandIdList
)
{
...
...
@@ -156,7 +157,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
}
//找不到特定的系数,那就去找全局的
if
!
foundRatio
{
fmt
.
Println
(
"去找默认系数"
)
//
fmt.Println("去找默认系数")
priceRatioCache
,
_
=
redis
.
String
(
redisCon
.
Do
(
"GET"
,
"magic_cube_price_rule_v2_default"
))
priceRatioArr
:=
gjson
.
Get
(
priceRatioCache
,
ratioDataKey
)
.
Array
()
priceRatioList
=
nil
...
...
@@ -174,16 +175,16 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
//这是用来展示在商品服务的价格系数,专营的系数和代购的不一样,所以要转换一下展示形式
//是否有设置最低利润点阶梯,不足5个阶梯时,最高阶梯对应的最小利润点阶梯
var
ladderPriceMiniProfitLevel
int
fmt
.
Println
(
"是否找到系数"
,
foundRatio
)
//
fmt.Println("是否找到系数", foundRatio)
//fmt.Println("系数redis数据为 : ", priceRatioCache)
fmt
.
Println
(
"具体系数为 : "
,
priceRatioList
)
//
fmt.Println("具体系数为 : ", priceRatioList)
if
foundRatio
{
priceRatioSortStr
:=
strconv
.
Itoa
(
priceRatioSort
)
ladderPriceMiniProfitLevel
=
int
(
gjson
.
Get
(
priceRatioCache
,
"ladder_price_mini_profit_level."
+
priceRatioSortStr
)
.
Int
())
}
else
{
ladderPriceMiniProfitLevel
=
int
(
gjson
.
Get
(
priceRatioCache
,
"ladder_price_mini_profit_level"
)
.
Int
())
}
fmt
.
Println
(
"最低利润点阶梯数 : "
,
ladderPriceMiniProfitLevel
)
//
fmt.Println("最低利润点阶梯数 : ", ladderPriceMiniProfitLevel)
var
generatedLadderPrice
[]
model
.
LadderPrice
//先直接获取成本价原始值,判断第一个阶梯的阶梯数量是否为0,如果是0,那么代表是要走成本价生成,如果不是0,那么就要走阶梯价生成
firstLadderPurchases
:=
sku
.
LadderPrice
[
0
]
.
Purchases
...
...
@@ -191,7 +192,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
//判断是否走成本价判断还是走阶梯价判断,因为上传sku的时候,可以设置每个sku的成本价(人民币&&美金),也可以设置每个sku的阶梯价
//如果有阶梯价,就要跳过设置的成本价(假设有设置的话)
if
isCostPrice
{
fmt
.
Println
(
"成本价"
)
//
fmt.Println("成本价")
costPriceCn
:=
sku
.
LadderPrice
[
0
]
.
PriceCn
costPriceUs
:=
sku
.
LadderPrice
[
0
]
.
PriceUs
//fmt.Println("人民币和美金的成本价分别为 : ", costPriceCn, costPriceUs)
...
...
@@ -279,8 +280,8 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
}
costLadderCount
++
}
fmt
.
Println
(
"阶梯数量为 : "
,
costLadderCount
)
fmt
.
Println
(
"设置的利润阶梯为 : "
,
ladderPriceMiniProfitLevel
)
//
fmt.Println("阶梯数量为 : ", costLadderCount)
//
fmt.Println("设置的利润阶梯为 : ", ladderPriceMiniProfitLevel)
if
costLadderCount
<=
ladderPriceMiniProfitLevel
{
for
i
:=
0
;
i
<
costLadderCount
;
i
++
{
priceRatioAndPurchases
:=
priceRatioList
[
i
]
...
...
@@ -296,7 +297,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
//如:库存满足1、2、3层阶梯,最小利润点层级是第5个层级,则利润点取3、4、5层级的
//最小利润点层级 - 库存满足多少个阶梯 + i
costMapIndex
:=
ladderPriceMiniProfitLevel
-
costLadderCount
+
i
fmt
.
Println
(
costMapIndex
)
//
fmt.Println(costMapIndex)
if
costMapIndex
<=
0
{
costMapIndex
=
0
}
...
...
@@ -363,7 +364,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
priceCnRatio
:=
priceRatio
.
Ratio
priceUsRatio
:=
priceRatio
.
RatioUsd
// 阶梯价格系数正序取
fmt
.
Println
(
"价格:"
,
c
.
MulFloat
(
ladder
.
PriceCn
,
priceCnRatio
))
//
fmt.Println("价格:",c.MulFloat(ladder.PriceCn, priceCnRatio))
generatedLadderPrice
=
append
(
generatedLadderPrice
,
model
.
LadderPrice
{
Purchases
:
ladder
.
Purchases
,
PriceCn
:
c
.
MyRound
(
c
.
MulFloat
(
ladder
.
PriceCn
,
priceCnRatio
),
5
),
...
...
@@ -653,13 +654,13 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku, priceUs f
}
else
{
currency
,
_
=
redis
.
Int
(
redisCon
.
Do
(
"HGET"
,
"magic_cube_supplier_currency"
,
sku
.
Canal
))
}
fmt
.
Println
(
"进来的美金价格:"
,
priceUs
)
//
fmt.Println("进来的美金价格:", priceUs)
if
currency
>
0
{
//这里进行转换,因为这里都只能取到对应的币种转人民币的比率,我们没有直接各种币种转美金的数据,所以我这边要
//先根据对应币种转人民币,然后根据人民币转美金,才能得到不同币种对应美金的汇率
rmbRatio
,
_
:=
redis
.
Float64
(
redisCon
.
Do
(
"HGET"
,
"erp_rate"
,
currency
))
fmt
.
Println
(
"特殊转换"
,
rmbRatio
)
fmt
.
Println
(
rmbRatio
,
usRatio
)
//
fmt.Println("特殊转换", rmbRatio)
//
fmt.Println(rmbRatio, usRatio)
//人民币汇率转美金汇率
usRatio
=
c
.
MyRound
(
c
.
DivFloat
(
rmbRatio
,
usRatio
),
6
)
...
...
service/service_zy_common.go
View file @
8e8a68f6
...
...
@@ -38,7 +38,7 @@ func (qs *ZiyingService) skuLockNum(c *redis.Conn, goodsId string) int64 {
}
/*
获取自营活动价
获取自营活动价
*/
func
(
qs
*
ZiyingService
)
ActivityPrice
(
ctx
*
gin
.
Context
,
SkuInfo
string
)
*
orderedmap
.
OrderedMap
{
data
:=
qs
.
HDActivityPrice
(
SkuInfo
)
...
...
@@ -48,7 +48,7 @@ func (qs *ZiyingService) ActivityPrice(ctx *gin.Context, SkuInfo string) *ordere
return
nil
}
//获取活动相关信息
//
获取活动相关信息
func
(
qs
*
ZiyingService
)
GetActivity
(
skuInfo
string
)
(
priceActivity
model
.
PriceActivity
,
giftActivity
model
.
GiftActivity
)
{
//去判断是否有活动(促销打折活动和满赠活动)
var
standardBrandId
int
...
...
@@ -72,6 +72,7 @@ func (qs *ZiyingService) GetActivity(skuInfo string) (priceActivity model.PriceA
StandardBrandId
:
standardBrandId
,
GoodsId
:
gjson
.
Get
(
skuInfo
,
"goods_id"
)
.
String
(),
ClassId
:
int
(
gjson
.
Get
(
skuInfo
,
"class_id2"
)
.
Int
()),
GoodsName
:
gjson
.
Get
(
skuInfo
,
"goods_name"
)
.
String
(),
}
var
activityService
ActivityService
priceActivity
,
giftActivity
=
activityService
.
GetActivityData
(
checkData
)
...
...
@@ -79,13 +80,12 @@ func (qs *ZiyingService) GetActivity(skuInfo string) (priceActivity model.PriceA
}
/*
计算活动价
计算活动价
ac_type说明: 0 没有活动
活动名称 ac_type 类型
自营系数 6 自营
折扣(系数)活动 10 自营/联营
*/
func
(
qs
*
ZiyingService
)
HDActivityPrice
(
SkuInfo
string
)
*
orderedmap
.
OrderedMap
{
priceActivity
,
giftActivity
:=
qs
.
GetActivity
(
SkuInfo
)
...
...
@@ -132,7 +132,7 @@ func (qs *ZiyingService) HDActivityPrice(SkuInfo string) *orderedmap.OrderedMap
}
/*
获取当前锁住的库存
获取当前锁住的库存
*/
func
(
qs
*
ZiyingService
)
HDGoodsLimit
(
SkuID
string
,
Stock
string
,
c
*
redis
.
Conn
)
*
orderedmap
.
OrderedMap
{
...
...
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