| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.yeshi.fanli.entity.SystemPIDInfo; |
| | | import com.yeshi.fanli.entity.config.SystemConfigKeyEnum; |
| | | import com.yeshi.fanli.service.manger.PIDManager; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | |
| | | @RequestMapping("api/v1/user") |
| | | public class RecommendController { |
| | | |
| | | @Resource |
| | | private BusinessSystemService businessSystemService; |
| | | @Resource |
| | | private BusinessSystemService businessSystemService; |
| | | |
| | | @Resource |
| | | private SuperRecommendBannerService superRecommendBannerService; |
| | | @Resource |
| | | private SuperRecommendBannerService superRecommendBannerService; |
| | | |
| | | @Resource |
| | | private SuperRecommendSpecialService superRecommendSpecialService; |
| | | @Resource |
| | | private SuperRecommendSpecialService superRecommendSpecialService; |
| | | |
| | | @Resource |
| | | private OrderService orderService; |
| | | @Resource |
| | | private OrderService orderService; |
| | | |
| | | @Resource |
| | | private ScanHistoryV2Service scanHistoryV2Service; |
| | | @Resource |
| | | private ScanHistoryV2Service scanHistoryV2Service; |
| | | |
| | | @Resource |
| | | private ConfigService configService; |
| | | @Resource |
| | | private ConfigService configService; |
| | | |
| | | @Resource |
| | | private HongBaoManageService hongBaoManageService; |
| | | @Resource |
| | | private HongBaoManageService hongBaoManageService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private TaoBaoCouponService taoBaoCouponService; |
| | | @Resource |
| | | private TaoBaoCouponService taoBaoCouponService; |
| | | |
| | | @Resource |
| | | private JumpDetailService jumpDetailService; |
| | | @Resource |
| | | private JumpDetailService jumpDetailService; |
| | | |
| | | @Resource |
| | | private SystemConfigService systemConfigService; |
| | | @Resource |
| | | private SystemConfigService systemConfigService; |
| | | |
| | | @Resource |
| | | private CollectionGoodsV2Service collectionGoodsV2Service; |
| | | @Resource |
| | | private CollectionGoodsV2Service collectionGoodsV2Service; |
| | | |
| | | @Resource |
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService; |
| | | @Resource |
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService; |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @Resource |
| | | private TBPidService tbPidService; |
| | | @Resource |
| | | private TBPidService tbPidService; |
| | | |
| | | @Resource |
| | | private SystemClientParamsService systemClientParamsService; |
| | | @Resource |
| | | private SystemClientParamsService systemClientParamsService; |
| | | |
| | | @Resource |
| | | private HongBaoManageService manageService; |
| | | @Resource |
| | | private HongBaoManageService manageService; |
| | | |
| | | @Resource |
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService; |
| | | @Resource |
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService; |
| | | |
| | | @Resource |
| | | private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService; |
| | | @Resource |
| | | private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService; |
| | | |
| | | @Resource |
| | | private QualityGoodsService qualityGoodsService; |
| | | @Resource |
| | | private QualityGoodsService qualityGoodsService; |
| | | |
| | | @Resource |
| | | private SuperSpecialService superSpecialService; |
| | | @Resource |
| | | private SuperSpecialService superSpecialService; |
| | | |
| | | @Resource |
| | | private SuperRecommendBannerV2Service superRecommendBannerV2Service; |
| | | @Resource |
| | | private SuperRecommendBannerV2Service superRecommendBannerV2Service; |
| | | |
| | | @Resource |
| | | private ShamUserService shamUserService; |
| | | @Resource |
| | | private ShamUserService shamUserService; |
| | | |
| | | @Resource |
| | | private SpecialService specialService; |
| | | @Resource |
| | | private SpecialService specialService; |
| | | |
| | | @Resource |
| | | private SwiperPictureService swiperPictureService; |
| | | @Resource |
| | | private SwiperPictureService swiperPictureService; |
| | | |
| | | @Resource |
| | | private MonitorService monitorService; |
| | | @Resource |
| | | private MonitorService monitorService; |
| | | |
| | | @Resource |
| | | private CommonGoodsService commonGoodsService; |
| | | @Resource |
| | | private CommonGoodsService commonGoodsService; |
| | | |
| | | @Resource |
| | | private UserGoodsStorageService userGoodsStorageService; |
| | | @Resource |
| | | private UserGoodsStorageService userGoodsStorageService; |
| | | |
| | | @Resource |
| | | private JumpDetailV2Service jumpDetailV2Service; |
| | | @Resource |
| | | private JumpDetailV2Service jumpDetailV2Service; |
| | | |
| | | @Resource |
| | | private UserCustomSettingsService userCustomSettingsService; |
| | | @Resource |
| | | private UserCustomSettingsService userCustomSettingsService; |
| | | |
| | | @Resource |
| | | private ShareGoodsActivityOrderService shareGoodsActivityOrderService; |
| | | @Resource |
| | | private ShareGoodsActivityOrderService shareGoodsActivityOrderService; |
| | | |
| | | @Resource |
| | | private UserInfoExtraService userInfoExtraService; |
| | | @Resource |
| | | private UserInfoExtraService userInfoExtraService; |
| | | |
| | | @Resource |
| | | private QualityFlashSaleService qualityFlashSaleService; |
| | | @Resource |
| | | private QualityFlashSaleService qualityFlashSaleService; |
| | | |
| | | @Resource |
| | | private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil; |
| | | @Resource |
| | | private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil; |
| | | |
| | | @Resource |
| | | private TaoBaoShopService taoBaoShopService; |
| | | @Resource |
| | | private TaoBaoShopService taoBaoShopService; |
| | | |
| | | @Resource |
| | | private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service; |
| | | @Resource |
| | | private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service; |
| | | |
| | | @Resource |
| | | private UserMoneyExtraService userMoneyExtraService; |
| | | @Resource |
| | | private UserMoneyExtraService userMoneyExtraService; |
| | | |
| | | @Resource |
| | | private UserTaoLiJinOriginService userTaoLiJinOriginService; |
| | | @Resource |
| | | private UserTaoLiJinOriginService userTaoLiJinOriginService; |
| | | |
| | | @Resource |
| | | private ConfigTaoLiJinService configTaoLiJinService; |
| | | @Resource |
| | | private ConfigTaoLiJinService configTaoLiJinService; |
| | | |
| | | @Resource |
| | | private DeviceSexService deviceSexService; |
| | | @Resource |
| | | private DeviceSexService deviceSexService; |
| | | |
| | | @Resource |
| | | private UserTaoLiJinRecordService userTaoLiJinRecordService; |
| | | @Resource |
| | | private UserTaoLiJinRecordService userTaoLiJinRecordService; |
| | | |
| | | @Resource |
| | | private RecommendGoodsDeleteHistoryService recommendGoodsDeleteHistoryService; |
| | | @Resource |
| | | private RecommendGoodsDeleteHistoryService recommendGoodsDeleteHistoryService; |
| | | |
| | | @Resource |
| | | private HomeRecommendGoodsService homeRecommendGoodsService; |
| | | @Resource |
| | | private HomeRecommendGoodsService homeRecommendGoodsService; |
| | | |
| | | @Resource |
| | | private TLJBuyGoodsService tljBuyGoodsService; |
| | | @Resource |
| | | private TLJBuyGoodsService tljBuyGoodsService; |
| | | |
| | | @RequestMapping(value = "getHonestList") |
| | | public void getHonestList(AcceptData acceptData, PrintWriter out) { |
| | | List<Honest> honestList = null; |
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID); |
| | | if ((Integer.parseInt(acceptData.getVersion()) >= 20 && "android".equalsIgnoreCase(acceptData.getPlatform())) |
| | | || ("ios".equalsIgnoreCase(acceptData.getPlatform()) |
| | | && Integer.parseInt(acceptData.getVersion()) >= 32))// Android |
| | | // 大于20的版本和ios大于31的版本返回新的内容 |
| | | { |
| | | honestList = new ArrayList<>(); |
| | | JumpDetail detail = new JumpDetail(); |
| | | detail.setActivity(String.format("%s.ui.invite.ShareBrowserActivity", |
| | | Constant.systemCommonConfig.getAndroidBaseactivityName())); |
| | | detail.setName("网页"); |
| | | detail.setController("ShonpingShareViewController"); |
| | | @Resource |
| | | private PIDManager pidManager; |
| | | |
| | | Honest honest = new Honest(); |
| | | honest.setName("9.9包邮"); |
| | | honest.setJumpDetail(detail); |
| | | JSONObject params = new JSONObject(); |
| | | params.put("url", "http://cdn.apph5.yeshitv.com/special/jingXuanN_9.html?type=9_9"); |
| | | honest.setParams(params.toString()); |
| | | honest.setPicture("http://ec-1255749512.file.myqcloud.com/resource/special/9k9.jpg"); |
| | | honest.setType(1); /* 1:9块9 2:19块9 3:特价好货 4:分享有礼 */ |
| | | honestList.add(honest); |
| | | |
| | | honest = new Honest(); |
| | | honest.setName("今日新品"); |
| | | honest.setJumpDetail(detail); |
| | | params = new JSONObject(); |
| | | params.put("url", "http://cdn.apph5.yeshitv.com/special/todayNew.html"); |
| | | honest.setParams(params.toString()); |
| | | honest.setPicture( |
| | | "http://ec-1255749512.file.myqcloud.com/resource/special/%E4%BB%8A%E6%97%A5%E6%96%B0%E5%93%81.jpg"); |
| | | honest.setType(1); |
| | | honestList.add(honest); |
| | | @RequestMapping(value = "getHonestList") |
| | | public void getHonestList(AcceptData acceptData, PrintWriter out) { |
| | | List<Honest> honestList = null; |
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID); |
| | | if ((Integer.parseInt(acceptData.getVersion()) >= 20 && "android".equalsIgnoreCase(acceptData.getPlatform())) |
| | | || ("ios".equalsIgnoreCase(acceptData.getPlatform()) |
| | | && Integer.parseInt(acceptData.getVersion()) >= 32))// Android |
| | | // 大于20的版本和ios大于31的版本返回新的内容 |
| | | { |
| | | honestList = new ArrayList<>(); |
| | | JumpDetail detail = new JumpDetail(); |
| | | detail.setActivity(String.format("%s.ui.invite.ShareBrowserActivity", |
| | | systemConfigService.getValueCache(SystemConfigKeyEnum.androidBaseActivityName,acceptData.getSystem()))); |
| | | detail.setName("网页"); |
| | | detail.setController("ShonpingShareViewController"); |
| | | |
| | | honest = new Honest(); |
| | | honest.setName("大额券"); |
| | | honest.setJumpDetail(detail); |
| | | params = new JSONObject(); |
| | | params.put("url", "http://cdn.apph5.yeshitv.com/special/daEQuan.html"); |
| | | honest.setParams(params.toString()); |
| | | honest.setPicture( |
| | | "http://ec-1255749512.file.myqcloud.com/resource/special/%E5%A4%A7%E9%A2%9D%E5%88%B8.jpg"); |
| | | honest.setType(1); |
| | | honestList.add(honest); |
| | | Honest honest = new Honest(); |
| | | honest.setName("9.9包邮"); |
| | | honest.setJumpDetail(detail); |
| | | JSONObject params = new JSONObject(); |
| | | params.put("url", "http://cdn.apph5.yeshitv.com/special/jingXuanN_9.html?type=9_9"); |
| | | honest.setParams(params.toString()); |
| | | honest.setPicture("http://ec-1255749512.file.myqcloud.com/resource/special/9k9.jpg"); |
| | | honest.setType(1); /* 1:9块9 2:19块9 3:特价好货 4:分享有礼 */ |
| | | honestList.add(honest); |
| | | |
| | | honest = new Honest(); |
| | | honest.setName("超高返"); |
| | | honest.setJumpDetail(detail); |
| | | params = new JSONObject(); |
| | | params.put("url", "http://cdn.apph5.yeshitv.com/special/chaoGaoJiangJin.html"); |
| | | honest.setParams(params.toString()); |
| | | honest.setPicture( |
| | | "http://ec-1255749512.file.myqcloud.com/resource/special/%E8%B6%85%E9%AB%98%E8%BF%94.jpg"); |
| | | honest.setType(1); |
| | | honestList.add(honest); |
| | | honest = new Honest(); |
| | | honest.setName("今日新品"); |
| | | honest.setJumpDetail(detail); |
| | | params = new JSONObject(); |
| | | params.put("url", "http://cdn.apph5.yeshitv.com/special/todayNew.html"); |
| | | honest.setParams(params.toString()); |
| | | honest.setPicture( |
| | | "http://ec-1255749512.file.myqcloud.com/resource/special/%E4%BB%8A%E6%97%A5%E6%96%B0%E5%93%81.jpg"); |
| | | honest.setType(1); |
| | | honestList.add(honest); |
| | | |
| | | if (Constant.IS_TEST) { |
| | | honest = new Honest(); |
| | | honest.setName("超高返"); |
| | | honest.setJumpDetail(detail); |
| | | params = new JSONObject(); |
| | | params.put("url", "http://cdn.apph5.yeshitv.com/special/chaoGaoJiangJin.html"); |
| | | honest.setParams(params.toString()); |
| | | honest.setPicture( |
| | | "http://ec-1255749512.file.myqcloud.com/resource/special/%E8%B6%85%E9%AB%98%E8%BF%94.jpg"); |
| | | honest.setType(1); |
| | | honestList.add(honest); |
| | | } |
| | | honest = new Honest(); |
| | | honest.setName("大额券"); |
| | | honest.setJumpDetail(detail); |
| | | params = new JSONObject(); |
| | | params.put("url", "http://cdn.apph5.yeshitv.com/special/daEQuan.html"); |
| | | honest.setParams(params.toString()); |
| | | honest.setPicture( |
| | | "http://ec-1255749512.file.myqcloud.com/resource/special/%E5%A4%A7%E9%A2%9D%E5%88%B8.jpg"); |
| | | honest.setType(1); |
| | | honestList.add(honest); |
| | | |
| | | // if (acceptData.getPlatform().equalsIgnoreCase("ios") |
| | | // && |
| | | // configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) |
| | | // { |
| | | // honest = new Honest(); |
| | | // honest.setName("今日必抢"); |
| | | // honest.setJumpDetail(detail); |
| | | // params = new JSONObject(); |
| | | // params.put("url", |
| | | // "https://pages.tmall.com/wow/a/act/20051/upr?spm=a219t.7664554.1998457203.704.2ae335d9FKajS5&wh_pid=industry-151736&wh_weex=true&wh_biz=tm"); |
| | | // honest.setParams(params.toString()); |
| | | // honest.setPicture("http://ec-1255749512.file.myqcloud.com/resource/jrbq.png"); |
| | | // honest.setType(1); |
| | | // honestList.add(honest); |
| | | // } else { |
| | | // honest = new Honest(); |
| | | // honest.setType(4); |
| | | // honest.setName("邀请有奖"); |
| | | // honest.setJumpDetail(null); |
| | | // honest.setPicture( |
| | | // "http://ec-1255749512.file.myqcloud.com/resource/%E9%82%80%E8%AF%B7%E6%9C%89%E5%A5%96.png"); |
| | | // honestList.add(honest); |
| | | // } |
| | | } else { |
| | | honestList = new ArrayList<>(); |
| | | JumpDetail detail = new JumpDetail(); |
| | | detail.setActivity( |
| | | String.format("%s.ui.BrowserActivity", Constant.systemCommonConfig.getAndroidBaseactivityName())); |
| | | detail.setName("网页"); |
| | | // GoodsDetailController |
| | | detail.setController("BrowserController"); |
| | | honest = new Honest(); |
| | | honest.setName("超高返"); |
| | | honest.setJumpDetail(detail); |
| | | params = new JSONObject(); |
| | | params.put("url", "http://cdn.apph5.yeshitv.com/special/chaoGaoJiangJin.html"); |
| | | honest.setParams(params.toString()); |
| | | honest.setPicture( |
| | | "http://ec-1255749512.file.myqcloud.com/resource/special/%E8%B6%85%E9%AB%98%E8%BF%94.jpg"); |
| | | honest.setType(1); |
| | | honestList.add(honest); |
| | | |
| | | Honest honest = new Honest(); |
| | | honest.setName("9块9"); |
| | | honest.setJumpDetail(detail); |
| | | JSONObject params = new JSONObject(); |
| | | params.put("url", "https://temai.m.taobao.com/9k9?pid=" + configList.get(0).getDefaultPid()); |
| | | honest.setParams(params.toString()); |
| | | honest.setPicture("http://ec-1255749512.file.myqcloud.com/resource/9.9.png"); |
| | | honest.setType(1); /* 1:9块9 2:19块9 3:特价好货 4:分享有礼 */ |
| | | honestList.add(honest); |
| | | if (Constant.IS_TEST) { |
| | | honest = new Honest(); |
| | | honest.setName("超高返"); |
| | | honest.setJumpDetail(detail); |
| | | params = new JSONObject(); |
| | | params.put("url", "http://cdn.apph5.yeshitv.com/special/chaoGaoJiangJin.html"); |
| | | honest.setParams(params.toString()); |
| | | honest.setPicture( |
| | | "http://ec-1255749512.file.myqcloud.com/resource/special/%E8%B6%85%E9%AB%98%E8%BF%94.jpg"); |
| | | honest.setType(1); |
| | | honestList.add(honest); |
| | | } |
| | | |
| | | honest = new Honest(); |
| | | honest.setName("淘宝特卖"); |
| | | honest.setJumpDetail(detail); |
| | | params = new JSONObject(); |
| | | params.put("url", "https://temai.m.taobao.com/index.htm?pid=" + configList.get(0).getDefaultPid()); |
| | | honest.setParams(params.toString()); |
| | | honest.setPicture( |
| | | "http://ec-1255749512.file.myqcloud.com/resource/%E7%89%B9%E4%BB%B7%E5%A5%BD%E8%B4%A7.png"); |
| | | honest.setType(1); |
| | | honestList.add(honest); |
| | | // if (acceptData.getPlatform().equalsIgnoreCase("ios") |
| | | // && |
| | | // configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) |
| | | // { |
| | | // honest = new Honest(); |
| | | // honest.setName("今日必抢"); |
| | | // honest.setJumpDetail(detail); |
| | | // params = new JSONObject(); |
| | | // params.put("url", |
| | | // "https://pages.tmall.com/wow/a/act/20051/upr?spm=a219t.7664554.1998457203.704.2ae335d9FKajS5&wh_pid=industry-151736&wh_weex=true&wh_biz=tm"); |
| | | // honest.setParams(params.toString()); |
| | | // honest.setPicture("http://ec-1255749512.file.myqcloud.com/resource/jrbq.png"); |
| | | // honest.setType(1); |
| | | // honestList.add(honest); |
| | | // } else { |
| | | // honest = new Honest(); |
| | | // honest.setType(4); |
| | | // honest.setName("邀请有奖"); |
| | | // honest.setJumpDetail(null); |
| | | // honest.setPicture( |
| | | // "http://ec-1255749512.file.myqcloud.com/resource/%E9%82%80%E8%AF%B7%E6%9C%89%E5%A5%96.png"); |
| | | // honestList.add(honest); |
| | | // } |
| | | } else { |
| | | honestList = new ArrayList<>(); |
| | | JumpDetail detail = new JumpDetail(); |
| | | detail.setActivity( |
| | | String.format("%s.ui.BrowserActivity", systemConfigService.getValueCache(SystemConfigKeyEnum.androidBaseActivityName,acceptData.getSystem()))); |
| | | detail.setName("网页"); |
| | | // GoodsDetailController |
| | | detail.setController("BrowserController"); |
| | | |
| | | honest = new Honest(); |
| | | honest.setName("旅游出行"); |
| | | honest.setJumpDetail(detail); |
| | | params = new JSONObject(); |
| | | params.put("url", |
| | | "https://s.click.taobao.com/t?e=m%3D2%26s%3DBYnJkWG4TG0cQipKwQzePCperVdZeJviEViQ0P1Vf2kguMN8XjClAu02u1KR7qygWNI3LssOJ1ZWrun95JZUdbCdKVyILC1Y4MhN4biK4jW7lfuQJIvfPIK88P%2FKzi0kxxWvg6Zgs%2BufKdnhu%2B44hB9qAVPM25K0cj5d26O5JTnBV7GfGbfBR06AKI8EMgZwgGJ6r9DajuEo%2Bq0qHgj4%2Fr%2BOY9SrDkfyH5S%2BAXadU8u31WUvb1IPCiGFCzYOOqAQ"); |
| | | honest.setParams(params.toString()); |
| | | honest.setPicture( |
| | | "http://ec-1255749512.file.myqcloud.com/resource/%E6%97%85%E6%B8%B8%E5%87%BA%E8%A1%8C.png"); |
| | | honest.setType(1); |
| | | honestList.add(honest); |
| | | Honest honest = new Honest(); |
| | | honest.setName("9块9"); |
| | | honest.setJumpDetail(detail); |
| | | JSONObject params = new JSONObject(); |
| | | params.put("url", "https://temai.m.taobao.com/9k9?pid=" + configList.get(0).getDefaultPid()); |
| | | honest.setParams(params.toString()); |
| | | honest.setPicture("http://ec-1255749512.file.myqcloud.com/resource/9.9.png"); |
| | | honest.setType(1); /* 1:9块9 2:19块9 3:特价好货 4:分享有礼 */ |
| | | honestList.add(honest); |
| | | |
| | | if (acceptData.getPlatform().equalsIgnoreCase("ios") |
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()),acceptData.getSystem())) { |
| | | honest = new Honest(); |
| | | honest.setName("今日必抢"); |
| | | honest.setJumpDetail(detail); |
| | | params = new JSONObject(); |
| | | params.put("url", |
| | | "https://pages.tmall.com/wow/a/act/20051/upr?spm=a219t.7664554.1998457203.704.2ae335d9FKajS5&wh_pid=industry-151736&wh_weex=true&wh_biz=tm"); |
| | | honest.setParams(params.toString()); |
| | | honest.setPicture("http://ec-1255749512.file.myqcloud.com/resource/jrbq.png"); |
| | | honest.setType(1); |
| | | honestList.add(honest); |
| | | } else { |
| | | honest = new Honest(); |
| | | honest.setType(4); |
| | | honest.setName("邀请有奖"); |
| | | honest.setJumpDetail(null); |
| | | honest.setPicture( |
| | | "http://ec-1255749512.file.myqcloud.com/resource/%E9%82%80%E8%AF%B7%E6%9C%89%E5%A5%96.png"); |
| | | honestList.add(honest); |
| | | } |
| | | honest = new Honest(); |
| | | honest.setName("淘宝特卖"); |
| | | honest.setJumpDetail(detail); |
| | | params = new JSONObject(); |
| | | params.put("url", "https://temai.m.taobao.com/index.htm?pid=" + configList.get(0).getDefaultPid()); |
| | | honest.setParams(params.toString()); |
| | | honest.setPicture( |
| | | "http://ec-1255749512.file.myqcloud.com/resource/%E7%89%B9%E4%BB%B7%E5%A5%BD%E8%B4%A7.png"); |
| | | honest.setType(1); |
| | | honestList.add(honest); |
| | | |
| | | } |
| | | String result = JsonUtil.loadTrueResult(honestList); |
| | | out.print(result); |
| | | return; |
| | | } |
| | | honest = new Honest(); |
| | | honest.setName("旅游出行"); |
| | | honest.setJumpDetail(detail); |
| | | params = new JSONObject(); |
| | | params.put("url", |
| | | "https://s.click.taobao.com/t?e=m%3D2%26s%3DBYnJkWG4TG0cQipKwQzePCperVdZeJviEViQ0P1Vf2kguMN8XjClAu02u1KR7qygWNI3LssOJ1ZWrun95JZUdbCdKVyILC1Y4MhN4biK4jW7lfuQJIvfPIK88P%2FKzi0kxxWvg6Zgs%2BufKdnhu%2B44hB9qAVPM25K0cj5d26O5JTnBV7GfGbfBR06AKI8EMgZwgGJ6r9DajuEo%2Bq0qHgj4%2Fr%2BOY9SrDkfyH5S%2BAXadU8u31WUvb1IPCiGFCzYOOqAQ"); |
| | | honest.setParams(params.toString()); |
| | | honest.setPicture( |
| | | "http://ec-1255749512.file.myqcloud.com/resource/%E6%97%85%E6%B8%B8%E5%87%BA%E8%A1%8C.png"); |
| | | honest.setType(1); |
| | | honestList.add(honest); |
| | | |
| | | @RequestMapping(value = "getrecommendspecial") |
| | | public void getRecommendSpecial(AcceptData acceptData, PrintWriter out) { |
| | | if (acceptData.getPlatform().equalsIgnoreCase("ios") |
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem())) { |
| | | honest = new Honest(); |
| | | honest.setName("今日必抢"); |
| | | honest.setJumpDetail(detail); |
| | | params = new JSONObject(); |
| | | params.put("url", |
| | | "https://pages.tmall.com/wow/a/act/20051/upr?spm=a219t.7664554.1998457203.704.2ae335d9FKajS5&wh_pid=industry-151736&wh_weex=true&wh_biz=tm"); |
| | | honest.setParams(params.toString()); |
| | | honest.setPicture("http://ec-1255749512.file.myqcloud.com/resource/jrbq.png"); |
| | | honest.setType(1); |
| | | honestList.add(honest); |
| | | } else { |
| | | honest = new Honest(); |
| | | honest.setType(4); |
| | | honest.setName("邀请有奖"); |
| | | honest.setJumpDetail(null); |
| | | honest.setPicture( |
| | | "http://ec-1255749512.file.myqcloud.com/resource/%E9%82%80%E8%AF%B7%E6%9C%89%E5%A5%96.png"); |
| | | honestList.add(honest); |
| | | } |
| | | |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(),acceptData.getSystem()); |
| | | } |
| | | String result = JsonUtil.loadTrueResult(honestList); |
| | | out.print(result); |
| | | return; |
| | | } |
| | | |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | String version = acceptData.getVersion(); |
| | | JumpDetail jumpDetail = null; |
| | | if (!"1".equals(version) && "android".equalsIgnoreCase(acceptData.getPlatform())) { |
| | | jumpDetail = jumpDetailService.getlastJumpDetailCache(); |
| | | } |
| | | List<RecommendSpecial> recommendSpecialList = null; |
| | | @RequestMapping(value = "getrecommendspecial") |
| | | public void getRecommendSpecial(AcceptData acceptData, PrintWriter out) { |
| | | |
| | | List<SuperRecommendSpecial> superRecommendSpecialList = superRecommendSpecialService |
| | | .getSuperRecommendSpecialBySystemId(system.getId()); |
| | | if (superRecommendSpecialList != null && superRecommendSpecialList.size() > 0) { |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | |
| | | recommendSpecialList = new ArrayList<RecommendSpecial>(); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | String version = acceptData.getVersion(); |
| | | JumpDetail jumpDetail = null; |
| | | if (!"1".equals(version) && "android".equalsIgnoreCase(acceptData.getPlatform())) { |
| | | jumpDetail = jumpDetailService.getlastJumpDetailCache(); |
| | | } |
| | | List<RecommendSpecial> recommendSpecialList = null; |
| | | |
| | | for (SuperRecommendSpecial superRecommendSpecial : superRecommendSpecialList) { |
| | | RecommendSpecial recommendSpecial = superRecommendSpecial.getRecommendSpecial(); |
| | | if (jumpDetail != null) { |
| | | recommendSpecial.setJumpDetail(jumpDetail); |
| | | } |
| | | recommendSpecialList.add(recommendSpecial); |
| | | } |
| | | } |
| | | List<SuperRecommendSpecial> superRecommendSpecialList = superRecommendSpecialService |
| | | .getSuperRecommendSpecialBySystemId(system.getId()); |
| | | if (superRecommendSpecialList != null && superRecommendSpecialList.size() > 0) { |
| | | |
| | | if (recommendSpecialList == null || recommendSpecialList.size() == 0) { |
| | | out.print(JsonUtil.loadFalseResult(1, "暂无数据")); |
| | | return; |
| | | } |
| | | recommendSpecialList = new ArrayList<RecommendSpecial>(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("count", recommendSpecialList.size()); |
| | | Gson gson = new Gson(); |
| | | data.put("data", gson.toJson(recommendSpecialList)); |
| | | String json = JsonUtil.loadTrueResult(data); |
| | | out.print(json); |
| | | } |
| | | for (SuperRecommendSpecial superRecommendSpecial : superRecommendSpecialList) { |
| | | RecommendSpecial recommendSpecial = superRecommendSpecial.getRecommendSpecial(); |
| | | if (jumpDetail != null) { |
| | | recommendSpecial.setJumpDetail(jumpDetail); |
| | | } |
| | | recommendSpecialList.add(recommendSpecial); |
| | | } |
| | | } |
| | | |
| | | // 猜你喜欢 |
| | | @RequestMapping(value = "guessLike", method = RequestMethod.POST) |
| | | public void guessLike(AcceptData acceptData, PrintWriter out) { |
| | | if (recommendSpecialList == null || recommendSpecialList.size() == 0) { |
| | | out.print(JsonUtil.loadFalseResult(1, "暂无数据")); |
| | | return; |
| | | } |
| | | |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(),acceptData.getSystem()); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("count", recommendSpecialList.size()); |
| | | Gson gson = new Gson(); |
| | | data.put("data", gson.toJson(recommendSpecialList)); |
| | | String json = JsonUtil.loadTrueResult(data); |
| | | out.print(json); |
| | | } |
| | | |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | List<TaoBaoGoodsBrief> taoBaoGoodsBriefs1 = taoBaoCouponService.getTaoBaoCouponList(2); |
| | | List<TaoBaoGoodsBrief> taoBaoGoodsBriefs2 = new ArrayList<>(); |
| | | taoBaoGoodsBriefs2.addAll(taoBaoGoodsBriefs1); |
| | | // 猜你喜欢 |
| | | @RequestMapping(value = "guessLike", method = RequestMethod.POST) |
| | | public void guessLike(AcceptData acceptData, PrintWriter out) { |
| | | |
| | | List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = new ArrayList<>(); |
| | | for (int i = 0; i < taoBaoGoodsBriefs2.size(); i++) { |
| | | if (taoBaoGoodsBriefs2.size() > 0 && taoBaoGoodsBriefs.size() < 6) { |
| | | int pos = (int) (Math.random() * taoBaoGoodsBriefs2.size()); |
| | | taoBaoGoodsBriefs.add(taoBaoGoodsBriefs2.get(pos)); |
| | | taoBaoGoodsBriefs2.remove(pos); |
| | | i--; |
| | | } |
| | | } |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | |
| | | BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); |
| | | JSONArray array = new JSONArray(); |
| | | TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra; |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create(); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | List<TaoBaoGoodsBrief> taoBaoGoodsBriefs1 = taoBaoCouponService.getTaoBaoCouponList(2); |
| | | List<TaoBaoGoodsBrief> taoBaoGoodsBriefs2 = new ArrayList<>(); |
| | | taoBaoGoodsBriefs2.addAll(taoBaoGoodsBriefs1); |
| | | |
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) { |
| | | taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), ""); |
| | | array.add(gson.toJson(taoBaoGoodsBriefExtra)); |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | data.put("goods", array); |
| | | data.put("count", array.size()); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = new ArrayList<>(); |
| | | for (int i = 0; i < taoBaoGoodsBriefs2.size(); i++) { |
| | | if (taoBaoGoodsBriefs2.size() > 0 && taoBaoGoodsBriefs.size() < 6) { |
| | | int pos = (int) (Math.random() * taoBaoGoodsBriefs2.size()); |
| | | taoBaoGoodsBriefs.add(taoBaoGoodsBriefs2.get(pos)); |
| | | taoBaoGoodsBriefs2.remove(pos); |
| | | i--; |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "getrecommendbanner") |
| | | public void getRecommendBanner(AcceptData acceptData, PrintWriter out) { |
| | | BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); |
| | | JSONArray array = new JSONArray(); |
| | | TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra; |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create(); |
| | | |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(),acceptData.getSystem()); |
| | | JSONObject json = new JSONObject(); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | List<SuperRecommendBanner> superRecommendBanners = superRecommendBannerService |
| | | .getSuperRecommendBannersBySystem(system); |
| | | List<RecommendBanner> list = null; |
| | | for (SuperRecommendBanner superRecommendBanner : superRecommendBanners) { |
| | | if (list == null) { |
| | | list = new ArrayList<RecommendBanner>(); |
| | | } |
| | | RecommendBanner recommendBanner = superRecommendBanner.getRecommendBanner(); |
| | | // 淘特价暂时修改 |
| | | if (system.getId() == 7) { |
| | | recommendBanner.getJumpDetail().setActivity(recommendBanner.getJumpDetail().getActivity() |
| | | .replace("com.yeshi.ec.rebate.myapplication", "com.yeshi.ec.taospecial")); |
| | | } |
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) { |
| | | taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), ""); |
| | | array.add(gson.toJson(taoBaoGoodsBriefExtra)); |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | data.put("goods", array); |
| | | data.put("count", array.size()); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | list.add(recommendBanner); |
| | | } |
| | | @RequestMapping(value = "getrecommendbanner") |
| | | public void getRecommendBanner(AcceptData acceptData, PrintWriter out) { |
| | | |
| | | // 测试 |
| | | // 添加跳转商品详情 |
| | | // RecommendBanner banner = new RecommendBanner(); |
| | | // banner.setId(1); |
| | | // JumpDetail jumpDetail = new JumpDetail(); |
| | | // jumpDetail.setActivity("com.yeshi.ec.rebate.myapplication.ui.recommend.GoodsBrowserActivity"); |
| | | // jumpDetail.setController("GoodsDetailController"); |
| | | // jumpDetail.setName("商品详情"); |
| | | // |
| | | // banner.setJumpDetail(jumpDetail); |
| | | // banner.setName("详情"); |
| | | // banner.setOrderby(1); |
| | | // JSONObject param = new JSONObject(); |
| | | // param.put("id", "568650986077"); |
| | | // banner.setParams(param.toString()); |
| | | // banner.setPicture( |
| | | // "https://gd3.alicdn.com/imgextra/i2/266969832/TB2iiKjoAyWBuNjy0FpXXassXXa_!!266969832.jpg_400x400.jpg_.webp"); |
| | | // list.add(banner); |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | JSONObject json = new JSONObject(); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | List<SuperRecommendBanner> superRecommendBanners = superRecommendBannerService |
| | | .getSuperRecommendBannersBySystem(system); |
| | | List<RecommendBanner> list = null; |
| | | for (SuperRecommendBanner superRecommendBanner : superRecommendBanners) { |
| | | if (list == null) { |
| | | list = new ArrayList<RecommendBanner>(); |
| | | } |
| | | RecommendBanner recommendBanner = superRecommendBanner.getRecommendBanner(); |
| | | // 淘特价暂时修改 |
| | | if (system.getId() == 7) { |
| | | recommendBanner.getJumpDetail().setActivity(recommendBanner.getJumpDetail().getActivity() |
| | | .replace("com.yeshi.ec.rebate.myapplication", "com.yeshi.ec.taospecial")); |
| | | } |
| | | |
| | | if (list == null) { |
| | | json.put("code", "1"); |
| | | json.put("msg", "暂无数据"); |
| | | out.print(json); |
| | | java.lang.System.out.println("json-" + json); |
| | | return; |
| | | } |
| | | json.put("code", 0); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("count", list.size()); |
| | | Gson gson = new Gson(); |
| | | data.put("data", gson.toJson(list)); |
| | | json.put("data", data); |
| | | out.print(json); |
| | | return; |
| | | } |
| | | list.add(recommendBanner); |
| | | } |
| | | |
| | | // 获取商品详情 |
| | | @RequestMapping(value = "getgoodsdetail", method = RequestMethod.POST) |
| | | public void getGoodsDetail(final AcceptData acceptData, final String id, final String uid, PrintWriter out) { |
| | | long begin = java.lang.System.currentTimeMillis(); |
| | | if (StringUtil.isNullOrEmpty(id)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请上传id")); |
| | | return; |
| | | } |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(),acceptData.getSystem()); |
| | | // 测试 |
| | | // 添加跳转商品详情 |
| | | // RecommendBanner banner = new RecommendBanner(); |
| | | // banner.setId(1); |
| | | // JumpDetail jumpDetail = new JumpDetail(); |
| | | // jumpDetail.setActivity("com.yeshi.ec.rebate.myapplication.ui.recommend.GoodsBrowserActivity"); |
| | | // jumpDetail.setController("GoodsDetailController"); |
| | | // jumpDetail.setName("商品详情"); |
| | | // |
| | | // banner.setJumpDetail(jumpDetail); |
| | | // banner.setName("详情"); |
| | | // banner.setOrderby(1); |
| | | // JSONObject param = new JSONObject(); |
| | | // param.put("id", "568650986077"); |
| | | // banner.setParams(param.toString()); |
| | | // banner.setPicture( |
| | | // "https://gd3.alicdn.com/imgextra/i2/266969832/TB2iiKjoAyWBuNjy0FpXXassXXa_!!266969832.jpg_400x400.jpg_.webp"); |
| | | // list.add(banner); |
| | | |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | if (list == null) { |
| | | json.put("code", "1"); |
| | | json.put("msg", "暂无数据"); |
| | | out.print(json); |
| | | java.lang.System.out.println("json-" + json); |
| | | return; |
| | | } |
| | | json.put("code", 0); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("count", list.size()); |
| | | Gson gson = new Gson(); |
| | | data.put("data", gson.toJson(list)); |
| | | json.put("data", data); |
| | | out.print(json); |
| | | return; |
| | | } |
| | | |
| | | // 获取会员推广位或者默认推广位 |
| | | // 获取商品详情 |
| | | @RequestMapping(value = "getgoodsdetail", method = RequestMethod.POST) |
| | | public void getGoodsDetail(final AcceptData acceptData, final String id, final String uid, PrintWriter out) { |
| | | long begin = java.lang.System.currentTimeMillis(); |
| | | if (StringUtil.isNullOrEmpty(id)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请上传id")); |
| | | return; |
| | | } |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | |
| | | TaoBaoGoodsBrief simpleGoods = null; |
| | | try { |
| | | simpleGoods = redisManager.getTaoBaoGoodsBrief(Long.parseLong(id)); |
| | | } catch (NumberFormatException e2) { |
| | | e2.printStackTrace(); |
| | | } catch (TaobaoGoodsDownException e2) { |
| | | e2.printStackTrace(); |
| | | } |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | |
| | | if (simpleGoods == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架")); |
| | | return; |
| | | } |
| | | // 获取会员推广位或者默认推广位 |
| | | |
| | | // 获取淘客参数 |
| | | ClientTBPid clientTBPid = null; |
| | | if (TaoBaoUtil.isSpecialGoods(simpleGoods.getMaterialLibType())) { |
| | | String pid = TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT; |
| | | clientTBPid = new ClientTBPid(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET, |
| | | pid.split("_")[2], pid.split("_")[3]); |
| | | } else { |
| | | if (acceptData.getPlatform().equalsIgnoreCase("android")) { |
| | | clientTBPid = tbPidService.getAndroidDefault(); |
| | | } else { |
| | | clientTBPid = tbPidService.getIOSDefault(); |
| | | } |
| | | } |
| | | TaoBaoGoodsBrief simpleGoods = null; |
| | | try { |
| | | simpleGoods = redisManager.getTaoBaoGoodsBrief(id); |
| | | } catch (NumberFormatException e2) { |
| | | e2.printStackTrace(); |
| | | } catch (TaobaoGoodsDownException e2) { |
| | | e2.printStackTrace(); |
| | | } |
| | | |
| | | TaoBaoGoodsBrief tb = null; |
| | | try { |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(clientTBPid.getSiteId()); |
| | | app.setAdzoneId(clientTBPid.getAdZoneId()); |
| | | app.setAppKey(clientTBPid.getAppKey()); |
| | | app.setAppSecret(config.getAppSecret()); |
| | | app.setPid(clientTBPid.getPid()); |
| | | tb = TaoKeApiUtil.searchGoodsDetail(Long.parseLong(id), app); |
| | | } catch (NumberFormatException e1) { |
| | | e1.printStackTrace(); |
| | | } catch (TaobaoGoodsDownException e1) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架")); |
| | | return; |
| | | } |
| | | if (simpleGoods == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架")); |
| | | return; |
| | | } |
| | | |
| | | if (tb != null) { |
| | | // tb.setAuctionUrl(null); |
| | | tb.setId(null); |
| | | int type = 0; |
| | | if ("android".equalsIgnoreCase(acceptData.getPlatform())) |
| | | type = PidUser.TYPE_FANLI_ANDROID; |
| | | else |
| | | type = PidUser.TYPE_FANLI_IOS; |
| | | // 获取淘客参数 |
| | | ClientTBPid clientTBPid = null; |
| | | if (TaoBaoUtil.isSpecialGoods(simpleGoods.getMaterialLibType())) { |
| | | String pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.fanli); |
| | | clientTBPid = new ClientTBPid(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET, |
| | | pid.split("_")[2], pid.split("_")[3]); |
| | | } else { |
| | | if (acceptData.getPlatform().equalsIgnoreCase("android")) { |
| | | clientTBPid = tbPidService.getAndroidDefault(); |
| | | } else { |
| | | clientTBPid = tbPidService.getIOSDefault(); |
| | | } |
| | | } |
| | | |
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(type); |
| | | TaoBaoGoodsBrief tb = null; |
| | | try { |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(clientTBPid.getSiteId()); |
| | | app.setAdzoneId(clientTBPid.getAdZoneId()); |
| | | app.setAppKey(clientTBPid.getAppKey()); |
| | | app.setAppSecret(config.getAppSecret()); |
| | | app.setPid(clientTBPid.getPid()); |
| | | tb = TaoKeApiUtil.searchGoodsDetail(id, app); |
| | | } catch (NumberFormatException e1) { |
| | | e1.printStackTrace(); |
| | | } catch (TaobaoGoodsDownException e1) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架")); |
| | | return; |
| | | } |
| | | |
| | | Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); |
| | | JSONObject data = new JSONObject(); |
| | | TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(tb, configList.get(0),acceptData.getSystem()); |
| | | if (!StringUtil.isNullOrEmpty(tb.getCouponLink()) && taoBaoGoodsBriefExtra.getTaoBaoQuanInfo() != null) |
| | | taoBaoGoodsBriefExtra.getTaoBaoQuanInfo().setCouponLink(tb.getCouponLink()); |
| | | taoBaoGoodsBriefExtra.setAuctionUrl(tb.getAuctionUrl()); |
| | | if (uid != null && !"".equals(uid.trim())) { |
| | | CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(Long.parseLong(uid), |
| | | Long.parseLong(id), Constant.SOURCE_TYPE_TAOBAO); |
| | | data.put("collection", collectionGoods != null ? true : false); |
| | | } |
| | | if (tb != null) { |
| | | // tb.setAuctionUrl(null); |
| | | tb.setId(null); |
| | | int type = 0; |
| | | if ("android".equalsIgnoreCase(acceptData.getPlatform())) |
| | | type = PidUser.TYPE_FANLI_ANDROID; |
| | | else |
| | | type = PidUser.TYPE_FANLI_IOS; |
| | | |
| | | data.put("tbPidInfo", clientTBPid); |
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(type); |
| | | |
| | | JSONObject taobaoJson = JSONObject.fromObject(gson.toJson(taoBaoGoodsBriefExtra)); |
| | | if (taoBaoGoodsBriefExtra.getImgList() != null) |
| | | taoBaoGoodsBriefExtra.getImgList().add(0, taoBaoGoodsBriefExtra.getPictUrl()); |
| | | taobaoJson.put("imgList", taoBaoGoodsBriefExtra.getImgList()); |
| | | taobaoJson.put("saleCount", taoBaoGoodsBriefExtra.getSalesCount());// 销量(和salesCount一致,此处处理兼容) |
| | | if (taoBaoGoodsBriefExtra.getTaoBaoQuanInfo() != null) |
| | | taobaoJson.put("coupon", true); |
| | | else |
| | | taobaoJson.put("coupon", false); |
| | | Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); |
| | | JSONObject data = new JSONObject(); |
| | | TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(tb, configList.get(0), acceptData.getSystem()); |
| | | if (!StringUtil.isNullOrEmpty(tb.getCouponLink()) && taoBaoGoodsBriefExtra.getTaoBaoQuanInfo() != null) |
| | | taoBaoGoodsBriefExtra.getTaoBaoQuanInfo().setCouponLink(tb.getCouponLink()); |
| | | taoBaoGoodsBriefExtra.setAuctionUrl(tb.getAuctionUrl()); |
| | | if (uid != null && !"".equals(uid.trim())) { |
| | | CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(Long.parseLong(uid), |
| | | id, Constant.SOURCE_TYPE_TAOBAO); |
| | | data.put("collection", collectionGoods != null ? true : false); |
| | | } |
| | | |
| | | // taoBaoGoodsBriefExtra.setAuctionUrl(null); |
| | | data.put("taobao", taobaoJson); |
| | | String info = configService.getValue(ConfigKeyEnum.detailPrompt.getKey(),acceptData.getSystem()); |
| | | data.put("info", info); |
| | | String onlyInfo = configService.getValue(ConfigKeyEnum.onlyInfo.getKey(),acceptData.getSystem()); |
| | | data.put("only", onlyInfo); |
| | | data.put("helpUrl", configService.getValue(ConfigKeyEnum.oldGoodsDetailHelpUrl.getKey(),acceptData.getSystem())); |
| | | data.put("tbPidInfo", clientTBPid); |
| | | |
| | | int showType = taoBaoGoodsBriefExtra.getShowType(); |
| | | String price = ""; |
| | | if (showType == 1 || showType == 3) { |
| | | price = taoBaoGoodsBriefExtra.getQuanPrice() + ""; |
| | | } else { |
| | | price = taoBaoGoodsBriefExtra.getZkPrice() + ""; |
| | | } |
| | | String appName = systemConfigService.get("appName", system); |
| | | data.put("sharePrice", "¥" + price + "元 送" + appName + "红包¥" |
| | | + taoBaoGoodsBriefExtra.getTaoBaoHongBaoInfo().getHongbao() + "元 "); |
| | | data.put("shareTitle", taoBaoGoodsBriefExtra.getTitle()); |
| | | data.put("shareContent", "¥" + price + "元"); |
| | | data.put("shareImg", taoBaoGoodsBriefExtra.getPictUrl()); |
| | | String html = configService.getValue(ConfigKeyEnum.downAPP.getKey(),acceptData.getSystem()); |
| | | data.put("downAPP", html); |
| | | String shareSinaContent = configService.getValue("shareSinaContent",acceptData.getSystem()); |
| | | data.put("shareSina", |
| | | "¥" + price + "元 送" + appName + "红包¥" |
| | | + taoBaoGoodsBriefExtra.getTaoBaoHongBaoInfo().getHongbao() + "元 " |
| | | + taoBaoGoodsBriefExtra.getTitle() + shareSinaContent); |
| | | JSONObject taobaoJson = JSONObject.fromObject(gson.toJson(taoBaoGoodsBriefExtra)); |
| | | if (taoBaoGoodsBriefExtra.getImgList() != null) |
| | | taoBaoGoodsBriefExtra.getImgList().add(0, taoBaoGoodsBriefExtra.getPictUrl()); |
| | | taobaoJson.put("imgList", taoBaoGoodsBriefExtra.getImgList()); |
| | | taobaoJson.put("saleCount", taoBaoGoodsBriefExtra.getSalesCount());// 销量(和salesCount一致,此处处理兼容) |
| | | if (taoBaoGoodsBriefExtra.getTaoBaoQuanInfo() != null) |
| | | taobaoJson.put("coupon", true); |
| | | else |
| | | taobaoJson.put("coupon", false); |
| | | |
| | | data.put("sharemoney", "分享奖金 ¥" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb,acceptData.getSystem()) + "元"); |
| | | // taoBaoGoodsBriefExtra.setAuctionUrl(null); |
| | | data.put("taobao", taobaoJson); |
| | | String info = configService.getValue(ConfigKeyEnum.detailPrompt.getKey(), acceptData.getSystem()); |
| | | data.put("info", info); |
| | | String onlyInfo = configService.getValue(ConfigKeyEnum.onlyInfo.getKey(), acceptData.getSystem()); |
| | | data.put("only", onlyInfo); |
| | | data.put("helpUrl", configService.getValue(ConfigKeyEnum.oldGoodsDetailHelpUrl.getKey(), acceptData.getSystem())); |
| | | |
| | | data.put("shareHongBao", "¥" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb,acceptData.getSystem())); |
| | | int showType = taoBaoGoodsBriefExtra.getShowType(); |
| | | String price = ""; |
| | | if (showType == 1 || showType == 3) { |
| | | price = taoBaoGoodsBriefExtra.getQuanPrice() + ""; |
| | | } else { |
| | | price = taoBaoGoodsBriefExtra.getZkPrice() + ""; |
| | | } |
| | | String appName = systemConfigService.getValueCache(SystemConfigKeyEnum.appName, acceptData.getSystem()); |
| | | data.put("sharePrice", "¥" + price + "元 送" + appName + "红包¥" |
| | | + taoBaoGoodsBriefExtra.getTaoBaoHongBaoInfo().getHongbao() + "元 "); |
| | | data.put("shareTitle", taoBaoGoodsBriefExtra.getTitle()); |
| | | data.put("shareContent", "¥" + price + "元"); |
| | | data.put("shareImg", taoBaoGoodsBriefExtra.getPictUrl()); |
| | | String html = configService.getValue(ConfigKeyEnum.downAPP.getKey(), acceptData.getSystem()); |
| | | data.put("downAPP", html); |
| | | String shareSinaContent = configService.getValue("shareSinaContent", acceptData.getSystem()); |
| | | data.put("shareSina", |
| | | "¥" + price + "元 送" + appName + "红包¥" |
| | | + taoBaoGoodsBriefExtra.getTaoBaoHongBaoInfo().getHongbao() + "元 " |
| | | + taoBaoGoodsBriefExtra.getTitle() + shareSinaContent); |
| | | |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | final TaoBaoGoodsBrief tbb = tb; |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | // 添加浏览记录 |
| | | try { |
| | | scanHistoryV2Service.addScanHistory(StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), |
| | | acceptData.getDevice(), tbb); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | data.put("sharemoney", "分享奖金 ¥" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb, acceptData.getSystem()) + "元"); |
| | | |
| | | } else { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架")); |
| | | } |
| | | long end = java.lang.System.currentTimeMillis(); |
| | | java.lang.System.out.println("耗时:" + (end - begin)); |
| | | return; |
| | | } |
| | | data.put("shareHongBao", "¥" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb, acceptData.getSystem())); |
| | | |
| | | // 新版商品图文详情 |
| | | @RequestMapping(value = "getnewgoodsdetail", method = RequestMethod.POST) |
| | | public void getNewGoodsDetail(AcceptData acceptData, String id, String uid, HttpServletRequest request, |
| | | PrintWriter out) { |
| | | if ("0".equalsIgnoreCase(uid)) |
| | | uid = ""; |
| | | if (StringUtil.isNullOrEmpty(id)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请上传id")); |
| | | return; |
| | | } |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(),acceptData.getSystem()); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | final TaoBaoGoodsBrief tbb = tb; |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | // 添加浏览记录 |
| | | try { |
| | | scanHistoryV2Service.addScanHistory(StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), |
| | | acceptData.getDevice(), tbb); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | } else { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架")); |
| | | } |
| | | long end = java.lang.System.currentTimeMillis(); |
| | | java.lang.System.out.println("耗时:" + (end - begin)); |
| | | return; |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("invalid", false); |
| | | // IOS是否正在上线 |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())) { |
| | | data.put("iosOnling", configService.iosOnLining(Integer.parseInt(acceptData.getVersion()),acceptData.getSystem())); |
| | | } |
| | | // 新版商品图文详情 |
| | | @RequestMapping(value = "getnewgoodsdetail", method = RequestMethod.POST) |
| | | public void getNewGoodsDetail(AcceptData acceptData, String id, String uid, HttpServletRequest request, |
| | | PrintWriter out) { |
| | | if ("0".equalsIgnoreCase(uid)) |
| | | uid = ""; |
| | | if (StringUtil.isNullOrEmpty(id)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请上传id")); |
| | | return; |
| | | } |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | |
| | | long startTime = java.lang.System.currentTimeMillis(); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | |
| | | // 获取淘客参数 |
| | | ClientTBPid clientTBPid = null; |
| | | // 用户已经登录 |
| | | JSONObject data = new JSONObject(); |
| | | data.put("invalid", false); |
| | | // IOS是否正在上线 |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())) { |
| | | data.put("iosOnling", configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem())); |
| | | } |
| | | |
| | | if (acceptData.getPlatform().equalsIgnoreCase("android")) |
| | | clientTBPid = tbPidService.getAndroidDefault(); |
| | | else |
| | | clientTBPid = tbPidService.getIOSDefault(); |
| | | long startTime = java.lang.System.currentTimeMillis(); |
| | | |
| | | LogHelper.test("获取PID耗时:" + (java.lang.System.currentTimeMillis() - startTime)); |
| | | // 获取淘客参数 |
| | | ClientTBPid clientTBPid = null; |
| | | // 用户已经登录 |
| | | |
| | | // 是否在服务端进行转链 |
| | | boolean convertInServer = configService.isConvertTaoBaoLinkInServer(acceptData.getSystem()); |
| | | final String clientPid = clientTBPid.getPid(); |
| | | List<String> taskList = new ArrayList<>(); |
| | | taskList.add("goods"); |
| | | taskList.add("imgs"); |
| | | if (acceptData.getPlatform().equalsIgnoreCase("android")) |
| | | clientTBPid = tbPidService.getAndroidDefault(); |
| | | else |
| | | clientTBPid = tbPidService.getIOSDefault(); |
| | | |
| | | List<String> detailImgs = new ArrayList<>(); |
| | | JSONArray detailImgsSize = new JSONArray(); |
| | | LogHelper.test("获取PID耗时:" + (java.lang.System.currentTimeMillis() - startTime)); |
| | | |
| | | final List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); |
| | | taskList.stream().parallel().forEach(task -> { |
| | | if (task.equalsIgnoreCase("goods")) {// 获取商品详情 |
| | | // TaoBaoGoodsBrief tb = null; |
| | | JSONObject ticket = new JSONObject(); |
| | | TaoBaoGoodsBrief goods = null; |
| | | if (convertInServer) { |
| | | String appId = clientPid.split("_")[2]; |
| | | TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(appId); |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAdzoneId(clientPid.split("_")[3]); |
| | | app.setAppKey(config.getAppKey()); |
| | | app.setAppSecret(config.getAppSecret()); |
| | | app.setPid(clientPid); |
| | | try { |
| | | goods = TaoKeApiUtil.searchGoodsDetail(Long.parseLong(id), app); |
| | | if (goods != null) { |
| | | ticket.put("clickUrl", goods.getAuctionUrl()); |
| | | // 测试使用 |
| | | ticket.put("couponUrl", goods.getCouponLink()); |
| | | data.put("ticket", ticket); |
| | | } |
| | | // 是否在服务端进行转链 |
| | | boolean convertInServer = configService.isConvertTaoBaoLinkInServer(acceptData.getSystem()); |
| | | final String clientPid = clientTBPid.getPid(); |
| | | List<String> taskList = new ArrayList<>(); |
| | | taskList.add("goods"); |
| | | taskList.add("imgs"); |
| | | |
| | | } catch (NumberFormatException e) { |
| | | e.printStackTrace(); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | try { |
| | | monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, 0, "商品下架")); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | } else { |
| | | try { |
| | | goods = redisManager.getTaoBaoGoodsBrief(Long.parseLong(id)); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | try { |
| | | monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, 0, "商品下架")); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | // 商品下架 |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | taoBaoGoodsUpdateService.deleteTaoBaoGoods(Long.parseLong(id)); |
| | | } |
| | | }); |
| | | List<String> detailImgs = new ArrayList<>(); |
| | | JSONArray detailImgsSize = new JSONArray(); |
| | | |
| | | } |
| | | } |
| | | final List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); |
| | | taskList.stream().parallel().forEach(task -> { |
| | | if (task.equalsIgnoreCase("goods")) {// 获取商品详情 |
| | | // TaoBaoGoodsBrief tb = null; |
| | | JSONObject ticket = new JSONObject(); |
| | | TaoBaoGoodsBrief goods = null; |
| | | if (convertInServer) { |
| | | String appId = clientPid.split("_")[2]; |
| | | TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(appId); |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAdzoneId(clientPid.split("_")[3]); |
| | | app.setAppKey(config.getAppKey()); |
| | | app.setAppSecret(config.getAppSecret()); |
| | | app.setPid(clientPid); |
| | | try { |
| | | goods = TaoKeApiUtil.searchGoodsDetail(id, app); |
| | | if (goods != null) { |
| | | ticket.put("clickUrl", goods.getAuctionUrl()); |
| | | // 测试使用 |
| | | ticket.put("couponUrl", goods.getCouponLink()); |
| | | data.put("ticket", ticket); |
| | | } |
| | | |
| | | if (goods != null) { |
| | | goodsList.add(goods); |
| | | final TaoBaoGoodsBrief newGoods = goods; |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | try { |
| | | // 更新商品 |
| | | LogHelper.test("更新商品详情:" + newGoods.getAuctionId()); |
| | | taoBaoGoodsUpdateService.updateTaoBaoGoods(newGoods); |
| | | } catch (TaobaoGoodsUpdateException e) { |
| | | } catch (NumberFormatException e) { |
| | | e.printStackTrace(); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | try { |
| | | monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, 0, "商品下架")); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | } else { |
| | | try { |
| | | goods = redisManager.getTaoBaoGoodsBrief(id); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | try { |
| | | monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, 0, "商品下架")); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | // 商品下架 |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | taoBaoGoodsUpdateService.deleteTaoBaoGoods(id); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } else if (task.equalsIgnoreCase("imgs")) {// 获取图文详情 |
| | | List<ImageInfo> imgs = redisManager.getTaoBaoGoodsDetailImgs(Long.parseLong(id),acceptData.getSystem()); |
| | | if (imgs != null && imgs.size() > 0) { |
| | | detailImgs.clear(); |
| | | detailImgsSize.clear(); |
| | | for (ImageInfo imgInfo : imgs) { |
| | | detailImgs.add(imgInfo.getPicture()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (ImageInfo imgInfo : imgs) { |
| | | if (imgInfo.getWidth() <= 0) { |
| | | detailImgsSize.clear(); |
| | | break; |
| | | } else { |
| | | JSONObject size = new JSONObject(); |
| | | size.put("w", imgInfo.getWidth()); |
| | | size.put("h", imgInfo.getHeight()); |
| | | detailImgsSize.add(size); |
| | | } |
| | | } |
| | | if (goods != null) { |
| | | goodsList.add(goods); |
| | | final TaoBaoGoodsBrief newGoods = goods; |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | try { |
| | | // 更新商品 |
| | | LogHelper.test("更新商品详情:" + newGoods.getAuctionId()); |
| | | taoBaoGoodsUpdateService.updateTaoBaoGoods(newGoods); |
| | | } catch (TaobaoGoodsUpdateException e) { |
| | | |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } else if (task.equalsIgnoreCase("imgs")) {// 获取图文详情 |
| | | List<ImageInfo> imgs = redisManager.getTaoBaoGoodsDetailImgs(id, acceptData.getSystem()); |
| | | if (imgs != null && imgs.size() > 0) { |
| | | detailImgs.clear(); |
| | | detailImgsSize.clear(); |
| | | for (ImageInfo imgInfo : imgs) { |
| | | detailImgs.add(imgInfo.getPicture()); |
| | | } |
| | | |
| | | TaoBaoGoodsBrief tb = null; |
| | | if (goodsList.size() > 0) |
| | | tb = goodsList.get(0); |
| | | for (ImageInfo imgInfo : imgs) { |
| | | if (imgInfo.getWidth() <= 0) { |
| | | detailImgsSize.clear(); |
| | | break; |
| | | } else { |
| | | JSONObject size = new JSONObject(); |
| | | size.put("w", imgInfo.getWidth()); |
| | | size.put("h", imgInfo.getHeight()); |
| | | detailImgsSize.add(size); |
| | | } |
| | | } |
| | | |
| | | if (tb == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品不存在")); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | |
| | | // 获取PID |
| | | String pid = ""; |
| | | TaoBaoGoodsBrief tb = null; |
| | | if (goodsList.size() > 0) |
| | | tb = goodsList.get(0); |
| | | |
| | | JSONObject goods = new JSONObject(); |
| | | // |
| | | if (tb.getImgList() == null) |
| | | tb.setImgList(new ArrayList<>()); |
| | | tb.getImgList().add(0, tb.getPictUrl()); |
| | | if (tb == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品不存在")); |
| | | return; |
| | | } |
| | | |
| | | List<String> finalImgList = new ArrayList<>(); |
| | | for (String img : tb.getImgList()) { |
| | | // img=TbImgUtil.getTBSizeImgWebp(img, 600); |
| | | finalImgList.add(img); |
| | | } |
| | | // 获取PID |
| | | String pid = ""; |
| | | |
| | | goods.put("auctionId", tb.getAuctionId()); |
| | | goods.put("imgList", finalImgList); |
| | | goods.put("title", tb.getTitle()); |
| | | goods.put("userType", tb.getUserType() == 1 ? 2 : 1); |
| | | goods.put("price", tb.getReservePrice().toString()); |
| | | goods.put("zkPrice", tb.getZkPrice().toString()); |
| | | JSONObject goods = new JSONObject(); |
| | | // |
| | | if (tb.getImgList() == null) |
| | | tb.setImgList(new ArrayList<>()); |
| | | tb.getImgList().add(0, tb.getPictUrl()); |
| | | |
| | | BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); |
| | | String hongBao = TaoBaoUtil.getGoodsHongBaoInfo(tb, proportion,false); |
| | | goods.put("hongBao", hongBao); |
| | | List<String> finalImgList = new ArrayList<>(); |
| | | for (String img : tb.getImgList()) { |
| | | // img=TbImgUtil.getTBSizeImgWebp(img, 600); |
| | | finalImgList.add(img); |
| | | } |
| | | |
| | | // 30天销量 |
| | | goods.put("saleCount", TaoBaoUtil.getSaleCount(tb.getBiz30day())); |
| | | goods.put("auctionId", tb.getAuctionId()); |
| | | goods.put("imgList", finalImgList); |
| | | goods.put("title", tb.getTitle()); |
| | | goods.put("userType", tb.getUserType() == 1 ? 2 : 1); |
| | | goods.put("price", tb.getReservePrice().toString()); |
| | | goods.put("zkPrice", tb.getZkPrice().toString()); |
| | | |
| | | // 获取详细的图文信息 |
| | | goods.put("detailImgs", detailImgs); |
| | | goods.put("detailImgsSize", detailImgsSize); |
| | | BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); |
| | | String hongBao = TaoBaoUtil.getGoodsHongBaoInfo(tb, proportion, false); |
| | | goods.put("hongBao", hongBao); |
| | | |
| | | String jumpUrl = "https://item.taobao.com/item.htm?id=" + tb.getAuctionId(); |
| | | // 30天销量 |
| | | goods.put("saleCount", TaoBaoUtil.getSaleCount(tb.getBiz30day())); |
| | | |
| | | // 分享赚 |
| | | data.put("shareMoney", "¥" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb,acceptData.getSystem())); |
| | | // 获取详细的图文信息 |
| | | goods.put("detailImgs", detailImgs); |
| | | goods.put("detailImgsSize", detailImgsSize); |
| | | |
| | | // 判断收藏 |
| | | if (!StringUtil.isNullOrEmpty(uid)) { |
| | | CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(Long.parseLong(uid), |
| | | Long.parseLong(id), Constant.SOURCE_TYPE_TAOBAO); |
| | | data.put("collected", collectionGoods != null ? true : false); |
| | | } else |
| | | data.put("collected", false); |
| | | String jumpUrl = "https://item.taobao.com/item.htm?id=" + tb.getAuctionId(); |
| | | |
| | | pid = clientTBPid.getPid(); |
| | | // 分享赚 |
| | | data.put("shareMoney", "¥" + taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb, acceptData.getSystem())); |
| | | |
| | | LogHelper.test(String.format("PID: uid-%s pid-%s", uid + "", pid)); |
| | | // 判断收藏 |
| | | if (!StringUtil.isNullOrEmpty(uid)) { |
| | | CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(Long.parseLong(uid), |
| | | id, Constant.SOURCE_TYPE_TAOBAO); |
| | | data.put("collected", collectionGoods != null ? true : false); |
| | | } else |
| | | data.put("collected", false); |
| | | |
| | | SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, |
| | | "goods_detail_jump_taobao"); |
| | | // 测试 |
| | | if ("1".equalsIgnoreCase((params.getValue() + "").trim())) |
| | | data.put("native", true); |
| | | else |
| | | data.put("native", false); |
| | | pid = clientTBPid.getPid(); |
| | | |
| | | goods.put("coupon", StringUtil.isNullOrEmpty(tb.getCouponInfo()) ? false : true); |
| | | // 获取券信息 |
| | | if (!StringUtil.isNullOrEmpty(tb.getCouponInfo())) { |
| | | BigDecimal quanPrice = TaoBaoUtil.getCouponPrice(tb); |
| | | JSONObject couponInfo = new JSONObject(); |
| | | couponInfo.put("couponPrice", quanPrice.toString()); |
| | | // 服务端转链 |
| | | if (convertInServer && !StringUtil.isNullOrEmpty(tb.getCouponLink())) |
| | | couponInfo.put("couponUrl", tb.getCouponLink()); |
| | | else |
| | | couponInfo.put("couponUrl", |
| | | TaoBaoCouponUtil.getCoupleUrl(tb.getCouponActivityId() + "", pid, tb.getAuctionId() + "")); |
| | | couponInfo.put("couponAmount", NumberUtil.subZeroAndDot(tb.getCouponAmount().toString())); |
| | | couponInfo.put("couponTime", "使用期限:" + tb.getCouponEffectiveStartTime().replace("-", ".") + "-" |
| | | + tb.getCouponEffectiveEndTime().replace("-", ".")); |
| | | goods.put("couponInfo", couponInfo); |
| | | } |
| | | LogHelper.test(String.format("PID: uid-%s pid-%s", uid + "", pid)); |
| | | |
| | | // 測試 |
| | | // clientTBPid.setAdZoneId("12"); |
| | | // clientTBPid.setPid("mm_123123_123123_123213"); |
| | | SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, |
| | | "goods_detail_jump_taobao"); |
| | | // 测试 |
| | | if ("1".equalsIgnoreCase((params.getValue() + "").trim())) |
| | | data.put("native", true); |
| | | else |
| | | data.put("native", false); |
| | | |
| | | data.put("tbPidInfo", clientTBPid); |
| | | goods.put("coupon", StringUtil.isNullOrEmpty(tb.getCouponInfo()) ? false : true); |
| | | // 获取券信息 |
| | | if (!StringUtil.isNullOrEmpty(tb.getCouponInfo())) { |
| | | BigDecimal quanPrice = TaoBaoUtil.getCouponPrice(tb); |
| | | JSONObject couponInfo = new JSONObject(); |
| | | couponInfo.put("couponPrice", quanPrice.toString()); |
| | | // 服务端转链 |
| | | if (convertInServer && !StringUtil.isNullOrEmpty(tb.getCouponLink())) |
| | | couponInfo.put("couponUrl", tb.getCouponLink()); |
| | | else |
| | | couponInfo.put("couponUrl", |
| | | TaoBaoCouponUtil.getCoupleUrl(tb.getCouponActivityId() + "", pid, tb.getAuctionId() + "")); |
| | | couponInfo.put("couponAmount", NumberUtil.subZeroAndDot(tb.getCouponAmount().toString())); |
| | | couponInfo.put("couponTime", "使用期限:" + tb.getCouponEffectiveStartTime().replace("-", ".") + "-" |
| | | + tb.getCouponEffectiveEndTime().replace("-", ".")); |
| | | goods.put("couponInfo", couponInfo); |
| | | } |
| | | |
| | | if (!StringUtil.isNullOrEmpty(tb.getCouponActivityId())) {// 有券,跳转券链接 |
| | | jumpUrl = TaoBaoCouponUtil.getCoupleUrl(tb.getCouponActivityId(), clientTBPid.getPid(), |
| | | "" + tb.getAuctionId()); |
| | | } |
| | | // 測試 |
| | | // clientTBPid.setAdZoneId("12"); |
| | | // clientTBPid.setPid("mm_123123_123123_123213"); |
| | | |
| | | // 设置跳转链接 |
| | | if (convertInServer) { |
| | | if (!StringUtil.isNullOrEmpty(tb.getCouponLink())) |
| | | jumpUrl = tb.getCouponLink(); |
| | | else |
| | | jumpUrl = tb.getAuctionUrl(); |
| | | } |
| | | data.put("tbPidInfo", clientTBPid); |
| | | |
| | | goods.put("jumpUrl", jumpUrl); |
| | | goods.put("shopInfo", redisManager.getTBShopInfo(tb.getShopTitle(), tb.getSellerId(), tb.getAuctionId())); |
| | | data.put("goods", goods); |
| | | if (!StringUtil.isNullOrEmpty(tb.getCouponActivityId())) {// 有券,跳转券链接 |
| | | jumpUrl = TaoBaoCouponUtil.getCoupleUrl(tb.getCouponActivityId(), clientTBPid.getPid(), |
| | | "" + tb.getAuctionId()); |
| | | } |
| | | |
| | | String shareUrl = String.format("%s?id=" + tb.getAuctionId(), Constant.systemCommonConfig.getAppShareInfoUrl()); |
| | | data.put("shareUrl", shareUrl); |
| | | // 设置跳转链接 |
| | | if (convertInServer) { |
| | | if (!StringUtil.isNullOrEmpty(tb.getCouponLink())) |
| | | jumpUrl = tb.getCouponLink(); |
| | | else |
| | | jumpUrl = tb.getAuctionUrl(); |
| | | } |
| | | |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | goods.put("jumpUrl", jumpUrl); |
| | | goods.put("shopInfo", redisManager.getTBShopInfo(tb.getShopTitle(), tb.getSellerId(), tb.getAuctionId())); |
| | | data.put("goods", goods); |
| | | |
| | | final String tempUid = uid; |
| | | final TaoBaoGoodsBrief goodsInfo = tb; |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | // 添加浏览记录 |
| | | try { |
| | | scanHistoryV2Service.addScanHistory( |
| | | StringUtil.isNullOrEmpty(tempUid) ? null : Long.parseLong(tempUid), acceptData.getDevice(), |
| | | goodsInfo); |
| | | } catch (NumberFormatException e) { |
| | | e.printStackTrace(); |
| | | } catch (CommonGoodsException e) { |
| | | e.printStackTrace(); |
| | | } catch (ScanHistoryException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | String shareUrl = String.format("%s?id=" + tb.getAuctionId(), Constant.systemCommonConfig.getAppShareInfoUrl()); |
| | | data.put("shareUrl", shareUrl); |
| | | |
| | | /** |
| | | * 淘宝转链 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param id |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "gettaobaolink") |
| | | public void getTaobaoLink(AcceptData acceptData, String uid, Long id, PrintWriter out) { |
| | | ClientTBPid clientTBPid = null; |
| | | // 用户已经登录 |
| | | if (!StringUtil.isNullOrEmpty(uid)) { |
| | | if (acceptData.getPlatform().equalsIgnoreCase("android")) { |
| | | clientTBPid = tbPidService.getAndroidDefault(); |
| | | } else { |
| | | clientTBPid = tbPidService.getIOSDefault(); |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | |
| | | } else { |
| | | if (acceptData.getPlatform().equalsIgnoreCase("android")) |
| | | clientTBPid = tbPidService.getAndroidDefault(); |
| | | else |
| | | clientTBPid = tbPidService.getIOSDefault(); |
| | | } |
| | | final String tempUid = uid; |
| | | final TaoBaoGoodsBrief goodsInfo = tb; |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | // 添加浏览记录 |
| | | try { |
| | | scanHistoryV2Service.addScanHistory( |
| | | StringUtil.isNullOrEmpty(tempUid) ? null : Long.parseLong(tempUid), acceptData.getDevice(), |
| | | goodsInfo); |
| | | } catch (NumberFormatException e) { |
| | | e.printStackTrace(); |
| | | } catch (CommonGoodsException e) { |
| | | e.printStackTrace(); |
| | | } catch (ScanHistoryException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | /** |
| | | * 淘宝转链 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param id |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "gettaobaolink") |
| | | public void getTaobaoLink(AcceptData acceptData, String uid, String id, PrintWriter out) { |
| | | ClientTBPid clientTBPid = null; |
| | | // 用户已经登录 |
| | | if (!StringUtil.isNullOrEmpty(uid)) { |
| | | if (acceptData.getPlatform().equalsIgnoreCase("android")) { |
| | | clientTBPid = tbPidService.getAndroidDefault(); |
| | | } else { |
| | | clientTBPid = tbPidService.getIOSDefault(); |
| | | } |
| | | |
| | | // 是否在服务端进行转链 |
| | | boolean convertInServer = configService.isConvertTaoBaoLinkInServer(acceptData.getSystem()); |
| | | TaoBaoGoodsBrief tb = null; |
| | | JSONObject ticket = new JSONObject(); |
| | | if (convertInServer) { |
| | | String appId = clientTBPid.getPid().split("_")[2]; |
| | | TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(appId); |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAdzoneId(clientTBPid.getPid().split("_")[3]); |
| | | app.setAppKey(config.getAppKey()); |
| | | app.setAppSecret(config.getAppSecret()); |
| | | app.setPid(clientTBPid.getPid()); |
| | | try { |
| | | tb = TaoKeApiUtil.searchGoodsDetail(id, app); |
| | | if (tb != null) { |
| | | ticket.put("clickUrl", tb.getAuctionUrl()); |
| | | ticket.put("couponUrl", tb.getCouponLink()); |
| | | data.put("ticket", ticket); |
| | | } |
| | | } else { |
| | | if (acceptData.getPlatform().equalsIgnoreCase("android")) |
| | | clientTBPid = tbPidService.getAndroidDefault(); |
| | | else |
| | | clientTBPid = tbPidService.getIOSDefault(); |
| | | } |
| | | |
| | | } catch (NumberFormatException e) { |
| | | e.printStackTrace(); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | |
| | | data.put("pidInfo", clientTBPid); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | // 是否在服务端进行转链 |
| | | boolean convertInServer = configService.isConvertTaoBaoLinkInServer(acceptData.getSystem()); |
| | | TaoBaoGoodsBrief tb = null; |
| | | JSONObject ticket = new JSONObject(); |
| | | if (convertInServer) { |
| | | String appId = clientTBPid.getPid().split("_")[2]; |
| | | TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(appId); |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAdzoneId(clientTBPid.getPid().split("_")[3]); |
| | | app.setAppKey(config.getAppKey()); |
| | | app.setAppSecret(config.getAppSecret()); |
| | | app.setPid(clientTBPid.getPid()); |
| | | try { |
| | | tb = TaoKeApiUtil.searchGoodsDetail(id, app); |
| | | if (tb != null) { |
| | | ticket.put("clickUrl", tb.getAuctionUrl()); |
| | | ticket.put("couponUrl", tb.getCouponLink()); |
| | | data.put("ticket", ticket); |
| | | } |
| | | |
| | | // 根据商品获取推荐 |
| | | @RequestMapping(value = "getgoodsrecommend", method = RequestMethod.POST) |
| | | public void getGoodsRecommend(final AcceptData acceptData, long id, PrintWriter out) { |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(),acceptData.getSystem()); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | } catch (NumberFormatException e) { |
| | | e.printStackTrace(); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(id, 6); |
| | | if (goodsList == null) |
| | | goodsList = new ArrayList<>(); |
| | | data.put("pidInfo", clientTBPid); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | if (goodsList == null || goodsList.size() == 0)// 重新做推荐 |
| | | { |
| | | TaoBaoGoodsBrief goods = null; |
| | | try { |
| | | goods = redisManager.getTaoBaoGoodsBrief(id); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (goods == null)// 商品下线 |
| | | { |
| | | // 从我们的商品库搜索 |
| | | CommonGoods cgoods = commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType(id, |
| | | CommonGoods.GOODS_TYPE_TB); |
| | | // 根据商品获取推荐 |
| | | @RequestMapping(value = "getgoodsrecommend", method = RequestMethod.POST) |
| | | public void getGoodsRecommend(final AcceptData acceptData, String id, PrintWriter out) { |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | |
| | | if (cgoods != null) {// 商品有本地缓存 |
| | | // 按名字搜索商品 |
| | | SearchFilter sf = new SearchFilter(); |
| | | sf.setKey(cgoods.getTitle().substring(0, cgoods.getTitle().length() / 2)); |
| | | TaoBaoSearchResult result = TaoBaoUtil.search(sf,null,null); |
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null |
| | | && result.getTaoBaoGoodsBriefs().size() > 0) |
| | | for (TaoBaoGoodsBrief gds : result.getTaoBaoGoodsBriefs()) { |
| | | if (goodsList.size() < 6) |
| | | goodsList.add(gds); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(id, 6); |
| | | if (goodsList == null) |
| | | goodsList = new ArrayList<>(); |
| | | |
| | | final List<TaoBaoGoodsBrief> recommendGoodsList = new ArrayList<>(); |
| | | if (goodsList == null || goodsList.size() == 0)// 重新做推荐 |
| | | { |
| | | TaoBaoGoodsBrief goods = null; |
| | | try { |
| | | goods = redisManager.getTaoBaoGoodsBrief(id); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (goods == null)// 商品下线 |
| | | { |
| | | // 从我们的商品库搜索 |
| | | CommonGoods cgoods = commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType(id, |
| | | CommonGoods.GOODS_TYPE_TB); |
| | | |
| | | goodsList.parallelStream().forEach(goods -> { |
| | | // 获取详情 |
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = null; |
| | | try { |
| | | taoBaoGoodsBrief = redisManager.getTaoBaoGoodsBrief(goods.getAuctionId()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (taoBaoGoodsBrief != null) |
| | | recommendGoodsList.add(taoBaoGoodsBrief); |
| | | }); |
| | | if (cgoods != null) {// 商品有本地缓存 |
| | | // 按名字搜索商品 |
| | | SearchFilter sf = new SearchFilter(); |
| | | sf.setKey(cgoods.getTitle().substring(0, cgoods.getTitle().length() / 2)); |
| | | TaoBaoSearchResult result = TaoBaoUtil.search(sf, null, null); |
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null |
| | | && result.getTaoBaoGoodsBriefs().size() > 0) |
| | | for (TaoBaoGoodsBrief gds : result.getTaoBaoGoodsBriefs()) { |
| | | if (goodsList.size() < 6) |
| | | goodsList.add(gds); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 取偶数个数据 |
| | | if (recommendGoodsList.size() % 2 != 0) { |
| | | recommendGoodsList.remove(recommendGoodsList.size() - 1); |
| | | } |
| | | final List<TaoBaoGoodsBrief> recommendGoodsList = new ArrayList<>(); |
| | | |
| | | List<TaoBaoGoodsBriefExtra> re = new ArrayList<TaoBaoGoodsBriefExtra>(); |
| | | goodsList.parallelStream().forEach(goods -> { |
| | | // 获取详情 |
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = null; |
| | | try { |
| | | taoBaoGoodsBrief = redisManager.getTaoBaoGoodsBrief(goods.getAuctionId()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (taoBaoGoodsBrief != null) |
| | | recommendGoodsList.add(taoBaoGoodsBrief); |
| | | }); |
| | | |
| | | BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); |
| | | if (recommendGoodsList != null) |
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : recommendGoodsList) { |
| | | if (taoBaoGoodsBrief == null) |
| | | continue; |
| | | // 取偶数个数据 |
| | | if (recommendGoodsList.size() % 2 != 0) { |
| | | recommendGoodsList.remove(recommendGoodsList.size() - 1); |
| | | } |
| | | |
| | | re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), "")); |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(JsonUtil.getApiCommonGson().toJson(re))); |
| | | } |
| | | List<TaoBaoGoodsBriefExtra> re = new ArrayList<TaoBaoGoodsBriefExtra>(); |
| | | |
| | | // 上传订单 |
| | | @RequestMapping(value = "reportorder", method = RequestMethod.POST) |
| | | public void reportOrder(AcceptData acceptData, String order, String auctionUrl, String money, long uid, |
| | | PrintWriter out, HttpServletRequest request) { |
| | | LogHelper.userOrder("[ip:" + IPUtil.getRemotIP(request) + "],上传的淘宝订单ID:" + order + ",用户ID:" + uid + ",订单金额:" |
| | | + money + ",商品链接:" + auctionUrl); |
| | | if (StringUtil.isNullOrEmpty(order)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请上传order")); |
| | | LogHelper.userOrder("[ip:" + IPUtil.getRemotIP(request) + "] 上传的订单为空!上传订单失败!"); |
| | | return; |
| | | } |
| | | BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); |
| | | if (recommendGoodsList != null) |
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : recommendGoodsList) { |
| | | if (taoBaoGoodsBrief == null) |
| | | continue; |
| | | |
| | | UserInfo user = userInfoService.getUserById(uid); |
| | | if (user == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请上传uid")); |
| | | LogHelper.userOrder("[ip:" + IPUtil.getRemotIP(request) + "] 用户不存在!上传订单失败!"); |
| | | return; |
| | | } |
| | | order = order.replace("[", "").replace("]", ""); |
| | | String[] orderArr = order.split(","); |
| | | for (String tbOrder : orderArr) { |
| | | Order or = new Order(); |
| | | or.setBeizhu("接口添加"); |
| | | or.setCreatetime(java.lang.System.currentTimeMillis()); |
| | | or.setDrawbackTime(0L); |
| | | or.setOrderId(tbOrder.trim()); |
| | | or.setOrderType(1); |
| | | or.setState(1); |
| | | or.setUserInfo(new UserInfo(uid)); |
| | | or.setVersion(2); |
| | | boolean b; |
| | | try { |
| | | b = orderService.addOrder(or); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | b = false; |
| | | } |
| | | if (b) { |
| | | LogHelper.userOrder("用户ID" + uid + "下单成功!订单ID[" + or.getOrderId() + "]"); |
| | | } else { |
| | | LogHelper.userOrder("用户ID" + uid + "下单失败!订单ID[" + or.getOrderId() + "]"); |
| | | } |
| | | } |
| | | out.print(JsonUtil.loadTrueResult("上报成功")); |
| | | return; |
| | | } |
| | | re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), "")); |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(JsonUtil.getApiCommonGson().toJson(re))); |
| | | } |
| | | |
| | | // 获取浏览记录 |
| | | @RequestMapping(value = "getscanhistory", method = RequestMethod.POST) |
| | | public void getScanHistory(AcceptData acceptData, String uid, int page, PrintWriter out) { |
| | | // 上传订单 |
| | | @RequestMapping(value = "reportorder", method = RequestMethod.POST) |
| | | public void reportOrder(AcceptData acceptData, String order, String auctionUrl, String money, long uid, |
| | | PrintWriter out, HttpServletRequest request) { |
| | | LogHelper.userOrder("[ip:" + IPUtil.getRemotIP(request) + "],上传的淘宝订单ID:" + order + ",用户ID:" + uid + ",订单金额:" |
| | | + money + ",商品链接:" + auctionUrl); |
| | | if (StringUtil.isNullOrEmpty(order)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请上传order")); |
| | | LogHelper.userOrder("[ip:" + IPUtil.getRemotIP(request) + "] 上传的订单为空!上传订单失败!"); |
| | | return; |
| | | } |
| | | |
| | | if (page < 0) { |
| | | out.print(JsonUtil.loadFalseResult(1, "page不小于0")); |
| | | return; |
| | | } |
| | | page = page + 1; |
| | | BusinessSystem sys = businessSystemService.getBusinessSystem(acceptData.getPlatform(), |
| | | acceptData.getPackages(),acceptData.getSystem()); |
| | | if (sys == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "不存在该系统")); |
| | | return; |
| | | } |
| | | try { |
| | | UserInfo user = userInfoService.getUserById(uid); |
| | | if (user == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请上传uid")); |
| | | LogHelper.userOrder("[ip:" + IPUtil.getRemotIP(request) + "] 用户不存在!上传订单失败!"); |
| | | return; |
| | | } |
| | | order = order.replace("[", "").replace("]", ""); |
| | | String[] orderArr = order.split(","); |
| | | for (String tbOrder : orderArr) { |
| | | Order or = new Order(); |
| | | or.setBeizhu("接口添加"); |
| | | or.setCreatetime(java.lang.System.currentTimeMillis()); |
| | | or.setDrawbackTime(0L); |
| | | or.setOrderId(tbOrder.trim()); |
| | | or.setOrderType(1); |
| | | or.setState(1); |
| | | or.setUserInfo(new UserInfo(uid)); |
| | | or.setVersion(2); |
| | | boolean b; |
| | | try { |
| | | b = orderService.addOrder(or); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | b = false; |
| | | } |
| | | if (b) { |
| | | LogHelper.userOrder("用户ID" + uid + "下单成功!订单ID[" + or.getOrderId() + "]"); |
| | | } else { |
| | | LogHelper.userOrder("用户ID" + uid + "下单失败!订单ID[" + or.getOrderId() + "]"); |
| | | } |
| | | } |
| | | out.print(JsonUtil.loadTrueResult("上报成功")); |
| | | return; |
| | | } |
| | | |
| | | List<ScanHistoryV2> list = scanHistoryV2Service.getScanHistoryByDeviceOrUid( |
| | | StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), acceptData.getDevice(), page, 20, |
| | | Constant.SOURCE_TYPE_TAOBAO, true); |
| | | long count = scanHistoryV2Service.getCountByDeviceOrUid( |
| | | StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), acceptData.getDevice(), |
| | | Constant.SOURCE_TYPE_TAOBAO, true); |
| | | // 获取浏览记录 |
| | | @RequestMapping(value = "getscanhistory", method = RequestMethod.POST) |
| | | public void getScanHistory(AcceptData acceptData, String uid, int page, PrintWriter out) { |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("count", count); |
| | | JSONArray array = new JSONArray(); |
| | | if (page < 0) { |
| | | out.print(JsonUtil.loadFalseResult(1, "page不小于0")); |
| | | return; |
| | | } |
| | | page = page + 1; |
| | | BusinessSystem sys = businessSystemService.getBusinessSystem(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | if (sys == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "不存在该系统")); |
| | | return; |
| | | } |
| | | try { |
| | | |
| | | GsonBuilder gsonBuilder = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()); |
| | | gsonBuilder.excludeFieldsWithoutExposeAnnotation(); |
| | | gsonBuilder.registerTypeAdapter(Date.class, new JsonSerializer<Date>() { |
| | | @Override |
| | | public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) { |
| | | if (value == null) { |
| | | return new JsonPrimitive(""); |
| | | } else { |
| | | return new JsonPrimitive(value.getTime() + ""); |
| | | } |
| | | } |
| | | }); |
| | | List<ScanHistoryV2> list = scanHistoryV2Service.getScanHistoryByDeviceOrUid( |
| | | StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), acceptData.getDevice(), page, 20, |
| | | Constant.SOURCE_TYPE_TAOBAO, true); |
| | | long count = scanHistoryV2Service.getCountByDeviceOrUid( |
| | | StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), acceptData.getDevice(), |
| | | Constant.SOURCE_TYPE_TAOBAO, true); |
| | | |
| | | Gson gson = gsonBuilder.create(); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("count", count); |
| | | JSONArray array = new JSONArray(); |
| | | |
| | | if (list != null) { |
| | | BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); |
| | | for (ScanHistoryV2 sh : list) { |
| | | TaoBaoGoodsBrief goods = TaoBaoUtil.convert(sh.getCommonGoods()); |
| | | goods.setId(sh.getId()); |
| | | TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, proportion.toString(), ""); |
| | | extra.setCreatetime(sh.getCreateTime()); |
| | | array.add(gson.toJson(extra)); |
| | | } |
| | | } |
| | | data.put("data", array); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | return; |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("data", new JSONArray()); |
| | | data.put("count", 0); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | GsonBuilder gsonBuilder = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()); |
| | | gsonBuilder.excludeFieldsWithoutExposeAnnotation(); |
| | | gsonBuilder.registerTypeAdapter(Date.class, new JsonSerializer<Date>() { |
| | | @Override |
| | | public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) { |
| | | if (value == null) { |
| | | return new JsonPrimitive(""); |
| | | } else { |
| | | return new JsonPrimitive(value.getTime() + ""); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } |
| | | Gson gson = gsonBuilder.create(); |
| | | |
| | | @RequestMapping(value = "deletescanhistory", method = RequestMethod.POST) |
| | | public void deleteScanHistory(AcceptData acceptData, String type, String uid, String ids, PrintWriter out) { |
| | | BusinessSystem sys = businessSystemService.getBusinessSystem(acceptData.getPlatform(), |
| | | acceptData.getPackages(),acceptData.getSystem()); |
| | | if (sys == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | if (list != null) { |
| | | BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); |
| | | for (ScanHistoryV2 sh : list) { |
| | | TaoBaoGoodsBrief goods = TaoBaoUtil.convert(sh.getCommonGoods()); |
| | | goods.setId(sh.getId()); |
| | | TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, proportion.toString(), ""); |
| | | extra.setCreatetime(sh.getCreateTime()); |
| | | array.add(gson.toJson(extra)); |
| | | } |
| | | } |
| | | data.put("data", array); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | return; |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("data", new JSONArray()); |
| | | data.put("count", 0); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | if ("0".equals(type)) { |
| | | String[] idStr = ids.split(","); |
| | | for (String auctionIdStr : idStr) { |
| | | scanHistoryV2Service.deleteByAuctionIdAndDeviceOrUid( |
| | | StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), acceptData.getDevice(), |
| | | Long.parseLong(auctionIdStr)); |
| | | } |
| | | } else { |
| | | scanHistoryV2Service.deleteByDeviceOrUid(StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), |
| | | acceptData.getDevice()); |
| | | } |
| | | out.print(JsonUtil.loadTrueResult("")); |
| | | } |
| | | |
| | | return; |
| | | } |
| | | @RequestMapping(value = "deletescanhistory", method = RequestMethod.POST) |
| | | public void deleteScanHistory(AcceptData acceptData, String type, String uid, String ids, PrintWriter out) { |
| | | BusinessSystem sys = businessSystemService.getBusinessSystem(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | if (sys == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | |
| | | // 根据原链接获取推广链接 |
| | | if ("0".equals(type)) { |
| | | String[] idStr = ids.split(","); |
| | | for (String auctionIdStr : idStr) { |
| | | scanHistoryV2Service.deleteByAuctionIdAndDeviceOrUid( |
| | | StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), acceptData.getDevice(), |
| | | auctionIdStr); |
| | | } |
| | | } else { |
| | | scanHistoryV2Service.deleteByDeviceOrUid(StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), |
| | | acceptData.getDevice()); |
| | | } |
| | | out.print(JsonUtil.loadTrueResult("")); |
| | | |
| | | @RequestMapping(value = "getTaoBaoLink", method = RequestMethod.POST) |
| | | public void getTaoBaoLink(AcceptData acceptData, String url, PrintWriter out) { |
| | | if (!url.contains("//detail.m.tmall.com/item.htm") && !url.contains("h5.m.taobao.com/awp/core/detail.htm") |
| | | && !url.contains("item.taobao.com/item.htm")) { |
| | | out.print(JsonUtil.loadFalseResult(1, "链接错误")); |
| | | return; |
| | | } |
| | | return; |
| | | } |
| | | |
| | | String params = url.split("\\?")[1]; |
| | | String[] ps = params.split("&"); |
| | | String id = ""; |
| | | for (String st : ps) { |
| | | if (st.contains("id=")) { |
| | | id = st.replace("id=", ""); |
| | | break; |
| | | } |
| | | } |
| | | if (StringUtil.isNullOrEmpty(id)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "商品ID错误")); |
| | | return; |
| | | } |
| | | // 根据原链接获取推广链接 |
| | | |
| | | @RequestMapping(value = "getTaoBaoLink", method = RequestMethod.POST) |
| | | public void getTaoBaoLink(AcceptData acceptData, String url, PrintWriter out) { |
| | | if (!url.contains("//detail.m.tmall.com/item.htm") && !url.contains("h5.m.taobao.com/awp/core/detail.htm") |
| | | && !url.contains("item.taobao.com/item.htm")) { |
| | | out.print(JsonUtil.loadFalseResult(1, "链接错误")); |
| | | return; |
| | | } |
| | | |
| | | String params = url.split("\\?")[1]; |
| | | String[] ps = params.split("&"); |
| | | String id = ""; |
| | | for (String st : ps) { |
| | | if (st.contains("id=")) { |
| | | id = st.replace("id=", ""); |
| | | break; |
| | | } |
| | | } |
| | | if (StringUtil.isNullOrEmpty(id)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "商品ID错误")); |
| | | return; |
| | | } |
| | | |
| | | /** |
| | | * 防止请求频率过高 |
| | | * |
| | | */ |
| | | // if (Constant.IS_OUTNET) { |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaolinkParse, acceptData.getDevice() + "-" + id); |
| | | String value = redisManager.getCommonString(key); |
| | | if (!StringUtil.isNullOrEmpty(value)) { |
| | | out.print(JsonUtil.loadFalseResult(11, "请求频率限制")); |
| | | return; |
| | | } |
| | | redisManager.cacheCommonString(key, "1", 5);// 5s间隔 |
| | | // } |
| | | TaoBaoGoodsBrief goods = null; |
| | | try { |
| | | goods = redisManager.getTaoBaoGoodsBrief(Long.parseLong(id)); |
| | | } catch (NumberFormatException e) { |
| | | e.printStackTrace(); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (goods == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品")); |
| | | return; |
| | | } |
| | | /** |
| | | * 防止请求频率过高 |
| | | * |
| | | */ |
| | | // if (Constant.IS_OUTNET) { |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.taobaolinkParse, acceptData.getDevice() + "-" + id); |
| | | String value = redisManager.getCommonString(key); |
| | | if (!StringUtil.isNullOrEmpty(value)) { |
| | | out.print(JsonUtil.loadFalseResult(11, "请求频率限制")); |
| | | return; |
| | | } |
| | | redisManager.cacheCommonString(key, "1", 5);// 5s间隔 |
| | | // } |
| | | TaoBaoGoodsBrief goods = null; |
| | | try { |
| | | goods = redisManager.getTaoBaoGoodsBrief(id); |
| | | } catch (NumberFormatException e) { |
| | | e.printStackTrace(); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (goods == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品")); |
| | | return; |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("id", id); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | return; |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | data.put("id", id); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | return; |
| | | } |
| | | |
| | | /** |
| | | * 根据设备信息获取猜你喜欢的内容 |
| | | * |
| | | * @param acceptData |
| | | * @param imei |
| | | * -Android的IMEI信息 |
| | | * @param idfa |
| | | * -IOS的idfa广告标识信息 |
| | | */ |
| | | @RequestMapping(value = "guessLikeByDevice") |
| | | public void guessUserLikeByDevice(AcceptData acceptData, String imei, String idfa, int page, |
| | | HttpServletRequest request, PrintWriter out) { |
| | | int pageSize = Constant.PAGE_SIZE; |
| | | JSONArray array = new JSONArray(); |
| | | /** |
| | | * 根据设备信息获取猜你喜欢的内容 |
| | | * |
| | | * @param acceptData |
| | | * @param imei -Android的IMEI信息 |
| | | * @param idfa -IOS的idfa广告标识信息 |
| | | */ |
| | | @RequestMapping(value = "guessLikeByDevice") |
| | | public void guessUserLikeByDevice(AcceptData acceptData, String imei, String idfa, int page, |
| | | HttpServletRequest request, PrintWriter out) { |
| | | int pageSize = Constant.PAGE_SIZE; |
| | | JSONArray array = new JSONArray(); |
| | | |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create(); |
| | | if (VersionUtil.greaterThan_1_5_70(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | List<TaoBaoGoodsBrief> goodsList = homeRecommendGoodsService.listGoodsByPage(null, acceptData.getDevice(), |
| | | imei, idfa, page); |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create(); |
| | | if (VersionUtil.greaterThan_1_5_70(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | List<TaoBaoGoodsBrief> goodsList = homeRecommendGoodsService.listGoodsByPage(null, acceptData.getDevice(), |
| | | imei, idfa, page); |
| | | |
| | | if (page < 4) {// 前三页加入更新 |
| | | try { |
| | | taoBaoGoodsUpdateService.addUpdateQueueAsync(goodsList); |
| | | } catch (Exception e) { |
| | | } |
| | | } |
| | | if (page < 4) {// 前三页加入更新 |
| | | try { |
| | | taoBaoGoodsUpdateService.addUpdateQueueAsync(goodsList); |
| | | } catch (Exception e) { |
| | | } |
| | | } |
| | | |
| | | BigDecimal rate = hongBaoManageService.getFanLiRate(acceptData.getSystem()); |
| | | for (TaoBaoGoodsBrief goods : goodsList) { |
| | | TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, rate + "", null); |
| | | if (page < 3) |
| | | extra.setRecommend(true); |
| | | BigDecimal rate = hongBaoManageService.getFanLiRate(acceptData.getSystem()); |
| | | for (TaoBaoGoodsBrief goods : goodsList) { |
| | | TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, rate + "", null); |
| | | if (page < 3) |
| | | extra.setRecommend(true); |
| | | |
| | | try { |
| | | array.add(gson.toJson(extra)); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | System.out.println(new Gson().toJson(goods)); |
| | | } |
| | | } |
| | | try { |
| | | array.add(gson.toJson(extra)); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | System.out.println(new Gson().toJson(goods)); |
| | | } |
| | | } |
| | | |
| | | if (page == 1) { |
| | | List<TLJBuyGoods> list = null; |
| | | try { |
| | | list = homeRecommendGoodsService.getZiGouLiJianHotGoods(acceptData.getDevice()); |
| | | } catch (Exception e) { |
| | | } |
| | | if (list != null && list.size() > 0) |
| | | for (int i = list.size() - 1; i >= 0; i--) { |
| | | TLJBuyGoods goods = list.get(i); |
| | | TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods.getGoods(), |
| | | TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE + "", null); |
| | | String hongBao = TaoBaoUtil.getGoodsHongBaoInfo(goods.getGoods(), |
| | | TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE,false); |
| | | TLJBuyHongBaoVO vo = new TLJBuyHongBaoVO(); |
| | | vo.setLeft(goods.getLeftHongBaoCount()); |
| | | vo.setMoney(hongBao); |
| | | vo.setTagName("付款立减 " + hongBao); |
| | | vo.setTip(""); |
| | | vo.setTotal(goods.getTotalHongBaoCount()); |
| | | extra.setTljBuyHongBao(vo); |
| | | extra.setPictureTag(new ClientTextStyleVO("立减TOP" + (i + 1), "#E5005C", "#FCE431", null)); |
| | | extra.setRecommend(true); |
| | | extra.setSpreadMoney(vo.getTagName()); |
| | | array.add(0, gson.toJson(extra)); |
| | | } |
| | | } |
| | | if (page == 1) { |
| | | List<TLJBuyGoods> list = null; |
| | | try { |
| | | list = homeRecommendGoodsService.getZiGouLiJianHotGoods(acceptData.getDevice()); |
| | | } catch (Exception e) { |
| | | } |
| | | if (list != null && list.size() > 0) |
| | | for (int i = list.size() - 1; i >= 0; i--) { |
| | | TLJBuyGoods goods = list.get(i); |
| | | TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods.getGoods(), |
| | | TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE + "", null); |
| | | String hongBao = TaoBaoUtil.getGoodsHongBaoInfo(goods.getGoods(), |
| | | TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE, false); |
| | | TLJBuyHongBaoVO vo = new TLJBuyHongBaoVO(); |
| | | vo.setLeft(goods.getLeftHongBaoCount()); |
| | | vo.setMoney(hongBao); |
| | | vo.setTagName("付款立减 " + hongBao); |
| | | vo.setTip(""); |
| | | vo.setTotal(goods.getTotalHongBaoCount()); |
| | | extra.setTljBuyHongBao(vo); |
| | | extra.setPictureTag(new ClientTextStyleVO("立减TOP" + (i + 1), "#E5005C", "#FCE431", null)); |
| | | extra.setRecommend(true); |
| | | extra.setSpreadMoney(vo.getTagName()); |
| | | array.add(0, gson.toJson(extra)); |
| | | } |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("data", array); |
| | | data.put("count", 1000); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | return; |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | data.put("data", array); |
| | | data.put("count", 1000); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | return; |
| | | } |
| | | |
| | | // 从推荐来 |
| | | if (page <= 1) { |
| | | array.clear(); |
| | | BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); |
| | | if (!StringUtil.isNullOrEmpty(imei) || !StringUtil.isNullOrEmpty(idfa)) { |
| | | long startTime = java.lang.System.currentTimeMillis(); |
| | | // 从推荐来 |
| | | if (page <= 1) { |
| | | array.clear(); |
| | | BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); |
| | | if (!StringUtil.isNullOrEmpty(imei) || !StringUtil.isNullOrEmpty(idfa)) { |
| | | long startTime = java.lang.System.currentTimeMillis(); |
| | | |
| | | TaoBaoSearchResult result = TaoKeApiUtil.guessDeviceLike(page, 50, imei, idfa,""); |
| | | TaoBaoSearchResult result = TaoKeApiUtil.guessDeviceLike(page, 50, imei, idfa, ""); |
| | | |
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null) { |
| | | // 筛选 |
| | | List<TaoBaoGoodsBriefExtra> goodsList = new ArrayList<>(); |
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null) { |
| | | // 筛选 |
| | | List<TaoBaoGoodsBriefExtra> goodsList = new ArrayList<>(); |
| | | |
| | | List<TaoBaoGoodsBrief> gList = recommendGoodsDeleteHistoryService |
| | | .filterGoods(acceptData.getDevice(), result.getTaoBaoGoodsBriefs()); |
| | | List<TaoBaoGoodsBrief> gList = recommendGoodsDeleteHistoryService |
| | | .filterGoods(acceptData.getDevice(), result.getTaoBaoGoodsBriefs()); |
| | | |
| | | // filter |
| | | try { |
| | | // filter |
| | | try { |
| | | |
| | | gList = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(gList); |
| | | } catch (Exception e) { |
| | | } |
| | | gList = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(gList); |
| | | } catch (Exception e) { |
| | | } |
| | | |
| | | // 设备推荐 |
| | | if (gList != null) |
| | | for (TaoBaoGoodsBrief goods : gList) { |
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && goods.getCouponAmount() != null |
| | | && goods.getCouponAmount().compareTo(new BigDecimal("5")) >= 0 |
| | | && goods.getBiz30day() > 1000 |
| | | && !StringUtil.isNullOrEmpty(goods.getPictUrlWhite())) { |
| | | // 设备推荐 |
| | | if (gList != null) |
| | | for (TaoBaoGoodsBrief goods : gList) { |
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && goods.getCouponAmount() != null |
| | | && goods.getCouponAmount().compareTo(new BigDecimal("5")) >= 0 |
| | | && goods.getBiz30day() > 1000 |
| | | && !StringUtil.isNullOrEmpty(goods.getPictUrlWhite())) { |
| | | |
| | | TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, |
| | | proportion.toString(), ""); |
| | | TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, |
| | | proportion.toString(), ""); |
| | | |
| | | extra.setRecommend(true); |
| | | goodsList.add(extra); |
| | | } |
| | | } |
| | | try { |
| | | monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, |
| | | (int) (java.lang.System.currentTimeMillis() - startTime), "推荐数量:" + goodsList.size())); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | extra.setRecommend(true); |
| | | goodsList.add(extra); |
| | | } |
| | | } |
| | | try { |
| | | monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, |
| | | (int) (java.lang.System.currentTimeMillis() - startTime), "推荐数量:" + goodsList.size())); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | Collections.shuffle(goodsList); |
| | | goodsList = goodsList.size() > 20 ? goodsList.subList(0, 20) : goodsList; |
| | | for (TaoBaoGoodsBriefExtra goods : goodsList) { |
| | | array.add(gson.toJson(goods)); |
| | | } |
| | | } else { |
| | | try { |
| | | monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, |
| | | (int) (java.lang.System.currentTimeMillis() - startTime), "无推荐")); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | JSONArray localArray = qualityGoodsService.getRecommendToIndex((page - 1) * pageSize, pageSize, |
| | | proportion.toString()); |
| | | array.addAll(localArray); |
| | | } else {// 从精选库来 |
| | | BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); |
| | | array = qualityGoodsService.getRecommendToIndex((page - 1) * pageSize, pageSize, proportion.toString()); |
| | | if (array == null) { |
| | | out.print(JsonUtil.loadFalseResult("没有更多了")); |
| | | return; |
| | | } |
| | | } |
| | | Collections.shuffle(goodsList); |
| | | goodsList = goodsList.size() > 20 ? goodsList.subList(0, 20) : goodsList; |
| | | for (TaoBaoGoodsBriefExtra goods : goodsList) { |
| | | array.add(gson.toJson(goods)); |
| | | } |
| | | } else { |
| | | try { |
| | | monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, |
| | | (int) (java.lang.System.currentTimeMillis() - startTime), "无推荐")); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | JSONArray localArray = qualityGoodsService.getRecommendToIndex((page - 1) * pageSize, pageSize, |
| | | proportion.toString()); |
| | | array.addAll(localArray); |
| | | } else {// 从精选库来 |
| | | BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); |
| | | array = qualityGoodsService.getRecommendToIndex((page - 1) * pageSize, pageSize, proportion.toString()); |
| | | if (array == null) { |
| | | out.print(JsonUtil.loadFalseResult("没有更多了")); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("data", array); |
| | | data.put("count", 1000); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | data.put("data", array); |
| | | data.put("count", 1000); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 获取首页推荐信息 |
| | | * |
| | | * @param acceptData |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getRecommendInfo") |
| | | public void getRecommendHomeInfo(AcceptData acceptData, PrintWriter out) { |
| | | /** |
| | | * 获取首页推荐信息 |
| | | * |
| | | * @param acceptData |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getRecommendInfo") |
| | | public void getRecommendHomeInfo(AcceptData acceptData, PrintWriter out) { |
| | | |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(),acceptData.getSystem()); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | |
| | | // 首页Banner |
| | | List<RecommendBannerV2> listBanner = superRecommendBannerV2Service |
| | | .getSuperRecommendBannerV2sBySystem(system.getId()); |
| | | // 首页Banner |
| | | List<RecommendBannerV2> listBanner = superRecommendBannerV2Service |
| | | .getSuperRecommendBannerV2sBySystem(system.getId()); |
| | | |
| | | JSONObject root = new JSONObject(); |
| | | root.put("banner", listBanner); |
| | | JSONObject root = new JSONObject(); |
| | | root.put("banner", listBanner); |
| | | |
| | | List<Special> honestList = null; |
| | | List<Special> specialList = null; |
| | | List<Special> honestList = null; |
| | | List<Special> specialList = null; |
| | | |
| | | Special miaoShaSpecial = new Special(); |
| | | Special miaoShaSpecial = new Special(); |
| | | |
| | | // 首页推荐专题 |
| | | List<SuperSpecial> listSuper = superSpecialService.listBySystemAndCardCache(system.getId(), "index"); |
| | | // 首页推荐专题 |
| | | List<SuperSpecial> listSuper = superSpecialService.listBySystemAndCardCache(system.getId(), "index"); |
| | | |
| | | if (listSuper != null && listSuper.size() > 0) { |
| | | if (listSuper != null && listSuper.size() > 0) { |
| | | |
| | | honestList = new ArrayList<Special>(); |
| | | honestList = new ArrayList<Special>(); |
| | | |
| | | specialList = new ArrayList<Special>(); |
| | | specialList = new ArrayList<Special>(); |
| | | |
| | | for (int i = 0; i < listSuper.size(); i++) { |
| | | for (int i = 0; i < listSuper.size(); i++) { |
| | | |
| | | Special special = listSuper.get(i).getSpecial(); |
| | | special.setCreatetime(null); |
| | | special.setUpdatetime(null); |
| | | Special special = listSuper.get(i).getSpecial(); |
| | | special.setCreatetime(null); |
| | | special.setUpdatetime(null); |
| | | |
| | | if ("限时秒杀".equals(special.getName())) { |
| | | miaoShaSpecial = special; |
| | | continue; |
| | | } |
| | | if ("限时秒杀".equals(special.getName())) { |
| | | miaoShaSpecial = special; |
| | | continue; |
| | | } |
| | | |
| | | if (i < 5) { |
| | | // 5大专题 |
| | | honestList.add(special); |
| | | } else { |
| | | // 其他专题 |
| | | specialList.add(special); |
| | | } |
| | | if (i < 5) { |
| | | // 5大专题 |
| | | honestList.add(special); |
| | | } else { |
| | | // 其他专题 |
| | | specialList.add(special); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | root.put("honest", honestList); |
| | | root.put("special", specialList); |
| | | root.put("honest", honestList); |
| | | root.put("special", specialList); |
| | | |
| | | /* 限时秒杀 - 时间处理 */ |
| | | JSONObject msJSON = JSONObject.fromObject(new Gson().toJson(miaoShaSpecial)); |
| | | /* 限时秒杀 - 时间处理 */ |
| | | JSONObject msJSON = JSONObject.fromObject(new Gson().toJson(miaoShaSpecial)); |
| | | |
| | | // 获取秒杀 |
| | | int[] hours = new int[] { 0, 9, 12, 14, 16, 20, 22 }; |
| | | int hour = -1; |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTimeInMillis(Long.parseLong(acceptData.getTime())); |
| | | int nowHour = calendar.get(Calendar.HOUR_OF_DAY); |
| | | for (int i = 0; i < hours.length - 1; i++) { |
| | | if (nowHour >= hours[i] && nowHour < hours[i + 1]) { |
| | | hour = hours[i + 1]; |
| | | break; |
| | | } |
| | | } |
| | | // 获取秒杀 |
| | | int[] hours = new int[]{0, 9, 12, 14, 16, 20, 22}; |
| | | int hour = -1; |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTimeInMillis(Long.parseLong(acceptData.getTime())); |
| | | int nowHour = calendar.get(Calendar.HOUR_OF_DAY); |
| | | for (int i = 0; i < hours.length - 1; i++) { |
| | | if (nowHour >= hours[i] && nowHour < hours[i + 1]) { |
| | | hour = hours[i + 1]; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (hour < 0) |
| | | hour = 24; |
| | | long time = TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(calendar.getTimeInMillis(), "yyyy-MM-dd"), |
| | | "yyyy-MM-dd") + 1000 * 60 * 60 * hour; |
| | | msJSON.put("time", time); |
| | | if (hour < 0) |
| | | hour = 24; |
| | | long time = TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(calendar.getTimeInMillis(), "yyyy-MM-dd"), |
| | | "yyyy-MM-dd") + 1000 * 60 * 60 * hour; |
| | | msJSON.put("time", time); |
| | | |
| | | root.put("miaoSha", msJSON); |
| | | root.put("miaoSha", msJSON); |
| | | |
| | | out.print(JsonUtil.loadTrueResult(root)); |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(root)); |
| | | } |
| | | |
| | | /** |
| | | * 新版推荐专题管理(1.4.0) |
| | | * |
| | | * @param acceptData |
| | | * @param out |
| | | */ |
| | | @Deprecated |
| | | @RequestMapping(value = "getNewRecommendInfo") |
| | | public void getNewRecommendInfo(AcceptData acceptData, Long uid, String specialCard, String swiperCard, |
| | | PrintWriter out) { |
| | | } |
| | | /** |
| | | * 新版推荐专题管理(1.4.0) |
| | | * |
| | | * @param acceptData |
| | | * @param out |
| | | */ |
| | | @Deprecated |
| | | @RequestMapping(value = "getNewRecommendInfo") |
| | | public void getNewRecommendInfo(AcceptData acceptData, Long uid, String specialCard, String swiperCard, |
| | | PrintWriter out) { |
| | | } |
| | | |
| | | /** |
| | | * 新版推荐专题管理(1.5.3) |
| | | * |
| | | * @param acceptData |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getRecommendIndex") |
| | | public void getRecommendIndex(AcceptData acceptData, Long uid, PrintWriter out) { |
| | | try { |
| | | // 获取设备定义性别 |
| | | int deviceSex = deviceSexService.getDeviceSex(acceptData.getDevice(),acceptData.getSystem()); |
| | | /** |
| | | * 新版推荐专题管理(1.5.3) |
| | | * |
| | | * @param acceptData |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getRecommendIndex") |
| | | public void getRecommendIndex(AcceptData acceptData, Long uid, PrintWriter out) { |
| | | try { |
| | | // 获取设备定义性别 |
| | | int deviceSex = deviceSexService.getDeviceSex(acceptData.getDevice(), acceptData.getSystem()); |
| | | |
| | | // 1、专题模块 |
| | | JSONObject root = specialService.listCacheSpecialToIndex(acceptData, deviceSex,acceptData.getSystem()); |
| | | // 1、专题模块 |
| | | JSONObject root = specialService.listCacheSpecialToIndex(acceptData, deviceSex, acceptData.getSystem()); |
| | | |
| | | // 2、顶部轮播图 |
| | | List<BannerVO> topPicList = getSwiperByCard("index_top", acceptData); |
| | | if (topPicList == null) { |
| | | topPicList = new ArrayList<BannerVO>(); |
| | | } |
| | | root.put("topPicList", JsonUtil.getApiCommonGson().toJson(topPicList)); |
| | | // 2、顶部轮播图 |
| | | List<BannerVO> topPicList = getSwiperByCard("index_top", acceptData); |
| | | if (topPicList == null) { |
| | | topPicList = new ArrayList<BannerVO>(); |
| | | } |
| | | root.put("topPicList", JsonUtil.getApiCommonGson().toJson(topPicList)); |
| | | |
| | | // 3、邀请有奖 |
| | | List<BannerVO> invitePicList = null; |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform()) |
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()),acceptData.getSystem())) { |
| | | // 如果IOS当前版本处于审核状态就不返回 |
| | | } else { |
| | | invitePicList = getSwiperByCard("index_invite", acceptData); |
| | | } |
| | | // 3、邀请有奖 |
| | | List<BannerVO> invitePicList = null; |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform()) |
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem())) { |
| | | // 如果IOS当前版本处于审核状态就不返回 |
| | | } else { |
| | | invitePicList = getSwiperByCard("index_invite", acceptData); |
| | | } |
| | | |
| | | if (invitePicList == null) { |
| | | invitePicList = new ArrayList<BannerVO>(); |
| | | } |
| | | root.put("invitePicList", JsonUtil.getApiCommonGson().toJson(invitePicList)); |
| | | if (invitePicList == null) { |
| | | invitePicList = new ArrayList<BannerVO>(); |
| | | } |
| | | root.put("invitePicList", JsonUtil.getApiCommonGson().toJson(invitePicList)); |
| | | |
| | | // 4、IOS的底部网页链接 |
| | | String platform = acceptData.getPlatform(); |
| | | if ("ios".equalsIgnoreCase(platform)) { |
| | | root.put("htmlLink", configService.getValue(ConfigKeyEnum.indexHtmlLinkIos.getKey(),acceptData.getSystem())); |
| | | } |
| | | // 4、IOS的底部网页链接 |
| | | String platform = acceptData.getPlatform(); |
| | | if ("ios".equalsIgnoreCase(platform)) { |
| | | root.put("htmlLink", configService.getValue(ConfigKeyEnum.indexHtmlLinkIos.getKey(), acceptData.getSystem())); |
| | | } |
| | | |
| | | root.put("spikeGoods", getSpikeGoodsContent(acceptData)); |
| | | root.put("spikeGoods", getSpikeGoodsContent(acceptData)); |
| | | |
| | | out.print(JsonUtil.loadTrueResult(root)); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult(1, "获取数据失败")); |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(root)); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult(1, "获取数据失败")); |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 邀请有奖是否需要返回 |
| | | * |
| | | * @param uid |
| | | * @param acceptData |
| | | * @return |
| | | */ |
| | | public List<BannerVO> getInvitePicList(Long uid, AcceptData acceptData) { |
| | | // 如果IOS当前版本处于审核状态就不返回 |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform()) |
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()),acceptData.getSystem())) { |
| | | return null; |
| | | } |
| | | /** |
| | | * 邀请有奖是否需要返回 |
| | | * |
| | | * @param uid |
| | | * @param acceptData |
| | | * @return |
| | | */ |
| | | public List<BannerVO> getInvitePicList(Long uid, AcceptData acceptData) { |
| | | // 如果IOS当前版本处于审核状态就不返回 |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform()) |
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem())) { |
| | | return null; |
| | | } |
| | | |
| | | List<BannerVO> invitePicList = getSwiperByCard("index_invite", acceptData); |
| | | List<BannerVO> invitePicList = getSwiperByCard("index_invite", acceptData); |
| | | |
| | | return invitePicList; |
| | | } |
| | | return invitePicList; |
| | | } |
| | | |
| | | public List<BannerVO> getSwiperByCard(String card, AcceptData acceptData) { |
| | | List<BannerVO> swiperList = null; |
| | | try { |
| | | swiperList = swiperPictureService.getByBannerCardAndVersion(card, acceptData.getPlatform(), |
| | | Integer.parseInt(acceptData.getVersion()),acceptData.getSystem()); |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | e.printStackTrace(); |
| | | } |
| | | return swiperList; |
| | | } |
| | | public List<BannerVO> getSwiperByCard(String card, AcceptData acceptData) { |
| | | List<BannerVO> swiperList = null; |
| | | try { |
| | | swiperList = swiperPictureService.getByBannerCardAndVersion(card, acceptData.getPlatform(), |
| | | Integer.parseInt(acceptData.getVersion()), acceptData.getSystem()); |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | e.printStackTrace(); |
| | | } |
| | | 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; |
| | | } |
| | | 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); |
| | | 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 = RedisKeyEnum.getRedisKey(RedisKeyEnum.spikeGoodsHour,acceptData.getPlatform() +"-"+acceptData.getVersion()); |
| | | String cachekey = RedisKeyEnum.getRedisKey(RedisKeyEnum.spikeGoodsList,acceptData.getPlatform() +"-"+acceptData.getVersion()); |
| | | JSONArray array = null; |
| | | String timekey = RedisKeyEnum.getRedisKey(RedisKeyEnum.spikeGoodsHour, acceptData.getPlatform() + "-" + acceptData.getVersion()); |
| | | String cachekey = RedisKeyEnum.getRedisKey(RedisKeyEnum.spikeGoodsList, acceptData.getPlatform() + "-" + acceptData.getVersion()); |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | JumpDetailV2 jumpDetail = jumpDetailV2Service.getByTypeCache("web"); |
| | | if (array == null) { |
| | | array = new JSONArray(); |
| | | 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); |
| | | } |
| | | } |
| | | JumpDetailV2 jumpDetail = jumpDetailV2Service.getByTypeCache("web",acceptData.getSystem()); |
| | | if (array == null) { |
| | | array = new JSONArray(); |
| | | |
| | | BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) |
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); |
| | | BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) |
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); |
| | | |
| | | // 缓存中不存在 |
| | | List<QualityFactory> listGoods = qualityGoodsService.listFlashSaleRandGoods(); |
| | | if (listGoods == null) { |
| | | listGoods = new ArrayList<QualityFactory>(); |
| | | } |
| | | // 缓存中不存在 |
| | | List<QualityFactory> listGoods = qualityGoodsService.listFlashSaleRandGoods(); |
| | | if (listGoods == null) { |
| | | listGoods = new ArrayList<QualityFactory>(); |
| | | } |
| | | |
| | | /* 遍历列表数据 */ |
| | | /* 遍历列表数据 */ |
| | | |
| | | for (QualityFactory qualityFactory : listGoods) { |
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = qualityFactory.getTaoBaoGoodsBrief(); |
| | | if (taoBaoGoodsBrief == null) { |
| | | continue; |
| | | } |
| | | JSONObject goods = new JSONObject(); |
| | | goods.put("goods", gson |
| | | .toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null))); |
| | | goods.put("jumpDetail", jumpDetail); |
| | | JSONObject params = new JSONObject(); |
| | | params.put("url", configService.getValue(ConfigKeyEnum.spikeGoodsLink.getKey(),acceptData.getSystem()) + "?id=" + taoBaoGoodsBrief.getAuctionId()); |
| | | goods.put("params", params); |
| | | for (QualityFactory qualityFactory : listGoods) { |
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = qualityFactory.getTaoBaoGoodsBrief(); |
| | | if (taoBaoGoodsBrief == null) { |
| | | continue; |
| | | } |
| | | JSONObject goods = new JSONObject(); |
| | | goods.put("goods", gson |
| | | .toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null))); |
| | | goods.put("jumpDetail", jumpDetail); |
| | | JSONObject params = new JSONObject(); |
| | | params.put("url", configService.getValue(ConfigKeyEnum.spikeGoodsLink.getKey(), acceptData.getSystem()) + "?id=" + taoBaoGoodsBrief.getAuctionId()); |
| | | goods.put("params", params); |
| | | |
| | | // 1.5.4及以后返回 |
| | | if (VersionUtil.greaterThan_1_5_40(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | array.add(goods); |
| | | } else { |
| | | array.add(goods.optJSONObject("goods")); |
| | | } |
| | | } |
| | | // 1.5.4及以后返回 |
| | | if (VersionUtil.greaterThan_1_5_40(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | array.add(goods); |
| | | } else { |
| | | array.add(goods.optJSONObject("goods")); |
| | | } |
| | | } |
| | | |
| | | // 缓存半个小时 |
| | | redisManager.cacheCommonString(cachekey, array.toString(), 60 * 30); |
| | | } |
| | | Long endTime = nextTime.getTimeInMillis() - java.lang.System.currentTimeMillis(); |
| | | // 缓存半个小时 |
| | | 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); |
| | | JSONObject root = new JSONObject(); |
| | | root.put("time", nextTime.getTimeInMillis()); |
| | | root.put("endTime", endTime > 0 ? endTime : 0); |
| | | root.put("listgoods", array); |
| | | |
| | | JSONObject params = new JSONObject(); |
| | | params.put("url", configService.getValue(ConfigKeyEnum.spikeGoodsLink.getKey(),acceptData.getSystem())); |
| | | JSONObject params = new JSONObject(); |
| | | params.put("url", configService.getValue(ConfigKeyEnum.spikeGoodsLink.getKey(), acceptData.getSystem())); |
| | | |
| | | root.put("params", params); |
| | | root.put("jumpDetail", jumpDetail); |
| | | root.put("params", params); |
| | | root.put("jumpDetail", jumpDetail); |
| | | |
| | | return root; |
| | | } |
| | | return root; |
| | | } |
| | | |
| | | /** |
| | | * 限时秒杀 1.5.3 |
| | | * |
| | | * @param acceptData |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getSpikeGoods") |
| | | public void getSpikeGoods(AcceptData acceptData, PrintWriter out) { |
| | | JSONObject root = getSpikeGoodsContent(acceptData); |
| | | out.print(JsonUtil.loadTrueResult(root)); |
| | | } |
| | | /** |
| | | * 限时秒杀 1.5.3 |
| | | * |
| | | * @param acceptData |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getSpikeGoods") |
| | | public void getSpikeGoods(AcceptData acceptData, PrintWriter out) { |
| | | JSONObject root = getSpikeGoodsContent(acceptData); |
| | | out.print(JsonUtil.loadTrueResult(root)); |
| | | } |
| | | |
| | | /** |
| | | * 商品基本详情 (1.4.0) |
| | | * |
| | | * @param acceptData |
| | | * @param id |
| | | * @param uid |
| | | * 页面来源 |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getgoodsinfo", method = RequestMethod.POST) |
| | | public void getGoodsInfo(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) { |
| | | /** |
| | | * 商品基本详情 (1.4.0) |
| | | * |
| | | * @param acceptData |
| | | * @param id |
| | | * @param uid 页面来源 |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getgoodsinfo", method = RequestMethod.POST) |
| | | public void getGoodsInfo(AcceptData acceptData, String id, Long uid, String from, PrintWriter out) { |
| | | |
| | | if (id == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请上传id")); |
| | | return; |
| | | } |
| | | if (id == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请上传id")); |
| | | return; |
| | | } |
| | | |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(),acceptData.getSystem()); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("invalid", false); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("invalid", false); |
| | | |
| | | // IOS是否正在上线 |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())) { |
| | | String version = acceptData.getVersion(); |
| | | data.put("iosOnling", configService.iosOnLining(Integer.parseInt(version),acceptData.getSystem())); |
| | | } |
| | | // IOS是否正在上线 |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())) { |
| | | String version = acceptData.getVersion(); |
| | | data.put("iosOnling", configService.iosOnLining(Integer.parseInt(version), acceptData.getSystem())); |
| | | } |
| | | |
| | | long startTime = java.lang.System.currentTimeMillis(); |
| | | long startTime = java.lang.System.currentTimeMillis(); |
| | | |
| | | // 获取淘客参数 |
| | | ClientTBPid clientTBPid = null; |
| | | // 获取淘客参数 |
| | | ClientTBPid clientTBPid = null; |
| | | |
| | | // 用户未登录 |
| | | if (acceptData.getPlatform().equalsIgnoreCase("android")) { |
| | | clientTBPid = tbPidService.getAndroidDefault(); |
| | | } else { |
| | | clientTBPid = tbPidService.getIOSDefault(); |
| | | } |
| | | // 用户未登录 |
| | | if (acceptData.getPlatform().equalsIgnoreCase("android")) { |
| | | clientTBPid = tbPidService.getAndroidDefault(); |
| | | } else { |
| | | clientTBPid = tbPidService.getIOSDefault(); |
| | | } |
| | | |
| | | LogHelper.test("获取PID耗时:" + (java.lang.System.currentTimeMillis() - startTime)); |
| | | LogHelper.test("获取PID耗时:" + (java.lang.System.currentTimeMillis() - startTime)); |
| | | |
| | | final List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); |
| | | // 是否在服务端进行转链 |
| | | boolean convertInServer = configService.isConvertTaoBaoLinkInServer(acceptData.getSystem()); |
| | | final List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); |
| | | // 是否在服务端进行转链 |
| | | boolean convertInServer = configService.isConvertTaoBaoLinkInServer(acceptData.getSystem()); |
| | | |
| | | JSONObject ticket = new JSONObject(); |
| | | TaoBaoGoodsBrief goods = null; |
| | | JSONObject ticket = new JSONObject(); |
| | | TaoBaoGoodsBrief goods = null; |
| | | |
| | | if (!convertInServer) { |
| | | try { |
| | | goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(id); |
| | | if (goods == null) { |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAppKey(TaoBaoConstant.TAOBAO_COMMON_APPKEY); |
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_COMMON_APPSECRET); |
| | | 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() { |
| | | @Override |
| | | public void run() { |
| | | taoBaoGoodsCacheUtil.saveCommonTaoBaoGoodsInfo(finalGoods); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } catch (TaobaoGoodsDownException e) { |
| | | // 商品下架 |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | taoBaoGoodsUpdateService.offlineTaoBaoGoods(id); |
| | | } |
| | | }); |
| | | if (!convertInServer) { |
| | | try { |
| | | goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(id); |
| | | if (goods == null) { |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAppKey(TaoBaoConstant.TAOBAO_COMMON_APPKEY); |
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_COMMON_APPSECRET); |
| | | 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() { |
| | | @Override |
| | | public void run() { |
| | | taoBaoGoodsCacheUtil.saveCommonTaoBaoGoodsInfo(finalGoods); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } catch (TaobaoGoodsDownException e) { |
| | | // 商品下架 |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | taoBaoGoodsUpdateService.offlineTaoBaoGoods(id); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | } |
| | | |
| | | } else { |
| | | final String clientPid = clientTBPid.getPid(); |
| | | String appId = clientPid.split("_")[2]; |
| | | TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(appId); |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAdzoneId(clientPid.split("_")[3]); |
| | | app.setAppKey(config.getAppKey()); |
| | | app.setAppSecret(config.getAppSecret()); |
| | | app.setPid(clientPid); |
| | | } else { |
| | | final String clientPid = clientTBPid.getPid(); |
| | | String appId = clientPid.split("_")[2]; |
| | | TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(appId); |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAdzoneId(clientPid.split("_")[3]); |
| | | app.setAppKey(config.getAppKey()); |
| | | app.setAppSecret(config.getAppSecret()); |
| | | app.setPid(clientPid); |
| | | |
| | | try { |
| | | goods = TaoKeApiUtil.searchGoodsDetail(id, app); |
| | | if (goods != null) { |
| | | ticket.put("clickUrl", goods.getAuctionUrl()); |
| | | // 测试使用 |
| | | ticket.put("couponUrl", goods.getCouponLink()); |
| | | data.put("ticket", ticket); |
| | | } |
| | | try { |
| | | goods = TaoKeApiUtil.searchGoodsDetail(id, app); |
| | | if (goods != null) { |
| | | ticket.put("clickUrl", goods.getAuctionUrl()); |
| | | // 测试使用 |
| | | ticket.put("couponUrl", goods.getCouponLink()); |
| | | data.put("ticket", ticket); |
| | | } |
| | | |
| | | if (goods.getTkRate() == null || new BigDecimal(0).compareTo(goods.getTkRate()) == 0) { |
| | | TaoBaoGoodsBrief linkInfo = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app,null,null); |
| | | if (linkInfo != null) { |
| | | goods.setAuctionUrl(linkInfo.getAuctionUrl()); |
| | | goods.setCouponLink(linkInfo.getCouponLink()); |
| | | goods.setTkRate(linkInfo.getTkRate()); |
| | | } |
| | | } |
| | | if (goods.getTkRate() == null || new BigDecimal(0).compareTo(goods.getTkRate()) == 0) { |
| | | TaoBaoGoodsBrief linkInfo = TaoKeApiUtil.specialConvertCouponV2(goods.getAuctionId(), app, null, null); |
| | | if (linkInfo != null) { |
| | | goods.setAuctionUrl(linkInfo.getAuctionUrl()); |
| | | goods.setCouponLink(linkInfo.getCouponLink()); |
| | | goods.setTkRate(linkInfo.getTkRate()); |
| | | } |
| | | } |
| | | |
| | | } catch (NumberFormatException e) { |
| | | e.printStackTrace(); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | taoBaoGoodsUpdateService.offlineTaoBaoGoods(id); |
| | | } |
| | | }); |
| | | } |
| | | } catch (NumberFormatException e) { |
| | | e.printStackTrace(); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | taoBaoGoodsUpdateService.offlineTaoBaoGoods(id); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | if (goods != null) { |
| | | goodsList.add(goods); |
| | | final TaoBaoGoodsBrief newGoods = goods; |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | try { |
| | | // 更新商品 |
| | | LogHelper.test("更新商品详情:" + newGoods.getAuctionId()); |
| | | taoBaoGoodsUpdateService.updateTaoBaoGoods(newGoods); |
| | | } catch (TaobaoGoodsUpdateException e) { |
| | | if (goods != null) { |
| | | goodsList.add(goods); |
| | | final TaoBaoGoodsBrief newGoods = goods; |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | try { |
| | | // 更新商品 |
| | | LogHelper.test("更新商品详情:" + newGoods.getAuctionId()); |
| | | taoBaoGoodsUpdateService.updateTaoBaoGoods(newGoods); |
| | | } catch (TaobaoGoodsUpdateException e) { |
| | | |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | TaoBaoGoodsBrief tb = null; |
| | | if (goodsList.size() > 0) { |
| | | tb = goodsList.get(0); |
| | | } |
| | | TaoBaoGoodsBrief tb = null; |
| | | if (goodsList.size() > 0) { |
| | | tb = goodsList.get(0); |
| | | } |
| | | |
| | | if (tb == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品不存在")); |
| | | return; |
| | | } |
| | | if (tb == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品不存在")); |
| | | return; |
| | | } |
| | | |
| | | if (tb.getImgList() == null) { |
| | | tb.setImgList(new ArrayList<>()); |
| | | } |
| | | if (tb.getImgList() == null) { |
| | | tb.setImgList(new ArrayList<>()); |
| | | } |
| | | |
| | | tb.getImgList().add(0, tb.getPictUrl()); |
| | | tb.getImgList().add(0, tb.getPictUrl()); |
| | | |
| | | List<String> finalImgList = new ArrayList<>(); |
| | | for (String img : tb.getImgList()) { |
| | | finalImgList.add(TbImgUtil.getTBSizeImg(img, 600)); |
| | | } |
| | | if (!StringUtil.isNullOrEmpty(tb.getPictUrlWhite())) |
| | | finalImgList.add(0, tb.getPictUrlWhite()); |
| | | List<String> finalImgList = new ArrayList<>(); |
| | | for (String img : tb.getImgList()) { |
| | | finalImgList.add(TbImgUtil.getTBSizeImg(img, 600)); |
| | | } |
| | | if (!StringUtil.isNullOrEmpty(tb.getPictUrlWhite())) |
| | | finalImgList.add(0, tb.getPictUrlWhite()); |
| | | |
| | | // 大淘客商品过滤 |
| | | try { |
| | | goods = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(goods).getGoods(); |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | JSONObject goodsJson = new JSONObject(); |
| | | goodsJson.put("auctionId", tb.getAuctionId()); |
| | | goodsJson.put("imgList", finalImgList); |
| | | goodsJson.put("title", tb.getTitle()); |
| | | goodsJson.put("userType", tb.getUserType() == 1 ? 2 : 1); |
| | | goodsJson.put("price", tb.getReservePrice().toString()); |
| | | goodsJson.put("zkPrice", MoneyBigDecimalUtil.getWithNoZera(tb.getZkPrice()).toString()); |
| | | // 大淘客商品过滤 |
| | | try { |
| | | goods = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(goods).getGoods(); |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | JSONObject goodsJson = new JSONObject(); |
| | | goodsJson.put("auctionId", tb.getAuctionId()); |
| | | goodsJson.put("imgList", finalImgList); |
| | | goodsJson.put("title", tb.getTitle()); |
| | | goodsJson.put("userType", tb.getUserType() == 1 ? 2 : 1); |
| | | goodsJson.put("price", tb.getReservePrice().toString()); |
| | | goodsJson.put("zkPrice", MoneyBigDecimalUtil.getWithNoZera(tb.getZkPrice()).toString()); |
| | | |
| | | // 30天销量 |
| | | goodsJson.put("saleCount", TaoBaoUtil.getSaleCount(tb.getBiz30day())); |
| | | goodsJson.put("salesCount", TaoBaoUtil.getSaleCount(tb.getBiz30day())); |
| | | // 30天销量 |
| | | goodsJson.put("saleCount", TaoBaoUtil.getSaleCount(tb.getBiz30day())); |
| | | goodsJson.put("salesCount", TaoBaoUtil.getSaleCount(tb.getBiz30day())); |
| | | |
| | | // 分享赚 |
| | | BigDecimal shareMoney = taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb,acceptData.getSystem()); |
| | | data.put("shareMoney", "¥" + shareMoney); |
| | | // 分享赚人提示 |
| | | List<ShamUser> listShareUser = new ArrayList<ShamUser>(); |
| | | if (tb.getBiz30day() >= 1000) { |
| | | listShareUser = shamUserService.listRandShareUser(10, shareMoney, 1, 5); |
| | | } |
| | | // 分享赚 |
| | | BigDecimal shareMoney = taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb, acceptData.getSystem()); |
| | | data.put("shareMoney", "¥" + shareMoney); |
| | | // 分享赚人提示 |
| | | List<ShamUser> listShareUser = new ArrayList<ShamUser>(); |
| | | if (tb.getBiz30day() >= 1000) { |
| | | listShareUser = shamUserService.listRandShareUser(10, shareMoney, 1, 5); |
| | | } |
| | | |
| | | // 判断收藏 |
| | | if (uid == null) { |
| | | data.put("collected", false); |
| | | } else { |
| | | CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id, |
| | | Constant.SOURCE_TYPE_TAOBAO); |
| | | data.put("collected", collectionGoods != null ? true : false); |
| | | } |
| | | // 判断收藏 |
| | | if (uid == null) { |
| | | data.put("collected", false); |
| | | } else { |
| | | CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id, |
| | | Constant.SOURCE_TYPE_TAOBAO); |
| | | data.put("collected", collectionGoods != null ? true : false); |
| | | } |
| | | |
| | | // 测试 |
| | | SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, |
| | | "goods_detail_jump_taobao"); |
| | | if ("1".equalsIgnoreCase((params.getValue() + "").trim())) { |
| | | data.put("native", true); |
| | | } else { |
| | | data.put("native", false); |
| | | } |
| | | // 测试 |
| | | SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, |
| | | "goods_detail_jump_taobao"); |
| | | if ("1".equalsIgnoreCase((params.getValue() + "").trim())) { |
| | | data.put("native", true); |
| | | } else { |
| | | data.put("native", false); |
| | | } |
| | | |
| | | // 获取PID |
| | | String pid = clientTBPid.getPid(); |
| | | LogHelper.test(String.format("PID: uid-%s pid-%s", uid + "", pid)); |
| | | // 获取PID |
| | | String pid = clientTBPid.getPid(); |
| | | LogHelper.test(String.format("PID: uid-%s pid-%s", uid + "", pid)); |
| | | |
| | | // 是否有券 |
| | | goodsJson.put("coupon", StringUtil.isNullOrEmpty(tb.getCouponInfo()) ? false : true); |
| | | // 是否有券 |
| | | goodsJson.put("coupon", StringUtil.isNullOrEmpty(tb.getCouponInfo()) ? false : true); |
| | | |
| | | // 领券人列表 |
| | | List<ShamUser> listCouponUser = new ArrayList<ShamUser>(); |
| | | // 领券人列表 |
| | | List<ShamUser> listCouponUser = new ArrayList<ShamUser>(); |
| | | |
| | | String hongBao = null; |
| | | String hongBao = null; |
| | | |
| | | // 获取券信息 |
| | | if (!StringUtil.isNullOrEmpty(tb.getCouponInfo()) && tb.getCouponAmount() != null |
| | | && tb.getCouponAmount().compareTo(new BigDecimal(0)) > 0 && tb.getCouponEffectiveStartTime() != null |
| | | && tb.getCouponEffectiveEndTime() != null) { |
| | | BigDecimal quanPrice = TaoBaoUtil.getCouponPrice(tb); |
| | | JSONObject couponInfo = new JSONObject(); |
| | | couponInfo.put("couponPrice", MoneyBigDecimalUtil.getWithNoZera(quanPrice).toString()); |
| | | // 获取券信息 |
| | | if (!StringUtil.isNullOrEmpty(tb.getCouponInfo()) && tb.getCouponAmount() != null |
| | | && tb.getCouponAmount().compareTo(new BigDecimal(0)) > 0 && tb.getCouponEffectiveStartTime() != null |
| | | && tb.getCouponEffectiveEndTime() != null) { |
| | | BigDecimal quanPrice = TaoBaoUtil.getCouponPrice(tb); |
| | | JSONObject couponInfo = new JSONObject(); |
| | | couponInfo.put("couponPrice", MoneyBigDecimalUtil.getWithNoZera(quanPrice).toString()); |
| | | |
| | | if (from != null && from.equals("miandan")) { |
| | | // 免单商品 |
| | | hongBao = "¥" + quanPrice.toString(); |
| | | } |
| | | if (from != null && from.equals("miandan")) { |
| | | // 免单商品 |
| | | hongBao = "¥" + quanPrice.toString(); |
| | | } |
| | | |
| | | String token = ""; |
| | | if (!StringUtil.isNullOrEmpty(tb.getCouponLink()) |
| | | && VersionUtil.greaterThan_1_5_60(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | token = redisManager.getCommonTaoToken(tb.getAuctionId()); |
| | | if (StringUtil.isNullOrEmpty(token)) { |
| | | token = TaoKeApiUtil.getTKToken(tb.getPictUrl(), tb.getTitle(), tb.getCouponLink()); |
| | | redisManager.saveCommonTaoToken(tb.getAuctionId(), token); |
| | | } |
| | | } |
| | | if (!VersionUtil.greaterThan_1_5_60(acceptData.getPlatform(), acceptData.getVersion())) |
| | | tb.setCouponLinkTaoToken(token); |
| | | String token = ""; |
| | | if (!StringUtil.isNullOrEmpty(tb.getCouponLink()) |
| | | && VersionUtil.greaterThan_1_5_60(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | token = redisManager.getCommonTaoToken(tb.getAuctionId()); |
| | | if (StringUtil.isNullOrEmpty(token)) { |
| | | token = TaoKeApiUtil.getTKToken(tb.getPictUrl(), tb.getTitle(), tb.getCouponLink()); |
| | | redisManager.saveCommonTaoToken(tb.getAuctionId(), token); |
| | | } |
| | | } |
| | | if (!VersionUtil.greaterThan_1_5_60(acceptData.getPlatform(), acceptData.getVersion())) |
| | | tb.setCouponLinkTaoToken(token); |
| | | |
| | | // 服务端转链 |
| | | // if (convertInServer && |
| | | // !StringUtil.isNullOrEmpty(tb.getCouponLink())) { |
| | | couponInfo.put("couponUrl", tb.getCouponLink()); |
| | | // } else { |
| | | // couponInfo.put("couponUrl", |
| | | // TaoBaoCouponUtil.getCoupleUrl(tb.getCouponActivityId() + "", pid, |
| | | // tb.getAuctionId() + "")); |
| | | // } |
| | | // 服务端转链 |
| | | // if (convertInServer && |
| | | // !StringUtil.isNullOrEmpty(tb.getCouponLink())) { |
| | | couponInfo.put("couponUrl", tb.getCouponLink()); |
| | | // } else { |
| | | // couponInfo.put("couponUrl", |
| | | // TaoBaoCouponUtil.getCoupleUrl(tb.getCouponActivityId() + "", pid, |
| | | // tb.getAuctionId() + "")); |
| | | // } |
| | | |
| | | couponInfo.put("couponAmount", MoneyBigDecimalUtil.getWithNoZera(tb.getCouponAmount()).toString()); |
| | | couponInfo.put("couponTime", "使用期限:" + tb.getCouponEffectiveStartTime().replace("-", ".") + "-" |
| | | + tb.getCouponEffectiveEndTime().replace("-", ".")); |
| | | // 券的口令 |
| | | couponInfo.put("couponAmount", MoneyBigDecimalUtil.getWithNoZera(tb.getCouponAmount()).toString()); |
| | | couponInfo.put("couponTime", "使用期限:" + tb.getCouponEffectiveStartTime().replace("-", ".") + "-" |
| | | + tb.getCouponEffectiveEndTime().replace("-", ".")); |
| | | // 券的口令 |
| | | |
| | | if (VersionUtil.greaterThan_1_5_60(acceptData.getPlatform(), acceptData.getVersion())) |
| | | couponInfo.put("couponToken", ""); |
| | | else |
| | | couponInfo.put("couponToken", token); |
| | | goodsJson.put("couponInfo", couponInfo); |
| | | if (VersionUtil.greaterThan_1_5_60(acceptData.getPlatform(), acceptData.getVersion())) |
| | | couponInfo.put("couponToken", ""); |
| | | else |
| | | couponInfo.put("couponToken", token); |
| | | goodsJson.put("couponInfo", couponInfo); |
| | | |
| | | if (tb.getBiz30day() >= 1000) { |
| | | // 领券人列表 |
| | | listCouponUser = shamUserService.listRandCouponUser(5, 1, 300); |
| | | } |
| | | } |
| | | if (tb.getBiz30day() >= 1000) { |
| | | // 领券人列表 |
| | | listCouponUser = shamUserService.listRandCouponUser(5, 1, 300); |
| | | } |
| | | } |
| | | |
| | | // 红包 |
| | | if (hongBao == null) { |
| | | BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); |
| | | if ("taolijin".equalsIgnoreCase(from)) |
| | | proportion = manageService.getTLJShareRate(System.currentTimeMillis(),acceptData.getSystem()); |
| | | hongBao = TaoBaoUtil.getGoodsHongBaoInfo(tb, proportion,false); |
| | | } |
| | | goodsJson.put("hongBao", hongBao); |
| | | // 红包 |
| | | if (hongBao == null) { |
| | | BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); |
| | | if ("taolijin".equalsIgnoreCase(from)) |
| | | proportion = manageService.getTLJShareRate(System.currentTimeMillis(), acceptData.getSystem()); |
| | | hongBao = TaoBaoUtil.getGoodsHongBaoInfo(tb, proportion, false); |
| | | } |
| | | goodsJson.put("hongBao", hongBao); |
| | | |
| | | List<ClientTextStyleVO> labels = new ArrayList<>(); |
| | | goodsJson.put("labels", labels); |
| | | List<ClientTextStyleVO> labels = new ArrayList<>(); |
| | | goodsJson.put("labels", labels); |
| | | |
| | | data.put("tbPidInfo", clientTBPid); |
| | | data.put("tbPidInfo", clientTBPid); |
| | | |
| | | String jumpUrl = "https://item.taobao.com/item.htm?id=" + tb.getAuctionId(); |
| | | String jumpUrl = "https://item.taobao.com/item.htm?id=" + tb.getAuctionId(); |
| | | |
| | | if (!StringUtil.isNullOrEmpty(tb.getCouponActivityId())) {// 有券,跳转券链接 |
| | | jumpUrl = TaoBaoCouponUtil.getCoupleUrl(tb.getCouponActivityId(), clientTBPid.getPid(), |
| | | "" + tb.getAuctionId()); |
| | | } |
| | | if (!StringUtil.isNullOrEmpty(tb.getCouponActivityId())) {// 有券,跳转券链接 |
| | | jumpUrl = TaoBaoCouponUtil.getCoupleUrl(tb.getCouponActivityId(), clientTBPid.getPid(), |
| | | "" + tb.getAuctionId()); |
| | | } |
| | | |
| | | // 设置跳转链接 |
| | | if (convertInServer) { |
| | | if (!StringUtil.isNullOrEmpty(tb.getCouponLink())) |
| | | jumpUrl = tb.getCouponLink(); |
| | | else |
| | | jumpUrl = tb.getAuctionUrl(); |
| | | } |
| | | goodsJson.put("jumpUrl", jumpUrl); |
| | | // 设置跳转链接 |
| | | if (convertInServer) { |
| | | if (!StringUtil.isNullOrEmpty(tb.getCouponLink())) |
| | | jumpUrl = tb.getCouponLink(); |
| | | else |
| | | jumpUrl = tb.getAuctionUrl(); |
| | | } |
| | | goodsJson.put("jumpUrl", jumpUrl); |
| | | |
| | | TaoBaoShopInfo tbShopInfo = redisManager.getTBShopInfo(tb.getShopTitle(), tb.getSellerId(), tb.getAuctionId()); |
| | | if (tbShopInfo != null) { |
| | | String shopType = tbShopInfo.getShopType(); |
| | | if (!StringUtil.isNullOrEmpty(shopType) && shopType.contains("tm.png")) { |
| | | tbShopInfo.setUserType("1"); |
| | | } else { |
| | | tbShopInfo.setUserType("0"); |
| | | } |
| | | TaoBaoShopInfo tbShopInfo = redisManager.getTBShopInfo(tb.getShopTitle(), tb.getSellerId(), tb.getAuctionId()); |
| | | if (tbShopInfo != null) { |
| | | String shopType = tbShopInfo.getShopType(); |
| | | if (!StringUtil.isNullOrEmpty(shopType) && shopType.contains("tm.png")) { |
| | | tbShopInfo.setUserType("1"); |
| | | } else { |
| | | tbShopInfo.setUserType("0"); |
| | | } |
| | | |
| | | String shopLink = tbShopInfo.getShopUrl(); |
| | | if (StringUtil.isNullOrEmpty(shopLink)) { |
| | | tbShopInfo.setShopUrl(TaoBaoUtil.getShopLink(tbShopInfo.getUserId())); |
| | | } |
| | | } |
| | | String shopLink = tbShopInfo.getShopUrl(); |
| | | if (StringUtil.isNullOrEmpty(shopLink)) { |
| | | tbShopInfo.setShopUrl(TaoBaoUtil.getShopLink(tbShopInfo.getUserId())); |
| | | } |
| | | } |
| | | |
| | | // 店铺1.5.4及以后版本 |
| | | if (VersionUtil.greaterThan_1_5_40(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | TaoBaoShop shop = taoBaoShopService.getTaoBaoShop(goods.getAuctionId(), goods.getSellerId()); |
| | | if (shop != null) { |
| | | String shopLink = shop.getShopLink(); |
| | | if (StringUtil.isNullOrEmpty(shopLink)) { |
| | | shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId())); |
| | | } |
| | | goodsJson.put("shopInfo", shop); |
| | | } |
| | | } else { |
| | | goodsJson.put("shopInfo", tbShopInfo); |
| | | } |
| | | // 店铺1.5.4及以后版本 |
| | | if (VersionUtil.greaterThan_1_5_40(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | TaoBaoShop shop = taoBaoShopService.getTaoBaoShop(goods.getAuctionId(), goods.getSellerId()); |
| | | if (shop != null) { |
| | | String shopLink = shop.getShopLink(); |
| | | if (StringUtil.isNullOrEmpty(shopLink)) { |
| | | shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId())); |
| | | } |
| | | goodsJson.put("shopInfo", shop); |
| | | } |
| | | } else { |
| | | goodsJson.put("shopInfo", tbShopInfo); |
| | | } |
| | | |
| | | // 分享路径 |
| | | String shareUrl = String.format("%s?id=" + tb.getAuctionId(), Constant.systemCommonConfig.getAppShareInfoUrl()); |
| | | // 分享路径 |
| | | String shareUrl = String.format("%s?id=" + tb.getAuctionId(), Constant.systemCommonConfig.getAppShareInfoUrl()); |
| | | |
| | | // 是否加入选品库: 0未加入 1 已加入 |
| | | boolean storageState = false; |
| | | if (uid != null) { |
| | | storageState = userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_TAOBAO); |
| | | } |
| | | // 是否加入选品库: 0未加入 1 已加入 |
| | | boolean storageState = false; |
| | | if (uid != null) { |
| | | storageState = userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_TAOBAO); |
| | | } |
| | | |
| | | data.put("storageState", storageState); |
| | | data.put("shareUrl", shareUrl); |
| | | data.put("shareUsers", listShareUser); |
| | | data.put("couponUsers", listCouponUser); |
| | | data.put("detailWebUrl", "http://apph5.banliapp.com/apppage/goods_img.html?id=" + id); |
| | | data.put("storageState", storageState); |
| | | data.put("shareUrl", shareUrl); |
| | | data.put("shareUsers", listShareUser); |
| | | data.put("couponUsers", listCouponUser); |
| | | data.put("detailWebUrl", "http://apph5.banliapp.com/apppage/goods_img.html?id=" + id); |
| | | |
| | | String noRebateHelpLink = null; |
| | | String noRebateHelpLink = null; |
| | | |
| | | // 商品链接 |
| | | String h5Url = String.format("http://%s%s?id=%s&appType=flq", configService.getH5Host(acceptData.getSystem()), |
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), tb.getAuctionId() + ""); |
| | | try { |
| | | data.put("h5Url", HttpUtil.getShortLink(h5Url)); |
| | | } catch (Exception e) { |
| | | data.put("h5Url", h5Url); |
| | | } |
| | | // 商品链接 |
| | | String h5Url = String.format("http://%s%s?id=%s&appType=flq", configService.getH5Host(acceptData.getSystem()), |
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), tb.getAuctionId() + ""); |
| | | try { |
| | | data.put("h5Url", HttpUtil.getShortLink(h5Url)); |
| | | } catch (Exception e) { |
| | | data.put("h5Url", h5Url); |
| | | } |
| | | |
| | | // 是否有返利 |
| | | boolean fanliValid = true; |
| | | // 资金类型 1-返 2-奖 |
| | | int moneyType = 1; |
| | | // 是否有返利 |
| | | boolean fanliValid = true; |
| | | // 资金类型 1-返 2-奖 |
| | | int moneyType = 1; |
| | | |
| | | // 推广红包 |
| | | if (from != null && from.equals("taolijin")) { |
| | | // 计算推广红包 |
| | | String warningRate = configTaoLiJinService.getValueByKey("warning_value", null); |
| | | BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods); |
| | | // 推广红包 |
| | | if (from != null && from.equals("taolijin")) { |
| | | // 计算推广红包 |
| | | String warningRate = configTaoLiJinService.getValueByKey("warning_value", null); |
| | | BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods); |
| | | |
| | | // 推广红包 不能小于1 |
| | | if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品不存在")); |
| | | return; |
| | | } |
| | | // 推广红包 不能小于1 |
| | | if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品不存在")); |
| | | return; |
| | | } |
| | | |
| | | // 是否为新用户 |
| | | boolean isNewUser = userInfoExtraService.isNewUser(uid); |
| | | if (isNewUser) { |
| | | // 判定为老用户: 新人只要使用了新人红包,也就是那1块钱,那么,他看到的分享爆款中的商品-就只能分享。 |
| | | long countRecord = userTaoLiJinRecordService.countRecordByUid(uid); |
| | | if (countRecord > 0) { |
| | | isNewUser = false; |
| | | } |
| | | } |
| | | // 是否为新用户 |
| | | boolean isNewUser = userInfoExtraService.isNewUser(uid); |
| | | if (isNewUser) { |
| | | // 判定为老用户: 新人只要使用了新人红包,也就是那1块钱,那么,他看到的分享爆款中的商品-就只能分享。 |
| | | long countRecord = userTaoLiJinRecordService.countRecordByUid(uid); |
| | | if (countRecord > 0) { |
| | | isNewUser = false; |
| | | } |
| | | } |
| | | |
| | | SpreadHongBao spreadHongBao = new SpreadHongBao(); |
| | | if (isNewUser) { |
| | | spreadHongBao.setMoney("1"); |
| | | } else { |
| | | spreadHongBao.setMoney(spreadMoney.toString()); |
| | | SpreadHongBao spreadHongBao = new SpreadHongBao(); |
| | | if (isNewUser) { |
| | | spreadHongBao.setMoney("1"); |
| | | } else { |
| | | spreadHongBao.setMoney(spreadMoney.toString()); |
| | | |
| | | moneyType = 2; |
| | | fanliValid = false; |
| | | ClientTextStyleVO textStyleVO1 = new ClientTextStyleVO(); |
| | | textStyleVO1.setContent("分享"); |
| | | textStyleVO1.setColor("#666666"); |
| | | ClientTextStyleVO textStyleVO2 = new ClientTextStyleVO(); |
| | | textStyleVO2.setContent("赚奖金"); |
| | | textStyleVO2.setColor("#F14242"); |
| | | ClientTextStyleVO textStyleVO3 = new ClientTextStyleVO(); |
| | | textStyleVO3.setContent(",好友"); |
| | | textStyleVO3.setColor("#666666"); |
| | | ClientTextStyleVO textStyleVO4 = new ClientTextStyleVO(); |
| | | textStyleVO4.setContent("领红包!"); |
| | | textStyleVO4.setColor("#F14242"); |
| | | moneyType = 2; |
| | | fanliValid = false; |
| | | ClientTextStyleVO textStyleVO1 = new ClientTextStyleVO(); |
| | | textStyleVO1.setContent("分享"); |
| | | textStyleVO1.setColor("#666666"); |
| | | ClientTextStyleVO textStyleVO2 = new ClientTextStyleVO(); |
| | | textStyleVO2.setContent("赚奖金"); |
| | | textStyleVO2.setColor("#F14242"); |
| | | ClientTextStyleVO textStyleVO3 = new ClientTextStyleVO(); |
| | | textStyleVO3.setContent(",好友"); |
| | | textStyleVO3.setColor("#666666"); |
| | | ClientTextStyleVO textStyleVO4 = new ClientTextStyleVO(); |
| | | textStyleVO4.setContent("领红包!"); |
| | | textStyleVO4.setColor("#F14242"); |
| | | |
| | | List<ClientTextStyleVO> listText = new ArrayList<ClientTextStyleVO>(); |
| | | listText.add(textStyleVO1); |
| | | listText.add(textStyleVO2); |
| | | listText.add(textStyleVO3); |
| | | listText.add(textStyleVO4); |
| | | List<ClientTextStyleVO> listText = new ArrayList<ClientTextStyleVO>(); |
| | | listText.add(textStyleVO1); |
| | | listText.add(textStyleVO2); |
| | | listText.add(textStyleVO3); |
| | | listText.add(textStyleVO4); |
| | | |
| | | data.put("listTip", listText); |
| | | } |
| | | spreadHongBao.setTip("当日领取,当日内使用,过期失效"); |
| | | goodsJson.put("spreadHongBao", spreadHongBao); |
| | | data.put("listTip", listText); |
| | | } |
| | | spreadHongBao.setTip("当日领取,当日内使用,过期失效"); |
| | | goodsJson.put("spreadHongBao", spreadHongBao); |
| | | |
| | | // 用户剩余可以淘礼金验证 |
| | | UserMoneyExtra userMoneyExtra = userMoneyExtraService.selectByPrimaryKey(uid); |
| | | if (userMoneyExtra == null || userMoneyExtra.getTlj() == null) { |
| | | data.put("userHongbao", new BigDecimal(0).setScale(2).toString()); |
| | | } else { |
| | | data.put("userHongbao", userMoneyExtra.getTlj().setScale(2).toString()); |
| | | } |
| | | // 用户剩余可以淘礼金验证 |
| | | UserMoneyExtra userMoneyExtra = userMoneyExtraService.selectByPrimaryKey(uid); |
| | | if (userMoneyExtra == null || userMoneyExtra.getTlj() == null) { |
| | | data.put("userHongbao", new BigDecimal(0).setScale(2).toString()); |
| | | } else { |
| | | data.put("userHongbao", userMoneyExtra.getTlj().setScale(2).toString()); |
| | | } |
| | | |
| | | noRebateHelpLink = configTaoLiJinService.getValueByKey("share_goods_help_link", null); |
| | | noRebateHelpLink = configTaoLiJinService.getValueByKey("share_goods_help_link", null); |
| | | |
| | | if (Constant.IS_TEST) { |
| | | fanliValid = true; |
| | | goodsJson.put("shareValid", false); |
| | | JSONObject tljNum = new JSONObject(); |
| | | tljNum.put("percent", "80"); |
| | | tljNum.put("num", "8825"); |
| | | goodsJson.put("tljNum", tljNum); |
| | | } |
| | | if (Constant.IS_TEST) { |
| | | fanliValid = true; |
| | | goodsJson.put("shareValid", false); |
| | | JSONObject tljNum = new JSONObject(); |
| | | tljNum.put("percent", "80"); |
| | | tljNum.put("num", "8825"); |
| | | goodsJson.put("tljNum", tljNum); |
| | | } |
| | | |
| | | } else if (from != null && from.equals("taolijin_buy")) { |
| | | noRebateHelpLink = configService.getValue(ConfigKeyEnum.zigoulijianNofanliHelp.getKey(),acceptData.getSystem()); |
| | | // 查询分享库 |
| | | TLJBuyGoods buyGoods = tljBuyGoodsService.selectByAuctionIdAndDay(goods.getAuctionId(), |
| | | TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd")); |
| | | if (buyGoods == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "自购立减红包过期")); |
| | | return; |
| | | } |
| | | } else if (from != null && from.equals("taolijin_buy")) { |
| | | noRebateHelpLink = configService.getValue(ConfigKeyEnum.zigoulijianNofanliHelp.getKey(), acceptData.getSystem()); |
| | | // 查询分享库 |
| | | TLJBuyGoods buyGoods = tljBuyGoodsService.selectByAuctionIdAndDay(goods.getAuctionId(), |
| | | TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd")); |
| | | if (buyGoods == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "自购立减红包过期")); |
| | | return; |
| | | } |
| | | |
| | | fanliValid = true; |
| | | goodsJson.put("shareValid", false); |
| | | String tljHongBao = TaoBaoUtil.getGoodsHongBaoMoney(goods, new BigDecimal(70),false).toString(); |
| | | TLJBuyHongBaoVO vo = new TLJBuyHongBaoVO(); |
| | | vo.setLeft(buyGoods.getLeftHongBaoCount()); |
| | | vo.setMoney(tljHongBao); |
| | | vo.setTagName("付款立减 ¥" + tljHongBao); |
| | | vo.setTip("当日领取,当日内使用,过期失效"); |
| | | vo.setTotal(buyGoods.getTotalHongBaoCount()); |
| | | goodsJson.put("tljBuyHongBao", vo); |
| | | moneyType = 2; |
| | | } |
| | | fanliValid = true; |
| | | goodsJson.put("shareValid", false); |
| | | String tljHongBao = TaoBaoUtil.getGoodsHongBaoMoney(goods, new BigDecimal(70), false).toString(); |
| | | TLJBuyHongBaoVO vo = new TLJBuyHongBaoVO(); |
| | | vo.setLeft(buyGoods.getLeftHongBaoCount()); |
| | | vo.setMoney(tljHongBao); |
| | | vo.setTagName("付款立减 ¥" + tljHongBao); |
| | | vo.setTip("当日领取,当日内使用,过期失效"); |
| | | vo.setTotal(buyGoods.getTotalHongBaoCount()); |
| | | goodsJson.put("tljBuyHongBao", vo); |
| | | moneyType = 2; |
| | | } |
| | | |
| | | goodsJson.put("moneyType", moneyType); |
| | | goodsJson.put("fanliValid", fanliValid); |
| | | data.put("goods", goodsJson); |
| | | goodsJson.put("moneyType", moneyType); |
| | | goodsJson.put("fanliValid", fanliValid); |
| | | data.put("goods", goodsJson); |
| | | |
| | | if (!StringUtil.isNullOrEmpty(noRebateHelpLink)) { |
| | | data.put("noRebateHelpLink", noRebateHelpLink); |
| | | } else { |
| | | data.put("noRebateHelpLink", configService.getValue(ConfigKeyEnum.noRebateHelpLink.getKey(),acceptData.getSystem())); |
| | | } |
| | | if (!StringUtil.isNullOrEmpty(noRebateHelpLink)) { |
| | | data.put("noRebateHelpLink", noRebateHelpLink); |
| | | } else { |
| | | data.put("noRebateHelpLink", configService.getValue(ConfigKeyEnum.noRebateHelpLink.getKey(), acceptData.getSystem())); |
| | | } |
| | | |
| | | // 取消分享活动 |
| | | // if (!StringUtil.isNullOrEmpty(uid) |
| | | // && |
| | | // shareGoodsActivityOrderService.countShareGoodsActivityOrder(Long.parseLong(uid)) |
| | | // > 0) { |
| | | // } else if(!"miandan".equals(from)) { |
| | | // // 非免单商品 |
| | | // JSONObject shareActivity = new JSONObject(); |
| | | // shareActivity.put("moneyDesc", "春节狂欢奖金:¥" + |
| | | // TaoBaoUtil.getGoodsHongBaoMoney(tb, |
| | | // new |
| | | // BigDecimal(hongBaoManageService.get("share_activity_proportion")))); |
| | | // shareActivity.put("ruleDescPicture", |
| | | // "http://img.flqapp.com/resource/share_activity_img.png"); |
| | | // |
| | | // data.put("shareActivity", shareActivity); |
| | | // } |
| | | // 取消分享活动 |
| | | // if (!StringUtil.isNullOrEmpty(uid) |
| | | // && |
| | | // shareGoodsActivityOrderService.countShareGoodsActivityOrder(Long.parseLong(uid)) |
| | | // > 0) { |
| | | // } else if(!"miandan".equals(from)) { |
| | | // // 非免单商品 |
| | | // JSONObject shareActivity = new JSONObject(); |
| | | // shareActivity.put("moneyDesc", "春节狂欢奖金:¥" + |
| | | // TaoBaoUtil.getGoodsHongBaoMoney(tb, |
| | | // new |
| | | // BigDecimal(hongBaoManageService.get("share_activity_proportion")))); |
| | | // shareActivity.put("ruleDescPicture", |
| | | // "http://img.flqapp.com/resource/share_activity_img.png"); |
| | | // |
| | | // data.put("shareActivity", shareActivity); |
| | | // } |
| | | |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | |
| | | final TaoBaoGoodsBrief goodsInfo = tb; |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | // 添加浏览记录 |
| | | try { |
| | | scanHistoryV2Service.addScanHistory(uid, acceptData.getDevice(), goodsInfo); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | final TaoBaoGoodsBrief goodsInfo = tb; |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | // 添加浏览记录 |
| | | try { |
| | | scanHistoryV2Service.addScanHistory(uid, acceptData.getDevice(), goodsInfo); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取图文详情(1.4.0) |
| | | * |
| | | * @param acceptData |
| | | * @param id |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getgoodsdetailimgs", method = RequestMethod.POST) |
| | | public void getgoodsdetailimgs(AcceptData acceptData, String id, PrintWriter out) { |
| | | /** |
| | | * 获取图文详情(1.4.0) |
| | | * |
| | | * @param acceptData |
| | | * @param id |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getgoodsdetailimgs", method = RequestMethod.POST) |
| | | public void getgoodsdetailimgs(AcceptData acceptData, String id, PrintWriter out) { |
| | | |
| | | if (StringUtil.isNullOrEmpty(id)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请上传id")); |
| | | return; |
| | | } |
| | | if (StringUtil.isNullOrEmpty(id)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请上传id")); |
| | | return; |
| | | } |
| | | |
| | | List<String> detailImgs = new ArrayList<>(); |
| | | JSONArray detailImgsSize = new JSONArray(); |
| | | List<String> detailImgs = new ArrayList<>(); |
| | | JSONArray detailImgsSize = new JSONArray(); |
| | | |
| | | List<ImageInfo> imgs = redisManager.getTaoBaoGoodsDetailImgs(Long.parseLong(id),acceptData.getSystem()); |
| | | List<ImageInfo> imgs = redisManager.getTaoBaoGoodsDetailImgs(id, acceptData.getSystem()); |
| | | |
| | | if (imgs != null && imgs.size() > 0) { |
| | | if (imgs != null && imgs.size() > 0) { |
| | | |
| | | for (ImageInfo imgInfo : imgs) { |
| | | detailImgs.add(imgInfo.getPicture()); |
| | | } |
| | | for (ImageInfo imgInfo : imgs) { |
| | | detailImgs.add(imgInfo.getPicture()); |
| | | } |
| | | |
| | | for (ImageInfo imgInfo : imgs) { |
| | | for (ImageInfo imgInfo : imgs) { |
| | | |
| | | if (imgInfo.getWidth() <= 0) { |
| | | detailImgsSize.clear(); |
| | | break; |
| | | } |
| | | if (imgInfo.getWidth() <= 0) { |
| | | detailImgsSize.clear(); |
| | | break; |
| | | } |
| | | |
| | | JSONObject size = new JSONObject(); |
| | | size.put("w", imgInfo.getWidth()); |
| | | size.put("h", imgInfo.getHeight()); |
| | | detailImgsSize.add(size); |
| | | } |
| | | JSONObject size = new JSONObject(); |
| | | size.put("w", imgInfo.getWidth()); |
| | | size.put("h", imgInfo.getHeight()); |
| | | detailImgsSize.add(size); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("detailImgs", detailImgs); |
| | | data.put("detailImgsSize", detailImgsSize); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("detailImgs", detailImgs); |
| | | data.put("detailImgsSize", detailImgsSize); |
| | | |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 商品详情推荐1.4.0 |
| | | * |
| | | * @param acceptData |
| | | * @param id |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getgoodsderivation", method = RequestMethod.POST) |
| | | public void getRecommendGoods(AcceptData acceptData, long id, PrintWriter out) { |
| | | /** |
| | | * 商品详情推荐1.4.0 |
| | | * |
| | | * @param acceptData |
| | | * @param id |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getgoodsderivation", method = RequestMethod.POST) |
| | | public void getRecommendGoods(AcceptData acceptData, String id, PrintWriter out) { |
| | | |
| | | try { |
| | | try { |
| | | |
| | | List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(id, 10); |
| | | // 初始化 |
| | | if (goodsList == null) { |
| | | goodsList = new ArrayList<TaoBaoGoodsBrief>(); |
| | | } |
| | | List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(id, 10); |
| | | // 初始化 |
| | | if (goodsList == null) { |
| | | goodsList = new ArrayList<TaoBaoGoodsBrief>(); |
| | | } |
| | | |
| | | BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); |
| | | BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); |
| | | |
| | | List<TaoBaoGoodsBriefExtra> listExtra = new ArrayList<TaoBaoGoodsBriefExtra>(); |
| | | List<TaoBaoGoodsBriefExtra> listExtra = new ArrayList<TaoBaoGoodsBriefExtra>(); |
| | | |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); |
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); |
| | | app.setAdzoneId(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT.split("_")[3]); |
| | | app.setPid(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT); |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); |
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); |
| | | app.setPid(pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.fanli)); |
| | | app.setAdzoneId(app.getPid().split("_")[3]); |
| | | |
| | | List<Long> ids = new ArrayList<>(); |
| | | for (TaoBaoGoodsBrief goods : goodsList) |
| | | ids.add(goods.getAuctionId()); |
| | | List<String> ids = new ArrayList<>(); |
| | | for (TaoBaoGoodsBrief goods : goodsList) |
| | | ids.add(goods.getAuctionId()); |
| | | |
| | | try { |
| | | goodsList = TaoKeApiUtil.getBatchGoodsInfo(ids); |
| | | } catch (TaoKeApiException e1) { |
| | | e1.printStackTrace(); |
| | | } catch (TaobaoGoodsDownException e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | try { |
| | | goodsList = TaoKeApiUtil.getBatchGoodsInfo(ids); |
| | | } catch (TaoKeApiException e1) { |
| | | e1.printStackTrace(); |
| | | } catch (TaobaoGoodsDownException e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | |
| | | if (goodsList != null && goodsList.size() > 0) |
| | | goodsList.parallelStream().forEach(goods -> { |
| | | if (goods != null) { |
| | | // 获取详情 |
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = null; |
| | | try { |
| | | taoBaoGoodsBrief = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goods.getAuctionId()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (goodsList != null && goodsList.size() > 0) |
| | | goodsList.parallelStream().forEach(goods -> { |
| | | if (goods != null) { |
| | | // 获取详情 |
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = null; |
| | | try { |
| | | taoBaoGoodsBrief = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goods.getAuctionId()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | if (taoBaoGoodsBrief == null) { |
| | | TaoBaoGoodsBrief newGoods = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app,null,null); |
| | | goods.setCouponInfo(newGoods.getCouponInfo()); |
| | | goods.setCouponLink(newGoods.getCouponLink()); |
| | | goods.setTkRate(newGoods.getTkRate()); |
| | | taoBaoGoodsBrief = goods; |
| | | } |
| | | if (taoBaoGoodsBrief == null) { |
| | | TaoBaoGoodsBrief newGoods = TaoKeApiUtil.specialConvertCouponV2(goods.getAuctionId(), app, null, null); |
| | | goods.setCouponInfo(newGoods.getCouponInfo()); |
| | | goods.setCouponLink(newGoods.getCouponLink()); |
| | | goods.setTkRate(newGoods.getTkRate()); |
| | | taoBaoGoodsBrief = goods; |
| | | } |
| | | |
| | | if (taoBaoGoodsBrief != null) { |
| | | listExtra.add( |
| | | TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), "")); |
| | | } |
| | | } |
| | | }); |
| | | if (taoBaoGoodsBrief != null) { |
| | | listExtra.add( |
| | | TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), "")); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | List<TaoBaoGoodsBrief> listQuality = new ArrayList<TaoBaoGoodsBrief>(); |
| | | List<TaoBaoGoodsBrief> listQuality = new ArrayList<>(); |
| | | |
| | | // 取偶数个数据 |
| | | if (listExtra.size() % 2 != 0) { |
| | | listExtra.remove(listExtra.size() - 1); |
| | | } |
| | | // 取偶数个数据 |
| | | if (listExtra.size() % 2 != 0) { |
| | | listExtra.remove(listExtra.size() - 1); |
| | | } |
| | | |
| | | if (listQuality.size() % 2 != 0) { |
| | | listQuality.remove(listQuality.size() - 1); |
| | | } |
| | | if (listQuality.size() % 2 != 0) { |
| | | listQuality.remove(listQuality.size() - 1); |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listExtra)); |
| | | data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listQuality)); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | JSONObject data = new JSONObject(); |
| | | data.put("listQuality", new JSONArray()); |
| | | data.put("listGuess", new JSONArray()); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listExtra)); |
| | | data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listQuality)); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | JSONObject data = new JSONObject(); |
| | | data.put("listQuality", new JSONArray()); |
| | | data.put("listGuess", new JSONArray()); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 活动列表 |
| | | * |
| | | * @param acceptData |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getSpecialActivities") |
| | | public void getSpecialActivities(AcceptData acceptData, Long uid, PrintWriter out, String callback) { |
| | | List<SpecialVO> listSpecial = specialService.listByVersion(0, Integer.MAX_VALUE, "special_activities", |
| | | acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()),acceptData.getSystem()); |
| | | /** |
| | | * 活动列表 |
| | | * |
| | | * @param acceptData |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getSpecialActivities") |
| | | public void getSpecialActivities(AcceptData acceptData, Long uid, PrintWriter out, String callback) { |
| | | List<SpecialVO> listSpecial = specialService.listByVersion(0, Integer.MAX_VALUE, "special_activities", |
| | | acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()), acceptData.getSystem()); |
| | | |
| | | List<SpecialVO> list = new ArrayList<SpecialVO>(); |
| | | if (listSpecial != null) { |
| | | list.addAll(listSpecial); |
| | | } |
| | | List<SpecialVO> list = new ArrayList<SpecialVO>(); |
| | | if (listSpecial != null) { |
| | | list.addAll(listSpecial); |
| | | } |
| | | |
| | | for (int i = 0; i < list.size(); i++) { |
| | | SpecialVO special = list.get(i); |
| | | JumpDetailV2 jumpDetail = special.getJumpDetail(); |
| | | if (jumpDetail != null) { |
| | | jumpDetail.setNeedLogin(special.isJumpLogin()); |
| | | special.setJumpDetail(jumpDetail); |
| | | } |
| | | String name = special.getName(); |
| | | if (StringUtil.isNullOrEmpty(name)) { |
| | | continue; |
| | | } |
| | | } |
| | | for (int i = 0; i < list.size(); i++) { |
| | | SpecialVO special = list.get(i); |
| | | JumpDetailV2 jumpDetail = special.getJumpDetail(); |
| | | if (jumpDetail != null) { |
| | | jumpDetail.setNeedLogin(special.isJumpLogin()); |
| | | special.setJumpDetail(jumpDetail); |
| | | } |
| | | String name = special.getName(); |
| | | if (StringUtil.isNullOrEmpty(name)) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | JSONObject root = new JSONObject(); |
| | | root.put("special", JsonUtil.getApiCommonGson().toJson(list)); |
| | | if (StringUtil.isNullOrEmpty(callback)) |
| | | out.print(JsonUtil.loadTrueResult(root)); |
| | | else |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(root)); |
| | | } |
| | | JSONObject root = new JSONObject(); |
| | | root.put("special", JsonUtil.getApiCommonGson().toJson(list)); |
| | | if (StringUtil.isNullOrEmpty(callback)) |
| | | out.print(JsonUtil.loadTrueResult(root)); |
| | | else |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(root)); |
| | | } |
| | | } |