后台公海列表,详情跟进、重置密码
This commit is contained in:
@@ -6,6 +6,7 @@ use app\common\model\Corp;
|
|||||||
use app\common\traits\crud\CrudControllerTrait;
|
use app\common\traits\crud\CrudControllerTrait;
|
||||||
use app\admin\service\UserService;
|
use app\admin\service\UserService;
|
||||||
use app\crm\model\Customer;
|
use app\crm\model\Customer;
|
||||||
|
use support\Request;
|
||||||
|
|
||||||
class UserController extends BaseController
|
class UserController extends BaseController
|
||||||
{
|
{
|
||||||
@@ -18,6 +19,42 @@ class UserController extends BaseController
|
|||||||
$this->service = new UserService();
|
$this->service = new UserService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改密码
|
||||||
|
* @param Request $request
|
||||||
|
* @return \support\Response
|
||||||
|
* @throws \Random\RandomException
|
||||||
|
*/
|
||||||
|
public function savePassword(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$data = $this->validate($this->service->getValidator(), $request->post(), 'password');
|
||||||
|
$data = $request->all();
|
||||||
|
$result = $this->service->savePassword($request,$data);;
|
||||||
|
return $this->success($result, '编辑成功');
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return $this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新
|
||||||
|
*
|
||||||
|
* @param Request $request 请求对象
|
||||||
|
* @return mixed 返回更新成功的数据或信息
|
||||||
|
*/
|
||||||
|
public function edit(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$data = $this->validate($this->service->getValidator(), $request->post(), 'update');
|
||||||
|
$res = $this->service->serviceUpdate($request, $data);
|
||||||
|
return $this->success([], '更新成功');
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
return $this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表页数据格式化
|
* 列表页数据格式化
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
namespace app\admin\service;
|
namespace app\admin\service;
|
||||||
|
|
||||||
use app\admin\validate\UserValidate;
|
use app\admin\logic\UserLogic;
|
||||||
use app\common\traits\crud\CrudServiceTrait;
|
use app\common\traits\crud\CrudServiceTrait;
|
||||||
use app\common\model\User;
|
use app\common\model\User;
|
||||||
|
use app\common\validate\UserValidate;
|
||||||
|
use support\exception\BusinessException;
|
||||||
use support\Request;
|
use support\Request;
|
||||||
|
|
||||||
class UserService
|
class UserService
|
||||||
@@ -30,6 +32,14 @@ class UserService
|
|||||||
return new $this->validator;
|
return new $this->validator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 更新 */
|
||||||
|
public function serviceUpdate(Request $request, array $data = [])
|
||||||
|
{
|
||||||
|
$data = $this->preProcess('Update', $data, $request);
|
||||||
|
$config = $this->buildQueryConfig($request, 'edit');
|
||||||
|
$updated = $this->logicUpdateBy($config, $data);
|
||||||
|
return $this->postProcess('Update', $data);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造 CrudUtil 查询配置
|
* 构造 CrudUtil 查询配置
|
||||||
@@ -74,8 +84,25 @@ class UserService
|
|||||||
case 'destroy':
|
case 'destroy':
|
||||||
$config['where']['id'] = $p['id'];
|
$config['where']['id'] = $p['id'];
|
||||||
break;
|
break;
|
||||||
|
case 'savePassword':
|
||||||
|
$config['where']['id'] = $p['id'];
|
||||||
|
break;
|
||||||
|
case 'edit':
|
||||||
|
$config['where']['id'] = $request->user->uid;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $config;
|
return $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户密码
|
||||||
|
*/
|
||||||
|
public function savePassword(Request $request, array $data)
|
||||||
|
{
|
||||||
|
$config = $this->buildQueryConfig($request, 'savePassword');
|
||||||
|
$data['password'] = password_hash($data['password'], PASSWORD_DEFAULT);
|
||||||
|
$user = $this->logicUpdateBy($config,$data);
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,8 @@ class UserValidate extends Validate
|
|||||||
'feishu_register' => ['feishu_code'],
|
'feishu_register' => ['feishu_code'],
|
||||||
'upwd_login' => ['account' => 'require|checkAccount', 'password'],
|
'upwd_login' => ['account' => 'require|checkAccount', 'password'],
|
||||||
'feishu_auth' => ['corp_abbr', 'system_code', 'login_type'],
|
'feishu_auth' => ['corp_abbr', 'system_code', 'login_type'],
|
||||||
'feishu_login' => ['feishu_code']
|
'feishu_login' => ['feishu_code'],
|
||||||
|
'password' => ['password'],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -325,6 +325,7 @@ class CustomerController extends BaseController
|
|||||||
'lng' => Util::getParam($request, 'lng', 0),
|
'lng' => Util::getParam($request, 'lng', 0),
|
||||||
'address' => Util::getParam($request, 'address', ''),
|
'address' => Util::getParam($request, 'address', ''),
|
||||||
'sex' => Util::getParam($request, 'sex', 0),
|
'sex' => Util::getParam($request, 'sex', 0),
|
||||||
|
'obtain' => time(),
|
||||||
];
|
];
|
||||||
|
|
||||||
if (Util::isEmpty($id)) {
|
if (Util::isEmpty($id)) {
|
||||||
@@ -485,10 +486,10 @@ class CustomerController extends BaseController
|
|||||||
return $this->error(trans('customer_id').trans('not_null'));
|
return $this->error(trans('customer_id').trans('not_null'));
|
||||||
}
|
}
|
||||||
$data = [
|
$data = [
|
||||||
'user_id' => $request->user->uid
|
'user_id' => $request->user->uid,
|
||||||
|
'obtain' => time(),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Db::beginTransaction();
|
Db::beginTransaction();
|
||||||
$customer= Customer::withTrashed()->find($customerId);
|
$customer= Customer::withTrashed()->find($customerId);
|
||||||
@@ -592,6 +593,7 @@ class CustomerController extends BaseController
|
|||||||
try {
|
try {
|
||||||
$customer = $query->get();
|
$customer = $query->get();
|
||||||
|
|
||||||
|
Db::beginTransaction();
|
||||||
foreach ($customer as $item) {
|
foreach ($customer as $item) {
|
||||||
//记录客户关系变化
|
//记录客户关系变化
|
||||||
$his = CustomerHis::create([
|
$his = CustomerHis::create([
|
||||||
@@ -607,7 +609,12 @@ class CustomerController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$res = $query->update(['user_id' => $user->id]);
|
|
||||||
|
$data = [
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'obtain' => time(),
|
||||||
|
];
|
||||||
|
$res = $query->update($data);
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
|
|||||||
@@ -162,6 +162,11 @@ class CustomerService
|
|||||||
return $config;
|
return $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 无用线索举报
|
||||||
|
* @param $params
|
||||||
|
* @return false
|
||||||
|
*/
|
||||||
public function report($params)
|
public function report($params)
|
||||||
{
|
{
|
||||||
$id = $params['id'];
|
$id = $params['id'];
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace app\crmAdmin\controller;
|
namespace app\crmAdmin\controller;
|
||||||
|
|
||||||
use app\common\model\Corp;
|
use app\common\model\Corp;
|
||||||
|
use app\crm\model\Customer;
|
||||||
use app\crmAdmin\service\CustomerService;
|
use app\crmAdmin\service\CustomerService;
|
||||||
use support\Request;
|
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
|
* @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;
|
$customer->status = $status;
|
||||||
$res = $customer->save();
|
$res = $customer->save();
|
||||||
|
|
||||||
|
if($status == 1){
|
||||||
|
$customer->restore();
|
||||||
|
}
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,7 +24,9 @@ class CustomerLogic
|
|||||||
{
|
{
|
||||||
$customer = Customer::withTrashed()->find($id);
|
$customer = Customer::withTrashed()->find($id);
|
||||||
//强制删除
|
//强制删除
|
||||||
$res = $customer->forceDelete();
|
// $res = $customer->forceDelete();
|
||||||
|
$customer->status = 3;
|
||||||
|
$res = $customer->save();
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ namespace app\crmAdmin\service;
|
|||||||
|
|
||||||
use app\common\model\InquiryLog;
|
use app\common\model\InquiryLog;
|
||||||
use app\common\model\User;
|
use app\common\model\User;
|
||||||
|
use app\common\service\OssService;
|
||||||
use app\crm\model\CustomerHis;
|
use app\crm\model\CustomerHis;
|
||||||
use app\crmAdmin\logic\CustomerLogic;
|
use app\crmAdmin\logic\CustomerLogic;
|
||||||
use app\crm\model\CarType;
|
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();
|
Db::commit();
|
||||||
return $res;
|
return $res;
|
||||||
@@ -394,4 +430,19 @@ class CustomerService
|
|||||||
|
|
||||||
return $customer;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -60,6 +60,7 @@ class InquiryToCrm implements Consumer
|
|||||||
$crmCustomer->contacts = $info->contacts;
|
$crmCustomer->contacts = $info->contacts;
|
||||||
$crmCustomer->desc_collect = $info->content;
|
$crmCustomer->desc_collect = $info->content;
|
||||||
$crmCustomer->enter_user_id = $info->enter_user_id;
|
$crmCustomer->enter_user_id = $info->enter_user_id;
|
||||||
|
$crmCustomer->obtain = time();
|
||||||
// 修改同步CRM状态
|
// 修改同步CRM状态
|
||||||
$info->sync_crm = 1;
|
$info->sync_crm = 1;
|
||||||
// 保存
|
// 保存
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ Route::group('/admin', function () {
|
|||||||
Route::any('/list', [app\admin\controller\UserController::class, 'index']);
|
Route::any('/list', [app\admin\controller\UserController::class, 'index']);
|
||||||
Route::any('/show', [app\admin\controller\UserController::class, 'show']);
|
Route::any('/show', [app\admin\controller\UserController::class, 'show']);
|
||||||
Route::any('/update', [app\admin\controller\UserController::class, 'update']);
|
Route::any('/update', [app\admin\controller\UserController::class, 'update']);
|
||||||
|
Route::any('/update/password', [app\admin\controller\UserController::class, 'savePassword']);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 公司
|
// 公司
|
||||||
@@ -119,6 +120,8 @@ Route::group('/admin', function () {
|
|||||||
Route::any('/audit', [app\crmAdmin\controller\CustomerController::class, 'audit']);
|
Route::any('/audit', [app\crmAdmin\controller\CustomerController::class, 'audit']);
|
||||||
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('/follow', [app\crmAdmin\controller\CustomerController::class, 'follow']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user