作者 张关杰

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

... ... @@ -109,7 +109,7 @@ class FileManageController extends BaseController
$fileName = $enName;
$i=1;
while($this->onlyName($enName.'.'.$nameArr[1],$project_id)){
$enName = $fileName .'_'.$i;
$enName = $fileName .'-'.$i;
$i++;
}
return $enName.'.'.$nameArr[1];
... ...
... ... @@ -33,9 +33,11 @@ class NavController extends BaseController
$lists = $nav->list($this->map,$this->order = ['sort','id'],['*'],'asc');
$data = array();
if(!empty($lists)){
foreach ($lists as $k => $v){
$v = $this->handleReturnInfo((array)$v);
$lists[$k] = $v;
}
foreach ($lists as $v){
$v = (array)$v;
$v = $this->handleReturnInfo($v);
if ($v['pid'] == 0) {
$v['sub'] = _get_child($v['id'], $lists);
$data[] = $v;
... ...
... ... @@ -443,7 +443,7 @@ class ProductController extends BaseController
}
/**
* @remark :批量设置产品分类及状态
* @remark :批量设置产品分类
* @name :batchSetCategory
* @author :lyh
* @method :post
... ... @@ -453,11 +453,9 @@ class ProductController extends BaseController
$this->request->validate([
'id'=>'required',
'category_id'=>'required',
'status'=>'required'
],[
'id.required' => '产品ID不能为空',
'category_id.required' => '分类ID不能为空',
'status.required'=>'状态不能为空'
]);
$logic->batchSetCategory();
$this->response('success');
... ...
... ... @@ -169,7 +169,7 @@ class FileController
$fileName = $enName;
$i=1;
while($this->onlyName($enName.'.'.$nameArr[1],$project_id)){
$enName = $fileName .'_'.$i;
$enName = $fileName .'-'.$i;
$i++;
}
return $enName.'.'.$nameArr[1];
... ...
... ... @@ -229,7 +229,7 @@ class ImageController extends Controller
$fileName = $enName;
$i=1;
while($this->onlyName($enName.'.'.$nameArr[1],$project_id)){
$enName = $fileName .'_'.$i;
$enName = $fileName .'-'.$i;
$i++;
}
return $enName.'.'.$nameArr[1];
... ...
... ... @@ -335,22 +335,6 @@ class ProductLogic extends BaseLogic
return !empty(trim($str,',')) ? ','.$str.',' : '';
}
/**
* @remark :获取最后一级分类id(数组)
* @name :getLastCategory
* @author :lyh
* @method :post
* @time :2023/10/20 9:02
*/
public function getLastCategoryArr($category){
$arr = [];
if(isset($category) && !empty($category)){
foreach ($category as $v){
$arr[] = $v;
}
}
return $arr;
}
/**
* @remark :编辑产品
... ... @@ -575,27 +559,29 @@ class ProductLogic extends BaseLogic
* @time :2023/8/15 17:53
*/
public function batchSetCategory(){
if(isset($this->param['category_id']) && !empty($this->param['category_id'])) {
DB::connection('custom_mysql')->beginTransaction();
$category_ids = $this->getLastCategoryArr($this->param['category_id']);
$this->param['category_id'] = ','.implode(',',$category_ids).',';
try {
//批量
$param = [
'category_id'=>$this->param['category_id'],
'status'=>$this->param['status']
];
$this->model->edit($param,['id'=>['in',$this->param['id']]]);
if(!isset($this->param['category_id']) || empty($this->param['category_id'])){
$this->fail('请选择分类');
}
try {
if(!isset($this->param['is_cover']) || ($this->param['is_cover'] == 1)){
$category_ids = ','.implode(',',$this->param['category_id']).',';
$this->model->edit(['category_id'=>$category_ids],['id'=>['in',$this->param['id']]]);
//分类关联
foreach ($this->param['id'] as $id){
CategoryRelated::saveRelated($id, $category_ids);
CategoryRelated::saveRelated($id, $this->param['category_id']);
}
}else{
foreach ($this->param['id'] as $id){
//获取当前产品的分类
$productInfo = $this->model->read(['id'=>$id],['id','category_id']);
$category_ids_arr = array_values(array_unique(array_merge($productInfo['category_id'],$this->param['category_id'])));
$category_ids = ','.implode(',',$category_ids_arr).',';
$this->model->edit(['category_id'=>$category_ids],['id'=>$id]);
CategoryRelated::saveRelated($id, $category_ids_arr);
}
DB::connection('custom_mysql')->commit();
//对应添加关联表
}catch (\Exception $e){
DB::connection('custom_mysql')->rollBack();
$this->fail('系统错误,请联系管理员');
}
}catch (\Exception $e){
$this->fail('设置分类失败,请联系管理员');
}
return $this->success();
}
... ...
... ... @@ -502,6 +502,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/sort', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'sort'])->name('custom_content_sort');
Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'del'])->name('custom_content_del');
Route::any('/allSort', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'allSort'])->name('custom_content_allSort');
Route::any('/copyModuleContent', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'copyModuleContent'])->name('custom_content_copyModuleContent');
});
Route::prefix('extend')->group(function () {
... ...