| | |
| | | import com.yeshi.fanli.service.manger.goods.ConvertLinkManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.ImageToBase64;
|
| | | import com.yeshi.fanli.util.ImageUtil;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.RedisKeyEnum;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | |
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | |
|
| | | |
| | | |
| | | @Override
|
| | | public UserCloud getValidByUid(Long uid) {
|
| | | return userCloudMapper.getValidByUid(uid);
|
| | |
| | | Long count = userCloudMapper.countByUid(uid);
|
| | | return count;
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public List<UserCloud> query(int page, int count,String key, Integer state) {
|
| | |
| | | return;
|
| | | }
|
| | | redisManager.cacheCommonString(key , "true" , 60);
|
| | | |
| | |
|
| | | // 更新信息
|
| | | UserCloud update = new UserCloud();
|
| | |
| | | sendCircleByDynamic(uid, id, UserCloudSendRecord.SEND_WAY_MANUAL);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void autoSendByDynamic(Long uid, String id) {
|
| | |
| | | LogHelper.cloudInfo("autoSendByDynamic - [uid:" +uid + " 动态id:"+ id + "]原因:"+ e.getMsg());
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | private void sendCircleByDynamic(Long uid, String id, int way) throws UserCloudException {
|
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
|
| | |
| | |
|
| | | if (StringUtil.isNullOrEmpty(relationId))
|
| | | throw new UserCloudException(2, "淘宝未授权,请前往\"我的\"绑定淘宝账号");
|
| | | |
| | |
|
| | | // 验证是否开通
|
| | | UserCloud userCloud = userCloudMapper.getValidByUid(uid);
|
| | |
| | | if (listOpen.size() == 0)
|
| | | throw new UserCloudException(1005, "请先开启云发单群功能");
|
| | |
|
| | | |
| | | // 验证发圈是否可行
|
| | | GoodsEvaluate evaluate = goodsEvaluateService.getById(id);
|
| | | if (evaluate == null || evaluate.getState() == 0)
|
| | |
| | |
|
| | | throw new UserCloudException(1003, "微信已掉线,需要重新扫描二维码登录");
|
| | | }
|
| | | |
| | |
|
| | | boolean hasToken = false;
|
| | | List<String> listComment = new ArrayList<>();
|
| | |
| | | if (!hasToken)
|
| | | throw new UserCloudException(1, "该内容包含可转链口令或链接");
|
| | |
|
| | |
|
| | | ImgInfo imgVideo = null;
|
| | | List<String> listImg = new ArrayList<>();
|
| | |
|
| | |
| | | listImg.add(imgInfo.getUrl());
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | // 保存发送记录
|
| | | UserCloudSendRecord sendRecord = new UserCloudSendRecord();
|
| | |
| | | sendContent.setType(UserCloudSendContent.TYPE_CIRCLE);
|
| | |
|
| | | if (imgVideo == null) {
|
| | |
|
| | | // 发送图文
|
| | | String picUrl = "";
|
| | | if (listImg.size() > 0) {
|
| | | for (String img: listImg) {
|
| | | picUrl += TbImgUtil.getTBSize220Img(img) + ";" ;
|
| | | picUrl += img + ";";
|
| | | }
|
| | | if (picUrl.endsWith(";"))
|
| | | picUrl = picUrl.substring(0, picUrl.length()-1);
|
| | | }
|
| | | String picUrlUpload = AitaokerApiUtil.macsendUpload(robotId, picUrl);
|
| | | sendContent.setPicUrlUpload(picUrlUpload);
|
| | | sendContent.setTitle(title);
|
| | | sendContent.setPicUrl(picUrl);
|
| | | circleId = AitaokerApiUtil.macsendCircle(robotId, title, picUrl);
|
| | | circleId = AitaokerApiUtil.macsendCircle(robotId, title, picUrlUpload);
|
| | | } else {
|
| | | // 发送视频
|
| | | sendContent.setPicUrl(imgVideo.getUrl());
|
| | |
| | | for (int i = 0; i < num && i < listImg.size(); i++) {
|
| | | try {
|
| | | String imgBase64 = ImageToBase64.NetImageToBase64(listImg.get(i));
|
| | | boolean macsend = AitaokerApiUtil.macsendImgBase64(robotId, cloudGroup.getGroupId(), imgBase64);
|
| | | boolean macsend = AitaokerApiUtil.macsendImgBase64(robotId, cloudGroup.getGroupId(),
|
| | | imgBase64);
|
| | | if (macsend)
|
| | | sendContent.setPicUrl(listImg.get(i));
|
| | | } catch (Exception e) {
|
| | |
| | | userCloudSendContentService.save(sendContent);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | |
| | |
|
| | | try {
|
| | | // 发送商品
|
| | | sendCircleByGoods(uid, cgoods.getGoodsId(), cgoods.getGoodsType(), id, cgoods.getSellerId(), UserCloudSendRecord.SEND_WAY_AUTO);
|
| | | sendCircleByGoods(uid, cgoods.getGoodsId(), cgoods.getGoodsType(), id, cgoods.getSellerId(),
|
| | | UserCloudSendRecord.SEND_WAY_AUTO);
|
| | | } catch (UserCloudException e) {
|
| | | LogHelper.cloudInfo("autoSendCustomGoods - [uid:" +uid + " 库id:"+ id + "]原因:"+ e.getMsg());
|
| | | }
|
| | | }
|
| | |
|
| | | private void sendCircleByGoods(Long uid, Long goodsId, Integer goodsType, Long storeId,
|
| | | Long sellerId, int way) throws UserCloudException {
|
| | | private void sendCircleByGoods(Long uid, Long goodsId, Integer goodsType, Long storeId, Long sellerId, int way)
|
| | | throws UserCloudException {
|
| | | // 验证是否授权
|
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
|
| | | if (user == null)
|
| | |
| | | if (userCloud == null)
|
| | | throw new UserCloudException(1001, "云发单已过期");
|
| | |
|
| | | |
| | | // 加入我的备选库
|
| | | if (storeId == null) {
|
| | | try {
|
| | |
| | | if (cloudGoods != null)
|
| | | storeId =cloudGoods.getId();
|
| | | } catch (UserCloudGoodsException e) {
|
| | | LogHelper.cloudInfo("sendCustomGoods - [uid:" +uid + "goodsId:"+ goodsId + "goodsType" + goodsType +"]原因:"+ e.getMsg());
|
| | | LogHelper.cloudInfo("sendCustomGoods - [uid:" + uid + "goodsId:" + goodsId + "goodsType" + goodsType
|
| | | + "]原因:" + e.getMsg());
|
| | | throw new UserCloudException(1, "加入云发单备选库失败");
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | if (listOpen.size() == 0)
|
| | | throw new UserCloudException(1004, "请先开启云发单群功能");
|
| | | |
| | |
|
| | | // 检测微信是否登录状态
|
| | | if (!AitaokerApiUtil.onlineCheck(robotId)) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | |
| | | }
|
| | |
|
| | | /**
|
| | | * 淘宝商品信息处理
|
| | | * |
| | | * @param user
|
| | | * @param inviteCode
|
| | | * @param robotId
|
| | |
| | | sendGoods(robotId, wxId, listOpen, recommendText, commentText, goods.getImgList(), user.getId(), pid);
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 京东商品云发单
|
| | | * |
| | | * @param user
|
| | | * @param robotId
|
| | | * @param wxId
|
| | |
| | | if (jdGoods == null)
|
| | | throw new UserCloudException(1, "该商品已下架");
|
| | |
|
| | | |
| | | String couponUrl = null;
|
| | | JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(jdGoods);
|
| | | if (couponInfo != null) {
|
| | | couponUrl = couponInfo.getLink();
|
| | | }
|
| | | String materialId = "https://item.jd.com/" + goodsId + ".html";
|
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "",user.getId() + "");
|
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "",
|
| | | user.getId() + "");
|
| | |
|
| | | boolean coupon = false;
|
| | | if (couponInfo != null) {
|
| | |
| | |
|
| | | /**
|
| | | * 京东商品云发单
|
| | | * |
| | | * @param user
|
| | | * @param robotId
|
| | | * @param wxId
|
| | |
| | | couponAmount, null);
|
| | |
|
| | | // 获取评论语
|
| | | String zkPrice = MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinGroupPrice()), new BigDecimal(100)).setScale(2).toString();
|
| | | String zkPrice = MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinGroupPrice()), new BigDecimal(100))
|
| | | .setScale(2).toString();
|
| | | String commentText = shareGoodsTextTemplateService.getCommentTextByLink(coupon, jumpLink, zkPrice, quanPrice,
|
| | | ConfigKeyEnum.quickSharePDDCommentText);
|
| | |
|
| | |
| | | sendGoods(robotId, wxId, listOpen, recommendText, commentText, list, user.getId(), pid );
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 唯品会商品
|
| | | * |
| | | * @param user
|
| | | * @param robotId
|
| | | * @param wxId
|
| | |
| | | if (goods == null)
|
| | | throw new UserCloudException(1, "该商品已下架");
|
| | |
|
| | | VIPConvertResultDTO resultDTO = VipShopApiUtil.convertLink(goodsId + "", VipShopUtil.getShareChanTag(user.getId()));
|
| | | VIPConvertResultDTO resultDTO = VipShopApiUtil.convertLink(goodsId + "",
|
| | | VipShopUtil.getShareChanTag(user.getId()));
|
| | | String jumpLink = resultDTO.getUrl();
|
| | |
|
| | | boolean coupon = false;
|
| | |
| | | String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, goods.getGoodsName(), null,
|
| | | couponAmount, null);
|
| | | // 获取评论语
|
| | | String commentText = shareGoodsTextTemplateService.getCommentTextByLink(coupon, jumpLink, goods.getMarketPrice(), |
| | | quanPrice, ConfigKeyEnum.quickShareVIPCommentText);
|
| | | String commentText = shareGoodsTextTemplateService.getCommentTextByLink(coupon, jumpLink,
|
| | | goods.getMarketPrice(), quanPrice, ConfigKeyEnum.quickShareVIPCommentText);
|
| | |
|
| | | // 云发单
|
| | | sendGoods(robotId, wxId, listOpen, recommendText, commentText, goods.getGoodsDetailPictures(), user.getId(), pid);
|
| | | sendGoods(robotId, wxId, listOpen, recommendText, commentText, goods.getGoodsDetailPictures(), user.getId(),
|
| | | pid);
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 京东商品云发单
|
| | | * |
| | | * @param user
|
| | | * @param robotId
|
| | | * @param wxId
|
| | |
| | | * @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 {
|
| | | 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 couponAmount = "";
|
| | |
| | | }
|
| | |
|
| | | // 获取推荐语
|
| | | String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, goods.getCommodityInfo().getCommodityName(), sales, |
| | | couponAmount, null);
|
| | | String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon,
|
| | | goods.getCommodityInfo().getCommodityName(), sales, couponAmount, null);
|
| | |
|
| | | // 生成快捷分享内容
|
| | | String template = configService.get(ConfigKeyEnum.quickShareSuNingCommentText.getKey());
|
| | | String commentText = shareGoodsTextTemplateService.createQuickShareTextSuNing(template, goods, jumpLink);
|
| | | |
| | |
|
| | | List<String> imgList = new ArrayList<>();
|
| | | for (SuningGoodsImg img : goods.getCommodityInfo().getPictureUrl()) {
|
| | |
| | |
|
| | | /**
|
| | | * 发送商品
|
| | | * |
| | | * @param robotId
|
| | | * @param title
|
| | | * @param comment
|
| | |
| | | * @param wxId
|
| | | * @param listOpen
|
| | | */
|
| | | private void sendGoods(int robotId,String wxId, List<UserCloudGroup> listOpen, String title,
|
| | | String comment, List<String> listImg, Long uid, String pid) {
|
| | | private void sendGoods(int robotId, String wxId, List<UserCloudGroup> listOpen, String title, String comment,
|
| | | List<String> listImg, Long uid, String pid) {
|
| | | // 遍历群-朋友圈
|
| | | for (UserCloudGroup cloudGroup: listOpen) {
|
| | | UserCloudSendContent sendContent = new UserCloudSendContent();
|
| | |
| | | for (String img: listImg) {
|
| | | picUrl += TbImgUtil.getTBSize220Img(img) + ";" ;
|
| | | }
|
| | | }
|
| | | |
| | | if (picUrl.endsWith(";"))
|
| | | picUrl = picUrl.substring(0, picUrl.length()-1);
|
| | | }
|
| | |
|
| | | String picUrlUpload = AitaokerApiUtil.macsendUpload(robotId, picUrl);
|
| | | sendContent.setPicUrlUpload(picUrlUpload);
|
| | | sendContent.setTitle(title);
|
| | | sendContent.setPicUrl(picUrl);
|
| | | // 发圈内容
|
| | | String circleId = AitaokerApiUtil.macsendCircle(robotId, title, picUrl);
|
| | | String circleId = AitaokerApiUtil.macsendCircle(robotId, title, picUrlUpload);
|
| | | // 评论文本
|
| | | if (!StringUtil.isNullOrEmpty(circleId)) {
|
| | | sendContent.setState(true);
|
| | |
| | | for (int i = 0; i < num && i < listImg.size(); i++) {
|
| | | try {
|
| | | String imgBase64 = ImageToBase64.NetImageToBase64(listImg.get(i));
|
| | | boolean macsend = AitaokerApiUtil.macsendImgBase64(robotId, cloudGroup.getGroupId(), imgBase64);
|
| | | boolean macsend = AitaokerApiUtil.macsendImgBase64(robotId, cloudGroup.getGroupId(),
|
| | | imgBase64);
|
| | | if (macsend)
|
| | | sendContent.setPicUrl(listImg.get(i));
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | // 评论文本
|
| | | List<String> list = new ArrayList<>();
|
| | |
| | | userCloudSendContentService.save(sendContent);
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public void fixedTimeSend(List<GoodsEvaluate> listActivity, List<GoodsEvaluate> listGoods) {
|
| | |
| | | // 活动
|
| | | if (listActivity != null && listActivity.size() > 0) {
|
| | | for (GoodsEvaluate evaluate: listActivity) {
|
| | | UserCloudSendRecord record = userCloudSendRecordService.getByUidAndSendId(uid, evaluate.getId());
|
| | | UserCloudSendRecord record = userCloudSendRecordService.getByUidAndSendId(uid,
|
| | | evaluate.getId());
|
| | | if (record != null)
|
| | | continue;
|
| | |
|
| | |
| | | // 单品
|
| | | if (StringUtil.isNullOrEmpty(evaluateId) && listGoods != null && listGoods.size() > 0) {
|
| | | for (GoodsEvaluate evaluate: listGoods) {
|
| | | UserCloudSendRecord record = userCloudSendRecordService.getByUidAndSendId(uid, evaluate.getId());
|
| | | UserCloudSendRecord record = userCloudSendRecordService.getByUidAndSendId(uid,
|
| | | evaluate.getId());
|
| | | if (record != null)
|
| | | continue;
|
| | |
|
| | |
| | |
|
| | | if(!StringUtil.isNullOrEmpty(evaluateId)) {
|
| | | UserCloudMQMsg msg = new UserCloudMQMsg(uid, evaluateId, UserCloudMQMsg.TYPE_EVALUATE);
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userCloud, msg);
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userCloud,
|
| | | msg);
|
| | | producer.send(message);
|
| | | }
|
| | | } catch (Exception e) {
|