提交 d6441d78 authored 作者: zhengfg's avatar zhengfg

1、商品价格人民币换成美元

上级 9f0148fb
......@@ -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 运费模板可改为缓存
*
......
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(skuValue.getString("salePrice"));
productPromotion.setPrice(salePrice);
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论