| | |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoShop;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
|
| | | import com.yeshi.fanli.exception.taobao.TaoKeApiException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsUpdateException;
|
| | |
| | | app.setPid(TaoBaoConstant.TAOBAO_COMMON_PID);
|
| | | app.setAdzoneId(TaoBaoConstant.TAOBAO_COMMON_PID.split("_")[3]);
|
| | | goods = TaoKeApiUtil.searchGoodsDetail(id, app);
|
| | |
|
| | | final TaoBaoGoodsBrief finalGoods = goods;
|
| | | if (goods != null) {
|
| | | ThreadUtil.run(new Runnable() {
|
| | |
| | |
|
| | | // 大淘客商品过滤
|
| | | try {
|
| | | goods = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(goods);
|
| | | goods = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(goods, acceptData.getPlatform(),
|
| | | acceptData.getVersion());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | |
| | | // 淘宝api搜索商品
|
| | | TaoBaoSearchResult result = TaoBaoUtil.search(sf);
|
| | |
|
| | | // 搜索是否在营销主商品库
|
| | | // 搜索结果缓存到redis
|
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null && result.getTaoBaoGoodsBriefs().size() > 0) {
|
| | | ThreadUtil.run(new Runnable() {
|
| | | @Override
|
| | |
| | | query.skip(start);
|
| | | query.limit(count);
|
| | | return mongoTemplate.find(query, DaTaoKeDetailV2.class);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 根据商品ID检索
|
| | | * @Title: selectByAuctionId
|
| | | * @Description: |
| | | * @param auctionId
|
| | | * @return |
| | | * DaTaoKeDetailV2 返回类型
|
| | | * @throws
|
| | | */
|
| | | public DaTaoKeDetailV2 selectByAuctionId(Long auctionId) {
|
| | | Query query = new Query();
|
| | | query.addCriteria(Criteria.where("goodsId").is(auctionId));
|
| | | query.limit(1);
|
| | | List<DaTaoKeDetailV2> list = mongoTemplate.find(query, DaTaoKeDetailV2.class);
|
| | | if (list != null && list.size() > 0) {
|
| | | return list.get(0);
|
| | | } else
|
| | | return null;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | private String description;//推荐语
|
| | |
|
| | | @Transient
|
| | | private boolean shopCoupon;//是否为店铺券
|
| | | |
| | |
|
| | |
|
| | | /* 新增字段 2018-7-16 ; 由于数据未从淘宝获取成功,暂不启用 */
|
| | |
|
| | |
|
| | |
|
| | | public boolean isShopCoupon() {
|
| | | return shopCoupon;
|
| | | }
|
| | |
|
| | | public void setShopCoupon(boolean shopCoupon) {
|
| | | this.shopCoupon = shopCoupon;
|
| | | }
|
| | |
|
| | | public Integer getMaterialLibType() {
|
| | | return materialLibType;
|
| | | }
|
| | |
| | | if ("饿了么".equalsIgnoreCase(list.get(0).getOrderType())) {
|
| | | // 处理饿了么订单
|
| | | elmeOrderMap.put(orderId, list);
|
| | | }
|
| | |
|
| | | else {
|
| | | // TODO 处理饿了么订单
|
| | | // if(list.get(0).getCreateTime()){
|
| | | // //下单时间大于一个定值就进入淘宝订单
|
| | | // //获取relationId
|
| | | //
|
| | | //
|
| | | // }
|
| | | } else {
|
| | | if (!StringUtil.isNullOrEmpty(list.get(0).getSpecialId())
|
| | | || pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID)) {// 设置渠道ID当做会员运营ID的位置ID
|
| | | fanliOrderMap.put(orderId, list);
|
| | |
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.util.dataoke.DaTaoKeApiUtil;
|
| | | import com.yeshi.fanli.util.taobao.DaTaoKeUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | |
| | |
|
| | | @Override
|
| | | public TaoBaoGoodsBrief filterTaoBaoGoods(TaoBaoGoodsBrief goods) {
|
| | | List<Long> goodsIdList = new ArrayList<>();
|
| | | goodsIdList.add(goods.getAuctionId());
|
| | |
|
| | | List<DaTaoKeDetailV2> daTaoKeList = listByGoodsIds(goodsIdList);
|
| | | if (daTaoKeList == null || daTaoKeList.size() == 0)
|
| | | return goods;
|
| | |
|
| | | // 重新设置标题与券价格
|
| | | goods = DaTaoKeUtil.filterTaoBaoGoods(goods, daTaoKeList.get(0));
|
| | |
|
| | | return goods;
|
| | | return filterTaoBaoGoods(goods, null, null);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | return daTaoKeGoodsDetailV2Dao.listBySellerId((int) start, count, sellerId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public DaTaoKeDetailV2 selectByAuctionId(Long auctionId) {
|
| | | return daTaoKeGoodsDetailV2Dao.selectByAuctionId(auctionId);
|
| | | }
|
| | |
|
| | | @Cacheable(value = "daTaoKeGoodsCache", key = "'selectByAuctionId-'+#auctionId")
|
| | | @Override
|
| | | public DaTaoKeDetailV2 selectByAuctionIdCache(Long auctionId) {
|
| | | return selectByAuctionId(auctionId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public TaoBaoGoodsBrief filterTaoBaoGoods(TaoBaoGoodsBrief goods, String platform, String version) {
|
| | | List<Long> goodsIdList = new ArrayList<>();
|
| | | goodsIdList.add(goods.getAuctionId());
|
| | |
|
| | | List<DaTaoKeDetailV2> daTaoKeList = listByGoodsIds(goodsIdList);
|
| | | if (daTaoKeList == null || daTaoKeList.size() == 0)
|
| | | return goods;
|
| | |
|
| | | if (platform != null && version != null && VersionUtil.greaterThan_2_1(platform, version)) {
|
| | | // 重新设置标题与券价格
|
| | | goods = DaTaoKeUtil.filterTaoBaoGoods(goods, daTaoKeList.get(0), true);
|
| | | } else
|
| | | goods = DaTaoKeUtil.filterTaoBaoGoods(goods, daTaoKeList.get(0), false);
|
| | |
|
| | | return goods;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | */
|
| | | public TaoBaoGoodsBrief filterTaoBaoGoods(TaoBaoGoodsBrief goods);
|
| | |
|
| | | |
| | | public TaoBaoGoodsBrief filterTaoBaoGoods(TaoBaoGoodsBrief goods,String platform,String version);
|
| | |
|
| | | /**
|
| | | * 根据主键查询
|
| | | *
|
| | |
| | | * @throws
|
| | | */
|
| | | public List<DaTaoKeDetailV2> listBySellerId(long start, int count, Long sellerId);
|
| | | |
| | | /**
|
| | | * 根据商品ID查询
|
| | | * @Title: selectByAuctionId
|
| | | * @Description: |
| | | * @param auctionId
|
| | | * @return |
| | | * DaTaoKeDetailV2 返回类型
|
| | | * @throws
|
| | | */
|
| | | public DaTaoKeDetailV2 selectByAuctionId(Long auctionId);
|
| | | |
| | | public DaTaoKeDetailV2 selectByAuctionIdCache(Long auctionId);
|
| | | }
|
| | |
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.Collections;
|
| | | import java.util.Comparator;
|
| | | import java.util.Date;
|
| | | import java.util.HashSet;
|
| | | import java.util.List;
|
| | |
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.jd.JDUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoCouponUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | |
| | | coupon.setStartTime(sdf.format(new Date(Long.parseLong(couponEffectiveStartTime))));
|
| | | coupon.setLink(taoBaoQuanInfo.getCouponLink());
|
| | | coupon.setStartFee(taoBaoQuanInfo.getCouponStartFee());
|
| | | coupon.setShopCoupon(goods.isShopCoupon());
|
| | | goodsInfo.setHasCoupon(true);
|
| | | goodsInfo.setCouponInfo(coupon);
|
| | | }
|
| | |
| | | coupon.setStartTime(goods.getCouponEffectiveStartTime().replace("-", "."));
|
| | | }
|
| | |
|
| | | coupon.setLink(TaoBaoCouponUtil.getCoupleUrl(goods.getCouponActivityId(), null, goods.getAuctionId() + ""));
|
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponLink()))
|
| | | coupon.setLink(goods.getCouponLink());
|
| | | else
|
| | | coupon.setLink(
|
| | | TaoBaoCouponUtil.getCoupleUrl(goods.getCouponActivityId(), null, goods.getAuctionId() + ""));
|
| | | coupon.setStartFee(goods.getCouponStartFee());
|
| | |
|
| | | coupon.setShopCoupon(goods.isShopCoupon());
|
| | | goodsInfo.setHasCoupon(true);
|
| | | goodsInfo.setCouponInfo(coupon);
|
| | | }
|
| | |
| | | * @return
|
| | | */
|
| | | public static String getJDGoodsIdByWeiXin(String url) {
|
| | | if (StringUtil.isNullOrEmpty(url))
|
| | | if (StringUtil.isNullOrEmpty(url) || url.indexOf("jd.com") < 0)
|
| | | return null;
|
| | |
|
| | | try {
|
| | |
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
| | | "🕦",// 十一点半
|
| | | };
|
| | |
|
| | | static final String[] evaluateEmojis = new String[] { |
| | | "💟",
|
| | | "🌸",
|
| | | "🍸",
|
| | | "🍺",
|
| | | "📢",
|
| | | "❤",
|
| | | "💝",
|
| | | "💋",
|
| | | "👛",
|
| | | "🐾",
|
| | | "🌹",
|
| | | "🔥",
|
| | | "🎉",
|
| | | "🎁",
|
| | | "🍥",
|
| | | "🍭",
|
| | | "🌺",
|
| | | "👑",
|
| | | "✨",
|
| | | "💫",
|
| | | "🍻",
|
| | | "🎈",
|
| | | "💥",
|
| | | "💕",
|
| | | "💞",
|
| | | "💰",
|
| | | "💌",
|
| | | "💭",
|
| | | "🌼",
|
| | | "🍀"
|
| | | };
|
| | | |
| | | |
| | | static final String[] evaluateEmojis = new String[] { "💟", "🌸", "🍸", "🍺", "📢", "❤", "💝", "💋", "👛", "🐾",
|
| | | "🌹", "🔥", "🎉", "🎁", "🍥", "🍭", "🌺", "👑", "✨", "💫", "🍻", "🎈", "💥", "💕", "💞", "💰", "💌", "💭",
|
| | | "🌼", "🍀" };
|
| | |
|
| | | public static List<GoodsClass> goodsClasses;
|
| | | static {
|
| | |
| | | return commonEmojis[(int) (Math.random() * commonEmojis.length)];
|
| | | }
|
| | |
|
| | | |
| | | public static String getEvaluateEmojis() {
|
| | | return evaluateEmojis[(int) (Math.random() * evaluateEmojis.length)];
|
| | | }
|
| | |
| | | return desc;
|
| | | }
|
| | |
|
| | | public static TaoBaoGoodsBrief filterTaoBaoGoods(TaoBaoGoodsBrief goods, DaTaoKeDetailV2 detail) {
|
| | | if (detail != null && goods != null) {
|
| | | public static TaoBaoGoodsBrief filterTaoBaoGoods(TaoBaoGoodsBrief goods, DaTaoKeDetailV2 v2,
|
| | | boolean filterCouponInfo) {
|
| | | if (v2 != null && goods != null) {
|
| | | // 重新设置标题与券价格
|
| | | goods.setTitle(detail.getDtitle());
|
| | | if (!StringUtil.isNullOrEmpty(detail.getMainPic()))
|
| | | goods.setPictUrlWhite(detail.getMainPic());
|
| | | goods.setTitle(v2.getDtitle());
|
| | | if (!StringUtil.isNullOrEmpty(v2.getMainPic()))
|
| | | goods.setPictUrlWhite(v2.getMainPic());
|
| | | // 如果没有券信息,则提供券信息
|
| | | if (StringUtil.isNullOrEmpty(goods.getCouponInfo()) && v2 != null
|
| | | && !StringUtil.isNullOrEmpty(v2.getCouponLink())) {
|
| | | try {
|
| | | long time = System.currentTimeMillis();
|
| | | // 券在有效期内并且还有剩余券
|
| | | if (time >= TimeUtil.convertToTimeTemp(v2.getCouponStartTime(), "yyyy-MM-dd HH:mm:ss")
|
| | | && time <= TimeUtil.convertToTimeTemp(v2.getCouponEndTime(), "yyyy-MM-dd HH:mm:ss")
|
| | | && (v2.getCouponTotalNum() - v2.getCouponReceiveNum()) > 0) {
|
| | | goods.setCouponStartFee(v2.getOriginalPrice());
|
| | |
|
| | | goods.setCouponEffectiveEndTime(TimeUtil.getGernalTime(
|
| | | TimeUtil.convertToTimeTemp(v2.getCouponEndTime(), "yyyy-MM-dd HH:mm:ss"),
|
| | | "yyyy-MM-dd"));
|
| | | goods.setCouponEffectiveStartTime(TimeUtil.getGernalTime(
|
| | | TimeUtil.convertToTimeTemp(v2.getCouponStartTime(), "yyyy-MM-dd HH:mm:ss"),
|
| | | "yyyy-MM-dd"));
|
| | |
|
| | | goods.setCouponAmount(v2.getCouponPrice());
|
| | | goods.setCouponInfo(
|
| | | String.format("满%s元减%s元", v2.getOriginalPrice() + "", v2.getCouponPrice() + ""));
|
| | | goods.setCouponLeftCount(v2.getCouponTotalNum() - v2.getCouponReceiveNum());
|
| | | goods.setCouponLink(v2.getCouponLink());
|
| | | goods.setCouponTotalCount(v2.getCouponTotalNum());
|
| | | goods.setShopCoupon(true);
|
| | | goods.setZkPrice(v2.getOriginalPrice());
|
| | | }
|
| | |
|
| | | } catch (Exception e) {
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | return goods;
|
| | | }
|
| | |
|
| | | public static TaoBaoGoodsBrief filterTaoBaoGoods(TaoBaoGoodsBrief goods, DaTaoKeDetailV2 v2) {
|
| | | return filterTaoBaoGoods(goods, v2, false);
|
| | | }
|
| | |
|
| | | public static DaTaoKeDetailV2 filterDaTaoKe(TaoBaoGoodsBrief goods, DaTaoKeDetailV2 detail) {
|
| | | if (goods != null) {
|
| | | BigDecimal price = TaoBaoUtil.getAfterUseCouplePrice(goods);
|
| | |
| | | TaoBaoGoodsBrief taoBaoGoods = new TaoBaoGoodsBrief();
|
| | | taoBaoGoods.setAuctionId(detail.getGoodsId());
|
| | | taoBaoGoods.setBiz30day(detail.getMonthSales());
|
| | | // 券相关转换
|
| | | taoBaoGoods.setCouponAmount(detail.getCouponPrice());
|
| | | taoBaoGoods.setCouponInfo(String.format("满%s元减%s元", detail.getCouponConditions(),
|
| | | taoBaoGoods.setCouponInfo(String.format("满%s元减%s元", detail.getOriginalPrice(),
|
| | | MoneyBigDecimalUtil.getWithNoZera(detail.getCouponPrice())));
|
| | | if (detail.getCouponTotalNum() != null && detail.getCouponReceiveNum() != null)
|
| | | taoBaoGoods.setCouponLeftCount(detail.getCouponTotalNum() - detail.getCouponReceiveNum());
|
| | | else
|
| | | taoBaoGoods.setCouponLeftCount(0);
|
| | | taoBaoGoods.setCouponStartFee(detail.getOriginalPrice());
|
| | | try {
|
| | | taoBaoGoods.setCouponStartFee(detail.getOriginalPrice());
|
| | | } catch (Exception e) {
|
| | | }
|
| | |
|
| | | taoBaoGoods.setCouponTotalCount(detail.getCouponTotalNum());
|
| | | taoBaoGoods.setCouponLink(detail.getCouponLink());
|
| | | taoBaoGoods.setCouponEffectiveStartTime(TimeUtil.getGernalTime(
|
| | | TimeUtil.convertToTimeTemp(detail.getCouponStartTime(), "yyyy-MM-dd HH:mm:ss"), "yyyy-MM-dd"));
|
| | | taoBaoGoods.setCouponEffectiveEndTime(TimeUtil.getGernalTime(
|
| | | TimeUtil.convertToTimeTemp(detail.getCouponEndTime(), "yyyy-MM-dd HH:mm:ss"), "yyyy-MM-dd"));
|
| | |
|
| | | taoBaoGoods.setPictUrl(detail.getMainPic());
|
| | | taoBaoGoods.setPictUrlWhite(detail.getMainPic());
|
| | | if (taoBaoGoods.getPictUrl() != null && !taoBaoGoods.getPictUrl().startsWith("http"))
|
| | |
| | |
|
| | | return goodsList;
|
| | | }
|
| | |
|
| | | public static List<TaoBaoGoodsBrief> getCouponListByItemId(Long auctionId) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.itemid.coupon.get");
|
| | | map.put("platform", auctionId + "");
|
| | | map.put("num_iids", auctionId + "");
|
| | | map.put("pid", TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT);
|
| | |
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | JSONObject resultJSON = null;
|
| | | try {
|
| | | resultJSON = TaoKeBaseUtil.baseRequest(map, new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY,
|
| | | TaoBaoConstant.TAOBAO_AUTH_APPSECRET, TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT));
|
| | |
|
| | | JSONObject response = resultJSON.optJSONObject("tbk_dg_optimus_material_response");
|
| | | if (response != null && response.optJSONObject("result_list") != null) {
|
| | | JSONArray array = response.optJSONObject("result_list").optJSONArray("map_data");
|
| | | if (array != null) {
|
| | |
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | JSONObject item = array.optJSONObject(i);
|
| | | TaoBaoGoodsBrief goods = parseWuLiaoItemFromMaterialId(item);
|
| | | if (goods != null)
|
| | | goodsList.add(goods);
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | return goodsList;
|
| | | }
|
| | | }
|
| | |
|
| | | class QuanInfo {
|