Jelajahi Sumber

内容库V1.0.0

kaick 1 tahun lalu
induk
melakukan
faa82bfdc1

+ 5 - 4
src/main/java/com/caimei365/user/controller/CmBehaviorRecordApi.java

@@ -2,9 +2,10 @@ package com.caimei365.user.controller;
 
 import com.caimei365.user.idempotent.IpSave;
 import com.caimei365.user.model.ResponseJson;
-import com.caimei365.user.model.dto.BehaviorRecordDto;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
@@ -35,7 +36,7 @@ public class CmBehaviorRecordApi {
      */
     @IpSave(saveName = "用户行为记录", saveParams = true)
     @GetMapping("/Statistics")
-    public ResponseJson<String> behaviorRecordApp(HttpServletRequest request, Integer userId, String pagePath, String pageType, String pageLabel, String behaviorType, Integer productId, String accessDuration, Integer accessClient, Integer shopId, String openId) {
+    public ResponseJson<String> behaviorRecordApp(HttpServletRequest request, Integer userId, String pagePath, String pageType, String pageLabel, String behaviorType, Integer productId, String accessDuration, Integer accessClient, Integer shopId, String headUserId, String productArchiveId, String openId) {
         HttpSession session = request.getSession();
         Cookie[] cookies = request.getCookies();
         if (null != cookies) {
@@ -46,7 +47,7 @@ public class CmBehaviorRecordApi {
             }
         }
         String touristId = (String) session.getAttribute("touristId");
-        log.info("用户行为记录=======userId==》" + userId + "==pagePath==" + pagePath + "==pageType==" + pageType + "==pageLabel==" + pageLabel + "==behaviorType==" + behaviorType + "==productId==" + productId + "==accessDuration==" + accessDuration + "==accessClient==" + accessClient + "==shopId==" + shopId + "==openId=="+openId);
+        log.info("用户行为记录=======userId==》" + userId + "==pagePath==" + pagePath + "==pageType==" + pageType + "==pageLabel==" + pageLabel + "==behaviorType==" + behaviorType + "==productId==" + productId + "==accessDuration==" + accessDuration + "==accessClient==" + accessClient + "==shopId==" + shopId + "==headUserId=="+headUserId+ "==productArchiveId=="+productArchiveId+ "==openId=="+openId);
         return ResponseJson.success("用户行为记录完成");
     }
 

+ 2 - 1
src/main/java/com/caimei365/user/controller/LoginApi.java

@@ -141,7 +141,8 @@ public class LoginApi {
         String mobile = loginPasswordDto.getMobileOrEmail();
         String password = loginPasswordDto.getPassword();
         String unionId = loginPasswordDto.getUnionId();
-        return sellerService.passwordLogin(mobile, password, unionId);
+        Integer isUnion = loginPasswordDto.getIsUnion();
+        return sellerService.passwordLogin(mobile, password, unionId, isUnion);
     }
 
 

+ 6 - 8
src/main/java/com/caimei365/user/controller/SellerApi.java

@@ -6,7 +6,6 @@ import com.caimei365.user.model.dto.OnlineDto;
 import com.caimei365.user.model.po.ServiceProviderPo;
 import com.caimei365.user.model.vo.*;
 import com.caimei365.user.service.SellerService;
-import com.caimei365.user.utils.MathUtil;
 import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -16,9 +15,6 @@ import lombok.RequiredArgsConstructor;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -241,20 +237,22 @@ public class SellerApi {
                 .setQrCode(serviceProviderPo.getQrCode()));
 
     }
+
     /**
      * 机构访问列表
      */
     @GetMapping("/getBehaviorRecordClub")
-    public ResponseJson<List<CmBehaviorRecordVo>> getBehaviorRecordClub(Integer spId, String accDateTime) {
-        return sellerService.getBehaviorRecordClub( spId, accDateTime);
+    public ResponseJson<List<CmBehaviorRecordVo>> getBehaviorRecordClub(Integer type, Integer spId, String accDateTime) {
+        return sellerService.getBehaviorRecordClub(type, spId, accDateTime);
 
     }
+
     /**
      * 机构访问详情
      */
     @GetMapping("/getBehaviorRecordClubFrom")
-    public ResponseJson<List<CmBehaviorRecordVo>> getBehaviorRecordClubFrom(Integer spId,Integer clubId,String accessTime) {
-        return sellerService.getBehaviorRecordClubFrom(spId,clubId, accessTime);
+    public ResponseJson<List<CmBehaviorRecordVo>> getBehaviorRecordClubFrom(Integer type, Integer spId, Integer clubId, String accessTime) {
+        return sellerService.getBehaviorRecordClubFrom(type, spId, clubId, accessTime);
     }
 
     /**

+ 4 - 0
src/main/java/com/caimei365/user/mapper/SellerMapper.java

@@ -147,11 +147,15 @@ public interface SellerMapper {
     List<ServiceProviderVo> findAllServices(@Param("spId")Integer spId,@Param("status")Integer status);
 
     String getBehaviorRecordYesterdayPageLabel(@Param("spId") Integer spId,@Param("clubId") Integer clubId,@Param("accessTime")String accessTime);
+    String getBehaviorRecordMinutePageLabel(@Param("spId") Integer spId,@Param("clubId") Integer clubId,@Param("accessTime")String accessTime);
 
     List<CmBehaviorRecordVo> getBehaviorRecordYesterdayClubFrom(@Param("spId") Integer spId, @Param("clubId") Integer clubId, @Param("accessTime")String accessTime);
+    List<CmBehaviorRecordVo> getBehaviorRecordMinuteClubFrom(@Param("spId") Integer spId, @Param("clubId") Integer clubId, @Param("accessTime")String accessTime);
 
     List<CmBehaviorRecordVo> getBehaviorRecordYesterdayClub(@Param("spId") Integer spId,@Param("accessTime")String accessTime);
 
+    List<CmBehaviorRecordVo> getBehaviorRecordMinuteClub(@Param("spId") Integer spId,@Param("accessTime")String accessTime);
+
     /**
      * 获取机构有访问记录的日期
      * @param clubId

+ 4 - 0
src/main/java/com/caimei365/user/model/dto/LoginPasswordDto.java

@@ -35,6 +35,10 @@ public class LoginPasswordDto implements Serializable {
      */
     @ApiModelProperty("微信unionId")
     private String unionId;
+    /**
+     * 是否需要unionId
+     */
+    private Integer isUnion;
     /**
      * 游客id
      */

+ 3 - 3
src/main/java/com/caimei365/user/service/SellerService.java

@@ -76,7 +76,7 @@ public interface SellerService {
      * @param unionId  微信unionId
      * @return UserLoginVo
      */
-    ResponseJson<UserLoginVo> passwordLogin(String mobile, String password, String unionId);
+    ResponseJson<UserLoginVo> passwordLogin(String mobile, String password, String unionId,Integer isUnion);
 
     /**
      * 采购员验证码登录 --组织
@@ -134,8 +134,8 @@ public interface SellerService {
 
     ResponseJson setSellerHome(ServiceProviderPo serviceProviderPo);
 
-    ResponseJson<List<CmBehaviorRecordVo>> getBehaviorRecordClub(Integer spId,String accessTime);
-    ResponseJson<List<CmBehaviorRecordVo>> getBehaviorRecordClubFrom(Integer spId, Integer clubId, String accessTime);
+    ResponseJson<List<CmBehaviorRecordVo>> getBehaviorRecordClub(Integer type,Integer spId,String accessTime);
+    ResponseJson<List<CmBehaviorRecordVo>> getBehaviorRecordClubFrom(Integer type,Integer spId, Integer clubId, String accessTime);
 
     ResponseJson<List<ServiceProviderVo>> getServiceTeam(Integer spId,Integer status);
 

+ 23 - 32
src/main/java/com/caimei365/user/service/impl/SellerServiceImpl.java

@@ -4,7 +4,6 @@ import com.caimei365.user.components.RedisService;
 import com.caimei365.user.components.WeChatService;
 import com.caimei365.user.mapper.*;
 import com.caimei365.user.model.ResponseJson;
-import com.caimei365.user.model.dto.ArrDateDto;
 import com.caimei365.user.model.dto.ClubTemporaryDto;
 import com.caimei365.user.model.dto.LoginCodeDto;
 import com.caimei365.user.model.po.ServiceProviderPo;
@@ -17,7 +16,6 @@ import com.caimei365.user.utils.MathUtil;
 import com.caimei365.user.utils.Md5Util;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
-import io.swagger.models.auth.In;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang3.ObjectUtils;
@@ -25,12 +23,8 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.time.LocalDate;
-import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -346,11 +340,11 @@ public class SellerServiceImpl implements SellerService {
      * @return UserLoginVo
      */
     @Override
-    public ResponseJson<UserLoginVo> passwordLogin(String mobile, String password, String unionId) {
+    public ResponseJson<UserLoginVo> passwordLogin(String mobile, String password, String unionId, Integer isUnion) {
         if (StringUtils.isBlank(mobile) || StringUtils.isBlank(password)) {
             return ResponseJson.error("请输入账号密码", null);
         }
-        if (StringUtils.isBlank(unionId)) {
+        if (StringUtils.isBlank(unionId) && isUnion == null) {
             return ResponseJson.error("请输入微信unionId", null);
         }
         UserLoginVo seller = sellerMapper.getLoginSellerByMobile(mobile);
@@ -362,10 +356,12 @@ public class SellerServiceImpl implements SellerService {
         // 为了过期续签,将token存入redis,并设置超时时间
         redisService.set(token, token, JwtUtil.getExpireTime());
         seller.setToken(token);
-        Map<Object, Object> infoData = redisService.getEntries("wxInfo:applets:" + unionId);
-        String openId = (String) infoData.get(WeChatService.Keys.OPEN_ID);
-        sellerMapper.updateServiceProviderByUserId(seller.getUserId(), openId, unionId);
-        log.info("协销账号密码登录openid>>>>" + openId + " ,unionId>>>>>" + unionId);
+        if (isUnion == null) {
+            Map<Object, Object> infoData = redisService.getEntries("wxInfo:applets:" + unionId);
+            String openId = (String) infoData.get(WeChatService.Keys.OPEN_ID);
+            sellerMapper.updateServiceProviderByUserId(seller.getUserId(), openId, unionId);
+            log.info("协销账号密码登录openid>>>>" + openId + " ,unionId>>>>>" + unionId);
+        }
         seller.setManager(sellerMapper.findManager(mobile));
         return ResponseJson.success(seller);
     }
@@ -528,34 +524,29 @@ public class SellerServiceImpl implements SellerService {
     }
 
     @Override
-    public ResponseJson<List<CmBehaviorRecordVo>> getBehaviorRecordClub(Integer spId, String accessTime) {
-        // 设置日期格式
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
-        LocalDate date = LocalDate.parse(accessTime, formatter);
-        // 获取前一天的日期
-        LocalDate dayBeforeYesterday = date.minusDays(1);
-        // 格式化日期
-        accessTime = dayBeforeYesterday.format(formatter);
-        List<CmBehaviorRecordVo> behaviorRecordYesterdayClub = sellerMapper.getBehaviorRecordYesterdayClub(spId, accessTime);
+    public ResponseJson<List<CmBehaviorRecordVo>> getBehaviorRecordClub(Integer type, Integer spId, String accessTime) {
+        List<CmBehaviorRecordVo> behaviorRecordYesterdayClub = null == type  //null 机构访问通知, 1内容库访问通知
+                ? sellerMapper.getBehaviorRecordYesterdayClub(spId, accessTime)
+                : sellerMapper.getBehaviorRecordMinuteClub(spId, accessTime);
         for (CmBehaviorRecordVo cmBehaviorRecordVo : behaviorRecordYesterdayClub) {
-            String pageLabel = sellerMapper.getBehaviorRecordYesterdayPageLabel(spId, cmBehaviorRecordVo.getClubId(), accessTime);
+            String pageLabel = null == type
+                    ? sellerMapper.getBehaviorRecordYesterdayPageLabel(spId, cmBehaviorRecordVo.getClubId(), accessTime)
+                    : sellerMapper.getBehaviorRecordMinutePageLabel(spId, cmBehaviorRecordVo.getClubId(), accessTime);
             cmBehaviorRecordVo.setPageLabel(pageLabel);
         }
         return ResponseJson.success(behaviorRecordYesterdayClub);
     }
 
     @Override
-    public ResponseJson<List<CmBehaviorRecordVo>> getBehaviorRecordClubFrom(Integer spId, Integer clubId, String accessTime) {
-//        // 设置日期格式
-//        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
-//        LocalDate date = LocalDate.parse(accessTime, formatter);
-//        // 获取前一天的日期
-//        LocalDate dayBeforeYesterday = date.minusDays(1);
-//        // 格式化日期
-//        accessTime= dayBeforeYesterday.format(formatter);
-        List<CmBehaviorRecordVo> behaviorRecordYesterdayClubFrom = sellerMapper.getBehaviorRecordYesterdayClubFrom(spId, clubId, accessTime);
+    public ResponseJson<List<CmBehaviorRecordVo>> getBehaviorRecordClubFrom(Integer type, Integer spId, Integer clubId, String accessTime) {
+
+        List<CmBehaviorRecordVo> behaviorRecordYesterdayClubFrom = null == type  //null 机构访问通知, 1内容库访问通知
+                ? sellerMapper.getBehaviorRecordYesterdayClubFrom(spId, clubId, accessTime)
+                : sellerMapper.getBehaviorRecordMinuteClubFrom(spId, clubId, accessTime);
         for (CmBehaviorRecordVo cmBehaviorRecordVo : behaviorRecordYesterdayClubFrom) {
-            String pageLabel = sellerMapper.getBehaviorRecordYesterdayPageLabel(spId, cmBehaviorRecordVo.getClubId(), accessTime);
+            String pageLabel = null == type
+                    ? sellerMapper.getBehaviorRecordYesterdayPageLabel(spId, cmBehaviorRecordVo.getClubId(), accessTime)
+                    : sellerMapper.getBehaviorRecordMinutePageLabel(spId, cmBehaviorRecordVo.getClubId(), accessTime);
             cmBehaviorRecordVo.setPageLabel(pageLabel);
             cmBehaviorRecordVo.setAccessDuration(calculationTime(cmBehaviorRecordVo.getAccessDuration()));
             if (cmBehaviorRecordVo.getProductID() != 0 && cmBehaviorRecordVo.getPageType().equals("6")) {

+ 1 - 1
src/main/java/com/caimei365/user/utils/BeanUtil.java

@@ -23,7 +23,7 @@ public class BeanUtil {
     }
 
     public static <T, S> List<T> setValues(List<S> sourceList, Class<T> target) {
-        if (CollectionUtils.isEmpty(sourceList)&&sourceList.size()>0) {
+        if (CollectionUtils.isEmpty(sourceList)) {
             return new ArrayList<>();
         }
         List<T> targetList = new ArrayList<>(sourceList.size());

+ 67 - 3
src/main/resources/mapper/SellerMapper.xml

@@ -498,7 +498,21 @@
             AND c.clubId =#{clubId}
         </if>
         and b.pageType in(6,8,11)
-        and  DATE(b.accessTime) = DATE(#{accessTime})
+        and  DATE(b.accessTime) = DATE(DATE_SUB(#{accessTime}, INTERVAL 1 day))
+        GROUP BY b.pageLabel LIMIT 10) as a
+    </select>
+    <select id="getBehaviorRecordMinutePageLabel" resultType="string">
+        SELECT GROUP_CONCAT(a.pageLabel)
+        FROM (SELECT b.pageLabel
+        FROM cm_behavior_record b
+        LEFT JOIN club c ON b.userID = c.userID
+        LEFT JOIN serviceprovider sp ON b.headUserId = sp.userID
+        WHERE  sp.status=90 and sp.serviceProviderID=#{spId}
+        and b.pageType in (69,70,71)
+        and b.accessTime between DATE_SUB(#{accessTime}, INTERVAL 5 Minute) and  #{accessTime}
+        <if test="clubId != null">
+            AND c.clubId =#{clubId}
+        </if>
         GROUP BY b.pageLabel LIMIT 10) as a
     </select>
     <select id="getBehaviorRecordYesterdayClubFrom" resultType="com.caimei365.user.model.vo.CmBehaviorRecordVo">
@@ -524,7 +538,32 @@
         and c.spId=#{spId}
         and c.clubId=#{clubId}
         and b.pageType in(6,11)
-        and  DATE(b.accessTime) = DATE(#{accessTime})
+        and  DATE(b.accessTime) = DATE(DATE_SUB(#{accessTime}, INTERVAL 1 day))
+    </select>
+    <select id="getBehaviorRecordMinuteClubFrom" resultType="com.caimei365.user.model.vo.CmBehaviorRecordVo">
+        SELECT
+            b.recordID,
+            b.userID,
+            b.pagePath,
+            b.pageType,
+            b.pageLabel,
+            b.productID,
+            b.accessTime,
+            b.accessDuration,
+            b.accessDate,
+            b.referer,
+            b.accessClient,
+            b.isReckon,
+            b.region,
+            c.name,c.linkMan,c.contractMobile,c.clubId,u.image
+        FROM cm_behavior_record b
+        LEFT JOIN club c ON b.userID = c.userID
+        LEFT JOIN user u ON u.userID = c.userID
+        LEFT JOIN serviceprovider sp ON b.headUserId = sp.userID
+        WHERE  sp.status=90 and sp.serviceProviderID=#{spId}
+          and b.pageType in (69,70,71)
+          and b.accessTime between DATE_SUB(#{accessTime}, INTERVAL 5 Minute) and  #{accessTime}
+        and c.clubId=#{clubId}
     </select>
     <select id="getBehaviorRecordYesterdayClub" resultType="com.caimei365.user.model.vo.CmBehaviorRecordVo">
         SELECT b.recordID,
@@ -547,9 +586,34 @@
         WHERE b.userId !=0
         and c.spId=#{spId}
           and b.pageType in(6,8,11)
-          and  DATE(b.accessTime) = DATE(#{accessTime})
+          and  DATE(b.accessTime) = DATE(DATE_SUB(#{accessTime}, INTERVAL 1 day))
         GROUP BY c.clubId
     </select>
+    <select id="getBehaviorRecordMinuteClub" resultType="com.caimei365.user.model.vo.CmBehaviorRecordVo">
+        SELECT b.recordID,
+               b.userID,
+               b.pagePath,
+               b.pageType,
+               b.pageLabel,
+               b.productID,
+               b.accessTime,
+               b.accessDuration,
+               b.accessDate,
+               b.referer,
+               b.accessClient,
+               b.isReckon,
+               b.region,
+               ifnull(c.name,b.region)
+               ,c.linkMan,c.contractMobile,c.clubId,u.image
+        FROM cm_behavior_record b
+                 LEFT JOIN club c ON b.userID = c.userID
+                 LEFT JOIN user u ON u.userID = c.userID
+                 LEFT JOIN serviceprovider sp ON b.headUserId = sp.userID
+        WHERE  sp.status=90 and sp.serviceProviderID=#{spId}
+          and b.pageType in (69,70,71)
+          and b.accessTime between DATE_SUB(#{accessTime}, INTERVAL 5 Minute) and  #{accessTime}
+        GROUP BY b.region
+    </select>
 
     <select id="getClubAccessDate" resultType="com.caimei365.user.model.vo.RetuenDataVo">
         select cbr.accessDate