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
723ef51b
authored
Dec 09, 2020
by
huangchengyi
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1.0
parent
2b0f4f7b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
18 deletions
pkg/common/function.go
service/service_zy_common.go
pkg/common/function.go
View file @
723ef51b
...
...
@@ -32,14 +32,12 @@ gjson 判断某值是否存在 map
@param targetk string 目标ID
*/
func
GInArray
(
json
string
,
arrK
string
,
targetK
string
)
bool
{
s
:=
gjson
.
Get
(
json
,
"brand_id"
)
.
Array
()
s
:=
gjson
.
Get
(
json
,
arrK
)
.
Array
()
d
:=
make
([]
string
,
0
)
for
_
,
a
:=
range
s
{
c
:=
a
.
String
()
d
=
append
(
d
,
c
)
}
return
php2go
.
InArray
(
targetK
,
d
)
}
/*
...
...
service/service_zy_common.go
View file @
723ef51b
...
...
@@ -127,13 +127,23 @@ func (qs *ZiyingService) HDActivityPrice(ctx *gin.Context,GoodsActivityPrice str
}
}
}
else
{
if
!
common
.
GInArray
(
GoodsActivityPrice
,
"brand_id"
,
gjson
.
Get
(
SkuInfo
,
"brand_id"
)
.
String
())
{
Ratio
=
false
;
//不符合活动价
goto
End
//fmt.Println(GoodsActivityPrice,SkuInfo)
brand_id
:=
gjson
.
Get
(
GoodsActivityPrice
,
"brand_id"
)
.
String
()
class_id
:=
gjson
.
Get
(
GoodsActivityPrice
,
"class_id"
)
.
String
()
if
brand_id
!=
""
{
if
!
common
.
GInArray
(
GoodsActivityPrice
,
"brand_id"
,
gjson
.
Get
(
SkuInfo
,
"brand_id"
)
.
String
())
{
Ratio
=
false
;
//不符合活动价
//fmt.Println("不符合活动价1")
goto
End
}
}
if
!
common
.
GInArray
(
GoodsActivityPrice
,
"class_id"
,
gjson
.
Get
(
SkuInfo
,
"class_id2"
)
.
String
())
{
Ratio
=
false
;
//不符合活动价
goto
End
if
class_id
!=
""
{
if
!
common
.
GInArray
(
GoodsActivityPrice
,
"class_id"
,
gjson
.
Get
(
SkuInfo
,
"class_id2"
)
.
String
())
{
Ratio
=
false
;
//不符合活动价
//fmt.Println("不符合活动价2")
goto
End
}
}
//会员价处理
...
...
@@ -173,21 +183,19 @@ func (qs *ZiyingService) HDActivityPrice(ctx *gin.Context,GoodsActivityPrice str
}
End
:
//最终执行
if
Ratio
{
ladder_price_arr
:=
gjson
.
Get
(
SkuInfo
,
"ladder_price"
)
.
Array
()
if
Ratio
&&
len
(
ladder_price_arr
)
>
0
{
discount_type
:=
gjson
.
Get
(
GoodsActivityPrice
,
"discount_type"
)
.
String
()
ratio
:=
gjson
.
Get
(
GoodsActivityPrice
,
"ratio"
)
.
Float
()
//当前活动折扣
ladder_price_arr
:=
gjson
.
Get
(
SkuInfo
,
"ladder_price"
)
.
Array
()
A
:=
orderedmap
.
New
();
ladderType
:=
make
([]
model
.
LadderPrice
,
0
)
for
_
,
v
:=
range
ladder_price_arr
{
if
Actype
!=
"7"
||
(
Actype
==
"7"
&&
discount_type
!=
""
)
||
discount_type
==
"1"
{
price_cn
:=
v
.
Get
(
"price_cn"
)
.
Float
()
price_ac
:=
php2go
.
Round
(
price_cn
*
ratio
/
100
)
price_ac
:=
php2go
.
Round
(
price_cn
*
ratio
/
100
*
10000
)
/
10000
ladderType
=
append
(
ladderType
,
model
.
LadderPrice
{
Purchases
:
v
.
Get
(
"
P
urchases"
)
.
Int
(),
Purchases
:
v
.
Get
(
"
p
urchases"
)
.
Int
(),
PriceUs
:
v
.
Get
(
"price_us"
)
.
Float
(),
PriceCn
:
price_cn
,
PriceAc
:
price_ac
,
...
...
@@ -195,11 +203,26 @@ End: //最终执行
})
}
}
allow_not_login
:=
gjson
.
Get
(
GoodsActivityPrice
,
"allow_not_login"
)
.
Int
()
if
allow_not_login
==
0
{
allow_not_login
=
2
}
A
.
Set
(
"activity_info"
,
map
[
string
]
interface
{}{
"activity_ad"
:
gjson
.
Get
(
GoodsActivityPrice
,
"activity_ad"
)
.
String
(),
"sign_name"
:
gjson
.
Get
(
GoodsActivityPrice
,
"sign_name"
)
.
String
(),
"allow_not_login"
:
allow_not_login
,
})
A
.
Set
(
"ladder_price"
,
ladderType
)
A
.
Set
(
"ratio"
,
ratio
)
A
.
Set
(
"ac_type"
,
Actype
)
A
.
Set
(
"allow_coupon"
,
ratio
)
A
.
Set
(
"activity_end_time"
,
ratio
)
A
.
Set
(
"activity_info"
,
ratio
)
allow_coupon
:=
gjson
.
Get
(
GoodsActivityPrice
,
"allow_coupon"
)
.
Int
()
if
gjson
.
Get
(
GoodsActivityPrice
,
"allow_coupon"
)
.
Int
()
==
0
{
allow_coupon
=
1
}
A
.
Set
(
"allow_coupon"
,
allow_coupon
)
A
.
Set
(
"activity_end_time"
,
gjson
.
Get
(
GoodsActivityPrice
,
"end_time"
)
.
Int
())
return
A
}
return
nil
...
...
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