add-licheb-group_type

This commit is contained in:
lccsw
2021-09-17 15:36:23 +08:00
parent cf6fc003c6
commit 606c272508
16 changed files with 1099 additions and 220 deletions
+8 -14
View File
@@ -404,6 +404,8 @@ class Common extends CI_Controller
$size = $this->input->post('size') ? intval($this->input->post('size')) : 10;
$type = $this->input->post('type');
$brand_id = intval($this->input->post('brand_id'));
$city_id = intval($this->input->post('city_id'));
$county_id = intval($this->input->post('county_id'));
$use_shop_list = $this->input->post('use_shop_list');
$sys_cate_id = intval($this->input->post('sys_cate_id'));
@@ -418,14 +420,13 @@ class Common extends CI_Controller
$where['status'] = 1;
$sys_cate_id && $where['cate_id'] = $sys_cate_id;
$biz_name && $where['biz_name like "%' . $biz_name . '%"'] = null;
$brand_id && $where['hd_biz.brand_id'] = $brand_id;
$ids && $where['hd_biz.id not in (' . $ids . ')'] = null;
if ($type == 'jdb') {
$this->load->model('app/jdb/receiver_orders_model', 'mdReceiverOrders');
}
$count = $this->mdBiz->selectBiz($where, '', '', '', 1, $type);
$brand_id && $where['brand_id'] = $brand_id;
$city_id && $where['city_id'] = $city_id;
$county_id && $where['county_id'] = $county_id;
$ids && $where['id not in (' . $ids . ')'] = null;
$count = $this->mdBiz->count($where);
if ($count) {
$resBiz = $this->mdBiz->selectBiz($where, 'hd_biz.id desc', $page, $size, 0, $type);
$resBiz = $this->mdBiz->select($where, 'id desc', $page, $size);
foreach ($resBiz as $key => $value) {
$setValue = array();
$setValue['id'] = $value['id'];
@@ -435,13 +436,6 @@ class Common extends CI_Controller
$setValue['sort'] = $key;
$setValue['is_checked'] = $shopChecked[$value['id']] ? 1 : 0;
$setValue['brand_id'] = $value['brand_id'];
if ($type == 'jdb') {
$firstDay = date('Y-m-01', strtotime(date("Y-m-d"))) . ' 00:00:00';
$lastDay = date('Y-m-d', strtotime("$firstDay +1 month -1 day")) . ' 23:59:59';
$setValue['orders_month'] = $this->mdReceiverOrders->count(array("c_time >=" => strtotime($firstDay)
, "c_time <=" => strtotime($lastDay), 'biz_id' => $value['id']));
$setValue['orders'] = $this->mdReceiverOrders->count(array('biz_id' => $value['id']));
}
$shopList[] = $setValue;
}
}
+31 -9
View File
@@ -4,7 +4,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
class Member extends HD_Controller{
private $groups = [1=>'销售',2=>'店长',3=>'老板'];
private $groups = [1=>'销售',2=>'店长',3=>'老板',4=>'渠道经理'];
public function __construct()
{
@@ -46,8 +46,16 @@ class Member extends HD_Controller{
$count = $this->userM->count($where);
$lists = $this->userM->select($where,'id desc',$page,$size);
foreach($lists as $key=>$val){
$biz = $this->biz_model->get(['id'=>$val['biz_id']],'biz_name');
$lists[$key]['biz_name'] = $biz['biz_name'];
$bizs = [];
$biz_id_arr = explode(',',$val['biz_id']);
if($biz_id_arr){
$ids = implode(',',$biz_id_arr);
$b_where = [
"id in ($ids)" => null
];
$bizs = $this->biz_model->select($b_where,'',0,0,'biz_name');
}
$lists[$key]['bizs'] = $bizs;
$lists[$key]['group_name'] = $this->groups[$val['group_id']];
if(SUPER_ADMIN == $this->role){//超级管理员才允许操作用户的披上超级马甲
@@ -74,6 +82,7 @@ class Member extends HD_Controller{
{
$id = $this->input->get('id');
$row = $this->userM->get(['id'=>$id]);
$selectedBrands = [];
if($id){
$info = array(
'id' => $row['id'],
@@ -81,19 +90,30 @@ class Member extends HD_Controller{
'mobile' => $row['mobile'],
'group_id' => $row['group_id'],
'biz_id' => $row['biz_id'],
'city_id' => 0,
'county_id' => 0
);
$biz_id_arr = explode(',',$row['biz_id']);
if($biz_id_arr){
$ids = implode(',',$biz_id_arr);
$where = [
"id in ($ids)" => null
];
$selectedBrands = $this->biz_model->select($where,'',0,0,'id as biz_id,biz_name as name');
}
$action = '/app/licheb/member/edit';
$_title = '编辑用户';
} else {
$info = array('biz_id' => '', 'group_id' => '');
$info = array('biz_id' => '', 'group_id' => '','city_id'=>0,'county_id'=>0);
$action = '/app/licheb/member/add';
$_title = '添加用户';
}
$this->data['selectedBrands'] = $selectedBrands;
$this->data['info'] = $info;
$this->data['groups'] = $this->groups;
$this->data['action'] = $action;
$this->data['_title'] = $_title;
return $this->show_view('app/licheb/member/get');
return $this->show_view('app/licheb/member/get',true);
}
//添加单条数据
@@ -102,7 +122,8 @@ class Member extends HD_Controller{
$uname = $info['uname'];
$mobile = $info['mobile'];
$group_id = $info['group_id'];
$biz_id = $info['biz_id'];
$bizs = $info['bizs'];
$biz_id_arr = array_column($bizs,'biz_id');
if (!mobile_valid($mobile)) {
return $this->show_json(SYS_CODE_FAIL, '输入正确手机号');
@@ -123,7 +144,7 @@ class Member extends HD_Controller{
'c_time' => time(),
);
$group_id && $add['group_id'] = $group_id;
$biz_id && $add['biz_id'] = $biz_id;
$biz_id_arr && $add['biz_id'] = implode(',',$biz_id_arr);
$id = $this->userM->add($add);
return $this->show_json(SYS_CODE_SUCCESS, '操作成功', '/app/licheb/member');
@@ -138,7 +159,8 @@ class Member extends HD_Controller{
$nickname = $info['nickname'];
$mobile = $info['mobile'];
$group_id = $info['group_id'];
$biz_id = $info['biz_id'];
$bizs = $info['bizs'];
$biz_id_arr = array_column($bizs,'biz_id');
if (!mobile_valid($mobile)) {
return $this->show_json(SYS_CODE_FAIL, '输入正确手机号');
@@ -154,7 +176,7 @@ class Member extends HD_Controller{
);
$upd['group_id'] = $group_id ? $group_id : 0;
$upd['biz_id'] = $biz_id ? $biz_id : 0;
$upd['biz_id'] = $biz_id_arr ? implode(',',$biz_id_arr) : 0;
$nickname && $upd['nickname'] = $nickname;
$uname && $upd['uname'] = $uname;
+30
View File
@@ -355,5 +355,35 @@ class Customer extends HD_Controller
}
return $id;
}
//更新晓致电话数据
public function get_update_xz(){
$page = $this->input->get('page');
$size = $this->input->get('size');
$lk = $this->input->get('lk');
!$page && $page = 1;
!$size && $size = 10;
$where = [
'cf_title' => 'customer',
'cf_platform' => 'api',
'status' => 1
];
if($lk){
$rows = $this->receiver_xz_model->select($where,'id desc',$page,$size,'id,biz_id');
print_r($rows);exit;
}
$total = $this->receiver_xz_model->count($where);
$rows = $this->receiver_xz_model->select($where,'id desc',$page,$size,'id,cf_id');
if($rows){
foreach($rows as $key => $val){
$row = $this->customers_model->get(['id'=>$val['cf_id']],'biz_id');
if($row){
$this->receiver_xz_model->update(['biz_id'=>$row['biz_id']],['id'=>$val['id']]);
}
}
echo "total:{$total},剩余:".($total-$page*$size);
}else{
echo "finish";
}
}
}
+1 -53
View File
@@ -485,57 +485,5 @@ class Orders extends HD_Controller
$this->data['info'] = $info;
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
}
//更新金额至json
public function get_update_money()
{
$page = $this->input->get('page');
$size = $this->input->get('size');
$lk = $this->input->get('lk');
!$page && $page = 1;
!$size && $size = 10;
$where = [];
if ($lk) {
$rows = $this->orders_model->select($where, 'id desc', $page, $size, 'id,money_json');
print_r($rows);
exit;
}
$rows = $this->orders_model->select($where, 'id desc', $page, $size);
if ($rows) {
$this->load->model('auto/auto_cars_model');
$this->load->model("biz/biz_model");
$this->load->model('sys/sys_city_model');
foreach ($rows as $key => $val) {
$car_row = $this->auto_cars_model->get(['brand_id' => $val['brand_id'], 's_id' => $val['s_id'], 'v_id' => $val['v_id'], 'cor_id' => $val['cor_id'], 'incor_id' => $val['incor_id']]);
//获取金额json数据
$money_json = [
'price_car' => $car_row['price_car'],
'price_book' => $car_row['price_book'],
'price_insure' => $car_row['price_insure'],
'price_fine' => $car_row['price_fine'],
];
//获取挂牌价
if ($val['brand_id'] == 3) { //狸车品牌写死挂牌费用0.01 测试用
$money_json['fee_carno'] = 0.01;
} else {
$biz = $this->biz_model->get(['id' => $val['biz_id']], 'company_id,city_id');
$city = $this->sys_city_model->get(['city_id' => $biz['city_id']], 'fee_carno');
$money_json['fee_carno'] = $city['fee_carno'];
}
if (!$val['payway']) { //分期
$money_json['price_finance'] = $car_row['price_finance'];
$money_json['first_pay'] = $car_row['first_pay'];
$money_json['month_pay'] = $car_row['month_pay'];
}
$update = [
'money_json' => json_encode($money_json, JSON_UNESCAPED_UNICODE)
];
$this->orders_model->update($update, ['id' => $val['id']]);
}
echo "do f";
} else {
echo "finish";
}
}
}
+213 -109
View File
@@ -15,7 +15,7 @@
<div class="am-form-group">
<label class="am-para-label">角色:</label>
<div class="am-para-input w100">
<select name="group_id" v-model="info.group_id">
<select name="group_id" v-model="info.group_id" @change="resetBiz">
<option value="">选择角色</option>
<option :value="i" v-for="(v,i) in groups">{{v}}</option>
</select>
@@ -23,31 +23,94 @@
</div>
<div class="am-form-group">
<label class="am-para-label">门店:</label>
<div class="am-para-inline w120">
<select title="城市" v-model="biz.city_id">
<option value="">选择城市</option>
<option :value="v.id" v-for="(v,i) in biz.cityAry">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w120">
<select title="行政区" v-model="biz.county_id">
<option value="">选择行政区</option>
<option :value="v.id" v-for="(v,i) in biz.countyAry">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w200">
<select name="biz_id" v-model="biz.biz_id">
<option value="">门店</option>
<template v-for="(v,i) in biz.bizAry">
<option :value="v.id">{{v.title}}</option>
</template>
</select>
<div class="am-para-inline lh-default">
<button class="am-btn am-btn-default" type="button" @click="brandModal">选择门店</button>
<div class="mt5">
<button class="am-btn am-btn-default mr5" type="button" @click="brandModal" v-for="(item) in selectedBrands">{{item.name}}</button>
</div>
</div>
</div>
<div class="am-form-group" style="margin-bottom: 2rem">
<div class="am-para-input"><button class="am-btn am-btn-success" type="button" @click='saveEdit'>提交</button></div>
</div>
<div id="brand-modal" style="display:none">
<div class="modal-body">
<div class="header">
<div class="am-form am-form-horizontal">
<div class="am-form-group fl">
<div class="am-form-group am-para-inline w150">
<select title="城市" v-model="info.city_id">
<option value="0">城市</option>
<template v-for="(v,i) in cityAry">
<option :value="v.id">{{v.name}}</option>
</template>
</select>
</div>
<div class="am-form-group am-para-inline w150">
<select title="行政区" name="county_id" v-model="info.county_id">
<option value="0">行政区</option>
<template v-for="(v,i) in countyAry">
<option :value="v.id">{{v.name}}</option>
</template>
</select>
</div>
<div class="am-form-group fl ml10">
<a class="am-btn am-btn-success am-btn-sm w100" @click="search()">搜索</a>
</div>
</div>
</div>
<div style="padding-top: 10px;">
<div class="vuetable-body-wrapper">
<table class="vuetable table table-middle table-hover fixed">
<colgroup>
<col class="vuetable-col-title" style="width: 50%;">
<col class="vuetable-col-actions text-right" style="width: 10%;">
</colgroup>
<thead>
<tr>
<th class="vuetable-th-slot-title">商家名</th>
<th class="vuetable-th-slot-actions text-right">操作</th>
</tr>
</thead>
<tfoot></tfoot>
<tbody class="vuetable-body">
<tr v-for="(v,i) in brandsList">
<td class="vuetable-slot">
{{v.name}}
</td>
<td class="vuetable-slot text-right">
<button type='button' v-if="v.is_checked==0 || !v.is_checked" class="btn btn-sm btn-success"
@click="addItem(i)">添加
</button>
<button type='button' v-if="v.is_checked==1" class="btn btn-sm btn-danger"
@click="removeItem(v)">删除
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="clearfix">
<span class="pull-left text-muted">{{brandsPage.page}}(每页{{brandsPage.pageLimit}},{{brandsPage.pageCount}})</span>
<nav class="pull-right" aria-label="Page navigation">
<ul class="pagination pagination-sm">
<li>
<a href="javascript:void(0);" @click="beforeShopPage();" aria-label="上一页">
<span class="glyphicon glyphicon-menu-left"></span>
</a>
</li>
<li v-if="brandsPage.hasNext">
<a href="javascript:void(0);" @click="afterShopPage();" aria-label="下一页">
<span class="glyphicon glyphicon-menu-right"></span>
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</form>
<script type="text/javascript">
var vue_app;
@@ -58,7 +121,14 @@
data: {
info:{},
groups:[],
biz: {cityAry: [], countyAry: [], bizAry: [], city_id: '', county_id: '', biz_id: ''}
biz: { bizAry: [], biz_id: ''},
brandsThPage: 0,
brandsPage: [],
bizIds:[],
brandsList:[],
selectedBrands: [],
cityAry: [],
countyAry: [],
},
computed: {},
created: function () {
@@ -69,44 +139,128 @@
var vm = this;
vm.info = <?=json_encode($info, JSON_UNESCAPED_UNICODE)?>;
vm.groups = <?=json_encode($groups, JSON_UNESCAPED_UNICODE)?>;
vm.init_biz();
vm.selectedBrands = <?=json_encode($selectedBrands,JSON_UNESCAPED_UNICODE)?>;
vm.init_citys();
},
methods: {
init_biz:function() {
resetBiz:function(){
this.selectedBrands = [];
},
search: function () {
this.changePage(1);
},
changePage: function (page) {
var that = this;
that.brandsThPage = page;
return this.brandModal();
},
beforeShopPage: function () {
var vm = this;
vm.biz.biz_id = vm.info.biz_id;
//初始化获取城市列表
$.ajax({
type: 'get',
url: '/common/area',
dataType: 'json',
data: {
id: '350',
key: 'city',
type: 1
},
success: function (response) {
if (response.code == 1) {
vm.biz.cityAry = response.data;
if (vm.brandsThPage == 1) {
alert('已经是第一页了');
return;
}
vm.brandsThPage--;
return this.brandModal();
},
afterShopPage: function () {
var vm = this;
vm.brandsThPage++;
return this.brandModal();
},
addItem: function (index) {
var vm = this;
var brand_id;
var biz_id;
biz_id = vm.brandsList[index]['id'];
var _shop = {
biz_id: biz_id,
name: vm.brandsList[index]['name'],
};
if(vm.info.group_id==4){
vm.selectedBrands.push(_shop);
vm.brandsList[index]['is_checked'] = 1;
}else{
vm.selectedBrands = [];
vm.selectedBrands.push(_shop);
this.brandsList.map(function (_item, _index) {
if(vm.brandsList[index]['id']==_item['id']){
vm.brandsList[_index]['is_checked'] = 1;
}else{
vm.brandsList[_index]['is_checked'] = 0;
}
})
}
},
removeItem: function (item) {
var vm = this;
if(vm.info.group_id==4){
this.selectedBrands = this.selectedBrands.filter(function (_item) {
var id = _item.biz_id > 0 ? _item.biz_id : _item.brand_id;
return id != item.id;
})
}else{
vm.selectedBrands = [];
}
this.brandsList.map(function (_item, _index) {
if (item.id == _item.id) {
vm.brandsList[_index].is_checked = 0;
}
})
},
//选择商家
brandModal: function () {
var that = this;
layer.open({
type: 1,
area: ['55%', '80%'], //宽高
content: $('#brand-modal'),
title: '选择商家',
shade: false,
btn: ['选好了'],
yes: function (index) {
layer.close(index);
}
});
//获取店铺信息
if(vm.biz.biz_id > 0){
$.ajax({
type: 'post',
url: '/biz/store/store/json_get',
dataType: 'json',
data: {
id: vm.biz.biz_id
},
success:function(response){
if (response.code == 1) {
if(response.data.id>0){
vm.biz.city_id = response.data.city_id;
vm.biz.county_id = response.data.county_id;
$.ajax({
url: '/common/shop_app',
type: 'post',
dataType: 'json',
data: {
page: that.brandsThPage,
city_id: that.info.city_id,
county_id: that.info.county_id
},
success: function (json) {
var brandsList = json.data.shopList;
that.brandsPage = json.data.shopPage;
brandsList.map(function (_item, _index) {
for (var index in that.selectedBrands) {
var item = that.selectedBrands[index];
var id = that.sys_type_id == 1 ? item.brand_id : item.biz_id;
if (id == _item.id) {
brandsList[_index].is_checked = 1;
break;
} else {
brandsList[_index].is_checked = 0;
}
}
})
that.brandsList = brandsList;
}
});
},
init_citys: function () {
var vm = this;
$.get('common/area', {id: '350', key: 'city', type: 1}, function (response) {
if (response.code == 1) {
vm.cityAry = response.data;
}
});
if (vm.info.city_id > 0) {
$.get('common/area', {id: vm.info.city_id, key: 'county', type: 1}, function (response) {
if (response.code == 1) {
vm.countyAry = response.data;
}
});
}
@@ -117,7 +271,7 @@
}
var vm = this;
vm.info.bizs = vm.selectedBrands;
loading = true;
$.ajax({
url: '<?=$action?>',
@@ -152,69 +306,19 @@
}
},
watch:{
'biz.city_id':function(nv, ov){
'info.city_id': function (nv, ov) {
var that = this;
if(nv == ''){
that.biz.countyAry = [];
that.biz.county_id = '';
if (nv == '') {
that.countyAry = [];
that.info.county_id = 0;
} else {
if(nv.substring(0,4) != that.biz.county_id.substring(0, 4)){
that.biz.county_id = '';
}
$.ajax({
type: 'get',
url: '/common/area',
dataType: 'json',
data: {
id: nv,
key:'county',
type:1
},
success:function(response){
if (response.code == 1) {
that.biz.countyAry = response.data;
}
$.get('common/area', {id: nv, key: 'county', type: 1}, function (response) {
if (response.code == 1) {
that.countyAry = response.data;
}
});
}
},
'biz.county_id':function(nv, ov){
var that = this;
if(nv == ''){
that.biz.bizAry = [];
that.biz.biz_id = '';
} else {
$.ajax({
type: 'post',
url: '/biz/store/store/json_lists',
dataType: 'json',
data: {
city_id: that.biz.city_id,
county_id: that.biz.county_id,
status:1
},
success:function(response){
if (response.code == 1) {
that.biz.bizAry = response.data.list;
if(that.biz.biz_id>0){
var biz_id = '';
for(var i in that.biz.bizAry){
if(that.biz.biz_id == that.biz.bizAry[i].id){
biz_id = that.biz.biz_id;
break;
}
}
that.biz.biz_id = biz_id;
}
}
}
});
}
},
'biz.biz_id':function(nv, ov){
var vm = this;
vm.info.biz_id = nv;
}
}
});
});
+7 -3
View File
@@ -39,7 +39,7 @@
<button type="submit" class="am-btn am-btn-success am-btn-sm w100">搜索</button>
</div>
<div class="am-form-group fl ml10">
<button type="button" data-modal="/app/licheb/member/get" class="am-btn am-btn-success am-btn-sm w100">添加用户</button>
<button type="button" data-open="/app/licheb/member/get" class="am-btn am-btn-success am-btn-sm w100">添加用户</button>
</div>
</div>
</form>
@@ -63,12 +63,16 @@
<td><?= $v['uname'] ?></td>
<td><?= $v['mobile'] ?></td>
<td><?= $v['group_name']?></td>
<td><?= $v['biz_name']?></td>
<td>
<?php foreach($v['bizs'] as $val) {?>
<span><?= $val['biz_name']?></span><br>
<?}?>
</td>
<td><?= date('Y-m-d H:i:s',$v['c_time']) ?></td>
</tr>
<tr>
<td colspan="6" class="align-r">
<a data-modal="/app/licheb/member/get?id=<?=$v['id']?>" class="am-btn am-btn-primary am-btn-xs">修改</a>
<a data-open="/app/licheb/member/get?id=<?=$v['id']?>" class="am-btn am-btn-primary am-btn-xs">修改</a>
<?if($v['umajia']){?>
<a class="am-btn am-btn-primary am-btn-xs" data-open="/app/appusual/umajia/get?uid=<?=$v['id']?>&app_id=<?=$app_id?>" data-title="编辑马甲">编辑马甲</a>
<a href="javascript:void(0)" data-ajax="post" data-action="/app/appusual/umajia/del?app_id=<?=$app_id?>"
+3 -3
View File
@@ -53,8 +53,8 @@ class Series extends Wxapp{
$where = [
'status' => 1
];
if($this->session['biz_id']){
$biz_id = $this->session['biz_id'];
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
if($biz_id){
$biz = $this->biz_model->get(['id'=>$biz_id],'jsondata');
$jsondata = json_decode($biz['jsondata'],true);
$auto_brands = $jsondata['auto_brands'] ? $jsondata['auto_brands'] : [0];
@@ -81,7 +81,7 @@ class Series extends Wxapp{
];
$user = $this->app_user_model->get(array('id' => $uid));
if(isset($user['biz_id'])){
$biz_id = $this->session['biz_id'];
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
$biz = $this->biz_model->get(['id'=>$biz_id],'jsondata');
$jsondata = json_decode($biz['jsondata'],true);
$auto_brands = $jsondata['auto_brands'] ? $jsondata['auto_brands'] : [0];
+6 -8
View File
@@ -119,12 +119,13 @@ class Cusorder extends Wxapp{
'version' => isset($version_row) ? $version_row : ''
];
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
$data = [
'rid' => $cus_id,
'sid' => create_order_no(350200,$this->app_key),
'name' => $name ? $name : $row['name'],
'mobile' => $mobile ? $mobile : $row['mobile'],
'biz_id' => $this->session['biz_id'],
'biz_id' => $biz_id,
'brand_id' => $series_row['brand_id'],
's_id' => $series_row['id'],
'v_id' => $v_id,
@@ -240,10 +241,10 @@ class Cusorder extends Wxapp{
private function lists(){
$group_id = $this->session['group_id'];
$uid = $this->session['uid'];
$biz_id = $this->session['biz_id'];
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
$keyword = $this->input_param('keyword');
$status = $this->input_param('status');
$ismy = $this->input_param('ismy'); //是否只显示自己
//$ismy = $this->input_param('ismy'); //是否只显示自己
$page = $this->input_param('page');
$size = $this->input_param('size');
@@ -253,10 +254,8 @@ class Cusorder extends Wxapp{
$where = [
'biz_id' => $biz_id
];
if($group_id==1 || $ismy){ //销售
$where ["admin_id"] = $uid;
}
$group_id == 1 && $where['admin_id'] = $uid;//销售
if($keyword){
$where["(name='{$keyword}' or mobile='{$keyword}')"] = null;
@@ -267,7 +266,6 @@ class Cusorder extends Wxapp{
$lists = [];
if($count){
$rows = $this->orders_model->select($where,'id desc',$page,$size,$fileds);
//品牌车型
$brand_arr = array_unique(array_column($rows,'brand_id'));
$brands = $this->auto_brand_model->get_map_by_ids($brand_arr,'id,name');
+6 -5
View File
@@ -96,7 +96,7 @@ class Customers extends Wxapp{
}
//修改基本信息
protected function put_data(){
$biz_id = $this->session['biz_id'];
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
$id = $this->input_param('cus_id');
$name = $this->input_param('name');
@@ -167,7 +167,7 @@ class Customers extends Wxapp{
}
//创建客户
protected function post(){
$biz_id = $this->session['biz_id'];
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
$name = $this->input_param('name');
$mobile = $this->input_param('mobile');
@@ -329,7 +329,7 @@ class Customers extends Wxapp{
private function lists(){
$uid = $this->session['uid'];
$group_id = $this->session['group_id'];
$biz_id = $this->session['biz_id'];
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
$s_time = $this->input_param('s_time');
$e_time = $this->input_param('e_time');
@@ -364,9 +364,10 @@ class Customers extends Wxapp{
'biz_id' => $biz_id
];
if($group_id==1 || $ismy){ //销售
$where ["admin_id"] = $uid;
if($group_id==1 || $ismy){
$where["admin_id"] = $uid;
}
if($s_time && $e_time){
$where['c_time >='] = strtotime($s_time);
$where['c_time <='] = strtotime(date('Y-m-d 23:59:59',strtotime($e_time)));
+3 -2
View File
@@ -27,7 +27,7 @@ class Employees extends Wxapp{
!$page && $page = 1;
!$size && $size = 10;
$uid = $this->session['uid'];
$biz_id = $this->session['biz_id'];
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
if($ifconf){
$where = [
@@ -56,6 +56,7 @@ class Employees extends Wxapp{
}
protected function post(){
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
$group_id = $this->session['group_id'];
$name = $this->input_param('name');
@@ -77,7 +78,7 @@ class Employees extends Wxapp{
'mobile' => $mobile,
'uname' => $name,
'group_id' => 1,
'biz_id' => $this->session['biz_id'],
'biz_id' => $biz_id,
'c_time' => time()
];
$result = $this->app_user_model->add($data);
+583
View File
@@ -0,0 +1,583 @@
<?php
defined('WXAPP_APP') OR exit('No direct script access allowed');
/**
* Created by Vim
* User: lcc
* Date: 2021/09/16
* Time: 10:30
*/
require_once APPPATH.'controllers/wxapp/Wxapp.php';
class Statistics extends Wxapp{
function __construct($inputs, $app_key){
parent::__construct($inputs, $app_key);
$this->load->model("biz/biz_model");
$this->load->model('receiver/receiver_customers_model','customers_model');
$this->load->model('receiver/order/receiver_orders_model','orders_model');
}
protected function get(){
}
//统计客户
protected function get_cust(){
$season = $this->input_param('season');
!strlen($season) && $season = ceil((date('n'))/3)-1;//当月是第几季度
$season_data = $this->season_data($season+1);
$days = getMonth($season+1);
$series = [];
$bizs = [];
$months_arr = [];
foreach($days as $val){
$months_arr[] = [
'cn' => date('n月',strtotime($val)),
's_time' => date('Y-m-01 00:00:00',strtotime($val)),
'e_time' => date('Y-m-t 23:59:59',strtotime($val)),
];
}
$biz_id_arr = explode(',',$this->session['biz_id']);
if($biz_id_arr){
$bizs_lists = $this->biz_model->get_by_id_arr($biz_id_arr);
$bizs = array_column($bizs_lists,'biz_name');
foreach($bizs_lists as $key=>$val){
$count_data = [];
foreach($months_arr as $v2){
$where = [
'biz_id' => $val['id'],
'status>=' => 0,
'c_time>=' => strtotime($v2['s_time']),
'c_time<=' => strtotime($v2['e_time']),
];
$count_data[] = $this->customers_model->count($where);
}
$series[] = [
'name' => $val['biz_name'],
'type' => 'bar',
'data' => $count_data
];
}
}
$stat_data = [
'tooltip' => [
'trigger' => 'axis',
'axisPointer' => ['type'=>'shadow']
],
'legend' => [
'top' => 'bottom',
'data'=> $bizs
],
'grid' => [
'top' => '8%',
'left' => '2%',
'right' => '5%',
'bottom' => '12%',
'containLabel' => true
],
'xAxis' => [
'type' => 'value',
'boundaryGap' => [0, 0.01]
],
'yAxis' => [
'type' => 'category',
'data' => array_column($months_arr,'cn')
],
'series' => $series
];
$data = [
'stat_data' => $stat_data,
'season_data' => $season_data,
'season' => $season
];
return $data;
}
//统计订单
protected function get_orders(){
$season = $this->input_param('season');
!strlen($season) && $season = ceil((date('n'))/3)-1;//当月是第几季度
$season_data = $this->season_data($season+1);
$days = getMonth($season+1);
$series = [];
$bizs = [];
$months_arr = [];
foreach($days as $val){
$months_arr[] = [
'cn' => date('n月',strtotime($val)),
's_time' => date('Y-m-01 00:00:00',strtotime($val)),
'e_time' => date('Y-m-t 23:59:59',strtotime($val)),
];
}
$biz_id_arr = explode(',',$this->session['biz_id']);
if($biz_id_arr){
$bizs_lists = $this->biz_model->get_by_id_arr($biz_id_arr);
$bizs = array_column($bizs_lists,'biz_name');
foreach($bizs_lists as $key=>$val){
$count_data = [];
foreach($months_arr as $v2){
$where = [
'biz_id' => $val['id'],
'status>=' => 0,
'c_time>=' => strtotime($v2['s_time']),
'c_time<=' => strtotime($v2['e_time']),
];
$count_data[] = $this->orders_model->count($where);
}
$series[] = [
'name' => $val['biz_name'],
'type' => 'line',
'stack' => '总量',
'data' => $count_data,
'smooth' => true
];
}
}
$stat_data = [
'tooltip' => ['trigger' => 'axis'],
'legend' => ['top'=>'bottom','data'=>$bizs],
'grid' => [
'top' => '10%',
'left' => '2%',
'right' => '5%',
'bottom' => '12%',
'containLabel' => true
],
'xAxis' => [
'type' => 'category',
'boundaryGap' => false,
'data' => array_column($months_arr,'cn')
],
'yAxis' => ['type'=>'value'],
'series' => $series,
];
$data = [
'stat_data' => $stat_data,
'season_data' => $season_data,
'season' => $season
];
return $data;
}
//数据分析页面客户数据
protected function get_scust(){
$day = $this->input_param('day');
$biz_id = $this->input_param('biz_id');
$admin_id = $this->input_param('admin_id');
if(!$biz_id){
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
!$day && $day = date('Y-m-d');//获取当天
$status_list = [
[
'title' => '订单客户',
'icon' => 'icon-statistics-custom-1',
'status' => 2
],
[
'title' => '到店客户',
'icon' => 'icon-statistics-custom-2',
'status' => 1
],
[
'title' => '未见客户',
'icon' => 'icon-statistics-custom-3',
'status' => 0
],
[
'title' => '未联潜客',
'icon' => 'icon-statistics-custom-4',
'status' => ''
],
[
'title' =>'战败客户',
'icon' => 'icon-statistics-custom-5',
'status' => 3
],
];
foreach($status_list as $key => $val){
$setValue = [
'title' => $val['title'],
'icon' => $val['icon'],
];
$where = [
'biz_id' => $biz_id
];
$admin_id && $where['admin_id'] = $admin_id;
if($day){
$s_time = date('Y-m-01 00:00:00',strtotime($day));
$e_time = date('Y-m-t 23:59:59',strtotime($day));
$where['c_time>='] = strtotime($s_time);
$where['c_time<='] = strtotime($e_time);
}
if(strlen($val['status'])){
$where['status'] = $val['status'];
$setValue['value'] = $this->customers_model->count($where);
}else{
$where["cont_time = '0000-00-00 00:00:00'"] = null;
$setValue['value'] = $this->customers_model->count($where);
}
$custom[] = $setValue;
}
$months_arr = [];
for($i=2;$i>=0;$i--){
$_time = date("Y-m-01",mktime(0, 0 , 0,date("m",strtotime($day))-$i,1,date("Y",strtotime($day))));
$months_arr [] = [
'cn' => date('n月',strtotime($_time)),
's_time' => date('Y-m-01 00:00:00',strtotime($_time)),
'e_time' => date('Y-m-t 23:59:59',strtotime($_time))
];
}
foreach($months_arr as $val){
$where = [
'biz_id' => $biz_id,
'status>=' => 0,
'c_time>=' => strtotime($val['s_time']),
'c_time<=' => strtotime($val['e_time']),
];
$count_data[] = $this->customers_model->count($where);
}
//图标数据
$stat_data = [
'tooltip' => [
'trigger' => 'axis',
'axisPointer' => [
'type' => 'shadow'
]
],
'grid' => [
'top' => '10%',
'left' => '2%',
'right' => '5%',
'bottom' => '5%',
'containLabel' => true
],
'xAxis' => [
'type' => 'value',
'boundaryGap' => [0, 0.01]
],
'yAxis' => [
'type' => 'category',
'data' => array_column($months_arr,'cn'),
],
'series' => [
[
'type' => 'bar',
'itemStyle' => [
'color' => '#2e3246',
'borderRadius' => [0, 20, 20, 0],
],
'barWidth' => '15',
'data' => $count_data,
'label' => [
'show' => true,
'position' => 'right',
'formatter' => '{@[n]}',
'valueAnimation' => true
]
]
]
];
$data = [
'custom' => $custom,
'stat_data' => $stat_data,
];
return $data;
}
//数据分析页面订单数据
protected function get_ocust(){
$day = $this->input_param('day');
$biz_id = $this->input_param('biz_id');
$admin_id = $this->input_param('admin_id');
if(!$biz_id){
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
!$day && $day = date('Y-m-d');//获取当天
$status_list = [
[
'title' => '合同签订',
'icon' => 'icon-statistics-order-1',
'status' => 0
],
[
'title' => '分期办理',
'icon' => 'icon-statistics-order-2',
'status' => 1
],
[
'title' => '车辆确认',
'icon' => 'icon-statistics-order-3',
'status' => 2
],
[
'title' => '申请开票',
'icon' => 'icon-statistics-order-4',
'status' => 3
],
[
'title' =>'代办服务',
'icon' => 'icon-statistics-order-5',
'status' => 4
],
[
'title' =>'交付确认',
'icon' => 'icon-statistics-order-6',
'status' => 5
],
[
'title' =>'完成交付',
'icon' => 'icon-statistics-order-7',
'status' => 6
],
];
foreach($status_list as $key => $val){
$setValue = [
'title' => $val['title'],
'icon' => $val['icon'],
];
$where = [
'status' => $val['status'],
'biz_id' => $biz_id
];
if($day){
$s_time = date('Y-m-01 00:00:00',strtotime($day));
$e_time = date('Y-m-t 23:59:59',strtotime($day));
$where['c_time>='] = strtotime($s_time);
$where['c_time<='] = strtotime($e_time);
}
$admin_id && $where['admin_id'] = $admin_id;
$setValue['value'] = $this->customers_model->count($where);
$custom[] = $setValue;
}
$months_arr = [];
for($i=2;$i>=0;$i--){
$_time = date("Y-m-01",mktime(0, 0 , 0,date("m",strtotime($day))-$i,1,date("Y",strtotime($day))));
$months_arr [] = [
'cn' => date('n月',strtotime($_time)),
's_time' => date('Y-m-01 00:00:00',strtotime($_time)),
'e_time' => date('Y-m-t 23:59:59',strtotime($_time))
];
}
foreach($months_arr as $val){
$where = [
'biz_id' => $biz_id,
'status>=' => 0,
'c_time>=' => strtotime($val['s_time']),
'c_time<=' => strtotime($val['e_time']),
];
$count_data[] = $this->orders_model->count($where);
}
$stat_data = [
'grid' => [
'top' => '15%',
'left' => '2%',
'right' => '5%',
'bottom' => '5%',
'containLabel' => true
],
'xAxis' =>[
'type' => 'category',
'data' => array_column($months_arr,'cn'),
],
'yAxis' => [
'type' => 'value'
],
'series' => [
[
'data' => $count_data,
'type' => 'line',
'smooth' => true
]
]
];
$data = [
'custom' => $custom,
'stat_data' => $stat_data,
];
return $data;
}
//首页饼状图客户统计
protected function get_hcust(){
$biz_id = $this->input_param('biz_id');
$group_id = $this->session['group_id'];
$uid = $this->session['uid'];
!$biz_id && $biz_id = intval($this->session['biz_id']);
if(!$biz_id){
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
$status_list = $this->customers_model->get_status();
unset($status_list[-1]);
$count_data = [];
foreach($status_list as $key => $val){
$where = [
'biz_id' => $biz_id,
'status' => $key
];
$group_id == 1 && $where['admin_id'] = $uid;
$count = $this->customers_model->count($where);
$count_data[] = [
'value' => $count,
'name' => $val
];
}
//所有客户数据
$where = [
'status>='=>0,
'biz_id'=>$biz_id
];
$group_id == 1 && $where['admin_id'] = $uid;
$count = $this->customers_model->count($where);
$where = [
'status>='=>0,
'biz_id'=>$biz_id,
'is_top'=>1
];
$group_id == 1 && $where['admin_id'] = $uid;
$top_count = $this->customers_model->count($where); //关注
$where = [
'status>='=>0,
'biz_id'=>$biz_id,
"cont_time = '0000-00-00 00:00:00'"=>null
];
$group_id == 1 && $where['admin_id'] = $uid;
$un_count = $this->customers_model->count($where);//未联系
$stat_data = [
'tooltip' =>[
'trigger' => 'axis',
],
'legend' => [
'top' => 'bottom',
'orient' => 'horizontal',
'textStyle' =>[
'fontSize' => 9,
]
],
'series' => [
'type' => 'pie',
'top' => '0',
'radius' => ['30%', '48%'],
'data' => $count_data,
'label' =>[
'formatter' => '\n{b|{b}}\n{c|{c}}\n{per|{d}%} ',
'rich' => [
'b' =>[
'color' => '#4C5058',
'fontSize' => 10,
'lineHeight' => 15,
'align' => 'left',
],
'b' =>[
'color' => '#4C5058',
'fontSize' => 10,
'lineHeight' => 15,
'align' => 'left',
],
'per' => [
'color' => '#4C5058',
'fontSize' => 10,
'lineHeight' => 15,
'align' => 'left',
],
]
],
]
];
$data = [
'stat_data' => $stat_data,
'total' => $count,
'cont_total' => $un_count,
'top_total' => $top_count
];
return $data;
}
//首页柱状图订单统计
protected function get_horder(){
$biz_id = $this->input_param('biz_id');
$group_id = $this->session['group_id'];
$uid = $this->session['uid'];
!$biz_id && $biz_id = intval($this->session['biz_id']);
if(!$biz_id){
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
$status_list = $this->orders_model->get_status();
unset($status_list[7]);
$count_data = [];
$total = 0;
foreach($status_list as $key => $val){
$where = [
'biz_id' => $biz_id,
'status' => $key
];
$group_id == 1 && $where['admin_id'] = $uid;
$count = $this->orders_model->count($where);
$total += $count;
$count_data[] = [
'value' => $count,
'name' => $val
];
}
$stat_data = [
'tooltip' =>[
'trigger' => 'axis',
'axisPointer' => [
'type' => 'shadow'
]
],
'grid' =>[
'top' => '8%',
'left' => '2%',
'right' => '5%',
'bottom' => '2%',
'containLabel' => true
],
'xAxis' =>[
'type' => 'value',
'boundaryGap' => [0, 0.01]
],
'yAxis' =>[
'type' => 'category',
'data' => array_column($count_data,'name'),
],
'series' =>[
'type' => 'bar',
'itemStyle' =>[
'color' => '#2e3246',
'borderRadius' => [0, 20, 20, 0],
],
'barWidth' => '15',
'data' => array_column($count_data,'value'),
'label'=>[
'show' => true,
'position' => 'right',
'formatter' => '{@[n]}',
'valueAnimation' => true
]
]
];
$data = [
'stat_data' => $stat_data,
'total' => $total
];
return $data;
}
/**
* 获取季度
* @param int $season 当前季度
*/
private function season_data($season){
$chiNum = ['一','二','三','四'];
if($season>3){
return [];
}
for($i=0;$i<$season;$i++){
$season_data[] = "{$chiNum[$i]}季度";
}
return $season_data;
}
}
+134 -13
View File
@@ -19,6 +19,8 @@ class User extends Wxapp{
$this->check_mobile = array();//需要手机号
$this->check_headimg =array();//授权微信信息
$this->load->model("biz/biz_model");
$this->load->model('auto/auto_brand_model');
}
/**
@@ -81,11 +83,11 @@ class User extends Wxapp{
*/
protected function get(){
$uid = $this->session['uid'];
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
$user = $this->app_user_model->get(array('id' => $uid));
//获取所属店铺字段
$this->load->model("biz/biz_model");
$biz = $this->biz_model->get(['id'=>$this->session['biz_id']],'biz_name');
$biz = $this->biz_model->get(['id'=>$biz_id],'biz_name');
$group_arr = $this->app_user_model->get_group();
$group_name = $group_arr[$user['group_id']] ? $group_arr[$user['group_id']] : '';
@@ -115,26 +117,72 @@ class User extends Wxapp{
*/
protected function get_cal(){
$uid = $this->session['uid'];
$biz_id = $this->session['biz_id'];
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
$group_id = $this->session['group_id'];
$this->load->model('receiver/receiver_customers_model','customers_model');
$this->load->model('receiver/order/receiver_orders_model','orders_model');
$this->load->model('receiver/order/receiver_order_signs_model','order_signs_model');
$wl_count = $this->customers_model->count(["cont_time = '0000-00-00 00:00:00'"=>null,'admin_id'=>$uid,'biz_id'=>$biz_id]);
$gz_count = $this->customers_model->count(['status>'=>-1,'is_top'=>1,'admin_id'=>$uid,'biz_id'=>$biz_id]);
$sign_count = $this->orders_model->count(['status'=>0,'admin_id'=>$uid,'biz_id'=>$biz_id]);
$loan_count = $this->orders_model->count(['status'=>1,'admin_id'=>$uid,'biz_id'=>$biz_id]);
$where = [
"cont_time = '0000-00-00 00:00:00'"=>null,
'biz_id'=>$biz_id
];
$group_id == 1 && $where['admin_id'] = $uid;
$wl_count = $this->customers_model->count($where);
$where = [
'status>'=>-1,
'is_top'=>1,
'biz_id'=>$biz_id
];
$group_id == 1 && $where['admin_id'] = $uid;
$gz_count = $this->customers_model->count($where);
$where = [
'status'=>0,
'biz_id'=>$biz_id
];
$group_id == 1 && $where['admin_id'] = $uid;
$sign_count = $this->orders_model->count($where);
$where = [
'status'=>1,
'biz_id'=>$biz_id
];
$group_id == 1 && $where['admin_id'] = $uid;
$loan_count = $this->orders_model->count($where);
//未派单客户
$unuse_count = $this->customers_model->count(['admin_id'=>0,'biz_id'=>$biz_id]);
//为创建订单客户
$uncre_count = $this->customers_model->count_order(['lc_receiver_customers.status'=>2,'lc_receiver_customers.admin_id'=>$uid,'lc_receiver_customers.biz_id'=>$biz_id,'lc_receiver_orders.id is null'=>null]);
$where = [
'lc_receiver_customers.status'=>2,
'lc_receiver_customers.biz_id'=>$biz_id,
'lc_receiver_orders.id is null'=>null
];
$group_id == 1 && $where['lc_receiver_customers.admin_id'] = $uid;
$uncre_count = $this->customers_model->count_order($where);
$t1 = 'lc_receiver_order_signs';
$t2 = 'lc_receiver_orders';
$need_sign = $this->order_signs_model->count_order(["$t1.status"=>0,"$t2.admin_id"=>$uid]);//需要签名
$loan_count = $this->orders_model->count(['status'=>1,'admin_id'=>$uid]);//未选择分期
$bill_count = $this->orders_model->count(['status'=>3,'admin_id'=>$uid]);//开票相关
$del_count = $this->orders_model->count(['status'=>5,'admin_id'=>$uid]);//交付确认
$where = [
"status"=>0,
"biz_id" => $biz_id
];
$group_id == 1 && $where["admin_id"] = $uid;
$need_sign = $this->orders_model->count($where);//需要签名
$where = [
"status"=>1,
"biz_id" => $biz_id
];
$group_id == 1 && $where["admin_id"] = $uid;
$loan_count = $this->orders_model->count($where);//未选择分期
$where = [
"status"=>3,
"biz_id" => $biz_id
];
$group_id == 1 && $where["admin_id"] = $uid;
$bill_count = $this->orders_model->count($where);//开票相关
$where = [
"status"=>5,
"biz_id" => $biz_id
];
$group_id == 1 && $where["admin_id"] = $uid;
$del_count = $this->orders_model->count($where);//交付确认
$deallist = [
['title'=>'需登记订单','icon'=>'icon-dengji','total'=>$uncre_count,'page'=>'/pages/order/register/index'],
['title'=>'需邀请签名','icon'=>'icon-qianming1','total'=>$need_sign,'page'=>'/pages/order/filterList/index?key=0&ismy=1'],
@@ -180,4 +228,77 @@ class User extends Wxapp{
return $data;
}
/**
* 获取门店信息
* @return array
*/
protected function get_bizs(){
$lists = [];
$biz_id_arr = explode(',',$this->session['biz_id']);
if($biz_id_arr){
$bizs = $this->biz_model->get_by_id_arr($biz_id_arr,'id,biz_name,jsondata');
foreach($bizs as $key => $val){
$auto_brands = [];
$jsondata = json_decode($val['jsondata'],true);
$auto_brands_arr = $jsondata['auto_brands'];
$brand_ids = implode(',',$auto_brands_arr);
if($auto_brands_arr && $brand_ids){
$where = [
"id in ($brand_ids)" => null
];
$brands = $this->auto_brand_model->select($where,'',0,0,'name');
$auto_brands = array_column($brands,'name');
}
$lists[] = [
'id' => $val['id'],
'name' => $val['biz_name'],
'auto_brands' => $auto_brands
];
}
}
$data = [
'list' => $lists,
];
return $data;
}
//获取门店管理员
protected function get_admins(){
$biz_id = $this->input_param('biz_id');
$page = $this->input_param('page');
$size = $this->input_param('size');
!$page && $page = 1;
!$size && $size = 10;
$where = [
'status' => 1,
'biz_id' => $biz_id
];
$lists = [];
$count = $this->app_user_model->count($where);
if($count){
$rows = $this->app_user_model->select($where,'id desc',$page,$size,'id,uname');
$lists = $rows;
}
$data = [
'list' => $lists,
'total' => $count
];
return $data;
}
/**
* 重新设置用户session里的biz_id
*/
protected function put_resetbiz(){
$ukey = $this->input_param('ukey');
$biz_id = $this->input_param('biz_id');
if (!$biz_id) {
throw new Hd_Exception('参数错误', API_CODE_INVILD_PARAM);
}
$this->session['new_biz_id'] = $biz_id;
$this->app_redis->save($this->redis_login.$ukey, json_encode($this->session, JSON_UNESCAPED_UNICODE), 30 * 24 * 3600);
throw new Exception('保存成功', API_CODE_SUCCESS);
}
}
+45
View File
@@ -69,6 +69,7 @@ class Xz extends Wxapp{
$add_data = [
'call_id' => $seq_id,
'display_number' => $result['data']['virtualMobile'],
'biz_id' => $row['biz_id'],
'cf_id' => $cus_id,
'cf_uid' => $admin_id,
'cf_title' => $cf_title,
@@ -84,4 +85,48 @@ class Xz extends Wxapp{
$data['mobile'] = $call_mobile;
return $data;
}
//电话统计
protected function get_stat(){
$biz_id = $this->input_param('biz_id');
$day = $this->input_param('day');
$admin_id = $this->input_param('admin_id');
if(!$biz_id){
throw new Hd_Exception('参数错误', API_CODE_INVILD_PARAM);
}
//接通次数
$where1 = [
'cf_title' => 'customer',
'cf_platform' => 'api',
'biz_id' => $biz_id,
'status' => 1,
];
if($day){
$s_time = date('Y-m-d 00:00:00',strtotime($day));
$e_time = date('Y-m-d 23:59:59',strtotime($day));
$where1["c_time>="] = strtotime($s_time);
$where1["c_time<="] = strtotime($e_time);
}
$admin_id && $where1['cf_uid'] = $admin_id;
$where2 = [
'duration' => 0
];
$where = array_merge($where1,$where2);
$num = $this->receiver_xz_model->count($where);
$where2 = [
'duration>' => 0
];
$where = array_merge($where1,$where2);
$count_call = $this->receiver_xz_model->count($where); //接通次数
$sum_call = $this->receiver_xz_model->sum('duration',$where); //接通总时长
$call_time = $sum_call['duration']/60000;
if($call_time){
$avg_time = $call_time/$count_call;
}
$data = [
'call_time' => round($call_time,2),
'avg_time' => round($avg_time,2),
'unget_num' => $num
];
return $data;
}
}
+11
View File
@@ -1043,3 +1043,14 @@ if (!function_exists('create_contract_no')) {
}
}
if(!function_exists('getMonth')){
function getMonth($season){
$times = array();
$firstday = date('Y-m-d H:i:s', mktime(0, 0, 0,$season*3-3+1,1,date('Y')));
$sm = date('m',mktime(0,0,0,$season*3-3+1,1,date('Y')))+1;
$seconday = date("Y-{$sm}-01");
$lastday = date('Y-m-d H:i:s', mktime(23,59,59,$season*3,date('t',mktime(0, 0 , 0,$season*3,1,date('Y'))),date('Y')));
return [$firstday,$seconday,$lastday];
}
}
+17
View File
@@ -34,6 +34,23 @@ class Biz_model extends HD_Model
return $rows;
}
/**
* id数组获取门店
* @param array() $ids
* @return array()
*/
public function get_by_id_arr($ids_arr,$fileds='id,biz_name'){
$bizs = [];
$ids = implode(',',$ids_arr);
if($ids){
$where = [
"id in ($ids)" => null,
"status" => 1
];
$bizs = $this->biz_model->select($where,'',0,0,$fileds);
}
return $bizs;
}
/**
* 获取类型
* @param null $key
+1 -1
View File
@@ -22,4 +22,4 @@ create table lc_app_licheb_users (
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='狸车宝用户表';
alter table lc_app_licheb_users add column jsondata json default null comment '其他信息' after biz_id;
alter table lc_app_licheb_users modify biz_id varchar(200) not null default 0 comment '门店id多个用逗号隔开(1,2,3)';