Files
2025-11-08 23:41:05 +08:00

88 lines
3.3 KiB
PHP

<?php
defined('WXAPP_APP') or exit('No direct script access allowed');
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
class Clues extends Wxapp
{
function __construct($inputs, $app_key)
{
parent::__construct($inputs, $app_key);
$this->login_white = array();//登录白名单
$this->check_status = array();//用户状态校验
$this->check_mobile = array();//需要手机号
$this->check_headimg = array();//授权微信信息
$this->load->model('receiver/receiver_clues_model', 'clues_model');
$this->load->model('receiver/receiver_clue_oplogs_model', 'clue_oplogs_model');
$this->load->model('area_model', 'mdArea');
$this->load->model('biz/biz_visit_log_model');
}
public function get()
{
$id = $this->input_param('id');
if ($id) {
$where = [
'id' => $id,
];
$row = $this->clues_model->get($where);
if (!$row) {
throw new Exception('数据不存在', ERR_PARAMS_ERROR);
}
$other_data = [];
if ($row['county_id']) {
$re_area = $this->mdArea->get(['county_id' => $row['county_id']], 'province_name,city_name,county_name');
$re_area && $other_data['所在地区'] = "{$re_area['province_name']}-{$re_area['city_name']}-{$re_area['county_name']}";
}
$other_data['创建时间'] = date('Y-m-d', $row['c_time']);
$logs = $this->clue_oplogs_model->select(['clue_id' => $id], 'id desc', 1, 1);
if ($logs) {
$other_data['最近联系时间'] = date('Y-m-d', $logs[0]['c_time']);
}
$data = [
'id' => $row['id'],
'name' => $row['name'],
'mobile' => mobile_asterisk($row['mobile']),
'other_data' => $other_data,
];
return $data;
} else {
$page = $this->input_param('page');
$size = $this->input_param('size');
!$page && $page = 1;
!$size && $size = 10;
$where = ['biz_id' => $this->get_biz_id(), 'status' => 1, 'status2' => 1];
$total = $this->clues_model->count($where);
$lists = [];
if ($total > 0) {
$rows = $this->clues_model->select($where, 'id desc', $page, $size, 'id,mobile,name');
foreach ($rows as $item) {
$item['mobile'] = mobile_asterisk($item['mobile']);
$lists[] = $item;
}
}
//增加埋点
$logData = [
'uid' => $this->session['uid'],
'biz_id' => $this->get_biz_id(),
'title' => '线索列表'
];
$this->biz_visit_log_model->addDataPushQueue($logData);
return ['list' => $lists, 'total' => $total];
}
}
//解锁线索
protected function put_unlock()
{
$id = $this->input_param('id');
/** @var MyResponse $result */
$result = $this->clues_model->unlock($id, $this->get_biz_id());
if (!$result->isSuccess()) {
throw new Exception($result->getMessage(), API_CODE_FAIL);
}
throw new Exception('解锁成功', API_CODE_SUCCESS);
}
}