|
@@ -64,7 +64,7 @@ class ReferralLinkPidDraw extends Command
|
64
|
64
|
continue;
|
65
|
65
|
}
|
66
|
66
|
|
67
|
|
- $res = MassMsgService::drawPid($data, $pid, 'ReferralLinkPidDraw');
|
|
67
|
+ $res = $this->drawPid($data, $pid, 'ReferralLinkPidDraw');
|
68
|
68
|
} catch (\Throwable $e) {
|
69
|
69
|
Log::logError('提取推广链接PID异常', [
|
70
|
70
|
'type' => $type,
|
|
@@ -92,12 +92,12 @@ class ReferralLinkPidDraw extends Command
|
92
|
92
|
}
|
93
|
93
|
}
|
94
|
94
|
|
95
|
|
- public function drawPid($data, &$pid)
|
|
95
|
+ public function drawPid($attachments, &$pid, $logName)
|
96
|
96
|
{
|
97
|
|
- Log::logInfo('提取开始', $data, 'ReferralLinkPidDraw');
|
|
97
|
+ Log::logInfo('提取开始', $attachments, $logName);
|
98
|
98
|
|
99
|
|
- $drawPids = [];
|
100
|
|
- foreach ($data as $datum) {
|
|
99
|
+ $drawPids = [];
|
|
100
|
+ foreach ($attachments as $datum) {
|
101
|
101
|
if (isset($datum['msgtype'])) {
|
102
|
102
|
$url = null;
|
103
|
103
|
// 小程序
|
|
@@ -133,71 +133,97 @@ class ReferralLinkPidDraw extends Command
|
133
|
133
|
$url = $datum['promote']['jump_url'];
|
134
|
134
|
}
|
135
|
135
|
|
|
136
|
+ // 欢迎语中的H5推广会被转换成普通链接方式
|
|
137
|
+ if (
|
|
138
|
+ ($datum['msgtype'] == 'link')
|
|
139
|
+ &&
|
|
140
|
+ isset($datum['link']['jump_url'])
|
|
141
|
+ &&
|
|
142
|
+ !empty($datum['link']['jump_url'])
|
|
143
|
+ ) {
|
|
144
|
+ $url = $datum['link']['jump_url'];
|
|
145
|
+ }
|
|
146
|
+
|
136
|
147
|
// 属于其他类型
|
137
|
148
|
if (is_null($url)) continue;
|
138
|
149
|
|
139
|
|
- Log::logInfo('处理url', ['url' => $url], 'ReferralLinkPidDraw');
|
|
150
|
+ Log::logInfo('提取URL', [
|
|
151
|
+ 'url' => $url
|
|
152
|
+ ], $logName);
|
140
|
153
|
|
141
|
154
|
// 处理url
|
142
|
|
- $fildExistNum = 0;
|
143
|
|
- $this->dealUrl($url, $fildExistNum, $drawPids);
|
|
155
|
+ $filedExistNum = 0;
|
|
156
|
+ $this->dealUrl($url, $filedExistNum, $drawPids, $logName);
|
144
|
157
|
|
145
|
|
- if ($fildExistNum > 1) {
|
146
|
|
- Log::logError('提取推广链接PID存在多个字段', $datum, 'ReferralLinkPidDraw');
|
|
158
|
+ if ($filedExistNum > 1) {
|
|
159
|
+ Log::logError('提取推广链接PID存在多个字段', $datum, $logName);
|
147
|
160
|
return false;
|
148
|
161
|
}
|
149
|
162
|
}
|
150
|
163
|
|
151
|
|
- if (count($drawPids) > 1) {
|
152
|
|
- Log::logError('提取推广链接PID存在多个值', $datum, 'ReferralLinkPidDraw');
|
153
|
|
- return false;
|
154
|
|
- }
|
|
164
|
+// if (count($drawPids) > 1) {
|
|
165
|
+// Log::logError('提取推广链接PID存在多个值', $datum, $logName);
|
|
166
|
+// return false;
|
|
167
|
+// }
|
155
|
168
|
|
156
|
|
- if (!empty($drawPids)) $pid = current($drawPids);
|
|
169
|
+ if (!empty($drawPids)) $pid = json_encode(array_filter($drawPids));
|
157
|
170
|
|
158
|
|
- Log::logInfo('提取结束', $data, 'ReferralLinkPidDraw');
|
|
171
|
+ Log::logInfo('提取结束', $attachments, $logName);
|
159
|
172
|
}
|
160
|
173
|
|
161
|
174
|
return true;
|
162
|
175
|
}
|
163
|
176
|
|
164
|
|
- public function dealUrl($url, &$fildExistNum, &$drawPids)
|
|
177
|
+ public function dealUrl($url, &$filedExistNum, &$drawPids, $logName)
|
165
|
178
|
{
|
|
179
|
+ $url = str_replace("%25", "%", $url);
|
|
180
|
+ $url = str_replace("&", "&", $url);
|
|
181
|
+
|
|
182
|
+ $url = urldecode($url);
|
166
|
183
|
$urlArr = parse_url($url);
|
|
184
|
+
|
167
|
185
|
if (!isset($urlArr['query']) && empty($urlArr['query'])) return false;
|
168
|
186
|
|
169
|
|
- Log::logInfo('提取url', ['url' => $url, 'fildExistNum' => $fildExistNum, 'drawPids' => $drawPids], 'ReferralLinkPidDraw');
|
|
187
|
+ Log::logInfo('提取url', [
|
|
188
|
+ 'url' => $url,
|
|
189
|
+ 'filedExistNum' => $filedExistNum,
|
|
190
|
+ 'drawPids' => $drawPids
|
|
191
|
+ ], $logName);
|
170
|
192
|
|
171
|
193
|
parse_str($urlArr['query'], $query);
|
172
|
194
|
|
173
|
195
|
// 柚子 pathId
|
174
|
196
|
if (isset($query['pathId']) && !empty($query['pathId'])) {
|
175
|
|
- $fildExistNum ++;
|
|
197
|
+ $filedExistNum ++;
|
176
|
198
|
$drawPids[] = $query['pathId'];
|
177
|
199
|
}
|
178
|
200
|
|
179
|
201
|
// 嘉书 article
|
180
|
202
|
if (isset($query['article']) && !empty($query['article'])) {
|
181
|
|
- $fildExistNum ++;
|
|
203
|
+ $filedExistNum ++;
|
182
|
204
|
$drawPids[] = $query['article'];
|
183
|
205
|
}
|
184
|
206
|
|
185
|
207
|
// 迈步 pid
|
186
|
208
|
if (isset($query['pid']) && !empty($query['pid'])) {
|
187
|
|
- $fildExistNum ++;
|
|
209
|
+ $filedExistNum ++;
|
188
|
210
|
$drawPids[] = $query['pid'];
|
189
|
211
|
}
|
190
|
212
|
|
191
|
213
|
// 点众阳光 referral_id
|
192
|
214
|
if (isset($query['referral_id']) && !empty($query['referral_id'])) {
|
193
|
|
- $fildExistNum ++;
|
|
215
|
+ $filedExistNum ++;
|
194
|
216
|
$drawPids[] = $query['referral_id'];
|
195
|
217
|
}
|
196
|
218
|
|
197
|
219
|
foreach ($query as $urlVal) {
|
198
|
|
- $this->dealUrl($urlVal, $fildExistNum, $drawPids);
|
|
220
|
+ $this->dealUrl($urlVal, $filedExistNum, $drawPids, $logName);
|
199
|
221
|
}
|
200
|
222
|
|
201
|
|
- Log::logInfo('提取url结果', ['url' => $url, 'fildExistNum' => $fildExistNum, 'drawPids' => $drawPids], 'ReferralLinkPidDraw');
|
|
223
|
+ Log::logInfo('提取url结果', [
|
|
224
|
+ 'url' => $url,
|
|
225
|
+ 'filedExistNum' => $filedExistNum,
|
|
226
|
+ 'drawPids' => $drawPids
|
|
227
|
+ ], $logName);
|
202
|
228
|
}
|
203
|
229
|
}
|