shensong лет назад: 5
Родитель
Сommit
02b0dc1470
1 измененных файлов с 9 добавлено и 6 удалено
  1. 9 6
      app/Order.php

+ 9 - 6
app/Order.php

@@ -310,9 +310,9 @@ class Order extends Model
310 310
     /*更新城市天气信息*/
311 311
     public static function updateWeather($order_id) {
312 312
         $redisKey = 'seafood_order_city_weather';
313
-        $appKey = self::getAppKey();
313
+
314 314
         //查询订单收件人所在的城市(过滤关键字 市)
315
-        $city = self::where('id', $order_id)->pluck('receiverCity');
315
+        $city = Order::where('id', $order_id)->pluck('receiverCity');
316 316
         $city = str_replace('市','',$city);
317 317
         $specialCity = array('朝阳区','嘉定区','海淀区','昌平区','密云区','大兴区','房山区','通州区','普陀区',);
318 318
         if(in_array($city, $specialCity)) {
@@ -321,13 +321,15 @@ class Order extends Model
321 321
         //查询redis中是否有该键,若没有则查询
322 322
         $weather = RedisModel::get($redisKey.'_'.$city);
323 323
         if($weather) {
324
-            $sellerMemo = self::where('id', $order_id)->pluck('sellerMemo');
324
+            $sellerMemo = Order::where('id', $order_id)->pluck('sellerMemo');
325 325
             if(strstr($sellerMemo, $city.'天气状况:'.$weather)) {
326 326
                 return true;
327 327
             }
328 328
             $sellerMemo = $sellerMemo.'  '.$city.'天气状况:'.$weather;
329
-            self::where('id', $order_id)->update(['sellerMemo'=>$sellerMemo]);
329
+            Log::errorLog(['order_id'=>$order_id, 'city'=> $city , 'app_key'=>''],['weather'=>$weather],"order/weather",1,'');
330
+            Order::where('id', $order_id)->update(['sellerMemo'=>$sellerMemo]);
330 331
         } else {
332
+            $appKey = self::getAppKey();
331 333
             $url = 'http://apis.juhe.cn/simpleWeather/query?city='.urlencode($city).'&key='.$appKey;
332 334
             $result = file_get_contents($url);
333 335
             $result = json_decode($result, true);
@@ -349,12 +351,13 @@ class Order extends Model
349 351
                 $endTime = strtotime(date('Y-m-d 00:00:00',strtotime('+1 days'))) -1;
350 352
                 $expire = $endTime - time();
351 353
                 RedisModel::expire($redisKey.'_'.$city, $expire);
352
-                $sellerMemo = self::where('id', $order_id)->pluck('sellerMemo');
354
+                $sellerMemo = Order::where('id', $order_id)->pluck('sellerMemo');
353 355
                 if(strstr($sellerMemo, $city.'天气状况:'.$weather)) {
354 356
                     return true;
355 357
                 }
356 358
                 $sellerMemo = $sellerMemo.'  '.$city.'天气状况:'.$weather;
357
-                self::where('id', $order_id)->update(['sellerMemo'=>$sellerMemo]);
359
+                Log::errorLog(['order_id'=>$order_id, 'city'=> $city , 'app_key'=>$appKey],['weather'=>$weather],"order/weather",1,'');
360
+                Order::where('id', $order_id)->update(['sellerMemo'=>$sellerMemo]);
358 361
             } else if($result['error_code'] == '10012'){
359 362
                 //判断是否为第二个APPkey也用完了
360 363
                 $key = (string) RedisModel::get('seafood_order_city_weather_key');