Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
Z
zion
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
zhengfg
zion
Commits
e65c294b
提交
e65c294b
authored
12月 07, 2019
作者:
梁业锦
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复 afrieshop 的bug
上级
e027f6dc
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
24 行增加
和
25 行删除
+24
-25
AfricaShopItemSpider.java
...iaoyun/zion/chinafrica/bis/impl/AfricaShopItemSpider.java
+24
-13
ItemInfo.java
src/main/java/com/diaoyun/zion/chinafrica/vo/ItemInfo.java
+0
-12
没有找到文件。
src/main/java/com/diaoyun/zion/chinafrica/bis/impl/AfricaShopItemSpider.java
浏览文件 @
e65c294b
...
@@ -57,8 +57,8 @@ public class AfricaShopItemSpider implements IItemSpider {
...
@@ -57,8 +57,8 @@ public class AfricaShopItemSpider implements IItemSpider {
ProductResponse
productResponse
=
new
ProductResponse
();
ProductResponse
productResponse
=
new
ProductResponse
();
// 含有商品的属性,设置为true
// 含有商品的属性,设置为true
productResponse
.
setPropFlag
(
true
);
productResponse
.
setPropFlag
(
true
);
//
无
库存信息
// 库存信息
productResponse
.
setStockFlag
(
fals
e
);
productResponse
.
setStockFlag
(
tru
e
);
// 库存信息,如果没有可使用的库存信息则默认为999
// 库存信息,如果没有可使用的库存信息则默认为999
DynStock
dynStock
=
new
DynStock
();
DynStock
dynStock
=
new
DynStock
();
dynStock
.
setSellableQuantity
(
9999
);
dynStock
.
setSellableQuantity
(
9999
);
...
@@ -68,8 +68,6 @@ public class AfricaShopItemSpider implements IItemSpider {
...
@@ -68,8 +68,6 @@ public class AfricaShopItemSpider implements IItemSpider {
List
<
ProductPromotion
>
promotionList
=
new
ArrayList
<>();
List
<
ProductPromotion
>
promotionList
=
new
ArrayList
<>();
// 商品的属性,常用的商品属性为颜色与尺码
// 商品的属性,常用的商品属性为颜色与尺码
Map
<
String
,
Set
<
ProductProp
>>
productPropSet
=
new
HashMap
<>(
16
);
Map
<
String
,
Set
<
ProductProp
>>
productPropSet
=
new
HashMap
<>(
16
);
Set
<
ProductProp
>
propSet1
=
new
HashSet
<>(
16
);
Set
<
ProductProp
>
propSet2
=
new
HashSet
<>(
16
);
// 商品的基本属性
// 商品的基本属性
ItemInfo
itemInfo
=
new
ItemInfo
();
ItemInfo
itemInfo
=
new
ItemInfo
();
...
@@ -79,6 +77,7 @@ public class AfricaShopItemSpider implements IItemSpider {
...
@@ -79,6 +77,7 @@ public class AfricaShopItemSpider implements IItemSpider {
itemInfo
.
setShopName
(
PlatformEnum
.
AfriEshop
.
getValue
());
itemInfo
.
setShopName
(
PlatformEnum
.
AfriEshop
.
getValue
());
itemInfo
.
setShopUrl
(
"https://www.afrieshop.com/"
);
itemInfo
.
setShopUrl
(
"https://www.afrieshop.com/"
);
itemInfo
.
setTitle
(
resultObj
.
getString
(
"title"
));
itemInfo
.
setTitle
(
resultObj
.
getString
(
"title"
));
itemInfo
.
setPic
(
resultObj
.
getString
(
"featured_image"
));
//////////////////////////////////// 获取商品基本信息End /////////////////////////
//////////////////////////////////// 获取商品基本信息End /////////////////////////
// 该商品拥有的属性
// 该商品拥有的属性
...
@@ -98,18 +97,26 @@ public class AfricaShopItemSpider implements IItemSpider {
...
@@ -98,18 +97,26 @@ public class AfricaShopItemSpider implements IItemSpider {
String
title
=
variantsObj
.
getString
(
"title"
);
String
title
=
variantsObj
.
getString
(
"title"
);
String
[]
optionStr
=
title
.
split
(
"/"
);
String
[]
optionStr
=
title
.
split
(
"/"
);
for
(
int
j
=
0
;
j
<
optionStr
.
length
;
j
++)
{
optionStr
[
j
]
=
optionStr
[
j
].
trim
();
}
for
(
int
j
=
0
;
j
<
options
.
size
();
j
++)
{
for
(
int
j
=
0
;
j
<
options
.
size
();
j
++)
{
String
optionName
=
options
.
get
(
j
);
// 商品的属性名
String
option
=
optionStr
[
j
].
trim
();
// 商品的属性值
//商品属性
Set
<
ProductProp
>
propSet
=
new
HashSet
<>();
Set
<
ProductProp
>
propSet
=
new
HashSet
<>();
ProductProp
productProp
=
new
ProductProp
();
ProductProp
productProp
=
new
ProductProp
();
if
(
variantsObj
.
containsKey
(
"featured_image"
)
&&
!
"null"
.
equals
(
variantsObj
.
getString
(
"featured_image"
)))
{
productProp
.
setImage
(
variantsObj
.
getJSONObject
(
"featured_image"
).
getString
(
"src"
));
String
optionName
=
options
.
get
(
j
);
// 商品的属性名
}
else
{
String
option
=
optionStr
[
j
];
// 商品的属性值
productProp
.
setImage
(
resultObj
.
getString
(
"featured_image"
));
// 获取图片信息,仅在这个 featured_image 节点获取
if
(
"Color"
.
equals
(
optionName
))
{
if
(
variantsObj
.
containsKey
(
"featured_image"
)
&&
!
"null"
.
equals
(
variantsObj
.
getString
(
"featured_image"
)))
{
productProp
.
setImage
(
variantsObj
.
getJSONObject
(
"featured_image"
).
getString
(
"src"
));
}
else
{
productProp
.
setImage
(
resultObj
.
getString
(
"featured_image"
));
}
}
}
productProp
.
setPropId
(
option
);
productProp
.
setPropId
(
option
);
productProp
.
setPropName
(
option
);
productProp
.
setPropName
(
option
);
propSet
.
add
(
productProp
);
propSet
.
add
(
productProp
);
...
@@ -122,6 +129,7 @@ public class AfricaShopItemSpider implements IItemSpider {
...
@@ -122,6 +129,7 @@ public class AfricaShopItemSpider implements IItemSpider {
}
}
}
}
// 获取库存id
String
skuStr
=
""
;
String
skuStr
=
""
;
if
(
optionStr
.
length
>
1
)
{
if
(
optionStr
.
length
>
1
)
{
skuStr
=
";"
+
optionStr
[
0
]
+
";"
+
optionStr
[
1
]
+
";"
;
skuStr
=
";"
+
optionStr
[
0
]
+
";"
+
optionStr
[
1
]
+
";"
;
...
@@ -145,14 +153,12 @@ public class AfricaShopItemSpider implements IItemSpider {
...
@@ -145,14 +153,12 @@ public class AfricaShopItemSpider implements IItemSpider {
if
(
productSkuStockList
==
null
)
{
if
(
productSkuStockList
==
null
)
{
productSkuStockList
=
new
ArrayList
<>();
productSkuStockList
=
new
ArrayList
<>();
}
}
ProductSkuStock
productSkuStock
=
new
ProductSkuStock
();
ProductSkuStock
productSkuStock
=
new
ProductSkuStock
();
productSkuStock
.
setSellableQuantity
(
999
);
productSkuStock
.
setSellableQuantity
(
999
);
productSkuStock
.
setSkuStr
(
skuStr
);
productSkuStock
.
setSkuStr
(
skuStr
);
productSkuStockList
.
add
(
productSkuStock
);
productSkuStockList
.
add
(
productSkuStock
);
dynStock
.
setProductSkuStockList
(
productSkuStockList
);
dynStock
.
setProductSkuStockList
(
productSkuStockList
);
////////////////////////////////////获取库存 END/////////////
////////////////////////////////////获取库存 END/////////////
}
}
productResponse
.
setProductPropSet
(
productPropSet
);
productResponse
.
setProductPropSet
(
productPropSet
);
...
@@ -161,6 +167,11 @@ public class AfricaShopItemSpider implements IItemSpider {
...
@@ -161,6 +167,11 @@ public class AfricaShopItemSpider implements IItemSpider {
productResponse
.
setOriginalPriceList
(
originalPriceList
);
productResponse
.
setOriginalPriceList
(
originalPriceList
);
productResponse
.
setItemInfo
(
itemInfo
);
productResponse
.
setItemInfo
(
itemInfo
);
productResponse
.
setDynStock
(
dynStock
);
productResponse
.
setDynStock
(
dynStock
);
String
price
=
resultObj
.
getString
(
"price"
);
BigDecimal
priceOld
=
new
BigDecimal
(
price
);
BigDecimal
div
=
new
BigDecimal
(
"100"
);
BigDecimal
priceNew
=
priceOld
.
divide
(
div
,
2
,
BigDecimal
.
ROUND_DOWN
);
productResponse
.
setPrice
(
priceNew
.
toString
());
return
productResponse
;
return
productResponse
;
}
}
...
...
src/main/java/com/diaoyun/zion/chinafrica/vo/ItemInfo.java
浏览文件 @
e65c294b
...
@@ -14,10 +14,6 @@ public class ItemInfo {
...
@@ -14,10 +14,6 @@ public class ItemInfo {
* 商品标题
* 商品标题
*/
*/
private
String
title
;
private
String
title
;
/**
* 商品的品名
*/
private
String
variety
;
/**
/**
* 商品主图
* 商品主图
*/
*/
...
@@ -31,14 +27,6 @@ public class ItemInfo {
...
@@ -31,14 +27,6 @@ public class ItemInfo {
*/
*/
private
String
shopUrl
;
private
String
shopUrl
;
public
String
getVariety
()
{
return
variety
;
}
public
void
setVariety
(
String
variety
)
{
this
.
variety
=
variety
;
}
public
String
getItemId
()
{
public
String
getItemId
()
{
return
itemId
;
return
itemId
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论