Browse Source

fix get pv

OMEGA\EricYH.Huang 3 years ago
parent
commit
1abbd2d425

+ 5
- 6
app/Http/Controllers/Api/GeneralInnerServiceController.php View File

@@ -173,15 +173,14 @@ class GeneralInnerServiceController extends Controller
173 173
         // 鑒權
174 174
         if ($this->oid == 0) return json_decode(json_encode(['code' => $this->apicode, 'msg' => GeneralConst::$apiMap[ $this->apicode ], 'data' => []], JSON_NUMERIC_CHECK), true);
175 175
         // 服務層
176
-        $orlId = $request->input('orlId');
177
-        $result = $this->urlManagementSv->takeOrlPV($orlId, $this->oid);
176
+        $orlIds = $request->input('orlId');
177
+        $result = $this->urlManagementSv->takeOrlPV($orlIds, $this->oid);
178 178
         // 整理返回資料
179 179
         $data = [];
180 180
         if (!empty($result)) {
181
-            $data = [
182
-                'id'      => $result["serno"],
183
-                'pv'    => $result["pv"],
184
-            ];
181
+            foreach($result as $dataPV){
182
+                $data[$dataPV["serno"]] = $dataPV["pv"];
183
+            }
185 184
         }
186 185
         // 返回
187 186
         return json_decode(json_encode(['code' => GeneralConst::API_OK, 'msg' => GeneralConst::$apiMap[ GeneralConst::API_OK ], 'data' => $data], JSON_NUMERIC_CHECK), true);       

+ 3
- 3
app/Http/Services/Backend/DataManagement/UrlManagementService.php View File

@@ -177,7 +177,7 @@ class UrlManagementService
177 177
         return $url;
178 178
     }
179 179
     
180
-    public function takeOrlPV($id, $oid)
180
+    public function takeOrlPV($ids, $oid)
181 181
     {
182 182
         // 取得參數
183 183
         // 調用資料庫(或者其他業務邏輯)
@@ -203,8 +203,8 @@ class UrlManagementService
203 203
                 ->where('oid', '=', $oid);
204 204
         }
205 205
         $url = $url
206
-            ->where('serno', $id)
207
-            ->first();
206
+            ->whereIn('serno', $ids)
207
+            ->get();
208 208
         if (is_null($url)) {
209 209
             return [];
210 210
         }