owners_617

This commit is contained in:
dengbw
2022-06-17 17:39:48 +08:00
parent 9f4f06a5cc
commit 1b5a42bdd4
10 changed files with 1613 additions and 52 deletions
+15 -3
View File
@@ -1061,9 +1061,12 @@ class Common extends CI_Controller
} else if ($type == 'customer') {
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
$re = $this->mdCustomers->get(array('id' => $id));
} else if ($type == 'owners') {
$this->load->model('receiver/receiver_owners_model', 'mdOwners');
$re = $this->mdOwners->get(array('id' => $id));
}
if (!$re['mobile']) {
return $this->show_json(SYS_CODE_FAIL, '客户不存在!');
return $this->show_json(SYS_CODE_FAIL, '手机不存在!');
}
$mobile = $re['mobile'];
$content = '';
@@ -1095,9 +1098,12 @@ class Common extends CI_Controller
} else if ($type == 'customer') {
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
$re = $this->mdCustomers->get(array('id' => $id));
} else if ($type == 'owners') {
$this->load->model('receiver/receiver_owners_model', 'mdOwners');
$re = $this->mdOwners->get(array('id' => $id));
}
if (!$re['mobile']) {
return $this->show_json(SYS_CODE_FAIL, '客户不存在!');
return $this->show_json(SYS_CODE_FAIL, '手机不存在!');
}
$mobile = $re['mobile'];
if (!$content) {
@@ -1140,6 +1146,9 @@ class Common extends CI_Controller
} else if ($type == 'customer') {
$this->load->model('receiver/receiver_customer_oplogs_model', 'mdOplogs');
$data['customer_id'] = $id;
} else if ($type == 'owners') {
$this->load->model('receiver/receiver_owners_oplogs_model', 'mdOplogs');
$data['own_id'] = $id;
}
$this->mdOplogs->add($data);//增加操作记录
}
@@ -1170,9 +1179,12 @@ class Common extends CI_Controller
} else if ($type == 'customer') {
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
$re = $this->mdCustomers->get(array('id' => $id));
} else if ($type == 'owners') {
$this->load->model('receiver/receiver_owners_model', 'mdOwners');
$re = $this->mdOwners->get(array('id' => $id));
}
if (!$re['mobile']) {
return $this->show_json(SYS_CODE_FAIL, '客户不存在!');
return $this->show_json(SYS_CODE_FAIL, '手机不存在!');
}
$mobile = $re['mobile'];
$cache = &load_cache('redis');
+399
View File
@@ -0,0 +1,399 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notes:车主
* Created on: 2022/6/15 17:15
* Created by: dengbw
*/
class Owners extends HD_Controller
{
private $searchTpAry = array('mobile' => '车主电话', 'name' => '车主姓名', 'car_num' => '车牌号');
private $searchTimeAry = array('c_time' => '创建时间', 'order_time' => '购车时间', 'ck_time' => '交付时间', 'u_time' => '最后操作时间');
protected $log_dir;
public function __construct()
{
parent::__construct();
$this->load->model('receiver/receiver_owners_model', 'mdOwners');
$this->load->model('receiver/receiver_owners_oplogs_model', 'mdOwnersOplogs');
$this->load->model('receiver/receiver_owners_tag_model', 'mdOwnersTag');
$this->load->model('receiver/receiver_owners_tagdata_model', 'mdOwnersTagdata');
$this->load->model('receiver/receiver_xz_model');
$this->log_dir = 'receiver_' . get_class($this);
}
public function index()
{
return $this->lists();
}
public function lists()
{
$params = $this->input->get();
$page = $params['page'] = $params['page'] ? intval($params['page']) : 1;
$size = $params['size'] = $params['size'] ? intval($params['size']) : 20;
$where = array('status>=0' => null);
if ($params['title']) {
$where["{$params['search_tp']} like '%{$params['title']}%'"] = null;
}
!$params['search_tp'] && $params['search_tp'] = 'mobile';
if ($params['c_time']) {
$c_time = explode(' ~ ', $params['c_time']);
$c_time[0] && $where["c_time >="] = strtotime($c_time[0] . ' 00:00:00');
$c_time[1] && $where["c_time <="] = strtotime($c_time[1] . ' 23:59:59');
}
if ($params['order_time']) {
$order_time = explode(' ~ ', $params['order_time']);
$order_time[0] && $where["order_time >="] = $order_time[0] . ' 00:00:00';
$order_time[1] && $where["order_time <="] = $order_time[1] . ' 23:59:59';
}
if ($params['ck_time']) {
$ck_time = explode(' ~ ', $params['ck_time']);
$ck_time[0] && $where["ck_time >="] = $ck_time[0] . ' 00:00:00';
$ck_time[1] && $where["ck_time <="] = $ck_time[1] . ' 23:59:59';
}
if ($params['u_time']) {
$u_time = explode(' ~ ', $params['u_time']);
$u_time[0] && $where["u_time >="] = $u_time[0] . ' 00:00:00';
$u_time[1] && $where["u_time <="] = $u_time[1] . ' 23:59:59';
}
if ($params['sex']) {
$where["sex"] = $params['sex'];
} else {
$params['sex'] = '';
}
if ($params['brand_id']) {
$where["brand_id"] = $params['brand_id'];
} else {
$params['brand_id'] = '';
}
if ($params['s_id']) {
$where["s_id"] = $params['s_id'];
} else {
$params['s_id'] = '';
}
if ($params['v_id']) {
$where["v_id"] = $params['v_id'];
} else {
$params['v_id'] = '';
}
$count = $this->mdOwners->count($where);
$lists = [];
if ($count) {
$this->load->model('auto/auto_brand_model', 'mdBrand');
$this->load->model('auto/auto_series_model', 'mdSeries');
$this->load->model('auto/auto_attr_model', 'mdAttr');
$res = $this->mdOwners->select($where, 'id desc', $page, $size);
$str_brand_ids = implode(',', array_unique(array_column($res, 'brand_id')));
$map_brands = $this->mdBrand->map('id', 'name', ["id in({$str_brand_ids})" => null]);
$str_s_ids = implode(',', array_unique(array_column($res, 's_id')));
$map_series = $this->mdSeries->map('id', 'name', ["id in({$str_s_ids})" => null]);
$str_v_ids = implode(',', array_unique(array_column($res, 'v_id')));
$map_attrs = $this->mdAttr->map('id', 'title', ["id in({$str_v_ids})" => null]);
foreach ($res as $key => $val) {
if (SUPER_ADMIN == $this->role || $this->role == 35) {
$mobile_sub = $val['mobile'];
} else {
$mobile_sub = $val['mobile'] ? substr_replace($val['mobile'], '*****', 0, 5) : '';
}
$sex = $car_name = '';
if ($val['sex']) {
$sex = $val['sex'] == 1 ? '男' : '女';
}
$map_brands[$val['brand_id']] && $car_name = $map_brands[$val['brand_id']];
$map_series[$val['s_id']] && $car_name = $car_name ? $car_name . '-' . $map_series[$val['s_id']] : $map_series[$val['s_id']];
$map_attrs[$val['v_id']] && $car_name = $car_name ? $car_name . '-' . $map_attrs[$val['v_id']] : $map_attrs[$val['v_id']];
$lists[] = array(
'id' => $val['id'],
'name' => $val['name'],
'mobile' => $val['mobile'],
'mobile_sub' => $mobile_sub,
'sex' => $sex,
'age' => $this->getAgeByBirth($val['birth_day']),
'car_name' => $car_name,
'car_num' => $val['car_num'],
'order_time' => $val['order_time'] != '0000-00-00 00:00:00' ? $val['order_time'] : '',
'ck_time' => $val['ck_time'] != '0000-00-00 00:00:00' ? $val['ck_time'] : '',
);
}
}
$this->data['lists'] = $lists;
$this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count);
$this->data['searchTpAry'] = $this->searchTpAry;
$this->data['searchTimeAry'] = $this->searchTimeAry;
$this->data['params'] = $params;
$this->data['_title'] = '车主列表';
return $this->show_view('receiver/owners/lists', true);
}
public function get()
{
$id = $this->input->get('id');
$row = $this->mdOwners->get(array('id' => $id));
if (!$row) {
return $this->show_json(SYS_CODE_FAIL, '车主不存在!');
}
//用户信息
if (SUPER_ADMIN == $this->role || 35 == $this->role) {
$mobile_sub = $row['mobile'];
} else {
$mobile_sub = $row['mobile'] ? substr_replace($row['mobile'], '*****', 0, 5) : '';
}
$info = $row;
$info['mobile'] = $mobile_sub;
$info['order_time'] = $row['order_time'] != '0000-00-00 00:00:00' ? $row['order_time'] : '';
$info['ck_time'] = $row['ck_time'] != '0000-00-00 00:00:00' ? $row['ck_time'] : '';
$info['c_time'] = date('Y-m-d H:i:s', $row['c_time']);
$info['tag'] = $this->get_tag($row['id']);
//操作日志
$rows_log = $this->mdOwnersOplogs->select(array('own_id' => $id), 'id desc', 0, 0);
$logs = [];
foreach ($rows_log as $key => $value) {
$rec_text = $rec_url = '';
if ($value['type'] == 2) {
$rec_row = $this->receiver_xz_model->get(['id' => $value['log']], 'rec_url,duration');
if ($rec_row['duration']) {
$rec_row['rec_url'] && $rec_url = $rec_row['rec_url'];
!$rec_row['rec_url'] && $rec_text = '录音暂未生成';
} else {
$rec_text = '未接通';
}
}
$imgs = [];
if ($value['imgs']) {
$json_imgs = json_decode($value['imgs'], true);
foreach ($json_imgs as $key1 => $value1) {
$imgs[] = build_qiniu_image_url($value1);
}
}
$logs[] = array(
'uname' => $value['uname'],
'log' => $value['log'],
'imgs' => $imgs,
'rec_url' => $rec_url,
'rec_text' => $rec_text,
'type_name' => $this->mdOwnersOplogs->typeAry()[$value['type']],
'c_time' => date('Y-m-d H:i', $value['c_time'])
);
}
$this->data['info'] = $info;
$this->data['logs'] = $logs;
$this->data['_title'] = '车主户详情';
return $this->show_view('receiver/owners/get', true);
}
public function add()
{
// TODO: Implement add() method.
}
/**
* 新增日志
* @return bool
*/
function add_log()
{
$params = $this->input->post();
if (!$params['id']) {
return $this->show_json(SYS_CODE_FAIL, '参数错误!');
}
if (!$params['log']) {
return $this->show_json(SYS_CODE_FAIL, '请输入内容!');
}
$addData = array(
'own_id' => $params['id'],
'uid' => $this->uid,
'uname' => $this->username,
'type' => intval($params['type']),
'log' => $params['log'],
'c_time' => time()
);
$id = $this->mdOwnersOplogs->add($addData);
if ($id) {
return $this->show_json(SYS_CODE_SUCCESS, '添加成功');
} else {
return $this->show_json(SYS_CODE_FAIL, '添加失败');
}
}
/**
* 编辑
* @return bool
*/
public function edit()
{
$info = $this->input->post('info');
if (!$info) {
return $this->show_json(SYS_CODE_FAIL, '非法参数!');
}
$row = $this->mdOwners->get(array('id' => $info['id']));
if (!$row) {
return $this->show_json(SYS_CODE_FAIL, '车主信息不存在!');
}
$msg = '修改成功';
$code = SYS_CODE_SUCCESS;
if ($info['editType'] == 1) {
} else if ($info['editType'] == 2) {
//更新车主信息
$ret = $this->mdOwners->update(['name' => $info['name'], 'birth_day' => $info['birth_day'], 'sex' => $info['sex'],
'brand_id' => $info['brand_id'], 's_id' => $info['s_id'], 'v_id' => $info['v_id'], 'car_num' => $info['car_num'],
'order_time' => $info['order_time'], 'ck_time' => $info['ck_time']], ['id' => $info['id']]);
if (!$ret) {
$code = SYS_CODE_FAIL;
$msg = '修改车主信息失败';
} else {
$msg = '修改车主信息成功';
$this->addLog(array('own_id' => $info['id'], 'type' => 0, 'log' => '更新车主信息'));
}
} else if ($info['editType'] == 3) {
$id = $info['id'];
//客户标签
if (!$info['tag']) {
return $this->show_json(SYS_CODE_FAIL, '客户画像不存在!');
}
$add_tag = [];
//查找已加入标签
$res_td = $this->mdOwnersTagdata->select(['o_id' => $id], 'id desc', 0, 0, 't_id');
$tag_data = $res_td ? array_unique(array_column($res_td, 't_id')) : '';
foreach ($info['tag'] as $key => $val) {
foreach ($val['list'] as $key2 => $val2) {
if ($val['type'] == 'checkbox') {
if ($val2['checked'] == 'true') {
if (!$tag_data || !in_array($val2['id'], $tag_data)) {//未加标签,新增
$add_tag[] = ['o_id' => $id, 't_id' => $val2['id'], 'c_time' => time()];
}
} else {
if ($tag_data && in_array($val2['id'], $tag_data)) {//删除标签
$this->mdOwnersTagdata->delete(['o_id' => $id, 't_id' => $val2['id']]);
}
}
} else {
if ($val['value'] == $val2['id']) {
if (!$tag_data || !in_array($val2['id'], $tag_data)) {//未加标签,新增
$add_tag[] = ['o_id' => $id, 't_id' => $val2['id'], 'c_time' => time()];
}
} else {
if ($tag_data && in_array($val2['id'], $tag_data)) {//删除标签
$this->mdOwnersTagdata->delete(['o_id' => $id, 't_id' => $val2['id']]);
}
}
}
}
}
if ($add_tag && count($add_tag)) {
$this->mdOwnersTagdata->add_batch($add_tag);
}
$this->addLog(array('own_id' => $info['id'], 'type' => 0, 'log' => '修改车主画像'));
}
return $this->show_json($code, $msg);
}
public function del()
{
}
public function batch()
{
// TODO: Implement batch() method.
}
public function export()
{
// TODO: Implement export() method.
}
/**
* Notes:增加日志
* Created on: 2021/7/23 10:48
* Created by: dengbw
* @param array $ary
* @return mixed
*/
private function addLog($ary = array())
{
$id = 0;
if ($ary['log']) {
$addData = array(
'own_id' => $ary['own_id'],
'uid' => $this->uid,
'uname' => $this->username,
'type' => intval($ary['type']),
'log' => $ary['log'],
'c_time' => time()
);
$id = $this->mdOwnersOplogs->add($addData);
}
return $id;
}
/**
* Notes:车主标签
* Created on: 2022/6/16 14:47
* Created by: dengbw
* @param $id
* @return array
*/
private function get_tag($id)
{
$show = $res_td = [];
$res = $this->mdOwnersTag->select(['status' => 1, 'pid' => 0], 'sort desc,id desc', 0, 0, 'id,name,type');
if ($res) {
$id && $res_td = $this->mdOwnersTagdata->select(['o_id' => $id], 'id desc', 0, 0, 't_id');//查找用户选择
$tag_data = $res_td ? array_unique(array_column($res_td, 't_id')) : '';
foreach ($res as $key => $val) {
$list = [];
$value = '';
$res2 = $this->mdOwnersTag->select(['status' => 1, 'pid' => $val['id']], 'sort desc,id desc', 0, 0, 'id,name');
foreach ($res2 as $key2 => $val2) {
//检查是否选中标签
$setValue = ['id' => $val2['id'], 'name' => $val2['name']];
if ($val['type'] == 'checkbox') {
$setValue['checked'] = $tag_data && in_array($val2['id'], $tag_data) ? true : false;
} else {
if ($tag_data && in_array($val2['id'], $tag_data)) {
$value = $val2['id'];
}
}
$list[] = $setValue;
}
$show[] = ['id' => $val['id'], 'name' => $val['name'], 'type' => $val['type'], 'value' => $value, 'list' => $list];
}
}
return $show;
}
/**
* Notes:根据生日计算年龄,年龄的格式是:2018-01-22
* Created on: 2022/6/16 14:47
* Created by: dengbw
* @param $birthday
* @return false|int|string
*/
private function getAgeByBirth($birthday)
{
$birth_year = date('Y', strtotime($birthday));
$birth_month = date('m', strtotime($birthday));
$birth_day = date('d', strtotime($birthday));
if (empty($birth_year) || empty($birth_month) || empty($birth_day)) {
return 0;
}
$current_year = date('Y', time());
$current_month = date('m', time());
$current_day = date('d', time());
if ($birth_year >= $current_year) {
return 0;
}
$age = $current_year - $birth_year - 1;
if ($current_month > $birth_month) {
return $age + 1;
} else if ($current_month == $birth_month && $current_day >= $birth_day) {
return $age + 1;
} else {
return $age;
}
}
}
+583
View File
@@ -0,0 +1,583 @@
<div class="am-form am-form-horizontal" style="width: 98%;padding-top: 10px">
<div id="vue-edit">
<div class="am-u-lg-12">
<div class="am-panel am-panel-default">
<div class="am-panel-hd">
<span href="javascript:void(0)" style="font-size: 20px">
车主信息
</span>
<span style="float:right;margin-top:5px;">
<a href="javascript:" @click="editType(2)"><i class="fa fa-edit"></i></a>
</span>
</div>
<div class="am-panel-bd am-g">
<table width="100%" style="margin-left: 10px;margin-right: 10px;">
<tr>
<td class="table-td">
<table>
<tr>
<td><span class="mr5">车主姓名:</span></td>
<td><input type="text" v-model="info.name" placeholder="请输入车主姓名"
style="width: 220px;"></td>
</tr>
</table>
</td>
<td class="table-td"><span class="mr5">车主电话:</span>{{info.mobile}}</td>
<td class="table-td"><span class="mr5">加入时间:</span>{{info.c_time}}</td>
</tr>
<tr>
<td class="table-td">
<table>
<tr>
<td><span class="mr5">车主生日:</span></td>
<td><input id="birth_day" type="text" v-model="info.birth_day"
autocomplete="off"
placeholder="请输入车主生日"
style="width: 220px;"></td>
</tr>
</table>
</td>
<td class="table-td">
<table>
<tr>
<td><span class="mr5">车主性别:</span></td>
<td>&nbsp;<input type="radio" :value='1' v-model="info.sex"> &nbsp;
<input type="radio" :value='2' v-model="info.sex"> &nbsp;
</td>
</tr>
</table>
</td>
<td class="table-td">
<table>
<tr>
<td><span class="mr5">品牌车型:</span></td>
<td>
<div class="am-para-inline w100">
<select name="brand_id" v-model="info.brand_id">
<option value="">选择品牌</option>
<option :value="v.id" v-for="(v,i) in brandAry">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w100">
<select name="s_id" v-model="info.s_id">
<option value="">选择车系</option>
<option :value="v.id" v-for="(v,i) in seryAry">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w170">
<select name="v_id" v-model="info.v_id">
<option value="">选择车型</option>
<option :value="v.id" v-for="(v,i) in attrvAry">{{v.title}}</option>
</select>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="table-td">
<table>
<tr>
<td><span class="mr5">车牌号码:</span></td>
<td><input type="text" v-model="info.car_num" placeholder="请输入车牌号码"
style="width: 220px;"></td>
</tr>
</table>
</td>
<td class="table-td">
<table>
<tr>
<td><span class="mr5">购车时间:</span></td>
<td><input id="order_time" type="text" v-model="info.order_time"
autocomplete="off"
placeholder="请输入购车时间"
style="width: 220px;"></td>
</tr>
</table>
</td>
<td class="table-td">
<table>
<tr>
<td><span class="mr5">交付时间:</span></td>
<td><input id="ck_time" type="text" v-model="info.ck_time"
autocomplete="off"
placeholder="请输入交付时间"
style="width: 220px;"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<div class="am-form-inline" style="padding-right: 30px;padding-top: 10px;">
<div class="text-left pt10" v-if="edit_index==2">
<div class="am-form-group ml10">
<a href="javascript:void(0)"
class="am-btn am-btn-sm am-btn-success"
@click="saveEdit()">修改车主信息</a>
</div>
</div>
</div>
</td>
<td colspan="3">
<div class="am-form-inline" style="padding-right: 30px;padding-top: 10px;">
<div class="text-right pt10">
<div class="am-form-group ml10">
<a data-modal="/common/show_sms?id=<?= $info['id'] ?>&type=owners"
data-title="发送短信"
class="am-btn am-btn-sm am-btn-success">短信</a>
</div>
<div class="am-form-group ml10">
<a href="javascript:void(0);"
data-modal="/common/bind_mobile?id=<?= $info['id'] ?>&type=owners"
class="am-btn am-btn-sm am-btn-success" data-title="获取手机号">
拨打电话
</a>
</div>
</div>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="am-u-lg-12">
<div class="am-panel am-panel-default">
<div class="am-panel-hd">
<span href="javascript:void(0)" style="font-size: 20px">
车主画像
</span>
<span style="float:right;margin-top:5px;">
<a href="javascript:" @click="editType(3)"><i class="fa fa-edit"></i></a>
</span>
</div>
<div class="am-panel-bd am-g">
<table width="100%" style="margin-left: 10px;margin-right: 10px;">
<template v-for="(v,i) in info.tag">
<tr>
<td class="table-td" style="width: 80%">
<table>
<tr v-if="v.type=='checkbox'">
<td style="min-width: 80px">{{v.name}}:</td>
<td>
<template v-for="(v2,i2) in v.list">
<input type="checkbox" :value='v2.checked'
v-model="v2.checked"> {{v2.name}}&nbsp;
</template>
</td>
</tr>
<tr v-else>
<td style="min-width: 80px">{{v.name}}:</td>
<td>
<template v-for="(v2,i2) in v.list">
<input type="radio" :value='v2.id'
v-model="v.value"> {{v2.name}}&nbsp;
</template>
</td>
</tr>
</table>
</td>
</tr>
</template>
<tr v-if="edit_index==3">
<td>
<div class="am-form-inline" style="padding-right: 30px;padding-top: 10px;">
<div class="text-left pt10">
<div class="am-form-group ml10">
<a href="javascript:void(0)"
class="am-btn am-btn-sm am-btn-success"
@click="saveEdit()">保存车主画像</a>
</div>
</div>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="am-u-lg-12">
<div class="am-panel am-panel-default">
<div class="am-panel-hd">
<span href="javascript:void(0)" style="font-size: 20px">
操作日志
</span>
<span style="float:right;margin-top:5px">
<a href="javascript:void(0)" @click="logModal()">新增小记</a>
</span>
</div>
<div class="am-panel-bd">
<div class="am-tabs" data-am-tabs>
<div class="am-tab-panel am-active">
<table class="am-table">
<thead>
<tr>
<th width="15%"><span>操作人员</span></th>
<th width=""><span>内容</span></th>
<th width="13%"><span>类型</span></th>
<th width="15%"><span>操作时间</span></th>
</tr>
</thead>
<tbody>
<?php foreach ($logs as $key => $val) { ?>
<tr>
<td style="vertical-align:middle;word-wrap:break-word"><?= $val['uname'] ?></td>
<td style="vertical-align:middle;word-wrap:break-word">
<? if ($val['rec_url']) { ?>
<audio controls="controls">
<source src="<?= $val['rec_url'] ?>"/>
</audio>
<? } else if ($val['rec_text']) { ?>
<?= $val['rec_text'] ?>
<? } else { ?>
<?= $val['log'] ?>
<? } ?>
<? if ($val['imgs']) { ?>
<div class="photo-upload" style="padding-top: 10px;">
<?php foreach ($val['imgs'] as $key1 => $val1) { ?>
<div class="photo-upload-item">
<a href="javascript:void (0);">
<img src="<?= $val1 ?>"
class="img-thumbnail" data-tips-image
style="height:auto;max-height:100px;min-width:100px">
</a>
</div>
<? } ?>
</div>
<? } ?>
</td>
<td style="vertical-align:middle;word-wrap:break-word"><?= $val['type_name'] ?></td>
<td style="vertical-align:middle;word-wrap:break-word;"><?= $val['c_time'] ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div id="log-modal" style="display: none;">
<div style="padding-top: 20px;">
<div class="am-form-group">
<label class="am-para-label label-width">内容:</label>
<div class="am-para-input" style="width: 80%">
<textarea name="log" rows="5" placeholder="请输入内容" v-model="goods.log"></textarea>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
var vue_obj;
$(document).ready(function () {
vue_obj = new Vue({
el: '#vue-edit',
data: {
edit_index: 0,
info: {},
logs: [],
brandAry: [],
seryAry: [],
attrvAry: [],
goods: {"imgs_url": [], "imgs": [], "log": ''}
},
mounted: function () {
var that = this;
that.info = <?=json_encode($info)?>;
that.logs = <?=json_encode($logs)?>;
that.init_brands();
},
computed: {},
created: function () {
},
updated: function () {
},
methods: {
init_brands: function () {
var vm = this;
$.ajax({
url: '/auto/brand/json_lists',
type: 'post',
dataType: 'json',
data: {status: 1},
beforeSend: function () {
},
success: function (data) {
if (1 == data.code) {
vm.brandAry = data.data.list;
}
},
complete: function () {
}
});
},
editType: function (index) {
var vm = this;
if (vm.edit_index == index) {
vm.edit_index = 0;
} else {
vm.edit_index = index;
}
},
logModal: function () {
var vm = this;
layer.open({
type: 1,
area: ['50%'], //宽高
content: $('#log-modal'),
title: '新增小记',
shade: false,
btn: ['保存', '取消'],
yes: function (index) {
$.ajax({
url: '/receiver/owners/add_log',
type: 'post',
dataType: 'json',
data: {
act_type: 1, id: <?= $info['id'] ?>, type: 0, log: vm.goods.log, imgs: vm.goods.imgs
},
beforeSend: function () {
layer.load(1, {
shade: [0.1, '#fff'] //0.1透明度的白色背景
});
},
success: function (data) {
if (data['code']) {
layer.msg(data.msg, {
icon: 1,
time: 2000
}, function () {
$.form.reload();
});
} else {
layer.msg(data.msg, {icon: 2});
}
},
complete: function () {
layer.closeAll('loading');
},
});
}
});
},
saveEdit: function () {
var vm = this;
vm.info.editType = vm.edit_index;
$.ajax({
url: '/receiver/owners/edit',
type: 'post',
dataType: 'json',
data: {
info: vm.info
},
beforeSend: function () {
layer.load(1, {
shade: [0.1, '#fff'] //0.1透明度的白色背景
});
},
success: function (data) {
loading = false;
if (data['code']) {
layer.msg(data.msg, {
icon: 1,
time: 2000
}, function () {
$.form.reload();
});
} else {
layer.msg(data.msg, {icon: 2});
}
},
complete: function () {
loading = false;
layer.closeAll('loading');
},
});
},
},
watch: {
'info.brand_id': function (nv, ov) {
var vm = this;
vm.seryAry = {};
if (nv > 0) {
$.ajax({
url: '/auto/series/json_lists',
type: 'post',
dataType: 'json',
data: {brand_id: nv},
beforeSend: function () {
},
success: function (data) {
if (1 == data.code) {
var lists = data.data.list;
var seryAry = {};
for (var i in lists) {
var row = lists[i];
seryAry[row.id] = row.name;
}
vm.seryAry = lists;
if (vm.info.s_id > 0 && undefined == seryAry[vm.info.s_id]) {
vm.info.s_id = '';
}
}
},
complete: function () {
layer.closeAll('loading');
}
});
} else {
vm.info.s_id = '';
}
},
'info.s_id': function (nv, ov) {
var vm = this;
if (nv > 0) {
//型号
$.ajax({
type: 'post',
url: '/auto/attr/json_lists',
dataType: 'json',
data: {
s_id: nv,
status: 1,
type: 1
},
success: function (response) {
if (response.code == 1) {
vm.attrvAry = response.data.list;
}
}
});
} else {
vm.attrvAry = [];
vm.info.v_id = '';
}
},
},
});
});
require(['laydate'], function (laydate) {
//日期范围
laydate.render({
elem: '#birth_day'
, type: 'date'
, done: function (value, date) {
vue_obj.info.birth_day = value;
}
});
laydate.render({
elem: '#order_time'
, type: 'datetime'
, done: function (value, date) {
vue_obj.info.order_time = value;
}
});
laydate.render({
elem: '#ck_time'
, type: 'datetime'
, done: function (value, date) {
vue_obj.info.ck_time = value;
}
});
});
</script>
<style type="text/css">
.input-group {
width: 100%;
padding-right: 30px;
}
.input-group-addon {
padding: 0px 10px 0px 0px;
font-size: 1.6rem;
font-weight: normal;
line-height: 0px;
color: #333;
text-align: right;
background-color: #fff;
border: 0px solid #fff;
border-radius: 0px;
width: 120px;
}
.table-td {
width: 20%;
padding-top: 15px;
line-height: 37px;
font-size: 1.6rem;
}
.my-ul ul li {
padding: 10px;
}
.my-panel {
padding: 10px;
border: 1px solid #ddd;
height: 90px;
}
.auto-content {
width: min-content;
min-width: 50%;
}
.btn-group .disabled {
background-color: #eee;
opacity: 1;
}
.photo-upload {
position: relative;
font-size: 0;
}
.photo-upload:after {
content: "";
display: table;
clear: both;
}
.photo-upload-item {
position: relative;
float: left;
margin-right: 10px;
margin-bottom: 10px;
font-size: 12px; /*display:inline-block;width:120px;*/
}
.photo-upload-item > img {
}
.photo-upload-item-check,
.photo-upload-item-remove {
opacity: 0;
position: absolute;
top: -8px;
right: -8px;
width: 24px;
height: 24px;
line-height: 24px;
border: 1px solid #fff;
background-color: #eee;
border-radius: 50%;
text-align: center;
cursor: pointer;
}
.photo-upload-item:hover .photo-upload-item-remove {
opacity: 1;
transition: all .4s ease
}
.photo-upload-item-check {
opacity: 1;
background-color: #36f;
color: #fff;
}
</style>
<link rel="stylesheet" type="text/css" href="/static/css/appitem/font-awesome.min.css?v=1581252500">
+331
View File
@@ -0,0 +1,331 @@
<link rel="stylesheet" type="text/css" href="/static/css/font-awesome.min.css?v=1581252500">
<div class="coms-table-wrap mt10">
<form id="vue-app" class="form-search coms-table-hd clearfix no-border" onsubmit="return false"
action="/receiver/owners">
<div class="am-form am-form-horizontal">
<div class="am-form-group fl">
<label class="am-para-label w100">客户搜索:</label>
<div class="am-para-inline w100">
<select name="search_tp" v-model="params.search_tp">
<option :value="i" v-for="(v,i) in searchTpAry">{{v}}</option>
</select>
</div>
</div>
<div class="am-form-group fl">
<div class="am-para-inline w200">
<input id="title" name="title" type="text" v-model="params.title"/>
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w60">性别:</label>
<div class="am-para-inline w100">
<select name="sex" v-model="params.sex">
<option value="">请选择</option>
<option value="1"></option>
<option value="2"></option>
</select>
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w100">品牌车型:</label>
<div class="am-para-inline w100">
<select name="brand_id" v-model="params.brand_id">
<option value="">选择品牌</option>
<option :value="v.id" v-for="(v,i) in brandAry">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w100">
<select name="s_id" v-model="params.s_id">
<option value="">选择车系</option>
<option :value="v.id" v-for="(v,i) in seryAry">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w200">
<select name="v_id" v-model="params.v_id">
<option value="">选择车型</option>
<option :value="v.id" v-for="(v,i) in attrvAry">{{v.title}}</option>
</select>
</div>
</div>
<div class="am-form-group" style="margin-bottom: 0px;"></div>
<? foreach ($searchTimeAry as $key => $value) { ?>
<div id="show-<?= $key ?>" style="display:<?= $params[$key] ? 'block' : 'none' ?>">
<div class="am-form-group" style="margin-bottom: 0px;"></div>
<label class="am-para-label w100"><?= $value ?></label>
<div class="am-form-group fl">
<div class="am-para-inline w300">
<input id="id-<?= $key ?>" name="<?= $key ?>" type="text" value="<?= $params[$key] ?>"
placeholder="<?= $value ?>范围" autocomplete="off"/>
</div>
<div class="am-para-inline" style="padding-top: 5px;">
<a class="mr10 id-<?= $key ?>-btn" href="javascript:void (0);" data-date="today">今日</a>
<a class="mr10 id-<?= $key ?>-btn" href="javascript:void (0);" data-date="yesterday">昨日</a>
<a class="mr10 id-<?= $key ?>-btn" href="javascript:void (0);" data-date="weeks">本周</a>
<a class="mr10 id-<?= $key ?>-btn" href="javascript:void (0);" data-date="month">本月</a>
</div>
</div>
</div>
<? } ?>
<div class="am-form-group" style="margin-bottom: 0px;"></div>
<div class="am-form-group fl" style="margin-bottom: 0px;">
<div class="am-form-group fl ml10">
<button type="submit" class="am-btn am-btn-success am-btn-sm w100">搜索</button>
</div>
<div class="am-form-group fl ml10">
<input type="button" @click="btnTimes" value="选择筛选时间" class="am-btn am-btn-success am-btn-sm">
</div>
<div class="am-form-group fl ml10">
<button type="button" class="am-btn am-btn-success am-btn-sm w100" @click="reset">重置</button>
</div>
</div>
</div>
</form>
<div class="coms-table-bd">
<div class="am-form-group fr mr10">
<span>共<?= intval($pager['totle']) ?>个客户</span>
</div>
<table class="am-table am-table-bordered">
<thead>
<tr>
<th width="3%">ID</th>
<th width="8%"><span>车主姓名</span></th>
<th width="8%"><span>车主电话</span></th>
<th width="15%"><span>车辆</span></th>
<th width="8%"><span>车牌号</span></th>
<th width="5%"><span>性别</span></th>
<th width="5%"><span>年龄</span></th>
<th width="10%"><span>购车时间</span></th>
<th width="10%"><span>交付时间</span></th>
</tr>
</thead>
<tbody>
<template v-for="(v,i) in lists">
<tr>
<td>{{v.id}}</td>
<td>{{v.name}}</td>
<td>{{v.mobile_sub}}</td>
<td>{{v.car_name}}</td>
<td>{{v.car_num}}</td>
<td>{{v.sex}}</td>
<td>{{v.age}}</td>
<td>{{v.order_time}}</td>
<td>{{v.ck_time}}</td>
</tr>
<tr>
<td colspan="9">
<div class="row">
<div class="col-md-4 align-l">
</div>
<div class="col-md-8 align-r" style="padding-right: 30px;">
<a :data-modal="'/common/bind_mobile?id='+v.id+'&type=owners'"
href="javascript:void(0);" class="am-btn am-btn-primary am-btn-xs"
data-title="获取手机号">拨打电话</a>
<a :data-modal="'/common/show_sms?id='+v.id+'&type=owners'"
href="javascript:void(0);" class="am-btn am-btn-primary am-btn-xs"
data-title="发送短信">短信</a>
<a href="javascript:void(0);" :data-open="'/receiver/owners/get?id='+v.id"
class="am-btn am-btn-primary am-btn-xs">查看详情</a>
</div>
</td>
</tr>
</template>
</table>
</div>
<div class="coms-table-ft clearfix">
<div class="hander am-form">
</div>
<div class="coms-pagination fr mr20">
<?php page_view($pager) ?>
</div>
</div>
<div id="times-modal" style="display: none;">
<div class="modal-body">
<label class="checkall" style="margin-left: 30px;">
<input id="times_checkbox" type="checkbox" data-check-target=".order-times"> 全选</label>
<div style="margin-left: 40px;">
<?php foreach ($searchTimeAry as $key => $value) { ?>
<label class="am-checkbox" style="padding-bottom: 8px;">
<input type="checkbox" class="order-times" <?= $params[$key] ? 'checked' : '' ?>
value='<?= $key ?>'><?= $value ?></label>
<? } ?>
</div>
</div>
</div>
</div>
<script>
require(['laydate', 'autocomplete'], function (laydate) {
<? foreach ($searchTimeAry as $key => $value) { ?>
laydate.render({
elem: '#id-<?=$key?>', range: '~'
});
$('.id-<?=$key?>-btn').click(function () {
var type = $(this).data('date'), date = '', nowDate = new Date();
var beginDate = '', endDate = '';
switch (type) {
case 'today':
beginDate = endDate = nowDate.Format('yyyy-MM-dd');
break;
case 'yesterday':
beginDate = endDate = (new Date(nowDate.getTime() - 86400000)).Format('yyyy-MM-dd');
break;
case 'weeks':
nowDate.setDate(nowDate.getDate() - nowDate.getDay() + 1);
beginDate = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-" + nowDate.getDate();
nowDate.setDate(nowDate.getDate() + 6);
endDate = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-" + nowDate.getDate();
break;
case 'month':
beginDate = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-01";
var day = new Date(nowDate.getFullYear(), nowDate.getMonth() + 1, 0);
endDate = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-" + day.getDate();
break;
}
date = beginDate + ' ~ ' + endDate;
$('#id-<?=$key?>').val(date);
});
<?}?>
});
var vue_obj;
$(function () {
vue_obj = new Vue({
el: '.coms-table-wrap',
data: {
params: {},
searchTpAry: [],
lists: [],
brandAry: [],
seryAry: [],
attrvAry: [],
},
mounted: function () {
var vm = this;
vm.params = <?=json_encode($params)?>;
vm.searchTpAry = <?=json_encode($searchTpAry)?>;
vm.lists = <?=json_encode($lists)?>;
vm.init_brands();
},
methods: {
init_brands: function () {
var vm = this;
$.ajax({
url: '/auto/brand/json_lists',
type: 'post',
dataType: 'json',
data: {status: 1},
beforeSend: function () {
},
success: function (data) {
if (1 == data.code) {
vm.brandAry = data.data.list;
}
},
complete: function () {
}
});
},
btnTimes: function () {
layer.open({
type: 1,
area: ['25%'], //宽高
content: $('#times-modal'),
title: '选择筛选时间',
shade: false,
btn: ['确定', '取消'],
yes: function (index) {
layer.close(index);
$(".order-times").map(function () {
var id = this.value;
if (this.checked) {
$('#show-' + id).show();
} else {
$('#id-' + id).val('');
$('#show-' + id).hide();
}
});
}
});
},
saveEdit: function () {
$("form").submit();
},
reset: function () {
var that = this;
that.params.search_tp = 'mobile';
that.params.title = '';
that.params.sex = '';
$(".order-times").map(function () {
var id = this.value;
this.checked = false;
$('#id-' + id).val('');
$('#show-' + id).hide();
});
$("#times_checkbox").prop("checked", false);
}
},
watch: {
'params.brand_id': function (nv, ov) {
var vm = this;
vm.seryAry = {};
if (nv > 0) {
$.ajax({
url: '/auto/series/json_lists',
type: 'post',
dataType: 'json',
data: {brand_id: nv},
beforeSend: function () {
},
success: function (data) {
if (1 == data.code) {
var lists = data.data.list;
var seryAry = {};
for (var i in lists) {
var row = lists[i];
seryAry[row.id] = row.name;
}
vm.seryAry = lists;
if (vm.params.s_id > 0 && undefined == seryAry[vm.params.s_id]) {
vm.params.s_id = '';
}
}
},
complete: function () {
layer.closeAll('loading');
}
});
} else {
vm.params.s_id = '';
}
},
'params.s_id': function (nv, ov) {
var vm = this;
if (nv > 0) {
//型号
$.ajax({
type: 'post',
url: '/auto/attr/json_lists',
dataType: 'json',
data: {
s_id: nv,
status: 1,
type: 1
},
success: function (response) {
if (response.code == 1) {
vm.attrvAry = response.data.list;
}
}
});
} else {
vm.attrvAry = [];
vm.params.v_id = '';
}
},
}
});
<?php page_script($pager) ?>
});
</script>
+109 -23
View File
@@ -1,4 +1,5 @@
<?php
/**
* Notes:博饼任务
* Created on: 2021/8/20 17:15
@@ -6,31 +7,114 @@
*/
class Liche extends HD_Controller
{
public function __construct(){
public function __construct()
{
parent::__construct();
$this->load->model('receiver/order/receiver_order_contracts_model');
$this->load->model('receiver/order/receiver_orders_v2_model');
}
$this->load->library('receiver/orders_v2_entity');
/**
* Notes:新增车主信息
* Created on: 2022/6/14 17:15
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/liche/add_owners?rds=1
* https://api.liche.cn/plan/liche/add_owners
*/
public function add_owners()
{
$params = $this->input->get();
$size = 5000;//每次最多处理多少条
$rds = intval($this->input->get('rds'));
$redis = &load_cache('redis');
$redisKey = 'receiver_owners_c_time';
if ($rds) {
$redis->delete($redisKey);
}
$c_time = $redis->get($redisKey);
!$c_time && $c_time = strtotime(date('Y-m-d') . ' 00:00:00');
$log = array();
$this->load->model('receiver/order/receiver_orders_v2_model', 'mdOrders');
$this->load->model('receiver/order/receiver_order_agents_model', 'mdOrdersAgents');
$this->load->model('app/liche/app_liche_users_model', 'mdUsers');
$this->load->model('receiver/receiver_owners_model', 'mdOwners');
$t1 = 'lc_receiver_orders_v2';
$t2 = 'lc_receiver_order_status';
$where = ["{$t2}.c_time>=" => $c_time, "{$t1}.status>=" => 0, "{$t1}.owner_name<>" => '', "{$t1}.owner_mobile<>" => '',
"{$t2}.pid_status" => 5, "{$t2}.status" => 1];
$having = "total >= 1";
$orderby = "{$t2}.c_time asc";
$fileds = "{$t1}.id,{$t1}.brand_id,{$t1}.s_id,{$t1}.v_id,{$t1}.owner_name,{$t1}.owner_mobile,{$t1}.order_time,{$t1}.ck_time
,{$t1}.info_json,{$t2}.c_time";
$res = $this->mdOrders->selectOrders($where, $orderby, 1, $size, '', $fileds, $having);
if (!$res) {
if ($params['rds']) {
echo '1执行到当前c_time' . date('Y-m-d H:i:s', $c_time) . '暂无数据';
}
return;
}
$str_o_ids = implode(',', array_unique(array_column($res, 'id')));
$map_agents = $this->mdOrdersAgents->map('o_id', 'car_num', ["o_id in({$str_o_ids})" => null]);
$str_mobiles = implode(',', array_unique(array_column($res, 'owner_mobile')));
$map_users = $this->mdUsers->map('mobile', 'id', ["mobile in({$str_mobiles})" => null]);
foreach ($res as $key => $value) {
$c_time = $value['c_time'];
$birth_day = '0000-00-00';
$sex = 0;
if ($value['info_json']) {
$info_json = json_decode($value['info_json'], true);
if ($info_json['c_owner_cardid']) {
$cardid = $info_json['c_owner_cardid'];
$birth_day = date('Y-m-d', strtotime(substr($cardid, 6, 8)));
$sex = substr($cardid, -2, 1) % 2 == 0 ? 2 : 1; //1为男 2为女
}
}
$uid = intval($map_users[$value['owner_mobile']]);
$car_num = $map_agents[$value['id']] ? $map_agents[$value['id']] : '';
$data = ['o_id' => $value['id'], 'uid' => $uid, 'name' => $value['owner_name'], 'mobile' => $value['owner_mobile'],
'birth_day' => $birth_day, 'sex' => $sex, 'brand_id' => $value['brand_id'], 's_id' => $value['s_id'],
'v_id' => $value['v_id'], 'order_time' => $value['order_time'], 'ck_time' => $value['ck_time'], 'car_num' => $car_num];
$re = $this->mdOwners->get(['o_id' => $value['id']]);
if ($re) {
$this->mdOwners->update($data, ['id' => $re['id']]);
} else {
$data['c_time'] = time();
$id = $this->mdOwners->add($data);
$id && $log[] = ['id' => $id, 'name' => $data['name'], 'mobile' => $data['mobile']];
}
}
$redis->save($redisKey, $c_time);
if ($params['rds']) {
echo '<br>2执行到当前c_time' . date('Y-m-d H:i:s', $c_time);
echo '<br>成功新增:<br>';
if ($log) {
echo json_encode($log, JSON_UNESCAPED_UNICODE);
echo '<br>';
}
echo '数据库获取:<br>';
echo json_encode($res, JSON_UNESCAPED_UNICODE);
}
}
//获取未签名pdf
public function un_sign_pdf(){
$row = $this->receiver_order_contracts_model->get(['o_id>='=>Orders_v2_entity::V2_START_ID,'flag'=>0,'file !='=>'','status'=>1]);
public function un_sign_pdf()
{
$this->load->model('receiver/order/receiver_order_contracts_model');
$this->load->model('receiver/order/receiver_orders_v2_model');
$this->load->library('receiver/orders_v2_entity');
$row = $this->receiver_order_contracts_model->get(['o_id>=' => Orders_v2_entity::V2_START_ID, 'flag' => 0, 'file !=' => '', 'status' => 1]);
$receiver = $this->receiver_orders_v2_model->get(['id' => $row['o_id']]);
if(file_exists(FCPATH.$row['file']) && $receiver){
$companys = $this->orders_v2_entity->get_biz_mchid($receiver['biz_id'],$receiver['brand_id']);
if (file_exists(FCPATH . $row['file']) && $receiver) {
$companys = $this->orders_v2_entity->get_biz_mchid($receiver['biz_id'], $receiver['brand_id']);
$url = http_host_com();
$width = 130;
$s_img = build_qiniu_image_url($companys['company']['img_seal']);
if($row['type']==1){
if ($row['type'] == 1) {
$page = 2;
$height = 380;
$s_img = build_qiniu_image_url($companys['srv_company']['img_seal']);
}elseif ($row['type']==3){
} elseif ($row['type'] == 3) {
$page = 1;
$height = 620;
} else{
} else {
$page = 3;
$height = 160;
}
@@ -41,32 +125,34 @@ class Liche extends HD_Controller
'width' => $width,
'height' => $height,
's_img' => $s_img,
'file_url' => $url.'/'.$row['file']
'file_url' => $url . '/' . $row['file']
];
die(json_encode($data,JSON_UNESCAPED_UNICODE));
}else{
$this->receiver_order_contracts_model->update(['flag'=>1],['id'=>$row['id']]);
die(json_encode($data, JSON_UNESCAPED_UNICODE));
} else {
$this->receiver_order_contracts_model->update(['flag' => 1], ['id' => $row['id']]);
}
}
//覆盖pdf文件
public function up_pdf(){
public function up_pdf()
{
$this->load->model('receiver/order/receiver_order_contracts_model');
$id = $this->input->post('id');
$row = $this->receiver_order_contracts_model->get(['id'=>$id,'flag'=>0]);
if($row){
$file_path_arr = explode('/',$row['file']);
$row = $this->receiver_order_contracts_model->get(['id' => $id, 'flag' => 0]);
if ($row) {
$file_path_arr = explode('/', $row['file']);
// $file_name = array_pop($file_path_arr);
// $file_name = 'test.pdf';
// $file_path = implode('/',$file_path_arr);
// $res = move_uploaded_file($_FILES['file']['tmp_name'],FCPATH.$file_path.'/'.$file_name);
move_uploaded_file($_FILES['file']['tmp_name'],FCPATH.$row['file']);
$res = $this->receiver_order_contracts_model->update(['flag'=>1],['id'=>$row['id']]);
if($res){
move_uploaded_file($_FILES['file']['tmp_name'], FCPATH . $row['file']);
$res = $this->receiver_order_contracts_model->update(['flag' => 1], ['id' => $row['id']]);
if ($res) {
$data = [
'code' => 1,
'msg' => '保存成功'
];
die(json_encode($data,JSON_UNESCAPED_UNICODE));
die(json_encode($data, JSON_UNESCAPED_UNICODE));
}
}
}
+2
View File
@@ -37,6 +37,8 @@ class Plan extends CI_Controller
$plan[] = array('url' => base_url(array('plan', 'licheb', 'customer_manager_sms')), 'interval' => 2);//给店长发送待分配短信
$plan[] = array('url' => base_url(array('plan', 'licheb', 'users_log')), 'interval' => 2);//顾问日志
$plan[] = array('url' => base_url(array('plan', 'liche', 'add_owners')), 'interval' => 5);//新增车主
$plan[] = array('url' => base_url(array('plan', 'items', 'stock_log')), 'interval' => 5);//库存车辆日志
$plan[] = array('url' => base_url(array('plan', 'polyv', 'view_log')), 'interval' => 5);//直播观看详情数据
+78
View File
@@ -16,6 +16,84 @@ class Temp extends HD_Controller
$this->log_file = 'temp.log';
}
/**
* Notes:加车主(状态交易完成)
* Created on: 2022/5/27 11:58
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/temp/receiver_owners
* https://api.liche.cn/plan/temp/receiver_owners
*/
public function receiver_owners()
{
$this->load->model('receiver/order/receiver_orders_v2_model', 'mdOrders');
$this->load->model('receiver/order/receiver_order_agents_model', 'mdOrdersAgents');
$this->load->model('app/liche/app_liche_users_model', 'mdUsers');
$this->load->model('receiver/receiver_owners_model', 'mdOwners');
$param = $this->input->get();
$param['page'] = intval($param['page']);
$param['size'] = intval($param['size']);
!$param['size'] && $param['size'] = 100;
!$param['page'] && $param['page'] = 1;
$counts = intval($param['counts']);
ob_start(); //打开缓冲区
$t1 = 'lc_receiver_orders_v2';
$t2 = 'lc_receiver_order_status';
$where = ["{$t1}.status>=" => 0, "{$t1}.owner_name<>" => '', "{$t1}.owner_mobile<>" => '', "{$t2}.pid_status" => 5, "{$t2}.status" => 1];
$having = "total >= 1";
$orderby = "{$t2}.c_time asc";
$fileds = "{$t1}.id,{$t1}.brand_id,{$t1}.s_id,{$t1}.v_id,{$t1}.owner_name,{$t1}.owner_mobile,{$t1}.order_time,{$t1}.ck_time
,{$t1}.info_json";
//$count = $this->mdOrders->selectOrders($where, '', '', '', 1, '', $having);
$res = $this->mdOrders->selectOrders($where, $orderby, $param['page'], $param['size'], '', $fileds, $having);
if (!$res) {
echo '<br>本次更新完成了:';
echo '<br><br>成功更新 <span style="color: red;">' . $counts . '</span> 条';
echo '<br><br><a href="/plan/temp/receiver_owners">点击将再次更新>>></a>';
exit;
}
$str_o_ids = implode(',', array_unique(array_column($res, 'id')));
$map_agents = $this->mdOrdersAgents->map('o_id', 'car_num', ["o_id in({$str_o_ids})" => null]);
$str_mobiles = implode(',', array_unique(array_column($res, 'owner_mobile')));
$map_users = $this->mdUsers->map('mobile', 'id', ["mobile in({$str_mobiles})" => null]);
$log = array();
foreach ($res as $key => $value) {
$birth_day = '0000-00-00';
$sex = 0;
if ($value['info_json']) {
$info_json = json_decode($value['info_json'], true);
if ($info_json['c_owner_cardid']) {
$cardid = $info_json['c_owner_cardid'];
$birth_day = date('Y-m-d', strtotime(substr($cardid, 6, 8)));
$sex = substr($cardid, -2, 1) % 2 == 0 ? 2 : 1; //1为男 2为女
}
}
$uid = intval($map_users[$value['owner_mobile']]);
$car_num = $map_agents[$value['id']] ? $map_agents[$value['id']] : '';
$data = ['o_id' => $value['id'], 'uid' => $uid, 'name' => $value['owner_name'], 'mobile' => $value['owner_mobile'],
'birth_day' => $birth_day, 'sex' => $sex, 'brand_id' => $value['brand_id'], 's_id' => $value['s_id'],
'v_id' => $value['v_id'], 'order_time' => $value['order_time'], 'ck_time' => $value['ck_time'], 'car_num' => $car_num];
$re = $this->mdOwners->get(['o_id' => $value['id']]);
if ($re) {
$this->mdOwners->update($data, ['id' => $re['id']]);
} else {
$data['c_time'] = time();
$id = $this->mdOwners->add($data);
if ($id) {
$log[] = ['id' => $id, 'name' => $data['name'], 'mobile' => $data['mobile']];
$counts++;
}
}
}
echo '<br>成功新增:';
if ($log) {
echo json_encode($log, JSON_UNESCAPED_UNICODE);
}
echo '<br><br>数据库获取:';
echo json_encode($res, JSON_UNESCAPED_UNICODE);
header('refresh:3;url=/plan/temp/receiver_owners?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1));
ob_end_flush();//输出全部内容到浏览器
}
/**
* Notes:更新企微好友
* Created on: 2022/5/27 11:58
+30 -26
View File
@@ -68,6 +68,9 @@ class Xzcall extends HD_Controller
} else if ($row['cf_title'] == 'customer') {//客户拨打电话回调
$this->load->model('receiver/receiver_customer_oplogs_model', 'mdOplogs');
$addData['customer_id'] = $row['cf_id'];
} else if ($row['cf_title'] == 'owners') {//车主拨打电话回调
$this->load->model('receiver/receiver_owners_oplogs_model', 'mdOplogs');
$addData['own_id'] = $row['cf_id'];
}
$this->mdOplogs->add($addData);
$xcall = new Xcall($this->admin_config);
@@ -94,14 +97,14 @@ class Xzcall extends HD_Controller
}
$this->load->library('receiver/customers_entity');
$visit = $row['cf_title'] == 'customer' ? 1 : 0;
$this->customers_entity->add_log_visit($cust['id'], $row['cf_uid'], $data['uname'], $row['id'], 2,$visit);
$this->customers_entity->add_log_visit($cust['id'], $row['cf_uid'], $data['uname'], $row['id'], 2, $visit);
}
} else {
if($data['virtualMobile']=='13391247942'){ //推送test环境
if ($data['virtualMobile'] == '13391247942') { //推送test环境
$url = "https://api.lc.haodian.cn/plan/xzcall";
$this->load->library('mycurl');
$res = $this->mycurl->httpPost($url,$data);
debug_log('结束,推送test环境:'.json_encode($res,JSON_UNESCAPED_UNICODE), $this->log_file);
$res = $this->mycurl->httpPost($url, $data);
debug_log('结束,推送test环境:' . json_encode($res, JSON_UNESCAPED_UNICODE), $this->log_file);
}
debug_log("error: 未找到拨打记录", $this->log_file);
}
@@ -148,12 +151,12 @@ class Xzcall extends HD_Controller
$jsondata['file_info'] = $data;
$up_data['json_data'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE);
$this->receiver_xz_model->update($up_data, ['id' => $row['id']]);
}else{
//推送test环境
} else {
//推送test环境
$url = "https://api.lc.haodian.cn/plan/xzcall/video";
$this->load->library('mycurl');
$res = $this->mycurl->httpPost($url,$data);
debug_log('结束,推送test环境:'.json_encode($res,JSON_UNESCAPED_UNICODE), $this->log_file);
$res = $this->mycurl->httpPost($url, $data);
debug_log('结束,推送test环境:' . json_encode($res, JSON_UNESCAPED_UNICODE), $this->log_file);
}
debug_log("end " . __FUNCTION__, $this->log_file);
echo '{"result":"0","error":""}';
@@ -187,14 +190,14 @@ class Xzcall extends HD_Controller
if ($o_id) {
$params = [];
$test && $params['test'] = 1;
$this->load->library('qyrobot',$params);
if($type){
if(!$pay_time){
$this->load->library('qyrobot', $params);
if ($type) {
if (!$pay_time) {
die('pay_time:不能为空');
}
$robot_res = $this->qyrobot->deposit_notify_v2($o_id,1,$pay_time);
}else{
$robot_res = $this->qyrobot->deposit_notify_v2($o_id, 1, $pay_time);
} else {
$robot_res = $this->qyrobot->deposit_notify_v2($o_id);
}
var_dump($robot_res);
@@ -202,7 +205,8 @@ class Xzcall extends HD_Controller
}
//更新订单服务id
public function up_srv_ids(){
public function up_srv_ids()
{
$page = $this->input->get('page');
$size = $this->input->get('size');
!$page && $page = 1;
@@ -210,31 +214,31 @@ class Xzcall extends HD_Controller
$where = [
"srv_ids like '%3%'" => null
];
$rows = $this->orders_model->select($where,'id asc',$page,$size,'id,srv_ids,jsondata');
if($rows){
foreach($rows as $item){
$rows = $this->orders_model->select($where, 'id asc', $page, $size, 'id,srv_ids,jsondata');
if ($rows) {
foreach ($rows as $item) {
$res = false;
$srv_ids_arr = explode(',',$item['srv_ids']);
if(in_array(3,$srv_ids_arr)){
$jsondata = json_decode($item['jsondata'],true);
$srv_ids_arr = explode(',', $item['srv_ids']);
if (in_array(3, $srv_ids_arr)) {
$jsondata = json_decode($item['jsondata'], true);
$jsondata['old_srv_ids'] = $item['srv_ids'];
$jsondata['if_fine'] = 1;
foreach($srv_ids_arr as $key=>$val){
if($val==3){
foreach ($srv_ids_arr as $key => $val) {
if ($val == 3) {
unset($srv_ids_arr[$key]);
break;
}
}
$updata = [
'jsondata' => json_encode($jsondata,JSON_UNESCAPED_UNICODE),
'srv_ids' => implode(',',$srv_ids_arr)
'jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE),
'srv_ids' => implode(',', $srv_ids_arr)
];
$res = $this->orders_model->update($updata,['id'=>$item['id']]);
$res = $this->orders_model->update($updata, ['id' => $item['id']]);
}
$log = "{$item['id']}更新结果:{$res}</br>";
echo $log;
}
}else{
} else {
echo "finish";
}
}
@@ -0,0 +1,30 @@
<?php
/**
* Notes:车主表
* Created on: 2022/6/13 10:31
* Created by: dengbw
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class Receiver_owners_model extends HD_Model
{
private $table_name = 'lc_receiver_owners';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
/**
* Notes:状态
* Created on: 2022/6/13 10:31
* Created by: dengbw
* @return array
*/
public function statusAry()
{
return [1 => '正常', 0 => '禁用'];
}
}
@@ -0,0 +1,36 @@
<?php
/**
* Notes:车主操作日志表
* Created on: 2022/6/15 16:51
* Created by: dengbw
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class Receiver_owners_oplogs_model extends HD_Model
{
private $table_name = 'lc_receiver_owners_oplogs';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
/**
* Notes:类型
* Created on: 2022/6/15 16:51
* Created by: dengbw
* @param int $id
* @return array|mixed
*/
public function typeAry($id = 0)
{
$arr = [0 => '小记', 1 => '发短信', 2 => '拨打号码', 3 => '系统'];
if ($id) {
return $arr[$id];
} else {
return $arr;
}
}
}