diff --git a/app/Admin/Repositories/MiniProgramDraft.php b/app/Admin/Repositories/MiniProgramDraft.php index 2f5bf75..9da52c9 100644 --- a/app/Admin/Repositories/MiniProgramDraft.php +++ b/app/Admin/Repositories/MiniProgramDraft.php @@ -7,6 +7,7 @@ use Dcat\Admin\Repositories\Repository; use EasyWeChat\Factory; use GuzzleHttp\Exception\GuzzleException; use Illuminate\Pagination\LengthAwarePaginator; +use Illuminate\Support\Facades\Cache; /** * 小程序草稿箱 @@ -15,10 +16,7 @@ use Illuminate\Pagination\LengthAwarePaginator; */ class MiniProgramDraft extends Repository { - public function getPrimaryKeyColumn() - { - return 'draft_id'; - } + protected $keyName = 'draft_id'; /** * 查询表格数据 @@ -37,15 +35,21 @@ class MiniProgramDraft extends Repository 'aes_key' => $setting['service_aeskey'], ]; - $openPlatform = Factory::openPlatform($config); - $codeTemplate = $openPlatform['code_template']; - - if (empty($codeTemplate) || (!$list = $codeTemplate->getDrafts())) { - $data['total'] = 0; - $data['subjects'] = []; + $cache_key = 'mini_program:draft_list'; + if ($data['subjects'] = Cache::get($cache_key)) { + $data['total'] = count($data['subjects']); } else { - $data['total'] = count($list['draft_list']); - $data['subjects'] = $list['draft_list'] ?? []; + $openPlatform = Factory::openPlatform($config); + $codeTemplate = $openPlatform['code_template']; + + if (empty($codeTemplate) || (!$list = $codeTemplate->getDrafts())) { + $data['total'] = 0; + $data['subjects'] = []; + } else { + $data['total'] = count($list['draft_list']); + $data['subjects'] = $list['draft_list'] ?? []; + Cache::put($cache_key, $list['draft_list'], 120); + } } return $model->makePaginator( diff --git a/app/Admin/Repositories/MiniProgramList.php b/app/Admin/Repositories/MiniProgramList.php index cbb99d6..bb88508 100644 --- a/app/Admin/Repositories/MiniProgramList.php +++ b/app/Admin/Repositories/MiniProgramList.php @@ -7,6 +7,7 @@ use Dcat\Admin\Repositories\Repository; use EasyWeChat\Factory; use GuzzleHttp\Exception\GuzzleException; use Illuminate\Pagination\LengthAwarePaginator; +use Illuminate\Support\Facades\Cache; /** * 小程序草稿箱 @@ -15,10 +16,7 @@ use Illuminate\Pagination\LengthAwarePaginator; */ class MiniProgramList extends Repository { - public function getPrimaryKeyColumn() - { - return ''; - } + protected $keyName = 'id'; /** * 查询表格数据 @@ -37,15 +35,21 @@ class MiniProgramList extends Repository 'aes_key' => $setting['service_aeskey'], ]; - $openPlatform = Factory::openPlatform($config); - $codeTemplate = $openPlatform['code_template']; - - if (empty($codeTemplate) || (!$list = $openPlatform->getAuthorizers())) { - $data['total'] = 0; - $data['subjects'] = []; + $cache_key = 'mini_program:list'; + if ($data['subjects'] = Cache::get($cache_key)) { + $data['total'] = count($data['subjects']); } else { - $data['total'] = count($list['list']); - $data['subjects'] = $list['list'] ?? []; + $openPlatform = Factory::openPlatform($config); + $codeTemplate = $openPlatform['code_template']; + + if (empty($codeTemplate) || (!$list = $openPlatform->getAuthorizers())) { + $data['total'] = 0; + $data['subjects'] = []; + } else { + $data['total'] = count($list['list']); + $data['subjects'] = $list['list'] ?? []; + Cache::put($cache_key, $list['list'], 120); + } } return $model->makePaginator( diff --git a/app/Admin/Repositories/MiniProgramTemplate.php b/app/Admin/Repositories/MiniProgramTemplate.php index 8883848..b1651b5 100644 --- a/app/Admin/Repositories/MiniProgramTemplate.php +++ b/app/Admin/Repositories/MiniProgramTemplate.php @@ -7,6 +7,7 @@ use Dcat\Admin\Repositories\Repository; use EasyWeChat\Factory; use GuzzleHttp\Exception\GuzzleException; use Illuminate\Pagination\LengthAwarePaginator; +use Illuminate\Support\Facades\Cache; /** * 小程序模板 @@ -15,10 +16,7 @@ use Illuminate\Pagination\LengthAwarePaginator; */ class MiniProgramTemplate extends Repository { - public function getPrimaryKeyColumn() - { - return 'template_id'; - } + protected $keyName = 'template_id'; /** * 查询表格数据 @@ -37,15 +35,21 @@ class MiniProgramTemplate extends Repository 'aes_key' => $setting['service_aeskey'], ]; - $openPlatform = Factory::openPlatform($config); - $codeTemplate = $openPlatform['code_template']; - - if (empty($codeTemplate) || (!$list = $codeTemplate->list())) { - $data['total'] = 0; - $data['subjects'] = []; + $cache_key = 'mini_program:template_list'; + if ($data['subjects'] = Cache::get($cache_key)) { + $data['total'] = count($data['subjects']); } else { - $data['total'] = count($list['template_list']); - $data['subjects'] = $list['template_list'] ?? []; + $openPlatform = Factory::openPlatform($config); + $codeTemplate = $openPlatform['code_template']; + + if (empty($codeTemplate) || (!$list = $codeTemplate->list())) { + $data['total'] = 0; + $data['subjects'] = []; + } else { + $data['total'] = count($list['template_list']); + $data['subjects'] = $list['template_list'] ?? []; + Cache::put($cache_key, $list['template_list'], 120); + } } return $model->makePaginator( diff --git a/app/Http/Controllers/Api/OrderController.php b/app/Http/Controllers/Api/OrderController.php index 88b46b1..c931106 100644 --- a/app/Http/Controllers/Api/OrderController.php +++ b/app/Http/Controllers/Api/OrderController.php @@ -86,7 +86,9 @@ class OrderController extends Controller Status::OFFLINE_UNPAID => '线下付款', Status::PAY_EARNEST => '付尾款', ]; - $v['status_text'] = '请在' . ceil($second / 60) . "分钟内" . ($text_arr[$v['status']] ?? '付款'); + if (isset($text_arr[$v['status']])) { + $v['status_text'] = '请在' . ceil($second / 60) . "分钟内" . ($text_arr[$v['status']] ?? '付款'); + } } else if ($second < 0 && $v['status'] == Status::PAY_EARNEST) { $v['status_text'] = '尾款支付已超时'; } /*else { //此部分由定时处理 diff --git a/resources/views/admin/filter/select.blade.php b/resources/views/admin/filter/select.blade.php index cd4b359..29594c9 100644 --- a/resources/views/admin/filter/select.blade.php +++ b/resources/views/admin/filter/select.blade.php @@ -3,10 +3,10 @@ {!! $label !!} - @foreach($options as $select => $option) - + @endforeach