fanli/src/main/java/com/yeshi/fanli/controller/client/v2/DynamicControllerV2.java
@@ -159,7 +159,7 @@ // 2.0.6版本增加 学院栏目 if (VersionUtil.greaterThan_2_0_6(acceptData.getPlatform(), acceptData.getVersion())) { list.add(menu6); //list.add(menu6); } list.add(menu4); fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/DynamicController.java
New file @@ -0,0 +1,208 @@ package com.yeshi.fanli.controller.wxmp.v1; import java.io.PrintWriter; 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.yeshi.utils.JsonUtil; import org.yeshi.utils.StringUtil; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.yeshi.fanli.dto.WXMPAcceptData; import com.yeshi.fanli.entity.bus.homemodule.Special; import com.yeshi.fanli.entity.bus.homemodule.SpecialLabel; import com.yeshi.fanli.entity.common.JumpDetailV2; import com.yeshi.fanli.entity.dynamic.GoodsPicture; import com.yeshi.fanli.entity.dynamic.WXMPDynamicInfo; import com.yeshi.fanli.exception.dynamic.WXMPDynamicInfoException; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.dynamic.WXMPDynamicInfoService; import com.yeshi.fanli.service.inter.homemodule.SpecialService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.JumpDetailUtil; import com.yeshi.fanli.util.jd.JDApiUtil; import com.yeshi.fanli.vo.msg.ClientTextStyleVO; import net.sf.json.JSONObject; @Controller("WXMPDynamicController") @RequestMapping("/wxmp/api/v1/dynamic") public class DynamicController { @Resource private WXMPDynamicInfoService wxmpDynamicInfoService; @Resource private SpecialService specialService; /** * 首页专题 * * @param acceptData * @param uid * @param out */ @RequestMapping(value = "getHotList") public void getHotList(WXMPAcceptData acceptData, int page, PrintWriter out) { List<WXMPDynamicInfo> infoList = wxmpDynamicInfoService.listDynamicInfo(page, Constant.PAGE_SIZE); for (WXMPDynamicInfo info : infoList) { if (info.getImgs() != null) for (GoodsPicture goodsPicture : info.getImgs()) { JSONObject params = new JSONObject(); if (goodsPicture.getGoodsVO() != null && goodsPicture.getJumpDetail() != null) { params.put("id", goodsPicture.getGoodsVO().getGoodsId()); goodsPicture.setJumpDetail(null); goodsPicture.getGoodsVO().setImgList(null); goodsPicture.getGoodsVO().setShopInfo(null); goodsPicture.getGoodsVO().setCouponInfoList(null); } } } long count = wxmpDynamicInfoService.countDynamicInfo(); Gson gson = JsonUtil.getConvertDateToShortNameBuilder(JsonUtil .getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder().excludeFieldsWithoutExposeAnnotation())) .create(); try { JSONObject data = new JSONObject(); data.put("list", gson.toJson(infoList)); data.put("count", count); out.print(JsonUtil.loadTrueResult(data)); } catch (Exception e) { out.print(JsonUtil.loadFalseResult(1, "获取数据失败")); try { LogHelper.errorDetailInfo(e); } catch (Exception e1) { e1.printStackTrace(); } } } @RequestMapping(value = "copyText") public void copyText(WXMPAcceptData acceptData, String id, Long uid, PrintWriter out) { if (uid == null) { out.print(JsonUtil.loadFalseResult("用户未登录")); return; } if (StringUtil.isNullOrEmpty(id)) { out.print(JsonUtil.loadFalseResult("商品ID未空")); return; } try { String content = wxmpDynamicInfoService.copyContent(id, uid); JSONObject data = new JSONObject(); data.put("content", content); out.print(JsonUtil.loadTrueResult(data)); } catch (WXMPDynamicInfoException e) { out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage())); } } @RequestMapping(value = "getActivityList") public void getActivityList(WXMPAcceptData acceptData, int page, PrintWriter out) { // 平台区分 int platformCode = Constant.getPlatformCode(acceptData.getPlatform()); List<String> listKey = new ArrayList<String>(); listKey.add("special_channel_jd"); listKey.add("special_channel_pdd"); List<Special> list = specialService.listByPlaceKeyHasLabel((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, listKey, platformCode, Integer.parseInt(acceptData.getVersion())); long time = System.currentTimeMillis(); // 删除尚未启用的过期的 for (int i = 0; i < list.size(); i++) { Special special = list.get(i); if (special.getJumpDetail() != null) { special.setJumpDetail(JumpDetailUtil.getWXMPJumDetail(special.getJumpDetail())); } if (special.getState() == 1L) { list.remove(i--); } else { if (special.getStartTime() != null && special.getEndTime() != null) special.setTimeTask(true); else special.setTimeTask(false); if (special.isTimeTask()) { if (time < special.getStartTime().getTime() || time > special.getEndTime().getTime()) { list.remove(i--); } else// 设置倒计时 { special.setCountDownTime((special.getEndTime().getTime() - time) / 1000); } } List<SpecialLabel> listLabels = special.getListLabels(); if (listLabels != null && !listLabels.isEmpty()) { List<ClientTextStyleVO> labels = new ArrayList<>(); for (SpecialLabel specialLabel : listLabels) { labels.add(new ClientTextStyleVO(specialLabel.getName(), specialLabel.getBgColor())); } special.setLabels(labels); } } } long count = specialService.countByPlaceKeyList(listKey, platformCode, Integer.parseInt(acceptData.getVersion())); GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); Gson gson = gsonBuilder.create(); JSONObject data = new JSONObject(); data.put("count", count); data.put("list", gson.toJson(list)); out.print(JsonUtil.loadTrueResult(data)); } @RequestMapping(value = "getActivityDetail") public void getActivityDetail(WXMPAcceptData acceptData, Long uid, Long id, PrintWriter out) { if (uid == null) out.print(JsonUtil.loadFalseResult("用户未登录")); if (id == null) out.print(JsonUtil.loadFalseResult("活动ID为空")); Special special = specialService.selectByPrimaryKey(id); if (special == null) { out.print(JsonUtil.loadFalseResult("专题不存在")); return; } JumpDetailV2 jumpDetail = special.getJumpDetail(); jumpDetail.setActivity(null); jumpDetail.setController(null); String params = special.getParams(); if (jumpDetail.getType().equalsIgnoreCase("jd")) {// 京东的专题活动 JSONObject paramsJson = JSONObject.fromObject(params); // 京东转链 String url = paramsJson.optString("url"); String link = JDApiUtil.convertLinkWithSubUnionId(url, null, JDApiUtil.POSITION_FANLI + "", uid + ""); if (StringUtil.isNullOrEmpty(link)) { out.print(JsonUtil.loadFalseResult("转链失败")); return; } paramsJson.put("url", link); params = paramsJson.toString(); } JSONObject data = new JSONObject(); GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); Gson gson = gsonBuilder.create(); data.put("jumpDetail", gson.toJson(jumpDetail)); data.put("params", params); out.print(JsonUtil.loadTrueResult(data)); } } fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/GoodsController.java
@@ -183,7 +183,7 @@ if (StringUtil.isNullOrEmpty(swiper.getParams())) { params = JSONObject.fromObject(swiper.getParams()); } swiper.setJumpDetail(JumpDetailUtil.getWXMPJumDetail(swiper.getJumpDetail(), params)); swiper.setJumpDetail(JumpDetailUtil.getWXMPJumDetail(swiper.getJumpDetail())); swiper.setParams(null); } data.put("bannerList", JsonUtil.getApiCommonGson().toJson(picList)); @@ -822,7 +822,7 @@ String scene = goodsType+"#"+goodsId+"#" + inviteCode; FileUploadResult uploadResult = null; if (type == 1) { String erCodeUrl = "https://wxmp.banliapp.com/goods?info="+ scene; String erCodeUrl = "https://wxmp.banliapp.com/goods?i="+ scene; uploadResult = qrCodeService.drawGoodsPoster(erCodeUrl, user.getPortrait(), goods); } else { String acessToken = WXUtil.getAcessToken(Constant.WXMP_APP_INFO.getAppId(), Constant.WXMP_APP_INFO.getAppSecret()); fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/RecommendController.java
@@ -135,7 +135,7 @@ if (StringUtil.isNullOrEmpty(swiper.getParams())) { params = JSONObject.fromObject(swiper.getParams()); } swiper.setJumpDetail(JumpDetailUtil.getWXMPJumDetail(swiper.getJumpDetail(), params)); swiper.setJumpDetail(JumpDetailUtil.getWXMPJumDetail(swiper.getJumpDetail())); swiper.setParams(null); } @@ -155,7 +155,7 @@ params = JSONObject.fromObject(special.getParams()); } special.setJumpDetail(JumpDetailUtil.getWXMPJumDetail(jumpDetail, params)); special.setJumpDetail(JumpDetailUtil.getWXMPJumDetail(jumpDetail)); special.setParams(null); } @@ -170,7 +170,7 @@ if (StringUtil.isNullOrEmpty(swiper.getParams())) { params = JSONObject.fromObject(swiper.getParams()); } swiper.setJumpDetail(JumpDetailUtil.getWXMPJumDetail(swiper.getJumpDetail(), params)); swiper.setJumpDetail(JumpDetailUtil.getWXMPJumDetail(swiper.getJumpDetail())); swiper.setParams(null); } fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/UserMsgController.java
@@ -146,7 +146,7 @@ if (StringUtil.isNullOrEmpty(zhuShouMsg.getParams())) { params = JSONObject.fromObject(zhuShouMsg.getParams()); } JumpDetailV2 wxmpJumDetail = JumpDetailUtil.getWXMPJumDetail(zhuShouMsg.getJumpDetail(), params); JumpDetailV2 wxmpJumDetail = JumpDetailUtil.getWXMPJumDetail(zhuShouMsg.getJumpDetail()); commonMsgList.add(new UserCommonMsgVO(zhuShouMsg.getIcon(), zhuShouMsg.getTitle(), zhuShouMsg.getUpdateTime(), UserCommonMsgVO.TYPE_ZHUSHOU, zhuShouMsg.getContent(), read, @@ -168,7 +168,7 @@ if (detail.getType() == MsgTypeOrderTypeEnum.share || detail.getType() == MsgTypeOrderTypeEnum.invite) params.put("orderHideNo", UserUtil.filterOrderId(detail.getOrderId())); JumpDetailV2 wxmpJumDetail = JumpDetailUtil.getWXMPJumDetail(jumpDetailV2Service.getByTypeCache("order_search"), params); JumpDetailV2 wxmpJumDetail = JumpDetailUtil.getWXMPJumDetail(jumpDetailV2Service.getByTypeCache("order_search")); UserMsgVO userMsgVO = UserMsgVOFactory.create(detail, wxmpJumDetail, params); userMsgVO.setType(MSG_TYPE_ORDER); @@ -248,7 +248,7 @@ // TODO 跳转地址 JSONObject params = new JSONObject(); params.put("url", "http://apph5.yeshitv.com/special/1.0.9/jingXuanN_9.html?type=9_9"); JumpDetailV2 wxmpJumDetail = JumpDetailUtil.getWXMPJumDetail(jumpDetailV2Service.getByTypeCache("web"), params); JumpDetailV2 wxmpJumDetail = JumpDetailUtil.getWXMPJumDetail(jumpDetailV2Service.getByTypeCache("web")); userSystemMsgVO.setJumpDetail(wxmpJumDetail); root.put("systemMsg", userSystemMsgVO); fanli/src/main/java/com/yeshi/fanli/entity/common/JumpDetailV2.java
@@ -62,6 +62,7 @@ @org.yeshi.utils.mybatis.Column(name = "jp_min_ios_version") private Integer minIOSAppVersion;// 最小ios版本 @Expose @org.yeshi.utils.mybatis.Column(name = "jp_path") private String path;//小程序路径 fanli/src/main/java/com/yeshi/fanli/entity/dynamic/WXMPDynamicInfo.java
@@ -51,6 +51,7 @@ private Integer shareCount; // 分享赚的资金 @Expose @Field("shareMoney") private BigDecimal shareMoney; fanli/src/main/java/com/yeshi/fanli/job/DynamicInfoJob.java
@@ -51,7 +51,7 @@ @Resource private WXMPDynamicInfoService wxmpDynamicInfoService; @Resource private ConvertLinkManager convertLinkManager; @@ -282,7 +282,6 @@ return ReturnT.SUCCESS; } /** * 添加内优惠相关商品 * @Title: addJDNYHInfo @@ -335,6 +334,7 @@ else if (jdGoods.getImageList().size() > 1) lastPicture.addAll(jdGoods.getImageList().subList(1, jdGoods.getImageList().size())); } info.setShareMoney(totalMoney); int count = 0; while (imgs.size() < 4 && count < 4) { count++; fanli/src/main/java/com/yeshi/fanli/util/Constant.java
@@ -337,9 +337,9 @@ else if ("ios".equalsIgnoreCase(platform)) return 2; else if ("wxmp".equalsIgnoreCase(platform)) return 4;// 未知 return 4; else return 0; return 0;// 未知 } public static String getAppName(String platform, String version) { fanli/src/main/java/com/yeshi/fanli/util/JumpDetailUtil.java
@@ -1,12 +1,6 @@ package com.yeshi.fanli.util; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Iterator; import com.yeshi.fanli.entity.common.JumpDetailV2; import net.sf.json.JSONObject; public class JumpDetailUtil { /** @@ -16,25 +10,10 @@ * @param params * @return */ public static JumpDetailV2 getWXMPJumDetail(JumpDetailV2 detail, JSONObject params) { String path = detail.getPath(); if (params != null) { path += "?"; for (Iterator<String> its = params.keys(); its.hasNext();) { String key = its.next(); try { path += (key + "=" + URLEncoder.encode(params.optString(key), "UTF-8") + "&"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } } if (path.endsWith("&")) path = path.substring(0, path.length() - 1); JumpDetailV2 v2 = new JumpDetailV2(); v2.setPath(path); v2.setType(detail.getType()); return v2; public static JumpDetailV2 getWXMPJumDetail(JumpDetailV2 detail) { detail.setActivity(null); detail.setController(null); return detail; } }