|
@@ -1,7 +1,10 @@
|
|
|
package org.jeecg.modules.adweb.enquiry.controller;
|
|
|
|
|
|
+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.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
@@ -27,11 +30,14 @@ import org.jeecg.common.system.vo.DictModel;
|
|
|
import org.jeecg.common.system.vo.DictPropertyModel;
|
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
|
import org.jeecg.common.util.FastJsonUtil;
|
|
|
+import org.jeecg.config.shiro.IgnoreAuth;
|
|
|
import org.jeecg.modules.adweb.common.constant.AdwebConstant;
|
|
|
import org.jeecg.modules.adweb.common.util.AwsTranslateUtils;
|
|
|
import org.jeecg.modules.adweb.common.util.DateUtil;
|
|
|
import org.jeecg.modules.adweb.enquiry.constant.EnquirySendStatus;
|
|
|
+import org.jeecg.modules.adweb.enquiry.dto.EnquiryDTO;
|
|
|
import org.jeecg.modules.adweb.enquiry.dto.param.EffectiveEnquiryParamDto;
|
|
|
+import org.jeecg.modules.adweb.enquiry.dto.param.EnquiryForm;
|
|
|
import org.jeecg.modules.adweb.enquiry.dto.param.EnquiryListSearchDto;
|
|
|
import org.jeecg.modules.adweb.enquiry.dto.param.EnquirySearchDto;
|
|
|
import org.jeecg.modules.adweb.enquiry.dto.result.EnquiryListDto;
|
|
@@ -40,6 +46,7 @@ import org.jeecg.modules.adweb.enquiry.entity.AdwebEnquiry;
|
|
|
import org.jeecg.modules.adweb.enquiry.entity.EnquiryEmailMessage;
|
|
|
import org.jeecg.modules.adweb.enquiry.mapper.AdwebEnquiryMapper;
|
|
|
import org.jeecg.modules.adweb.enquiry.service.IAdwebEnquiryService;
|
|
|
+import org.jeecg.modules.adweb.enquiry.service.IEnquiryEmailMessageService;
|
|
|
import org.jeecg.modules.adweb.site.entity.AdwebSite;
|
|
|
import org.jeecg.modules.adweb.site.service.IAdwebSiteService;
|
|
|
import org.jeecg.modules.adweb.site.service.ISiteUserPermissionService;
|
|
@@ -54,10 +61,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
/**
|
|
|
- * @Description: 询盘信息存储表单
|
|
|
- * @Author: jeecg-boot
|
|
|
- * @Date: 2024-10-12
|
|
|
- * @Version: V1.0
|
|
|
+ * @Description: 询盘信息存储表单 @Author: jeecg-boot @Date: 2024-10-12 @Version: V1.0
|
|
|
*/
|
|
|
@Tag(name = "询盘信息存储表单")
|
|
|
@RestController
|
|
@@ -65,711 +69,858 @@ import org.springframework.web.servlet.ModelAndView;
|
|
|
@Slf4j
|
|
|
public class AdwebEnquiryController extends JeecgController<AdwebEnquiry, IAdwebEnquiryService> {
|
|
|
|
|
|
- @Value("${enquiry.disable-admin-read:true}")
|
|
|
- private Boolean disableAdminRead;
|
|
|
-
|
|
|
- @Value("${enquiry.demoFlag:false}")
|
|
|
- private Boolean demoFlag;
|
|
|
-
|
|
|
- @Resource private IAdwebEnquiryService adwebEnquiryService;
|
|
|
-
|
|
|
- @Resource private AdwebEnquiryMapper adwebEnquiryMapper;
|
|
|
-
|
|
|
- @Resource private SysAdwebApi sysAdwebApi;
|
|
|
-
|
|
|
- @Resource private IAdwebSiteService adwebSiteService;
|
|
|
-
|
|
|
- @Resource private ISiteUserPermissionService siteUserPermissionService;
|
|
|
-
|
|
|
- @Resource private ISysDictService sysDictService;
|
|
|
-
|
|
|
- @Resource private AwsTranslateUtils awsTranslateUtils;
|
|
|
-
|
|
|
- @Resource private ISysUserService sysUserService;
|
|
|
-
|
|
|
- /**
|
|
|
- * 分页列表查询
|
|
|
- *
|
|
|
- * @param searchDto
|
|
|
- * @param pageNo
|
|
|
- * @param pageSize
|
|
|
- * @param principalUid
|
|
|
- * @return
|
|
|
- */
|
|
|
- // @AutoLog(value = "询盘信息存储表单-分页列表查询")
|
|
|
- @Operation(summary = "询盘信息存储表单-分页列表查询")
|
|
|
- @GetMapping(value = "/list")
|
|
|
- public Result<?> queryPageList(
|
|
|
- EnquiryListSearchDto searchDto,
|
|
|
- @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
- @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
|
- String principalUid) {
|
|
|
-
|
|
|
- if (sysAdwebApi.isNotOwnSite(searchDto.getSiteId())) {
|
|
|
- return Result.OK(new Page<>());
|
|
|
- }
|
|
|
-
|
|
|
- Page<EnquirySearchDto> page = new Page<>(pageNo, pageSize);
|
|
|
- LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
-
|
|
|
- List<String> codeList = null;
|
|
|
- List<String> uidList = null;
|
|
|
-
|
|
|
- if (sysAdwebApi.isAdmin()) {
|
|
|
-
|
|
|
- } else if (sysAdwebApi.isChannelAdmin()) {
|
|
|
- uidList = sysAdwebApi.getChannelGroupUids();
|
|
|
- } else {
|
|
|
- uidList = new ArrayList<>();
|
|
|
- uidList.add(sysUser.getId());
|
|
|
- }
|
|
|
- List<String> siteCodeList = null;
|
|
|
- if (CollectionUtils.isNotEmpty(uidList)) {
|
|
|
- siteCodeList = siteUserPermissionService.getSiteCodeListByUids(uidList);
|
|
|
- }
|
|
|
-
|
|
|
- if (searchDto.getSiteId() != null) {
|
|
|
- String siteCode = adwebSiteService.getSiteCodeById(searchDto.getSiteId());
|
|
|
- if (StringUtils.isNotBlank(siteCode)) {
|
|
|
- LambdaQueryWrapper<AdwebSite> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper
|
|
|
- .eq(AdwebSite::getId, searchDto.getSiteId())
|
|
|
- .or()
|
|
|
- .eq(AdwebSite::getParentGroupCode, siteCode);
|
|
|
- queryWrapper.ne(AdwebSite::getStatus, 0);
|
|
|
- queryWrapper.in(!sysAdwebApi.isAdmin(), AdwebSite::getCode, siteCodeList);
|
|
|
- codeList =
|
|
|
- adwebSiteService.list(queryWrapper).stream()
|
|
|
- .map(AdwebSite::getCode)
|
|
|
- .collect(Collectors.toList());
|
|
|
+ @Value("${enquiry.disable-admin-read:true}")
|
|
|
+ private Boolean disableAdminRead;
|
|
|
+
|
|
|
+ @Value("${enquiry.demoFlag:false}")
|
|
|
+ private Boolean demoFlag;
|
|
|
+
|
|
|
+ @Resource private IAdwebEnquiryService adwebEnquiryService;
|
|
|
+
|
|
|
+ @Resource private AdwebEnquiryMapper adwebEnquiryMapper;
|
|
|
+
|
|
|
+ @Resource private SysAdwebApi sysAdwebApi;
|
|
|
+
|
|
|
+ @Resource private IAdwebSiteService adwebSiteService;
|
|
|
+
|
|
|
+ @Resource private ISiteUserPermissionService siteUserPermissionService;
|
|
|
+
|
|
|
+ @Resource private ISysDictService sysDictService;
|
|
|
+
|
|
|
+ @Resource private AwsTranslateUtils awsTranslateUtils;
|
|
|
+
|
|
|
+ @Resource private ISysUserService sysUserService;
|
|
|
+
|
|
|
+ @Resource private IEnquiryEmailMessageService enquiryEmailMessageService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页列表查询
|
|
|
+ *
|
|
|
+ * @param searchDto
|
|
|
+ * @param pageNo
|
|
|
+ * @param pageSize
|
|
|
+ * @param principalUid
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ // @AutoLog(value = "询盘信息存储表单-分页列表查询")
|
|
|
+ @Operation(summary = "询盘信息存储表单-分页列表查询")
|
|
|
+ @GetMapping(value = "/list")
|
|
|
+ public Result<?> queryPageList(
|
|
|
+ EnquiryListSearchDto searchDto,
|
|
|
+ @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
+ @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
|
+ String principalUid) {
|
|
|
+
|
|
|
+ if (sysAdwebApi.isNotOwnSite(searchDto.getSiteId())) {
|
|
|
+ return Result.OK(new Page<>());
|
|
|
+ }
|
|
|
+
|
|
|
+ Page<EnquirySearchDto> page = new Page<>(pageNo, pageSize);
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+
|
|
|
+ List<String> codeList = null;
|
|
|
+ List<String> uidList = null;
|
|
|
+
|
|
|
+ if (sysAdwebApi.isAdmin()) {
|
|
|
+
|
|
|
+ } else if (sysAdwebApi.isChannelAdmin()) {
|
|
|
+ uidList = sysAdwebApi.getChannelGroupUids();
|
|
|
+ } else {
|
|
|
+ uidList = new ArrayList<>();
|
|
|
+ uidList.add(sysUser.getId());
|
|
|
+ }
|
|
|
+ List<String> siteCodeList = null;
|
|
|
+ if (CollectionUtils.isNotEmpty(uidList)) {
|
|
|
+ siteCodeList = siteUserPermissionService.getSiteCodeListByUids(uidList);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (searchDto.getSiteId() != null) {
|
|
|
+ String siteCode = adwebSiteService.getSiteCodeById(searchDto.getSiteId());
|
|
|
+ if (StringUtils.isNotBlank(siteCode)) {
|
|
|
+ LambdaQueryWrapper<AdwebSite> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper
|
|
|
+ .eq(AdwebSite::getId, searchDto.getSiteId())
|
|
|
+ .or()
|
|
|
+ .eq(AdwebSite::getParentGroupCode, siteCode);
|
|
|
+ queryWrapper.ne(AdwebSite::getStatus, 0);
|
|
|
+ queryWrapper.in(!sysAdwebApi.isAdmin(), AdwebSite::getCode, siteCodeList);
|
|
|
+ codeList =
|
|
|
+ adwebSiteService.list(queryWrapper).stream()
|
|
|
+ .map(AdwebSite::getCode)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ codeList = siteCodeList;
|
|
|
+ }
|
|
|
+
|
|
|
+ String dateType = searchDto.getDateType();
|
|
|
+ Date start = searchDto.getStart();
|
|
|
+ Date end = searchDto.getEnd();
|
|
|
+ if (StringUtils.isNotBlank(dateType)) {
|
|
|
+ Pair<Date, Date> dateRange = DateUtil.getDateRangeByType(dateType);
|
|
|
+ start = dateRange.getLeft();
|
|
|
+ end = dateRange.getRight();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollectionUtils.isEmpty(codeList)) {
|
|
|
+ return Result.OK(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ String selfPrincipalUid = null;
|
|
|
+ if (sysAdwebApi.isAdwebSubVip()) {
|
|
|
+ selfPrincipalUid = sysUser.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ String userEfftecive = "(" + searchDto.getUserEffective() + ")";
|
|
|
+
|
|
|
+ IPage<EnquiryListDto> pageList =
|
|
|
+ adwebEnquiryMapper.selectEnquiryList(
|
|
|
+ page,
|
|
|
+ codeList,
|
|
|
+ userEfftecive,
|
|
|
+ searchDto.getWasteEnquiryType(),
|
|
|
+ searchDto.getSearchText(),
|
|
|
+ searchDto.getSearchContent(),
|
|
|
+ start,
|
|
|
+ end,
|
|
|
+ searchDto.getWhatsApp(),
|
|
|
+ searchDto.getReadStatus(),
|
|
|
+ principalUid,
|
|
|
+ selfPrincipalUid);
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(pageList.getRecords())) {
|
|
|
+ dealInfo(pageList.getRecords());
|
|
|
+ }
|
|
|
+ return Result.OK(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理询盘列表结果集
|
|
|
+ *
|
|
|
+ * @param enquiryList
|
|
|
+ */
|
|
|
+ private void dealInfo(List<EnquiryListDto> enquiryList) {
|
|
|
+ if (CollectionUtils.isEmpty(enquiryList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<DictModel> userEffectiveDict =
|
|
|
+ sysDictService.queryDictItemsByCode(AdwebConstant.ENQUIRY_EFFECTIVE);
|
|
|
+ AtomicInteger atomicInteger = new AtomicInteger();
|
|
|
+
|
|
|
+ enquiryList.forEach(
|
|
|
+ enquiry -> {
|
|
|
+ // 来源页面如果以 / 结尾,去掉最后一个字符
|
|
|
+ String fromPage = enquiry.getFromPage();
|
|
|
+ if (StringUtils.isNotBlank(fromPage)) {
|
|
|
+ if (fromPage.endsWith("/")) {
|
|
|
+ enquiry.setFromPage(fromPage.substring(0, fromPage.length() - 1));
|
|
|
}
|
|
|
- } else {
|
|
|
- codeList = siteCodeList;
|
|
|
- }
|
|
|
-
|
|
|
- String dateType = searchDto.getDateType();
|
|
|
- Date start = searchDto.getStart();
|
|
|
- Date end = searchDto.getEnd();
|
|
|
- if (StringUtils.isNotBlank(dateType)) {
|
|
|
- Pair<Date, Date> dateRange = DateUtil.getDateRangeByType(dateType);
|
|
|
- start = dateRange.getLeft();
|
|
|
- end = dateRange.getRight();
|
|
|
- }
|
|
|
-
|
|
|
- if (CollectionUtils.isEmpty(codeList)) {
|
|
|
- return Result.OK(page);
|
|
|
- }
|
|
|
-
|
|
|
- String selfPrincipalUid = null;
|
|
|
- if (sysAdwebApi.isAdwebSubVip()) {
|
|
|
- selfPrincipalUid = sysUser.getId();
|
|
|
- }
|
|
|
-
|
|
|
- String userEfftecive = "(" + searchDto.getUserEffective() + ")";
|
|
|
-
|
|
|
- IPage<EnquiryListDto> pageList =
|
|
|
- adwebEnquiryMapper.selectEnquiryList(
|
|
|
- page,
|
|
|
- codeList,
|
|
|
- userEfftecive,
|
|
|
- searchDto.getWasteEnquiryType(),
|
|
|
- searchDto.getSearchText(),
|
|
|
- searchDto.getSearchContent(),
|
|
|
- start,
|
|
|
- end,
|
|
|
- searchDto.getWhatsApp(),
|
|
|
- searchDto.getReadStatus(),
|
|
|
- principalUid,
|
|
|
- selfPrincipalUid);
|
|
|
-
|
|
|
- if (CollectionUtils.isNotEmpty(pageList.getRecords())) {
|
|
|
- dealInfo(pageList.getRecords());
|
|
|
- }
|
|
|
- return Result.OK(pageList);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 处理询盘列表结果集
|
|
|
- *
|
|
|
- * @param enquiryList
|
|
|
- */
|
|
|
- private void dealInfo(List<EnquiryListDto> enquiryList) {
|
|
|
- if (CollectionUtils.isEmpty(enquiryList)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
- List<DictModel> userEffectiveDict =
|
|
|
- sysDictService.queryDictItemsByCode(AdwebConstant.ENQUIRY_EFFECTIVE);
|
|
|
- AtomicInteger atomicInteger = new AtomicInteger();
|
|
|
-
|
|
|
- enquiryList.forEach(
|
|
|
- enquiry -> {
|
|
|
- // 来源页面如果以 / 结尾,去掉最后一个字符
|
|
|
- String fromPage = enquiry.getFromPage();
|
|
|
- if (StringUtils.isNotBlank(fromPage)) {
|
|
|
- if (fromPage.endsWith("/")) {
|
|
|
- enquiry.setFromPage(fromPage.substring(0, fromPage.length() - 1));
|
|
|
- }
|
|
|
- }
|
|
|
- atomicInteger.getAndIncrement();
|
|
|
- enquiry.setDataIndex(atomicInteger.get());
|
|
|
-
|
|
|
- // 示例关键信息脱敏
|
|
|
- if (demoFlag) {
|
|
|
- enquiry.setFormCompany("**********");
|
|
|
- enquiry.setFromEmail("**********");
|
|
|
- enquiry.setWhatsApp("**********");
|
|
|
- enquiry.setPhone("**********");
|
|
|
- String siteName = enquiry.getSiteName();
|
|
|
- enquiry.setSiteName(
|
|
|
- siteName.substring(0, 2)
|
|
|
- + "**********"
|
|
|
- + siteName.substring(siteName.length() - 2));
|
|
|
- }
|
|
|
-
|
|
|
- /**********************字典数据处理***********************/
|
|
|
- if (CollectionUtils.isNotEmpty(userEffectiveDict)) {
|
|
|
- userEffectiveDict.forEach(
|
|
|
- dict -> {
|
|
|
- if (dict.getValue().equals(enquiry.getUserEffective() + "")) {
|
|
|
- enquiry.setUserEffectiveStr(dict.getLabel());
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- // 询盘中用户自定义的字段处理
|
|
|
- if (StringUtils.isNotBlank(enquiry.getSpecialField())) {
|
|
|
- List<EnquirySpecialFields> specialFieldsList =
|
|
|
- FastJsonUtil.parseList(
|
|
|
- enquiry.getSpecialField(), EnquirySpecialFields.class);
|
|
|
- enquiry.setSpecialFieldList(specialFieldsList);
|
|
|
- enquiry.setSpecialField(null);
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(enquiry.getContext())) {
|
|
|
- String context = enquiry.getContext();
|
|
|
- Pattern CRLF = Pattern.compile("(\r\n|\r|\n|\n\r)");
|
|
|
- Matcher m = CRLF.matcher(context);
|
|
|
- if (m.find()) {
|
|
|
- context = m.replaceAll("<br/>");
|
|
|
- }
|
|
|
- enquiry.setContext(context);
|
|
|
- }
|
|
|
+ }
|
|
|
+ atomicInteger.getAndIncrement();
|
|
|
+ enquiry.setDataIndex(atomicInteger.get());
|
|
|
+
|
|
|
+ // 示例关键信息脱敏
|
|
|
+ if (demoFlag) {
|
|
|
+ enquiry.setFormCompany("**********");
|
|
|
+ enquiry.setFromEmail("**********");
|
|
|
+ enquiry.setWhatsApp("**********");
|
|
|
+ enquiry.setPhone("**********");
|
|
|
+ String siteName = enquiry.getSiteName();
|
|
|
+ enquiry.setSiteName(
|
|
|
+ siteName.substring(0, 2)
|
|
|
+ + "**********"
|
|
|
+ + siteName.substring(siteName.length() - 2));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**********************字典数据处理***********************/
|
|
|
+ if (CollectionUtils.isNotEmpty(userEffectiveDict)) {
|
|
|
+ userEffectiveDict.forEach(
|
|
|
+ dict -> {
|
|
|
+ if (dict.getValue().equals(enquiry.getUserEffective() + "")) {
|
|
|
+ enquiry.setUserEffectiveStr(dict.getLabel());
|
|
|
+ }
|
|
|
});
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 添加
|
|
|
- *
|
|
|
- * @param adwebEnquiry
|
|
|
- * @return
|
|
|
- */
|
|
|
- @AutoLog(value = "询盘信息存储表单-添加")
|
|
|
- @Operation(summary = "询盘信息存储表单-添加")
|
|
|
- @PreAuthorize("@jps.requiresPermissions('adweb:adweb_enquiry:add')")
|
|
|
- @PostMapping(value = "/add")
|
|
|
- public Result<String> add(@RequestBody AdwebEnquiry adwebEnquiry) {
|
|
|
- adwebEnquiryService.save(adwebEnquiry);
|
|
|
- return Result.OK("添加成功!");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 编辑
|
|
|
- *
|
|
|
- * @param adwebEnquiry
|
|
|
- * @return
|
|
|
- */
|
|
|
- @AutoLog(value = "询盘信息存储表单-编辑")
|
|
|
- @Operation(summary = "询盘信息存储表单-编辑")
|
|
|
- @PreAuthorize("@jps.requiresPermissions('adweb:adweb_enquiry:edit')")
|
|
|
- @RequestMapping(
|
|
|
- value = "/edit",
|
|
|
- method = {RequestMethod.PUT, RequestMethod.POST})
|
|
|
- public Result<String> edit(@RequestBody AdwebEnquiry adwebEnquiry) {
|
|
|
- adwebEnquiryService.updateById(adwebEnquiry);
|
|
|
- return Result.OK("编辑成功!");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 通过id删除
|
|
|
- *
|
|
|
- * @param id
|
|
|
- * @return
|
|
|
- */
|
|
|
- @AutoLog(value = "询盘信息存储表单-通过id删除")
|
|
|
- @Operation(summary = "询盘信息存储表单-通过id删除")
|
|
|
- @PreAuthorize("@jps.requiresPermissions('adweb:adweb_enquiry:delete')")
|
|
|
- @DeleteMapping(value = "/delete")
|
|
|
- public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
|
|
- adwebEnquiryService.removeById(id);
|
|
|
- return Result.OK("删除成功!");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 批量删除
|
|
|
- *
|
|
|
- * @param ids
|
|
|
- * @return
|
|
|
- */
|
|
|
- @AutoLog(value = "询盘信息存储表单-批量删除")
|
|
|
- @Operation(summary = "询盘信息存储表单-批量删除")
|
|
|
- @PreAuthorize("@jps.requiresPermissions('adweb:adweb_enquiry:deleteBatch')")
|
|
|
- @DeleteMapping(value = "/deleteBatch")
|
|
|
- public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
|
|
- this.adwebEnquiryService.removeByIds(Arrays.asList(ids.split(",")));
|
|
|
- return Result.OK("批量删除成功!");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 通过id查询
|
|
|
- *
|
|
|
- * @param id
|
|
|
- * @return
|
|
|
- */
|
|
|
- // @AutoLog(value = "询盘信息存储表单-通过id查询")
|
|
|
- @Operation(summary = "询盘信息存储表单-通过id查询")
|
|
|
- @GetMapping(value = "/queryById")
|
|
|
- public Result<AdwebEnquiry> queryById(@RequestParam(name = "id", required = true) String id) {
|
|
|
- AdwebEnquiry adwebEnquiry = adwebEnquiryService.getById(id);
|
|
|
- if (adwebEnquiry == null) {
|
|
|
- return Result.error("未找到对应数据");
|
|
|
- }
|
|
|
- return Result.OK(adwebEnquiry);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 导出excel
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * @param adwebEnquiry
|
|
|
- */
|
|
|
- @PreAuthorize("@jps.requiresPermissions('adweb:adweb_enquiry:exportXls')")
|
|
|
- @RequestMapping(value = "/exportXls")
|
|
|
- public ModelAndView exportXls(HttpServletRequest request, AdwebEnquiry adwebEnquiry) {
|
|
|
- return super.exportXls(request, adwebEnquiry, AdwebEnquiry.class, "询盘信息存储表单");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 通过excel导入数据
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- * @return
|
|
|
- */
|
|
|
- @PreAuthorize("@jps.requiresPermissions('adweb:adweb_enquiry:importExcel')")
|
|
|
- @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
- public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
|
- return super.importExcel(request, response, AdwebEnquiry.class);
|
|
|
- }
|
|
|
-
|
|
|
- /** 获取需要轮流询盘的站点code */
|
|
|
- @GetMapping("/getTurnInquiryCode")
|
|
|
- public Result<?> getTurnInquiryCode() {
|
|
|
- List<DictPropertyModel> siteRes =
|
|
|
- sysAdwebApi.queryDictInfoByDictCode("turn_inquiry_site_code");
|
|
|
- if (CollectionUtils.isNotEmpty(siteRes)) {
|
|
|
- return Result.OK(siteRes);
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @return
|
|
|
- */
|
|
|
- @GetMapping(value = "/getEnquiryCatalog")
|
|
|
- public Result<?> getEnquiryCatalog() {
|
|
|
- List<DictPropertyModel> userEffectiveDict =
|
|
|
- sysAdwebApi.queryDictInfoByDictCode(AdwebConstant.ENQUIRY_EFFECTIVE);
|
|
|
- return Result.OK(FastJsonUtil.toJSONString(userEffectiveDict));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取不同状态询盘的数量
|
|
|
- *
|
|
|
- * @param siteId 站点id
|
|
|
- * @return 数量信息
|
|
|
- */
|
|
|
- @GetMapping("getEnquiryNums")
|
|
|
- public Result<?> getEnquiryNums(
|
|
|
- Integer siteId,
|
|
|
- String dateType,
|
|
|
- @DateTimeFormat(pattern = "yyyy-MM-dd") Date start,
|
|
|
- @DateTimeFormat(pattern = "yyyy-MM-dd") Date end) {
|
|
|
- LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
- if (StringUtils.isNotBlank(dateType)) {
|
|
|
- Pair<Date, Date> dateRange = DateUtil.getDateRangeByType(dateType);
|
|
|
- start = dateRange.getLeft();
|
|
|
- end = dateRange.getRight();
|
|
|
- }
|
|
|
-
|
|
|
- List<Integer> siteIds = null;
|
|
|
- if (siteId != null) {
|
|
|
- String siteCode = adwebSiteService.getSiteCodeById(siteId);
|
|
|
- LambdaQueryWrapper<AdwebSite> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper
|
|
|
- .eq(AdwebSite::getCode, siteCode)
|
|
|
- .or()
|
|
|
- .eq(AdwebSite::getParentGroupCode, siteCode);
|
|
|
- queryWrapper.ne(AdwebSite::getStatus, 0);
|
|
|
- List<AdwebSite> sites = adwebSiteService.list(queryWrapper);
|
|
|
- siteIds = sites.stream().map(AdwebSite::getId).collect(Collectors.toList());
|
|
|
- } else {
|
|
|
- if (sysAdwebApi.isAdmin()) {
|
|
|
- LambdaQueryWrapper<AdwebSite> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.ne(AdwebSite::getStatus, 0);
|
|
|
- List<AdwebSite> sites = adwebSiteService.list(queryWrapper);
|
|
|
- siteIds = sites.stream().map(AdwebSite::getId).collect(Collectors.toList());
|
|
|
- } else if (sysAdwebApi.isChannelAdmin()) {
|
|
|
- List<String> channelGroupUids = sysAdwebApi.getChannelGroupUids();
|
|
|
- List<String> codeList =
|
|
|
- siteUserPermissionService.getSiteCodeListByUids(channelGroupUids);
|
|
|
- LambdaQueryWrapper<AdwebSite> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.in(AdwebSite::getCode, codeList);
|
|
|
- queryWrapper.ne(AdwebSite::getStatus, 0);
|
|
|
- List<AdwebSite> sites = adwebSiteService.list(queryWrapper);
|
|
|
- siteIds = sites.stream().map(AdwebSite::getId).collect(Collectors.toList());
|
|
|
- } else {
|
|
|
- List<String> codeList =
|
|
|
- siteUserPermissionService.getSiteCodeList(loginUser.getId());
|
|
|
- LambdaQueryWrapper<AdwebSite> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.in(AdwebSite::getCode, codeList);
|
|
|
- queryWrapper.ne(AdwebSite::getStatus, 0);
|
|
|
- List<AdwebSite> sites = adwebSiteService.list(queryWrapper);
|
|
|
- siteIds = sites.stream().map(AdwebSite::getId).collect(Collectors.toList());
|
|
|
+ enquiry.setPrincipalName("ALL");
|
|
|
+ if (StringUtils.isNotBlank(enquiry.getPrincipalUid())) {
|
|
|
+ SysUser sysUser = sysUserService.getById(enquiry.getPrincipalUid());
|
|
|
+ if (sysUser != null) {
|
|
|
+ enquiry.setPrincipalName(sysUser.getUsername());
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- String principalUid = null;
|
|
|
- if (sysAdwebApi.isAdwebSubVip()) {
|
|
|
- principalUid = loginUser.getId();
|
|
|
- }
|
|
|
-
|
|
|
- LambdaQueryWrapper<AdwebEnquiry> enquiryQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- enquiryQueryWrapper.eq(AdwebEnquiry::getStatus, 1);
|
|
|
- if (start != null) {
|
|
|
- enquiryQueryWrapper.ge(AdwebEnquiry::getRecordCtime, start);
|
|
|
- }
|
|
|
- if (end != null) {
|
|
|
- enquiryQueryWrapper.lt(AdwebEnquiry::getRecordCtime, DateUtil.addDays(end, 1));
|
|
|
- }
|
|
|
- if (siteIds != null) {
|
|
|
- enquiryQueryWrapper.in(AdwebEnquiry::getSiteId, siteIds);
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(principalUid)) {
|
|
|
- String finalPrincipalUid = principalUid;
|
|
|
- enquiryQueryWrapper.and(
|
|
|
- wrapper ->
|
|
|
- wrapper.eq(AdwebEnquiry::getPrincipalUid, finalPrincipalUid)
|
|
|
- .or()
|
|
|
- .eq(AdwebEnquiry::getPrincipalUid, "ALL"));
|
|
|
- }
|
|
|
- enquiryQueryWrapper.ne(AdwebEnquiry::getUserEffective, 0);
|
|
|
- int all = (int) adwebEnquiryService.count(enquiryQueryWrapper);
|
|
|
-
|
|
|
- LambdaQueryWrapper<AdwebEnquiry> enquiryQueryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
- enquiryQueryWrapper1.eq(AdwebEnquiry::getStatus, 1);
|
|
|
- if (start != null) {
|
|
|
- enquiryQueryWrapper1.ge(AdwebEnquiry::getRecordCtime, start);
|
|
|
- }
|
|
|
- if (end != null) {
|
|
|
- enquiryQueryWrapper1.lt(AdwebEnquiry::getRecordCtime, DateUtil.addDays(end, 1));
|
|
|
- }
|
|
|
- if (siteIds != null) {
|
|
|
- enquiryQueryWrapper1.in(AdwebEnquiry::getSiteId, siteIds);
|
|
|
- }
|
|
|
- enquiryQueryWrapper1.eq(AdwebEnquiry::getReadStatus, 0);
|
|
|
- if (StringUtils.isNotBlank(principalUid)) {
|
|
|
- String finalPrincipalUid = principalUid;
|
|
|
- enquiryQueryWrapper1.and(
|
|
|
- wrapper ->
|
|
|
- wrapper.eq(AdwebEnquiry::getPrincipalUid, finalPrincipalUid)
|
|
|
- .or()
|
|
|
- .eq(AdwebEnquiry::getPrincipalUid, "ALL"));
|
|
|
- }
|
|
|
- enquiryQueryWrapper1.ne(AdwebEnquiry::getUserEffective, 0);
|
|
|
- int noRead = (int) adwebEnquiryService.count(enquiryQueryWrapper1);
|
|
|
-
|
|
|
- LambdaQueryWrapper<AdwebEnquiry> enquiryQueryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
- enquiryQueryWrapper2.eq(AdwebEnquiry::getStatus, 1);
|
|
|
- if (start != null) {
|
|
|
- enquiryQueryWrapper2.ge(AdwebEnquiry::getRecordCtime, start);
|
|
|
- }
|
|
|
- if (end != null) {
|
|
|
- enquiryQueryWrapper2.lt(AdwebEnquiry::getRecordCtime, DateUtil.addDays(end, 1));
|
|
|
- }
|
|
|
- if (siteIds != null) {
|
|
|
- enquiryQueryWrapper2.in(AdwebEnquiry::getSiteId, siteIds);
|
|
|
- }
|
|
|
- enquiryQueryWrapper2.eq(AdwebEnquiry::getUserEffective, 1);
|
|
|
- if (StringUtils.isNotBlank(principalUid)) {
|
|
|
- String finalPrincipalUid = principalUid;
|
|
|
- enquiryQueryWrapper2.and(
|
|
|
- wrapper ->
|
|
|
- wrapper.eq(AdwebEnquiry::getPrincipalUid, finalPrincipalUid)
|
|
|
- .or()
|
|
|
- .eq(AdwebEnquiry::getPrincipalUid, "ALL"));
|
|
|
- }
|
|
|
- enquiryQueryWrapper2.ne(AdwebEnquiry::getUserEffective, 0);
|
|
|
- int product = (int) adwebEnquiryService.count(enquiryQueryWrapper2);
|
|
|
-
|
|
|
- LambdaQueryWrapper<AdwebEnquiry> enquiryQueryWrapper3 = new LambdaQueryWrapper<>();
|
|
|
- enquiryQueryWrapper3.eq(AdwebEnquiry::getStatus, 1);
|
|
|
- if (start != null) {
|
|
|
- enquiryQueryWrapper3.ge(AdwebEnquiry::getRecordCtime, start);
|
|
|
- }
|
|
|
- if (end != null) {
|
|
|
- enquiryQueryWrapper3.lt(AdwebEnquiry::getRecordCtime, DateUtil.addDays(end, 1));
|
|
|
- }
|
|
|
- if (siteIds != null) {
|
|
|
- enquiryQueryWrapper3.in(AdwebEnquiry::getSiteId, siteIds);
|
|
|
- }
|
|
|
- enquiryQueryWrapper3.eq(AdwebEnquiry::getUserEffective, 2);
|
|
|
- if (StringUtils.isNotBlank(principalUid)) {
|
|
|
- String finalPrincipalUid = principalUid;
|
|
|
- enquiryQueryWrapper3.and(
|
|
|
- wrapper ->
|
|
|
- wrapper.eq(AdwebEnquiry::getPrincipalUid, finalPrincipalUid)
|
|
|
- .or()
|
|
|
- .eq(AdwebEnquiry::getPrincipalUid, "ALL"));
|
|
|
- }
|
|
|
- enquiryQueryWrapper3.ne(AdwebEnquiry::getUserEffective, 0);
|
|
|
- int wait = (int) adwebEnquiryService.count(enquiryQueryWrapper3);
|
|
|
-
|
|
|
- Map<String, Integer> map = new HashMap<>();
|
|
|
- map.put("all", all);
|
|
|
- map.put("noRead", noRead);
|
|
|
- map.put("product", product);
|
|
|
- map.put("wait", wait);
|
|
|
-
|
|
|
- return Result.OK(map);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 将询盘的状态改为已读
|
|
|
- *
|
|
|
- * @param id 询盘id
|
|
|
- * @return 处理结果
|
|
|
- */
|
|
|
- @GetMapping("/read")
|
|
|
- public Result<?> read(@Param("id") String id) {
|
|
|
- if (disableAdminRead && (sysAdwebApi.isAdmin() || sysAdwebApi.isChannelAdmin())) {
|
|
|
- return Result.OK();
|
|
|
- }
|
|
|
- LambdaUpdateWrapper<AdwebEnquiry> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- updateWrapper.in(AdwebEnquiry::getId, id);
|
|
|
- updateWrapper.set(AdwebEnquiry::getReadStatus, 1);
|
|
|
- adwebEnquiryService.update(updateWrapper);
|
|
|
- return Result.OK();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @param query
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequestMapping(value = "/enquiryTrans", method = RequestMethod.POST)
|
|
|
- @ResponseBody
|
|
|
- public Result<String> getEnquiryTrans(String query, String id) {
|
|
|
- String text = awsTranslateUtils.translate(query);
|
|
|
- LambdaUpdateWrapper<AdwebEnquiry> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- updateWrapper.eq(AdwebEnquiry::getId, id);
|
|
|
- updateWrapper.set(AdwebEnquiry::getTransContent, text);
|
|
|
- adwebEnquiryService.update(updateWrapper);
|
|
|
-
|
|
|
- return Result.ok(text);
|
|
|
- }
|
|
|
-
|
|
|
- /** 更改询盘用户有效性 */
|
|
|
- @PostMapping("/update/user/effective")
|
|
|
- public Result<?> updateUserEffective(EffectiveEnquiryParamDto effectiveEnquiryParamDto) {
|
|
|
- LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
-
|
|
|
- boolean res = adwebEnquiryService.updateUserEffective(effectiveEnquiryParamDto);
|
|
|
- if (res) {
|
|
|
- return Result.OK("ok");
|
|
|
- }
|
|
|
- return Result.error("fail");
|
|
|
- }
|
|
|
-
|
|
|
- /** 转发询盘 */
|
|
|
- @AutoLog(value = "转发询盘")
|
|
|
- @GetMapping(value = "/setForward")
|
|
|
- public Result<?> setForward(
|
|
|
- @RequestParam String ids, @RequestParam String uid, @RequestParam String code) {
|
|
|
- LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
-
|
|
|
- SysUser user = sysUserService.getById(uid);
|
|
|
- if (StringUtils.isEmpty(user.getEmail())) {
|
|
|
- return Result.error("该账户未设置邮箱!");
|
|
|
- }
|
|
|
- List<String> idList = Arrays.asList(ids.split(","));
|
|
|
- LambdaUpdateWrapper<AdwebEnquiry> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- updateWrapper.in(AdwebEnquiry::getId, idList);
|
|
|
- updateWrapper.set(AdwebEnquiry::getPrincipalUid, uid);
|
|
|
- updateWrapper.set(AdwebEnquiry::getPrincipalType, 1);
|
|
|
- adwebEnquiryService.update(updateWrapper);
|
|
|
-
|
|
|
- LambdaQueryWrapper<AdwebEnquiry> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.in(AdwebEnquiry::getId, idList);
|
|
|
- List<AdwebEnquiry> list = adwebEnquiryService.list(queryWrapper);
|
|
|
- // 获取站点
|
|
|
- LambdaQueryWrapper<AdwebSite> adwebSiteQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- adwebSiteQueryWrapper.eq(AdwebSite::getCode, code);
|
|
|
- AdwebSite adwebSite = adwebSiteService.getOne(adwebSiteQueryWrapper);
|
|
|
-
|
|
|
- // 返回跟进人名称
|
|
|
- for (String id : idList) {
|
|
|
- AdwebEnquiry adwebEnquiry = adwebEnquiryService.getById(id);
|
|
|
-
|
|
|
- adwebEnquiryService.specialSendEmail(adwebEnquiry, adwebSite);
|
|
|
- if (adwebEnquiry != null && StringUtils.isNotBlank(adwebEnquiry.getRecordId())) {
|
|
|
- adwebEnquiryService.returnSalesperson(
|
|
|
- code, adwebEnquiry.getRecordId(), user.getUsername());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 询盘中用户自定义的字段处理
|
|
|
+ if (StringUtils.isNotBlank(enquiry.getSpecialField())) {
|
|
|
+ List<EnquirySpecialFields> specialFieldsList =
|
|
|
+ FastJsonUtil.parseList(enquiry.getSpecialField(), EnquirySpecialFields.class);
|
|
|
+ enquiry.setSpecialFieldList(specialFieldsList);
|
|
|
+ enquiry.setSpecialField(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(enquiry.getContext())) {
|
|
|
+ String context = enquiry.getContext();
|
|
|
+ Pattern CRLF = Pattern.compile("(\r\n|\r|\n|\n\r)");
|
|
|
+ Matcher m = CRLF.matcher(context);
|
|
|
+ if (m.find()) {
|
|
|
+ context = m.replaceAll("<br/>");
|
|
|
}
|
|
|
- }
|
|
|
- return Result.OK();
|
|
|
- }
|
|
|
-
|
|
|
- /** 回收站列表接口 */
|
|
|
- @AutoLog(value = "adweb_enquiry-分页列表查询")
|
|
|
- @GetMapping(value = "/queryWasteEnquiryList")
|
|
|
- public Result<?> queryWasteEnquiryList(
|
|
|
- Integer siteId,
|
|
|
- String searchText,
|
|
|
- String enquiryType,
|
|
|
- @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
- @RequestParam(name = "pageSize", defaultValue = "1000") Integer pageSize) {
|
|
|
- if (sysAdwebApi.isNotOwnSite(siteId)) {
|
|
|
- return Result.OK(new Page<>());
|
|
|
- }
|
|
|
- LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
- Page<EnquirySearchDto> page = new Page<>(pageNo, pageSize);
|
|
|
- List<String> codeList = null;
|
|
|
- List<String> uidList = null;
|
|
|
-
|
|
|
- if (sysAdwebApi.isAdmin()) {
|
|
|
- } else if (sysAdwebApi.isChannelAdmin()) {
|
|
|
- uidList = sysAdwebApi.getChannelGroupUids();
|
|
|
- } else {
|
|
|
- uidList = new ArrayList<>();
|
|
|
- uidList.add(sysUser.getId());
|
|
|
- }
|
|
|
-
|
|
|
- List<String> siteCodeList = null;
|
|
|
- if (CollectionUtils.isNotEmpty(uidList)) {
|
|
|
- siteCodeList = siteUserPermissionService.getSiteCodeListByUids(uidList);
|
|
|
- }
|
|
|
+ enquiry.setContext(context);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加
|
|
|
+ *
|
|
|
+ * @param adwebEnquiry
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "询盘信息存储表单-添加")
|
|
|
+ @Operation(summary = "询盘信息存储表单-添加")
|
|
|
+ @PostMapping(value = "/add")
|
|
|
+ public Result<String> add(@RequestBody EnquiryForm enquiryForm) {
|
|
|
+ String defaultPlugin = "wpforms";
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(enquiryForm.getSiteCode())) {
|
|
|
+ return Result.error("当前未选择站点");
|
|
|
+ }
|
|
|
|
|
|
- codeList =
|
|
|
- adwebSiteService
|
|
|
- .list(
|
|
|
- new LambdaQueryWrapper<AdwebSite>()
|
|
|
- .eq(siteId != null, AdwebSite::getId, siteId)
|
|
|
- .in(
|
|
|
- !sysAdwebApi.isAdmin(),
|
|
|
- AdwebSite::getCode,
|
|
|
- siteCodeList)
|
|
|
- .ne(AdwebSite::getStatus, 0))
|
|
|
- .stream()
|
|
|
- .map(AdwebSite::getCode)
|
|
|
- .collect(Collectors.toList());
|
|
|
-
|
|
|
- String principalUid = null;
|
|
|
- if (sysAdwebApi.isAdwebSubVip()) {
|
|
|
- principalUid = sysUser.getId();
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(searchText)) {
|
|
|
- searchText = searchText.trim();
|
|
|
- }
|
|
|
- enquiryType = "(" + enquiryType + ")";
|
|
|
- IPage<EnquiryListDto> pageList =
|
|
|
- adwebEnquiryMapper.queryWasteEnquiryList(
|
|
|
- page,
|
|
|
- codeList,
|
|
|
- "",
|
|
|
- enquiryType,
|
|
|
- searchText,
|
|
|
- null,
|
|
|
- null,
|
|
|
- null,
|
|
|
- principalUid);
|
|
|
- if (CollectionUtils.isNotEmpty(pageList.getRecords())) {
|
|
|
- dealInfo(pageList.getRecords());
|
|
|
- return Result.OK(pageList);
|
|
|
- }
|
|
|
- dealInfo(pageList.getRecords());
|
|
|
- return Result.OK(pageList);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 批量复原
|
|
|
- *
|
|
|
- * @param adwebEnquiry
|
|
|
- * @return
|
|
|
- */
|
|
|
- @PutMapping(value = "/refreshBatch")
|
|
|
- public Result<?> refreshBatch(@RequestBody AdwebEnquiry adwebEnquiry) {
|
|
|
- LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
-
|
|
|
- LambdaUpdateWrapper<AdwebEnquiry> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- updateWrapper.in(AdwebEnquiry::getId, adwebEnquiry.getNo().split(","));
|
|
|
- updateWrapper.set(AdwebEnquiry::getStatus, 1);
|
|
|
- adwebEnquiryService.update(updateWrapper);
|
|
|
-
|
|
|
- return Result.OK("批量复原成功!");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 批量删除
|
|
|
- *
|
|
|
- * @param id 删除的询盘
|
|
|
- * @return
|
|
|
- */
|
|
|
- @GetMapping(value = "/delBatch")
|
|
|
- public Result<?> delBatch(@RequestParam("id") String id) {
|
|
|
-
|
|
|
- LambdaUpdateWrapper<AdwebEnquiry> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- updateWrapper.in(AdwebEnquiry::getId, id.split(","));
|
|
|
- updateWrapper.set(AdwebEnquiry::getStatus, 0);
|
|
|
- this.adwebEnquiryService.update(updateWrapper);
|
|
|
- return Result.OK("批量删除成功!");
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/getWastedEnquiry")
|
|
|
- public Result<List<EnquiryListDto>> getWastedEnquiry(
|
|
|
- EnquiryListSearchDto enquiryListSearchDto) {
|
|
|
-
|
|
|
- List<EnquiryListDto> wasterEnquiries =
|
|
|
- adwebEnquiryMapper.getWastedEnquiry(
|
|
|
- enquiryListSearchDto.getWasteEnquiryType(),
|
|
|
- enquiryListSearchDto.getIp(),
|
|
|
- enquiryListSearchDto.getEmail(),
|
|
|
- enquiryListSearchDto.getKeyword(),
|
|
|
- enquiryListSearchDto.getSearchText(),
|
|
|
- enquiryListSearchDto.getType(),
|
|
|
- enquiryListSearchDto.getSiteId());
|
|
|
-
|
|
|
- LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
-
|
|
|
- return Result.OK(wasterEnquiries);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据询盘信息创建邮件发送记录
|
|
|
- *
|
|
|
- * @param adwebEnquiry 询盘信息
|
|
|
- * @param email 接收邮箱
|
|
|
- * @return
|
|
|
- */
|
|
|
- private static EnquiryEmailMessage newEmail(AdwebEnquiry adwebEnquiry, String email) {
|
|
|
- EnquiryEmailMessage enquiryEmailMessage = new EnquiryEmailMessage();
|
|
|
- enquiryEmailMessage.setEnquiryId(adwebEnquiry.getId());
|
|
|
- enquiryEmailMessage.setEmail(email);
|
|
|
- enquiryEmailMessage.setFromEmail(adwebEnquiry.getFromEmail());
|
|
|
- enquiryEmailMessage.setCreateTime(new Date());
|
|
|
- enquiryEmailMessage.setSiteCode(adwebEnquiry.getSiteCode());
|
|
|
- enquiryEmailMessage.setSendStatus(EnquirySendStatus.WAIT_SEND);
|
|
|
- enquiryEmailMessage.setSendErrorNum(0);
|
|
|
-
|
|
|
- return enquiryEmailMessage;
|
|
|
+ QueryWrapper<AdwebSite> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper
|
|
|
+ .ne("status", 0)
|
|
|
+ .in("create_type", Arrays.asList("manual", "wp"))
|
|
|
+ .eq("code", enquiryForm.getSiteCode());
|
|
|
+
|
|
|
+ AdwebSite adwebSite = adwebSiteService.getOne(queryWrapper);
|
|
|
+
|
|
|
+ String maxRecordId =
|
|
|
+ adwebEnquiryMapper.getMaxRecordIdByCode(adwebSite.getCode(), defaultPlugin);
|
|
|
+ if (StringUtils.isEmpty(maxRecordId)) {
|
|
|
+ maxRecordId = "1";
|
|
|
+ } else {
|
|
|
+ maxRecordId = String.valueOf((int) Double.parseDouble(maxRecordId) + 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject formObject = generateFormJsonObject(enquiryForm, adwebSite);
|
|
|
+ EnquiryDTO enquiryDTO = new EnquiryDTO();
|
|
|
+ enquiryDTO.setForms(formObject);
|
|
|
+ enquiryDTO.setFromIp("");
|
|
|
+ enquiryDTO.setFromEmail(enquiryForm.getEmail());
|
|
|
+ enquiryDTO.setFromSource(enquiryForm.getFromSource());
|
|
|
+ enquiryDTO.setCountryCode(enquiryForm.getCountryCode());
|
|
|
+ enquiryDTO.setPluginName(defaultPlugin);
|
|
|
+ enquiryDTO.setSiteHost(adwebSite.getDomain().replace("https://", ""));
|
|
|
+ enquiryDTO.setRecordCtime(new Date());
|
|
|
+ enquiryDTO.setRecordId(maxRecordId);
|
|
|
+ // 推送询盘
|
|
|
+ adwebEnquiryService.addEnquiry(enquiryDTO, defaultPlugin, adwebSite);
|
|
|
+ return Result.OK("添加成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑
|
|
|
+ *
|
|
|
+ * @param adwebEnquiry
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "询盘信息存储表单-编辑")
|
|
|
+ @Operation(summary = "询盘信息存储表单-编辑")
|
|
|
+ @PreAuthorize("@jps.requiresPermissions('adweb:adweb_enquiry:edit')")
|
|
|
+ @RequestMapping(
|
|
|
+ value = "/edit",
|
|
|
+ method = {RequestMethod.PUT, RequestMethod.POST})
|
|
|
+ public Result<String> edit(@RequestBody AdwebEnquiry adwebEnquiry) {
|
|
|
+ adwebEnquiryService.updateById(adwebEnquiry);
|
|
|
+ return Result.OK("编辑成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id删除
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "询盘信息存储表单-通过id删除")
|
|
|
+ @Operation(summary = "询盘信息存储表单-通过id删除")
|
|
|
+ @PreAuthorize("@jps.requiresPermissions('adweb:adweb_enquiry:delete')")
|
|
|
+ @DeleteMapping(value = "/delete")
|
|
|
+ public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
|
|
+ adwebEnquiryService.removeById(id);
|
|
|
+ return Result.OK("删除成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "询盘信息存储表单-批量删除")
|
|
|
+ @Operation(summary = "询盘信息存储表单-批量删除")
|
|
|
+ @PreAuthorize("@jps.requiresPermissions('adweb:adweb_enquiry:deleteBatch')")
|
|
|
+ @DeleteMapping(value = "/deleteBatch")
|
|
|
+ public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
|
|
+ this.adwebEnquiryService.removeByIds(Arrays.asList(ids.split(",")));
|
|
|
+ return Result.OK("批量删除成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id查询
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ // @AutoLog(value = "询盘信息存储表单-通过id查询")
|
|
|
+ @Operation(summary = "询盘信息存储表单-通过id查询")
|
|
|
+ @GetMapping(value = "/queryById")
|
|
|
+ public Result<AdwebEnquiry> queryById(@RequestParam(name = "id", required = true) String id) {
|
|
|
+ AdwebEnquiry adwebEnquiry = adwebEnquiryService.getById(id);
|
|
|
+ if (adwebEnquiry == null) {
|
|
|
+ return Result.error("未找到对应数据");
|
|
|
}
|
|
|
+ return Result.OK(adwebEnquiry);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出excel
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param adwebEnquiry
|
|
|
+ */
|
|
|
+ @PreAuthorize("@jps.requiresPermissions('adweb:adweb_enquiry:exportXls')")
|
|
|
+ @RequestMapping(value = "/exportXls")
|
|
|
+ public ModelAndView exportXls(HttpServletRequest request, AdwebEnquiry adwebEnquiry) {
|
|
|
+ return super.exportXls(request, adwebEnquiry, AdwebEnquiry.class, "询盘信息存储表单");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过excel导入数据
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PreAuthorize("@jps.requiresPermissions('adweb:adweb_enquiry:importExcel')")
|
|
|
+ @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
+ public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ return super.importExcel(request, response, AdwebEnquiry.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 获取需要轮流询盘的站点code */
|
|
|
+ @GetMapping("/getTurnInquiryCode")
|
|
|
+ public Result<?> getTurnInquiryCode() {
|
|
|
+ List<DictPropertyModel> siteRes = sysAdwebApi.queryDictInfoByDictCode("turn_inquiry_site_code");
|
|
|
+ if (CollectionUtils.isNotEmpty(siteRes)) {
|
|
|
+ return Result.OK(siteRes);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/getEnquiryCatalog")
|
|
|
+ public Result<?> getEnquiryCatalog() {
|
|
|
+ List<DictPropertyModel> userEffectiveDict =
|
|
|
+ sysAdwebApi.queryDictInfoByDictCode(AdwebConstant.ENQUIRY_EFFECTIVE);
|
|
|
+ return Result.OK(FastJsonUtil.toJSONString(userEffectiveDict));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取不同状态询盘的数量
|
|
|
+ *
|
|
|
+ * @param siteId 站点id
|
|
|
+ * @return 数量信息
|
|
|
+ */
|
|
|
+ @GetMapping("getEnquiryNums")
|
|
|
+ public Result<?> getEnquiryNums(
|
|
|
+ Integer siteId,
|
|
|
+ String dateType,
|
|
|
+ @DateTimeFormat(pattern = "yyyy-MM-dd") Date start,
|
|
|
+ @DateTimeFormat(pattern = "yyyy-MM-dd") Date end) {
|
|
|
+ LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ if (StringUtils.isNotBlank(dateType)) {
|
|
|
+ Pair<Date, Date> dateRange = DateUtil.getDateRangeByType(dateType);
|
|
|
+ start = dateRange.getLeft();
|
|
|
+ end = dateRange.getRight();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Integer> siteIds = null;
|
|
|
+ if (siteId != null) {
|
|
|
+ String siteCode = adwebSiteService.getSiteCodeById(siteId);
|
|
|
+ LambdaQueryWrapper<AdwebSite> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper
|
|
|
+ .eq(AdwebSite::getCode, siteCode)
|
|
|
+ .or()
|
|
|
+ .eq(AdwebSite::getParentGroupCode, siteCode);
|
|
|
+ queryWrapper.ne(AdwebSite::getStatus, 0);
|
|
|
+ List<AdwebSite> sites = adwebSiteService.list(queryWrapper);
|
|
|
+ siteIds = sites.stream().map(AdwebSite::getId).collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ if (sysAdwebApi.isAdmin()) {
|
|
|
+ LambdaQueryWrapper<AdwebSite> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.ne(AdwebSite::getStatus, 0);
|
|
|
+ List<AdwebSite> sites = adwebSiteService.list(queryWrapper);
|
|
|
+ siteIds = sites.stream().map(AdwebSite::getId).collect(Collectors.toList());
|
|
|
+ } else if (sysAdwebApi.isChannelAdmin()) {
|
|
|
+ List<String> channelGroupUids = sysAdwebApi.getChannelGroupUids();
|
|
|
+ List<String> codeList = siteUserPermissionService.getSiteCodeListByUids(channelGroupUids);
|
|
|
+ LambdaQueryWrapper<AdwebSite> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(AdwebSite::getCode, codeList);
|
|
|
+ queryWrapper.ne(AdwebSite::getStatus, 0);
|
|
|
+ List<AdwebSite> sites = adwebSiteService.list(queryWrapper);
|
|
|
+ siteIds = sites.stream().map(AdwebSite::getId).collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ List<String> codeList = siteUserPermissionService.getSiteCodeList(loginUser.getId());
|
|
|
+ LambdaQueryWrapper<AdwebSite> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(AdwebSite::getCode, codeList);
|
|
|
+ queryWrapper.ne(AdwebSite::getStatus, 0);
|
|
|
+ List<AdwebSite> sites = adwebSiteService.list(queryWrapper);
|
|
|
+ siteIds = sites.stream().map(AdwebSite::getId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String principalUid = null;
|
|
|
+ if (sysAdwebApi.isAdwebSubVip()) {
|
|
|
+ principalUid = loginUser.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaQueryWrapper<AdwebEnquiry> enquiryQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ enquiryQueryWrapper.eq(AdwebEnquiry::getStatus, 1);
|
|
|
+ if (start != null) {
|
|
|
+ enquiryQueryWrapper.ge(AdwebEnquiry::getRecordCtime, start);
|
|
|
+ }
|
|
|
+ if (end != null) {
|
|
|
+ enquiryQueryWrapper.lt(AdwebEnquiry::getRecordCtime, DateUtil.addDays(end, 1));
|
|
|
+ }
|
|
|
+ if (siteIds != null) {
|
|
|
+ enquiryQueryWrapper.in(AdwebEnquiry::getSiteId, siteIds);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(principalUid)) {
|
|
|
+ String finalPrincipalUid = principalUid;
|
|
|
+ enquiryQueryWrapper.and(
|
|
|
+ wrapper ->
|
|
|
+ wrapper
|
|
|
+ .eq(AdwebEnquiry::getPrincipalUid, finalPrincipalUid)
|
|
|
+ .or()
|
|
|
+ .eq(AdwebEnquiry::getPrincipalUid, "ALL"));
|
|
|
+ }
|
|
|
+ enquiryQueryWrapper.ne(AdwebEnquiry::getUserEffective, 0);
|
|
|
+ int all = (int) adwebEnquiryService.count(enquiryQueryWrapper);
|
|
|
+
|
|
|
+ LambdaQueryWrapper<AdwebEnquiry> enquiryQueryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
+ enquiryQueryWrapper1.eq(AdwebEnquiry::getStatus, 1);
|
|
|
+ if (start != null) {
|
|
|
+ enquiryQueryWrapper1.ge(AdwebEnquiry::getRecordCtime, start);
|
|
|
+ }
|
|
|
+ if (end != null) {
|
|
|
+ enquiryQueryWrapper1.lt(AdwebEnquiry::getRecordCtime, DateUtil.addDays(end, 1));
|
|
|
+ }
|
|
|
+ if (siteIds != null) {
|
|
|
+ enquiryQueryWrapper1.in(AdwebEnquiry::getSiteId, siteIds);
|
|
|
+ }
|
|
|
+ enquiryQueryWrapper1.eq(AdwebEnquiry::getReadStatus, 0);
|
|
|
+ if (StringUtils.isNotBlank(principalUid)) {
|
|
|
+ String finalPrincipalUid = principalUid;
|
|
|
+ enquiryQueryWrapper1.and(
|
|
|
+ wrapper ->
|
|
|
+ wrapper
|
|
|
+ .eq(AdwebEnquiry::getPrincipalUid, finalPrincipalUid)
|
|
|
+ .or()
|
|
|
+ .eq(AdwebEnquiry::getPrincipalUid, "ALL"));
|
|
|
+ }
|
|
|
+ enquiryQueryWrapper1.ne(AdwebEnquiry::getUserEffective, 0);
|
|
|
+ int noRead = (int) adwebEnquiryService.count(enquiryQueryWrapper1);
|
|
|
+
|
|
|
+ LambdaQueryWrapper<AdwebEnquiry> enquiryQueryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
+ enquiryQueryWrapper2.eq(AdwebEnquiry::getStatus, 1);
|
|
|
+ if (start != null) {
|
|
|
+ enquiryQueryWrapper2.ge(AdwebEnquiry::getRecordCtime, start);
|
|
|
+ }
|
|
|
+ if (end != null) {
|
|
|
+ enquiryQueryWrapper2.lt(AdwebEnquiry::getRecordCtime, DateUtil.addDays(end, 1));
|
|
|
+ }
|
|
|
+ if (siteIds != null) {
|
|
|
+ enquiryQueryWrapper2.in(AdwebEnquiry::getSiteId, siteIds);
|
|
|
+ }
|
|
|
+ enquiryQueryWrapper2.eq(AdwebEnquiry::getUserEffective, 1);
|
|
|
+ if (StringUtils.isNotBlank(principalUid)) {
|
|
|
+ String finalPrincipalUid = principalUid;
|
|
|
+ enquiryQueryWrapper2.and(
|
|
|
+ wrapper ->
|
|
|
+ wrapper
|
|
|
+ .eq(AdwebEnquiry::getPrincipalUid, finalPrincipalUid)
|
|
|
+ .or()
|
|
|
+ .eq(AdwebEnquiry::getPrincipalUid, "ALL"));
|
|
|
+ }
|
|
|
+ enquiryQueryWrapper2.ne(AdwebEnquiry::getUserEffective, 0);
|
|
|
+ int product = (int) adwebEnquiryService.count(enquiryQueryWrapper2);
|
|
|
+
|
|
|
+ LambdaQueryWrapper<AdwebEnquiry> enquiryQueryWrapper3 = new LambdaQueryWrapper<>();
|
|
|
+ enquiryQueryWrapper3.eq(AdwebEnquiry::getStatus, 1);
|
|
|
+ if (start != null) {
|
|
|
+ enquiryQueryWrapper3.ge(AdwebEnquiry::getRecordCtime, start);
|
|
|
+ }
|
|
|
+ if (end != null) {
|
|
|
+ enquiryQueryWrapper3.lt(AdwebEnquiry::getRecordCtime, DateUtil.addDays(end, 1));
|
|
|
+ }
|
|
|
+ if (siteIds != null) {
|
|
|
+ enquiryQueryWrapper3.in(AdwebEnquiry::getSiteId, siteIds);
|
|
|
+ }
|
|
|
+ enquiryQueryWrapper3.eq(AdwebEnquiry::getUserEffective, 2);
|
|
|
+ if (StringUtils.isNotBlank(principalUid)) {
|
|
|
+ String finalPrincipalUid = principalUid;
|
|
|
+ enquiryQueryWrapper3.and(
|
|
|
+ wrapper ->
|
|
|
+ wrapper
|
|
|
+ .eq(AdwebEnquiry::getPrincipalUid, finalPrincipalUid)
|
|
|
+ .or()
|
|
|
+ .eq(AdwebEnquiry::getPrincipalUid, "ALL"));
|
|
|
+ }
|
|
|
+ enquiryQueryWrapper3.ne(AdwebEnquiry::getUserEffective, 0);
|
|
|
+ int wait = (int) adwebEnquiryService.count(enquiryQueryWrapper3);
|
|
|
+
|
|
|
+ Map<String, Integer> map = new HashMap<>();
|
|
|
+ map.put("all", all);
|
|
|
+ map.put("noRead", noRead);
|
|
|
+ map.put("product", product);
|
|
|
+ map.put("wait", wait);
|
|
|
+
|
|
|
+ return Result.OK(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将询盘的状态改为已读
|
|
|
+ *
|
|
|
+ * @param id 询盘id
|
|
|
+ * @return 处理结果
|
|
|
+ */
|
|
|
+ @GetMapping("/read")
|
|
|
+ public Result<?> read(@Param("id") String id) {
|
|
|
+ if (disableAdminRead && (sysAdwebApi.isAdmin() || sysAdwebApi.isChannelAdmin())) {
|
|
|
+ return Result.OK();
|
|
|
+ }
|
|
|
+ LambdaUpdateWrapper<AdwebEnquiry> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.in(AdwebEnquiry::getId, id);
|
|
|
+ updateWrapper.set(AdwebEnquiry::getReadStatus, 1);
|
|
|
+ adwebEnquiryService.update(updateWrapper);
|
|
|
+ return Result.OK();
|
|
|
+ }
|
|
|
+
|
|
|
+ @AutoLog(value = "编辑询盘的负责人")
|
|
|
+ @GetMapping(value = "/setPrincipal")
|
|
|
+ public Result<?> setPrincipal(@RequestParam String productId, @RequestParam String uid) {
|
|
|
+
|
|
|
+ UpdateWrapper<AdwebEnquiry> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.eq("id", productId);
|
|
|
+ updateWrapper.set("principal_uid", uid);
|
|
|
+ updateWrapper.set("principal_type", 1);
|
|
|
+ adwebEnquiryService.update(updateWrapper);
|
|
|
+
|
|
|
+ AdwebEnquiry adwebEnquiry = adwebEnquiryService.getById(productId);
|
|
|
+ if (adwebEnquiry.getUserEffective() != 0) {
|
|
|
+ // 添加负责人发送询盘邮件并发送
|
|
|
+ Result<?> result = enquiryEmailMessageService.addAndEnquiryEmailMsg(adwebEnquiry, uid);
|
|
|
+ if (!result.isSuccess()) {
|
|
|
+ log.error("询盘邮件存入或发送失败,原因:负责人可能没有邮箱!");
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ return Result.OK();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param query
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/enquiryTrans", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public Result<String> getEnquiryTrans(String query, String id) {
|
|
|
+ String text = awsTranslateUtils.translate(query);
|
|
|
+ LambdaUpdateWrapper<AdwebEnquiry> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.eq(AdwebEnquiry::getId, id);
|
|
|
+ updateWrapper.set(AdwebEnquiry::getTransContent, text);
|
|
|
+ adwebEnquiryService.update(updateWrapper);
|
|
|
+
|
|
|
+ return Result.ok(text);
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 更改询盘用户有效性 */
|
|
|
+ @PostMapping("/update/user/effective")
|
|
|
+ public Result<?> updateUserEffective(EffectiveEnquiryParamDto effectiveEnquiryParamDto) {
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+
|
|
|
+ boolean res = adwebEnquiryService.updateUserEffective(effectiveEnquiryParamDto);
|
|
|
+ if (res) {
|
|
|
+ return Result.OK("ok");
|
|
|
+ }
|
|
|
+ return Result.error("fail");
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 转发询盘 */
|
|
|
+ @AutoLog(value = "转发询盘")
|
|
|
+ @GetMapping(value = "/setForward")
|
|
|
+ public Result<?> setForward(
|
|
|
+ @RequestParam String ids, @RequestParam String uid, @RequestParam String code) {
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+
|
|
|
+ SysUser user = sysUserService.getById(uid);
|
|
|
+ if (StringUtils.isEmpty(user.getEmail())) {
|
|
|
+ return Result.error("该账户未设置邮箱!");
|
|
|
+ }
|
|
|
+ List<String> idList = Arrays.asList(ids.split(","));
|
|
|
+ LambdaUpdateWrapper<AdwebEnquiry> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.in(AdwebEnquiry::getId, idList);
|
|
|
+ updateWrapper.set(AdwebEnquiry::getPrincipalUid, uid);
|
|
|
+ updateWrapper.set(AdwebEnquiry::getPrincipalType, 1);
|
|
|
+ adwebEnquiryService.update(updateWrapper);
|
|
|
+
|
|
|
+ LambdaQueryWrapper<AdwebEnquiry> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(AdwebEnquiry::getId, idList);
|
|
|
+ List<AdwebEnquiry> list = adwebEnquiryService.list(queryWrapper);
|
|
|
+ // 获取站点
|
|
|
+ LambdaQueryWrapper<AdwebSite> adwebSiteQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ adwebSiteQueryWrapper.eq(AdwebSite::getCode, code);
|
|
|
+ AdwebSite adwebSite = adwebSiteService.getOne(adwebSiteQueryWrapper);
|
|
|
+
|
|
|
+ // 返回跟进人名称
|
|
|
+ for (String id : idList) {
|
|
|
+ AdwebEnquiry adwebEnquiry = adwebEnquiryService.getById(id);
|
|
|
+
|
|
|
+ adwebEnquiryService.specialSendEmail(adwebEnquiry, adwebSite);
|
|
|
+ if (adwebEnquiry != null && StringUtils.isNotBlank(adwebEnquiry.getRecordId())) {
|
|
|
+ adwebEnquiryService.returnSalesperson(code, adwebEnquiry.getRecordId(), user.getUsername());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Result.OK();
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 回收站列表接口 */
|
|
|
+ @AutoLog(value = "adweb_enquiry-分页列表查询")
|
|
|
+ @GetMapping(value = "/queryWasteEnquiryList")
|
|
|
+ public Result<?> queryWasteEnquiryList(
|
|
|
+ Integer siteId,
|
|
|
+ String searchText,
|
|
|
+ String enquiryType,
|
|
|
+ @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
+ @RequestParam(name = "pageSize", defaultValue = "1000") Integer pageSize) {
|
|
|
+ if (sysAdwebApi.isNotOwnSite(siteId)) {
|
|
|
+ return Result.OK(new Page<>());
|
|
|
+ }
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ Page<EnquirySearchDto> page = new Page<>(pageNo, pageSize);
|
|
|
+ List<String> codeList = null;
|
|
|
+ List<String> uidList = null;
|
|
|
+
|
|
|
+ if (sysAdwebApi.isAdmin()) {
|
|
|
+ } else if (sysAdwebApi.isChannelAdmin()) {
|
|
|
+ uidList = sysAdwebApi.getChannelGroupUids();
|
|
|
+ } else {
|
|
|
+ uidList = new ArrayList<>();
|
|
|
+ uidList.add(sysUser.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> siteCodeList = null;
|
|
|
+ if (CollectionUtils.isNotEmpty(uidList)) {
|
|
|
+ siteCodeList = siteUserPermissionService.getSiteCodeListByUids(uidList);
|
|
|
+ }
|
|
|
+
|
|
|
+ codeList =
|
|
|
+ adwebSiteService
|
|
|
+ .list(
|
|
|
+ new LambdaQueryWrapper<AdwebSite>()
|
|
|
+ .eq(siteId != null, AdwebSite::getId, siteId)
|
|
|
+ .in(!sysAdwebApi.isAdmin(), AdwebSite::getCode, siteCodeList)
|
|
|
+ .ne(AdwebSite::getStatus, 0))
|
|
|
+ .stream()
|
|
|
+ .map(AdwebSite::getCode)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ String principalUid = null;
|
|
|
+ if (sysAdwebApi.isAdwebSubVip()) {
|
|
|
+ principalUid = sysUser.getId();
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(searchText)) {
|
|
|
+ searchText = searchText.trim();
|
|
|
+ }
|
|
|
+ enquiryType = "(" + enquiryType + ")";
|
|
|
+ IPage<EnquiryListDto> pageList =
|
|
|
+ adwebEnquiryMapper.queryWasteEnquiryList(
|
|
|
+ page, codeList, "", enquiryType, searchText, null, null, null, principalUid);
|
|
|
+ if (CollectionUtils.isNotEmpty(pageList.getRecords())) {
|
|
|
+ dealInfo(pageList.getRecords());
|
|
|
+ return Result.OK(pageList);
|
|
|
+ }
|
|
|
+ dealInfo(pageList.getRecords());
|
|
|
+ return Result.OK(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量复原
|
|
|
+ *
|
|
|
+ * @param adwebEnquiry
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PutMapping(value = "/refreshBatch")
|
|
|
+ public Result<?> refreshBatch(@RequestBody AdwebEnquiry adwebEnquiry) {
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+
|
|
|
+ LambdaUpdateWrapper<AdwebEnquiry> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.in(AdwebEnquiry::getId, adwebEnquiry.getNo().split(","));
|
|
|
+ updateWrapper.set(AdwebEnquiry::getStatus, 1);
|
|
|
+ adwebEnquiryService.update(updateWrapper);
|
|
|
+
|
|
|
+ return Result.OK("批量复原成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除
|
|
|
+ *
|
|
|
+ * @param id 删除的询盘
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/delBatch")
|
|
|
+ public Result<?> delBatch(@RequestParam("id") String id) {
|
|
|
+
|
|
|
+ LambdaUpdateWrapper<AdwebEnquiry> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.in(AdwebEnquiry::getId, id.split(","));
|
|
|
+ updateWrapper.set(AdwebEnquiry::getStatus, 0);
|
|
|
+ this.adwebEnquiryService.update(updateWrapper);
|
|
|
+ return Result.OK("批量删除成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/getWastedEnquiry")
|
|
|
+ public Result<List<EnquiryListDto>> getWastedEnquiry(EnquiryListSearchDto enquiryListSearchDto) {
|
|
|
+
|
|
|
+ List<EnquiryListDto> wasterEnquiries =
|
|
|
+ adwebEnquiryMapper.getWastedEnquiry(
|
|
|
+ enquiryListSearchDto.getWasteEnquiryType(),
|
|
|
+ enquiryListSearchDto.getIp(),
|
|
|
+ enquiryListSearchDto.getEmail(),
|
|
|
+ enquiryListSearchDto.getKeyword(),
|
|
|
+ enquiryListSearchDto.getSearchText(),
|
|
|
+ enquiryListSearchDto.getType(),
|
|
|
+ enquiryListSearchDto.getSiteId());
|
|
|
+
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+
|
|
|
+ return Result.OK(wasterEnquiries);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 本地开发环境测试询盘同步,从远程站点拉取询盘到开发数据库
|
|
|
+ @IgnoreAuth
|
|
|
+ @GetMapping("local_test_enquiryNotify")
|
|
|
+ public Result<?> enquiryNotifyss(
|
|
|
+ @RequestParam(name = "siteCodeJobParam", required = false) String siteCodeJobParam,
|
|
|
+ @RequestParam(name = "siteRecodeId", required = false) String siteRecodeId) {
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(siteCodeJobParam)) {
|
|
|
+ return Result.error("请输入站点code");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(siteRecodeId)) {
|
|
|
+ return Result.error("站点询盘记录ID");
|
|
|
+ }
|
|
|
+
|
|
|
+ QueryWrapper<AdwebSite> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper
|
|
|
+ .ne("status", 0)
|
|
|
+ .in("create_type", Arrays.asList("manual", "wp"))
|
|
|
+ .eq("code", siteCodeJobParam);
|
|
|
+
|
|
|
+ List<AdwebSite> siteList = adwebSiteService.list(queryWrapper);
|
|
|
+
|
|
|
+ if (siteList.isEmpty()) {
|
|
|
+ return Result.error("当前站点不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ String jsonString =
|
|
|
+ "{\"1\":{\"name\":\"Name\",\"value\":\"chen peiqing\",\"id\":1,\"type\":\"text\"},\"2\":{\"name\":\"Email\",\"value\":\"chenpeiqing.1393599253@live.com\",\"id\":2,\"type\":\"email\"},\"3\":{\"name\":\"Phone\",\"value\":\"13223012703\",\"id\":3,\"type\":\"phone\"},\"4\":{\"name\":\"Message\",\"value\":\"tets\",\"id\":4,\"type\":\"textarea\"},\"5\":{\"name\":\"Customer IP\",\"value\":\"::1\",\"id\":5,\"type\":\"hidden\"},\"6\":{\"name\":\"From Page\",\"value\":\"http:\\/\\/wp063.cpq\\/products\\/occupancy-product-3\\/\",\"id\":6,\"type\":\"hidden\"}}";
|
|
|
+
|
|
|
+ JSONObject object = FastJsonUtil.parseObject(jsonString, JSONObject.class);
|
|
|
+ EnquiryDTO adwebEnquiry = new EnquiryDTO();
|
|
|
+ adwebEnquiry.setForms(object);
|
|
|
+ adwebEnquiry.setFromEmail("chenpeiqing.1393599253@dfd.com");
|
|
|
+ adwebEnquiry.setFromIp("107.182.184.127");
|
|
|
+ adwebEnquiry.setPluginName("wpforms");
|
|
|
+ adwebEnquiry.setSiteHost("20250219i96eui.v3-site.adwebcloud.com");
|
|
|
+ adwebEnquiry.setRecordCtime(new Date("Tue Feb 25 03:31:37 UTC 2025"));
|
|
|
+ adwebEnquiry.setRecordId(siteRecodeId);
|
|
|
+ // 模拟mq推送询盘
|
|
|
+ adwebEnquiryService.addEnquiry(adwebEnquiry, adwebEnquiry.getPluginName(), siteList.get(0));
|
|
|
+
|
|
|
+ return Result.OK(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据询盘信息创建邮件发送记录
|
|
|
+ *
|
|
|
+ * @param adwebEnquiry 询盘信息
|
|
|
+ * @param email 接收邮箱
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private static EnquiryEmailMessage newEmail(AdwebEnquiry adwebEnquiry, String email) {
|
|
|
+ EnquiryEmailMessage enquiryEmailMessage = new EnquiryEmailMessage();
|
|
|
+ enquiryEmailMessage.setEnquiryId(adwebEnquiry.getId());
|
|
|
+ enquiryEmailMessage.setEmail(email);
|
|
|
+ enquiryEmailMessage.setFromEmail(adwebEnquiry.getFromEmail());
|
|
|
+ enquiryEmailMessage.setCreateTime(new Date());
|
|
|
+ enquiryEmailMessage.setSiteCode(adwebEnquiry.getSiteCode());
|
|
|
+ enquiryEmailMessage.setSendStatus(EnquirySendStatus.WAIT_SEND);
|
|
|
+ enquiryEmailMessage.setSendErrorNum(0);
|
|
|
+
|
|
|
+ return enquiryEmailMessage;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static JSONObject generateFormJsonObject(EnquiryForm adwebEnquiry, AdwebSite adwebSite) {
|
|
|
+ // 创建外层json
|
|
|
+ JSONObject outObject = new JSONObject();
|
|
|
+
|
|
|
+ // 创建内容json
|
|
|
+ JSONObject object1 = new JSONObject();
|
|
|
+ object1.put("name", "Name");
|
|
|
+ object1.put("value", adwebEnquiry.getName());
|
|
|
+ object1.put("id", "1");
|
|
|
+ object1.put("type", "text");
|
|
|
+ outObject.put("1", object1);
|
|
|
+
|
|
|
+ JSONObject object2 = new JSONObject();
|
|
|
+ object2.put("name", "Email");
|
|
|
+ object2.put("value", adwebEnquiry.getEmail());
|
|
|
+ object2.put("id", "2");
|
|
|
+ object2.put("type", "email");
|
|
|
+ outObject.put("2", object2);
|
|
|
+
|
|
|
+ JSONObject object3 = new JSONObject();
|
|
|
+ object3.put("name", "Phone");
|
|
|
+ object3.put("value", adwebEnquiry.getPhone());
|
|
|
+ object3.put("id", "3");
|
|
|
+ object3.put("type", "phone");
|
|
|
+ outObject.put("3", object3);
|
|
|
+
|
|
|
+ JSONObject object4 = new JSONObject();
|
|
|
+ object4.put("name", "Message");
|
|
|
+ object4.put("value", adwebEnquiry.getMessage());
|
|
|
+ object4.put("id", "4");
|
|
|
+ object4.put("type", "textarea");
|
|
|
+ outObject.put("4", object4);
|
|
|
+
|
|
|
+ JSONObject object5 = new JSONObject();
|
|
|
+ object5.put("name", "Customer IP");
|
|
|
+ object5.put("value", "::1");
|
|
|
+ object5.put("id", "5");
|
|
|
+ object5.put("type", "hidden");
|
|
|
+ outObject.put("5", object5);
|
|
|
+
|
|
|
+ JSONObject object6 = new JSONObject();
|
|
|
+ object6.put("name", "From Page");
|
|
|
+ object6.put("value", adwebSite.getDomain());
|
|
|
+ object6.put("id", "6");
|
|
|
+ object6.put("type", "hidden");
|
|
|
+ outObject.put("6", object6);
|
|
|
+
|
|
|
+ return outObject;
|
|
|
+ }
|
|
|
}
|