|
@@ -8,9 +8,12 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.pig4cloud.pig.marketing.api.dto.MktMgmtPushRecordQueryDTO;
|
|
|
import com.pig4cloud.pig.marketing.api.dto.MktMgmtPushRecordSaveDTO;
|
|
|
+import com.pig4cloud.pig.marketing.api.dto.go.GoPushDataItem;
|
|
|
+import com.pig4cloud.pig.marketing.api.dto.go.GoPushRequest;
|
|
|
import com.pig4cloud.pig.marketing.api.entity.*;
|
|
|
import com.pig4cloud.pig.marketing.api.vo.rule.StatKeywordVO;
|
|
|
import com.pig4cloud.pig.marketing.config.PushValidationConfig;
|
|
|
+import com.pig4cloud.pig.marketing.feign.GoPushClient;
|
|
|
import com.pig4cloud.pig.marketing.mapper.*;
|
|
|
import com.pig4cloud.pig.marketing.service.MktMgmtPushRecordService;
|
|
|
import com.pig4cloud.pig.marketing.util.IPLocationUtil;
|
|
@@ -47,6 +50,7 @@ public class MktMgmtPushRecordServiceImpl implements MktMgmtPushRecordService {
|
|
|
private final RedisTemplate<String, Object> redisTemplate;
|
|
|
private final IPLocationUtil ipLocationUtil;
|
|
|
private final PushValidationConfig pushValidationConfig;
|
|
|
+ private final GoPushClient goPushClient;
|
|
|
|
|
|
@Override
|
|
|
public Page<MktMgmtPushRecord> pageQuery(MktMgmtPushRecordQueryDTO queryDTO) {
|
|
@@ -184,6 +188,8 @@ public class MktMgmtPushRecordServiceImpl implements MktMgmtPushRecordService {
|
|
|
int result = mktMgmtPushRecordMapper.insert(record);
|
|
|
if (result > 0) {
|
|
|
log.info("营销推送记录新增成功,ID:{},规则:{},匹配关键字:{}", record.getId(), selectedRule.getRuleName(), matchedKeywords);
|
|
|
+ // 调用 Go 服务
|
|
|
+ sendToGoService(saveDTO.getClientId(), String.valueOf(record.getPushAction()), selectedRule.getPushContent());
|
|
|
return "新增成功";
|
|
|
}
|
|
|
|
|
@@ -196,6 +202,28 @@ public class MktMgmtPushRecordServiceImpl implements MktMgmtPushRecordService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void sendToGoService(String clientId, String pushAction, String content) {
|
|
|
+ try {
|
|
|
+ GoPushDataItem item = new GoPushDataItem();
|
|
|
+ if ("1".equals(pushAction)){
|
|
|
+ item.setTitle("ping");
|
|
|
+ }else {
|
|
|
+ item.setTitle("消息");
|
|
|
+ }
|
|
|
+ item.setMsg(content);
|
|
|
+
|
|
|
+ GoPushRequest req = new GoPushRequest();
|
|
|
+ req.setClientId(clientId);
|
|
|
+ req.setPushAction(pushAction);
|
|
|
+ req.setData(List.of(item));
|
|
|
+
|
|
|
+ String resp = goPushClient.receive(req);
|
|
|
+ log.info("Go 服务响应: {}", resp);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("调用Go服务失败: {}", e.getMessage(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 统计关键词
|
|
|
* @param days 统计天数
|