| | |
| | | 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;
|
| | |
| | | @Resource
|
| | | private UserCloudManageService userCloudManageService;
|
| | |
|
| | | @Resource(name = "producer")
|
| | | private Producer producer;
|
| | | @Resource
|
| | | private RocketMQManager rocketMQManager;
|
| | |
|
| | | @Resource
|
| | | private UserOtherMsgNotificationService userOtherMsgNotificationService;
|
| | |
| | | if (robotId == null)
|
| | | throw new UserCloudException(1, "云发单机器人不存在");
|
| | |
|
| | | List<String> list = AitaokerApiUtil.getContract(12793);
|
| | | List<String> list = AitaokerApiUtil.getContract(robotId);
|
| | | if (list == null || list.size() == 0)
|
| | | throw new UserCloudException(1, "未检索到对应群");
|
| | |
|
| | |
| | | String result = redisManager.getCommonString(key);
|
| | | if (!StringUtil.isNullOrEmpty(result)) {
|
| | | String groupName = null;
|
| | | WeiXinGroupDTO groupDetail = AitaokerApiUtil.getGroupDetail(12793, roomId);
|
| | | WeiXinGroupDTO groupDetail = AitaokerApiUtil.getGroupDetail(robotId, roomId);
|
| | | if (groupDetail != null) {
|
| | | groupName = groupDetail.getGroupName();
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | private void sendCircleByDynamic(Long uid, String id, int way) throws UserCloudException {
|
| | | long time1= java.lang.System.currentTimeMillis();
|
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
|
| | | if (user == null)
|
| | | throw new UserCloudException(1, "用户信息不存在");
|
| | |
| | |
|
| | | if (StringUtil.isNullOrEmpty(relationId))
|
| | | throw new UserCloudException(2, "淘宝未授权,请前往\"我的\"绑定淘宝账号");
|
| | | |
| | | long time2= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByDynamic保验证用户状态:" + (time2 - time1));
|
| | |
|
| | | |
| | | // 验证是否开通
|
| | | UserCloud userCloud = userCloudMapper.getValidByUid(uid);
|
| | | if (userCloud == null)
|
| | |
| | | if (StringUtil.isNullOrEmpty(wxId))
|
| | | throw new UserCloudException(1003, "微信号不存在,请先微信登录");
|
| | |
|
| | | long time3= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByDynamic验证是否满足开通:" + (time3 - time2));
|
| | |
|
| | | |
| | | // 验证开启状态
|
| | | List<UserCloudGroup> listGroup = userCloudGroupService.listByUid(uid);
|
| | | if (listGroup == null || listGroup.size() == 0)
|
| | |
| | | if (listOpen.size() == 0)
|
| | | throw new UserCloudException(1005, "请先开启云发单群功能");
|
| | |
|
| | | long time4= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByDynamic验证是否开启:" + (time4 - time3));
|
| | | |
| | | // 验证发圈是否可行
|
| | | GoodsEvaluate evaluate = goodsEvaluateService.getById(id);
|
| | | if (evaluate == null || evaluate.getState() == 0)
|
| | |
| | | if (comments == null || comments.size() == 0)
|
| | | throw new UserCloudException(1, "该内容不能转链");
|
| | |
|
| | | long time5= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByDynamic验证发圈内容是否满足:" + (time5 - time4));
|
| | | |
| | | // 检测微信是否登录状态
|
| | | if (!AitaokerApiUtil.onlineCheck(robotId)) {
|
| | | // 通知登录微信
|
| | |
| | | throw new UserCloudException(1003, "微信已掉线,需要重新扫描二维码登录");
|
| | | }
|
| | |
|
| | | long time6= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByDynamic验证发是否登录:" + (time6 - time5));
|
| | | |
| | | boolean hasToken = false;
|
| | | List<String> listComment = new ArrayList<>();
|
| | | for (CommentInfo commentInfo : comments) {
|
| | |
| | |
|
| | | if (!hasToken)
|
| | | throw new UserCloudException(1, "该内容包含可转链口令或链接");
|
| | | |
| | | // 异步执行发送
|
| | | 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<>();
|
| | |
|
| | |
| | | listImg.add(imgInfo.getUrl());
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | 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);
|
| | |
| | | UserCloudSendRecord result = userCloudSendRecordService.save(sendRecord);
|
| | | String pid = result.getId();
|
| | |
|
| | | |
| | | for (UserCloudGroup cloudGroup : listOpen) {
|
| | | String title = evaluate.getTitle();
|
| | |
|
| | |
| | | userCloudSendContentService.save(sendContent);
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | |
| | | |
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void sendCustomGoods(Long uid, Long goodsId, Integer goodsType, Long sellerId) throws UserCloudException {
|
| | |
| | |
|
| | | private void sendCircleByGoods(Long uid, Long goodsId, Integer goodsType, Long storeId, Long sellerId, int way)
|
| | | throws UserCloudException {
|
| | | long begainTime = java.lang.System.currentTimeMillis();
|
| | | |
| | | // 验证是否授权
|
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
|
| | | if (user == null)
|
| | |
| | | if (StringUtil.isNullOrEmpty(relationId))
|
| | | throw new UserCloudException(2, "淘宝未授权,请前往\"我的\"绑定淘宝账号");
|
| | |
|
| | | long time2 = java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByGoods验证用户耗时:" + (time2 - begainTime));
|
| | | |
| | | |
| | | // 验证是否开通
|
| | | UserCloud userCloud = userCloudMapper.getValidByUid(uid);
|
| | | if (userCloud == null)
|
| | | throw new UserCloudException(1001, "云发单已过期");
|
| | |
|
| | | |
| | | long time3= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByGoods验证是否开通:" + (time3 - time2));
|
| | | |
| | | long time4 = time3;
|
| | | // 加入我的备选库
|
| | | if (storeId == null) {
|
| | | try {
|
| | |
| | | + "]原因:" + e.getMsg());
|
| | | throw new UserCloudException(1, "加入云发单备选库失败");
|
| | | }
|
| | | time4= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByGoods加入备选库:" + (time4 - time3));
|
| | | }
|
| | |
|
| | | // 自选库商品是否打开
|
| | |
| | | if (listGroup == null || listGroup.size() == 0)
|
| | | throw new UserCloudException(1003, "请先登录微信");
|
| | |
|
| | | long time5= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByGoods验证是否绑定微信:" + (time5 - time4));
|
| | | |
| | | List<UserCloudGroup> listOpen = new ArrayList<>();
|
| | | for (UserCloudGroup cloudGrou : listGroup) {
|
| | | if (cloudGrou.getState()) {
|
| | |
| | | throw new UserCloudException(1003, "微信已掉线,需要重新扫描二维码登录");
|
| | | }
|
| | |
|
| | | long time6= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByGoods验证是否登录微信:" + (time6 - time5));
|
| | | |
| | | // 保存发送记录
|
| | | UserCloudSendRecord sendRecord = new UserCloudSendRecord();
|
| | | sendRecord.setUid(uid);
|
| | |
| | | sendRecord.setSendWay(UserCloudSendRecord.SEND_WAY_MANUAL);
|
| | | }
|
| | | UserCloudSendRecord result = userCloudSendRecordService.save(sendRecord);
|
| | | |
| | | long time7= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByGoods保存发送记录:" + (time7 - time6));
|
| | |
|
| | | try {
|
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | |
| | | record.setUpdateTime(new Date());
|
| | | userCloudGoodsService.updateByPrimaryKeySelective(record);
|
| | | }
|
| | |
|
| | | long time8= java.lang.System.currentTimeMillis();
|
| | | LogHelper.test("sendCircleByGoods执行发送:" + (time8 - time7));
|
| | | } catch (UserCloudException e) {
|
| | | LogHelper.cloudInfo("autoSendCustomGoods - [uid:" + uid + " 库id:" + storeId + "]原因:" + e.getMsg());
|
| | | // 更新发单记录
|
| | |
| | | String commentText = shareGoodsTextTemplateService.getCommentTextByTaoToken(coupon, taoBaoLink.getTaoToken(),
|
| | | goods.getZkPrice().toString(), quanPrice);
|
| | |
|
| | | // 云发单
|
| | | 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);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | String commentText = shareGoodsTextTemplateService.getCommentTextByLink(coupon, jumpLink, zkPrice, quanPrice,
|
| | | ConfigKeyEnum.quickShareJDCommentText);
|
| | |
|
| | | // 云发单
|
| | | 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);
|
| | | }
|
| | | });
|
| | | |
| | | }
|
| | |
|
| | | /**
|
| | |
| | | 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);
|
| | | }
|
| | | });
|
| | | |
| | | }
|
| | |
|
| | | /**
|
| | |
| | | String commentText = shareGoodsTextTemplateService.getCommentTextByLink(coupon, jumpLink,
|
| | | goods.getMarketPrice(), quanPrice, ConfigKeyEnum.quickShareVIPCommentText);
|
| | |
|
| | | // 云发单
|
| | | 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);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | 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);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public void fixedTimeSend(List<GoodsEvaluate> listActivity, List<GoodsEvaluate> listGoods) {
|
| | | public void fixedTimeSend(List<GoodsEvaluate> listActivity, List<GoodsEvaluate> listGoods, boolean timeLimit) {
|
| | | if (listGoods == null && listActivity == null)
|
| | | return;
|
| | | // 一个小时之前
|
| | |
| | | if (cloudManage == null || cloudManage.getOfficial() == null || !cloudManage.getOfficial()) {
|
| | | continue;
|
| | | }
|
| | | // 是否在一个小时内已发送过
|
| | | UserCloudSendRecord last = userCloudSendRecordService.getLastByUid(uid, lastTime);
|
| | | if (last != null)
|
| | | continue;
|
| | |
|
| | | |
| | | // 时间间隔:是否在一个小时内已发送过
|
| | | if (timeLimit) {
|
| | | UserCloudSendRecord last = userCloudSendRecordService.getLastByUid(uid, lastTime);
|
| | | if (last != null)
|
| | | continue;
|
| | | }
|
| | | |
| | | |
| | | String evaluateId = null;
|
| | | // 活动
|
| | | if (listActivity != null && listActivity.size() > 0) {
|
| | |
| | | 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);
|
| | |
| | | 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);
|
| | | }
|
| | |
|
| | | // 更新已提醒
|