Merge remote-tracking branch 'origin/master'
Conflicts:
fanli/src/main/java/com/yeshi/fanli/controller/client/UserMsgController.java
2个文件已删除
49个文件已修改
12个文件已添加
| | |
| | | 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.goods.TaoBaoGoodsBriefService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FileUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | |
| | | private HelpCenterMapper helpCenterMapper;
|
| | | @Resource
|
| | | private Scheduler scheduler;
|
| | | |
| | | @Resource
|
| | | private DynamicInfoService dynamicInfoService;
|
| | | |
| | | @Resource
|
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private EhCacheCacheManager ehCacheCacheManager;
|
| | |
| | | long startDTime = System.currentTimeMillis();
|
| | |
|
| | | /*
|
| | | * try { //ImageUtil.drawGoodsShareImg(new FileInputStream(new
|
| | | * File(destPath)), portrait, goods, shareImgPath); } catch
|
| | | * (FileNotFoundException e) { e.printStackTrace(); }
|
| | | * try { //ImageUtil.drawGoodsShareImg(new FileInputStream(new File(destPath)),
|
| | | * portrait, goods, shareImgPath); } catch (FileNotFoundException e) {
|
| | | * e.printStackTrace(); }
|
| | | */
|
| | | System.out.println(System.currentTimeMillis() - startDTime);
|
| | |
|
| | |
| | | out.print("<script>yestv.finishPage();</script>");
|
| | | out.close();
|
| | | }
|
| | |
|
| | | |
| | | |
| | | /**
|
| | | * 清除缓存
|
| | | *
|
| | |
| | | pw.print(els.get(i).html().replace("var brandData =", "").trim().split("};")[0] + "}");
|
| | | }
|
| | | }
|
| | |
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | | |
| | | @RequestMapping(value = "insetDynamicInfo")
|
| | | public void insetDynamicInfo(PrintWriter out) {
|
| | | String content= "emoji六一儿童节来了\r\n" + |
| | | "老少儿童们到快活起来吧:用童真憧憬人生\r\n" + |
| | | "emoji用童趣装点人生emoji\r\n" + |
| | | "用童话描绘人生emoji\r\n" + |
| | | "用童心度过人生 emoji \r\n" + |
| | | "--------------------- \r\n今天 : 6月1日 ️ 星期四\r\n" + |
| | | "天气 : 晴转多云 15-24℃\r\n" + |
| | | "各位亲爱的你 早安~\r\n" + |
| | | "购物省钱返利券App:【邀请链接】\r\n" + |
| | | "我的邀请码:【邀请码】" ;
|
| | | |
| | | dynamicInfoService.insertInviteMaterial(content, null, null, null);
|
| | | |
| | | |
| | | String content2= "emoji六一儿童节来了\r\n" + |
| | | "老少儿童们到快活起来吧:用童真憧憬人生\r\n" + |
| | | "emoji用童趣装点人生emoji\r\n" + |
| | | "用童话描绘人生emoji\r\n" + |
| | | "用童心度过人生 emoji \r\n" + |
| | | "--------------------- \r\n今天 : 6月1日 ️ 星期四\r\n" + |
| | | "天气 : 晴转多云 15-24℃\r\n" + |
| | | "各位亲爱的你 早安~\r\n" + |
| | | "购物省钱返利券App:【邀请链接】\r\n" + |
| | | "我的邀请码:【邀请码】" ;
|
| | | |
| | | dynamicInfoService.insertInviteMaterial(content2, "http://ec-1255749512.file.myqcloud.com/img/invite/53420a05de1644bd947fa23800ab0131.jpeg", null, null);
|
| | | }
|
| | |
|
| | | |
| | | @RequestMapping(value = "insertShop")
|
| | | public void insertShop(PrintWriter out) {
|
| | | try {
|
| | | dynamicInfoService.insertShopInfo();
|
| | | dynamicInfoService.insertTimeHotSale();
|
| | | dynamicInfoService.insertTimeRecommend();
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | }
|
| | |
| | |
|
| | | 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.JsonUtil;
|
| | |
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | |
| | | @Resource
|
| | | private AppVersionService appVersionService;
|
| | |
|
| | | @Resource
|
| | | private EhCacheCacheManager ehCacheCacheManager;
|
| | |
|
| | | private AppVersionService appVersionService;
|
| | | |
| | | /**
|
| | | * 查询列表 - 新后台
|
| | | *
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 查询列表 - 新后台
|
| | | * |
| | | * @param callback
|
| | | * @param key
|
| | | * 查询词 名称
|
| | | * @param key 查询词 名称
|
| | | * @param pageIndex
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getVersionList")
|
| | | public void getVersionList(String callback, String key, Integer pageIndex, PrintWriter out) {
|
| | |
|
| | | public void getVersionList(String callback, String key, Integer pageIndex, PrintWriter out){
|
| | | |
| | | try {
|
| | | AppVersionInfo appVersionInfo = new AppVersionInfo();
|
| | | appVersionInfo.setVersion("全推");
|
| | |
|
| | | |
| | | |
| | | // IOS版本
|
| | | List<AppVersionInfo> list1 = appVersionService.getAppVersionInfoListByPlatform(AppVersionInfo.PLATFORM_IOS);
|
| | | if (list1 == null) {
|
| | |
| | | List<AppVersionInfo> listIOS = new ArrayList<AppVersionInfo>();
|
| | | listIOS.add(appVersionInfo);
|
| | | listIOS.addAll(list1);
|
| | |
|
| | | |
| | | |
| | | // 安卓版本
|
| | | List<AppVersionInfo> list2 = appVersionService
|
| | | .getAppVersionInfoListByPlatform(AppVersionInfo.PLATFORM_ANDROID);
|
| | | List<AppVersionInfo> list2 = appVersionService.getAppVersionInfoListByPlatform(AppVersionInfo.PLATFORM_ANDROID);
|
| | | if (list2 == null) {
|
| | | list2 = new ArrayList<AppVersionInfo>();
|
| | | }
|
| | | List<AppVersionInfo> listAndroid = new ArrayList<AppVersionInfo>();
|
| | | listAndroid.add(appVersionInfo);
|
| | | listAndroid.addAll(list2);
|
| | |
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("android", listAndroid);
|
| | | data.put("ios", listIOS);
|
| | |
|
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | |
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("版本查询失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /***
|
| | | * 清除缓存
|
| | | * |
| | | * @param callback
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "clearCaches")
|
| | | public void clearCaches(String callback, PrintWriter out) {
|
| | | ehCacheCacheManager.getCacheManager().clearAll();
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(""));
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import com.google.gson.reflect.TypeToken;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsSubClass;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsSubClassLabel;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsSubClassLabelMap;
|
| | | import com.yeshi.fanli.entity.bus.clazz.TaoBaoClass;
|
| | | import com.yeshi.fanli.exception.FloatADException;
|
| | | import com.yeshi.fanli.service.inter.clazz.GoodsSubClassLabelService;
|
| | | import com.yeshi.fanli.service.inter.goods.GoodsSubClassService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoClassService;
|
| | | import com.yeshi.fanli.service.inter.lable.LabelClassService;
|
| | |
| | | @Resource
|
| | | private TaoBaoClassService taoBaoClassService;
|
| | |
|
| | | @Resource
|
| | | private GoodsSubClassLabelService goodsSubClassLabelService;
|
| | |
|
| | | /**
|
| | | * 保存信息
|
| | | *
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "save")
|
| | | public void save(String callback, GoodsSubClass goodsSubClass, Long pid, Integer type, Long labelId,
|
| | | HttpServletRequest request, PrintWriter out) {
|
| | | public void save(String callback, GoodsSubClass goodsSubClass, Long pid, Integer type, HttpServletRequest request,
|
| | | PrintWriter out) {
|
| | | if (goodsSubClass.getTaobaoCids() != null)
|
| | | goodsSubClass.setTaobaoCids(goodsSubClass.getTaobaoCids().replace(",", ","));
|
| | |
|
| | | GoodsSubClassLabelMap map = null;
|
| | | if (labelId != null) {
|
| | | map = new GoodsSubClassLabelMap();
|
| | | map.setLabel(new GoodsSubClassLabel(labelId));
|
| | | map.setOrderBy(0);
|
| | | }
|
| | |
|
| | | try {
|
| | | // 1. 先判断httpRequest 是否含有文件类型
|
| | | if (request instanceof MultipartHttpServletRequest) {
|
| | | MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request;
|
| | | goodsSubClassService.saveObject(fileRequest.getFile("file"), fileRequest.getFile("file2"),
|
| | | goodsSubClass, type, pid,map);
|
| | | goodsSubClass, type, pid);
|
| | | } else {
|
| | | goodsSubClassService.saveObject(null, null, goodsSubClass, type, pid,map);
|
| | | goodsSubClassService.saveObject(null, null, goodsSubClass, type, pid);
|
| | | }
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
|
| | |
| | | }
|
| | | goodsSubClass.setTaobaoCids(taobaoCids);
|
| | | }
|
| | |
|
| | | // 查询分类标签
|
| | | GoodsSubClassLabelMap map = goodsSubClassLabelService.selectBySubClassId(goodsSubClass.getId());
|
| | | if (map != null)
|
| | | goodsSubClass.setClassLabel(map.getLabel());
|
| | | }
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder();
|
| | |
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.vo.quality.QualityFactoryVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | |
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
|
| | | @Resource
|
| | | private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
|
| | | |
| | |
|
| | | public static final int SALES_ASC = 1;
|
| | | public static final int SALES_DESC = 2;
|
| | |
| | |
|
| | | public static final int TKRATE_ASC = 5;
|
| | | public static final int TKRATE_DESC = 6;
|
| | |
|
| | | |
| | | |
| | | public static final int PROPOR_ASC = 7;
|
| | | public static final int PROPOR_DESC = 8;
|
| | |
|
| | | @RequestMapping(value = "addBatch")
|
| | | public void addBatch(String callback, String auctionIds, String lableNames, HttpServletRequest request,
|
| | | PrintWriter out) {
|
| | |
|
| | | try {
|
| | | // 获取当前操作用户
|
| | | AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
|
| | | if (admin == null) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("当前账户失效,请重新登陆")));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(auctionIds)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请选者正确的商品入库")));
|
| | | return;
|
| | | }
|
| | |
|
| | | Gson gson = new Gson();
|
| | | List<Long> auctionIdList = gson.fromJson(auctionIds, new TypeToken<ArrayList<Long>>() {
|
| | | }.getType());
|
| | | if (auctionIdList == null || auctionIdList.size() == 0) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请选择正确的商品入库")));
|
| | | return;
|
| | | }
|
| | |
|
| | | List<TaoBaoGoodsBrief> listTaoBaoGoods = new ArrayList<>();
|
| | |
|
| | | JSONArray array = JSONArray.fromObject(auctionIds);
|
| | |
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | listTaoBaoGoods.add(TaoKeApiUtil.searchGoodsDetail(array.optLong(i)));
|
| | | }
|
| | | qualityFactoryService.addBatchTaoBaoGoods(listTaoBaoGoods, lableNames, admin);
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("添加成功")));
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("操作异常")));
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 保存修改精品库商品关联信息
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "saveModify")
|
| | | public void saveModify(String callback, QualityFactory selectionGoods, HttpServletRequest request,
|
| | | PrintWriter out) {
|
| | | public void saveModify(String callback, QualityFactory selectionGoods, HttpServletRequest request, PrintWriter out) {
|
| | |
|
| | | try {
|
| | | AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
|
| | |
| | | try {
|
| | |
|
| | | Gson gson = new Gson();
|
| | | List<String> goodsIds = gson.fromJson(ids, new TypeToken<ArrayList<String>>() {
|
| | | }.getType());
|
| | | List<String> goodsIds = gson.fromJson(ids, new TypeToken<ArrayList<String>>() {}.getType());
|
| | |
|
| | | if (goodsIds == null || goodsIds.size() == 0) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("未检测到移除商品数据")));
|
| | |
| | |
|
| | | /**
|
| | | * 查询
|
| | | * |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "query")
|
| | | public void query(String callback, Integer pageIndex, Integer pageSize, Integer sort,
|
| | | public void query(String callback, Integer pageIndex,Integer pageSize, Integer sort, |
| | | QualityFactoryVO qualityFactoryVO, PrintWriter out) {
|
| | |
|
| | | try {
|
| | |
| | | case PROPOR_ASC:
|
| | | propor = 1;
|
| | | break;
|
| | | case PROPOR_DESC:
|
| | | case PROPOR_DESC: |
| | | propor = 2;
|
| | | break;
|
| | | default:
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | qualityFactoryVO.setPrice(price);
|
| | | qualityFactoryVO.setTkRate(tkRate);
|
| | | qualityFactoryVO.setTotalSales(totalSales);
|
| | | qualityFactoryVO.setPropor(propor);
|
| | | qualityFactoryVO.setStart((pageIndex - 1) * pageSize);
|
| | | qualityFactoryVO.setStart((pageIndex - 1) * pageSize); |
| | | qualityFactoryVO.setCount(pageSize);
|
| | |
|
| | | List<QualityFactory> selectionList = qualityFactoryService.query(qualityFactoryVO);
|
| | |
| | |
|
| | | List<Map<String, Object>> listmap = new ArrayList<Map<String, Object>>();
|
| | |
|
| | | /* 验证网络: 获取商品链接 图片链接 */
|
| | | /* 验证网络: 获取商品链接 图片链接 */
|
| | | List<TaoBaoGoodsBrief> goodsBriefList = new ArrayList<TaoBaoGoodsBrief>();
|
| | |
|
| | | |
| | | StringBuffer idBuf = new StringBuffer();
|
| | | StringBuffer auctionIdBuf = new StringBuffer();
|
| | |
|
| | | |
| | | int j = 0;
|
| | | for (int i = 0; i < selectionList.size(); i++) {
|
| | | for (int i = 0; i < selectionList.size(); i++ ) {
|
| | | QualityFactory selectionGoods = selectionList.get(i);
|
| | |
|
| | | |
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
|
| | | if (taoBaoGoodsBrief == null)
|
| | | continue; // 为空结束本次循环
|
| | |
|
| | | |
| | | |
| | | Long id = taoBaoGoodsBrief.getId();
|
| | | idBuf.append(id + ",");
|
| | |
|
| | | |
| | | Long auctionId = taoBaoGoodsBrief.getAuctionId();
|
| | | if (auctionId != null) {
|
| | | j++;
|
| | | auctionIdBuf.append(auctionId + ",");
|
| | | }
|
| | |
|
| | | |
| | | if (selectionList.size() <= 40) {
|
| | | // 小于40个参数
|
| | | if (i == selectionList.size() - 1) {
|
| | | if (i == selectionList.size()-1 ){
|
| | | if (auctionIdBuf != null && auctionIdBuf.length() > 0) {
|
| | | String auctionIds = auctionIdBuf.toString();
|
| | | String ids = auctionIds.substring(0, auctionIds.length() - 1);
|
| | | String ids = auctionIds.substring(0, auctionIds.length() -1);
|
| | | List<TaoBaoGoodsBrief> list = null;
|
| | | try {
|
| | | list = TaoKeApiUtil.getBatchGoodsInfos(ids);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | |
| | | if (list != null && list.size() > 0) {
|
| | | goodsBriefList.addAll(list);
|
| | | }
|
| | |
|
| | | |
| | | auctionIdBuf = new StringBuffer();
|
| | | }
|
| | | }
|
| | |
| | | if (j == 40) {
|
| | | // 大于40参数
|
| | | String auctionIds = auctionIdBuf.toString();
|
| | | String ids = auctionIds.substring(0, auctionIds.length() - 1);
|
| | | String ids = auctionIds.substring(0, auctionIds.length() -1);
|
| | | List<TaoBaoGoodsBrief> list = null;
|
| | | try {
|
| | | list = TaoKeApiUtil.getBatchGoodsInfos(ids);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | |
| | | if (list != null && list.size() > 0) {
|
| | | goodsBriefList.addAll(list);
|
| | | }
|
| | |
|
| | | j = 0;
|
| | | |
| | | j= 0;
|
| | | auctionIdBuf = new StringBuffer();
|
| | |
|
| | | } else if (i == selectionList.size() - 1) {
|
| | | |
| | | } else if (i == selectionList.size()-1 ){
|
| | | // 最后一个
|
| | | String auctionIds = auctionIdBuf.toString();
|
| | | String ids = auctionIds.substring(0, auctionIds.length() - 1);
|
| | | String ids = auctionIds.substring(0, auctionIds.length() -1);
|
| | | List<TaoBaoGoodsBrief> list = null;
|
| | | try {
|
| | | list = TaoKeApiUtil.getBatchGoodsInfos(ids);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | |
| | | if (list != null && list.size() > 0) {
|
| | | goodsBriefList.addAll(list);
|
| | | }
|
| | | auctionIdBuf = new StringBuffer();
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | }
|
| | |
|
| | | |
| | | |
| | | for (QualityFactory selectionGoods : selectionList) {
|
| | |
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
|
| | | if (taoBaoGoodsBrief == null)
|
| | | continue; // 为空结束本次循环
|
| | |
|
| | | |
| | | String auctionUrl = taoBaoGoodsBrief.getAuctionUrl();
|
| | | if (auctionUrl != null && auctionUrl.trim().length() > 0 && auctionUrl.contains("id=null")) {
|
| | | auctionUrl = auctionUrl.replace("id=null", "id=" + taoBaoGoodsBrief.getAuctionId());
|
| | | auctionUrl =auctionUrl.replace("id=null","id="+ taoBaoGoodsBrief.getAuctionId());
|
| | | taoBaoGoodsBrief.setAuctionUrl(auctionUrl);
|
| | | }
|
| | |
|
| | | |
| | | Map<String, Object> map = new HashMap<String, Object>();
|
| | |
|
| | | |
| | | BoutiqueAutoRule boutiqueAutoRule = selectionGoods.getBoutiqueAutoRule();
|
| | | if (boutiqueAutoRule == null) {
|
| | | boutiqueAutoRule = new BoutiqueAutoRule();
|
| | | selectionGoods.setBoutiqueAutoRule(boutiqueAutoRule);
|
| | | }
|
| | |
|
| | | |
| | | String reslutSource = "";
|
| | | Integer gsSource = selectionGoods.getGoodsSource();
|
| | | if (QualityFactory.SOURCE_TAOBAO == gsSource) {
|
| | | if (QualityFactory.SOURCE_TAOBAO == gsSource ) {
|
| | | reslutSource = "淘宝";
|
| | | } else if (QualityFactory.SOURCE_TAOBAO_MATERIAL == gsSource) {
|
| | | reslutSource = "淘宝推荐";
|
| | |
| | | } else if (QualityFactory.SOURCE_OTHER == gsSource) {
|
| | | reslutSource = "商务合作";
|
| | | }
|
| | |
|
| | | |
| | | map.put("goodsSource", reslutSource);
|
| | |
|
| | | |
| | | |
| | | map.put("selectionGoods", selectionGoods);
|
| | |
|
| | | /* 商品销售状态: 0 在售 1停售 */
|
| | |
| | | Long auctionId = taoBaoGoodsBrief.getAuctionId();
|
| | | if (auctionId != null) {
|
| | | if (goodsBriefList != null && goodsBriefList.size() > 0) {
|
| | | for (TaoBaoGoodsBrief tb : goodsBriefList) {
|
| | | for (TaoBaoGoodsBrief tb :goodsBriefList) {
|
| | | Long auctionIdTB = tb.getAuctionId();
|
| | | if (auctionId.equals(auctionIdTB)) {
|
| | | saleStae = 0;
|
| | | }
|
| | | }
|
| | | }
|
| | | } |
| | | }
|
| | |
|
| | | |
| | | map.put("saleStae", saleStae);
|
| | | |
| | |
|
| | | /* 1 定向计划 2 营销返利 、高佣 3 普佣 */
|
| | | Integer includeDxjh = taoBaoGoodsBrief.getIncludeDxjh();
|
| | |
| | | map.put("yongjinType", 3);
|
| | | }
|
| | | }
|
| | |
|
| | | /* 券后价--计算 */
|
| | | |
| | | |
| | | |
| | | /* 券后价--计算 */
|
| | | BigDecimal couponPrice = TaoBaoUtil.getAfterUseCouplePrice(taoBaoGoodsBrief);
|
| | | map.put("couponPrice", couponPrice);
|
| | |
|
| | |
| | | BigDecimal estimateProfit = MoneyBigDecimalUtil.div(profit, new BigDecimal("100"));
|
| | | // 预计收益
|
| | | map.put("estimateProfit", estimateProfit);
|
| | |
|
| | | |
| | | |
| | | BigDecimal couponAmount = taoBaoGoodsBrief.getCouponAmount();
|
| | | if (couponAmount != null && zkPrice != null) {
|
| | | BigDecimal propors = couponAmount.divide(zkPrice, 10, BigDecimal.ROUND_HALF_DOWN);
|
| | | BigDecimal propors = couponAmount.divide(zkPrice ,10 ,BigDecimal.ROUND_HALF_DOWN);
|
| | | BigDecimal resultPropor = MoneyBigDecimalUtil.mul(propors, new BigDecimal("100"));
|
| | | map.put("propor", resultPropor);
|
| | | } else {
|
| | | map.put("propor", 0);
|
| | | }
|
| | | |
| | |
|
| | | /* 商品标签列表 */
|
| | | Long id = taoBaoGoodsBrief.getId();
|
| | | int totalLabels = labelGoodsService.getCountQueryByGoodsId(id);
|
| | |
|
| | | // List<LabelGoods> labelList = labelService.getByGoodsId(id);
|
| | |
|
| | | |
| | | //List<LabelGoods> labelList = labelService.getByGoodsId(id);
|
| | | |
| | | map.put("totalLabels", totalLabels);
|
| | |
|
| | | listmap.add(map);
|
| | |
| | | * 获取商品信息 以及对应标签列表;此商品标签候选项
|
| | | *
|
| | | * @param callback
|
| | | * @param id
|
| | | * 精选id
|
| | | * @param id 精选id
|
| | | * @param request
|
| | | * @param out
|
| | | */
|
| | |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("该商品已不在")));
|
| | | return;
|
| | | }
|
| | |
|
| | | |
| | | // 商品图片
|
| | | List<String> imgList = TaoBaoUtil.getTbImg(taobao.getAuctionId() + "");
|
| | |
|
| | |
| | |
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 单个商品贴上标签
|
| | | *
|
| | |
| | | try {
|
| | | // 获取当前操作用户
|
| | | AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
|
| | | // if (admin == null) {
|
| | | // out.print(JsonUtil.loadJSONP(callback,
|
| | | // JsonUtil.loadFalseResult("当前账户失效,请重新登陆。")));
|
| | | // return;
|
| | | // }
|
| | | // if (admin == null) {
|
| | | // out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("当前账户失效,请重新登陆。")));
|
| | | // return;
|
| | | // }
|
| | |
|
| | | if (id == null || labId == null) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请传递正确的参数")));
|
| | |
| | |
|
| | | try {
|
| | | AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
|
| | | //
|
| | | // if (admin == null) {
|
| | | // out.print(JsonUtil.loadJSONP(callback,
|
| | | // JsonUtil.loadFalseResult("当前账户已失效,请重新登陆")));
|
| | | // return;
|
| | | // }
|
| | | //
|
| | | // if (admin == null) {
|
| | | // out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("当前账户已失效,请重新登陆")));
|
| | | // return;
|
| | | // } |
| | |
|
| | | Long id = selectionGoods.getId();
|
| | | QualityFactory resultObj = qualityFactoryService.selectByPrimaryKey(id);
|
| | |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("修改失败")));
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | } catch (QualityFactoryException e) {
|
| | | e.printStackTrace();
|
| | |
| | | }
|
| | |
|
| | | @RequestMapping(value = "queryMyLabels")
|
| | | public void queryMyLabels(String callback, Integer pageIndex, Integer pageSize, String ids,
|
| | | HttpServletRequest request, PrintWriter out) {
|
| | | public void queryMyLabels(String callback, Integer pageIndex, Integer pageSize, |
| | | String ids, HttpServletRequest request, PrintWriter out) {
|
| | |
|
| | | try {
|
| | |
|
| | | |
| | | if (StringUtil.isNullOrEmpty(ids)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请传递正确参数:101")));
|
| | | return;
|
| | | }
|
| | |
|
| | | |
| | | Gson gson = new Gson();
|
| | | List<Long> idList = gson.fromJson(ids, new TypeToken<ArrayList<Long>>() {
|
| | | }.getType());
|
| | | List<Long> idList = gson.fromJson(ids, new TypeToken<ArrayList<Long>>() {}.getType());
|
| | | if (idList == null || idList.size() == 0) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请传递正确参数:102")));
|
| | | return;
|
| | | }
|
| | |
|
| | | |
| | | if (idList.size() > 1) {
|
| | | // 只处理单个商品
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请传递正确参数:103")));
|
| | | return;
|
| | | }
|
| | |
|
| | | |
| | | |
| | | Long id = idList.get(0);
|
| | |
|
| | | |
| | | if (id == null) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请传递正确参数:104")));
|
| | | return;
|
| | |
| | | pageSize = Constant.PAGE_SIZE;
|
| | |
|
| | | // 商品标签列表
|
| | | List<LabelGoods> labelList = labelGoodsService.queryByGoodsId((pageIndex - 1) * pageSize, pageSize, id);
|
| | | List<LabelGoods> labelList = labelGoodsService.queryByGoodsId((pageIndex - 1) * pageSize, |
| | | pageSize, id);
|
| | |
|
| | | if (labelList == null || labelList.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无标签"));
|
| | | return;
|
| | | }
|
| | |
|
| | | |
| | | int count = labelGoodsService.getCountQueryByGoodsId(id);
|
| | |
|
| | | int totalPage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1;
|
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder();
|
| | | gsonBuilder.serializeNulls();
|
| | | gsonBuilder.serializeNulls(); |
| | | Gson rgson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "queryLabel")
|
| | | public void queryLabel(String callback, Integer pageIndex, Integer pageSize, String key, String ids,
|
| | | HttpServletRequest request, PrintWriter out) {
|
| | | public void queryLabel(String callback, Integer pageIndex, Integer pageSize, String key, |
| | | String ids, HttpServletRequest request, PrintWriter out) {
|
| | |
|
| | | try {
|
| | |
|
| | |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请传递正确参数:101")));
|
| | | return;
|
| | | }
|
| | |
|
| | | |
| | | Gson gson = new Gson();
|
| | | List<Long> idList = gson.fromJson(ids, new TypeToken<ArrayList<Long>>() {
|
| | | }.getType());
|
| | | List<Long> idList = gson.fromJson(ids, new TypeToken<ArrayList<Long>>() {}.getType());
|
| | | if (idList == null || idList.size() == 0) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请传递正确参数:102")));
|
| | | return;
|
| | | }
|
| | |
|
| | | |
| | | int count = 0;
|
| | | List<Label> labelList = null;
|
| | |
|
| | | |
| | | if (pageIndex == null)
|
| | | pageIndex = 1;
|
| | |
|
| | | if (pageSize == null)
|
| | | pageSize = Constant.PAGE_SIZE;
|
| | |
|
| | | |
| | | if (idList.size() > 1) {
|
| | | // 多个商品 查询所有标签
|
| | | labelList = labelService.query((pageIndex - 1) * pageSize, pageSize, key, null, null, null);
|
| | |
|
| | | count = labelService.getQueryCount(key, null, null);
|
| | |
|
| | | labelList = labelService.query((pageIndex - 1) * pageSize, pageSize, key, null, null,null);
|
| | | |
| | | count = labelService.getQueryCount(key, null, null);
|
| | | |
| | | } else {
|
| | | // 单个商品
|
| | | Long id = idList.get(0);
|
| | |
| | |
|
| | | count = labelService.getCountQueryGoodsCandidate(key, id);
|
| | | }
|
| | |
|
| | | |
| | | if (labelList == null || labelList.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无标签"));
|
| | | return;
|
| | | }
|
| | |
|
| | | |
| | | int totalPage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1;
|
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
|
| | |
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "addBatchcGoodsLabel")
|
| | | public void addBatchcGoodsLabel(String callback, String labIds, Long id, HttpServletRequest request,
|
| | | PrintWriter out) {
|
| | | public void addBatchcGoodsLabel(String callback, String labIds, Long id, HttpServletRequest request, PrintWriter out) {
|
| | |
|
| | | try {
|
| | | if (StringUtil.isNullOrEmpty(labIds)) {
|
| | |
| | | }
|
| | |
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = taoBaoGoodsBriefService.selectByPrimaryKey(id);
|
| | |
|
| | | |
| | | // 获取当前操作用户
|
| | | AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
|
| | | labelGoodsService.addBatchByLabId(taoBaoGoodsBrief, labIdList, admin);
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "updateGoodsBrief")
|
| | | public void updateGoodsBrief(String callback, TaoBaoGoodsBrief tb, PrintWriter out) {
|
| | | |
| | | @RequestMapping(value="updateGoodsBrief")
|
| | | public void updateGoodsBrief(String callback, TaoBaoGoodsBrief tb, PrintWriter out){
|
| | | try {
|
| | |
|
| | | |
| | | // 实际未精选ID
|
| | | Long id = tb.getId();
|
| | |
|
| | | |
| | | QualityFactory resultObj = qualityFactoryService.selectByPrimaryKey(id);
|
| | |
|
| | | if (resultObj == null) {
|
| | |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("该商品已不在")));
|
| | | return;
|
| | | }
|
| | |
|
| | | |
| | | String title = tb.getTitle();
|
| | | String pictUrl = tb.getPictUrl();
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(title))
|
| | | |
| | | if (!StringUtil.isNullOrEmpty(title)) |
| | | taobao.setTitle(title);
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(pictUrl))
|
| | | |
| | | if (!StringUtil.isNullOrEmpty(pictUrl)) |
| | | taobao.setPictUrl(pictUrl);
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(tb.getPictUrlWhite()))
|
| | | |
| | | if (!StringUtil.isNullOrEmpty(tb.getPictUrlWhite())) |
| | | taobao.setPictUrlWhite(tb.getPictUrlWhite());
|
| | |
|
| | | |
| | | // 更新商品
|
| | | taoBaoGoodsUpdateService.getUpdateTaoBaoGoodsBrief(taobao);
|
| | |
|
| | | |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("修改成功")));
|
| | |
|
| | | |
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("修改失败")));
|
| | | }
|
| | |
|
| | | |
| | | }
|
| | |
|
| | | |
| | | |
| | | /**
|
| | | * 批量添加标签 --- 精品库(随机权重)
|
| | | * |
| | | * @param callback
|
| | | * @param request
|
| | | * @param out
|
| | | * @param 权重范围
|
| | | * 大值
|
| | | * @param 佣金范围
|
| | | * 小值
|
| | | * @param out @param 权重范围 大值
|
| | | * @param 佣金范围 小值
|
| | | */
|
| | | @RequestMapping(value = "setWeightBatch")
|
| | | public void setWeightBatch(String callback, String ids, Integer weight, Integer weightSmall, Integer weightLarge,
|
| | | HttpServletRequest request, PrintWriter out) {
|
| | | public void setWeightBatch(String callback,String ids, Integer weight,Integer weightSmall, |
| | | Integer weightLarge, HttpServletRequest request, PrintWriter out) {
|
| | |
|
| | | try {
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(ids)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("未选择需操作的商品")));
|
| | | return;
|
| | | }
|
| | |
|
| | | Gson gson = new Gson();
|
| | | List<Long> idList = gson.fromJson(ids, new TypeToken<ArrayList<Long>>() {
|
| | | }.getType());
|
| | |
|
| | | if (idList == null || idList.size() == 0) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请选择需操作的商品")));
|
| | | return;
|
| | | }
|
| | | // 获取当前操作用户
|
| | | AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
|
| | |
|
| | | qualityFactoryService.setWeightBatch(idList, admin, weight, weightSmall, weightLarge);
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("设置成功")));
|
| | |
|
| | | } catch (Exception e) {
|
| | | try { |
| | | |
| | | if (StringUtil.isNullOrEmpty(ids)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("未选择需操作的商品")));
|
| | | return;
|
| | | } |
| | | |
| | | Gson gson = new Gson();
|
| | | List<Long> idList = gson.fromJson(ids, new TypeToken<ArrayList<Long>>() {}.getType());
|
| | | |
| | | if (idList == null || idList.size() == 0) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请选择需操作的商品")));
|
| | | return;
|
| | | } |
| | | // 获取当前操作用户
|
| | | AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
|
| | | |
| | | qualityFactoryService.setWeightBatch(idList, admin, weight, weightSmall, weightLarge);
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("设置成功")));
|
| | | |
| | | } catch ( Exception e) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("操作异常")));
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | |
| | | |
| | | }
|
| | |
| | | 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.entity.taobao.dataoke.DaTaoKeDetail;
|
| | | import com.yeshi.fanli.service.inter.goods.GoodsClassService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoClassService;
|
| | | 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.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | |
| | | @Resource
|
| | | private TaoBaoClassService taoBaoClassService;
|
| | |
|
| | | @Resource
|
| | | private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
|
| | |
|
| | | /**
|
| | | *
|
| | | * @param callback
|
| | |
| | | // 查询物料
|
| | | TaoBaoSearchResult result = getGoodsByWuLiao(pageIndex, pageSize, key, tbClassId, startPrice, endPrice,
|
| | | startTkRate, endTkRate, sort, istmall, hasCoupon, baoYou, startDsr, overseas, needPrepay,
|
| | | includePayRate30, includeGoodRate, includeRfdRate, npxLevel, cid);
|
| | | includePayRate30, includeGoodRate, includeRfdRate, npxLevel,cid);
|
| | |
|
| | | if (result == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未获取到淘宝商品信息"));
|
| | |
| | | // 查询物料
|
| | | TaoBaoSearchResult result = getGoodsByWuLiao(pageIndex, pageSize, key, tbClassId, startPrice, endPrice,
|
| | | startTkRate, endTkRate, sort, istmall, hasCoupon, baoYou, startDsr, overseas, needPrepay,
|
| | | includePayRate30, includeGoodRate, includeRfdRate, npxLevel, null);
|
| | | includePayRate30, includeGoodRate, includeRfdRate, npxLevel,null);
|
| | |
|
| | | if (result == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未获取到淘宝商品信息"));
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | private List<Map<String, Object>> filterTaoBaoGoodsWithQulity(List<TaoBaoGoodsBrief> goodsList) {
|
| | |
|
| | | // 插入商品集合
|
| | | List<Long> listAuctionId = new ArrayList<Long>();
|
| | | for (TaoBaoGoodsBrief goodsBrief : goodsList) {
|
| | | listAuctionId.add(goodsBrief.getAuctionId());
|
| | | }
|
| | |
|
| | | // 验证是否存在数据库
|
| | | List<QualityFactory> listHas = qualityFactoryService.listQueryByAuctionId(listAuctionId);
|
| | |
|
| | | List<Map<String, Object>> listmap = new ArrayList<Map<String, Object>>();
|
| | |
|
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : goodsList) {
|
| | | taoBaoGoodsBrief.setId(null);
|
| | |
|
| | | Map<String, Object> map = new HashMap<String, Object>();
|
| | |
|
| | | map.put("pictUrl", taoBaoGoodsBrief.getPictUrl());
|
| | | map.put("title", taoBaoGoodsBrief.getTitle());
|
| | | map.put("auctionId", taoBaoGoodsBrief.getAuctionId());
|
| | | map.put("auctionUrl", taoBaoGoodsBrief.getAuctionUrl());
|
| | | map.put("zkPrice", taoBaoGoodsBrief.getZkPrice());
|
| | | map.put("biz30day", taoBaoGoodsBrief.getBiz30day());
|
| | | map.put("couponInfo", taoBaoGoodsBrief.getCouponInfo());
|
| | | map.put("couponTotalCount", taoBaoGoodsBrief.getCouponTotalCount());
|
| | | map.put("couponLeftCount", taoBaoGoodsBrief.getCouponLeftCount());
|
| | | map.put("couponEffectiveEndTime", taoBaoGoodsBrief.getCouponEffectiveEndTime());
|
| | | map.put("tkRate", taoBaoGoodsBrief.getTkRate());
|
| | |
|
| | | // 来源 0 无 1淘宝 2 京东
|
| | | map.put("goodsSource", 1);
|
| | |
|
| | | /* 券后价--计算 */
|
| | | BigDecimal couponPrice = TaoBaoUtil.getAfterUseCouplePrice(taoBaoGoodsBrief);
|
| | | map.put("couponPrice", couponPrice);
|
| | |
|
| | | /* 预计收益: 公司、用户 */
|
| | | BigDecimal tkRate = taoBaoGoodsBrief.getTkRate();
|
| | | BigDecimal zkPrice = taoBaoGoodsBrief.getZkPrice();
|
| | | BigDecimal profit = MoneyBigDecimalUtil.mul(tkRate, zkPrice);
|
| | | // 计算结果
|
| | | BigDecimal estimateProfit = MoneyBigDecimalUtil.div(profit, new BigDecimal("100"));
|
| | |
|
| | | // 预计收益
|
| | | map.put("estimateProfit", estimateProfit);
|
| | |
|
| | | int existence = 0;
|
| | |
|
| | | /* 查询商品是否已存在商品精选库中 */
|
| | | Long localAuctionId = taoBaoGoodsBrief.getAuctionId();
|
| | | if (localAuctionId != null) {
|
| | | if (listHas != null && listHas.size() > 0) {
|
| | | for (QualityFactory selectionGoods : listHas) {
|
| | | TaoBaoGoodsBrief hasgoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
|
| | | Long hasId = hasgoodsBrief.getAuctionId();
|
| | | if (localAuctionId.equals(hasId) || localAuctionId == hasId) {
|
| | | existence = 1; // 存在商品中
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | map.put("isExistence", existence);
|
| | |
|
| | | listmap.add(map);
|
| | | }
|
| | |
|
| | | return listmap;
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | *
|
| | | * @param callback
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | List<Map<String, Object>> listmap = filterTaoBaoGoodsWithQulity(taoBaoGoodsBriefs);
|
| | |
|
| | | PageEntity pe = result.getPageEntity();
|
| | | JSONObject data = new JSONObject();
|
| | | GsonBuilder gsonBuilder = new GsonBuilder();
|
| | | gsonBuilder.serializeNulls(); // 重点
|
| | | Gson gson = gsonBuilder.setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | | data.put("pe", pe);
|
| | | data.put("listGoods", gson.toJson(listmap));
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "searchDaTaoKe")
|
| | | public void searchDaTaoKe(String callback, Integer pageIndex, Integer pageSize, String key, Long cid,
|
| | | PrintWriter out) {
|
| | |
|
| | | try {
|
| | | key = StringUtil.isNullOrEmpty(key) ? "" : key;
|
| | | List<DaTaoKeDetail> list = daTaoKeGoodsDetailService.listSearchByTitleWithCid(key, cid, pageIndex,
|
| | | pageSize);
|
| | | long count = daTaoKeGoodsDetailService.countSearchByTitleWithCid(key, cid);
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | for (DaTaoKeDetail detail : list) {
|
| | | goodsList.add(TaoBaoUtil.convert(detail));
|
| | | // 插入商品集合
|
| | | List<Long> listAuctionId = new ArrayList<Long>();
|
| | | for (TaoBaoGoodsBrief goodsBrief : taoBaoGoodsBriefs) {
|
| | | listAuctionId.add(goodsBrief.getAuctionId());
|
| | | }
|
| | |
|
| | | List<Map<String, Object>> listmap = filterTaoBaoGoodsWithQulity(goodsList);
|
| | | // 验证是否存在数据库
|
| | | List<QualityFactory> listHas = qualityFactoryService.listQueryByAuctionId(listAuctionId);
|
| | |
|
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, (int) count,
|
| | | (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1));
|
| | | 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("title", taoBaoGoodsBrief.getTitle());
|
| | | map.put("auctionId", taoBaoGoodsBrief.getAuctionId());
|
| | | map.put("auctionUrl", taoBaoGoodsBrief.getAuctionUrl());
|
| | | map.put("zkPrice", taoBaoGoodsBrief.getZkPrice());
|
| | | map.put("biz30day", taoBaoGoodsBrief.getBiz30day());
|
| | | map.put("couponInfo", taoBaoGoodsBrief.getCouponInfo());
|
| | | map.put("couponTotalCount", taoBaoGoodsBrief.getCouponTotalCount());
|
| | | map.put("couponLeftCount", taoBaoGoodsBrief.getCouponLeftCount());
|
| | | map.put("couponEffectiveEndTime", taoBaoGoodsBrief.getCouponEffectiveEndTime());
|
| | | map.put("tkRate", taoBaoGoodsBrief.getTkRate());
|
| | |
|
| | | // 来源 0 无 1淘宝 2 京东
|
| | | map.put("goodsSource", 1);
|
| | |
|
| | | /* 券后价--计算 */
|
| | | BigDecimal couponPrice = TaoBaoUtil.getAfterUseCouplePrice(taoBaoGoodsBrief);
|
| | | map.put("couponPrice", couponPrice);
|
| | |
|
| | | /* 预计收益: 公司、用户 */
|
| | | BigDecimal tkRate = taoBaoGoodsBrief.getTkRate();
|
| | | BigDecimal zkPrice = taoBaoGoodsBrief.getZkPrice();
|
| | | BigDecimal profit = MoneyBigDecimalUtil.mul(tkRate, zkPrice);
|
| | | // 计算结果
|
| | | BigDecimal estimateProfit = MoneyBigDecimalUtil.div(profit, new BigDecimal("100"));
|
| | |
|
| | | // 预计收益
|
| | | map.put("estimateProfit", estimateProfit);
|
| | |
|
| | | int existence = 0;
|
| | |
|
| | | /* 查询商品是否已存在商品精选库中 */
|
| | | Long localAuctionId = taoBaoGoodsBrief.getAuctionId();
|
| | | if (localAuctionId != null) {
|
| | | if (listHas != null && listHas.size() > 0) {
|
| | | for (QualityFactory selectionGoods : listHas) {
|
| | | TaoBaoGoodsBrief hasgoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
|
| | | Long hasId = hasgoodsBrief.getAuctionId();
|
| | | if (localAuctionId.equals(hasId) || localAuctionId == hasId) {
|
| | | existence = 1; // 存在商品中
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | map.put("isExistence", existence);
|
| | |
|
| | | listmap.add(map);
|
| | | }
|
| | |
|
| | | PageEntity pe = result.getPageEntity();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | GsonBuilder gsonBuilder = new GsonBuilder();
|
| | | gsonBuilder.serializeNulls(); // 重点
|
| | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "getQiangGou")
|
New file |
| | |
| | | package com.yeshi.fanli.controller.client;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.lang.reflect.Type;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | 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.google.gson.JsonElement;
|
| | | import com.google.gson.JsonPrimitive;
|
| | | import com.google.gson.JsonSerializationContext;
|
| | | import com.google.gson.JsonSerializer;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
|
| | | import com.yeshi.fanli.entity.dynamic.DynamicInfo;
|
| | | import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.dynamic.DynamicInfoService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.taobao.DaTaoKeUtil;
|
| | | import com.yeshi.fanli.vo.dynamic.DynamicClassVO;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | /**
|
| | | * 动态
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Controller
|
| | | @RequestMapping("api/v1/dynamic")
|
| | | public class DynamicController {
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
|
| | |
|
| | | @Resource
|
| | | private JumpDetailV2Service jumpDetailV2Service;
|
| | |
|
| | | @Resource
|
| | | private DynamicInfoService dynamicInfoService;
|
| | |
|
| | | /**
|
| | | * 查询顶部分类
|
| | | * |
| | | * @param acceptData
|
| | | * @param page
|
| | | * @param cid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getClass", method = RequestMethod.POST)
|
| | | public void getClass(AcceptData acceptData, Integer cid, PrintWriter out) {
|
| | | try {
|
| | | // ios 只返回子集分类
|
| | | if (cid != null) {
|
| | | List<GoodsClass> list = new ArrayList<GoodsClass>();
|
| | |
|
| | | switch (cid) {
|
| | | case 1:
|
| | | list.add(new GoodsClass(0L, "今日单品"));
|
| | | list.addAll(DaTaoKeUtil.goodsClasses);
|
| | | break;
|
| | | case 2:
|
| | | break;
|
| | | case 3:
|
| | | break;
|
| | | case 4:
|
| | | break;
|
| | | default:
|
| | | break;
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("list", JsonUtil.getApiCommonGson().toJson(list));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | |
|
| | | // Android 返回分类以及顶部数据
|
| | | List<DynamicClassVO> list = new ArrayList<DynamicClassVO>();
|
| | | DynamicClassVO c1 = new DynamicClassVO();
|
| | | c1.setId(1L);
|
| | | c1.setName("热销单品");
|
| | |
|
| | | List<GoodsClass> listSub = new ArrayList<GoodsClass>();
|
| | | listSub.add(new GoodsClass(0L, "今日单品"));
|
| | | listSub.addAll(DaTaoKeUtil.goodsClasses);
|
| | | c1.setListSub(listSub);
|
| | |
|
| | | DynamicClassVO c2 = new DynamicClassVO();
|
| | | c2.setId(2L);
|
| | | c2.setName("好货推荐");
|
| | | c2.setListSub(new ArrayList<GoodsClass>());
|
| | |
|
| | | DynamicClassVO c3 = new DynamicClassVO();
|
| | | c3.setId(3L);
|
| | | c3.setName("有家好店");
|
| | | c3.setListSub(new ArrayList<GoodsClass>());
|
| | |
|
| | | DynamicClassVO c4 = new DynamicClassVO();
|
| | | c4.setId(4L);
|
| | | c4.setName("邀请素材");
|
| | | c4.setListSub(new ArrayList<GoodsClass>());
|
| | |
|
| | | list.add(c1);
|
| | | list.add(c2);
|
| | | list.add(c3);
|
| | | list.add(c4);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("list", JsonUtil.getApiCommonGson().toJson(list));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("查询失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "getList", method = RequestMethod.POST)
|
| | | public void getList2(AcceptData acceptData, Integer page, Long cid, Long subId, PrintWriter out) {
|
| | | try {
|
| | | if (cid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("主分类id不能为空"));
|
| | | return;
|
| | | }
|
| | | |
| | | long count = 0;
|
| | | List<DynamicInfo> list = dynamicInfoService.query((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, cid,
|
| | | subId);
|
| | | if (list == null) {
|
| | | list = new ArrayList<DynamicInfo>();
|
| | | } else {
|
| | | count = dynamicInfoService.count(cid, subId);
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", count);
|
| | | data.put("list", getGson().toJson(list));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("查询失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "shareRecord", method = RequestMethod.POST)
|
| | | public void shareRecord(AcceptData acceptData, String id, Long uid, PrintWriter out) {
|
| | | try {
|
| | | DynamicInfo dynamicInfo = dynamicInfoService.getById(id);
|
| | | if (dynamicInfo == null) {
|
| | | out.print(JsonUtil.loadFalseResult("该动态信息已不存在"));
|
| | | return;
|
| | | }
|
| | | |
| | | Integer shareCount = dynamicInfo.getShareCount();
|
| | | dynamicInfo.setShareCount(shareCount + 1);
|
| | | dynamicInfoService.updateShareCount(dynamicInfo);
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("shareCount", shareCount +1);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | |
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("记录失败"));
|
| | | }
|
| | | |
| | | }
|
| | |
|
| | | |
| | | |
| | | private Gson getGson() {
|
| | | GsonBuilder gb = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder());
|
| | | gb.excludeFieldsWithoutExposeAnnotation();
|
| | | gb.registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
|
| | | @Override
|
| | | public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) {
|
| | | String desc = "";
|
| | | if (value != null) {
|
| | | // 判断是否是同一天
|
| | | long old = value.getTime();
|
| | | long now = System.currentTimeMillis();
|
| | | long oldDay = old / (1000 * 60 * 60 * 24L);
|
| | | long nowDay = now / (1000 * 60 * 60 * 24L);
|
| | | if (oldDay == nowDay) {// 同一天
|
| | | long cha = now - old;
|
| | | if (cha < 1000 * 60 * 2L)
|
| | | desc = "刚刚";
|
| | | else if (cha < 1000 * 60 * 60L)
|
| | | desc = (cha / (1000 * 60)) + "分钟前";
|
| | | else
|
| | | desc = (cha / (1000 * 60 * 60)) + "小时前";
|
| | | } else if (nowDay - oldDay == 1) {
|
| | | desc = "昨天";
|
| | | } else {
|
| | | desc = (nowDay - oldDay) + "天前";
|
| | | }
|
| | | return new JsonPrimitive(desc);
|
| | | }
|
| | |
|
| | | return new JsonPrimitive("");
|
| | | }
|
| | | });
|
| | |
|
| | | Gson gson = gb.create();
|
| | | return gson;
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.regex.Matcher;
|
| | | import java.util.regex.Pattern;
|
| | |
| | | import com.yeshi.fanli.entity.taobao.SearchFilter;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.Utils;
|
| | |
| | |
|
| | | @Resource
|
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService;
|
| | |
|
| | | @Resource
|
| | | private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
|
| | |
|
| | | /**
|
| | | * 获取商品信息
|
| | |
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | // 查询大淘客标题
|
| | | List<DaTaoKeDetail> list = daTaoKeGoodsDetailService.listByDtitle(text);
|
| | | if (list != null && list.size() > 0) {
|
| | | root.put("type", 2);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("title", list.get(0).getdTitle());
|
| | | root.put("data", data);
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | return;
|
| | | }
|
| | |
|
| | | out.print(JsonUtil.loadFalseResult("暂不支持该类型!"));
|
| | | return;
|
| | | }
|
| | |
| | | filter.setPage(page);
|
| | | filter.setPageSize(pageSize);
|
| | | filter.setCateIds(taoBaoCatIds);
|
| | | //测试时添加
|
| | | filter.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW);//销量从高到低
|
| | |
|
| | | JSONObject result = taoKeGoodsService.searchWuLiao(filter);
|
| | | out.print(JsonUtil.loadTrueResult(result));
|
| | |
| | | // 缓存半个小时
|
| | | redisManager.cacheCommonString(cachekey, array.toString(), 60 * 30);
|
| | | }
|
| | |
|
| | | Long endTime = nextTime.getTimeInMillis() - java.lang.System.currentTimeMillis();
|
| | | |
| | | JSONObject root = new JSONObject();
|
| | | root.put("time", nextTime.getTimeInMillis());
|
| | | root.put("endTime", endTime > 0? endTime : 0);
|
| | | root.put("listgoods", array);
|
| | |
|
| | | return root;
|
| | |
| | | */
|
| | | @RequestMapping(value = "getSpikeGoods")
|
| | | public void getSpikeGoods(AcceptData acceptData, PrintWriter out) {
|
| | | JSONObject params = new JSONObject();
|
| | | params.put("url", configService.get("spike_goods_link"));
|
| | | JumpDetailV2 jumpDetail = jumpDetailV2Service.getByTypeCache("web");
|
| | | |
| | | JSONObject root = getSpikeGoodsContent(acceptData);
|
| | | root.put("params", params);
|
| | | root.put("jumpDetail", jumpDetail);
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | }
|
| | |
|
| | |
| | | goodsJson.put("price", tb.getReservePrice().toString());
|
| | | goodsJson.put("zkPrice", tb.getZkPrice().toString());
|
| | |
|
| | | |
| | | // 30天销量
|
| | | goodsJson.put("saleCount", TaoBaoUtil.getSaleCount(tb.getBiz30day()));
|
| | |
|
| | | goodsJson.put("salesCount", TaoBaoUtil.getSaleCount(tb.getBiz30day()));
|
| | | |
| | | // 分享赚
|
| | | BigDecimal shareMoney = taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb);
|
| | | data.put("shareMoney", "¥" + shareMoney);
|
| | |
| | | import java.util.Set;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.print.attribute.standard.NumberUp;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.stereotype.Controller;
|
| | |
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.lable.QualityFactory;
|
| | | import com.yeshi.fanli.entity.bus.recommend.Honest;
|
| | | import com.yeshi.fanli.entity.bus.search.HistorySearch;
|
| | | import com.yeshi.fanli.entity.bus.search.HotSearch;
|
| | | import com.yeshi.fanli.entity.bus.su.search.SuperHotSearch;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchNav;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.service.inter.config.BusinessSystemService;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | |
| | | import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
|
| | | import com.yeshi.fanli.service.inter.lable.TaoKeGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
|
| | | import com.yeshi.fanli.service.inter.user.HistorySearchService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.EhcacheUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
|
| | | import com.yeshi.fanli.util.taobao.DaTaoKeUtil;
|
| | | import com.yeshi.fanli.util.taobao.SearchFilterUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
|
| | |
|
| | | @Resource
|
| | | private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
|
| | |
|
| | | @RequestMapping(value = "gethotsearch", method = RequestMethod.POST)
|
| | | public void getHotSearch(AcceptData acceptData, PrintWriter out) {
|
| | |
| | | }
|
| | |
|
| | | TaoBaoSearchResult result = TaoBaoUtil.search(sf);
|
| | | // 大淘客过滤
|
| | | List<DaTaoKeDetail> detaokeList = daTaoKeGoodsDetailService.listByDtitle(kw);
|
| | | if (detaokeList != null)
|
| | | for (DaTaoKeDetail detail : detaokeList) {
|
| | | for (int i = 0; i < result.getTaoBaoGoodsBriefs().size(); i++) {
|
| | | if (detail.getGoodsId().longValue() == result.getTaoBaoGoodsBriefs().get(i).getAuctionId()) {
|
| | | result.getTaoBaoGoodsBriefs().set(i,
|
| | | DaTaoKeUtil.filterTaoBaoGoods(result.getTaoBaoGoodsBriefs().get(i), detail));
|
| | | break;
|
| | | } |
| | | }
|
| | | }
|
| | |
|
| | | // result.setTaoBaoGoodsBriefs(daTaoKeGoodsDetailService.filterTaoBaoGoods(result.getTaoBaoGoodsBriefs()));
|
| | |
|
| | | if (result == null) {
|
| | | return null;
|
| | | }
|
| | |
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | import org.springframework.core.task.TaskExecutor;
|
| | | 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 org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.yeshi.fanli.dto.share.ShareInfoDTO;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.dynamic.DynamicInfo;
|
| | | import com.yeshi.fanli.entity.dynamic.GoodsPicture;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | | import com.yeshi.fanli.entity.system.SystemClientParams;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoLink;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.exception.ShareGoodsException;
|
| | |
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.config.SystemClientParamsService;
|
| | | import com.yeshi.fanli.service.inter.dynamic.DynamicInfoService;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsTextTemplateService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.monitor.MonitorService;
|
| | | import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
|
| | | import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
|
| | |
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | | import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
|
| | | import com.yeshi.fanli.util.factory.MonitorFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
| | | @RequestMapping("api/v1/share")
|
| | | public class ShareController {
|
| | |
|
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | | |
| | | @Resource
|
| | | private ShareGoodsService shareGoodsService;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private ShareGoodsTextTemplateService shareGoodsTextTemplateService;
|
| | | |
| | | @Resource
|
| | | private SystemClientParamsService systemClientParamsService;
|
| | | |
| | | @Resource
|
| | | private DynamicInfoService dynamicInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | | |
| | | @Resource
|
| | | private SpreadUserImgService spreadUserImgService;
|
| | | |
| | |
|
| | | // 获取商品分享链接
|
| | | @RequestMapping(value = "getGoodsShareUrl")
|
| | |
| | |
|
| | | // 添加分享记录
|
| | | BigDecimal rate = hongBaoManageService.getShareRate();
|
| | | UserShareGoodsHistory history = new UserShareGoodsHistory();
|
| | | history.setTkCode(taoBaoLink.getTaoToken());
|
| | | history.setLink(taoBaoLink.getClickUrl());
|
| | | history.setQuanLink(taoBaoLink.getCouponLink());
|
| | |
|
| | | history.setCreateTime(new Date());
|
| | | history.setGoodsId(taoBaoLink.getGoods().getAuctionId());
|
| | | history.setGoodsType(UserShareGoodsHistory.TYPE_TAOBAO);
|
| | | history.setHongbao(TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate));
|
| | | List<String> imgList = taoBaoLink.getGoods().getImgList();
|
| | | if (imgList == null) {
|
| | | imgList = new ArrayList<>();
|
| | | }
|
| | | history.setPictures(JsonUtil.getGson().toJson(imgList));
|
| | | history.setUser(new UserInfo(uid));
|
| | | history.setPostPicture(taoBaoLink.getGoods().getPictUrl());
|
| | |
|
| | | data.put("shareMoney", "¥" + history.getHongbao().toString());
|
| | |
|
| | | BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate);
|
| | | |
| | | data.put("shareMoney", "¥" + shareMoney.toString());
|
| | | data.put("shareId", userShareGoodsRecordService.saveSingleShareRecord(uid, auctionId));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | // 异步操作
|
| | | com.yeshi.fanli.util.ThreadUtil.run(new Runnable() {
|
| | |
|
| | | @Override
|
| | | public void run() {
|
| | | //异步操作 添加分享记录
|
| | | UserShareGoodsHistory history = new UserShareGoodsHistory();
|
| | | history.setUser(new UserInfo(uid));
|
| | | history.setHongbao(shareMoney);
|
| | | history.setCreateTime(new Date());
|
| | | history.setGoodsType(UserShareGoodsHistory.TYPE_TAOBAO);
|
| | | history.setTkCode(taoBaoLink.getTaoToken());
|
| | | history.setLink(taoBaoLink.getClickUrl());
|
| | | history.setQuanLink(taoBaoLink.getCouponLink());
|
| | | history.setGoodsId(taoBaoLink.getGoods().getAuctionId());
|
| | | history.setPostPicture(taoBaoLink.getGoods().getPictUrl());
|
| | | |
| | | List<String> imgList = taoBaoLink.getGoods().getImgList();
|
| | | if (imgList == null) {
|
| | | imgList = new ArrayList<>();
|
| | | }
|
| | | history.setPictures(JsonUtil.getGson().toJson(imgList));
|
| | | shareGoodsService.addShareGoodsHistory(history);
|
| | | }
|
| | | });
|
| | | return;
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | e.printStackTrace();
|
| | | } catch (ShareGoodsException e) {
|
| | | try {
|
| | | monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, e.getCode(), 0, "分享出错"));
|
| | |
| | | out.print(JsonUtil.loadTrueResult(configService.get("share_goods_template_rules")));
|
| | | }
|
| | |
|
| | | |
| | |
|
| | | /**
|
| | | * 查询顶部分类
|
| | | * @param acceptData
|
| | | * @param page
|
| | | * @param cid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "shareDynamic", method = RequestMethod.POST)
|
| | | public void shareDynamic(AcceptData acceptData, String id, Long uid, PrintWriter out) {
|
| | | try {
|
| | | |
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (StringUtil.isNullOrEmpty(id)) {
|
| | | out.print(JsonUtil.loadFalseResult("参数不能为空"));
|
| | | return;
|
| | | }
|
| | | |
| | | DynamicInfo dynamicInfo = dynamicInfoService.getById(id);
|
| | | if (dynamicInfo == null) {
|
| | | out.print(JsonUtil.loadFalseResult("该动态信息已不存在"));
|
| | | return;
|
| | | }
|
| | | |
| | | |
| | | |
| | | JSONObject data = new JSONObject();
|
| | | // 分类id
|
| | | long cid = dynamicInfo.getClassId();
|
| | | |
| | | if (cid == 1) { // 热销单品
|
| | | // 文字内容
|
| | | String title ="";
|
| | | List<ClientTextStyleVO> listTitle = dynamicInfo.getTitle();
|
| | | if (listTitle != null && listTitle.size() > 0) {
|
| | | for (ClientTextStyleVO textStyleVO : listTitle) {
|
| | | title += textStyleVO.getContent();
|
| | | }
|
| | | }
|
| | | data.put("title", title);
|
| | | data.put("content", "我在返利券发现了一个很好的商品,快来看看~");
|
| | | |
| | | // 分享奖金
|
| | | ClientTextStyleVO desc = dynamicInfo.getDesc();
|
| | | String content = desc.getContent();
|
| | | int index = content.indexOf("¥");
|
| | | data.put("shareMoney", new BigDecimal(content.substring(index + 1, content.length())));
|
| | | |
| | | // 商品分享链接
|
| | | List<GoodsPicture> imgs2 = dynamicInfo.getImgs();
|
| | | GoodsPicture goodsPicture = imgs2.get(0);
|
| | | Long auctionId = goodsPicture.getGoods().getAuctionId();
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | auctionId + "");
|
| | | String shortLink = HttpUtil.getShortLink(url);
|
| | | if (!StringUtil.isNullOrEmpty(shortLink)) {
|
| | | url = shortLink;
|
| | | }
|
| | | data.put("clickUrl", url);
|
| | | |
| | | // 分享提示图片
|
| | | String imgs = configService.get("goods_share_notify_imgs");
|
| | | JSONArray array = JSONArray.fromObject(imgs);
|
| | | int p = (int) (array.size() * Math.random());
|
| | | if (p < array.size()) {
|
| | | data.put("notifyPicture", array.optString(p));
|
| | | }
|
| | | |
| | | |
| | | UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService.getByUid(uid);
|
| | | String relationId = null;
|
| | | if (extraInfo != null && extraInfo.getRelationId() != null && extraInfo.getRelationValid() != null
|
| | | && extraInfo.getRelationValid() == true) {
|
| | | relationId = extraInfo.getRelationId();
|
| | | }
|
| | | TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId);
|
| | | |
| | | data.put("pictUrl", TbImgUtil.getTBSizeImg(goodsPicture.getUrl(), 500));
|
| | | // 淘宝口令
|
| | | data.put("token", taoBaoLink.getTaoToken());
|
| | | // 帮助链接
|
| | | data.put("helpLink","http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
|
| | | // 分享提醒
|
| | | data.put("notifyDesc", configService.get("goods_share_notify"));
|
| | | // 分享记录id
|
| | | data.put("shareId", userShareGoodsRecordService.saveSingleShareRecord(uid, auctionId));
|
| | | |
| | | } else if (cid == 2) { // 推荐好货
|
| | | |
| | | String picUrl = null;
|
| | | List<TaoBaoGoodsBrief> listGoods = new ArrayList<TaoBaoGoodsBrief>();
|
| | | List<GoodsPicture> listImgs = dynamicInfo.getImgs();
|
| | | for (GoodsPicture goodsPicture: listImgs) {
|
| | | TaoBaoGoodsBriefExtra goods = goodsPicture.getGoods();
|
| | | listGoods.add(goods);
|
| | | |
| | | if (picUrl == null) {
|
| | | picUrl = goodsPicture.getUrl();
|
| | | }
|
| | | }
|
| | | |
| | | // 文字内容
|
| | | String title ="";
|
| | | List<ClientTextStyleVO> listTitle = dynamicInfo.getTitle();
|
| | | if (listTitle != null && listTitle.size() > 0) {
|
| | | for (ClientTextStyleVO textStyleVO : listTitle) {
|
| | | title += textStyleVO.getContent();
|
| | | }
|
| | | }
|
| | | data.put("title", title);
|
| | | data.put("content", "我在返利券发现了一个很好的商品,快来看看~");
|
| | | |
| | | // 分享奖金
|
| | | ClientTextStyleVO desc = dynamicInfo.getDesc();
|
| | | String content = desc.getContent();
|
| | | int index = content.indexOf("¥");
|
| | | data.put("shareMoney", new BigDecimal(content.substring(index + 1 , content.length())));
|
| | | |
| | | // 分享链接
|
| | | ShareInfoDTO shareInfo = userShareGoodsRecordService.saveShareRecord(uid, |
| | | ShareSourceTypeEnum.activity, title, listGoods);
|
| | | data.put("shareId", shareInfo.getShareId());
|
| | | data.put("clickUrl", shareInfo.getCodeUrl());
|
| | | data.put("pictUrl", TbImgUtil.getTBSizeImg(picUrl, 500));
|
| | | // 帮助链接
|
| | | data.put("helpLink","http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
|
| | | // 分享提醒
|
| | | data.put("notifyDesc", configService.get("goods_share_notify"));
|
| | | // 分享提醒语
|
| | | String notifyImgs = configService.get("goods_share_notify_imgs");
|
| | | JSONArray array = JSONArray.fromObject(notifyImgs);
|
| | | int p = (int) (array.size() * Math.random());
|
| | | if (p < array.size()) {
|
| | | data.put("notifyPicture", array.optString(p));
|
| | | }
|
| | | |
| | | } else if (cid == 4) { // 邀请分享
|
| | | |
| | | String inviteCode = null;
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
|
| | | inviteCode = userInfoExtra.getInviteCode();
|
| | | } else {
|
| | | out.print(JsonUtil.loadFalseResult(9001, "邀请码未激活"));
|
| | | return;
|
| | | }
|
| | | |
| | | Integer showType = dynamicInfo.getShowType();
|
| | | if (showType == 0) { // 无图分享
|
| | | String title ="";
|
| | | List<ClientTextStyleVO> listTitle = dynamicInfo.getTitle();
|
| | | if (listTitle != null && listTitle.size() > 0) {
|
| | | for (ClientTextStyleVO textStyleVO : listTitle) {
|
| | | title += textStyleVO.getContent();
|
| | | }
|
| | | }
|
| | | title = title.replace("【邀请码】", inviteCode);
|
| | | title = title.replace("【邀请链接】", UserUtil.getInviteShortLink(uid));
|
| | | data.put("title", title);
|
| | | |
| | | } else { // 有图分享
|
| | | |
| | | // 邀请链接
|
| | | String shortLink = HttpUtil.getShortLink("http://" + Constant.wxGZConfig.getLoginHost() + "/" |
| | | + Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid);
|
| | | data.put("inviteLink", shortLink);
|
| | | data.put("inviteCode", inviteCode);
|
| | | |
| | | // 邀请图片
|
| | | List<GoodsPicture> imgs = dynamicInfo.getImgs();
|
| | | String imgLink = spreadUserImgService.getInviteImg(uid, imgs.get(0).getUrl(), inviteCode);
|
| | | data.put("imgLink", imgLink);
|
| | | |
| | | // 邀请规则
|
| | | BusinessSystem system = new BusinessSystem();
|
| | | system.setCreatetime(java.lang.System.currentTimeMillis());
|
| | | system.setPlatform(1);
|
| | | system.setId(4L);
|
| | | String key = "inviteRules"; // key值
|
| | | SystemClientParams values = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, key);
|
| | | String valueN = values.getValue();
|
| | | String valueBr = valueN.replace("\n", "<br><br>");
|
| | | data.put("inviteRules", valueBr);
|
| | | }
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | |
| | | // 更新分享次数
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | Integer shareCount = dynamicInfo.getShareCount();
|
| | | dynamicInfo.setShareCount(shareCount + 1);
|
| | | dynamicInfoService.updateShareCount(dynamicInfo);
|
| | | }
|
| | | });
|
| | | |
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("分享记录失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | }
|
| | |
| | | List<UserMsgCenter> listCenter = new ArrayList<>();
|
| | |
|
| | | // 单条消息
|
| | | List<UserCommonMsgVO> commonMsgList = new ArrayList<>();
|
| | |
|
| | | |
| | |
|
| | | |
| | | List<UserCommonMsgVO> commonMsgList = new ArrayList<>(); |
| | |
|
| | | long currentTime = System.currentTimeMillis();
|
| | |
|
| | |
| | | msgDeviceReadStateService.setDeviceMsgRead(UserCommonMsgVO.TYPE_RECOMMEND, acceptData.getDevice(),
|
| | | (acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2));
|
| | | } else if (type.equalsIgnoreCase(UserCommonMsgVO.TYPE_ZHUSHOU)) {
|
| | | msgDeviceReadStateService.setDeviceMsgRead(UserCommonMsgVO.TYPE_ZHUSHOU, acceptData.getDevice(),
|
| | | msgDeviceReadStateService.setDeviceMsgRead(UserCommonMsgVO.TYPE_RECOMMEND, acceptData.getDevice(),
|
| | | (acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2));
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(""));
|
New file |
| | |
| | | package com.yeshi.fanli.dao.dynamic;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.data.domain.Sort;
|
| | | import org.springframework.data.mongodb.core.MongoTemplate;
|
| | | import org.springframework.data.mongodb.core.query.Criteria;
|
| | | import org.springframework.data.mongodb.core.query.Query;
|
| | | import org.springframework.data.mongodb.core.query.Update;
|
| | | import org.springframework.stereotype.Repository;
|
| | |
|
| | | import com.yeshi.fanli.entity.dynamic.DynamicInfo;
|
| | |
|
| | | @Repository
|
| | | public class DynamicInfoDao {
|
| | | |
| | | @Resource
|
| | | private MongoTemplate mongoTemplate;
|
| | | |
| | | /**
|
| | | * 新增
|
| | | * @param record
|
| | | */
|
| | | public void insert(DynamicInfo record) {
|
| | | if (record == null) {
|
| | | return;
|
| | | }
|
| | | mongoTemplate.insert(record);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 更新分享次数
|
| | | * @param record
|
| | | */
|
| | | public void updateShareCount(DynamicInfo record) {
|
| | | if (record == null) {
|
| | | return;
|
| | | }
|
| | | |
| | | // 查询数据是存在
|
| | | Query query = new Query();
|
| | | query.addCriteria(Criteria.where("id").is(record.getId()));
|
| | | |
| | | // 更新分享次数
|
| | | Update update = Update.update("shareCount", record.getShareCount());
|
| | | mongoTemplate.updateMulti(query, update, DynamicInfo.class);
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 更新分享次数
|
| | | * @param record
|
| | | */
|
| | | public void updateGoodInfo(DynamicInfo record) {
|
| | | if (record == null) {
|
| | | return;
|
| | | }
|
| | | |
| | | // 查询数据是存在
|
| | | Query query = new Query();
|
| | | query.addCriteria(Criteria.where("id").is(record.getId()));
|
| | | |
| | | // 更新分享次数
|
| | | Update update = Update.update("imgs", record.getImgs()).set("desc", record.getDesc());
|
| | | mongoTemplate.updateMulti(query, update, DynamicInfo.class);
|
| | | }
|
| | | |
| | | /**
|
| | | * 根据id查询数据
|
| | | * @param id
|
| | | * @return
|
| | | */
|
| | | public DynamicInfo getById(String id) {
|
| | | Query query = new Query();
|
| | | query.addCriteria(Criteria.where("id").is(id));
|
| | | DynamicInfo info = mongoTemplate.findOne(query, DynamicInfo.class);
|
| | | return info;
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 根据id查询数据
|
| | | * @param id
|
| | | * @return
|
| | | */
|
| | | public DynamicInfo getByActivityId(Long activityId) {
|
| | | Query query = new Query();
|
| | | query.addCriteria(Criteria.where("activityId").is(activityId));
|
| | | DynamicInfo info = mongoTemplate.findOne(query, DynamicInfo.class);
|
| | | return info;
|
| | | }
|
| | | |
| | | /**
|
| | | * 删除
|
| | | * |
| | | * @param id
|
| | | * @return
|
| | | */
|
| | | public void deleteById(String id) {
|
| | | DynamicInfo info = getById(id);
|
| | | if (info == null ) {
|
| | | return;
|
| | | }
|
| | | mongoTemplate.remove(info);
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 删除根据时间
|
| | | * |
| | | * @param id
|
| | | * @return
|
| | | */
|
| | | public void removeByDate(Date createTime) {
|
| | | Query query = new Query();
|
| | | query.addCriteria(Criteria.where("createTime").lt(createTime));
|
| | | query.addCriteria(
|
| | | new Criteria().andOperator(
|
| | | Criteria.where("createTime").lt(createTime),
|
| | | Criteria.where("classId").ne(4L)
|
| | | )
|
| | | );
|
| | | mongoTemplate.remove(query);
|
| | | }
|
| | | |
| | | |
| | | |
| | | /**
|
| | | * 查询
|
| | | * @param clazz
|
| | | * @return
|
| | | */
|
| | | public List<DynamicInfo> query(Long cid, Long subId) {
|
| | | Query query = new Query();
|
| | | if (subId == null) {
|
| | | query.addCriteria(Criteria.where("classId").is(cid));
|
| | | } else {
|
| | | query.addCriteria(
|
| | | new Criteria().andOperator(
|
| | | Criteria.where("classId").is(cid),
|
| | | Criteria.where("subclassId").is(subId)
|
| | | )
|
| | | );
|
| | | }
|
| | | |
| | | List<DynamicInfo> list = mongoTemplate.find(query, DynamicInfo.class);
|
| | | return list;
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 查询所有数据
|
| | | * @param clazz
|
| | | * @return
|
| | | */
|
| | | public List<DynamicInfo> query(int start, int count, Long cid, Long subId) {
|
| | | Query query = new Query();
|
| | | if (subId == null) {
|
| | | query.addCriteria(Criteria.where("classId").is(cid));
|
| | | } else {
|
| | | query.addCriteria(
|
| | | new Criteria().andOperator(
|
| | | Criteria.where("classId").is(cid),
|
| | | Criteria.where("subclassId").is(subId)
|
| | | )
|
| | | );
|
| | | }
|
| | | |
| | | //分页
|
| | | query.skip(start).limit(count);
|
| | | //排序
|
| | | query.with(new Sort(Sort.Direction.DESC,"createTime"));
|
| | | |
| | | List<DynamicInfo> list = mongoTemplate.find(query, DynamicInfo.class);
|
| | | return list;
|
| | | }
|
| | | |
| | | public long count(Long cid, Long subId) {
|
| | | Query query = new Query();
|
| | | if (subId == null) {
|
| | | query.addCriteria(Criteria.where("classId").is(cid));
|
| | | } else {
|
| | | query.addCriteria(
|
| | | new Criteria().andOperator(
|
| | | Criteria.where("classId").is(cid),
|
| | | Criteria.where("subclassId").is(subId)
|
| | | )
|
| | | );
|
| | | }
|
| | | return mongoTemplate.count(query, DynamicInfo.class);
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 查询所有数据
|
| | | * @param clazz
|
| | | * @return
|
| | | */
|
| | | public List<DynamicInfo> queryAll() {
|
| | | return (List<DynamicInfo>) mongoTemplate.findAll(DynamicInfo.class);
|
| | | }
|
| | | |
| | | }
|
| | |
|
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.bus.activity.ActivityUser; |
| | | |
| | | public interface ActivityUserMapper { |
| | | public interface ActivityUserMapper extends BaseMapper<ActivityUser>{ |
| | | |
| | | int deleteByPrimaryKey(Long id); |
| | | |
| | | int insert(ActivityUser record); |
| | | |
| | | int insertSelective(ActivityUser record); |
| | | |
| | | ActivityUser selectByPrimaryKey(Long id); |
| | | |
| | | int updateByPrimaryKeySelective(ActivityUser record); |
| | | |
| | | int updateByPrimaryKey(ActivityUser record); |
| | | |
| | | List<ActivityUser> selectList(); |
| | | |
| | | /** |
| | | * 随机抽取 |
| | | * @param count |
| | | * @return |
| | | */ |
| | | List<ActivityUser> listRand(@Param("count") int count); |
| | | } |
| | |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivity; |
| | | |
| | | public interface RecommendActivityMapper { |
| | | |
| | | int deleteByPrimaryKey(Long id); |
| | | public interface RecommendActivityMapper extends BaseMapper<RecommendActivity> { |
| | | |
| | | int batchDeleteByPrimaryKey(long[] ids); |
| | | |
| | | int insert(RecommendActivity record); |
| | | |
| | | int insertSelective(RecommendActivity record); |
| | | |
| | | RecommendActivity selectByPrimaryKey(Long id); |
| | | |
| | | int updateByPrimaryKeySelective(RecommendActivity record); |
| | | |
| | | int updateByPrimaryKey(RecommendActivity record); |
| | | |
| | | List<RecommendActivity> getRecommendActivityList(@Param("start") long start, @Param("count") int count); |
| | | |
| | |
| | | @Param("count") int count); |
| | | |
| | | int addShareCount(@Param("id") Long id, @Param("count") int count); |
| | | |
| | | /** |
| | | * 查询待发布的动态 |
| | | * @return |
| | | */ |
| | | List<RecommendActivity> getNeedPublish(); |
| | | |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | List<DaTaoKeDetail> listByIds(@Param("idList") List<Long> idList); |
| | | |
| | | |
| | | /** |
| | | * 取出最新的id |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | List<DaTaoKeDetail> getGoodsNotInList(@Param("cid") Long cid, @Param("list") List<Long> list, @Param("count") int count); |
| | | |
| | | |
| | | /** |
| | | * 根据标题查询 |
New file |
| | |
| | | package com.yeshi.fanli.dto.share;
|
| | |
|
| | | public class ShareInfoDTO {
|
| | | // 分享记录id
|
| | | private Long shareId;
|
| | | // 分享链接
|
| | | private String shareUrl;
|
| | | // 分享二维码
|
| | | private String codeUrl;
|
| | | // md5
|
| | | private String md5;
|
| | | |
| | | |
| | | public Long getShareId() {
|
| | | return shareId;
|
| | | }
|
| | | public void setShareId(Long shareId) {
|
| | | this.shareId = shareId;
|
| | | }
|
| | | public String getShareUrl() {
|
| | | return shareUrl;
|
| | | }
|
| | | public void setShareUrl(String shareUrl) {
|
| | | this.shareUrl = shareUrl;
|
| | | }
|
| | | public String getCodeUrl() {
|
| | | return codeUrl;
|
| | | }
|
| | | public void setCodeUrl(String codeUrl) {
|
| | | this.codeUrl = codeUrl;
|
| | | }
|
| | | public String getMd5() {
|
| | | return md5;
|
| | | }
|
| | | public void setMd5(String md5) {
|
| | | this.md5 = md5;
|
| | | }
|
| | | |
| | | |
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.dto.taobao;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | |
|
| | | public class TaoBaoShopDTO {
|
| | |
|
| | | private Long sellerId;// 卖家ID
|
| | | private Integer userType;// 用户类型 0-淘宝 1-天猫
|
| | | private String shopName;// 店铺名称
|
| | | private String shopIcon;// 店铺图标
|
| | | private String shopLink; // 店铺链接
|
| | | private String brandId; // 大淘客品牌Id
|
| | | private String brandDes; // 大淘客品牌描述
|
| | | |
| | | private List<TaoBaoGoodsBrief> listGoods;
|
| | | |
| | | |
| | | |
| | | public Long getSellerId() {
|
| | | return sellerId;
|
| | | }
|
| | | public void setSellerId(Long sellerId) {
|
| | | this.sellerId = sellerId;
|
| | | }
|
| | | public Integer getUserType() {
|
| | | return userType;
|
| | | }
|
| | | public void setUserType(Integer userType) {
|
| | | this.userType = userType;
|
| | | }
|
| | | public String getShopName() {
|
| | | return shopName;
|
| | | }
|
| | | public void setShopName(String shopName) {
|
| | | this.shopName = shopName;
|
| | | }
|
| | | public String getShopIcon() {
|
| | | return shopIcon;
|
| | | }
|
| | | public void setShopIcon(String shopIcon) {
|
| | | this.shopIcon = shopIcon;
|
| | | }
|
| | | public String getShopLink() {
|
| | | return shopLink;
|
| | | }
|
| | | public void setShopLink(String shopLink) {
|
| | | this.shopLink = shopLink;
|
| | | }
|
| | | public String getBrandId() {
|
| | | return brandId;
|
| | | }
|
| | | public void setBrandId(String brandId) {
|
| | | this.brandId = brandId;
|
| | | }
|
| | | public List<TaoBaoGoodsBrief> getListGoods() {
|
| | | return listGoods;
|
| | | }
|
| | | public void setListGoods(List<TaoBaoGoodsBrief> listGoods) {
|
| | | this.listGoods = listGoods;
|
| | | }
|
| | | public String getBrandDes() {
|
| | | return brandDes;
|
| | | }
|
| | | public void setBrandDes(String brandDes) {
|
| | | this.brandDes = brandDes;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | @Column(name = "ar_top")
|
| | | private Boolean top;// 是否置顶
|
| | |
|
| | | @Column(name = "ar_state")
|
| | | private Integer state;// 发布状态:1已发布 0未发布
|
| | | |
| | | |
| | | |
| | | @Expose
|
| | | @SerializedName("shareCount")
|
| | | private String shareCountShow;
|
| | |
| | | public void setEndTime_str(String endTime_str) {
|
| | | this.endTime_str = endTime_str;
|
| | | }
|
| | |
|
| | | public Integer getState() {
|
| | | return state;
|
| | | }
|
| | |
|
| | | public void setState(Integer state) {
|
| | | this.state = state;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | private String taobaoCids;
|
| | |
|
| | | |
| | |
|
| | | @Column(name = "sub_createtime")
|
| | | private Date createtime; // 创建时间
|
| | |
|
| | |
| | | private int countlabel = 0;
|
| | |
|
| | | private String searchParam;
|
| | |
|
| | | private GoodsSubClassLabel classLabel;
|
| | |
|
| | | public GoodsSubClass() {
|
| | | }
|
| | |
| | | public void setPictureSecond(String pictureSecond) {
|
| | | this.pictureSecond = pictureSecond;
|
| | | }
|
| | |
|
| | | |
| | | public String getTaobaoCids() {
|
| | | return taobaoCids;
|
| | | }
|
| | |
| | | public void setTaobaoCids(String taobaoCids) {
|
| | | this.taobaoCids = taobaoCids;
|
| | | }
|
| | |
|
| | | public GoodsSubClassLabel getClassLabel() {
|
| | | return classLabel;
|
| | | }
|
| | |
|
| | | public void setClassLabel(GoodsSubClassLabel classLabel) {
|
| | | this.classLabel = classLabel;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.entity.dynamic;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import org.springframework.data.annotation.Id;
|
| | | import org.springframework.data.mongodb.core.mapping.Document;
|
| | | import org.springframework.data.mongodb.core.mapping.Field;
|
| | |
|
| | | import com.google.gson.annotations.Expose;
|
| | | import com.yeshi.fanli.entity.bus.activity.ActivityUser;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoShop;
|
| | | import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
|
| | |
|
| | | @Document(collection = "dynamic_info")
|
| | | public class DynamicInfo {
|
| | |
|
| | | |
| | | // 分享类型 1:单图分享 、2:4图分享、 3:9图分享 、 4:邀请分享
|
| | | public final static int SHARE_TYPE_ONE = 1;
|
| | | public final static int SHARE_TYPE_FOUR = 2;
|
| | | public final static int SHARE_TYPE_NINE = 3;
|
| | | public final static int SHARE_TYPE_INVITE = 4;
|
| | | |
| | | |
| | | // 图片格式: 一排显示: 0无图 1一张 2两张 3张
|
| | | public final static int SHOW_TYPE_ZERO = 0;
|
| | | public final static int SHOW_TYPE_ONE = 1;
|
| | | public final static int SHOW_TYPE_TWO = 2;
|
| | | public final static int SHOW_TYPE_THREE = 3;
|
| | | |
| | | |
| | | @Id
|
| | | @Expose
|
| | | @Field("id")
|
| | | private String id;
|
| | | // 发布用户
|
| | | @Expose
|
| | | @Field("user")
|
| | | private ActivityUser user;
|
| | | // 发布内容
|
| | | @Expose
|
| | | @Field("title")
|
| | | private List<ClientTextStyleVO> title;
|
| | | // 图片信息
|
| | | @Expose
|
| | | @Field("imgs")
|
| | | private List<GoodsPicture> imgs;
|
| | | // 图片格式: 2-一排2个 1-一排一个 3-一排三个
|
| | | @Expose
|
| | | @Field("showType")
|
| | | private Integer showType;
|
| | | // 分享次数
|
| | | @Expose
|
| | | @Field("shareCount")
|
| | | private Integer shareCount;
|
| | | // 分享类型 1单图分享 、2 多图分享
|
| | | @Expose
|
| | | @Field("shareType")
|
| | | private Integer shareType;
|
| | | // 预计收入
|
| | | @Expose
|
| | | @Field("desc")
|
| | | private ClientTextStyleVO desc;
|
| | | // 店铺信息
|
| | | @Expose
|
| | | @Field("shop")
|
| | | private TaoBaoShop shop;
|
| | | // 前端发布时间
|
| | | @Expose
|
| | | @Field("createTime")
|
| | | private Date createTime;
|
| | |
|
| | | // 所属类型 1热销 2好货 3好店 4邀请
|
| | | @Field("classId")
|
| | | private Long classId;
|
| | | // 所属类型 1热销 2好货 3好店 4邀请
|
| | | @Field("subclassId")
|
| | | private Long subclassId;
|
| | |
|
| | | // 所属类型 1热销 2好货 3好店 4邀请
|
| | | @Field("daTaoKeId")
|
| | | private Long daTaoKeId;
|
| | | |
| | | |
| | | // 所属类型 人工编辑的动态id
|
| | | @Field("activityId")
|
| | | private Long activityId;
|
| | |
|
| | |
|
| | | public DynamicInfo() {
|
| | | }
|
| | |
|
| | | public DynamicInfo(String id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public String getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(String id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public ActivityUser getUser() {
|
| | | return user;
|
| | | }
|
| | |
|
| | | public void setUser(ActivityUser user) {
|
| | | this.user = user;
|
| | | }
|
| | |
|
| | | public List<ClientTextStyleVO> getTitle() {
|
| | | return title;
|
| | | }
|
| | |
|
| | | public void setTitle(List<ClientTextStyleVO> title) {
|
| | | this.title = title;
|
| | | }
|
| | |
|
| | | public List<GoodsPicture> getImgs() {
|
| | | return imgs;
|
| | | }
|
| | |
|
| | | public void setImgs(List<GoodsPicture> imgs) {
|
| | | this.imgs = imgs;
|
| | | }
|
| | |
|
| | | public Integer getShowType() {
|
| | | return showType;
|
| | | }
|
| | |
|
| | | public void setShowType(Integer showType) {
|
| | | this.showType = showType;
|
| | | }
|
| | |
|
| | | public Integer getShareCount() {
|
| | | return shareCount;
|
| | | }
|
| | |
|
| | | public void setShareCount(Integer shareCount) {
|
| | | this.shareCount = shareCount;
|
| | | }
|
| | |
|
| | | public ClientTextStyleVO getDesc() {
|
| | | return desc;
|
| | | }
|
| | |
|
| | | public void setDesc(ClientTextStyleVO desc) {
|
| | | this.desc = desc;
|
| | | }
|
| | |
|
| | | public TaoBaoShop getShop() {
|
| | | return shop;
|
| | | }
|
| | |
|
| | | public void setShop(TaoBaoShop shop) {
|
| | | this.shop = shop;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | |
|
| | | public Integer getShareType() {
|
| | | return shareType;
|
| | | }
|
| | |
|
| | | public void setShareType(Integer shareType) {
|
| | | this.shareType = shareType;
|
| | | }
|
| | |
|
| | | public Long getClassId() {
|
| | | return classId;
|
| | | }
|
| | |
|
| | | public void setClassId(Long classId) {
|
| | | this.classId = classId;
|
| | | }
|
| | |
|
| | | public Long getSubclassId() {
|
| | | return subclassId;
|
| | | }
|
| | |
|
| | | public void setSubclassId(Long subclassId) {
|
| | | this.subclassId = subclassId;
|
| | | }
|
| | |
|
| | | public Long getDaTaoKeId() {
|
| | | return daTaoKeId;
|
| | | }
|
| | |
|
| | | public void setDaTaoKeId(Long daTaoKeId) {
|
| | | this.daTaoKeId = daTaoKeId;
|
| | | }
|
| | |
|
| | | public Long getActivityId() {
|
| | | return activityId;
|
| | | }
|
| | |
|
| | | public void setActivityId(Long activityId) {
|
| | | this.activityId = activityId;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.entity.dynamic;
|
| | |
|
| | | import com.google.gson.annotations.Expose;
|
| | | import com.yeshi.fanli.entity.common.JumpDetailV2;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
|
| | |
|
| | | public class GoodsPicture {
|
| | | // 图片链接
|
| | | @Expose
|
| | | private String url;
|
| | | // 宽度
|
| | | @Expose
|
| | | private Integer w;
|
| | | // 高度
|
| | | @Expose
|
| | | private Integer h;
|
| | | // 商品信息
|
| | | @Expose
|
| | | private TaoBaoGoodsBriefExtra goods;
|
| | | // 跳转类型
|
| | | @Expose
|
| | | private JumpDetailV2 jumpDetail;
|
| | | // 跳转参数
|
| | | @Expose
|
| | | private String params;
|
| | | |
| | | |
| | |
|
| | | public String getUrl() {
|
| | | return url;
|
| | | }
|
| | |
|
| | | public void setUrl(String url) {
|
| | | this.url = url;
|
| | | }
|
| | |
|
| | | public Integer getW() {
|
| | | return w;
|
| | | }
|
| | |
|
| | | public void setW(Integer w) {
|
| | | this.w = w;
|
| | | }
|
| | |
|
| | | public Integer getH() {
|
| | | return h;
|
| | | }
|
| | |
|
| | | public void setH(Integer h) {
|
| | | this.h = h;
|
| | | }
|
| | |
|
| | | public TaoBaoGoodsBriefExtra getGoods() {
|
| | | return goods;
|
| | | }
|
| | |
|
| | | public void setGoods(TaoBaoGoodsBriefExtra goods) {
|
| | | this.goods = goods;
|
| | | }
|
| | |
|
| | | public JumpDetailV2 getJumpDetail() {
|
| | | return jumpDetail;
|
| | | }
|
| | |
|
| | | public void setJumpDetail(JumpDetailV2 jumpDetail) {
|
| | | this.jumpDetail = jumpDetail;
|
| | | }
|
| | |
|
| | | public String getParams() {
|
| | | return params;
|
| | | }
|
| | |
|
| | | public void setParams(String params) {
|
| | | this.params = params;
|
| | | }
|
| | | }
|
| | |
| | | @Expose
|
| | | private int salesType;//销量类型:1-月销量 2-2小时销量 3-今日销量
|
| | |
|
| | | @Expose
|
| | | private boolean coupon; // 是否有券
|
| | |
|
| | |
|
| | | public int getMoneyType() {
|
| | |
| | | this.collected = collected;
|
| | | }
|
| | |
|
| | | public boolean isCoupon() {
|
| | | return coupon;
|
| | | }
|
| | |
|
| | | public void setCoupon(boolean coupon) {
|
| | | this.coupon = coupon;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.job;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.scheduling.annotation.Scheduled;
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.yeshi.utils.DateUtil;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivity;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.activity.ActivityService;
|
| | | import com.yeshi.fanli.service.inter.dynamic.DynamicInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
|
| | | @Component
|
| | | public class DynamicInfoJob {
|
| | | |
| | | @Resource
|
| | | private DynamicInfoService dynamicInfoService;
|
| | | |
| | | @Resource
|
| | | private ActivityService activityService;
|
| | | |
| | | |
| | | /**
|
| | | * 每10分钟 晚上00:00~06:00不下发任何一个商品
|
| | | */
|
| | | @Scheduled(cron = "0 0/10 6-23 * * ?")
|
| | | public void insetDynamicInfo() {
|
| | | |
| | | if (!Constant.IS_TASK) {
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | dynamicInfoService.insertTimeHotSale();
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | try {
|
| | | dynamicInfoService.insertTimeRecommend();
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 早上6,7,15,16,21,22,23点更新1次
|
| | | */
|
| | | @Scheduled(cron = "0 0 6,7,15,16,21,22,23 * * ? ")
|
| | | public void insetShopInfo1() {
|
| | | |
| | | if (!Constant.IS_TASK) {
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | dynamicInfoService.insertShopInfo();
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 早上8:00~10:00每半个小时更新
|
| | | */
|
| | | @Scheduled(cron = "0 0/30 8,9,10 * * ?")
|
| | | public void insetShopInfo2() {
|
| | | |
| | | if (!Constant.IS_TASK) {
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | dynamicInfoService.insertShopInfo();
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 早上11:00~14:00每半个小时更新
|
| | | */
|
| | | @Scheduled(cron = "0 0/30 11,12,13,14 * * ?")
|
| | | public void insetShopInfo3() {
|
| | | |
| | | if (!Constant.IS_TASK) {
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | dynamicInfoService.insertShopInfo();
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 下午17:00~20:00每半个小时更新
|
| | | */
|
| | | @Scheduled(cron = "0 0/30 17,18,19,20 * * ? ")
|
| | | public void insetShopInfo4() {
|
| | | |
| | | if (!Constant.IS_TASK) {
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | dynamicInfoService.insertShopInfo();
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | } |
| | | |
| | | |
| | | /**
|
| | | * 每天零点删除3天之前数据
|
| | | */
|
| | | @Scheduled(cron = "0 0 0 * * ?")
|
| | | public void remove() {
|
| | | |
| | | if (!Constant.IS_TASK) {
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | dynamicInfoService.removeByDate(DateUtil.reduceDay(3, new Date()));
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 后台编辑动态: 每3分钟检索
|
| | | */
|
| | | @Scheduled(cron = "0 0/3 * * * ?")
|
| | | public void activityNeedPublish() {
|
| | | |
| | | if (!Constant.IS_TASK) {
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | List<RecommendActivity> list = activityService.getNeedPublish();
|
| | | if (list == null || list.size() == 0) {
|
| | | return;
|
| | | }
|
| | | |
| | | |
| | | for (RecommendActivity activity : list) {
|
| | | Integer type = activity.getType();
|
| | | if (RecommendActivity.TYPE_SHARE_GOODS == type) {
|
| | | // 商品动态
|
| | | dynamicInfoService.saveActivityRecommend(activity);
|
| | | |
| | | activity.setState(1);
|
| | | activityService.updateByPrimaryKeySelective(activity);
|
| | | |
| | | } else if (RecommendActivity.TYPE_INVITE == type) {
|
| | | // 邀请素材
|
| | | String imgUrl = null;
|
| | | List<String> imageList = activityService.getImgByActivityId(activity.getId());
|
| | | if (imageList != null && imageList.size() > 0) {
|
| | | imgUrl = imageList.get(0);
|
| | | }
|
| | | |
| | | dynamicInfoService.insertInviteMaterial(activity.getTitle(), imgUrl, activity.getId(), activity.getActivityUser());
|
| | | |
| | | activity.setState(1);
|
| | | activityService.updateByPrimaryKeySelective(activity);
|
| | | }
|
| | | }
|
| | | |
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | }
|
| | |
| | | </select> |
| | | |
| | | |
| | | |
| | | <select id="listRand" resultMap="BaseResultMap"> |
| | | SELECT |
| | | <include refid="Base_Column_List" /> |
| | | FROM yeshi_ec_activity_user ORDER BY RAND() LIMIT #{count} |
| | | </select> |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_activity_user where au_id = #{id,jdbcType=BIGINT} |
| | |
| | | <result column="ar_top" property="top" jdbcType="BOOLEAN"/> |
| | | <result column="ar_start_time" property="startTime" jdbcType="TIMESTAMP"/> |
| | | <result column="ar_end_time" property="endTime" jdbcType="TIMESTAMP"/> |
| | | |
| | | <result column="ar_state" property="state" jdbcType="INTEGER"/> |
| | | |
| | | <association property="activityUser" column="ar_activity_uid" |
| | | resultMap="com.yeshi.fanli.dao.mybatis.activity.ActivityUserMapper.BaseResultMap" /> |
| | | |
| | |
| | | |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List">ar_id,ar_title,ar_type,ar_order_by,ar_activity_uid,ar_share_count,ar_total_getmoney,ar_video_post_picture,ar_video_url,ar_create_time,ar_top,ar_start_time,ar_end_time</sql> |
| | | <sql id="Base_Column_List">ar_id,ar_title,ar_type,ar_order_by,ar_activity_uid,ar_share_count,ar_total_getmoney,ar_video_post_picture,ar_video_url,ar_create_time,ar_top,ar_start_time,ar_end_time,ar_state</sql> |
| | | |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long"> |
| | | select *,ar_activity_uid AS au_id from yeshi_ec_activity_recommend |
| | |
| | | </delete> |
| | | |
| | | |
| | | <select id="getNeedPublish" resultMap="BaseResultMap"> |
| | | SELECT * FROM yeshi_ec_activity_recommend |
| | | LEFT JOIN yeshi_ec_activity_user ON ar_activity_uid= au_id |
| | | WHERE ar_state = 0 AND IF(ar_start_time IS NULL,TRUE, ar_start_time<![CDATA[<=]]> NOW()) |
| | | AND IF(ar_end_time IS NULL,TRUE, ar_end_time <![CDATA[>=]]> NOW()) |
| | | </select> |
| | | |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_activity_recommend where ar_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.activity.RecommendActivity" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_activity_recommend (ar_id,ar_title,ar_type,ar_order_by,ar_activity_uid,ar_share_count,ar_total_getmoney,ar_video_post_picture,ar_video_url,ar_create_time,ar_top,ar_start_time,ar_end_time) values (#{id,jdbcType=BIGINT},#{title,jdbcType=VARCHAR},#{type,jdbcType=INTEGER},#{orderBy,jdbcType=INTEGER},#{activityUser.id,jdbcType=BIGINT},#{shareCount,jdbcType=INTEGER},#{totalGetMoney,jdbcType=VARCHAR},#{videoPostPictire,jdbcType=VARCHAR},#{videoUrl,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{top,jdbcType=BOOLEAN},#{startTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.activity.RecommendActivity" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_activity_recommend (ar_id,ar_title,ar_type,ar_order_by,ar_activity_uid,ar_share_count,ar_total_getmoney,ar_video_post_picture,ar_video_url,ar_create_time,ar_top,ar_start_time,ar_end_time,ar_state) values (#{id,jdbcType=BIGINT},#{title,jdbcType=VARCHAR},#{type,jdbcType=INTEGER},#{orderBy,jdbcType=INTEGER},#{activityUser.id,jdbcType=BIGINT},#{shareCount,jdbcType=INTEGER},#{totalGetMoney,jdbcType=VARCHAR},#{videoPostPictire,jdbcType=VARCHAR},#{videoUrl,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{top,jdbcType=BOOLEAN},#{startTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{state,jdbcType=INTEGER})</insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.activity.RecommendActivity" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_activity_recommend |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">ar_id,</if> |
| | |
| | | <if test="top != null">ar_top,</if> |
| | | <if test="startTime != null">ar_start_time,</if> |
| | | <if test="endTime != null">ar_end_time,</if> |
| | | <if test="state != null">ar_state,</if> |
| | | </trim>values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | |
| | | <if test="top != null">#{top,jdbcType=BOOLEAN},</if> |
| | | <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="state != null">#{state,jdbcType=INTEGER},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.activity.RecommendActivity">update yeshi_ec_activity_recommend set ar_title = #{title,jdbcType=VARCHAR},ar_type = #{type,jdbcType=INTEGER},ar_order_by = #{orderBy,jdbcType=INTEGER},ar_activity_uid = #{activityUser.id,jdbcType=BIGINT},ar_share_count = #{shareCount,jdbcType=INTEGER},ar_total_getmoney = #{totalGetMoney,jdbcType=VARCHAR},ar_video_post_picture = #{videoPostPictire,jdbcType=VARCHAR},ar_video_url = #{videoUrl,jdbcType=VARCHAR},ar_create_time = #{createTime,jdbcType=TIMESTAMP},ar_top = #{top,jdbcType=BOOLEAN},ar_start_time = #{startTime,jdbcType=TIMESTAMP},ar_end_time = #{endTime,jdbcType=TIMESTAMP} where ar_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.activity.RecommendActivity">update yeshi_ec_activity_recommend set ar_title = #{title,jdbcType=VARCHAR},ar_type = #{type,jdbcType=INTEGER},ar_order_by = #{orderBy,jdbcType=INTEGER},ar_activity_uid = #{activityUser.id,jdbcType=BIGINT},ar_share_count = #{shareCount,jdbcType=INTEGER},ar_total_getmoney = #{totalGetMoney,jdbcType=VARCHAR},ar_video_post_picture = #{videoPostPictire,jdbcType=VARCHAR},ar_video_url = #{videoUrl,jdbcType=VARCHAR},ar_create_time = #{createTime,jdbcType=TIMESTAMP},ar_top = #{top,jdbcType=BOOLEAN},ar_start_time = #{startTime,jdbcType=TIMESTAMP},ar_end_time = #{endTime,jdbcType=TIMESTAMP},ar_state = #{state,jdbcType=INTEGER} where ar_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.activity.RecommendActivity">update yeshi_ec_activity_recommend |
| | | <set> |
| | | <if test="title != null">ar_title=#{title,jdbcType=VARCHAR},</if> |
| | |
| | | <if test="createTime != null">ar_create_time=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="top != null">ar_top=#{top,jdbcType=BOOLEAN},</if> |
| | | <if test="startTime != null">ar_start_time=#{startTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="endTime != null">ar_end_time=#{endTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="state != null">ar_state=#{state,jdbcType=INTEGER},</if> |
| | | </set> where ar_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </mapper> |
| | |
| | | <if test="createtime != null">#{createtime,jdbcType=TIMESTAMP},</if> |
| | | <if test="tkMktStatus != null">#{tkMktStatus,jdbcType=VARCHAR},</if> |
| | | <if test="updatetime != null">#{updatetime,jdbcType=TIMESTAMP},</if> |
| | | <if test="state != null">#{state,jdbcType=INTEGER},</if> |
| | | <if test="totalSales != null">#{totalSales,jdbcType=INTEGER},</if> |
| | | <if test="state != null">#{state,jdbcType=INTEGER}</if> |
| | | <if test="totalSales != null">#{totalSales,jdbcType=INTEGER}</if> |
| | | <if test="materialLibType != null">#{materialLibType,jdbcType=INTEGER}</if> |
| | | |
| | | |
| | |
| | | </foreach> |
| | | </select> |
| | | |
| | | <select id="getGoodsNotInList" resultMap="BaseResultMap"> |
| | | SELECT * FROM `yeshi_ec_goods_dataoke` d |
| | | WHERE 1=1 |
| | | <if test="cid != null and cid !=0"> |
| | | AND d.`cid` = #{cid} |
| | | </if> |
| | | <if test="list != null"> |
| | | AND d.`id` NOT IN <foreach collection="list" item="item" open="(" close=")" |
| | | separator=",">#{item}</foreach> |
| | | </if> |
| | | ORDER BY RAND() LIMIT #{count} |
| | | </select> |
| | | |
| | | |
| | | <select id="listByDtitle" resultMap="BaseResultMap" |
| | |
| | | </select> |
| | | |
| | | |
| | | <<<<<<< HEAD |
| | | <select id="listSearchByTitleWithCid" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | |
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsUpdateException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.activity.ActivityService;
|
| | | import com.yeshi.fanli.service.inter.activity.ActivityUserService;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.dynamic.DynamicInfoService;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
|
| | |
| | |
|
| | | @Resource
|
| | | private CommonGoodsService commonGoodsService;
|
| | | |
| | | @Resource
|
| | | private DynamicInfoService dynamicInfoService;
|
| | | |
| | | @Resource
|
| | | private ActivityUserService activityUserService;
|
| | | |
| | |
|
| | | @Override
|
| | | public List<RecommendActivity> getRecommendActivityList(int page, int pageSize) {
|
| | |
| | | for (long auctionId : goodsList) {
|
| | | TaoBaoGoodsBrief tb = null;
|
| | | try {
|
| | | tb = TaoKeApiUtil.searchGoodsDetail(auctionId);
|
| | | tb = redisManager.getTaoBaoGoodsBrief(auctionId);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
| | | recommendActivityMapper.batchDeleteByPrimaryKey(ids);
|
| | | recommendActivityImgMapper.batchDeleteByActivityid(ids);
|
| | | recommendActivityTaoBaoGoodsMapper.batchDeleteByActivityid(ids);
|
| | | |
| | | try {
|
| | | for (Long id: ids) {
|
| | | dynamicInfoService.deleteActivity(id);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
| | | activity.setType(RecommendActivity.TYPE_SHARE_GOODS);
|
| | | recommendActivityMapper.updateByPrimaryKeySelective(activity);
|
| | |
|
| | | List<RecommendActivityTaoBaoGoods> listgoods = new ArrayList<RecommendActivityTaoBaoGoods>();
|
| | | BigDecimal taotaoMoney = new BigDecimal(0);
|
| | | for (long auctionId : goodsList) {
|
| | | TaoBaoGoodsBrief tb = null;
|
| | |
|
| | | try {
|
| | | tb = TaoKeApiUtil.searchGoodsDetail(auctionId);
|
| | | tb = redisManager.getTaoBaoGoodsBrief(auctionId);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
| | | recommendActivityTaoBaoGoodsMapper.insertSelective(goods);
|
| | | BigDecimal money = taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb);
|
| | | taotaoMoney = taotaoMoney.add(money);
|
| | | |
| | | listgoods.add(goods);
|
| | | }
|
| | |
|
| | | RecommendActivity updateActivity = new RecommendActivity();
|
| | | updateActivity.setId(activity.getId());
|
| | | updateActivity.setTotalGetMoney("预估分享奖金:¥" + taotaoMoney.toString());
|
| | | recommendActivityMapper.updateByPrimaryKeySelective(updateActivity);
|
| | |
|
| | | |
| | | RecommendActivity exist = recommendActivityMapper.selectByPrimaryKey(activity.getId());
|
| | | if (exist.getState() != null && exist.getState() == 1) {
|
| | | try {
|
| | | ActivityUser activityUser = activityUserService.selectByPrimaryKey(activityUid);
|
| | | exist.setActivityUser(activityUser);
|
| | | exist.setGoodsList(listgoods);
|
| | | dynamicInfoService.saveActivityRecommend(exist);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | return activity;
|
| | | }
|
| | |
|
| | |
| | | recommendActivityInviteInfo.setSize(erCodeSize);
|
| | | recommendActivityInviteInfoMapper.insertSelective(recommendActivityInviteInfo);
|
| | |
|
| | | |
| | | RecommendActivity exist = recommendActivityMapper.selectByPrimaryKey(activity.getId());
|
| | | if (exist.getState() != null && exist.getState() == 1) {
|
| | | try {
|
| | | ActivityUser activityUser = activityUserService.selectByPrimaryKey(activityUid);
|
| | | dynamicInfoService.insertInviteMaterial(exist.getTitle(), url, activity.getId(), activityUser);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | return activity;
|
| | | }
|
| | |
|
| | |
| | | public List<RecommendActivity> getRecommendActivityListCache(int page, int pageSize) {
|
| | | List<RecommendActivity> activityList = getRecommendActivityList(page, pageSize);
|
| | | if (activityList != null) {
|
| | | for (RecommendActivity activity : activityList) {
|
| | | for (int i = 0; i < activityList.size(); i++) {
|
| | | |
| | | RecommendActivity activity = activityList.get(i);
|
| | | |
| | | // 筛选出不足9个的商品
|
| | | if (RecommendActivity.TYPE_SHARE_GOODS == activity.getType()
|
| | | && (activity.getGoodsList() == null || activity.getGoodsList().size() < 9)) {
|
| | | activityList.remove(activity);
|
| | | i--;
|
| | | continue;
|
| | | }
|
| | | |
| | |
|
| | | if (activity != null && activity.getGoodsList() != null) {
|
| | | for (RecommendActivityTaoBaoGoods goods : activity.getGoodsList()) {
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | @Override
|
| | | public List<String> getImgByActivityId(Long activityId){
|
| | | return recommendActivityImgMapper.getImgByActivityId(activityId);
|
| | | }
|
| | | |
| | | @Override
|
| | | public List<RecommendActivity> getNeedPublish() {
|
| | | return recommendActivityMapper.getNeedPublish();
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.activity;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.activity.ActivityUserMapper;
|
| | | import com.yeshi.fanli.entity.bus.activity.ActivityUser;
|
| | | import com.yeshi.fanli.service.inter.activity.ActivityUserService;
|
| | |
|
| | | @Service
|
| | | public class ActivityUserServiceImpl implements ActivityUserService {
|
| | |
|
| | | @Resource
|
| | | private ActivityUserMapper activityUserMapper;
|
| | |
|
| | |
|
| | | @Override
|
| | | public ActivityUser selectByPrimaryKey(Long id) {
|
| | | return activityUserMapper.selectByPrimaryKey(id);
|
| | | }
|
| | | |
| | | @Override
|
| | | public List<ActivityUser> listRand(int count) {
|
| | | return activityUserMapper.listRand(count);
|
| | | }
|
| | | |
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.dynamic;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.dynamic.DynamicInfoDao;
|
| | | import com.yeshi.fanli.dto.taobao.TaoBaoShopDTO;
|
| | | import com.yeshi.fanli.entity.bus.activity.ActivityUser;
|
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivity;
|
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivityTaoBaoGoods;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
|
| | | import com.yeshi.fanli.entity.dynamic.DynamicInfo;
|
| | | import com.yeshi.fanli.entity.dynamic.GoodsPicture;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoShop;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.activity.ActivityUserService;
|
| | | import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.dynamic.DynamicInfoService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsService;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.dataoke.DaTaoKeApiUtil;
|
| | | import com.yeshi.fanli.util.taobao.DaTaoKeUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Service
|
| | | public class DynamicInfoServiceImpl implements DynamicInfoService {
|
| | | |
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | | |
| | | @Resource
|
| | | private DynamicInfoDao dynamicInfoDao;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | | |
| | | @Resource
|
| | | private DaTaoKeGoodsService daTaoKeGoodsService;
|
| | |
|
| | | @Resource
|
| | | private JumpDetailV2Service jumpDetailV2Service;
|
| | |
|
| | | @Resource
|
| | | private ActivityUserService activityUserService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
|
| | | |
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | | |
| | | @Resource
|
| | | private TaoBaoShopService taoBaoShopService;
|
| | | |
| | | @Override
|
| | | public void insert(DynamicInfo record) {
|
| | | dynamicInfoDao.insert(record);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public DynamicInfo getById(String id) {
|
| | | return dynamicInfoDao.getById(id);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public void insertTimeRecommend() {
|
| | | try {
|
| | | Long classId = 2L;
|
| | | List<GoodsClass> list = DaTaoKeUtil.goodsClasses;
|
| | | int index = (int) (Math.random() * list.size());
|
| | | Long subclassId = list.get(index).getId();
|
| | | int count = 0;
|
| | | double random = Math.random();
|
| | | if (random > 0.5) {
|
| | | count = 9;
|
| | | } else {
|
| | | count = 4;
|
| | | }
|
| | |
|
| | | List<DaTaoKeDetail> listDaTaoKe = daTaoKeGoodsService.getGoodsNotInList(subclassId, null, count);
|
| | |
|
| | | DaTaoKeDetail daTaoKeDetail = null;
|
| | | // 商品列表
|
| | | List<GoodsPicture> listPicture = new ArrayList<GoodsPicture>();
|
| | |
|
| | | // 分享奖金
|
| | | BigDecimal shareMoney = new BigDecimal(0);
|
| | |
|
| | | BigDecimal proportion = hongBaoManageService.getFanLiRate();
|
| | | for (DaTaoKeDetail daTaoKe : listDaTaoKe) {
|
| | | if (daTaoKeDetail == null) {
|
| | | daTaoKeDetail = daTaoKe;
|
| | | }
|
| | | // 分享奖金
|
| | |
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = TaoBaoUtil.convert(daTaoKe);
|
| | | TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null);
|
| | | if (!taoBaoGoodsBriefExtra.isCoupon()) {
|
| | | taoBaoGoodsBriefExtra.setState(1);
|
| | | }
|
| | | |
| | | BigDecimal money = taoBaoGoodsBriefService.getShareGoodsUserHongBao(taoBaoGoodsBrief);
|
| | | shareMoney = MoneyBigDecimalUtil.add(shareMoney, money);
|
| | | // 商品图片
|
| | | taoBaoGoodsBriefExtra.setUpdatetime(new Date());
|
| | | taoBaoGoodsBriefExtra.setCouponInfo(null);
|
| | | GoodsPicture goodsPicture = getGoodsPicture(daTaoKe);
|
| | | goodsPicture.setGoods(taoBaoGoodsBriefExtra);
|
| | | |
| | | listPicture.add(goodsPicture);
|
| | | }
|
| | |
|
| | | // 组织动态信息
|
| | | DynamicInfo dynamicInfo = getDynamicInfo(daTaoKeDetail, classId, subclassId);
|
| | | dynamicInfo.setImgs(listPicture);
|
| | |
|
| | | ClientTextStyleVO shareMoneyDesc = new ClientTextStyleVO();
|
| | | shareMoneyDesc.setColor("#FFFFFF");
|
| | | shareMoneyDesc.setBottomColor("#E8AE48");
|
| | | shareMoneyDesc.setContent("预估分享奖金:¥" + shareMoney);
|
| | | dynamicInfo.setDesc(shareMoneyDesc);
|
| | | dynamicInfo.setShowType(2);
|
| | |
|
| | | if (count == 4) {
|
| | | dynamicInfo.setShowType(DynamicInfo.SHOW_TYPE_TWO);
|
| | | dynamicInfo.setShareType(DynamicInfo.SHARE_TYPE_FOUR); // 分享类型4图
|
| | | } else {
|
| | | dynamicInfo.setShowType(DynamicInfo.SHOW_TYPE_THREE);
|
| | | dynamicInfo.setShareType(DynamicInfo.SHARE_TYPE_NINE); // 分享类型9图
|
| | | }
|
| | | // 保存信息
|
| | | dynamicInfoDao.insert(dynamicInfo);
|
| | |
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | // 定时插入
|
| | | @Override
|
| | | public void insertTimeHotSale() {
|
| | | Long classId = 1L;
|
| | | try {
|
| | | saveHotSale(classId, 0L);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | // 热销单品的分类
|
| | | List<GoodsClass> list = DaTaoKeUtil.goodsClasses;
|
| | | for (GoodsClass goodsClass : list) {
|
| | | try {
|
| | | saveHotSale(classId, goodsClass.getId());
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 保存热销单品
|
| | | * |
| | | * @param classId
|
| | | * @param subclassId
|
| | | * @throws TaobaoGoodsDownException
|
| | | */
|
| | | public void saveHotSale(Long classId, Long subclassId) throws TaobaoGoodsDownException {
|
| | | List<Long> listId = null;
|
| | | List<DynamicInfo> listInfo = dynamicInfoDao.query(classId, subclassId);
|
| | | if (listInfo != null && listInfo.size() > 0) {
|
| | | listId = new ArrayList<Long>();
|
| | | for (DynamicInfo dynamicInfo : listInfo) {
|
| | | Long daTaoKeId = dynamicInfo.getDaTaoKeId();
|
| | | if (daTaoKeId != null) {
|
| | | listId.add(dynamicInfo.getDaTaoKeId());
|
| | | }
|
| | | }
|
| | | }
|
| | | // 大淘客数据
|
| | | DaTaoKeDetail daTaoKe = daTaoKeGoodsService.getGoodsNotInList(subclassId, listId, 1).get(0);
|
| | |
|
| | | |
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = TaoBaoUtil.convert(daTaoKe);
|
| | | BigDecimal proportion = hongBaoManageService.getFanLiRate();
|
| | | TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null);
|
| | | if (!taoBaoGoodsBriefExtra.isCoupon()) {
|
| | | taoBaoGoodsBriefExtra.setState(1);
|
| | | }
|
| | | |
| | | // 分享奖金
|
| | | BigDecimal shareMoney = taoBaoGoodsBriefService.getShareGoodsUserHongBao(taoBaoGoodsBrief);
|
| | | ClientTextStyleVO shareMoneyDesc = new ClientTextStyleVO();
|
| | | shareMoneyDesc.setColor("#FFFFFF");
|
| | | shareMoneyDesc.setBottomColor("#E8AE48");
|
| | | shareMoneyDesc.setContent("预估分享奖金:¥" + shareMoney);
|
| | | // 商品图片
|
| | | GoodsPicture goodsPicture = getGoodsPicture(daTaoKe);
|
| | | taoBaoGoodsBriefExtra.setUpdatetime(new Date());
|
| | | taoBaoGoodsBriefExtra.setCouponInfo(null);
|
| | | goodsPicture.setGoods(taoBaoGoodsBriefExtra);
|
| | | // 商品列表
|
| | | List<GoodsPicture> listPicture = new ArrayList<GoodsPicture>();
|
| | | listPicture.add(goodsPicture);
|
| | |
|
| | | // 获取商品列表图片
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief2 = TaoKeApiUtil.getSimpleGoodsInfo(daTaoKe.getGoodsId());
|
| | | List<String> imgList = taoBaoGoodsBrief2.getImgList();
|
| | | List<String> listimgs = new ArrayList<String>();
|
| | | String pic = daTaoKe.getPic();
|
| | | listimgs.add(TbImgUtil.getTBSize320Img(pic));
|
| | | if (imgList != null && imgList.size() > 0) {
|
| | | for (String img : imgList) {
|
| | |
|
| | | if (listPicture.size() >= 4) {
|
| | | break;
|
| | | }
|
| | | if (pic.equals(img)) {
|
| | | continue;
|
| | | }
|
| | | |
| | | listimgs.add(img);
|
| | | GoodsPicture picture = new GoodsPicture();
|
| | | picture.setH(100);
|
| | | picture.setW(100);
|
| | | picture.setUrl(TbImgUtil.getTBSize320Img(img));
|
| | | listPicture.add(picture);
|
| | | }
|
| | | }
|
| | | |
| | | taoBaoGoodsBriefExtra.setImgList(imgList);
|
| | |
|
| | | // 组织动态信息
|
| | | DynamicInfo dynamicInfo = getDynamicInfo(daTaoKe, classId, subclassId);
|
| | |
|
| | | dynamicInfo.setImgs(listPicture);
|
| | | dynamicInfo.setDesc(shareMoneyDesc);
|
| | | dynamicInfo.setShareType(DynamicInfo.SHARE_TYPE_ONE);
|
| | | dynamicInfo.setShowType(DynamicInfo.SHOW_TYPE_TWO);
|
| | |
|
| | | // 保存信息
|
| | | dynamicInfoDao.insert(dynamicInfo);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 数据组织存入MongoDB中
|
| | | * |
| | | * @param daTaoKe
|
| | | * @param classId
|
| | | * @param subclassId
|
| | | * @throws TaobaoGoodsDownException
|
| | | */
|
| | | public DynamicInfo getDynamicInfo(DaTaoKeDetail daTaoKe, Long classId, Long subclassId) {
|
| | | DynamicInfo dynamicInfo = new DynamicInfo();
|
| | | dynamicInfo.setId(UUID.randomUUID().toString().replace("-", ""));
|
| | | dynamicInfo.setClassId(classId);
|
| | | dynamicInfo.setSubclassId(subclassId);
|
| | | dynamicInfo.setDaTaoKeId(daTaoKe.getId());
|
| | | dynamicInfo.setCreateTime(new Date());
|
| | |
|
| | | // 随机分享次数
|
| | | dynamicInfo.setShareCount(1000 + (int) (Math.random() * 8000));
|
| | | // 随机分布用户
|
| | | dynamicInfo.setUser(activityUserService.listRand(1).get(0));
|
| | | // 内容
|
| | | dynamicInfo.setTitle(convertIntroduce(DaTaoKeUtil.getDesc(daTaoKe)));
|
| | |
|
| | | return dynamicInfo;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 文字内容
|
| | | * |
| | | * @param introduce
|
| | | * @return
|
| | | */
|
| | | public List<ClientTextStyleVO> convertIntroduce(String introduce) {
|
| | | List<ClientTextStyleVO> title = new ArrayList<ClientTextStyleVO>();
|
| | | ClientTextStyleVO desc = new ClientTextStyleVO();
|
| | | desc.setColor("#333333");
|
| | | desc.setContent(introduce);
|
| | | title.add(desc);
|
| | | return title;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 图片列表
|
| | | * |
| | | * @param daTaoKe
|
| | | * @return
|
| | | */
|
| | | public GoodsPicture getGoodsPicture(DaTaoKeDetail daTaoKe) {
|
| | | GoodsPicture goodsPicture = new GoodsPicture();
|
| | | goodsPicture.setH(100);
|
| | | goodsPicture.setW(100);
|
| | | goodsPicture.setUrl(TbImgUtil.getTBSize320Img(daTaoKe.getPic()));
|
| | | goodsPicture.setJumpDetail(jumpDetailV2Service.getByTypeCache("goodsdetail"));
|
| | | |
| | | String goodsId = daTaoKe.getGoodsId().toString();
|
| | | JSONObject item = new JSONObject();
|
| | | item.put("id", goodsId);
|
| | | item.put("from", "dynamics");
|
| | | goodsPicture.setParams(item.toString());
|
| | | return goodsPicture;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long count(Long cid, Long subId) {
|
| | | return dynamicInfoDao.count(cid, subId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<DynamicInfo> query(int start, int count, Long cid, Long subId) {
|
| | | List<DynamicInfo> list = dynamicInfoDao.query(start, count, cid, subId);
|
| | | |
| | | // // 更新商品信息
|
| | | // executor.execute(new Runnable() {
|
| | | // @Override
|
| | | // public void run() {
|
| | | // updateGoodInfo(list);
|
| | | // }
|
| | | // });
|
| | | |
| | | return list;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void updateShareCount(DynamicInfo record) {
|
| | | dynamicInfoDao.updateShareCount(record);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public void insertInviteMaterial(String title, String picUrl, Long activityId, ActivityUser activityUser) {
|
| | | |
| | | DynamicInfo existInfo = null;
|
| | | if (activityId != null) {
|
| | | existInfo = dynamicInfoDao.getByActivityId(activityId);
|
| | | if (existInfo != null) {
|
| | | dynamicInfoDao.deleteById(existInfo.getId());
|
| | | }
|
| | | |
| | | if (!StringUtil.isNullOrEmpty(title)) {
|
| | | title = title.replace("<p>", "");
|
| | | title = title.replace("</p>", "");
|
| | | }
|
| | | }
|
| | | |
| | | DynamicInfo dynamicVO = new DynamicInfo();
|
| | | dynamicVO.setId(UUID.randomUUID().toString().replace("-", ""));
|
| | | dynamicVO.setActivityId(activityId);
|
| | | dynamicVO.setClassId(4L);
|
| | | dynamicVO.setSubclassId(0L);
|
| | | dynamicVO.setShareType(DynamicInfo.SHARE_TYPE_INVITE);
|
| | | if (existInfo != null) {
|
| | | dynamicVO.setCreateTime(existInfo.getCreateTime());
|
| | | dynamicVO.setShareCount(existInfo.getShareCount());
|
| | | } else {
|
| | | dynamicVO.setCreateTime(new Date());
|
| | | dynamicVO.setShareCount(1000 + (int) (Math.random() * 8000));
|
| | | }
|
| | | |
| | | |
| | | if (activityUser == null) {
|
| | | dynamicVO.setUser(activityUserService.listRand(1).get(0));
|
| | | } else {
|
| | | dynamicVO.setUser(activityUser);
|
| | | }
|
| | | |
| | | |
| | | // 介绍内容
|
| | | ClientTextStyleVO row1 = new ClientTextStyleVO();
|
| | | row1.setColor("#333333");
|
| | | row1.setContent(title);
|
| | | List<ClientTextStyleVO> listtitle = new ArrayList<ClientTextStyleVO>();
|
| | | listtitle.add(row1);
|
| | | dynamicVO.setTitle(listtitle);
|
| | | |
| | | List<GoodsPicture> listImg = new ArrayList<GoodsPicture>();
|
| | | if(!StringUtil.isNullOrEmpty(picUrl)) {
|
| | | GoodsPicture p2 = new GoodsPicture();
|
| | | p2.setW(100);
|
| | | p2.setH(100);
|
| | | p2.setUrl(picUrl);
|
| | | listImg.add(p2);
|
| | | dynamicVO.setShowType(DynamicInfo.SHOW_TYPE_ONE);
|
| | | } else {
|
| | | dynamicVO.setShowType(DynamicInfo.SHOW_TYPE_ZERO);
|
| | | }
|
| | | |
| | | dynamicVO.setImgs(listImg);
|
| | | dynamicInfoDao.insert(dynamicVO);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public void insertShopInfo() {
|
| | | List<String> brandIdList = DaTaoKeApiUtil.getBrandIdList();
|
| | | if (brandIdList == null || brandIdList.size() == 0) {
|
| | | LogHelper.test("大淘客品牌id获取失败(DynamicInfoService-insertShopInfo)");
|
| | | return;
|
| | | }
|
| | | |
| | | |
| | | Long classId = 3L;
|
| | | Long subclassId = 0L;
|
| | | List<DynamicInfo> listInfo = dynamicInfoDao.query(classId, subclassId);
|
| | |
|
| | | // 清理已存在品牌
|
| | | if (listInfo != null && listInfo.size() > 0) {
|
| | | for (int i = 0; i < brandIdList.size(); i++) {
|
| | | String brandId = brandIdList.get(i);
|
| | | |
| | | for (int j = 0; j < listInfo.size(); j++) {
|
| | | String id = listInfo.get(j).getId();
|
| | | if (brandId.equals(id)) {
|
| | | brandIdList.remove(brandId);
|
| | | i--;
|
| | | |
| | | listInfo.remove(listInfo.get(j));
|
| | | j--;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | if (brandIdList == null || brandIdList.size() == 0) {
|
| | | LogHelper.test("大淘客品牌已全部爬取(DynamicInfoService-insertShopInfo)");
|
| | | return;
|
| | | }
|
| | | |
| | | int index = (int) (Math.random() * brandIdList.size());
|
| | | String brandId = brandIdList.get(index);
|
| | | |
| | | TaoBaoShopDTO dynamicShopInfo = DaTaoKeApiUtil.getDynamicShopInfo(brandId);
|
| | | if (dynamicShopInfo == null) {
|
| | | LogHelper.test("大淘客品牌信息爬取失败(DynamicInfoService-insertShopInfo)");
|
| | | return;
|
| | | }
|
| | | |
| | | |
| | | List<TaoBaoGoodsBrief> listGoods = dynamicShopInfo.getListGoods();
|
| | | if (listGoods == null || listGoods.size() == 0) {
|
| | | LogHelper.test("大淘客品牌商品信息爬取失败(DynamicInfoService-insertShopInfo)");
|
| | | return;
|
| | | }
|
| | | |
| | | Long sellerId = dynamicShopInfo.getSellerId();
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = listGoods.get(0);
|
| | | TaoBaoShop taoBaoShop = taoBaoShopService.getTaoBaoShop(taoBaoGoodsBrief.getAuctionId(), sellerId);
|
| | | if (taoBaoShop == null) {
|
| | | LogHelper.test("店铺详情信息获取失败(DynamicInfoService-insertShopInfo)");
|
| | | return;
|
| | | }
|
| | | String shopLink = taoBaoShop.getShopLink();
|
| | | if (StringUtil.isNullOrEmpty(shopLink)) {
|
| | | taoBaoShop.setShopLink(TaoBaoUtil.getShopLink(taoBaoShop.getId()));
|
| | | }
|
| | | |
| | | DynamicInfo dynamicVO = new DynamicInfo();
|
| | | dynamicVO.setId(brandId);
|
| | | dynamicVO.setClassId(classId);
|
| | | dynamicVO.setSubclassId(subclassId);
|
| | | dynamicVO.setShowType(DynamicInfo.SHOW_TYPE_TWO);
|
| | | dynamicVO.setShop(taoBaoShop);
|
| | | dynamicVO.setUser(activityUserService.listRand(1).get(0));
|
| | | dynamicVO.setCreateTime(new Date());
|
| | | |
| | | // 介绍内容
|
| | | ClientTextStyleVO row1 = new ClientTextStyleVO();
|
| | | row1.setColor("#333333");
|
| | | row1.setContent(dynamicShopInfo.getBrandDes());
|
| | | List<ClientTextStyleVO> listTitle = new ArrayList<ClientTextStyleVO>();
|
| | | listTitle.add(row1);
|
| | | dynamicVO.setTitle(listTitle);
|
| | | |
| | | // 商品信息
|
| | | List<GoodsPicture> listPicture = new ArrayList<GoodsPicture>();
|
| | | for (TaoBaoGoodsBrief goodsBrief : listGoods) {
|
| | | BigDecimal proportion = hongBaoManageService.getFanLiRate();
|
| | | TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion.toString(), null);
|
| | | taoBaoGoodsBriefExtra.setCouponInfo(null);
|
| | | taoBaoGoodsBriefExtra.setUpdatetime(new Date());
|
| | | |
| | | String goodsId = goodsBrief.getAuctionId().toString();
|
| | | JSONObject item = new JSONObject();
|
| | | item.put("id", goodsId);
|
| | | item.put("from", "dynamics");
|
| | | |
| | | GoodsPicture goodsPicture = new GoodsPicture();
|
| | | goodsPicture.setH(100);
|
| | | goodsPicture.setW(100);
|
| | | goodsPicture.setUrl(TbImgUtil.getTBSize320Img(goodsBrief.getPictUrl()));
|
| | | goodsPicture.setJumpDetail(jumpDetailV2Service.getByTypeCache("goodsdetail"));
|
| | | goodsPicture.setParams(item.toString());
|
| | | goodsPicture.setGoods(taoBaoGoodsBriefExtra);
|
| | | |
| | | listPicture.add(goodsPicture);
|
| | | }
|
| | | dynamicVO.setImgs(listPicture);
|
| | | |
| | | dynamicInfoDao.insert(dynamicVO);
|
| | | }
|
| | | |
| | | @Override
|
| | | public void removeByDate(Date createTime) {
|
| | | dynamicInfoDao.removeByDate(createTime);
|
| | | }
|
| | | |
| | | |
| | | |
| | | /**
|
| | | * 更新商品信息
|
| | | */
|
| | | public void updateGoodInfo(List<DynamicInfo> list) {
|
| | | if (list == null || list.size() == 0) {
|
| | | return;
|
| | | }
|
| | | |
| | | BigDecimal proportion = hongBaoManageService.getFanLiRate();
|
| | | for (DynamicInfo dynamicInfo: list) {
|
| | | List<GoodsPicture> imgs = dynamicInfo.getImgs();
|
| | | if (imgs == null || imgs.size() == 0) {
|
| | | continue;
|
| | | }
|
| | | |
| | | boolean isupdate = false;
|
| | | BigDecimal shareMoney = null;
|
| | | for (GoodsPicture goodsPicture: imgs) {
|
| | | TaoBaoGoodsBriefExtra oldExtra = goodsPicture.getGoods();
|
| | | if (oldExtra == null) {
|
| | | continue;
|
| | | }
|
| | | |
| | | Integer state = oldExtra.getState();
|
| | | if (state != null && state == 1) {
|
| | | continue;
|
| | | }
|
| | | |
| | | long nd = 1000 * 24 * 60 * 60;// 一天的毫秒数 |
| | | long nh = 1000 * 60 * 60;// 一小时的毫秒数 |
| | | long diff = System.currentTimeMillis() - oldExtra.getUpdatetime().getTime(); |
| | | long day = diff / nd;// 计算差多少天 |
| | | long hour = diff % nd / nh + day * 24;// 计算差多少小时 |
| | | if (hour < 1) {
|
| | | continue;
|
| | | }
|
| | | |
| | | isupdate = true;
|
| | | try {
|
| | | TaoBaoGoodsBrief goodsBrief = redisManager.getTaoBaoGoodsBrief(oldExtra.getAuctionId());
|
| | | TaoBaoGoodsBriefExtra newExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion.toString(), null);
|
| | | |
| | | if (!newExtra.isCoupon()) {
|
| | | newExtra.setState(1);
|
| | | }
|
| | | newExtra.setUpdatetime(new Date());
|
| | | goodsPicture.setGoods(newExtra);
|
| | | |
| | | BigDecimal money = taoBaoGoodsBriefService.getShareGoodsUserHongBao(goodsBrief);
|
| | | shareMoney = MoneyBigDecimalUtil.add(shareMoney, money);
|
| | | |
| | | } catch (TaobaoGoodsDownException e) {
|
| | | oldExtra.setState(1);
|
| | | oldExtra.setCoupon(false);
|
| | | oldExtra.setUpdatetime(new Date());
|
| | | goodsPicture.setGoods(oldExtra);
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | if (shareMoney != null) {
|
| | | ClientTextStyleVO shareMoneyDesc = new ClientTextStyleVO();
|
| | | shareMoneyDesc.setColor("#FFFFFF");
|
| | | shareMoneyDesc.setBottomColor("#E8AE48");
|
| | | shareMoneyDesc.setContent("预估分享奖金:¥" + shareMoney);
|
| | | dynamicInfo.setDesc(shareMoneyDesc);
|
| | | }
|
| | | |
| | | if (isupdate) {
|
| | | dynamicInfoDao.updateGoodInfo(dynamicInfo);
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public void deleteActivity(Long activityId) {
|
| | | DynamicInfo dynamicInfo = dynamicInfoDao.getByActivityId(activityId);
|
| | | if (dynamicInfo != null) {
|
| | | // 删除之前的
|
| | | dynamicInfoDao.deleteById(dynamicInfo.getId());
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public void saveActivityRecommend(RecommendActivity activity) {
|
| | | if (activity == null || activity.getGoodsList() == null) {
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | DynamicInfo existInfo = dynamicInfoDao.getByActivityId(activity.getId());
|
| | | if (existInfo != null) {
|
| | | dynamicInfoDao.deleteById(existInfo.getId());
|
| | | }
|
| | | |
| | | DynamicInfo dynamicInfo = new DynamicInfo();
|
| | | dynamicInfo.setId(UUID.randomUUID().toString().replace("-", ""));
|
| | | dynamicInfo.setClassId(2L);
|
| | | dynamicInfo.setSubclassId(0L);
|
| | | dynamicInfo.setUser(activity.getActivityUser());
|
| | | dynamicInfo.setActivityId(activity.getId());
|
| | | |
| | | String title = activity.getTitle();
|
| | | if (!StringUtil.isNullOrEmpty(title)) {
|
| | | title = title.replace("<p>", "");
|
| | | title = title.replace("</p>", "");
|
| | | dynamicInfo.setTitle(convertIntroduce(title));
|
| | | }
|
| | | |
| | | if (existInfo != null) {
|
| | | dynamicInfo.setCreateTime(existInfo.getCreateTime());
|
| | | dynamicInfo.setShareCount(existInfo.getShareCount());
|
| | | } else {
|
| | | dynamicInfo.setCreateTime(new Date());
|
| | | dynamicInfo.setShareCount(1000 + (int) (Math.random() * 8000));
|
| | | }
|
| | |
|
| | | // 商品列表
|
| | | List<GoodsPicture> listPicture = new ArrayList<GoodsPicture>();
|
| | | BigDecimal proportion = hongBaoManageService.getFanLiRate();
|
| | | // 分享奖金
|
| | | BigDecimal shareMoney = new BigDecimal(0);
|
| | |
|
| | | if (activity.getGoodsList() != null) {
|
| | | for (RecommendActivityTaoBaoGoods activityGoods : activity.getGoodsList()) {
|
| | | |
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = null;
|
| | | TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = null;
|
| | | String auctionId = activityGoods.getAuctionId();
|
| | | try {
|
| | | taoBaoGoodsBrief = redisManager.getTaoBaoGoodsBrief(Long.parseLong(auctionId));
|
| | | |
| | | taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null);
|
| | | if (!taoBaoGoodsBriefExtra.isCoupon()) {
|
| | | taoBaoGoodsBriefExtra.setState(1);
|
| | | }
|
| | | |
| | | BigDecimal money = taoBaoGoodsBriefService.getShareGoodsUserHongBao(taoBaoGoodsBrief);
|
| | | shareMoney = MoneyBigDecimalUtil.add(shareMoney, money);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | taoBaoGoodsBrief = activityGoods.getTaoBaoGoodsBrief();
|
| | | taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null);
|
| | | taoBaoGoodsBriefExtra.setState(1);
|
| | | taoBaoGoodsBriefExtra.setCoupon(false);
|
| | | }
|
| | | // 商品图片
|
| | | taoBaoGoodsBriefExtra.setCouponInfo(null);
|
| | | taoBaoGoodsBriefExtra.setUpdatetime(new Date());
|
| | | |
| | | JSONObject item = new JSONObject();
|
| | | item.put("id", auctionId);
|
| | | item.put("from", "dynamics");
|
| | | |
| | | GoodsPicture goodsPicture = new GoodsPicture();
|
| | | goodsPicture.setH(100);
|
| | | goodsPicture.setW(100);
|
| | | goodsPicture.setUrl(TbImgUtil.getTBSize320Img(taoBaoGoodsBrief.getPictUrl()));
|
| | | goodsPicture.setJumpDetail(jumpDetailV2Service.getByTypeCache("goodsdetail"));
|
| | | goodsPicture.setParams(item.toString());
|
| | | goodsPicture.setGoods(taoBaoGoodsBriefExtra);
|
| | | |
| | | listPicture.add(goodsPicture);
|
| | | }
|
| | | }
|
| | | dynamicInfo.setImgs(listPicture);
|
| | | |
| | | |
| | | ClientTextStyleVO shareMoneyDesc = new ClientTextStyleVO();
|
| | | shareMoneyDesc.setColor("#FFFFFF");
|
| | | shareMoneyDesc.setBottomColor("#E8AE48");
|
| | | shareMoneyDesc.setContent("预估分享奖金:¥" + shareMoney);
|
| | | dynamicInfo.setDesc(shareMoneyDesc);
|
| | | dynamicInfo.setShowType(2);
|
| | |
|
| | | if (listPicture.size() < 7) {
|
| | | dynamicInfo.setShowType(DynamicInfo.SHOW_TYPE_TWO);
|
| | | dynamicInfo.setShareType(DynamicInfo.SHARE_TYPE_FOUR); // 分享类型4图
|
| | | } else {
|
| | | dynamicInfo.setShowType(DynamicInfo.SHOW_TYPE_THREE);
|
| | | dynamicInfo.setShareType(DynamicInfo.SHARE_TYPE_NINE); // 分享类型9图
|
| | | }
|
| | | // 保存信息
|
| | | dynamicInfoDao.insert(dynamicInfo);
|
| | |
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsSubClass;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsSubClassLabelMap;
|
| | | import com.yeshi.fanli.exception.GoodsSubClassException;
|
| | | import com.yeshi.fanli.service.inter.clazz.GoodsSubClassLabelService;
|
| | | import com.yeshi.fanli.service.inter.goods.GoodsSubClassService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoClassService;
|
| | | import com.yeshi.fanli.service.inter.lable.LabelClassService;
|
| | |
| | |
|
| | | @Resource
|
| | | private TaoBaoClassService taoBaoClassService;
|
| | |
|
| | | @Resource
|
| | | private GoodsSubClassLabelService goodsSubClassLabelService;
|
| | |
|
| | | @Override
|
| | | public int deleteByPrimaryKey(Long id) {
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public void saveObject(MultipartFile file, MultipartFile file2, GoodsSubClass record, Integer type, Long pid,
|
| | | GoodsSubClassLabelMap labelMap) throws GoodsSubClassException, Exception {
|
| | | public void saveObject(MultipartFile file, MultipartFile file2, GoodsSubClass record, Integer type, Long pid)
|
| | | throws GoodsSubClassException, Exception {
|
| | |
|
| | | String name = record.getName();
|
| | | if (name == null || name.trim().length() == 0) {
|
| | |
| | | }
|
| | |
|
| | | goodsSubClassMapper.insert(record);
|
| | | if (labelMap != null) {
|
| | | labelMap.setCreateTime(new Date());
|
| | | labelMap.setGoodsSubClass(record);
|
| | | goodsSubClassLabelService.addSubClassLabelMap(labelMap);
|
| | | }
|
| | |
|
| | | } else {
|
| | | // 修改
|
| | |
| | | record.setCreatetime(resultObj.getCreatetime());
|
| | | record.setUpdatetime(new Date());
|
| | | goodsSubClassMapper.updateByPrimaryKey(record);
|
| | |
|
| | | if (labelMap != null) {
|
| | | labelMap.setCreateTime(new Date());
|
| | | labelMap.setGoodsSubClass(record);
|
| | | goodsSubClassLabelService.addSubClassLabelMap(labelMap);
|
| | | }
|
| | | }
|
| | |
|
| | | // 保存淘宝商品分类id
|
| | |
| | | update.setUnReadCount(0);
|
| | | update.setUpdateTime(new Date());
|
| | | msgDeviceReadStateMapper.updateByPrimaryKeySelective(update);
|
| | | } else {
|
| | | state = new MsgDeviceReadState();
|
| | | state.setCreateTime(new Date());
|
| | | state.setDevice(device);
|
| | | state.setPlatform(platform);
|
| | | state.setReadTime(new Date());
|
| | | state.setType(type);
|
| | | state.setUnReadCount(0);
|
| | | msgDeviceReadStateMapper.insertSelective(state);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | package com.yeshi.fanli.service.impl.taobao.dataoke;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | |
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.dataoke.DaTaoKeApiUtil;
|
| | | import com.yeshi.fanli.util.taobao.DaTaoKeUtil;
|
| | |
| | |
|
| | | @Override
|
| | | public void startSyncGoods() {
|
| | | |
| | | // 判断是否有正在进行的更新
|
| | | String key1 = "dataoke-updating";
|
| | | // if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(key1)))
|
| | |
| | | List<DaTaoKeDetail> daTaoKeList = daTaoKeDetailMapper.listByGoodsIds(goodsIdList);
|
| | | if (daTaoKeList == null || daTaoKeList.size() == 0)
|
| | | return goods;
|
| | |
|
| | | // 重新设置标题与券价格
|
| | | goods = DaTaoKeUtil.filterTaoBaoGoods(goods, daTaoKeList.get(0));
|
| | |
|
| | | return goods;
|
| | | }
|
| | |
|
| | |
| | | public List<DaTaoKeDetail> listByIds(List<Long> idList) {
|
| | | return daTaoKeDetailMapper.listByIds(idList);
|
| | | }
|
| | |
|
| | | |
| | | |
| | | @Override
|
| | | public List<DaTaoKeDetail> listByDtitle(String dtitle) {
|
| | |
|
| | | return daTaoKeDetailMapper.listByDtitle(dtitle.trim());
|
| | | }
|
| | |
|
| | |
| | | return daTaoKeDetailMapper.countSearchByTitleWithCid(title, (cid == null || cid == 0 ? null : cid));
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public List<DaTaoKeDetail> getGoodsNotInList(Long cid, List<Long> listId,int count) {
|
| | | return daTaoKeDetailMapper.getGoodsNotInList(cid, listId,count);
|
| | | }
|
| | | |
| | | }
|
| | |
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.dataoke.DaTaoKeDetailMapper;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsService;
|
| | |
| | | @Service
|
| | | public class DaTaoKeGoodsServiceImpl implements DaTaoKeGoodsService {
|
| | |
|
| | | @Resource
|
| | | private DaTaoKeDetailMapper daTaoKeDetailMapper;
|
| | | |
| | | @Resource
|
| | | private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
|
| | |
|
| | |
| | | } else
|
| | | return list;
|
| | | }
|
| | | |
| | | @Override
|
| | | public List<DaTaoKeDetail> getGoodsNotInList(Long cid, List<Long> listId,int count) {
|
| | | return daTaoKeDetailMapper.getGoodsNotInList(cid, listId,count);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | @Override
|
| | | public int countUserSpreadImg(Long uid) {
|
| | |
|
| | | return (int) (spreadUserImgMapper.imgUrlCount(uid));
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public String getInviteImg(Long uid, String bgImg, String inviteCode) throws Exception {
|
| | | UserInfo user = userInfoDao.find(UserInfo.class, uid);
|
| | | return qrCodeService.drawInviteQrCode(bgImg, uid, user.getPortrait(), inviteCode);
|
| | | }
|
| | | }
|
| | |
| | | String fileLink= COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | |
|
| | | userInfo.setPortrait(fileLink);
|
| | | userInfoMapper.updateByPrimaryKey(userInfo);
|
| | | userInfoMapper.updateByPrimaryKeySelective(userInfo);
|
| | | }
|
| | |
|
| | |
|
| | |
| | | throw new UserInfoException(1, "用户不存在");
|
| | | }
|
| | |
|
| | | UserInfo updateInfo = new UserInfo();
|
| | | updateInfo.setId(userInfo.getId());
|
| | | updateInfo.setNickName(nickName);
|
| | | userInfoMapper.updateByPrimaryKeySelective(updateInfo);
|
| | | userInfo.setNickName(nickName);
|
| | | userInfoMapper.updateByPrimaryKeySelective(userInfo);
|
| | | }
|
| | | }
|
| | |
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.share.UserShareGoodsRecordMapper;
|
| | | import com.yeshi.fanli.dto.share.ShareInfoDTO;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum;
|
| | |
| | | singleGoodsShare(userShareGoodsRecord, goodsBrief);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public Long saveSingleShareRecord(Long uid, Long auctionId) throws UserShareGoodsRecordException {
|
| | |
|
| | | if (auctionId == null) {
|
| | | throw new UserShareGoodsRecordException(1, "分享商品不能为空");
|
| | | }
|
| | |
|
| | | if (uid == null) {
|
| | | throw new UserShareGoodsRecordException(1, "用户ID不能为空");
|
| | | }
|
| | |
|
| | | TaoBaoGoodsBrief goodsBrief = null;
|
| | | try {
|
| | | goodsBrief = redisManager.getTaoBaoGoodsBrief(auctionId);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | throw new UserShareGoodsRecordException(1, "商品已下架");
|
| | | }
|
| | |
|
| | | UserShareGoodsRecord userShareGoodsRecord = new UserShareGoodsRecord();
|
| | | userShareGoodsRecord.setUid(uid);
|
| | | userShareGoodsRecord.setSource(ShareSourceTypeEnum.goodsDetail);
|
| | | userShareGoodsRecord.setShareState(0);
|
| | | // 单个商品分享
|
| | | singleGoodsShare(userShareGoodsRecord, goodsBrief);
|
| | | |
| | | return userShareGoodsRecord.getId();
|
| | | }
|
| | | |
| | | @Override
|
| | | public void save(Long uid, ShareSourceTypeEnum source, String title, TaoBaoGoodsBrief taoBaoGoodsBrief)
|
| | | throws UserShareGoodsRecordException {
|
| | |
| | |
|
| | | return map;
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 保存分享记录
|
| | | * |
| | | * @param userShareGoodsRecord
|
| | | * 分享记录: uid、picture、source 为必输入
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | @Override
|
| | | public ShareInfoDTO saveShareRecord(Long uid, ShareSourceTypeEnum source, String title,
|
| | | List<TaoBaoGoodsBrief> listGoods) throws UserShareGoodsRecordException {
|
| | |
|
| | | if (listGoods == null || listGoods.size() == 0) {
|
| | | throw new UserShareGoodsRecordException(1, "分享商品数量不足");
|
| | | }
|
| | |
|
| | | if (uid == null) {
|
| | | throw new UserShareGoodsRecordException(1, "用户ID不能为空");
|
| | | }
|
| | |
|
| | | if (source == null) {
|
| | | throw new UserShareGoodsRecordException(1, "分享来源不能为空");
|
| | | }
|
| | |
|
| | | UserShareGoodsRecord userShareGoodsRecord = new UserShareGoodsRecord();
|
| | | userShareGoodsRecord.setUid(uid);
|
| | | userShareGoodsRecord.setSource(source);
|
| | | userShareGoodsRecord.setTitle(title);
|
| | | // 取一个商品图片作为主图
|
| | | userShareGoodsRecord.setPicture(listGoods.get(0).getPictUrl());
|
| | |
|
| | | Date date = new Date();
|
| | | userShareGoodsRecord.setShareState(0); // 初始未分享
|
| | | userShareGoodsRecord.setCreateTime(date);
|
| | | userShareGoodsRecord.setUpdateTime(date);
|
| | | userShareGoodsRecordMapper.insertSelective(userShareGoodsRecord);
|
| | |
|
| | | Map<String, Object> map = new HashMap<String, Object>();
|
| | | // 多个商品分享
|
| | | FileUploadResult loadResult = multipleGoodsShare(userShareGoodsRecord, listGoods);
|
| | | |
| | | ShareInfoDTO shareInfo = new ShareInfoDTO();
|
| | | shareInfo.setMd5(loadResult.getMd5());
|
| | | shareInfo.setCodeUrl(loadResult.getUrl());
|
| | | shareInfo.setShareId(userShareGoodsRecord.getId());
|
| | | shareInfo.setShareUrl(getShareUrl(userShareGoodsRecord));
|
| | | |
| | | return shareInfo;
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 单个商品分享生成记录
|
| | |
| | | return shareImg;
|
| | | }
|
| | |
|
| | | public String getShareUrl (UserShareGoodsRecord shareRecord) {
|
| | | Long uid = shareRecord.getUid();
|
| | | Long shareId = shareRecord.getId();
|
| | | String source = shareRecord.getSource().name();
|
| | |
|
| | | String url = String.format("http://%s/share_mushGoods.html?uid=%s&shareId=%s&source=%s",
|
| | | configService.getH5Host(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), shareId + "",
|
| | | source + "");
|
| | |
|
| | | String shortLink = HttpUtil.getShortLink(url);
|
| | | if (!StringUtil.isNullOrEmpty(shortLink)) {
|
| | | url = shortLink;
|
| | | }
|
| | | return url;
|
| | | }
|
| | | |
| | | /**
|
| | | * 生成分享图
|
| | | *
|
| | |
| | | * @param goods
|
| | | */
|
| | | public void updateRecommendActivityGoods(TaoBaoGoodsBrief goods);
|
| | | |
| | | /**
|
| | | * 查询需发布的动态
|
| | | * @return
|
| | | */
|
| | | public List<RecommendActivity> getNeedPublish();
|
| | |
|
| | | /**
|
| | | * 动态图片
|
| | | * @param activityId
|
| | | * @return
|
| | | */
|
| | | public List<String> getImgByActivityId(Long activityId);
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.activity;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.activity.ActivityUser;
|
| | |
|
| | | /**
|
| | | * 动态服务
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public interface ActivityUserService {
|
| | | |
| | | |
| | | /**
|
| | | * 随机抽取
|
| | | * @param count
|
| | | * @return
|
| | | */
|
| | | public List<ActivityUser> listRand(int count);
|
| | |
|
| | | /**
|
| | | * |
| | | * @param id
|
| | | * @return
|
| | | */
|
| | | public ActivityUser selectByPrimaryKey(Long id);
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.dynamic;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.activity.ActivityUser;
|
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivity;
|
| | | import com.yeshi.fanli.entity.dynamic.DynamicInfo;
|
| | |
|
| | | public interface DynamicInfoService {
|
| | |
|
| | | /**
|
| | | * 定时插入热销单品
|
| | | */
|
| | | public void insertTimeHotSale();
|
| | | |
| | | /**
|
| | | * 定时插入推荐好货
|
| | | */
|
| | | public void insertTimeRecommend();
|
| | | |
| | | |
| | | /**
|
| | | * 查询
|
| | | * @param start
|
| | | * @param count
|
| | | * @param cid
|
| | | * @param subId
|
| | | * @param limitTime
|
| | | */
|
| | | public List<DynamicInfo> query(int start, int count, Long cid, Long subId);
|
| | |
|
| | | /**
|
| | | * |
| | | * @param id
|
| | | * @return
|
| | | */
|
| | | public DynamicInfo getById(String id);
|
| | |
|
| | | /**
|
| | | * 更新分享次数
|
| | | * @param record
|
| | | */
|
| | | public void updateShareCount(DynamicInfo record);
|
| | |
|
| | | /**
|
| | | * 插入邀请素材
|
| | | * @param content
|
| | | * @param picUrl
|
| | | */
|
| | | public void insertInviteMaterial(String content, String picUrl, Long activityId, ActivityUser activityUser);
|
| | |
|
| | | void insert(DynamicInfo record);
|
| | |
|
| | | public long count(Long cid, Long subId);
|
| | |
|
| | | /**
|
| | | * 插入店铺信息
|
| | | * @return
|
| | | */
|
| | | public void insertShopInfo();
|
| | |
|
| | | /**
|
| | | * 根据时间删除
|
| | | * @param createTime
|
| | | */
|
| | | public void removeByDate(Date createTime);
|
| | |
|
| | | /**
|
| | | * 动态商品
|
| | | * @param activity
|
| | | */
|
| | | public void saveActivityRecommend(RecommendActivity activity);
|
| | |
|
| | | /**
|
| | | * 删除动态信息
|
| | | * @param activityId
|
| | | */
|
| | | public void deleteActivity(Long activityId);
|
| | |
|
| | | }
|
| | |
| | |
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsSubClass;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsSubClassLabelMap;
|
| | | import com.yeshi.fanli.exception.GoodsSubClassException;
|
| | |
|
| | |
|
| | |
| | | * @throws GoodsSubClassException
|
| | | * @throws Exception
|
| | | */
|
| | | public void saveObject(MultipartFile file,MultipartFile file2, GoodsSubClass record, Integer type, Long pid,GoodsSubClassLabelMap labelMap)
|
| | | public void saveObject(MultipartFile file,MultipartFile file2, GoodsSubClass record, Integer type, Long pid)
|
| | | throws GoodsSubClassException, Exception;
|
| | |
|
| | | }
|
| | |
| | | */
|
| | | public List<DaTaoKeDetail> listByIds(List<Long> idList);
|
| | |
|
| | | |
| | | /**
|
| | | * 根据标题查询
|
| | | * |
| | | * 查询一类全部
|
| | | * @param cid
|
| | | * @param listId
|
| | | * @param count
|
| | | * @return
|
| | | */
|
| | | public List<DaTaoKeDetail> getGoodsNotInList(Long cid, List<Long> listId, int count);
|
| | | |
| | | /* 根据标题查询
|
| | | * @param dtitle
|
| | | * @return
|
| | | */
|
| | |
| | | */
|
| | | public List<DaTaoKeDetail> getCurrentHotSalesRankGoodsList();
|
| | |
|
| | | |
| | | |
| | | public List<DaTaoKeDetail> getGoodsNotInList(Long cid, List<Long> listId, int count);
|
| | |
|
| | | }
|
| | |
| | | */
|
| | | String getUserSpreadImg(Long uid, String bgImg, int erCodePostionX, int erCodePostionY, int erCodeSize);
|
| | |
|
| | | |
| | | String getInviteImg(Long uid, String bgImg, String inviteCode) throws Exception;
|
| | |
|
| | | }
|
| | |
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import com.yeshi.fanli.dto.share.ShareInfoDTO;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | |
| | | */
|
| | | public long countShareRecordByUid(Long uid);
|
| | |
|
| | | /**
|
| | | * 多商品分享
|
| | | * @param uid
|
| | | * @param source
|
| | | * @param title
|
| | | * @param listGoods
|
| | | * @return
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | public ShareInfoDTO saveShareRecord(Long uid, ShareSourceTypeEnum source, String title, List<TaoBaoGoodsBrief> listGoods)
|
| | | throws UserShareGoodsRecordException;
|
| | |
|
| | | |
| | | /**
|
| | | * 保存单个商品分享记录
|
| | | * @param uid
|
| | | * @param auctionId
|
| | | * @param type
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | public Long saveSingleShareRecord(Long uid, Long auctionId) throws UserShareGoodsRecordException;
|
| | | }
|
| | |
| | | public class Constant {
|
| | | public static boolean IS_TASK = false;
|
| | | // 外网环境
|
| | | public static boolean IS_OUTNET = true;
|
| | | public static boolean IS_OUTNET = false;
|
| | |
|
| | | public static boolean IS_TEST = false;
|
| | | public static boolean IS_TEST = true;
|
| | |
|
| | | public static int PAGE_SIZE = 20;
|
| | | public static int[] TASK_TYPE = { 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008// 微信任务类型编号
|
| | |
| | |
|
| | | // 新人抽奖-最大次数
|
| | | public static final int MAX_COUNT_LOTTERY_NEWBIES = 5;
|
| | | |
| | | |
| | |
|
| | | static {
|
| | |
|
| | | if (smsConfig == null) {
|
| | |
| | | */
|
| | | public Class<?> getObj(Class<?> clazz, String key) {
|
| | | String value = getCommonString(key);
|
| | | return new Gson().fromJson(value, clazz);
|
| | | return (Class<?>) new Gson().fromJson(value, clazz);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | package com.yeshi.fanli.util.dataoke;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import org.jsoup.Jsoup;
|
| | | import org.jsoup.nodes.Document;
|
| | | import org.jsoup.select.Elements;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dto.dataoke.DaTaoKeApiResult;
|
| | | import com.yeshi.fanli.dto.taobao.TaoBaoShopDTO;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
| | | System.out.println(resultJson);
|
| | | JSONArray array = resultJson.optJSONArray("result");
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | DaTaoKeDetail detail = gson.fromJson(array.optJSONObject(i).toString(), DaTaoKeDetail.class);
|
| | | if (detail != null && !detail.getPic().startsWith("http"))
|
| | | detail.setPic("https:" + detail.getPic());
|
| | | list.add(detail);
|
| | | list.add(gson.fromJson(array.optJSONObject(i).toString(), DaTaoKeDetail.class));
|
| | | }
|
| | | return new DaTaoKeApiResult(resultJson.optJSONObject("data").optInt("total_num"),
|
| | | resultJson.optJSONObject("data").optString("update_time"), list);
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 获取大淘客品牌优选 品牌id
|
| | | * @return
|
| | | */
|
| | | public static List<String> getBrandIdList() {
|
| | | List<String> listId = null;
|
| | | try {
|
| | | Document doc = Jsoup.connect("http://www.dataoke.com/brandFeature").get();
|
| | | Elements els = doc.getElementsByTag("script");
|
| | | for (int i = 0; i < els.size(); i++) {
|
| | | if (els.get(i).html().contains("var brandData")) {
|
| | |
|
| | | JSONObject data = JSONObject
|
| | | .fromObject(els.get(i).html().replace("var brandData =", "").trim().split("};")[0] + "}");
|
| | | listId = convertList(data);
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return listId;
|
| | | }
|
| | |
|
| | | |
| | | public static List<String> convertList(JSONObject data) {
|
| | | List<String> listId = new ArrayList<String>();
|
| | |
|
| | | // 萌趣新生力 夏日好食光栏目
|
| | | JSONArray arrayActs = data.optJSONObject("acts").optJSONArray("list");
|
| | | for (int i = 0; i < arrayActs.size(); i++) {
|
| | | JSONObject item = arrayActs.optJSONObject(i);
|
| | | listId.add(item.optString("brand_id"));
|
| | | }
|
| | |
|
| | | // 热推爆款
|
| | | JSONArray arrayPushs = data.optJSONObject("pushs").optJSONArray("list");
|
| | | for (int i = 0; i < arrayPushs.size(); i++) {
|
| | | JSONObject item = arrayPushs.optJSONObject(i);
|
| | | listId.add(item.optString("brand_id"));
|
| | | }
|
| | |
|
| | | // 热销品牌榜
|
| | | JSONArray arrayRanks = data.optJSONObject("ranks").optJSONArray("list");
|
| | | for (int i = 0; i < arrayRanks.size(); i++) {
|
| | | JSONObject item = arrayRanks.optJSONObject(i);
|
| | | // long id = item.optLong("id");
|
| | | // String title =item.optString("title");
|
| | | JSONArray goods = item.optJSONArray("goods");
|
| | | for (int j = 0; j < goods.size(); j++) {
|
| | | JSONObject good = goods.optJSONObject(j);
|
| | | listId.add(good.optString("brand_id"));
|
| | | }
|
| | | }
|
| | | return listId;
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 获取店铺下前4个商品、店铺介绍
|
| | | * @param brandId
|
| | | * @return
|
| | | */
|
| | | public static TaoBaoShopDTO getDynamicShopInfo(String brandId) {
|
| | | if (brandId == null) {
|
| | | return null;
|
| | | }
|
| | | TaoBaoShopDTO taoBaoShopDTO = null;
|
| | |
|
| | | Document doc;
|
| | | try {
|
| | | doc = Jsoup.connect("http://www.dataoke.com/brandSingle?id=" + brandId).get();
|
| | | Elements els = doc.getElementsByTag("script");
|
| | | for (int i = 0; i < els.size(); i++) {
|
| | | if (els.get(i).html().contains("var brandData")) {
|
| | |
|
| | | JSONObject data = JSONObject
|
| | | .fromObject(els.get(i).html().replace("var brandData =", "").trim().split("};")[0] + "}");
|
| | | taoBaoShopDTO = convertTaoBaoShopDTO(data);
|
| | | break;
|
| | | }
|
| | | }
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return taoBaoShopDTO;
|
| | |
|
| | | }
|
| | |
|
| | | public static TaoBaoShopDTO convertTaoBaoShopDTO(JSONObject data) {
|
| | | TaoBaoShopDTO taoBaoShopDTO = new TaoBaoShopDTO();
|
| | | JSONObject item = data.optJSONObject("act");
|
| | | taoBaoShopDTO.setSellerId(item.optLong("seller_id"));
|
| | | taoBaoShopDTO.setBrandId(item.optString("brand_id"));
|
| | | taoBaoShopDTO.setBrandDes(item.optString("brand_des"));
|
| | | int userType = 0;
|
| | |
|
| | | List<TaoBaoGoodsBrief> listGoods = new ArrayList<TaoBaoGoodsBrief>();
|
| | | JSONArray arrayGoods = data.optJSONArray("goods");
|
| | | for (int i = 0; i < arrayGoods.size(); i++) {
|
| | | if (i > 3) {
|
| | | break;
|
| | | }
|
| | | JSONObject itemGoods = arrayGoods.optJSONObject(i);
|
| | | TaoBaoGoodsBrief taoBaoGoods = new TaoBaoGoodsBrief();
|
| | | taoBaoGoods.setAuctionId(itemGoods.optLong("goodsid"));
|
| | | taoBaoGoods.setBiz30day(itemGoods.optInt("xiaoliang"));
|
| | | taoBaoGoods.setCouponAmount(new BigDecimal(itemGoods.optString("quan_jine")));
|
| | | taoBaoGoods.setCouponInfo(String.format("满%s元减%s元", itemGoods.optString("quan_tiaojian"),
|
| | | MoneyBigDecimalUtil.getWithNoZera(new BigDecimal(itemGoods.optString("quan_jine")))));
|
| | | taoBaoGoods.setCouponLeftCount(itemGoods.optInt("quan_num"));
|
| | | taoBaoGoods.setCouponStartFee(new BigDecimal(itemGoods.optString("quan_tiaojian")));
|
| | | taoBaoGoods.setCouponTotalCount(itemGoods.optInt("quan_num"));
|
| | | taoBaoGoods.setPictUrl(itemGoods.optString("pic"));
|
| | | taoBaoGoods.setPictUrlWhite(itemGoods.optString("pic"));
|
| | | taoBaoGoods.setSellerId(itemGoods.optLong("seller_id"));
|
| | | taoBaoGoods.setShopTitle("");
|
| | | taoBaoGoods.setTitle(itemGoods.optString("title"));
|
| | | taoBaoGoods.setUserType(itemGoods.optInt("istmall"));
|
| | | taoBaoGoods.setZkPrice(new BigDecimal(itemGoods.optString("yuanjia")));
|
| | | taoBaoGoods.setTkRate(new BigDecimal(itemGoods.optString("yongjin")));
|
| | | taoBaoGoods.setTkCommFee(new BigDecimal("0"));
|
| | | taoBaoGoods.setState(0);
|
| | | |
| | | listGoods.add(taoBaoGoods);
|
| | | |
| | | userType = itemGoods.optInt("istmall");
|
| | | }
|
| | | taoBaoShopDTO.setListGoods(listGoods);
|
| | | taoBaoShopDTO.setUserType(userType);
|
| | | return taoBaoShopDTO;
|
| | | }
|
| | | |
| | | class DaTaoKeResult {
|
| | | Date updateTime;
|
| | | List<DaTaoKeDetail> dataList;
|
| | |
| | | desc += detail.getIntroduce();
|
| | | return desc;
|
| | | }
|
| | |
|
| | |
|
| | | public static TaoBaoGoodsBrief filterTaoBaoGoods(TaoBaoGoodsBrief goods, DaTaoKeDetail detail) {
|
| | | if (detail != null) {
|
| | |
| | | }
|
| | | return goods;
|
| | | }
|
| | |
|
| | | |
| | | }
|
| | |
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | |
| | | public static void taoKeContent() {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.content.get");
|
| | | map.put("adzone_id",TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT.split("_")[3]);
|
| | | map.put("type", "1");
|
| | | |
| | | // map.put("method", "taobao.tbk.content.get");
|
| | | TaoKeAppInfo app = new TaoKeAppInfo();
|
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
|
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | app.setAppKey("24838852");
|
| | | app.setAppSecret("bc8265e2bf8d8115329d652f9d3d4cd8");
|
| | | try {
|
| | | JSONObject json = TaoKeBaseUtil.baseRequest(map,app);
|
| | | System.out.println(json);
|
| | | } catch (TaoKeApiException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | // AA5ISJ
|
New file |
| | |
| | | package com.yeshi.fanli.vo.dynamic;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.google.gson.annotations.Expose;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
|
| | |
|
| | | public class DynamicClassVO {
|
| | | @Expose
|
| | | private Long id;
|
| | | @Expose
|
| | | private String name;
|
| | | @Expose
|
| | | private List<GoodsClass> listSub;
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public String getName() {
|
| | | return name;
|
| | | }
|
| | |
|
| | | public void setName(String name) {
|
| | | this.name = name;
|
| | | }
|
| | |
|
| | | public List<GoodsClass> getListSub() {
|
| | | return listSub;
|
| | | }
|
| | |
|
| | | public void setListSub(List<GoodsClass> listSub) {
|
| | | this.listSub = listSub;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | druid.driverClassName=com.mysql.jdbc.Driver
|
| | | #本地测试
|
| | | #druid.url=jdbc:mysql://192.168.1.253:3306/ec_quan
|
| | | #druid.username=root
|
| | | #druid.password=123456
|
| | | druid.url=jdbc:mysql://192.168.1.253:3306/ec_quan
|
| | | druid.username=root
|
| | | druid.password=123456
|
| | | |
| | |
|
| | |
|
| | |
| | |
|
| | |
|
| | | #外网正式
|
| | | druid.url=jdbc:mysql://172.16.16.17:3306/ec_quan
|
| | | druid.username=root
|
| | | druid.password=Yeshi2016@
|
| | | #druid.url=jdbc:mysql://172.16.16.17:3306/ec_quan
|
| | | #druid.username=root
|
| | | #druid.password=Yeshi2016@
|
| | |
|
| | | #外网本地测试
|
| | | #druid.url=jdbc:mysql://gz-cdb-r13d0yi9.sql.tencentcdb.com:62929/ec_quan
|
| | |
| | | log4j.appender.smsLog.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} [%c]-[%p] %m%n
|
| | |
|
| | |
|
| | | log4j.logger.requestLog=info,requestLog
|
| | | log4j.appender.requestLog=org.apache.log4j.DailyRollingFileAppender
|
| | | log4j.appender.requestLog.File=logs/request/requestLog.log
|
| | | log4j.appender.requestLog.MaxFileSize=20MB
|
| | | log4j.appender.requestLog.MaxBackupIndex=100
|
| | | log4j.appender.requestLog.layout=org.apache.log4j.PatternLayout
|
| | | log4j.appender.requestLog.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} [%c]-[%p] %m%n
|
| | |
|
| | |
|
| | |
|
| | | log4j.logger.loginLog=info,loginLog
|
| | |
| | | redis.addr=172.16.16.15
|
| | | #redis.addr=192.168.1.253
|
| | | #redis.addr=172.16.16.15
|
| | | redis.addr=192.168.1.253
|
| | | redis.port=6379
|
| | | redis.auth=crs-43yhgz0i:Yeshi2016@
|
| | | #redis.auth=123456
|
| | | #redis.auth=crs-43yhgz0i:Yeshi2016@
|
| | | redis.auth=123456
|
| | | redis.max_active=1024
|
| | | redis.max_idle=200
|
| | | redis.max_wait=10000
|
| | |
| | | sms_appid=1400092621
|
| | | sms_appkey=a710f8995ceb7d1c7dacfaff730531e2
|
| | | sms_sign=返利券APP
|
| | |
|
| | | #阿里云短信配置
|
| | | sms_aliyun_accesskey_id=LTAIqpGdSJwB1l7i
|
| | | sms_aliyun_accesskey_secret=ZYoT7zSaUVOA2pT2Fv5EpymBjePirN
|
| | | sms_aliyun_login_template_code=SMS_163625190 |
| | |
| | |
|
| | |
|
| | | #识别二维码跳转详情页面路径
|
| | | share_goods_page_path=/xiangQing.html
|
| | | share_goods_page_path=/single/xiangQing.html
|
| | |
|
| | | #app内分享详情页面路径
|
| | | app_shareinfo_url=http://flq.yeshitv.com/fanli/client/html/sharegoods/index.html
|
| | |
| | | package org.fanli;
|
| | |
|
| | | import org.junit.Ignore;
|
| | | import org.junit.Test;
|
| | | import org.yeshi.utils.mybatis.ColumnParseUtil;
|
| | | import org.yeshi.utils.mybatis.MyBatisMapperUtil;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.LostOrder;
|
| | | import com.yeshi.fanli.entity.bus.user.UserAccountBindingHistory;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsSubClass;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsSubClassLabel;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsSubClassLabelMap;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgDeviceReadState;
|
| | |
|
| | | //@Ignore
|
| | | public class MyBatisProduce {
|
| | |
|
| | | @Test
|
| | | public void test3() {
|
| | | MyBatisMapperUtil.createMapper(UserAccountBindingHistory.class);
|
| | | // MyBatisMapperUtil.createMapper(TaoBaoUnionAuthRecord.class);
|
| | | MyBatisMapperUtil.createMapper(GoodsSubClassLabel.class);
|
| | | MyBatisMapperUtil.createMapper(GoodsSubClassLabelMap.class);
|
| | | // MyBatisMapperUtil.createMapper(UserMoneyDebtReturnHistory.class);
|
| | | }
|
| | |
|
| | | @Test
|
| | | public void test1() {
|
| | | ColumnParseUtil.parseColumn(LostOrder.class,
|
| | | "D:/workspace/fanli/fanli-server/fanli/src/main/java/com/yeshi/fanli/mapping/order/LostOrderMapper.xml");
|
| | | ColumnParseUtil.parseColumn(GoodsSubClass.class,
|
| | | "D:/workspace/fanli/fanli-server/fanli/src/main/java/com/yeshi/fanli/mapping/GoodsSubClassMapper.xml");
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import java.io.FileInputStream;
|
| | | import java.io.FileNotFoundException;
|
| | | import java.util.ArrayList;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.UUID;
|
| | |
|
| | | import org.junit.Ignore;
|
| | | import org.junit.Test;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TBPidMapper;
|
| | | import com.yeshi.fanli.entity.taobao.SearchFilter;
|
| | | import com.yeshi.fanli.entity.taobao.TBPid;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.exception.taobao.TaoKeApiException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsUpdateException;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService;
|
| | | import com.yeshi.fanli.util.BeanUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | @Ignore
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | //@Ignore
|
| | | public class TaoKeTest {
|
| | |
|
| | | public static int count = 0;
|
| | |
| | |
|
| | | @Test
|
| | | public void test3() {
|
| | | TaoBaoGoodsUpdateService taoBaoGoodsUpdateService = BeanUtil.getBean(TaoBaoGoodsUpdateService.class);
|
| | | try {
|
| | | taoBaoGoodsUpdateService.updateTaoBaoGoods(TaoKeApiUtil.searchGoodsDetail(571566226590L));
|
| | | } catch (TaobaoGoodsUpdateException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | for (int i = 0; i < 10; i++) {
|
| | | String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
| | | System.out.println(uuid);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | static String cookie = "cna=Q9eYFEM1rm8CAXH7EKUDSamu; account-path-guide-s1=true; 124933865_yxjh-filter-1=true; undefined_yxjh-filter-1=true; t=9dd8d10a742dccaf3c42af830249fe39; pub-message-center=1; cookie2=102d56e20037f8d9d1edff803285bb30; v=0; _tb_token_=58995010ab130; alimamapwag=TW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzczLjAuMzY4My4xMDMgU2FmYXJpLzUzNy4zNg%3D%3D; cookie32=b9eeefb51faae3c2f2d5a08032516932; alimamapw=F3AHRnRyE3slFHALR3V%2BEHIDF3Z2RndyPwhRVQAOAwAPBVMABQ0HAFMBVQtTAgdaUwAJUwUEVlFX%0A; cookie31=MTI0OTMzODY1LCVFNiVBNCVCMCVFOCVBNyU4NiVFNyVBNyU5MSVFNiU4QSU4MCw0MTI2NjE4NjlAcXEuY29tLFRC; login=VFC%2FuZ9ayeYq2g%3D%3D; rurl=aHR0cHM6Ly9wdWIuYWxpbWFtYS5jb20v; apushcbb2dd0258025fce735efc665422e16d=%7B%22ts%22%3A1556431673690%2C%22heir%22%3A1556431667417%2C%22parentId%22%3A1556431661238%7D; l=bBT2uo87vPM0bgSWBOfNquI8Lx7OPIRb8sPzw4OG5ICP_m1JWkBPWZO5aaYvC3GNa6FDR3y1Nww8BuLKsy4Eh; isg=BNLSh7GG2qh7bSaDwEb8EBBFI5h0S9cHLDtQ4pwrXwV9r3CphHO9jLWJH0M2304V";
|
| | |
|
| | | private List<String> getPids() {
|
| | |
|
| | | List<String> pids = new ArrayList<>();
|
| | |
|
| | | String url = "https://pub.alimama.com/common/adzone/adzoneManage.json";
|
| | | Map<String, String> headers = new HashMap<>();
|
| | | headers.put("cookie", cookie);
|
| | | headers.put("user-agent",
|
| | | "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36");
|
| | | headers.put("referer", "https://pub.alimama.com/myunion.htm");
|
| | | Map<String, String> params = new HashMap<>();
|
| | | params.put("tab", 3 + "");//3
|
| | | params.put("toPage", "10");
|
| | | params.put("perPageSize", "500");
|
| | | params.put("_input_charset", "utf-8");
|
| | | params.put("gcid", "8");//8
|
| | | params.put("t", System.currentTimeMillis() + "");
|
| | | params.put("_tb_token_", "78e513aee5563");
|
| | |
|
| | | String result = HttpUtil.get(url, params, headers);
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | | JSONArray array = resultJson.optJSONObject("data").optJSONArray("pagelist");
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | JSONObject item = array.optJSONObject(i);
|
| | | String pid = item.optString("adzonePid");
|
| | | if ((item.optString("name").startsWith("quanqudao_") || item.optString("name").startsWith("tuiguang_"))
|
| | | && item.optInt("mixClick30day")<3000) {
|
| | | pids.add(pid);
|
| | | }
|
| | | }
|
| | |
|
| | | return pids;
|
| | | }
|
| | |
|
| | | @Test
|
| | | public void test5() {
|
| | | String[] pids = new String[] { "mm_124933865_43788020_437192946", "mm_124933865_35320824_165774413",
|
| | | "mm_124933865_43788020_381938426", "mm_124933865_46852994_1828270335",
|
| | | "mm_124933865_56750082_10647300249", "mm_124933865_56750082_87140050199",
|
| | | "mm_124933865_56750082_89555600043" };
|
| | | TBPidMapper tbPidMapper = BeanUtil.getBean(TBPidMapper.class);
|
| | | for (int i = 200; i < 230; i++) {
|
| | | List<TBPid> list = tbPidMapper.listByTypeAndUse(true, 500 * i, 500);
|
| | | String adzones = "";
|
| | | for (TBPid tbPid : list) {
|
| | | boolean needAdd = true;
|
| | | for (String p : pids)
|
| | | if (p.equalsIgnoreCase(tbPid.getPid())) {
|
| | | needAdd = false;
|
| | | break;
|
| | | }
|
| | | if (needAdd)
|
| | | adzones += tbPid.getPid().split("_")[3] + ",";
|
| | | }
|
| | | adzones = adzones.substring(0, adzones.length() - 1);
|
| | | }
|
| | | }
|
| | |
|
| | | @Test
|
| | | public void test6() {
|
| | | TaoKeApiUtil.taoKeContent();
|
| | | }
|
| | |
|
| | | private void deleteAdzones(String adzones) {
|
| | | String url = "https://pub.alimama.com/common/adzone/adzoneDelete.json";
|
| | | Map<String, String> headers = new HashMap<>();
|
| | | headers.put("cookie", cookie);
|
| | | headers.put("user-agent",
|
| | | "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36");
|
| | | headers.put("referer", "https://pub.alimama.com/myunion.htm");
|
| | | Map<String, String> params = new HashMap<>();
|
| | | params.put("adzoneids", adzones);
|
| | | params.put("gcid", "8");
|
| | | params.put("t", System.currentTimeMillis() + "");
|
| | | params.put("_tb_token_", "58995010ab130");
|
| | | // System.out.println("位置:" + i);
|
| | | String result = (HttpUtil.post(url, params, headers));
|
| | | if (result != null && JSONObject.fromObject(result).optBoolean("ok") == true) {
|
| | | System.out.println(result);
|
| | | } else {
|
| | | System.out.println("error---");
|
| | | // break;
|
| | |
|
| | | }
|
| | | try {
|
| | | TaoBaoGoodsBrief goods= TaoKeApiUtil.getSimpleGoodsInfo(566534626407L);
|
| | | System.out.println(goods);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | Thread.sleep(1000 * 3 + (int) (Math.random() * 3000));
|
| | | } catch (InterruptedException e) {
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | </dependency> |
| | | |
| | | |
| | | <!-- 图片压缩工具 --> |
| | | <dependency> |
| | | <groupId>net.coobird</groupId> |
| | | <artifactId>thumbnailator</artifactId> |
| | | <version>0.4.8</version> |
| | | </dependency> |
| | | |
| | | |
| | | </dependencies> |
| | | |
| | | <build> |
| | |
| | |
|
| | | return datatime;
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 通过时间秒毫秒数判断两个时间的间隔
|
| | | * @param date1
|
| | | * @param date2
|
| | | * @return
|
| | | */
|
| | | public static int differentDaysByMillisecond(Date start, Date end) {
|
| | | return (int) ((end.getTime() - start.getTime()) / (1000*3600*24));
|
| | | }
|
| | | |
| | | * |
| | | * @param date1
|
| | | * @param date2
|
| | | * @return
|
| | | */
|
| | | public static int differentDaysByMillisecond(Date start, Date end) {
|
| | | return (int) ((end.getTime() - start.getTime()) / (1000 * 3600 * 24));
|
| | | }
|
| | |
|
| | | public String transferLongToDate(String dateFormat, Long millSec) {
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
| | | Date date = new Date(millSec);
|
| | |
| | | return false;
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 指定日期加上天数后的日期
|
| | | *
|
| | | * @param num
|
| | | * 增加的天数
|
| | | * @param nowDate
|
| | | * 创建时间
|
| | | * @param num 增加的天数
|
| | | * @param nowDate 创建时间
|
| | | * @return
|
| | | * @throws ParseException
|
| | | */
|
| | | public static String plusDay(int num, String nowDate) throws ParseException {
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
| | | Date currdate = format.parse(nowDate);
|
| | | |
| | |
|
| | | Calendar ca = Calendar.getInstance();
|
| | | ca.setTime(currdate);
|
| | | ca.add(Calendar.DATE, num);
|
| | | |
| | |
|
| | | return format.format(ca.getTime());
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 指定日期加上天数后的日期
|
| | | *
|
| | | * @param num
|
| | | * 增加的天数
|
| | | * @param nowDate
|
| | | * 创建时间
|
| | | * @param num 增加的天数
|
| | | * @param nowDate 创建时间
|
| | | * @return
|
| | | * @throws ParseException
|
| | | */
|
| | | public static String plusDay(int num, Date currdate) throws ParseException {
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
| | | |
| | |
|
| | | Calendar ca = Calendar.getInstance();
|
| | | ca.setTime(currdate);
|
| | | ca.add(Calendar.DATE, num);
|
| | | |
| | |
|
| | | return format.format(ca.getTime());
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 指定日期减去天数后的日期
|
| | | *
|
| | | * @param num
|
| | | * 减去的天数
|
| | | * @param nowDate
|
| | | * 创建时间
|
| | | * @param num 减去的天数
|
| | | * @param nowDate 创建时间
|
| | | * @return
|
| | | * @throws ParseException
|
| | | */
|
| | | public static String reduceDay(int num, String nowDate) throws ParseException {
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
| | | Date currdate = format.parse(nowDate);
|
| | | |
| | |
|
| | | Calendar ca = Calendar.getInstance();
|
| | | ca.setTime(currdate);
|
| | | ca.add(Calendar.DATE, -num); // 日期减 如果不够减会将月变动
|
| | | |
| | |
|
| | | return format.format(ca.getTime());
|
| | | }
|
| | | |
| | | /**
|
| | | * 计算两个日期之间相差的天数 |
| | | * @param smdate 较小的时间 |
| | | * @param bdate 较大的时间 |
| | | * @return 相差天数 |
| | | * @throws ParseException |
| | | * calendar 对日期进行时间操作
|
| | | * getTimeInMillis() 获取日期的毫秒显示形式
|
| | | */
|
| | | public static int daysBetween(Date smdate,Date bdate) throws ParseException |
| | | { |
| | | Calendar cal = Calendar.getInstance();
|
| | | cal.setTime(smdate);
|
| | | long time1 = cal.getTimeInMillis();
|
| | | cal.setTime(bdate);
|
| | | long time2 = cal.getTimeInMillis(); |
| | | long between_days=(time2-time1)/(1000*3600*24); |
| | | return Integer.parseInt(String.valueOf(between_days)); |
| | | }
|
| | | |
| | | /**
|
| | | * 字符串日期格式的计算
|
| | | * @param smdate
|
| | | * @param bdate
|
| | | * @return
|
| | | * @throws ParseException
|
| | | */
|
| | | public static int daysBetween(String smdate,String bdate) throws ParseException{ |
| | | SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(sdf.parse(smdate)); |
| | | long time1 = cal.getTimeInMillis(); |
| | | cal.setTime(sdf.parse(bdate)); |
| | | long time2 = cal.getTimeInMillis(); |
| | | long between_days=(time2-time1)/(1000*3600*24); |
| | | return Integer.parseInt(String.valueOf(between_days)); |
| | | } |
| | | |
| | |
|
| | | /**
|
| | | * 指定日期减去天数后的日期
|
| | | * |
| | | * @param num 减去的天数
|
| | | * @param nowDate 创建时间
|
| | | * @return
|
| | | * @throws ParseException
|
| | | */
|
| | | public static Date reduceDay(int num, Date date) throws ParseException {
|
| | | // 设置要获取到什么样的时间
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
| | | // 获取String类型的时间
|
| | | String date_str = format.format(date);
|
| | | Date currdate = format.parse(date_str);
|
| | |
|
| | | Calendar ca = Calendar.getInstance();
|
| | | ca.setTime(currdate);
|
| | | ca.add(Calendar.DATE, -num); // 日期减 如果不够减会将月变动
|
| | |
|
| | | return ca.getTime();
|
| | | }
|
| | |
|
| | | /**
|
| | | * 计算两个日期之间相差的天数
|
| | | * |
| | | * @param smdate 较小的时间
|
| | | * @param bdate 较大的时间
|
| | | * @return 相差天数
|
| | | * @throws ParseException calendar 对日期进行时间操作 getTimeInMillis() 获取日期的毫秒显示形式
|
| | | */
|
| | | public static int daysBetween(Date smdate, Date bdate) throws ParseException {
|
| | | Calendar cal = Calendar.getInstance();
|
| | | cal.setTime(smdate);
|
| | | long time1 = cal.getTimeInMillis();
|
| | | cal.setTime(bdate);
|
| | | long time2 = cal.getTimeInMillis();
|
| | | long between_days = (time2 - time1) / (1000 * 3600 * 24);
|
| | | return Integer.parseInt(String.valueOf(between_days));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 字符串日期格式的计算
|
| | | * |
| | | * @param smdate
|
| | | * @param bdate
|
| | | * @return
|
| | | * @throws ParseException
|
| | | */
|
| | | public static int daysBetween(String smdate, String bdate) throws ParseException {
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
| | | Calendar cal = Calendar.getInstance();
|
| | | cal.setTime(sdf.parse(smdate));
|
| | | long time1 = cal.getTimeInMillis();
|
| | | cal.setTime(sdf.parse(bdate));
|
| | | long time2 = cal.getTimeInMillis();
|
| | | long between_days = (time2 - time1) / (1000 * 3600 * 24);
|
| | | return Integer.parseInt(String.valueOf(between_days));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 返回中间日期
|
| | | * |
| | | * @param startTime
|
| | | * @param endTime
|
| | | * @return
|
| | |
| | | }
|
| | | return listDate;
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * @param args
|
| | | * @throws ParseException
|
| | | * format() 对日期进行格式化处理
|
| | | * parse() 将日期设置为date类型
|
| | | */
|
| | | public static void main(String[] args) throws ParseException { |
| | | // TODO Auto-generated method stub |
| | | SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | Date d1=sdf.parse("2016-09-08 00:00:00"); |
| | | Date d2=sdf.parse("2016-09-08 00:00:00");
|
| | | |
| | | System.out.println(daysBetween(d1,d2)); |
| | | System.out.println(daysBetween("2016-09-08 10:10:10","2016-09-29 00:00:00")); |
| | | } |
| | |
|
| | | |
| | | /**
|
| | | * @param args
|
| | | * @throws ParseException format() 对日期进行格式化处理 parse() 将日期设置为date类型
|
| | | */
|
| | | public static void main(String[] args) throws ParseException {
|
| | | // TODO Auto-generated method stub
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
| | | Date d1 = sdf.parse("2016-09-08 00:00:00");
|
| | | Date d2 = sdf.parse("2016-09-08 00:00:00");
|
| | |
|
| | | System.out.println(daysBetween(d1, d2));
|
| | | System.out.println(daysBetween("2016-09-08 10:10:10", "2016-09-29 00:00:00"));
|
| | | }
|
| | |
|
| | | } |