From dcb37a9df7c41be08d3aed13667e9162382d134a Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期五, 19 六月 2020 10:47:53 +0800 Subject: [PATCH] 发圈商品来源调整 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/cloud/UserCloudServiceImpl.java | 386 +++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 277 insertions(+), 109 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 7807105..4b15830 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 @@ -8,6 +8,7 @@ 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; @@ -55,8 +56,11 @@ 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; @@ -71,6 +75,7 @@ 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; @@ -158,6 +163,19 @@ @Resource(name = "producer") private Producer producer; + @Resource + private UserOtherMsgNotificationService userOtherMsgNotificationService; + + @Resource + private PushService pushService; + + @Resource + private UserSystemMsgService userSystemMsgService; + + @Resource(name = "taskExecutor") + private TaskExecutor executor; + + @Override public UserCloud getValidByUid(Long uid) { @@ -196,6 +214,15 @@ 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()); @@ -203,7 +230,24 @@ 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); @@ -216,7 +260,6 @@ } @Override - @Transactional(rollbackFor = Exception.class) public void openCloud(Long uid, Long orderId, CloudOrderMenuEnum menuEnum) throws UserCloudException { UserCloud existCloud = userCloudMapper.getByOrderId(orderId); if (existCloud != null) { @@ -230,7 +273,7 @@ if (userCloud.getEndTime().getTime() > java.lang.System.currentTimeMillis()) renew = true; // 楠岃瘉濂楅鏄惁鐩稿悓 - if (renew && userCloud.getRobotType() != menuEnum.getType()) { + if (renew && userCloud.getRobotType() != menuEnum.getRobotType()) { LogHelper.cloudInfo("鏂规硶openCloud: [uid=" + uid + "][璁㈠崟ID=" + orderId + "]宸叉湁鍏朵粬浜戝彂鍗曞椁愯繕鏈粨鏉�"); throw new UserCloudException(1, "宸叉湁鍏朵粬浜戝彂鍗曞椁愯繕鏈粨鏉�"); } @@ -239,19 +282,22 @@ RobotInfoDTO dto = null; if (renew) { // 缁垂 dto = AitaokerApiUtil.robotRenewals(userCloud.getRobotId(), menuEnum.getMonth()); - } else { - dto = AitaokerApiUtil.robotCreate(menuEnum.getMonth(), menuEnum.getType(), "wechatrobot", null); + } else { // 鍒涘缓鏈哄櫒浜� + dto = AitaokerApiUtil.robotCreate(menuEnum.getMonth(), menuEnum.getRobotType(), "wechatrobot", null); } if (dto == null) { - LogHelper.cloudInfo("鏂规硶openCloud: [uid=" + uid + "][璁㈠崟ID=" + orderId + "]鏈哄櫒浜哄け璐ワ細 杩斿洖绌哄��"); - throw new UserCloudException(1, "鏈哄櫒浜鸿幏鍙栧け璐�"); + 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 + "]鏈哄櫒浜哄け璐ワ細 杩斿洖鏃堕棿涓虹┖"); - throw new UserCloudException(1, "鏈哄櫒浜鸿繑鍥炴椂闂翠负绌�"); } long endTime = 0; @@ -259,19 +305,11 @@ endTime = Long.parseLong(endTimeStr); } catch (Exception e) { LogHelper.cloudInfo("鏂规硶openCloud: [uid=" + uid + "][璁㈠崟ID=" + orderId + "]鏈哄櫒浜哄け璐ワ細 杩斿洖鏃堕棿鏍煎紡涓嶆纭�"); - throw new UserCloudException(1, "鏈哄櫒浜鸿繑鍥炴椂闂存牸寮忎笉姝g‘"); - } - - Integer robotId = dto.getId(); - if (robotId == null) { - LogHelper.cloudInfo("鏂规硶openCloud: [uid=" + uid + "][璁㈠崟ID=" + orderId + "]鏈哄櫒浜哄け璐ワ細 鏈哄櫒浜篒D杩斿洖涓虹┖"); - throw new UserCloudException(1, "鏈哄櫒浜篒D杩斿洖涓虹┖"); } Integer groupNum = dto.getGroupNum(); if (groupNum == null) { LogHelper.cloudInfo("鏂规硶openCloud: [uid=" + uid + "][璁㈠崟ID=" + orderId + "]鏈哄櫒浜哄け璐ワ細 groupNum杩斿洖涓虹┖"); - throw new UserCloudException(1, "groupNum杩斿洖涓虹┖"); } UserCloud newCloud = new UserCloud(); @@ -279,8 +317,11 @@ newCloud.setOrderId(orderId); newCloud.setGroupNum(groupNum); newCloud.setRobotId(robotId); - newCloud.setRobotType(menuEnum.getType()); + 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()); @@ -291,6 +332,19 @@ // 寮�鍚彂鍦堝姛鑳� 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 @@ -306,12 +360,27 @@ List<WeiXinGroupDTO> list = AitaokerApiUtil.getContract(robotId); if (list == null || list.size() == 0) throw new UserCloudException(1, "鏈绱㈠埌瀵瑰簲缇�"); - + + String wxId = userCloud.getWxId(); for (WeiXinGroupDTO dto : list) { - userCloudGroupService.addGroup(uid, dto.getGroupId(), dto.getGroupName(), userCloud.getGroupNum()); + String groupId = dto.getGroupId(); + // 妫�娴嬫槸鍚﹀尮閰嶇兢 + String key = RedisKeyEnum.cloudMatchGroup.getKey() + StringUtil.Md5(wxId + "_" + groupId); + String result = redisManager.getCommonString(key); + if (!StringUtil.isNullOrEmpty(result)) { + userCloudGroupService.addGroup(uid, dto.getGroupId(), dto.getGroupName(), 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); @@ -405,7 +474,10 @@ // 妫�娴嬪井淇℃槸鍚︾櫥褰曠姸鎬� if (!AitaokerApiUtil.onlineCheck(robotId)) { - throw new UserCloudException(1003, "璇烽噸鏂扮櫥褰曞井淇�"); + // 閫氱煡鐧诲綍寰俊 + offlineNotification(uid); + + throw new UserCloudException(1003, "寰俊宸叉帀绾匡紝闇�瑕侀噸鏂版壂鎻忎簩缁寸爜鐧诲綍"); } @@ -449,7 +521,6 @@ String qrCode = null; - String cloudPic = null; ImgInfo imgVideo = null; List<String> listImg = new ArrayList<>(); @@ -460,26 +531,7 @@ imgVideo = imgInfo; continue; } - - if (imgInfo.getType() == ImgEnum.goods) { - cloudPic = imgInfo.getUrl(); - } listImg.add(imgInfo.getUrl()); - - // 鍙栨秷浜岀淮鐮佸浘 -// GoodsDetailVO goodsVO = imgInfo.getGoodsVO(); -// if (goodsVO == null) { -// listImg.add(imgInfo.getUrl()); -// } else { -// String jumpLink = getJumpLink(goodsVO, user, relationId, inviteCode, imgInfo.getUrl()); -// if (!StringUtil.isNullOrEmpty(jumpLink)) { -// qrCode = jumpLink; -// } -// } - } - - if (cloudPic == null) { - cloudPic = imgs.get(0).getUrl(); } } @@ -492,7 +544,7 @@ sendRecord.setWxId(wxId); sendRecord.setRobotId(robotId); sendRecord.setSendTime(new Date()); - sendRecord.setSendOrigin(UserCloudSendRecord.ORIGIN_STORE); + sendRecord.setSendOrigin(UserCloudSendRecord.ORIGIN_EVALUATE); UserCloudSendRecord result = userCloudSendRecordService.save(sendRecord); String pid = result.getId(); @@ -516,9 +568,12 @@ if (listImg.size() > 0) { for (String img: listImg) { - picUrl += "," + img; + picUrl += img + ";" ; } } + + if (picUrl.endsWith(";")) + picUrl = picUrl.substring(0, picUrl.length()-1); sendContent.setTitle(title); sendContent.setPicUrl(picUrl); // 鍙戦�佸浘鏂� @@ -553,16 +608,23 @@ } // 鍙戦�佸浘鐗� - if (!StringUtil.isNullOrEmpty(cloudPic)) { - try { - String imgBase64 = ImageToBase64.NetImageToBase64(cloudPic); - boolean macsend = AitaokerApiUtil.macsendImgBase64(robotId, cloudGroup.getGroupId(), imgBase64); - if (macsend) - sendContent.setPicUrl(cloudPic); - } catch (Exception e) { - LogHelper.errorDetailInfo(e); - } + 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<>(); @@ -583,7 +645,7 @@ @Override @Transactional(rollbackFor = Exception.class) public void sendCustomGoods(Long uid, Long goodsId, Integer goodsType, Long sellerId) throws UserCloudException{ - sendCircleByGoods(uid, goodsId, goodsType, null, sellerId); + sendCircleByGoods(uid, goodsId, goodsType, null, sellerId, UserCloudSendRecord.SEND_WAY_MANUAL); } @Override @@ -610,13 +672,14 @@ try { // 鍙戦�佸晢鍝� - sendCircleByGoods(uid, cgoods.getGoodsId(), cgoods.getGoodsType(), id, cgoods.getSellerId()); + 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) throws UserCloudException { + private void sendCircleByGoods(Long uid, Long goodsId, Integer goodsType, Long storeId, + Long sellerId, int way) throws UserCloudException { // 楠岃瘉鏄惁鎺堟潈 UserInfo user = userInfoService.getUserByIdWithMybatis(uid); if (user == null) @@ -665,7 +728,7 @@ custom = cloudManage.getCustom(); } if (!custom) { - throw new UserCloudException(0, "鎴愬姛鍔犲叆浜戝彂鍗曞簱"); + return; } Integer robotId = userCloud.getRobotId(); @@ -694,9 +757,11 @@ // 妫�娴嬪井淇℃槸鍚︾櫥褰曠姸鎬� if (!AitaokerApiUtil.onlineCheck(robotId)) { - throw new UserCloudException(1003, "璇烽噸鏂扮櫥褰曞井淇�"); + // 閫氱煡鐧诲綍寰俊 + offlineNotification(uid); + + throw new UserCloudException(1003, "寰俊宸叉帀绾匡紝闇�瑕侀噸鏂版壂鎻忎簩缁寸爜鐧诲綍"); } - // 淇濆瓨鍙戦�佽褰� UserCloudSendRecord sendRecord = new UserCloudSendRecord(); @@ -715,27 +780,43 @@ } UserCloudSendRecord result = userCloudSendRecordService.save(sendRecord); - 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()); + 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); + } + + } 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); + } } + - // 鏇存柊鍙戝崟璁板綍 - 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); - } + } /** @@ -1009,9 +1090,12 @@ String picUrl = ""; if (listImg.size() > 0) { for (String img: listImg) { - picUrl += "," + img; + picUrl += img + ";" ; } } + + if (picUrl.endsWith(";")) + picUrl = picUrl.substring(0, picUrl.length()-1); sendContent.setTitle(title); sendContent.setPicUrl(picUrl); @@ -1037,18 +1121,25 @@ } // 鍙戦�佸浘鐗� - String picurl = listImg.get(0); - if (!StringUtil.isNullOrEmpty(picurl)) { - try { - String imgBase64 = ImageToBase64.NetImageToBase64(picurl); - boolean macsend = AitaokerApiUtil.macsendImgBase64(robotId, cloudGroup.getGroupId(), imgBase64); - if (macsend) - sendContent.setPicUrl(picurl); - } catch (Exception e) { - LogHelper.errorDetailInfo(e); + 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); @@ -1062,40 +1153,58 @@ } } + @Override - public void fixedTimeSend(String id) { - if (StringUtil.isNullOrEmpty(id)) + public void fixedTimeSend(List<GoodsEvaluate> listActivity, List<GoodsEvaluate> listGoods) { + if (listGoods == null && listActivity == null) return; - // 涓�涓皬鏃朵箣鍓� - long time = java.lang.System.currentTimeMillis() - 1000 * 60 * 60 ; - Date lastTime = new Date(time); - + Date lastTime = new Date(java.lang.System.currentTimeMillis() - 1000 * 60 * 60); for (int i = 0; i < 1000; i ++) { - List<Long> list = userCloudMapper.listValidUid((i-1)*1000, 1000); - if (list == null || list.size() == 0) { + // 鏌ヨ鍝簺鐢ㄦ埛寮�閫� + List<Long> listUser = userCloudMapper.listValidUid(i*1000, 1000); + if (listUser == null || listUser.size() == 0) { break; } - for (Long uid: list) { - try { - UserCloudSendRecord record = userCloudSendRecordService.getByUidAndSendId(uid, id); - if (record != null) + // 閬嶅巻鐢ㄦ埛 + for (Long uid: listUser) { + try {// 鍒ゆ柇鏄惁寮�閫氬畼鏂归噰闆� + UserCloudManage cloudManage = userCloudManageService.selectByPrimaryKey(uid); + if (cloudManage == null || cloudManage.getOfficial() == null || !cloudManage.getOfficial()) { continue; - + } + // 鏄惁鍦ㄤ竴涓皬鏃跺唴宸插彂閫佽繃 UserCloudSendRecord last = userCloudSendRecordService.getLastByUid(uid, lastTime); if (last != null) continue; - boolean official = false; - UserCloudManage cloudManage = userCloudManageService.selectByPrimaryKey(uid); - if (cloudManage != null) { - if (cloudManage.getOfficial() != null) - official = cloudManage.getOfficial(); + 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 (!Constant.IS_TEST && official) { - UserCloudMQMsg msg = new UserCloudMQMsg(uid, id, UserCloudMQMsg.TYPE_EVALUATE); + // 鍗曞搧 + 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); producer.send(message); } @@ -1104,6 +1213,65 @@ } } } - } + + 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); + producer.send(message); + } + + // 鏇存柊宸叉彁閱� + 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); + } + } + } \ No newline at end of file -- Gitblit v1.8.0