|
@@ -1,6 +1,10 @@
|
|
|
package shop.alien.second.service.impl;
|
|
package shop.alien.second.service.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
@@ -8,22 +12,26 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import shop.alien.entity.second.SecondGoods;
|
|
import shop.alien.entity.second.SecondGoods;
|
|
|
import shop.alien.entity.second.SecondGoodsRecord;
|
|
import shop.alien.entity.second.SecondGoodsRecord;
|
|
|
|
|
+import shop.alien.entity.second.vo.SecondGoodsVo;
|
|
|
import shop.alien.entity.second.vo.SecondReportingVo;
|
|
import shop.alien.entity.second.vo.SecondReportingVo;
|
|
|
|
|
+import shop.alien.entity.second.vo.SecondUserViolationVo;
|
|
|
import shop.alien.entity.store.*;
|
|
import shop.alien.entity.store.*;
|
|
|
-import shop.alien.mapper.LifeNoticeMapper;
|
|
|
|
|
-import shop.alien.mapper.LifeUserMapper;
|
|
|
|
|
-import shop.alien.mapper.LifeUserViolationMapper;
|
|
|
|
|
-import shop.alien.mapper.StoreDictionaryMapper;
|
|
|
|
|
-import shop.alien.mapper.second.SecondGoodsMapper;
|
|
|
|
|
|
|
+import shop.alien.entity.store.vo.WebSocketVo;
|
|
|
|
|
+import shop.alien.mapper.*;
|
|
|
import shop.alien.mapper.second.SecondGoodsRecordMapper;
|
|
import shop.alien.mapper.second.SecondGoodsRecordMapper;
|
|
|
|
|
+import shop.alien.second.feign.AlienStoreFeign;
|
|
|
import shop.alien.second.service.SecondGoodsReportingService;
|
|
import shop.alien.second.service.SecondGoodsReportingService;
|
|
|
import shop.alien.second.util.JsonUtils;
|
|
import shop.alien.second.util.JsonUtils;
|
|
|
|
|
+import shop.alien.util.common.Constants;
|
|
|
|
|
+import shop.alien.util.common.EnumUtil;
|
|
|
|
|
+import shop.alien.util.common.JwtUtil;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 二手商品服务实现类
|
|
* 二手商品服务实现类
|
|
@@ -50,6 +58,11 @@ public class SecondGoodsReportingServiceImpl implements SecondGoodsReportingServ
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private final SecondGoodsRecordMapper secondGoodsRecordMapper;
|
|
private final SecondGoodsRecordMapper secondGoodsRecordMapper;
|
|
|
|
|
|
|
|
|
|
+ private final AlienStoreFeign alienStoreFeign;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private final StoreImgMapper storeImgMapper;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public SecondReportingVo queryReportingDetail (Integer id) {
|
|
public SecondReportingVo queryReportingDetail (Integer id) {
|
|
|
SecondReportingVo secondReportingVo = new SecondReportingVo();
|
|
SecondReportingVo secondReportingVo = new SecondReportingVo();
|
|
@@ -110,31 +123,50 @@ public class SecondGoodsReportingServiceImpl implements SecondGoodsReportingServ
|
|
|
// 存放已存在文件list
|
|
// 存放已存在文件list
|
|
|
List<String> videoList = new ArrayList<>();
|
|
List<String> videoList = new ArrayList<>();
|
|
|
|
|
|
|
|
- for (int i = 0; i < urlList.size(); i++) {
|
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
|
|
|
+ if (lifeUserViolation.getReportContextType().equals("1") || lifeUserViolation.getReportContextType().equals("2") || lifeUserViolation.getReportContextType().equals("3")) {
|
|
|
|
|
+ for (int i = 0; i < urlList.size(); i++) {
|
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ // 查找最后一个点的位置
|
|
|
|
|
+ int lastDotIndex = urlList.get(i).lastIndexOf('.');
|
|
|
|
|
|
|
|
- // 查找最后一个点的位置
|
|
|
|
|
- int lastDotIndex = urlList.get(i).lastIndexOf('.');
|
|
|
|
|
|
|
+ String fileType = urlList.get(i).substring(urlList.get(i).lastIndexOf(".") + 1);
|
|
|
|
|
+ String contains = null;
|
|
|
|
|
+ if (lastDotIndex != -1) { // 确保存在
|
|
|
|
|
+ contains = urlList.get(i).substring(0, lastDotIndex);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!videoList.contains(contains)) {
|
|
|
|
|
+ videoList.add(contains);
|
|
|
|
|
+ if (videoFileType.contains(fileType.toLowerCase())) {
|
|
|
|
|
+ map.put("type", "video");
|
|
|
|
|
+ map.put("imgUrl", urlList.get(i + 1));
|
|
|
|
|
+ map.put("videoUrl", urlList.get(i));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ map.put("type", "image");
|
|
|
|
|
+ map.put("imgUrl", urlList.get(i));
|
|
|
|
|
+ }
|
|
|
|
|
+ list.add(map);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- String fileType = urlList.get(i).substring(urlList.get(i).lastIndexOf(".") + 1);;
|
|
|
|
|
- String contains = null;
|
|
|
|
|
- if (lastDotIndex != -1) { // 确保存在
|
|
|
|
|
- contains = urlList.get(i).substring(0, lastDotIndex);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ } else {
|
|
|
|
|
+ LambdaQueryWrapper<StoreImg> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapper.eq(StoreImg::getStoreId, lifeUserViolation.getId());
|
|
|
|
|
+ wrapper.eq(StoreImg::getImgType, Constants.ImageType.SECOND_HAND_REPORT);
|
|
|
|
|
+ List<StoreImg> imgList = storeImgMapper.selectList(wrapper);
|
|
|
|
|
+ for (int i = 0; i < imgList.size(); i++) {
|
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ String fileType = urlList.get(i).substring(imgList.get(i).getImgUrl().lastIndexOf(".") + 1);
|
|
|
|
|
|
|
|
- if (!videoList.contains(contains)){
|
|
|
|
|
- videoList.add(contains);
|
|
|
|
|
if (videoFileType.contains(fileType.toLowerCase())) {
|
|
if (videoFileType.contains(fileType.toLowerCase())) {
|
|
|
map.put("type", "video");
|
|
map.put("type", "video");
|
|
|
- map.put("imgUrl", urlList.get(i + 1));
|
|
|
|
|
- map.put("videoUrl", urlList.get(i));
|
|
|
|
|
} else {
|
|
} else {
|
|
|
map.put("type", "image");
|
|
map.put("type", "image");
|
|
|
- map.put("imgUrl", urlList.get(i));
|
|
|
|
|
}
|
|
}
|
|
|
- list.add(map);
|
|
|
|
|
|
|
+ map.put("imgUrl", imgList.get(i).getImgUrl());
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
secondReportingVo.setImgList(list);
|
|
secondReportingVo.setImgList(list);
|
|
@@ -143,4 +175,93 @@ public class SecondGoodsReportingServiceImpl implements SecondGoodsReportingServ
|
|
|
return secondReportingVo;
|
|
return secondReportingVo;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int reporting(SecondUserViolationVo lifeuserViolation) throws Exception {
|
|
|
|
|
+ try {
|
|
|
|
|
+ if ("4".equals(lifeuserViolation.getReportContextType())) {
|
|
|
|
|
+ LambdaQueryWrapper<SecondGoodsRecord> goodsWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ goodsWrapper.eq(SecondGoodsRecord::getGoodsId, lifeuserViolation.getBusinessId());
|
|
|
|
|
+ goodsWrapper.eq(SecondGoodsRecord::getGoodsStatus, "3");
|
|
|
|
|
+ goodsWrapper.orderByDesc(SecondGoodsRecord::getCreatedTime);
|
|
|
|
|
+ goodsWrapper.last(" limit 1 ");
|
|
|
|
|
+ SecondGoodsRecord goodsRecord = secondGoodsRecordMapper.selectOne(goodsWrapper);
|
|
|
|
|
+ if (null != goodsRecord) lifeuserViolation.setBusinessId(goodsRecord.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ int result = lifeUserViolationMapper.insert(lifeuserViolation);
|
|
|
|
|
+ if (result > 0) {
|
|
|
|
|
+ if (lifeuserViolation.getReportContextType().equals("4") || lifeuserViolation.getReportContextType().equals("5")) {
|
|
|
|
|
+ String phoneId = Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getString("userType") + "_" + JwtUtil.getCurrentUserInfo().getString("phone");
|
|
|
|
|
+ // 举报通知
|
|
|
|
|
+ LifeNotice lifeNotice = getLifeNotice(lifeuserViolation);
|
|
|
|
|
+ lifeNoticeMapper.insert(lifeNotice);
|
|
|
|
|
+
|
|
|
|
|
+ // 保存图片
|
|
|
|
|
+ saveStoreImages(lifeuserViolation.getId(), lifeuserViolation);
|
|
|
|
|
+
|
|
|
|
|
+ WebSocketVo websocketVo = new WebSocketVo();
|
|
|
|
|
+ websocketVo.setSenderId("system");
|
|
|
|
|
+ websocketVo.setReceiverId(phoneId);
|
|
|
|
|
+ websocketVo.setCategory("notice");
|
|
|
|
|
+ websocketVo.setNoticeType("1");
|
|
|
|
|
+ websocketVo.setIsRead(0);
|
|
|
|
|
+ websocketVo.setText(com.alibaba.fastjson2.JSONObject.from(lifeNotice).toJSONString());
|
|
|
|
|
+ alienStoreFeign.sendMsgToClientByPhoneId(lifeNotice.getReceiverId(), com.alibaba.fastjson2.JSONObject.from(websocketVo).toJSONString());
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("SecondGoodsReportingServiceImpl_reporting Error Stack={}", e.getMessage());
|
|
|
|
|
+ throw new Exception(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static LifeNotice getLifeNotice(LifeUserViolation lifeuserViolation) {
|
|
|
|
|
+ JSONObject data = JwtUtil.getCurrentUserInfo();
|
|
|
|
|
+ String phoneId = null;
|
|
|
|
|
+ if (data != null) {
|
|
|
|
|
+ phoneId = data.getString("phone");
|
|
|
|
|
+ }
|
|
|
|
|
+ LifeNotice lifeNotice = new LifeNotice();
|
|
|
|
|
+ lifeNotice.setSenderId("system");
|
|
|
|
|
+ lifeNotice.setReceiverId("user_" + phoneId);
|
|
|
|
|
+ lifeNotice.setBusinessId(lifeuserViolation.getId());
|
|
|
|
|
+ lifeNotice.setTitle("举报通知");
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ jsonObject.put("title", "平台已受理");
|
|
|
|
|
+ jsonObject.put("message", "平台已受理,感谢您的反馈!");
|
|
|
|
|
+ lifeNotice.setContext(jsonObject.toJSONString());
|
|
|
|
|
+ lifeNotice.setNoticeType(1);
|
|
|
|
|
+ return lifeNotice;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 保存商品图片信息
|
|
|
|
|
+ * @param id 举报ID
|
|
|
|
|
+ * @param goods .getimgUrl 图片URL列表
|
|
|
|
|
+ * @return 保存结果
|
|
|
|
|
+ */
|
|
|
|
|
+ private boolean saveStoreImages(Integer id, SecondUserViolationVo goods ) {
|
|
|
|
|
+ if (CollectionUtil.isEmpty(goods.getImgUrl())) {
|
|
|
|
|
+ return true; // 如果没有图片,则返回成功
|
|
|
|
|
+ }
|
|
|
|
|
+ // 批量保存图片信息
|
|
|
|
|
+ for(int i = 0; i < goods.getImgUrl().size(); i++){
|
|
|
|
|
+ StoreImg storeImg = new StoreImg();
|
|
|
|
|
+ storeImg.setStoreId(id);
|
|
|
|
|
+ storeImg.setImgType(Constants.ImageType.SECOND_HAND_REPORT);
|
|
|
|
|
+ storeImg.setImgSort(i);
|
|
|
|
|
+ storeImg.setImgDescription("二手举报图片");
|
|
|
|
|
+ storeImg.setDeleteFlag(Constants.DeleteFlag.NOT_DELETED);
|
|
|
|
|
+ storeImg.setCreatedTime(new Date());
|
|
|
|
|
+ storeImg.setUpdatedTime(new Date());
|
|
|
|
|
+ storeImg.setCreatedUserId(1);
|
|
|
|
|
+ storeImg.setUpdatedUserId(1);
|
|
|
|
|
+ storeImg.setImgUrl(goods.getImgUrl().get(i));
|
|
|
|
|
+ // 保存图片 插入store_img数据库
|
|
|
|
|
+ storeImgMapper.insert(storeImg);
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|