diff --git a/admin/application/admin/common.php b/admin/application/admin/common.php index 24da5f4..6645280 100644 --- a/admin/application/admin/common.php +++ b/admin/application/admin/common.php @@ -11,9 +11,9 @@ if (!function_exists('build_select')) { /** * 生成下拉列表 * @param string $name - * @param mixed $options - * @param mixed $selected - * @param mixed $attr + * @param mixed $options + * @param mixed $selected + * @param mixed $attr * @return string */ function build_select($name, $options, $selected = [], $attr = []) @@ -29,8 +29,8 @@ if (!function_exists('build_radios')) { /** * 生成单选按钮组 * @param string $name - * @param array $list - * @param mixed $selected + * @param array $list + * @param mixed $selected * @return string */ function build_radios($name, $list = [], $selected = null) @@ -50,8 +50,8 @@ if (!function_exists('build_checkboxs')) { /** * 生成复选按钮组 * @param string $name - * @param array $list - * @param mixed $selected + * @param array $list + * @param mixed $selected * @return string */ function build_checkboxs($name, $list = [], $selected = null) @@ -73,9 +73,9 @@ if (!function_exists('build_category_select')) { * 生成分类下拉列表框 * @param string $name * @param string $type - * @param mixed $selected - * @param array $attr - * @param array $header + * @param mixed $selected + * @param array $attr + * @param array $header * @return string */ function build_category_select($name, $type, $selected = null, $attr = [], $header = []) @@ -112,10 +112,10 @@ if (!function_exists('build_toolbar')) { } $btnAttr = [ 'refresh' => ['javascript:;', 'btn btn-primary btn-refresh', 'fa fa-refresh', '', __('Refresh')], - 'add' => ['javascript:;', 'btn btn-success btn-add', 'fa fa-plus', __('Add'), __('Add')], - 'edit' => ['javascript:;', 'btn btn-success btn-edit btn-disabled disabled', 'fa fa-pencil', __('Edit'), __('Edit')], - 'del' => ['javascript:;', 'btn btn-danger btn-del btn-disabled disabled', 'fa fa-trash', __('Delete'), __('Delete')], - 'import' => ['javascript:;', 'btn btn-info btn-import', 'fa fa-upload', __('Import'), __('Import')], + 'add' => ['javascript:;', 'btn btn-success btn-add', 'fa fa-plus', __('Add'), __('Add')], + 'edit' => ['javascript:;', 'btn btn-success btn-edit btn-disabled disabled', 'fa fa-pencil', __('Edit'), __('Edit')], + 'del' => ['javascript:;', 'btn btn-danger btn-del btn-disabled disabled', 'fa fa-trash', __('Delete'), __('Delete')], + 'import' => ['javascript:;', 'btn btn-info btn-import', 'fa fa-upload', __('Import'), __('Import')], ]; $btnAttr = array_merge($btnAttr, $attr); $html = []; @@ -197,18 +197,28 @@ if (!function_exists('build_heading')) { } -function session_admin($key=''){ - $admin = session('admin'); - if($key){ - return $admin[$key]; +if (!function_exists('session_admin')) { + function session_admin($key = '') + { + $admin = session('admin'); + if ($key) { + return $admin[$key]; + } + return $admin; } - return $admin; } -function session_admin_firm_id(){ - $admin = session('admin.firm_id'); - return $admin; + +if (!function_exists('session_admin_firm_id')) { + function session_admin_firm_id() + { + $admin = session('admin.firm_id'); + return $admin; + } } -function session_admin_firmstore_id(){ - $admin = session('admin.firmstore_id'); - return $admin; +if (!function_exists('session_admin_firmstore_id')) { + function session_admin_firmstore_id() + { + $admin = session('admin.firmstore_id'); + return $admin; + } } diff --git a/admin/application/admin/controller/Ai.php b/admin/application/admin/controller/Ai.php new file mode 100644 index 0000000..3bde6ac --- /dev/null +++ b/admin/application/admin/controller/Ai.php @@ -0,0 +1,51 @@ +url = $talk_skill['base_url']; + $obj->apiKey = $talk_skill['api_key']; + + $answer_json_arr = []; + Tools::log_to_write_txt(['示例话术请求gpt,入参'=>input()]); + $obj->returnAnswer($txt,['stream' => false],$answer_json_arr); + Tools::log_to_write_txt(['示例话术请求gpt,出参'=>$answer_json_arr]); + $json_arr = json_decode($answer_json_arr[0],true); + + if(empty($json_arr['choices'][0]['message']['content'])){ + $msg = '处理失败'; + }else{ + $msg = $json_arr['choices'][0]['message']['content']; + } + return json(Tools::set_ok('ok',$msg)); + } +} \ No newline at end of file diff --git a/admin/application/admin/controller/Firmcustomerfollowuptimelist.php b/admin/application/admin/controller/Firmcustomerfollowuptimelist.php index 148205d..d15d9f6 100644 --- a/admin/application/admin/controller/Firmcustomerfollowuptimelist.php +++ b/admin/application/admin/controller/Firmcustomerfollowuptimelist.php @@ -34,4 +34,39 @@ class Firmcustomerfollowuptimelist extends Backend */ + /** + * 查看 + */ + public function index() + { + //当前是否为关联查询 + $this->relationSearch = true; + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + if ($this->request->isAjax()) { + //如果发送的来源是Selectpage,则转发到Selectpage + if ($this->request->request('keyField')) { + return $this->selectpage(); + } + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + + $list = $this->model + ->with(['firmcustomerfollowuprecord']) + ->where($where) + ->order($sort, $order) + ->paginate($limit); + + foreach ($list as $row) { + $row->visible(['id','day','followup_time']); + $row->visible(['firmcustomerfollowuprecord']); + $row->getRelation('firmcustomerfollowuprecord')->visible(['name']); + } + + $result = array("total" => $list->total(), "rows" => $list->items()); + + return json($result); + } + return $this->view->fetch(); + } + } diff --git a/admin/application/admin/controller/Firmfollowuptemplate.php b/admin/application/admin/controller/Firmfollowuptemplate.php index 33340f9..76792b4 100644 --- a/admin/application/admin/controller/Firmfollowuptemplate.php +++ b/admin/application/admin/controller/Firmfollowuptemplate.php @@ -23,8 +23,6 @@ class Firmfollowuptemplate extends Backend parent::_initialize(); $this->model = new \app\admin\model\Firmfollowuptemplate; - $this->model->where('firmfollowuptemplate.firm_id',session_admin_firm_id()); - $this->model->where('firmfollowuptemplate.firmstore_id',session_admin_firmstore_id()); } @@ -52,6 +50,8 @@ class Firmfollowuptemplate extends Backend } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + $this->model->where('firmfollowuptemplate.firm_id',session_admin_firm_id()); + $this->model->where('firmfollowuptemplate.firmstore_id',session_admin_firmstore_id()); $list = $this->model ->with(['firmbigcategory']) ->where($where) diff --git a/admin/application/admin/controller/Firmfollowuptemplatetimelist.php b/admin/application/admin/controller/Firmfollowuptemplatetimelist.php index 7854487..09aa1e3 100644 --- a/admin/application/admin/controller/Firmfollowuptemplatetimelist.php +++ b/admin/application/admin/controller/Firmfollowuptemplatetimelist.php @@ -3,6 +3,7 @@ namespace app\admin\controller; use app\common\controller\Backend; +use think\Db; /** * 回访模板回访时间列管理 @@ -17,7 +18,8 @@ class Firmfollowuptemplatetimelist extends Backend * @var \app\admin\model\Firmfollowuptemplatetimelist */ protected $model = null; - + //protected $selectpageFields = "day,send_time"; + protected $noNeedRight = ['getList']; public function _initialize() { parent::_initialize(); @@ -50,6 +52,11 @@ class Firmfollowuptemplatetimelist extends Backend } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + $firmfollowuptemplate_id = input('firmfollowuptemplate_id'); + if($firmfollowuptemplate_id){ + $this->model->where('firmfollowuptemplate_id',$firmfollowuptemplate_id); + } + //dump(input());die; $list = $this->model ->with(['firmfollowuptemplate']) ->where($where) @@ -57,16 +64,28 @@ class Firmfollowuptemplatetimelist extends Backend ->paginate($limit); foreach ($list as $row) { - $row->visible(['id','day','send_time']); + $row->visible(['id','day','send_time','name']); $row->visible(['firmfollowuptemplate']); $row->getRelation('firmfollowuptemplate')->visible(['name']); + $row->send_time = $row['day'].'天-'.$row['send_time']; } $result = array("total" => $list->total(), "rows" => $list->items()); return json($result); } + $this->assignconfig('firmfollowuptemplate_id',input('firmfollowuptemplate_id')); return $this->view->fetch(); } + + function getList(){ + + $list = Db::table('fa_firmfollowuptemplatetimelist') + ->select(); + foreach ($list as $k=>&$v){ + $v['name'] = $v['day'].'天后 - '.$v['send_time'].'发送'; + } + return json(['list'=>$list,'total'=>count($list)]); + } } diff --git a/admin/application/admin/lang/zh-cn/firmcustomerfollowuptimelist.php b/admin/application/admin/lang/zh-cn/firmcustomerfollowuptimelist.php index af0d86a..dce4841 100644 --- a/admin/application/admin/lang/zh-cn/firmcustomerfollowuptimelist.php +++ b/admin/application/admin/lang/zh-cn/firmcustomerfollowuptimelist.php @@ -1,7 +1,9 @@ 'ID', - 'Firmcustomerfollowuprecord_id' => '回访记录ID(非必须)', - 'Followup_time' => '回访时间' + 'Id' => 'ID', + 'Firmcustomerfollowuprecord_id' => '回访记录', + 'Day' => 'N天后回访', + 'Followup_time' => '回访时间', + 'Firmcustomerfollowuprecord.name' => '客户名称' ]; diff --git a/admin/application/admin/model/Firmcustomerfollowuptimelist.php b/admin/application/admin/model/Firmcustomerfollowuptimelist.php index 0954111..d0712ff 100644 --- a/admin/application/admin/model/Firmcustomerfollowuptimelist.php +++ b/admin/application/admin/model/Firmcustomerfollowuptimelist.php @@ -37,4 +37,8 @@ class Firmcustomerfollowuptimelist extends Model + public function firmcustomerfollowuprecord() + { + return $this->belongsTo('Firmcustomerfollowuprecord', 'firmcustomerfollowuprecord_id', 'id', [], 'LEFT')->setEagerlyType(0); + } } diff --git a/admin/application/admin/view/firmcustomer/add.html b/admin/application/admin/view/firmcustomer/add.html index 501e419..66be1d9 100644 --- a/admin/application/admin/view/firmcustomer/add.html +++ b/admin/application/admin/view/firmcustomer/add.html @@ -91,12 +91,13 @@ -