119 lines
3.7 KiB
PHP
119 lines
3.7 KiB
PHP
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use app\common\model\informationg\UserInformationg;
|
|
use app\common\logic\BaseLogic;
|
|
use app\common\model\task\Task;
|
|
use app\common\model\task_template\TaskTemplate;
|
|
use app\common\model\user\User;
|
|
|
|
class InformationController extends BaseApiController
|
|
{
|
|
public function list()
|
|
{
|
|
$param = Request()->param();
|
|
[$page, $limit] = $this->getPage();
|
|
if(isset($param['user_id'])&&$param['user_id']>0){
|
|
$data[] = ['create_user_id','=',$param['user_id']];
|
|
}else{
|
|
$data[] = ['company_id','=',$this->userInfo['company_id']];
|
|
}
|
|
if(isset($param['arr']) && count($param['arr'])>0){
|
|
$data[] =['id','in', $param['arr']];
|
|
}
|
|
$res = UserInformationg::list($data,$page,$limit);
|
|
if ($res != true) {
|
|
return $this->fail( BaseLogic::getError());
|
|
}
|
|
return $this->success('ok', $res->toArray());
|
|
}
|
|
|
|
/**
|
|
* 添加
|
|
*/
|
|
public function add()
|
|
{
|
|
$param = Request()->param();
|
|
$user=User::where('id',$this->userId)->find();
|
|
if(isset($param['street']) && $param['street']>0){
|
|
$param['street_id']=$param['street'];
|
|
}else{
|
|
$param['street_id']=$user['street'];
|
|
}
|
|
if(isset($param['village'])&& $param['village']>0){
|
|
$param['village_id']=$param['village'];
|
|
}else{
|
|
$param['village_id']=$user['village'];
|
|
}
|
|
if(isset($param['brigade']) && $param['brigade']>0){
|
|
$param['brigade_id']=$param['brigade'];
|
|
}else{
|
|
$param['brigade_id']=$user['brigade'];
|
|
}
|
|
$param['admin_id'] = $this->userId;
|
|
$param['company_id']=$this->userInfo['company_id'];
|
|
$param['province_id']=$user['province'];
|
|
$param['city_id']=$user['city'];
|
|
$param['area_id']=$user['area'];
|
|
$res = UserInformationg::add($param);
|
|
if ($res != true) {
|
|
return $this->fail( BaseLogic::getError());
|
|
}
|
|
return $this->success('成功');
|
|
}
|
|
|
|
/**
|
|
* 详情
|
|
*/
|
|
public function details(){
|
|
$param = Request()->param();
|
|
$res = UserInformationg::details($param['id']);
|
|
if ($res != true) {
|
|
return $this->fail( BaseLogic::getError());
|
|
}
|
|
return $this->success('成功',$res->toArray());
|
|
}
|
|
|
|
/**
|
|
* 商机更新
|
|
*/
|
|
public function opportunity_update(){
|
|
$param = Request()->param();
|
|
foreach ($param['datas'] as $k => $v) {
|
|
$res = UserInformationg::informationg_demand($v,$param['id'],$this->userId);
|
|
}
|
|
if ($res != true) {
|
|
return $this->fail( BaseLogic::getError());
|
|
}
|
|
if(isset($param['task_id'])&& $param['task_id']>0){
|
|
$task=Task::where('id',$param['task_id'])->find();
|
|
$extend=$task['extend'];
|
|
$extend['informationg']['update']+=1;
|
|
$extend['informationg']['ids'][]=$param['id'];
|
|
$task->extend=json_encode($extend);
|
|
if($extend['informationg']['update']>=5){
|
|
$task->status=3;
|
|
}
|
|
$task->save();
|
|
TaskTemplate::where('id',$task['template_id'])->inc('information_count',1)->update();
|
|
}
|
|
|
|
UserInformationg::where('id',$param['id'])->update(['update_time'=>time(),'is_update'=>1]);
|
|
|
|
return $this->success('成功');
|
|
}
|
|
|
|
/**
|
|
* 编辑
|
|
*/
|
|
public function edit(){
|
|
$param = Request()->param();
|
|
$res = UserInformationg::edit($param);
|
|
if ($res != true) {
|
|
return $this->fail( BaseLogic::getError());
|
|
}
|
|
return $this->success('成功');
|
|
}
|
|
}
|