作者 Your Name

Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev

... ... @@ -26,6 +26,9 @@ class CategoryController extends BaseController
}
$sort = ['id' => 'desc'];
$data = $logic->getList($map, $sort, ['id', 'pid', 'title', 'image', 'keywords', 'describe', 'status','created_at'],0);
foreach ($data as &$v){
$v['product_num'] = $logic->getProductNum($v['id']);
}
return $this->success(Arr::listToTree($data));
}
... ...
<?php
namespace App\Http\Controllers\Bside\Project;
use App\Http\Controllers\Bside\BaseController;
class CountryController extends BaseController
{
/**
* @name :lists
* @author :lyh
* @method :post
* @time :2023/4/28 14:49
*/
public function lists(){
}
}
<?php
namespace App\Http\Controllers\Bside\Setting;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Setting\ProjectCountryLogic;
class ProjectCountryController extends BaseController
{
/**
* @name :(当前项目的多语言列表)lists
* @author :lyh
* @method :post
* @time :2023/4/28 14:49
*/
public function info(ProjectCountryLogic $projectCountryLogic){
$lists = $projectCountryLogic->country_info();
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @name :(更新当前项目多语言设置)edit
* @author :lyh
* @method :post
* @time :2023/4/28 17:53
*/
public function edit(ProjectCountryLogic $projectCountryLogic){
$projectCountryLogic->country_edit();
$this->response('success');
}
}
... ...
... ... @@ -19,15 +19,4 @@ class WebSettingCountryController extends BaseController
$lists = $webSettingCountryLogic->country_list();
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @name :(获取当前项目设置的多语言列表)user_get_list
* @author :lyh
* @method :post
* @time :2023/4/28 16:55
*/
public function get_country_info(WebSettingCountryLogic $webSettingCountryLogic){
$info = $webSettingCountryLogic->get_country_info();
$this->response('success',Code::SUCCESS,$info);
}
}
... ...
... ... @@ -54,4 +54,16 @@ class CategoryLogic extends BaseLogic
}
return parent::delete($ids);
}
/**
* 关联产品数量
* @param $cate_id
* @return mixed
* @author zbj
* @date 2023/4/28
*/
public function getProductNum($cate_id){
$ids = $this->model->getChildIdsArr($cate_id);
return CategoryRelated::whereIn('cate_id', $ids)->count();
}
}
... ...
<?php
namespace App\Http\Logic\Bside\Setting;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Project\Country as CountryModel;
class ProjectCountryLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new CountryModel();
$this->param = $this->requestAll;
}
/**
* @name :(获取当前项目关联的多语言)get_country_info
* @author :lyh
* @method :post
* @time :2023/4/28 17:03
*/
public function country_info(){
$lists = $this->model->read(['project_id'=>$this->param['project_id']]);
if (empty($lists)){
$this->fail('当前数据不存在');
}
return $this->success($lists);
}
/**
* @name :(更新多语言设置)country_edit
* @author :lyh
* @method :post
* @time :2023/4/28 17:42
*/
public function country_edit(){
$rs = $this->model->edit($this->param,['project_id'=>$this->param['project_id']]);
if($rs === false){
$this->fail('当前数据不存在');
}
return $this->success();
}
}
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Http\Logic\Bside\Setting;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Project\Country;
use App\Models\Project\Country as CountryModel;
use App\Models\WebSetting\WebSettingCountry;
... ... @@ -23,25 +24,16 @@ class WebSettingCountryLogic extends BaseLogic
* @time :2023/4/28 16:18
*/
public function country_list(){
$settingCountryModel = new WebSettingCountry();
$lists = $settingCountryModel->list($this->param,'id',['id','name','image']);
$lists = $this->model->list($this->param,'id',['id','name','image']);
if (empty($lists)){
$this->fail('当前数据不存在');
}
return $this->success($lists);
}
/**
* @name :(获取当前项目关联的多语言)get_country_info
* @author :lyh
* @method :post
* @time :2023/4/28 17:03
*/
public function get_country_info(){
$lists = $this->model->read(['project_id'=>$this->param['project_id']]);
if (empty($lists)){
$this->fail('当前数据不存在');
}
return $this->success($lists);
public function edit_country(){
return $this->success();
}
}
... ...
... ... @@ -14,6 +14,12 @@ class Category extends Base
//设置关联表名
protected $table = 'gl_product_category';
/**
* 子分类
* @var array
*/
protected $child_ids_arr = [];
public function getImageAttribute($value)
{
return Upload::path2url($value);
... ... @@ -23,4 +29,37 @@ class Category extends Base
{
$this->attributes['image'] = Upload::url2path($value);
}
/**
* 获取指定分类的所有子分类IDS(包括自己)
* @param $id
* @return array
* @author zbj
* @date 2023/4/28
*/
public function getChildIdsArr($id)
{
$this->child_ids_arr = [$id];
return $this->getChildrenIdArr($id);
}
/**
* 递归获取指定分类的所有子孙
* @param $id
* @return array
* @author zbj
* @date 2023/4/28
*/
protected function getChildrenIdArr($id)
{
$list = parent::where("pid", $id)->pluck('pid', 'id');
if ($list) {
foreach ($list as $id => $pid) {
$this->child_ids_arr[] = $id;
$this->getChildrenIdArr($id);
}
}
return $this->child_ids_arr;
}
}
... ...
... ... @@ -112,8 +112,13 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\Setting\WebSettingController::class, 'lists'])->name('web_setting_lists');
Route::any('/save', [\App\Http\Controllers\Bside\Setting\WebSettingController::class, 'save'])->name('web_setting_save');
//多语言设置
Route::any('/country/', [\App\Http\Controllers\Bside\Setting\WebSettingCountryController::class, 'lists'])->name('web_setting_country_lists');
Route::any('/country/get_country_info', [\App\Http\Controllers\Bside\Setting\WebSettingCountryController::class, 'get_country_info'])->name('web_setting_country_info');
Route::prefix('country')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\Setting\WebSettingCountryController::class, 'lists'])->name('web_setting_country_lists');
//项目多语言设置详情
Route::any('/info', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'info'])->name('web_setting_country_info');
Route::any('/edit', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'edit'])->name('web_setting_country_edit');
});
});
//产品
Route::prefix('product')->group(function () {
... ...