|
|
@@ -2,10 +2,14 @@ package shop.alien.store.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
@@ -13,11 +17,10 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
import org.springframework.web.multipart.MultipartRequest;
|
|
|
-import shop.alien.entity.store.StoreCommentAppeal;
|
|
|
-import shop.alien.entity.store.StoreCommentAppealLog;
|
|
|
-import shop.alien.entity.store.StoreDictionary;
|
|
|
-import shop.alien.entity.store.StoreImg;
|
|
|
+import shop.alien.entity.store.*;
|
|
|
import shop.alien.entity.store.excelVo.util.ExcelExporter;
|
|
|
+import shop.alien.entity.store.vo.StoreCommentAppealLogVo;
|
|
|
+import shop.alien.entity.store.vo.StoreCommentAppealInfoVo;
|
|
|
import shop.alien.entity.store.vo.StoreCommentAppealVo;
|
|
|
import shop.alien.mapper.*;
|
|
|
import shop.alien.store.service.StoreCommentAppealService;
|
|
|
@@ -87,6 +90,20 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
|
|
|
return storeCommentAppealPage;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Integer> getAppealHistoryCountStatus(Integer storeId) {
|
|
|
+ Map<String, Integer> map = new HashMap<>();
|
|
|
+ //全部
|
|
|
+ map.put("-1", storeCommentAppealMapper.selectCount(new LambdaQueryWrapper<StoreCommentAppeal>().eq(StoreCommentAppeal::getStoreId, storeId).eq(StoreCommentAppeal::getDeleteFlag, 0)));
|
|
|
+ //审核中
|
|
|
+ map.put("0", storeCommentAppealMapper.selectCount(new LambdaQueryWrapper<StoreCommentAppeal>().eq(StoreCommentAppeal::getStoreId, storeId).eq(StoreCommentAppeal::getDeleteFlag, 0).eq(StoreCommentAppeal::getAppealStatus, 0)));
|
|
|
+ //驳回
|
|
|
+ map.put("1", storeCommentAppealMapper.selectCount(new LambdaQueryWrapper<StoreCommentAppeal>().eq(StoreCommentAppeal::getStoreId, storeId).eq(StoreCommentAppeal::getDeleteFlag, 0).eq(StoreCommentAppeal::getAppealStatus, 1)));
|
|
|
+ // 通过
|
|
|
+ map.put("2", storeCommentAppealMapper.selectCount(new LambdaQueryWrapper<StoreCommentAppeal>().eq(StoreCommentAppeal::getStoreId, storeId).eq(StoreCommentAppeal::getDeleteFlag, 0).eq(StoreCommentAppeal::getAppealStatus, 2)));
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 新增申诉
|
|
|
*
|
|
|
@@ -160,6 +177,91 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 新增申诉
|
|
|
+ *
|
|
|
+ * @param multipartRequest 文件
|
|
|
+ * @param storeId 门店id
|
|
|
+ * @param commentId 评论id
|
|
|
+ * @param appealReason 申诉原因
|
|
|
+ * @return Integer(0 : 申诉成功, 1 : 申诉失败, 2 : 申诉已存在, 3 : 文本内容异常)
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public StoreCommentAppealInfoVo addAppealNew(MultipartRequest multipartRequest, Integer storeId, Integer commentId, String appealReason) {
|
|
|
+ StoreCommentAppealInfoVo storeCommentAppealInfoVo = new StoreCommentAppealInfoVo();
|
|
|
+ try {
|
|
|
+ Map<String, String> checkText = TextCheckUtil.check(appealReason);
|
|
|
+ // todo 暂时去掉校验,防止校验不通过
|
|
|
+// if (null == checkText || checkText.get("result").equals("1")) {
|
|
|
+// storeCommentAppealInfoVo.setResult(3);
|
|
|
+// return storeCommentAppealInfoVo;
|
|
|
+// }
|
|
|
+ List<String> fileNameSet = new ArrayList<>(multipartRequest.getMultiFileMap().keySet());
|
|
|
+ LambdaQueryWrapper<StoreCommentAppeal> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ //待审批, 已通过
|
|
|
+ List<Integer> list = new ArrayList<>();
|
|
|
+ list.add(0);
|
|
|
+ list.add(2);
|
|
|
+ wrapper.eq(StoreCommentAppeal::getStoreId, storeId)
|
|
|
+ .eq(StoreCommentAppeal::getCommentId, commentId)
|
|
|
+ .in(StoreCommentAppeal::getAppealStatus, list)
|
|
|
+ .orderByDesc(StoreCommentAppeal::getCreatedTime)
|
|
|
+ .last("limit 1");
|
|
|
+ if (this.getOne(wrapper) != null) {
|
|
|
+ storeCommentAppealInfoVo.setResult(2);
|
|
|
+ return storeCommentAppealInfoVo;
|
|
|
+ }
|
|
|
+ /*if (this.getOne(wrapper) != null) {
|
|
|
+ return 2;
|
|
|
+ }*/
|
|
|
+ StoreCommentAppeal storeCommentAppeal = new StoreCommentAppeal();
|
|
|
+ StringBuilder imgId = new StringBuilder();
|
|
|
+ for (int i = 0; i < fileNameSet.size(); i++) {
|
|
|
+ MultipartFile multipartFile = multipartRequest.getFileMap().get(fileNameSet.get(i));
|
|
|
+ if (null != multipartFile) {
|
|
|
+ StoreImg storeImg = new StoreImg();
|
|
|
+ storeImg.setStoreId(storeId);
|
|
|
+ storeImg.setImgType(9);
|
|
|
+ storeImg.setImgSort(i + 1);
|
|
|
+ storeImg.setImgUrl(fileUploadUtil.uploadOneFile(multipartFile));
|
|
|
+ storeImgMapper.insert(storeImg);
|
|
|
+ imgId.append(storeImg.getId()).append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!imgId.toString().isEmpty()) {
|
|
|
+ storeCommentAppeal.setImgId(imgId.substring(0, imgId.length() - 1));
|
|
|
+ }
|
|
|
+ storeCommentAppeal.setStoreId(storeId);
|
|
|
+ storeCommentAppeal.setCommentId(commentId);
|
|
|
+ storeCommentAppeal.setAppealReason(appealReason);
|
|
|
+ storeCommentAppeal.setAppealStatus(0);
|
|
|
+
|
|
|
+ int insertResult = storeCommentAppealMapper.insert(storeCommentAppeal);
|
|
|
+ boolean storeCommentAppealSave = insertResult > 0;
|
|
|
+
|
|
|
+ BeanUtils.copyProperties(storeCommentAppeal, storeCommentAppealInfoVo);
|
|
|
+ //商家申诉
|
|
|
+ StoreCommentAppealLog storeCommentAppealLog = new StoreCommentAppealLog();
|
|
|
+ storeCommentAppealLog.setAppealId(storeCommentAppeal.getId());
|
|
|
+ storeCommentAppealLog.setProcessType(0);
|
|
|
+ storeCommentAppealLog.setDeleteFlag(0);
|
|
|
+ storeCommentAppealLog.setCreatedTime(storeCommentAppeal.getCreatedTime());
|
|
|
+ boolean result = storeCommentAppealSave && storeCommentAppealLogMapper.insert(storeCommentAppealLog) > 0;
|
|
|
+ //系统审核
|
|
|
+ StoreCommentAppealLog storeCommentAppealLogSystem = new StoreCommentAppealLog();
|
|
|
+ storeCommentAppealLogSystem.setAppealId(storeCommentAppeal.getId());
|
|
|
+ storeCommentAppealLogSystem.setProcessType(1);
|
|
|
+ storeCommentAppealLogSystem.setDeleteFlag(0);
|
|
|
+ storeCommentAppealLogSystem.setCreatedTime(storeCommentAppeal.getCreatedTime());
|
|
|
+ boolean resultSystem = storeCommentAppealSave && storeCommentAppealLogMapper.insert(storeCommentAppealLogSystem) > 0;
|
|
|
+ storeCommentAppealInfoVo.setResult(result && resultSystem ? 0 : 1);
|
|
|
+ } catch (Exception e) {
|
|
|
+ storeCommentAppealInfoVo.setResult(1);
|
|
|
+ return storeCommentAppealInfoVo;
|
|
|
+ }
|
|
|
+ return storeCommentAppealInfoVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 申诉详情
|
|
|
*
|
|
|
* @param id 申诉id
|
|
|
@@ -170,7 +272,36 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
|
|
|
QueryWrapper<StoreCommentAppealVo> storeCommentAppealVoQueryWrapper = new QueryWrapper<>();
|
|
|
storeCommentAppealVoQueryWrapper.eq("a.id", id).eq("a.delete_flag", 0);
|
|
|
StoreCommentAppealVo commentDetail = storeCommentAppealMapper.getCommentDetail(storeCommentAppealVoQueryWrapper);
|
|
|
- commentDetail.setStoreCommentAppealLogList(storeCommentAppealLogMapper.getStoreCommentAppealLogVo(commentDetail.getId()));
|
|
|
+
|
|
|
+ String[] split = commentDetail.getImgId().split(",");
|
|
|
+ List<String> imgList = new ArrayList<>();
|
|
|
+ for (String s : split) {
|
|
|
+ StoreImg storeImg = storeImgMapper.selectById(s);
|
|
|
+ if (null != storeImg) {
|
|
|
+ imgList.add(storeImg.getImgUrl());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ commentDetail.setImgList(imgList);
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(commentDetail.getCommentImgId())) {
|
|
|
+ String[] split2 = commentDetail.getCommentImgId().split(",");
|
|
|
+ List<String> imgList2 = new ArrayList<>();
|
|
|
+ for (String s : split2) {
|
|
|
+ StoreImg storeImg = storeImgMapper.selectById(s);
|
|
|
+ if (null != storeImg) {
|
|
|
+ imgList2.add(storeImg.getImgUrl());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ commentDetail.setCommentImgList(imgList2);
|
|
|
+ } else {
|
|
|
+ commentDetail.setCommentImgList(new ArrayList<>());
|
|
|
+ }
|
|
|
+
|
|
|
+ List<StoreCommentAppealLogVo> storeCommentAppealLogVo = storeCommentAppealLogMapper.getStoreCommentAppealLogVo(commentDetail.getId());
|
|
|
+ commentDetail.setStoreCommentAppealLogList(storeCommentAppealLogVo);
|
|
|
+ if (ObjectUtils.isNotEmpty(storeCommentAppealLogVo)) {
|
|
|
+ commentDetail.setLogRemark(storeCommentAppealLogVo.get(storeCommentAppealLogVo.size() - 1).getLogRemark());
|
|
|
+ }
|
|
|
return commentDetail;
|
|
|
}
|
|
|
|
|
|
@@ -242,7 +373,7 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
|
|
|
* @return boolean
|
|
|
*/
|
|
|
@Override
|
|
|
- public boolean setAppealStatus(Integer id, Integer appealStatus) {
|
|
|
+ public boolean setAppealStatus(Integer id, Integer appealStatus, String logRemark) {
|
|
|
StoreCommentAppeal storeCommentAppeal = new StoreCommentAppeal();
|
|
|
storeCommentAppeal.setId(id);
|
|
|
storeCommentAppeal.setAppealStatus(appealStatus);
|
|
|
@@ -256,7 +387,10 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
|
|
|
case 2:
|
|
|
storeCommentAppeal.setFinalResult("已同意");
|
|
|
//删除原评论
|
|
|
- storeCommentMapper.deleteById(this.getById(id).getCommentId());
|
|
|
+ StoreCommentAppeal byId = this.getById(id);
|
|
|
+ storeCommentMapper.deleteById(byId.getCommentId());
|
|
|
+ //删除原评论下的评论
|
|
|
+ storeCommentMapper.update(null, new LambdaUpdateWrapper<StoreComment>().eq(StoreComment::getReplyId, byId.getCommentId()).set(StoreComment::getDeleteFlag, 1));
|
|
|
break;
|
|
|
}
|
|
|
//商家申诉
|
|
|
@@ -269,6 +403,7 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
|
|
|
}
|
|
|
storeCommentAppealLog.setDeleteFlag(0);
|
|
|
storeCommentAppealLog.setCreatedTime(new Date());
|
|
|
+ storeCommentAppealLog.setLogRemark(logRemark);
|
|
|
storeCommentAppealLogMapper.insert(storeCommentAppealLog);
|
|
|
return this.updateById(storeCommentAppeal);
|
|
|
}
|