diff --git a/admin/config/autoload.php b/admin/config/autoload.php index 2eccb128..4194ef90 100644 --- a/admin/config/autoload.php +++ b/admin/config/autoload.php @@ -58,7 +58,7 @@ $autoload['packages'] = array(); | | $autoload['libraries'] = array('user_agent' => 'ua'); */ -$autoload['libraries'] = array('database'); +$autoload['libraries'] = array('database','myResponse'); /* | ------------------------------------------------------------------- diff --git a/admin/controllers/Common.php b/admin/controllers/Common.php index 3fabfd8e..2857aad3 100644 --- a/admin/controllers/Common.php +++ b/admin/controllers/Common.php @@ -415,9 +415,12 @@ class Common extends CI_Controller $page = $this->input->post('page') ? intval($this->input->post('page')) : 1; $size = $this->input->post('size') ? intval($this->input->post('size')) : 10; $brand_id = intval($this->input->post('brand_id')); + $car_brand_id = intval($this->input->post('car_brand_id')); $province_id = intval($this->input->post('province_id')); $city_id = intval($this->input->post('city_id')); $county_id = intval($this->input->post('county_id')); + $type = intval($this->input->post('type')); + $unset_city_limit = intval($this->input->post('unset_city_limit')); $use_shop_list = $this->input->post('use_shop_list'); $sys_cate_id = intval($this->input->post('sys_cate_id')); @@ -430,6 +433,7 @@ class Common extends CI_Controller } } $where['status'] = 1; + $car_brand_id && $where['car_brand_id'] = $car_brand_id; $sys_cate_id && $where['cate_id'] = $sys_cate_id; $biz_name && $where['biz_name like "%' . $biz_name . '%"'] = null; $brand_id && $where['brand_id'] = $brand_id; @@ -437,8 +441,9 @@ class Common extends CI_Controller $city_id && $where['city_id'] = $city_id; $county_id && $where['county_id'] = $county_id;; $ids && $where['id not in (' . $ids . ')'] = null; + $type && $where['type'] = $type; - if ($province_id && $city_id) { + if (($province_id && $city_id) || $unset_city_limit) { $count = $this->mdBiz->count($where); if ($count) { $resBiz = $this->mdBiz->select($where, 'id desc', $page, $size); @@ -1103,7 +1108,7 @@ class Common extends CI_Controller $lists = $this->auto_brand_model->select($where, 'initial asc', $page, $size); foreach ($lists as $key => $val) { $itemsList[] = [ - 'id' => $val['id'], + 'id' => intval($val['id']), 'name' => $val['name'], 'is_checked' => $itemsChecked[$val['id']] ? 1 : 0 ]; diff --git a/admin/controllers/app/licheb/Member.php b/admin/controllers/app/licheb/Member.php index 7e22e657..3192eb2a 100644 --- a/admin/controllers/app/licheb/Member.php +++ b/admin/controllers/app/licheb/Member.php @@ -5,7 +5,7 @@ defined('BASEPATH') or exit('No direct script access allowed'); class Member extends HD_Controller { - private $groups = [1 => '车管家', 2 => '店长', 3 => '投资人', 4 => '客户成功经理']; + private $groups; public function __construct() { @@ -13,6 +13,7 @@ class Member extends HD_Controller $this->load->model('app/licheb/App_licheb_users_model', 'userM'); $this->load->model('app/licheb/App_licheb_channel_biz_model', 'mdChannelBiz'); $this->load->model("biz/biz_model"); + $this->groups = $this->userM->get_group(); } //首页信息 diff --git a/admin/controllers/biz/store/Store.php b/admin/controllers/biz/store/Store.php index dec57c14..2c8968cd 100644 --- a/admin/controllers/biz/store/Store.php +++ b/admin/controllers/biz/store/Store.php @@ -19,6 +19,9 @@ class Store extends HD_Controller $this->load->helper('image_helper'); $this->load->model("biz/biz_model"); $this->load->model('area_model'); + $this->load->library('bizAccount'); + $this->load->helper('db'); + $this->load->model('auto/auto_brand_model'); } public function index() @@ -69,11 +72,23 @@ class Store extends HD_Controller $biz_lists = $this->biz_model->select($where, 'id desc', $page, $pagesize); $count = $this->biz_model->count($where); $bizlists = []; - foreach ($biz_lists as $v) { - $v['c_time'] = date('Y-m-d H:i:s', $v['c_time']); - $v['biz_type'] = $typeAry[$v['type']]; - $bizlists[] = $v; + $account = new BizAccount(); + $brandAry = $this->auto_brand_model->select(['status>'=>0], 'initial asc', 0, 0, 'id,name'); + if($biz_lists){ + $map = []; + foreach($brandAry as $item) { + $map[$item['id']] = null !== $item['name'] ? $item['name'] : ''; + } + foreach ($biz_lists as $v) { + $bizAccount = $account->getAccountBizId($v['id']); + $v['money_left'] = $bizAccount ? $bizAccount['money_left'] : 0; + $v['c_time'] = date('Y-m-d H:i:s', $v['c_time']); + $v['biz_type'] = $typeAry[$v['type']]; + $v['brand_name'] = $map[$v['car_brand_id']]; + $bizlists[] = $v; + } } + $this->data['brandAry'] = $brandAry; $this->data['params'] = $params; $this->data['lists'] = $bizlists; $this->data['typeAry'] = $typeAry; @@ -101,6 +116,7 @@ class Store extends HD_Controller $biz['county_id'] && $areas = $this->sys_area_model->select(array('county_id' => $biz['county_id'])); $this->data['areas'] = $areas; $biz['avatar'] = build_qiniu_image_url($biz['headimg'], 200, 200); + $biz['car_brand_id'] = $biz['car_brand_id'] ? intval($biz['car_brand_id']) : ''; $this->data['biz'] = $biz; } else { @@ -118,7 +134,7 @@ class Store extends HD_Controller 'type' => 0, 'company_id' => 0, 'auto_brands' => array(), - 'car_brand_id' => 0 + 'car_brand_id' => '' );//默认福建城市 $this->data['biz'] = $biz; } @@ -150,6 +166,7 @@ class Store extends HD_Controller $biz['lat'] = $this->input->post('lat', true); $biz['lng'] = $this->input->post('lng', true); $biz['type'] = intval($this->input->post('type', true)); + $biz['car_brand_id'] = intval($this->input->post('car_brand_id', true)) ?: ''; //上传头像 $biz['headimg'] = $this->input->post('headimg'); @@ -191,6 +208,7 @@ class Store extends HD_Controller $biz['lat'] = $this->input->post('lat', true); $biz['lng'] = $this->input->post('lng', true); $biz['type'] = intval($this->input->post('type', true)); + $biz['car_brand_id'] = intval($this->input->post('car_brand_id', true)) ?: ''; //上传头像 $biz['headimg'] = $this->input->post('headimg'); $res = $this->biz_model->update($biz, array('id' => $id)); @@ -270,7 +288,7 @@ class Store extends HD_Controller $county_id && $where['county_id'] = $county_id; $title && $where["biz_name like '%{$title}%'"] = null; - if($province_id||$city_id||$county_id||$title){ + if ($province_id || $city_id || $county_id || $title) { $total = $this->biz_model->count($where); } @@ -291,4 +309,29 @@ class Store extends HD_Controller $this->data = array('total' => $total, 'list' => $lists); return $this->show_json(SYS_CODE_SUCCESS); } + + public function add_money() + { + $id = intval($this->input->get_post('id')); + $biz = $this->biz_model->get(array('id' => $id, 'status>-1' => null)); + if (!$biz) { + return $this->show_json(0, '门店不存在'); + } + if ($this->input->method() == 'post') { + $money = $this->input->post('money'); + if (!$money) { + return $this->show_json(SYS_CODE_FAIL, '请输入金额'); + } + $bizAccount = new BizAccount(); + $account = $bizAccount->getAccountBizId($id, true); + $sqlArr = $bizAccount->charge($account['id'], $money, '充值'); + $result = trans_sql($sqlArr); + if (!$result) { + return $this->show_json(SYS_CODE_FAIL, '充值失败'); + } + return $this->show_json(SYS_CODE_SUCCESS, '充值成功'); + } + $this->data['biz'] = $biz; + $this->show_view('biz/store/add_money'); + } } diff --git a/admin/controllers/receiver/Clues.php b/admin/controllers/receiver/Clues.php index 59053e2a..643158f9 100644 --- a/admin/controllers/receiver/Clues.php +++ b/admin/controllers/receiver/Clues.php @@ -27,6 +27,7 @@ class Clues extends HD_Controller $this->load->model('auto/auto_brand_model'); $this->load->model('auto/auto_series_model'); $this->load->model('app/paic/app_paic_users_model'); + $this->load->model('receiver/receiver_enroll_model'); $this->log_dir = 'receiver_clues'; } @@ -44,7 +45,7 @@ class Clues extends HD_Controller $where = array("status" => $key); if ($this->admin_biz_str) { $where["belong_id in ($this->admin_biz_str)"] = null; - }else{ + } else { $this->belong && $where["belong_id"] = $this->belong; } $count1 = $this->clues_model->count($where); @@ -96,7 +97,7 @@ class Clues extends HD_Controller } if ($this->admin_biz_str) { $where["belong_id in ($this->admin_biz_str)"] = null; - }else{ + } else { $params['belong_id'] && $where["belong_id"] = $params['belong_id']; } //创建时间 @@ -162,7 +163,8 @@ class Clues extends HD_Controller $count = $this->clues_model->count($where); $lists = []; if ($count) { - $fileds = 'id,name,mobile,brand_id,series_id,cf_id,cf2_id,c_time,admin_id,status,status2,en_time,province_id,city_id,county_id,biz_id,p_time,u_time'; + $fileds = 'id,name,mobile,brand_id,series_id,cf_id,cf2_id,c_time,admin_id,status,status2,en_time, + province_id,city_id,county_id,biz_id,p_time,u_time,rec_time'; $rows = $this->clues_model->select($where, 'en_time desc,id desc', $page, $size, $fileds); $map_admin = $map_cf_pid = $cf_title_arr = []; @@ -259,6 +261,7 @@ class Clues extends HD_Controller if ($val['p_time'] == '0000-00-00 00:00:00') { $val['p_time'] = ''; } + $val['rec_time'] = $val['rec_time'] != '0000-00-00 00:00:00' ? $val['rec_time'] : ''; $lists[] = $val; } } @@ -266,7 +269,6 @@ class Clues extends HD_Controller $adminLists = $this->sys_admin_model->select($where, 'id desc', 0, 0, 'id,username'); $this->data['adminLists'] = $adminLists; $this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count); - return [$lists, $count]; } @@ -298,6 +300,7 @@ class Clues extends HD_Controller $info_show['c_time'] = date('Y-m-d H:i', $re['c_time']); $info_show['en_time'] = $re['en_time']; $info_show['mobile_sub'] = $re['mobile']; + $info_show['buy_time_cn'] = $re['buy_time'] ? Receiver_clues_model::BUY_TIME_LIST[$re['buy_time']] : ''; $resLogs = $this->mdOplogs->select(array('clue_id' => $id), 'c_time desc', 0, 0); foreach ($resLogs as $key => $value) { @@ -321,6 +324,7 @@ class Clues extends HD_Controller } $info_show['logsList'] = $logsList; + $dataInfo['rec_time'] = $dataInfo['rec_time'] == '0000-00-00 00:00:00' ? '' : $dataInfo['rec_time']; //获取所在地区 $dataInfo['province_id'] = $re['province_id']; $dataInfo['city_id'] = $re['city_id']; @@ -338,12 +342,20 @@ class Clues extends HD_Controller $map_cfrom = $this->clues_cfrom_model->map('id', 'title', array('status' => 1, 'pid' => 0, 'type' => 0), '', 0, 0, 'id, title'); $map_cfrom2 = $this->clues_cfrom_model->map('id', 'title', array('status' => 1, 'pid' => $params['cfrom_id']), '', 0, 0, 'id, title'); - + //已分配门店 + $selectedBrands1 = []; + if ($dataInfo['app_id'] == Receiver_clues_model::APP_ID_ACTIVITY) { + $customerRows = $this->customers_model->select(['rid' => $re['id'], 'status >' => -1], '', '', '', 'biz_id'); + $ids = implode(',', array_column($customerRows, 'biz_id')); + $ids && $selectedBrands1 = $this->biz_model->select(["id in ($ids)" => null, 'status' => 1], '', 0, 0, 'id as biz_id,biz_name as name'); + } $this->data['cfromAry'] = $map_cfrom; $this->data['cfromAry2'] = $map_cfrom2; $this->data['provinces'] = $this->province_ary(); $this->data['info'] = $dataInfo; $this->data['info_show'] = $info_show; + $this->data['selectedBrands1'] = $selectedBrands1; + $this->data['buyTimeList'] = Receiver_clues_model::BUY_TIME_LIST; $this->data['_title'] = '线索详情'; return $this->show_view('receiver/clues/edit', true); } @@ -423,7 +435,7 @@ class Clues extends HD_Controller $this->data['limit_province_id'] = $this->limit_province_id; $this->data['_title'] = $title; - return $this->show_view('receiver/clues/get',true); + return $this->show_view('receiver/clues/get', true); } //添加单条数据 @@ -555,6 +567,19 @@ class Clues extends HD_Controller if (!$params['log']) { return $this->show_json(SYS_CODE_FAIL, '请输入内容!'); } + if(strlen($params['buy_time'])){ + $buy_time_cn = Receiver_clues_model::BUY_TIME_LIST[$params['buy_time']]; + $addData = array( + 'clue_id' => $params['id'], + 'uid' => $this->uid, + 'uname' => $this->username, + 'type' => intval($params['type']), + 'log' => '修改意向购车周期为:'.$buy_time_cn, + 'c_time' => time() + ); + $this->mdOplogs->add($addData); + $this->clues_model->update(['buy_time' => $params['buy_time']], ['id' => $params['id']]); + } $addData = array( 'clue_id' => $params['id'], 'uid' => $this->uid, @@ -716,7 +741,7 @@ class Clues extends HD_Controller 'status2' => 1, 'p_time' => date('Y-m-d H:i:s'), ]; - + $info['rec_time'] && $up_data['rec_time'] = $info['rec_time']; $ret = $this->clues_model->update($up_data, array('id' => $info['id'])); if (!$ret) { $code = SYS_CODE_FAIL; @@ -1233,4 +1258,124 @@ class Clues extends HD_Controller return $this->show_view('receiver/clues/get_admin'); } + //派单到客户池 + public function add_customer() + { + $this->load->helper("order"); + $info = $this->input->post('info'); + $bizList = $this->input->post('bizList'); + if (!count($bizList)) { + return $this->show_json(SYS_CODE_FAIL, '请选择门店'); + } + if (!$info['rec_time']) { + return $this->show_json(SYS_CODE_FAIL, '请选择回收时间'); + } + $re = $this->clues_model->get(array('id' => $info['id'])); + if (!$re || empty($re)) { + return $this->show_json(SYS_CODE_FAIL, '线索不存在!'); + } + foreach ($bizList as $item) { + $customers = $this->customers_model->get(array('rid' => $re['id'], 'status >' => -1, 'biz_id' => $item['biz_id'])); + if ($customers) { + continue; + } + $biz = $this->biz_model->get(array('id' => $item['biz_id'])); + $add = array( + 'rid' => $re['id'], + 'cid' => create_customer_no($biz['county_id']), + 'name' => $re['name'], + 'province_id' => $biz['province_id'], + 'city_id' => $biz['city_id'], + 'county_id' => $biz['county_id'], + 'mobile' => $re['mobile'], + 'biz_id' => $item['biz_id'], + 'level' => 'H', + 'cf_title' => '数字营销中台', + 'of_id' => $re['cf_id'], + 'of2_id' => $re['cf2_id'], + 'brand_id' => $re['brand_id'], + 'series_id' => $re['series_id'], + 'p_time' => date('Y-m-d H:i:s'), + 'cont_time' => $re['cont_time'], + 'cf_pid' => $re['cf_pid'], + 'c_time' => $re['c_time'], + 'rec_time' => $info['rec_time'] + ); + + $customers_id = $this->customers_model->add($add); + if (!$customers_id) { + continue; + } + //同步线索日志到客户日志 + $this->load->library('receiver/customers_entity'); + $this->customers_entity->syn_clues($customers_id, $re['id']); + //短信通知店长 +// $this->load->model('app/licheb/app_licheb_users_model'); +// $where = array('biz_id' => $biz['biz_id'], 'status' => 1, 'group_id' => 2); +// $res_u = $this->app_licheb_users_model->select($where); +// if ($res_u) { +// foreach ($res_u as $v) { +// if ($re['biz_id'] != 1) { +// b2m_send_sms($v['mobile'], '【理车宝】您好,门店新增了1个客户线索。请及时到小程序"理车宝-待分配客户”分配给销售顾问跟进。祝您生活愉快!'); +// } +// } +// } + } + $this->clues_model->update(['rec_time' => $info['rec_time'], 'p_time' => date('Y-m-d H:i:s')], ['id' => $re['id']]); + return $this->show_json(SYS_CODE_SUCCESS, '修改成功'); + } + + /** + * 删除客户派单 + * @return bool + */ + public function delete_customer() + { + $info = $this->input->post('info'); + $bizId = $this->input->post('bizId'); + if (!$bizId) { + return $this->show_json(SYS_CODE_FAIL, '请选择门店'); + } + $re = $this->clues_model->get(array('id' => $info['id'])); + if (!$re || empty($re)) { + return $this->show_json(SYS_CODE_FAIL, '线索不存在!'); + } + $this->customers_model->update(array('status' => -1), ['rid' => $re['id'], 'biz_id' => $bizId]); + return $this->show_json(SYS_CODE_SUCCESS, '修改成功'); + } + + public function enroll_list() + { + $params = $this->input->get(); + $page = $params['page'] = $params['page'] ? intval($params['page']) : 1; + $size = $params['size'] = $params['size'] ? intval($params['size']) : 20; + $list = []; + $id = intval($params['id']); + $clues = $this->clues_model->get(['id' => $id]); + if (!$clues) { + return $this->show_json(SYS_CODE_FAIL, '线索不存在!'); + } + $where = ['mobile' => $clues['mobile']]; + $count = $this->receiver_enroll_model->count($where); + if ($count) { + $rows = $this->receiver_enroll_model->select($where, 'id desc', $page, $size); + $brands = $this->auto_brand_model->get_map_by_ids(array_column($rows, 'brand_id')); + $series = $this->auto_series_model->get_map_by_ids(array_column($rows, 'series_id')); + foreach ($rows as $key => $value) { + $setValue = $value; + $setValue['mobile'] = $value['mobile']; + $setValue['c_time'] = date('Y-m-d H:i:s'); + $brandName = $brands[$value['brand_id']] ? $brands[$value['brand_id']][0]['name'] : ''; + $seriesName = $series[$value['series_id']] ? $series[$value['series_id']][0]['name'] : ''; + $cfRow = $this->clues_cfrom_model->get(['id' => $value['cf2_id']]); + $cfrom2 = $cfRow['title'] ?: ''; + $setValue['brandName'] = "{$brandName} {$seriesName}"; + $setValue['cfrom2'] = $cfrom2; + $list[] = $setValue; + } + } + $this->data['list'] = $list; + $this->data['count'] = $count; + return $this->show_json(SYS_CODE_SUCCESS); + } } diff --git a/admin/views/biz/store/add_money.php b/admin/views/biz/store/add_money.php new file mode 100644 index 00000000..2b6692ae --- /dev/null +++ b/admin/views/biz/store/add_money.php @@ -0,0 +1,18 @@ +
\ No newline at end of file diff --git a/admin/views/biz/store/edit.php b/admin/views/biz/store/edit.php index 93d39650..a69dd215 100644 --- a/admin/views/biz/store/edit.php +++ b/admin/views/biz/store/edit.php @@ -266,6 +266,18 @@ + +