| | |
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
|
| | | import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | | import com.yeshi.fanli.entity.taobao.SearchFilter;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | |
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.Utils;
|
| | | import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
|
| | | import com.yeshi.fanli.util.factory.CommonGoodsFactory;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | | import com.yeshi.fanli.util.jd.JDUtil;
|
| | |
| | | out.print(JsonUtil.loadFalseResult("值为空"));
|
| | | return;
|
| | | }
|
| | | //去除前后空格
|
| | | text=text.trim();
|
| | | // 去除前后空格
|
| | | text = text.trim();
|
| | |
|
| | | if (text.length() > 256) {
|
| | | out.print(JsonUtil.loadFalseResult("值过长"));
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | CommonGoods commonGoods = null;
|
| | | text = matcher.group();
|
| | | if (text.contains("ju.taobao.com") || text.contains(".juhuasuan.com")) {// 聚划算
|
| | | int index = text.indexOf("item_id");
|
| | |
| | | }
|
| | | } else {
|
| | | tb = TaoBaoUtil.parsePhoneShareUrlByTB(text);
|
| | | if (tb == null)// 淘宝是空值
|
| | | {
|
| | | String jdId = JDUtil.getJDGoodsId(text);
|
| | | if (!StringUtil.isNullOrEmpty(jdId)) {
|
| | | JDGoods goods = JDApiUtil.getGoodsDetail(Long.parseLong(jdId));
|
| | | if (goods != null)
|
| | | commonGoods = CommonGoodsFactory.create(goods);
|
| | | } else {
|
| | | String pddId = PinDuoDuoUtil.getPDDGoodsId(text);
|
| | | if (!StringUtil.isNullOrEmpty(pddId)) {
|
| | | PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(pddId));
|
| | | if (goods != null)
|
| | | commonGoods = CommonGoodsFactory.create(goods);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (tb == null) {
|
| | | if (tb == null && commonGoods == null) {
|
| | | out.println(JsonUtil.loadFalseResult("暂未找到该商品,请稍后再试!"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (tb != null) {
|
| | | commonGoods = new CommonGoods();
|
| | | commonGoods.setPrice(tb.getZkPrice());
|
| | | commonGoods.setTitle(tb.getTitle());
|
| | | commonGoods.setGoodsId(tb.getAuctionId());
|
| | | commonGoods.setGoodsType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | commonGoods.setPicture(tb.getPictUrl());
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | JSONObject taoBaoGoodsJSON = new JSONObject();
|
| | | taoBaoGoodsJSON.put("title", tb.getTitle());
|
| | | taoBaoGoodsJSON.put("zkPrice", tb.getZkPrice());
|
| | | taoBaoGoodsJSON.put("id", tb.getAuctionId());
|
| | | taoBaoGoodsJSON.put("goodsType", Constant.SOURCE_TYPE_TAOBAO);
|
| | | taoBaoGoodsJSON.put("url", "http://item.taobao.com/item.htm?id=" + tb.getAuctionId());
|
| | | data.put("goods", taoBaoGoodsJSON);
|
| | | if (!StringUtil.isNullOrEmpty(tb.getPictUrl())) {
|
| | | if (tb.getImgList() == null)
|
| | | tb.setImgList(new ArrayList<>());
|
| | | tb.getImgList().add(0, TbImgUtil.getTBSize220Img(tb.getPictUrl()));
|
| | | taoBaoGoodsJSON.put("title", commonGoods.getTitle());
|
| | | taoBaoGoodsJSON.put("zkPrice", commonGoods.getPrice() + "");
|
| | | taoBaoGoodsJSON.put("id", commonGoods.getGoodsId());
|
| | | taoBaoGoodsJSON.put("goodsType", commonGoods.getGoodsType());
|
| | | if (commonGoods.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | taoBaoGoodsJSON.put("url", "http://item.taobao.com/item.htm?id=" + commonGoods.getGoodsId());
|
| | | } else if (commonGoods.getGoodsType() == Constant.SOURCE_TYPE_JD) {
|
| | | taoBaoGoodsJSON.put("url", String.format("https://item.jd.com/%s.html", commonGoods.getGoodsId() + ""));
|
| | | } else if (commonGoods.getGoodsType() == Constant.SOURCE_TYPE_PDD) {
|
| | | taoBaoGoodsJSON.put("url", "http://yangkeduo.com/goods.html?goods_id=" + commonGoods.getGoodsId());
|
| | | }
|
| | | data.put("imgs", tb.getImgList());
|
| | | data.put("goods", taoBaoGoodsJSON);
|
| | | List<String> picList = new ArrayList<>();
|
| | | picList.add(commonGoods.getPicture());
|
| | | data.put("imgs", picList);
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("type", 1);
|
| | | root.put("data", data);
|
| | |
| | |
|
| | | @RequestMapping(value = "getStrategyPictureList")
|
| | | public void strategyPicture(String callback, AcceptData acceptData, PrintWriter out) {
|
| | | List<StrategyPicture> list = strategtPictureService.getStrategyPictureListCache();
|
| | | List<StrategyPicture> list = strategtPictureService.getTextStrategyPictureListCache();
|
| | | Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
| | | if (StringUtil.isNullOrEmpty(callback)) {
|
| | | List<StrategyPicture> newList = new ArrayList<StrategyPicture>();
|
| | |
| | | import java.lang.reflect.Field;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.regex.Pattern;
|
| | |
|
| | |
| | | }
|
| | |
|
| | | public void saveWithCommision(DaTaoKeDetailV2 v2) {
|
| | | v2.setUpdateTime(new Date());
|
| | | BigDecimal commision = MoneyBigDecimalUtil
|
| | | .div(MoneyBigDecimalUtil.mul(v2.getActualPrice(), v2.getCommissionRate()), new BigDecimal(100));
|
| | | int commissionInt = commision.multiply(new BigDecimal(100)).intValue();
|
| | |
| | | import org.springframework.data.mongodb.core.mapping.Field;
|
| | |
|
| | | @Document(collection = "daTaoKeGoods")
|
| | | public class DaTaoKeDetailV2 implements Serializable{
|
| | | public class DaTaoKeDetailV2 implements Serializable {
|
| | | /**
|
| | | *
|
| | | */
|
| | |
| | | @Field
|
| | | private Integer activityType;// 活动类型,1-无活动,2-淘抢购,3-聚划算
|
| | | @Field
|
| | | private String createTime;// 商品创建时间
|
| | | private Date createTime;// 商品创建时间
|
| | | @Field
|
| | | private String mainPic;// 商品主图链接
|
| | | @Field
|
| | |
| | | private Integer tbcid;// 商品在淘宝的二级分类id ,非大淘客的二级分类
|
| | | @Field
|
| | | private Date updateTime;
|
| | | //额外字段维护
|
| | | // 额外字段维护
|
| | | @Field
|
| | | private Integer commission;// 佣金金额,单位为分
|
| | |
|
| | |
| | | this.activityType = activityType;
|
| | | }
|
| | |
|
| | | public String getCreateTime() {
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(String createTime) {
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | |
| | | @Table("ye_yeshi_strategy_picture")
|
| | | public class StrategyPicture {
|
| | |
|
| | | public static int TYPE_TEXT = 1;
|
| | |
|
| | | public static int TYPE_VIDEO = 2;
|
| | |
|
| | | @Expose
|
| | | @Id
|
| | | @GeneratedValue(strategy = GenerationType.AUTO)
|
| | |
| | | @Column(name = "orderBy")
|
| | | private Integer orderBy;
|
| | |
|
| | | @Expose
|
| | | @Column(name = "type")
|
| | | private Integer type;
|
| | |
|
| | | @Expose
|
| | | @Column(name = "video_url")
|
| | | private String videoUrl;
|
| | |
|
| | | public Integer getType() {
|
| | | return type;
|
| | | }
|
| | |
|
| | | public void setType(Integer type) {
|
| | | this.type = type;
|
| | | }
|
| | |
|
| | | public String getVideoUrl() {
|
| | | return videoUrl;
|
| | | }
|
| | |
|
| | | public void setVideoUrl(String videoUrl) {
|
| | | this.videoUrl = videoUrl;
|
| | | }
|
| | |
|
| | | public String getPostPicture() {
|
| | | return postPicture;
|
| | | }
|
| | |
| | | <result column="post_picture" property="postPicture" jdbcType="VARCHAR" /> |
| | | <result column="title" property="title" jdbcType="VARCHAR" /> |
| | | <result column="orderBy" property="orderBy" jdbcType="INTEGER" /> |
| | | <result column="type" property="type" jdbcType="INTEGER" /> |
| | | <result column="video_url" property="videoUrl" jdbcType="VARCHAR" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">id,strategyPicture,post_picture,title,orderBy</sql> |
| | | <sql id="Base_Column_List">id,strategyPicture,post_picture,title,orderBy,type,video_url |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from ye_yeshi_strategy_picture where id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | <select id="selectStrategyPictureList" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from ye_yeshi_strategy_picture order by orderBy desc |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | ye_yeshi_strategy_picture where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | ye_yeshi_strategy_picture where id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.xcx.StrategyPicture" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | ye_yeshi_strategy_picture |
| | | (id,strategyPicture,post_picture,title,orderBy) values |
| | | (#{id,jdbcType=BIGINT},#{strategyPicture,jdbcType=VARCHAR},#{postPicture,jdbcType=VARCHAR},#{title,jdbcType=VARCHAR},#{orderBy,jdbcType=INTEGER}) |
| | | (id,strategyPicture,post_picture,title,orderBy,type,video_url) values |
| | | (#{id,jdbcType=BIGINT},#{strategyPicture,jdbcType=VARCHAR},#{postPicture,jdbcType=VARCHAR},#{title,jdbcType=VARCHAR},#{orderBy,jdbcType=INTEGER},#{type,jdbcType=INTEGER},#{videoUrl,jdbcType=VARCHAR}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.xcx.StrategyPicture" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | |
| | | <if test="postPicture != null">post_picture,</if> |
| | | <if test="title != null">title,</if> |
| | | <if test="orderBy != null">orderBy,</if> |
| | | <if test="type != null">type,</if> |
| | | <if test="videoUrl != null">video_url,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | |
| | | <if test="postPicture != null">#{postPicture,jdbcType=VARCHAR},</if> |
| | | <if test="title != null">#{title,jdbcType=VARCHAR},</if> |
| | | <if test="orderBy != null">#{orderBy,jdbcType=INTEGER},</if> |
| | | <if test="type != null">#{type,jdbcType=INTEGER},</if> |
| | | <if test="videoUrl != null">#{videoUrl,jdbcType=VARCHAR}</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.xcx.StrategyPicture">update |
| | | ye_yeshi_strategy_picture set strategyPicture = |
| | | #{strategyPicture,jdbcType=VARCHAR},post_picture = |
| | | #{postPicture,jdbcType=VARCHAR},title = |
| | | #{title,jdbcType=VARCHAR},orderBy = #{orderBy,jdbcType=INTEGER} where |
| | | id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | #{title,jdbcType=VARCHAR},orderBy = #{orderBy,jdbcType=INTEGER} ,type |
| | | =#{type,jdbcType=INTEGER} ,video_url =#{videoUrl,jdbcType=VARCHAR} |
| | | where id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.xcx.StrategyPicture"> |
| | | update ye_yeshi_strategy_picture |
| | | <set> |
| | |
| | | <if test="postPicture != null">post_picture=#{postPicture,jdbcType=VARCHAR},</if> |
| | | <if test="title != null">title=#{title,jdbcType=VARCHAR},</if> |
| | | <if test="orderBy != null">orderBy=#{orderBy,jdbcType=INTEGER},</if> |
| | | <if test="type !=null">type =#{type,jdbcType=INTEGER},</if> |
| | | <if test="videoUrl !=null">video_url =#{videoUrl,jdbcType=VARCHAR},</if> |
| | | </set> |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | |
| | | JSONObject arcMap = new JSONObject();
|
| | |
|
| | | String indexArc = "index_arc";
|
| | | if (VersionUtil.greaterThan_1_5_60(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | if (VersionUtil.greaterThan_1_6_0(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | indexArc = "index_arc_1.6.0";
|
| | | else if (VersionUtil.greaterThan_1_5_70(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | indexArc = "index_arc_1.5.7";
|
| | |
| | | }
|
| | |
|
| | | // 分享、邀请 隐藏订单号
|
| | | if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType || HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
|
| | | || HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType
|
| | | || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
|
| | | if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType || HongBaoV2.TYPE_YAOQING == hongBaoType
|
| | | || HongBaoV2.TYPE_YIJI == hongBaoType || HongBaoV2.TYPE_ERJI == hongBaoType
|
| | | || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
|
| | | order.setOrderNo(UserUtil.filterOrderId(order.getOrderNo()));
|
| | | }
|
| | | }
|
| | |
| | | commonOrderGoodsMapper.insertSelective(cog);
|
| | | newCommonOrder.setCommonOrderGoods(cog);
|
| | | } else {
|
| | | if (!Constant.IS_OUTNET) {
|
| | | PDDGoodsDetail pddGoods = null;
|
| | | pddGoods = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(cog.getGoodsId()));
|
| | | if (pddGoods != null) {
|
| | | cog = CommonOrderGoodsFactory.create(pddGoods);
|
| | | commonGoodsList.get(0).setPicture(cog.getPicture());
|
| | | commonOrderGoodsMapper.updateByPrimaryKeySelective(commonGoodsList.get(0));
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | newCommonOrder.setUserInfo(new UserInfo(uid));
|
| | | commonOrderList.add(addCommonOrder(newCommonOrder));
|
| | |
| | | if (commonGoodsList.size() <= 0)// 不存在就插入商品
|
| | | {
|
| | | JDGoods goods = JDApiUtil.getGoodsDetail(itemOrder.getSkuId());
|
| | | if (goods == null) {
|
| | | goods = JDUtil.getGoodsFromWeb(itemOrder.getSkuId());
|
| | | }
|
| | |
|
| | | if (goods != null) {
|
| | | cog = CommonOrderGoodsFactory.create(goods);
|
| | |
| | | cog.setUpdateTime(new Date());
|
| | | commonOrderGoodsMapper.insertSelective(cog);
|
| | | } else {
|
| | | if (!Constant.IS_OUTNET) {
|
| | | JDGoods goods = JDApiUtil.getGoodsDetail(itemOrder.getSkuId());
|
| | | if(goods==null)
|
| | | goods=JDUtil.getGoodsFromWeb(itemOrder.getSkuId());
|
| | | commonGoodsList.get(0).setTitle(goods.getSkuName());
|
| | | commonGoodsList.get(0).setPicture(goods.getPicUrl());
|
| | | commonOrderGoodsMapper.updateByPrimaryKeySelective(commonGoodsList.get(0));
|
| | | }
|
| | |
|
| | | }
|
| | | newCommonOrder.setUserInfo(new UserInfo(uid));
|
| | | commonOrderList.add(addCommonOrder(newCommonOrder));
|
| | |
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service;
|
| | | import com.yeshi.fanli.util.BeanUtil;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
| | | while (result.getGoodsList() != null && result.getGoodsList().size() > 0) {
|
| | | System.out.println(page++);
|
| | | for (DaTaoKeDetailV2 v2 : result.getGoodsList())
|
| | | daTaoKeGoodsDetailV2Dao.saveWithCommision(v2);
|
| | | {
|
| | | try {
|
| | | daTaoKeGoodsDetailV2Dao.saveWithCommision(v2);
|
| | | } catch (Exception e) {
|
| | | }
|
| | | |
| | | }
|
| | | result = DaTaoKeApiUtil.listAll(result.getPageId());
|
| | | try {
|
| | | Thread.sleep(10);
|
| | |
| | | String startTime = null;
|
| | | DaTaoKeDetailV2 latest = daTaoKeGoodsDetailV2Dao.selectLatest();
|
| | | if (latest != null) {
|
| | | startTime = latest.getCreateTime();
|
| | | startTime =TimeUtil.getGernalTime(latest.getCreateTime().getTime(),"yyyy-MM-dd HH:mm:ss");
|
| | | }
|
| | | DaTaoKeGoodsResult result = DaTaoKeApiUtil.getNewGoodsList(null, startTime, null);
|
| | | while (!StringUtil.isNullOrEmpty(result.getPageId())) {
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List<StrategyPicture> getStrategyPictureListCache() {
|
| | | return strategyPictureMapper.selectStrategyPictureList();
|
| | | public List<StrategyPicture> getTextStrategyPictureListCache() {
|
| | | List<StrategyPicture> list = strategyPictureMapper.selectStrategyPictureList();
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | if (list.get(i).getType() != StrategyPicture.TYPE_TEXT) {
|
| | | list.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | | return list;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<StrategyPicture> getVideoStrategyPictureListCache() {
|
| | | List<StrategyPicture> list = strategyPictureMapper.selectStrategyPictureList();
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | if (list.get(i).getType() != StrategyPicture.TYPE_VIDEO) {
|
| | | list.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | | return list;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | String strategyPictureList(Long id);
|
| | |
|
| | | List<StrategyPicture> getStrategyPictureListCache();
|
| | | List<StrategyPicture> getTextStrategyPictureListCache();
|
| | | |
| | | List<StrategyPicture> getVideoStrategyPictureListCache();
|
| | |
|
| | | }
|
| | |
| | |
|
| | | return null;
|
| | | }
|
| | | |
| | | public static String getJDGoodsId(String url) {
|
| | | try {
|
| | | if (url.startsWith("https://item.m.jd.com/product/") || url.startsWith("http://item.m.jd.com/product/")
|
| | | || url.startsWith("https://item.jd.com/") || url.startsWith("http://item.jd.com/")) {
|
| | | String preUrl = url.split("\\?")[0];
|
| | | String index = preUrl.split("/")[preUrl.split("/").length - 1];
|
| | | index = index.split("\\.")[0];
|
| | | return index.trim();
|
| | | } else if (url.startsWith("https://item.m.jd.com/ware/view.action?")) {
|
| | | String preUrl = url.substring(url.indexOf("?") + 1, url.length());
|
| | | String[] sts = preUrl.split("&");
|
| | | for (String st : sts) {
|
| | | if (st.startsWith("wareId=")) {
|
| | | return st.split("=")[1].trim();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | } catch (Exception e) {
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | return goods;
|
| | | }
|
| | | |
| | | public static String getPDDGoodsId(String url) {
|
| | | try {
|
| | | if (url.startsWith("https://mobile.yangkeduo.com/goods.html?")
|
| | | || url.startsWith("http://mobile.yangkeduo.com/goods.html?")||url.contains("yangkeduo.com/duo_coupon_landing.html?")) {
|
| | | String preUrl = url.substring(url.indexOf("?") + 1, url.length());
|
| | | String[] sts = preUrl.split("&");
|
| | | for (String st : sts) {
|
| | | if (st.startsWith("goods_id=")) {
|
| | | return st.split("=")[1].trim();
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | }
|
| | | return null;
|
| | | }
|
| | | |
| | | |
| | | }
|