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
658b9332
authored
Jul 21, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'ysx-mrq需求-20230710'
# Conflicts: # go.mod
parents
49d30d83
fd4e83fe
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
28 deletions
go.mod
model/ly_sku.go
service/service_ly.go
service/service_ly_common.go
go.mod
View file @
658b9332
...
...
@@ -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
)
replace google.golang.org/grpc => google.golang.org/grpc v1.26.0
model/ly_sku.go
View file @
658b9332
...
...
@@ -31,6 +31,7 @@ type LySku struct {
Packing
string
`json:"packing"`
GoodsId
string
`json:"goods_id"`
GoodsName
string
`json:"goods_name"`
SkuName
string
`json:"sku_name"`
BrandName
string
`json:"brand_name"`
SupplierName
string
`json:"supplier_name"`
Attrs
interface
{}
`json:"attrs"`
...
...
@@ -153,15 +154,18 @@ func InitSkuData(sku string) (data LySku) {
goodsStatus
:=
gjson
.
Get
(
sku
,
"goods_status"
)
.
Int
()
data
.
GoodsStatus
=
goodsStatus
supplierId
:=
gjson
.
Get
(
sku
,
"supplier_id"
)
.
Int
()
data
.
SupplierId
=
supplierId
goodsName
:=
gjson
.
Get
(
sku
,
"goods_name"
)
.
String
()
data
.
GoodsName
=
goodsName
skuName
:=
gjson
.
Get
(
sku
,
"goods_name"
)
.
String
()
data
.
SkuName
=
skuName
goodsType
:=
gjson
.
Get
(
sku
,
"goods_type"
)
.
Int
()
data
.
GoodsType
=
goodsType
supplierId
:=
gjson
.
Get
(
sku
,
"supplier_id"
)
.
Int
()
data
.
SupplierId
=
supplierId
encoded
:=
gjson
.
Get
(
sku
,
"encoded"
)
.
String
()
data
.
Encoded
=
encoded
...
...
service/service_ly.go
View file @
658b9332
...
...
@@ -28,7 +28,7 @@ type Power struct {
}
/*
联营数据详情
联营数据详情
*/
func
(
ls
*
LyService
)
LyGoodsDetail
(
ctx
*
gin
.
Context
,
goodsIds
[]
string
,
ch
chan
sync
.
Map
)
{
redisConn
:=
gredis
.
Conn
(
"search_r"
)
...
...
@@ -77,6 +77,10 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
}
//获取商品名称
//1688就是mro的sku spuName和GoodsName不是一个东西,不能公用
if
sku
.
GoodsName
!=
""
&&
sku
.
SupplierId
==
1688
{
sku
.
GoodsName
=
gjson
.
Get
(
spu
,
"spu_name"
)
.
String
()
}
if
sku
.
GoodsName
==
""
{
sku
.
GoodsName
=
gjson
.
Get
(
spu
,
"spu_name"
)
.
String
()
}
...
...
@@ -207,7 +211,7 @@ 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
{
...
...
service/service_ly_common.go
View file @
658b9332
...
...
@@ -19,7 +19,7 @@ import (
_
"gopkg.in/mgo.v2/bson"
)
//获取图片信息
//
获取图片信息
func
(
ls
*
LyService
)
GetGoodsImages
(
sku
model
.
LySku
,
spu
string
)
model
.
LySku
{
//图片
spuLargeImage
:=
gjson
.
Get
(
spu
,
"images_l"
)
.
String
()
...
...
@@ -40,7 +40,7 @@ func (ls *LyService) GetGoodsImages(sku model.LySku, spu string) model.LySku {
return
sku
}
//获取分类信息
//
获取分类信息
func
(
ls
*
LyService
)
GetGoodsClass
(
sku
model
.
LySku
,
spu
string
)
model
.
LySku
{
//仅提供价格和库存
spuClassId1
:=
gjson
.
Get
(
spu
,
"class_id1"
)
.
Int
()
...
...
@@ -57,7 +57,7 @@ func (ls *LyService) GetGoodsClass(sku model.LySku, spu string) model.LySku {
return
sku
}
//获取税务信息,对接税务系统
//
获取税务信息,对接税务系统
func
(
ls
*
LyService
)
GetErpTax
(
goodsName
,
brandName
string
)
interface
{}
{
redisCon
:=
gredis
.
Conn
(
"default_r"
)
defer
redisCon
.
Close
()
...
...
@@ -73,7 +73,7 @@ func (ls *LyService) GetErpTax(goodsName, brandName string) interface{} {
}
}
//获取联营供应商的名字
//
获取联营供应商的名字
func
(
ls
*
LyService
)
GetPoolSupplierName
(
supplierId
int64
)
(
supplierName
string
)
{
redisCon
:=
gredis
.
Conn
(
"default_r"
)
defer
redisCon
.
Close
()
...
...
@@ -81,7 +81,7 @@ func (ls *LyService) GetPoolSupplierName(supplierId int64) (supplierName string)
return
supplier
}
//从缓存获取分类
//
从缓存获取分类
func
(
ls
*
LyService
)
GetCacheClass
(
classId
int64
)
string
{
redisCon
:=
gredis
.
Conn
(
"default_r"
)
defer
redisCon
.
Close
()
...
...
@@ -102,7 +102,7 @@ type AttrsExtend struct {
AttrUnit
string
`bson:"attr_unit" json:"attr_unit,omitempty"`
}
//H获取供应链标准品牌
//
H获取供应链标准品牌
func
(
ls
*
LyService
)
GetScmBrand
(
brandId
int64
)
(
res
interface
{})
{
redisCon
:=
gredis
.
Conn
(
"default_r"
)
defer
redisCon
.
Close
()
...
...
@@ -122,7 +122,7 @@ func (ls *LyService) GetScmBrand(brandId int64) (res interface{}) {
}
}
//获取新版标准品牌
//
获取新版标准品牌
func
(
ls
*
LyService
)
GetStandardBrand
(
brandId
int64
)
(
standardBrand
model
.
StandardBrand
)
{
redisCon
:=
gredis
.
Conn
(
"default_r"
)
defer
redisCon
.
Close
()
...
...
@@ -150,7 +150,7 @@ type ExtendFee struct {
}
`json:"hk"`
}
//获取附加费
//
获取附加费
func
(
ls
*
LyService
)
GetExtendFee
(
supplierId
int64
,
canal
string
)
interface
{}
{
redisCon
:=
gredis
.
Conn
(
"default_r"
)
defer
redisCon
.
Close
()
...
...
@@ -181,7 +181,7 @@ func (ls *LyService) GetExtendFee(supplierId int64, canal string) interface{} {
}
}
//获取系数
//
获取系数
func
(
ls
*
LyService
)
GetCoefficientAndPrice
(
sku
model
.
LySku
)
model
.
LySku
{
if
len
(
sku
.
LadderPrice
)
==
0
{
//sku.Original = nil
...
...
@@ -225,7 +225,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
data
[
key
]
.
PriceCostCn
=
price
.
PriceCostCn
//联营或者专卖 同时 存在活动价格
if
(
sku
.
GoodsType
==
1
||
sku
.
GoodsType
==
2
)
&&
sku
.
AcType
>
1
&&
sku
.
Ratio
>
0
{
if
(
sku
.
GoodsType
==
1
||
sku
.
GoodsType
==
2
||
sku
.
GoodsType
==
6
)
&&
sku
.
AcType
>
1
&&
sku
.
Ratio
>
0
{
tempAcPrice
:=
c
.
MyRound
(
c
.
MulFloat
(
price
.
PriceCn
,
sku
.
Ratio
/
100
),
4
)
data
[
key
]
.
PriceAc
=
tempAcPrice
data
[
key
]
.
PriceAcUs
=
c
.
MyRound
(
c
.
MulFloat
(
price
.
PriceUs
,
sku
.
RatioUs
/
100
),
4
)
...
...
@@ -323,7 +323,10 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
sku
.
DiscountRatio
.
Ratio
=
cnDiscountRatio
sku
.
DiscountRatio
.
RatioUsd
=
usDiscountRatio
//再去找售价组系数
/**
再去找售价组系数
**/
//找一个标志位,因为默认的全局折扣系数的数据格式和非全局的是不一样的
isDefaultPriceRatio
:=
false
priceRatioCache
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"magic_cube_price_rule_channel"
,
sku
.
SupplierId
))
...
...
@@ -333,7 +336,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
isDefaultPriceRatio
=
true
priceRatioCache
,
_
=
redis
.
String
(
redisCon
.
Do
(
"GET"
,
"magic_cube_price_rule_channel_default"
))
}
var
priceRatioSort
int
//这个就是最终要获取到的价格系数
var
priceRatioList
[]
model
.
PriceRatio
...
...
@@ -341,7 +343,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
findedRatio
:=
false
//如果只有默认系数,那么就去找默认系数
if
isDefaultPriceRatio
{
}
else
{
//拿到系数以后,就要去计算
//拿出里面的所有排序
...
...
@@ -461,7 +462,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
sku
.
PriceRatio
=
priceRatioList
sku
.
PriceRatioSort
=
priceRatioSort
//这里是供应商系数,先保留这块逻辑
ratio
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"pool_supplier_ratio"
,
sku
.
SupplierId
))
if
ratio
==
""
{
...
...
@@ -512,7 +512,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
if
!
hasCoefficient
{
coefficient
=
defaultCoefficient
}
//下面是计算价格
//价格计算文档 https://docs.qq.com/doc/DR3RJcnNPeUNkWHRk
// 为何是固定的1.13,关税基本不会变,有变的话跟产品沟通手动修改即可
...
...
@@ -553,14 +552,18 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
RatioUsd
:
1
,
}
}
//美金成本价
priceCostUs
:=
c
.
MulFloat
(
price
.
PriceUs
,
usDiscountRatio
)
priceCostUs
=
c
.
MyRound
(
priceCostUs
,
4
)
//美金售价
priceUs
:=
c
.
MulFloat
(
priceCostUs
,
priceRatio
.
RatioUsd
)
//人民币成本价
priceCostCn
:=
c
.
MulFloat
(
price
.
PriceUs
,
coefficient
.
Ratio
,
tax
)
//人民币成本价,mro只有人民币,所以人民币价格不是从美金来的,而且人民币是含税的.就它要特殊处理
var
priceCostCn
float64
if
sku
.
SupplierId
==
1688
{
priceCostCn
=
c
.
MulFloat
(
price
.
PriceCn
,
coefficient
.
Ratio
)
}
else
{
priceCostCn
=
c
.
MulFloat
(
price
.
PriceUs
,
coefficient
.
Ratio
,
tax
)
}
priceCostCn
=
c
.
MulFloat
(
c
.
MyRound
(
priceCostCn
,
4
),
cnDiscountRatio
)
priceCostCn
=
c
.
MyRound
(
priceCostCn
,
4
)
//人民币售价
...
...
@@ -571,7 +574,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
data
[
key
]
.
PriceCn
=
c
.
MyRound
(
priceCn
,
4
)
data
[
key
]
.
PriceCostCn
=
priceCostCn
//处理活动价和原价相同的情况
if
(
sku
.
GoodsType
==
1
||
sku
.
GoodsType
==
2
)
&&
sku
.
AcType
>
1
&&
sku
.
Ratio
>
0
{
if
(
sku
.
GoodsType
==
1
||
sku
.
GoodsType
==
2
||
sku
.
GoodsType
==
6
)
&&
sku
.
AcType
>
1
&&
sku
.
Ratio
>
0
{
priceAc
:=
c
.
MyRound
(
c
.
MulFloat
(
data
[
key
]
.
PriceCn
,
(
sku
.
Ratio
/
100
)),
4
)
data
[
key
]
.
PriceAc
=
priceAc
if
sku
.
RatioUs
>
0
{
...
...
@@ -603,7 +606,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
}
}
//判断原始价格有变化,那就要覆盖
if
len
(
originalPrice
)
>
0
{
sku
.
Original
=
originalPrice
...
...
@@ -619,7 +621,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
return
sku
}
//获取供应商货期
//
获取供应商货期
func
(
ls
*
LyService
)
GetDelivery
(
supplierId
int64
,
canal
string
)
(
delivery
map
[
string
]
string
)
{
delivery
=
make
(
map
[
string
]
string
)
redisCon
:=
gredis
.
Conn
(
"default_r"
)
...
...
@@ -655,7 +657,7 @@ func (ls *LyService) GetDelivery(supplierId int64, canal string) (delivery map[s
return
}
//判断能否购买
//
判断能否购买
func
(
ls
*
LyService
)
GetIsBuy
(
sku
model
.
LySku
)
(
isBuy
int
)
{
if
sku
.
GoodsStatus
!=
1
{
return
...
...
@@ -672,7 +674,7 @@ func (ls *LyService) GetIsBuy(sku model.LySku) (isBuy int) {
return
1
}
//合并spu的信息
//
合并spu的信息
func
(
ls
*
LyService
)
CombineSup
(
sku
model
.
LySku
,
spuStr
string
)
model
.
LySku
{
sku
.
UpdateTime
=
gjson
.
Get
(
spuStr
,
"update_time"
)
.
Int
()
sku
.
ClassID1
=
int
(
gjson
.
Get
(
spuStr
,
"class_id1"
)
.
Int
())
...
...
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