提交 0818a63b authored 作者: 梁业锦's avatar 梁业锦 💬

Merge branch 'master' of http://code.diaosaas.com/zhengfg/zion

 Conflicts:
	src/main/java/com/diaoyun/zion/chinafrica/service/impl/SpiderServiceImpl.java
package com.diaoyun.zion.chinafrica.bis.impl;
import com.diaoyun.zion.chinafrica.bis.IItemSpider;
import com.diaoyun.zion.chinafrica.enums.PlatformEnum;
import com.diaoyun.zion.chinafrica.vo.ProductResponse;
import com.diaoyun.zion.master.util.HttpClientUtil;
import com.diaoyun.zion.master.util.JsoupUtil;
import com.diaoyun.zion.master.util.SpiderUtil;
import com.diaoyun.zion.master.util.TranslateHelper;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
/**
* afri-eshop 数据爬虫
*/
@Component("africaShopItemSpider")
public class AfricaShopItemSpider implements IItemSpider {
private static Logger logger = LoggerFactory.getLogger(AfricaShopItemSpider.class);
@Override
public JSONObject captureItem(String targetUrl) throws URISyntaxException, IOException, InterruptedException, ExecutionException, TimeoutException {
JSONObject resultObj;
//获取url中的网页内容 >
String content = HttpClientUtil.getContentByUrl(targetUrl, PlatformEnum.AfriEshop.getValue());
//获取商品相关信息,详情放在<script> 标签里 <script type="application/json" id="ProductJson-product-template">
resultObj = JsoupUtil.getScriptContentById(content, "ProductJson-product-template");
//格式化为封装数据
ProductResponse productResponse = SpiderUtil.formatAfricaShopProductResponse(resultObj);
resultObj = JSONObject.fromObject(productResponse);
//翻译
TranslateHelper.translateProductResponse(resultObj);
return resultObj;
}
}
package com.diaoyun.zion.chinafrica.bis.impl;
import com.diaoyun.zion.chinafrica.bis.IItemSpider;
import com.diaoyun.zion.chinafrica.enums.PlatformEnum;
import com.diaoyun.zion.chinafrica.vo.ProductResponse;
import com.diaoyun.zion.master.util.*;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.http.message.BasicHeader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
......@@ -34,7 +24,7 @@ public class GapItemSpider implements IItemSpider {
private static final String gapUrl="https://apicn.gap.cn/gap/store/product/list/searchProductByCondition.do";
@Override
public JSONObject captureItem(String targetUrl) throws URISyntaxException, IOException, ExecutionException, InterruptedException, TimeoutException {
public JSONObject captureItem(String targetUrl) throws IOException, InterruptedException, ExecutionException, TimeoutException {
JSONObject resultObj;
//获取链接中的商品spuCode
String itemId= getItemId(targetUrl);
......@@ -56,11 +46,16 @@ public class GapItemSpider implements IItemSpider {
//格式化为封装数据
ProductResponse productResponse = SpiderUtil.formatGapProductResponse(resultObj.getJSONObject("data"));
resultObj=JSONObject.fromObject(productResponse);
//翻译
TranslateHelper.translateProductResponse(resultObj);
}
return resultObj;
}
private String getItemId(String targetUrl) {
String spuCode=targetUrl.substring(targetUrl.lastIndexOf("/")+1);
int firstUnder=spuCode.indexOf("_");
......
......@@ -4,30 +4,26 @@ import com.diaoyun.zion.chinafrica.bis.IItemSpider;
import com.diaoyun.zion.chinafrica.enums.PlatformEnum;
import com.diaoyun.zion.chinafrica.vo.ProductResponse;
import com.diaoyun.zion.master.util.*;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
/**
* Gap数据爬虫
* nike数据爬虫
*/
@Component("nikeItemSpider")
public class NikeItemSpider implements IItemSpider {
private static Logger logger = LoggerFactory.getLogger(NikeItemSpider.class);
@Override
public JSONObject captureItem(String targetUrl) throws URISyntaxException, IOException, ExecutionException, InterruptedException, TimeoutException {
public JSONObject captureItem(String targetUrl) throws URISyntaxException, IOException, InterruptedException, ExecutionException, TimeoutException {
JSONObject resultObj;
//获取url中的网页内容 >
String content = HttpClientUtil.getContentByUrl(targetUrl, PlatformEnum.NIKE.getValue());
......@@ -36,6 +32,8 @@ public class NikeItemSpider implements IItemSpider {
//格式化为封装数据
ProductResponse productResponse = SpiderUtil.formatNikeProductResponse(resultObj);
resultObj = JSONObject.fromObject(productResponse);
//翻译
TranslateHelper.translateProductResponse(resultObj);
return resultObj;
}
......
......@@ -2,9 +2,6 @@ package com.diaoyun.zion.chinafrica.bis.impl;
import com.diaoyun.zion.chinafrica.bis.IItemSpider;
import com.diaoyun.zion.chinafrica.enums.PlatformEnum;
import com.diaoyun.zion.master.bo.TencentTranslateParam;
import com.diaoyun.zion.master.thread.TaskLimitSemaphore;
import com.diaoyun.zion.master.thread.TranslateCallable;
import com.diaoyun.zion.master.util.HttpClientUtil;
import com.diaoyun.zion.master.util.JsoupUtil;
import com.diaoyun.zion.master.util.TranslateHelper;
......@@ -12,28 +9,17 @@ import com.diaoyun.zion.master.util.ValidateUtils;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.message.BasicHeader;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeoutException;
/**
......@@ -102,7 +88,7 @@ public class TbItemSpider implements IItemSpider {
* @throws ExecutionException
* @throws InterruptedException
*/
private void translateProp(List<Map<String, Object>> futureList,Map<String, Object> propMap) throws ExecutionException, InterruptedException {
private void translateProp(List<Map<String, Object>> futureList,Map<String, Object> propMap) {
/*腾讯翻译*/
for(Map.Entry<String,Object>entry : propMap.entrySet()) {
String key=entry.getKey();
......@@ -124,7 +110,7 @@ public class TbItemSpider implements IItemSpider {
* @throws ExecutionException
* @throws InterruptedException
*/
private void translateTitle(List<Map<String, Object>> futureList,Map<String, Object> skuMap) throws ExecutionException, InterruptedException {
private void translateTitle(List<Map<String, Object>> futureList,Map<String, Object> skuMap) {
for(Map.Entry<String,Object>entry : skuMap.entrySet()) {
String key=entry.getKey();
if(entry.getValue() instanceof Map) {
......
......@@ -42,7 +42,9 @@ public class TokenVerification {
"&&!execution(* com.diaoyun.zion.chinafrica.controller.TbCfHomePageController.*(..))" +
"&&!execution(* com.diaoyun.zion.chinafrica.controller.TbCfUserInfoController.resetPassWord(..))" +
"&&!execution(* com.diaoyun.zion.chinafrica.controller.TbCfFeedbackController.getFeedbackList(..))" +
"&&!execution(* com.diaoyun.zion.chinafrica.controller.TbCfUserInfoController.getUserIdentifyCode(..))")
"&&!execution(* com.diaoyun.zion.chinafrica.controller.TbCfUserInfoController.getUserIdentifyCode(..))"+
"&&!execution(* com.diaoyun.zion.chinafrica.controller.GoodsTypeController.*(..))"+
"&&!execution(* com.diaoyun.zion.chinafrica.controller.TbCfFeeController.*(..))")
public void controllerAspect() {
}
......
package com.diaoyun.zion.chinafrica.controller;
import com.diaoyun.zion.chinafrica.entity.TbCfGoodstypeEntity;
import com.diaoyun.zion.chinafrica.entity.TbCfStationItemEntity;
import com.diaoyun.zion.chinafrica.service.TbCfGoodstypeService;
import com.diaoyun.zion.chinafrica.service.TbCfStationItemService;
import com.diaoyun.zion.chinafrica.vo.StationToGoodsType;
import com.diaoyun.zion.chinafrica.vo.TbCfOrderVo;
import com.diaoyun.zion.master.base.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.Collections;
import java.util.HashMap;
import java.util.*;
import java.util.Map;
@RestController
@RequestMapping("/goodsType")
public class GoodsTypeController {
private static Logger logger = LoggerFactory.getLogger(LoginController.class);
@Autowired
private HttpServletRequest request; //自动注入request
@Autowired
private TbCfGoodstypeService tbCfGoodstypeService;
@Autowired
private TbCfStationItemService tbCfStationItemService;
@RequestMapping("/getGoodsTypeList")
@GetMapping
public Map<String,List<StationToGoodsType>> getGoodsTypeList() {
Map<String,List<StationToGoodsType>> map = new HashMap<>();
List<StationToGoodsType> listStation = new ArrayList<StationToGoodsType>();
List<TbCfGoodstypeEntity> list = tbCfGoodstypeService.queryList(null);
for (TbCfGoodstypeEntity goods:list) {
StationToGoodsType goodsType = new StationToGoodsType();
goodsType.setCategoryId(goods.getGoodstypeId());
goodsType.setGoodstypetitle(goods.getGoodstypeTitle());
List<TbCfStationItemEntity> station = tbCfStationItemService.getGoodsTypeList(goods.getGoodstypeId());
goodsType.setStationlist(station);
listStation.add(goodsType);
}
map.put("data",listStation);
return map;
}
@RequestMapping("/getItemStationList")
@GetMapping
public Result getItemStationList(@RequestParam(required = false) Integer pageNum,
@RequestParam(required = false) Integer pageSize,
@RequestParam(required = false) String categoryId) {
if (pageNum == null) {
pageNum = 1;
}
if (pageSize == null) {
pageSize = 6;
}
return tbCfStationItemService.getItemStationList(pageNum,pageSize,categoryId);
}
}
package com.diaoyun.zion.chinafrica.controller;
import com.diaoyun.zion.chinafrica.entity.TbCfFeeEntity;
import com.diaoyun.zion.chinafrica.service.TbCfFeeService;
import com.diaoyun.zion.master.base.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Map;
/**
* 手续费Controller
*/
@RestController
@RequestMapping("fee")
public class TbCfFeeController {
@Autowired
private TbCfFeeService tbCfFeeService;
/**
* 查看所有运费模板
*/
@GetMapping("/getRate")
public Result getRate(Double price) {
TbCfFeeEntity fee = tbCfFeeService.getRateFee();
BigDecimal rate = fee.getFeeRate();
BigDecimal prices = new BigDecimal(price);
BigDecimal sum = prices.divide(rate,4,RoundingMode.HALF_UP);
return new Result<>(sum);
}
}
......@@ -24,7 +24,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
public class TbCfStationItemController {
@Autowired
private TbCfStationItemService tbCfStationItemService;
/*
@ApiOperation("获取商品独立站")
@GetMapping
public Result getItemStationList(@ApiParam(value = "页数 默认1") @RequestParam(required = false) Integer pageNum,
......@@ -33,9 +33,9 @@ public class TbCfStationItemController {
pageNum = 1;
}
if (pageSize == null) {
pageSize = 10;
pageSize = 2;
}
return tbCfStationItemService.getItemStationList(pageNum,pageSize);
}
}*/
}
......@@ -15,4 +15,10 @@ public interface TbCfFeeDao extends BaseDao<TbCfFeeEntity> {
* @return
*/
TbCfFeeEntity getAvailableFee();
/**
* 获取当前后台人民币转成美元设置
* @return
*/
TbCfFeeEntity getRateFee();
}
package com.diaoyun.zion.chinafrica.dao;
import com.diaoyun.zion.chinafrica.entity.TbCfGoodstypeEntity;
import com.diaoyun.zion.master.dao.BaseDao;
/**
* Dao
*
* @author lipengjun
* @date 2019-10-08 16:34:40
*/
public interface TbCfGoodstypeDao extends BaseDao<TbCfGoodstypeEntity> {
}
......@@ -18,5 +18,12 @@ public interface TbCfStationItemDao extends BaseDao<TbCfStationItemEntity> {
* 获取商品独立站
* @return
*/
List<TbCfStationItemEntity> getItemStationList();
List<TbCfStationItemEntity> getItemStationList(String categoryId);
/**
* 根据主键一级分类实体集合
*
* @return List集合
*/
List<TbCfStationItemEntity> getGoodsTypeList(String categoryId);
}
......@@ -8,8 +8,8 @@ import java.util.Date;
* 手续费实体
* 表名 tb_cf_fee
*
* @author G
* @date 2019-08-14 09:11:48
* @author LHB
* @date 2019-10-13 16:18:55
*/
public class TbCfFeeEntity implements Serializable {
private static final long serialVersionUID = 1L;
......@@ -19,17 +19,21 @@ public class TbCfFeeEntity implements Serializable {
*/
private String feeId;
/**
* 收费类型
* 收费类型,1为百分比,目前只有一种收费方式
*/
private Integer feeType;
/**
* 是否生效
* 是否生效标志
*/
private Integer enableFlag;
/**
* 收取费用百分比
*/
private BigDecimal feePercent;
/**
* 设置美元转换
*/
private BigDecimal feeRate;
/**
* 设置:收费id
......@@ -45,27 +49,27 @@ public class TbCfFeeEntity implements Serializable {
return feeId;
}
/**
* 设置:收费类型
* 设置:收费类型,1为百分比,目前只有一种收费方式
*/
public void setFeeType(Integer feeType) {
this.feeType = feeType;
}
/**
* 获取:收费类型
* 获取:收费类型,1为百分比,目前只有一种收费方式
*/
public Integer getFeeType() {
return feeType;
}
/**
* 设置:是否生效
* 设置:是否生效标志
*/
public void setEnableFlag(Integer enableFlag) {
this.enableFlag = enableFlag;
}
/**
* 获取:是否生效
* 获取:是否生效标志
*/
public Integer getEnableFlag() {
return enableFlag;
......@@ -80,7 +84,21 @@ public class TbCfFeeEntity implements Serializable {
/**
* 获取:收取费用百分比
*/
public BigDecimal getFeePercent() {
return feePercent;
}
/**
* 设置:设置美元转换
*/
public void setFeeRate(BigDecimal feeRate) {
this.feeRate = feeRate;
}
/**
* 获取:设置美元转换
*/
public BigDecimal getFeeRate() {
return feeRate;
}
}
package com.diaoyun.zion.chinafrica.entity;
import java.io.Serializable;
import java.util.Date;
/**
* 实体
* 表名 tb_cf_goodstype
*
* @author lipengjun
* @date 2019-10-08 16:34:40
*/
public class TbCfGoodstypeEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 商品分类Id
*/
private String goodstypeId;
/**
* 商品分类标题
*/
private String goodstypeTitle;
/**
* 商品分类排序编号
*/
private Integer goodstypeSort;
/**
* 设置:商品分类Id
*/
public void setGoodstypeId(String goodstypeId) {
this.goodstypeId = goodstypeId;
}
/**
* 获取:商品分类Id
*/
public String getGoodstypeId() {
return goodstypeId;
}
/**
* 设置:商品分类标题
*/
public void setGoodstypeTitle(String goodstypeTitle) {
this.goodstypeTitle = goodstypeTitle;
}
/**
* 获取:商品分类标题
*/
public String getGoodstypeTitle() {
return goodstypeTitle;
}
/**
* 设置:商品分类排序编号
*/
public void setGoodstypeSort(Integer goodstypeSort) {
this.goodstypeSort = goodstypeSort;
}
/**
* 获取:商品分类排序编号
*/
public Integer getGoodstypeSort() {
return goodstypeSort;
}
}
......@@ -17,7 +17,8 @@ public enum PlatformEnum implements EnumItemable<PlatformEnum> {
ZARA("Zara", "zara"),
UNIQLO("优衣库", "uniqlo"),
NIKE("NIKE", "nike"),
UN("未知", "un");
UN("未知", "un"),
AfriEshop("afri-eshop","afri-eshop" );
private String label;
private String value;
......
......@@ -40,6 +40,10 @@ public class ItemSpiderFactory {
iItemSpider= (IItemSpider) SpringContextUtil.getBean("nikeItemSpider");
break;
}
case "afri-eshop":{
iItemSpider= (IItemSpider) SpringContextUtil.getBean("africaShopItemSpider");
break;
}
default:{
iItemSpider= (IItemSpider) SpringContextUtil.getBean("emptyItemSpider");
break;
......
......@@ -74,4 +74,10 @@ public interface TbCfFeeService {
* @return
*/
TbCfFeeEntity getAvailableFee();
/**
* 获取当前生效的人民币转成美元设置
* @return
*/
TbCfFeeEntity getRateFee();
}
package com.diaoyun.zion.chinafrica.service;
import com.diaoyun.zion.chinafrica.entity.TbCfGoodstypeEntity;
import java.util.List;
import java.util.Map;
/**
* Service接口
*
* @author lipengjun
* @date 2019-10-08 16:34:40
*/
public interface TbCfGoodstypeService {
/**
* 根据主键查询实体
*
* @param id 主键
* @return 实体
*/
TbCfGoodstypeEntity queryObject(String goodstypeId);
/**
* 分页查询
*
* @param map 参数
* @return list
*/
List<TbCfGoodstypeEntity> queryList(Map<String, Object> map);
/**
* 分页统计总数
*
* @param map 参数
* @return 总数
*/
int queryTotal(Map<String, Object> map);
/**
* 保存实体
*
* @param tbCfGoodstype 实体
* @return 保存条数
*/
int save(TbCfGoodstypeEntity tbCfGoodstype);
/**
* 根据主键更新实体
*
* @param tbCfGoodstype 实体
* @return 更新条数
*/
int update(TbCfGoodstypeEntity tbCfGoodstype);
/**
* 根据主键删除
*
* @param goodstypeId
* @return 删除条数
*/
int delete(String goodstypeId);
/**
* 根据主键批量删除
*
* @param goodstypeIds
* @return 删除条数
*/
int deleteBatch(String[] goodstypeIds);
}
package com.diaoyun.zion.chinafrica.service;
import com.diaoyun.zion.chinafrica.dao.TbCfGoodstypeDao;
import com.diaoyun.zion.chinafrica.entity.TbCfGoodstypeEntity;
import com.diaoyun.zion.master.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* Service实现类
*
* @author lipengjun
* @date 2019-10-08 16:34:40
*/
@Service("tbCfGoodstypeService")
public class TbCfGoodstypeServiceImpl implements TbCfGoodstypeService {
@Autowired
private TbCfGoodstypeDao tbCfGoodstypeDao;
@Override
public TbCfGoodstypeEntity queryObject(String goodstypeId) {
return tbCfGoodstypeDao.queryObject(goodstypeId);
}
@Override
public List<TbCfGoodstypeEntity> queryList(Map<String, Object> map) {
return tbCfGoodstypeDao.queryList(map);
}
@Override
public int queryTotal(Map<String, Object> map) {
return tbCfGoodstypeDao.queryTotal(map);
}
@Override
public int save(TbCfGoodstypeEntity tbCfGoodstype) {
tbCfGoodstype.setGoodstypeId(IdUtil.createIdbyUUID());
return tbCfGoodstypeDao.save(tbCfGoodstype);
}
@Override
public int update(TbCfGoodstypeEntity tbCfGoodstype) {
return tbCfGoodstypeDao.update(tbCfGoodstype);
}
@Override
public int delete(String goodstypeId) {
return tbCfGoodstypeDao.delete(goodstypeId);
}
@Override
public int deleteBatch(String[] goodstypeIds) {
return tbCfGoodstypeDao.deleteBatch(goodstypeIds);
}
}
......@@ -22,6 +22,13 @@ public interface TbCfStationItemService {
*/
TbCfStationItemEntity queryObject(String itemId);
/**
* 根据主键一级分类实体集合
*
* @return List集合
*/
List<TbCfStationItemEntity> getGoodsTypeList(String categoryId);
/**
* 分页查询
*
......@@ -76,5 +83,5 @@ public interface TbCfStationItemService {
* @param pageSize
* @return
*/
Result getItemStationList(Integer pageNum, Integer pageSize);
Result getItemStationList(Integer pageNum, Integer pageSize,String categoryId);
}
......@@ -43,20 +43,14 @@ public class SpiderServiceImpl implements SpiderService {
private PlatformEnum judgeUrlType(String targetUrl) {
PlatformEnum platformEnum = PlatformEnum.UN;
if (targetUrl.contains("taobao.com")&&(targetUrl.contains("item.htm")||targetUrl.contains("detail.htm"))) {
platformEnum = PlatformEnum.TB;
} else if (targetUrl.contains("tmall.com/item.htm")) {
if(targetUrl.contains("taobao.com")&&(targetUrl.contains("item.htm")||targetUrl.contains("detail.htm"))) {
platformEnum=PlatformEnum.TB;
} else if(targetUrl.contains("tmall.com/item.htm")) {
platformEnum=PlatformEnum.TM;
} else if (targetUrl.contains("https://www.pullandbear.cn")) {
platformEnum = PlatformEnum.PULLANDBEAR;
} else if (targetUrl.contains("www.gap.cn/pdp/")) {
platformEnum = PlatformEnum.GAP;
} else if (targetUrl.contains("zara.cn")) {
platformEnum = platformEnum.ZARA;
} else if (targetUrl.contains("uniqlo.cn/product-detail.html")) {
platformEnum = platformEnum.UNIQLO;
} else if (targetUrl.contains("www.nike.com/cn/t/")) {
platformEnum = platformEnum.NIKE;
} else if(targetUrl.contains("www.gap.cn/pdp/")) {
platformEnum=PlatformEnum.GAP;
} else if(targetUrl.contains("www.nike.com/cn/t/")) {
platformEnum=PlatformEnum.NIKE;
}
return platformEnum;
}
......
package com.diaoyun.zion.chinafrica.service.impl;
import com.diaoyun.zion.chinafrica.dao.TbCfFeeDao;
import com.diaoyun.zion.chinafrica.entity.TbCfFeeEntity;
import com.diaoyun.zion.chinafrica.service.TbCfFeeService;
......@@ -18,6 +19,7 @@ import java.util.Map;
*/
@Service("tbCfFeeService")
public class TbCfFeeServiceImpl implements TbCfFeeService {
@Autowired
private TbCfFeeDao tbCfFeeDao;
......@@ -62,4 +64,10 @@ public class TbCfFeeServiceImpl implements TbCfFeeService {
return tbCfFeeDao.getAvailableFee();
}
@Override
public TbCfFeeEntity getRateFee() {
return tbCfFeeDao.getRateFee();
}
}
......@@ -55,6 +55,7 @@ import static com.github.pagehelper.page.PageMethod.startPage;
@Service("tbCfOrderService")
public class TbCfOrderServiceImpl implements TbCfOrderService {
private static Logger logger = LoggerFactory.getLogger(TbCfOrderServiceImpl.class);
@Autowired
private TbCfOrderDao tbCfOrderDao;
@Autowired
......@@ -75,6 +76,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
private TbCfCouponUseDao tbCfCouponUseDao;
@Autowired
private TbCfFinanceDao tbCfFinanceDao;
@Autowired
private TbCfExpressTemplateDao tbCfExpressTemplateDao;
@Autowired
......@@ -84,6 +86,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
private TbCfFeeService tbCfFeeService;
@Autowired
private TbCfCouponService tbCfCouponService;
@Autowired
private SpiderService spiderService;
......@@ -100,6 +103,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
@Autowired
private HttpServletRequest request; //自动注入request
@Override
public TbCfOrderEntity queryObject(String orderId) {
return tbCfOrderDao.queryObject(orderId);
......@@ -619,6 +623,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
* @return
*/
private TbCfOrderVo getGenericOrder(List<TbCfCartItemDetailVo> tbCfCartItemDetailList) throws IOException, URISyntaxException, ExecutionException, InterruptedException, TimeoutException {
TbCfFeeEntity feeEntity = tbCfFeeService.getRateFee();
TbCfOrderVo genericOrder = new TbCfOrderVo();
genericOrder.setItemDetailList(tbCfCartItemDetailList);
//初始商品总价
......@@ -632,8 +637,12 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
expressCost = expressCost.multiply(itemNum);
totalExpressCost = totalExpressCost.add(expressCost);
}
/*获取人民币汇率 1美元换取人民币 TODO 汇率接口出问题,暂设置为1 */
BigDecimal rate = new BigDecimal(1);//spiderService.getExchangeRate(null);
/*获取人民币汇率 1美元换取人民币
*TODO 汇率接口出问题,暂设置为1(暂时先不用爬虫爬区汇率,用后台手续费设置的汇率)
*暂时从后台获取人工设置的汇率
* */
BigDecimal rate = feeEntity.getFeeRate();//spiderService.getExchangeRate(null);
itemsPrice = itemsPrice.divide(rate, 2, BigDecimal.ROUND_UP);
//计算手续费
BigDecimal fee = countFee(itemsPrice);
......
......@@ -31,6 +31,11 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService {
return tbCfStationItemDao.queryObject(itemId);
}
@Override
public List<TbCfStationItemEntity> getGoodsTypeList(String categoryId) {
return tbCfStationItemDao.getGoodsTypeList(categoryId);
}
@Override
public List<TbCfStationItemEntity> queryList(Map<String, Object> map) {
return tbCfStationItemDao.queryList(map);
......@@ -63,10 +68,10 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService {
}
@Override
public Result getItemStationList(Integer pageNum, Integer pageSize) {
public Result getItemStationList(Integer pageNum, Integer pageSize,String categoryId) {
Result<PageInfo> result = new Result<>();
startPage(pageNum,pageSize);
List<TbCfStationItemEntity> tbCfStationItemList=tbCfStationItemDao.getItemStationList();
List<TbCfStationItemEntity> tbCfStationItemList=tbCfStationItemDao.getItemStationList(categoryId);
PageInfo<TbCfStationItemEntity> pageInfo = new PageInfo<>(tbCfStationItemList);
result.setData(pageInfo);
return result;
......
package com.diaoyun.zion.chinafrica.vo;
import com.diaoyun.zion.chinafrica.entity.TbCfStationItemEntity;
import java.util.List;
public class StationToGoodsType {
private String CategoryId;
private String Goodstypetitle;
private List<TbCfStationItemEntity> stationlist;
public String getCategoryId() {
return CategoryId;
}
public String getGoodstypetitle() {
return Goodstypetitle;
}
public List<TbCfStationItemEntity> getStationlist() {
return stationlist;
}
public void setCategoryId(String categoryId) {
CategoryId = categoryId;
}
public void setGoodstypetitle(String goodstypetitle) {
Goodstypetitle = goodstypetitle;
}
public void setStationlist(List<TbCfStationItemEntity> stationlist) {
this.stationlist = stationlist;
}
}
......@@ -125,7 +125,7 @@ public class HttpClientUtil {
headerList.add(new BasicHeader(HttpHeaders.CACHE_CONTROL, "max-age=0"));
headerList.add(new BasicHeader(HttpHeaders.CONNECTION, "keep-alive"));
headerList.add(new BasicHeader(HttpHeaders.ACCEPT_LANGUAGE, "zh-CN,zh;q=0.9"));
headerList.add(new BasicHeader(HttpHeaders.CONTENT_TYPE, "charset=utf-8"));
headerList.add(new BasicHeader(HttpHeaders.CONTENT_TYPE, "application/json;charset=utf-8"));
//cookie
CookieStore cookieStore = new BasicCookieStore();
return HttpClients.custom().setDefaultHeaders(headerList).setDefaultCookieStore(cookieStore).build();
......
......@@ -225,5 +225,18 @@ public class JsoupUtil {
}
/**
* 根据script id获取内容
* @param content
* @param id
* @return
*/
public static JSONObject getScriptContentById(String content, String id) {
Document document = Jsoup.parse(content);
Element element = document.getElementById(id);
String dataStr=element.data();
JSONObject dataMap= JSONObject.fromObject(dataStr);
return dataMap;
}
}
......@@ -3,9 +3,12 @@ package com.diaoyun.zion.master.util;
import com.diaoyun.zion.master.bo.TencentTranslateParam;
import com.diaoyun.zion.master.thread.TaskLimitSemaphore;
import com.diaoyun.zion.master.thread.TranslateCallable;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -62,4 +65,74 @@ public class TranslateHelper {
valeMap.put("translate",targetText);
}
}
/**
* 翻译规格属性 productPropSetMap 为 ProductResponse 的productPropSetMap 属性
* @param futureList 线程回调
* @param productPropSetMap 属性集合Map 为 ProductResponse 的productPropSetMap 属性
*/
public static void translateProp(List<Map<String, Object>> futureList, Map<String,JSONArray> productPropSetMap) {
JSONArray translateArray=new JSONArray();
/*腾讯翻译*/
for(Map.Entry<String, JSONArray>entry : productPropSetMap.entrySet()) {
String key=entry.getKey();
Map <String,Object> keyTranslateMap=new HashMap<>();
keyTranslateMap.put(key,key);
JSONArray productPropSet = entry.getValue();
for(int i=0;i<productPropSet.size();i++) {
JSONObject productPropMap=productPropSet.getJSONObject(i);
//翻译属性值
if(ValidateUtils.isContainChinese((String) productPropMap.get("propName"))) {
TranslateHelper.translateText(futureList,productPropMap, (String) productPropMap.get("propName"));
} else {
productPropMap.put("translate",(String) productPropMap.get("propName"));
}
}
translateArray.add(keyTranslateMap);
}
// TODO productPropSetMap.put("translateArray",translateArray);
}
/**
* 翻译爬取回来的数据
* @param resultObj ProductResponse格式的JSONObject
* @throws InterruptedException
* @throws ExecutionException
* @throws TimeoutException
*/
public static void translateProductResponse(JSONObject resultObj) throws InterruptedException, ExecutionException, TimeoutException {
//////////////////////翻译//////////////////////
List<Map<String, Object>> futureList= new ArrayList<>();
Map<String, JSONArray> productPropSet = resultObj.getJSONObject("productPropSet");
if(!productPropSet.isEmpty()) {
//调用腾讯ai,翻译属性值
TranslateHelper.translateProp(futureList,productPropSet);
//翻译属性名
//翻译属性名 // TODO 返回格式有待和前端确认
/*JSONArray translateArray =productPropSet.get("translateArray");
for(int i=0;i<translateArray.size();i++) {
Map <String,Object> keyTranslateMap=translateArray.getJSONObject(i);
boolean tranlateFlag=false;
String key="";
for(Map.Entry<String,Object> entry:keyTranslateMap.entrySet()) {
key=entry.getKey();
//翻译属性名
if(ValidateUtils.isContainChinese(key)) {
tranlateFlag=true;
TranslateHelper.translateText(futureList,keyTranslateMap,key);
}
}
if(!tranlateFlag) {
keyTranslateMap.put("translate",key);
}
}*/
}
//等待翻译结果
TranslateHelper.waitForResult(futureList);
resultObj.put("productPropSet",productPropSet);
//////////////////////翻译 END//////////////////////
}
}
......@@ -100,6 +100,6 @@ security:
jwt:
token:
secret-key: secret-key
expire-length: 604800000 # one week or 300000 5 minutes duration by default: 5 minutes * 60 seconds * 1000 miliseconds
expire-length: 60480000000 # one week 604800000 or 300000 5 minutes duration by default: 5 minutes * 60 seconds * 1000 miliseconds
......@@ -8,6 +8,7 @@
<result property="feeType" column="fee_type"/>
<result property="enableFlag" column="enable_flag"/>
<result property="feePercent" column="fee_percent"/>
<result property="feeRate" column="fee_rate"/>
</resultMap>
<select id="queryObject" resultType="com.diaoyun.zion.chinafrica.entity.TbCfFeeEntity">
......@@ -15,7 +16,8 @@
`fee_id`,
`fee_type`,
`enable_flag`,
`fee_percent`
`fee_percent`,
`fee_rate`
from tb_cf_fee
where fee_id = #{id}
</select>
......@@ -25,7 +27,8 @@
`fee_id`,
`fee_type`,
`enable_flag`,
`fee_percent`
`fee_percent`,
`fee_rate`
from tb_cf_fee
WHERE 1=1
<if test="name != null and name.trim() != ''">
......@@ -57,12 +60,14 @@
`fee_id`,
`fee_type`,
`enable_flag`,
`fee_percent`)
`fee_percent`,
`fee_rate`)
values(
#{feeId},
#{feeType},
#{enableFlag},
#{feePercent})
#{feePercent},
#{feeRate})
</insert>
<update id="update" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfFeeEntity">
......@@ -70,7 +75,8 @@
<set>
<if test="feeType != null">`fee_type` = #{feeType}, </if>
<if test="enableFlag != null">`enable_flag` = #{enableFlag}, </if>
<if test="feePercent != null">`fee_percent` = #{feePercent}</if>
<if test="feePercent != null">`fee_percent` = #{feePercent}, </if>
<if test="feeRate != null">`fee_rate` = #{feeRate}</if>
</set>
where fee_id = #{feeId}
</update>
......@@ -97,4 +103,16 @@
WHERE enable_flag=1
</select>
<!--获取当前生效的手人民币转成美元 理论上只有一个-->
<select id="getRateFee" resultMap="tbCfFeeMap">
select
`fee_id`,
`fee_type`,
`enable_flag`,
`fee_percent`,
`fee_rate`
from tb_cf_fee
WHERE enable_flag=1
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.diaoyun.zion.chinafrica.dao.TbCfGoodstypeDao">
<resultMap type="com.diaoyun.zion.chinafrica.entity.TbCfGoodstypeEntity" id="tbCfGoodstypeMap">
<result property="goodstypeId" column="goodstype_id"/>
<result property="goodstypeTitle" column="goodstype_title"/>
<result property="goodstypeSort" column="goodstype_sort"/>
</resultMap>
<select id="queryObject" resultType="com.diaoyun.zion.chinafrica.entity.TbCfGoodstypeEntity">
select
`goodstype_id`,
`goodstype_title`,
`goodstype_sort`
from tb_cf_goodstype
where goodstype_id = #{id}
</select>
<select id="queryList" resultType="com.diaoyun.zion.chinafrica.entity.TbCfGoodstypeEntity">
select
`goodstype_id`,
`goodstype_title`,
`goodstype_sort`
from tb_cf_goodstype
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
<choose>
<when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order}
</when>
<otherwise>
order by goodstype_sort asc
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<select id="queryTotal" resultType="int">
select count(*) from tb_cf_goodstype
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
</select>
<insert id="save" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfGoodstypeEntity">
insert into tb_cf_goodstype(
`goodstype_id`,
`goodstype_title`,
`goodstype_sort`)
values(
#{goodstypeId},
#{goodstypeTitle},
#{goodstypeSort})
</insert>
<update id="update" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfGoodstypeEntity">
update tb_cf_goodstype
<set>
<if test="goodstypeTitle != null">`goodstype_title` = #{goodstypeTitle}, </if>
<if test="goodstypeSort != null">`goodstype_sort` = #{goodstypeSort}</if>
</set>
where goodstype_id = #{goodstypeId}
</update>
<delete id="delete">
delete from tb_cf_goodstype where goodstype_id = #{value}
</delete>
<delete id="deleteBatch">
delete from tb_cf_goodstype where goodstype_id in
<foreach item="goodstypeId" collection="array" open="(" separator="," close=")">
#{goodstypeId}
</foreach>
</delete>
</mapper>
\ No newline at end of file
......@@ -17,6 +17,23 @@
<result property="createTime" column="create_time"/>
</resultMap>
<select id="getGoodsTypeList" resultType="com.diaoyun.zion.chinafrica.entity.TbCfStationItemEntity">
select
`item_id`,
`item_code`,
`item_name`,
`item_brief`,
`item_category`,
`item_url`,
`item_img`,
`platform_code`,
`platform_name`,
`enable_flag`,
`create_time`
from tb_cf_station_item
where item_category = #{categoryId} order by create_time desc limit 0,4
</select>
<select id="queryObject" resultType="com.diaoyun.zion.chinafrica.entity.TbCfStationItemEntity">
select
`item_id`,
......@@ -130,7 +147,10 @@
<!--获取商品独立站-->
<select id="getItemStationList" resultType="com.diaoyun.zion.chinafrica.entity.TbCfStationItemEntity">
select * from tb_cf_station_item where enable_flag=1 order by create_time desc
select * from tb_cf_station_item
where enable_flag=1 and item_category = #{categoryId}
order by create_time desc
</select>
......
......@@ -22,8 +22,8 @@ email.subject=Verification Code from Chinafrica
###################################邮箱 END###############################################
################redis有效时间###################
#登录token second 默认30分 一个星期
redis.token.expiredTime=604800
#登录token second 默认30分 一个星期 604800
redis.token.expiredTime=60480000
#订单 30分 second
redis.order.expiredTime=1800
......
{
"id": 4046724890721,
"title": "Cotton Core Pillow Core A set of three pieces",
"handle": "cotton-core-pillow-core-a-set-of-three-pieces",
"description": "\u003cp\u003eProduct category: cushion core \/ pillow core \/ seat core\u003c\/p\u003e\n\u003cp\u003eProduct material: chemical fiber, pp cotton\u003c\/p\u003e\n\u003cp\u003eFiller: fiber\u003c\/p\u003e\n\u003cp\u003eStyle: modern simplicity\u003c\/p\u003e",
"published_at": "2019-09-12T11:27:55+08:00",
"created_at": "2019-09-12T11:33:50+08:00",
"vendor": "MollyKitty",
"type": "Afri Home",
"tags": ["Bedroom", "Livingroom"],
"price": 199,
"price_min": 199,
"price_max": 599,
"available": true,
"price_varies": true,
"compare_at_price": null,
"compare_at_price_min": 0,
"compare_at_price_max": 0,
"compare_at_price_varies": false,
"variants": [{
"id": 29948484649057,
"title": "60*60cm \/ 3",
"option1": "60*60cm",
"option2": "3",
"option3": null,
"sku": "",
"requires_shipping": true,
"taxable": true,
"featured_image": null,
"available": true,
"name": "Cotton Core Pillow Core A set of three pieces - 60*60cm \/ 3",
"public_title": "60*60cm \/ 3",
"options": ["60*60cm", "3"],
"price": 399,
"weight": 300,
"compare_at_price": null,
"inventory_management": "shopify",
"barcode": ""
}, {
"id": 29948484681825,
"title": "70*70cm \/ 3",
"option1": "70*70cm",
"option2": "3",
"option3": null,
"sku": "",
"requires_shipping": true,
"taxable": true,
"featured_image": null,
"available": true,
"name": "Cotton Core Pillow Core A set of three pieces - 70*70cm \/ 3",
"public_title": "70*70cm \/ 3",
"options": ["70*70cm", "3"],
"price": 599,
"weight": 300,
"compare_at_price": null,
"inventory_management": "shopify",
"barcode": ""
}, {
"id": 29948484714593,
"title": "50*50cm \/ 3",
"option1": "50*50cm",
"option2": "3",
"option3": null,
"sku": "",
"requires_shipping": true,
"taxable": true,
"featured_image": null,
"available": true,
"name": "Cotton Core Pillow Core A set of three pieces - 50*50cm \/ 3",
"public_title": "50*50cm \/ 3",
"options": ["50*50cm", "3"],
"price": 299,
"weight": 300,
"compare_at_price": null,
"inventory_management": "shopify",
"barcode": ""
}, {
"id": 29948484747361,
"title": "45*45cm \/ 3",
"option1": "45*45cm",
"option2": "3",
"option3": null,
"sku": "",
"requires_shipping": true,
"taxable": true,
"featured_image": null,
"available": true,
"name": "Cotton Core Pillow Core A set of three pieces - 45*45cm \/ 3",
"public_title": "45*45cm \/ 3",
"options": ["45*45cm", "3"],
"price": 199,
"weight": 300,
"compare_at_price": null,
"inventory_management": "shopify",
"barcode": ""
}, {
"id": 29948484780129,
"title": "65*65cm \/ 3",
"option1": "65*65cm",
"option2": "3",
"option3": null,
"sku": "",
"requires_shipping": true,
"taxable": true,
"featured_image": null,
"available": true,
"name": "Cotton Core Pillow Core A set of three pieces - 65*65cm \/ 3",
"public_title": "65*65cm \/ 3",
"options": ["65*65cm", "3"],
"price": 499,
"weight": 300,
"compare_at_price": null,
"inventory_management": "shopify",
"barcode": ""
}, {
"id": 29948484812897,
"title": "55*55cm \/ 3",
"option1": "55*55cm",
"option2": "3",
"option3": null,
"sku": "",
"requires_shipping": true,
"taxable": true,
"featured_image": null,
"available": true,
"name": "Cotton Core Pillow Core A set of three pieces - 55*55cm \/ 3",
"public_title": "55*55cm \/ 3",
"options": ["55*55cm", "3"],
"price": 299,
"weight": 300,
"compare_at_price": null,
"inventory_management": "shopify",
"barcode": ""
}, {
"id": 29948484845665,
"title": "30*45cm \/ 3",
"option1": "30*45cm",
"option2": "3",
"option3": null,
"sku": "",
"requires_shipping": true,
"taxable": true,
"featured_image": null,
"available": true,
"name": "Cotton Core Pillow Core A set of three pieces - 30*45cm \/ 3",
"public_title": "30*45cm \/ 3",
"options": ["30*45cm", "3"],
"price": 299,
"weight": 300,
"compare_at_price": null,
"inventory_management": "shopify",
"barcode": ""
}, {
"id": 29948484878433,
"title": "35*60cm \/ 3",
"option1": "35*60cm",
"option2": "3",
"option3": null,
"sku": "",
"requires_shipping": true,
"taxable": true,
"featured_image": null,
"available": true,
"name": "Cotton Core Pillow Core A set of three pieces - 35*60cm \/ 3",
"public_title": "35*60cm \/ 3",
"options": ["35*60cm", "3"],
"price": 299,
"weight": 300,
"compare_at_price": null,
"inventory_management": "shopify",
"barcode": ""
}, {
"id": 29948484911201,
"title": "30*50cm \/ 3",
"option1": "30*50cm",
"option2": "3",
"option3": null,
"sku": "",
"requires_shipping": true,
"taxable": true,
"featured_image": null,
"available": true,
"name": "Cotton Core Pillow Core A set of three pieces - 30*50cm \/ 3",
"public_title": "30*50cm \/ 3",
"options": ["30*50cm", "3"],
"price": 199,
"weight": 300,
"compare_at_price": null,
"inventory_management": "shopify",
"barcode": ""
}],
"images": ["\/\/cdn.shopify.com\/s\/files\/1\/0079\/8330\/0705\/products\/q1.jpg?v=1568259234", "\/\/cdn.shopify.com\/s\/files\/1\/0079\/8330\/0705\/products\/q2.jpg?v=1568259235", "\/\/cdn.shopify.com\/s\/files\/1\/0079\/8330\/0705\/products\/q3.jpg?v=1568259236", "\/\/cdn.shopify.com\/s\/files\/1\/0079\/8330\/0705\/products\/q4.jpg?v=1568259238", "\/\/cdn.shopify.com\/s\/files\/1\/0079\/8330\/0705\/products\/q5.jpg?v=1568259239"],
"featured_image": "\/\/cdn.shopify.com\/s\/files\/1\/0079\/8330\/0705\/products\/q1.jpg?v=1568259234",
"options": ["Size", "Quantity"],
"content": "\u003cp\u003eProduct category: cushion core \/ pillow core \/ seat core\u003c\/p\u003e\n\u003cp\u003eProduct material: chemical fiber, pp cotton\u003c\/p\u003e\n\u003cp\u003eFiller: fiber\u003c\/p\u003e\n\u003cp\u003eStyle: modern simplicity\u003c\/p\u003e"
}
\ No newline at end of file
......@@ -5,6 +5,5 @@
<title>Title</title>
</head>
<body>
dddddddddddddddddddd
</body>
ddddddddddddddddddddddd</body>
</html>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论