Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
Z
zion
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
zhengfg
zion
Commits
d6441d78
提交
d6441d78
authored
10月 17, 2019
作者:
zhengfg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1、商品价格人民币换成美元
上级
9f0148fb
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
45 行增加
和
14 行删除
+45
-14
TbCfOrderServiceImpl.java
...un/zion/chinafrica/service/impl/TbCfOrderServiceImpl.java
+6
-10
SpiderUtil.java
src/main/java/com/diaoyun/zion/master/util/SpiderUtil.java
+39
-4
没有找到文件。
src/main/java/com/diaoyun/zion/chinafrica/service/impl/TbCfOrderServiceImpl.java
浏览文件 @
d6441d78
...
...
@@ -569,7 +569,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
* @throws IOException
* @throws URISyntaxException
*/
private
TbCfOrderVo
ensureOrder
(
TbCfUserInfoVo
tbCfUserInfoVo
,
TbCfOrderVo
pageOrder
,
List
<
TbCfCartItemDetailVo
>
tbCfCartItemDetailList
)
throws
IOException
,
URISyntaxException
,
ExecutionException
,
InterruptedException
,
TimeoutException
{
private
TbCfOrderVo
ensureOrder
(
TbCfUserInfoVo
tbCfUserInfoVo
,
TbCfOrderVo
pageOrder
,
List
<
TbCfCartItemDetailVo
>
tbCfCartItemDetailList
)
{
TbCfOrderVo
definiteOrder
=
getGenericOrder
(
tbCfCartItemDetailList
);
//获取可以使用的优惠券,后续还有判断此订单是否可以使用
List
<
TbCfCouponEntity
>
tbCfCouponList
=
tbCfCouponDao
.
queryUserAvailableCoupon
(
tbCfUserInfoVo
.
getUserId
(),
new
Date
());
...
...
@@ -622,8 +622,8 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
*
* @return
*/
private
TbCfOrderVo
getGenericOrder
(
List
<
TbCfCartItemDetailVo
>
tbCfCartItemDetailList
)
throws
IOException
,
URISyntaxException
,
ExecutionException
,
InterruptedException
,
TimeoutException
{
TbCfFeeEntity
feeEntity
=
tbCfFeeService
.
getRateFee
();
private
TbCfOrderVo
getGenericOrder
(
List
<
TbCfCartItemDetailVo
>
tbCfCartItemDetailList
)
{
TbCfOrderVo
genericOrder
=
new
TbCfOrderVo
();
genericOrder
.
setItemDetailList
(
tbCfCartItemDetailList
);
//初始商品总价
...
...
@@ -631,19 +631,14 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
BigDecimal
totalExpressCost
=
BigDecimal
.
ZERO
;
for
(
TbCfCartItemDetailVo
tbCfCartItemDetailVo
:
tbCfCartItemDetailList
)
{
BigDecimal
itemNum
=
BigDecimal
.
valueOf
(
tbCfCartItemDetailVo
.
getItemNum
());
itemsPrice
=
itemsPrice
.
add
(
tbCfCartItemDetailVo
.
getItemPrice
().
multiply
(
itemNum
));
BigDecimal
itemSourcePrice
=
tbCfCartItemDetailVo
.
getItemPrice
();
itemsPrice
=
itemsPrice
.
add
(
itemSourcePrice
.
multiply
(
itemNum
));
//计算运费
BigDecimal
expressCost
=
getExpressTemplate
(
tbCfCartItemDetailVo
.
getItemCategory
());
expressCost
=
expressCost
.
multiply
(
itemNum
);
totalExpressCost
=
totalExpressCost
.
add
(
expressCost
);
}
/*获取人民币汇率 1美元换取人民币
*TODO 汇率接口出问题,暂设置为1(暂时先不用爬虫爬区汇率,用后台手续费设置的汇率)
*暂时从后台获取人工设置的汇率
* */
BigDecimal
rate
=
feeEntity
.
getFeeRate
();
//spiderService.getExchangeRate(null);
itemsPrice
=
itemsPrice
.
divide
(
rate
,
2
,
BigDecimal
.
ROUND_UP
);
//计算手续费
BigDecimal
fee
=
countFee
(
itemsPrice
);
//税费
...
...
@@ -658,6 +653,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
return
genericOrder
;
}
/**
* 获取运费 TODO 运费模板可改为缓存
*
...
...
src/main/java/com/diaoyun/zion/master/util/SpiderUtil.java
浏览文件 @
d6441d78
package
com
.
diaoyun
.
zion
.
master
.
util
;
import
com.diaoyun.zion.chinafrica.constant.KeyConstant
;
import
com.diaoyun.zion.chinafrica.entity.TbCfFeeEntity
;
import
com.diaoyun.zion.chinafrica.enums.PlatformEnum
;
import
com.diaoyun.zion.chinafrica.service.TbCfFeeService
;
import
com.diaoyun.zion.chinafrica.vo.*
;
import
net.sf.json.JSONArray
;
import
net.sf.json.JSONObject
;
import
org.apache.commons.lang3.StringUtils
;
import
java.math.BigDecimal
;
import
java.util.*
;
public
class
SpiderUtil
{
private
static
BigDecimal
rate
;
static
{
TbCfFeeService
tbCfFeeService
=
(
TbCfFeeService
)
SpringContextUtil
.
getBean
(
"tbCfFeeService"
);
rate
=
tbCfFeeService
.
getRateFee
().
getFeeRate
();
}
/**
* 格式化 gap 返回数据
...
...
@@ -43,14 +52,21 @@ public class SpiderUtil {
//原始价格
OriginalPrice
originalPrice
=
new
OriginalPrice
();
originalPrice
.
setSkuStr
(
skuStr
);
originalPrice
.
setPrice
(
skuValue
.
getString
(
"listPrice"
));
String
listPrice
=
skuValue
.
getString
(
"listPrice"
);
//转换汇率
listPrice
=
exchangeRate
(
listPrice
);
originalPrice
.
setPrice
(
listPrice
);
originalPriceList
.
add
(
originalPrice
);
//促销价格
if
(
StringUtils
.
isNotBlank
(
skuValue
.
getString
(
"salePrice"
)))
{
String
salePrice
=
skuValue
.
getString
(
"salePrice"
);
//转换汇率
salePrice
=
exchangeRate
(
salePrice
);
productResponse
.
setPromotionFlag
(
true
);
ProductPromotion
productPromotion
=
new
ProductPromotion
();
productPromotion
.
setSkuStr
(
skuStr
);
productPromotion
.
setPrice
(
s
kuValue
.
getString
(
"salePrice"
)
);
productPromotion
.
setPrice
(
s
alePrice
);
promotionList
.
add
(
productPromotion
);
}
...
...
@@ -102,11 +118,16 @@ public class SpiderUtil {
}
String
minPrice
=
dataMap
.
getString
(
"minPrice"
);
String
maxPrice
=
dataMap
.
getString
(
"maxPrice"
);
//转换汇率
minPrice
=
exchangeRate
(
minPrice
);
maxPrice
=
exchangeRate
(
maxPrice
);
//一口价
productResponse
.
setPrice
(
dataMap
.
getString
(
"minPrice"
)
+
"-"
+
dataMap
.
getString
(
"maxPrice"
)
);
productResponse
.
setPrice
(
minPrice
+
"-"
+
maxPrice
);
//一口价
productResponse
.
setSalePrice
(
dataMap
.
getString
(
"minPrice"
)
+
"-"
+
dataMap
.
getString
(
"maxPrice"
)
);
productResponse
.
setSalePrice
(
minPrice
+
"-"
+
maxPrice
);
//没有库存信息 需要另外获取
productResponse
.
setStockFlag
(
false
);
//有商品属性
...
...
@@ -126,6 +147,7 @@ public class SpiderUtil {
* @return
*/
public
static
ProductResponse
formatNikeProductResponse
(
JSONObject
dataMap
)
{
ProductResponse
productResponse
=
new
ProductResponse
();
//nike 基本是 颜色、尺码属性
Map
<
String
,
Set
<
ProductProp
>>
productPropSet
=
new
HashMap
<>();
...
...
@@ -151,7 +173,11 @@ public class SpiderUtil {
JSONObject
itemDetail
=
entry
.
getValue
();
////////////////////////////////////获取价格和商品属性////////////////////////////////////////////
String
fullPrice
=
itemDetail
.
getString
(
"fullPrice"
);
//转换汇率
fullPrice
=
exchangeRate
(
fullPrice
);
String
currentPrice
=
itemDetail
.
getString
(
"currentPrice"
);
//转换汇率
currentPrice
=
exchangeRate
(
currentPrice
);
productResponse
.
setPrice
(
currentPrice
);
JSONArray
skusArr
=
itemDetail
.
getJSONArray
(
"skus"
);
//获取商品尺码属性,同时记录下skuid和尺码关系
...
...
@@ -264,6 +290,15 @@ public class SpiderUtil {
return
productResponse
;
}
//转换汇率
private
static
String
exchangeRate
(
String
fullPrice
)
{
/*获取人民币汇率 1美元换取人民币
*TODO 同步汇率问题
*暂时从后台获取人工设置的汇率
* */
return
new
BigDecimal
(
fullPrice
).
divide
(
rate
,
2
,
BigDecimal
.
ROUND_UP
).
toString
();
}
/**
* 格式化 afric-eshop 返回数据
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论