管理端回收站
This commit is contained in:
@@ -4,6 +4,7 @@ namespace app\crmAdmin\controller;
|
|||||||
|
|
||||||
use app\common\model\Corp;
|
use app\common\model\Corp;
|
||||||
use app\crm\model\Customer;
|
use app\crm\model\Customer;
|
||||||
|
use app\crm\utils\Util;
|
||||||
use app\crmAdmin\service\CustomerService;
|
use app\crmAdmin\service\CustomerService;
|
||||||
use support\Request;
|
use support\Request;
|
||||||
|
|
||||||
@@ -148,19 +149,18 @@ class CustomerController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$customer_id = explode(',', $param['customer_id']);
|
$customer_id = explode(',', $param['customer_id']);
|
||||||
$customer = Customer::whereIn('id',$customer_id)->withTrashed()->first();
|
$query = Customer::whereIn('id',$customer_id)->withTrashed();
|
||||||
if(empty($customer)){
|
if(!$query->exists()){
|
||||||
return $this->error( trans('fail'));
|
return $this->error( trans('fail'));
|
||||||
}
|
}
|
||||||
if($param['scene'] == 'list'){ //管理端客户列表移除
|
$scene = $param['scene'] ?? '';
|
||||||
$customer->status = 4;
|
if ($scene === 'list') { //管理端客户列表移除
|
||||||
|
$res = $query->update(['status' => 4, 'deleted_at' => time()]);
|
||||||
}else{ //公海软删除
|
} elseif ($scene === 'force') { //强删除
|
||||||
$customer->status = 3;
|
$res = $query->forceDelete();
|
||||||
|
} else { //公海软删除
|
||||||
|
$res = $query->update(['status' => 3, 'deleted_at' => time()]);
|
||||||
}
|
}
|
||||||
$res = $customer->save();
|
|
||||||
$customer->delete();
|
|
||||||
|
|
||||||
return $this->success($res);
|
return $this->success($res);
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
@@ -168,6 +168,29 @@ class CustomerController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户恢复
|
||||||
|
* @param Request $request
|
||||||
|
* @return \support\Response
|
||||||
|
*/
|
||||||
|
public function restore(Request $request)
|
||||||
|
{
|
||||||
|
$id = $request->input('id', '');
|
||||||
|
if (Util::isEmpty($id)) {
|
||||||
|
return $this->error(trans('id_empty'));
|
||||||
|
}
|
||||||
|
$id = explode(',', $id);
|
||||||
|
$query = Customer::whereIn('id', $id);
|
||||||
|
//$res = $query->restore();
|
||||||
|
$res = $query->update(['status' => 1, 'user_id' => 0]);
|
||||||
|
if($res){
|
||||||
|
return $this->success($res, trans('success'));
|
||||||
|
}else{
|
||||||
|
return $this->error(trans('fail'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户详情
|
* 客户详情
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
|
|||||||
@@ -51,12 +51,14 @@ class CustomerService
|
|||||||
$follow_last = $params['follow_last'] ?? '';
|
$follow_last = $params['follow_last'] ?? '';
|
||||||
$tagId = $params['tag_id'] ?? [];
|
$tagId = $params['tag_id'] ?? [];
|
||||||
$user_id = $params['user_id'] ?? '';
|
$user_id = $params['user_id'] ?? '';
|
||||||
$seas = $params['seas'] ?? '';
|
$seas = $params['seas'] ?? ''; //recyclea:管理端回收站,audit:待审核列表,seas:公海
|
||||||
$scene = $params['scene'] ?? '';
|
$scene = $params['scene'] ?? '';
|
||||||
$where = [];
|
$where = [];
|
||||||
|
|
||||||
if ($scene == 'audit') {
|
if ($scene == 'audit') {
|
||||||
$where[] = ['status', '=', 2];
|
$where[] = ['status', '=', 2];
|
||||||
|
} elseif ($scene == 'recyclea') {
|
||||||
|
$where[] = ['status', '>', 2];
|
||||||
} else {
|
} else {
|
||||||
$where[] = ['status', '=', 1];
|
$where[] = ['status', '=', 1];
|
||||||
}
|
}
|
||||||
@@ -121,8 +123,8 @@ class CustomerService
|
|||||||
if ($recycle == 'recycle' || $scene == 'recycle' || $scene == 'audit') {
|
if ($recycle == 'recycle' || $scene == 'recycle' || $scene == 'audit') {
|
||||||
$query->onlyTrashed();
|
$query->onlyTrashed();
|
||||||
}
|
}
|
||||||
if ($seas == 'seas' || $scene == 'seas') {
|
if ($seas == 'seas' || $scene == 'recyclea') {
|
||||||
$query->withTrashed();
|
$query = $query->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$export) {
|
if (!$export) {
|
||||||
@@ -153,6 +155,14 @@ class CustomerService
|
|||||||
}
|
}
|
||||||
$item['audit'] = $audit;
|
$item['audit'] = $audit;
|
||||||
}
|
}
|
||||||
|
if ($scene == 'recyclea' && $item['status'] == 3) { //回收站删除来源
|
||||||
|
$item['del_source'] = '公海';
|
||||||
|
}elseif ($scene == 'recyclea' && $item['status'] == 4) {
|
||||||
|
$item['del_source'] = '管理端';
|
||||||
|
}elseif ($scene == 'recyclea' && $item['status'] == 5) {
|
||||||
|
$source = (!empty($item['user_id'])) ? (':' . User::where('id',$item['user_id'])->value('name')) : '';
|
||||||
|
$item['del_source'] = '业务员' . $source;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($item);
|
unset($item);
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ Route::group('/admin', function () {
|
|||||||
Route::any('/transfer', [app\crmAdmin\controller\CustomerController::class, 'transfer']);
|
Route::any('/transfer', [app\crmAdmin\controller\CustomerController::class, 'transfer']);
|
||||||
Route::any('/detail', [app\crmAdmin\controller\CustomerController::class, 'detail']);
|
Route::any('/detail', [app\crmAdmin\controller\CustomerController::class, 'detail']);
|
||||||
Route::any('/delete', [app\crmAdmin\controller\CustomerController::class, 'delete']);
|
Route::any('/delete', [app\crmAdmin\controller\CustomerController::class, 'delete']);
|
||||||
|
Route::any('/restore', [app\crmAdmin\controller\CustomerController::class, 'restore']); //恢复客户
|
||||||
Route::any('/cede', [app\crm\controller\CustomerController::class, 'cede']);
|
Route::any('/cede', [app\crm\controller\CustomerController::class, 'cede']);
|
||||||
Route::any('/follow', [app\crmAdmin\controller\CustomerController::class, 'follow']);
|
Route::any('/follow', [app\crmAdmin\controller\CustomerController::class, 'follow']);
|
||||||
Route::any('/allocation', [app\crmAdmin\controller\CustomerController::class, 'allocation']);
|
Route::any('/allocation', [app\crmAdmin\controller\CustomerController::class, 'allocation']);
|
||||||
|
|||||||
Reference in New Issue
Block a user