删除客户为放入公海
This commit is contained in:
@@ -394,13 +394,31 @@ class CustomerController extends BaseController
|
||||
if(empty($customer)){
|
||||
return $this->error( trans('fail'));
|
||||
}
|
||||
if($force == 'force'){
|
||||
//强制删除
|
||||
$res = $customer->forceDelete();
|
||||
}else{
|
||||
//软删除
|
||||
$res = $customer->delete();
|
||||
try {
|
||||
Db::beginTransaction();
|
||||
if ($force == 'force') {
|
||||
//强制删除
|
||||
$res = $customer->forceDelete();
|
||||
} else {
|
||||
$customer->user_id = 0;
|
||||
$customer->save();
|
||||
|
||||
//记录客户关系变化
|
||||
$his = CustomerHis::create([
|
||||
'customer_id' => $id,
|
||||
'user_his' => $userId,
|
||||
'user_id' => 0,
|
||||
]);
|
||||
|
||||
//软删除
|
||||
$res = $customer->delete();
|
||||
}
|
||||
Db::commit();
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
|
||||
if ($res) {
|
||||
return $this->success($res, trans('success'));
|
||||
} else {
|
||||
@@ -527,53 +545,6 @@ class CustomerController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户转移至公海
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function putSeas(Request $request)
|
||||
{
|
||||
$customerId = Util::getParam($request, 'customer_id');
|
||||
$userId = $request->user->uid;
|
||||
if (Util::isEmpty($customerId)) {
|
||||
return $this->error(trans('customer_id').trans('not_null'));
|
||||
}
|
||||
|
||||
try {
|
||||
Db::beginTransaction();
|
||||
$customer= Customer::withTrashed()->where('user_id',$userId)->find($customerId);
|
||||
|
||||
if(empty($customer)){
|
||||
return $this->error( 'customer_id错误');
|
||||
}
|
||||
$data = [
|
||||
'user_id' => 0,
|
||||
];
|
||||
|
||||
$res = $customer->update($data);
|
||||
|
||||
//记录客户关系变化
|
||||
$his = CustomerHis::create([
|
||||
'customer_id' => $customerId,
|
||||
'user_his' => $userId,
|
||||
'user_id' => 0,
|
||||
]);
|
||||
Db::commit();
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
|
||||
if ($res) {
|
||||
return $this->success($res, trans('success'));
|
||||
} else {
|
||||
return $this->error(trans('fail'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 批量转让
|
||||
* @param Request $request
|
||||
|
||||
@@ -175,7 +175,6 @@ Route::group('/crm', function () {
|
||||
Route::any('/customer/getCountry', [app\crm\controller\CustomerController::class, 'getCountry']);
|
||||
Route::any('/customer/followNext', [app\crm\controller\CustomerController::class, 'followNext']);
|
||||
Route::any('/customer/report', [app\crm\controller\CustomerController::class, 'report']);
|
||||
Route::any('/customer/seas', [app\crm\controller\CustomerController::class, 'putSeas']);
|
||||
|
||||
Route::any('/tagGroup/list', [app\crm\controller\TagGroupController::class, 'list']);
|
||||
Route::any('/tagGroup/updatePivot', [app\crm\controller\TagGroupController::class, 'updatePivot']);
|
||||
|
||||
Reference in New Issue
Block a user