| | |
| | | package com.yeshi.fanli.controller.client;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.lang.reflect.Type;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Collections;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | |
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.BigDecimalUtil;
|
| | | import org.yeshi.utils.IPUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | |
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.google.gson.JsonElement;
|
| | | import com.google.gson.JsonPrimitive;
|
| | | import com.google.gson.JsonSerializationContext;
|
| | | import com.google.gson.JsonSerializer;
|
| | | import com.yeshi.fanli.dao.mybatis.HongBaoManageMapper;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.Special;
|
| | |
| | | import com.yeshi.fanli.service.inter.config.SystemService;
|
| | | import com.yeshi.fanli.service.inter.goods.CollectionGoodsV2Service;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.HonestService;
|
| | | import com.yeshi.fanli.service.inter.goods.RecommendBannerService;
|
| | | import com.yeshi.fanli.service.inter.goods.RecommendSectionGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.ScanHistoryV2Service;
|
| | |
| | |
|
| | | @Resource
|
| | | private SystemConfigService systemConfigService;
|
| | |
|
| | | @Resource
|
| | | private HonestService honestService;
|
| | |
|
| | | @Resource
|
| | | private CollectionGoodsV2Service collectionGoodsV2Service;
|
| | |
| | | @RequestMapping(value = "getHonestList")
|
| | | public void getHonestList(AcceptData acceptData, PrintWriter out) {
|
| | | System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
|
| | | List<Honest> honestList = honestService.getHonestListCache();
|
| | | 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())
|
| | |
| | |
|
| | | data.put("tbPidInfo", clientTBPid);
|
| | |
|
| | | 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);
|
| | |
|
| | | // taoBaoGoodsBriefExtra.setAuctionUrl(null);
|
| | | data.put("taobao", gson.toJson(taoBaoGoodsBriefExtra));
|
| | | data.put("taobao", taobaoJson);
|
| | | String info = configService.get("detail_prompt");
|
| | | data.put("info", info);
|
| | | String onlyInfo = configService.get("only_info");
|
| | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", count);
|
| | | JSONArray array = new JSONArray();
|
| | | Gson gson = JsonUtil.getApiCommonGson();
|
| | |
|
| | | 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();
|
| | |
|
| | | if (list != null) {
|
| | | Map<String, String> map = hongBaoManageService.convertMap();
|
| | | BigDecimal proportion = manageService.getFanLiRate();
|
| | | for (ScanHistoryV2 sh : list) {
|
| | | TaoBaoGoodsBrief goods = TaoBaoUtil.convert(sh.getCommonGoods());
|
| | | goods.setId(sh.getId());
|
| | | array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, proportion.toString(), "")));
|
| | | TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, proportion.toString(), "");
|
| | | extra.setCreatetime(sh.getCreateTime());
|
| | | array.add(gson.toJson(extra));
|
| | | }
|
| | | }
|
| | | data.put("data", array);
|
| | |
| | |
|
| | | /**
|
| | | * 防止请求频率过高
|
| | | * |
| | | */
|
| | | String key = "linkParse-" + acceptData.getDevice() + "-" + id;
|
| | | if (Constant.IS_OUTNET) {
|
| | | String key = "linkParse-" + acceptData.getDevice() + "-" + id;
|
| | |
|
| | | String value = redisManager.getCommonString(key);
|
| | | if (!StringUtil.isNullOrEmpty(value)) {
|
| | | out.print(JsonUtil.loadFalseResult(11, "请求频率限制"));
|
| | | return;
|
| | | String value = redisManager.getCommonString(key);
|
| | | if (!StringUtil.isNullOrEmpty(value)) {
|
| | | out.print(JsonUtil.loadFalseResult(11, "请求频率限制"));
|
| | | return;
|
| | | }
|
| | | redisManager.cacheCommonString(key, "1", 5);// 5s间隔
|
| | | }
|
| | | redisManager.cacheCommonString(key, "1", 5);// 5s间隔
|
| | |
|
| | | TaoBaoGoodsBrief goods = null;
|
| | | try {
|
| | | goods = redisManager.getTaoBaoGoodsBrief(Long.parseLong(id));
|
| | |
| | | JSONObject invite = new JSONObject();
|
| | | JumpDetailV2 jumpDetail = jumpDetailV2Service.getByTypeCache("invite");
|
| | | invite.put("jumpDetail", jumpDetail);
|
| | | invite.put("picture", "");
|
| | | invite.put("picture", "http://ec-1255749512.file.myqcloud.com/resource/weex/img/invite_input_img.png");
|
| | |
|
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())
|
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) {
|
| | |
| | | // 商品下架
|
| | | ThreadUtil.run(new Runnable() {
|
| | | public void run() {
|
| | | taoBaoGoodsUpdateService.deleteTaoBaoGoods(Long.parseLong(id));
|
| | | taoBaoGoodsUpdateService.offlineTaoBaoGoods(Long.parseLong(id));
|
| | | }
|
| | | });
|
| | |
|
| | |
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | ThreadUtil.run(new Runnable() {
|
| | | public void run() {
|
| | | taoBaoGoodsUpdateService.offlineTaoBaoGoods(Long.parseLong(id));
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | List<String> finalImgList = new ArrayList<>();
|
| | | for (String img : tb.getImgList()) {
|
| | | finalImgList.add(img);
|
| | | finalImgList.add(TbImgUtil.getTBSizeImg(img, 600));
|
| | | }
|
| | |
|
| | | JSONObject goods = new JSONObject();
|
| | |
| | | data.put("goods", goods);
|
| | | data.put("shareUsers", listShareUser);
|
| | | data.put("couponUsers", listCouponUser);
|
| | | data.put("detailWebUrl", "http://apph5.yeshitv.com/apppage/goods_img.html?id=" + id);
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | |
| | | }
|
| | |
|
| | | List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.getRelationGoodsRecommend(id, 10);
|
| | |
|
| | | // 重新做推荐
|
| | | if (goodsList == null || goodsList.size() == 0) {
|
| | |
|
| | | goodsList = new ArrayList<>();
|
| | |
|
| | | 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);
|
| | | // 商品有本地缓存
|
| | | if (cgoods != null) {
|
| | | // 按名字搜索商品
|
| | | SearchFilter sf = new SearchFilter();
|
| | | sf.setKey(cgoods.getTitle().substring(0, cgoods.getTitle().length() / 2));
|
| | |
|
| | | TaoBaoSearchResult result = TaoBaoUtil.search(sf);
|
| | |
|
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null
|
| | | && result.getTaoBaoGoodsBriefs().size() > 0) {
|
| | |
|
| | | for (TaoBaoGoodsBrief gds : result.getTaoBaoGoodsBriefs()) {
|
| | | if (goodsList.size() == 10) {
|
| | | break;
|
| | | }
|
| | | goodsList.add(gds);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 需要另做推荐
|
| | | if (goodsList.size() < 2) {
|
| | | try {
|
| | | List<RecommendSectionGoods> list = recommendSectionGoodsService.getSectionGoods(10);
|
| | | if (list != null) {
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | if (i == 10) {
|
| | | break;
|
| | | }
|
| | | goodsList.add(list.get(i).getTaoBaoGoodsBrief());
|
| | | }
|
| | | }
|
| | | } catch (Exception e2) {
|
| | | e2.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | | // 初始化
|
| | | if (goodsList == null) {
|
| | | goodsList = new ArrayList<TaoBaoGoodsBrief>();
|
| | | }
|
| | |
|
| | | BigDecimal proportion = manageService.getFanLiRate();
|