package com.matrix.system.app.action;
|
|
import com.matrix.core.constance.MatrixConstance;
|
import com.matrix.core.exception.GlobleException;
|
import com.matrix.core.pojo.AjaxResult;
|
import com.matrix.core.pojo.PaginationVO;
|
import com.matrix.core.tools.StringUtils;
|
import com.matrix.core.tools.WebUtil;
|
import com.matrix.system.app.dto.*;
|
import com.matrix.system.app.vo.OrderDetailVo;
|
import com.matrix.system.app.vo.ShoppingGoodsDetailVo;
|
import com.matrix.system.app.vo.ShoppingGoodsListVo;
|
import com.matrix.system.common.bean.SysUsers;
|
import com.matrix.system.common.tools.DataAuthUtil;
|
import com.matrix.system.hive.bean.*;
|
import com.matrix.system.hive.dao.SysFollowupCommentDao;
|
import com.matrix.system.hive.dao.SysFollowupDao;
|
import com.matrix.system.hive.dao.SysVipAlbumDao;
|
import com.matrix.system.hive.dao.SysVipInfoDao;
|
import com.matrix.system.hive.plugin.util.CollectionUtils;
|
import com.matrix.system.hive.pojo.ShoppingCarItem;
|
import com.matrix.system.hive.pojo.ShoppingCarItemsVo;
|
import com.matrix.system.hive.service.ShoppingGoodsCategoryService;
|
import com.matrix.system.hive.service.ShoppingGoodsService;
|
import com.matrix.system.hive.service.SysOrderService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiResponse;
|
import io.swagger.annotations.ApiResponses;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.*;
|
import java.util.stream.Collectors;
|
|
/**
|
* @author jyy
|
* @date 2020-12-21
|
**/
|
@Api(value = "ApiFollowupAction", tags = "跟进记录接口类")
|
@RestController
|
@RequestMapping(value = "/api/followup")
|
public class ApiFollowupAction {
|
|
@Autowired
|
private SysFollowupDao followupDao;
|
|
@Autowired
|
private SysVipAlbumDao vipAlbumDao;
|
|
@Autowired
|
private SysVipInfoDao vipInfoDao;
|
|
@Autowired
|
private SysFollowupCommentDao followupCommentDao;
|
|
|
@ApiOperation(value = "新增跟进记录", notes = "新增跟进记录")
|
@ApiResponses({
|
@ApiResponse(code = 200, message = "ok", response = SysFollowup.class)
|
})
|
@PostMapping(value = "/addFollowup")
|
public AjaxResult addFollowup(@RequestBody @Validated SysFollowup followup) {
|
SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
|
followup.setCreateBy(user.getSuName());
|
followup.setUpdateBy(user.getSuName());
|
followup.setStaffId(user.getSuId());
|
followup.setCompanyId(user.getCompanyId());
|
followup.setShopId(user.getShopId());
|
followupDao.insert(followup);
|
//插入图片
|
List<SysVipAlbum> albums=followup.getAlbums();
|
for (SysVipAlbum vipAlbum:albums){
|
if(StringUtils.isNotBlank(vipAlbum.getImg())){
|
vipAlbum.setCreateBy(user.getSuName());
|
vipAlbum.setUpdateBy(user.getSuName());
|
vipAlbum.setSource(SysVipAlbum.SOURCE_FOLLOW);
|
vipAlbum.setVipId(followup.getVipId());
|
vipAlbum.setSourceId(followup.getId());
|
vipAlbumDao.insert(vipAlbum);
|
}
|
}
|
return AjaxResult.buildSuccessInstance("保存成功");
|
}
|
|
@ApiOperation(value = "跟进记录点赞或者取消点赞", notes = "跟进记录点赞或者取消点赞")
|
@ApiResponses({
|
@ApiResponse(code = 200, message = "ok", response = AjaxResult.class)
|
})
|
@GetMapping(value = "/zanFollowup/{id}")
|
public AjaxResult zanFollowup(@PathVariable("id")Long id) {
|
SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
|
SysFollowup followup = followupDao.selectById(id);
|
String zans=followup.getZans();
|
if(StringUtils.isNotBlank(zans)){
|
List<Long> zanIds = StringUtils.strToCollToLong(zans, ",");
|
List<Long> zaned = zanIds.stream().filter(zanid -> zanid.equals(user.getSuId())).collect(Collectors.toList());
|
if(CollectionUtils.isNotEmpty(zaned)){
|
//取消赞
|
List<Long> newZaned = zanIds.stream().filter(zanid -> !zanid.equals(user.getSuId())).collect(Collectors.toList());
|
zans=StringUtils.collToStr(newZaned,",");
|
|
}else{
|
//点赞
|
zaned.add(user.getSuId());
|
zans=StringUtils.collToStr(zaned,",");
|
}
|
}else{
|
//直接点赞
|
zans=user.getSuId()+"";
|
}
|
followupDao.updateZan(id,zans);
|
return AjaxResult.buildSuccessInstance("修改成功");
|
}
|
|
|
@ApiOperation(value = "评论跟进", notes = "评论跟进")
|
@ApiResponses({
|
@ApiResponse(code = 200, message = "ok", response = AjaxResult.class)
|
})
|
@PostMapping(value = "/addFollowupComment")
|
public AjaxResult addFollowupComment(@RequestBody @Validated SysFollowupComment followupComment) {
|
SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
|
followupComment.setCreateBy(user.getSuName());
|
followupComment.setUpdateBy(user.getSuName());
|
followupComment.setStaffId(user.getSuId());
|
followupCommentDao.insert(followupComment);
|
return AjaxResult.buildSuccessInstance("评论成功");
|
}
|
|
|
@ApiOperation(value = "查询跟进记录", notes = "查询跟进记录")
|
@ApiResponses({
|
@ApiResponse(code = 200, message = "ok", response = SysFollowup.class)
|
})
|
@PostMapping(value = "/findFollowup")
|
public AjaxResult findFollowup(@RequestBody @Validated FollowupCommonetListDto followupCommonetListDto) {
|
SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
|
followupCommonetListDto.setShopId(user.getShopId());
|
followupCommonetListDto.setCompanyId(user.getCompanyId());
|
followupCommonetListDto.setSelfStaff(user.getSuId());
|
//TODO 需要设置跨店数据权限
|
List<SysFollowup> rows= followupDao.selectByAppDto(followupCommonetListDto);
|
return AjaxResult.buildSuccessInstance(rows,"查询成功");
|
}
|
|
|
|
}
|