From 80e39e3a40283521fc732c930aa51d9bece7c146 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期三, 03 六月 2020 15:15:49 +0800 Subject: [PATCH] 云发单 后台管理 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/cloud/UserCloudServiceImpl.java | 237 ++++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 154 insertions(+), 83 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 59a0720..b18deb6 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 @@ -11,11 +11,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.yeshi.utils.BigDecimalUtil; -import org.yeshi.utils.entity.FileUploadResult; import com.aliyun.openservices.ons.api.Message; import com.aliyun.openservices.ons.api.Producer; -import com.yeshi.fanli.controller.client.v2.ShareControllerV2; import com.yeshi.fanli.dao.mybatis.user.cloud.UserCloudMapper; import com.yeshi.fanli.dto.aitaoker.RobotInfoDTO; import com.yeshi.fanli.dto.aitaoker.WeiXinGroupDTO; @@ -24,6 +22,10 @@ import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum; import com.yeshi.fanli.dto.mq.user.body.UserCloudMQMsg; import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; +import com.yeshi.fanli.dto.suning.SuningGoodsImg; +import com.yeshi.fanli.dto.suning.SuningGoodsInfo; +import com.yeshi.fanli.dto.vip.VIPConvertResultDTO; +import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo; import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo; import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.bus.user.cloud.CloudOrderMenuEnum; @@ -77,7 +79,11 @@ import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil; import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory; import com.yeshi.fanli.util.rocketmq.MQTopicName; +import com.yeshi.fanli.util.suning.SuningApiUtil; +import com.yeshi.fanli.util.suning.SuningUtil; import com.yeshi.fanli.util.taobao.TaoBaoUtil; +import com.yeshi.fanli.util.vipshop.VipShopApiUtil; +import com.yeshi.fanli.util.vipshop.VipShopUtil; import com.yeshi.fanli.vo.goods.GoodsDetailVO; @Service @@ -162,6 +168,23 @@ Long count = userCloudMapper.countByUid(uid); return count; } + + + @Override + public List<UserCloud> query(int page, int count,String key, Integer state) { + return userCloudMapper.query((page-1)* count, count, key, state); + } + + @Override + public long count(String key, Integer state) { + Long count = userCloudMapper.count(key, state); + if (count == null) + count = 0L; + return count; + } + + + @Override @Transactional(rollbackFor = Exception.class) @@ -306,7 +329,7 @@ String inviteCode = userInfoExtraService.getInviteCodeByUid(uid); if (StringUtil.isNullOrEmpty(inviteCode)) - throw new UserCloudException(1, "閭�璇风爜鏈縺娲�"); + throw new UserCloudException(3, "閭�璇风爜鏈縺娲�"); UserExtraTaoBaoInfo taoBaoInfo = userExtraTaoBaoInfoService.getByUid(uid); String relationId = null; @@ -321,20 +344,20 @@ // 楠岃瘉鏄惁寮�閫� UserCloud userCloud = userCloudMapper.getValidByUid(uid); if (userCloud == null) - throw new UserCloudException(1, "浜戝彂鍗曞凡杩囨湡"); + throw new UserCloudException(1001, "浜戝彂鍗曞凡杩囨湡"); Integer robotId = userCloud.getRobotId(); if (robotId == null) - throw new UserCloudException(1, "浜戝彂鍗曟満鍣ㄤ汉涓嶅瓨鍦�"); + throw new UserCloudException(1002, "浜戝彂鍗曟満鍣ㄤ汉涓嶅瓨鍦�"); String wxId = userCloud.getWxId(); if (StringUtil.isNullOrEmpty(wxId)) - throw new UserCloudException(1, "寰俊鍙风己澶�"); + throw new UserCloudException(1003, "寰俊鍙蜂笉瀛樺湪锛岃鍏堝井淇$櫥褰�"); // 楠岃瘉寮�鍚姸鎬� List<UserCloudGroup> listGroup = userCloudGroupService.listByUid(uid); if (listGroup == null || listGroup.size() == 0) - throw new UserCloudException(1, "璇峰厛娣诲姞浜戝彂鍗曠兢淇℃伅"); + throw new UserCloudException(1004, "璇峰厛寰俊鐧诲綍"); List<UserCloudGroup> listOpen = new ArrayList<>(); for (UserCloudGroup cloudGrou : listGroup) { @@ -343,7 +366,8 @@ } } if (listOpen.size() == 0) - throw new UserCloudException(1, "璇峰厛寮�鍚簯鍙戝崟缇ゅ姛鑳�"); + throw new UserCloudException(1005, "璇峰厛寮�鍚簯鍙戝崟缇ゅ姛鑳�"); + // 楠岃瘉鍙戝湀鏄惁鍙 GoodsEvaluate evaluate = goodsEvaluateService.getById(id); @@ -414,16 +438,18 @@ if (imgInfo.getType() == ImgEnum.goods) { cloudPic = imgInfo.getUrl(); } + listImg.add(imgInfo.getUrl()); - GoodsDetailVO goodsVO = imgInfo.getGoodsVO(); - if (goodsVO == null) { - listImg.add(imgInfo.getUrl()); - } else { - String jumpLink = getJumpLink(goodsVO, user, relationId, inviteCode, imgInfo.getUrl()); - if (!StringUtil.isNullOrEmpty(jumpLink)) { - qrCode = jumpLink; - } - } + // 鍙栨秷浜岀淮鐮佸浘 +// GoodsDetailVO goodsVO = imgInfo.getGoodsVO(); +// if (goodsVO == null) { +// listImg.add(imgInfo.getUrl()); +// } else { +// String jumpLink = getJumpLink(goodsVO, user, relationId, inviteCode, imgInfo.getUrl()); +// if (!StringUtil.isNullOrEmpty(jumpLink)) { +// qrCode = jumpLink; +// } +// } } if (cloudPic == null) { @@ -502,10 +528,14 @@ // 鍙戦�佸浘鐗� if (!StringUtil.isNullOrEmpty(cloudPic)) { - String imgBase64 = ImageToBase64.NetImageToBase64(cloudPic); - boolean macsend = AitaokerApiUtil.macsendImgBase64(robotId, cloudGroup.getGroupId(), imgBase64); - if (macsend) - sendContent.setPicUrl(cloudPic); + try { + String imgBase64 = ImageToBase64.NetImageToBase64(cloudPic); + boolean macsend = AitaokerApiUtil.macsendImgBase64(robotId, cloudGroup.getGroupId(), imgBase64); + if (macsend) + sendContent.setPicUrl(cloudPic); + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } } // 璇勮鏂囨湰 @@ -523,58 +553,11 @@ } } - /** - * 鍟嗗搧鍒嗕韩璺宠浆閾炬帴 - * @param goodsVO - * @param user - * @param relationId - * @param inviteCode - * @param mainPic - * @return - */ - private String getJumpLink(GoodsDetailVO goodsVO, UserInfo user, String relationId, String inviteCode, - String mainPic) { - String jumpLink = null; - if (goodsVO.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) { - TaoBaoLink taoBaoLink = null; - try { - taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(user.getId(), Long.parseLong(goodsVO.getGoodsId()), relationId); - } catch (ShareGoodsException e) { - e.printStackTrace(); - } - jumpLink = ShareControllerV2.getERCodeContentNew( - configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()), taoBaoLink.getGoods(), - TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); - } else if (goodsVO.getGoodsType() == Constant.SOURCE_TYPE_JD) { - JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(Long.parseLong(goodsVO.getGoodsId())); - if (jdGoods == null) { - return null; - } - - String couponUrl = null; - JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(jdGoods); - if (couponInfo != null) { - couponUrl = couponInfo.getLink(); - } - String materialId = "https://item.jd.com/" + goodsVO.getGoodsId() + ".html"; - jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", - user.getId() + ""); - } else if (goodsVO.getGoodsType() == Constant.SOURCE_TYPE_PDD) { - jumpLink = PinDuoDuoApiUtil.getPromotionUrl(Long.parseLong(goodsVO.getGoodsId()), PinDuoDuoApiUtil.PID_SHARE + "", - user.getId() + ""); - } - - FileUploadResult uploadResult = qrCodeService.drawDynamicGoodsPoster(jumpLink, user.getPortrait(), inviteCode, mainPic, goodsVO); - - if (uploadResult != null) { - return uploadResult.getUrl(); - } - return null; - } + @Override - public void sendCustomGoods(Long uid, Long goodsId, Integer goodsType) throws UserCloudException{ - sendCircleByGoods(uid, goodsId, goodsType, null); + public void sendCustomGoods(Long uid, Long goodsId, Integer goodsType, Long sellerId) throws UserCloudException{ + sendCircleByGoods(uid, goodsId, goodsType, null, sellerId); } @Override @@ -589,7 +572,7 @@ try { // 鍙戦�佸晢鍝� - sendCircleByGoods(uid, cgoods.getGoodsId(), cgoods.getGoodsType(), id); + sendCircleByGoods(uid, cgoods.getGoodsId(), cgoods.getGoodsType(), id, cgoods.getSellerId()); UserCloudGoods record = new UserCloudGoods(); record.setId(id); @@ -601,7 +584,7 @@ } } - private void sendCircleByGoods(Long uid, Long goodsId, Integer goodsType, Long storeId) throws UserCloudException { + private void sendCircleByGoods(Long uid, Long goodsId, Integer goodsType, Long storeId, Long sellerId) throws UserCloudException { // 楠岃瘉鏄惁鎺堟潈 UserInfo user = userInfoService.getUserByIdWithMybatis(uid); if (user == null) @@ -610,6 +593,10 @@ if (user != null && user.getState() != UserInfo.STATE_NORMAL) { throw new UserCloudException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC); } + + String inviteCode = userInfoExtraService.getInviteCodeByUid(uid); + if (StringUtil.isNullOrEmpty(inviteCode)) + throw new UserCloudException(3, "閭�璇风爜鏈縺娲�"); UserExtraTaoBaoInfo taoBaoInfo = userExtraTaoBaoInfoService.getByUid(uid); String relationId = null; @@ -623,7 +610,7 @@ // 楠岃瘉鏄惁寮�閫� UserCloud userCloud = userCloudMapper.getValidByUid(uid); if (userCloud == null) - throw new UserCloudException(1, "浜戝彂鍗曞凡杩囨湡"); + throw new UserCloudException(1001, "浜戝彂鍗曞凡杩囨湡"); Integer robotId = userCloud.getRobotId(); if (robotId == null) @@ -631,12 +618,12 @@ String wxId = userCloud.getWxId(); if (StringUtil.isNullOrEmpty(wxId)) - throw new UserCloudException(1, "寰俊鍙风己澶�"); + throw new UserCloudException(1002, "璇峰厛鐧诲綍寰俊"); // 楠岃瘉寮�鍚姸鎬� List<UserCloudGroup> listGroup = userCloudGroupService.listByUid(uid); if (listGroup == null || listGroup.size() == 0) - throw new UserCloudException(1, "璇峰厛娣诲姞浜戝彂鍗曠兢淇℃伅"); + throw new UserCloudException(1003, "璇峰厛鐧诲綍寰俊"); List<UserCloudGroup> listOpen = new ArrayList<>(); for (UserCloudGroup cloudGrou : listGroup) { @@ -646,7 +633,7 @@ } if (listOpen.size() == 0) - throw new UserCloudException(1, "璇峰厛寮�鍚簯鍙戝崟缇ゅ姛鑳�"); + throw new UserCloudException(1004, "璇峰厛寮�鍚簯鍙戝崟缇ゅ姛鑳�"); // 淇濆瓨鍙戦�佽褰� UserCloudSendRecord sendRecord = new UserCloudSendRecord(); @@ -672,9 +659,9 @@ } else if (goodsType == Constant.SOURCE_TYPE_PDD) { sendPDDGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId()); } else if (goodsType == Constant.SOURCE_TYPE_VIP) { - + sendVIPGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId()); } else if (goodsType == Constant.SOURCE_TYPE_SUNING) { - + sendSuNingGoods(user, robotId, wxId, goodsId, sellerId, relationId, listOpen, result.getId()); } } @@ -843,6 +830,85 @@ /** + * 鍞搧浼氬晢鍝� + * @param user + * @param robotId + * @param wxId + * @param goodsId + * @param relationId + * @param listOpen + * @param pid + * @throws UserCloudException + */ + private void sendVIPGoods(UserInfo user, int robotId, String wxId, Long goodsId, String relationId, + List<UserCloudGroup> listOpen, String pid) throws UserCloudException { + VIPGoodsInfo goods = VipShopApiUtil.getGoodsDetail(goodsId + ""); + if (goods == null) + throw new UserCloudException(1, "璇ュ晢鍝佸凡涓嬫灦"); + + VIPConvertResultDTO resultDTO = VipShopApiUtil.convertLink(goodsId + "", VipShopUtil.getShareChanTag(user.getId())); + String jumpLink = resultDTO.getUrl(); + + boolean coupon = false; + String quanPrice = ""; + String couponAmount = ""; + // 鑾峰彇鎺ㄨ崘璇� + String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, goods.getGoodsName(), null, + couponAmount, null); + // 鑾峰彇璇勮璇� + String commentText = shareGoodsTextTemplateService.getCommentTextByLink(coupon, jumpLink, goods.getMarketPrice(), + quanPrice, ConfigKeyEnum.quickShareJDCommentText); + + // 浜戝彂鍗� + sendGoods(robotId, wxId, listOpen, recommendText, commentText, goods.getGoodsDetailPictures(), user.getId(), pid); + } + + + /** + * 浜笢鍟嗗搧浜戝彂鍗� + * @param user + * @param robotId + * @param wxId + * @param goodsId + * @param relationId + * @param listOpen + * @throws UserCloudException + */ + private void sendSuNingGoods(UserInfo user, int robotId, String wxId, Long goodsId, Long sellerId, String relationId, + List<UserCloudGroup> listOpen, String pid) throws UserCloudException { + SuningGoodsInfo goods = SuningApiUtil.getGoodsDetail(goodsId +"", sellerId +""); + if (goods == null) + throw new UserCloudException(1, "璇ュ晢鍝佸凡涓嬫灦"); + + + String couponLink = goods.getCouponInfo().getCouponUrl(); + String jumpLink = SuningApiUtil.convertLink(SuningUtil.getProductUrl(sellerId +"", goodsId +""), + StringUtil.isNullOrEmpty(couponLink) ? null : couponLink, SuningApiUtil.PID_SHARE, user.getId() + ""); + + + boolean coupon = false; + String quanPrice = ""; + String couponAmount = ""; + String sales = null; + // 鑾峰彇鎺ㄨ崘璇� + String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, goods.getCommodityInfo().getCommodityName(), sales, + couponAmount, null); + + // 鑾峰彇璇勮璇� + String zkPrice = goods.getCommodityInfo().getCommodityPrice().toString(); + String commentText = shareGoodsTextTemplateService.getCommentTextByLink(coupon, jumpLink, zkPrice, quanPrice, + ConfigKeyEnum.quickShareJDCommentText); + + 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); + } + + /** * 鍙戦�佸晢鍝� * @param robotId * @param title @@ -896,10 +962,15 @@ // 鍙戦�佸浘鐗� String picurl = listImg.get(0); if (!StringUtil.isNullOrEmpty(picurl)) { - String imgBase64 = ImageToBase64.NetImageToBase64(picurl); - boolean macsend = AitaokerApiUtil.macsendImgBase64(robotId, cloudGroup.getGroupId(), imgBase64); - if (macsend) - sendContent.setPicUrl(picurl); + try { + String imgBase64 = ImageToBase64.NetImageToBase64(picurl); + boolean macsend = AitaokerApiUtil.macsendImgBase64(robotId, cloudGroup.getGroupId(), imgBase64); + if (macsend) + sendContent.setPicUrl(picurl); + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } + } // 璇勮鏂囨湰 List<String> list = new ArrayList<>(); -- Gitblit v1.8.0