zhijiezhao 10 miesięcy temu
rodzic
commit
8d284b3ad6

+ 4 - 0
src/main/java/com/caimei365/tools/model/po/CmBehaviorRecordPo.java

@@ -14,6 +14,10 @@ import java.util.Date;
 public class CmBehaviorRecordPo {
 
     private Integer recordID;
+    /**
+     * 友站id,1 唯美概念官网
+     */
+    private Integer partnerId;
     /**
      * 访问人IP地址
      */

+ 57 - 46
src/main/java/com/caimei365/tools/service/impl/CmBehaviorRecordServiceImpl.java

@@ -163,7 +163,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
                         }
                     }
                     // 访问页面类型为供应商主页 且供应商 id 不为空的时候 将页面 pageLabel 改为供应商名称
-                    if ( null != cmBehaviorRecordPo.getShopId() && 14 == cmBehaviorRecordPo.getPageType()) {
+                    if (null != cmBehaviorRecordPo.getShopId() && 14 == cmBehaviorRecordPo.getPageType()) {
                         // 获取供应商名称
                         String shopName = recordMapper.getShopName(cmBehaviorRecordPo.getShopId());
                         if (StringUtils.isNotBlank(shopName)) {
@@ -250,7 +250,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
                             String trim = value.trim();
                             if (StringUtils.isNotBlank(trim)) {
                                 log.info("openId============》" + trim);
-                                 cmBehaviorRecordPo.setOpenId(trim);
+                                cmBehaviorRecordPo.setOpenId(trim);
                             }
                         }
                     }
@@ -262,7 +262,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
                             String trim = value.trim();
                             if (StringUtils.isNotBlank(trim)) {
                                 log.info("headUserId============》" + trim);
-                                 cmBehaviorRecordPo.setHeadUserId(trim);
+                                cmBehaviorRecordPo.setHeadUserId(trim);
                             }
                         }
                     }
@@ -274,11 +274,21 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
                             String trim = value.trim();
                             if (StringUtils.isNotBlank(trim)) {
                                 log.info("productArchiveId============》" + trim);
-                                 cmBehaviorRecordPo.setProductArchiveId(trim);
+                                cmBehaviorRecordPo.setProductArchiveId(trim);
+                            }
+                        }
+                    }
+                    if (str.startsWith("partnerId") && str.contains("=")) {
+                        String[] split1 = str.split("=");
+                        if (split1.length > 1) {
+                            String value = split1[1];
+                            String trim = value.trim();
+                            if (StringUtils.isNotBlank(trim)) {
+                                log.info("partnerId============》" + trim);
+                                cmBehaviorRecordPo.setPartnerId(Integer.valueOf(trim));
                             }
                         }
                     }
-
                 }
                 // 处理页面标签为空
                 if (StringUtils.isBlank(cmBehaviorRecordPo.getPageLabel()) || StringUtils.isEmpty(cmBehaviorRecordPo.getPageLabel())) {
@@ -304,7 +314,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
                                     productId = cmBehaviorRecordPo.getPagePath().substring(cmBehaviorRecordPo.getPagePath().indexOf("id="), cmBehaviorRecordPo.getPagePath().lastIndexOf("&typeId"));
                                 } else {
                                     // /pages/goods/product?id=1017
-                                    productId = cmBehaviorRecordPo.getPagePath().substring(cmBehaviorRecordPo.getPagePath().indexOf("id=")+3);
+                                    productId = cmBehaviorRecordPo.getPagePath().substring(cmBehaviorRecordPo.getPagePath().indexOf("id=") + 3);
                                 }
                             }
                         }
@@ -323,7 +333,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
                             if (labelPath[1].contains(".html")) {
                                 // 暂无该情况
                                 infoId = labelPath[1].substring(0, labelPath[1].lastIndexOf(".html"));
-                            }else {
+                            } else {
                                 infoId = labelPath[1];
                             }
                         }
@@ -332,7 +342,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
                         } catch (Exception e) {
                             e.printStackTrace();
                         }
-                    } else if (12 == cmBehaviorRecordPo.getPageType()){
+                    } else if (12 == cmBehaviorRecordPo.getPageType()) {
                         String baikeId = "";
                         // 采美百科
                         if ("0".equals(cmBehaviorRecordPo.getAccessClient())) {
@@ -341,7 +351,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
                             String[] labelPath = cmBehaviorRecordPo.getPagePath().split("-");
                             if (labelPath[1].contains(".html")) {
                                 baikeId = labelPath[1].substring(0, labelPath[1].lastIndexOf(".html"));
-                            }else {
+                            } else {
                                 // 暂无该情况
                                 baikeId = labelPath[1];
                             }
@@ -377,37 +387,37 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
             }
             cmBehaviorRecordPo.setRegion(region);
             // if (flag) {
-                recordMapper.insertRecord(cmBehaviorRecordPo);
+            recordMapper.insertRecord(cmBehaviorRecordPo);
 
-                int recordId = cmBehaviorRecordPo.getRecordID();
-                if (cmBehaviorRecordPo.getShopId() != null) {
-                    if (14 != cmBehaviorRecordPo.getPageType()) {
-                        if (StringUtils.isNotBlank(cmBehaviorRecordPo.getPageLabel())) {
-                            List<String> strList = new ArrayList<>();
-                            // 页面标签在含有多个,包含 , 是可分割,进行分割作为关键词
-                            if (cmBehaviorRecordPo.getPageLabel().contains(",")) {
-                                String[] split = cmBehaviorRecordPo.getPageLabel().split(",");
-                                for (String s : split) {
-                                    strList.add(s);
-                                }
-                            } else {
-                                strList.add(cmBehaviorRecordPo.getPageLabel());
-                            }
-                            // 供应商id
-                            List<Integer> shopIds = recordMapper.shopIds(strList);
-                            if (shopIds.size() > 0) {
-                                for (Integer shopId : shopIds) {
-                                    recordMapper.insertShopId(recordId, shopId);
-                                }
+            int recordId = cmBehaviorRecordPo.getRecordID();
+            if (cmBehaviorRecordPo.getShopId() != null) {
+                if (14 != cmBehaviorRecordPo.getPageType()) {
+                    if (StringUtils.isNotBlank(cmBehaviorRecordPo.getPageLabel())) {
+                        List<String> strList = new ArrayList<>();
+                        // 页面标签在含有多个,包含 , 是可分割,进行分割作为关键词
+                        if (cmBehaviorRecordPo.getPageLabel().contains(",")) {
+                            String[] split = cmBehaviorRecordPo.getPageLabel().split(",");
+                            for (String s : split) {
+                                strList.add(s);
                             }
+                        } else {
+                            strList.add(cmBehaviorRecordPo.getPageLabel());
                         }
-                    } else {
-                        Integer id = recordMapper.selShopId(cmBehaviorRecordPo.getShopId());
-                        if (id != null) {
-                            recordMapper.insertShopId(recordId, cmBehaviorRecordPo.getShopId());
+                        // 供应商id
+                        List<Integer> shopIds = recordMapper.shopIds(strList);
+                        if (shopIds.size() > 0) {
+                            for (Integer shopId : shopIds) {
+                                recordMapper.insertShopId(recordId, shopId);
+                            }
                         }
                     }
+                } else {
+                    Integer id = recordMapper.selShopId(cmBehaviorRecordPo.getShopId());
+                    if (id != null) {
+                        recordMapper.insertShopId(recordId, cmBehaviorRecordPo.getShopId());
+                    }
                 }
+            }
             //}
         }
     }
@@ -480,7 +490,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
         skuList.forEach(sku -> {
             if (null != sku.getPrice() && 0 != sku.getPrice()) {
                 // 供应商比例
-                double shopPercent = (sku.getCostPrice()/sku.getPrice()*100);
+                double shopPercent = (sku.getCostPrice() / sku.getPrice() * 100);
                 double rint = Math.rint(shopPercent);
                 // 分账组织佣金比例
                 double organizePercent = 0d;
@@ -553,7 +563,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
                     List<Integer> userIdAttribute = recordMapper.getUserIdAttribute(format, null, touristId);
                     boolean userBean = userIdAttribute.contains(0);
                     // 该openId下只有两个身份 游客-机构、游客-供应商
-                    if(num == 2 && userBean) {
+                    if (num == 2 && userBean) {
                         for (CmBehaviorTouristInfoPo touristInfoPo : touristInfo) {
                             if (touristId.equals(touristInfoPo.getTouristId())) {
                                 CmBehaviorRecordPo cmBehaviorRecordPo = new CmBehaviorRecordPo();
@@ -762,7 +772,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
         if (recordPoList.size() > 0) {
             recordPoList.forEach(r -> {
                 if (StringUtils.isNotBlank(r.getRegisterIp()) && (null == r.getProvinceId() && null == r.getCityId())) {
-                    log.info("个人机构地址初始化=====》"+r.getClubId());
+                    log.info("个人机构地址初始化=====》" + r.getClubId());
                     try {
                         Map<String, String> map = recordAddress(r.getRegisterIp());
                         if (!map.isEmpty()) {
@@ -815,10 +825,10 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
         instance.add(Calendar.DAY_OF_MONTH, -1);
         Date time = instance.getTime();
         String format = dateFormat.format(time);
-        log.info("dateTime========"+format);
+        log.info("dateTime========" + format);
         // 统计供应商
         List<Integer> shopIds = recordMapper.getShopId();
-        shopIds.forEach( s -> {
+        shopIds.forEach(s -> {
             log.info("统计供应商数据");
             // 检索供应商统计信息
             CmBehaviorRecordPo behavior = recordMapper.getBehaviorList(format, 14, s.toString());
@@ -1004,11 +1014,11 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
                             } else {
                                 // 第一次加入, 初始出现系数为 1
                                 if (StringUtils.isNotBlank(stateKeyword) && StringUtils.isNotEmpty(stateKeyword)) {
-                                    if (!demandList.contains(stateKeyword)){
+                                    if (!demandList.contains(stateKeyword)) {
                                         demandList.add(stateKeyword);
                                         map.put(stateKeyword, 1);
                                         clubIdMap.put(stateKeyword, clubId);
-                                    } else{
+                                    } else {
                                         // 记录过,出现次数在原来基础上 + 1
                                         Integer number = map.get(stateKeyword) + 1;
                                         map.put(stateKeyword, number);
@@ -1050,7 +1060,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
                 Map<String, Integer> pageTypeMap = new HashMap<>();
                 // 访问记录
                 List<CmBehaviorRecordPo> behaviorRecordList = recordMapper.getClubBehavior(clubId, startTime, endTime);
-                log.info("behaviorRecordList===="+behaviorRecordList);
+                log.info("behaviorRecordList====" + behaviorRecordList);
                 if (null != behaviorRecordList && behaviorRecordList.size() > 0) {
                     for (CmBehaviorRecordPo behaviorRecord : behaviorRecordList) {
                         if (behaviorRecord.getPageLabel().contains(",")) {
@@ -1076,7 +1086,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
                                     map.put(behaviorRecord.getPageLabel(), Integer.parseInt(behaviorRecord.getNumber()));
                                     clubIdMap.put(behaviorRecord.getPageLabel(), clubId);
                                     pageTypeMap.put(behaviorRecord.getPageLabel(), behaviorRecord.getPageType());
-                                } else{
+                                } else {
                                     // 记录过,出现次数在原来基础上 + 1
                                     Integer number = map.get(behaviorRecord.getPageLabel()) + 1;
                                     map.put(behaviorRecord.getPageLabel(), number);
@@ -1091,7 +1101,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
                         stateCollect = clubStateKeywordList.stream().filter(st -> st.getClubId().equals(clubId)).map(CmClubLabelPo::getLabel).collect(Collectors.toList());
                     }
                     // 保存访问标签
-                    log.info("demandList==访问标签=="+demandList);
+                    log.info("demandList==访问标签==" + demandList);
                     for (String demand : demandList) {
                         if (!trendsCollect.contains(demand) && !stateCollect.contains(demand)) {
                             CmClubLabelPo cmClubLabelPo = new CmClubLabelPo();
@@ -1169,6 +1179,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
         }
         return region;
     }
+
     // 获取IP对应地址 ---- 太平洋
     public static Map<String, String> recordAddress(String ip) throws IOException {
         URL url = null;
@@ -1178,7 +1189,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
         String line = "";
         String regionPro = "";
         String regionCity = "";
-        Map<String,String> map = new HashMap<>();
+        Map<String, String> map = new HashMap<>();
         String urlStr = "http://whois.pconline.com.cn/ipJson.jsp?ip=" + ip + "&json=true";
         try {
             url = new URL(urlStr);
@@ -1244,7 +1255,7 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
         if (link.contains("zzjtest.gz.aeert.com")) {
             return "0";
         }
-        if (link.contains("material")&&link.contains("caimei365.com")) { //https://material-b.caimei365.com
+        if (link.contains("material") && link.contains("caimei365.com")) { //https://material-b.caimei365.com
             return "8";
         }
         return null;

+ 26 - 12
src/main/java/com/caimei365/tools/task/CmOrganValueSystemTask.java

@@ -27,19 +27,23 @@ import java.util.Date;
 @RequiredArgsConstructor
 public class CmOrganValueSystemTask {
 
-    @Resource private CmOrganValueSystemService cmOrganValueSystemService;
+    @Resource
+    private CmOrganValueSystemService cmOrganValueSystemService;
 
-    @Resource private CmBehaviorRecordService cmBehaviorRecordService;
+    @Resource
+    private CmBehaviorRecordService cmBehaviorRecordService;
 
-    @Resource private CmVipCouponService cmVipCouponService;
+    @Resource
+    private CmVipCouponService cmVipCouponService;
 
-    @Resource private MessageService messageService;
+    @Resource
+    private MessageService messageService;
 
     /**
      * 每天生成用户活跃状态
      */
     @Scheduled(cron = "0 13 0 * * ?")
-    public void organData(){
+    public void organData() {
         cmOrganValueSystemService.insertOrgan();
     }
 
@@ -47,7 +51,7 @@ public class CmOrganValueSystemTask {
      * 每月一号更新用户价值
      */
     @Scheduled(cron = "0 15 0 1 * ?")
-    public void organCustomer(){
+    public void organCustomer() {
         cmOrganValueSystemService.insertcustomer();
     }
 
@@ -63,13 +67,18 @@ public class CmOrganValueSystemTask {
      * 每天修改前一天的符合条件的数据 合并ip
      */
     @Scheduled(cron = "0 5 0 * * ?")
-    public void updateBehavior() { cmBehaviorRecordService.updateBehaviorUser();}
+    public void updateBehavior() {
+        cmBehaviorRecordService.updateBehaviorUser();
+    }
 
     /**
      * 每天生成前一天的符用户行为列表数据
      */
     @Scheduled(cron = "0 15 0 * * ?")
-    public void insertBehaviorUser() { cmBehaviorRecordService.insertBehaviorUser();}
+    public void insertBehaviorUser() {
+        cmBehaviorRecordService.insertBehaviorUser();
+    }
+
     /**
      * 每个季度创建专属优惠券
      */
@@ -82,13 +91,17 @@ public class CmOrganValueSystemTask {
      * 生成今日用户行为数据
      */
     @Scheduled(cron = "0 0/10 * * * ?")
-    public void insertBehaviorToday() { cmBehaviorRecordService.insertTodayData();}
+    public void insertBehaviorToday() {
+        cmBehaviorRecordService.insertTodayData();
+    }
 
     /**
      * 生成页面统计数据
      */
     @Scheduled(cron = "0 0 8 * * ?")
-    public void pageStatistics(){ cmBehaviorRecordService.pageStatistics();}
+    public void pageStatistics() {
+        cmBehaviorRecordService.pageStatistics();
+    }
 
     /**
      * 每天10点 给协销微信模板提醒 -- 不活跃机构
@@ -102,7 +115,7 @@ public class CmOrganValueSystemTask {
      * 每天获取前一天机构需求标签
      */
     @Scheduled(cron = "0 20 0 * * ?")
-    public void getClubDemand(){
+    public void getClubDemand() {
         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
         Date date = new Date();
         String endTime = dateFormat.format(date);
@@ -111,5 +124,6 @@ public class CmOrganValueSystemTask {
         instance.add(Calendar.DAY_OF_MONTH, -1);
         Date time = instance.getTime();
         String startTime = dateFormat.format(time);
-        cmBehaviorRecordService.clubDemand(startTime, endTime); }
+        cmBehaviorRecordService.clubDemand(startTime, endTime);
+    }
 }

Plik diff jest za duży
+ 460 - 359
src/main/resources/mapper/CmBehaviorRecordMapper.xml


Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików