1509 lines
60 KiB
PHP
1509 lines
60 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: linfan
|
|
* Date: 2018/11/13
|
|
* Time: 16:43
|
|
*/
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
ini_set('display_errors', 'On');
|
|
error_reporting(E_ALL);
|
|
|
|
class Common extends CI_Controller
|
|
{
|
|
|
|
public $data = array();
|
|
|
|
//获取行政区域
|
|
public function area()
|
|
{
|
|
$key = $this->input->get('key');
|
|
$id = intval($this->input->get('id'));
|
|
$url = $this->input->get('url');
|
|
$type = intval($this->input->get('type'));
|
|
$this->load->model('area_model');
|
|
|
|
switch ($key) {
|
|
case 'city':
|
|
if ($url == 'search') {
|
|
$city = $this->filter($this->area_model->city($id, $type));
|
|
} else {
|
|
$city = $this->area_model->city($id, $type);
|
|
}
|
|
$this->data = $city;
|
|
break;
|
|
case 'county':
|
|
$this->data = $this->area_model->county($id, $type);
|
|
break;
|
|
default:
|
|
$this->data = $this->area_model->province();
|
|
break;
|
|
}
|
|
|
|
return $this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
protected function filter($data)
|
|
{
|
|
if ($_SESSION['admin_info'] && $_SESSION['admin_role_id'] != '0') {
|
|
$city_id = $_SESSION['admin_info']['city_id'];
|
|
foreach ($data as $key => $value) {
|
|
foreach ($city_id as $k => $val) {
|
|
if ($val == $value['id']) {
|
|
$tmp[] = $value;
|
|
}
|
|
}
|
|
if ($value['id'] == '') $tmp[] = $value;
|
|
}
|
|
return $tmp;
|
|
} else if ($_SESSION['admin_role_id'] == '0') {
|
|
return $data;
|
|
}
|
|
}
|
|
|
|
//获取商圈
|
|
public function areas()
|
|
{
|
|
$pid = intval($this->input->post('id'));
|
|
if (!$pid) {
|
|
$pid = intval($this->input->get('id'));
|
|
}
|
|
|
|
$this->load->model("sys/sys_area_model");
|
|
$lists = $this->sys_area_model->select(array('county_id' => $pid, 'status' => 1));
|
|
$data[] = array('name' => '商圈', 'value' => '');
|
|
foreach ($lists as $value) {
|
|
$data[] = array('name' => $value['name'], 'id' => $value['id']);
|
|
}
|
|
|
|
$this->data = $data;
|
|
$this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
/**
|
|
* 获取小区价格
|
|
* @return bool
|
|
*/
|
|
public function vill_price()
|
|
{
|
|
$village = $this->input->post('village');//小区
|
|
$county = $this->input->post('county');//县区
|
|
$city = $this->input->post('city');//城市
|
|
$square = $this->input->post('square');//面积
|
|
|
|
if (!$village) {
|
|
return $this->show_json(SYS_CODE_FAIL, '小区不能为空');
|
|
}
|
|
|
|
if ("小区" == substr($village, -(strlen("小区")))) {
|
|
$village = substr($village, 0, strlen($village) - strlen('小区'));
|
|
}
|
|
|
|
$url = "https://open.xiaoyu.com/v2/es/comm?query={$village}";
|
|
$res = file_get_contents($url);
|
|
// $ch = curl_init($url);
|
|
// curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
|
|
// //关闭https验证
|
|
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
// curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
|
// $res = curl_exec($ch);
|
|
$ret = json_decode($res, true);
|
|
if (!$ret['data']) {
|
|
return $this->show_json(SYS_CODE_FAIL, '暂无报价');
|
|
}
|
|
|
|
$aprice = $ret['data'][0]['_source']['price'];
|
|
if (!$aprice) {
|
|
return $this->show_json(SYS_CODE_FAIL, '暂无报价');
|
|
}
|
|
|
|
$this->data = $aprice;
|
|
|
|
return $this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
##todo
|
|
//获取行业分类
|
|
public function category()
|
|
{
|
|
$pid = intval($this->input->post('pid'));
|
|
if (!$pid) {
|
|
$pid = intval($this->input->get('pid'));
|
|
}
|
|
$this->load->model("sys/sys_category_model");
|
|
$pid != '' && $lists = $this->sys_category_model->select(array('pid' => $pid, 'status' => 1));
|
|
|
|
$data = array();
|
|
if ($lists) {
|
|
foreach ($lists as $value) {
|
|
$data[] = array('name' => $value['name'], 'value' => $value['id']);
|
|
}
|
|
}
|
|
$this->data = $data;
|
|
|
|
return $this->show_json(SYS_CODE_SUCCESS);
|
|
|
|
}
|
|
|
|
//获取品牌
|
|
public function brand()
|
|
{
|
|
$cate_id = intval($this->input->post('cate_id'));
|
|
if (!$cate_id) {
|
|
$cate_id = intval($this->input->get('cate_id'));
|
|
}
|
|
|
|
$this->load->model('biz/biz_brand_model');
|
|
//获取品牌行业
|
|
$cate_id && $lists = $this->biz_brand_model->selectBrand(array('cate_id' => $cate_id, 'status' => 1));
|
|
|
|
$data = array();
|
|
if ($lists) {
|
|
foreach ($lists as $value) {
|
|
$data[] = array('name' => $value['brand_name'], 'id' => $value['id']);
|
|
}
|
|
}
|
|
$this->data = $data;
|
|
|
|
return $this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
//获取标签
|
|
public function tags()
|
|
{
|
|
$list = array();
|
|
|
|
|
|
$this->load->model("sys/sys_tag_model");
|
|
$rows = $this->sys_tag_model->select($where);
|
|
if ($rows) {
|
|
foreach ($rows as $v) {
|
|
$v['tag_id'] = $v['id'];
|
|
$v['tag_name'] = $v['tag_name'];
|
|
$list[] = $v;
|
|
}
|
|
}
|
|
|
|
$this->data = $list;
|
|
return $this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
/**
|
|
* Notes:获取管理员
|
|
* Created on: 2020/5/20 16:35
|
|
* Created by: dengbw
|
|
* @return bool
|
|
*/
|
|
public function admin_app()
|
|
{
|
|
$this->load->model('sys/Sys_admin_model', 'mdSysAdmin');
|
|
$page = $this->input->post('page') ? intval($this->input->post('page')) : 1;
|
|
$size = $this->input->post('size') ? intval($this->input->post('size')) : 10;
|
|
$name = $this->input->post('name');
|
|
$role_id = $this->input->post('role_id');
|
|
$ids = $this->input->post('ids');
|
|
$where['status'] = 1;
|
|
$name && $where['username like "%' . $name . '%"'] = null;
|
|
$role_id && $where['role_id in (' . $role_id . ')'] = null;
|
|
$ids && $where['id in (' . $ids . ')'] = null;
|
|
$count = $this->mdSysAdmin->count($where);
|
|
$list = array();
|
|
if ($count) {
|
|
$list = $this->mdSysAdmin->select($where, 'id DESC', $page, $size, 'id,username as name');
|
|
}
|
|
$this->data['commonList'] = $list;
|
|
$hasNext = ceil($count / $size) > $page ? 1 : 0;
|
|
$this->data['commonPage'] = array('page' => $page, 'pageLimit' => $size, 'pageCount' => $count, 'hasNext' => $hasNext);
|
|
return $this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
/**
|
|
* 获取基础用户信息列表
|
|
*/
|
|
function hduser()
|
|
{
|
|
$mobile = $this->input->post('mobile');
|
|
$where = array('status' => 1);
|
|
$mobile && $where['mobile'] = $mobile;
|
|
$this->load->model('user/user_model');
|
|
$this->data = $list = $this->user_model->get($where);
|
|
|
|
$this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
function hdusers()
|
|
{
|
|
$keyword = $this->input->get('keyword');
|
|
$page = $this->input->get('page');
|
|
$size = $this->input->get('size');
|
|
!$page && $page = 1;
|
|
!$size && $size = 20;
|
|
|
|
$this->load->model('user/user_model');
|
|
|
|
$where = array('status' => 1);
|
|
if (is_numeric($keyword)) {
|
|
$where["(uname LIKE '%{$keyword}%' OR mobile LIKE '%{$keyword}%')"] = null;
|
|
} elseif ($keyword) {
|
|
$where["(uname LIKE '%{$keyword}%')"] = null;
|
|
}
|
|
|
|
$total = $this->user_model->count($where);
|
|
$rows = array();
|
|
if ($total) {
|
|
$select = 'uid, uname, mobile';
|
|
$rows = $this->user_model->select($where, 'uid DESC', $page, $size, $select);
|
|
}
|
|
|
|
$this->data = array('total' => $total, 'list' => $rows);
|
|
|
|
$this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
/**
|
|
* 获取应用用户列表
|
|
*/
|
|
function appusers()
|
|
{
|
|
$nickey = $this->input->get('nickey');
|
|
$is_nick = $this->input->get('is_nick');//昵称不为空
|
|
$app_id = $this->input->get('app_id');
|
|
$page = $this->input->get('page');
|
|
$size = $this->input->get('size');
|
|
$keyword = $this->input->get('keyword');
|
|
|
|
!$page && $page = 1;
|
|
!$size && $size = 20;
|
|
|
|
if (!$app_id) {
|
|
$this->data = array();
|
|
$this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
$this->load->library('entity/user_entity');
|
|
|
|
$where = array();
|
|
if (strlen($nickey) > 0) {
|
|
$where['nickname like'] = "%{$nickey}%";
|
|
} elseif ($is_nick) {//nickname不为空
|
|
$where['nickname <>'] = "";
|
|
}
|
|
if (is_numeric($keyword)) {
|
|
$where["(nickname LIKE '%{$keyword}%' OR mobile LIKE '%{$keyword}%')"] = null;
|
|
} else {
|
|
$where["(nickname LIKE '%{$keyword}%')"] = null;
|
|
}
|
|
|
|
$user_entity = new User_entity($app_id);
|
|
$select = 'id, nickname, mobile';
|
|
$total = $user_entity->count($where);
|
|
$rows = array();
|
|
if ($total) {
|
|
$rows = $user_entity->select($where, 'id DESC', $page, $size, $select);
|
|
}
|
|
|
|
$this->data = array('total' => $total, 'list' => $rows);
|
|
|
|
$this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
/**
|
|
* Notes:获取小程序
|
|
* Created on: 2020/3/23 15:02
|
|
* Created by: dengbw
|
|
* @return array
|
|
*/
|
|
public function app_list()
|
|
{
|
|
$this->load->model('app/App_model', 'mdApp');
|
|
$app_id = intval($this->input->post('app_id'));
|
|
$type = intval($this->input->post('type'));
|
|
if ($app_id) {
|
|
$appList[] = $this->mdApp->get(array("id" => $app_id), 'id,name');
|
|
} else {
|
|
!$type && $appList[] = array("id" => "0", "name" => "选择小程序");
|
|
$resApp = $this->mdApp->select('', 'id DESC', 0, 0, 'id,name');
|
|
if ($resApp) {
|
|
foreach ($resApp as $key => $value) {
|
|
$setValue = array();
|
|
$setValue['id'] = $value['id'];
|
|
$setValue['name'] = $value['name'];
|
|
$appList[$value['id']] = $setValue;
|
|
}
|
|
}
|
|
}
|
|
return $appList;
|
|
}
|
|
|
|
/**
|
|
* Notes:获取小程序分类
|
|
* Created on: 2020/3/11 11:07
|
|
* Created by: dengbw
|
|
* @return array
|
|
*/
|
|
public function category_app()
|
|
{
|
|
$app_id = intval($this->input->post('app_id'));
|
|
$pid = intval($this->input->post('pid'));
|
|
$type = intval($this->input->post('type'));
|
|
$name = $this->input->post('name');
|
|
|
|
!$app_id && $app_id = intval($this->input->get('app_id'));
|
|
!$pid && $pid = intval($this->input->get('pid'));
|
|
!$type && $type = intval($this->input->get('type'));
|
|
$lists = array();
|
|
$is_cate = 0;
|
|
if ($app_id) {
|
|
$this->load->model('app/app_model', 'mdApp');
|
|
$resApp = $this->mdApp->get(array('id' => $app_id));
|
|
if ($resApp) {
|
|
$jsondata = json_decode($resApp['jsondata'], true);
|
|
$is_cate = $jsondata['biz_cate'] ? 1 : 0;
|
|
}
|
|
}
|
|
if ($is_cate) {
|
|
//自定义分类
|
|
$this->load->model('app/appusual/App_category_model', 'mdAppCate');
|
|
$res = $this->mdAppCate->select(array('app_id' => $app_id, 'pid' => $pid, 'status' => 1), 'sort desc');
|
|
} else {
|
|
//系统定义分类
|
|
$this->load->model("sys/sys_category_model", 'mdSysCate');
|
|
$res = $this->mdSysCate->select(array('pid' => $pid, 'status' => 1));
|
|
}
|
|
if ($type) {
|
|
$type == 1 && $lists[] = array('id' => 0, 'name' => $name ? $name : '二级分类');
|
|
$type == 2 && $lists[] = array('id' => 0, 'name' => $name ? $name : '三级分类');
|
|
if (!$pid) {
|
|
$this->data = $lists;
|
|
return $this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
} else {
|
|
!$pid && $lists[] = array('id' => 0, 'name' => $name ? $name : '一级分类');
|
|
}
|
|
if ($res) {
|
|
foreach ($res as $value) {
|
|
$lists[] = array('id' => $value['id'], 'name' => $value['name']);
|
|
}
|
|
}
|
|
$this->data = $lists;
|
|
return $this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
/**
|
|
* Notes:选择门店
|
|
* Created on: 2020/3/12 14:15
|
|
* Created by: dengbw
|
|
* @return bool
|
|
*/
|
|
public function shop_app()
|
|
{
|
|
$this->load->model('biz/biz_model', 'mdBiz');
|
|
$page = $this->input->post('page') ? intval($this->input->post('page')) : 1;
|
|
$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'));
|
|
$biz_name = $this->input->post('name');
|
|
$shopChecked = $shopList = $resBiz = array();
|
|
$ids = $this->input->post('ids');
|
|
if ($use_shop_list) {
|
|
foreach ($use_shop_list as $key => $value) {
|
|
$shopChecked[$value['id']] = $value['id'];
|
|
}
|
|
}
|
|
$where['status'] = 1;
|
|
$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;
|
|
$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->select($where, 'id desc', $page, $size);
|
|
foreach ($resBiz as $key => $value) {
|
|
$setValue = array();
|
|
$setValue['id'] = $value['id'];
|
|
$setValue['name'] = $value['biz_name'];
|
|
$img = $value['headimg'] ? $value['headimg'] : $value['cover'];
|
|
$setValue['img'] = $img ? build_qiniu_image_url($img) : '';
|
|
$setValue['sort'] = $key;
|
|
$setValue['is_checked'] = $shopChecked[$value['id']] ? 1 : 0;
|
|
$setValue['brand_id'] = $value['brand_id'];
|
|
$shopList[] = $setValue;
|
|
}
|
|
}
|
|
$this->data['shopList'] = $shopList;
|
|
$hasNext = ceil($count / $size) > $page ? 1 : 0;
|
|
$this->data['shopPage'] = array('page' => $page, 'pageLimit' => $size, 'pageCount' => $count, 'hasNext' => $hasNext);
|
|
return $this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
/**
|
|
* Notes:选择合作门店
|
|
* Created on: 2020/5/18 15:33
|
|
* Created by: dengbw
|
|
*/
|
|
public function cooperation_shop_app()
|
|
{
|
|
$this->load->model('app/App_model', 'appM');
|
|
$this->load->model('sys/Sys_category_model', 'sysCate');
|
|
$this->load->model('app/appusual/App_category_model', 'appCate');
|
|
$params = $this->input->post();
|
|
$params['page'] = $this->input->post('page') ? intval($this->input->post('page')) : 1;
|
|
$params['size'] = $this->input->post('size') ? intval($this->input->post('size')) : 10;
|
|
$data = $this->appM->get(array('id' => $params['app_id']));
|
|
$jsondata = json_decode($data['jsondata'], true);
|
|
$is_cate = $jsondata['biz_cate'] ? $jsondata['biz_cate'] : '0';
|
|
|
|
$where = 'hd_app_biz_cate.app_id = ' . $params['app_id'];
|
|
$params['name'] && $where .= ' AND biz_name like "%' . trim($params['name']) . '%" ';
|
|
if ($params['cate_id']) {
|
|
if ($is_cate) {
|
|
$ids = $this->appCate->select(array('pid' => $params['cate_id'], 'status' => 1), 'sort desc');
|
|
} else {
|
|
$ids = $this->sysCate->select(array('pid' => $params['cate_id'], 'status' => 1));
|
|
}
|
|
$ids = $ids ? array_column($ids, 'id') : array();
|
|
$ids[] = $params['cate_id'];//加上大类
|
|
$ids && $ids = implode(',', $ids);
|
|
$where .= " AND cate_id in ({$ids})";
|
|
}
|
|
if ($params['biz_ids']) {
|
|
$biz_ids = implode(',', $params['biz_ids']);
|
|
$where .= " AND hd_biz.id not in ({$biz_ids})";
|
|
}
|
|
$count = $this->db->select('hd_biz.id')
|
|
->join('hd_biz', 'hd_biz.id = hd_app_biz_cate.biz_id', 'left')
|
|
->where($where)
|
|
->count_all_results('hd_app_biz_cate');
|
|
$lists = array();
|
|
if ($count) {
|
|
if ($is_cate) { //自定义分类
|
|
$lists = $this->db->query(
|
|
'SELECT tmp.* FROM hd_biz INNER JOIN(SELECT hd_biz.id,hd_biz.biz_name as name FROM hd_app_biz_cate ' .
|
|
'LEFT JOIN hd_biz ON hd_biz.id = hd_app_biz_cate.biz_id ' .
|
|
'LEFT JOIN hd_app_category ON hd_app_category.id = hd_app_biz_cate.cate_id ' .
|
|
'WHERE ' . $where . ' ORDER BY top desc,hd_app_biz_cate.id desc LIMIT ' . ($params['page'] - 1)
|
|
* $params['size'] . ',' . $params['size'] . ') as tmp ON tmp.id = hd_biz.id'
|
|
)->result_array();
|
|
} else {//系统定义分类
|
|
$lists = $this->db->query(
|
|
'SELECT tmp.* FROM hd_biz INNER JOIN(SELECT SELECT hd_biz.id,hd_biz.biz_name as name FROM hd_app_biz_cate ' .
|
|
'LEFT JOIN hd_biz ON hd_biz.id = hd_app_biz_cate.biz_id ' .
|
|
'LEFT JOIN hd_sys_category ON hd_sys_category.id = hd_app_biz_cate.sys_id AND hd_sys_category.pid = 0 ' .
|
|
'WHERE ' . $where . ' ORDER BY top desc LIMIT ' . ($params['page'] - 1) * $params['size'] . ',' .
|
|
$params['size'] . ') as tmp ON tmp.id = hd_biz.id'
|
|
)->result_array();
|
|
}
|
|
}
|
|
$this->data['shopList'] = $lists;
|
|
$hasNext = ceil($count / $params['size']) > $params['page'] ? 1 : 0;
|
|
$this->data['shopPage'] = array('page' => $params['page'], 'pageLimit' => $params['size'], 'pageCount' => $count, 'hasNext' => $hasNext);
|
|
return $this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
/**
|
|
* Notes:选择品牌
|
|
* Created on: 2020/3/12 14:15
|
|
* Created by: dengbw
|
|
* @return bool
|
|
*/
|
|
public function brand_app()
|
|
{
|
|
$this->load->model("biz/biz_brand_model", 'mdBrand');
|
|
$page = $this->input->post('page') ? intval($this->input->post('page')) : 1;
|
|
$size = $this->input->post('size') ? intval($this->input->post('size')) : 10;
|
|
$type = $this->input->post('type');
|
|
|
|
$sys_cate_id = intval($this->input->post('sys_cate_id'));
|
|
$brand_name = $this->input->post('name');
|
|
$ids = $this->input->post('ids');
|
|
$shopList = $resBiz = array();
|
|
$where['status'] = 1;
|
|
$sys_cate_id && $where['cate_id'] = $sys_cate_id;
|
|
$brand_name && $where['brand_name like "%' . $brand_name . '%"'] = null;
|
|
$ids && $where['hd_biz_brand.id not in (' . $ids . ')'] = null;
|
|
if ($type == 'jdb') {
|
|
$this->load->model('app/jdb/receiver_orders_model', 'mdReceiverOrders');
|
|
}
|
|
$count = $this->mdBrand->selectBrand($where, '', '', '', 1, $type);
|
|
if ($count) {
|
|
$res = $this->mdBrand->selectBrand($where, 'id desc', $page, $size, 0, $type);
|
|
foreach ($res as $key => $value) {
|
|
$setValue = array();
|
|
$setValue['id'] = $value['id'];
|
|
$setValue['name'] = $value['brand_name'];
|
|
$setValue['img'] = $value['brand_logo'] ? build_qiniu_image_url($value['brand_logo']) : '';
|
|
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), 'brand_id' => $value['id'], 'biz_id' => 0));
|
|
$setValue['orders'] = $this->mdReceiverOrders->count(array('brand_id' => $value['id'], 'biz_id' => 0));
|
|
}
|
|
$shopList[] = $setValue;
|
|
}
|
|
}
|
|
$this->data['shopList'] = $shopList;
|
|
$hasNext = ceil($count / $size) > $page ? 1 : 0;
|
|
$this->data['shopPage'] = array('page' => $page, 'pageLimit' => $size, 'pageCount' => $count, 'hasNext' => $hasNext);
|
|
return $this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
/**
|
|
* Notes:接单宝-商户池
|
|
* Created on: 2020/8/24 14:43
|
|
* Created by: dengbw
|
|
*/
|
|
public function receiver_biz_app()
|
|
{
|
|
$this->load->model('app/jdb/receiver_biz_model', 'mdReceiverBiz');
|
|
$this->load->model('app/jdb/receiver_orders_model', 'mdReceiverOrders');
|
|
$this->load->model('app/jdb/receiver_biz_contract_model', 'mdReceiverBizContract');
|
|
$this->load->model("biz/biz_brand_model", 'mdBrand');
|
|
$this->load->model("biz/biz_model", 'mdBiz');
|
|
$this->load->model('app/jdb/receiver_cfrom_model', 'mdReceiverCfrom');
|
|
$params = $this->input->post();
|
|
$params['page'] = $params['page'] ? intval($params['page']) : 1;
|
|
$params['size'] = $params['size'] ? intval($params['size']) : 10;
|
|
$params['type'] = intval($params['type']);
|
|
$params['rid'] = intval($params['rid']);
|
|
$params['cf_id'] = intval($params['cf_id']);
|
|
$params['if_orders'] = intval($params['if_orders']);//1显示单数
|
|
$ids = $this->input->post('ids');
|
|
$shopList = $resBiz = array();
|
|
$resNull = true;
|
|
if ($params['if_orders'] == 1) {
|
|
$where = array("r_id" => $params['rid'], "c_status in (1,2)" => null, "p_status" => 1);
|
|
} else {
|
|
$where = array("r_id" => $params['rid']);
|
|
}
|
|
if ($params['type'] == 2) {
|
|
$ids && $where['biz_id not in (' . $ids . ')'] = null;
|
|
$where["biz_id >"] = 0;
|
|
if ($params['name']) {
|
|
$whereBiz['biz_name LIKE "%' . $params['name'] . '%"'] = null;
|
|
$resBiz = $this->mdBiz->select($whereBiz, "id desc", 0, 0, 'id');
|
|
if ($resBiz) {
|
|
$ids = $resBiz ? array_column($resBiz, 'id') : array();
|
|
if ($ids) {
|
|
$ids = implode("','", $ids);
|
|
$where["biz_id in ('" . $ids . "')"] = null;
|
|
$resNull = false;
|
|
}
|
|
}
|
|
if ($resNull) {
|
|
$where['id'] = 0;
|
|
}
|
|
}
|
|
} else {
|
|
$ids && $where['brand_id not in (' . $ids . ')'] = null;
|
|
$where["biz_id"] = 0;
|
|
if ($params['name']) {
|
|
$whereBrand['brand_name LIKE "%' . $params['name'] . '%"'] = null;
|
|
$resBrand = $this->mdBrand->select($whereBrand, "id desc", 0, 0, 'id');
|
|
if ($resBrand) {
|
|
$ids = $resBrand ? array_column($resBrand, 'id') : array();
|
|
if ($ids) {
|
|
$ids = implode("','", $ids);
|
|
$where["brand_id in ('" . $ids . "')"] = null;
|
|
$resNull = false;
|
|
}
|
|
}
|
|
if ($resNull) {
|
|
$where['id'] = 0;
|
|
}
|
|
}
|
|
}
|
|
$count = $this->mdReceiverBiz->count($where);
|
|
if ($count) {
|
|
$cf_name = '';
|
|
if ($params['cf_id']) {
|
|
$reCf = $this->mdReceiverCfrom->get(array('id' => $params['cf_id']));
|
|
$cf_name = $reCf['title'];
|
|
if ($reCf['pid']) {
|
|
$reCf2 = $this->mdReceiverCfrom->get(array('id' => $reCf['pid']));
|
|
$cf_name = $reCf2['title'];
|
|
if ($reCf2['pid']) {
|
|
$reCf3 = $this->mdReceiverCfrom->get(array('id' => $reCf2['pid']));
|
|
$cf_name = $reCf3['title'];
|
|
}
|
|
}
|
|
}
|
|
$res = $this->mdReceiverBiz->select($where, 'id desc', $params['page'], $params['size']);
|
|
foreach ($res as $key => $value) {
|
|
$setValue = array();
|
|
if ($params['type'] == 2) {
|
|
$reBiz = $this->mdBiz->get(array('id' => $value['biz_id']));
|
|
$setValue['id'] = $reBiz['id'];
|
|
$setValue['name'] = $reBiz['biz_name'];
|
|
$setValue['brand_id'] = $reBiz['brand_id'];
|
|
$img = $reBiz['headimg'] ? $reBiz['headimg'] : $reBiz['cover'];
|
|
$setValue['img'] = $img ? build_qiniu_image_url($img) : '';
|
|
} else {
|
|
$reBiz = $this->mdBrand->get(array('id' => $value['brand_id']));
|
|
$setValue['id'] = $reBiz['id'];
|
|
$setValue['name'] = $reBiz['brand_name'];
|
|
$setValue['img'] = $reBiz['brand_logo'] ? build_qiniu_image_url($reBiz['brand_logo']) : '';
|
|
}
|
|
if ($params['if_orders'] == 1) {
|
|
$orders = $orders_month = $orders_sy = $cid = $cid_field = 0;
|
|
if ($value['cid2'] || $value['cid1']) {
|
|
if ($cf_name == '小鱼网') {//小鱼网客户优先派小鱼网合同,然后再派星师傅合同
|
|
if ($value['cid2']) {
|
|
$cid = $value['cid2'];
|
|
$cid_field = 'cid2';
|
|
$orders_sy = $this->ordersSys($cid);
|
|
}
|
|
if ($orders_sy <= 0 && $value['cid1']) {
|
|
$cid = $value['cid1'];
|
|
$cid_field = 'cid1';
|
|
$orders_sy = $this->ordersSys($cid);
|
|
}
|
|
} else if ($value['cid1']) {//星师傅,只派星师傅合同
|
|
$cid = $value['cid1'];
|
|
$cid_field = 'cid1';
|
|
$orders_sy = $this->ordersSys($cid);
|
|
}
|
|
}
|
|
if ($cid) {
|
|
$orders = $this->mdReceiverOrders->count(array('cid' => $cid));
|
|
$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';
|
|
$orders_month = $this->mdReceiverOrders->count(array("c_time >=" => strtotime($firstDay)
|
|
, "c_time <=" => strtotime($lastDay), 'cid' => $cid));
|
|
}
|
|
$setValue['orders'] = $orders;
|
|
$setValue['orders_month'] = $orders_month;
|
|
$setValue['orders_sy'] = $orders_sy;
|
|
$setValue['cid'] = $cid;
|
|
$setValue['cid_field'] = $cid_field;
|
|
}
|
|
$shopList[] = $setValue;
|
|
}
|
|
}
|
|
$this->data['shopList'] = $shopList;
|
|
$hasNext = ceil($count / $params['size']) > $params['page'] ? 1 : 0;
|
|
$this->data['shopPage'] = array('page' => $params['page'], 'pageLimit' => $params['size'], 'pageCount' => $count, 'hasNext' => $hasNext);
|
|
return $this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
/**
|
|
* Notes:合同剩余数
|
|
* Created on: 2020/8/27 10:00
|
|
* Created by: dengbw
|
|
* @param $cid
|
|
* @return mixed
|
|
*/
|
|
private function ordersSys($cid)
|
|
{
|
|
$orders_sy = 0;
|
|
if ($cid) {
|
|
$reBc = $this->mdReceiverBizContract->get(array('id' => $cid));
|
|
$orders_yx = $this->mdReceiverOrders->count(array('cid' => $cid, 'status != -1' => null));
|
|
$orders_sy = $reBc['num'] - $orders_yx;
|
|
}
|
|
return $orders_sy;
|
|
}
|
|
|
|
|
|
/**
|
|
* Notes:选择商品
|
|
* Created on: 2020/3/12 14:33
|
|
* Created by: dengbw
|
|
*/
|
|
public function items_app()
|
|
{
|
|
$this->load->model('appitem/items_model', 'mdItems');
|
|
$page = $this->input->post('page') ? intval($this->input->post('page')) : 1;
|
|
$size = $this->input->post('size') ? intval($this->input->post('size')) : 10;
|
|
|
|
$app_id = intval($this->input->post('app_id'));
|
|
$use_items_list = $this->input->post('use_items_list');
|
|
$title = $this->input->post('title');
|
|
$cate_id = intval($this->input->post('cate_id'));
|
|
$type = intval($this->input->post('type'));
|
|
$item_type = intval($this->input->post('item_type'));//商品类型
|
|
$use_type = $this->input->post('use_type');
|
|
$status = intval($this->input->post('status'));
|
|
$goods_type = intval($this->input->post('goods_type'));
|
|
$itemsChecked = $itemsList = $resItems = array();
|
|
if ($use_items_list) {
|
|
foreach ($use_items_list as $key => $value) {
|
|
$itemsChecked[$value['id']] = $value['id'];
|
|
}
|
|
}
|
|
$where['app_id'] = $app_id;
|
|
$cate_id && $where['cate_id'] = $cate_id;
|
|
$status && $where['status'] = $status;
|
|
$title && $where['title like "%' . $title . '%"'] = null;
|
|
$item_type && $where['type'] = $item_type;
|
|
$where['use_type'] = intval($use_type);
|
|
if ($goods_type == 2) { //选择礼包商品
|
|
$where['use_type'] = 6;
|
|
}
|
|
$count = $this->mdItems->count($where);
|
|
if ($count) {
|
|
if ($type == 1) { //来自抽奖选商品
|
|
$this->load->model('appitem/item_stock_model', 'mdItemStock');
|
|
$resItems = $this->mdItems->select($where, 'id desc', $page, $size, 'id,title,imgs,show_s_time,show_e_time,
|
|
buy_s_time,buy_e_time,use_s_time,use_e_time');
|
|
} else {
|
|
$resItems = $this->mdItems->select($where, 'id desc', $page, $size, 'id,title,imgs,code_type');
|
|
}
|
|
if ($resItems) {
|
|
foreach ($resItems as $key => $value) {
|
|
$setValue = array();
|
|
if ($type == 1) {
|
|
$resStock = $this->mdItemStock->sum('stock', array('item_id' => $value['id']));
|
|
$setValue['stock'] = $resStock['stock'];
|
|
$setValue['goods_id'] = $value['id'];
|
|
$setValue['title'] = $value['title'];
|
|
$setValue['retail_price'] = $this->mdItems->get_sale_price($value['id']);
|
|
$setValue['show_s_time'] = $value['show_s_time'];
|
|
$setValue['show_e_time'] = $value['show_e_time'];
|
|
$setValue['buy_s_time'] = $value['buy_s_time'];
|
|
$setValue['buy_e_time'] = $value['buy_e_time'];
|
|
$setValue['use_s_time'] = $value['use_s_time'];
|
|
$setValue['use_e_time'] = $value['use_e_time'];
|
|
} else {
|
|
$setValue['id'] = $value['id'];
|
|
$setValue['is_checked'] = $itemsChecked[$value['id']] ? 1 : 0;
|
|
$setValue['code_type'] = $value['code_type'];
|
|
}
|
|
$setValue['title'] = $value['title'];
|
|
$setValue['img'] = item_img($value['imgs'], 690, 390);
|
|
$itemsList[] = $setValue;
|
|
}
|
|
}
|
|
}
|
|
$this->data['itemsList'] = $itemsList;
|
|
$hasNext = ceil($count / $size) > $page ? 1 : 0;
|
|
$this->data['itemsPage'] = array('page' => $page, 'pageLimit' => $size, 'pageCount' => $count, 'hasNext' => $hasNext);
|
|
return $this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
/**
|
|
* Notes:选择优惠券
|
|
* Created on: 2020/5/12 14:33
|
|
* Created by: dengbw
|
|
*/
|
|
public function coupon_app()
|
|
{
|
|
$this->load->model('vipcard/Vipcard_coupon_model', 'mdCoupon');
|
|
$this->load->model('biz/biz_brand_model', 'mdBizBrand');
|
|
|
|
$page = $this->input->post('page') ? intval($this->input->post('page')) : 1;
|
|
$size = $this->input->post('size') ? intval($this->input->post('size')) : 10;
|
|
|
|
$app_id = intval($this->input->post('app_id'));
|
|
$title = $this->input->post('title');
|
|
$status = intval($this->input->post('status'));
|
|
$brand_id = intval($this->input->post('brand_id'));
|
|
$where = $list = array();
|
|
$where['use_limit'] = 1;//券是线下使用的
|
|
|
|
$app_id && $where['app_id'] = $app_id;
|
|
$status && $where['status'] = $status;
|
|
$title && $where['title like "%' . $title . '%"'] = null;
|
|
$brand_id && $where['brand_id'] = $brand_id;
|
|
$count = $this->mdCoupon->count($where);
|
|
if ($count) {
|
|
$res = $this->mdCoupon->select($where, 'id desc', $page, $size, 'id,title,stock,ls_time,le_time,us_time
|
|
,ue_time,jsondata,type,brand_id');
|
|
if ($res) {
|
|
foreach ($res as $key => $value) {
|
|
$setValue = array();
|
|
$title = $value['title'];
|
|
//获取品牌
|
|
if ($value['brand_id']) {
|
|
$brand = $this->mdBizBrand->get(array('id' => $value['brand_id']), 'brand_name');
|
|
$brand && $title = $brand['brand_name'] . $title;
|
|
}
|
|
$setValue['id'] = $value['id'];
|
|
$setValue['title'] = $title;
|
|
$setValue['stock'] = $value['stock'];
|
|
$json = json_decode($value['jsondata'], true);
|
|
if (2 == $value['type']) {
|
|
$limit_way = $json['limit_way'] == 2 ? "满{$json['limit_price']}可用" : '不限制';
|
|
$limit_way .= $json['price_way'] == 1 ? ",抵用{$json['price']}元" : ",{$json['discount']}折";
|
|
} else {
|
|
$limit_way = $json['biz_type'] == '0' ? '全场通用' : '部份商家可用';
|
|
}
|
|
$setValue['limit_way'] = $limit_way;
|
|
$setValue['ls_time'] = date('Y-m-d H:i:s', $value['ls_time']);
|
|
$setValue['le_time'] = date('Y-m-d H:i:s', $value['le_time']);
|
|
$setValue['us_time'] = date('Y-m-d H:i:s', $value['us_time']);
|
|
$setValue['ue_time'] = date('Y-m-d H:i:s', $value['ue_time']);
|
|
$list[] = $setValue;
|
|
}
|
|
}
|
|
}
|
|
$this->data['couponList'] = $list;
|
|
$hasNext = ceil($count / $size) > $page ? 1 : 0;
|
|
$this->data['couponPage'] = array('page' => $page, 'pageLimit' => $size, 'pageCount' => $count, 'hasNext' => $hasNext);
|
|
return $this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
/**
|
|
* Notes:获取小程序用户列表
|
|
* Created on: 2020/4/17 14:15
|
|
* Created by: dengbw
|
|
* @return bool
|
|
*/
|
|
public function users_app()
|
|
{
|
|
$page = $this->input->post('page') ? intval($this->input->post('page')) : 1;
|
|
$size = $this->input->post('size') ? intval($this->input->post('size')) : 10;
|
|
$group_id = intval($this->input->post('group_id'));
|
|
$app_id = intval($this->input->post('app_id'));
|
|
$nickname = $this->input->post('nickname');
|
|
$where['status'] = 1;
|
|
if ($nickname) {
|
|
$where['nickname like "%' . $nickname . '%"'] = null;
|
|
} else {
|
|
$where["nickname !=''"] = null;
|
|
}
|
|
$group_id && $where["group_id >="] = $group_id;
|
|
$count = 0;
|
|
$list = array();
|
|
if ($app_id) {
|
|
$this->load->service("app/user_service", array("app_id" => $app_id));
|
|
$count = $this->user_service->count($where);
|
|
if ($count) {
|
|
$list = $this->user_service->select($where, "id desc", $page, $size, 'id, nickname');
|
|
}
|
|
}
|
|
$this->data['usersList'] = $list;
|
|
$hasNext = ceil($count / $size) > $page ? 1 : 0;
|
|
$this->data['usersPage'] = array('page' => $page, 'pageLimit' => $size, 'pageCount' => $count, 'hasNext' => $hasNext);
|
|
return $this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
/**
|
|
* Notes:获取接单宝状态
|
|
* Created on: 2020/3/27 14:28
|
|
* Created by: dengbw
|
|
*/
|
|
public function receiver_status()
|
|
{
|
|
$this->load->model('app/jdb/receiver_status_model', 'mdReceiverStatus');
|
|
$rid = intval($this->input->post('rid'));
|
|
$pid = intval($this->input->post('pid'));
|
|
$type = intval($this->input->post('type'));
|
|
$res = $this->mdReceiverStatus->select(array("rid" => $rid, "pid" => $pid, "type" => $type, "status" => 1)
|
|
, 'sort ASC,id ASC', 0, 0, 'id,sname as name');
|
|
$this->data = $res;
|
|
return $this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
/**
|
|
* Notes:分享连接
|
|
* Created on: 2020/1/20 16:56
|
|
* Created by: dengbw
|
|
*/
|
|
public function share_link()
|
|
{
|
|
$this->load->model('app/app_model', 'mdApp');
|
|
$app_id = $this->input->get('app_id');
|
|
$scene = $this->input->get('id');
|
|
$pages = $this->input->get('pages');
|
|
$pages = 'pages_' . $pages;
|
|
$wxconfig = $this->mdApp->appConfig()[$app_id]['wx'];
|
|
if (is_array($wxconfig[$pages])) {
|
|
$page = $wxconfig[$pages]['pages'];
|
|
$id = $wxconfig[$pages]['id'];
|
|
} else {
|
|
$page = $wxconfig[$pages];
|
|
$id = 'id';
|
|
}
|
|
$openlink = '';
|
|
if ($wxconfig && $page) {
|
|
$width = '850px';
|
|
$path = "{$page}?{$scene}";
|
|
$width && $path .= "{$width}";
|
|
$filename = "{$this->mdApp->appConfig()[$app_id]['app_key']}/" . substr(md5($path), 8, 16);
|
|
$this->load->library('hdwechat', $wxconfig);
|
|
$result = $this->hdwechat->qrcode($filename, $scene, $page, $width);
|
|
if ($result) {
|
|
if (false !== strpos($_SERVER['HTTP_HOST'], 'dev')) { //dev 测试
|
|
$base_url = 'https://hd-api-dev.xiaoyu.com/';
|
|
} elseif (false !== strpos($_SERVER['HTTP_HOST'], 'test')) {//test 测试
|
|
$base_url = 'https://api.test.haodian.cn/';
|
|
} else { // 正式
|
|
$base_url = 'https://api.haodian.cn/';
|
|
}
|
|
$this->data['qrcode'] = $base_url . $result['url'];
|
|
}
|
|
// $scene = 82;
|
|
// $url_params = array('path' => '/' . $page, 'query' => 'id=' . $scene . '&form=auth&_um_campaign=604823e96ee47d382b7a2b79&_um_channel=604823e96ee47d382b7a2b7a',
|
|
// 'is_expire' => false, 'expire_time' => strtotime('+30 day'));
|
|
// $result2 = $this->hdwechat->urlscheme($url_params);
|
|
// $openlink= $result2['openlink'] ? $result2['openlink'] : '';
|
|
}
|
|
$this->data['page'] = $page . '?' . $id . '=' . $scene;
|
|
$this->data['openlink'] = $openlink;
|
|
$this->show_view('common/share_link');
|
|
}
|
|
|
|
public function get_qrcode()
|
|
{
|
|
$url = $this->input->get('url');
|
|
if ($url) {
|
|
require_once COMMPATH . 'third_party/phpqrcode/phpqrcode.php';
|
|
$errorCorrectionLevel = 'L'; //容错级别
|
|
$matrixPointSize = 5; //生成图片大小
|
|
//生成二维码图片
|
|
QRcode::png($url, false, $errorCorrectionLevel, $matrixPointSize, 1);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Notes:分享二维码
|
|
* Created on: 2020/11/2 15:37
|
|
* Created by: dengbw
|
|
*/
|
|
public function share_qrcode()
|
|
{
|
|
$url = $this->input->get('url');
|
|
$this->data['qrcode'] = '/common/get_qrcode?url=' . $url;
|
|
$this->data['page'] = $url;
|
|
$this->show_view('common/share_link');
|
|
}
|
|
|
|
/**
|
|
* Notes:生成公众号二维码
|
|
* Created on: 2020/6/16 14:17
|
|
* Created by: dengbw
|
|
*/
|
|
public function kzh_qrcode()
|
|
{
|
|
$type = intval($this->input->get('type'));
|
|
$act_type = intval($this->input->get('act_type'));
|
|
$this->load->library('HdyServer');
|
|
$hdy = new HdyServer();
|
|
$result = $hdy->get_qrurl(array("act_type" => $act_type, "type" => $type, "uid" => $this->uid));
|
|
$this->data['qrcode'] = $result['qrcode'];
|
|
$this->data['mobile'] = $result['mobile'];
|
|
$this->show_view('common/kzh_qrcode');
|
|
}
|
|
|
|
/**
|
|
* Notes:发送短信页面
|
|
* Created on: 2020/3/31 15:00
|
|
* Created by: dengbw
|
|
*/
|
|
public function show_sms()
|
|
{
|
|
$type = $this->input->get('type');
|
|
$id = intval($this->input->get('id'));
|
|
if (!$id || !$type) {
|
|
return $this->show_json(SYS_CODE_FAIL, '参数错误!');
|
|
}
|
|
if ($type == 'clues') {
|
|
$this->load->model('receiver/receiver_clues_model', 'mdClues');
|
|
$re = $this->mdClues->get(array('id' => $id));
|
|
} else if ($type == 'customer') {
|
|
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
|
|
$re = $this->mdCustomers->get(array('id' => $id));
|
|
}
|
|
if (!$re['mobile']) {
|
|
return $this->show_json(SYS_CODE_FAIL, '客户不存在!');
|
|
}
|
|
$mobile = $re['mobile'];
|
|
$content = '';
|
|
$mobile_edit = 0;
|
|
$mobile_sub = $mobile ? substr_replace($mobile, '*****', 0, 5) : '';
|
|
$this->data['mobile_sub'] = $mobile_sub;
|
|
$this->data['mobile_edit'] = $mobile_edit;
|
|
$this->data['id'] = $id;
|
|
$this->data['type'] = $type;
|
|
$this->data['content'] = $content;
|
|
$this->data['url'] = '/common/send_sms';
|
|
$this->show_view('common/show_sms');
|
|
}
|
|
|
|
/**
|
|
* Notes:发送短信
|
|
* Created on: 2020/3/31 15:05
|
|
* Created by: dengbw
|
|
* @return bool
|
|
*/
|
|
public function send_sms()
|
|
{
|
|
$content = $this->input->post('content');
|
|
$type = $this->input->post('type');
|
|
$id = intval($this->input->post('id'));
|
|
if ($type == 'clues') {
|
|
$this->load->model('receiver/receiver_clues_model', 'mdClues');
|
|
$re = $this->mdClues->get(array('id' => $id));
|
|
} else if ($type == 'customer') {
|
|
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
|
|
$re = $this->mdCustomers->get(array('id' => $id));
|
|
}
|
|
if (!$re['mobile']) {
|
|
return $this->show_json(SYS_CODE_FAIL, '客户不存在!');
|
|
}
|
|
$mobile = $re['mobile'];
|
|
if (!$content) {
|
|
return $this->show_json(SYS_CODE_FAIL, '请输入短信内容');
|
|
}
|
|
if (!strstr($mobile, ',') && !mobile_valid($mobile)) {
|
|
return $this->show_json(SYS_CODE_FAIL, '请填写正确手机号');
|
|
}
|
|
if (mb_strlen($content) > 300) {
|
|
return $this->show_json(SYS_CODE_FAIL, '短信最多300个字');
|
|
}
|
|
$content = '【狸车】' . $content;
|
|
$plaintext = '';
|
|
if (strstr($mobile, ',')) { //多个手机号
|
|
$mobiles = explode(',', $mobile);
|
|
foreach ($mobiles as $key => $value) {
|
|
if (mobile_valid($value)) {
|
|
$result = b2m_send_sms($value, $content);
|
|
$plaintext = $plaintext ? $plaintext . ',' . $result : $result;
|
|
}
|
|
}
|
|
} else {
|
|
$plaintext = b2m_send_sms($mobile, $content);
|
|
}
|
|
$this->data['mobile'] = $mobile;
|
|
$this->data['content'] = $content;
|
|
$this->data['result'] = $plaintext;
|
|
if ($plaintext) {
|
|
if ($id) {
|
|
$data = array(
|
|
'uid' => $this->uid,
|
|
'uname' => $this->username,
|
|
'type' => 1,
|
|
'log' => $content,
|
|
'c_time' => time()
|
|
);
|
|
if ($type == 'clues') {
|
|
$this->load->model('receiver/receiver_clue_oplogs_model', 'mdOplogs');
|
|
$data['clue_id'] = $id;
|
|
} else if ($type == 'customer') {
|
|
$this->load->model('receiver/receiver_customer_oplogs_model', 'mdOplogs');
|
|
$data['customer_id'] = $id;
|
|
}
|
|
$this->mdOplogs->add($data);//增加操作记录
|
|
}
|
|
return $this->show_json(SYS_CODE_SUCCESS, '发送短信成功');
|
|
} else {
|
|
return $this->show_json(SYS_CODE_FAIL, '发送短信失败');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Notes:绑定晓致虚似号手机
|
|
* Created on: 2021/7/28 11:17
|
|
* Created by: dengbw
|
|
* @return bool
|
|
*/
|
|
public function bind_mobile()
|
|
{
|
|
$params = $this->input->get();
|
|
$id = intval($params['id']);
|
|
$type = $params['type'];
|
|
if (!$id || !$type) {
|
|
return $this->show_json(SYS_CODE_FAIL, '参数错误!');
|
|
}
|
|
$this->load->model('receiver/receiver_xz_model', 'mdReceiverXz');
|
|
if ($type == 'clues') {
|
|
$this->load->model('receiver/receiver_clues_model', 'mdClues');
|
|
$re = $this->mdClues->get(array('id' => $id));
|
|
} else if ($type == 'customer') {
|
|
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
|
|
$re = $this->mdCustomers->get(array('id' => $id));
|
|
}
|
|
if (!$re['mobile']) {
|
|
return $this->show_json(SYS_CODE_FAIL, '客户不存在!');
|
|
}
|
|
$mobile = $re['mobile'];
|
|
$cache = &load_cache('redis');
|
|
$xz_admin_phone = $cache->get('xz_admin_phone');
|
|
$middleNumber = '';
|
|
if ($xz_admin_phone) {
|
|
$middleNumber = $xz_admin_phone['admins'][$this->uid];
|
|
}
|
|
if (!$middleNumber) {
|
|
return $this->show_json(SYS_CODE_FAIL, '还未分配号码不可使用');
|
|
}
|
|
$this->load->helper('order');
|
|
$seq_id = create_order_no();
|
|
require_once COMMPATH . 'third_party/Xcall/Xcall.php';
|
|
|
|
$this->config->load('xcall');
|
|
$init_config = [
|
|
'app_id' => $this->config->item('app_id'),
|
|
'app_key' => $this->config->item('app_key'),
|
|
];
|
|
$xcall = new Xcall($init_config);
|
|
$result = $xcall->SWbind($mobile, $seq_id, $middleNumber);
|
|
if ($result['t_code'] == '-26') {//已经绑定解绑
|
|
$s_res = $xcall->Searchbind($middleNumber);
|
|
$bined_mobile = $s_res['data']['value'];//已绑定手机号
|
|
if ($bined_mobile) {
|
|
$xcall->SWunbind($bined_mobile, $middleNumber);//解绑
|
|
$result = $xcall->SWbind($mobile, $seq_id, $middleNumber);
|
|
}
|
|
}
|
|
if ($result['code']) {
|
|
$this->data['middlenumber'] = $result['data']['virtualMobile'];
|
|
$add_data = [
|
|
'call_id' => $seq_id,
|
|
'display_number' => $result['data']['virtualMobile'],
|
|
'cf_id' => $id,
|
|
'cf_uid' => $this->uid,
|
|
'cf_title' => $type,
|
|
'cf_platform' => 'admin',
|
|
'c_time' => time()
|
|
];
|
|
$this->mdReceiverXz->add($add_data);
|
|
} else {
|
|
return $this->show_json(SYS_CODE_FAIL, $result['msg']);
|
|
}
|
|
$this->data['mobile_sub'] = substr_replace($mobile, '*****', 0, 5);
|
|
$this->data['id'] = $id;
|
|
$this->show_view('common/bind_mobile');
|
|
}
|
|
|
|
/**
|
|
* Notes: 获取七牛token
|
|
* Created on: 2020/4/16 14:27
|
|
* Created by: dengbw
|
|
* @return bool
|
|
*/
|
|
public function qiniu_token()
|
|
{
|
|
$filename = $this->input->post('filename');
|
|
$type = $this->input->post('type');
|
|
!$type && $type = '';
|
|
$this->load->library('qiniu', array('type' => $type));
|
|
|
|
$token = $this->qiniu->getToken($filename);
|
|
$this->data = $token ? $token : '';
|
|
return $this->show_json(SYS_CODE_SUCCESS, '成功获取七牛token');
|
|
}
|
|
|
|
/**
|
|
* Notes:设置七牛视频
|
|
* Created on: 2020/4/16 14:30
|
|
* Created by: dengbw
|
|
* @return bool
|
|
*/
|
|
public function qiniu_video()
|
|
{
|
|
$filename = $this->input->post('filename');
|
|
if (!$filename) {
|
|
return $this->show_json(SYS_CODE_FAIL, '上传视频失败');
|
|
}
|
|
$ext_arr = explode(".", $filename);
|
|
$file_ext = $ext_arr[count($ext_arr) - 1];
|
|
if (!in_array(strtolower($file_ext), array('avi', 'rmvb', 'rm', 'asf', 'divx', 'mpg', 'mpeg', 'mpe', 'wmv', 'mp4', 'mkv', 'vob', 'mov'))) {
|
|
return $this->show_json(SYS_CODE_FAIL, "文件格式不对");
|
|
}
|
|
$ext = count($ext_arr) > 1 ? $file_ext : 'mp4';
|
|
$phoId = md5(uniqid() . mt_rand(0, 10000) . time());
|
|
$oriKey = $phoId . '.' . $ext;
|
|
$filename = "hdi/" . date('Ym') . "/" . $oriKey;
|
|
$this->data = $filename;
|
|
return $this->show_json(SYS_CODE_SUCCESS, '七牛视频设置成功');
|
|
}
|
|
|
|
/**
|
|
* Notes:显示视频
|
|
* Created on: 2020/4/16 16:38
|
|
* Created by: dengbw
|
|
*/
|
|
public function show_video()
|
|
{
|
|
$video = $this->input->get('video');
|
|
if (!$video) {
|
|
return $this->show_json(SYS_CODE_FAIL, '无视频文件');
|
|
}
|
|
$this->data['video'] = $video;
|
|
return $this->show_view('common/show_video');
|
|
}
|
|
|
|
/**
|
|
* 导入excel表格生成数组
|
|
* @return bool
|
|
*/
|
|
public function excel2arr()
|
|
{
|
|
require_once COMMPATH . '/third_party/PHPExcel/IOFactory.php';
|
|
|
|
$key = $this->input->get('key');
|
|
|
|
$res = $this->upload();
|
|
if (!$res['code']) {
|
|
return $this->show_json(0, $res['message']);
|
|
}
|
|
$file = $res['path'];
|
|
if ($res['file_ext'] == '.xls') {
|
|
$reader = \PHPExcel_IOFactory::createReader('Excel5'); // 读取 excel 文档
|
|
} elseif ($res['file_ext'] == '.xlsx') {
|
|
$reader = \PHPExcel_IOFactory::createReader('Excel2007'); // 读取 excel 文档
|
|
} else {
|
|
return $this->show_json(0, '不是excel文件');
|
|
}
|
|
$PHPExcel = $reader->load($file); // 文档名称
|
|
$objWorksheet = $PHPExcel->getActiveSheet();
|
|
$rowCnt = $objWorksheet->getHighestRow(); //获取总行数
|
|
$col_max = $objWorksheet->getHighestColumn();//最大列
|
|
$arr = array();
|
|
for ($i = 1; $i <= $rowCnt; $i++) { //读取内容
|
|
$row = array();
|
|
for ($j = 'A'; $j < $col_max; $j++) {
|
|
$row[] = $objWorksheet->getCell($j . $i)->getValue();
|
|
}
|
|
$arr[] = $row;
|
|
}
|
|
|
|
!$key = 0;
|
|
$r = &load_cache('redis');
|
|
|
|
|
|
$total = count($arr);
|
|
@unlink($file);
|
|
$this->data['total'] = $total;
|
|
$this->data['key'] = 1;
|
|
return $this->show_json(SYS_CODE_SUCCESS, "成功加载excel数据{$total}行");
|
|
}
|
|
|
|
/**
|
|
* 获取json数据
|
|
* @return bool
|
|
*/
|
|
public function jsons_jdb()
|
|
{
|
|
$this->load->model('app/jdb/receiver_model');
|
|
$where = array();
|
|
$rows = $this->receiver_model->select($where, "id ASC", 0, 0, 'id,cate_title as title');
|
|
$this->data['lists'] = $rows;
|
|
return $this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
|
|
//返回视图页面
|
|
private function show_view($view)
|
|
{
|
|
$this->load->vars($this->data);
|
|
$this->load->view($view);
|
|
$this->load->view('snav');
|
|
return true;
|
|
}
|
|
|
|
//返回json数据
|
|
private function show_json($code = 0, $msg = 'success')
|
|
{
|
|
header('Content-Type:application/json; charset=utf-8');
|
|
echo json_encode(array('data' => $this->data, 'code' => $code, 'msg' => $msg), JSON_UNESCAPED_UNICODE);
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Notes:选择车型
|
|
*/
|
|
public function cars()
|
|
{
|
|
$this->load->model('auto/auto_brand_model');
|
|
$this->load->model('auto/auto_series_model');
|
|
$page = $this->input->post('page') ? intval($this->input->post('page')) : 1;
|
|
$size = $this->input->post('size') ? intval($this->input->post('size')) : 10;
|
|
|
|
$use_items_list = $this->input->post('use_items_list');
|
|
$title = $this->input->post('title');
|
|
$status = intval($this->input->post('status'));
|
|
$itemsChecked = $itemsList = $resItems = array();
|
|
if ($use_items_list) {
|
|
foreach ($use_items_list as $key => $value) {
|
|
$itemsChecked[$value['id']] = $value['id'];
|
|
}
|
|
}
|
|
$where = [];
|
|
$status && $where['lc_auto_series.status'] = $status;
|
|
$title && $where['lc_auto_series.name like "%' . $title . '%"'] = null;
|
|
$count = $this->auto_series_model->select_brand($where, '', '', '', '', 1);
|
|
$itemsList = [];
|
|
if ($count) {
|
|
$lists = $this->auto_series_model->select_brand($where, 'lc_auto_series.id desc', $page, $size);
|
|
foreach ($lists as $key => $val) {
|
|
$itemsList[] = [
|
|
'id' => $val['id'],
|
|
'name' => $val['name'],
|
|
'b_name' => $val['b_name'],
|
|
'is_checked' => $itemsChecked[$value['id']] ? 1 : 0
|
|
];
|
|
}
|
|
}
|
|
$this->data['itemsList'] = $itemsList;
|
|
$hasNext = ceil($count / $size) > $page ? 1 : 0;
|
|
$this->data['itemsPage'] = array('page' => $page, 'pageLimit' => $size, 'pageCount' => $count, 'hasNext' => $hasNext);
|
|
return $this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
/**
|
|
* Notes:选择品牌
|
|
*/
|
|
public function brands()
|
|
{
|
|
$this->load->model('auto/auto_brand_model');
|
|
$this->load->model('auto/auto_series_model');
|
|
$page = $this->input->post('page') ? intval($this->input->post('page')) : 1;
|
|
$size = $this->input->post('size') ? intval($this->input->post('size')) : 10;
|
|
|
|
$use_items_list = $this->input->post('use_items_list');
|
|
$title = $this->input->post('title');
|
|
$status = intval($this->input->post('status'));
|
|
$itemsChecked = $itemsList = $resItems = array();
|
|
if ($use_items_list) {
|
|
foreach ($use_items_list as $key => $value) {
|
|
$itemsChecked[$value['id']] = $value['id'];
|
|
}
|
|
}
|
|
$where = [];
|
|
$status && $where['status'] = $status;
|
|
$title && $where['name like "%' . $title . '%"'] = null;
|
|
$count = $this->auto_brand_model->count($where);
|
|
$itemsList = [];
|
|
if ($count) {
|
|
$lists = $this->auto_brand_model->select($where, 'id desc', $page, $size);
|
|
foreach ($lists as $key => $val) {
|
|
$itemsList[] = [
|
|
'id' => $val['id'],
|
|
'name' => $val['name'],
|
|
'is_checked' => $itemsChecked[$val['id']] ? 1 : 0
|
|
];
|
|
}
|
|
}
|
|
$this->data['itemsList'] = $itemsList;
|
|
$hasNext = ceil($count / $size) > $page ? 1 : 0;
|
|
$this->data['itemsPage'] = array('page' => $page, 'pageLimit' => $size, 'pageCount' => $count, 'hasNext' => $hasNext);
|
|
return $this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
/**
|
|
* Notes:车型库
|
|
* Created on: 2021/7/19 10:18
|
|
* Created by: dengbw
|
|
* @return bool
|
|
*/
|
|
public function auto()
|
|
{
|
|
$type = intval($this->input->get('type'));//1品牌2车系3型号
|
|
$pid = intval($this->input->get('pid'));
|
|
$name = $this->input->get('name');
|
|
$tp = intval($this->input->get('tp'));//0搜索使用,1修改使用
|
|
$this->load->model('auto/auto_brand_model', 'mdAutoBrand');
|
|
$this->load->model('auto/auto_series_model', 'mdAutoSeries');
|
|
$this->load->model('auto/auto_attr_model', 'mdAutoAttr');
|
|
$res = $lists = array();
|
|
if ($type == 1) {
|
|
$tp == 0 && $lists[] = array('id' => 0, 'name' => $name ? $name : '选择品牌');
|
|
$res = $this->mdAutoBrand->select(array('status' => 1), 'id desc', 0, 0, 'id,name');
|
|
} else if ($type == 2) {
|
|
$tp == 0 && $lists[] = array('id' => 0, 'name' => $name ? $name : '选择车系');
|
|
$res = $this->mdAutoSeries->select(array('status' => 1, 'brand_id' => $pid), 'id desc', 0, 0, 'id,name');
|
|
} else if ($type == 3) {
|
|
$tp == 0 && $lists[] = array('id' => 0, 'name' => $name ? $name : '选择车型');
|
|
$res = $this->mdAutoAttr->select(array('type' => 1, 's_id' => $pid), 'id desc', 0, 0, 'id,title as name');
|
|
}
|
|
if ($tp == 1 && $type == 3) {
|
|
$lists[3] = $res;//车型
|
|
$lists[4] = $this->mdAutoAttr->select(array('type' => 0, 's_id' => $pid), 'id desc', 0, 0, 'id,title as name');//车身颜色
|
|
$lists[5] = $this->mdAutoAttr->select(array('type' => 2, 's_id' => $pid), 'id desc', 0, 0, 'id,title as name');//内饰颜色
|
|
} else {
|
|
foreach ($res as $key => $value) {
|
|
$lists[] = array('id' => $value['id'], 'name' => $value['name']);
|
|
}
|
|
}
|
|
$this->data = $lists;
|
|
return $this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
|
|
/**
|
|
* Notes:获取商品列表
|
|
*/
|
|
public function items()
|
|
{
|
|
$select_id = $this->input->post('select_id');
|
|
$brand_id = $this->input->post('brand_id');
|
|
$s_id = $this->input->post('s_id');
|
|
$v_id = $this->input->post('v_id');
|
|
$cor_id = $this->input->post('cor_id');
|
|
$incor_id = $this->input->post('incor_id');
|
|
$vin = $this->input->post('vin');
|
|
$page = $this->input->post('page') ? intval($this->input->post('page')) : 1;
|
|
$size = $this->input->post('size') ? intval($this->input->post('size')) : 10;
|
|
$where = "status=1 ";
|
|
if($vin){
|
|
$where .= " and vin='{$vin}'";
|
|
} else {
|
|
$brand_id && $where .= " and brand_id=$brand_id";
|
|
$s_id && $where .= " and s_id=$s_id";
|
|
$v_id && $where .= " and v_id=$v_id";
|
|
$cor_id && $where .= " and cor_id=$cor_id";
|
|
$incor_id && $where .= " and incor_id=$incor_id";
|
|
}
|
|
|
|
if ($select_id) {
|
|
$fhwhere = [
|
|
"($where) or (id=$select_id)" => null
|
|
];
|
|
} else {
|
|
$fhwhere = [
|
|
"($where)" => null
|
|
];
|
|
}
|
|
$count = 0;
|
|
$list = array();
|
|
|
|
$this->load->model("items/items_model");
|
|
$this->load->model('auto/auto_series_model');
|
|
$this->load->model('auto/auto_brand_model');
|
|
$this->load->model('auto/auto_attr_model');
|
|
|
|
$count = $this->items_model->count($fhwhere);
|
|
if ($count) {
|
|
$rows = $this->items_model->select($fhwhere, "id desc", $page, $size, 'id,brand_id,s_id,v_id,cor_id,incor_id,vin');
|
|
|
|
//品牌车型
|
|
$brand_arr = array_unique(array_column($rows, 'brand_id'));
|
|
$brands = $this->auto_brand_model->get_map_by_ids($brand_arr, 'id,name');
|
|
//车系车型
|
|
$series_arr = array_unique(array_column($rows, 's_id'));
|
|
$series = $this->auto_series_model->get_map_by_ids($series_arr, 'id,name');
|
|
//获取属性
|
|
$v_arr = array_unique(array_column($rows, 'v_id'));
|
|
$cor_arr = array_unique(array_column($rows, 'cor_id'));
|
|
$incor_arr = array_unique(array_column($rows, 'incor_id'));
|
|
$attr_arr = array_merge($v_arr, $cor_arr, $incor_arr);
|
|
$attr = $this->auto_attr_model->get_map_by_ids($attr_arr, 'id,title');
|
|
foreach ($rows as $key => $val) {
|
|
$setval = [
|
|
'id' => $val['id'],
|
|
'vin' => $val['vin']
|
|
];
|
|
$setval['brand_name'] = isset($brands[$val['brand_id']]) ? $brands[$val['brand_id']][0]['name'] : '';
|
|
$setval['series_name'] = isset($series[$val['s_id']]) ? $series[$val['s_id']][0]['name'] : '';
|
|
$setval['v_name'] = isset($attr[$val['v_id']]) ? $attr[$val['v_id']][0]['title'] : '';
|
|
$setval['cor_name'] = isset($attr[$val['cor_id']]) ? $attr[$val['cor_id']][0]['title'] : '';
|
|
$setval['incor_name'] = isset($attr[$val['incor_id']]) ? $attr[$val['incor_id']][0]['title'] : '';
|
|
$list[] = $setval;
|
|
}
|
|
}
|
|
$this->data['list'] = $list;
|
|
$hasNext = ceil($count / $size) > $page ? 1 : 0;
|
|
$this->data['page'] = array('page' => $page, 'pageLimit' => $size, 'pageCount' => $count, 'hasNext' => $hasNext);
|
|
return $this->show_json(SYS_CODE_SUCCESS);
|
|
}
|
|
}
|