Commit 0eae72e1 by zhouhaibao

feat(sop): 更新SOP策略埋点和营销页面功能

- 在SopMarketingPageViewReqDTO中添加序列化接口并增加字段注释
- 为请求参数添加必填验证注解
- 在SopStrategyEventLog实体类中添加任务ID字段
- 更新埋点记录方法将executionRecordId替换为taskId
- 优化营销页面URL构建功能
- 移除多余日志输出并更新日志内容
1 parent c8867de5
package cn.com.glsx.dj.strategy.dto.sop;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import lombok.Data;
@Data
public class SopMarketingPageViewReqDTO {
private Long pageId;
private Long customerInstanceId;
public class SopMarketingPageViewReqDTO implements Serializable {
@ApiModelProperty(notes = "策略ID")
private Long strategyId;
private Long executionRecordId;
@ApiModelProperty(notes = "执行记录ID")
private Long taskId;
@ApiModelProperty(notes = "门店ID")
private Long storeId;
@ApiModelProperty(notes = "门店名称")
private String storeName;
@ApiModelProperty(notes = "客户名称")
private String customerName;
@ApiModelProperty(notes = "客户手机号")
private String customerPhone;
}
\ No newline at end of file
......@@ -72,4 +72,10 @@ public class SopStrategyEventLog implements Serializable {
*/
@Column(name = "created_date")
private Date createdDate;
/**
* 任务id
*/
@Column(name = "task_id")
private Long taskId;
}
\ No newline at end of file
......@@ -177,8 +177,7 @@ public class SopStrategyRemoteImpl implements SopStrategyRemote {
@Override
public RpcResponse<Boolean> recordMarketingPageView(SopMarketingPageViewReqDTO request) {
log.info("营销网页访问埋点, pageId:{}, customerInstanceId:{}, strategyId:{}",
request.getPageId(), request.getCustomerInstanceId(), request.getStrategyId());
try {
Boolean result = strategySopService.recordMarketingPageView(request);
return RpcResponse.success(result);
......
......@@ -30,34 +30,33 @@ public class SopStrategyEventLogService {
recordEvent(null, null, "SOP策略", EVENT_CODE_MENU_ENTRY, null);
}
public void recordSubmitChangeEvent(Integer strategyId, Long executionRecordId) {
public void recordSubmitChangeEvent(Integer strategyId, Long taskId) {
Map<String, Object> eventData = new HashMap<>();
eventData.put("strategyId", strategyId);
eventData.put("executionRecordId", executionRecordId);
eventData.put("taskId", taskId);
recordEvent(strategyId, null, "SOP策略", EVENT_CODE_SUBMIT_CHANGE, eventData);
}
public void recordH5PageViewEvent(Integer strategyId, Long executionRecordId,
Long customerInstanceId, String storeName,
public void recordH5PageViewEvent(Integer strategyId, Long taskId,
String storeName,
String customerName, String customerPhone) {
Map<String, Object> eventData = new HashMap<>();
eventData.put("strategyId", strategyId);
eventData.put("executionRecordId", executionRecordId);
eventData.put("customerInstanceId", customerInstanceId);
eventData.put("taskId", taskId);
eventData.put("storeName", storeName);
eventData.put("customerName", customerName);
eventData.put("customerPhone", customerPhone);
recordEvent(strategyId, customerInstanceId, "SOP策略", EVENT_CODE_H5_PAGE_VIEW, eventData);
recordEvent(strategyId, taskId,"SOP策略", EVENT_CODE_H5_PAGE_VIEW, eventData);
}
private void recordEvent(Integer strategyId, Long customerInstanceId,
String eventType, String eventCode, Map<String, Object> eventData) {
private void recordEvent(Integer strategyId,
Long taskId, String eventType, String eventCode, Map<String, Object> eventData) {
try {
SopStrategyEventLog eventLog = new SopStrategyEventLog();
eventLog.setStrategyId(strategyId);
eventLog.setCustomerInstanceId(customerInstanceId);
eventLog.setEventType(eventType);
eventLog.setEventCode(eventCode);
eventLog.setTaskId(taskId);
if (eventData != null && !eventData.isEmpty()) {
try {
eventLog.setEventData(objectMapper.writeValueAsString(eventData));
......@@ -68,8 +67,8 @@ public class SopStrategyEventLogService {
eventLog.setEventTime(new Date());
eventLog.setDeletedFlag("N");
sopStrategyEventLogMapper.insertSelective(eventLog);
log.info("记录埋点事件成功, eventCode:{}, strategyId:{}, customerInstanceId:{}",
eventCode, strategyId, customerInstanceId);
log.info("记录埋点事件成功, eventCode:{}, strategyId:{}",
eventCode, strategyId);
} catch (Exception e) {
log.error("记录埋点事件失败, eventCode:{}, error:{}", eventCode, e.getMessage(), e);
}
......
package cn.com.glsx.dj.strategy.service;
import cn.com.glsx.dj.strategy.config.ImHubConfig;
import cn.com.glsx.dj.strategy.dto.MerchantInfo;
import cn.com.glsx.dj.strategy.dto.sop.*;
import cn.com.glsx.dj.strategy.enums.SopStrategyStatusEnum;
......@@ -49,6 +50,8 @@ public class StrategySopService {
private final SopStrategySnapshotCacheService sopStrategySnapshotCacheService;
private final ObjectMapper objectMapper;
private final ImHubConfig imHubConfig;
@Transactional
public Integer createSopStrategy(SopStrategyCreateReqDTO request) {
validateStrategy(request);
......@@ -298,6 +301,11 @@ public class StrategySopService {
if (messageType == 4) {
action.setContent(actionReq.getPageTitle());
String finalUrl = buildWebpageUrl(action);
if (StrUtil.isNotBlank(finalUrl)) {
action.setJumpUrl(finalUrl);
}
}
}
......@@ -308,6 +316,24 @@ public class StrategySopService {
}
}
private String buildWebpageUrl(SopStrategyAction action) {
String baseUrl = imHubConfig.getMarketingPageUrl();
if (StrUtil.isBlank(baseUrl)) {
log.warn("营销网页基础URL未配置");
return action.getJumpUrl();
}
StringBuilder urlBuilder = new StringBuilder(baseUrl);
boolean hasParams = baseUrl.contains("?");
if (action.getMessageType() != null && action.getMessageType() == 4) {
urlBuilder.append(hasParams ? "&" : "?");
urlBuilder.append("actionId=").append(action.getId());
}
return urlBuilder.toString();
}
private void saveActionMedias(Integer actionId, List<SopActionMediaReqDTO> medias, String createdBy) {
if (CollUtil.isEmpty(medias)) {
return;
......@@ -375,19 +401,16 @@ public class StrategySopService {
}
public Boolean recordMarketingPageView(SopMarketingPageViewReqDTO request) {
log.info("记录营销网页访问埋点, pageId:{}, customerInstanceId:{}, strategyId:{}, executionRecordId:{}, storeId:{}",
request.getPageId(), request.getCustomerInstanceId(), request.getStrategyId(),
request.getExecutionRecordId(), request.getStoreId());
log.info("记录营销网页访问埋点, strategyId:{}, executionRecordId:{}, storeId:{}", request.getStrategyId(),
request.getTaskId(), request.getStoreId());
sopStrategyEventLogService.recordH5PageViewEvent(
request.getStrategyId() != null ? request.getStrategyId().intValue() : null,
request.getExecutionRecordId(),
request.getCustomerInstanceId(),
request.getTaskId(),
request.getStoreName(),
request.getCustomerName(),
request.getCustomerPhone()
);
return true;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!