edit-licheb-customer
This commit is contained in:
@@ -67,9 +67,10 @@ class Main extends HD_Controller
|
||||
/*小程序设置 end*/
|
||||
|
||||
$list = [];
|
||||
$value = $this->userM->count(['dealer'=>1,'up_uid'=>0]);
|
||||
$list[] = array(
|
||||
'title' => '分销用户(人)',
|
||||
'value' => 0,
|
||||
'value' => $value,
|
||||
'btns' => array(
|
||||
array('name' => '查看详情', 'url' => '/appdistribution/distribution?app_id='.$this->app_id),
|
||||
),
|
||||
|
||||
@@ -112,11 +112,9 @@ class Member extends HD_Controller{
|
||||
$id = $this->input->post('id');
|
||||
$dealer = $this->input->post('dealer');
|
||||
|
||||
|
||||
$upd = [
|
||||
'dealer' => $dealer,
|
||||
];
|
||||
|
||||
$this->userM->update($upd, array('id' => $id));
|
||||
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Vim
|
||||
* User: lcc
|
||||
* Date: 2020/08/04
|
||||
* Time: 10:19
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Brand extends HD_Controller{
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->load->model('auto/auto_brand_model');
|
||||
}
|
||||
|
||||
public function index(){
|
||||
$this->lists();
|
||||
}
|
||||
|
||||
public function lists(){
|
||||
$params = $this->input->get();
|
||||
$page = $this->input->get('page');
|
||||
!$page && $page = 1;
|
||||
$size = 20;
|
||||
$where["status > -1"] = null;
|
||||
$params['title'] && $where["name like '%{$params['title']}%'"] = null;
|
||||
$count = $this->auto_brand_model->count($where);
|
||||
$rows = $this->auto_brand_model->select($where, 'id desc', $page, $size);
|
||||
$status_arr = $this->auto_brand_model->get_status();
|
||||
$list = [];
|
||||
if($rows){
|
||||
foreach($rows as $key=>$val){
|
||||
$list[] = [
|
||||
'id' => $val['id'],
|
||||
'name' => $val['name'],
|
||||
'status' => $val['status'],
|
||||
'status_name' => $status_arr[$val['status']],
|
||||
'c_time' => date('Y-m-d H:i:s',$val['c_time'])
|
||||
];
|
||||
}
|
||||
}
|
||||
$this->data['lists'] = $list;
|
||||
$this->data['params'] = $params;
|
||||
$this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count);
|
||||
$this->data['_title'] = '品牌列表';
|
||||
$this->show_view('auto/brand/lists', true);
|
||||
}
|
||||
|
||||
public function get(){
|
||||
$id = $this->input->get('id');
|
||||
|
||||
$info = [];
|
||||
if ($id) {
|
||||
$info = $this->auto_brand_model->get(array('id' => $id));
|
||||
if (!$info || empty($info)) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '数据不存在!');
|
||||
}
|
||||
}
|
||||
|
||||
$this->data['info'] = $info;
|
||||
$this->data['_title'] = $id ? '编辑品牌' : '新增品牌';
|
||||
return $this->show_view('auto/brand/edit');
|
||||
}
|
||||
|
||||
public function add(){
|
||||
if (!$this->if_ajax) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '提交出错!');
|
||||
}
|
||||
$id = $this->input->post('id');
|
||||
$name = $this->input->post('name');
|
||||
$img = $this->input->post('img');
|
||||
if (!$name || empty($name)) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '品牌名称不能为空');
|
||||
}
|
||||
$old = $this->auto_brand_model->get(['name'=>$name,'status>'=>-1]);
|
||||
if ($old) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '品牌已经存在');
|
||||
}
|
||||
$add_data = array(
|
||||
'name' => $name,
|
||||
'logo' => $img,
|
||||
'c_time' => time()
|
||||
);
|
||||
$brand_id = $this->auto_brand_model->add($add_data);
|
||||
if (!$brand_id) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '添加失败');
|
||||
}
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '添加成功');
|
||||
}
|
||||
|
||||
public function edit(){
|
||||
if (!$this->if_ajax) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '提交出错!');
|
||||
}
|
||||
$id = $this->input->post('id');
|
||||
$name = $this->input->post('name');
|
||||
$img = $this->input->post('img');
|
||||
$row = $this->auto_brand_model->get(['id' => $id]);
|
||||
if (!$row) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '数据不存在!');
|
||||
}
|
||||
if (!$name) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '品牌名称不能为空');
|
||||
}
|
||||
//防止品牌名称重复
|
||||
$where = array('name' => $name, "status<>-1" => null);
|
||||
$id && $where['id <>'] = $id;
|
||||
$old = $this->auto_brand_model->get($where);
|
||||
if ($old) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '品牌已经存在');
|
||||
}
|
||||
$up_data = array(
|
||||
'name' => $name,
|
||||
);
|
||||
$img && $up_data['logo'] = $img;
|
||||
$this->auto_brand_model->update($up_data, array('id' => $id));
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
|
||||
}
|
||||
|
||||
public function del(){
|
||||
$id = $this->input->post('id');
|
||||
if (!$id) {
|
||||
$this->show_json(SYS_CODE_FAIL, '参数错误');
|
||||
}
|
||||
$stauts = $this->input->post('status');
|
||||
$where = array('id' => $id);
|
||||
$this->auto_brand_model->update(array('status' => $stauts), $where);
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
|
||||
}
|
||||
|
||||
public function batch(){
|
||||
|
||||
}
|
||||
|
||||
public function export(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Vim
|
||||
* User: lcc
|
||||
* Date: 2020/08/05
|
||||
* Time: 10:19
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Series extends HD_Controller{
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->load->model('auto/auto_brand_model');
|
||||
$this->load->model('auto/auto_series_model');
|
||||
}
|
||||
|
||||
public function index(){
|
||||
$this->lists();
|
||||
}
|
||||
|
||||
public function lists(){
|
||||
$params = $this->input->get();
|
||||
$page = $this->input->get('page');
|
||||
!$page && $page = 1;
|
||||
$size = 20;
|
||||
$where["status > -1"] = null;
|
||||
$params['title'] && $where["name like '%{$params['title']}%'"] = null;
|
||||
$count = $this->auto_brand_model->count($where);
|
||||
$rows = $this->auto_brand_model->select($where, 'id desc', $page, $size);
|
||||
$status_arr = $this->auto_brand_model->get_status();
|
||||
$list = [];
|
||||
if($rows){
|
||||
foreach($rows as $key=>$val){
|
||||
$list[] = [
|
||||
'id' => $val['id'],
|
||||
'name' => $val['name'],
|
||||
'status' => $val['status'],
|
||||
'status_name' => $status_arr[$val['status']],
|
||||
'c_time' => date('Y-m-d H:i:s',$val['c_time'])
|
||||
];
|
||||
}
|
||||
}
|
||||
$this->data['lists'] = $list;
|
||||
$this->data['params'] = $params;
|
||||
$this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count);
|
||||
$this->data['_title'] = '品牌列表';
|
||||
$this->show_view('auto/brand/lists', true);
|
||||
}
|
||||
|
||||
public function get(){
|
||||
$id = $this->input->get('id');
|
||||
|
||||
$info = [];
|
||||
if ($id) {
|
||||
$info = $this->auto_brand_model->get(array('id' => $id));
|
||||
if (!$info || empty($info)) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '数据不存在!');
|
||||
}
|
||||
}
|
||||
|
||||
$this->data['info'] = $info;
|
||||
$this->data['_title'] = $id ? '编辑品牌' : '新增品牌';
|
||||
return $this->show_view('auto/brand/edit');
|
||||
}
|
||||
|
||||
public function add(){
|
||||
if (!$this->if_ajax) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '提交出错!');
|
||||
}
|
||||
$id = $this->input->post('id');
|
||||
$name = $this->input->post('name');
|
||||
$img = $this->input->post('img');
|
||||
if (!$name || empty($name)) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '品牌名称不能为空');
|
||||
}
|
||||
$old = $this->auto_brand_model->get(['name'=>$name,'status>'=>-1]);
|
||||
if ($old) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '品牌已经存在');
|
||||
}
|
||||
$add_data = array(
|
||||
'name' => $name,
|
||||
'logo' => $img,
|
||||
'c_time' => time()
|
||||
);
|
||||
$brand_id = $this->auto_brand_model->add($add_data);
|
||||
if (!$brand_id) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '添加失败');
|
||||
}
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '添加成功');
|
||||
}
|
||||
|
||||
public function edit(){
|
||||
if (!$this->if_ajax) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '提交出错!');
|
||||
}
|
||||
$id = $this->input->post('id');
|
||||
$name = $this->input->post('name');
|
||||
$img = $this->input->post('img');
|
||||
$row = $this->auto_brand_model->get(['id' => $id]);
|
||||
if (!$row) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '数据不存在!');
|
||||
}
|
||||
if (!$name) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '品牌名称不能为空');
|
||||
}
|
||||
//防止品牌名称重复
|
||||
$where = array('name' => $name, "status<>-1" => null);
|
||||
$id && $where['id <>'] = $id;
|
||||
$old = $this->auto_brand_model->get($where);
|
||||
if ($old) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '品牌已经存在');
|
||||
}
|
||||
$up_data = array(
|
||||
'name' => $name,
|
||||
);
|
||||
$img && $up_data['logo'] = $img;
|
||||
$this->auto_brand_model->update($up_data, array('id' => $id));
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
|
||||
}
|
||||
|
||||
public function del(){
|
||||
$id = $this->input->post('id');
|
||||
if (!$id) {
|
||||
$this->show_json(SYS_CODE_FAIL, '参数错误');
|
||||
}
|
||||
$stauts = $this->input->post('status');
|
||||
$where = array('id' => $id);
|
||||
$this->auto_brand_model->update(array('status' => $stauts), $where);
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
|
||||
}
|
||||
|
||||
public function batch(){
|
||||
|
||||
}
|
||||
|
||||
public function export(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,7 +37,7 @@
|
||||
<td><?= $v['nickname'] ?></td>
|
||||
<td><?= $v['mobile'] ?></td>
|
||||
<td>
|
||||
<input type="checkbox" class="mui-switch mui-switch-anim va-mid" true-value="1" false-value="0" <?=$v['dealer']?'checked':''?> onchange="set_publish(this,<?=$v['id']?>)"/>
|
||||
<input type="checkbox" class="mui-switch mui-switch-anim va-mid" true-value="1" false-value="0" <?=$v['dealer']&&!$v['up_uid']?'checked':''?> onchange="set_publish(this,<?=$v['id']?>)"/>
|
||||
</td>
|
||||
<td><?= date('Y-m-d H:i:s',$v['c_time']) ?></td>
|
||||
</tr>
|
||||
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
<form class="am-form am-form-horizontal" action="<?=$info?'/auto/brand/edit':'auto/brand/add'?>" data-auto="true" method="post" style="width: 90%;padding-top: 10px">
|
||||
<input type="hidden" value="<?=$info['id']?>" name="id">
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">品牌名称:</label>
|
||||
<div class="am-para-input">
|
||||
<input type="text" placeholder="输入品牌名称" name="name" value="<?=$info['name']?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group" style="margin-bottom: 0">
|
||||
<label class="am-para-label">logo:</label>
|
||||
<div class="am-para-input">
|
||||
<div class="am-form-group am-form-file">
|
||||
<button type="button" class="am-btn am-btn-default am-btn-sm"
|
||||
data-file="1" data-type="jpg,png,gif,png,jpeg"
|
||||
data-uptype="qiniu" data-field="img"><i class="am-icon-cloud-upload"></i> 选择要上传的文件
|
||||
</button>
|
||||
|
||||
<input type="hidden" name="img" value="<?= $info['logo'] ?>" class="layui-input">
|
||||
<img data-tips-image style="height:auto;max-height:32px;max-width:32px"
|
||||
src="<?= $info['logo'] ? build_qiniu_image_url($info['logo']) : '' ?>"/>
|
||||
尺寸100x100
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group" style="margin-bottom: 2rem">
|
||||
<div class="am-para-input">
|
||||
<button class="am-btn am-btn-secondary" type="submit">保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
Executable
+63
@@ -0,0 +1,63 @@
|
||||
<div class="coms-table-wrap mt10">
|
||||
<form class="form-search" onsubmit="return false" action="/auto/brand/lists">
|
||||
<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 w200">
|
||||
<input type="text" name="title" value="<?=$params['title'] ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl ml10">
|
||||
<button type="submit" class="am-btn am-btn-success w100">搜索</button>
|
||||
</div>
|
||||
<div class="am-form-group fl ml10">
|
||||
<button type="button" data-title="新增品牌" data-modal="/auto/brand/get" class="am-btn am-btn-success w100">新增</button>
|
||||
</div>
|
||||
<div class="am-form-group fr" style="font-size: 15px;padding-right: 20px;padding-top: 6px;">
|
||||
共有<?= $pager['totle'] ?>条数据
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="coms-table-bd">
|
||||
<table class="am-table am-table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="10%"><span>ID</span></th>
|
||||
<th width="20%"><span>品牌名称</span></th>
|
||||
<th width="10%"><span>状态</span></th>
|
||||
<th width="15%"><span>创建时间</span></th>
|
||||
<th width="35%"><span>操作</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($lists as $v) { ?>
|
||||
<tr>
|
||||
<td><?= $v['id'] ?></td>
|
||||
<td><?= $v['name'] ?></td>
|
||||
<td><?= $v['status_name'] ?></td>
|
||||
<td><?= $v['c_time'] ?></td>
|
||||
<td>
|
||||
<a href="javascript:void (0);" data-title="编辑品牌" data-modal="/auto/brand/get?id=<?= $v['id'] ?>"
|
||||
class="am-text-primary"><?= '编辑' ?></a> |
|
||||
<?php if ($v['status'] == 1) { ?>
|
||||
<a href="javascript:void (0);" data-ajax="post" data-action="/auto/brand/del"
|
||||
data-params-id="<?= $v['id'] ?>" data-params-status="0">禁用</a>
|
||||
<?php } else { ?>
|
||||
<a style="color: red" href="javascript:void (0);" data-ajax="post"
|
||||
data-action="/auto/brand/del"
|
||||
data-params-id="<?= $v['id'] ?>" data-params-status="1">恢复</a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="coms-table-ft clearfix">
|
||||
<div class="coms-pagination fr mr20">
|
||||
<?php page_view($pager) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class Car extends Wxapp{
|
||||
$version[] = [
|
||||
'id' => $val['id'],
|
||||
'title' => $val['title'],
|
||||
'v' => number_format($jsondata['v']).'元起',
|
||||
'v' => number_format($jsondata['price']).'元起',
|
||||
];
|
||||
}else{ //颜色
|
||||
$color[] = [
|
||||
|
||||
@@ -260,7 +260,7 @@ class Cusorder extends Wxapp{
|
||||
'车辆名称' => $brand['name'].$series['name'],
|
||||
'车辆级别' => $version,
|
||||
'颜色' => $color,
|
||||
'车辆平台价格' => $row['price'],
|
||||
'车辆合同售价' => $row['price'],
|
||||
'定金' => $row['deposit']
|
||||
];
|
||||
//开票信息
|
||||
|
||||
@@ -89,4 +89,20 @@ class Customerlogs extends Wxapp{
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function post(){
|
||||
$id = $this->input_param('cus_id');
|
||||
$log = $this->input_param('content');
|
||||
$img_arr = $this->input_param('imgs');
|
||||
if(!$log && !$img_arr){
|
||||
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
||||
}
|
||||
$this->load->library('receiver/customers_entity');
|
||||
$result = $this->customers_entity->add_log($id,$this->session['uid'],$this->session['uname'],$log,'','wxapp',$img_arr);
|
||||
if($result){
|
||||
throw new Exception('修改成功', API_CODE_SUCCESS);
|
||||
}else{
|
||||
throw new Exception('修改失败', ERR_PARAMS_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ class Customers extends Wxapp{
|
||||
$this->load->model('receiver/receiver_customer_oplogs_model','customer_oplogs_model');
|
||||
$this->load->model('auto/auto_series_model');
|
||||
$this->load->model('auto/auto_brand_model');
|
||||
$this->load->model('auto/auto_attr_model');
|
||||
}
|
||||
|
||||
protected function get(){
|
||||
@@ -77,17 +78,93 @@ class Customers extends Wxapp{
|
||||
if(!$row){
|
||||
throw new Exception('数据不存在', ERR_PARAMS_ERROR);
|
||||
}
|
||||
$car_json = json_decode($row['car_json'],true);
|
||||
$data['baseinfo'] = [
|
||||
'客户姓名' => $row['name'],
|
||||
'客户电话' => mobile_asterisk($row['mobile']),
|
||||
'name' => ['value'=>$row['name'],'cn'=>'客户姓名'],
|
||||
'mobile' => ['value'=>mobile_asterisk($row['mobile']),'cn'=>'客户电话'],
|
||||
'car_id' => ['value'=>$row['s_id'],'cn'=>'品牌车型'],
|
||||
'v_id' => ['value'=>$row['v_id'],'cn'=>'车型级别'],
|
||||
'color_id' => ['value'=>$car_json['c_id'],'cn'=>'车型颜色'],
|
||||
'cf_clues' => ['value'=>$row['cf_clues'],'cn'=>'线索来源'],
|
||||
'buy_time' => ['value'=>$row['buy_time'],'cn'=>'预计购车时间'],
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
//修改基本信息
|
||||
protected function put_data(){
|
||||
$biz_id = $this->session['biz_id'];
|
||||
|
||||
$id = $this->input_param('cus_id');
|
||||
$name = $this->input_param('name');
|
||||
$mobile = $this->input_param('mobile');
|
||||
$car_id = $this->input_param('car_id'); //品牌车型id
|
||||
$v_id = $this->input_param('v_id'); //车型id
|
||||
$color_id = $this->input_param('color_id'); //颜色id
|
||||
$cf_clues = $this->input_param('cf_clues'); //线索来源
|
||||
$buy_time = $this->input_param('buy_time'); //预计购车时间
|
||||
$row = $this->customers_model->get(['id'=>$id]);
|
||||
if(!$row){
|
||||
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
||||
}
|
||||
$car_json = json_decode($row['car_json'],true);
|
||||
$update = [];
|
||||
if($mobile){
|
||||
if(!mobile_valid($mobile)){
|
||||
throw new Exception('手机号格式错误', ERR_PARAMS_ERROR);
|
||||
}
|
||||
if($this->customers_model->count(['biz_id'=>$biz_id,'mobile'=>$mobile])){
|
||||
throw new Exception('客户已存在', API_CODE_FAIL);
|
||||
}
|
||||
$update['mobile'] = $mobile;
|
||||
}
|
||||
$s_row = $this->auto_series_model->get(['id'=>$car_id]);
|
||||
$ids_arr = [];
|
||||
if($v_id){
|
||||
$car_json['v_id'] = $v_id;
|
||||
$ids_arr[] = $v_id;
|
||||
}
|
||||
if($color_id){
|
||||
$car_json['c_id'] = $color_id;
|
||||
$ids_arr[] = $color_id;
|
||||
}
|
||||
$attr_row = $this->auto_attr_model->get_map_by_ids($ids_arr);
|
||||
if($attr_row[$color_id]){
|
||||
$color_row = $attr_row[$color_id][0];
|
||||
$color_row['jsondata'] = json_decode($color_row['jsondata'],true);
|
||||
isset($color_row) && $car_json['color'] = $color_row;
|
||||
}
|
||||
if($attr_row[$v_id]){
|
||||
$version_row = $attr_row[$v_id][0];
|
||||
$version_row['jsondata'] = json_decode($version_row['jsondata'],true);
|
||||
isset($version_row) && $car_json['version'] = $version_row;
|
||||
}
|
||||
$update['car_json'] = json_encode($car_json,JSON_UNESCAPED_UNICODE);
|
||||
$name && $update['name'] = $name;
|
||||
$cf_clues && $update['cf_clues'] = $cf_clues;
|
||||
$v_id && $update['v_id'] = $v_id;
|
||||
if($s_row){
|
||||
$update['s_id'] = $s_row['id'];
|
||||
$update['brand_id'] = $s_row['brand_id'];
|
||||
}
|
||||
$s_row && $update['s_id'] = $s_row;
|
||||
if($buy_time){
|
||||
$this->load->library('receiver/customers_entity');
|
||||
$update['level'] = $this->customers_entity->cal_level($buy_time);
|
||||
$update['buy_time'] = $buy_time;
|
||||
}
|
||||
$result = $this->customers_model->update($update,['id'=>$id]);
|
||||
if($result){
|
||||
$uname = $this->session['uname'];
|
||||
$this->load->library('receiver/customers_entity');
|
||||
$this->customers_entity->add_log($id,$this->session['uid'],$uname,"修改用户基本信息");
|
||||
throw new Exception('保存成功', API_CODE_SUCCESS);
|
||||
}else{
|
||||
throw new Exception('保存失败', ERR_PARAMS_ERROR);
|
||||
}
|
||||
}
|
||||
//创建客户
|
||||
protected function post(){
|
||||
$biz_id = $this->session['biz_id'];
|
||||
$this->load->model('auto/auto_series_model');
|
||||
$this->load->model('auto/auto_attr_model');
|
||||
|
||||
$name = $this->input_param('name');
|
||||
$mobile = $this->input_param('mobile');
|
||||
@@ -95,6 +172,7 @@ class Customers extends Wxapp{
|
||||
$v_id = $this->input_param('v_id'); //车型id
|
||||
$color_id = $this->input_param('color_id'); //颜色id
|
||||
$back_s_id = $this->input_param('b_s_id'); //备选车型
|
||||
$cf_clues = $this->input_param('cf_clues'); //线索来源
|
||||
$buy_time = $this->input_param('buy_time'); //预计购车时间
|
||||
|
||||
if(!mobile_valid($mobile)) throw new Exception('请输入正确的手机号码', ERR_PARAMS_ERROR);
|
||||
@@ -125,7 +203,7 @@ class Customers extends Wxapp{
|
||||
'version' => isset($version_row) ? $version_row : ''
|
||||
];
|
||||
$this->load->library('receiver/customers_entity');
|
||||
$level = $this->customers_entity->cal_level(strtotime($buy_time),time());
|
||||
$level = $this->customers_entity->cal_level($buy_time);
|
||||
|
||||
$add_data = [
|
||||
'name' => $name,
|
||||
@@ -141,7 +219,8 @@ class Customers extends Wxapp{
|
||||
'cont_time' => date('Y-m-d H:i:s'),
|
||||
'c_time' => time()
|
||||
];
|
||||
$buy_time && $add_data['buy_time'] = date('Y-m-d H:i:s',strtotime($buy_time));
|
||||
$buy_time && $add_data['buy_time'] = $buy_time;
|
||||
$cf_clues && $add_data['cf_clues'] = $cf_clues;
|
||||
$result = $this->customers_model->add($add_data);
|
||||
if($result){
|
||||
$uname = $this->session['uname'];
|
||||
@@ -228,16 +307,16 @@ class Customers extends Wxapp{
|
||||
}
|
||||
return $lists;
|
||||
}
|
||||
|
||||
|
||||
//获取筛选条件
|
||||
protected function get_filter(){
|
||||
|
||||
$this->load->library('receiver/customers_entity');
|
||||
$level = $this->customers_entity->get_level();
|
||||
$cfrom = ['自行到店','平台分配'];
|
||||
$level = $this->customers_model->get_sdata('level');
|
||||
$cfrom = $this->customers_model->get_sdata();
|
||||
$buy_time = $this->customers_model->get_sdata('btime');
|
||||
$data = [
|
||||
'level' => $level,
|
||||
'cfrom' => $cfrom
|
||||
'cfrom' => $cfrom,
|
||||
'buy_time' => $buy_time
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
@@ -383,7 +462,7 @@ class Customers extends Wxapp{
|
||||
if($rid){ //更新线索跟进人
|
||||
$this->clues_model->update(['admin_id'=>$admin_id,'status'=>2],['id'=>$rid]);
|
||||
}
|
||||
$log = "【{$uname}】分配客户";
|
||||
$log = "分配客户";
|
||||
$this->customers_entity->add_log($val,$uid,$uname,$log);
|
||||
}
|
||||
throw new Exception('分配成功', API_CODE_SUCCESS);
|
||||
|
||||
@@ -7,7 +7,7 @@ class Customers_entity{
|
||||
|
||||
private $ci;
|
||||
|
||||
private $level = ['H','A','B','C','D'];
|
||||
private $level = [3=>'H',7=>'A',15=>'B',30=>'C'];
|
||||
public function __construct(){
|
||||
$this->ci = & get_instance();
|
||||
}
|
||||
@@ -21,17 +21,18 @@ class Customers_entity{
|
||||
* @param $type int 操作类型 (0普通日志 1短信 2拨打电话)
|
||||
* @param $cf_platform string 来源 (wxapp小程序 admin后台)
|
||||
*/
|
||||
public function add_log($customer_id,$uid,$uname,$content,$type='',$cf_platform='wxapp'){
|
||||
public function add_log($customer_id,$uid,$uname,$content,$type='',$cf_platform='wxapp',$imgs = []){
|
||||
$this->ci->load->model('receiver/receiver_customer_oplogs_model','customer_oplogs_model');
|
||||
$add_data = [
|
||||
'customer_id' => $customer_id,
|
||||
'uid' => $uid,
|
||||
'log' => $content,
|
||||
'c_time' => time()
|
||||
];
|
||||
$content && $add_data['log'] = $content;
|
||||
$uname && $add_data['uname'] = $uname;
|
||||
$type && $add_data['type'] = $type;
|
||||
$cf_platform && $add_data['cf_platform'] = $cf_platform;
|
||||
$imgs && $add_data['imgs'] = json_encode($imgs,JSON_UNESCAPED_UNICODE);
|
||||
$result = $this->ci->customer_oplogs_model->add($add_data);
|
||||
if($type==2 && $result){ //更新最后联系时间
|
||||
$this->ci->load->model('receiver/receiver_customers_model');
|
||||
@@ -41,29 +42,17 @@ class Customers_entity{
|
||||
}
|
||||
/**
|
||||
* 购车时间计算用户等级
|
||||
* @param $buy_time int 预计购车时间戳
|
||||
* @param $c_time int 创建时间
|
||||
* @param $buy_time int 预计购车天数
|
||||
*/
|
||||
public function cal_level($buy_time,$c_time){
|
||||
$time = $buy_time - $c_time;
|
||||
if($time<=3*24*60*60){
|
||||
$level = 'H';
|
||||
}elseif($time>3*24*60*60 && $time<=7*24*60*60){
|
||||
$level = 'A';
|
||||
}elseif($time>7*24*60*60 && $time<=15*24*60*60){
|
||||
$level = 'B';
|
||||
}elseif($time>15*24*60*60 && $time<=30*24*60*60){
|
||||
$level = 'C';
|
||||
public function cal_level($buy_time){
|
||||
if($this->level[$buy_time]){
|
||||
$level = $this->level[$buy_time];
|
||||
}else{
|
||||
$level = 'D';
|
||||
$level = 'C';
|
||||
}
|
||||
return $level;
|
||||
}
|
||||
|
||||
//返回用户等级数组
|
||||
public function get_level(){
|
||||
return $this->level;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -10,6 +10,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
class Auto_brand_model extends HD_Model
|
||||
{
|
||||
private $table_name = 'lc_auto_brand';
|
||||
private $status_arr = [ '-1' => '删除',0 => '下架',1 => '正常'];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -37,4 +38,8 @@ class Auto_brand_model extends HD_Model
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
//获取状态
|
||||
public function get_status(){
|
||||
return $this->status_arr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,9 @@ class Receiver_customers_model extends HD_Model
|
||||
private $table_name = 'lc_receiver_customers';
|
||||
|
||||
private $status_arr = [-1 => '删除',0 => '未见客户',1 => '到店客户',2 => '订单客户',3 => '战败客户'];
|
||||
private $level = ['H','A','B','C','D'];
|
||||
private $cfrom_arr = ['自行到店','平台分配'];
|
||||
private $buy_time = [3,7,15,30];
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($this->table_name, 'default');
|
||||
@@ -41,6 +44,23 @@ class Receiver_customers_model extends HD_Model
|
||||
public function get_status(){
|
||||
return $this->status_arr;
|
||||
}
|
||||
|
||||
public function get_sdata($type='cfrom'){
|
||||
switch($type){
|
||||
case 'cfrom':
|
||||
$result = $this->cfrom_arr;
|
||||
break;
|
||||
case 'btime':
|
||||
$result = $this->buy_time;
|
||||
break;
|
||||
case 'level':
|
||||
$result = $this->level;
|
||||
break;
|
||||
default:
|
||||
$result = '';
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function count_order($where){
|
||||
return $this->select_order($where,'','','','',1);
|
||||
|
||||
@@ -12,6 +12,7 @@ create table lc_auto_brand (
|
||||
u_time timestamp not null default current_timestamp on update current_timestamp,
|
||||
primary key (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='车型库_品牌';
|
||||
alter table lc_auto_brand add logo varchar(70) not null default '' comment '品牌logo' after name;
|
||||
|
||||
-- ----------------------------
|
||||
-- Title:车型库_车系
|
||||
|
||||
@@ -22,7 +22,7 @@ create table lc_receiver_customers (
|
||||
a_num tinyint(3) not null default '0' comment '到店次数',
|
||||
p_time timestamp not null default '0000-00-00 00:00:00' comment '分配时间',
|
||||
cont_time timestamp not null default '0000-00-00 00:00:00' comment '最后联系时间',
|
||||
buy_time timestamp not null default '0000-00-00 00:00:00' comment '预计购买时间',
|
||||
buy_time tinyint(3) not null default '0' comment '预计购买时间',
|
||||
user_json json default null comment '用户其它数据',
|
||||
car_json json default null comment '车信息',
|
||||
jsondata json default null comment '其他信息',
|
||||
@@ -31,6 +31,7 @@ create table lc_receiver_customers (
|
||||
u_time timestamp not null default current_timestamp on update current_timestamp,
|
||||
primary key (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='客户表';
|
||||
alter table lc_receiver_customers add cf_clues varchar(50) not null default '' comment '线索来源' after cf_title;
|
||||
|
||||
-- ----------------------------
|
||||
-- Title:客户操作日志表
|
||||
@@ -50,4 +51,5 @@ create table lc_receiver_customer_oplogs (
|
||||
u_time timestamp not null default current_timestamp on update current_timestamp,
|
||||
primary key (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='客户操作日志表';
|
||||
alter table lc_receiver_customer_oplogs add imgs json default null comment '图片' after log;
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 0 B After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 0 B After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 0 B After Width: | Height: | Size: 1.8 KiB |
Reference in New Issue
Block a user