|
|
|
@ -4,6 +4,7 @@ import cc.hiver.core.common.constant.SettingConstant; |
|
|
|
import cc.hiver.core.common.sms.SmsUtil; |
|
|
|
import cc.hiver.core.entity.User; |
|
|
|
import cc.hiver.core.service.UserService; |
|
|
|
import cc.hiver.mall.billing.mq.BillingRecordProducer; |
|
|
|
import cc.hiver.mall.fishmarket.dto.*; |
|
|
|
import cc.hiver.mall.fishmarket.entity.*; |
|
|
|
import cc.hiver.mall.fishmarket.mapper.*; |
|
|
|
@ -16,12 +17,14 @@ import cc.hiver.mall.ie.service.IeContentAuditLogService; |
|
|
|
import cc.hiver.mall.ie.service.IeSecurityAuditService; |
|
|
|
import cc.hiver.mall.ie.vo.IeAliyunModerationResult; |
|
|
|
import cc.hiver.mall.ie.vo.IeAuditResult; |
|
|
|
import cc.hiver.mall.utils.WechatSendMessageUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
@ -87,9 +90,14 @@ public class FishMarketServiceImpl implements FishMarketService { |
|
|
|
private UserService userService; |
|
|
|
@Autowired(required = false) |
|
|
|
private SmsUtil smsUtil; |
|
|
|
@Autowired(required = false) |
|
|
|
private BillingRecordProducer billingRecordProducer; |
|
|
|
@Autowired |
|
|
|
private SimpMessagingTemplate messagingTemplate; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WechatSendMessageUtil wechatSendMessageUtil; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private PlatformTransactionManager transactionManager; |
|
|
|
|
|
|
|
@ -103,6 +111,7 @@ public class FishMarketServiceImpl implements FishMarketService { |
|
|
|
private static final String FISH_COMMENT_UNREAD_KEY_PREFIX = "fishmarket:unread:comment:"; |
|
|
|
private static final String FISH_SMS_NOTIFIED_KEY_PREFIX = "fishmarket:sms:notified:"; |
|
|
|
private static final String FISH_SMS_DAILY_SESSION_KEY_PREFIX = "fishmarket:sms:daily:session:"; |
|
|
|
private static final String FISH_CHAT_WECHAT_TEMPLATE_ID = "X-lezVQyqm9EUsHCi6ja2cAnjdif5uyA21nhmg0RsuU"; |
|
|
|
|
|
|
|
@Override |
|
|
|
public IPage<FishGoods> pageGoods(FishPageQuery query) { |
|
|
|
@ -234,8 +243,8 @@ public class FishMarketServiceImpl implements FishMarketService { |
|
|
|
requireLogin(user); |
|
|
|
validatePublishUser(user); |
|
|
|
validatePublishDTO(dto, true); |
|
|
|
auditStrictText("fish_goods_title", dto.getId(), user.getId(), dto.getTitle()); |
|
|
|
auditStrictText("fish_goods_content", dto.getId(), user.getId(), publishContentText(dto)); |
|
|
|
auditStrictText("fish_goods_title", dto.getId(), user.getId(), dto.getTitle(), dto.getRegionId()); |
|
|
|
auditStrictText("fish_goods_content", dto.getId(), user.getId(), publishContentText(dto), dto.getRegionId()); |
|
|
|
|
|
|
|
FishGoods goods = StringUtils.isNotBlank(dto.getId()) ? goodsMapper.selectById(dto.getId()) : null; |
|
|
|
if (goods == null) { |
|
|
|
@ -288,8 +297,8 @@ public class FishMarketServiceImpl implements FishMarketService { |
|
|
|
requireLogin(user); |
|
|
|
validatePublishUser(user); |
|
|
|
validatePublishDTO(dto, false); |
|
|
|
auditStrictText("fish_want_title", dto.getId(), user.getId(), dto.getTitle()); |
|
|
|
auditStrictText("fish_want_content", dto.getId(), user.getId(), publishContentText(dto)); |
|
|
|
auditStrictText("fish_want_title", dto.getId(), user.getId(), dto.getTitle(), dto.getRegionId()); |
|
|
|
auditStrictText("fish_want_content", dto.getId(), user.getId(), publishContentText(dto), dto.getRegionId()); |
|
|
|
|
|
|
|
FishWant want = StringUtils.isNotBlank(dto.getId()) ? wantMapper.selectById(dto.getId()) : null; |
|
|
|
if (want == null) { |
|
|
|
@ -327,7 +336,7 @@ public class FishMarketServiceImpl implements FishMarketService { |
|
|
|
@Override |
|
|
|
public Map<String, Object> auditReleaseImage(String imageUrl, User user) { |
|
|
|
requireLogin(user); |
|
|
|
auditStrictImages("fish_release_image", user.getId(), Collections.singletonList(imageUrl)); |
|
|
|
auditStrictImages("fish_release_image", user.getId(), Collections.singletonList(imageUrl), user.getDepartmentId()); |
|
|
|
return resultMap("passed", true); |
|
|
|
} |
|
|
|
|
|
|
|
@ -464,7 +473,7 @@ public class FishMarketServiceImpl implements FishMarketService { |
|
|
|
throw new RuntimeException("评论内容不能为空"); |
|
|
|
} |
|
|
|
FishGoods goods = requireGoods(dto.getGoodsId()); |
|
|
|
auditStrictText("fish_comment", null, user.getId(), dto.getContent()); |
|
|
|
auditStrictText("fish_comment", null, user.getId(), dto.getContent(), goods.getRegionId()); |
|
|
|
FishComment parent = StringUtils.isNotBlank(dto.getParentId()) ? commentMapper.selectById(dto.getParentId()) : null; |
|
|
|
FishComment comment = new FishComment(); |
|
|
|
comment.setGoodsId(dto.getGoodsId()); |
|
|
|
@ -566,8 +575,10 @@ public class FishMarketServiceImpl implements FishMarketService { |
|
|
|
if (dto == null || StringUtils.isBlank(dto.getComplaintType()) || StringUtils.isBlank(dto.getReason())) { |
|
|
|
throw new RuntimeException("举报类型和原因不能为空"); |
|
|
|
} |
|
|
|
auditText("fish_complaint", null, user.getId(), dto.getReason()); |
|
|
|
auditImages("fish_complaint_image", user.getId(), dto.getImages()); |
|
|
|
String regionId = resolveFishRegionId(dto.getGoodsId(), null, dto.getRoomId(), user); |
|
|
|
auditText("fish_complaint", null, user.getId(), dto.getReason(), regionId); |
|
|
|
auditImages("fish_complaint_image", user.getId(), dto.getImages(), regionId); |
|
|
|
boolean commentComplaint = "comment".equals(dto.getComplaintType()) || StringUtils.isNotBlank(dto.getCommentId()); |
|
|
|
FishComplaint complaint = new FishComplaint(); |
|
|
|
complaint.setReporterId(user.getId()); |
|
|
|
complaint.setReporterName(defaultString(user.getNickname(), user.getUsername())); |
|
|
|
@ -579,10 +590,23 @@ public class FishMarketServiceImpl implements FishMarketService { |
|
|
|
complaint.setImages(JSON.toJSONString(limitList(dto.getImages(), 6))); |
|
|
|
complaint.setStatus(0); |
|
|
|
complaint.setCreateBy(user.getId()); |
|
|
|
if (StringUtils.isNotBlank(dto.getGoodsId())) { |
|
|
|
FishGoods goods = goodsMapper.selectById(dto.getGoodsId()); |
|
|
|
if (commentComplaint) { |
|
|
|
if (StringUtils.isBlank(dto.getCommentId())) { |
|
|
|
throw new RuntimeException("举报评论ID不能为空"); |
|
|
|
} |
|
|
|
FishComment comment = commentMapper.selectById(dto.getCommentId()); |
|
|
|
if (comment == null || Integer.valueOf(2).equals(comment.getStatus())) { |
|
|
|
throw new RuntimeException("举报评论不存在"); |
|
|
|
} |
|
|
|
complaint.setGoodsId(comment.getGoodsId()); |
|
|
|
complaint.setSellerId(comment.getUserId()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(complaint.getGoodsId())) { |
|
|
|
FishGoods goods = goodsMapper.selectById(complaint.getGoodsId()); |
|
|
|
if (goods != null) { |
|
|
|
complaint.setSellerId(goods.getUserId()); |
|
|
|
if (!commentComplaint) { |
|
|
|
complaint.setSellerId(goods.getUserId()); |
|
|
|
} |
|
|
|
goods.setComplaintCount(safeInt(goods.getComplaintCount()) + 1); |
|
|
|
goodsMapper.updateById(goods); |
|
|
|
} |
|
|
|
@ -680,11 +704,12 @@ public class FishMarketServiceImpl implements FishMarketService { |
|
|
|
throw new RuntimeException("消息内容不能为空"); |
|
|
|
} |
|
|
|
FishChatSession session = requireChatSession(dto.getSessionId(), user); |
|
|
|
String regionId = resolveSessionRegionId(session); |
|
|
|
Integer messageType = dto.getMessageType() == null ? 1 : dto.getMessageType(); |
|
|
|
if (messageType == 1) { |
|
|
|
auditText("fish_chat_message", null, user.getId(), dto.getContent()); |
|
|
|
auditText("fish_chat_message", null, user.getId(), dto.getContent(), regionId); |
|
|
|
} else if (messageType == 2) { |
|
|
|
auditImages("fish_chat_message_image", user.getId(), Collections.singletonList(dto.getContent())); |
|
|
|
auditImages("fish_chat_message_image", user.getId(), Collections.singletonList(dto.getContent()), regionId); |
|
|
|
} |
|
|
|
FishChatMessage message = new FishChatMessage(); |
|
|
|
message.setSessionId(session.getId()); |
|
|
|
@ -711,6 +736,7 @@ public class FishMarketServiceImpl implements FishMarketService { |
|
|
|
session.setUpdateBy(user.getId()); |
|
|
|
chatSessionMapper.updateById(session); |
|
|
|
incrementChatUnread(message.getReceiverId(), session.getId()); |
|
|
|
sendWechatChatNotifyAfterCommit(message, session, user); |
|
|
|
sendUnreadSmsReminderAfterCommit(message.getId()); |
|
|
|
deliverChatMessage(message); |
|
|
|
return message; |
|
|
|
@ -1012,22 +1038,51 @@ public class FishMarketServiceImpl implements FishMarketService { |
|
|
|
complaintMapper.updateById(complaint); |
|
|
|
boolean shouldBlockUser = Boolean.TRUE.equals(dto.getBlockUser()) || dto.getStatus() == null || Integer.valueOf(1).equals(dto.getStatus()); |
|
|
|
if (shouldBlockUser) { |
|
|
|
String sellerUserId = resolveComplaintSellerUserId(complaint); |
|
|
|
if (StringUtils.isBlank(sellerUserId)) { |
|
|
|
throw new RuntimeException("无法确认被举报商品卖家"); |
|
|
|
String targetUserId = resolveComplaintTargetUserId(complaint); |
|
|
|
if (StringUtils.isBlank(targetUserId)) { |
|
|
|
throw new RuntimeException("无法确认被举报用户"); |
|
|
|
} |
|
|
|
FishAdminActionDTO limitDTO = new FishAdminActionDTO(); |
|
|
|
limitDTO.setUserId(sellerUserId); |
|
|
|
limitDTO.setUserId(targetUserId); |
|
|
|
limitDTO.setPublishBanned(1); |
|
|
|
limitDTO.setMuted(1); |
|
|
|
limitDTO.setPermanentBanned(dto.getPermanentBanned() == null ? 1 : dto.getPermanentBanned()); |
|
|
|
limitDTO.setReason(dto.getReason()); |
|
|
|
saveUserLimit(limitDTO, admin); |
|
|
|
forceOffShelfComplaintGoods(complaint, dto, admin); |
|
|
|
if (isCommentComplaint(complaint)) { |
|
|
|
adminDeleteComment(complaint.getCommentId(), admin); |
|
|
|
} else { |
|
|
|
forceOffShelfComplaintGoods(complaint, dto, admin); |
|
|
|
} |
|
|
|
} |
|
|
|
logAdmin(admin, "complaint_handle", "complaint", complaint.getId(), dto.getHandleResult()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public void unblockComplaintUser(FishAdminActionDTO dto, User admin) { |
|
|
|
if (dto == null || StringUtils.isBlank(dto.getComplaintId())) { |
|
|
|
throw new RuntimeException("举报ID不能为空"); |
|
|
|
} |
|
|
|
FishComplaint complaint = complaintMapper.selectById(dto.getComplaintId()); |
|
|
|
if (complaint == null) { |
|
|
|
throw new RuntimeException("举报不存在"); |
|
|
|
} |
|
|
|
String targetUserId = resolveComplaintTargetUserId(complaint); |
|
|
|
if (StringUtils.isBlank(targetUserId)) { |
|
|
|
throw new RuntimeException("无法确认被举报用户"); |
|
|
|
} |
|
|
|
String reason = defaultString(dto.getReason(), "后台解除举报封禁"); |
|
|
|
FishAdminActionDTO limitDTO = new FishAdminActionDTO(); |
|
|
|
limitDTO.setUserId(targetUserId); |
|
|
|
limitDTO.setMuted(0); |
|
|
|
limitDTO.setPublishBanned(0); |
|
|
|
limitDTO.setPermanentBanned(0); |
|
|
|
limitDTO.setReason(reason); |
|
|
|
saveUserLimit(limitDTO, admin); |
|
|
|
logAdmin(admin, "complaint_unblock", "complaint", complaint.getId(), reason); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public FishUserLimit saveUserLimit(FishAdminActionDTO dto, User admin) { |
|
|
|
@ -1130,6 +1185,8 @@ public class FishMarketServiceImpl implements FishMarketService { |
|
|
|
} |
|
|
|
try { |
|
|
|
smsUtil.sendCode(receiver.getMobile(), null, SMS_PRODUCTTALK_TEMPLATE); |
|
|
|
recordSmsBilling(resolveSessionRegionId(session), SMS_PRODUCTTALK_TEMPLATE, |
|
|
|
receiver.getMobile(), "fish_chat_message", message.getId()); |
|
|
|
markSmsReminderSent(receiverId, session.getId(), message.getId(), today); |
|
|
|
int count = today.equals(session.getLastSmsNoticeDate()) ? safeInt(session.getSmsNoticeCount()) : 0; |
|
|
|
session.setSmsNoticeCount(count + 1); |
|
|
|
@ -1164,6 +1221,59 @@ public class FishMarketServiceImpl implements FishMarketService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private String resolveSessionRegionId(FishChatSession session) { |
|
|
|
try { |
|
|
|
if (session == null) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(session.getGoodsId())) { |
|
|
|
FishGoods goods = goodsMapper.selectById(session.getGoodsId()); |
|
|
|
return goods == null ? null : goods.getRegionId(); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(session.getWantId())) { |
|
|
|
FishWant want = wantMapper.selectById(session.getWantId()); |
|
|
|
return want == null ? null : want.getRegionId(); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
log.warn("校园二手会话校区查询失败,不影响计费记录 sessionId={}", session == null ? null : session.getId(), e); |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
private String resolveFishRegionId(String goodsId, String wantId, String sessionId, User user) { |
|
|
|
try { |
|
|
|
if (StringUtils.isNotBlank(goodsId)) { |
|
|
|
FishGoods goods = goodsMapper.selectById(goodsId); |
|
|
|
if (goods != null && StringUtils.isNotBlank(goods.getRegionId())) { |
|
|
|
return goods.getRegionId(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(wantId)) { |
|
|
|
FishWant want = wantMapper.selectById(wantId); |
|
|
|
if (want != null && StringUtils.isNotBlank(want.getRegionId())) { |
|
|
|
return want.getRegionId(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(sessionId)) { |
|
|
|
FishChatSession session = chatSessionMapper.selectById(sessionId); |
|
|
|
String regionId = resolveSessionRegionId(session); |
|
|
|
if (StringUtils.isNotBlank(regionId)) { |
|
|
|
return regionId; |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
log.warn("校园二手业务校区查询失败,不影响计费记录 goodsId={}, wantId={}, sessionId={}", |
|
|
|
goodsId, wantId, sessionId, e); |
|
|
|
} |
|
|
|
return user == null ? null : user.getDepartmentId(); |
|
|
|
} |
|
|
|
|
|
|
|
private void recordSmsBilling(String regionId, String smsType, String mobile, String bizType, String bizId) { |
|
|
|
if (billingRecordProducer != null) { |
|
|
|
billingRecordProducer.recordSms(regionId, smsType, mobile, bizType, bizId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void fillSessionListFields(List<FishChatSession> sessions, String userId) { |
|
|
|
if (sessions == null || sessions.isEmpty()) return; |
|
|
|
Set<String> goodsIds = sessions.stream() |
|
|
|
@ -1464,6 +1574,95 @@ public class FishMarketServiceImpl implements FishMarketService { |
|
|
|
smsReminderProducer.sendUnreadReminder(messageId); |
|
|
|
} |
|
|
|
|
|
|
|
private void sendWechatChatNotifyAfterCommit(FishChatMessage message, FishChatSession session, User sender) { |
|
|
|
if (message == null || session == null || sender == null || StringUtils.isBlank(message.getReceiverId())) return; |
|
|
|
if (TransactionSynchronizationManager.isSynchronizationActive()) { |
|
|
|
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { |
|
|
|
@Override |
|
|
|
public void afterCommit() { |
|
|
|
sendWechatChatNotify(message, session, sender); |
|
|
|
} |
|
|
|
}); |
|
|
|
return; |
|
|
|
} |
|
|
|
sendWechatChatNotify(message, session, sender); |
|
|
|
} |
|
|
|
|
|
|
|
private void sendWechatChatNotify(FishChatMessage message, FishChatSession session, User sender) { |
|
|
|
try { |
|
|
|
User receiver = userService.findById(message.getReceiverId()); |
|
|
|
if (receiver == null || StringUtils.isBlank(receiver.getOfficialAccountOpenid())) { |
|
|
|
return; |
|
|
|
} |
|
|
|
String itemCode = resolveChatItemCode(session); |
|
|
|
String itemTitle = resolveChatItemTitle(session); |
|
|
|
List<WxMpTemplateData> data = new ArrayList<>(); |
|
|
|
Date createTime = message.getCreateTime() == null ? new Date() : message.getCreateTime(); |
|
|
|
data.add(new WxMpTemplateData("time5", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTime))); |
|
|
|
data.add(new WxMpTemplateData("thing10", buildContactTemplateValue("半径咨询", itemTitle))); |
|
|
|
data.add(new WxMpTemplateData("character_string6", limitCharacterStringValue(itemCode))); |
|
|
|
wechatSendMessageUtil.sendWechatTempMessage( |
|
|
|
Collections.singletonList(receiver.getOfficialAccountOpenid()), |
|
|
|
FISH_CHAT_WECHAT_TEMPLATE_ID, |
|
|
|
data, |
|
|
|
"pages/index/index" |
|
|
|
); |
|
|
|
log.info("校园二手咨询公众号通知已发送,messageId={}, receiverId={}", message.getId(), message.getReceiverId()); |
|
|
|
} catch (Exception e) { |
|
|
|
log.warn("校园二手咨询公众号通知发送失败,messageId={}, receiverId={}, reason={}", |
|
|
|
message.getId(), message.getReceiverId(), e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private String resolveChatItemCode(FishChatSession session) { |
|
|
|
if (session == null) { |
|
|
|
return "fishmarket"; |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(session.getGoodsId())) { |
|
|
|
return session.getGoodsId(); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(session.getWantId())) { |
|
|
|
return session.getWantId(); |
|
|
|
} |
|
|
|
return defaultString(session.getSessionId(), session.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
private String resolveChatItemTitle(FishChatSession session) { |
|
|
|
if (session == null) { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(session.getGoodsId())) { |
|
|
|
FishGoods goods = goodsMapper.selectById(session.getGoodsId()); |
|
|
|
return goods == null ? "" : StringUtils.defaultString(goods.getTitle()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(session.getWantId())) { |
|
|
|
FishWant want = wantMapper.selectById(session.getWantId()); |
|
|
|
return want == null ? "" : StringUtils.defaultString(want.getTitle()); |
|
|
|
} |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
private String buildContactTemplateValue(String contactName, String itemTitle) { |
|
|
|
String value = StringUtils.defaultString(contactName); |
|
|
|
if (StringUtils.isNotBlank(itemTitle)) { |
|
|
|
value = value + "-" + itemTitle; |
|
|
|
} |
|
|
|
return limitTemplateValue(value, 20); |
|
|
|
} |
|
|
|
|
|
|
|
private String limitTemplateValue(String value, int maxLength) { |
|
|
|
String text = StringUtils.defaultString(value); |
|
|
|
return text.length() > maxLength ? text.substring(0, maxLength) : text; |
|
|
|
} |
|
|
|
|
|
|
|
private String limitCharacterStringValue(String value) { |
|
|
|
String text = StringUtils.defaultString(value).replaceAll("[^A-Za-z0-9_-]", ""); |
|
|
|
if (StringUtils.isBlank(text)) { |
|
|
|
text = "fishmarket"; |
|
|
|
} |
|
|
|
return text.length() > 32 ? text.substring(text.length() - 32) : text; |
|
|
|
} |
|
|
|
|
|
|
|
private boolean isSmsReminderMessageEligible(FishChatMessage message) { |
|
|
|
return message != null |
|
|
|
&& StringUtils.isNotBlank(message.getId()) |
|
|
|
@ -1550,15 +1749,15 @@ public class FishMarketServiceImpl implements FishMarketService { |
|
|
|
return contentText.replaceAll("\\s+", "").trim(); |
|
|
|
} |
|
|
|
|
|
|
|
private void auditText(String bizType, String bizId, String userId, String content) { |
|
|
|
private void auditText(String bizType, String bizId, String userId, String content, String regionId) { |
|
|
|
if (StringUtils.isBlank(content)) return; |
|
|
|
IeAuditResult result = securityAuditService.audit(bizType, parseLong(bizId), parseLong(userId), content); |
|
|
|
IeAuditResult result = securityAuditService.audit(bizType, parseLong(bizId), parseLong(userId), content, regionId); |
|
|
|
if (result != null && Boolean.TRUE.equals(result.getBlocked())) { |
|
|
|
recordFishAuditBlock(bizType, bizId, userId, content, result); |
|
|
|
throw new RuntimeException(FISH_TEXT_AUDIT_REJECT_MESSAGE); |
|
|
|
} |
|
|
|
if (aliyunModerationService != null) { |
|
|
|
IeAliyunModerationResult aliyun = aliyunModerationService.checkText(content); |
|
|
|
IeAliyunModerationResult aliyun = aliyunModerationService.checkText(content, regionId, bizType, bizId, parseLong(userId)); |
|
|
|
if (aliyun != null && aliyun.isBlock()) { |
|
|
|
recordFishAliyunBlock(bizType, bizId, userId, content, aliyun); |
|
|
|
throw new RuntimeException(FISH_TEXT_AUDIT_REJECT_MESSAGE); |
|
|
|
@ -1566,15 +1765,15 @@ public class FishMarketServiceImpl implements FishMarketService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void auditStrictText(String bizType, String bizId, String userId, String content) { |
|
|
|
private void auditStrictText(String bizType, String bizId, String userId, String content, String regionId) { |
|
|
|
if (StringUtils.isBlank(content)) return; |
|
|
|
IeAuditResult result = securityAuditService.audit(bizType, parseLong(bizId), parseLong(userId), content); |
|
|
|
IeAuditResult result = securityAuditService.audit(bizType, parseLong(bizId), parseLong(userId), content, regionId); |
|
|
|
if (result != null && (Boolean.TRUE.equals(result.getBlocked()) || isMediumOrHigh(result.getRiskLevel()))) { |
|
|
|
recordFishAuditBlock(bizType, bizId, userId, content, result); |
|
|
|
throw new RuntimeException(FISH_TEXT_AUDIT_REJECT_MESSAGE); |
|
|
|
} |
|
|
|
if (aliyunModerationService != null) { |
|
|
|
IeAliyunModerationResult aliyun = aliyunModerationService.checkText(content); |
|
|
|
IeAliyunModerationResult aliyun = aliyunModerationService.checkText(content, regionId, bizType, bizId, parseLong(userId)); |
|
|
|
if (aliyun != null && (aliyun.isBlock() || isMediumOrHigh(aliyun.getRiskLevel()))) { |
|
|
|
recordFishAliyunBlock(bizType, bizId, userId, content, aliyun); |
|
|
|
throw new RuntimeException(FISH_TEXT_AUDIT_REJECT_MESSAGE); |
|
|
|
@ -1582,11 +1781,11 @@ public class FishMarketServiceImpl implements FishMarketService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void auditImages(String bizType, String userId, List<String> images) { |
|
|
|
private void auditImages(String bizType, String userId, List<String> images, String regionId) { |
|
|
|
if (images == null || images.isEmpty() || aliyunModerationService == null) return; |
|
|
|
for (String image : images) { |
|
|
|
if (StringUtils.isBlank(image)) continue; |
|
|
|
IeAliyunModerationResult result = aliyunModerationService.checkImage(image); |
|
|
|
IeAliyunModerationResult result = aliyunModerationService.checkImage(image, regionId, bizType, null, parseLong(userId)); |
|
|
|
if (result != null && result.isBlock()) { |
|
|
|
recordFishAliyunBlock(bizType, null, userId, image, result); |
|
|
|
throw new RuntimeException(FISH_IMAGE_AUDIT_REJECT_MESSAGE); |
|
|
|
@ -1594,11 +1793,11 @@ public class FishMarketServiceImpl implements FishMarketService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void auditStrictImages(String bizType, String userId, List<String> images) { |
|
|
|
private void auditStrictImages(String bizType, String userId, List<String> images, String regionId) { |
|
|
|
if (images == null || images.isEmpty() || aliyunModerationService == null) return; |
|
|
|
for (String image : images) { |
|
|
|
if (StringUtils.isBlank(image)) continue; |
|
|
|
IeAliyunModerationResult result = aliyunModerationService.checkImage(image); |
|
|
|
IeAliyunModerationResult result = aliyunModerationService.checkImage(image, regionId, bizType, null, parseLong(userId)); |
|
|
|
if (result != null && (result.isBlock() || isMediumOrHigh(result.getRiskLevel()))) { |
|
|
|
recordFishAliyunBlock(bizType, null, userId, image, result); |
|
|
|
throw new RuntimeException(FISH_IMAGE_AUDIT_REJECT_MESSAGE); |
|
|
|
@ -1783,6 +1982,23 @@ public class FishMarketServiceImpl implements FishMarketService { |
|
|
|
return resolveUserId(complaint.getSellerId()); |
|
|
|
} |
|
|
|
|
|
|
|
private String resolveComplaintTargetUserId(FishComplaint complaint) { |
|
|
|
if (complaint == null) return ""; |
|
|
|
if (isCommentComplaint(complaint)) { |
|
|
|
FishComment comment = StringUtils.isBlank(complaint.getCommentId()) ? null : commentMapper.selectById(complaint.getCommentId()); |
|
|
|
if (comment != null && StringUtils.isNotBlank(comment.getUserId())) { |
|
|
|
complaint.setSellerId(comment.getUserId()); |
|
|
|
return comment.getUserId(); |
|
|
|
} |
|
|
|
return resolveUserId(complaint.getSellerId()); |
|
|
|
} |
|
|
|
return resolveComplaintSellerUserId(complaint); |
|
|
|
} |
|
|
|
|
|
|
|
private boolean isCommentComplaint(FishComplaint complaint) { |
|
|
|
return complaint != null && ("comment".equals(complaint.getComplaintType()) || StringUtils.isNotBlank(complaint.getCommentId())); |
|
|
|
} |
|
|
|
|
|
|
|
private String resolveUserId(String value) { |
|
|
|
if (StringUtils.isBlank(value)) return ""; |
|
|
|
if (userService == null) return value; |
|
|
|
@ -1794,11 +2010,21 @@ public class FishMarketServiceImpl implements FishMarketService { |
|
|
|
|
|
|
|
private void fillComplaintDisplayInfo(List<FishComplaint> complaints) { |
|
|
|
if (complaints == null || complaints.isEmpty()) return; |
|
|
|
List<String> goodsIds = complaints.stream() |
|
|
|
Set<String> commentIds = complaints.stream() |
|
|
|
.map(FishComplaint::getCommentId) |
|
|
|
.filter(StringUtils::isNotBlank) |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
Map<String, FishComment> commentMap = commentIds.isEmpty() ? Collections.emptyMap() : commentMapper.selectBatchIds(commentIds).stream() |
|
|
|
.collect(Collectors.toMap(FishComment::getId, comment -> comment, (a, b) -> a)); |
|
|
|
|
|
|
|
Set<String> goodsIds = complaints.stream() |
|
|
|
.map(FishComplaint::getGoodsId) |
|
|
|
.filter(StringUtils::isNotBlank) |
|
|
|
.distinct() |
|
|
|
.collect(Collectors.toList()); |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
goodsIds.addAll(commentMap.values().stream() |
|
|
|
.map(FishComment::getGoodsId) |
|
|
|
.filter(StringUtils::isNotBlank) |
|
|
|
.collect(Collectors.toSet())); |
|
|
|
Map<String, FishGoods> goodsMap = goodsIds.isEmpty() ? Collections.emptyMap() : goodsMapper.selectBatchIds(goodsIds).stream() |
|
|
|
.collect(Collectors.toMap(FishGoods::getId, goods -> goods, (a, b) -> a)); |
|
|
|
|
|
|
|
@ -1806,6 +2032,10 @@ public class FishMarketServiceImpl implements FishMarketService { |
|
|
|
.map(FishComplaint::getSellerId) |
|
|
|
.filter(StringUtils::isNotBlank) |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
sellerIds.addAll(commentMap.values().stream() |
|
|
|
.map(FishComment::getUserId) |
|
|
|
.filter(StringUtils::isNotBlank) |
|
|
|
.collect(Collectors.toSet())); |
|
|
|
sellerIds.addAll(goodsMap.values().stream() |
|
|
|
.map(FishGoods::getUserId) |
|
|
|
.filter(StringUtils::isNotBlank) |
|
|
|
@ -1816,12 +2046,20 @@ public class FishMarketServiceImpl implements FishMarketService { |
|
|
|
.collect(Collectors.toMap(User::getId, user -> user, (a, b) -> a)); |
|
|
|
|
|
|
|
for (FishComplaint complaint : complaints) { |
|
|
|
FishComment comment = commentMap.get(complaint.getCommentId()); |
|
|
|
if (comment != null) { |
|
|
|
complaint.setCommentContent(comment.getContent()); |
|
|
|
complaint.setGoodsId(StringUtils.defaultIfBlank(complaint.getGoodsId(), comment.getGoodsId())); |
|
|
|
if (isCommentComplaint(complaint)) { |
|
|
|
complaint.setSellerId(comment.getUserId()); |
|
|
|
} |
|
|
|
} |
|
|
|
FishGoods goods = goodsMap.get(complaint.getGoodsId()); |
|
|
|
if (goods != null) { |
|
|
|
complaint.setDisplayTitle(goods.getTitle()); |
|
|
|
complaint.setDisplayCover(goods.getCoverImage()); |
|
|
|
complaint.setDisplayPrice(goods.getPrice() == null ? null : goods.getPrice().toPlainString()); |
|
|
|
if (StringUtils.isBlank(complaint.getSellerId())) { |
|
|
|
if (StringUtils.isBlank(complaint.getSellerId()) && !isCommentComplaint(complaint)) { |
|
|
|
complaint.setSellerId(goods.getUserId()); |
|
|
|
} |
|
|
|
} |
|
|
|
|