| | |
| | | package com.yeshi.fanli.controller.client.v2;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.dto.common.CommonContentResult;
|
| | | import com.yeshi.fanli.dto.common.CommonContentTypeEnum;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonTemplateContentService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | /**
|
| | | * 通用模板
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Controller
|
| | | @RequestMapping("api/v2/commoncontent")
|
| | | public class CommonContentControllerV2 {
|
| | |
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private CommonTemplateContentService commonTemplateContentService;
|
| | |
|
| | |
|
| | | /**
|
| | | * 获取内容
|
| | | * |
| | | * @param acceptData
|
| | | * @param key
|
| | | * @param page-页码
|
| | | * @param navId-导航ID
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getNavGoodsList", method = RequestMethod.POST)
|
| | | public void getNavContent(AcceptData acceptData, String key, Integer page, String cid, PrintWriter out) {
|
| | | if (StringUtil.isNullOrEmpty(key)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请传入Key"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (page == null || page < 1) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请传入正确的page"));
|
| | | return;
|
| | | }
|
| | |
|
| | | CommonContentResult result = commonTemplateContentService.getContentList(CommonContentTypeEnum.valueOf(key),
|
| | | cid, page, Constant.PAGE_SIZE);
|
| | |
|
| | | // 保留暂时不开启,待后续开启
|
| | | List<SwiperPicture> bannerList = new ArrayList<>();
|
| | |
|
| | | JSONObject root = new JSONObject();
|
| | | if (page == 1)
|
| | | root.put("bannerList", new Gson().toJson(bannerList));
|
| | |
|
| | | JSONArray array = new JSONArray();
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create();
|
| | | List<TaoBaoGoodsBrief> goodsList = result.getGoodsList();
|
| | | BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : goodsList) {
|
| | | array.add(gson.toJson(GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, fanLiRate, shareRate)));
|
| | | }
|
| | | root.put("goodsList", array);
|
| | | root.put("goodsCount", result.getCount());
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.controller.client.v2; |
| | | |
| | | import java.io.PrintWriter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.entity.goods.CommonGoods; |
| | | import com.yeshi.fanli.lijin.manager.GoodsLijinMnager; |
| | | import com.yeshi.fanli.util.CommonGoodsUtil; |
| | | import com.yeshi.fanli.util.factory.CommonGoodsFactory; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.yeshi.utils.JsonUtil; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.yeshi.fanli.dto.GoodsMoneyConfigParamsDTO; |
| | | import com.yeshi.fanli.dto.common.CommonContentNav; |
| | | import com.yeshi.fanli.dto.common.CommonContentResult; |
| | | import com.yeshi.fanli.dto.common.CommonContentTypeEnum; |
| | | import com.yeshi.fanli.dto.common.JDCommonContentTypeEnum; |
| | | import com.yeshi.fanli.dto.common.PDDCommonContentTypeEnum; |
| | | import com.yeshi.fanli.dto.jd.JDSearchResult; |
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; |
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsResult; |
| | | import com.yeshi.fanli.entity.accept.AcceptData; |
| | | import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture; |
| | | import com.yeshi.fanli.entity.jd.JDGoods; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult; |
| | | import com.yeshi.fanli.service.inter.goods.CommonTemplateContentService; |
| | | import com.yeshi.fanli.service.inter.goods.JDCommonTemplateContentService; |
| | | import com.yeshi.fanli.service.inter.goods.PDDCommonTemplateContentService; |
| | | import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService; |
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService; |
| | | import com.yeshi.common.entity.PageEntity; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; |
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil; |
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO; |
| | | import com.yeshi.fanli.vo.homemodule.BannerVO; |
| | | |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | |
| | | /** |
| | | * 通用模板 |
| | | * |
| | | * @author Administrator |
| | | */ |
| | | @Controller |
| | | @RequestMapping("api/v2/commoncontent") |
| | | public class CommonContentControllerV2 { |
| | | |
| | | @Resource |
| | | private SwiperPictureService swiperPictureService; |
| | | |
| | | @Resource |
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; |
| | | |
| | | @Resource |
| | | private CommonTemplateContentService commonTemplateContentService; |
| | | |
| | | @Resource |
| | | private JDCommonTemplateContentService jdCommonTemplateContentService; |
| | | |
| | | @Resource |
| | | private PDDCommonTemplateContentService pddCommonTemplateContentService; |
| | | |
| | | @Resource |
| | | private GoodsLijinMnager goodsLijinMnager; |
| | | |
| | | /** |
| | | * 通用模板导航 |
| | | * |
| | | * @param acceptData |
| | | * @param key |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getNavList", method = RequestMethod.POST) |
| | | public void getNavList(AcceptData acceptData, String key, Integer type, PrintWriter out) { |
| | | if (StringUtil.isNullOrEmpty(key)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请传入Key")); |
| | | return; |
| | | } |
| | | |
| | | List<CommonContentNav> list = null; |
| | | if (type == null || type == Constant.SOURCE_TYPE_TAOBAO) { |
| | | list = commonTemplateContentService.getNavList(CommonContentTypeEnum.valueOf(key), acceptData.getSystem()); |
| | | } else if (type == Constant.SOURCE_TYPE_JD) { |
| | | // 暂无分类 |
| | | } else if (type == Constant.SOURCE_TYPE_PDD) { |
| | | list = pddCommonTemplateContentService.getNavList(PDDCommonContentTypeEnum.valueOf(key)); |
| | | } |
| | | |
| | | if (list == null) { |
| | | list = new ArrayList<CommonContentNav>(); |
| | | } |
| | | |
| | | out.print(JsonUtil.loadTrueResult(new Gson().toJson(list))); |
| | | } |
| | | |
| | | /** |
| | | * 获取内容 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param key |
| | | * @param type |
| | | * @param page |
| | | * @param cid |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getNavGoodsList", method = RequestMethod.POST) |
| | | public void getNavContent(AcceptData acceptData, Long uid, String key, Integer type, Integer page, String cid, |
| | | PrintWriter out) { |
| | | if (StringUtil.isNullOrEmpty(key)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请传入Key")); |
| | | return; |
| | | } |
| | | |
| | | if (page == null || page < 1) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请传入正确的page")); |
| | | return; |
| | | } |
| | | |
| | | if (type == null || type == Constant.SOURCE_TYPE_TAOBAO) { |
| | | getListTB(acceptData, uid, key, page, cid, out); |
| | | return; |
| | | } |
| | | |
| | | if (type == Constant.SOURCE_TYPE_JD) { |
| | | getListJD(acceptData, uid, key, page, cid, out); |
| | | return; |
| | | } |
| | | |
| | | if (type == Constant.SOURCE_TYPE_PDD) { |
| | | getListPDD(acceptData, uid, key, page, cid, out); |
| | | return; |
| | | } |
| | | out.print(JsonUtil.loadFalseResult("goodsType参数不正确")); |
| | | } |
| | | |
| | | private void getListTB(AcceptData acceptData, Long uid, String key, Integer page, String cid, PrintWriter out) { |
| | | CommonContentResult result = null; |
| | | CommonContentTypeEnum type = CommonContentTypeEnum.valueOf(key); |
| | | if (type == CommonContentTypeEnum.guessLikeDevice) { |
| | | // 猜你喜欢 |
| | | String idfa = acceptData.getIdfa(); |
| | | String imei = acceptData.getImei(); |
| | | result = guessLikeDeviceTB(idfa, imei, acceptData.getUtdid(), page); |
| | | } else { |
| | | // 大淘客页码只能为10,50,100,200 |
| | | result = commonTemplateContentService.getContentList(type, cid, page, 10, acceptData.getSystem()); |
| | | } |
| | | |
| | | JSONObject root = new JSONObject(); |
| | | if (page == 1) { |
| | | // 保留暂时不开启,待后续开启 |
| | | List<SwiperPicture> bannerList = new ArrayList<>(); |
| | | root.put("bannerList", new Gson().toJson(bannerList)); |
| | | } |
| | | |
| | | JSONArray array = new JSONArray(); |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create(); |
| | | List<CommonGoods> goodsList = new ArrayList<>(); |
| | | if (result != null) |
| | | goodsList = result.getGoodsList(); |
| | | |
| | | GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), |
| | | acceptData.getVersion(), acceptData.getSystem()); |
| | | |
| | | List<GoodsDetailVO> goodsDetailVOList = goodsLijinMnager.loadCommonGoodsMoneyInfo(acceptData.getSystem(), uid, goodsList, paramsDTO); |
| | | int p = 0; |
| | | for (GoodsDetailVO vo : goodsDetailVOList) { |
| | | vo.setCreatetime(null); |
| | | if (type == CommonContentTypeEnum.mianDan)// 免单商品 |
| | | { |
| | | vo.getMoneyInfo().setFanliMoney("¥" + CommonGoodsUtil.getAfterUseCouplePrice(goodsList.get(p))); |
| | | vo.getMoneyInfo().setShareMoney("¥" + CommonGoodsUtil.getAfterUseCouplePrice(goodsList.get(p))); |
| | | vo.getMoneyInfo().setMaxMoney(null); |
| | | } |
| | | array.add(gson.toJson(vo)); |
| | | p++; |
| | | } |
| | | |
| | | root.put("list", array); |
| | | root.put("count", result != null ? result.getCount() : 0); |
| | | out.print(JsonUtil.loadTrueResult(root)); |
| | | } |
| | | |
| | | /** |
| | | * 京东通用专题模板 |
| | | * |
| | | * @param acceptData |
| | | * @param key |
| | | * @param page |
| | | * @param cid |
| | | * @param out |
| | | */ |
| | | public void getListJD(AcceptData acceptData, Long uid, String key, Integer page, String cid, PrintWriter out) { |
| | | JSONObject data = new JSONObject(); |
| | | if (page == 1) { |
| | | List<SwiperPicture> bannerList = new ArrayList<>(); |
| | | data.put("bannerList", new Gson().toJson(bannerList)); |
| | | } |
| | | |
| | | JDSearchResult result = jdCommonTemplateContentService.getContentList(JDCommonContentTypeEnum.valueOf(key), cid, |
| | | page, Constant.PAGE_SIZE); |
| | | JSONArray array = new JSONArray(); |
| | | |
| | | long count = 0; |
| | | if (result != null) { |
| | | PageEntity pageEntity = result.getPageEntity(); |
| | | if (pageEntity != null) { |
| | | count = pageEntity.getTotalCount(); |
| | | } |
| | | |
| | | List<JDGoods> goodsList = result.getGoodsList(); |
| | | if (goodsList != null && goodsList.size() > 0) { |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) |
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); |
| | | GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), |
| | | acceptData.getVersion(), acceptData.getSystem()); |
| | | |
| | | List<GoodsDetailVO> voList = goodsLijinMnager.loadOtherMoneyInfo(acceptData.getSystem(), uid, goodsList, paramsDTO); |
| | | for (GoodsDetailVO goods : voList) { |
| | | array.add(gson.toJson(goods)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | data.put("list", array); |
| | | data.put("count", count); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 拼多多通用专题模板 |
| | | * |
| | | * @param acceptData |
| | | * @param key |
| | | * @param page |
| | | * @param cid |
| | | * @param out |
| | | */ |
| | | public void getListPDD(AcceptData acceptData, Long uid, String key, Integer page, String cid, PrintWriter out) { |
| | | JSONObject data = new JSONObject(); |
| | | if (page == 1) { |
| | | // 2、顶部轮播图 |
| | | List<BannerVO> bannerList = null; |
| | | if (Constant.IS_TEST) { |
| | | bannerList = swiperPictureService.getByBannerCardAndVersion("index_top", acceptData.getPlatform(), |
| | | Integer.parseInt(acceptData.getVersion()), acceptData.getSystem()); |
| | | } |
| | | |
| | | if (bannerList == null) { |
| | | bannerList = new ArrayList<BannerVO>(); |
| | | } |
| | | |
| | | data.put("bannerList", new Gson().toJson(bannerList)); |
| | | } |
| | | |
| | | PDDGoodsResult result = pddCommonTemplateContentService.getContentList(PDDCommonContentTypeEnum.valueOf(key), |
| | | cid, page, Constant.PAGE_SIZE); |
| | | JSONArray array = new JSONArray(); |
| | | long count = 0; |
| | | if (result != null) { |
| | | count = result.getTotalCount(); |
| | | |
| | | List<PDDGoodsDetail> goodsList = result.getGoodsList(); |
| | | if (goodsList != null && goodsList.size() > 0) { |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) |
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); |
| | | GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), |
| | | acceptData.getVersion(), acceptData.getSystem()); |
| | | |
| | | List<GoodsDetailVO> voList = goodsLijinMnager.loadOtherMoneyInfo(acceptData.getSystem(), uid, goodsList, paramsDTO); |
| | | for (GoodsDetailVO goods : voList) { |
| | | array.add(gson.toJson(goods)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | data.put("list", array); |
| | | data.put("count", count); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 猜你喜欢-淘宝设备推荐 |
| | | * |
| | | * @param idfa |
| | | * @param imei |
| | | * @param utdid |
| | | * @param page |
| | | * @return |
| | | */ |
| | | private CommonContentResult guessLikeDeviceTB(String idfa, String imei, String utdid, Integer page) { |
| | | TaoBaoSearchResult searchResult = TaoKeApiUtil.guessDeviceLike(page, Constant.PAGE_SIZE, imei, idfa, utdid); |
| | | if (searchResult != null && searchResult.getTaoBaoGoodsBriefs() != null |
| | | && searchResult.getTaoBaoGoodsBriefs().size() > 0) { |
| | | CommonContentResult result = new CommonContentResult(); |
| | | result.setCount(searchResult.getPageEntity().getTotalCount()); |
| | | result.setGoodsList(CommonGoodsFactory.createTaoBaoList(searchResult.getTaoBaoGoodsBriefs())); |
| | | return result; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |