Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tb_goods
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bigdata
tb_goods
Commits
83b66d06
Commit
83b66d06
authored
Jun 18, 2021
by
杨林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加对京东数据的支持
parent
c6d0199f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
166 additions
and
0 deletions
+166
-0
src/main/scala/model/CouponItem.scala
src/main/scala/model/CouponItem.scala
+20
-0
src/main/scala/tools/dataformat/Data.scala
src/main/scala/tools/dataformat/Data.scala
+146
-0
No files found.
src/main/scala/model/CouponItem.scala
0 → 100644
View file @
83b66d06
package
model
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
/**
* Created with IntelliJ IDEA.
* Class: CouponItem
* Description:
* User: lin
* Date: 2021-06-04
* Time: 17:56
*/
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
case
class
CouponItem
(
discount
:
Double
,
link
:
String
,
quota
:
Double
,
useEndTime
:
Long
,
useStartTime
:
Long
)
src/main/scala/tools/dataformat/Data.scala
0 → 100644
View file @
83b66d06
package
tools.dataformat
import
model.
{
CouponItem
,
Item
}
import
tools.http.HttpTools
import
tools.json.Jackson
import
tools.timestamp.TimestampTools
import
scala.collection.
{
immutable
,
mutable
}
/**
* Created with IntelliJ IDEA.
* Class: Data
* Description:
* User: lin
* Date: 2021-06-11
* Time: 16:22
*/
object
Data
{
/**
* 解析淘宝字段
*
* @param x 淘宝字段映射
* @return 返回格式化结果
*/
def
formatJDData
(
x
:
mutable.Map
[
String
,
String
])
:
Item
=
{
val
title
=
x
.
getOrElse
(
"skuName"
,
""
).
replaceAll
(
"\""
,
""
)
val
list
=
Jackson
.
parseStringToArray
(
x
.
getOrElse
(
"couponList"
,
"[]"
))
val
image
=
Jackson
.
parseStringToArray
(
x
.
getOrElse
(
"imageList"
,
"[]"
))
// 取第一张券
var
couponItem
:
CouponItem
=
null
if
(
list
.
isEmpty
)
{
couponItem
=
CouponItem
(
0.0
,
""
,
0.0
,
0L
,
0L
)
}
else
{
val
coupon
=
list
(
0
).
asInstanceOf
[
immutable.HashMap
[
String
,
Any
]]
couponItem
=
CouponItem
(
discount
=
coupon
.
getOrElse
(
"discount"
,
"0"
).
toString
.
replaceAll
(
"\""
,
""
).
toDouble
,
link
=
coupon
.
getOrElse
(
"link"
,
""
).
toString
.
replaceAll
(
"\""
,
""
),
quota
=
coupon
.
getOrElse
(
"quota"
,
"0"
).
toString
.
replaceAll
(
"\""
,
""
).
toDouble
,
useEndTime
=
coupon
.
getOrElse
(
"useEndTime"
,
"0"
).
toString
.
replaceAll
(
"\""
,
""
).
toLong
,
useStartTime
=
coupon
.
getOrElse
(
"useStartTime"
,
"0"
).
toString
.
replaceAll
(
"\""
,
""
).
toLong
)
}
var
imageUrl
:
String
=
null
if
(
image
.
isEmpty
)
{
imageUrl
=
""
}
else
{
val
map
=
image
(
0
).
asInstanceOf
[
immutable.Map
[
String
,
Any
]]
imageUrl
=
map
.
getOrElse
(
"url"
,
""
).
toString
}
val
price
=
x
.
getOrElse
(
"price"
,
""
).
replaceAll
(
"\""
,
""
).
toDouble
Item
(
platform
=
2
,
item_id
=
x
.
getOrElse
(
"skuId"
,
""
).
replaceAll
(
"\""
,
""
),
item_name
=
title
,
item_desc
=
x
.
getOrElse
(
"document"
,
""
).
replaceAll
(
"\""
,
""
),
brand_name
=
x
.
getOrElse
(
"brandName"
,
""
).
replaceAll
(
"\""
,
""
),
item_url
=
x
.
getOrElse
(
"materialUrl"
,
""
).
replaceAll
(
"\""
,
""
),
item_pic_url
=
imageUrl
,
item_volume
=
x
.
getOrElse
(
"inOrderCount30Days"
,
""
).
replaceAll
(
"\""
,
""
),
origin_category
=
x
.
getOrElse
(
"cid1Name"
,
""
).
replaceAll
(
"\""
,
""
)
+
"/"
+
x
.
getOrElse
(
"cid2Name"
,
""
).
replaceAll
(
"\""
,
""
)
+
"/"
+
x
.
getOrElse
(
"cid3Name"
,
""
).
replaceAll
(
"\""
,
""
),
origin_category_id
=
x
.
getOrElse
(
"cid1"
,
""
).
replaceAll
(
"\""
,
""
)
+
"/"
+
x
.
getOrElse
(
"cid2"
,
""
).
replaceAll
(
"\""
,
""
)
+
"/"
+
x
.
getOrElse
(
"cid3"
,
""
).
replaceAll
(
"\""
,
""
),
new_category
=
""
,
new_category_id
=
""
,
price
=
price
,
coupon_price
=
price
-
couponItem
.
discount
,
commission_rate
=
x
.
getOrElse
(
"commissionShare"
,
"0"
).
replaceAll
(
"\""
,
""
).
toDouble
/
100
,
coupon_commission
=
x
.
getOrElse
(
"couponCommission"
,
"0"
).
toDouble
,
commission_start_time
=
0L
,
commission_end_time
=
0L
,
coupon_amount
=
couponItem
.
discount
,
coupon_tips
=
"满"
+
couponItem
.
quota
+
"减"
+
couponItem
.
discount
,
coupon_count
=
9999
,
coupon_remain
=
9999
,
coupon_start_time
=
couponItem
.
useStartTime
,
coupon_end_time
=
couponItem
.
useEndTime
,
coupon_link
=
couponItem
.
link
,
item_label
=
HttpTools
(
"POST"
).
nlp_request
(
title
),
shop_id
=
x
.
getOrElse
(
"shopId"
,
""
).
replaceAll
(
"\""
,
""
),
shop_name
=
x
.
getOrElse
(
"shopName"
,
""
).
replaceAll
(
"\""
,
""
),
shop_level
=
x
.
getOrElse
(
"shopLevel"
,
"0"
).
replaceAll
(
"\""
,
""
).
toDouble
,
description_level
=
x
.
getOrElse
(
"userEvaluateScore"
,
"0"
).
replaceAll
(
"\""
,
""
).
toDouble
,
express_level
=
x
.
getOrElse
(
"logisticsLvyueScore"
,
"0"
).
replaceAll
(
"\""
,
""
).
toDouble
,
server_level
=
x
.
getOrElse
(
"afterServiceScore"
,
"0"
).
replaceAll
(
"\""
,
""
).
toDouble
,
shop_type
=
x
.
getOrElse
(
"shopLabel"
,
"0"
).
replaceAll
(
"\""
,
""
).
toInt
,
createTime
=
System
.
currentTimeMillis
()
/
1000
)
}
/**
* 解析淘宝字段
*
* @param x 淘宝字段映射
* @return 返回格式化结果
*/
def
formatTBData
(
x
:
mutable.Map
[
String
,
String
])
:
Item
=
{
val
price
=
x
.
getOrElse
(
"zk_final_price"
,
"0.0"
).
replaceAll
(
"\""
,
""
).
toDouble
val
coupon_amount
=
x
.
getOrElse
(
"coupon_amount"
,
"0.0"
).
replaceAll
(
"\""
,
""
).
toDouble
val
coupon_price
=
price
-
coupon_amount
val
commission_rate
=
x
.
getOrElse
(
"commission_rate"
,
"0"
).
replaceAll
(
"\""
,
""
).
toInt
/
10000.0
val
title
=
x
.
getOrElse
(
"title"
,
""
).
replaceAll
(
"\""
,
""
)
Item
(
platform
=
1
,
item_id
=
x
.
getOrElse
(
"item_id"
,
""
).
replaceAll
(
"\""
,
""
),
item_name
=
title
,
item_desc
=
x
.
getOrElse
(
"item_description"
,
""
).
replaceAll
(
"\""
,
""
),
brand_name
=
""
,
item_url
=
x
.
getOrElse
(
"item_url"
,
""
).
replaceAll
(
"\""
,
""
),
item_pic_url
=
if
(
x
.
getOrElse
(
"white_image"
,
""
).
replaceAll
(
"\""
,
""
).
isEmpty
)
x
.
getOrElse
(
"pict_url"
,
""
).
replaceAll
(
"\""
,
""
)
else
x
.
getOrElse
(
"white_image"
,
""
).
replaceAll
(
"\""
,
""
),
item_volume
=
x
.
getOrElse
(
"volume"
,
""
).
replaceAll
(
"\""
,
""
),
origin_category
=
x
.
getOrElse
(
"level_one_category_name"
,
""
).
replaceAll
(
"\""
,
""
)
+
"/"
+
x
.
getOrElse
(
"category_name"
,
""
).
replaceAll
(
"\""
,
""
),
origin_category_id
=
x
.
getOrElse
(
"level_one_category_id"
,
""
).
replaceAll
(
"\""
,
""
)
+
"/"
+
x
.
getOrElse
(
"category_id"
,
""
).
replaceAll
(
"\""
,
""
),
new_category
=
""
,
new_category_id
=
""
,
price
=
price
,
coupon_price
=
coupon_price
,
commission_rate
=
commission_rate
,
coupon_commission
=
coupon_price
,
commission_start_time
=
0
,
commission_end_time
=
0
,
coupon_amount
=
coupon_amount
,
coupon_tips
=
x
.
getOrElse
(
"coupon_info"
,
""
).
replaceAll
(
"\""
,
""
),
coupon_count
=
x
.
getOrElse
(
"coupon_total_count"
,
"0"
).
replaceAll
(
"\""
,
""
).
toInt
,
coupon_remain
=
x
.
getOrElse
(
"coupon_remain_count"
,
"0"
).
replaceAll
(
"\""
,
""
).
toInt
,
coupon_start_time
=
TimestampTools
.
date2Timestamp
(
x
.
getOrElse
(
"coupon_start_time"
,
""
).
replaceAll
(
"\""
,
""
)),
coupon_end_time
=
TimestampTools
.
date2Timestamp
(
x
.
getOrElse
(
"coupon_end_time"
,
""
).
replaceAll
(
"\""
,
""
)),
coupon_link
=
x
.
getOrElse
(
"coupon_share_url"
,
""
).
replaceAll
(
"\""
,
""
),
item_label
=
HttpTools
(
"POST"
).
nlp_request
(
title
),
shop_id
=
x
.
getOrElse
(
"seller_id"
,
""
).
replaceAll
(
"\""
,
""
),
shop_name
=
x
.
getOrElse
(
"shop_title"
,
""
).
replaceAll
(
"\""
,
""
),
shop_level
=
0
,
description_level
=
0
,
express_level
=
0
,
server_level
=
0
,
shop_type
=
0
,
createTime
=
System
.
currentTimeMillis
()
/
1000
)
}
}
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