Procházet zdrojové kódy

Merge branch 'zz/dev001' into dev/test

zhaozhen %!s(int64=2) %!d(string=před) roky
rodič
revize
c3282553c1

File diff suppressed because it is too large
+ 39 - 74
app/Console/Commands/Test.php


+ 9 - 2
app/Models/MassMsg.php

@@ -148,8 +148,15 @@ class MassMsg extends Model
148 148
         }
149 149
 
150 150
         $popu_data = array();
151
-        $pids = $data->pluck('pid')->all();
152
-        $pids = array_filter($pids);
151
+        $pidVals = $data->pluck('pid')->all();
152
+        $pids = [];
153
+        foreach ($pidVals as $pidVal) {
154
+            if (empty($pidVal)) continue;
155
+
156
+            $itemPids = json_decode($pidVal, true);
157
+            $pids = array_merge($pids, $itemPids);
158
+        }
159
+
153 160
         if( !empty($pids) ){
154 161
             $popu_data = MassPopularizData::selectRaw('sum(viewUv) as viewUv, sum(payPv) as payPv, sum(payUv) as payUv, sum(payMoney) as payMoney')->whereIn('pid', $pids)->first();
155 162
 

+ 9 - 1
app/Models/MomentTask.php

@@ -131,7 +131,15 @@ class MomentTask extends Model
131 131
 //        }
132 132
 
133 133
         $popu_data = null;
134
-        $pids = $data->pluck('pid')->all();
134
+        $pids = [];
135
+        $pidVals = $data->pluck('pid')->all();
136
+        foreach ($pidVals as $pidVal) {
137
+            if (empty($pidVal)) continue;
138
+
139
+            $itemPids = json_decode($pidVal, true);
140
+            $pids = array_merge($pids, $itemPids);
141
+        }
142
+
135 143
         $pids = array_filter($pids);
136 144
         if( !empty($pids) ){
137 145
             $popu_data = MassPopularizData::selectRaw('sum(viewUv) as viewUv, sum(payPv) as payPv, sum(payUv) as payUv, sum(payMoney) as payMoney')->whereIn('pid', $pids)->first();

+ 5 - 5
app/Service/MassMsgService.php

@@ -122,12 +122,12 @@ class MassMsgService
122 122
                 }
123 123
             }
124 124
 
125
-            if (count($drawPids) > 1) {
126
-                Log::logError('提取推广链接PID存在多个值', $datum, $logName);
127
-                return false;
128
-            }
125
+//            if (count($drawPids) > 1) {
126
+//                Log::logError('提取推广链接PID存在多个值', $datum, $logName);
127
+//                return false;
128
+//            }
129 129
 
130
-            if (!empty($drawPids)) $pid = current($drawPids);
130
+            if (!empty($drawPids)) $pid = json_encode(array_filter($drawPids));
131 131
 
132 132
             Log::logInfo('提取结束', $attachments, $logName);
133 133
         }

+ 103 - 47
app/Service/PopularizService.php

@@ -44,8 +44,15 @@ class PopularizService
44 44
                 ->whereIn('rule_id', $ruleIds)->groupBy(['rule_id'])->get();
45 45
 
46 46
             #统计回收信息
47
-            $pids = $list->pluck('pid')->all();
48
-            $pids = array_filter($pids);
47
+            $pids = [];
48
+            $pidVals = $list->pluck('pid')->all();
49
+            foreach ($pidVals as $pidVal) {
50
+                if (empty($pidVal)) continue;
51
+
52
+                $itemPids = json_decode($pidVal, true);
53
+                $pids = array_merge($pids, $itemPids);
54
+            }
55
+
49 56
             if( !empty($pids) ){
50 57
                 $popu_data = MassPopularizData::select('viewPv', 'viewUv', 'payPv', 'payUv', 'payMoney', 'pid', 'playletActivityId')
51 58
                     ->whereIn('pid', $pids)
@@ -102,35 +109,57 @@ class PopularizService
102 109
                 $datum->send_total = isset($sendStatInfo->send_total) ? $sendStatInfo->send_total : 0;
103 110
                 unset($datum->admin_id);
104 111
 
105
-                $pid = $datum->pid;
112
+                $datumPids = json_decode($datum->pid, true);
106 113
                 #统计 总播放人数(:总uv)  充值人数 充值次数(今日) 充值金额(今日)   付费率 点击率
107
-                if($pid){
108
-                    $popu_info = $popu_data->where('pid', $pid)->first();
109
-
110
-                    $datum->viewUv = $popu_info->viewUv ?? null;
111
-                    $datum->payUv = $popu_info->payUv ?? null;
112
-                    $datum->payPv = $popu_info->payPv ?? null;
113
-                    $datum->payMoney = $popu_info->payMoney ?? null;
114
+                if($datumPids){
114 115
                     $datum->payAvg = $datum->payUv>0 ? round($datum->payPv/$datum->payUv, 2) : null;
115 116
                     $datum->payRate = $datum->viewUv>0 ? round($datum->payUv/$datum->viewUv*100, 2) .'%' : null;
116 117
                     $datum->clickRate = $datum->send_success>0 ? round($datum->viewUv/$datum->send_success*100, 2) .'%' : null;
117 118
 
118
-                    if(isset($popu_info->playletActivityId)) {
119
-                        $datum->newPayUv = $orderData[$popu_info->playletActivityId]['newPayUv'] ?? null;
120
-                        $datum->newPayPv = $orderData[$popu_info->playletActivityId]['newPayPv'] ?? null;
121
-                        $datum->newPayAmount = isset($orderData[$popu_info->playletActivityId]['newPayAmount']) ? round($orderData[$popu_info->playletActivityId]['newPayAmount']/10000, 2) : null;
122
-                        $datum->oldPayAmount = isset($orderData[$popu_info->playletActivityId]['oldPayAmount']) ? round($orderData[$popu_info->playletActivityId]['oldPayAmount']/10000, 2) : null;
123
-                        $datum->otherPayAmount = isset($otherOrderData[$popu_info->playletActivityId]['otherPayAmount']) ? round($otherOrderData[$popu_info->playletActivityId]['otherPayAmount']/10000, 2) : null;
119
+                    $popu_list = MassPopularizData::select('viewPv', 'viewUv', 'payPv', 'payUv', 'payMoney', 'pid', 'playletActivityId')
120
+                        ->whereIn('pid', $datumPids)
121
+                        ->get();
122
+                    if ($popu_list->isNotEmpty()) {
123
+                        $datum->viewUv         = 0;
124
+                        $datum->payUv          = 0;
125
+                        $datum->payPv          = 0;
126
+                        $datum->payMoney       = 0;
127
+                        $datum->newPayUv       = 0;
128
+                        $datum->newPayPv       = 0;
129
+                        $datum->newPayAmount   = 0;
130
+                        $datum->oldPayAmount   = 0;
131
+                        $datum->otherPayAmount = 0;
132
+                        foreach ($popu_list as $popu_info) {
133
+                            $datum->viewUv   += ($popu_info->viewUv ?? 0);
134
+                            $datum->payUv    += ($popu_info->payUv ?? 0);
135
+                            $datum->payPv    += ($popu_info->payPv ?? 0);
136
+                            $datum->payMoney += ($popu_info->payMoney ?? 0);
137
+
138
+                            if(isset($popu_info->playletActivityId)) {
139
+                                $datum->newPayUv       += ($orderData[$popu_info->playletActivityId]['newPayUv'] ?? 0);
140
+                                $datum->newPayPv       += ($orderData[$popu_info->playletActivityId]['newPayPv'] ?? 0);
141
+                                $datum->newPayAmount   += ($orderData[$popu_info->playletActivityId]['newPayAmount'] ?? 0);
142
+                                $datum->oldPayAmount   += ($orderData[$popu_info->playletActivityId]['oldPayAmount'] ?? 0);
143
+                                $datum->otherPayAmount += ($otherOrderData[$popu_info->playletActivityId]['otherPayAmount'] ?? 0);
144
+                            }
145
+                        }
146
+
147
+                        $datum->newPayAmount   = round($orderData[$popu_info->playletActivityId]['newPayAmount']/10000, 2);
148
+                        $datum->oldPayAmount   = round($orderData[$popu_info->playletActivityId]['oldPayAmount']/10000, 2);
149
+                        $datum->otherPayAmount = round($otherOrderData[$popu_info->playletActivityId]['otherPayAmount']/10000, 2);
150
+                        $datum->newPayAvg      = $datum->newPayUv>0 ? round($datum->newPayPv/$datum->newPayUv, 2) : null;
124 151
                     } else {
125
-                        $datum->newPayUv = null;
126
-                        $datum->newPayPv = null;
127
-                        $datum->newPayAmount = null;
128
-                        $datum->oldPayAmount = null;
152
+                        $datum->viewUv         = null;
153
+                        $datum->payUv          = null;
154
+                        $datum->payPv          = null;
155
+                        $datum->payMoney       = null;
156
+                        $datum->newPayUv       = null;
157
+                        $datum->newPayPv       = null;
158
+                        $datum->newPayAmount   = null;
159
+                        $datum->oldPayAmount   = null;
129 160
                         $datum->otherPayAmount = null;
161
+                        $datum->newPayAvg      = null;
130 162
                     }
131
-
132
-                    $datum->newPayAvg = $datum->newPayUv>0 ? round($datum->newPayPv/$datum->newPayUv, 2) : null;
133
-
134 163
                 } else {
135 164
                     $datum->viewUv = null;
136 165
                     $datum->payUv = null;
@@ -205,8 +234,15 @@ class PopularizService
205 234
                 ->whereIn('rule_id', $ruleIds)->groupBy(['rule_id'])->get();
206 235
 
207 236
             #统计回收信息
208
-            $pids = $list->pluck('pid')->all();
209
-            $pids = array_filter($pids);
237
+            $pids = [];
238
+            $pidVals = $list->pluck('pid')->all();
239
+            foreach ($pidVals as $pidVal) {
240
+                if (empty($pidVal)) continue;
241
+
242
+                $itemPids = json_decode($pidVal, true);
243
+                $pids = array_merge($pids, $itemPids);
244
+            }
245
+
210 246
             if( !empty($pids) ){
211 247
                 $popu_data = MassPopularizData::select('viewPv', 'viewUv', 'payPv', 'payUv', 'payMoney', 'pid', 'playletActivityId')
212 248
                     ->whereIn('pid', $pids)
@@ -259,35 +295,55 @@ class PopularizService
259 295
 
260 296
                 unset($datum->admin_id);
261 297
 
262
-                $pid = $datum->pid;
298
+                $datumPids = json_decode($datum->pid, true);
263 299
                 #统计 总播放人数(:总uv)  充值人数 充值次数(今日) 充值金额(今日)   付费率 点击率
264
-                if($pid){
265
-                    $popu_info = $popu_data->where('pid', $pid)->first();
266
-
267
-                    $datum->viewUv = $popu_info->viewUv ?? null;
268
-                    $datum->payUv = $popu_info->payUv ?? null;
269
-                    $datum->payPv = $popu_info->payPv ?? null;
270
-                    $datum->payMoney = $popu_info->payMoney ?? null;
300
+                if($datumPids){
271 301
                     $datum->payAvg = $datum->payUv>0 ? round($datum->payPv/$datum->payUv, 2) : null;
272 302
                     $datum->payRate = $datum->viewUv>0 ? round($datum->payUv/$datum->viewUv*100, 2) .'%' : null;
273 303
                     $datum->clickRate = $datum->published_count>0 ? round($datum->viewUv/$datum->published_count*100, 2) .'%' : null;
274 304
 
275
-                    if(isset($popu_info->playletActivityId)) {
276
-                        $datum->newPayUv = $orderData[$popu_info->playletActivityId]['newPayUv'] ?? null;
277
-                        $datum->newPayPv = $orderData[$popu_info->playletActivityId]['newPayPv'] ?? null;
278
-                        $datum->newPayAmount = isset($orderData[$popu_info->playletActivityId]['newPayAmount']) ? round($orderData[$popu_info->playletActivityId]['newPayAmount']/10000, 2) : null;
279
-                        $datum->oldPayAmount = isset($orderData[$popu_info->playletActivityId]['oldPayAmount']) ? round($orderData[$popu_info->playletActivityId]['oldPayAmount']/10000, 2) : null;
280
-                        $datum->otherPayAmount = isset($otherOrderData[$popu_info->playletActivityId]['otherPayAmount']) ? round($otherOrderData[$popu_info->playletActivityId]['otherPayAmount']/10000, 2) : null;
305
+                    $popu_list = MassPopularizData::select('viewPv', 'viewUv', 'payPv', 'payUv', 'payMoney', 'pid', 'playletActivityId')
306
+                        ->whereIn('pid', $datumPids)
307
+                        ->get();
308
+                    if ($popu_list->isNotEmpty()) {
309
+                        $datum->viewUv         = 0;
310
+                        $datum->payUv          = 0;
311
+                        $datum->payPv          = 0;
312
+                        $datum->payMoney       = 0;
313
+                        $datum->newPayUv       = 0;
314
+                        $datum->newPayPv       = 0;
315
+                        $datum->newPayAmount   = 0;
316
+                        $datum->oldPayAmount   = 0;
317
+                        $datum->otherPayAmount = 0;
318
+                        foreach ($popu_list as $popu_info) {
319
+                            $datum->viewUv   += ($popu_info->viewUv ?? 0);
320
+                            $datum->payUv    += ($popu_info->payUv ?? 0);
321
+                            $datum->payPv    += ($popu_info->payPv ?? 0);
322
+                            $datum->payMoney += ($popu_info->payMoney ?? 0);
323
+                            if(isset($popu_info->playletActivityId)) {
324
+                                $datum->newPayUv       += ($orderData[$popu_info->playletActivityId]['newPayUv'] ?? 0);
325
+                                $datum->newPayPv       += ($orderData[$popu_info->playletActivityId]['newPayPv'] ?? 0);
326
+                                $datum->newPayAmount   += ($orderData[$popu_info->playletActivityId]['newPayAmount'] ?? 0);
327
+                                $datum->oldPayAmount   += ($orderData[$popu_info->playletActivityId]['oldPayAmount'] ?? 0);
328
+                                $datum->otherPayAmount += ($otherOrderData[$popu_info->playletActivityId]['otherPayAmount'] ?? 0);
329
+                            }
330
+                        }
331
+                        $datum->newPayAmount   = round($orderData[$popu_info->playletActivityId]['newPayAmount']/10000, 2);
332
+                        $datum->oldPayAmount   = round($orderData[$popu_info->playletActivityId]['oldPayAmount']/10000, 2);
333
+                        $datum->otherPayAmount = round($otherOrderData[$popu_info->playletActivityId]['otherPayAmount']/10000, 2);
334
+                        $datum->newPayAvg      = $datum->newPayUv>0 ? round($datum->newPayPv/$datum->newPayUv, 2) : null;
281 335
                     } else {
282
-                        $datum->newPayUv = null;
283
-                        $datum->newPayPv = null;
284
-                        $datum->newPayAmount = null;
285
-                        $datum->oldPayAmount = null;
286
-                        $datum->otherPayAmount = null;
336
+                        $datum->viewUv         = 0;
337
+                        $datum->payUv          = 0;
338
+                        $datum->payPv          = 0;
339
+                        $datum->payMoney       = 0;
340
+                        $datum->newPayUv       = 0;
341
+                        $datum->newPayPv       = 0;
342
+                        $datum->newPayAmount   = 0;
343
+                        $datum->oldPayAmount   = 0;
344
+                        $datum->otherPayAmount = 0;
345
+                        $datum->newPayAvg      = 0;
287 346
                     }
288
-
289
-                    $datum->newPayAvg = $datum->newPayUv>0 ? round($datum->newPayPv/$datum->newPayUv, 2) : null;
290
-
291 347
                 } else {
292 348
                     $datum->viewUv = null;
293 349
                     $datum->payUv = null;