Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
Z
zion
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
zhengfg
zion
Commits
f1db8cfe
提交
f1db8cfe
authored
12月 11, 2019
作者:
luojie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复zara,sku为中文的问题
上级
b68feb39
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
176 行增加
和
86 行删除
+176
-86
ThirdPartyController.java
...com/diaoyun/zion/chinafrica/api/ThirdPartyController.java
+17
-0
ZaraSpider.java
...java/com/diaoyun/zion/chinafrica/bis/impl/ZaraSpider.java
+96
-84
TbCfItemShippedEntity.java
...diaoyun/zion/chinafrica/entity/TbCfItemShippedEntity.java
+9
-0
TbCfOrderService.java
...com/diaoyun/zion/chinafrica/service/TbCfOrderService.java
+2
-0
TbCfOrderServiceImpl.java
...un/zion/chinafrica/service/impl/TbCfOrderServiceImpl.java
+20
-0
TranslateHelper.java
...in/java/com/diaoyun/zion/master/util/TranslateHelper.java
+9
-1
TbCfOrderDao.xml
src/main/resources/mapper/TbCfOrderDao.xml
+23
-1
没有找到文件。
src/main/java/com/diaoyun/zion/chinafrica/api/ThirdPartyController.java
浏览文件 @
f1db8cfe
...
@@ -63,6 +63,23 @@ public class ThirdPartyController {
...
@@ -63,6 +63,23 @@ public class ThirdPartyController {
}
}
return
tbCfOrderService
.
getDeliveryList
(
beginTime
,
endTime
,
pageNum
,
pageSize
);
return
tbCfOrderService
.
getDeliveryList
(
beginTime
,
endTime
,
pageNum
,
pageSize
);
}
}
/* *//**
*获取某段时间已发货订单数据
*//*
@ApiOperation(value = "获取某段时间已发货订单数据")
@GetMapping(value ="/delivery")
public Result getDeliveryLists(@ApiParam(value ="开始时间") @RequestParam("beginTime")long beginTime,
@ApiParam(value ="结束时间") @RequestParam("endTime")long endTime,
@ApiParam(value = "页数") @RequestParam(required = false) Integer pageNum,
@ApiParam(value ="每页大小 默认100") @RequestParam(required = false) Integer pageSize) {
if (pageNum == null) {
pageNum = 1;
}
if (pageSize == null) {
pageSize = 100;
}
return tbCfOrderService.getDeliveryLists(beginTime,endTime,pageNum,pageSize);
}*/
/**
/**
* 根据订单号获取详细订单数据
* 根据订单号获取详细订单数据
...
...
src/main/java/com/diaoyun/zion/chinafrica/bis/impl/ZaraSpider.java
浏览文件 @
f1db8cfe
...
@@ -5,6 +5,7 @@ import com.diaoyun.zion.chinafrica.enums.PlatformEnum;
...
@@ -5,6 +5,7 @@ import com.diaoyun.zion.chinafrica.enums.PlatformEnum;
import
com.diaoyun.zion.chinafrica.vo.*
;
import
com.diaoyun.zion.chinafrica.vo.*
;
import
com.diaoyun.zion.master.util.HttpClientUtil
;
import
com.diaoyun.zion.master.util.HttpClientUtil
;
import
com.diaoyun.zion.master.util.TranslateHelper
;
import
com.diaoyun.zion.master.util.TranslateHelper
;
import
com.diaoyun.zion.master.util.ValidateUtils
;
import
net.sf.json.JSONArray
;
import
net.sf.json.JSONArray
;
import
net.sf.json.JSONObject
;
import
net.sf.json.JSONObject
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -31,6 +32,7 @@ public class ZaraSpider implements IItemSpider {
...
@@ -31,6 +32,7 @@ public class ZaraSpider implements IItemSpider {
/**
/**
* Zara 数据爬虫
* Zara 数据爬虫
*
* @param targetUrl 接收的商品详情路径
* @param targetUrl 接收的商品详情路径
* @return 格式化与翻译后的 Json 数据
* @return 格式化与翻译后的 Json 数据
*/
*/
...
@@ -49,6 +51,7 @@ public class ZaraSpider implements IItemSpider {
...
@@ -49,6 +51,7 @@ public class ZaraSpider implements IItemSpider {
/**
/**
* 格式化 Zara 返回数据
* 格式化 Zara 返回数据
*
* @param dataMap 主要的 json 数据
* @param dataMap 主要的 json 数据
* @return 格式化后的数据
* @return 格式化后的数据
*/
*/
...
@@ -85,101 +88,110 @@ public class ZaraSpider implements IItemSpider {
...
@@ -85,101 +88,110 @@ public class ZaraSpider implements IItemSpider {
JSONArray
colorsArr
=
productObj
.
getJSONObject
(
"detail"
).
getJSONArray
(
"colors"
);
JSONArray
colorsArr
=
productObj
.
getJSONObject
(
"detail"
).
getJSONArray
(
"colors"
);
for
(
int
i
=
0
;
i
<
colorsArr
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
colorsArr
.
size
();
i
++)
{
JSONObject
colorsObj
=
colorsArr
.
getJSONObject
(
i
);
JSONObject
colorsObj
=
colorsArr
.
getJSONObject
(
i
);
// 取 detailImagesArr 节点数组第一个对象
// 取 detailImagesArr 节点数组第一个对象
JSONObject
detailImagesObj_0
=
colorsObj
.
getJSONArray
(
"detailImages"
).
getJSONObject
(
0
);
JSONObject
detailImagesObj_0
=
colorsObj
.
getJSONArray
(
"detailImages"
).
getJSONObject
(
0
);
String
color
=
colorsObj
.
getString
(
"name"
);
String
color
=
colorsObj
.
getString
(
"name"
);
String
imageUrl
=
"http://static.zara.cn/photos//"
+
detailImagesObj_0
.
getString
(
"path"
)
+
"w/1920/"
+
detailImagesObj_0
.
getString
(
"name"
)
+
"_1.jpg?ts="
+
detailImagesObj_0
.
getString
(
"timestamp"
);
if
(
i
==
0
)
{
itemInfo
.
setPic
(
imageUrl
);
}
//////////////////////////////////// 获取商品颜色属性 ////////////////////////////////////////////
if
(
ValidateUtils
.
isContainChinese
(
color
))
{
ProductProp
productPropColor
=
new
ProductProp
();
List
<
Map
<
String
,
Object
>>
futureList
=
new
ArrayList
<>();
productPropColor
.
setPropId
(
color
);
String
productSet
=
color
;
productPropColor
.
setPropName
(
color
);
if
(!
productSet
.
isEmpty
())
{
productPropColor
.
setImage
(
imageUrl
);
//调用腾讯ai,翻译color
propSet
.
add
(
productPropColor
);
String
s
=
TranslateHelper
.
translateProps
(
futureList
,
productSet
);
if
(
productPropSet
.
get
(
"Color"
)
==
null
)
{
color
=
s
;
productPropSet
.
put
(
"Color"
,
propSet
);
}
}
else
{
Set
<
ProductProp
>
oldPropSet
=
productPropSet
.
get
(
"Color"
);
propSet
.
addAll
(
oldPropSet
);
productPropSet
.
put
(
"Color"
,
propSet
);
}
}
//////////////////////////////////// 获取商品颜色属性 END ////////////////////////////////////////////
String
imageUrl
=
"http://static.zara.cn/photos//"
+
detailImagesObj_0
.
getString
(
"path"
)
// 取 sizes 节点数组
+
"w/1920/"
JSONArray
sizesArr
=
colorsArr
.
getJSONObject
(
i
).
getJSONArray
(
"sizes"
);
+
detailImagesObj_0
.
getString
(
"name"
)
for
(
int
j
=
0
;
j
<
sizesArr
.
size
();
j
++)
{
+
"_1.jpg?ts="
JSONObject
sizesObj
=
sizesArr
.
getJSONObject
(
j
);
+
detailImagesObj_0
.
getString
(
"timestamp"
);
if
(
i
==
0
)
{
itemInfo
.
setPic
(
imageUrl
);
}
///////////////////////// 获取商品尺码属性 ////////////////////
//////////////////////////////////// 获取商品颜色属性 ////////////////////////////////////////////
// String sizeNo = sizesObj.getString("sku");
ProductProp
productPropColor
=
new
ProductProp
();
String
size
=
sizesObj
.
getString
(
"name"
);
productPropColor
.
setPropId
(
color
);
String
[]
s
=
size
.
split
(
" "
);
productPropColor
.
setPropName
(
color
);
size
=
s
[
0
];
productPropColor
.
setImage
(
imageUrl
);
propSet
.
add
(
productPropColor
);
ProductProp
productPropSize
=
new
ProductProp
();
if
(
productPropSet
.
get
(
"Color"
)
==
null
)
{
productPropSize
.
setPropId
(
size
);
productPropSet
.
put
(
"Color"
,
propSet
);
productPropSize
.
setPropName
(
size
);
sizePropSet
.
add
(
productPropSize
);
if
(
productPropSet
.
get
(
"Size"
)
==
null
)
{
productPropSet
.
put
(
"Size"
,
sizePropSet
);
}
else
{
}
else
{
Set
<
ProductProp
>
oldPropSet
=
productPropSet
.
get
(
"
Size
"
);
Set
<
ProductProp
>
oldPropSet
=
productPropSet
.
get
(
"
Color
"
);
sizeP
ropSet
.
addAll
(
oldPropSet
);
p
ropSet
.
addAll
(
oldPropSet
);
productPropSet
.
put
(
"
Size"
,
sizeP
ropSet
);
productPropSet
.
put
(
"
Color"
,
p
ropSet
);
}
}
/////////////////////////
获取商品尺码属性 END
////////////////////
/////////////////////////
/////////// 获取商品颜色属性 END ////////////////////////
////////////////////
// 库存对应的id(Zara 中以颜色id + 尺码id)
// 取 sizes 节点数组
String
skuStr
=
";"
+
color
+
";"
+
size
+
";"
;
JSONArray
sizesArr
=
colorsArr
.
getJSONObject
(
i
).
getJSONArray
(
"sizes"
);
for
(
int
j
=
0
;
j
<
sizesArr
.
size
();
j
++)
{
JSONObject
sizesObj
=
sizesArr
.
getJSONObject
(
j
);
//////////////////////////////////// 获取库存 ////////////////////////////////////////////
///////////////////////// 获取商品尺码属性 ////////////////////
if
(
productSkuStockList
==
null
)
{
// String sizeNo = sizesObj.getString("sku");
productSkuStockList
=
new
ArrayList
<>();
String
size
=
sizesObj
.
getString
(
"name"
);
String
[]
s
=
size
.
split
(
" "
);
size
=
s
[
0
];
ProductProp
productPropSize
=
new
ProductProp
();
productPropSize
.
setPropId
(
size
);
productPropSize
.
setPropName
(
size
);
sizePropSet
.
add
(
productPropSize
);
if
(
productPropSet
.
get
(
"Size"
)
==
null
)
{
productPropSet
.
put
(
"Size"
,
sizePropSet
);
}
else
{
Set
<
ProductProp
>
oldPropSet
=
productPropSet
.
get
(
"Size"
);
sizePropSet
.
addAll
(
oldPropSet
);
productPropSet
.
put
(
"Size"
,
sizePropSet
);
}
///////////////////////// 获取商品尺码属性 END////////////////////
// 库存对应的id(Zara 中以颜色id + 尺码id)
String
skuStr
=
";"
+
color
+
";"
+
size
+
";"
;
//////////////////////////////////// 获取库存 ////////////////////////////////////////////
if
(
productSkuStockList
==
null
)
{
productSkuStockList
=
new
ArrayList
<>();
}
ProductSkuStock
productSkuStock
=
new
ProductSkuStock
();
productSkuStock
.
setSkuStr
(
skuStr
);
productSkuStock
.
setSellableQuantity
(
999
);
productSkuStockList
.
add
(
productSkuStock
);
dynStock
.
setProductSkuStockList
(
productSkuStockList
);
//////////////////////////////////// 获取库存 END/////////////////////////////////////////
//////////////////////////////////// 获取原始价 //////////////////////////////////
String
fullPrice
=
sizesObj
.
getString
(
"price"
);
BigDecimal
priceOld
=
new
BigDecimal
(
fullPrice
);
BigDecimal
div
=
new
BigDecimal
(
"100"
);
BigDecimal
priceNew
=
priceOld
.
divide
(
div
,
2
,
BigDecimal
.
ROUND_DOWN
);
fullPrice
=
exchangeRate
(
priceNew
.
toString
());
OriginalPrice
originalPrice
=
new
OriginalPrice
();
originalPrice
.
setPrice
(
fullPrice
);
originalPrice
.
setSkuStr
(
skuStr
);
originalPriceList
.
add
(
originalPrice
);
productResponse
.
setPrice
(
fullPrice
);
productResponse
.
setSalePrice
(
fullPrice
+
"-"
+
fullPrice
);
//////////////////////////////////// 获取原始价 END//////////////////////////////////
}
}
ProductSkuStock
productSkuStock
=
new
ProductSkuStock
();
productSkuStock
.
setSkuStr
(
skuStr
);
productSkuStock
.
setSellableQuantity
(
999
);
productSkuStockList
.
add
(
productSkuStock
);
dynStock
.
setProductSkuStockList
(
productSkuStockList
);
//////////////////////////////////// 获取库存 END/////////////////////////////////////////
//////////////////////////////////// 获取原始价 //////////////////////////////////
String
fullPrice
=
sizesObj
.
getString
(
"price"
);
BigDecimal
priceOld
=
new
BigDecimal
(
fullPrice
);
BigDecimal
div
=
new
BigDecimal
(
"100"
);
BigDecimal
priceNew
=
priceOld
.
divide
(
div
,
2
,
BigDecimal
.
ROUND_DOWN
);
fullPrice
=
exchangeRate
(
priceNew
.
toString
());
OriginalPrice
originalPrice
=
new
OriginalPrice
();
originalPrice
.
setPrice
(
fullPrice
);
originalPrice
.
setSkuStr
(
skuStr
);
originalPriceList
.
add
(
originalPrice
);
productResponse
.
setPrice
(
fullPrice
);
productResponse
.
setSalePrice
(
fullPrice
+
"-"
+
fullPrice
);
//////////////////////////////////// 获取原始价 END//////////////////////////////////
}
}
}
// 按照一下顺序进行 json 数据的填充
// 按照一下顺序进行 json 数据的填充
productResponse
.
setProductPropSet
(
productPropSet
);
productResponse
.
setProductPropSet
(
productPropSet
);
productResponse
.
setPlatform
(
"Zara"
);
productResponse
.
setPlatform
(
"Zara"
);
productResponse
.
setPromotionList
(
promotionList
);
productResponse
.
setPromotionList
(
promotionList
);
productResponse
.
setOriginalPriceList
(
originalPriceList
);
productResponse
.
setOriginalPriceList
(
originalPriceList
);
productResponse
.
setItemInfo
(
itemInfo
);
productResponse
.
setItemInfo
(
itemInfo
);
productResponse
.
setDynStock
(
dynStock
);
productResponse
.
setDynStock
(
dynStock
);
return
productResponse
;
return
productResponse
;
}
}
}
}
\ No newline at end of file
src/main/java/com/diaoyun/zion/chinafrica/entity/TbCfItemShippedEntity.java
浏览文件 @
f1db8cfe
...
@@ -59,6 +59,7 @@ public class TbCfItemShippedEntity implements Serializable {
...
@@ -59,6 +59,7 @@ public class TbCfItemShippedEntity implements Serializable {
* 商品品名
* 商品品名
*/
*/
private
String
descripition
;
private
String
descripition
;
private
String
descripitionId
;
public
static
long
getSerialVersionUID
()
{
public
static
long
getSerialVersionUID
()
{
return
serialVersionUID
;
return
serialVersionUID
;
...
@@ -183,4 +184,12 @@ public class TbCfItemShippedEntity implements Serializable {
...
@@ -183,4 +184,12 @@ public class TbCfItemShippedEntity implements Serializable {
public
void
setDescripition
(
String
descripition
)
{
public
void
setDescripition
(
String
descripition
)
{
this
.
descripition
=
descripition
;
this
.
descripition
=
descripition
;
}
}
public
String
getDescripitionId
()
{
return
descripitionId
;
}
public
void
setDescripitionId
(
String
descripitionId
)
{
this
.
descripitionId
=
descripitionId
;
}
}
}
src/main/java/com/diaoyun/zion/chinafrica/service/TbCfOrderService.java
浏览文件 @
f1db8cfe
...
@@ -177,4 +177,6 @@ public interface TbCfOrderService {
...
@@ -177,4 +177,6 @@ public interface TbCfOrderService {
Result
rePayForOrder
(
String
orderId
);
Result
rePayForOrder
(
String
orderId
);
Result
currencyConversion
(
String
price
,
String
currency
);
Result
currencyConversion
(
String
price
,
String
currency
);
Result
getDeliveryLists
(
long
beginTime
,
long
endTime
,
Integer
pageNum
,
Integer
pageSize
);
}
}
src/main/java/com/diaoyun/zion/chinafrica/service/impl/TbCfOrderServiceImpl.java
浏览文件 @
f1db8cfe
...
@@ -517,6 +517,26 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
...
@@ -517,6 +517,26 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
return
result
;
return
result
;
}
}
@Override
public
Result
getDeliveryLists
(
long
beginTime
,
long
endTime
,
Integer
pageNum
,
Integer
pageSize
)
{
Result
result
=
new
Result
<>();
if
((
endTime
-
beginTime
)
>
31
*
24
*
60
*
60
)
{
result
.
setCode
(
ResultCodeEnum
.
ERROR
.
getCode
()).
setMessage
(
"Time interval is too long"
);
}
else
{
startPage
(
pageNum
,
pageSize
);
Date
beginDate
=
new
Date
(
beginTime
*
1000
);
Date
endDate
=
new
Date
(
endTime
*
1000
);
List
<
TbCfItemShippedEntity
>
orderList
=
tbCfOrderDao
.
getDeliveryList
(
beginDate
,
endDate
);
// TODO 暂设为赞比亚
for
(
TbCfItemShippedEntity
list
:
orderList
)
{
list
.
setCountry
(
"赞比亚"
);
}
PageInfo
<
TbCfItemShippedEntity
>
pageInfo
=
new
PageInfo
<>(
orderList
);
result
.
setData
(
pageInfo
);
}
return
result
;
}
/**
/**
* 记录财务流水
* 记录财务流水
...
...
src/main/java/com/diaoyun/zion/master/util/TranslateHelper.java
浏览文件 @
f1db8cfe
...
@@ -96,7 +96,14 @@ public class TranslateHelper {
...
@@ -96,7 +96,14 @@ public class TranslateHelper {
}
}
// TODO productPropSetMap.put("translateArray",translateArray);
// TODO productPropSetMap.put("translateArray",translateArray);
}
}
public
static
String
translateProps
(
List
<
Map
<
String
,
Object
>>
futureList
,
String
productSet
)
throws
InterruptedException
,
ExecutionException
,
TimeoutException
{
Map
<
String
,
Object
>
valMap
=
new
HashMap
<>();
if
(
ValidateUtils
.
isContainChinese
(
productSet
))
{
TranslateHelper
.
translateText
(
futureList
,
valMap
,
productSet
);
TranslateHelper
.
waitForResult
(
futureList
);
}
return
String
.
valueOf
(
valMap
.
get
(
"translate"
));
}
/**
/**
* 翻译爬取回来的数据
* 翻译爬取回来的数据
*
*
...
@@ -137,4 +144,5 @@ public class TranslateHelper {
...
@@ -137,4 +144,5 @@ public class TranslateHelper {
resultObj
.
put
(
"productPropSet"
,
productPropSet
);
resultObj
.
put
(
"productPropSet"
,
productPropSet
);
//////////////////////翻译 END//////////////////////
//////////////////////翻译 END//////////////////////
}
}
}
}
src/main/resources/mapper/TbCfOrderDao.xml
浏览文件 @
f1db8cfe
...
@@ -346,8 +346,30 @@
...
@@ -346,8 +346,30 @@
and deal_time
<![CDATA[ >= ]]>
#{beginDate} and deal_time
<![CDATA[ < ]]>
#{endDate}
and deal_time
<![CDATA[ >= ]]>
#{beginDate} and deal_time
<![CDATA[ < ]]>
#{endDate}
</select>
</select>
<!--获取某段时间已发货订单数据-->
<select
id=
"getDeliveryList"
resultType=
"com.diaoyun.zion.chinafrica.entity.TbCfItemShippedEntity"
>
<select
id=
"getDeliveryList"
resultType=
"com.diaoyun.zion.chinafrica.entity.TbCfItemShippedEntity"
>
select
DISTINCT
r.order_item_id orderId,
o.delivery_name deliveryName,
o.delivery_address deliveryAddress,
o.user_id userId,
p.p_express_number expressId,
i.item_id itemId,
i.item_num itemNum,
a.address_country_name country,
p.descripition_id
from tb_cf_order o
INNER JOIN tb_cf_item_order_r r on r.order_id=o.order_id
INNER JOIN tb_cf_platform_order p on r.order_item_id=p.relative_id
INNER JOIN tb_cf_item_detail i on r.item_id=i.item_id
INNER JOIN tb_cf_address a on a.user_id=o.user_id
INNER JOIN tb_cf_user_info u on u.user_id=o.user_id
INNER JOIN tb_cf_express_template e on e.template_id=p.descripition_id
where r.delivery_flag=10 and r.enable_flag=1 and r.order_status=40
and p.create_time
<![CDATA[ >= ]]>
#{beginDate} and p.create_time
<![CDATA[ < ]]>
#{endDate}
</select>
<!--获取某段时间已发货订单数据-->
<select
id=
"getDeliveryLists"
resultType=
"com.diaoyun.zion.chinafrica.entity.TbCfItemShippedEntity"
>
select
select
DISTINCT
DISTINCT
r.order_item_id orderId,
r.order_item_id orderId,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论