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