| | |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoShop;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoShopInfo;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | |
| | | import com.yeshi.fanli.service.inter.order.OrderService;
|
| | | import com.yeshi.fanli.service.inter.order.ShareGoodsActivityOrderService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.user.ShamUserService;
|
| | | import com.yeshi.fanli.service.inter.user.TBPidService;
|
| | |
| | | import com.yeshi.fanli.util.taobao.TaoBaoCouponUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
|
| | | import com.yeshi.fanli.vo.user.UserSettingsVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | |
| | | @Controller
|
| | | @RequestMapping("api/v1/user")
|
| | | public class RecommendController {
|
| | |
|
| | |
|
| | | @Resource
|
| | | private BusinessSystemService businessSystemService;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | |
|
| | | @Resource
|
| | | private TaoBaoCouponService taoBaoCouponService;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private QualityFlashSaleService qualityFlashSaleService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoShopService taoBaoShopService;
|
| | |
|
| | | @RequestMapping(value = "getHonestList")
|
| | | public void getHonestList(AcceptData acceptData, PrintWriter out) {
|
| | |
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 新版推荐专题管理(1.5.3)
|
| | | *
|
| | |
| | | @RequestMapping(value = "getRecommendIndex")
|
| | | public void getRecommendIndex(AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | try {
|
| | | // 1、专题模块
|
| | | // 1、专题模块
|
| | | JSONObject root = specialService.listCacheSpecialToIndex(acceptData);
|
| | |
|
| | | // 2、顶部轮播图
|
| | |
| | | topPicList = new ArrayList<SwiperPicture>();
|
| | | }
|
| | | root.put("topPicList", JsonUtil.getApiCommonGson().toJson(topPicList));
|
| | | |
| | | |
| | |
|
| | | // 3、邀请有奖
|
| | | List<SwiperPicture> invitePicList = null;
|
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())
|
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) {
|
| | | // 如果IOS当前版本处于审核状态就不返回
|
| | | } else {
|
| | | invitePicList = getSwiperByCard("index_invite"); |
| | | invitePicList = getSwiperByCard("index_invite");
|
| | | }
|
| | | |
| | |
|
| | | if (invitePicList == null) {
|
| | | invitePicList = new ArrayList<SwiperPicture>();
|
| | | } |
| | | }
|
| | | root.put("invitePicList", JsonUtil.getApiCommonGson().toJson(invitePicList));
|
| | | |
| | | |
| | |
|
| | | // 4、IOS的底部网页链接
|
| | | String platform = acceptData.getPlatform();
|
| | | if ("ios".equalsIgnoreCase(platform)) {
|
| | | root.put("htmlLink", configService.get("index_html_link_ios"));
|
| | | } |
| | | }
|
| | |
|
| | | root.put("spikeGoods", getSpikeGoodsContent(acceptData));
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "获取数据失败"));
|
| | |
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | } |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 邀请有奖是否需要返回
|
| | | * |
| | | * @param uid
|
| | | * @param acceptData
|
| | | * @return
|
| | | */
|
| | | public List<SwiperPicture> getInvitePicList(Long uid, AcceptData acceptData) {
|
| | | public List<SwiperPicture> getInvitePicList(Long uid, AcceptData acceptData) {
|
| | | // 如果IOS当前版本处于审核状态就不返回
|
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())
|
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) {
|
| | | return null;
|
| | | } |
| | | |
| | | List<SwiperPicture> invitePicList = getSwiperByCard("index_invite"); |
| | | |
| | | |
| | | |
| | | }
|
| | |
|
| | | List<SwiperPicture> invitePicList = getSwiperByCard("index_invite");
|
| | |
|
| | | return invitePicList;
|
| | | }
|
| | | |
| | | |
| | | public List<SwiperPicture> getSwiperByCard(String card){
|
| | |
|
| | | public List<SwiperPicture> getSwiperByCard(String card) {
|
| | | List<SwiperPicture> swiperList = null;
|
| | | try {
|
| | | swiperList = swiperPictureService.getByBannerCard(card);
|
| | |
| | | }
|
| | | return swiperList;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | private JSONObject getSpikeGoodsContent(AcceptData acceptData) {
|
| | | // 下一次倒计时的时间
|
| | | int type = qualityFlashSaleService.getNowType() + 1;
|
| | | int hour = 0;
|
| | | switch (type) {
|
| | | case 1:
|
| | | hour = 0;
|
| | | break;
|
| | | case 2:
|
| | | hour = 9;
|
| | | break;
|
| | | case 3:
|
| | | hour = 12;
|
| | | break;
|
| | | case 4:
|
| | | hour = 14;
|
| | | break;
|
| | | case 5:
|
| | | hour = 16;
|
| | | break;
|
| | | case 6:
|
| | | hour = 20;
|
| | | break;
|
| | | case 7:
|
| | | hour = 22;
|
| | | break;
|
| | | default:
|
| | | break;
|
| | | }
|
| | |
|
| | | Calendar nextTime = Calendar.getInstance();
|
| | | nextTime.set(Calendar.HOUR_OF_DAY, hour);
|
| | | nextTime.set(Calendar.MINUTE, 0);
|
| | | nextTime.set(Calendar.SECOND, 0);
|
| | | nextTime.set(Calendar.MILLISECOND, 0);
|
| | |
|
| | | JSONArray array = null;
|
| | | String timekey = "spikeGoods_hour";
|
| | | String cachekey = "spikeGoodsList";
|
| | |
|
| | | String timeValue = redisManager.getCommonString(timekey);
|
| | | if (timeValue == null || !timeValue.equals(hour + "")) {
|
| | | redisManager.cacheCommonString(timekey, hour + "", 60 * 30);
|
| | | } else {
|
| | | String cacheValue = redisManager.getCommonString(cachekey);
|
| | | if (!StringUtil.isNullOrEmpty(cacheValue)) {
|
| | | array = JSONArray.fromObject(cacheValue);
|
| | | }
|
| | | }
|
| | |
|
| | | if (array == null) {
|
| | | array = new JSONArray();
|
| | |
|
| | | BigDecimal proportion = manageService.getFanLiRate();
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | | // 缓存中不存在
|
| | | List<QualityFactory> listGoods = qualityGoodsService.listFlashSaleRandGoods();
|
| | | if (listGoods == null) {
|
| | | listGoods = new ArrayList<QualityFactory>();
|
| | | }
|
| | |
|
| | | /* 遍历列表数据 */
|
| | | for (QualityFactory qualityFactory : listGoods) {
|
| | |
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = qualityFactory.getTaoBaoGoodsBrief();
|
| | | if (taoBaoGoodsBrief == null) {
|
| | | continue;
|
| | | }
|
| | | array.add(gson
|
| | | .toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
|
| | | }
|
| | |
|
| | | // 缓存半个小时
|
| | | 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;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 限时秒杀 1.5.3
|
| | | *
|
| | |
| | | */
|
| | | @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");
|
| | |
|
| | | // 下一次倒计时的时间
|
| | | int type = qualityFlashSaleService.getNowType() + 1;
|
| | | int hour = 0;
|
| | | switch(type) {
|
| | | case 1:
|
| | | hour = 0;
|
| | | break;
|
| | | case 2:
|
| | | hour = 9;
|
| | | break;
|
| | | case 3:
|
| | | hour = 12;
|
| | | break;
|
| | | case 4:
|
| | | hour = 14;
|
| | | break;
|
| | | case 5:
|
| | | hour = 16;
|
| | | break;
|
| | | case 6:
|
| | | hour = 20;
|
| | | break;
|
| | | case 7:
|
| | | hour = 22;
|
| | | break;
|
| | | default:
|
| | | break;
|
| | | }
|
| | | |
| | | Calendar nextTime = Calendar.getInstance();
|
| | | nextTime.set(Calendar.HOUR_OF_DAY, hour);
|
| | | nextTime.set(Calendar.MINUTE, 0);
|
| | | nextTime.set(Calendar.SECOND, 0);
|
| | | nextTime.set(Calendar.MILLISECOND, 0);
|
| | | |
| | | |
| | | JSONArray array = null;
|
| | | String timekey = "spikeGoods_hour";
|
| | | String cachekey = "spikeGoodsList";
|
| | | |
| | | String timeValue = redisManager.getCommonString(timekey);
|
| | | if (timeValue == null || !timeValue.equals(hour+"")) {
|
| | | redisManager.cacheCommonString(timekey, hour+"", 60 * 30);
|
| | | } else {
|
| | | String cacheValue = redisManager.getCommonString(cachekey);
|
| | | if (!StringUtil.isNullOrEmpty(cacheValue)) {
|
| | | array = JSONArray.fromObject(cacheValue);
|
| | | }
|
| | | }
|
| | | |
| | | if (array == null) {
|
| | | array = new JSONArray();
|
| | | |
| | | BigDecimal proportion = manageService.getFanLiRate();
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | | |
| | | // 缓存中不存在
|
| | | List<QualityFactory> listGoods = qualityGoodsService.listFlashSaleRandGoods();
|
| | | if (listGoods == null) {
|
| | | listGoods = new ArrayList<QualityFactory>();
|
| | | }
|
| | | |
| | | /* 遍历列表数据 */
|
| | | for (QualityFactory qualityFactory : listGoods) {
|
| | | |
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = qualityFactory.getTaoBaoGoodsBrief();
|
| | | if (taoBaoGoodsBrief == null) {
|
| | | continue;
|
| | | }
|
| | | array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)));
|
| | | }
|
| | | |
| | | // 缓存半个小时
|
| | | redisManager.cacheCommonString(cachekey, array.toString(), 60 * 30);
|
| | | }
|
| | | |
| | | JSONObject root = new JSONObject();
|
| | | root.put("time", nextTime.getTimeInMillis());
|
| | | root.put("listgoods", array);
|
| | | JSONObject root = getSpikeGoodsContent(acceptData);
|
| | | root.put("params", params);
|
| | | root.put("jumpDetail", jumpDetail);
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 商品基本详情 (1.4.0)
|
| | | *
|
| | |
| | | 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);
|
| | |
| | | }
|
| | | goodsJson.put("hongBao", hongBao);
|
| | |
|
| | | List<ClientTextStyleVO> labels = new ArrayList<>();
|
| | | labels.add(new ClientTextStyleVO("标签内容", "#F14242"));
|
| | | labels.add(new ClientTextStyleVO("标签内容", "#00FF00"));
|
| | | goodsJson.put("labels", labels);
|
| | |
|
| | | data.put("tbPidInfo", clientTBPid);
|
| | |
|
| | | String jumpUrl = "https://item.taobao.com/item.htm?id=" + tb.getAuctionId();
|
| | |
| | | }
|
| | | }
|
| | | // 店铺
|
| | | goodsJson.put("shopInfo", tbShopInfo);
|
| | | if (("android".equalsIgnoreCase(acceptData.getPlatform()) && Integer.parseInt(acceptData.getVersion()) >= 40)
|
| | | || ("ios".equalsIgnoreCase(acceptData.getPlatform())
|
| | | && Integer.parseInt(acceptData.getVersion()) >= 49)) {
|
| | | TaoBaoShop shop = taoBaoShopService.getTaoBaoShop(goods.getAuctionId(), goods.getSellerId());
|
| | | if (shop != null)
|
| | | goodsJson.put("shopInfo", shop);
|
| | | } else {
|
| | | goodsJson.put("shopInfo", tbShopInfo);
|
| | | }
|
| | |
|
| | | goodsJson.put("fanliValid",Math.random()>0.5? true:false);// 是否有返利
|
| | |
|
| | | // 分享路径
|
| | | String shareUrl = String.format("%s?id=" + tb.getAuctionId(), Constant.systemCommonConfig.getAppShareInfoUrl());
|