|
@@ -1,11 +1,14 @@
|
|
|
package com.caimei.www.service.link.impl;
|
|
|
|
|
|
import com.caimei.www.mapper.ShortLinkDao;
|
|
|
+import com.caimei.www.pojo.link.CmBehaviorInfoPo;
|
|
|
import com.caimei.www.pojo.link.ShortLink;
|
|
|
import com.caimei.www.service.link.ShortLinkService;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* Description
|
|
@@ -18,6 +21,9 @@ public class ShortLinkServiceImpl implements ShortLinkService {
|
|
|
@Resource
|
|
|
private ShortLinkDao shortLinkDao;
|
|
|
|
|
|
+ @Value("${caimei.wwwDomain}")
|
|
|
+ private String wwwDomain;
|
|
|
+
|
|
|
@Override
|
|
|
public String linkJump(String link, String ip) {
|
|
|
ShortLink shortLink = shortLinkDao.findByShortLink(link);
|
|
@@ -27,6 +33,87 @@ public class ShortLinkServiceImpl implements ShortLinkService {
|
|
|
}
|
|
|
//修改点击数量
|
|
|
shortLinkDao.updateOnClick(shortLink.getMarkId());
|
|
|
+ // 行为记录
|
|
|
+ try {
|
|
|
+ // 记录
|
|
|
+ CmBehaviorInfoPo behaviorInfo = shortLinkDao.getClubSpId(link);
|
|
|
+ link = wwwDomain + link;
|
|
|
+ setBehaviorInfo(behaviorInfo, link);
|
|
|
+ behaviorInfo.setOperateObject(1);
|
|
|
+ behaviorInfo.setType(2);
|
|
|
+ shortLinkDao.insertBehaviorInfo(behaviorInfo);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
return shortLink.getJumpLink();
|
|
|
}
|
|
|
+
|
|
|
+ private void setBehaviorInfo(CmBehaviorInfoPo behaviorInfo, String link) {
|
|
|
+ Pattern compile = Pattern.compile("^[0-9]+$");
|
|
|
+ behaviorInfo.setPagePath(link);
|
|
|
+ String labels = "";
|
|
|
+ Integer id = 0;
|
|
|
+ // 文章详情
|
|
|
+ // https://www.caimei365.com/info/detail-7855-1.html
|
|
|
+ if (link.contains("info") && link.contains("detail")) {
|
|
|
+ behaviorInfo.setPageType("文章详情");
|
|
|
+ String[] split = link.split("-");
|
|
|
+ for (String s : split) {
|
|
|
+ if (compile.matcher(s).matches()) {
|
|
|
+ id = Integer.parseInt(s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 获取文章标签
|
|
|
+ labels = shortLinkDao.getInfoLabels(id);
|
|
|
+ }
|
|
|
+ // 商品详情
|
|
|
+ id = 0;
|
|
|
+ if (link.contains("product")) {
|
|
|
+ behaviorInfo.setPageType("商品详情");
|
|
|
+ String[] split = link.split("-");
|
|
|
+ // https://www.caimei365.com/product-7729.html
|
|
|
+ if (split.length <= 2) {
|
|
|
+ for (String s : split) {
|
|
|
+ String str = s.substring(0, s.lastIndexOf(".html"));
|
|
|
+ if (compile.matcher(str).matches()) {
|
|
|
+ id = Integer.parseInt(str);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // https://www.caimei365.com/product-7729-1.html
|
|
|
+ for (String s : split) {
|
|
|
+ if (compile.matcher(s).matches()) {
|
|
|
+ id = Integer.parseInt(s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 获取商品标签
|
|
|
+ labels = shortLinkDao.getProductLabels(id);
|
|
|
+ }
|
|
|
+ // 网页
|
|
|
+ id = 0;
|
|
|
+ // https://www.caimei365.com/page-375.html
|
|
|
+ if (link.contains("topic") || link.contains("equipment") || link.contains("page") || link.contains("product/type") || link.contains("product/activity")
|
|
|
+ || link.contains("product/beauty") || link.contains("quickOperation/operation") || link.contains("cmpage/info")) {
|
|
|
+ behaviorInfo.setPageType("网页列表");
|
|
|
+ String[] split = link.split("-");
|
|
|
+ if (split.length <= 2) {
|
|
|
+ for (String s : split) {
|
|
|
+ String str = s.substring(0, s.lastIndexOf(".html"));
|
|
|
+ if (compile.matcher(str).matches()) {
|
|
|
+ id = Integer.parseInt(str);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (String s : split) {
|
|
|
+ if (compile.matcher(s).matches()) {
|
|
|
+ id = Integer.parseInt(s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ labels = shortLinkDao.getPageLabels(id);
|
|
|
+ }
|
|
|
+ behaviorInfo.setLabel(labels);
|
|
|
+ }
|
|
|
}
|