12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- declare (strict_types = 1);
- namespace app\index\controller;
- use app\model\CustomerVisitLog;
- use app\model\Employee;
- use app\model\Customer;
- use toolkits\Aec;
- class Downdocument
- {
- public function index()
- {
- $param = request()->only(['token']);
- if ($param['token']) {
- $aec = new Aec(config('app.aec_key'), config('app.aec_iv'));
- $value = $aec->decrypt($param['token']);
- }
- if (!$value) {
- json(['code' => 1, 'msg' => '参数错误'])->send();
- exit;
- }
- $value = explode('#', $value);
- $root_id = $value[0];
- $employee_id = $value[1];
- $visitlog_id = $value[2];
- $empdata = Employee::where([['root_id','=',$root_id],['id','=',$employee_id]])->field('id,uid,name,org_id')->find();
- $orgids = orgSubIds($root_id);
- $logdata = CustomerVisitLog::where([['id','=',$visitlog_id],['org_id','in',$orgids]])->field('id,customer_id,document_field,document_name')->find();
- $had = Customer::where([['id','=',$logdata['customer_id']],['org_id','in',$orgids]])->field('id,name,employee_id')->find();
- $time = date('Y-m-d H:i:s');
- $remark = $empdata['name'].'在'.$time.'下载了名称为'.$logdata['document_name'].'的文件';
- // 添加追踪记录
- $visitLog = [
- 'customer_id' => $logdata['customer_id'],
- 'type' => '',
- 'next_contact_date' => null,
- 'employee_id' => $employee_id,
- 'user_id' => $empdata['uid'],
- 'remark' => $remark,
- 'state' => 0,
- 'org_id' => $empdata['org_id'],
- 'customer_employee_id' => $had->employee_id,
- 'customer_org_id' => Employee::where('id', $had->employee_id)->value('org_id')
- ];
- $visitLog = CustomerVisitLog::create($visitLog);
- $url = 'https://'.config('app.ali_oss_bindurl').'/'.$logdata['document_field'];
- header("Location:".$url);
- exit;
- }
- }
- ?>
|