| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- /**
- * @package merchant
- *
- * @author xaboy
- * @day 2020/6/17
- *
- *
- */
- namespace crmeb\services;
- use think\facade\Cache;
- class ExpressService
- {
- const API = 'https://wuliu.market.alicloudapi.com/kdi';
- public static function query($no, $type = '')
- {
- $appCode = systemConfig('express_app_code');
- if (!$appCode) return false;
- $res = HttpService::getRequest(self::API, compact('no'), ['Authorization:APPCODE ' . $appCode]);
- return json_decode($res, true) ?: null;
- }
- public static function express($delivery_id, $delivery_type = 1)
- {
- // 虚拟发货不返回物流信息
- if ($delivery_type == 3) {
- return [];
- }
- if (Cache::has('express_' . $delivery_id)) {
- $result = Cache::get('express_' . $delivery_id);
- } else {
- $result = self::query($delivery_id);
- if (is_array($result) &&
- isset($result['result']) &&
- isset($result['result']['deliverystatus']) &&
- $result['result']['deliverystatus'] >= 3)
- $cacheTime = 0;
- else
- $cacheTime = 1800;
- $result = $result['result']['list'] ?? [];
- Cache::set('express_' . $delivery_id, $result, $cacheTime);
- }
- return $result;
- }
- }
|