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
e87d8272
authored
Jul 13, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'ysx-mrq需求-20230710' into dev
parents
4feb4387
af8b6151
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
21 deletions
service/service_ly_common.go
service/service_ly_common.go
View file @
e87d8272
...
@@ -19,7 +19,7 @@ import (
...
@@ -19,7 +19,7 @@ import (
_
"gopkg.in/mgo.v2/bson"
_
"gopkg.in/mgo.v2/bson"
)
)
//获取图片信息
//
获取图片信息
func
(
ls
*
LyService
)
GetGoodsImages
(
sku
model
.
LySku
,
spu
string
)
model
.
LySku
{
func
(
ls
*
LyService
)
GetGoodsImages
(
sku
model
.
LySku
,
spu
string
)
model
.
LySku
{
//图片
//图片
spuLargeImage
:=
gjson
.
Get
(
spu
,
"images_l"
)
.
String
()
spuLargeImage
:=
gjson
.
Get
(
spu
,
"images_l"
)
.
String
()
...
@@ -40,7 +40,7 @@ func (ls *LyService) GetGoodsImages(sku model.LySku, spu string) model.LySku {
...
@@ -40,7 +40,7 @@ func (ls *LyService) GetGoodsImages(sku model.LySku, spu string) model.LySku {
return
sku
return
sku
}
}
//获取分类信息
//
获取分类信息
func
(
ls
*
LyService
)
GetGoodsClass
(
sku
model
.
LySku
,
spu
string
)
model
.
LySku
{
func
(
ls
*
LyService
)
GetGoodsClass
(
sku
model
.
LySku
,
spu
string
)
model
.
LySku
{
//仅提供价格和库存
//仅提供价格和库存
spuClassId1
:=
gjson
.
Get
(
spu
,
"class_id1"
)
.
Int
()
spuClassId1
:=
gjson
.
Get
(
spu
,
"class_id1"
)
.
Int
()
...
@@ -57,7 +57,7 @@ func (ls *LyService) GetGoodsClass(sku model.LySku, spu string) model.LySku {
...
@@ -57,7 +57,7 @@ func (ls *LyService) GetGoodsClass(sku model.LySku, spu string) model.LySku {
return
sku
return
sku
}
}
//获取税务信息,对接税务系统
//
获取税务信息,对接税务系统
func
(
ls
*
LyService
)
GetErpTax
(
goodsName
,
brandName
string
)
interface
{}
{
func
(
ls
*
LyService
)
GetErpTax
(
goodsName
,
brandName
string
)
interface
{}
{
redisCon
:=
gredis
.
Conn
(
"default_r"
)
redisCon
:=
gredis
.
Conn
(
"default_r"
)
defer
redisCon
.
Close
()
defer
redisCon
.
Close
()
...
@@ -73,7 +73,7 @@ func (ls *LyService) GetErpTax(goodsName, brandName string) interface{} {
...
@@ -73,7 +73,7 @@ func (ls *LyService) GetErpTax(goodsName, brandName string) interface{} {
}
}
}
}
//获取联营供应商的名字
//
获取联营供应商的名字
func
(
ls
*
LyService
)
GetPoolSupplierName
(
supplierId
int64
)
(
supplierName
string
)
{
func
(
ls
*
LyService
)
GetPoolSupplierName
(
supplierId
int64
)
(
supplierName
string
)
{
redisCon
:=
gredis
.
Conn
(
"default_r"
)
redisCon
:=
gredis
.
Conn
(
"default_r"
)
defer
redisCon
.
Close
()
defer
redisCon
.
Close
()
...
@@ -81,7 +81,7 @@ func (ls *LyService) GetPoolSupplierName(supplierId int64) (supplierName string)
...
@@ -81,7 +81,7 @@ func (ls *LyService) GetPoolSupplierName(supplierId int64) (supplierName string)
return
supplier
return
supplier
}
}
//从缓存获取分类
//
从缓存获取分类
func
(
ls
*
LyService
)
GetCacheClass
(
classId
int64
)
string
{
func
(
ls
*
LyService
)
GetCacheClass
(
classId
int64
)
string
{
redisCon
:=
gredis
.
Conn
(
"default_r"
)
redisCon
:=
gredis
.
Conn
(
"default_r"
)
defer
redisCon
.
Close
()
defer
redisCon
.
Close
()
...
@@ -102,7 +102,7 @@ type AttrsExtend struct {
...
@@ -102,7 +102,7 @@ type AttrsExtend struct {
AttrUnit
string
`bson:"attr_unit" json:"attr_unit,omitempty"`
AttrUnit
string
`bson:"attr_unit" json:"attr_unit,omitempty"`
}
}
//H获取供应链标准品牌
//
H获取供应链标准品牌
func
(
ls
*
LyService
)
GetScmBrand
(
brandId
int64
)
(
res
interface
{})
{
func
(
ls
*
LyService
)
GetScmBrand
(
brandId
int64
)
(
res
interface
{})
{
redisCon
:=
gredis
.
Conn
(
"default_r"
)
redisCon
:=
gredis
.
Conn
(
"default_r"
)
defer
redisCon
.
Close
()
defer
redisCon
.
Close
()
...
@@ -122,7 +122,7 @@ func (ls *LyService) GetScmBrand(brandId int64) (res interface{}) {
...
@@ -122,7 +122,7 @@ func (ls *LyService) GetScmBrand(brandId int64) (res interface{}) {
}
}
}
}
//获取新版标准品牌
//
获取新版标准品牌
func
(
ls
*
LyService
)
GetStandardBrand
(
brandId
int64
)
(
standardBrand
model
.
StandardBrand
)
{
func
(
ls
*
LyService
)
GetStandardBrand
(
brandId
int64
)
(
standardBrand
model
.
StandardBrand
)
{
redisCon
:=
gredis
.
Conn
(
"default_r"
)
redisCon
:=
gredis
.
Conn
(
"default_r"
)
defer
redisCon
.
Close
()
defer
redisCon
.
Close
()
...
@@ -150,7 +150,7 @@ type ExtendFee struct {
...
@@ -150,7 +150,7 @@ type ExtendFee struct {
}
`json:"hk"`
}
`json:"hk"`
}
}
//获取附加费
//
获取附加费
func
(
ls
*
LyService
)
GetExtendFee
(
supplierId
int64
,
canal
string
)
interface
{}
{
func
(
ls
*
LyService
)
GetExtendFee
(
supplierId
int64
,
canal
string
)
interface
{}
{
redisCon
:=
gredis
.
Conn
(
"default_r"
)
redisCon
:=
gredis
.
Conn
(
"default_r"
)
defer
redisCon
.
Close
()
defer
redisCon
.
Close
()
...
@@ -181,7 +181,7 @@ func (ls *LyService) GetExtendFee(supplierId int64, canal string) interface{} {
...
@@ -181,7 +181,7 @@ func (ls *LyService) GetExtendFee(supplierId int64, canal string) interface{} {
}
}
}
}
//获取系数
//
获取系数
func
(
ls
*
LyService
)
GetCoefficientAndPrice
(
sku
model
.
LySku
)
model
.
LySku
{
func
(
ls
*
LyService
)
GetCoefficientAndPrice
(
sku
model
.
LySku
)
model
.
LySku
{
if
len
(
sku
.
LadderPrice
)
==
0
{
if
len
(
sku
.
LadderPrice
)
==
0
{
//sku.Original = nil
//sku.Original = nil
...
@@ -323,7 +323,10 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
...
@@ -323,7 +323,10 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
sku
.
DiscountRatio
.
Ratio
=
cnDiscountRatio
sku
.
DiscountRatio
.
Ratio
=
cnDiscountRatio
sku
.
DiscountRatio
.
RatioUsd
=
usDiscountRatio
sku
.
DiscountRatio
.
RatioUsd
=
usDiscountRatio
//再去找售价组系数
/**
再去找售价组系数
**/
//找一个标志位,因为默认的全局折扣系数的数据格式和非全局的是不一样的
//找一个标志位,因为默认的全局折扣系数的数据格式和非全局的是不一样的
isDefaultPriceRatio
:=
false
isDefaultPriceRatio
:=
false
priceRatioCache
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"magic_cube_price_rule_channel"
,
sku
.
SupplierId
))
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 {
...
@@ -333,7 +336,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
isDefaultPriceRatio
=
true
isDefaultPriceRatio
=
true
priceRatioCache
,
_
=
redis
.
String
(
redisCon
.
Do
(
"GET"
,
"magic_cube_price_rule_channel_default"
))
priceRatioCache
,
_
=
redis
.
String
(
redisCon
.
Do
(
"GET"
,
"magic_cube_price_rule_channel_default"
))
}
}
var
priceRatioSort
int
var
priceRatioSort
int
//这个就是最终要获取到的价格系数
//这个就是最终要获取到的价格系数
var
priceRatioList
[]
model
.
PriceRatio
var
priceRatioList
[]
model
.
PriceRatio
...
@@ -341,7 +343,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
...
@@ -341,7 +343,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
findedRatio
:=
false
findedRatio
:=
false
//如果只有默认系数,那么就去找默认系数
//如果只有默认系数,那么就去找默认系数
if
isDefaultPriceRatio
{
if
isDefaultPriceRatio
{
}
else
{
}
else
{
//拿到系数以后,就要去计算
//拿到系数以后,就要去计算
//拿出里面的所有排序
//拿出里面的所有排序
...
@@ -461,7 +462,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
...
@@ -461,7 +462,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
}
sku
.
PriceRatio
=
priceRatioList
sku
.
PriceRatio
=
priceRatioList
sku
.
PriceRatioSort
=
priceRatioSort
sku
.
PriceRatioSort
=
priceRatioSort
//这里是供应商系数,先保留这块逻辑
//这里是供应商系数,先保留这块逻辑
ratio
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"pool_supplier_ratio"
,
sku
.
SupplierId
))
ratio
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"pool_supplier_ratio"
,
sku
.
SupplierId
))
if
ratio
==
""
{
if
ratio
==
""
{
...
@@ -512,7 +512,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
...
@@ -512,7 +512,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
if
!
hasCoefficient
{
if
!
hasCoefficient
{
coefficient
=
defaultCoefficient
coefficient
=
defaultCoefficient
}
}
//下面是计算价格
//下面是计算价格
//价格计算文档 https://docs.qq.com/doc/DR3RJcnNPeUNkWHRk
//价格计算文档 https://docs.qq.com/doc/DR3RJcnNPeUNkWHRk
// 为何是固定的1.13,关税基本不会变,有变的话跟产品沟通手动修改即可
// 为何是固定的1.13,关税基本不会变,有变的话跟产品沟通手动修改即可
...
@@ -553,14 +552,18 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
...
@@ -553,14 +552,18 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
RatioUsd
:
1
,
RatioUsd
:
1
,
}
}
}
}
//美金成本价
//美金成本价
priceCostUs
:=
c
.
MulFloat
(
price
.
PriceUs
,
usDiscountRatio
)
priceCostUs
:=
c
.
MulFloat
(
price
.
PriceUs
,
usDiscountRatio
)
priceCostUs
=
c
.
MyRound
(
priceCostUs
,
4
)
priceCostUs
=
c
.
MyRound
(
priceCostUs
,
4
)
//美金售价
//美金售价
priceUs
:=
c
.
MulFloat
(
priceCostUs
,
priceRatio
.
RatioUsd
)
priceUs
:=
c
.
MulFloat
(
priceCostUs
,
priceRatio
.
RatioUsd
)
//人民币成本价
//人民币成本价,mro只有人民币,所以人民币价格不是从美金来的,就它要特殊处理
priceCostCn
:=
c
.
MulFloat
(
price
.
PriceUs
,
coefficient
.
Ratio
,
tax
)
var
priceCostCn
float64
if
sku
.
SupplierId
==
1688
{
priceCostCn
=
c
.
MulFloat
(
price
.
PriceCn
,
coefficient
.
Ratio
,
tax
)
}
else
{
priceCostCn
=
c
.
MulFloat
(
price
.
PriceUs
,
coefficient
.
Ratio
,
tax
)
}
priceCostCn
=
c
.
MulFloat
(
c
.
MyRound
(
priceCostCn
,
4
),
cnDiscountRatio
)
priceCostCn
=
c
.
MulFloat
(
c
.
MyRound
(
priceCostCn
,
4
),
cnDiscountRatio
)
priceCostCn
=
c
.
MyRound
(
priceCostCn
,
4
)
priceCostCn
=
c
.
MyRound
(
priceCostCn
,
4
)
//人民币售价
//人民币售价
...
@@ -603,7 +606,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
...
@@ -603,7 +606,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
}
}
}
}
}
//判断原始价格有变化,那就要覆盖
//判断原始价格有变化,那就要覆盖
if
len
(
originalPrice
)
>
0
{
if
len
(
originalPrice
)
>
0
{
sku
.
Original
=
originalPrice
sku
.
Original
=
originalPrice
...
@@ -619,7 +621,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
...
@@ -619,7 +621,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
return
sku
return
sku
}
}
//获取供应商货期
//
获取供应商货期
func
(
ls
*
LyService
)
GetDelivery
(
supplierId
int64
,
canal
string
)
(
delivery
map
[
string
]
string
)
{
func
(
ls
*
LyService
)
GetDelivery
(
supplierId
int64
,
canal
string
)
(
delivery
map
[
string
]
string
)
{
delivery
=
make
(
map
[
string
]
string
)
delivery
=
make
(
map
[
string
]
string
)
redisCon
:=
gredis
.
Conn
(
"default_r"
)
redisCon
:=
gredis
.
Conn
(
"default_r"
)
...
@@ -655,7 +657,7 @@ func (ls *LyService) GetDelivery(supplierId int64, canal string) (delivery map[s
...
@@ -655,7 +657,7 @@ func (ls *LyService) GetDelivery(supplierId int64, canal string) (delivery map[s
return
return
}
}
//判断能否购买
//
判断能否购买
func
(
ls
*
LyService
)
GetIsBuy
(
sku
model
.
LySku
)
(
isBuy
int
)
{
func
(
ls
*
LyService
)
GetIsBuy
(
sku
model
.
LySku
)
(
isBuy
int
)
{
if
sku
.
GoodsStatus
!=
1
{
if
sku
.
GoodsStatus
!=
1
{
return
return
...
@@ -672,7 +674,7 @@ func (ls *LyService) GetIsBuy(sku model.LySku) (isBuy int) {
...
@@ -672,7 +674,7 @@ func (ls *LyService) GetIsBuy(sku model.LySku) (isBuy int) {
return
1
return
1
}
}
//合并spu的信息
//
合并spu的信息
func
(
ls
*
LyService
)
CombineSup
(
sku
model
.
LySku
,
spuStr
string
)
model
.
LySku
{
func
(
ls
*
LyService
)
CombineSup
(
sku
model
.
LySku
,
spuStr
string
)
model
.
LySku
{
sku
.
UpdateTime
=
gjson
.
Get
(
spuStr
,
"update_time"
)
.
Int
()
sku
.
UpdateTime
=
gjson
.
Get
(
spuStr
,
"update_time"
)
.
Int
()
sku
.
ClassID1
=
int
(
gjson
.
Get
(
spuStr
,
"class_id1"
)
.
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