| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | |
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("admin/new/api/v1/taobao")
|
| | |
| | | private QualityFactoryService selectionGoodsService;
|
| | | @Resource
|
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private TaobaoMeterialService taobaoMeterialService;
|
| | | @Resource
|
| | | private GoodsClassService goodsClassService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private TaoBaoClassService taoBaoClassService;
|
| | | |
| | | |
| | |
|
| | | @RequestMapping(value = "getTBGoodsList", method = RequestMethod.POST)
|
| | | public void getTaoBaoGoodsBriefList(int pageIndex, String key, PrintWriter out) {
|
| | |
|
| | |
| | | JSONObject data = null;
|
| | | for (String id : ids) {
|
| | | data = new JSONObject();
|
| | | |
| | | TaoBaoGoodsBrief taoBaoGoodsBrief=null;
|
| | |
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = null;
|
| | | try {
|
| | | taoBaoGoodsBrief = TaoKeApiUtil.searchGoodsDetail(Long.parseLong(id));
|
| | | taoBaoGoodsBrief.setUpdatetime(new Date());
|
| | |
| | | }
|
| | | try {
|
| | | taoBaoGoodsBriefService.insertSelective(taoBaoGoodsBrief);
|
| | | // taoBaoGoodsBriefService.save(taoBaoGoodsBrief);
|
| | | // taoBaoGoodsBriefService.save(taoBaoGoodsBrief);
|
| | | data.put("id", id);
|
| | | data.put("msg", "添加成功");
|
| | | } catch (Exception e) {
|
| | |
| | | data = new JSONObject();
|
| | | try {
|
| | | taoBaoGoodsBriefService.addRecommendSectionGoods(rsid, tbid);
|
| | | data.put("id", tbid);
|
| | | data.put("msg", "添加成功");
|
| | | } catch (NotExistObjectException e) {
|
| | | data.put("id", tbid);
|
| | | data.put("msg", e.getMessage());
|
| | | } catch (ExistObjectException e) {
|
| | | data.put("id", tbid);
|
| | | data.put("msg", e.getMessage());
|
| | | }
|
| | | list.add(data);
|
| | | }
|
| | | JSONObject dataAll = new JSONObject();
|
| | | dataAll.put("list", list);
|
| | | out.print(JsonUtil.loadTrueResult(dataAll));
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * 方法说明: 添加商品到每日任务
|
| | | * |
| | | * @author mawurui createTime 2018年3月29日 上午11:36:25
|
| | | * @param tbids
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "addEveryDayTask", method = RequestMethod.POST)
|
| | | public void addEveryDayTask(String tbids, PrintWriter out) {
|
| | | String[] tbidStrArr = tbids.split(",");
|
| | | long[] tbidArr = StringUtil.parseLong(tbidStrArr);
|
| | | List<JSONObject> list = new ArrayList<JSONObject>();
|
| | | JSONObject data = null;
|
| | | for (long tbid : tbidArr) {
|
| | | data = new JSONObject();
|
| | | try {
|
| | | taoBaoGoodsBriefService.addEveryDayTask(tbid);
|
| | | data.put("id", tbid);
|
| | | data.put("msg", "添加成功");
|
| | | } catch (NotExistObjectException e) {
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "queryOnSale")
|
| | | public void queryOnSale(String callback, Integer pageIndex, Integer pageSize, String key, Long tbClassId, Integer startPrice,
|
| | | Integer endPrice, String startTkRate, String endTkRate, Integer sort, Integer istmall, Integer hasCoupon,
|
| | | Integer baoYou, Integer startDsr, Integer overseas, Integer needPrepay, Integer includePayRate30,
|
| | | Integer includeGoodRate, Integer includeRfdRate, Integer npxLevel, PrintWriter out) {
|
| | | public void queryOnSale(String callback, Integer pageIndex, Integer pageSize, String key, Long tbClassId,
|
| | | Integer startPrice, Integer endPrice, String startTkRate, String endTkRate, Integer sort, Integer istmall,
|
| | | Integer hasCoupon, Integer baoYou, Integer startDsr, Integer overseas, Integer needPrepay,
|
| | | Integer includePayRate30, Integer includeGoodRate, Integer includeRfdRate, Integer npxLevel,
|
| | | PrintWriter out) {
|
| | |
|
| | | try {
|
| | | |
| | |
|
| | | SearchFilter filter = new SearchFilter();
|
| | | |
| | |
|
| | | // 页大小,默认20,1~100
|
| | | if (pageSize == null || pageSize < 1)
|
| | |
| | | if (!StringUtil.isNullOrEmpty(key))
|
| | | filter.setKey(key);
|
| | |
|
| | | if(tbClassId != null ) {
|
| | | if (tbClassId != null) {
|
| | | GoodsClass rb = goodsClassService.getGoodsClass(tbClassId);
|
| | | if (rb == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("该类型已不存在,请刷新重试"));
|
| | | return;
|
| | | } else {
|
| | | |
| | |
|
| | | // 淘宝类目id
|
| | | String taoBaoCatIds = taoBaoClassService.getTaoBaoCatIds(tbClassId);
|
| | | |
| | | if (StringUtil.isNullOrEmpty(taoBaoCatIds)){
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(taoBaoCatIds)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("该类型淘宝id为空,请通知相关人员进行维护"));
|
| | | return;
|
| | | } else {
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | // 查询条件和类目id不能同时为空
|
| | | if (StringUtil.isNullOrEmpty(key) && tbClassId == null){
|
| | | if (StringUtil.isNullOrEmpty(key) && tbClassId == null) {
|
| | | filter.setKey("女装");
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | // 折扣价范围下限
|
| | | if (startPrice != null)
|
| | | filter.setStartPrice(new BigDecimal(startPrice));
|
| | |
| | |
|
| | | // 淘客佣金比率下限 如:1234表示12.34%
|
| | | if (!StringUtil.isNullOrEmpty(startTkRate)) {
|
| | | BigDecimal b = new BigDecimal(startTkRate);
|
| | | double df = b.setScale(2, BigDecimal.ROUND_FLOOR).doubleValue();
|
| | | int tkRate = (int) (df * 100);
|
| | | int tkRate = (int) (Float.parseFloat(startTkRate) * 100);
|
| | | filter.setStartTkRate(tkRate);
|
| | | }
|
| | |
|
| | | // 淘客佣金比率上限 如:1234表示12.34%
|
| | | if (!StringUtil.isNullOrEmpty(endTkRate)) {
|
| | | BigDecimal b = new BigDecimal(endTkRate);
|
| | | double df = b.setScale(2, BigDecimal.ROUND_FLOOR).doubleValue();
|
| | | int tkRate = (int) (df * 100);
|
| | | int tkRate = (int) (Float.parseFloat(endTkRate) * 100);
|
| | | filter.setEndTkRate(tkRate);
|
| | | }
|
| | |
|
| | |
| | | // 是否包邮,true表示包邮,空或false表示不限
|
| | | if (baoYou != null && baoYou == 1) {
|
| | | filter.setBaoYou(true);
|
| | | //filter.setIp("113.251.22.10");// 重庆
|
| | | // filter.setIp("113.251.22.10");// 重庆
|
| | | filter.setIp("218.72.111.105");// 杭州
|
| | | |
| | |
|
| | | }
|
| | |
|
| | | // 店铺dsr评分
|
| | |
| | | if (taoBaoGoodsBriefs == null || taoBaoGoodsBriefs.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未查询到淘宝商品信息"));
|
| | | return;
|
| | | } |
| | | }
|
| | |
|
| | | // 插入商品集合
|
| | | List<Long> listAuctionId = new ArrayList<Long>();
|
| | | for (TaoBaoGoodsBrief goodsBrief : taoBaoGoodsBriefs) {
|
| | | listAuctionId.add(goodsBrief.getAuctionId());
|
| | | }
|
| | | |
| | |
|
| | | // 验证是否存在数据库
|
| | | List<QualityFactory> listHas = selectionGoodsService.listQueryByAuctionId(listAuctionId);
|
| | | |
| | |
|
| | | List<Map<String, Object>> listmap = new ArrayList<Map<String, Object>>();
|
| | |
|
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) {
|
| | | |
| | |
|
| | | taoBaoGoodsBrief.setId(null);
|
| | | |
| | |
|
| | | Map<String, Object> map = new HashMap<String, Object>();
|
| | |
|
| | | map.put("pictUrl", taoBaoGoodsBrief.getPictUrl());
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | map.put("isExistence", existence);
|
| | |
|
| | |
| | | data.put("listGoods", gson.toJson(listmap));
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | |
| | |
|
| | | // 插入本地数据-淘宝数据记录
|
| | | taoBaoGoodsBriefRecordService.insertBatch(taoBaoGoodsBriefs);
|
| | | |
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | if (!StringUtil.isNullOrEmpty(key)) {
|
| | | filter.setKey(key);
|
| | | } else {
|
| | | // 高佣id |
| | | // 高佣id
|
| | | if (!StringUtil.isNullOrEmpty(catIds)) {
|
| | | |
| | |
|
| | | // 男装+ 类目id
|
| | | String[] split = catIds.split(",");
|
| | | filter.setCateIds(split[1]);
|
| | |
| | | filter.setStartPrice(new BigDecimal(startPrice));
|
| | |
|
| | | // 折扣价范围上限
|
| | | if (endPrice != null )
|
| | | if (endPrice != null)
|
| | | filter.setEndPrice(new BigDecimal(endPrice));
|
| | |
|
| | | // 佣金比率下限
|
| | |
| | | filter.setBaoYou(true);
|
| | |
|
| | | // 销量
|
| | | if (!StringUtil.isNullOrEmpty(startBiz30day))
|
| | | if (!StringUtil.isNullOrEmpty(startBiz30day))
|
| | | filter.setStartBiz30day(startBiz30day);
|
| | |
|
| | | List<TaoBaoUnionConfig> config = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID);
|
| | |
| | | List<Map<String, Object>> listmap = new ArrayList<Map<String, Object>>();
|
| | |
|
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) {
|
| | | |
| | |
|
| | | taoBaoGoodsBrief.setId(null);
|
| | | |
| | |
|
| | | Map<String, Object> map = new HashMap<String, Object>();
|
| | |
|
| | | map.put("pictUrl", taoBaoGoodsBrief.getPictUrl());
|
| | |
| | | data.put("listGoods", gson.toJson(listmap));
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | |
| | |
|
| | | // 插入本地数据-淘宝数据记录
|
| | | taoBaoGoodsBriefRecordService.insertBatch(taoBaoGoodsBriefs);
|
| | | }
|
| | | |
| | |
|
| | | } catch (Exception e) {
|
| | | // TODO Auto-generated catch block
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询异常"));
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | *
|
| | | * @param callback
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "searchMaterial")
|
| | | public void searchMaterial(String callback, Integer pageIndex, Integer pageSize, |
| | | String subName, String superName, PrintWriter out) {
|
| | | public void searchMaterial(String callback, Integer pageIndex, Integer pageSize, String subName, String superName,
|
| | | PrintWriter out) {
|
| | |
|
| | | try {
|
| | |
|
| | | List<TaobaoMeterial> taobaoMeterials = null;
|
| | | if (!StringUtil.isNullOrEmpty(subName) && !StringUtil.isNullOrEmpty(superName) ) {
|
| | | if (!StringUtil.isNullOrEmpty(subName) && !StringUtil.isNullOrEmpty(superName)) {
|
| | | taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperName(subName, superName);
|
| | | } else if (!StringUtil.isNullOrEmpty(superName)) {
|
| | | taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperName(null, superName);
|
| | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择筛选类目"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("类目信息不存在"));
|
| | | return;
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | TaobaoMeterial taobaoMeterial = taobaoMeterials.get(0);
|
| | | Integer materialId = taobaoMeterial.getMaterialId();
|
| | | if (materialId == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("该类目物料ID不存在"));
|
| | | return;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | // 页大小,默认20,1~100
|
| | | if (pageSize == null || pageSize < 1)
|
| | | pageSize = Constant.PAGE_SIZE;
|
| | |
|
| | |
|
| | | // 第几页,默认:1
|
| | | if (pageIndex == null || pageIndex < 1)
|
| | | pageIndex = 1;
|
| | |
|
| | | TaoBaoSearchResult result = TaoKeApiUtil.getMaterialByMaterialId(materialId, pageIndex, pageSize);
|
| | | |
| | |
|
| | | if (result == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂未获取到相关数据"));
|
| | | return;
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = result.getTaoBaoGoodsBriefs();
|
| | | if (taoBaoGoodsBriefs == null || taoBaoGoodsBriefs.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无相关数据"));
|
| | | return;
|
| | | } |
| | | |
| | | |
| | | }
|
| | |
|
| | | // 插入商品集合
|
| | | List<Long> listAuctionId = new ArrayList<Long>();
|
| | | for (TaoBaoGoodsBrief goodsBrief : taoBaoGoodsBriefs) {
|
| | | listAuctionId.add(goodsBrief.getAuctionId());
|
| | | }
|
| | | |
| | |
|
| | | // 验证是否存在数据库
|
| | | List<QualityFactory> listHas = selectionGoodsService.listQueryByAuctionId(listAuctionId);
|
| | | |
| | | |
| | |
|
| | | List<Map<String, Object>> listmap = new ArrayList<Map<String, Object>>();
|
| | |
|
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) {
|
| | | taoBaoGoodsBrief.setId(null);
|
| | | |
| | | Map<String, Object> map = new HashMap<String, Object>();
|
| | |
|
| | | Map<String, Object> map = new HashMap<String, Object>();
|
| | |
|
| | | map.put("pictUrl", taoBaoGoodsBrief.getPictUrl());
|
| | | map.put("title", taoBaoGoodsBrief.getTitle());
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | map.put("isExistence", existence);
|
| | |
|
| | | listmap.add(map);
|
| | |
| | | data.put("listGoods", gson.toJson(listmap));
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | |
| | |
|
| | | // 插入本地数据-淘宝数据记录
|
| | | taoBaoGoodsBriefRecordService.insertBatch(taoBaoGoodsBriefs);
|
| | | |
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | | |
| | |
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | @RequestMapping(value = "getQiangGou")
|
| | | public void getQiangGou(String callback, Integer pageIndex, PrintWriter out) {
|
| | |
|
| | | try {
|
| | |
|
| | | |
| | | int pageSize = 40;
|
| | |
|
| | | // 第几页,默认:1
|
| | | if (pageIndex == null || pageIndex < 1)
|
| | | pageIndex = 1;
|
| | | |
| | |
|
| | | String startTime = "2018-09-17 09:00:00";
|
| | | |
| | | String endTime ="2018-09-17 16:00:00";
|
| | | |
| | | TaoBaoSearchResult result = TaoKeApiUtil.taoQiangGou(pageIndex, pageSize,startTime, endTime);
|
| | | |
| | | |
| | | |
| | |
|
| | | String endTime = "2018-09-17 16:00:00";
|
| | |
|
| | | TaoBaoSearchResult result = TaoKeApiUtil.taoQiangGou(pageIndex, pageSize, startTime, endTime);
|
| | |
|
| | | if (result == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂未获取到相关数据"));
|
| | | return;
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = result.getTaoBaoGoodsBriefs();
|
| | | if (taoBaoGoodsBriefs == null || taoBaoGoodsBriefs.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无相关数据"));
|
| | | return;
|
| | | } |
| | | |
| | | |
| | | }
|
| | |
|
| | | // 插入商品集合
|
| | | List<Long> listAuctionId = new ArrayList<Long>();
|
| | | for (TaoBaoGoodsBrief goodsBrief : taoBaoGoodsBriefs) {
|
| | | listAuctionId.add(goodsBrief.getAuctionId());
|
| | | }
|
| | | |
| | |
|
| | | // 验证是否存在数据库
|
| | | List<QualityFactory> listHas = selectionGoodsService.listQueryByAuctionId(listAuctionId);
|
| | | |
| | | |
| | |
|
| | | List<Map<String, Object>> listmap = new ArrayList<Map<String, Object>>();
|
| | |
|
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) {
|
| | | taoBaoGoodsBrief.setId(null);
|
| | | |
| | | Map<String, Object> map = new HashMap<String, Object>();
|
| | |
|
| | | Map<String, Object> map = new HashMap<String, Object>();
|
| | |
|
| | | map.put("pictUrl", taoBaoGoodsBrief.getPictUrl());
|
| | | map.put("title", taoBaoGoodsBrief.getTitle());
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | map.put("isExistence", existence);
|
| | |
|
| | | listmap.add(map);
|
| | |
| | | data.put("listGoods", gson.toJson(listmap));
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | |
| | | // // 插入本地数据-淘宝数据记录
|
| | |
|
| | | // // 插入本地数据-淘宝数据记录
|
| | | taoBaoGoodsBriefRecordService.insertBatch(taoBaoGoodsBriefs);
|
| | | |
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | | |
| | |
|
| | | }
|
| | | |
| | |
|
| | | }
|