83 lines
2.3 KiB
PHP
83 lines
2.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace app\crmAdmin\controller;
|
||
|
|
|
||
|
|
use app\common\model\Corp;
|
||
|
|
use app\crmAdmin\service\CustomerService;
|
||
|
|
use support\Request;
|
||
|
|
|
||
|
|
class CustomerController extends BaseController
|
||
|
|
{
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 不需要头信息的方法
|
||
|
|
*/
|
||
|
|
protected $noNeedHeader = [];
|
||
|
|
|
||
|
|
protected $noNeedLogin = [];
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 客户列表
|
||
|
|
* @param Request $request
|
||
|
|
* @return \support\Response
|
||
|
|
*/
|
||
|
|
public function list(Request $request)
|
||
|
|
{
|
||
|
|
try {
|
||
|
|
$param = $request->all();
|
||
|
|
$corp = Corp::where(['abbr' => $request->basic_data['corp_abbr']])->first();
|
||
|
|
$param['corp_abbr'] = $corp->id;
|
||
|
|
// $param['corp_abbr'] = $request->basic_data['corp_abbr'];
|
||
|
|
$result = (new CustomerService())->list($param);
|
||
|
|
|
||
|
|
return $this->success($this->page($result));
|
||
|
|
} catch (\Throwable $e) {
|
||
|
|
return $this->error($e->getMessage().$e->getFile().$e->getLine().$e->getTraceAsString());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 客户导出
|
||
|
|
* @param Request $request
|
||
|
|
* @return \support\Response
|
||
|
|
*/
|
||
|
|
public function export(Request $request)
|
||
|
|
{
|
||
|
|
try {
|
||
|
|
$param = $request->all();
|
||
|
|
$corp = Corp::where(['abbr' => $request->basic_data['corp_abbr']])->first();
|
||
|
|
$param['corp_abbr'] = $corp->id;
|
||
|
|
// $param['corp_abbr'] = $request->basic_data['corp_abbr'];
|
||
|
|
$result = (new CustomerService())->export($param);
|
||
|
|
|
||
|
|
return $this->success($this->page($result));
|
||
|
|
} catch (\Throwable $e) {
|
||
|
|
return $this->error($e->getMessage().$e->getFile().$e->getLine().$e->getTraceAsString());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 客户列表
|
||
|
|
* @param Request $request
|
||
|
|
* @return \support\Response
|
||
|
|
*/
|
||
|
|
public function audit(Request $request)
|
||
|
|
{
|
||
|
|
try {
|
||
|
|
$param = $request->all();
|
||
|
|
if (empty($param['id'])) {
|
||
|
|
return $this->error('ID'.trans('not_null'));
|
||
|
|
}
|
||
|
|
if (in_array($param['scene'],['delete','report'])) {
|
||
|
|
return $this->error('scene 不合法');
|
||
|
|
}
|
||
|
|
$result = (new CustomerService())->audit($param);
|
||
|
|
|
||
|
|
return $this->success($result);
|
||
|
|
|
||
|
|
} catch (\Throwable $e) {
|
||
|
|
return $this->error($e->getMessage().$e->getFile().$e->getLine().$e->getTraceAsString());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|