| | |
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
| | |
|
| | | 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.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.entity.taobao.TaobaoMeterial;
|
| | | import com.yeshi.fanli.exception.ExistObjectException;
|
| | | import com.yeshi.fanli.exception.NotExistObjectException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.service.inter.goods.GoodsClassService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoClassService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefRecordService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityFactoryService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaobaoMeterialService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.GsonUtil;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
|
| | | @Resource
|
| | | private TaoBaoGoodsBriefRecordService taoBaoGoodsBriefRecordService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | | @Resource
|
| | | private QualityFactoryService qualityFactoryService;
|
| | | |
| | | @Resource
|
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService;
|
| | |
|
| | |
| | | @Resource
|
| | | private TaoBaoClassService taoBaoClassService;
|
| | |
|
| | | @RequestMapping(value = "getTBGoodsList", method = RequestMethod.POST)
|
| | | public void getTaoBaoGoodsBriefList(int pageIndex, String key, PrintWriter out) {
|
| | |
|
| | | List<TaoBaoGoodsBrief> taoBaoGoodsBriefList = taoBaoGoodsBriefService.getTBList(pageIndex - 1, key);
|
| | | int count = taoBaoGoodsBriefService.getCount(key);
|
| | | int totalPage = count % Constant.PAGE_SIZE == 0 ? count / Constant.PAGE_SIZE : count / Constant.PAGE_SIZE + 1;
|
| | | PageEntity pe = new PageEntity(pageIndex, Constant.PAGE_SIZE, count, totalPage);
|
| | | Map<String, String> map = new HashMap<String, String>();
|
| | | map.put("key", key);
|
| | | pe.setParams(map);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("taoBaoGoodsBriefList", GsonUtil.toDFJson(taoBaoGoodsBriefList));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "getInvalidTaoBaoGoods", method = RequestMethod.POST)
|
| | | public void getInvalidTaoBaoGoods(int pageIndex, PrintWriter out) {
|
| | | List<TaoBaoGoodsBrief> taoBaoGoodsBriefList = taoBaoGoodsBriefService.getInvalidTB(pageIndex);
|
| | | int count = taoBaoGoodsBriefService.getInvalidCount();
|
| | | int totalPage = count % Constant.PAGE_SIZE == 0 ? count / Constant.PAGE_SIZE : count / Constant.PAGE_SIZE + 1;
|
| | | PageEntity pe = new PageEntity(pageIndex, Constant.PAGE_SIZE, count, totalPage);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("taoBaoGoodsBriefList", GsonUtil.toDFJson(taoBaoGoodsBriefList));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "getTaobaoGoods", method = RequestMethod.POST)
|
| | | public void getTaoBaoGoodsBrief(long id, PrintWriter out) {
|
| | | TaoBaoGoodsBrief taobao = taoBaoGoodsBriefService.getTaoBao(id);
|
| | |
|
| | | if (taobao == null) {
|
| | | out.append(JsonUtil.loadFalseResult("不存在该商品"));
|
| | | return;
|
| | | }
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("taobao", GsonUtil.toDFJson(taobao));
|
| | | List<String> list = new ArrayList<String>();
|
| | | list = TaoBaoUtil.getTbImg(taobao.getAuctionId() + "");
|
| | | data.put("imgList", list);
|
| | | out.append(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "updateTaoBaoGoodsBrief", method = RequestMethod.POST)
|
| | | public void updateTaoBaoGoodsBrief(TaoBaoGoodsBrief tb, PrintWriter out) {
|
| | | try {
|
| | | taoBaoGoodsBriefService.updateTBGoods(tb);
|
| | | } catch (NotExistObjectException e) {
|
| | | out.append(JsonUtil.loadFalseResult(e.getMessage()));
|
| | | return;
|
| | | }
|
| | | out.append(JsonUtil.loadTrueResult("修改成功"));
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "deleteTaoBaoGoods", method = RequestMethod.POST)
|
| | | public void deleteTaoBaoGoods(long[] ids, PrintWriter out) {
|
| | | for (long id : ids) {
|
| | | taoBaoGoodsBriefService.deleteTaoBaoGoods(id);
|
| | | }
|
| | | out.append(JsonUtil.loadTrueResult("删除成功"));
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "addTaoBaoGoodsBrief", method = RequestMethod.POST)
|
| | | public void addTaoBaoGoodsBrief(String[] ids, PrintWriter out) {
|
| | | List<JSONObject> list = new ArrayList<JSONObject>();
|
| | | JSONObject data = null;
|
| | | for (String id : ids) {
|
| | | data = new JSONObject();
|
| | |
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = null;
|
| | | try {
|
| | | taoBaoGoodsBrief = TaoKeApiUtil.searchGoodsDetail(Long.parseLong(id));
|
| | | taoBaoGoodsBrief.setUpdatetime(new Date());
|
| | | taoBaoGoodsBrief.setCreatetime(new Date());
|
| | | } catch (NumberFormatException e1) {
|
| | | e1.printStackTrace();
|
| | | } catch (TaobaoGoodsDownException e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | try {
|
| | | taoBaoGoodsBriefService.insertSelective(taoBaoGoodsBrief);
|
| | | // taoBaoGoodsBriefService.save(taoBaoGoodsBrief);
|
| | | data.put("id", id);
|
| | | data.put("msg", "添加成功");
|
| | | } catch (Exception e) {
|
| | | data.put("id", id);
|
| | | data.put("msg", e.getMessage());
|
| | | }
|
| | | list.add(data);
|
| | | }
|
| | | JSONObject dataAll = new JSONObject();
|
| | | dataAll.put("list", list);
|
| | | out.print(JsonUtil.loadTrueResult(dataAll));
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "addRecommendSectionGoods", method = RequestMethod.POST)
|
| | | public void addRecommendSectionGoods(long rsid, 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.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));
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "addClassRecommendGoods", method = RequestMethod.POST)
|
| | | public void addClassRecommendGoods(long gcid, 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.addClassRecommendGoods(gcid, 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));
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "updateAllTaoBaoGoods", method = RequestMethod.POST)
|
| | | public void updateAllTaoBaoGoods(PrintWriter out) {
|
| | | taoBaoGoodsBriefService.getUpdateTaoBao();
|
| | | out.print(JsonUtil.loadTrueResult("更新完成"));
|
| | | }
|
| | |
|
| | | /**
|
| | | *
|
| | |
| | | AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
|
| | | // 插入精选库
|
| | | qualityFactoryService.addBatchTaoBaoGoods(listAddGoods, lableNames, admin);
|
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("加入成功"));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, e.getMessage()));
|
| | |
| | | data.put("listGoods", gson.toJson(listmap));
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | // 插入本地数据-淘宝数据记录
|
| | | taoBaoGoodsBriefRecordService.insertBatch(taoBaoGoodsBriefs);
|
| | | }
|
| | |
|
| | | } catch (Exception e) {
|
| | |
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | // 插入本地数据-淘宝数据记录
|
| | | taoBaoGoodsBriefRecordService.insertBatch(taoBaoGoodsBriefs);
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询异常"));
|
| | | e.printStackTrace();
|
| | |
| | | }
|
| | |
|
| | | 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();
|