提交 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; package com.diaoyun.zion.chinafrica.bis.impl;
import com.diaoyun.zion.chinafrica.bis.IItemSpider; 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.chinafrica.vo.ProductResponse;
import com.diaoyun.zion.master.util.*; import com.diaoyun.zion.master.util.*;
import net.sf.json.JSONArray; import net.sf.json.JSONArray;
import net.sf.json.JSONObject; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException; import java.util.*;
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.ExecutionException;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
...@@ -34,7 +24,7 @@ public class GapItemSpider implements IItemSpider { ...@@ -34,7 +24,7 @@ public class GapItemSpider implements IItemSpider {
private static final String gapUrl="https://apicn.gap.cn/gap/store/product/list/searchProductByCondition.do"; private static final String gapUrl="https://apicn.gap.cn/gap/store/product/list/searchProductByCondition.do";
@Override @Override
public JSONObject captureItem(String targetUrl) throws URISyntaxException, IOException, ExecutionException, InterruptedException, TimeoutException { public JSONObject captureItem(String targetUrl) throws IOException, InterruptedException, ExecutionException, TimeoutException {
JSONObject resultObj; JSONObject resultObj;
//获取链接中的商品spuCode //获取链接中的商品spuCode
String itemId= getItemId(targetUrl); String itemId= getItemId(targetUrl);
...@@ -56,11 +46,16 @@ public class GapItemSpider implements IItemSpider { ...@@ -56,11 +46,16 @@ public class GapItemSpider implements IItemSpider {
//格式化为封装数据 //格式化为封装数据
ProductResponse productResponse = SpiderUtil.formatGapProductResponse(resultObj.getJSONObject("data")); ProductResponse productResponse = SpiderUtil.formatGapProductResponse(resultObj.getJSONObject("data"));
resultObj=JSONObject.fromObject(productResponse); resultObj=JSONObject.fromObject(productResponse);
//翻译
TranslateHelper.translateProductResponse(resultObj);
} }
return resultObj; return resultObj;
} }
private String getItemId(String targetUrl) { private String getItemId(String targetUrl) {
String spuCode=targetUrl.substring(targetUrl.lastIndexOf("/")+1); String spuCode=targetUrl.substring(targetUrl.lastIndexOf("/")+1);
int firstUnder=spuCode.indexOf("_"); int firstUnder=spuCode.indexOf("_");
......
...@@ -4,30 +4,26 @@ import com.diaoyun.zion.chinafrica.bis.IItemSpider; ...@@ -4,30 +4,26 @@ import com.diaoyun.zion.chinafrica.bis.IItemSpider;
import com.diaoyun.zion.chinafrica.enums.PlatformEnum; import com.diaoyun.zion.chinafrica.enums.PlatformEnum;
import com.diaoyun.zion.chinafrica.vo.ProductResponse; import com.diaoyun.zion.chinafrica.vo.ProductResponse;
import com.diaoyun.zion.master.util.*; import com.diaoyun.zion.master.util.*;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException; 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.ExecutionException;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
/** /**
* Gap数据爬虫 * nike数据爬虫
*/ */
@Component("nikeItemSpider") @Component("nikeItemSpider")
public class NikeItemSpider implements IItemSpider { public class NikeItemSpider implements IItemSpider {
private static Logger logger = LoggerFactory.getLogger(NikeItemSpider.class); private static Logger logger = LoggerFactory.getLogger(NikeItemSpider.class);
@Override @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; JSONObject resultObj;
//获取url中的网页内容 > //获取url中的网页内容 >
String content = HttpClientUtil.getContentByUrl(targetUrl, PlatformEnum.NIKE.getValue()); String content = HttpClientUtil.getContentByUrl(targetUrl, PlatformEnum.NIKE.getValue());
...@@ -36,6 +32,8 @@ public class NikeItemSpider implements IItemSpider { ...@@ -36,6 +32,8 @@ public class NikeItemSpider implements IItemSpider {
//格式化为封装数据 //格式化为封装数据
ProductResponse productResponse = SpiderUtil.formatNikeProductResponse(resultObj); ProductResponse productResponse = SpiderUtil.formatNikeProductResponse(resultObj);
resultObj = JSONObject.fromObject(productResponse); resultObj = JSONObject.fromObject(productResponse);
//翻译
TranslateHelper.translateProductResponse(resultObj);
return resultObj; return resultObj;
} }
......
...@@ -2,9 +2,6 @@ package com.diaoyun.zion.chinafrica.bis.impl; ...@@ -2,9 +2,6 @@ package com.diaoyun.zion.chinafrica.bis.impl;
import com.diaoyun.zion.chinafrica.bis.IItemSpider; import com.diaoyun.zion.chinafrica.bis.IItemSpider;
import com.diaoyun.zion.chinafrica.enums.PlatformEnum; 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.HttpClientUtil;
import com.diaoyun.zion.master.util.JsoupUtil; import com.diaoyun.zion.master.util.JsoupUtil;
import com.diaoyun.zion.master.util.TranslateHelper; import com.diaoyun.zion.master.util.TranslateHelper;
...@@ -12,28 +9,17 @@ import com.diaoyun.zion.master.util.ValidateUtils; ...@@ -12,28 +9,17 @@ import com.diaoyun.zion.master.util.ValidateUtils;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils; 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.message.BasicHeader;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
/** /**
...@@ -102,7 +88,7 @@ public class TbItemSpider implements IItemSpider { ...@@ -102,7 +88,7 @@ public class TbItemSpider implements IItemSpider {
* @throws ExecutionException * @throws ExecutionException
* @throws InterruptedException * @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()) { for(Map.Entry<String,Object>entry : propMap.entrySet()) {
String key=entry.getKey(); String key=entry.getKey();
...@@ -124,7 +110,7 @@ public class TbItemSpider implements IItemSpider { ...@@ -124,7 +110,7 @@ public class TbItemSpider implements IItemSpider {
* @throws ExecutionException * @throws ExecutionException
* @throws InterruptedException * @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()) { for(Map.Entry<String,Object>entry : skuMap.entrySet()) {
String key=entry.getKey(); String key=entry.getKey();
if(entry.getValue() instanceof Map) { if(entry.getValue() instanceof Map) {
......
...@@ -42,7 +42,9 @@ public class TokenVerification { ...@@ -42,7 +42,9 @@ public class TokenVerification {
"&&!execution(* com.diaoyun.zion.chinafrica.controller.TbCfHomePageController.*(..))" + "&&!execution(* com.diaoyun.zion.chinafrica.controller.TbCfHomePageController.*(..))" +
"&&!execution(* com.diaoyun.zion.chinafrica.controller.TbCfUserInfoController.resetPassWord(..))" + "&&!execution(* com.diaoyun.zion.chinafrica.controller.TbCfUserInfoController.resetPassWord(..))" +
"&&!execution(* com.diaoyun.zion.chinafrica.controller.TbCfFeedbackController.getFeedbackList(..))" + "&&!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() { 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; ...@@ -24,7 +24,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
public class TbCfStationItemController { public class TbCfStationItemController {
@Autowired @Autowired
private TbCfStationItemService tbCfStationItemService; private TbCfStationItemService tbCfStationItemService;
/*
@ApiOperation("获取商品独立站") @ApiOperation("获取商品独立站")
@GetMapping @GetMapping
public Result getItemStationList(@ApiParam(value = "页数 默认1") @RequestParam(required = false) Integer pageNum, public Result getItemStationList(@ApiParam(value = "页数 默认1") @RequestParam(required = false) Integer pageNum,
...@@ -33,9 +33,9 @@ public class TbCfStationItemController { ...@@ -33,9 +33,9 @@ public class TbCfStationItemController {
pageNum = 1; pageNum = 1;
} }
if (pageSize == null) { if (pageSize == null) {
pageSize = 10; pageSize = 2;
} }
return tbCfStationItemService.getItemStationList(pageNum,pageSize); return tbCfStationItemService.getItemStationList(pageNum,pageSize);
} }*/
} }
...@@ -15,4 +15,10 @@ public interface TbCfFeeDao extends BaseDao<TbCfFeeEntity> { ...@@ -15,4 +15,10 @@ public interface TbCfFeeDao extends BaseDao<TbCfFeeEntity> {
* @return * @return
*/ */
TbCfFeeEntity getAvailableFee(); 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> { ...@@ -18,5 +18,12 @@ public interface TbCfStationItemDao extends BaseDao<TbCfStationItemEntity> {
* 获取商品独立站 * 获取商品独立站
* @return * @return
*/ */
List<TbCfStationItemEntity> getItemStationList(); List<TbCfStationItemEntity> getItemStationList(String categoryId);
/**
* 根据主键一级分类实体集合
*
* @return List集合
*/
List<TbCfStationItemEntity> getGoodsTypeList(String categoryId);
} }
...@@ -8,8 +8,8 @@ import java.util.Date; ...@@ -8,8 +8,8 @@ import java.util.Date;
* 手续费实体 * 手续费实体
* 表名 tb_cf_fee * 表名 tb_cf_fee
* *
* @author G * @author LHB
* @date 2019-08-14 09:11:48 * @date 2019-10-13 16:18:55
*/ */
public class TbCfFeeEntity implements Serializable { public class TbCfFeeEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -19,17 +19,21 @@ public class TbCfFeeEntity implements Serializable { ...@@ -19,17 +19,21 @@ public class TbCfFeeEntity implements Serializable {
*/ */
private String feeId; private String feeId;
/** /**
* 收费类型 * 收费类型,1为百分比,目前只有一种收费方式
*/ */
private Integer feeType; private Integer feeType;
/** /**
* 是否生效 * 是否生效标志
*/ */
private Integer enableFlag; private Integer enableFlag;
/** /**
* 收取费用百分比 * 收取费用百分比
*/ */
private BigDecimal feePercent; private BigDecimal feePercent;
/**
* 设置美元转换
*/
private BigDecimal feeRate;
/** /**
* 设置:收费id * 设置:收费id
...@@ -45,27 +49,27 @@ public class TbCfFeeEntity implements Serializable { ...@@ -45,27 +49,27 @@ public class TbCfFeeEntity implements Serializable {
return feeId; return feeId;
} }
/** /**
* 设置:收费类型 * 设置:收费类型,1为百分比,目前只有一种收费方式
*/ */
public void setFeeType(Integer feeType) { public void setFeeType(Integer feeType) {
this.feeType = feeType; this.feeType = feeType;
} }
/** /**
* 获取:收费类型 * 获取:收费类型,1为百分比,目前只有一种收费方式
*/ */
public Integer getFeeType() { public Integer getFeeType() {
return feeType; return feeType;
} }
/** /**
* 设置:是否生效 * 设置:是否生效标志
*/ */
public void setEnableFlag(Integer enableFlag) { public void setEnableFlag(Integer enableFlag) {
this.enableFlag = enableFlag; this.enableFlag = enableFlag;
} }
/** /**
* 获取:是否生效 * 获取:是否生效标志
*/ */
public Integer getEnableFlag() { public Integer getEnableFlag() {
return enableFlag; return enableFlag;
...@@ -80,7 +84,21 @@ public class TbCfFeeEntity implements Serializable { ...@@ -80,7 +84,21 @@ public class TbCfFeeEntity implements Serializable {
/** /**
* 获取:收取费用百分比 * 获取:收取费用百分比
*/ */
public BigDecimal getFeePercent() { public BigDecimal getFeePercent() {
return feePercent; 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> { ...@@ -17,7 +17,8 @@ public enum PlatformEnum implements EnumItemable<PlatformEnum> {
ZARA("Zara", "zara"), ZARA("Zara", "zara"),
UNIQLO("优衣库", "uniqlo"), UNIQLO("优衣库", "uniqlo"),
NIKE("NIKE", "nike"), NIKE("NIKE", "nike"),
UN("未知", "un"); UN("未知", "un"),
AfriEshop("afri-eshop","afri-eshop" );
private String label; private String label;
private String value; private String value;
......
...@@ -40,6 +40,10 @@ public class ItemSpiderFactory { ...@@ -40,6 +40,10 @@ public class ItemSpiderFactory {
iItemSpider= (IItemSpider) SpringContextUtil.getBean("nikeItemSpider"); iItemSpider= (IItemSpider) SpringContextUtil.getBean("nikeItemSpider");
break; break;
} }
case "afri-eshop":{
iItemSpider= (IItemSpider) SpringContextUtil.getBean("africaShopItemSpider");
break;
}
default:{ default:{
iItemSpider= (IItemSpider) SpringContextUtil.getBean("emptyItemSpider"); iItemSpider= (IItemSpider) SpringContextUtil.getBean("emptyItemSpider");
break; break;
......
...@@ -74,4 +74,10 @@ public interface TbCfFeeService { ...@@ -74,4 +74,10 @@ public interface TbCfFeeService {
* @return * @return
*/ */
TbCfFeeEntity getAvailableFee(); 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 { ...@@ -22,6 +22,13 @@ public interface TbCfStationItemService {
*/ */
TbCfStationItemEntity queryObject(String itemId); TbCfStationItemEntity queryObject(String itemId);
/**
* 根据主键一级分类实体集合
*
* @return List集合
*/
List<TbCfStationItemEntity> getGoodsTypeList(String categoryId);
/** /**
* 分页查询 * 分页查询
* *
...@@ -76,5 +83,5 @@ public interface TbCfStationItemService { ...@@ -76,5 +83,5 @@ public interface TbCfStationItemService {
* @param pageSize * @param pageSize
* @return * @return
*/ */
Result getItemStationList(Integer pageNum, Integer pageSize); Result getItemStationList(Integer pageNum, Integer pageSize,String categoryId);
} }
...@@ -43,20 +43,14 @@ public class SpiderServiceImpl implements SpiderService { ...@@ -43,20 +43,14 @@ public class SpiderServiceImpl implements SpiderService {
private PlatformEnum judgeUrlType(String targetUrl) { private PlatformEnum judgeUrlType(String targetUrl) {
PlatformEnum platformEnum = PlatformEnum.UN; PlatformEnum platformEnum = PlatformEnum.UN;
if (targetUrl.contains("taobao.com")&&(targetUrl.contains("item.htm")||targetUrl.contains("detail.htm"))) { if(targetUrl.contains("taobao.com")&&(targetUrl.contains("item.htm")||targetUrl.contains("detail.htm"))) {
platformEnum = PlatformEnum.TB; platformEnum=PlatformEnum.TB;
} else if (targetUrl.contains("tmall.com/item.htm")) { } else if(targetUrl.contains("tmall.com/item.htm")) {
platformEnum=PlatformEnum.TM; platformEnum=PlatformEnum.TM;
} else if (targetUrl.contains("https://www.pullandbear.cn")) { } else if(targetUrl.contains("www.gap.cn/pdp/")) {
platformEnum = PlatformEnum.PULLANDBEAR; platformEnum=PlatformEnum.GAP;
} else if (targetUrl.contains("www.gap.cn/pdp/")) { } else if(targetUrl.contains("www.nike.com/cn/t/")) {
platformEnum = PlatformEnum.GAP; platformEnum=PlatformEnum.NIKE;
} 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;
} }
return platformEnum; return platformEnum;
} }
......
package com.diaoyun.zion.chinafrica.service.impl; package com.diaoyun.zion.chinafrica.service.impl;
import com.diaoyun.zion.chinafrica.dao.TbCfFeeDao; import com.diaoyun.zion.chinafrica.dao.TbCfFeeDao;
import com.diaoyun.zion.chinafrica.entity.TbCfFeeEntity; import com.diaoyun.zion.chinafrica.entity.TbCfFeeEntity;
import com.diaoyun.zion.chinafrica.service.TbCfFeeService; import com.diaoyun.zion.chinafrica.service.TbCfFeeService;
...@@ -18,6 +19,7 @@ import java.util.Map; ...@@ -18,6 +19,7 @@ import java.util.Map;
*/ */
@Service("tbCfFeeService") @Service("tbCfFeeService")
public class TbCfFeeServiceImpl implements TbCfFeeService { public class TbCfFeeServiceImpl implements TbCfFeeService {
@Autowired @Autowired
private TbCfFeeDao tbCfFeeDao; private TbCfFeeDao tbCfFeeDao;
...@@ -62,4 +64,10 @@ public class TbCfFeeServiceImpl implements TbCfFeeService { ...@@ -62,4 +64,10 @@ public class TbCfFeeServiceImpl implements TbCfFeeService {
return tbCfFeeDao.getAvailableFee(); return tbCfFeeDao.getAvailableFee();
} }
@Override
public TbCfFeeEntity getRateFee() {
return tbCfFeeDao.getRateFee();
}
} }
...@@ -55,6 +55,7 @@ import static com.github.pagehelper.page.PageMethod.startPage; ...@@ -55,6 +55,7 @@ import static com.github.pagehelper.page.PageMethod.startPage;
@Service("tbCfOrderService") @Service("tbCfOrderService")
public class TbCfOrderServiceImpl implements TbCfOrderService { public class TbCfOrderServiceImpl implements TbCfOrderService {
private static Logger logger = LoggerFactory.getLogger(TbCfOrderServiceImpl.class); private static Logger logger = LoggerFactory.getLogger(TbCfOrderServiceImpl.class);
@Autowired @Autowired
private TbCfOrderDao tbCfOrderDao; private TbCfOrderDao tbCfOrderDao;
@Autowired @Autowired
...@@ -75,6 +76,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService { ...@@ -75,6 +76,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
private TbCfCouponUseDao tbCfCouponUseDao; private TbCfCouponUseDao tbCfCouponUseDao;
@Autowired @Autowired
private TbCfFinanceDao tbCfFinanceDao; private TbCfFinanceDao tbCfFinanceDao;
@Autowired @Autowired
private TbCfExpressTemplateDao tbCfExpressTemplateDao; private TbCfExpressTemplateDao tbCfExpressTemplateDao;
@Autowired @Autowired
...@@ -84,6 +86,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService { ...@@ -84,6 +86,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
private TbCfFeeService tbCfFeeService; private TbCfFeeService tbCfFeeService;
@Autowired @Autowired
private TbCfCouponService tbCfCouponService; private TbCfCouponService tbCfCouponService;
@Autowired @Autowired
private SpiderService spiderService; private SpiderService spiderService;
...@@ -100,6 +103,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService { ...@@ -100,6 +103,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
@Autowired @Autowired
private HttpServletRequest request; //自动注入request private HttpServletRequest request; //自动注入request
@Override @Override
public TbCfOrderEntity queryObject(String orderId) { public TbCfOrderEntity queryObject(String orderId) {
return tbCfOrderDao.queryObject(orderId); return tbCfOrderDao.queryObject(orderId);
...@@ -619,6 +623,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService { ...@@ -619,6 +623,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
* @return * @return
*/ */
private TbCfOrderVo getGenericOrder(List<TbCfCartItemDetailVo> tbCfCartItemDetailList) throws IOException, URISyntaxException, ExecutionException, InterruptedException, TimeoutException { private TbCfOrderVo getGenericOrder(List<TbCfCartItemDetailVo> tbCfCartItemDetailList) throws IOException, URISyntaxException, ExecutionException, InterruptedException, TimeoutException {
TbCfFeeEntity feeEntity = tbCfFeeService.getRateFee();
TbCfOrderVo genericOrder = new TbCfOrderVo(); TbCfOrderVo genericOrder = new TbCfOrderVo();
genericOrder.setItemDetailList(tbCfCartItemDetailList); genericOrder.setItemDetailList(tbCfCartItemDetailList);
//初始商品总价 //初始商品总价
...@@ -632,8 +637,12 @@ public class TbCfOrderServiceImpl implements TbCfOrderService { ...@@ -632,8 +637,12 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
expressCost = expressCost.multiply(itemNum); expressCost = expressCost.multiply(itemNum);
totalExpressCost = totalExpressCost.add(expressCost); 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); itemsPrice = itemsPrice.divide(rate, 2, BigDecimal.ROUND_UP);
//计算手续费 //计算手续费
BigDecimal fee = countFee(itemsPrice); BigDecimal fee = countFee(itemsPrice);
......
...@@ -31,6 +31,11 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService { ...@@ -31,6 +31,11 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService {
return tbCfStationItemDao.queryObject(itemId); return tbCfStationItemDao.queryObject(itemId);
} }
@Override
public List<TbCfStationItemEntity> getGoodsTypeList(String categoryId) {
return tbCfStationItemDao.getGoodsTypeList(categoryId);
}
@Override @Override
public List<TbCfStationItemEntity> queryList(Map<String, Object> map) { public List<TbCfStationItemEntity> queryList(Map<String, Object> map) {
return tbCfStationItemDao.queryList(map); return tbCfStationItemDao.queryList(map);
...@@ -63,10 +68,10 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService { ...@@ -63,10 +68,10 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService {
} }
@Override @Override
public Result getItemStationList(Integer pageNum, Integer pageSize) { public Result getItemStationList(Integer pageNum, Integer pageSize,String categoryId) {
Result<PageInfo> result = new Result<>(); Result<PageInfo> result = new Result<>();
startPage(pageNum,pageSize); startPage(pageNum,pageSize);
List<TbCfStationItemEntity> tbCfStationItemList=tbCfStationItemDao.getItemStationList(); List<TbCfStationItemEntity> tbCfStationItemList=tbCfStationItemDao.getItemStationList(categoryId);
PageInfo<TbCfStationItemEntity> pageInfo = new PageInfo<>(tbCfStationItemList); PageInfo<TbCfStationItemEntity> pageInfo = new PageInfo<>(tbCfStationItemList);
result.setData(pageInfo); result.setData(pageInfo);
return result; 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 { ...@@ -125,7 +125,7 @@ public class HttpClientUtil {
headerList.add(new BasicHeader(HttpHeaders.CACHE_CONTROL, "max-age=0")); headerList.add(new BasicHeader(HttpHeaders.CACHE_CONTROL, "max-age=0"));
headerList.add(new BasicHeader(HttpHeaders.CONNECTION, "keep-alive")); 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.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 //cookie
CookieStore cookieStore = new BasicCookieStore(); CookieStore cookieStore = new BasicCookieStore();
return HttpClients.custom().setDefaultHeaders(headerList).setDefaultCookieStore(cookieStore).build(); return HttpClients.custom().setDefaultHeaders(headerList).setDefaultCookieStore(cookieStore).build();
......
...@@ -225,5 +225,18 @@ public class JsoupUtil { ...@@ -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;
}
} }
...@@ -23,22 +23,22 @@ public class SpiderUtil { ...@@ -23,22 +23,22 @@ public class SpiderUtil {
List<OriginalPrice> originalPriceList = new ArrayList<>(); List<OriginalPrice> originalPriceList = new ArrayList<>();
//促销价格 //促销价格
List<ProductPromotion> promotionList = new ArrayList<>(); List<ProductPromotion> promotionList = new ArrayList<>();
Map<String, Set<ProductProp>> productPropSet=new HashMap<>(); Map<String, Set<ProductProp>> productPropSet = new HashMap<>();
JSONArray productList=dataMap.getJSONArray("productList"); JSONArray productList = dataMap.getJSONArray("productList");
//商品信息 //商品信息
ItemInfo itemInfo =new ItemInfo(); ItemInfo itemInfo = new ItemInfo();
for (int index = 0; index < productList.size(); index++) { for (int index = 0; index < productList.size(); index++) {
JSONObject propObj=productList.getJSONObject(index); JSONObject propObj = productList.getJSONObject(index);
//////////////////获取价格////////////////// //////////////////获取价格//////////////////
JSONArray skuList = propObj.getJSONArray("skuList"); JSONArray skuList = propObj.getJSONArray("skuList");
for (int i = 0; i < skuList.size(); i++) { for (int i = 0; i < skuList.size(); i++) {
JSONObject skuValue = skuList.getJSONObject(i); JSONObject skuValue = skuList.getJSONObject(i);
JSONArray attrSaleList=skuValue.getJSONArray("attrSaleList"); JSONArray attrSaleList = skuValue.getJSONArray("attrSaleList");
String skuStr=";"; String skuStr = ";";
for(int m=0;m<attrSaleList.size();m++) { for (int m = 0; m < attrSaleList.size(); m++) {
JSONObject attrSale=attrSaleList.getJSONObject(m); JSONObject attrSale = attrSaleList.getJSONObject(m);
JSONArray attributeValueList=attrSale.getJSONArray("attributeValueList"); JSONArray attributeValueList = attrSale.getJSONArray("attributeValueList");
skuStr=skuStr+attributeValueList.getJSONObject(0).getString("code")+";"; skuStr = skuStr + attributeValueList.getJSONObject(0).getString("code") + ";";
} }
//原始价格 //原始价格
OriginalPrice originalPrice = new OriginalPrice(); OriginalPrice originalPrice = new OriginalPrice();
...@@ -46,7 +46,7 @@ public class SpiderUtil { ...@@ -46,7 +46,7 @@ public class SpiderUtil {
originalPrice.setPrice(skuValue.getString("listPrice")); originalPrice.setPrice(skuValue.getString("listPrice"));
originalPriceList.add(originalPrice); originalPriceList.add(originalPrice);
//促销价格 //促销价格
if(StringUtils.isNotBlank(skuValue.getString("salePrice"))) { if (StringUtils.isNotBlank(skuValue.getString("salePrice"))) {
productResponse.setPromotionFlag(true); productResponse.setPromotionFlag(true);
ProductPromotion productPromotion = new ProductPromotion(); ProductPromotion productPromotion = new ProductPromotion();
productPromotion.setSkuStr(skuStr); productPromotion.setSkuStr(skuStr);
...@@ -58,28 +58,28 @@ public class SpiderUtil { ...@@ -58,28 +58,28 @@ public class SpiderUtil {
//////////////////获取价格 END////////////////// //////////////////获取价格 END//////////////////
//////////////////获取商品属性////////////////// //////////////////获取商品属性//////////////////
JSONArray attrSaleList = propObj.getJSONArray("attrSaleList"); JSONArray attrSaleList = propObj.getJSONArray("attrSaleList");
for(int i=0;i<attrSaleList.size();i++) { for (int i = 0; i < attrSaleList.size(); i++) {
JSONArray attributeValueList = attrSaleList.getJSONObject(i).getJSONArray("attributeValueList"); JSONArray attributeValueList = attrSaleList.getJSONObject(i).getJSONArray("attributeValueList");
//商品属性 //商品属性
Set<ProductProp> propSet=new HashSet<>(); Set<ProductProp> propSet = new HashSet<>();
for(int j=0;j<attributeValueList.size();j++) { for (int j = 0; j < attributeValueList.size(); j++) {
ProductProp productProp=new ProductProp(); ProductProp productProp = new ProductProp();
//获取图片,拿第一张 //获取图片,拿第一张
if(attributeValueList.getJSONObject(j).get("itemAttributeValueImageList")!=null&&!"null".equalsIgnoreCase(attributeValueList.getJSONObject(j).getString("itemAttributeValueImageList"))) { if (attributeValueList.getJSONObject(j).get("itemAttributeValueImageList") != null && !"null".equalsIgnoreCase(attributeValueList.getJSONObject(j).getString("itemAttributeValueImageList"))) {
JSONArray itemAttributeValueImageList =attributeValueList.getJSONObject(j).getJSONArray("itemAttributeValueImageList"); JSONArray itemAttributeValueImageList = attributeValueList.getJSONObject(j).getJSONArray("itemAttributeValueImageList");
productProp.setImage(itemAttributeValueImageList.getJSONObject(0).getString("picUrl")); productProp.setImage(itemAttributeValueImageList.getJSONObject(0).getString("picUrl"));
} }
productProp.setPropName(attributeValueList.getJSONObject(j).getString("attributeValueName")); productProp.setPropName(attributeValueList.getJSONObject(j).getString("attributeValueName"));
productProp.setPropId(attributeValueList.getJSONObject(j).getString("code")); productProp.setPropId(attributeValueList.getJSONObject(j).getString("code"));
propSet.add(productProp); propSet.add(productProp);
} }
String attributeFrontName=attrSaleList.getJSONObject(i).getString("attributeFrontName"); String attributeFrontName = attrSaleList.getJSONObject(i).getString("attributeFrontName");
if(productPropSet.get(attributeFrontName)==null) { if (productPropSet.get(attributeFrontName) == null) {
productPropSet.put(attributeFrontName,propSet); productPropSet.put(attributeFrontName, propSet);
} else { } else {
Set<ProductProp> oldPropSet=productPropSet.get(attributeFrontName); Set<ProductProp> oldPropSet = productPropSet.get(attributeFrontName);
propSet.addAll(oldPropSet); propSet.addAll(oldPropSet);
productPropSet.put(attributeFrontName,propSet); productPropSet.put(attributeFrontName, propSet);
} }
} }
...@@ -87,12 +87,15 @@ public class SpiderUtil { ...@@ -87,12 +87,15 @@ public class SpiderUtil {
//////////////////获取商品属性 END////////////////// //////////////////获取商品属性 END//////////////////
itemInfo.setItemId(propObj.getString("style")); itemInfo.setItemId(propObj.getString("style"));
JSONArray itemImageList=propObj.getJSONArray("itemImageList"); if (propObj.get("itemImageList") != null && !"null".equalsIgnoreCase(propObj.getString("itemImageList"))) {
if(!itemImageList.isEmpty()) {
String pic=itemImageList.getJSONObject(0).getString("picUrl"); JSONArray itemImageList = propObj.getJSONArray("itemImageList");
if (!itemImageList.isEmpty()) {
String pic = itemImageList.getJSONObject(0).getString("picUrl");
//取第一张当作主图 //取第一张当作主图
itemInfo.setPic(pic); itemInfo.setPic(pic);
} }
}
itemInfo.setShopName(PlatformEnum.GAP.getLabel()); itemInfo.setShopName(PlatformEnum.GAP.getLabel());
itemInfo.setShopUrl("https://www.gap.cn/"); itemInfo.setShopUrl("https://www.gap.cn/");
itemInfo.setTitle(propObj.getString("title")); itemInfo.setTitle(propObj.getString("title"));
...@@ -100,11 +103,10 @@ public class SpiderUtil { ...@@ -100,11 +103,10 @@ public class SpiderUtil {
} }
//一口价 //一口价
productResponse.setPrice(dataMap.getString("minPrice")+"-"+dataMap.getString("maxPrice")); productResponse.setPrice(dataMap.getString("minPrice") + "-" + dataMap.getString("maxPrice"));
//一口价 //一口价
productResponse.setSalePrice(dataMap.getString("minPrice")+"-"+dataMap.getString("maxPrice")); productResponse.setSalePrice(dataMap.getString("minPrice") + "-" + dataMap.getString("maxPrice"));
//没有库存信息 需要另外获取 //没有库存信息 需要另外获取
productResponse.setStockFlag(false); productResponse.setStockFlag(false);
//有商品属性 //有商品属性
...@@ -116,6 +118,7 @@ public class SpiderUtil { ...@@ -116,6 +118,7 @@ public class SpiderUtil {
productResponse.setProductPropSet(productPropSet); productResponse.setProductPropSet(productPropSet);
return productResponse; return productResponse;
} }
/** /**
* 格式化 nike 返回数据 * 格式化 nike 返回数据
* *
...@@ -136,52 +139,52 @@ public class SpiderUtil { ...@@ -136,52 +139,52 @@ public class SpiderUtil {
dynStock.setSellableQuantity(9999); dynStock.setSellableQuantity(9999);
//商品基本信息 //商品基本信息
ItemInfo itemInfo = new ItemInfo(); ItemInfo itemInfo = new ItemInfo();
JSONObject threadObj=dataMap.getJSONObject("Threads"); JSONObject threadObj = dataMap.getJSONObject("Threads");
JSONObject productsObj=threadObj.getJSONObject("products"); JSONObject productsObj = threadObj.getJSONObject("products");
Set es = productsObj.entrySet(); Set es = productsObj.entrySet();
Iterator it = es.iterator(); Iterator it = es.iterator();
while(it.hasNext()) { while (it.hasNext()) {
Map.Entry<String,JSONObject> entry = (Map.Entry) it.next(); Map.Entry<String, JSONObject> entry = (Map.Entry) it.next();
String skuStr=";"; String skuStr = ";";
String modelCode = entry.getKey(); String modelCode = entry.getKey();
skuStr=skuStr+modelCode+";"; skuStr = skuStr + modelCode + ";";
JSONObject itemDetail = entry.getValue(); JSONObject itemDetail = entry.getValue();
////////////////////////////////////获取价格和商品属性//////////////////////////////////////////// ////////////////////////////////////获取价格和商品属性////////////////////////////////////////////
String fullPrice =itemDetail.getString("fullPrice"); String fullPrice = itemDetail.getString("fullPrice");
String currentPrice =itemDetail.getString("currentPrice"); String currentPrice = itemDetail.getString("currentPrice");
productResponse.setPrice(currentPrice); productResponse.setPrice(currentPrice);
JSONArray skusArr=itemDetail.getJSONArray("skus"); JSONArray skusArr = itemDetail.getJSONArray("skus");
//获取商品尺码属性,同时记录下skuid和尺码关系 //获取商品尺码属性,同时记录下skuid和尺码关系
Map<String,String> sizeSkuIdMapping=new HashMap<>(); Map<String, String> sizeSkuIdMapping = new HashMap<>();
for(int i=0;i<skusArr.size();i++) { for (int i = 0; i < skusArr.size(); i++) {
String skuId=skusArr.getJSONObject(i).getString("skuId"); String skuId = skusArr.getJSONObject(i).getString("skuId");
/////////////////////////获取商品尺码属性//////////////////// /////////////////////////获取商品尺码属性////////////////////
//商品属性 //商品属性
Set<ProductProp> sizePropSet=new HashSet<>(); Set<ProductProp> sizePropSet = new HashSet<>();
ProductProp productProp = new ProductProp(); ProductProp productProp = new ProductProp();
String localizedSize=skusArr.getJSONObject(i).getString("localizedSize"); String localizedSize = skusArr.getJSONObject(i).getString("localizedSize");
String localizedSizePrefix=skusArr.getJSONObject(i).getString("localizedSizePrefix"); String localizedSizePrefix = skusArr.getJSONObject(i).getString("localizedSizePrefix");
//因为尺码一样的时候skuid却不一样,这里只能赋予一个propid,否则后面去重不了 //因为尺码一样的时候skuid却不一样,这里只能赋予一个propid,否则后面去重不了
String customizeId= KeyConstant.CUSTOMIZE_ID +localizedSize+localizedSizePrefix; String customizeId = KeyConstant.CUSTOMIZE_ID + localizedSize + localizedSizePrefix;
sizeSkuIdMapping.put(skuId,customizeId); sizeSkuIdMapping.put(skuId, customizeId);
productProp.setPropId(customizeId); productProp.setPropId(customizeId);
productProp.setPropName(localizedSizePrefix+" "+localizedSize); productProp.setPropName(localizedSizePrefix + " " + localizedSize);
sizePropSet.add(productProp); sizePropSet.add(productProp);
if(productPropSet.get("尺码")==null) { if (productPropSet.get("尺码") == null) {
productPropSet.put("尺码",sizePropSet); productPropSet.put("尺码", sizePropSet);
} else { } else {
Set<ProductProp> oldPropSet=productPropSet.get("尺码"); Set<ProductProp> oldPropSet = productPropSet.get("尺码");
sizePropSet.addAll(oldPropSet); sizePropSet.addAll(oldPropSet);
productPropSet.put("尺码",sizePropSet); productPropSet.put("尺码", sizePropSet);
} }
/////////////////////////获取商品尺码属性 END//////////////////// /////////////////////////获取商品尺码属性 END////////////////////
} }
////////////////////////////////////获取价格////////////////////////////////// ////////////////////////////////////获取价格//////////////////////////////////
for(int i=0;i<skusArr.size();i++) { for (int i = 0; i < skusArr.size(); i++) {
String skuId=skusArr.getJSONObject(i).getString("skuId"); String skuId = skusArr.getJSONObject(i).getString("skuId");
String customizeId=sizeSkuIdMapping.get(skuId); String customizeId = sizeSkuIdMapping.get(skuId);
OriginalPrice originalPrice = new OriginalPrice(); OriginalPrice originalPrice = new OriginalPrice();
originalPrice.setSkuStr(skuStr + customizeId + ";"); originalPrice.setSkuStr(skuStr + customizeId + ";");
originalPrice.setPrice(fullPrice); originalPrice.setPrice(fullPrice);
...@@ -200,17 +203,17 @@ public class SpiderUtil { ...@@ -200,17 +203,17 @@ public class SpiderUtil {
/////////////////////////////////////获取价格和商品属性 END//////////////////////////////////////////// /////////////////////////////////////获取价格和商品属性 END////////////////////////////////////////////
////////////////////////////////////获取库存 //////////////////////////////////////////// ////////////////////////////////////获取库存 ////////////////////////////////////////////
productResponse.setStockFlag(true); productResponse.setStockFlag(true);
List<ProductSkuStock> productSkuStockList =dynStock.getProductSkuStockList(); List<ProductSkuStock> productSkuStockList = dynStock.getProductSkuStockList();
if(productSkuStockList==null) { if (productSkuStockList == null) {
productSkuStockList=new ArrayList<>(); productSkuStockList = new ArrayList<>();
} }
JSONArray availableSkusArr=itemDetail.getJSONArray("availableSkus"); JSONArray availableSkusArr = itemDetail.getJSONArray("availableSkus");
for(int i=0;i<availableSkusArr.size();i++) { for (int i = 0; i < availableSkusArr.size(); i++) {
String skuId=availableSkusArr.getJSONObject(i).getString("skuId"); String skuId = availableSkusArr.getJSONObject(i).getString("skuId");
String customizeId=sizeSkuIdMapping.get(skuId); String customizeId = sizeSkuIdMapping.get(skuId);
ProductSkuStock productSkuStock = new ProductSkuStock(); ProductSkuStock productSkuStock = new ProductSkuStock();
productSkuStock.setSellableQuantity(999); productSkuStock.setSellableQuantity(999);
productSkuStock.setSkuStr(skuStr+customizeId+";"); productSkuStock.setSkuStr(skuStr + customizeId + ";");
productSkuStockList.add(productSkuStock); productSkuStockList.add(productSkuStock);
} }
dynStock.setProductSkuStockList(productSkuStockList); dynStock.setProductSkuStockList(productSkuStockList);
...@@ -218,33 +221,33 @@ public class SpiderUtil { ...@@ -218,33 +221,33 @@ public class SpiderUtil {
////////////////////////////////////获取库存 END//////////////////////////////////////////// ////////////////////////////////////获取库存 END////////////////////////////////////////////
////////////////////////////////////获取商品颜色属性//////////////////////////////////////////// ////////////////////////////////////获取商品颜色属性////////////////////////////////////////////
//商品属性 //商品属性
Set<ProductProp> propSet=new HashSet<>(); Set<ProductProp> propSet = new HashSet<>();
ProductProp productProp = new ProductProp(); ProductProp productProp = new ProductProp();
String colorDescription=itemDetail.getString("colorDescription"); String colorDescription = itemDetail.getString("colorDescription");
String firstImageUrl=itemDetail.getString("firstImageUrl"); String firstImageUrl = itemDetail.getString("firstImageUrl");
productProp.setPropId(modelCode); productProp.setPropId(modelCode);
productProp.setPropName(colorDescription); productProp.setPropName(colorDescription);
productProp.setImage(firstImageUrl); productProp.setImage(firstImageUrl);
propSet.add(productProp); propSet.add(productProp);
if(productPropSet.get("颜色")==null) { if (productPropSet.get("颜色") == null) {
productPropSet.put("颜色",propSet); productPropSet.put("颜色", propSet);
} else { } else {
Set<ProductProp> oldPropSet=productPropSet.get("颜色"); Set<ProductProp> oldPropSet = productPropSet.get("颜色");
propSet.addAll(oldPropSet); propSet.addAll(oldPropSet);
productPropSet.put("颜色",propSet); productPropSet.put("颜色", propSet);
} }
////////////////////////////////////获取商品属性 END//////////////////////////////////////////// ////////////////////////////////////获取商品属性 END////////////////////////////////////////////
} }
JSONObject globalObj=dataMap.getJSONObject("global"); JSONObject globalObj = dataMap.getJSONObject("global");
JSONObject metaTagsObj=globalObj.getJSONObject("metaTags"); JSONObject metaTagsObj = globalObj.getJSONObject("metaTags");
JSONArray metaArr=metaTagsObj.getJSONArray("meta"); JSONArray metaArr = metaTagsObj.getJSONArray("meta");
for(int i=0;i<metaArr.size();i++) { for (int i = 0; i < metaArr.size(); i++) {
if(metaArr.getJSONObject(i).get("property")!=null) { if (metaArr.getJSONObject(i).get("property") != null) {
String propertyValue=metaArr.getJSONObject(i).getString("property"); String propertyValue = metaArr.getJSONObject(i).getString("property");
if("og:title".equalsIgnoreCase(propertyValue)) { if ("og:title".equalsIgnoreCase(propertyValue)) {
itemInfo.setTitle(metaArr.getJSONObject(i).getString("content")); itemInfo.setTitle(metaArr.getJSONObject(i).getString("content"));
} }
if("og:image".equalsIgnoreCase(propertyValue)) { if ("og:image".equalsIgnoreCase(propertyValue)) {
itemInfo.setPic(metaArr.getJSONObject(i).getString("content")); itemInfo.setPic(metaArr.getJSONObject(i).getString("content"));
} }
} }
...@@ -260,4 +263,98 @@ public class SpiderUtil { ...@@ -260,4 +263,98 @@ public class SpiderUtil {
productResponse.setDynStock(dynStock); productResponse.setDynStock(dynStock);
return productResponse; return productResponse;
} }
/**
* 格式化 afric-eshop 返回数据
*
* @param resultObj
* @return
*/
public static ProductResponse formatAfricaShopProductResponse(JSONObject resultObj) {
ProductResponse productResponse = new ProductResponse();
//原始价
List<OriginalPrice> originalPriceList = new ArrayList<>();
//促销价格 TODO
List<ProductPromotion> promotionList = new ArrayList<>();
//库存
DynStock dynStock = new DynStock();
//其实数据没有包含确切的库存数,这里默认给足量的库存
dynStock.setSellableQuantity(9999);
//nike 基本是 颜色、尺码属性
Map<String, Set<ProductProp>> productPropSet = new HashMap<>();
//商品基本信息
ItemInfo itemInfo = new ItemInfo();
JSONArray variantsArray = resultObj.getJSONArray("variants");
//属性
JSONArray optionsArray = resultObj.getJSONArray("options");
for (int i = 0; i < variantsArray.size(); i++) {
//属性
JSONArray itemOptionsArray = variantsArray.getJSONObject(i).getJSONArray("options");
//没有属性的时候,会返回 Default Title
if("Default Title".equalsIgnoreCase(itemOptionsArray.getString(0))) {
break;
}
String skuStr = ";";
for (int m = 0; m < itemOptionsArray.size(); m++) {
skuStr = skuStr + KeyConstant.CUSTOMIZE_ID + itemOptionsArray.getString(m) + ";";
}
///////////////////原始价////////////////////////////////////
OriginalPrice originalPrice = new OriginalPrice();
String price = variantsArray.getJSONObject(i).getString("price");
originalPrice.setPrice(price);
originalPrice.setSkuStr(skuStr);
originalPriceList.add(originalPrice);
///////////////////原始价 END////////////////////////////////
////////////////////////////////////获取库存 ////////////////////////////////////////////
productResponse.setStockFlag(true);
List<ProductSkuStock> productSkuStockList = dynStock.getProductSkuStockList();
if (productSkuStockList == null) {
productSkuStockList = new ArrayList<>();
}
ProductSkuStock productSkuStock = new ProductSkuStock();
productSkuStock.setSellableQuantity(999);
productSkuStock.setSkuStr(skuStr);
productSkuStockList.add(productSkuStock);
dynStock.setProductSkuStockList(productSkuStockList);
////////////////////////////////////获取库存 END////////////////////////////////////////////
//获取所有的属性
for (int j = 0; j < optionsArray.size(); j++) {
////////////////////////////////////获取商品属性////////////////////////////////////////////
//商品属性
Set<ProductProp> propSet = new HashSet<>();
ProductProp productProp = new ProductProp();
productProp.setPropId(KeyConstant.CUSTOMIZE_ID + itemOptionsArray.getString(j));
productProp.setPropName(itemOptionsArray.getString(j));
propSet.add(productProp);
if (productPropSet.get(optionsArray.getString(j)) == null) {
productPropSet.put(optionsArray.getString(j), propSet);
} else {
Set<ProductProp> oldPropSet = productPropSet.get(optionsArray.getString(j));
propSet.addAll(oldPropSet);
productPropSet.put(optionsArray.getString(j), propSet);
}
////////////////////////////////////获取属性 END////////////////////////////////////////////
}
}
itemInfo.setItemId(resultObj.getString("id"));
//取第一张
itemInfo.setPic(resultObj.getString("featured_image"));
itemInfo.setShopName(PlatformEnum.AfriEshop.getValue());
itemInfo.setShopUrl("https://www.afri-eshop.com/");
itemInfo.setTitle(resultObj.getString("title"));
productResponse.setPropFlag(true);
productResponse.setProductPropSet(productPropSet);
productResponse.setPlatform(PlatformEnum.AfriEshop.getValue());
productResponse.setPromotionList(promotionList);
productResponse.setOriginalPriceList(originalPriceList);
productResponse.setItemInfo(itemInfo);
productResponse.setDynStock(dynStock);
productResponse.setPrice(resultObj.getString("price"));
return productResponse;
}
} }
...@@ -3,9 +3,12 @@ package com.diaoyun.zion.master.util; ...@@ -3,9 +3,12 @@ package com.diaoyun.zion.master.util;
import com.diaoyun.zion.master.bo.TencentTranslateParam; import com.diaoyun.zion.master.bo.TencentTranslateParam;
import com.diaoyun.zion.master.thread.TaskLimitSemaphore; import com.diaoyun.zion.master.thread.TaskLimitSemaphore;
import com.diaoyun.zion.master.thread.TranslateCallable; import com.diaoyun.zion.master.thread.TranslateCallable;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -62,4 +65,74 @@ public class TranslateHelper { ...@@ -62,4 +65,74 @@ public class TranslateHelper {
valeMap.put("translate",targetText); 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: ...@@ -100,6 +100,6 @@ security:
jwt: jwt:
token: token:
secret-key: secret-key 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 @@ ...@@ -8,6 +8,7 @@
<result property="feeType" column="fee_type"/> <result property="feeType" column="fee_type"/>
<result property="enableFlag" column="enable_flag"/> <result property="enableFlag" column="enable_flag"/>
<result property="feePercent" column="fee_percent"/> <result property="feePercent" column="fee_percent"/>
<result property="feeRate" column="fee_rate"/>
</resultMap> </resultMap>
<select id="queryObject" resultType="com.diaoyun.zion.chinafrica.entity.TbCfFeeEntity"> <select id="queryObject" resultType="com.diaoyun.zion.chinafrica.entity.TbCfFeeEntity">
...@@ -15,7 +16,8 @@ ...@@ -15,7 +16,8 @@
`fee_id`, `fee_id`,
`fee_type`, `fee_type`,
`enable_flag`, `enable_flag`,
`fee_percent` `fee_percent`,
`fee_rate`
from tb_cf_fee from tb_cf_fee
where fee_id = #{id} where fee_id = #{id}
</select> </select>
...@@ -25,7 +27,8 @@ ...@@ -25,7 +27,8 @@
`fee_id`, `fee_id`,
`fee_type`, `fee_type`,
`enable_flag`, `enable_flag`,
`fee_percent` `fee_percent`,
`fee_rate`
from tb_cf_fee from tb_cf_fee
WHERE 1=1 WHERE 1=1
<if test="name != null and name.trim() != ''"> <if test="name != null and name.trim() != ''">
...@@ -57,12 +60,14 @@ ...@@ -57,12 +60,14 @@
`fee_id`, `fee_id`,
`fee_type`, `fee_type`,
`enable_flag`, `enable_flag`,
`fee_percent`) `fee_percent`,
`fee_rate`)
values( values(
#{feeId}, #{feeId},
#{feeType}, #{feeType},
#{enableFlag}, #{enableFlag},
#{feePercent}) #{feePercent},
#{feeRate})
</insert> </insert>
<update id="update" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfFeeEntity"> <update id="update" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfFeeEntity">
...@@ -70,7 +75,8 @@ ...@@ -70,7 +75,8 @@
<set> <set>
<if test="feeType != null">`fee_type` = #{feeType}, </if> <if test="feeType != null">`fee_type` = #{feeType}, </if>
<if test="enableFlag != null">`enable_flag` = #{enableFlag}, </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> </set>
where fee_id = #{feeId} where fee_id = #{feeId}
</update> </update>
...@@ -97,4 +103,16 @@ ...@@ -97,4 +103,16 @@
WHERE enable_flag=1 WHERE enable_flag=1
</select> </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> </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 @@ ...@@ -17,6 +17,23 @@
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
</resultMap> </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 id="queryObject" resultType="com.diaoyun.zion.chinafrica.entity.TbCfStationItemEntity">
select select
`item_id`, `item_id`,
...@@ -130,7 +147,10 @@ ...@@ -130,7 +147,10 @@
<!--获取商品独立站--> <!--获取商品独立站-->
<select id="getItemStationList" resultType="com.diaoyun.zion.chinafrica.entity.TbCfStationItemEntity"> <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> </select>
......
...@@ -22,8 +22,8 @@ email.subject=Verification Code from Chinafrica ...@@ -22,8 +22,8 @@ email.subject=Verification Code from Chinafrica
###################################邮箱 END############################################### ###################################邮箱 END###############################################
################redis有效时间################### ################redis有效时间###################
#登录token second 默认30分 一个星期 #登录token second 默认30分 一个星期 604800
redis.token.expiredTime=604800 redis.token.expiredTime=60480000
#订单 30分 second #订单 30分 second
redis.order.expiredTime=1800 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 @@ ...@@ -5,6 +5,5 @@
<title>Title</title> <title>Title</title>
</head> </head>
<body> <body>
dddddddddddddddddddd ddddddddddddddddddddddd</body>
</body>
</html> </html>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论