智慧教务系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

107 lines
3.1 KiB

<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的多应用管理平台
// +----------------------------------------------------------------------
// | 官方网址:https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\admin\customer_resources;
use app\model\customer_resources\CustomerResources;
use app\model\campus\Campus;
use core\base\BaseAdminService;
/**
* 客户资源服务层
* Class CustomerResourcesService
* @package app\service\admin\customer_resources
*/
class CustomerResourcesService extends BaseAdminService
{
public function __construct()
{
parent::__construct();
$this->model = new CustomerResources();
}
/**
* 获取客户资源列表
* @param array $where
* @return array
*/
public function getPage(array $where = [])
{
$field = 'id,create_year_month,create_date,source,source_channel,consultant,name,age,gender,phone_number,demand,purchasing_power,cognitive_idea,optional_class_time,distance,decision_maker,initial_intent,campus,created_at,updated_at,deleted_at,status';
$order = 'id desc';
$search_model = $this->model->where(get_campus_where($this->uid))->withSearch(["name","phone_number"], $where)->with(['campus'])->field($field)->order($order);
$list = $this->pageQuery($search_model);
return $list;
}
/**
* 获取客户资源信息
* @param int $id
* @return array
*/
public function getInfo(int $id)
{
$field = 'id,create_year_month,create_date,source,source_channel,consultant,name,age,gender,phone_number,demand,purchasing_power,cognitive_idea,optional_class_time,distance,decision_maker,initial_intent,campus,created_at,updated_at,deleted_at,status';
$info = $this->model->field($field)->where([['id', "=", $id]])->findOrEmpty()->toArray();
return $info;
}
/**
* 添加客户资源
* @param array $data
* @return mixed
*/
public function add(array $data)
{
$data['consultant'] = $this->username;
$res = $this->model->create($data);
return $res->id;
}
/**
* 客户资源编辑
* @param int $id
* @param array $data
* @return bool
*/
public function edit(int $id, array $data)
{
$data['consultant'] = $this->username;
$this->model->where([['id', '=', $id]])->update($data);
return true;
}
/**
* 删除客户资源
* @param int $id
* @return bool
*/
public function del(int $id)
{
$model = $this->model->where([['id', '=', $id]])->find();
$res = $model->delete();
return $res;
}
public function getCampusAll(){
$campusModel = new Campus();
return $campusModel->select()->toArray();
}
}