| | |
| | | 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 org.springframework.cache.ehcache.EhCacheCacheManager;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.QRCodeUtil;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | | import org.yeshi.utils.wx.WXUtil;
|
| | |
|
| | | 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.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.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
|
| | | 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.dynamic.DynamicInfoService;
|
| | | import com.yeshi.fanli.service.inter.dynamic.InviteMaterialService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyExtraService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralGetService;
|
| | | 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.TimeUtil;
|
| | | 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.vo.goods.GoodsDetailVO;
|
| | | import com.yeshi.fanli.util.push.OPPOPushUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | | import redis.clients.jedis.Jedis;
|
| | | import redis.clients.jedis.JedisPool;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("test")
|
| | |
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private InviteMaterialService inviteMaterialService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private DynamicInfoDao dynamicInfoDao;
|
| | | |
| | |
|
| | | @RequestMapping(value = "testimg")
|
| | | public void testImg(HttpServletRequest request, PrintWriter out) {
|
| | | long startTime = System.currentTimeMillis();
|
| | | @Resource
|
| | | private JedisPool jedisPool;
|
| | |
|
| | | List<String> list = new ArrayList<>();
|
| | | for (int i = 0; i < 10; i++) {
|
| | | list.add("i" + i);
|
| | | }
|
| | | @Resource
|
| | | private IntegralGetService integralGetService;
|
| | |
|
| | | try {
|
| | | final TaoBaoGoodsBrief goods = redisManager.getTaoBaoGoodsBrief(569823237075L);
|
| | | } catch (TaobaoGoodsDownException e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | String url = "http://www.baidu.com";
|
| | | list.parallelStream().forEach(ids -> {
|
| | | InputStream portrait = HttpUtil.getAsInputStream(
|
| | | "https://wwc.alicdn.com/avatar/getAvatar.do?userId=1889722423&width=160&height=160&type=sns");
|
| | | System.out.println(ids + "开始时间:" + System.currentTimeMillis());
|
| | | String uid = "123";
|
| | | String auctionId = "test-" + ids;
|
| | |
|
| | | String destPath = FileUtil.getCacheDir() + "/" + auctionId + ".jpg";
|
| | |
|
| | | String shareImgPath = FileUtil.getCacheDir() + "/share_" + uid + "_" + auctionId + ".png";
|
| | |
|
| | | try {
|
| | | QRCodeUtil.getInstance(500).encode(url, destPath);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | long startDTime = System.currentTimeMillis();
|
| | |
|
| | | /*
|
| | | * try { //ImageUtil.drawGoodsShareImg(new FileInputStream(new
|
| | | * File(destPath)), portrait, goods, shareImgPath); } catch
|
| | | * (FileNotFoundException e) { e.printStackTrace(); }
|
| | | */
|
| | | System.out.println(System.currentTimeMillis() - startDTime);
|
| | |
|
| | | String shareImgUrl = COSManager.getInstance()
|
| | | .uploadFile(new File(shareImgPath), "share_" + uid + "_" + auctionId + ".png").getUrl();
|
| | | System.out.println(ids + "结束时间:" + System.currentTimeMillis());
|
| | | });
|
| | | System.out.println("整体耗时:" + (System.currentTimeMillis() - startTime));
|
| | | }
|
| | | @Resource
|
| | | private UserMoneyExtraService userMoneyExtraService;
|
| | |
|
| | | @RequestMapping(value = "kefu")
|
| | | public void kefu(HttpServletRequest request, PrintWriter out) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @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();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 插入邀请素材
|
| | | *
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 插入邀请素材
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getJingFenList")
|
| | | public void getJingFenList(String callback, Integer page, Integer eliteId, PrintWriter out) {
|
| | | |
| | | @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 {
|
| | | 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();
|
| | | }
|
| | | Set<String> sets = jedis.keys("rs-*");
|
| | | for (Iterator<String> its = sets.iterator(); its.hasNext();)
|
| | | array.add(its.next());
|
| | | } finally {
|
| | | jedis.close();
|
| | | }
|
| | | out.println(array.toString());
|
| | | }
|
| | |
|
| | | List<JDGoods> goodsList = result.getGoodsList();
|
| | | if (goodsList != null && goodsList.size() > 0) {
|
| | | BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | | for (JDGoods goods : goodsList) {
|
| | | GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(goods, fanLiRate, shareRate);
|
| | | 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("操作失败"));
|
| | | @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("getLocalTime")
|
| | | public void getLocalTime(PrintWriter out) {
|
| | | out.print(TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
|
| | | }
|
| | |
|
| | | @RequestMapping("getSchedulerList")
|
| | | public void getSchedulerList(PrintWriter out) {
|
| | | try {
|
| | | for (String groupName : scheduler.getJobGroupNames()) {
|
| | | System.out.println(groupName);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping("getTBGoodsCate")
|
| | | public void getTaoBaoGoodsCat(Long id, PrintWriter out) {
|
| | | TaoBaoGoodsBrief goods = null;
|
| | | try {
|
| | | goods = TaoKeApiUtil.getSimpleGoodsInfo(id);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | if (goods == null)
|
| | | out.println("商品已下架");
|
| | | else
|
| | | out.println(
|
| | | "<html><head><meta charset=utf-8></head><body>" + String.format("cat_name:%s <br> cat_leaf_name:%s",
|
| | | goods.getRootCategoryName(), goods.getLeafName()) + "</body></html>");
|
| | | }
|
| | |
|
| | | @RequestMapping("getJedisInfo")
|
| | | public void getJedisInfo(PrintWriter out) {
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("active", jedisPool.getNumActive());
|
| | | data.put("idle", jedisPool.getNumIdle());
|
| | | data.put("waiters", jedisPool.getNumWaiters());
|
| | | out.print(data.toString());
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 插入邀请素材
|
| | | * |
| | | * @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();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | |
| | | }
|