Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev
正在显示
9 个修改的文件
包含
143 行增加
和
45 行删除
| @@ -26,6 +26,9 @@ class CategoryController extends BaseController | @@ -26,6 +26,9 @@ class CategoryController extends BaseController | ||
| 26 | } | 26 | } |
| 27 | $sort = ['id' => 'desc']; | 27 | $sort = ['id' => 'desc']; |
| 28 | $data = $logic->getList($map, $sort, ['id', 'pid', 'title', 'image', 'keywords', 'describe', 'status','created_at'],0); | 28 | $data = $logic->getList($map, $sort, ['id', 'pid', 'title', 'image', 'keywords', 'describe', 'status','created_at'],0); |
| 29 | + foreach ($data as &$v){ | ||
| 30 | + $v['product_num'] = $logic->getProductNum($v['id']); | ||
| 31 | + } | ||
| 29 | return $this->success(Arr::listToTree($data)); | 32 | return $this->success(Arr::listToTree($data)); |
| 30 | } | 33 | } |
| 31 | 34 |
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Http\Controllers\Bside\Project; | ||
| 4 | - | ||
| 5 | -use App\Http\Controllers\Bside\BaseController; | ||
| 6 | - | ||
| 7 | -class CountryController extends BaseController | ||
| 8 | -{ | ||
| 9 | - /** | ||
| 10 | - * @name :lists | ||
| 11 | - * @author :lyh | ||
| 12 | - * @method :post | ||
| 13 | - * @time :2023/4/28 14:49 | ||
| 14 | - */ | ||
| 15 | - public function lists(){ | ||
| 16 | - | ||
| 17 | - } | ||
| 18 | -} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Bside\Setting; | ||
| 4 | + | ||
| 5 | +use App\Enums\Common\Code; | ||
| 6 | +use App\Http\Controllers\Bside\BaseController; | ||
| 7 | +use App\Http\Logic\Bside\Setting\ProjectCountryLogic; | ||
| 8 | + | ||
| 9 | +class ProjectCountryController extends BaseController | ||
| 10 | +{ | ||
| 11 | + /** | ||
| 12 | + * @name :(当前项目的多语言列表)lists | ||
| 13 | + * @author :lyh | ||
| 14 | + * @method :post | ||
| 15 | + * @time :2023/4/28 14:49 | ||
| 16 | + */ | ||
| 17 | + public function info(ProjectCountryLogic $projectCountryLogic){ | ||
| 18 | + $lists = $projectCountryLogic->country_info(); | ||
| 19 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * @name :(更新当前项目多语言设置)edit | ||
| 24 | + * @author :lyh | ||
| 25 | + * @method :post | ||
| 26 | + * @time :2023/4/28 17:53 | ||
| 27 | + */ | ||
| 28 | + public function edit(ProjectCountryLogic $projectCountryLogic){ | ||
| 29 | + $projectCountryLogic->country_edit(); | ||
| 30 | + $this->response('success'); | ||
| 31 | + } | ||
| 32 | +} |
| @@ -19,15 +19,4 @@ class WebSettingCountryController extends BaseController | @@ -19,15 +19,4 @@ class WebSettingCountryController extends BaseController | ||
| 19 | $lists = $webSettingCountryLogic->country_list(); | 19 | $lists = $webSettingCountryLogic->country_list(); |
| 20 | $this->response('success',Code::SUCCESS,$lists); | 20 | $this->response('success',Code::SUCCESS,$lists); |
| 21 | } | 21 | } |
| 22 | - | ||
| 23 | - /** | ||
| 24 | - * @name :(获取当前项目设置的多语言列表)user_get_list | ||
| 25 | - * @author :lyh | ||
| 26 | - * @method :post | ||
| 27 | - * @time :2023/4/28 16:55 | ||
| 28 | - */ | ||
| 29 | - public function get_country_info(WebSettingCountryLogic $webSettingCountryLogic){ | ||
| 30 | - $info = $webSettingCountryLogic->get_country_info(); | ||
| 31 | - $this->response('success',Code::SUCCESS,$info); | ||
| 32 | - } | ||
| 33 | } | 22 | } |
| @@ -54,4 +54,16 @@ class CategoryLogic extends BaseLogic | @@ -54,4 +54,16 @@ class CategoryLogic extends BaseLogic | ||
| 54 | } | 54 | } |
| 55 | return parent::delete($ids); | 55 | return parent::delete($ids); |
| 56 | } | 56 | } |
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * 关联产品数量 | ||
| 60 | + * @param $cate_id | ||
| 61 | + * @return mixed | ||
| 62 | + * @author zbj | ||
| 63 | + * @date 2023/4/28 | ||
| 64 | + */ | ||
| 65 | + public function getProductNum($cate_id){ | ||
| 66 | + $ids = $this->model->getChildIdsArr($cate_id); | ||
| 67 | + return CategoryRelated::whereIn('cate_id', $ids)->count(); | ||
| 68 | + } | ||
| 57 | } | 69 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Logic\Bside\Setting; | ||
| 4 | + | ||
| 5 | +use App\Http\Logic\Bside\BaseLogic; | ||
| 6 | +use App\Models\Project\Country as CountryModel; | ||
| 7 | + | ||
| 8 | +class ProjectCountryLogic extends BaseLogic | ||
| 9 | +{ | ||
| 10 | + public function __construct() | ||
| 11 | + { | ||
| 12 | + parent::__construct(); | ||
| 13 | + | ||
| 14 | + $this->model = new CountryModel(); | ||
| 15 | + $this->param = $this->requestAll; | ||
| 16 | + } | ||
| 17 | + /** | ||
| 18 | + * @name :(获取当前项目关联的多语言)get_country_info | ||
| 19 | + * @author :lyh | ||
| 20 | + * @method :post | ||
| 21 | + * @time :2023/4/28 17:03 | ||
| 22 | + */ | ||
| 23 | + public function country_info(){ | ||
| 24 | + $lists = $this->model->read(['project_id'=>$this->param['project_id']]); | ||
| 25 | + if (empty($lists)){ | ||
| 26 | + $this->fail('当前数据不存在'); | ||
| 27 | + } | ||
| 28 | + return $this->success($lists); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * @name :(更新多语言设置)country_edit | ||
| 33 | + * @author :lyh | ||
| 34 | + * @method :post | ||
| 35 | + * @time :2023/4/28 17:42 | ||
| 36 | + */ | ||
| 37 | + public function country_edit(){ | ||
| 38 | + $rs = $this->model->edit($this->param,['project_id'=>$this->param['project_id']]); | ||
| 39 | + if($rs === false){ | ||
| 40 | + $this->fail('当前数据不存在'); | ||
| 41 | + } | ||
| 42 | + return $this->success(); | ||
| 43 | + } | ||
| 44 | +} |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Http\Logic\Bside\Setting; | 3 | namespace App\Http\Logic\Bside\Setting; |
| 4 | 4 | ||
| 5 | use App\Http\Logic\Bside\BaseLogic; | 5 | use App\Http\Logic\Bside\BaseLogic; |
| 6 | +use App\Models\Project\Country; | ||
| 6 | use App\Models\Project\Country as CountryModel; | 7 | use App\Models\Project\Country as CountryModel; |
| 7 | use App\Models\WebSetting\WebSettingCountry; | 8 | use App\Models\WebSetting\WebSettingCountry; |
| 8 | 9 | ||
| @@ -23,25 +24,16 @@ class WebSettingCountryLogic extends BaseLogic | @@ -23,25 +24,16 @@ class WebSettingCountryLogic extends BaseLogic | ||
| 23 | * @time :2023/4/28 16:18 | 24 | * @time :2023/4/28 16:18 |
| 24 | */ | 25 | */ |
| 25 | public function country_list(){ | 26 | public function country_list(){ |
| 26 | - $settingCountryModel = new WebSettingCountry(); | ||
| 27 | - $lists = $settingCountryModel->list($this->param,'id',['id','name','image']); | 27 | + $lists = $this->model->list($this->param,'id',['id','name','image']); |
| 28 | if (empty($lists)){ | 28 | if (empty($lists)){ |
| 29 | $this->fail('当前数据不存在'); | 29 | $this->fail('当前数据不存在'); |
| 30 | } | 30 | } |
| 31 | return $this->success($lists); | 31 | return $this->success($lists); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | - /** | ||
| 35 | - * @name :(获取当前项目关联的多语言)get_country_info | ||
| 36 | - * @author :lyh | ||
| 37 | - * @method :post | ||
| 38 | - * @time :2023/4/28 17:03 | ||
| 39 | - */ | ||
| 40 | - public function get_country_info(){ | ||
| 41 | - $lists = $this->model->read(['project_id'=>$this->param['project_id']]); | ||
| 42 | - if (empty($lists)){ | ||
| 43 | - $this->fail('当前数据不存在'); | ||
| 44 | - } | ||
| 45 | - return $this->success($lists); | 34 | + |
| 35 | + public function edit_country(){ | ||
| 36 | + | ||
| 37 | + return $this->success(); | ||
| 46 | } | 38 | } |
| 47 | } | 39 | } |
| @@ -14,6 +14,12 @@ class Category extends Base | @@ -14,6 +14,12 @@ class Category extends Base | ||
| 14 | //设置关联表名 | 14 | //设置关联表名 |
| 15 | protected $table = 'gl_product_category'; | 15 | protected $table = 'gl_product_category'; |
| 16 | 16 | ||
| 17 | + /** | ||
| 18 | + * 子分类 | ||
| 19 | + * @var array | ||
| 20 | + */ | ||
| 21 | + protected $child_ids_arr = []; | ||
| 22 | + | ||
| 17 | public function getImageAttribute($value) | 23 | public function getImageAttribute($value) |
| 18 | { | 24 | { |
| 19 | return Upload::path2url($value); | 25 | return Upload::path2url($value); |
| @@ -23,4 +29,37 @@ class Category extends Base | @@ -23,4 +29,37 @@ class Category extends Base | ||
| 23 | { | 29 | { |
| 24 | $this->attributes['image'] = Upload::url2path($value); | 30 | $this->attributes['image'] = Upload::url2path($value); |
| 25 | } | 31 | } |
| 32 | + | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * 获取指定分类的所有子分类IDS(包括自己) | ||
| 36 | + * @param $id | ||
| 37 | + * @return array | ||
| 38 | + * @author zbj | ||
| 39 | + * @date 2023/4/28 | ||
| 40 | + */ | ||
| 41 | + public function getChildIdsArr($id) | ||
| 42 | + { | ||
| 43 | + $this->child_ids_arr = [$id]; | ||
| 44 | + return $this->getChildrenIdArr($id); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 递归获取指定分类的所有子孙 | ||
| 49 | + * @param $id | ||
| 50 | + * @return array | ||
| 51 | + * @author zbj | ||
| 52 | + * @date 2023/4/28 | ||
| 53 | + */ | ||
| 54 | + protected function getChildrenIdArr($id) | ||
| 55 | + { | ||
| 56 | + $list = parent::where("pid", $id)->pluck('pid', 'id'); | ||
| 57 | + if ($list) { | ||
| 58 | + foreach ($list as $id => $pid) { | ||
| 59 | + $this->child_ids_arr[] = $id; | ||
| 60 | + $this->getChildrenIdArr($id); | ||
| 61 | + } | ||
| 62 | + } | ||
| 63 | + return $this->child_ids_arr; | ||
| 64 | + } | ||
| 26 | } | 65 | } |
| @@ -112,8 +112,13 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -112,8 +112,13 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 112 | Route::any('/', [\App\Http\Controllers\Bside\Setting\WebSettingController::class, 'lists'])->name('web_setting_lists'); | 112 | Route::any('/', [\App\Http\Controllers\Bside\Setting\WebSettingController::class, 'lists'])->name('web_setting_lists'); |
| 113 | Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingController::class, 'save'])->name('web_setting_save'); | 113 | Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingController::class, 'save'])->name('web_setting_save'); |
| 114 | //多语言设置 | 114 | //多语言设置 |
| 115 | - Route::any('/country/', [\App\Http\Controllers\Bside\Setting\WebSettingCountryController::class, 'lists'])->name('web_setting_country_lists'); | ||
| 116 | - Route::any('/country/get_country_info', [\App\Http\Controllers\Bside\Setting\WebSettingCountryController::class, 'get_country_info'])->name('web_setting_country_info'); | 115 | + Route::prefix('country')->group(function () { |
| 116 | + Route::any('/', [\App\Http\Controllers\Bside\Setting\WebSettingCountryController::class, 'lists'])->name('web_setting_country_lists'); | ||
| 117 | + //项目多语言设置详情 | ||
| 118 | + Route::any('/info', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'info'])->name('web_setting_country_info'); | ||
| 119 | + Route::any('/edit', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'edit'])->name('web_setting_country_edit'); | ||
| 120 | + }); | ||
| 121 | + | ||
| 117 | }); | 122 | }); |
| 118 | //产品 | 123 | //产品 |
| 119 | Route::prefix('product')->group(function () { | 124 | Route::prefix('product')->group(function () { |
-
请 注册 或 登录 后发表评论