| | |
| | | import com.yeshi.fanli.entity.bus.user.cloud.UserCloud;
|
| | | import com.yeshi.fanli.entity.bus.user.cloud.UserCloudGoods;
|
| | | import com.yeshi.fanli.entity.bus.user.cloud.UserCloudGroup;
|
| | | import com.yeshi.fanli.entity.bus.user.cloud.UserCloudManage;
|
| | | import com.yeshi.fanli.entity.bus.user.cloud.UserCloudSendContent;
|
| | | import com.yeshi.fanli.entity.bus.user.cloud.UserCloudSendRecord;
|
| | | import com.yeshi.fanli.entity.dynamic.CommentInfo;
|
| | |
| | | import com.yeshi.fanli.exception.goods.ConvertLinkExceptionException;
|
| | | import com.yeshi.fanli.exception.share.ShareGoodsException;
|
| | | import com.yeshi.fanli.exception.user.cloud.UserCloudException;
|
| | | import com.yeshi.fanli.exception.user.cloud.UserCloudGoodsException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.dynamic.GoodsEvaluateService;
|
| | |
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.cloud.UserCloudGoodsService;
|
| | | import com.yeshi.fanli.service.inter.user.cloud.UserCloudGroupService;
|
| | | import com.yeshi.fanli.service.inter.user.cloud.UserCloudManageService;
|
| | | import com.yeshi.fanli.service.inter.user.cloud.UserCloudSendContentService;
|
| | | import com.yeshi.fanli.service.inter.user.cloud.UserCloudSendRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.cloud.UserCloudService;
|
| | |
| | | @Resource
|
| | | private UserCloudSendContentService userCloudSendContentService;
|
| | |
|
| | | @Resource
|
| | | private UserCloudManageService userCloudManageService;
|
| | | |
| | | @Resource(name = "producer")
|
| | | private Producer producer;
|
| | |
|
| | |
| | | count = 0L;
|
| | | return count;
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | |
| | | renew = true;
|
| | | // 验证套餐是否相同
|
| | | if (renew && userCloud.getRobotType() != menuEnum.getType()) {
|
| | | LogHelper.error("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]已有其他云发单套餐还未结束");
|
| | | LogHelper.cloudInfo("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]已有其他云发单套餐还未结束");
|
| | | throw new UserCloudException(1, "已有其他云发单套餐还未结束");
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | if (dto == null) {
|
| | | LogHelper.error("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]机器人失败: 返回空值");
|
| | | LogHelper.cloudInfo("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]机器人失败: 返回空值");
|
| | | throw new UserCloudException(1, "机器人获取失败");
|
| | | }
|
| | |
|
| | | String endTimeStr = dto.getEndTime();
|
| | | if (StringUtil.isNullOrEmpty(endTimeStr)) {
|
| | | LogHelper.error("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]机器人失败: 返回时间为空");
|
| | | LogHelper.cloudInfo("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]机器人失败: 返回时间为空");
|
| | | throw new UserCloudException(1, "机器人返回时间为空");
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | endTime = Long.parseLong(endTimeStr);
|
| | | } catch (Exception e) {
|
| | | LogHelper.error("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]机器人失败: 返回时间格式不正确");
|
| | | LogHelper.cloudInfo("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]机器人失败: 返回时间格式不正确");
|
| | | throw new UserCloudException(1, "机器人返回时间格式不正确");
|
| | | }
|
| | |
|
| | | Integer robotId = dto.getId();
|
| | | if (robotId == null) {
|
| | | LogHelper.error("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]机器人失败: 机器人ID返回为空");
|
| | | LogHelper.cloudInfo("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]机器人失败: 机器人ID返回为空");
|
| | | throw new UserCloudException(1, "机器人ID返回为空");
|
| | | }
|
| | |
|
| | | Integer groupNum = dto.getGroupNum();
|
| | | if (groupNum == null) {
|
| | | LogHelper.error("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]机器人失败: groupNum返回为空");
|
| | | LogHelper.cloudInfo("方法openCloud: [uid=" + uid + "][订单ID=" + orderId + "]机器人失败: groupNum返回为空");
|
| | | throw new UserCloudException(1, "groupNum返回为空");
|
| | | }
|
| | |
|
| | |
| | | newCloud.setGroupNum(groupNum);
|
| | | newCloud.setRobotId(robotId);
|
| | | newCloud.setRobotType(menuEnum.getType());
|
| | | newCloud.setStartTime(new Date());
|
| | | if (renew) {
|
| | | newCloud.setStartTime(userCloud.getStartTime());
|
| | | } else {
|
| | | newCloud.setStartTime(new Date());
|
| | | }
|
| | | newCloud.setEndTime(new Date(endTime * 1000)); // Unix 转换 普通时间
|
| | | newCloud.setCreateTime(new Date());
|
| | | userCloudMapper.insertSelective(newCloud);
|
| | | |
| | | // 开启发圈功能
|
| | | userCloudManageService.save(uid, null, null);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | |
|
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void autoSendByDynamic(Long uid, String id) {
|
| | | boolean official = false;
|
| | | UserCloudManage cloudManage = userCloudManageService.selectByPrimaryKey(uid);
|
| | | if (cloudManage != null) {
|
| | | if (cloudManage.getOfficial() != null)
|
| | | official = cloudManage.getOfficial();
|
| | | }
|
| | | |
| | | if (!official)
|
| | | return;
|
| | | |
| | | try {
|
| | | sendCircleByDynamic(uid, id, UserCloudSendRecord.SEND_WAY_AUTO);
|
| | | } catch (UserCloudException e) {
|
| | |
| | | if (comments == null || comments.size() == 0)
|
| | | throw new UserCloudException(1, "该内容不能转链");
|
| | |
|
| | | // 检测微信是否登录状态
|
| | | if (!AitaokerApiUtil.onlineCheck(robotId)) {
|
| | | throw new UserCloudException(1003, "请重新登录微信");
|
| | | }
|
| | | |
| | |
|
| | | boolean hasToken = false;
|
| | | List<String> listComment = new ArrayList<>();
|
| | |
| | | }
|
| | |
|
| | |
|
| | | |
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void sendCustomGoods(Long uid, Long goodsId, Integer goodsType, Long sellerId) throws UserCloudException{
|
| | | sendCircleByGoods(uid, goodsId, goodsType, null, sellerId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void autoSendCustomGoods(Long uid, Long id) {
|
| | | boolean custom = false;
|
| | | UserCloudManage cloudManage = userCloudManageService.selectByPrimaryKey(uid);
|
| | | if (cloudManage != null) {
|
| | | if (cloudManage.getCustom() != null)
|
| | | custom = cloudManage.getCustom();
|
| | | }
|
| | | |
| | | if (!custom) {
|
| | | return;
|
| | | }
|
| | | |
| | | UserCloudGoods cloudGoods = userCloudGoodsService.selectByPrimaryKey(id);
|
| | | if (cloudGoods == null) {
|
| | | return;
|
| | |
| | | try {
|
| | | // 发送商品
|
| | | sendCircleByGoods(uid, cgoods.getGoodsId(), cgoods.getGoodsType(), id, cgoods.getSellerId());
|
| | | |
| | | UserCloudGoods record = new UserCloudGoods();
|
| | | record.setId(id);
|
| | | record.setState(UserCloudGoods.STATE_SHARED);
|
| | | record.setUpdateTime(new Date());
|
| | | userCloudGoodsService.updateByPrimaryKeySelective(record);
|
| | | } catch (UserCloudException e) {
|
| | | LogHelper.cloudInfo("autoSendCustomGoods - [uid:" +uid + " 库id:"+ id + "]原因:"+ e.getMsg());
|
| | | }
|
| | |
| | | if (userCloud == null)
|
| | | throw new UserCloudException(1001, "云发单已过期");
|
| | |
|
| | | |
| | | // 加入我的备选库
|
| | | if (storeId == null) {
|
| | | try {
|
| | | UserCloudGoods cloudGoods = userCloudGoodsService.addGoods(uid, goodsId, goodsType, sellerId);
|
| | | if (cloudGoods != null)
|
| | | storeId =cloudGoods.getId();
|
| | | } catch (UserCloudGoodsException e) {
|
| | | LogHelper.cloudInfo("sendCustomGoods - [uid:" +uid + "goodsId:"+ goodsId + "goodsType" + goodsType +"]原因:"+ e.getMsg());
|
| | | throw new UserCloudException(1, "加入云发单备选库失败");
|
| | | }
|
| | | }
|
| | | |
| | | // 自选库商品是否打开
|
| | | boolean custom = false;
|
| | | UserCloudManage cloudManage = userCloudManageService.selectByPrimaryKey(uid);
|
| | | if (cloudManage != null) {
|
| | | if (cloudManage.getCustom() != null)
|
| | | custom = cloudManage.getCustom();
|
| | | }
|
| | | if (!custom) {
|
| | | throw new UserCloudException(0, "成功加入云发单库");
|
| | | }
|
| | | |
| | | Integer robotId = userCloud.getRobotId();
|
| | | if (robotId == null)
|
| | | throw new UserCloudException(1, "云发单机器人不存在");
|
| | |
| | |
|
| | | if (listOpen.size() == 0)
|
| | | throw new UserCloudException(1004, "请先开启云发单群功能");
|
| | | |
| | | |
| | | // 检测微信是否登录状态
|
| | | if (!AitaokerApiUtil.onlineCheck(robotId)) {
|
| | | throw new UserCloudException(1003, "请重新登录微信");
|
| | | }
|
| | | |
| | |
|
| | | // 保存发送记录
|
| | | UserCloudSendRecord sendRecord = new UserCloudSendRecord();
|
| | |
| | | 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());
|
| | | }
|
| | | |
| | | // 更新发单记录
|
| | | if (storeId != null) {
|
| | | UserCloudGoods record = new UserCloudGoods();
|
| | | record.setId(storeId);
|
| | | record.setState(UserCloudGoods.STATE_SHARED);
|
| | | record.setSendTime(new Date());
|
| | | record.setUpdateTime(new Date());
|
| | | userCloudGoodsService.updateByPrimaryKeySelective(record);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | couponAmount, null);
|
| | | // 获取评论语
|
| | | String commentText = shareGoodsTextTemplateService.getCommentTextByLink(coupon, jumpLink, goods.getMarketPrice(),
|
| | | quanPrice, ConfigKeyEnum.quickShareJDCommentText);
|
| | | quanPrice, ConfigKeyEnum.quickShareVIPCommentText);
|
| | |
|
| | | // 云发单
|
| | | sendGoods(robotId, wxId, listOpen, recommendText, commentText, goods.getGoodsDetailPictures(), user.getId(), pid);
|
| | |
| | |
|
| | |
|
| | | boolean coupon = false;
|
| | | String quanPrice = "";
|
| | | String couponAmount = "";
|
| | | String sales = null;
|
| | | if (goods.getCouponInfo() != null && !StringUtil.isNullOrEmpty(goods.getCouponInfo().getCouponUrl())) {// 有券
|
| | | couponAmount = new BigDecimal(goods.getCouponInfo().getCouponValue()).toString();
|
| | | coupon = true;
|
| | | } |
| | | |
| | | // 获取推荐语
|
| | | 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);
|
| | | // 生成快捷分享内容
|
| | | 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()) {
|
| | |
| | | return;
|
| | |
|
| | | // 一个小时之前
|
| | | long rand = 1000 * 60 * 60 ;
|
| | | long time = java.lang.System.currentTimeMillis() - rand;
|
| | | long time = java.lang.System.currentTimeMillis() - 1000 * 60 * 60 ;
|
| | | Date lastTime = new Date(time);
|
| | | |
| | |
|
| | | for (int i = 0; i < 1000; i ++) {
|
| | | List<Long> list = userCloudMapper.listValidUid((i-1)*1000, 1000);
|
| | |
| | | if (last != null)
|
| | | continue;
|
| | |
|
| | | if (!Constant.IS_TEST) {
|
| | | boolean official = false;
|
| | | UserCloudManage cloudManage = userCloudManageService.selectByPrimaryKey(uid);
|
| | | if (cloudManage != null) {
|
| | | if (cloudManage.getOfficial() != null)
|
| | | official = cloudManage.getOfficial();
|
| | | }
|
| | | |
| | | if (!Constant.IS_TEST && official) {
|
| | | UserCloudMQMsg msg = new UserCloudMQMsg(uid, id, UserCloudMQMsg.TYPE_EVALUATE);
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userCloud, msg);
|
| | | producer.send(message);
|