From ff942c3f9f6fe84f6d141c87f47e58bf70273d40 Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期五, 24 五月 2019 15:13:42 +0800 Subject: [PATCH] 动态 二维码样式修改 已下架商品不提供分享 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java | 246 ++++++++++++++++++++++++------------------------ 1 files changed, 123 insertions(+), 123 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java index efdd79d..cf7a051 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java @@ -17,12 +17,11 @@ import org.yeshi.utils.JsonUtil; import org.yeshi.utils.taobao.TbImgUtil; -import com.yeshi.fanli.dto.share.ShareInfoDTO; +import com.yeshi.fanli.dto.share.ShareGoodsRecordDTO; import com.yeshi.fanli.entity.accept.AcceptData; import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup; import com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory; import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord; -import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum; import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo; import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.bus.user.UserInfoExtra; @@ -38,6 +37,7 @@ import com.yeshi.fanli.exception.goods.ShareGoodsTextTemplateException; import com.yeshi.fanli.exception.share.UserShareGoodsRecordException; import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; +import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.config.ConfigService; import com.yeshi.fanli.service.inter.config.SystemClientParamsService; import com.yeshi.fanli.service.inter.dynamic.DynamicInfoService; @@ -226,7 +226,16 @@ BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate); data.put("shareMoney", "楼" + shareMoney.toString()); - data.put("shareId", userShareGoodsRecordService.saveSingleShareRecord(uid, auctionId)); + try { + ShareGoodsRecordDTO shareRecord= userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId); + data.put("shareId", shareRecord.getRedisKey()); + } catch (Exception e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + } out.print(JsonUtil.loadTrueResult(data)); // 寮傛鎿嶄綔 @@ -254,10 +263,8 @@ } }); return; - } catch (UserShareGoodsRecordException e) { - out.print(JsonUtil.loadFalseResult(e.getMsg())); - e.printStackTrace(); - } catch (ShareGoodsException e) { + } + catch (ShareGoodsException e) { try { monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, e.getCode(), 0, "鍒嗕韩鍑洪敊")); } catch (Exception e1) { @@ -384,7 +391,7 @@ @RequestMapping(value = "sharedetail", method = RequestMethod.POST) public void shareDetail(AcceptData acceptData, Long uid, Long auctionId, String type, PrintWriter out) { try { - userShareGoodsRecordService.saveDetail(uid, auctionId, type); + userShareGoodsRecordService.saveSingleShareRecord(uid, auctionId); out.print(JsonUtil.loadTrueResult("鍒嗕韩鎴愬姛")); } catch (UserShareGoodsRecordException e) { out.print(JsonUtil.loadFalseResult(e.getMsg())); @@ -403,21 +410,33 @@ * @param out */ @RequestMapping(value = "updaterecord", method = RequestMethod.POST) - public void updateRecord(AcceptData acceptData, Long shareId, PrintWriter out) { - if (shareId == null) { + public void updateRecord(AcceptData acceptData, String shareId, PrintWriter out) { + if (StringUtil.isNullOrEmpty(shareId)) { out.print(JsonUtil.loadFalseResult("鍙傛暟涓嶆纭�")); } - try { - userShareGoodsRecordService.updateShareRecord(shareId); - out.print(JsonUtil.loadTrueResult("")); - } catch (UserShareGoodsRecordException e) { - out.print(JsonUtil.loadFalseResult(e.getMsg())); - e.printStackTrace(); - } catch (Exception e) { - out.print(JsonUtil.loadFalseResult("鍔犺浇澶辫触")); - e.printStackTrace(); - } + // 鏇存柊鍒嗕韩鐢熸晥 + executor.execute(new Runnable() { + @Override + public void run() { + try { + userShareGoodsRecordService.takeEffectShareRecord(shareId); + } catch (UserShareGoodsRecordException eu) { + try { + LogHelper.errorDetailInfo(eu); + } catch (Exception e) { + e.printStackTrace(); + } + } catch (Exception e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + }); + out.print(JsonUtil.loadTrueResult("鍒嗕韩鎴愬姛")); } /** @@ -655,16 +674,33 @@ } - JSONObject data = new JSONObject(); // 鍒嗙被id long cid = dynamicInfo.getClassId(); - if (cid == 1) { // 鐑攢鍗曞搧 - // 鏂囧瓧鍐呭 - String title =""; + if (cid == 1 || cid == 2) { // 1 鐑攢鍗曞搧 2 鎺ㄨ崘濂借揣 + if (cid == 1) { + List<GoodsPicture> imgs = dynamicInfo.getImgs(); + GoodsPicture goodsPicture = imgs.get(0); + if (goodsPicture.getGoodState() == 1) { + out.print(JsonUtil.loadFalseResult("璇ュ晢鍝佸凡涓嬫灦")); + return; + } else { + TaoBaoGoodsBriefExtra goods = goodsPicture.getGoods(); + try { + TaoKeApiUtil.getSimpleGoodsInfo(goods.getAuctionId()); + } catch (TaobaoGoodsDownException e) { + out.print(JsonUtil.loadFalseResult("璇ュ晢鍝佸凡涓嬫灦")); + return; + } + } + } + + // 鍒嗕韩鏂囧瓧 + String title = null; List<ClientTextStyleVO> listTitle = dynamicInfo.getTitle(); if (listTitle != null && listTitle.size() > 0) { + title = ""; for (ClientTextStyleVO textStyleVO : listTitle) { title += textStyleVO.getContent(); } @@ -678,21 +714,10 @@ int index = content.indexOf("楼"); data.put("shareMoney", new BigDecimal(content.substring(index + 1, content.length()))); - // 鍟嗗搧鍒嗕韩閾炬帴 - List<GoodsPicture> imgs2 = dynamicInfo.getImgs(); - GoodsPicture goodsPicture = imgs2.get(0); - Long auctionId = goodsPicture.getGoods().getAuctionId(); - String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(), - Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), - auctionId + ""); + // 鍒嗕韩鎻愰啋 + data.put("notifyDesc", configService.get("goods_share_notify")); - String shortLink = HttpUtil.getShortLink(url); - if (!StringUtil.isNullOrEmpty(shortLink)) { - url = shortLink; - } - data.put("clickUrl", url); - - // 鍒嗕韩鎻愮ず鍥剧墖 + // 鍒嗕韩鎻愮ず璇� String imgs = configService.get("goods_share_notify_imgs"); JSONArray array = JSONArray.fromObject(imgs); int p = (int) (array.size() * Math.random()); @@ -700,72 +725,41 @@ data.put("notifyPicture", array.optString(p)); } + // 鍒嗕韩鍑哄幓鐨勫浘鐗� + String pictUrl = dynamicInfo.getImgs().get(0).getUrl(); + data.put("pictUrl", TbImgUtil.getTBSizeImg(pictUrl, 500)); - UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService.getByUid(uid); - String relationId = null; - if (extraInfo != null && extraInfo.getRelationId() != null && extraInfo.getRelationValid() != null - && extraInfo.getRelationValid() == true) { - relationId = extraInfo.getRelationId(); - } - TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId); - - data.put("pictUrl", TbImgUtil.getTBSizeImg(goodsPicture.getUrl(), 500)); - // 娣樺疂鍙d护 - data.put("token", taoBaoLink.getTaoToken()); // 甯姪閾炬帴 data.put("helpLink","http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0"); - // 鍒嗕韩鎻愰啋 - data.put("notifyDesc", configService.get("goods_share_notify")); - // 鍒嗕韩璁板綍id - data.put("shareId", userShareGoodsRecordService.saveSingleShareRecord(uid, auctionId)); - } else if (cid == 2) { // 鎺ㄨ崘濂借揣 - - String picUrl = null; - List<TaoBaoGoodsBrief> listGoods = new ArrayList<TaoBaoGoodsBrief>(); - List<GoodsPicture> listImgs = dynamicInfo.getImgs(); - for (GoodsPicture goodsPicture: listImgs) { - TaoBaoGoodsBriefExtra goods = goodsPicture.getGoods(); - listGoods.add(goods); + if (cid == 2) { // 2 鎺ㄨ崘濂借揣 + ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordDynamic(uid, dynamicInfo.getListGoodsBrief()); + data.put("shareId", shareRecord.getRedisKey()); + data.put("clickUrl", shareRecord.getShareUrl()); + } else { + // 鍒嗕韩id + ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordDynamic(uid, dynamicInfo.getListGoodsBrief()); + data.put("shareId", shareRecord.getRedisKey()); - if (picUrl == null) { - picUrl = goodsPicture.getUrl(); + Long auctionId = dynamicInfo.getImgs().get(0).getGoods().getAuctionId(); + // 鍟嗗搧鍒嗕韩閾炬帴 + String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(), + Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), auctionId + ""); + String shortLink = HttpUtil.getShortLink(url); + if (!StringUtil.isNullOrEmpty(shortLink)) { + url = shortLink; } - } - - // 鏂囧瓧鍐呭 - String title =""; - List<ClientTextStyleVO> listTitle = dynamicInfo.getTitle(); - if (listTitle != null && listTitle.size() > 0) { - for (ClientTextStyleVO textStyleVO : listTitle) { - title += textStyleVO.getContent(); + data.put("clickUrl", url); + + // 娣樺疂鍙d护 + UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService.getByUid(uid); + String relationId = null; + if (extraInfo != null && extraInfo.getRelationId() != null && extraInfo.getRelationValid() != null + && extraInfo.getRelationValid() == true) { + relationId = extraInfo.getRelationId(); } - } - data.put("title", title); - data.put("content", "鎴戝湪杩斿埄鍒稿彂鐜颁簡涓�涓緢濂界殑鍟嗗搧锛屽揩鏉ョ湅鐪媬"); - - // 鍒嗕韩濂栭噾 - ClientTextStyleVO desc = dynamicInfo.getDesc(); - String content = desc.getContent(); - int index = content.indexOf("楼"); - data.put("shareMoney", new BigDecimal(content.substring(index + 1 , content.length()))); - - // 鍒嗕韩閾炬帴 - ShareInfoDTO shareInfo = userShareGoodsRecordService.saveShareRecord(uid, - ShareSourceTypeEnum.activity, title, listGoods); - data.put("shareId", shareInfo.getShareId()); - data.put("clickUrl", shareInfo.getShareUrl()); - data.put("pictUrl", TbImgUtil.getTBSizeImg(picUrl, 500)); - // 甯姪閾炬帴 - data.put("helpLink","http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0"); - // 鍒嗕韩鎻愰啋 - data.put("notifyDesc", configService.get("goods_share_notify")); - // 鍒嗕韩鎻愰啋璇� - String notifyImgs = configService.get("goods_share_notify_imgs"); - JSONArray array = JSONArray.fromObject(notifyImgs); - int p = (int) (array.size() * Math.random()); - if (p < array.size()) { - data.put("notifyPicture", array.optString(p)); + TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId); + data.put("token", taoBaoLink.getTaoToken()); } } else if (cid == 4) { // 閭�璇峰垎浜� @@ -781,9 +775,10 @@ Integer showType = dynamicInfo.getShowType(); if (showType == 0) { // 鏃犲浘鍒嗕韩 - String title =""; + String title = null; List<ClientTextStyleVO> listTitle = dynamicInfo.getTitle(); if (listTitle != null && listTitle.size() > 0) { + title =""; for (ClientTextStyleVO textStyleVO : listTitle) { title += textStyleVO.getContent(); } @@ -793,37 +788,30 @@ data.put("title", title); } else { // 鏈夊浘鍒嗕韩 - - // 閭�璇烽摼鎺� - String shortLink = HttpUtil.getShortLink("http://" + Constant.wxGZConfig.getLoginHost() + "/" - + Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid); - data.put("inviteLink", shortLink); - data.put("inviteCode", inviteCode); - data.put("helpLink", configService.get("invite_help_link")); - - - // 閭�璇疯儗鏅浘鐗� List<GoodsPicture> imgs = dynamicInfo.getImgs(); - String bgUrl = imgs.get(0).getUrl(); + + GoodsPicture goodsPicture = imgs.get(0); + String bgUrl = goodsPicture.getUrlOriginal(); + + if (StringUtil.isNullOrEmpty(bgUrl)) { + out.print(JsonUtil.loadFalseResult("鍥剧墖璺緞涓嶅瓨鍦�")); + return; + } + // 鐢ㄦ埛淇℃伅 UserInfo userInfo = userInfoService.selectByPKey(uid); String portrait = userInfo.getPortrait(); // 鐢婚個璇峰浘鐗� - if (StringUtil.isNullOrEmpty(dynamicInfo.getInviteMaterialId())) { - String imgLink = spreadUserImgService.getInviteImg(bgUrl,uid, portrait, inviteCode); + Long activityId = dynamicInfo.getActivityId(); + if (activityId != null) { + Integer pX = goodsPicture.getPx();; + Integer pY = goodsPicture.getPy();; + Integer size = goodsPicture.getSize(); + + String imgLink = spreadUserImgService.drawInviteQrCodeNew(bgUrl,uid, portrait,pX, pY, size, inviteCode); data.put("imgLink", imgLink); } else { - - String title =""; - List<ClientTextStyleVO> listTitle = dynamicInfo.getTitle(); - if (listTitle != null && listTitle.size() > 0) { - for (ClientTextStyleVO textStyleVO : listTitle) { - title += textStyleVO.getContent(); - } - } - title = title.replace("銆愰個璇风爜銆�", inviteCode); - title = title.replace("銆愰個璇烽摼鎺ャ��", UserUtil.getInviteShortLink(uid)); - + String title = imgs.get(0).getTitleOriginal(); String imgLink = spreadUserImgService.getInviteImgToGreet(bgUrl,uid, portrait, inviteCode, title, new Date()); data.put("imgLink", imgLink); } @@ -838,6 +826,14 @@ String valueN = values.getValue(); String valueBr = valueN.replace("\n", "<br><br>"); data.put("inviteRules", valueBr); + + + // 閭�璇烽摼鎺� + String shortLink = HttpUtil.getShortLink("http://" + Constant.wxGZConfig.getLoginHost() + "/" + + Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid); + data.put("inviteLink", shortLink); + data.put("inviteCode", inviteCode); + data.put("helpLink", configService.get("invite_help_link")); } } out.print(JsonUtil.loadTrueResult(data)); @@ -854,7 +850,11 @@ } catch (Exception e) { out.print(JsonUtil.loadFalseResult("鍒嗕韩璁板綍澶辫触")); - e.printStackTrace(); + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } } } } -- Gitblit v1.8.0