|
@@ -37,6 +37,7 @@ 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;
|
|
@@ -277,10 +278,43 @@ public class AdwebEnquiryController extends JeecgController<AdwebEnquiry, IAdweb
|
|
|
*/
|
|
|
@AutoLog(value = "询盘信息存储表单-添加")
|
|
|
@Operation(summary = "询盘信息存储表单-添加")
|
|
|
- @PreAuthorize("@jps.requiresPermissions('adweb:adweb_enquiry:add')")
|
|
|
@PostMapping(value = "/add")
|
|
|
- public Result<String> add(@RequestBody AdwebEnquiry adwebEnquiry) {
|
|
|
- adwebEnquiryService.save(adwebEnquiry);
|
|
|
+ public Result<String> add(@RequestBody EnquiryForm enquiryForm) {
|
|
|
+ String defaultPlugin = "wpforms";
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(enquiryForm.getSiteCode())) {
|
|
|
+ return Result.error("当前未选择站点");
|
|
|
+ }
|
|
|
+
|
|
|
+ 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("添加成功!");
|
|
|
}
|
|
|
|
|
@@ -839,4 +873,54 @@ public class AdwebEnquiryController extends JeecgController<AdwebEnquiry, IAdweb
|
|
|
|
|
|
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;
|
|
|
+ }
|
|
|
}
|