From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 25 二月 2025 16:41:22 +0800
Subject: [PATCH] 淘宝转链接口更新

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/cloud/UserCloudServiceImpl.java | 2732 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 1,371 insertions(+), 1,361 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 cb1a78c..9581d0d 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
@@ -1,1362 +1,1372 @@
-package com.yeshi.fanli.service.impl.user.cloud;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-
-import javax.annotation.Resource;
-
-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.aliyun.openservices.ons.api.Message;
-import com.aliyun.openservices.ons.api.Producer;
-import com.yeshi.fanli.dao.mybatis.user.cloud.UserCloudMapper;
-import com.yeshi.fanli.dto.aitaoker.RobotInfoDTO;
-import com.yeshi.fanli.dto.aitaoker.WeiXinGroupDTO;
-import com.yeshi.fanli.dto.jd.JDCouponInfo;
-import com.yeshi.fanli.dto.jd.JDPingouInfo;
-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;
-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.entity.dynamic.GoodsEvaluate;
-import com.yeshi.fanli.entity.dynamic.GoodsEvaluate.EvaluateEnum;
-import com.yeshi.fanli.entity.dynamic.ImgInfo;
-import com.yeshi.fanli.entity.dynamic.ImgInfo.ImgEnum;
-import com.yeshi.fanli.entity.goods.CommonGoods;
-import com.yeshi.fanli.entity.jd.JDGoods;
-import com.yeshi.fanli.entity.system.ConfigKeyEnum;
-import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
-import com.yeshi.fanli.entity.taobao.TaoBaoLink;
-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.goods.CommonGoodsService;
-import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
-import com.yeshi.fanli.service.inter.goods.ShareGoodsTextTemplateService;
-import com.yeshi.fanli.service.inter.msg.UserOtherMsgNotificationService;
-import com.yeshi.fanli.service.inter.msg.UserSystemMsgService;
-import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
-import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
-import com.yeshi.fanli.service.inter.push.PushService;
-import com.yeshi.fanli.service.inter.user.QrCodeService;
-import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
-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;
-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;
-import com.yeshi.fanli.util.RedisKeyEnum;
-import com.yeshi.fanli.util.RedisManager;
-import com.yeshi.fanli.util.StringUtil;
-import com.yeshi.fanli.util.aitaoker.AitaokerApiUtil;
-import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
-import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil;
-import com.yeshi.fanli.util.jd.JDApiUtil;
-import com.yeshi.fanli.util.jd.JDUtil;
-import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
-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
-public class UserCloudServiceImpl implements UserCloudService {
-
-	@Resource
-	private UserCloudMapper userCloudMapper;
-
-	@Resource
-	private UserCloudGroupService userCloudGroupService;
-
-	@Resource
-	private GoodsEvaluateService goodsEvaluateService;
-
-	@Resource
-	private ConvertLinkManager convertLinkManager;
-
-	@Resource
-	private UserCloudGoodsService userCloudGoodsService;
-
-	@Resource
-	private UserInfoExtraService userInfoExtraService;
-
-	@Resource
-	private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
-
-	@Resource
-	private UserInfoService userInfoService;
-
-	@Resource
-	private ShareGoodsService shareGoodsService;
-
-	@Resource
-	private ConfigService configService;
-
-	@Resource
-	private JDGoodsCacheUtil jdGoodsCacheUtil;
-
-	@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;
-
-	@Resource
-	private UserCloudSendContentService userCloudSendContentService;
-
-	@Resource
-	private UserCloudManageService userCloudManageService;
-
-	@Resource
-	private RocketMQManager rocketMQManager;
-
-	@Resource
-	private UserOtherMsgNotificationService userOtherMsgNotificationService;
-
-	@Resource
-	private PushService pushService;
-
-	@Resource
-	private UserSystemMsgService userSystemMsgService;
-
-	@Resource(name = "taskExecutor")
-	private TaskExecutor executor;
-
-	@Override
-	public UserCloud getValidByUid(Long uid) {
-		return userCloudMapper.getValidByUid(uid);
-	}
-
-	@Override
-	public UserCloud getLastByUid(Long uid) {
-		return userCloudMapper.getLastByUid(uid);
-	}
-
-	@Override
-	public long countByUid(Long uid) {
-		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)
-	public void updateWXInfo(Long uid, String wxId, String wxName, String wxPortrait) throws UserCloudException {
-		UserCloud userCloud = userCloudMapper.getValidByUid(uid);
-		if (userCloud == null)
-			throw new UserCloudException(1, "浜戝彂鍗曞凡杩囨湡");
-
-		// 妫�娴嬫槸鍚﹂渶瑕佹洿鏂� - 1鍒嗛挓闂撮殧
-		String key = "cloudLogin_" + uid;
-		String result = redisManager.getCommonString(key);
-		if (!StringUtil.isNullOrEmpty(result)) {
-			return;
-		}
-		redisManager.cacheCommonString(key, "true", 60);
-
-		// 鏇存柊淇℃伅
-		UserCloud update = new UserCloud();
-		update.setId(userCloud.getId());
-		update.setWxId(wxId);
-		update.setWxName(wxName);
-		update.setWxPortrait(wxPortrait);
-		userCloudMapper.updateByPrimaryKeySelective(update);
-
-		try {
-			userOtherMsgNotificationService.cloudMsg(uid, "浜戝彂鍗曞井淇¤处鍙�", "寰俊璐﹀彿鐧诲綍鎴愬姛", "鍙互寮�鍚綘鐨勭兢鍙戝崟浜�");
-		} catch (Exception e) {
-			LogHelper.errorDetailInfo(e);
-		}
-
-		// 鏇存柊鎻愰啋鐘舵��
-		UserCloudManage cloudManage = userCloudManageService.selectForUpdate(uid);
-		if (cloudManage == null) {
-			userCloudManageService.save(uid, false, false);
-		} else {
-			UserCloudManage updateManage = new UserCloudManage();
-			updateManage.setId(uid);
-			updateManage.setOfflineNotice(false);
-			userCloudManageService.updateByPrimaryKeySelective(updateManage);
-		}
-
-		// 寰俊鍙峰彉鍖�-娓呯┖缇や俊鎭�
-		if (!wxId.equals(userCloud.getWxId())) {
-			userCloudGroupService.deleteGroupByUid(uid);
-		}
-
-		// 鍔犲叆鏈嬪弸鍦�
-		if (StringUtil.isNullOrEmpty(userCloud.getWxId())) {
-			userCloudGroupService.addCircle(uid);
-		}
-	}
-
-	@Override
-	public void openCloud(Long uid, Long orderId, CloudOrderMenuEnum menuEnum) throws UserCloudException {
-		UserCloud existCloud = userCloudMapper.getByOrderId(orderId);
-		if (existCloud != null) {
-			return; // 璇ヨ鍗曞凡澶勭悊瀹屾垚
-		}
-
-		boolean renew = false;
-		UserCloud userCloud = userCloudMapper.getLastByUid(uid);
-		if (userCloud != null) {
-			// 缁垂
-			if (userCloud.getEndTime().getTime() > java.lang.System.currentTimeMillis())
-				renew = true;
-			// 楠岃瘉濂楅鏄惁鐩稿悓
-			if (renew && userCloud.getRobotType() != menuEnum.getRobotType()) {
-				LogHelper.cloudInfo("鏂规硶openCloud: [uid=" + uid + "][璁㈠崟ID=" + orderId + "]宸叉湁鍏朵粬浜戝彂鍗曞椁愯繕鏈粨鏉�");
-				throw new UserCloudException(1, "宸叉湁鍏朵粬浜戝彂鍗曞椁愯繕鏈粨鏉�");
-			}
-		}
-
-		RobotInfoDTO dto = null;
-		if (renew) { // 缁垂
-			dto = AitaokerApiUtil.robotRenewals(userCloud.getRobotId(), menuEnum.getMonth());
-		} else { // 鍒涘缓鏈哄櫒浜�
-			dto = AitaokerApiUtil.robotCreate(menuEnum.getMonth(), menuEnum.getRobotType(), "wechatrobot", null);
-		}
-
-		if (dto == null) {
-			LogHelper.cloudInfo("鏂规硶openCloud: [uid=" + uid + "][璁㈠崟ID=" + orderId + "]鏈哄櫒浜哄け璐ワ細 鏈哄櫒浜哄垱寤哄け璐�");
-		}
-
-		Integer robotId = dto.getId();
-		if (robotId == null) {
-			LogHelper.cloudInfo("鏂规硶openCloud: [uid=" + uid + "][璁㈠崟ID=" + orderId + "]鏈哄櫒浜哄け璐ワ細 鏈哄櫒浜篒D杩斿洖涓虹┖");
-		}
-
-		String endTimeStr = dto.getEndTime();
-		if (StringUtil.isNullOrEmpty(endTimeStr)) {
-			LogHelper.cloudInfo("鏂规硶openCloud: [uid=" + uid + "][璁㈠崟ID=" + orderId + "]鏈哄櫒浜哄け璐ワ細 杩斿洖鏃堕棿涓虹┖");
-		}
-
-		long endTime = 0;
-		try {
-			endTime = Long.parseLong(endTimeStr);
-		} catch (Exception e) {
-			LogHelper.cloudInfo("鏂规硶openCloud: [uid=" + uid + "][璁㈠崟ID=" + orderId + "]鏈哄櫒浜哄け璐ワ細 杩斿洖鏃堕棿鏍煎紡涓嶆纭�");
-		}
-
-		Integer groupNum = dto.getGroupNum();
-		if (groupNum == null) {
-			LogHelper.cloudInfo("鏂规硶openCloud: [uid=" + uid + "][璁㈠崟ID=" + orderId + "]鏈哄櫒浜哄け璐ワ細 groupNum杩斿洖涓虹┖");
-		}
-
-		UserCloud newCloud = new UserCloud();
-		newCloud.setUid(uid);
-		newCloud.setOrderId(orderId);
-		newCloud.setGroupNum(groupNum);
-		newCloud.setRobotId(robotId);
-		newCloud.setRobotType(menuEnum.getRobotType());
-		if (renew) {
-			newCloud.setWxId(userCloud.getWxId());
-			newCloud.setWxName(userCloud.getWxName());
-			newCloud.setWxPortrait(userCloud.getPortrait());
-			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);
-
-		try {
-			String item = null;
-			if (renew) {
-				item = "鎴愬姛缁垂" + menuEnum.getDescShow();
-			} else {
-				item = "鎴愬姛寮�閫�" + menuEnum.getDescShow();
-			}
-			String desc = "瀹屾垚鍏呭�兼敮浠�" + BigDecimal.valueOf(menuEnum.getMoney()).setScale(2, BigDecimal.ROUND_DOWN) + "鍏�";
-			userOtherMsgNotificationService.cloudMsg(uid, "浜戝彂鍗曞厖鍊�", item, desc);
-		} catch (Exception e) {
-			LogHelper.errorDetailInfo(e);
-		}
-	}
-
-	@Override
-	public void searchGroup(Long uid) throws UserCloudException {
-		UserCloud userCloud = userCloudMapper.getValidByUid(uid);
-		if (userCloud == null)
-			throw new UserCloudException(1, "浜戝彂鍗曞凡杩囨湡");
-
-		Integer robotId = userCloud.getRobotId();
-		if (robotId == null)
-			throw new UserCloudException(1, "浜戝彂鍗曟満鍣ㄤ汉涓嶅瓨鍦�");
-
-		List<String> list = AitaokerApiUtil.getContract(robotId);
-		if (list == null || list.size() == 0)
-			throw new UserCloudException(1, "鏈绱㈠埌瀵瑰簲缇�");
-
-		String wxId = userCloud.getWxId();
-		for (String roomId : list) {
-			String key = RedisKeyEnum.cloudMatchGroup.getKey() + StringUtil.Md5(wxId + "_" + roomId);
-			String result = redisManager.getCommonString(key);
-			if (!StringUtil.isNullOrEmpty(result)) {
-				String groupName = null;
-				WeiXinGroupDTO groupDetail = AitaokerApiUtil.getGroupDetail(robotId, roomId);
-				if (groupDetail != null) {
-					groupName = groupDetail.getGroupName();
-				}
-				userCloudGroupService.addGroup(uid, roomId, groupName, userCloud.getGroupNum());
-			}
-		}
-	}
-
-	@Override
-	public void cacheMatchGroup(String wxId, String groupId) {
-		if (StringUtil.isNullOrEmpty(wxId) || StringUtil.isNullOrEmpty(groupId))
-			return;
-		String key = RedisKeyEnum.cloudMatchGroup.getKey() + StringUtil.Md5(wxId + "_" + groupId);
-		redisManager.cacheCommonString(key, "true", 60 * 20);
-	}
-
-	@Override
-	public void sendByDynamic(Long uid, String id) throws UserCloudException {
-		sendCircleByDynamic(uid, id, UserCloudSendRecord.SEND_WAY_MANUAL);
-	}
-
-	@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) {
-			LogHelper.cloudInfo("autoSendByDynamic - [uid:" + uid + " 鍔ㄦ�乮d:" + id + "]鍘熷洜锛�" + e.getMsg());
-		}
-	}
-
-	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 (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;
-		if (taoBaoInfo != null && taoBaoInfo.getRelationId() != null && taoBaoInfo.getRelationValid() != null
-				&& taoBaoInfo.getRelationValid() == true)
-			relationId = taoBaoInfo.getRelationId();
-
-		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)
-			throw new UserCloudException(1001, "浜戝彂鍗曞凡杩囨湡");
-
-		Integer robotId = userCloud.getRobotId();
-		if (robotId == null)
-			throw new UserCloudException(1002, "浜戝彂鍗曟満鍣ㄤ汉涓嶅瓨鍦�");
-
-		String wxId = userCloud.getWxId();
-		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)
-			throw new UserCloudException(1004, "璇峰厛寰俊鐧诲綍");
-
-		List<UserCloudGroup> listOpen = new ArrayList<>();
-		for (UserCloudGroup cloudGrou : listGroup) {
-			if (cloudGrou.getState()) {
-				listOpen.add(cloudGrou);
-			}
-		}
-		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)
-			throw new UserCloudException(1, "璇ュ唴瀹瑰凡涓嬫灦");
-
-		if (evaluate.getType() != EvaluateEnum.single && evaluate.getType() != EvaluateEnum.activity)
-			throw new UserCloudException(1, "璇ュ唴瀹逛笉鏀寔浜戝彂鍗�");
-
-		// 楠岃瘉鏄惁鍙浆閾�
-		List<CommentInfo> comments = evaluate.getComments();
-		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)) {
-			// 閫氱煡鐧诲綍寰俊
-			offlineNotification(uid);
-
-			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) {
-			String comment = null;
-			try {
-				comment = convertLinkManager.convertLinkFromText(commentInfo.getContent(), uid, true);
-				hasToken = true;
-			} catch (ConvertLinkExceptionException e) {
-				if (e.getCode() != ConvertLinkExceptionException.CODE_NONE) {
-					throw new UserCloudException(1, e.getMsg());
-				}
-			} catch (Exception e) {
-				LogHelper.errorDetailInfo(e);
-				throw new UserCloudException(1, "璇ュ唴瀹瑰寘鍚彲杞摼鍙d护鎴栭摼鎺�");
-			}
-
-			if (StringUtil.isNullOrEmpty(comment))
-				comment = commentInfo.getContent();
-
-			// 鏇挎崲浠锋牸
-			if (evaluate.getType() == EvaluateEnum.single) {
-				GoodsDetailVO goods = evaluate.getGoods();
-				comment = comment.replace("[鍘熶环]", MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()) + "");
-				if (!goods.isHasCoupon()) {
-					comment = comment.replace("棰嗗埜鎶㈣喘", "鎶㈣喘");
-					comment = comment.replace("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", "");
-				} else {
-					comment = comment.replace("[鍒稿悗浠穄", MoneyBigDecimalUtil.getWithNoZera(goods.getCouponPrice()) + "");
-				}
-				comment = comment.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n");
-			}
-
-			listComment.add(comment);
-		}
-
-		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<>();
-
-		List<ImgInfo> imgs = evaluate.getImgList();
-		if (imgs != null && imgs.size() > 0) {
-			for (ImgInfo imgInfo : imgs) {
-				if (imgInfo.getType() == ImgEnum.video) {
-					imgVideo = imgInfo;
-					continue;
-				}
-				listImg.add(imgInfo.getUrl());
-			}
-		}
-		
-		String wxId = userCloud.getWxId();
-		Integer robotId = userCloud.getRobotId();
-		// 淇濆瓨鍙戦�佽褰�
-		UserCloudSendRecord sendRecord = new UserCloudSendRecord();
-		sendRecord.setUid(uid);
-		sendRecord.setSendId(evaluate.getId());
-		sendRecord.setSendWay(way);
-		sendRecord.setWxId(wxId);
-		sendRecord.setRobotId(robotId);
-		sendRecord.setSendTime(new Date());
-		sendRecord.setSendOrigin(UserCloudSendRecord.ORIGIN_EVALUATE);
-		UserCloudSendRecord result = userCloudSendRecordService.save(sendRecord);
-		String pid = result.getId();
-
-		
-		for (UserCloudGroup cloudGroup : listOpen) {
-			String title = evaluate.getTitle();
-
-			UserCloudSendContent sendContent = new UserCloudSendContent();
-			sendContent.setPid(pid);
-			sendContent.setUid(uid);
-			sendContent.setGroupId(cloudGroup.getGroupId());
-			sendContent.setCreateTime(new Date());
-
-			if (cloudGroup.getType() == UserCloudGroup.TYPE_CIRCLE) { // 鏈嬪弸鍦�
-				String circleId = null;
-				sendContent.setType(UserCloudSendContent.TYPE_CIRCLE);
-
-				if (imgVideo == null) {
-
-					// 鍙戦�佸浘鏂�
-					String picUrl = "";
-					if (listImg.size() > 0) {
-						for (String img : listImg) {
-							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, picUrlUpload);
-				} else {
-					// 鍙戦�佽棰�
-					sendContent.setPicUrl(imgVideo.getUrl());
-					sendContent.setVideoUrl(imgVideo.getVideoUrl());
-					circleId = AitaokerApiUtil.macsendCircleVideo(robotId, imgVideo.getVideoUrl(), imgVideo.getUrl());
-				}
-
-				// 璇勮鏂囨湰
-				if (!StringUtil.isNullOrEmpty(circleId)) {
-					sendContent.setState(true);
-					List<String> list = new ArrayList<>();
-					for (String comment : listComment) {
-						boolean macsend = AitaokerApiUtil.macsendCircleComment(robotId, wxId, circleId, comment);
-						if (macsend) {
-							list.add(comment);
-						}
-					}
-					sendContent.setComments(list);
-				}
-			} else { // 缇�
-				sendContent.setType(UserCloudSendContent.TYPE_GROUP);
-
-				// 鍙戦�佹枃鏈�
-				if (!StringUtil.isNullOrEmpty(title)) {
-					boolean macsend = AitaokerApiUtil.macsendText(robotId, cloudGroup.getGroupId(), title);
-					if (macsend)
-						sendContent.setTitle(title);
-				}
-
-				// 鍙戦�佸浘鐗�
-				int num = 1;
-				String picNum = configService.get(ConfigKeyEnum.robotCloudGroupPictureNum.getKey());
-				if (!StringUtil.isNullOrEmpty(picNum)) {
-					num = Integer.parseInt(picNum);
-				}
-
-				if (listImg.size() > 0)
-					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);
-							if (macsend)
-								sendContent.setPicUrl(listImg.get(i));
-						} catch (Exception e) {
-							LogHelper.errorDetailInfo(e);
-						}
-					}
-
-				// 璇勮鏂囨湰
-				List<String> list = new ArrayList<>();
-				for (String comment : listComment) {
-					boolean macsend = AitaokerApiUtil.macsendText(robotId, cloudGroup.getGroupId(), comment);
-					if (macsend) {
-						list.add(comment);
-					}
-				}
-				sendContent.setState(true);
-				sendContent.setComments(list);
-			}
-			userCloudSendContentService.save(sendContent);
-		}
-	}
-	
-	
-	
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public void sendCustomGoods(Long uid, Long goodsId, Integer goodsType, Long sellerId) throws UserCloudException {
-		sendCircleByGoods(uid, goodsId, goodsType, null, sellerId, UserCloudSendRecord.SEND_WAY_MANUAL);
-	}
-
-	@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;
-		}
-		CommonGoods cgoods = cloudGoods.getCommonGoods();
-		if (cgoods == null)
-			return;
-
-		try {
-			// 鍙戦�佸晢鍝�
-			sendCircleByGoods(uid, cgoods.getGoodsId(), cgoods.getGoodsType(), id, cgoods.getSellerId(),
-					UserCloudSendRecord.SEND_WAY_AUTO);
-		} catch (UserCloudException e) {
-			LogHelper.cloudInfo("autoSendCustomGoods - [uid:" + uid + " 搴搃d:" + id + "]鍘熷洜锛�" + e.getMsg());
-		}
-	}
-
-	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)
-			throw new UserCloudException(1, "鐢ㄦ埛淇℃伅涓嶅瓨鍦�");
-
-		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;
-		if (taoBaoInfo != null && taoBaoInfo.getRelationId() != null && taoBaoInfo.getRelationValid() != null
-				&& taoBaoInfo.getRelationValid() == true)
-			relationId = taoBaoInfo.getRelationId();
-
-		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 {
-				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, "鍔犲叆浜戝彂鍗曞閫夊簱澶辫触");
-			}
-			time4= java.lang.System.currentTimeMillis();
-			LogHelper.test("sendCircleByGoods鍔犲叆澶囬�夊簱锛�" + (time4 - time3));
-		}
-
-		// 鑷�夊簱鍟嗗搧鏄惁鎵撳紑
-		boolean custom = false;
-		UserCloudManage cloudManage = userCloudManageService.selectByPrimaryKey(uid);
-		if (cloudManage != null) {
-			if (cloudManage.getCustom() != null)
-				custom = cloudManage.getCustom();
-		}
-		if (!custom) {
-			return;
-		}
-
-		Integer robotId = userCloud.getRobotId();
-		if (robotId == null)
-			throw new UserCloudException(1, "浜戝彂鍗曟満鍣ㄤ汉涓嶅瓨鍦�");
-
-		String wxId = userCloud.getWxId();
-		if (StringUtil.isNullOrEmpty(wxId))
-			throw new UserCloudException(1002, "璇峰厛鐧诲綍寰俊");
-
-		// 楠岃瘉寮�鍚姸鎬�
-		List<UserCloudGroup> listGroup = userCloudGroupService.listByUid(uid);
-		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()) {
-				listOpen.add(cloudGrou);
-			}
-		}
-
-		if (listOpen.size() == 0)
-			throw new UserCloudException(1004, "璇峰厛寮�鍚簯鍙戝崟缇ゅ姛鑳�");
-
-		// 妫�娴嬪井淇℃槸鍚︾櫥褰曠姸鎬�
-		if (!AitaokerApiUtil.onlineCheck(robotId)) {
-			// 閫氱煡鐧诲綍寰俊
-			offlineNotification(uid);
-
-			throw new UserCloudException(1003, "寰俊宸叉帀绾匡紝闇�瑕侀噸鏂版壂鎻忎簩缁寸爜鐧诲綍");
-		}
-
-		long time6= java.lang.System.currentTimeMillis();
-		LogHelper.test("sendCircleByGoods楠岃瘉鏄惁鐧诲綍寰俊锛�" + (time6 - time5));
-		
-		// 淇濆瓨鍙戦�佽褰�
-		UserCloudSendRecord sendRecord = new UserCloudSendRecord();
-		sendRecord.setUid(uid);
-		sendRecord.setGoodsId(goodsId + "");
-		sendRecord.setGoodsType(goodsType + "");
-		sendRecord.setWxId(wxId);
-		sendRecord.setRobotId(robotId);
-		sendRecord.setSendTime(new Date());
-		if (storeId != null) {
-			sendRecord.setSendId(storeId + "");
-			sendRecord.setSendOrigin(UserCloudSendRecord.ORIGIN_STORE);
-			sendRecord.setSendWay(UserCloudSendRecord.SEND_WAY_AUTO);
-		} else {
-			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) {
-				sendTaoBaoGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId());
-			} else if (goodsType == Constant.SOURCE_TYPE_JD) {
-				sendJDGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId());
-			} 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());
-			}
-			// 鏇存柊鍙戝崟璁板綍
-			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);
-			}
-			long time8= java.lang.System.currentTimeMillis();
-			LogHelper.test("sendCircleByGoods鎵ц鍙戦�侊細" + (time8 - time7));
-		} catch (UserCloudException e) {
-			LogHelper.cloudInfo("autoSendCustomGoods - [uid:" + uid + " 搴搃d:" + storeId + "]鍘熷洜锛�" + e.getMsg());
-			// 鏇存柊鍙戝崟璁板綍
-			if (storeId != null) {
-				UserCloudGoods record = new UserCloudGoods();
-				record.setId(storeId);
-				record.setState(UserCloudGoods.STATE_INVALID);
-				record.setSendTime(new Date());
-				record.setUpdateTime(new Date());
-				userCloudGoodsService.updateByPrimaryKeySelective(record);
-			}
-		}
-
-	}
-
-	/**
-	 * 娣樺疂鍟嗗搧淇℃伅澶勭悊
-	 * 
-	 * @param user
-	 * @param inviteCode
-	 * @param robotId
-	 * @param wxId
-	 * @param goodsId
-	 * @param relationId
-	 * @param listOpen
-	 * @throws UserCloudException
-	 */
-	private void sendTaoBaoGoods(UserInfo user, int robotId, String wxId, Long goodsId, String relationId,
-			List<UserCloudGroup> listOpen, String pid) throws UserCloudException {
-		TaoBaoLink taoBaoLink = null;
-		try {
-			taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(user.getId(), goodsId, relationId);
-		} catch (ShareGoodsException e) {
-			LogHelper.errorDetailInfo(e);
-			throw new UserCloudException(1, "璇ュ晢鍝佸凡涓嬫灦");
-		}
-		if (taoBaoLink == null)
-			throw new UserCloudException(1, "璇ュ晢鍝佸凡涓嬫灦");
-
-		TaoBaoGoodsBrief goods = taoBaoLink.getGoods();
-		boolean coupon = false;
-		if (!StringUtil.isNullOrEmpty(goods.getCouponInfo())) {
-			coupon = true;
-		}
-
-		String quanPrice = "";
-		String description = "";
-		String couponAmount = "";
-		if (coupon) {
-			description = goods.getDescription();
-			quanPrice = TaoBaoUtil.getAfterUseCouplePrice(goods) + "";
-			couponAmount = MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount()).toString();
-		}
-		String sales = TaoBaoUtil.getSaleCount(goods.getBiz30day());
-
-		// 鑾峰彇鎺ㄨ崘璇�
-		String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, goods.getTitle(), sales,
-				couponAmount, description);
-		// 鑾峰彇璇勮璇�
-		String commentText = shareGoodsTextTemplateService.getCommentTextByTaoToken(coupon, taoBaoLink.getTaoToken(),
-				goods.getZkPrice().toString(), quanPrice);
-
-		// 寮傛鎵ц鍙戦��
-		executor.execute(new Runnable() {
-			@Override
-			public void run() {
-				sendGoods(robotId, wxId, listOpen, recommendText, commentText, goods.getImgList(), user.getId(), pid);
-			}
-		});
-	}
-
-	/**
-	 * 浜笢鍟嗗搧浜戝彂鍗�
-	 * 
-	 * @param user
-	 * @param robotId
-	 * @param wxId
-	 * @param goodsId
-	 * @param relationId
-	 * @param listOpen
-	 * @throws UserCloudException
-	 */
-	private void sendJDGoods(UserInfo user, int robotId, String wxId, Long goodsId, String relationId,
-			List<UserCloudGroup> listOpen, String pid) throws UserCloudException {
-		JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(goodsId);
-		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() + "");
-
-		boolean coupon = false;
-		if (couponInfo != null) {
-			coupon = true;
-		}
-
-		String quanPrice = "";
-		String couponAmount = "";
-		if (coupon) {
-			quanPrice = BigDecimalUtil.getWithNoZera(JDUtil.getQuanPrice(jdGoods)).toString() + "";
-			couponAmount = BigDecimalUtil.getWithNoZera(couponInfo.getDiscount()).toString();
-		}
-
-		String sales = JDUtil.getSaleCount(jdGoods.getInOrderCount30Days());
-
-		// 鑾峰彇鎺ㄨ崘璇�
-		String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, jdGoods.getSkuName(), sales,
-				couponAmount, null);
-
-		// 鑾峰彇璇勮璇�
-		BigDecimal price = jdGoods.getPrice();
-		JDPingouInfo pinGouInfo = jdGoods.getPinGouInfo();
-		if (pinGouInfo != null) {
-			price = pinGouInfo.getPingouPrice();
-		}
-		String zkPrice = BigDecimalUtil.getWithNoZera(price).toString();
-		String commentText = shareGoodsTextTemplateService.getCommentTextByLink(coupon, jumpLink, zkPrice, quanPrice,
-				ConfigKeyEnum.quickShareJDCommentText);
-
-		// 寮傛鎵ц鍙戦��
-		executor.execute(new Runnable() {
-			@Override
-			public void run() {
-				sendGoods(robotId, wxId, listOpen, recommendText, commentText, jdGoods.getImageList(), user.getId(), pid);
-			}
-		});
-				
-	}
-
-	/**
-	 * 浜笢鍟嗗搧浜戝彂鍗�
-	 * 
-	 * @param user
-	 * @param robotId
-	 * @param wxId
-	 * @param goodsId
-	 * @param relationId
-	 * @param listOpen
-	 * @throws UserCloudException
-	 */
-	private void sendPDDGoods(UserInfo user, int robotId, String wxId, Long goodsId, String relationId,
-			List<UserCloudGroup> listOpen, String pid) throws UserCloudException {
-		PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
-		if (goods == null)
-			throw new UserCloudException(1, "璇ュ晢鍝佸凡涓嬫灦");
-
-		String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", user.getId() + "");
-
-		boolean coupon = true;
-		if (goods.getHasCoupon() == null || !goods.getHasCoupon()) {
-			coupon = false;
-		}
-
-		String quanPrice = "";
-		String couponAmount = "";
-		if (coupon) {
-			BigDecimal hundred = new BigDecimal(100);
-			BigDecimal amount = MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponDiscount()), hundred);
-			quanPrice = BigDecimalUtil.getWithNoZera(amount).toString();
-			couponAmount = BigDecimalUtil.getWithNoZera(PinDuoDuoUtil.getQuanPrice(goods)).toString();
-		}
-
-		String sales = goods.getSalesTip();
-		if (StringUtil.isNullOrEmpty(sales)) {
-			sales = "0";
-		}
-
-		// 鑾峰彇鎺ㄨ崘璇�
-		String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, goods.getGoodsName(), sales,
-				couponAmount, null);
-
-		// 鑾峰彇璇勮璇�
-		String zkPrice = MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinGroupPrice()), new BigDecimal(100))
-				.setScale(2).toString();
-		String commentText = shareGoodsTextTemplateService.getCommentTextByLink(coupon, jumpLink, zkPrice, quanPrice,
-				ConfigKeyEnum.quickSharePDDCommentText);
-
-		List<String> list = null;
-		String[] goodsGalleryUrls = goods.getGoodsGalleryUrls();
-		if (goodsGalleryUrls != null && goodsGalleryUrls.length > 0) {
-			list = Arrays.asList(goodsGalleryUrls);
-		}
-		
-		List<String> list2 = list;
-		// 寮傛鎵ц鍙戦��
-		executor.execute(new Runnable() {
-			@Override
-			public void run() {
-				sendGoods(robotId, wxId, listOpen, recommendText, commentText, list2, user.getId(), pid);
-			}
-		});
-				
-	}
-
-	/**
-	 * 鍞搧浼氬晢鍝�
-	 * 
-	 * @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.quickShareVIPCommentText);
-
-		// 寮傛鎵ц鍙戦��
-		executor.execute(new Runnable() {
-			@Override
-			public void run() {
-				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 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 template = configService.get(ConfigKeyEnum.quickShareSuNingCommentText.getKey());
-		String commentText = shareGoodsTextTemplateService.createQuickShareTextSuNing(template, goods, jumpLink);
-
-		List<String> imgList = new ArrayList<>();
-		for (SuningGoodsImg img : goods.getCommodityInfo().getPictureUrl()) {
-			imgList.add(img.getPicUrl());
-		}
-		
-		executor.execute(new Runnable() {
-			@Override
-			public void run() {
-				// 浜戝彂鍗�
-				sendGoods(robotId, wxId, listOpen, recommendText, commentText, imgList, user.getId(), pid);
-			}
-		});
-	}
-
-	/**
-	 * 鍙戦�佸晢鍝�
-	 * 
-	 * @param robotId
-	 * @param title
-	 * @param comment
-	 * @param listImg
-	 * @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) {
-		// 閬嶅巻缇�-鏈嬪弸鍦�
-		for (UserCloudGroup cloudGroup : listOpen) {
-			UserCloudSendContent sendContent = new UserCloudSendContent();
-			sendContent.setPid(pid);
-			sendContent.setUid(uid);
-			sendContent.setGroupId(cloudGroup.getGroupId());
-			sendContent.setCreateTime(new Date());
-
-			if (cloudGroup.getType() == UserCloudGroup.TYPE_CIRCLE) { // 鏈嬪弸鍦�
-				sendContent.setType(UserCloudSendContent.TYPE_CIRCLE);
-				String picUrl = "";
-				if (listImg.size() > 0) {
-					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, picUrlUpload);
-				// 璇勮鏂囨湰
-				if (!StringUtil.isNullOrEmpty(circleId)) {
-					sendContent.setState(true);
-					List<String> list = new ArrayList<>();
-					boolean macsend = AitaokerApiUtil.macsendCircleComment(robotId, wxId, circleId, comment);
-					if (macsend) {
-						list.add(comment);
-					}
-					sendContent.setComments(list);
-				}
-			} else {
-				sendContent.setType(UserCloudSendContent.TYPE_GROUP);
-				// 鍙戦�佹枃鏈�
-				if (!StringUtil.isNullOrEmpty(title)) {
-					boolean macsend = AitaokerApiUtil.macsendText(robotId, cloudGroup.getGroupId(), title);
-					if (macsend)
-						sendContent.setTitle(title);
-				}
-
-				// 鍙戦�佸浘鐗�
-				int num = 1;
-				String picNum = configService.get(ConfigKeyEnum.robotCloudGroupPictureNum.getKey());
-				if (!StringUtil.isNullOrEmpty(picNum)) {
-					num = Integer.parseInt(picNum);
-				}
-
-				if (listImg.size() > 0)
-					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);
-							if (macsend)
-								sendContent.setPicUrl(listImg.get(i));
-						} catch (Exception e) {
-							LogHelper.errorDetailInfo(e);
-						}
-					}
-
-				// 璇勮鏂囨湰
-				List<String> list = new ArrayList<>();
-				boolean macsend = AitaokerApiUtil.macsendText(robotId, cloudGroup.getGroupId(), comment);
-				if (macsend) {
-					list.add(comment);
-				}
-				sendContent.setState(true);
-				sendContent.setComments(list);
-			}
-			userCloudSendContentService.save(sendContent);
-		}
-	}
-
-	@Override
-	public void fixedTimeSend(List<GoodsEvaluate> listActivity, List<GoodsEvaluate> listGoods, boolean timeLimit) {
-		if (listGoods == null && listActivity == null)
-			return;
-		// 涓�涓皬鏃朵箣鍓�
-		Date lastTime = new Date(java.lang.System.currentTimeMillis() - 1000 * 60 * 60);
-		for (int i = 0; i < 1000; i++) {
-			// 鏌ヨ鍝簺鐢ㄦ埛寮�閫�
-			List<Long> listUser = userCloudMapper.listValidUid(i * 1000, 1000);
-			if (listUser == null || listUser.size() == 0) {
-				break;
-			}
-
-			// 閬嶅巻鐢ㄦ埛
-			for (Long uid : listUser) {
-				try {// 鍒ゆ柇鏄惁寮�閫氬畼鏂归噰闆�
-					UserCloudManage cloudManage = userCloudManageService.selectByPrimaryKey(uid);
-					if (cloudManage == null || cloudManage.getOfficial() == null || !cloudManage.getOfficial()) {
-						continue;
-					}
-					
-					// 鏃堕棿闂撮殧锛氭槸鍚﹀湪涓�涓皬鏃跺唴宸插彂閫佽繃
-					if (timeLimit) {
-						UserCloudSendRecord last = userCloudSendRecordService.getLastByUid(uid, lastTime);
-						if (last != null)
-							continue;
-					}
-					
-				
-					String evaluateId = null;
-					// 娲诲姩
-					if (listActivity != null && listActivity.size() > 0) {
-						for (GoodsEvaluate evaluate : listActivity) {
-							UserCloudSendRecord record = userCloudSendRecordService.getByUidAndSendId(uid,
-									evaluate.getId());
-							if (record != null)
-								continue;
-
-							evaluateId = evaluate.getId();
-							break;
-						}
-					}
-					// 鍗曞搧
-					if (StringUtil.isNullOrEmpty(evaluateId) && listGoods != null && listGoods.size() > 0) {
-						for (GoodsEvaluate evaluate : listGoods) {
-							UserCloudSendRecord record = userCloudSendRecordService.getByUidAndSendId(uid,
-									evaluate.getId());
-							if (record != null)
-								continue;
-
-							evaluateId = evaluate.getId();
-							break;
-						}
-					}
-
-					if (!StringUtil.isNullOrEmpty(evaluateId)) {
-						UserCloudMQMsg msg = new UserCloudMQMsg(uid, evaluateId, UserCloudMQMsg.TYPE_EVALUATE);
-						Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userCloud,
-								msg);
-						rocketMQManager.sendNormalMsg(message, null);
-					}
-				} catch (Exception e) {
-					LogHelper.errorDetailInfo(e);
-				}
-			}
-		}
-	}
-
-	private void offlineNotification(Long uid) {
-		UserCloudManage cloudManage = userCloudManageService.selectForUpdate(uid);
-		if (cloudManage == null) {
-			return;
-		}
-
-		Boolean offlineNotice = cloudManage.getOfflineNotice();
-		if (offlineNotice != null && offlineNotice) {
-			return;
-		}
-
-		try {
-			userOtherMsgNotificationService.cloudMsg(uid, "浜戝彂鍗曞井淇¤处鍙�", "寰俊璐﹀彿鎺夌嚎", "闇�瑕佷綘閲嶆柊鎵弿浜岀淮鐮佺櫥褰�");
-		} catch (Exception e) {
-			LogHelper.errorDetailInfo(e);
-		}
-
-		// 绔欏唴淇¢�氱煡
-		offlineNotificationZNX(uid);
-
-		// 寤惰繜10鍒嗛挓鍐嶆鎻愰啋
-		if (!Constant.IS_TEST) {
-			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);
-			rocketMQManager.sendNormalMsg(message, null);
-		}
-
-		// 鏇存柊宸叉彁閱�
-		UserCloudManage updateManage = new UserCloudManage();
-		updateManage.setId(uid);
-		updateManage.setOfflineNotice(true);
-		userCloudManageService.updateByPrimaryKeySelective(updateManage);
-	}
-
-	// 绔欏唴淇¢�氱煡
-	@Override
-	public void offlineNotificationZNX(Long uid) {
-		// 楠岃瘉鏄惁寮�閫�
-		UserCloud userCloud = userCloudMapper.getValidByUid(uid);
-		if (userCloud == null)
-			return;
-
-		Integer robotId = userCloud.getRobotId();
-		if (robotId == null)
-			return;
-
-		// 鐧诲綍鐘舵��
-		if (AitaokerApiUtil.onlineCheck(robotId)) {
-			return;
-		}
-
-		try {
-			pushService.pushZNX(uid, "銆愰噸瑕侀�氱煡銆戜綘鐨勪簯鍙戝崟寰俊宸叉帀绾裤��", "闇�瑕佷綘閲嶆柊鎵弿浜岀淮鐮佺櫥褰�", null, null);
-		} catch (Exception e) {
-			LogHelper.errorDetailInfo(e);
-		}
-	}
-
+package com.yeshi.fanli.service.impl.user.cloud;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import com.yeshi.fanli.entity.SystemEnum;
+import com.yeshi.fanli.entity.SystemPIDInfo;
+import com.yeshi.fanli.exception.taobao.TaoBaoConvertLinkException;
+import com.yeshi.fanli.service.manger.PIDManager;
+import com.yeshi.fanli.service.manger.goods.TaoBaoLinkManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+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.aliyun.openservices.ons.api.Message;
+import com.yeshi.fanli.dao.mybatis.user.cloud.UserCloudMapper;
+import com.yeshi.fanli.dto.aitaoker.RobotInfoDTO;
+import com.yeshi.fanli.dto.aitaoker.WeiXinGroupDTO;
+import com.yeshi.fanli.dto.jd.JDCouponInfo;
+import com.yeshi.fanli.dto.jd.JDPingouInfo;
+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;
+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.entity.dynamic.GoodsEvaluate;
+import com.yeshi.fanli.entity.dynamic.GoodsEvaluate.EvaluateEnum;
+import com.yeshi.fanli.entity.dynamic.ImgInfo;
+import com.yeshi.fanli.entity.dynamic.ImgInfo.ImgEnum;
+import com.yeshi.fanli.entity.goods.CommonGoods;
+import com.yeshi.fanli.entity.jd.JDGoods;
+import com.yeshi.fanli.entity.system.ConfigKeyEnum;
+import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief;
+import com.yeshi.fanli.entity.taobao.TaoBaoLink;
+import com.yeshi.fanli.exception.goods.ConvertLinkException;
+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.goods.ShareGoodsService;
+import com.yeshi.fanli.service.inter.goods.ShareGoodsTextTemplateService;
+import com.yeshi.fanli.service.inter.msg.UserOtherMsgNotificationService;
+import com.yeshi.fanli.service.inter.push.PushService;
+import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
+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;
+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 org.yeshi.utils.MoneyBigDecimalUtil;
+import com.yeshi.fanli.util.RedisKeyEnum;
+import com.yeshi.fanli.util.RedisManager;
+import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.aitaoker.AitaokerApiUtil;
+import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
+import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil;
+import com.yeshi.fanli.util.jd.JDApiUtil;
+import com.yeshi.fanli.util.jd.JDUtil;
+import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
+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
+public class UserCloudServiceImpl implements UserCloudService {
+
+    Logger logger = LoggerFactory.getLogger(UserCloudService.class);
+
+    @Resource
+    private UserCloudMapper userCloudMapper;
+
+    @Resource
+    private UserCloudGroupService userCloudGroupService;
+
+    @Resource
+    private GoodsEvaluateService goodsEvaluateService;
+
+    @Resource
+    private ConvertLinkManager convertLinkManager;
+
+    @Resource
+    private UserCloudGoodsService userCloudGoodsService;
+
+    @Resource
+    private UserInfoExtraService userInfoExtraService;
+
+    @Resource
+    private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
+
+    @Resource
+    private UserInfoService userInfoService;
+
+    @Resource
+    private ShareGoodsService shareGoodsService;
+
+    @Resource
+    private ConfigService configService;
+
+    @Resource
+    private JDGoodsCacheUtil jdGoodsCacheUtil;
+
+    @Resource
+    private PinDuoDuoCacheUtil pinDuoDuoCacheUtil;
+
+
+    @Resource
+    private RedisManager redisManager;
+
+    @Resource
+    private ShareGoodsTextTemplateService shareGoodsTextTemplateService;
+
+    @Resource
+    private UserCloudSendRecordService userCloudSendRecordService;
+
+    @Resource
+    private UserCloudSendContentService userCloudSendContentService;
+
+    @Resource
+    private UserCloudManageService userCloudManageService;
+
+    @Resource
+    private RocketMQManager rocketMQManager;
+
+    @Resource
+    private UserOtherMsgNotificationService userOtherMsgNotificationService;
+
+    @Resource
+    private PushService pushService;
+
+    @Resource(name = "taskExecutor")
+    private TaskExecutor executor;
+
+    @Resource
+    private TaoBaoLinkManager taoBaoLinkManager;
+
+
+    @Resource
+    private PIDManager pidManager;
+
+    @Override
+    public UserCloud getValidByUid(Long uid) {
+        return userCloudMapper.getValidByUid(uid);
+    }
+
+    @Override
+    public UserCloud getLastByUid(Long uid) {
+        return userCloudMapper.getLastByUid(uid);
+    }
+
+    @Override
+    public long countByUid(Long uid) {
+        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)
+    public void updateWXInfo(Long uid, String wxId, String wxName, String wxPortrait) throws UserCloudException {
+        UserCloud userCloud = userCloudMapper.getValidByUid(uid);
+        if (userCloud == null)
+            throw new UserCloudException(1, "浜戝彂鍗曞凡杩囨湡");
+
+        // 妫�娴嬫槸鍚﹂渶瑕佹洿鏂� - 1鍒嗛挓闂撮殧
+        String key = "cloudLogin_" + uid;
+        String result = redisManager.getCommonString(key);
+        if (!StringUtil.isNullOrEmpty(result)) {
+            return;
+        }
+        redisManager.cacheCommonString(key, "true", 60);
+
+        // 鏇存柊淇℃伅
+        UserCloud update = new UserCloud();
+        update.setId(userCloud.getId());
+        update.setWxId(wxId);
+        update.setWxName(wxName);
+        update.setWxPortrait(wxPortrait);
+        userCloudMapper.updateByPrimaryKeySelective(update);
+
+        try {
+            userOtherMsgNotificationService.cloudMsg(uid, "浜戝彂鍗曞井淇¤处鍙�", "寰俊璐﹀彿鐧诲綍鎴愬姛", "鍙互寮�鍚綘鐨勭兢鍙戝崟浜�");
+        } catch (Exception e) {
+            LogHelper.errorDetailInfo(e);
+        }
+
+        // 鏇存柊鎻愰啋鐘舵��
+        UserCloudManage cloudManage = userCloudManageService.selectForUpdate(uid);
+        if (cloudManage == null) {
+            userCloudManageService.save(uid, false, false);
+        } else {
+            UserCloudManage updateManage = new UserCloudManage();
+            updateManage.setId(uid);
+            updateManage.setOfflineNotice(false);
+            userCloudManageService.updateByPrimaryKeySelective(updateManage);
+        }
+
+        // 寰俊鍙峰彉鍖�-娓呯┖缇や俊鎭�
+        if (!wxId.equals(userCloud.getWxId())) {
+            userCloudGroupService.deleteGroupByUid(uid);
+        }
+
+        // 鍔犲叆鏈嬪弸鍦�
+        if (StringUtil.isNullOrEmpty(userCloud.getWxId())) {
+            userCloudGroupService.addCircle(uid);
+        }
+    }
+
+    @Override
+    public void openCloud(Long uid, Long orderId, CloudOrderMenuEnum menuEnum) throws UserCloudException {
+        UserCloud existCloud = userCloudMapper.getByOrderId(orderId);
+        if (existCloud != null) {
+            return; // 璇ヨ鍗曞凡澶勭悊瀹屾垚
+        }
+
+        boolean renew = false;
+        UserCloud userCloud = userCloudMapper.getLastByUid(uid);
+        if (userCloud != null) {
+            // 缁垂
+            if (userCloud.getEndTime().getTime() > java.lang.System.currentTimeMillis())
+                renew = true;
+            // 楠岃瘉濂楅鏄惁鐩稿悓
+            if (renew && userCloud.getRobotType() != menuEnum.getRobotType()) {
+                LogHelper.cloudInfo("鏂规硶openCloud: [uid=" + uid + "][璁㈠崟ID=" + orderId + "]宸叉湁鍏朵粬浜戝彂鍗曞椁愯繕鏈粨鏉�");
+                throw new UserCloudException(1, "宸叉湁鍏朵粬浜戝彂鍗曞椁愯繕鏈粨鏉�");
+            }
+        }
+
+        RobotInfoDTO dto = null;
+        if (renew) { // 缁垂
+            dto = AitaokerApiUtil.robotRenewals(userCloud.getRobotId(), menuEnum.getMonth());
+        } else { // 鍒涘缓鏈哄櫒浜�
+            dto = AitaokerApiUtil.robotCreate(menuEnum.getMonth(), menuEnum.getRobotType(), "wechatrobot", null);
+        }
+
+        if (dto == null) {
+            LogHelper.cloudInfo("鏂规硶openCloud: [uid=" + uid + "][璁㈠崟ID=" + orderId + "]鏈哄櫒浜哄け璐ワ細 鏈哄櫒浜哄垱寤哄け璐�");
+        }
+
+        Integer robotId = dto.getId();
+        if (robotId == null) {
+            LogHelper.cloudInfo("鏂规硶openCloud: [uid=" + uid + "][璁㈠崟ID=" + orderId + "]鏈哄櫒浜哄け璐ワ細 鏈哄櫒浜篒D杩斿洖涓虹┖");
+        }
+
+        String endTimeStr = dto.getEndTime();
+        if (StringUtil.isNullOrEmpty(endTimeStr)) {
+            LogHelper.cloudInfo("鏂规硶openCloud: [uid=" + uid + "][璁㈠崟ID=" + orderId + "]鏈哄櫒浜哄け璐ワ細 杩斿洖鏃堕棿涓虹┖");
+        }
+
+        long endTime = 0;
+        try {
+            endTime = Long.parseLong(endTimeStr);
+        } catch (Exception e) {
+            LogHelper.cloudInfo("鏂规硶openCloud: [uid=" + uid + "][璁㈠崟ID=" + orderId + "]鏈哄櫒浜哄け璐ワ細 杩斿洖鏃堕棿鏍煎紡涓嶆纭�");
+        }
+
+        Integer groupNum = dto.getGroupNum();
+        if (groupNum == null) {
+            LogHelper.cloudInfo("鏂规硶openCloud: [uid=" + uid + "][璁㈠崟ID=" + orderId + "]鏈哄櫒浜哄け璐ワ細 groupNum杩斿洖涓虹┖");
+        }
+
+        UserCloud newCloud = new UserCloud();
+        newCloud.setUid(uid);
+        newCloud.setOrderId(orderId);
+        newCloud.setGroupNum(groupNum);
+        newCloud.setRobotId(robotId);
+        newCloud.setRobotType(menuEnum.getRobotType());
+        if (renew) {
+            newCloud.setWxId(userCloud.getWxId());
+            newCloud.setWxName(userCloud.getWxName());
+            newCloud.setWxPortrait(userCloud.getPortrait());
+            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);
+
+        try {
+            String item = null;
+            if (renew) {
+                item = "鎴愬姛缁垂" + menuEnum.getDescShow();
+            } else {
+                item = "鎴愬姛寮�閫�" + menuEnum.getDescShow();
+            }
+            String desc = "瀹屾垚鍏呭�兼敮浠�" + BigDecimal.valueOf(menuEnum.getMoney()).setScale(2, BigDecimal.ROUND_DOWN) + "鍏�";
+            userOtherMsgNotificationService.cloudMsg(uid, "浜戝彂鍗曞厖鍊�", item, desc);
+        } catch (Exception e) {
+            LogHelper.errorDetailInfo(e);
+        }
+    }
+
+    @Override
+    public void searchGroup(Long uid) throws UserCloudException {
+        UserCloud userCloud = userCloudMapper.getValidByUid(uid);
+        if (userCloud == null)
+            throw new UserCloudException(1, "浜戝彂鍗曞凡杩囨湡");
+
+        Integer robotId = userCloud.getRobotId();
+        if (robotId == null)
+            throw new UserCloudException(1, "浜戝彂鍗曟満鍣ㄤ汉涓嶅瓨鍦�");
+
+        List<String> list = AitaokerApiUtil.getContract(robotId);
+        if (list == null || list.size() == 0)
+            throw new UserCloudException(1, "鏈绱㈠埌瀵瑰簲缇�");
+
+        String wxId = userCloud.getWxId();
+        for (String roomId : list) {
+            String key = RedisKeyEnum.cloudMatchGroup.getKey() + StringUtil.Md5(wxId + "_" + roomId);
+            String result = redisManager.getCommonString(key);
+            if (!StringUtil.isNullOrEmpty(result)) {
+                String groupName = null;
+                WeiXinGroupDTO groupDetail = AitaokerApiUtil.getGroupDetail(robotId, roomId);
+                if (groupDetail != null) {
+                    groupName = groupDetail.getGroupName();
+                }
+                userCloudGroupService.addGroup(uid, roomId, groupName, userCloud.getGroupNum());
+            }
+        }
+    }
+
+    @Override
+    public void cacheMatchGroup(String wxId, String groupId) {
+        if (StringUtil.isNullOrEmpty(wxId) || StringUtil.isNullOrEmpty(groupId))
+            return;
+        String key = RedisKeyEnum.cloudMatchGroup.getKey() + StringUtil.Md5(wxId + "_" + groupId);
+        redisManager.cacheCommonString(key, "true", 60 * 20);
+    }
+
+    @Override
+    public void sendByDynamic(Long uid, String id) throws UserCloudException {
+        sendCircleByDynamic(uid, id, UserCloudSendRecord.SEND_WAY_MANUAL);
+    }
+
+    @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) {
+            LogHelper.cloudInfo("autoSendByDynamic - [uid:" + uid + " 鍔ㄦ�乮d:" + id + "]鍘熷洜锛�" + e.getMsg());
+        }
+    }
+
+    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 (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;
+        if (taoBaoInfo != null && taoBaoInfo.getRelationId() != null && taoBaoInfo.getRelationValid() != null
+                && taoBaoInfo.getRelationValid() == true)
+            relationId = taoBaoInfo.getRelationId();
+
+        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)
+            throw new UserCloudException(1001, "浜戝彂鍗曞凡杩囨湡");
+
+        Integer robotId = userCloud.getRobotId();
+        if (robotId == null)
+            throw new UserCloudException(1002, "浜戝彂鍗曟満鍣ㄤ汉涓嶅瓨鍦�");
+
+        String wxId = userCloud.getWxId();
+        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)
+            throw new UserCloudException(1004, "璇峰厛寰俊鐧诲綍");
+
+        List<UserCloudGroup> listOpen = new ArrayList<>();
+        for (UserCloudGroup cloudGrou : listGroup) {
+            if (cloudGrou.getState()) {
+                listOpen.add(cloudGrou);
+            }
+        }
+        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)
+            throw new UserCloudException(1, "璇ュ唴瀹瑰凡涓嬫灦");
+
+        if (evaluate.getType() != EvaluateEnum.single && evaluate.getType() != EvaluateEnum.activity)
+            throw new UserCloudException(1, "璇ュ唴瀹逛笉鏀寔浜戝彂鍗�");
+
+        // 楠岃瘉鏄惁鍙浆閾�
+        List<CommentInfo> comments = evaluate.getComments();
+        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)) {
+            // 閫氱煡鐧诲綍寰俊
+            offlineNotification(uid);
+
+            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) {
+            String comment = null;
+            try {
+                comment = convertLinkManager.convertLinkFromText(user.getSystem(), commentInfo.getContent(), uid, true, false);
+                hasToken = true;
+            } catch (ConvertLinkException e) {
+                if (e.getCode() != ConvertLinkException.CODE_NONE) {
+                    throw new UserCloudException(1, e.getMsg());
+                }
+            } catch (Exception e) {
+                LogHelper.errorDetailInfo(e);
+                throw new UserCloudException(1, "璇ュ唴瀹瑰寘鍚彲杞摼鍙d护鎴栭摼鎺�");
+            }
+
+            if (StringUtil.isNullOrEmpty(comment))
+                comment = commentInfo.getContent();
+
+            // 鏇挎崲浠锋牸
+            if (evaluate.getType() == EvaluateEnum.single) {
+                GoodsDetailVO goods = evaluate.getGoods();
+                comment = comment.replace("[鍘熶环]", MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()) + "");
+                if (!goods.isHasCoupon()) {
+                    comment = comment.replace("棰嗗埜鎶㈣喘", "鎶㈣喘");
+                    comment = comment.replace("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", "");
+                } else {
+                    comment = comment.replace("[鍒稿悗浠穄", MoneyBigDecimalUtil.getWithNoZera(goods.getCouponPrice()) + "");
+                }
+                comment = comment.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n");
+            }
+
+            listComment.add(comment);
+        }
+
+        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<>();
+
+        List<ImgInfo> imgs = evaluate.getImgList();
+        if (imgs != null && imgs.size() > 0) {
+            for (ImgInfo imgInfo : imgs) {
+                if (imgInfo.getType() == ImgEnum.video) {
+                    imgVideo = imgInfo;
+                    continue;
+                }
+                listImg.add(imgInfo.getUrl());
+            }
+        }
+
+
+        String wxId = userCloud.getWxId();
+        Integer robotId = userCloud.getRobotId();
+        // 淇濆瓨鍙戦�佽褰�
+        UserCloudSendRecord sendRecord = new UserCloudSendRecord();
+        sendRecord.setUid(uid);
+        sendRecord.setSendId(evaluate.getId());
+        sendRecord.setSendWay(way);
+        sendRecord.setWxId(wxId);
+        sendRecord.setRobotId(robotId);
+        sendRecord.setSendTime(new Date());
+        sendRecord.setSendOrigin(UserCloudSendRecord.ORIGIN_EVALUATE);
+        UserCloudSendRecord result = userCloudSendRecordService.save(sendRecord);
+        String pid = result.getId();
+
+
+        for (UserCloudGroup cloudGroup : listOpen) {
+            String title = evaluate.getTitle();
+
+            UserCloudSendContent sendContent = new UserCloudSendContent();
+            sendContent.setPid(pid);
+            sendContent.setUid(uid);
+            sendContent.setGroupId(cloudGroup.getGroupId());
+            sendContent.setCreateTime(new Date());
+
+            if (cloudGroup.getType() == UserCloudGroup.TYPE_CIRCLE) { // 鏈嬪弸鍦�
+                String circleId = null;
+                sendContent.setType(UserCloudSendContent.TYPE_CIRCLE);
+
+                if (imgVideo == null) {
+
+                    // 鍙戦�佸浘鏂�
+                    String picUrl = "";
+                    if (listImg.size() > 0) {
+                        for (String img : listImg) {
+                            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, picUrlUpload);
+                } else {
+                    // 鍙戦�佽棰�
+                    sendContent.setPicUrl(imgVideo.getUrl());
+                    sendContent.setVideoUrl(imgVideo.getVideoUrl());
+                    circleId = AitaokerApiUtil.macsendCircleVideo(robotId, imgVideo.getVideoUrl(), imgVideo.getUrl());
+                }
+
+                // 璇勮鏂囨湰
+                if (!StringUtil.isNullOrEmpty(circleId)) {
+                    sendContent.setState(true);
+                    List<String> list = new ArrayList<>();
+                    for (String comment : listComment) {
+                        boolean macsend = AitaokerApiUtil.macsendCircleComment(robotId, wxId, circleId, comment);
+                        if (macsend) {
+                            list.add(comment);
+                        }
+                    }
+                    sendContent.setComments(list);
+                }
+            } else { // 缇�
+                sendContent.setType(UserCloudSendContent.TYPE_GROUP);
+
+                // 鍙戦�佹枃鏈�
+                if (!StringUtil.isNullOrEmpty(title)) {
+                    boolean macsend = AitaokerApiUtil.macsendText(robotId, cloudGroup.getGroupId(), title);
+                    if (macsend)
+                        sendContent.setTitle(title);
+                }
+                SystemEnum system = userInfoService.getUserSystem(uid);
+                // 鍙戦�佸浘鐗�
+                int num = 1;
+                String picNum = configService.getValue(ConfigKeyEnum.robotCloudGroupPictureNum.getKey(), system);
+                if (!StringUtil.isNullOrEmpty(picNum)) {
+                    num = Integer.parseInt(picNum);
+                }
+
+                if (listImg.size() > 0)
+                    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);
+                            if (macsend)
+                                sendContent.setPicUrl(listImg.get(i));
+                        } catch (Exception e) {
+                            LogHelper.errorDetailInfo(e);
+                        }
+                    }
+
+                // 璇勮鏂囨湰
+                List<String> list = new ArrayList<>();
+                for (String comment : listComment) {
+                    boolean macsend = AitaokerApiUtil.macsendText(robotId, cloudGroup.getGroupId(), comment);
+                    if (macsend) {
+                        list.add(comment);
+                    }
+                }
+                sendContent.setState(true);
+                sendContent.setComments(list);
+            }
+            userCloudSendContentService.save(sendContent);
+        }
+    }
+
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void sendCustomGoods(Long uid, String goodsId, Integer goodsType, Long sellerId) throws UserCloudException {
+        sendCircleByGoods(uid, goodsId, goodsType, null, sellerId, UserCloudSendRecord.SEND_WAY_MANUAL);
+    }
+
+    @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;
+        }
+        CommonGoods cgoods = cloudGoods.getCommonGoods();
+        if (cgoods == null)
+            return;
+
+        try {
+            // 鍙戦�佸晢鍝�
+            sendCircleByGoods(uid, cgoods.getGoodsId(), cgoods.getGoodsType(), id, cgoods.getSellerId(),
+                    UserCloudSendRecord.SEND_WAY_AUTO);
+        } catch (UserCloudException e) {
+            LogHelper.cloudInfo("autoSendCustomGoods - [uid:" + uid + " 搴搃d:" + id + "]鍘熷洜锛�" + e.getMsg());
+        }
+    }
+
+    private void sendCircleByGoods(Long uid, String 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)
+            throw new UserCloudException(1, "鐢ㄦ埛淇℃伅涓嶅瓨鍦�");
+
+        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;
+        if (taoBaoInfo != null && taoBaoInfo.getRelationId() != null && taoBaoInfo.getRelationValid() != null
+                && taoBaoInfo.getRelationValid() == true)
+            relationId = taoBaoInfo.getRelationId();
+
+        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 {
+                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, "鍔犲叆浜戝彂鍗曞閫夊簱澶辫触");
+            }
+            time4 = java.lang.System.currentTimeMillis();
+            LogHelper.test("sendCircleByGoods鍔犲叆澶囬�夊簱锛�" + (time4 - time3));
+        }
+
+        // 鑷�夊簱鍟嗗搧鏄惁鎵撳紑
+        boolean custom = false;
+        UserCloudManage cloudManage = userCloudManageService.selectByPrimaryKey(uid);
+        if (cloudManage != null) {
+            if (cloudManage.getCustom() != null)
+                custom = cloudManage.getCustom();
+        }
+        if (!custom) {
+            return;
+        }
+
+        Integer robotId = userCloud.getRobotId();
+        if (robotId == null)
+            throw new UserCloudException(1, "浜戝彂鍗曟満鍣ㄤ汉涓嶅瓨鍦�");
+
+        String wxId = userCloud.getWxId();
+        if (StringUtil.isNullOrEmpty(wxId))
+            throw new UserCloudException(1002, "璇峰厛鐧诲綍寰俊");
+
+        // 楠岃瘉寮�鍚姸鎬�
+        List<UserCloudGroup> listGroup = userCloudGroupService.listByUid(uid);
+        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()) {
+                listOpen.add(cloudGrou);
+            }
+        }
+
+        if (listOpen.size() == 0)
+            throw new UserCloudException(1004, "璇峰厛寮�鍚簯鍙戝崟缇ゅ姛鑳�");
+
+        // 妫�娴嬪井淇℃槸鍚︾櫥褰曠姸鎬�
+        if (!AitaokerApiUtil.onlineCheck(robotId)) {
+            // 閫氱煡鐧诲綍寰俊
+            offlineNotification(uid);
+
+            throw new UserCloudException(1003, "寰俊宸叉帀绾匡紝闇�瑕侀噸鏂版壂鎻忎簩缁寸爜鐧诲綍");
+        }
+
+        long time6 = java.lang.System.currentTimeMillis();
+        LogHelper.test("sendCircleByGoods楠岃瘉鏄惁鐧诲綍寰俊锛�" + (time6 - time5));
+
+        // 淇濆瓨鍙戦�佽褰�
+        UserCloudSendRecord sendRecord = new UserCloudSendRecord();
+        sendRecord.setUid(uid);
+        sendRecord.setGoodsId(goodsId + "");
+        sendRecord.setGoodsType(goodsType + "");
+        sendRecord.setWxId(wxId);
+        sendRecord.setRobotId(robotId);
+        sendRecord.setSendTime(new Date());
+        if (storeId != null) {
+            sendRecord.setSendId(storeId + "");
+            sendRecord.setSendOrigin(UserCloudSendRecord.ORIGIN_STORE);
+            sendRecord.setSendWay(UserCloudSendRecord.SEND_WAY_AUTO);
+        } else {
+            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) {
+                sendTaoBaoGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId());
+            } else if (goodsType == Constant.SOURCE_TYPE_JD) {
+                sendJDGoods(user, robotId, wxId, goodsId, relationId, listOpen, result.getId());
+            } 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,  Long.parseLong(goodsId), relationId, listOpen, result.getId());
+            } else if (goodsType == Constant.SOURCE_TYPE_SUNING) {
+                sendSuNingGoods(user, robotId, wxId,  Long.parseLong(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);
+            }
+            long time8 = java.lang.System.currentTimeMillis();
+            LogHelper.test("sendCircleByGoods鎵ц鍙戦�侊細" + (time8 - time7));
+        } catch (UserCloudException e) {
+            LogHelper.cloudInfo("autoSendCustomGoods - [uid:" + uid + " 搴搃d:" + storeId + "]鍘熷洜锛�" + e.getMsg());
+            // 鏇存柊鍙戝崟璁板綍
+            if (storeId != null) {
+                UserCloudGoods record = new UserCloudGoods();
+                record.setId(storeId);
+                record.setState(UserCloudGoods.STATE_INVALID);
+                record.setSendTime(new Date());
+                record.setUpdateTime(new Date());
+                userCloudGoodsService.updateByPrimaryKeySelective(record);
+            }
+        }
+
+    }
+
+    /**
+     * 娣樺疂鍟嗗搧淇℃伅澶勭悊
+     *
+     * @param user
+     * @param robotId
+     * @param wxId
+     * @param goodsId
+     * @param relationId
+     * @param listOpen
+     * @throws UserCloudException
+     */
+    private void sendTaoBaoGoods(UserInfo user, int robotId, String wxId, String goodsId, String relationId,
+                                 List<UserCloudGroup> listOpen, String pid) throws UserCloudException {
+        TaoBaoLink taoBaoLink = null;
+        try {
+            taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(user.getSystem(), user.getId(), goodsId, relationId, null);
+        } catch (TaoBaoConvertLinkException e) {
+            LogHelper.errorDetailInfo(e);
+            throw new UserCloudException(1, "璇ュ晢鍝佸凡涓嬫灦");
+        }
+        if (taoBaoLink == null)
+            throw new UserCloudException(1, "璇ュ晢鍝佸凡涓嬫灦");
+
+        TaoBaoGoodsBrief goods = taoBaoLink.getGoods();
+        boolean coupon = false;
+        if (!StringUtil.isNullOrEmpty(goods.getCouponInfo())) {
+            coupon = true;
+        }
+
+        String quanPrice = "";
+        String description = "";
+        String couponAmount = "";
+        if (coupon) {
+            description = goods.getDescription();
+            quanPrice = TaoBaoUtil.getCouponPrice(goods) + "";
+            couponAmount = MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount()).toString();
+        }
+        String sales = TaoBaoUtil.getSaleCount(goods.getBiz30day());
+
+        SystemEnum system = userInfoService.getUserSystem(user.getId());
+
+        // 鑾峰彇鎺ㄨ崘璇�
+        String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, goods.getTitle(), sales,
+                couponAmount, description, system);
+        // 鑾峰彇璇勮璇�
+        String commentText = shareGoodsTextTemplateService.getCommentTextByTaoToken(coupon, taoBaoLink.getTaoToken(),
+                goods.getZkPrice().toString(), quanPrice, system);
+
+        // 寮傛鎵ц鍙戦��
+        executor.execute(new Runnable() {
+            @Override
+            public void run() {
+                sendGoods(robotId, wxId, listOpen, recommendText, commentText, goods.getImgList(), user.getId(), pid);
+            }
+        });
+    }
+
+    /**
+     * 浜笢鍟嗗搧浜戝彂鍗�
+     *
+     * @param user
+     * @param robotId
+     * @param wxId
+     * @param goodsId
+     * @param relationId
+     * @param listOpen
+     * @throws UserCloudException
+     */
+    private void sendJDGoods(UserInfo user, int robotId, String wxId, String goodsId, String relationId,
+                             List<UserCloudGroup> listOpen, String pid) throws UserCloudException {
+        JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(goodsId);
+        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 = null;
+        try {
+            jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pidManager.getPidCache(user.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.share),
+                    user.getId() + "");
+        } catch (Exception e) {
+            logger.warn(String.format("浜笢杞摼鍑洪敊锛歮aterialId-%s  couponUrl-%s", materialId, couponUrl), e);
+        }
+
+        boolean coupon = false;
+        if (couponInfo != null) {
+            coupon = true;
+        }
+
+        String quanPrice = "";
+        String couponAmount = "";
+        if (coupon) {
+            quanPrice = BigDecimalUtil.getWithNoZera(JDUtil.getCouponPrice(jdGoods)).toString() + "";
+            couponAmount = BigDecimalUtil.getWithNoZera(couponInfo.getDiscount()).toString();
+        }
+
+        String sales = JDUtil.getSaleCount(jdGoods.getInOrderCount30Days());
+
+        SystemEnum system = userInfoService.getUserSystem(user.getId());
+
+        // 鑾峰彇鎺ㄨ崘璇�
+        String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, jdGoods.getSkuName(), sales,
+                couponAmount, null, system);
+
+        // 鑾峰彇璇勮璇�
+        BigDecimal price = jdGoods.getPrice();
+        JDPingouInfo pinGouInfo = jdGoods.getPinGouInfo();
+        if (pinGouInfo != null) {
+            price = pinGouInfo.getPingouPrice();
+        }
+        String zkPrice = BigDecimalUtil.getWithNoZera(price).toString();
+        String commentText = shareGoodsTextTemplateService.getCommentTextByLink(coupon, jumpLink, zkPrice, quanPrice,
+                ConfigKeyEnum.quickShareJDCommentText, system);
+
+        // 寮傛鎵ц鍙戦��
+        executor.execute(new Runnable() {
+            @Override
+            public void run() {
+                sendGoods(robotId, wxId, listOpen, recommendText, commentText, jdGoods.getImageList(), user.getId(), pid);
+            }
+        });
+
+    }
+
+    /**
+     * 浜笢鍟嗗搧浜戝彂鍗�
+     *
+     * @param user
+     * @param robotId
+     * @param wxId
+     * @param goodsId
+     * @param relationId
+     * @param listOpen
+     * @throws UserCloudException
+     */
+    private void sendPDDGoods(UserInfo user, int robotId, String wxId, String goodsId, String relationId,
+                              List<UserCloudGroup> listOpen, String pid) throws UserCloudException {
+        PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
+        if (goods == null)
+            throw new UserCloudException(1, "璇ュ晢鍝佸凡涓嬫灦");
+
+        String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goods.getGoodsSign(), pidManager.getPidCache(user.getSystem(), Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.share), user.getId() + "");
+
+        boolean coupon = true;
+        if (goods.getHasCoupon() == null || !goods.getHasCoupon()) {
+            coupon = false;
+        }
+
+        String quanPrice = "";
+        String couponAmount = "";
+        if (coupon) {
+            BigDecimal hundred = new BigDecimal(100);
+            BigDecimal amount = MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponDiscount()), hundred);
+            quanPrice = BigDecimalUtil.getWithNoZera(amount).toString();
+            couponAmount = BigDecimalUtil.getWithNoZera(PinDuoDuoUtil.getCouponPrice(goods)).toString();
+        }
+
+        String sales = goods.getSalesTip();
+        if (StringUtil.isNullOrEmpty(sales)) {
+            sales = "0";
+        }
+
+        SystemEnum system = userInfoService.getUserSystem(user.getId());
+
+        // 鑾峰彇鎺ㄨ崘璇�
+        String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, goods.getGoodsName(), sales,
+                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, system);
+
+        List<String> list = null;
+        String[] goodsGalleryUrls = goods.getGoodsGalleryUrls();
+        if (goodsGalleryUrls != null && goodsGalleryUrls.length > 0) {
+            list = Arrays.asList(goodsGalleryUrls);
+        }
+
+        List<String> list2 = list;
+        // 寮傛鎵ц鍙戦��
+        executor.execute(new Runnable() {
+            @Override
+            public void run() {
+                sendGoods(robotId, wxId, listOpen, recommendText, commentText, list2, user.getId(), pid);
+            }
+        });
+
+    }
+
+    /**
+     * 鍞搧浼氬晢鍝�
+     *
+     * @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 = "";
+        SystemEnum system = userInfoService.getUserSystem(user.getId());
+        // 鑾峰彇鎺ㄨ崘璇�
+        String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon, goods.getGoodsName(), null,
+                couponAmount, null, system);
+        // 鑾峰彇璇勮璇�
+        String commentText = shareGoodsTextTemplateService.getCommentTextByLink(coupon, jumpLink,
+                goods.getMarketPrice(), quanPrice, ConfigKeyEnum.quickShareVIPCommentText, system);
+
+        // 寮傛鎵ц鍙戦��
+        executor.execute(new Runnable() {
+            @Override
+            public void run() {
+                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, pidManager.getPidCache(user.getSystem(), Constant.SOURCE_TYPE_SUNING, SystemPIDInfo.PidType.share), user.getId() + "");
+
+        boolean coupon = false;
+        String couponAmount = "";
+        String sales = null;
+        if (goods.getCouponInfo() != null && !StringUtil.isNullOrEmpty(goods.getCouponInfo().getCouponUrl())) {// 鏈夊埜
+            couponAmount = new BigDecimal(goods.getCouponInfo().getCouponValue()).toString();
+            coupon = true;
+        }
+
+        SystemEnum system = userInfoService.getUserSystem(user.getId());
+
+        // 鑾峰彇鎺ㄨ崘璇�
+        String recommendText = shareGoodsTextTemplateService.getRecommendText(coupon,
+                goods.getCommodityInfo().getCommodityName(), sales, couponAmount, null, system);
+
+        // 鐢熸垚蹇嵎鍒嗕韩鍐呭
+        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());
+        }
+
+        executor.execute(new Runnable() {
+            @Override
+            public void run() {
+                // 浜戝彂鍗�
+                sendGoods(robotId, wxId, listOpen, recommendText, commentText, imgList, user.getId(), pid);
+            }
+        });
+    }
+
+    /**
+     * 鍙戦�佸晢鍝�
+     *
+     * @param robotId
+     * @param title
+     * @param comment
+     * @param listImg
+     * @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) {
+        // 閬嶅巻缇�-鏈嬪弸鍦�
+        for (UserCloudGroup cloudGroup : listOpen) {
+            UserCloudSendContent sendContent = new UserCloudSendContent();
+            sendContent.setPid(pid);
+            sendContent.setUid(uid);
+            sendContent.setGroupId(cloudGroup.getGroupId());
+            sendContent.setCreateTime(new Date());
+
+            if (cloudGroup.getType() == UserCloudGroup.TYPE_CIRCLE) { // 鏈嬪弸鍦�
+                sendContent.setType(UserCloudSendContent.TYPE_CIRCLE);
+                String picUrl = "";
+                if (listImg.size() > 0) {
+                    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, picUrlUpload);
+                // 璇勮鏂囨湰
+                if (!StringUtil.isNullOrEmpty(circleId)) {
+                    sendContent.setState(true);
+                    List<String> list = new ArrayList<>();
+                    boolean macsend = AitaokerApiUtil.macsendCircleComment(robotId, wxId, circleId, comment);
+                    if (macsend) {
+                        list.add(comment);
+                    }
+                    sendContent.setComments(list);
+                }
+            } else {
+                sendContent.setType(UserCloudSendContent.TYPE_GROUP);
+                // 鍙戦�佹枃鏈�
+                if (!StringUtil.isNullOrEmpty(title)) {
+                    boolean macsend = AitaokerApiUtil.macsendText(robotId, cloudGroup.getGroupId(), title);
+                    if (macsend)
+                        sendContent.setTitle(title);
+                }
+                SystemEnum system = userInfoService.getUserSystem(uid);
+                // 鍙戦�佸浘鐗�
+                int num = 1;
+                String picNum = configService.getValue(ConfigKeyEnum.robotCloudGroupPictureNum.getKey(), system);
+                if (!StringUtil.isNullOrEmpty(picNum)) {
+                    num = Integer.parseInt(picNum);
+                }
+
+                if (listImg.size() > 0)
+                    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);
+                            if (macsend)
+                                sendContent.setPicUrl(listImg.get(i));
+                        } catch (Exception e) {
+                            LogHelper.errorDetailInfo(e);
+                        }
+                    }
+
+                // 璇勮鏂囨湰
+                List<String> list = new ArrayList<>();
+                boolean macsend = AitaokerApiUtil.macsendText(robotId, cloudGroup.getGroupId(), comment);
+                if (macsend) {
+                    list.add(comment);
+                }
+                sendContent.setState(true);
+                sendContent.setComments(list);
+            }
+            userCloudSendContentService.save(sendContent);
+        }
+    }
+
+    @Override
+    public void fixedTimeSend(List<GoodsEvaluate> listActivity, List<GoodsEvaluate> listGoods, boolean timeLimit) {
+        if (listGoods == null && listActivity == null)
+            return;
+        // 涓�涓皬鏃朵箣鍓�
+        Date lastTime = new Date(java.lang.System.currentTimeMillis() - 1000 * 60 * 60);
+        for (int i = 0; i < 1000; i++) {
+            // 鏌ヨ鍝簺鐢ㄦ埛寮�閫�
+            List<Long> listUser = userCloudMapper.listValidUid(i * 1000, 1000);
+            if (listUser == null || listUser.size() == 0) {
+                break;
+            }
+
+            // 閬嶅巻鐢ㄦ埛
+            for (Long uid : listUser) {
+                try {// 鍒ゆ柇鏄惁寮�閫氬畼鏂归噰闆�
+                    UserCloudManage cloudManage = userCloudManageService.selectByPrimaryKey(uid);
+                    if (cloudManage == null || cloudManage.getOfficial() == null || !cloudManage.getOfficial()) {
+                        continue;
+                    }
+
+                    // 鏃堕棿闂撮殧锛氭槸鍚﹀湪涓�涓皬鏃跺唴宸插彂閫佽繃
+                    if (timeLimit) {
+                        UserCloudSendRecord last = userCloudSendRecordService.getLastByUid(uid, lastTime);
+                        if (last != null)
+                            continue;
+                    }
+
+
+                    String evaluateId = null;
+                    // 娲诲姩
+                    if (listActivity != null && listActivity.size() > 0) {
+                        for (GoodsEvaluate evaluate : listActivity) {
+                            UserCloudSendRecord record = userCloudSendRecordService.getByUidAndSendId(uid,
+                                    evaluate.getId());
+                            if (record != null)
+                                continue;
+
+                            evaluateId = evaluate.getId();
+                            break;
+                        }
+                    }
+                    // 鍗曞搧
+                    if (StringUtil.isNullOrEmpty(evaluateId) && listGoods != null && listGoods.size() > 0) {
+                        for (GoodsEvaluate evaluate : listGoods) {
+                            UserCloudSendRecord record = userCloudSendRecordService.getByUidAndSendId(uid,
+                                    evaluate.getId());
+                            if (record != null)
+                                continue;
+
+                            evaluateId = evaluate.getId();
+                            break;
+                        }
+                    }
+
+                    if (!StringUtil.isNullOrEmpty(evaluateId)) {
+                        UserCloudMQMsg msg = new UserCloudMQMsg(uid, evaluateId, UserCloudMQMsg.TYPE_EVALUATE);
+                        Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userCloud,
+                                msg);
+                        rocketMQManager.sendNormalMsg(message, null);
+                    }
+                } catch (Exception e) {
+                    LogHelper.errorDetailInfo(e);
+                }
+            }
+        }
+    }
+
+    private void offlineNotification(Long uid) {
+        UserCloudManage cloudManage = userCloudManageService.selectForUpdate(uid);
+        if (cloudManage == null) {
+            return;
+        }
+
+        Boolean offlineNotice = cloudManage.getOfflineNotice();
+        if (offlineNotice != null && offlineNotice) {
+            return;
+        }
+
+        try {
+            userOtherMsgNotificationService.cloudMsg(uid, "浜戝彂鍗曞井淇¤处鍙�", "寰俊璐﹀彿鎺夌嚎", "闇�瑕佷綘閲嶆柊鎵弿浜岀淮鐮佺櫥褰�");
+        } catch (Exception e) {
+            LogHelper.errorDetailInfo(e);
+        }
+
+        // 绔欏唴淇¢�氱煡
+        offlineNotificationZNX(uid);
+
+        // 寤惰繜10鍒嗛挓鍐嶆鎻愰啋
+        if (!Constant.IS_TEST) {
+            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);
+            rocketMQManager.sendNormalMsg(message, null);
+        }
+
+        // 鏇存柊宸叉彁閱�
+        UserCloudManage updateManage = new UserCloudManage();
+        updateManage.setId(uid);
+        updateManage.setOfflineNotice(true);
+        userCloudManageService.updateByPrimaryKeySelective(updateManage);
+    }
+
+    // 绔欏唴淇¢�氱煡
+    @Override
+    public void offlineNotificationZNX(Long uid) {
+        // 楠岃瘉鏄惁寮�閫�
+        UserCloud userCloud = userCloudMapper.getValidByUid(uid);
+        if (userCloud == null)
+            return;
+
+        Integer robotId = userCloud.getRobotId();
+        if (robotId == null)
+            return;
+
+        // 鐧诲綍鐘舵��
+        if (AitaokerApiUtil.onlineCheck(robotId)) {
+            return;
+        }
+
+        SystemEnum system = userInfoService.getUserSystem(uid);
+
+        try {
+            pushService.pushZNX(uid, "銆愰噸瑕侀�氱煡銆戜綘鐨勪簯鍙戝崟寰俊宸叉帀绾裤��", "闇�瑕佷綘閲嶆柊鎵弿浜岀淮鐮佺櫥褰�", null, null, system);
+        } catch (Exception e) {
+            LogHelper.errorDetailInfo(e);
+        }
+    }
+
 }
\ No newline at end of file

--
Gitblit v1.8.0