| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.apache.commons.beanutils.PropertyUtils;
|
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | |
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.activity.ActivityUser;
|
| | | import com.yeshi.fanli.entity.common.JumpDetailV2;
|
| | | import com.yeshi.fanli.entity.dynamic.GoodsEvaluate;
|
| | | import com.yeshi.fanli.entity.dynamic.ImgInfo;
|
| | | import com.yeshi.fanli.entity.dynamic.ImgInfo.ImgEnum;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.push.DeviceActive;
|
| | | import com.yeshi.fanli.entity.push.DeviceTokenOPPO;
|
| | |
| | | import com.yeshi.fanli.service.inter.push.PushService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKey;
|
| | | import com.yeshi.fanli.util.factory.JumpDetailParamsFactory;
|
| | | import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
|
| | |
| | | totalwords.add(new ClientTextStyleVO("个商品", "#666666"));
|
| | | } else if (type == PushGoods.TYPE_ACTIVITY) {
|
| | | GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(pushGoods.getOtherId());
|
| | | if (goodsEvaluate != null) {
|
| | | ActivityUser user = goodsEvaluate.getUser();
|
| | | if (user != null) {
|
| | | nickName = user.getNickName();
|
| | | if (goodsEvaluate == null) {
|
| | | continue;
|
| | | }
|
| | | ActivityUser user = goodsEvaluate.getUser();
|
| | | if (user != null) {
|
| | | nickName = user.getNickName();
|
| | | }
|
| | | |
| | | if (StringUtil.isNullOrEmpty(vo.getPicture()) && goodsEvaluate.getImgList() != null &&
|
| | | goodsEvaluate.getImgList().size() > 0) {
|
| | | for (ImgInfo tmgInfo: goodsEvaluate.getImgList()) {
|
| | | if (tmgInfo.getType() == ImgEnum.img || tmgInfo.getType() == ImgEnum.activity) {
|
| | | vo.setPicture(tmgInfo.getUrl());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | String url = configService.get(ConfigKeyEnum.pushActivityLink.getKey());
|
| | | if (url == null) {
|
| | | url = "";
|
| | | }
|
| | | url = url + "?id=" + id + "&otherId=" + pushGoods.getOtherId();
|
| | | url = url + "?id=" + id;
|
| | | params = JumpDetailParamsFactory.createWEBParams(url);
|
| | | jumpDetail = jumpDetailV2Service.getByTypeCache("web",
|
| | | Constant.getPlatformCode(acceptData.getPlatform()), Integer.parseInt(acceptData.getVersion()));
|
| | |
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取推送活动详情
|
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping("getPushDetail")
|
| | | public void getPushDetail(String callback, AcceptData acceptData, Long uid, Long id, PrintWriter out) {
|
| | | if (uid == null || id == null) {
|
| | | JsonUtil.printMode(out, callback,JsonUtil.loadFalseResult("参数不完整"));
|
| | | return;
|
| | | }
|
| | | |
| | | PushGoods pushGoods = pushGoodsService.selectByPrimaryKey(id);
|
| | | if (pushGoods == null || StringUtil.isNullOrEmpty(pushGoods.getOtherId())) {
|
| | | JsonUtil.printMode(out, callback,JsonUtil.loadFalseResult("该活动已下架"));
|
| | | return;
|
| | | }
|
| | | |
| | | GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(pushGoods.getOtherId());
|
| | | if (goodsEvaluate == null) {
|
| | | JsonUtil.printMode(out, callback,JsonUtil.loadFalseResult("该活动已下架"));
|
| | | return;
|
| | | }
|
| | | |
| | | String scanResult = null;
|
| | | Integer scanNum = pushGoods.getScanNum();
|
| | | if (scanNum == null) {
|
| | | } else if (scanNum >= 10000) {
|
| | | double num = scanNum;
|
| | | String numMidea = String.format("%.1f", num / 10000);
|
| | | scanResult = numMidea + "万";
|
| | | } else {
|
| | | scanResult = scanNum +"";
|
| | | }
|
| | | |
| | | String jumpLink = configService.get(ConfigKeyEnum.activityDetailLink.getKey()) + "?type=%s&id=%s";
|
| | | jumpLink = String.format(jumpLink, "circle", goodsEvaluate.getId());
|
| | | if (!StringUtil.isNullOrEmpty(goodsEvaluate.getJumpLink())) {
|
| | | goodsEvaluate.setJumpLink(jumpLink);
|
| | | }
|
| | | |
| | | List<ImgInfo> imgListNew = new ArrayList<>();
|
| | | List<ImgInfo> imgList = goodsEvaluate.getImgList();
|
| | | if (imgList != null && imgList.size() > 0) {
|
| | | for (ImgInfo imgInfo: imgList) {
|
| | | if (imgInfo.getType() != ImgEnum.img || imgInfo.getType() == ImgEnum.activity) {
|
| | | ImgInfo imgInfoNew = new ImgInfo();
|
| | | try {
|
| | | PropertyUtils.copyProperties(imgInfoNew, imgInfo);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | continue;
|
| | | }
|
| | | |
| | | if (!StringUtil.isNullOrEmpty(imgInfoNew.getActivityUrl())) {
|
| | | imgInfoNew.setActivityUrl(jumpLink);
|
| | | }
|
| | | |
| | | imgListNew.add(imgInfoNew);
|
| | | continue;
|
| | | } |
| | | imgListNew.add(imgInfo);
|
| | | }
|
| | | }
|
| | | goodsEvaluate.setImgList(imgListNew);
|
| | | |
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | |
| | | JSONObject json = new JSONObject();
|
| | | json.put("title", pushGoods.getTitle());
|
| | | json.put("content", pushGoods.getContent());
|
| | | json.put("pushTime", TimeUtil.formatDate(pushGoods.getPushTime()));
|
| | | json.put("scanNum", scanResult);
|
| | | json.put("detailInfo", gsonBuilder.create().toJson(goodsEvaluate));
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(json));
|
| | | }
|
| | | }
|