| | |
| | | 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.bus.homemodule.Special;
|
| | | 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.homemodule.SpecialService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.taobao.DaTaoKeUtil;
|
| | | import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | |
| | | @Resource
|
| | | private DynamicInfoService dynamicInfoService;
|
| | |
|
| | | @Resource
|
| | | private SpecialService specialService;
|
| | | |
| | |
|
| | | /**
|
| | | * 动态商品列表
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | if (cid != null && cid == 5) {
|
| | | // 活动主题
|
| | | getSpecialList(acceptData, page, subId, out);
|
| | | return;
|
| | | }
|
| | | |
| | | |
| | | long count = 0;
|
| | |
|
| | | int platform = 1;
|
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
|
| | | platform = 2;
|
| | | }
|
| | | |
| | | int version = Integer.parseInt(acceptData.getVersion());
|
| | | List<DynamicInfo> list = dynamicInfoService.queryV2(platform, version, (page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, cid,
|
| | | subId);
|
| | |
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 活动列表
|
| | | * @param acceptData
|
| | | * @param out
|
| | | */
|
| | | private void getSpecialList(AcceptData acceptData, Integer page, Long subId, PrintWriter out) {
|
| | | if (subId == null) {
|
| | | out.print(JsonUtil.loadFalseResult("分类id不能为空"));
|
| | | return;
|
| | | }
|
| | | |
| | | // 平台区分
|
| | | int platformCode = Constant.getPlatformCode(acceptData.getPlatform());
|
| | | List<String> listKey = new ArrayList<String>();
|
| | | |
| | | if (subId == 1) { // 淘宝
|
| | | listKey.add("special_channel_tb");
|
| | | } else if (subId == 2) { // 京东
|
| | | listKey.add("special_channel_jd");
|
| | | } else if (subId == 3) { // 拼多多
|
| | | listKey.add("special_channel_pdd");
|
| | | } else { // 全部
|
| | | listKey.add("special_channel_tb");
|
| | | listKey.add("special_channel_jd");
|
| | | listKey.add("special_channel_pdd");
|
| | | }
|
| | | |
| | | List<Special> list = specialService.listByPlaceKeyList((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, listKey, platformCode,
|
| | | Integer.parseInt(acceptData.getVersion()));
|
| | | |
| | | long time = System.currentTimeMillis();
|
| | | |
| | | // 删除尚未启用的过期的
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | Special special = list.get(i);
|
| | | if (special.getState() == 1L) {
|
| | | list.remove(i--);
|
| | | } else {
|
| | | if (special.getStartTime() != null && special.getEndTime() != null)
|
| | | special.setTimeTask(true);
|
| | | else
|
| | | special.setTimeTask(false);
|
| | | |
| | | if (special.isTimeTask()) {
|
| | | if (time < special.getStartTime().getTime() || time > special.getEndTime().getTime()) {
|
| | | list.remove(i--);
|
| | | } else// 设置倒计时
|
| | | {
|
| | | special.setCountDownTime((special.getEndTime().getTime() - time) / 1000);
|
| | | }
|
| | | }
|
| | | |
| | | if (Constant.IS_TEST) {// 测试标签
|
| | | List<ClientTextStyleVO> labels = new ArrayList<>();
|
| | | labels.add(new ClientTextStyleVO("文章标签", "#FE0014"));
|
| | | labels.add(new ClientTextStyleVO("标签内容", "#FE0014"));
|
| | | special.setLabels(labels);
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | long count = specialService.countByPlaceKeyList( listKey, platformCode, Integer.parseInt(acceptData.getVersion()));
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | Gson gson = gsonBuilder.create();
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", count);
|
| | | data.put("list", gson.toJson(list));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | |
| | | |
| | | |
| | | /**
|
| | | * 查询顶部分类
|
| | | * |
| | | * @param acceptData
|
| | | * @param page
|
| | | * @param cid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getClass", method = RequestMethod.POST)
|
| | | public void getClass(AcceptData acceptData, Integer cid, PrintWriter out) {
|
| | | // 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;
|
| | | case 5:
|
| | | break;
|
| | | default:
|
| | | break;
|
| | | }
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("list", JsonUtil.getApiCommonGson().toJson(list));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | |
|
| | | // Android 返回分类以及顶部数据
|
| | | List<GoodsClass> listSub = new ArrayList<GoodsClass>();
|
| | | listSub.add(new GoodsClass(0L, "今日单品"));
|
| | | listSub.addAll(DaTaoKeUtil.goodsClasses);
|
| | | |
| | | GoodsClass menu1 = new GoodsClass(1L, "热销");
|
| | | menu1.setListSub(listSub);
|
| | | |
| | | GoodsClass menu2 = new GoodsClass(2L, "推荐");
|
| | | menu2.setListSub(new ArrayList<GoodsClass>());
|
| | | |
| | | GoodsClass menu3 = new GoodsClass(3L, "好店");
|
| | | menu3.setListSub(new ArrayList<GoodsClass>());
|
| | | |
| | | GoodsClass menu4 = new GoodsClass(4L, "邀请");
|
| | | menu4.setListSub(new ArrayList<GoodsClass>());
|
| | | |
| | | GoodsClass menu5 = new GoodsClass(5L, "活动");
|
| | | List<GoodsClass> sub5 = new ArrayList<GoodsClass>();
|
| | | sub5.add(new GoodsClass(0L, "全部"));
|
| | | sub5.add(new GoodsClass(1L, "淘宝"));
|
| | | sub5.add(new GoodsClass(2L, "京东"));
|
| | | sub5.add(new GoodsClass(3L, "拼多多"));
|
| | | menu5.setListSub(sub5);
|
| | | |
| | | List<GoodsClass> list = new ArrayList<GoodsClass>();
|
| | | list.add(menu1);
|
| | | list.add(menu5);
|
| | | list.add(menu2);
|
| | | list.add(menu3);
|
| | | list.add(menu4);
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("list", JsonUtil.getApiCommonGson().toJson(list));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | /**
|
| | | * 时间处理
|
| | |
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
|
| | | import com.yeshi.fanli.service.inter.goods.recommend.HomeRecommendGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.recommend.RecommendGoodsDeleteHistoryService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.DeviceSexService;
|
| | |
| | |
|
| | | @Resource
|
| | | private DaTaoKeGoodsService daTaoKeGoodsService;
|
| | | |
| | | @Resource
|
| | | private HongBaoV2CountService hongBaoV2CountService;
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 新版推荐专题管理(1.5.3)
|
| | |
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 获取专题渠道活动
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param callback
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getGuide")
|
| | | public void getGuide(AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | String tips = null;
|
| | | if (uid == null || uid <= 0) {
|
| | | tips = configService.get("tip_guide_new_user");
|
| | | } else {
|
| | | long rebateOrder = hongBaoV2CountService.countRebateOrder(uid);
|
| | | long shareOrInviteOrder = hongBaoV2CountService.countShareOrInviteOrder(uid);
|
| | | if (rebateOrder <= 0 && shareOrInviteOrder <= 0) {
|
| | | // 新人版
|
| | | tips = configService.get("tip_guide_new_user");
|
| | | } else if (rebateOrder > 0 && shareOrInviteOrder <= 0) {
|
| | | // 省钱版
|
| | | tips = configService.get("tip_guide_save_money");
|
| | | } else if (shareOrInviteOrder > 0) {
|
| | | // 赚钱版
|
| | | tips = configService.get("tip_guide_share_invite");
|
| | | } else {
|
| | | // 熟客版
|
| | | }
|
| | | }
|
| | | |
| | | if (StringUtil.isNullOrEmpty(tips)) {
|
| | | out.print(JsonUtil.loadFalseResult("暂无提示"));
|
| | | return;
|
| | | }
|
| | | |
| | | JSONObject data = JSONObject.fromObject(tips);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | BigDecimal countRebateCouponMoney(); |
| | | |
| | | |
| | | /**
|
| | | * 统计返利订单
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | long countRebateOrder(@Param("uid") Long uid);
|
| | | |
| | | /**
|
| | | * 统计分享和邀请订单
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | long countShareOrInviteOrder(@Param("uid") Long uid);
|
| | |
|
| | | } |
| | |
| | | List<Special> listByPlaceKey(@Param("placeKey") String placeKey, @Param("sex")Integer sex
|
| | | , @Param("platform") Integer platform, @Param("versionCode") Integer versionCode);
|
| | |
|
| | | |
| | | /**
|
| | | * 根据多个位置标识查询
|
| | | * @param list
|
| | | * @param sex
|
| | | * @param platform
|
| | | * @param versionCode
|
| | | * @return
|
| | | */
|
| | | List<Special> listByPlaceKeyList(@Param("start")long start, @Param("count")int count,@Param("list") List<String> list, @Param("sex")Integer sex
|
| | | , @Param("platform") Integer platform, @Param("versionCode") Integer versionCode);
|
| | | |
| | | long countByPlaceKeyList(@Param("list") List<String> list, @Param("sex")Integer sex
|
| | | , @Param("platform") Integer platform, @Param("versionCode") Integer versionCode);
|
| | | |
| | | } |
| | |
| | |
|
| | | import java.io.Serializable;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | import com.google.gson.annotations.Expose;
|
| | | import com.yeshi.fanli.entity.common.JumpDetailV2;
|
| | | import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
|
| | |
|
| | | /**
|
| | | * 专题管理
|
| | |
| | |
|
| | | @Expose
|
| | | private long countDownTime;//倒计时
|
| | |
|
| | | @Expose
|
| | | private List<ClientTextStyleVO> labels; //标签
|
| | |
|
| | |
|
| | | public long getCountDownTime() {
|
| | | return countDownTime;
|
| | |
| | | this.endTime_str = endTime_str;
|
| | | }
|
| | |
|
| | | public List<ClientTextStyleVO> getLabels() {
|
| | | return labels;
|
| | | }
|
| | |
|
| | | public void setLabels(List<ClientTextStyleVO> labels) {
|
| | | this.labels = labels;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | <if test="platform == 2">
|
| | | AND IF(sp.`b_min_ios_version_code` IS NOT NULL, #{versionCode}<![CDATA[>=]]> sp.b_min_ios_version_code,TRUE)
|
| | | </if>
|
| | | <include refid="Sex_Screen" />
|
| | | <if test="sex == null"> ORDER BY sp.`b_orderby`</if>
|
| | | </select>
|
| | |
|
| | | <select id="listByPlaceKeyList" resultMap="BaseResultMap">
|
| | | SELECT sp.*,c.`cd_bottom_picture` FROM `yeshi_ec_special` sp
|
| | | RIGHT JOIN
|
| | | (SELECT c.* FROM yeshi_ec_special_card c
|
| | | LEFT JOIN
|
| | | `yeshi_ec_special_place` pc ON pc.`sp_id` = c.`cd_place_id`
|
| | | WHERE
|
| | | c.`cd_state` = 0
|
| | | AND IF(c.`cd_start_time` IS NULL,TRUE,
|
| | | c.`cd_start_time`<![CDATA[<=]]>NOW())
|
| | | AND IF(c.`cd_end_time` IS NULL,TRUE,c.`cd_end_time`<![CDATA[>=]]>NOW())
|
| | | AND pc.`sp_key` in
|
| | | <foreach collection="list" item="item" open="(" close=")" separator=",">
|
| | | #{item}
|
| | | </foreach>
|
| | | )c ON sp.`b_card_id` = c.`cd_id`
|
| | | WHERE sp.`b_state` = 0 |
| | | AND IF(sp.b_start_time IS NULL,TRUE, sp.b_start_time<![CDATA[<=]]> NOW()) |
| | | AND IF(sp.b_end_time IS NULL,TRUE, sp.b_end_time <![CDATA[>=]]> NOW())
|
| | | <if test="platform == 1">
|
| | | AND IF(sp.`b_min_android_version_code` IS NOT NULL, #{versionCode}<![CDATA[>=]]> sp.b_min_android_version_code,TRUE)
|
| | | </if>
|
| | | <if test="platform == 2">
|
| | | AND IF(sp.`b_min_ios_version_code` IS NOT NULL, #{versionCode}<![CDATA[>=]]> sp.b_min_ios_version_code,TRUE)
|
| | | </if>
|
| | | <include refid="Sex_Screen" />
|
| | | <if test="sex == null"> ORDER BY sp.`b_orderby`</if>
|
| | | LIMIT ${start},${count}
|
| | | </select>
|
| | | |
| | | |
| | | <select id="countByPlaceKeyList" resultType="Long">
|
| | | SELECT IFNULL(COUNT(sp.`b_id`),0) FROM `yeshi_ec_special` sp
|
| | | RIGHT JOIN
|
| | | (SELECT c.* FROM yeshi_ec_special_card c
|
| | | LEFT JOIN
|
| | | `yeshi_ec_special_place` pc ON pc.`sp_id` = c.`cd_place_id`
|
| | | WHERE
|
| | | c.`cd_state` = 0
|
| | | AND IF(c.`cd_start_time` IS NULL,TRUE,
|
| | | c.`cd_start_time`<![CDATA[<=]]>NOW())
|
| | | AND IF(c.`cd_end_time` IS NULL,TRUE,c.`cd_end_time`<![CDATA[>=]]>NOW())
|
| | | AND pc.`sp_key` in
|
| | | <foreach collection="list" item="item" open="(" close=")" separator=",">
|
| | | #{item}
|
| | | </foreach>
|
| | | )c ON sp.`b_card_id` = c.`cd_id`
|
| | | WHERE sp.`b_state` = 0 |
| | | AND IF(sp.b_start_time IS NULL,TRUE, sp.b_start_time<![CDATA[<=]]> NOW()) |
| | | AND IF(sp.b_end_time IS NULL,TRUE, sp.b_end_time <![CDATA[>=]]> NOW())
|
| | | <if test="platform == 1">
|
| | | AND IF(sp.`b_min_android_version_code` IS NOT NULL, #{versionCode}<![CDATA[>=]]> sp.b_min_android_version_code,TRUE)
|
| | | </if>
|
| | | <if test="platform == 2">
|
| | | AND IF(sp.`b_min_ios_version_code` IS NOT NULL, #{versionCode}<![CDATA[>=]]> sp.b_min_ios_version_code,TRUE)
|
| | | </if>
|
| | | <include refid="Sex_Screen" />
|
| | | </select>
|
| | | </mapper>
|
| | |
| | | </select> |
| | | |
| | | |
| | | <select id="countRebateOrder" resultType="Long">
|
| | | SELECT IFNULL(COUNT(hb_id),0) FROM `yeshi_ec_hongbao_v2`
|
| | | WHERE hb_uid = #{uid} AND (hb_type =1 OR hb_type =2)
|
| | | </select>
|
| | |
|
| | | <select id="countShareOrInviteOrder" resultType="Long">
|
| | | SELECT IFNULL(COUNT(hb_id),0) FROM `yeshi_ec_hongbao_v2` |
| | | WHERE hb_uid = #{uid}
|
| | | AND (`hb_type` =5 OR `hb_type` =6 OR `hb_type` =7 OR `hb_type` =20 OR `hb_type`=21 OR `hb_type` =22 )
|
| | | </select>
|
| | |
|
| | | |
| | | </mapper> |
| | |
| | | public BigDecimal countRebateCouponMoney() {
|
| | | return hongBaoV2CountMapper.countRebateCouponMoney();
|
| | | }
|
| | | |
| | | @Override
|
| | | public long countRebateOrder(Long uid) {
|
| | | return hongBaoV2CountMapper.countRebateOrder(uid);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public long countShareOrInviteOrder(Long uid) {
|
| | | return hongBaoV2CountMapper.countShareOrInviteOrder(uid);
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | |
| | | public List<Special> listByPlaceKey(String placeKey, Integer platform, Integer versionCode) {
|
| | | return specialMapper.listByPlaceKey(placeKey, null, platform, versionCode);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public List<Special> listByPlaceKeyList(long start, int count, List<String> list, Integer platform, Integer versionCode) {
|
| | | return specialMapper.listByPlaceKeyList(start, count, list, null, platform, versionCode);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public long countByPlaceKeyList(List<String> list, Integer platform, Integer versionCode) {
|
| | | return specialMapper.countByPlaceKeyList(list, null, platform, versionCode);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 处理 数据
|
| | |
| | | */
|
| | | public BigDecimal countRebateCouponMoney();
|
| | |
|
| | | /**
|
| | | * 统计返利订单
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public long countRebateOrder(Long uid);
|
| | |
|
| | | /**
|
| | | * 统计分享+ 邀请订单
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public long countShareOrInviteOrder(Long uid);
|
| | |
|
| | | }
|
| | |
| | | */
|
| | | public List<Special> listByVersion(long start, int count, String card, Integer platform, Integer versionCode);
|
| | |
|
| | |
|
| | | /**
|
| | | * 专题版本区分 传递多个位置
|
| | | * @param list
|
| | | * @param platform
|
| | | * @param versionCode
|
| | | * @return
|
| | | */
|
| | | public List<Special> listByPlaceKeyList(long start, int count, List<String> list, Integer platform, Integer versionCode);
|
| | |
|
| | |
|
| | | public long countByPlaceKeyList(List<String> list, Integer platform, Integer versionCode);
|
| | |
|
| | | }
|
| | |
| | | return false;
|
| | | }
|
| | |
|
| | | |
| | | public static boolean greaterThan_2_0_1(String platform, String versionCode) {
|
| | | if ((("android".equalsIgnoreCase(platform) && Integer.parseInt(versionCode) >= 50))
|
| | | || (("ios".equalsIgnoreCase(platform) && Integer.parseInt(versionCode) >= 67)))
|
| | | return true;
|
| | | else
|
| | | return false;
|
| | | }
|
| | |
|
| | |
|
| | | public static boolean smallerThan_1_5_1(String platform, String versionCode) {
|
| | | if ((("android".equalsIgnoreCase(platform) && Integer.parseInt(versionCode) < 36))
|
| | |
| | |
|
| | | import org.apache.commons.httpclient.HttpClient;
|
| | | import org.apache.commons.httpclient.methods.PostMethod;
|
| | | import org.jsoup.Connection;
|
| | | import org.jsoup.Jsoup;
|
| | | import org.jsoup.nodes.Document;
|
| | | import org.jsoup.nodes.Element;
|
| | |
| | | import com.yeshi.fanli.dto.jd.JDSearchResult;
|
| | | import com.yeshi.fanli.dto.jd.JDShopInfo;
|
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | public class JDUtil {
|
| | |
|
| | | |
| | | public static final String TM_PHONE_URL = "https://item.m.jd.com/product/%s.html";
|
| | |
|
| | | public void test() {
|
| | | Map<String, String> systemParams = new HashMap<>();
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 查询天猫商品图片、标题
|
| | | * @param auctionId
|
| | | * @return
|
| | | */
|
| | | public static JDGoods getSimpleGoodsInfo(String goodsId) {
|
| | | JDGoods jdGoods = null;
|
| | | try {
|
| | | Connection connect = Jsoup.connect(String.format(TM_PHONE_URL, goodsId));
|
| | | Document document = connect.get();
|
| | | Elements elements = document.getElementsByTag("script");
|
| | | if (elements.size() >= 0) {
|
| | | for (int i = 0; i < elements.size(); i++) {
|
| | | String content = elements.get(i).toString();
|
| | | if (content.contains("window._itemOnly")) {
|
| | | System.out.println("存在"); |
| | | content = content.replace("<script>", "");
|
| | | content = content.replace("</script>", "");
|
| | | int indexOf = content.indexOf("window._isLogin");
|
| | | content = content.substring(0,indexOf);
|
| | | |
| | | int indexItem = content.indexOf("\"item\":");
|
| | | content = content.substring(indexItem,content.length() - 1);
|
| | | content = content.replace("\"item\":", "var item =");
|
| | | content = content.replace("});", "").trim();
|
| | | |
| | | content+=";function getData() {return item;}";
|
| | | ScriptEngineManager manager = new ScriptEngineManager();
|
| | | ScriptEngine engine = manager.getEngineByName("javascript");
|
| | | engine.eval(content);
|
| | | |
| | | if (engine instanceof Invocable) {
|
| | | Invocable in = (Invocable) engine;
|
| | | JSONObject json = JSONObject.fromObject(in.invokeFunction("getData"));
|
| | | |
| | | jdGoods = new JDGoods();
|
| | | jdGoods.setSkuName(json.getString("skuName"));
|
| | | JSONObject jsonImage = json.getJSONObject("image");
|
| | | if (jsonImage != null && jsonImage.size() > 0) {
|
| | | String picUrl = jsonImage.getString("0");
|
| | | jdGoods.setPicUrl("http://m.360buyimg.com/mobilecms/s750x750_" + picUrl);
|
| | | }
|
| | | }
|
| | | |
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return jdGoods;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | import javax.annotation.PostConstruct;
|
| | | import javax.annotation.Resource;
|
| | | import javax.script.Invocable;
|
| | | import javax.script.ScriptEngine;
|
| | | import javax.script.ScriptEngineManager;
|
| | | import javax.xml.parsers.DocumentBuilder;
|
| | | import javax.xml.parsers.DocumentBuilderFactory;
|
| | |
|
| | |
| | | return true;
|
| | | }
|
| | |
|
| | | public static void main(String[] args) {
|
| | | String s = channelMap.get("3");
|
| | | System.out.println(s);
|
| | | /**
|
| | | * 查询天猫商品图片、标题
|
| | | * @param auctionId
|
| | | * @return
|
| | | */
|
| | | public static TaoBaoGoodsBrief getTmallGoodsInfo(String auctionId) {
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = null;
|
| | | try {
|
| | | Connection connect = Jsoup.connect(String.format(TM_PHONE_URL, auctionId));
|
| | | Document document = connect.get();
|
| | | Elements elements = document.getElementsByTag("script");
|
| | | if (elements.size() >= 0) {
|
| | | for (int i = 0; i < elements.size(); i++) {
|
| | | String content = elements.get(i).toString();
|
| | | if (content.contains("var _DATA_Mdskip")) {
|
| | | content = content.replace("<script>", "");
|
| | | content = content.replace("</script>", "");
|
| | | content+=";function getData(){ var json={title:_DATA_Mdskip.item.title,pictUrl:_DATA_Mdskip.item.videoDetail.videoThumbnailURL}; return JSON.stringify(json);}";
|
| | |
|
| | | ScriptEngineManager manager = new ScriptEngineManager();
|
| | | ScriptEngine engine = manager.getEngineByName("javascript");
|
| | | engine.eval(content);
|
| | | |
| | | if (engine instanceof Invocable) {
|
| | | Invocable in = (Invocable) engine;
|
| | | JSONObject json = JSONObject.fromObject(in.invokeFunction("getData"));
|
| | | Object title = json.get("title");
|
| | | Object pictUrl = json.get("pictUrl");
|
| | | taoBaoGoodsBrief = new TaoBaoGoodsBrief();
|
| | | taoBaoGoodsBrief.setTitle(title.toString());
|
| | | taoBaoGoodsBrief.setPictUrl(pictUrl.toString());
|
| | | }
|
| | | |
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return taoBaoGoodsBrief;
|
| | | }
|
| | |
|
| | | }
|