| | |
| | | package com.yeshi.fanli.controller;
|
| | |
|
| | | import java.io.BufferedReader;
|
| | | import java.io.File;
|
| | | import java.io.FileReader;
|
| | | import java.io.IOException;
|
| | | import java.io.InputStream;
|
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | | import java.util.Set;
|
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.script.Invocable;
|
| | | import javax.script.ScriptEngine;
|
| | | import javax.script.ScriptEngineManager;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | import org.jsoup.Jsoup;
|
| | | import org.jsoup.nodes.Document;
|
| | | import org.jsoup.select.Elements;
|
| | | import org.quartz.JobExecutionContext;
|
| | | import org.quartz.Scheduler;
|
| | | import org.quartz.SchedulerException;
|
| | | import org.springframework.cache.ehcache.EhCacheCacheManager;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | |
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.dao.dynamic.DynamicInfoDao;
|
| | | import com.yeshi.fanli.dao.mybatis.help.HelpCenterMapper;
|
| | | import com.yeshi.fanli.dto.ConfigParamsDTO;
|
| | | import com.yeshi.fanli.dto.jd.JDSearchResult;
|
| | | import com.yeshi.fanli.entity.bus.activity.ActivityShareResult;
|
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivity;
|
| | | import com.yeshi.fanli.entity.dynamic.DynamicInfo;
|
| | | import com.yeshi.fanli.entity.dynamic.GoodsPicture;
|
| | | import com.yeshi.fanli.entity.dynamic.InviteMaterial;
|
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | | import com.yeshi.fanli.entity.taobao.SearchFilter;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
|
| | | import com.yeshi.fanli.exception.ActivityException;
|
| | | import com.yeshi.fanli.exception.push.PushException;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.activity.ActivityService;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.dynamic.DynamicInfoService;
|
| | | import com.yeshi.fanli.service.inter.dynamic.InviteMaterialService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralGetService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FileUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.db.MongoDBManager;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | | import com.yeshi.fanli.util.push.OPPOPushUtil;
|
| | | import com.yeshi.fanli.util.push.VIVOPushUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | | import redis.clients.jedis.Jedis;
|
| | | import redis.clients.jedis.JedisPool;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("test")
|
| | |
| | | private HelpCenterMapper helpCenterMapper;
|
| | | @Resource
|
| | | private Scheduler scheduler;
|
| | |
|
| | | @Resource
|
| | | private DynamicInfoService dynamicInfoService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
|
| | |
|
| | | @Resource
|
| | | private EhCacheCacheManager ehCacheCacheManager;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private InviteMaterialService inviteMaterialService;
|
| | |
|
| | | @Resource
|
| | | private DynamicInfoDao dynamicInfoDao;
|
| | |
|
| | | @Resource
|
| | | private JedisPool jedisPool;
|
| | |
|
| | | @Resource
|
| | | private IntegralGetService integralGetService;
|
| | |
|
| | | @RequestMapping(value = "testimg")
|
| | | public void testImg(HttpServletRequest request, PrintWriter out) {
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | @RequestMapping(value = "testhtml")
|
| | | public void testhtml(PrintWriter out) {
|
| | | out.print("<script>yestv.finishPage();</script>");
|
| | | out.close();
|
| | | }
|
| | |
|
| | | /**
|
| | | * 清除缓存
|
| | | * |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "removeCache")
|
| | | public void removeCache(PrintWriter out) {
|
| | | ehCacheCacheManager.getCacheManager().clearAll();
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "removeRedisCache")
|
| | | public void removeRedisCache(String key, PrintWriter out) {
|
| | | redisManager.removeCommonString(key);
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "testConfig")
|
| | | public void getTestConfig(PrintWriter pw) {
|
| | | pw.print(configService.get("test"));
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "testDaTaoKe")
|
| | | public void getTestDaTaoKe(PrintWriter pw) {
|
| | | Document doc = null;
|
| | | try {
|
| | | doc = Jsoup.connect("http://www.dataoke.com/ddq").get();
|
| | | } catch (IOException e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | Elements els = doc.getElementsByTag("script");
|
| | | for (int i = 0; i < els.size(); i++) {
|
| | | String content = els.get(i).html();
|
| | | if (content.indexOf("var dataDef") > -1) {
|
| | | ScriptEngineManager manager = new ScriptEngineManager();
|
| | | ScriptEngine engine = manager.getEngineByName("javascript");
|
| | | try {
|
| | | String js = "function getData(){return JSON.stringify(dataDef);}" + content;
|
| | | engine.eval(js);
|
| | | if (engine instanceof Invocable) {
|
| | | Invocable in = (Invocable) engine;
|
| | | pw.print(in.invokeFunction("getData"));
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "insertShop")
|
| | | public void insertShop(PrintWriter out) {
|
| | | try {
|
| | | dynamicInfoService.insertShopInfo();
|
| | | dynamicInfoService.insertTimeHotSale();
|
| | | dynamicInfoService.insertTimeRecommend();
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 插入邀请素材
|
| | | * |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "uploadInviteMaterial")
|
| | | public void uploadInviteMaterial(PrintWriter out) {
|
| | | try {
|
| | | List<InviteMaterial> list = new ArrayList<InviteMaterial>();
|
| | |
|
| | | // 图片文件
|
| | | File file = new File("E:\\Invite\\Picture");
|
| | | File[] files = file.listFiles();
|
| | | for (File filePic : files) {// 遍历这个数组
|
| | | String name = filePic.getName();
|
| | | String prefix = name.substring(name.lastIndexOf(".") + 1);
|
| | | // 上传文件相对位置
|
| | | String filePath = "/resource/invite/everyday/" + UUID.randomUUID().toString().replace("-", "") + "."
|
| | | + prefix;
|
| | |
|
| | | String fileUrl = COSManager.getInstance().uploadFile(filePic, filePath).getUrl();
|
| | |
|
| | | System.out.println("FileName:" + name);
|
| | | System.out.println("url:" + fileUrl);
|
| | |
|
| | | InviteMaterial inviteMaterial = new InviteMaterial();
|
| | | inviteMaterial.setState(0);
|
| | | inviteMaterial.setPicture(fileUrl);
|
| | | list.add(inviteMaterial);
|
| | | }
|
| | |
|
| | | List<String> listTxt = new ArrayList<String>();
|
| | | File textfile = new File("E:\\Invite\\content.txt");// Text文件
|
| | | BufferedReader br = new BufferedReader(new FileReader(textfile));// 构造一个BufferedReader类来读取文件
|
| | | String s = "";
|
| | | while ((s = br.readLine()) != null) {// 使用readLine方法,一次读一行
|
| | | if (StringUtil.isNullOrEmpty(s)) {
|
| | | continue;
|
| | | }
|
| | | listTxt.add(s);
|
| | | }
|
| | | br.close();
|
| | |
|
| | | if (list.size() == 0 || listTxt.size() == 0 || listTxt.size() < list.size()) {
|
| | | return;
|
| | | }
|
| | |
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | InviteMaterial invite = list.get(i);
|
| | | invite.setText(listTxt.get(i));
|
| | | inviteMaterialService.insert(invite);
|
| | | }
|
| | | JsonUtil.printMode(out, null, JsonUtil.loadTrueResult("上传成功"));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, null, JsonUtil.loadFalseResult("上传失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 插入邀请素材
|
| | | * |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "uploadInviteMaterial2")
|
| | | public void uploadInviteMaterial2(PrintWriter out) {
|
| | | try {
|
| | | List<InviteMaterial> list = new ArrayList<InviteMaterial>();
|
| | | File picfile = new File("E:\\Invite\\pic.txt");// Text文件
|
| | | BufferedReader brp = new BufferedReader(new FileReader(picfile));// 构造一个BufferedReader类来读取文件
|
| | | String fileUrl = "";
|
| | | while ((fileUrl = brp.readLine()) != null) {// 使用readLine方法,一次读一行
|
| | | if (StringUtil.isNullOrEmpty(fileUrl)) {
|
| | | continue;
|
| | | }
|
| | | InviteMaterial inviteMaterial = new InviteMaterial();
|
| | | inviteMaterial.setId(UUID.randomUUID().toString().replace("-", ""));
|
| | | inviteMaterial.setState(0);
|
| | | inviteMaterial.setPicture(fileUrl);
|
| | | list.add(inviteMaterial);
|
| | | }
|
| | | brp.close();
|
| | |
|
| | | List<String> listTxt = new ArrayList<String>();
|
| | | File textfile = new File("E:\\Invite\\content.txt");// Text文件
|
| | | BufferedReader br = new BufferedReader(new FileReader(textfile));// 构造一个BufferedReader类来读取文件
|
| | | String s = "";
|
| | | while ((s = br.readLine()) != null) {// 使用readLine方法,一次读一行
|
| | | if (StringUtil.isNullOrEmpty(s)) {
|
| | | continue;
|
| | | }
|
| | | listTxt.add(s);
|
| | | }
|
| | | br.close();
|
| | |
|
| | | if (list.size() == 0 || listTxt.size() == 0 || listTxt.size() < list.size()) {
|
| | | return;
|
| | | }
|
| | |
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | InviteMaterial invite = list.get(i);
|
| | | invite.setText(listTxt.get(i));
|
| | | inviteMaterialService.insert(invite);
|
| | | }
|
| | | JsonUtil.printMode(out, null, JsonUtil.loadTrueResult("上传成功"));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, null, JsonUtil.loadFalseResult("上传失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 插入邀请素材
|
| | | * |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "saveInvite")
|
| | | public void saveInvite(InviteMaterial inviteMaterial, PrintWriter out) {
|
| | | try {
|
| | | inviteMaterial.setState(0);
|
| | | inviteMaterialService.insert(inviteMaterial);
|
| | | JsonUtil.printMode(out, null, JsonUtil.loadTrueResult("上传成功"));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, null, JsonUtil.loadFalseResult("上传失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 插入邀请素材
|
| | | * |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "insertTimeInvite")
|
| | | public void insertTimeInvite(PrintWriter out) {
|
| | | try {
|
| | | dynamicInfoService.insertTimeInvite();
|
| | | JsonUtil.printMode(out, null, JsonUtil.loadTrueResult("操作成功"));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, null, JsonUtil.loadFalseResult("操作失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 插入邀请素材
|
| | | * |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getJingFenList")
|
| | | public void getJingFenList(String callback, Integer page, Integer eliteId, PrintWriter out) {
|
| | | try {
|
| | | JDSearchResult result = JDApiUtil.getJingFenGoods(page, eliteId);
|
| | | long count = 0;
|
| | | JSONObject data = new JSONObject();
|
| | | JSONArray array = new JSONArray();
|
| | | if (result != null) {
|
| | | PageEntity pageEntity = result.getPageEntity();
|
| | | if (pageEntity != null) {
|
| | | count = pageEntity.getTotalCount();
|
| | | }
|
| | |
|
| | | List<JDGoods> goodsList = result.getGoodsList();
|
| | | if (goodsList != null && goodsList.size() > 0) {
|
| | | BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | | ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE);
|
| | |
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | | for (JDGoods goods : goodsList) {
|
| | | GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO);
|
| | | array.add(gson.toJson(goodsDetailVO));
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | data.put("count", count);
|
| | | data.put("list", array);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 插入邀请素材
|
| | | * |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "queryExistsId")
|
| | | public void queryExistsAuctionId(PrintWriter out) {
|
| | | try {
|
| | | List<DynamicInfo> list = dynamicInfoDao.queryExistsAuctionId();
|
| | | for (DynamicInfo dynamicInfo : list) {
|
| | | List<GoodsPicture> imgs = dynamicInfo.getImgs();
|
| | | if (imgs == null || imgs.size() == 0) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | boolean update = false;
|
| | | for (GoodsPicture goodsPicture : imgs) {
|
| | | TaoBaoGoodsBriefExtra goods = goodsPicture.getGoods();
|
| | | if (goods == null) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | if (goods.getAuctionId() == null) {
|
| | | update = true;
|
| | | goods.setAuctionId(goods.getId());
|
| | | }
|
| | | }
|
| | |
|
| | | if (update) {
|
| | | dynamicInfo.setImgs(imgs);
|
| | | dynamicInfoDao.updateGoodInfo(dynamicInfo);
|
| | | }
|
| | | }
|
| | | JsonUtil.printMode(out, null, JsonUtil.loadTrueResult("操作成功"));
|
| | | // JsonUtil.printMode(out, null,
|
| | | // JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(list)));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, null, JsonUtil.loadFalseResult("操作失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "getWaitingThreadsCount")
|
| | | public void getWaitingThreadsCount(PrintWriter out) {
|
| | | out.print(Constant.waitingThreadSet.size());
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "getBinFaRedisKey")
|
| | | public void getPinFaRedisKey(PrintWriter out) {
|
| | | JSONArray array = new JSONArray();
|
| | | Jedis jedis = jedisPool.getResource();
|
| | | try {
|
| | | Set<String> sets = jedis.keys("rs-*");
|
| | | for (Iterator<String> its = sets.iterator(); its.hasNext();)
|
| | | array.add(its.next());
|
| | | } finally {
|
| | | jedisPool.returnResource(jedis);
|
| | | }
|
| | | out.println(array.toString());
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "pushOppo")
|
| | | public void pushOppo(String registerId, PrintWriter out) {
|
| | | List<String> registerIds = new ArrayList<>();
|
| | | registerIds.add(registerId);
|
| | | try {
|
| | | OPPOPushUtil.pushUrl(registerIds, "测试网页推送", "测试网页推送内容", "http://www.baidu.com");
|
| | | } catch (PushException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | try {
|
| | | OPPOPushUtil.pushGoods(registerIds, "测试商品网页推送", "测试商品推送内容", 1, 577628549116L);
|
| | | } catch (PushException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | try {
|
| | | OPPOPushUtil.pushUserSignInNotification(registerIds, "测试签到推送", "测试签到推送");
|
| | | } catch (PushException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | try {
|
| | | OPPOPushUtil.pushWelfareCenter(registerIds, "测试福利中心推送", "测试福利中心推送");
|
| | | } catch (PushException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | try {
|
| | | OPPOPushUtil.pushZNX(registerIds, "测试站内信推送", "测试站内信推送");
|
| | | } catch (PushException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | out.print("success");
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "testListTLJGoods")
|
| | | public void getGoodsList(String callback, PrintWriter out) {
|
| | | SearchFilter sf = new SearchFilter();
|
| | | sf.setQuan(1);
|
| | | sf.setTmall(true);
|
| | | // sf.setEndPrice(new BigDecimal(1000));
|
| | | sf.setPage(1);
|
| | | sf.setPage(100);
|
| | | sf.setCateIds("16");
|
| | | sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW);
|
| | |
|
| | | TaoBaoSearchResult result = TaoKeApiUtil.searchWuLiao(sf);
|
| | | Gson gson = new Gson();
|
| | | JSONArray array = new JSONArray();
|
| | | for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs()) {
|
| | | array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, "100", null)));
|
| | | }
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(array)));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 插入邀请素材
|
| | | * |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "addInviteOrderLevelOne")
|
| | | public void addInviteOrderLevelOne(PrintWriter out) {
|
| | | try {
|
| | | System.out.println("-------------请求---------------");
|
| | | integralGetService.addShareSingleGoods(974767L);
|
| | | JsonUtil.printMode(out, null, JsonUtil.loadTrueResult("操作成功"));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, null, JsonUtil.loadFalseResult("操作失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping("pushVIVO")
|
| | | public void pushVIVO(PrintWriter out) {
|
| | | List<String> regList = new ArrayList<>();
|
| | | regList.add("15710270630271520610033");
|
| | | // regList.add("15711218630321520681531");
|
| | | // try {
|
| | | // VIVOPushUtil.pushUrl(regList, "标题", "网页内容", "http://www.baidu.com");
|
| | | // } catch (Exception e) {
|
| | | // }
|
| | |
|
| | | try {
|
| | | VIVOPushUtil.pushBaiChuanUrl(regList, "标题", "百川内容", "http://www.taobao.com");// 有bug
|
| | | // VIVOPushUtil.pushGoods(regList, "标题", "商品内容", 2, 100005625634L);
|
| | | // VIVOPushUtil.pushUserSignInNotification(regList, "标题", "签到");
|
| | | // VIVOPushUtil.pushWelfareCenter(regList,"标题", "福利中心");
|
| | | } catch (PushException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping("getSchedulerList")
|
| | | public void getSchedulerList(PrintWriter out) {
|
| | | try {
|
| | | for (String groupName : scheduler.getJobGroupNames()) {
|
| | | System.out.println(groupName);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | }
|
| | | }
|
| | |
|
| | | }
|