Merge branch 'feature/user0812' into develop_bm
# Conflicts: # app/admin/service/UserService.php # config/route.php
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace app\crmAdmin\controller;
|
||||
|
||||
use app\common\model\Corp;
|
||||
use app\crm\model\Customer;
|
||||
use app\crmAdmin\service\CustomerService;
|
||||
use support\Request;
|
||||
|
||||
@@ -133,6 +134,37 @@ class CustomerController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function delete(Request $request)
|
||||
{
|
||||
try {
|
||||
$param = $request->all();
|
||||
if (empty($param['customer_id'])) {
|
||||
return $this->error('customer_id'.trans('not_null'));
|
||||
}
|
||||
|
||||
$where = [
|
||||
'id' => $param['customer_id'],
|
||||
];
|
||||
$customer = Customer::where($where)->withTrashed()->first();
|
||||
if(empty($customer)){
|
||||
return $this->error( trans('fail'));
|
||||
}
|
||||
//软删除
|
||||
$customer->status = 3;
|
||||
$res = $customer->save();
|
||||
$customer->delete();
|
||||
|
||||
return $this->success($res);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->error($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户详情
|
||||
* @param Request $request
|
||||
@@ -154,4 +186,25 @@ class CustomerController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户详情
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function follow(Request $request)
|
||||
{
|
||||
try {
|
||||
$param = $request->all();
|
||||
if (empty($param['id'])) {
|
||||
return $this->error('id'.trans('not_null'));
|
||||
}
|
||||
|
||||
$result = (new CustomerService())->follow($param);
|
||||
|
||||
return $this->success($result);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->error($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,6 +13,10 @@ class CustomerLogic
|
||||
$customer->status = $status;
|
||||
$res = $customer->save();
|
||||
|
||||
if($status == 1){
|
||||
$customer->restore();
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
@@ -20,7 +24,9 @@ class CustomerLogic
|
||||
{
|
||||
$customer = Customer::withTrashed()->find($id);
|
||||
//强制删除
|
||||
$res = $customer->forceDelete();
|
||||
// $res = $customer->forceDelete();
|
||||
$customer->status = 3;
|
||||
$res = $customer->save();
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace app\crmAdmin\service;
|
||||
|
||||
use app\common\model\InquiryLog;
|
||||
use app\common\model\User;
|
||||
use app\common\service\OssService;
|
||||
use app\crm\model\CustomerHis;
|
||||
use app\crmAdmin\logic\CustomerLogic;
|
||||
use app\crm\model\CarType;
|
||||
@@ -315,7 +316,42 @@ class CustomerService
|
||||
}
|
||||
}
|
||||
}
|
||||
$res = $query->update(['user_id' => $userId]);
|
||||
$data = [
|
||||
'user_id' => $userId,
|
||||
'obtain' => time(),
|
||||
];
|
||||
$res = $query->update($data);
|
||||
|
||||
Db::commit();
|
||||
return $res;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $params
|
||||
* @return bool
|
||||
*/
|
||||
public function delete($params)
|
||||
{
|
||||
try {
|
||||
Db::beginTransaction();
|
||||
$customerId = $params['customer_id'];
|
||||
|
||||
$query= Customer::whereIn('id',explode(',',$customerId));
|
||||
$customer = $query->get();
|
||||
|
||||
foreach ($customer as $item) {
|
||||
//记录客户关系变化
|
||||
$his = CustomerHis::create([
|
||||
'customer_id' => $item->id,
|
||||
'user_his' => $item->user_id,
|
||||
'user_id' => 0,
|
||||
]);
|
||||
}
|
||||
$res = $query->update(['user_id' => 0]);
|
||||
|
||||
Db::commit();
|
||||
return $res;
|
||||
@@ -394,4 +430,19 @@ class CustomerService
|
||||
|
||||
return $customer;
|
||||
}
|
||||
|
||||
public function follow($params)
|
||||
{
|
||||
$id = $params['id'];
|
||||
$follow = Follow::
|
||||
where('customer_id', $id)
|
||||
->first();
|
||||
|
||||
$ossservice = new OssService();
|
||||
foreach ($follow as $item) {
|
||||
$item['picture_full'] = $item->picture??$ossservice->generatePrivateUrl($item->picture);
|
||||
}
|
||||
|
||||
return $follow;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user