|
@@ -0,0 +1,118 @@
|
|
|
|
+package com.caimei365.user.service.impl;
|
|
|
|
+
|
|
|
|
+import com.caimei365.user.mapper.RoosInformationMapper;
|
|
|
|
+import com.caimei365.user.model.dto.RoosInformationDto;
|
|
|
|
+import com.caimei365.user.service.RoosInformationService;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
|
+import org.springframework.web.context.request.RequestAttributes;
|
|
|
|
+import org.springframework.web.context.request.RequestContextHolder;
|
|
|
|
+import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
+
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Description
|
|
|
|
+ *
|
|
|
|
+ * @author : Charles
|
|
|
|
+ * @date : 2022/12/9
|
|
|
|
+ */
|
|
|
|
+@Slf4j
|
|
|
|
+@Service
|
|
|
|
+public class RoosInformationServiceImpl implements RoosInformationService {
|
|
|
|
+
|
|
|
|
+ @Autowired private RoosInformationMapper roosInformationMapper;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查看用户是否有过弹框,游客当天是否有过弹框
|
|
|
|
+ *
|
|
|
|
+ * @param IP
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public Boolean boolIsClick(String IP) {
|
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ String format = simpleDateFormat.format(new Date());
|
|
|
|
+ List<Integer> list = roosInformationMapper.selIsClick(IP, format);
|
|
|
|
+ boolean isClick = false;
|
|
|
|
+ // 判断是否点击过取消、或者填写过信息
|
|
|
|
+ for (Integer i: list) {
|
|
|
|
+ if (i == 1) {
|
|
|
|
+ isClick = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return isClick;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 插入填写咨询人基本信息
|
|
|
|
+ *
|
|
|
|
+ * @param roosInformationDto
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void insRoosInformation(RoosInformationDto roosInformationDto) {
|
|
|
|
+ // 设置创建时间
|
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ String format = simpleDateFormat.format(new Date());
|
|
|
|
+ roosInformationDto.setCreateTime(format);
|
|
|
|
+ roosInformationMapper.insRoosInformation(roosInformationDto);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查看访问者是否浏览过roos相关页面
|
|
|
|
+ *
|
|
|
|
+ * @param userID
|
|
|
|
+ * @param IP
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public Boolean selectVisitRoos(String userID , String IP) {
|
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ String format = simpleDateFormat.format(new Date());
|
|
|
|
+ boolean isVisit = false;
|
|
|
|
+ List<String> list = roosInformationMapper.visitRoos(userID, IP, format);
|
|
|
|
+ for (String str: list) {
|
|
|
|
+ if (str.equals("2")) {
|
|
|
|
+ isVisit = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return isVisit;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取用户访问IP
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String obtainIp() {
|
|
|
|
+ RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
|
|
|
|
+ ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) requestAttributes;
|
|
|
|
+ HttpServletRequest request = servletRequestAttributes.getRequest();
|
|
|
|
+ // ip
|
|
|
|
+ String unknown = "unknown";
|
|
|
|
+ String ip = "";
|
|
|
|
+ ip = request.getHeader("x-forwarded-for");
|
|
|
|
+ if (org.apache.commons.lang.StringUtils.isBlank(ip)) {
|
|
|
|
+ ip = request.getHeader("X-Real-IP");
|
|
|
|
+ }
|
|
|
|
+ if (ip == null || ip.length() == 0 || unknown.equalsIgnoreCase(ip)) {
|
|
|
|
+ ip = request.getHeader("Proxy-Client-IP");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (ip == null || ip.length() == 0 || unknown.equalsIgnoreCase(ip)) {
|
|
|
|
+ ip = request.getHeader("WL-Proxy-Client-IP");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (ip == null || ip.length() == 0 || unknown.equalsIgnoreCase(ip)) {
|
|
|
|
+ ip = request.getRemoteAddr();
|
|
|
|
+ }
|
|
|
|
+ log.info("获取访问人ip==========="+ip);
|
|
|
|
+ return ip;
|
|
|
|
+ }
|
|
|
|
+}
|