From 651a15c78f668bef3859d9ed1bb7ad0b669d3600 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 03 七月 2020 17:52:07 +0800 Subject: [PATCH] 多APP优化 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/cloud/UserCloudServiceImpl.java | 158 ++++++++++++++++++++++++++++++++-------------------- 1 files changed, 97 insertions(+), 61 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/cloud/UserCloudServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/cloud/UserCloudServiceImpl.java index 141e421..3d64611 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/cloud/UserCloudServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/cloud/UserCloudServiceImpl.java @@ -8,13 +8,15 @@ import javax.annotation.Resource; +import com.yeshi.fanli.entity.SystemEnum; +import com.yeshi.fanli.exception.taobao.TaoBaoConvertLinkException; +import com.yeshi.fanli.service.manger.goods.TaoBaoLinkManager; import org.springframework.core.task.TaskExecutor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.yeshi.utils.BigDecimalUtil; import org.yeshi.utils.taobao.TbImgUtil; -import com.alibaba.druid.support.logging.Log; import com.aliyun.openservices.ons.api.Message; import com.aliyun.openservices.ons.api.Producer; import com.yeshi.fanli.dao.mybatis.user.cloud.UserCloudMapper; @@ -74,6 +76,7 @@ import com.yeshi.fanli.service.inter.user.cloud.UserCloudService; import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService; import com.yeshi.fanli.service.manger.goods.ConvertLinkManager; +import com.yeshi.fanli.service.manger.msg.RocketMQManager; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.ImageToBase64; import com.yeshi.fanli.util.MoneyBigDecimalUtil; @@ -135,23 +138,13 @@ @Resource private PinDuoDuoCacheUtil pinDuoDuoCacheUtil; - @Resource - private QrCodeService qrCodeService; + @Resource private RedisManager redisManager; @Resource - private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; - - @Resource - private HongBaoManageService hongBaoManageService; - - @Resource private ShareGoodsTextTemplateService shareGoodsTextTemplateService; - - @Resource - private CommonGoodsService commonGoodsService; @Resource private UserCloudSendRecordService userCloudSendRecordService; @@ -162,8 +155,8 @@ @Resource private UserCloudManageService userCloudManageService; - @Resource(name = "producer") - private Producer producer; + @Resource + private RocketMQManager rocketMQManager; @Resource private UserOtherMsgNotificationService userOtherMsgNotificationService; @@ -171,11 +164,11 @@ @Resource private PushService pushService; - @Resource - private UserSystemMsgService userSystemMsgService; - @Resource(name = "taskExecutor") private TaskExecutor executor; + + @Resource + private TaoBaoLinkManager taoBaoLinkManager; @Override public UserCloud getValidByUid(Long uid) { @@ -532,7 +525,18 @@ if (!hasToken) throw new UserCloudException(1, "璇ュ唴瀹瑰寘鍚彲杞摼鍙d护鎴栭摼鎺�"); + + // 寮傛鎵ц鍙戦�� + executor.execute(new Runnable() { + @Override + public void run() { + sendEvaluate(uid, evaluate, way, userCloud, listOpen, listComment); + } + }); + } + private void sendEvaluate(Long uid, GoodsEvaluate evaluate, int way, UserCloud userCloud, + List<UserCloudGroup> listOpen, List<String> listComment) { ImgInfo imgVideo = null; List<String> listImg = new ArrayList<>(); @@ -546,15 +550,15 @@ listImg.add(imgInfo.getUrl()); } } - - long time7= java.lang.System.currentTimeMillis(); - LogHelper.test("sendCircleByDynamic鍙戝湀鍐呭缁勭粐杞摼锛�" + (time7 - time6)); - + + + String wxId = userCloud.getWxId(); + Integer robotId = userCloud.getRobotId(); // 淇濆瓨鍙戦�佽褰� UserCloudSendRecord sendRecord = new UserCloudSendRecord(); sendRecord.setUid(uid); - sendRecord.setSendId(id); + sendRecord.setSendId(evaluate.getId()); sendRecord.setSendWay(way); sendRecord.setWxId(wxId); sendRecord.setRobotId(robotId); @@ -563,9 +567,6 @@ UserCloudSendRecord result = userCloudSendRecordService.save(sendRecord); String pid = result.getId(); - long time8= java.lang.System.currentTimeMillis(); - LogHelper.test("sendCircleByDynamic淇濆瓨鍙戝湀璁板綍锛�" + (time8 - time7)); - for (UserCloudGroup cloudGroup : listOpen) { String title = evaluate.getTitle(); @@ -624,10 +625,10 @@ if (macsend) sendContent.setTitle(title); } - + SystemEnum system=userInfoService.getUserSystem(uid); // 鍙戦�佸浘鐗� int num = 1; - String picNum = configService.get(ConfigKeyEnum.robotCloudGroupPictureNum.getKey()); + String picNum = configService.getValue(ConfigKeyEnum.robotCloudGroupPictureNum.getKey(),system); if (!StringUtil.isNullOrEmpty(picNum)) { num = Integer.parseInt(picNum); } @@ -658,12 +659,10 @@ } userCloudSendContentService.save(sendContent); } - - long time9= java.lang.System.currentTimeMillis(); - LogHelper.test("sendCircleByDynamic鎵ц鍙戝湀鑰楁椂锛�" + (time9 - time8)); - } - + + + @Override @Transactional(rollbackFor = Exception.class) public void sendCustomGoods(Long uid, Long goodsId, Integer goodsType, Long sellerId) throws UserCloudException { @@ -865,7 +864,6 @@ * 娣樺疂鍟嗗搧淇℃伅澶勭悊 * * @param user - * @param inviteCode * @param robotId * @param wxId * @param goodsId @@ -877,8 +875,8 @@ List<UserCloudGroup> listOpen, String pid) throws UserCloudException { TaoBaoLink taoBaoLink = null; try { - taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(user.getId(), goodsId, relationId); - } catch (ShareGoodsException e) { + taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(user.getId(), goodsId, relationId,null); + } catch (TaoBaoConvertLinkException e) { LogHelper.errorDetailInfo(e); throw new UserCloudException(1, "璇ュ晢鍝佸凡涓嬫灦"); } @@ -901,15 +899,22 @@ } String sales = TaoBaoUtil.getSaleCount(goods.getBiz30day()); + SystemEnum system=userInfoService.getUserSystem(user.getId()); + // 鑾峰彇鎺ㄨ崘璇� String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, goods.getTitle(), sales, - couponAmount, description); + couponAmount, description,system); // 鑾峰彇璇勮璇� String commentText = shareGoodsTextTemplateService.getCommentTextByTaoToken(coupon, taoBaoLink.getTaoToken(), - goods.getZkPrice().toString(), quanPrice); + goods.getZkPrice().toString(), quanPrice,system); - // 浜戝彂鍗� - sendGoods(robotId, wxId, listOpen, recommendText, commentText, goods.getImgList(), user.getId(), pid); + // 寮傛鎵ц鍙戦�� + executor.execute(new Runnable() { + @Override + public void run() { + sendGoods(robotId, wxId, listOpen, recommendText, commentText, goods.getImgList(), user.getId(), pid); + } + }); } /** @@ -952,9 +957,11 @@ String sales = JDUtil.getSaleCount(jdGoods.getInOrderCount30Days()); + SystemEnum system=userInfoService.getUserSystem(user.getId()); + // 鑾峰彇鎺ㄨ崘璇� String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, jdGoods.getSkuName(), sales, - couponAmount, null); + couponAmount, null,system); // 鑾峰彇璇勮璇� BigDecimal price = jdGoods.getPrice(); @@ -964,10 +971,16 @@ } String zkPrice = BigDecimalUtil.getWithNoZera(price).toString(); String commentText = shareGoodsTextTemplateService.getCommentTextByLink(coupon, jumpLink, zkPrice, quanPrice, - ConfigKeyEnum.quickShareJDCommentText); + ConfigKeyEnum.quickShareJDCommentText,system); - // 浜戝彂鍗� - sendGoods(robotId, wxId, listOpen, recommendText, commentText, jdGoods.getImageList(), user.getId(), pid); + // 寮傛鎵ц鍙戦�� + executor.execute(new Runnable() { + @Override + public void run() { + sendGoods(robotId, wxId, listOpen, recommendText, commentText, jdGoods.getImageList(), user.getId(), pid); + } + }); + } /** @@ -1008,23 +1021,33 @@ sales = "0"; } + SystemEnum system=userInfoService.getUserSystem(user.getId()); + // 鑾峰彇鎺ㄨ崘璇� String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, goods.getGoodsName(), sales, - couponAmount, null); + couponAmount, null,system); // 鑾峰彇璇勮璇� String zkPrice = MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinGroupPrice()), new BigDecimal(100)) .setScale(2).toString(); String commentText = shareGoodsTextTemplateService.getCommentTextByLink(coupon, jumpLink, zkPrice, quanPrice, - ConfigKeyEnum.quickSharePDDCommentText); + ConfigKeyEnum.quickSharePDDCommentText,system); List<String> list = null; String[] goodsGalleryUrls = goods.getGoodsGalleryUrls(); if (goodsGalleryUrls != null && goodsGalleryUrls.length > 0) { list = Arrays.asList(goodsGalleryUrls); } - // 浜戝彂鍗� - sendGoods(robotId, wxId, listOpen, recommendText, commentText, list, user.getId(), pid); + + List<String> list2 = list; + // 寮傛鎵ц鍙戦�� + executor.execute(new Runnable() { + @Override + public void run() { + sendGoods(robotId, wxId, listOpen, recommendText, commentText, list2, user.getId(), pid); + } + }); + } /** @@ -1052,16 +1075,22 @@ boolean coupon = false; String quanPrice = ""; String couponAmount = ""; + SystemEnum system=userInfoService.getUserSystem(user.getId()); // 鑾峰彇鎺ㄨ崘璇� String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, goods.getGoodsName(), null, - couponAmount, null); + couponAmount, null,system); // 鑾峰彇璇勮璇� String commentText = shareGoodsTextTemplateService.getCommentTextByLink(coupon, jumpLink, - goods.getMarketPrice(), quanPrice, ConfigKeyEnum.quickShareVIPCommentText); + goods.getMarketPrice(), quanPrice, ConfigKeyEnum.quickShareVIPCommentText,system); - // 浜戝彂鍗� - sendGoods(robotId, wxId, listOpen, recommendText, commentText, goods.getGoodsDetailPictures(), user.getId(), - pid); + // 寮傛鎵ц鍙戦�� + executor.execute(new Runnable() { + @Override + public void run() { + sendGoods(robotId, wxId, listOpen, recommendText, commentText, goods.getGoodsDetailPictures(), user.getId(), + pid); + } + }); } /** @@ -1093,21 +1122,28 @@ coupon = true; } + SystemEnum system=userInfoService.getUserSystem(user.getId()); + // 鑾峰彇鎺ㄨ崘璇� String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, - goods.getCommodityInfo().getCommodityName(), sales, couponAmount, null); + goods.getCommodityInfo().getCommodityName(), sales, couponAmount, null,system); // 鐢熸垚蹇嵎鍒嗕韩鍐呭 - String template = configService.get(ConfigKeyEnum.quickShareSuNingCommentText.getKey()); + String template = configService.getValue(ConfigKeyEnum.quickShareSuNingCommentText.getKey(),system); String commentText = shareGoodsTextTemplateService.createQuickShareTextSuNing(template, goods, jumpLink); List<String> imgList = new ArrayList<>(); for (SuningGoodsImg img : goods.getCommodityInfo().getPictureUrl()) { imgList.add(img.getPicUrl()); } - - // 浜戝彂鍗� - sendGoods(robotId, wxId, listOpen, recommendText, commentText, imgList, user.getId(), pid); + + executor.execute(new Runnable() { + @Override + public void run() { + // 浜戝彂鍗� + sendGoods(robotId, wxId, listOpen, recommendText, commentText, imgList, user.getId(), pid); + } + }); } /** @@ -1165,10 +1201,10 @@ if (macsend) sendContent.setTitle(title); } - + SystemEnum system=userInfoService.getUserSystem(uid); // 鍙戦�佸浘鐗� int num = 1; - String picNum = configService.get(ConfigKeyEnum.robotCloudGroupPictureNum.getKey()); + String picNum = configService.getValue(ConfigKeyEnum.robotCloudGroupPictureNum.getKey(),system); if (!StringUtil.isNullOrEmpty(picNum)) { num = Integer.parseInt(picNum); } @@ -1258,7 +1294,7 @@ UserCloudMQMsg msg = new UserCloudMQMsg(uid, evaluateId, UserCloudMQMsg.TYPE_EVALUATE); Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userCloud, msg); - producer.send(message); + rocketMQManager.sendNormalMsg(message, null); } } catch (Exception e) { LogHelper.errorDetailInfo(e); @@ -1292,7 +1328,7 @@ UserCloudMQMsg msg = new UserCloudMQMsg(uid, UserCloudMQMsg.TYPE_PUSH); Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userCloud, msg); message.setStartDeliverTime(java.lang.System.currentTimeMillis() + 1000 * 60 * 10); - producer.send(message); + rocketMQManager.sendNormalMsg(message, null); } // 鏇存柊宸叉彁閱� -- Gitblit v1.8.0