transfer_1216

This commit is contained in:
dengbw
2021-12-16 16:58:51 +08:00
committed by lccsw
parent 604145c83f
commit 1cc30a7e0d
21 changed files with 2709 additions and 28 deletions
+13 -1
View File
@@ -46,6 +46,18 @@ class Common extends CI_Controller
case 'county':
$this->data = $this->area_model->county($id, $type);
break;
case 'street':
$this->load->model('sys/sys_street_model', 'mdStreet');
$result = [];
$type == 0 && $result[] = array('name' => '街道/乡镇', 'id' => '');
$list = $this->mdStreet->select(['county_id' => $id], 'id ASC', 0, 0, 'street_id,street_name');
if ($list) {
foreach ($list as $v) {
$result[$v['street_id']] = array('id' => $v['street_id'], 'name' => $v['street_name']);
}
}
$this->data = $result;
break;
default:
$this->data = $this->area_model->province();
break;
@@ -942,7 +954,7 @@ class Common extends CI_Controller
$this->load->library('hdwechat', $wxconfig);
$result = $this->hdwechat->qrcode($filename, $scene, $page, $width);
if ($result) {
$this->data['qrcode'] = http_host_com() .'/'. $result['url'];
$this->data['qrcode'] = http_host_com() . '/' . $result['url'];
}
// $scene = 82;
// $url_params = array('path' => '/' . $page, 'query' => 'id=' . $scene . '&form=auth&_um_campaign=604823e96ee47d382b7a2b79&_um_channel=604823e96ee47d382b7a2b7a',
+256
View File
@@ -0,0 +1,256 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Created by PhpStorm.
* User: xuxb
* Date: 2021/8/25
* Time: 11:35
*/
class Article extends HD_Controller
{
protected $log_dir;
public function __construct()
{
parent::__construct();
$this->load->model('auto/auto_article_model');
$this->log_dir = "auto_" . get_class($this);
}
public function index()
{
return $this->lists();
}
public function lists()
{
$params = $this->input->get();
$statusAry = array(0 => '关闭', 1 => '开启');
$where = array();
if ($params['title']) {
$where["title like '%{$params['title']}%'"] = null;
}
if (strlen($params['status']) > 0) {
$where['status'] = $params['status'];
} else {
$where['status>-1'] = null;
$params['status'] = '';
}
$page = $params['page'];
$page = !$page ? 1 : $page;
$size = $params['size'];
$size = !$size ? 20 : $size;
$total = $this->auto_article_model->count($where);
$lists = array();
if ($total) {
$orderby = 'id desc';
$select = 'id, title, status';
$rows = $this->auto_article_model->select($where, $orderby, $page, $size, $select);
foreach ($rows as $v) {
$lists[] = array(
'id' => $v['id'],
'title' => $v['title'],
'status' => $v['status'],
'status_name' => $statusAry[$v['status']],
);
}
}
$this->data['params'] = $params;
$this->data['lists'] = $lists;
$this->data['statusAry'] = $statusAry;
$this->data['pager'] = array('count' => ceil($total / $size), 'curr' => $page, 'totle' => $total);
$this->data['_title'] = '随车物品管理';
$this->show_view('auto/article/lists', true);
}
public function get()
{
$id = $this->input->get('id');
if ($id) {
$row = $this->auto_article_model->get(array('id' => $id));
$info = array(
'id' => $row['id'],
'title' => $row['title'],
'status' => $row['status']
);
$title = '编辑随车物品';
$action = 'auto/article/edit';
} else {
$info = array(
'title' => '',
'status' => 1,
);
$title = '新增随车物品';
$action = 'auto/article/add';
}
$statusAry = array(0 => '关闭', 1 => '开启');
$this->data['info'] = $info;
$this->data['statusAry'] = $statusAry;
$this->data['action'] = $action;
$this->data['_title'] = $title;
$this->show_view('auto/article/get');
}
/**
* 新增物品
* @return bool
*/
public function add()
{
$info = $this->input->post('info');
if (!$info['title']) {
return $this->show_json(SYS_CODE_FAIL, '请输入物品名称');
}
$where = array("title" => trim($info['title']));
$old = $this->auto_article_model->get($where);
if ($old && $old['status'] > -1) {
return $this->show_json(SYS_CODE_FAIL, '物品已经存在');
} else if (-1 == $old['status']) {
//旧数据存在,更新
$upd = array('status' => $info['status']);
$ret = $this->auto_article_model->update($upd, array('id' => $old['id']));
if (!$ret) {
debug_log('[error]# update fail; ' . $this->auto_article_model->db->last_query(), __FUNCTION__, $this->log_dir);
return $this->show_json(SYS_CODE_FAIL, '添加失败');
}
} else {
$add = array(
'title' => $info['title'],
'status' => $info['status'],
'c_time' => time(),
);
$ret = $this->auto_article_model->add($add);
if (!$ret) {
debug_log('[error]# add fail; ' . $this->auto_article_model->db->last_query(), __FUNCTION__, $this->log_dir);
return $this->show_json(SYS_CODE_FAIL, '添加失败');
}
}
return $this->show_json(SYS_CODE_SUCCESS, '添加成功');
}
/**
* 编辑
* @return bool
*/
public function edit()
{
$info = $this->input->post('info');
if (!$info['title']) {
return $this->show_json(SYS_CODE_FAIL, '请输入物品名称');
}
$where = array(
"title" => trim($info['title']),
"id<>{$info['id']}" => null,
"status>-1" => null
);
$old = $this->auto_article_model->get($where);
if ($old) {
return $this->show_json(SYS_CODE_FAIL, '物品已经存在');
}
$upd = array('title' => $info['title'], 'status' => $info['status']);
$ret = $this->auto_article_model->update($upd, array('id' => $info['id']));
if (!$ret) {
debug_log('[error]# update fail; ' . $this->auto_article_model->db->last_query(), __FUNCTION__, $this->log_dir);
return $this->show_json(SYS_CODE_FAIL, '添加失败');
}
return $this->show_json(SYS_CODE_SUCCESS, '添加成功');
}
function edit_status()
{
$id = $this->input->post('id');
$stauts = $this->input->post('status');
if (!$id) {
$this->show_json(SYS_CODE_FAIL, '参数错误');
}
$where = array('id' => $id);
$this->auto_article_model->update(array('status' => $stauts), $where);
return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
}
public function del()
{
$id = $this->input->post('id');
if (!$id) {
$this->show_json(SYS_CODE_FAIL, '参数错误');
}
$where = array('id' => $id);
$ret = $this->auto_article_model->update(array('status' => -1), $where);
return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
}
public function batch()
{
// TODO: Implement batch() method.
}
public function export()
{
// TODO: Implement export() method.
}
/**
* @return bool
*/
function json_lists()
{
$id = $this->input->post('id');
$title = trim($this->input->post('title'));
$status = $this->input->post('status');
$page = $this->input->post('page');
$size = $this->input->post('size');
$where = array();
if ($id) {
if (is_numeric($id)) {
$where['id'] = $id;
} else {
if (is_array($id)) {
$id = implode(',', $id);
}
$where["id in ({$id})"] = null;
}
} else {
$title && $where["title like '%{$title}%'"] = null;
if (strlen($status) > 0) {
$where['status'] = $status;
} else {
$where['status>-1'] = null;
}
}
$total = $this->auto_article_model->count($where);
$lists = array();
if ($total) {
$orderby = 'id desc';
$select = 'id, title';
$rows = $this->auto_article_model->select($where, $orderby, $page, $size, $select);
foreach ($rows as $v) {
$lists[] = array(
'id' => $v['id'],
'title' => $v['title'],
);
}
}
$this->data = array('total' => $total, 'list' => $lists);
return $this->show_json(SYS_CODE_SUCCESS);
}
}
+428
View File
@@ -0,0 +1,428 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notes:车辆调拨
* Created on: 2021/12/6 16:43
* Created by: dengbw
*/
class Transfer extends HD_Controller
{
private $cacheKeyTransports = 'admin_transports';
public function __construct()
{
parent::__construct();
$this->load->model('items/items_transfer_model', 'mdTransfer');
$this->load->model('items/items_transfer_remind_model', 'mdTransferRemind');
$this->load->model('app/licheb/app_licheb_users_model', 'mdUsers');
$this->load->model('items/items_model', 'mdItems');
$this->load->model('auto/auto_brand_model', 'mdAutoBrand');
$this->load->model('auto/auto_series_model', 'mdAutoSeries');
$this->load->model('auto/auto_attr_model', 'mdAutoAttr');
$this->load->model("sys/sys_addr_model", 'mdAddr');
$this->load->model("biz/biz_model", 'mdBiz');
$this->load->model('area_model', 'mdArea');
}
public function index()
{
return $this->lists();
}
public function lists()
{
$this->load->model('auto/auto_brand_model', 'mdAutoBrand');
$this->load->model('auto/auto_series_model', 'mdAutoSeries');
$this->load->model('auto/auto_attr_model', 'mdAutoAttr');
$params = $this->input->get();
$params['page'] = $params['page'] ? intval($params['page']) : 1;
$params['size'] = $params['size'] ? intval($params['size']) : 20;
$re = $this->dataSelect($params);
$autoList[1] = $this->mdAutoBrand->select(array('status' => 1), 'id desc', 0, 0, 'id,name');
if ($params['brand_id']) {
$autoList[2] = $this->mdAutoSeries->select(array('status' => 1, 'brand_id' => $params['brand_id']), 'id desc', 0, 0, 'id,name');
}
if ($params['s_id']) {
$autoList[3] = $this->mdAutoAttr->select(array('type' => 1, 's_id' => $params['s_id']), 'id desc', 0, 0, 'id,title as name');
}
$total = $re['total'];
$this->data['params'] = $re['params'];
$this->data['lists'] = $re['lists'];
$this->data['statusAry'] = $this->mdTransfer->statusAry();
$this->data['abnormalAry'] = $this->mdTransfer->abnormalAry();
$this->data['autoList'] = $autoList;
$this->data['pager'] = array('count' => ceil($total / $params['size']), 'curr' => $params['page'], 'totle' => $total);
$this->data['_title'] = '车辆调拨';
$this->show_view('items/transfer/lists', true);
}
private function dataSelect($params)
{
$statusAry = $this->mdTransfer->statusAry();
$where = ['status<>' => -1];
if (strlen($params['status'])) {
$where['status'] = $params['status'];
} else {
$params['status'] = '';
}
if (strlen($params['abnormal'])) {
$where['abnormal'] = $params['abnormal'];
} else {
$params['abnormal'] = '';
}
if ($params['out_uid']) {
$where['out_uid'] = $params['out_uid'];
} else {
$params['out_uid'] = '';
!$params['city_id_out'] && $params['city_id_out'] = '';
!$params['county_id_out'] && $params['county_id_out'] = '';
!$params['biz_id_out'] && $params['biz_id_out'] = '';
}
if ($params['in_uid']) {
$where['in_uid'] = $params['in_uid'];
} else {
$params['in_uid'] = '';
!$params['city_id_in'] && $params['city_id_in'] = '';
!$params['county_id_in'] && $params['county_id_in'] = '';
!$params['biz_id_in'] && $params['biz_id_in'] = '';
}
if ($params['title']) {
$where["item_id in (select id from lc_items where vin like '%{$params['title']}%')"] = null;
}
if ($params['brand_id'] || $params['s_id'] || $params['v_id']) {
$where_items = "brand_id = {$params['brand_id']}";
$params['s_id'] && $where_items .= " and s_id = {$params['s_id']}";
$params['v_id'] && $where_items .= " and v_id = {$params['v_id']}";
$where["item_id in (select id from lc_items where $where_items)"] = null;
}
if ($params['out_time']) {
$out_time = explode(' ~ ', $params['out_time']);
$out_time[0] && $where["out_time >="] = $out_time[0] . ' 00:00:00';
$out_time[1] && $where["out_time <="] = $out_time[1] . ' 23:59:59';
}
if ($params['in_time']) {
$in_time = explode(' ~ ', $params['in_time']);
$in_time[0] && $where["in_time >="] = $in_time[0] . ' 00:00:00';
$in_time[1] && $where["in_time <="] = $in_time[1] . ' 23:59:59';
}
$total = $this->mdTransfer->count($where);
$lists = array();
if ($total) {
$rows = $this->mdTransfer->select($where, 'id desc', $params['page'], $params['size']);
$out_uids = array_unique(array_column($rows, 'out_uid'));
$in_uids = array_unique(array_column($rows, 'in_uid'));
$uids_arr = array_merge($out_uids, $in_uids);
$uids = $this->mdUsers->get_map_by_ids($uids_arr, 'id,uname');
foreach ($rows as $v) {
$jsondata = $v['jsondata'] ? json_decode($v['jsondata'], true) : [];
$item_info = $this->item_info($v['item_id'], 1);
$lists[] = array(
'id' => $v['id'],
'title' => $item_info['title'],
'vin' => $item_info['vin'],
'out_uid_title' => $v['out_uid'] ? $uids[$v['out_uid']][0]['uname'] . '/' . date('Y.m.d H:i', strtotime($v['out_time'])) : '-',
'in_uid_title' => $v['in_uid'] ? $uids[$v['in_uid']][0]['uname'] . '/' . date('Y.m.d H:i', strtotime($v['in_time'])) : '-',
'transport_name' => $jsondata['transport']['name'],
'abnormal' => $this->mdTransfer->abnormalAry($v['abnormal']),
'c_time' => date('Y.m.d H:i', $v['c_time']),
'status_name' => $statusAry[$v['status']],
);
}
}
$data['lists'] = $lists;
$data['params'] = $params;
$data['total'] = $total;
return $data;
}
public function get()
{
$id = $this->input->get('id');
$info = [];
if ($id) {
$re = $this->mdTransfer->get(array('id' => $id, 'status <>' => -1));
if (!$re || empty($re)) {
return $this->show_json(SYS_CODE_FAIL, '车辆调拨不存在!');
}
$this->load->model('auto/auto_article_model', 'mdArticle');
$info['item_id'] = $re['item_id'];
$info['items_info'] = $this->item_info($re['item_id']);
$res_r = $this->mdTransferRemind->select(['tran_id' => $id], 'type asc', 0, 0, 'uid,type');
$out_content = $in_content = $arti_content = $abnormal = '';
foreach ($res_r as $key => $value) {
if ($value['type'] == 1) {
$re_user = $this->mdUsers->get(array('id' => $value['uid']));
$re_biz = $this->mdBiz->get(array('id' => $re_user['biz_id']));
if ($re_biz['county_id']) {
$re_area = $this->mdArea->get(array('county_id' => $re_biz['county_id']));
$city_name = $re_area['city_name'] . ' ' . $re_area['county_name'];
} else {
$re_area = $this->mdArea->get(array('city_id' => $re_biz['city_id']));
$city_name = $re_area['city_name'];
}
$out_content = $city_name . ' ' . $re_biz['biz_name'] . ' &nbsp;&nbsp;&nbsp;提车人:' . $re_user['uname']
. '&nbsp;&nbsp;' . $re_user['mobile'];
} else if ($value['type'] == 2) {
$re_user = $this->mdUsers->get(array('id' => $value['uid']));
$out_content .= ' &nbsp;&nbsp;&nbsp;备用提车人:' . $re_user['uname'] . '&nbsp;&nbsp;' . $re_user['mobile'];
} else if ($value['type'] == 3) {
$re_user = $this->mdUsers->get(array('id' => $value['uid']));
$re_biz = $this->mdBiz->get(array('id' => $re_user['biz_id']));
if ($re_biz['county_id']) {
$re_area = $this->mdArea->get(array('county_id' => $re_biz['county_id']));
$city_name = $re_area['city_name'] . ' ' . $re_area['county_name'];
} else {
$re_area = $this->mdArea->get(array('city_id' => $re_biz['city_id']));
$city_name = $re_area['city_name'];
}
$in_content = $city_name . ' ' . $re_biz['biz_name'] . ' &nbsp;&nbsp;&nbsp;接车人:' . $re_user['uname']
. '&nbsp;&nbsp;' . $re_user['mobile'];
} else if ($value['type'] == 4) {
$re_user = $this->mdUsers->get(array('id' => $value['uid']));
$in_content .= ' &nbsp;&nbsp;&nbsp;备用接车人:' . $re_user['uname'] . '&nbsp;&nbsp;' . $re_user['mobile'];
}
}
$jsondata = $re['jsondata'] ? json_decode($re['jsondata'], true) : [];
$trailer_fees = $re['trailer_fees'] ? $re['trailer_fees'] . '元' : '';
$trailer_fees .= '&nbsp;&nbsp;费用承担人:';
if ($re['fees_city']) {
$re_area = $this->mdArea->get(array('city_id' => $re['fees_city']));
$trailer_fees .= $re_area['city_name'];
}
$trailer_fees .= '&nbsp;&nbsp;' . $this->mdTransfer->feesTypeAry($re['fees_type']);
$fields[] = ['title' => '提车信息', 'value' => $out_content];
$fields[] = ['title' => '接车信息', 'value' => $in_content];
$fields[] = ['title' => '运输费用', 'value' => $trailer_fees];
$fields[] = ['title' => '运输人员', 'value' => $jsondata['transport']['name'] . '&nbsp;&nbsp;&nbsp;' .
$jsondata['transport']['mobile'] . '&nbsp;&nbsp;&nbsp;身份证:' . $jsondata['transport']['cardid']];
if ($re['arti_id']) {
$res_a = $this->mdArticle->select(["id in ({$re['arti_id']})" => null], 'id desc', 0, 0, 'title');
$res_a && $arti_content = implode(' &nbsp;&nbsp;', array_unique(array_column($res_a, 'title')));
}
$fields[] = ['title' => '随身物品', 'value' => $arti_content];
$fields[] = ['title' => '车辆异常', 'value' => $this->mdTransfer->abnormalAry()[$re['abnormal']]];
if ($re['abnormal'] && $jsondata['abnormal']) {
$abnormal = $jsondata['abnormal'];
foreach ($abnormal['imgs'] as $key => $value) {
$abnormal['imgs'][$key] = $value ? build_qiniu_image_url($value) : '';
}
}
$this->data['fields'] = $fields;
$this->data['abnormal'] = $abnormal;
$title = '车辆调拨详情';
$view = 'items/transfer/get';
} else {
$title = '新增车辆调拨';
$view = 'items/transfer/get_add';
$showInfo = ['vin' => '', 'items_info' => ['id' => 0, 'title' => '', 'vin' => '', 'cor' => '', 'address' => ''],
'feesTypeAry' => $this->mdTransfer->feesTypeAry()];
$info = ['item_id' => 0, 'arti_id' => [], 'out_uid' => '', 'out_uid_bak' => '', 'in_uid' => '', 'in_uid_bak' => ''
, 'out_bak' => 0, 'in_bak' => 0, 'trailer_fees' => '', 'fees_city' => '', 'fees_type' => 1, 'transport' => ['name' => '', 'mobile' => '', 'cardid' => '']];
//常用运输人员
$cache = &load_cache('redis');
$cache_transports = $cache->get($this->cacheKeyTransports);
$transports = [];
$time = date('Y-m-d', strtotime("-1 month"));
foreach ($cache_transports as $key => $value) {
if ($value['time'] >= $time) {//小于1个月过期不显示
$transports[] = $value;
}
}
$cache->save($this->cacheKeyTransports, $transports);
$transports && $transports = array_reverse($transports);//倒序
$this->data['transports'] = $transports;//常用运输人员
$this->data['showInfo'] = $showInfo;
}
$this->data['info'] = $info;
$this->data['_title'] = $title;
return $this->show_view($view, true);
}
/**
* 新增物品
* @return bool
*/
public function add()
{
$info = $this->input->post('info');
if (!$info['arti_id']) {
return $this->show_json(SYS_CODE_FAIL, '请选择随车物品');
}
if (!$info['out_uid']) {
return $this->show_json(SYS_CODE_FAIL, '请选择提车人');
}
if (!$info['in_uid']) {
return $this->show_json(SYS_CODE_FAIL, '请选择接车人');
}
$trailer_fees = intval($info['trailer_fees']);
if (!$trailer_fees) {
return $this->show_json(SYS_CODE_FAIL, '请输入运输费用');
}
if (!$info['transport']['name'] || !$info['transport']['mobile'] || !$info['transport']['cardid']) {
return $this->show_json(SYS_CODE_FAIL, '请输入运输人员姓名/电话/身份证号');
}
$re = $this->mdTransfer->get(['item_id' => $info['item_id'], 'status in(0,1)' => null]);
if ($re) {
return $this->show_json(SYS_CODE_FAIL, '添加失败,车辆正在调拨中...');
}
$re_user = $this->mdUsers->get(array('id' => $info['in_uid']));//查找用户负责门店
$biz_id = $re_user['biz_id'] ? $re_user['biz_id'] : 0;
$jsondata['transport'] = $info['transport'];
$c_time = time();
$add = [
'item_id' => $info['item_id'],
'biz_id' => $biz_id,
'arti_id' => $info['arti_id'] ? implode(',', $info['arti_id']) : '',
'jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE),
'trailer_fees' => $trailer_fees,
'fees_city' => intval($info['fees_city']),
'fees_type' => $info['fees_type'],
'c_time' => $c_time,
];
$id = $this->mdTransfer->add($add);
if (!$id) {
return $this->show_json(SYS_CODE_FAIL, '添加失败');
}
//车辆调拨提醒
$send_uids[] = $info['out_uid'];
$addRemind[] = ['tran_id' => $id, 'uid' => $info['out_uid'], 'type' => 1, 'status' => 1, 'c_time' => $c_time];//提车人
if ($info['out_uid_bak']) {
$addRemind[] = ['tran_id' => $id, 'uid' => $info['out_uid_bak'], 'type' => 2, 'status' => 1, 'c_time' => $c_time];//备用提车人
$send_uids[] = $info['out_uid_bak'];
}
$addRemind[] = ['tran_id' => $id, 'uid' => $info['in_uid'], 'type' => 3, 'status' => 0, 'c_time' => $c_time];//接车人
$info['in_uid_bak'] && $addRemind[] = ['tran_id' => $id, 'uid' => $info['in_uid_bak'], 'type' => 4, 'status' => 0, 'c_time' => $c_time];//备用接车人
$this->mdTransferRemind->add_batch($addRemind);
//调拨短信提醒
if ($send_uids) {
$item_info = $this->input->post('items_info');
$uids_str = implode(',', $send_uids);
$res_u = $this->mdUsers->select(["id in({$uids_str})" => null], 'id desc', 0, 0, 'mobile');
foreach ($res_u as $key => $value) {
$car = $item_info['title'];
$item_info['cor'] && $car .= '-' . $item_info['cor'];
send_alisms(array('mobile' => $value['mobile'], 'template' => 'SMS_229648438'
, 'param' => ['car' => $car, 'vin' => $item_info['vin']]));
}
}
//常用运输人员
$cache = &load_cache('redis');
$cache_transports = $cache->get($this->cacheKeyTransports);
$addTransports = true;
foreach ($cache_transports as $key => $value) {
if ($value['mobile'] == $info['transport']['mobile']) {
$value['time'] = date('Y-m-d');
$addTransports = false;
}
}
if ($addTransports) {
$info['transport']['time'] = date('Y-m-d');
$cache_transports[] = $info['transport'];
}
$cache->save($this->cacheKeyTransports, $cache_transports);
return $this->show_json(SYS_CODE_SUCCESS, '添加成功');
}
/**
* 编辑
* @return bool
*/
public function edit()
{
}
public function del()
{
}
public function batch()
{
// TODO: Implement batch() method.
}
public function export()
{
$params = $this->input->get();
$params['page'] = 1;
$params['size'] = 10000;
$data = $indexs = array();
$res = $this->dataSelect($params);
$fileName = "车辆调拨";
foreach ($res['lists'] as $key => $value) {
$temp['title'] = $value['title'];
$temp['vin'] = $value['vin'];
$temp['transport_name'] = $value['transport_name'];
$temp['c_time'] = $value['c_time'];
$temp['out_uid_title'] = $value['out_uid_title'];
$temp['in_uid_title'] = $value['in_uid_title'];
$temp['abnormal'] = $value['abnormal'];
$temp['status_name'] = $value['status_name'];
$data[] = $temp;
}
$indexs = [
'title' => '车辆',
'vin' => '车架号',
'transport_name' => '运输人员',
'c_time' => '调拨时间',
'out_uid_title' => '提车人/提车时间',
"in_uid_title" => "接车人/接车时间",
"abnormal" => "是否异常",
"status_name" => "状态",
];
array_unshift($data, $indexs);
$this->load->library('excel');
$this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis'));
}
/**
* Notes:获取商品信息
* Created on: 2021/12/9 10:47
* Created by: dengbw
* @param $item_id
* @param int $type
* @return array
*/
private function item_info($item_id, $type = 0)
{
$re = $this->mdItems->get(array('id' => $item_id));
if (!$re || empty($re)) {
return [];
}
$re_b = $this->mdAutoBrand->get(array('id' => $re['brand_id']), 'name');
$re_s = $this->mdAutoSeries->get(array('id' => $re['s_id']), 'name');
$re_v = $this->mdAutoAttr->get(array('id' => $re['v_id']), 'title');
$re_cor = $this->mdAutoAttr->get(array('id' => $re['cor_id']), 'title');
$title = '';
$re_b['name'] && $title = $re_b['name'];
$re_s['name'] && $title = $title ? $title . '-' . $re_s['name'] : $re_s['name'];
$re_v['title'] && $title = $title ? $title . '-' . $re_v['title'] : $re_v['title'];
if ($type == 1) {
$re_cor['title'] && $title = $title ? $title . '-' . $re_cor['title'] : $re_cor['title'];
}
$info['title'] = $title;
$info['vin'] = $re['vin'];
if ($type == 0) {
$info['id'] = $re['id'];
$info['cor'] = $re_cor['title'] ? $re_cor['title'] : '';
$address = '';
if ($re['biz_id'] > 0) {
$re_biz = $this->mdBiz->get(array('id' => $re['biz_id']));
$re_biz && $address = $re_biz['biz_name'];
if ($re_biz['county_id']) {
$re_area = $this->mdArea->get(array('county_id' => $re_biz['county_id']));
$re_area && $address = "{$re_area['city_name']} {$re_area['county_name']} {$address}";
} else if ($re_biz['city_id']) {
$re_area = $this->mdArea->get(array('city_id' => $re_biz['city_id']));
$re_area && $address = "{$re_area['city_name']} {$address}";
}
} else if ($re['biz_id'] == -1 && $re['addr_id']) {
$row_addr = $this->mdAddr->get(array('id' => $re['addr_id']));
$row_addr && $address = "{$row_addr['city_name']} {$row_addr['county_name']} 其它 {$row_addr['title']}";
}
$info['address'] = $address;
}
return $info;
}
}
+45
View File
@@ -1258,4 +1258,49 @@ class Goods extends HD_Controller
}
}
function json_info()
{
$vin = trim($this->input->post('vin'));
$item_id = intval($this->input->post('item_id'));
if ($vin) {
$re = $this->mdItems->get(array('vin' => $vin));
} else {
$re = $this->mdItems->get(array('id' => $item_id));
}
if (!$re || empty($re)) {
return $this->show_json(SYS_CODE_FAIL, '车辆不存在!');
}
$re_b = $this->mdAutoBrand->get(array('id' => $re['brand_id']), 'name');
$re_s = $this->mdAutoSeries->get(array('id' => $re['s_id']), 'name');
$re_v = $this->mdAutoAttr->get(array('id' => $re['v_id']), 'title');
$re_cor = $this->mdAutoAttr->get(array('id' => $re['cor_id']), 'title');
$title = '';
$re_b['name'] && $title = $re_b['name'];
$re_s['name'] && $title = $title ? $title . '-' . $re_s['name'] : $re_s['name'];
$re_v['title'] && $title = $title ? $title . '-' . $re_v['title'] : $re_v['title'];
$info['id'] = $re['id'];
$info['title'] = $title;
$info['vin'] = $re['vin'];
$info['cor'] = $re_cor['title'] ? $re_cor['title'] : '';
$address = '';
if ($re['biz_id'] > 0) {
$re_biz = $this->mdBiz->get(array('id' => $re['biz_id']));
$re_biz && $address = $re_biz['biz_name'];
if ($re_biz['county_id']) {
$re_area = $this->mdArea->get(array('county_id' => $re_biz['county_id']));
$re_area && $address = "{$re_area['city_name']} {$re_area['county_name']} {$address}";
} else if ($re_biz['city_id']) {
$re_area = $this->mdArea->get(array('city_id' => $re_biz['city_id']));
$re_area && $address = "{$re_area['city_name']} {$address}";
}
} else if ($re['biz_id'] == -1 && $re['addr_id']) {
$row_addr = $this->addr_model->get(array('id' => $re['addr_id']));
$row_addr && $address = "{$row_addr['city_name']} {$row_addr['county_name']} 其它 {$row_addr['title']}";
}
$info['address'] = $address;
$this->data = $info;
return $this->show_json(SYS_CODE_SUCCESS);
}
}
+76
View File
@@ -0,0 +1,76 @@
<form id="vue-edit" class="am-form am-form-horizontal" action="/auto/article/edit" data-auto="true" method="post" style="width: 90%;padding:25px 30px 20px 0;margin: 0 auto">
<div class="am-form-group">
<label class="am-para-label"><span class="com-must-star">*</span>名称:</label>
<div class="am-para-input"><input type="text" placeholder="请输入名称" name="title" v-model="info.title"/></div>
</div>
<div class="am-form-group">
<label class="am-para-label">状态:</label>
<div class="am-para-input wp50">
<select name="status" v-model="info.status">
<option v-for="(v,i) in statusAry" :value="i">{{v}}</option>
</select>
</div>
</div>
<div class="am-form-group" style="margin-bottom: 2rem">
<div class="am-para-input"><button class="am-btn am-btn-secondary" type="button" @click="saveEdit">提交</button></div>
</div>
</form>
<script>
var loading = 0;
var vue_obj;
$(function(){
vue_obj = new Vue({
el: '#vue-edit',
data: {
info:{},
statusAry:[],
action:''
},
mounted:function(){
var vm = this;
vm.info = <?=json_encode($info)?>;
vm.action = '<?=$action?>';
vm.statusAry = <?=json_encode($statusAry)?>;
},
methods:{
saveEdit:function(){
var vm = this;
if(1 == loading){
return 0;
}
loading = 1;
$.ajax({
url: vm.action,
type: 'post',
dataType: 'json',
data: {info:vm.info},
beforeSend: function () {
layer.load(1, {
shade: [0.1, '#fff'] //0.1透明度的白色背景
});
},
success: function (data) {
loading = 0;
if (data['code']) {
layer.msg(data.msg, {
icon: 1,
time: 2000
}, function () {
window.location.reload();
});
} else {
layer.msg(data.msg, {icon: 2});
}
},
complete: function () {
loading = 0;
layer.closeAll('loading');
}
});
}
},
watch:{}
});
});
</script>
+90
View File
@@ -0,0 +1,90 @@
<div class="coms-table-wrap">
<div class="coms-table-hd clearfix no-border">
<form action="/auto/article/lists" class="form-search" onsubmit="return false">
<div class="am-form am-form-horizontal">
<div class="am-form-group fl">
<label class="am-para-label">名称:</label>
<div class="am-para-inline w200">
<input type="text" name="title" id="input" placeholder="输入关键字" v-model="params.title"/>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">状态:</label>
<div class="am-para-inline w150">
<select name="status" v-model="params.status">
<option value="">请选择</option>
<option :value="i" v-for="(v,i) in statusAry">{{v}}</option>
</select>
</div>
</div>
<div class="am-form-group fl ml20">
<button type="submit" class="am-btn am-btn-sm am-btn-success w100">搜索</button>
<button data-modal="/auto/article/get" data-title="新增" type="button" class="am-btn am-btn-success w100 am-btn-sm">新增</button>
</div>
</div>
</form>
</div>
<div class="coms-table-bd">
<div class="fr">共有<?= $pager['totle'] ?>条数据</div>
<table class="am-table am-table-bordered">
<thead>
<tr>
<th width="5%"><span>ID</span></th>
<th width="60%"><span>名称</span></th>
<th width="10%"><span>状态</span></th>
<th width=""><span>操作</span></th>
</tr>
</thead>
<tbody>
<tr v-for="(v,i) in lists">
<td>{{v.id}}</td>
<td>{{v.title}}</td>
<td>{{v.status_name}}</td>
<td>
<a href="javascript:void(0);" :data-modal="'auto/article/get?id='+v.id"
class="am-btn am-btn-primary am-btn-xs">编辑</a>
<a data-ajax="post" data-action="/auto/article/edit_status" class="am-btn am-btn-danger am-btn-xs"
:data-params-id="v.id" :data-params-status="0" v-if="1==v.status">关闭</a>
<a data-ajax="post" data-action="/auto/article/edit_status" class="am-btn am-btn-success am-btn-xs"
:data-params-id="v.id" :data-params-status="1" v-if="0==v.status">开启</a>
<a data-ajax="post" data-action="/auto/article/del" class="am-btn am-btn-danger am-btn-xs"
:data-params-id="v.id">删除</a>
</td>
</tr>
</tbody>
</table>
</div>
<div class="coms-table-ft clearfix">
<div class="hander am-form">
</div>
<div class="coms-pagination fr mr20">
<?php page_view($pager) ?>
</div>
</div>
</div>
<script>
var vue_obj;
var loading = 0;
$(function(){
vue_obj = new Vue({
el: '.coms-table-wrap',
data: {
params:[],
statusAry:[],
lists:[]
},
mounted:function() {
var vm = this;
vm.params = <?=json_encode($params)?>;
vm.lists = <?=json_encode($lists)?>;
vm.statusAry = <?=json_encode($statusAry)?>;
},
methods:{},
watch:{}
});
<?php page_script($pager) ?>
});
</script>
+1 -1
View File
@@ -31,7 +31,7 @@
<thead>
<tr>
<th width="5%"><span>ID</span></th>
<th width="25%"><span>名称</span></th>
<th width="60%"><span>名称</span></th>
<th width="10%"><span>状态</span></th>
<th width=""><span>操作</span></th>
</tr>
+26 -14
View File
@@ -161,7 +161,7 @@
<label class="am-para-label">商家地址:</label>
<div class="am-para-input">
<div class="am-form-inline">
<div class="am-form-group" style="display: none">
<div class="am-form-group" style="display: none">
<select name="province_id" style="width: 200px;" data-toggle="next-select"
data-refurl="/common/area?key=city&id={value}&url=edit" data-next="#bd-hd-city">
<option value="0">省份</option>
@@ -186,8 +186,9 @@
</select>
</div>
<div class="am-form-group">
<select id="bd-hd-county" name="county_id" style="width: 200px;" data-toggle="next-select"
data-refurl="/common/areas?id={value}" data-next="#bd-hd-area">
<!--<select id="bd-hd-county" name="county_id" style="width: 200px;" data-toggle="next-select"-->
<!-- data-refurl="/common/area?key=street&id={value}" data-next="#bd-hd-street">-->
<select id="bd-hd-county" name="county_id" style="width: 200px;">
<option value="0">行政区</option>
<?php if ($countys) {
foreach ($countys as $value) { ?>
@@ -197,8 +198,18 @@
} ?>
</select>
</div>
<!--
<div class="am-form-group">
<div class="am-form-group" style="display: none">
<select id="bd-hd-street" name="street_id" style="width: 200px;">
<option value="0">街道/乡镇</option>
<?php if ($street) {
foreach ($street as $value) { ?>
<option value="<?= $value['id'] ?>"
<?= $value['id'] == $biz['street_id'] ? 'selected' : '' ?>><?= $value['name'] ?></option>
<?php }
} ?>
</select>
</div>
<div class="am-form-group" style="display: none">
<select name="area_id" style="width: 200px;" id="bd-hd-area">
<option value="0">商圈</option>
<?php if ($areas) {
@@ -209,7 +220,6 @@
} ?>
</select>
</div>
-->
</div>
</div>
</div>
@@ -296,7 +306,7 @@
<div class="am-para-input">
<div class="am-g">
<label class="mr10" style="margin-top: 7px" v-for="(v,i) in auto_brands">
<input type="checkbox" name="auto_brands[]" :value="v.id" v-model="info.auto_brands" />{{v.name}}
<input type="checkbox" name="auto_brands[]" :value="v.id" v-model="info.auto_brands"/>{{v.name}}
</label>
</div>
</div>
@@ -443,22 +453,23 @@
typeAry:<?=json_encode($typeAry)?>,
companyAry:<?=json_encode($companyAry)?>,
info:<?=json_encode($biz)?>,
auto_brands:[]
auto_brands: []
},
mounted:function(){
mounted: function () {
var vm = this;
console.log(vm.info);
vm.init_auto_brands();
},
methods: {
init_auto_brands:function(){
init_auto_brands: function () {
var vm = this;
$.ajax({
url: '/auto/brand/json_lists',
type: 'post',
dataType: 'json',
data: {status:1},
beforeSend: function () {},
data: {status: 1},
beforeSend: function () {
},
success: function (data) {
if (1 == data.code) {
vm.auto_brands = data.data.list;
@@ -473,12 +484,13 @@
},
created: function () {
},
watch:{
'info.auto_brands':function(nv, ov){
watch: {
'info.auto_brands': function (nv, ov) {
console.log(nv);
}
}
});
/**
* 根据地址定位
* @param addr
+73
View File
@@ -0,0 +1,73 @@
<div id="vue-edit" class="am-form am-form-horizontal" style="width: 100%;padding-top: 10px">
<div class="am-form-group">
<div class="coms-table-bd">
<table class="am-table am-table-bordered">
<thead>
<tr>
<th width="30%"><span>车辆</span></th>
<th width="20%"><span>车架号</span></th>
<th width="10%"><span>颜色</span></th>
<th width="25%"><span>存放信息</span></th>
</tr>
</thead>
<tbody>
<tr>
<td>{{info.items_info.title}}</td>
<td>{{info.items_info.vin}}</td>
<td>{{info.items_info.cor}}</td>
<td>{{info.items_info.address}}</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="am-panel am-panel-default">
<div class="am-panel-hd"><span style="font-size: 20px">调拨信息</span></div>
<div class="am-panel-bd am-g" style="margin: 10px">
<? foreach ($fields as $key => $value) { ?>
<div class="am-form-inline" style="line-height: 37px;font-size: 1.6rem;">
<?= $value['title'] ?><?= $value['value'] ?>
</div>
<? } ?>
<? if ($abnormal) { ?>
<div class="am-form-inline">
<? if ($abnormal['imgs']) { ?>
<div class="photo-upload">
<?php foreach ($abnormal['imgs'] as $key => $val) { ?>
<div class="photo-upload-item">
<a href="javascript:void (0);">
<img src="<?= $val ?>"
class="img-thumbnail" data-tips-image
style="height:auto;max-height:100px;min-width:100px">
</a>
</div>
<? } ?>
</div>
<? } ?>
</div>
<? if ($abnormal['note']) { ?>
<div class="am-form-inline">
<textarea rows="5" disabled style="width: 50%"><?= $abnormal['note'] ?></textarea>
</div>
<? } ?>
<? } ?>
</div>
</div>
</div>
<script>
var vue_obj;
$(function () {
vue_obj = new Vue({
el: '#vue-edit',
data: {
info: {'items_info': {}},
},
mounted: function () {
var vm = this;
vm.info = <?=json_encode($info)?>;
},
methods: {},
watch: {}
});
});
</script>
+468
View File
@@ -0,0 +1,468 @@
<div id="vue-edit" class="am-form am-form-horizontal" style="width: 100%;padding-top: 10px">
<div class="am-form-group">
<div class="am-para-input" style="padding-left: 0px;margin-left: 0px">
<div class="am-form-inline">
<div class="am-form-group" style="width:30%">
<input type="text" v-model="showInfo.vin" placeholder="请输入车架号">
</div>
<div class="am-form-group ml10">
<button type="button" class="am-btn am-btn-sm am-btn-success w100" @click='searchItems();'>搜索车辆
</button>
</div>
</div>
</div>
</div>
<div class="am-form-group" v-if="showInfo.items_info.vin">
<div class="coms-table-bd">
<table class="am-table am-table-bordered">
<thead>
<tr>
<th width="30%"><span>车辆</span></th>
<th width="20%"><span>车架号</span></th>
<th width="10%"><span>颜色</span></th>
<th width="25%"><span>存放信息</span></th>
<th width="10%"><span>操作</span></th>
</tr>
</thead>
<tbody>
<tr>
<td>{{showInfo.items_info.title}}</td>
<td>{{showInfo.items_info.vin}}</td>
<td>{{showInfo.items_info.cor}}</td>
<td>{{showInfo.items_info.address}}</td>
<td v-if="info.item_id">已选择</td>
<td v-else><a href="javascript:void(0);" @click='chooseItems();'>选择</a></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="am-panel am-panel-default" v-if="info.item_id">
<div class="am-panel-hd"><span style="font-size: 20px">调拨信息</span></div>
<div class="am-panel-bd am-g" style="margin-top: 10px;margin-bottom: 10px;">
<div class="am-form-group">
<label class="am-para-label">随车物品:</label>
<div class="am-para-input">
<div class="am-g">
<label class="mr10" style="margin-top: 7px" v-for="(v,i) in auto_article">
<input type="checkbox" :value="v.id" v-model="info.arti_id"/> {{v.title}}
</label>
</div>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label w100">提车人:</label>
<div class="am-para-inline w120">
<select title="城市" v-model="carOut.city_id">
<option value="">选择城市</option>
<option :value="v.id" v-for="(v,i) in carOut.cityAry">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w120">
<select title="行政区" v-model="carOut.county_id">
<option value="">选择行政区</option>
<option :value="v.id" v-for="(v,i) in carOut.countyAry">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w150">
<select v-model="carOut.biz_id">
<option value="">门店</option>
<template v-for="(v,i) in carOut.bizAry">
<option :value="v.id">{{v.title}}</option>
</template>
</select>
</div>
<div class="am-para-inline w120">
<select v-model="info.out_uid">
<option value="">提车人</option>
<template v-for="(v,i) in carOut.list">
<option :value="v.id">{{v.title}}</option>
</template>
</select>
</div>
<div class="am-para-inline ml20" style="padding-top: 3px;">
<button type="button" class="am-btn am-btn-default am-btn-sm" @click='addBak("out");'>
{{info.out_bak?'删除备用提车人':'添加备用提车人'}}
</button>
</div>
<div class="am-para-inline w120 ml20" v-if="info.out_bak">
<select v-model="info.out_uid_bak">
<option value="">备用提车人</option>
<template v-for="(v,i) in carOut.list">
<option :value="v.id">{{v.title}}</option>
</template>
</select>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label w100">接车人:</label>
<div class="am-para-inline w120">
<select title="城市" v-model="carIn.city_id">
<option value="">选择城市</option>
<option :value="v.id" v-for="(v,i) in carIn.cityAry">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w120">
<select title="行政区" v-model="carIn.county_id">
<option value="">选择行政区</option>
<option :value="v.id" v-for="(v,i) in carIn.countyAry">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w150">
<select v-model="carIn.biz_id">
<option value="">门店</option>
<template v-for="(v,i) in carIn.bizAry">
<option :value="v.id">{{v.title}}</option>
</template>
</select>
</div>
<div class="am-para-inline w120">
<select v-model="info.in_uid">
<option value="">接车人</option>
<template v-for="(v,i) in carIn.list">
<option :value="v.id">{{v.title}}</option>
</template>
</select>
</div>
<div class="am-para-inline ml20" style="padding-top: 3px;">
<button type="button" class="am-btn am-btn-default am-btn-sm" @click='addBak("in");'>
{{info.in_bak?'删除备用接车人':'添加备用接车人'}}
</button>
</div>
<div class="am-para-inline w120 ml20" v-if="info.in_bak">
<select v-model="info.in_uid_bak">
<option value="">备用接车人</option>
<template v-for="(v,i) in carIn.list">
<option :value="v.id">{{v.title}}</option>
</template>
</select>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label w100">运输费用:</label>
<div class="am-para-inline w120">
<input type="text" v-model="info.trailer_fees" placeholder="费用">
</div>
<label class="am-para-label w110">费用承担人:</label>
<div class="am-para-inline w120">
<select v-model="info.fees_city">
<option value="">选择城市</option>
<option :value="v.id" v-for="(v,i) in carOut.cityAry">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w120">
<select v-model="info.fees_type">
<option :value="i" v-for="(v,i) in showInfo.feesTypeAry">{{v}}</option>
</select>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label w100">运输人员:</label>
<div class="am-para-inline w120">
<input type="text" v-model="info.transport.name" placeholder="姓名">
</div>
<div class="am-para-inline w150">
<input type="text" v-model="info.transport.mobile" placeholder="电话">
</div>
<div class="am-para-inline w200">
<input type="text" v-model="info.transport.cardid" placeholder="身份证号码">
</div>
</div>
<div class="am-form-group" style="width: 80%;padding-left: 100px;">
常用运输人员:
<button v-for="(v,i) in transports" type="button" class="am-btn am-btn-default am-btn-sm"
style="margin-bottom: 3px;margin-right: 5px;" @click='chooseTransports(i);'>
{{v.name}}
</button>
</div>
<div class="am-form-group">
<a href="javascript:void(0);" @click='saveAdd();' style="margin-left: 3.5rem;margin-top: 4rem;"
class="am-btn ml20 am-btn-sm am-btn-success w100">保存</a>
</div>
</div>
</div>
</div>
<script>
var loading = 0;
var vue_obj;
$(function () {
vue_obj = new Vue({
el: '#vue-edit',
data: {
info: {'item_id': 0},
showInfo: {items_info: {'vin': ""}},
auto_article: {},
transports: [],
carOut: {city_id: "", county_id: "", biz_id: "", cityAry: [], countyAry: [], bizAry: [], list: []},
carIn: {city_id: "", county_id: "", biz_id: "", cityAry: [], countyAry: [], bizAry: [], list: []},
},
mounted: function () {
var vm = this;
vm.info = <?=json_encode($info)?>;
vm.showInfo = <?=json_encode($showInfo)?>;
vm.transports = <?=json_encode($transports)?>;
vm.init_auto_article();
vm.init_citys();
},
methods: {
init_auto_article: function () {
var vm = this;
$.ajax({
url: '/auto/article/json_lists',
type: 'post',
dataType: 'json',
data: {status: 1},
beforeSend: function () {
},
success: function (data) {
if (data.code) {
vm.auto_article = data.data.list;
}
},
complete: function () {
}
});
},
init_citys: function () {
var vm = this;
$.ajax({
type: 'get',
url: '/common/area',
dataType: 'json',
data: {
id: '350',
key: 'city',
type: 1
},
success: function (response) {
if (response.code == 1) {
vm.carOut.cityAry = JSON.parse(JSON.stringify(response.data));
vm.carIn.cityAry = JSON.parse(JSON.stringify(response.data));
}
}
});
},
searchItems: function () {
var vm = this;
if (!vm.showInfo.vin) {
layer.msg("请输入车架号");
return;
}
$.ajax({
type: 'post',
url: '/items/goods/goods/json_info',
dataType: 'json',
data: {vin: vm.showInfo.vin},
success: function (re) {
vm.info.item_id = 0;
if (re.code) {
vm.showInfo.items_info = re.data;
} else {
vm.showInfo.items_info = {items_info: {'item_id': 0, 'vin': ""}};
layer.msg(re.msg, {icon: 2});
}
}
});
},
addBak: function (type) {
var vm = this;
if (type == 'out') {
vm.info.out_bak = vm.info.out_bak ? 0 : 1;
vm.info.out_uid_bak = '';
} else if (type == 'in') {
vm.info.in_bak = vm.info.in_bak ? 0 : 1;
vm.info.in_uid_bak = '';
}
},
chooseItems: function () {
var vm = this;
if (!vm.showInfo.items_info.id) {
layer.msg("请先搜索车辆");
return;
}
vm.info.item_id = vm.showInfo.items_info.id;
},
chooseTransports: function (i) {
var vm = this;
vm.info.transport = {
'name': vm.transports[i].name, 'mobile': vm.transports[i].mobile
, 'cardid': vm.transports[i].cardid
};
},
saveAdd: function () {
var vm = this;
$.ajax({
url: '/items/transfer/add',
type: 'post',
dataType: 'json',
data: {info: vm.info, items_info: vm.showInfo.items_info},
beforeSend: function () {
layer.load(1, {
shade: [0.1, '#fff'] //0.1透明度的白色背景
});
},
success: function (data) {
if (data['code']) {
layer.msg(data.msg, {
icon: 1,
time: 2000
}, function () {
window.location.reload();
});
} else {
layer.msg(data.msg, {icon: 2});
}
},
complete: function () {
layer.closeAll('loading');
}
});
}
},
watch: {
'carOut.city_id': function (nv, ov) {
var that = this;
if (nv == '') {
that.carOut.countyAry = [];
that.carOut.county_id = '';
} else {
if (nv.substring(0, 4) != that.carOut.county_id.substring(0, 4)) {
that.carOut.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.carOut.countyAry = response.data;
}
}
});
}
},
'carOut.county_id': function (nv, ov) {
var that = this;
if (nv == '') {
that.carOut.bizAry = [];
that.carOut.biz_id = '';
} else {
$.ajax({
type: 'post',
url: '/biz/store/store/json_lists',
dataType: 'json',
data: {
city_id: that.carOut.city_id,
county_id: that.carOut.county_id,
status: 1
},
success: function (response) {
if (response.code == 1) {
that.carOut.bizAry = response.data.list;
}
}
});
}
},
'carOut.biz_id': function (nv, ov) {
var that = this;
if (nv == '') {
that.carOut.list = [];
that.carOut.admin_id = '';
} else {
$.ajax({
type: 'post',
url: '/app/licheb/member/json_lists',
dataType: 'json',
data: {
biz_id: nv,
status: 1
},
success: function (response) {
if (response.code == 1) {
that.carOut.list = response.data.list;
}
}
});
}
},
'carIn.city_id': function (nv, ov) {
var that = this;
if (nv == '') {
that.carIn.countyAry = [];
that.carIn.county_id = '';
} else {
if (nv.substring(0, 4) != that.carIn.county_id.substring(0, 4)) {
that.carIn.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.carIn.countyAry = response.data;
}
}
});
}
},
'carIn.county_id': function (nv, ov) {
var that = this;
if (nv == '') {
that.carIn.bizAry = [];
that.carIn.biz_id = '';
} else {
$.ajax({
type: 'post',
url: '/biz/store/store/json_lists',
dataType: 'json',
data: {
city_id: that.carIn.city_id,
county_id: that.carIn.county_id,
status: 1
},
success: function (response) {
if (response.code == 1) {
that.carIn.bizAry = response.data.list;
}
}
});
}
},
'carIn.biz_id': function (nv, ov) {
var that = this;
if (nv == '') {
that.carIn.list = [];
that.carIn.admin_id = '';
} else {
$.ajax({
type: 'post',
url: '/app/licheb/member/json_lists',
dataType: 'json',
data: {
biz_id: nv,
status: 1
},
success: function (response) {
if (response.code == 1) {
that.carIn.list = response.data.list;
}
}
});
}
}
}
});
});
</script>
+529
View File
@@ -0,0 +1,529 @@
<div class="coms-table-wrap">
<div class="coms-table-hd clearfix no-border">
<form action="/items/transfer/lists" class="form-search" onsubmit="return false">
<div class="am-form am-form-horizontal">
<div class="am-form-group fl">
<label class="am-para-label w70">车架号:</label>
<div class="am-para-inline w200">
<input type="text" name="title" id="title" placeholder="输入车架号" value="<?= $params['title'] ?>"/>
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w70">状态:</label>
<div class="am-para-inline w100">
<select id="status" name="status" v-model="params.status">
<option value="">选择状态</option>
<option :value="i" v-for="(v,i) in statusAry">{{v}}</option>
</select>
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w70">异常:</label>
<div class="am-para-inline w100">
<select id="abnormal" name="abnormal" v-model="params.abnormal">
<option value="">选择异常</option>
<option :value="i" v-for="(v,i) in abnormalAry">{{v}}</option>
</select>
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w70">车型:</label>
<div class="am-para-inline w120">
<select id="brand_id" name="brand_id" data-toggle="next-select"
data-refurl="/common/auto?pid={value}&type=2"
data-next="#s_id">
<option value="0">选择品牌</option>
<? if ($autoList[1]) {
foreach ($autoList[1] as $v) { ?>
<option value="<?= $v['id'] ?>" <?= $v['id'] == $params['brand_id'] ? 'selected' : '' ?>
><?= $v['name'] ?></option>
<? }
} ?>
</select>
</div>
</div>
<div class="am-form-group fl">
<div class="am-para-inline w120">
<select id="s_id" name="s_id" data-toggle="next-select"
data-refurl="/common/auto?pid={value}&type=3"
data-next="#v_id">
<option value="0">选择车系</option>
<?php if ($autoList[2]) {
foreach ($autoList[2] as $v) { ?>
<option value="<?= $v['id'] ?>" <?= $v['id'] == $params['s_id'] ? 'selected' : '' ?>
><?= $v['name'] ?></option>
<?php }
} ?>
</select>
</div>
</div>
<div class="am-form-group fl">
<div class="am-para-inline w220">
<select id="v_id" name="v_id">
<option value="0">选择车型</option>
<?php if ($autoList[3]) {
foreach ($autoList[3] as $v) { ?>
<option value="<?= $v['id'] ?>" <?= $v['id'] == $params['v_id'] ? 'selected' : '' ?>
><?= $v['name'] ?></option>
<?php }
} ?>
</select>
</div>
</div>
<div class="am-form-group" style="margin-bottom: 0px;"></div>
<div class="am-form-group fl">
<label class="am-para-label w70">提车人:</label>
<div class="am-para-inline w120">
<select title="城市" name="city_id_out" v-model="params.city_id_out">
<option value="">选择城市</option>
<option :value="v.id" v-for="(v,i) in outs.cityAry">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w120">
<select title="行政区" name="county_id_out" v-model="params.county_id_out">
<option value="">选择行政区</option>
<option :value="v.id" v-for="(v,i) in outs.countyAry">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w120">
<select name="biz_id_out" v-model="params.biz_id_out">
<option value="">门店</option>
<template v-for="(v,i) in outs.bizAry">
<option :value="v.id">{{v.title}}</option>
</template>
</select>
</div>
<div class="am-para-inline w120">
<select name="out_uid" v-model="params.out_uid">
<option value="">提车人</option>
<template v-for="(v,i) in outs.list">
<option :value="v.id">{{v.title}}</option>
</template>
</select>
</div>
</div>
<div class="am-form-group fl">
<div class="am-form-group" style="margin-bottom: 0px;"></div>
<label class="am-para-label w100">提车时间:</label>
<div class="am-form-group fl">
<div class="am-para-inline w220">
<input id="out_time" name="out_time" type="text" value="<?= $params['out_time'] ?>"
placeholder="提车时间范围" autocomplete="off"/>
</div>
<div class="am-para-inline" style="padding-top: 5px;">
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="today"
data-source="out_time">今天</a>
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="yesterday"
data-source="out_time">昨日</a>
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="7day"
data-source="out_time">最近7天</a>
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="30day"
data-source="out_time">最近30天</a>
</div>
</div>
</div>
<div class="am-form-group" style="margin-bottom: 0px;"></div>
<div class="am-form-group fl">
<label class="am-para-label w70">接车人:</label>
<div class="am-para-inline w120">
<select title="城市" name="city_id_in" v-model="params.city_id_in">
<option value="">选择城市</option>
<option :value="v.id" v-for="(v,i) in ins.cityAry">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w120">
<select title="行政区" name="county_id_in" v-model="params.county_id_in">
<option value="">选择行政区</option>
<option :value="v.id" v-for="(v,i) in ins.countyAry">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w120">
<select name="biz_id_in" v-model="params.biz_id_in">
<option value="">门店</option>
<template v-for="(v,i) in ins.bizAry">
<option :value="v.id">{{v.title}}</option>
</template>
</select>
</div>
<div class="am-para-inline w120">
<select name="in_uid" v-model="params.in_uid">
<option value="">接车人</option>
<template v-for="(v,i) in ins.list">
<option :value="v.id">{{v.title}}</option>
</template>
</select>
</div>
</div>
<div class="am-form-group fl">
<div class="am-form-group" style="margin-bottom: 0px;"></div>
<label class="am-para-label w100">接车时间:</label>
<div class="am-form-group fl">
<div class="am-para-inline w220">
<input id="in_time" name="in_time" type="text" value="<?= $params['in_time'] ?>"
placeholder="接车时间范围" autocomplete="off"/>
</div>
<div class="am-para-inline" style="padding-top: 5px;">
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="today"
data-source="in_time">今天</a>
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="yesterday"
data-source="in_time">昨日</a>
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="7day"
data-source="in_time">最近7天</a>
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="30day"
data-source="in_time">最近30天</a>
</div>
</div>
</div>
<div class="am-form-group" style="margin-bottom: 0px;"></div>
<div class="am-form-group ml20">
<button type="submit" class="am-btn am-btn-sm am-btn-success w100">搜索</button>
<button type="button" class="am-btn am-btn-success am-btn-sm w100" @click="reset">重置</button>
<button data-open="/items/transfer/get" data-title="新增" type="button"
class="am-btn am-btn-success w100 am-btn-sm">新增
</button>
<button type="button" id="export" class="am-btn am-btn-success am-btn-sm w100">导出</button>
</div>
</div>
</form>
</div>
<div class="coms-table-bd">
<div class="fr">共有<?= $pager['totle'] ?>条数据</div>
<table class="am-table am-table-bordered">
<thead>
<tr>
<th width="22%"><span>车辆</span></th>
<th width="15%"><span>车架号</span></th>
<th width="7%"><span>运输人员</span></th>
<th width="12%"><span>调拨时间</span></th>
<th width="15%"><span>提车人/提车时间</span></th>
<th width="15%"><span>接车人/接车时间</span></th>
<th width="7%"><span>是否异常</span></th>
<th width="7%"><span>状态</span></th>
<th width="7%"><span>操作</span></th>
</tr>
</thead>
<tbody>
<tr v-for="(v,i) in lists">
<td>{{v.title}}</td>
<td>{{v.vin}}</td>
<td>{{v.transport_name}}</td>
<td>{{v.c_time}}</td>
<td>{{v.out_uid_title}}</td>
<td>{{v.in_uid_title}}</td>
<td>{{v.abnormal}}</td>
<td>{{v.status_name}}</td>
<td>
<a href="javascript:void(0);" :data-open="'items/transfer/get?id='+v.id">查看详情</a>
</td>
</tr>
</tbody>
</table>
</div>
<div class="coms-table-ft clearfix">
<div class="hander am-form">
</div>
<div class="coms-pagination fr mr20">
<?php page_view($pager) ?>
</div>
</div>
</div>
<script>
var vue_obj;
var loading = 0;
$(function () {
vue_obj = new Vue({
el: '.coms-table-wrap',
data: {
params: [],
statusAry: [],
abnormalAry: [],
outs: {cityAry: [], countyAry: [], bizAry: [], list: []},
ins: {cityAry: [], countyAry: [], bizAry: [], list: []},
lists: []
},
mounted: function () {
var vm = this;
vm.params = <?=json_encode($params)?>;
vm.lists = <?=json_encode($lists)?>;
vm.statusAry = <?=json_encode($statusAry)?>;
vm.abnormalAry = <?=json_encode($abnormalAry)?>;
vm.init_citys();
},
methods: {
reset: function () {
var that = this;
$('#title').val('');
$('#brand_id').val('0');
$('#s_id').val('0');
$('#v_id').val('0');
$('#out_time').val('');
$('#in_time').val('');
that.params.status = '';
that.params.abnormal = '';
that.params.city_id_out = '';
that.params.county_id_out = '';
that.params.biz_id_out = '';
that.params.out_uid = '';
that.params.city_id_in = '';
that.params.county_id_in = '';
that.params.biz_id_in = '';
that.params.out_in = '';
},
init_citys: function () {
var vm = this;
$.ajax({
type: 'get',
url: '/common/area',
dataType: 'json',
data: {
id: '350',
key: 'city',
type: 1
},
success: function (response) {
if (response.code == 1) {
vm.outs.cityAry = JSON.parse(JSON.stringify(response.data));
vm.ins.cityAry = JSON.parse(JSON.stringify(response.data));
}
}
});
},
},
watch: {
'params.city_id_out': function (nv, ov) {
var that = this;
if (nv == '') {
that.outs.countyAry = [];
that.params.county_id_out = '';
} else {
if (nv.substring(0, 4) != that.params.county_id_out.substring(0, 4)) {
that.params.county_id_out = '';
}
$.ajax({
type: 'get',
url: '/common/area',
dataType: 'json',
data: {
id: nv,
key: 'county',
type: 1
},
success: function (response) {
if (response.code == 1) {
that.outs.countyAry = response.data;
}
}
});
}
},
'params.county_id_out': function (nv, ov) {
var that = this;
if (nv == '') {
that.outs.bizAry = [];
that.params.biz_id_out = '';
} else {
$.ajax({
type: 'post',
url: '/biz/store/store/json_lists',
dataType: 'json',
data: {
city_id: that.params.city_id_out,
county_id: that.params.county_id_out,
status: 1
},
success: function (response) {
if (response.code == 1) {
that.outs.bizAry = response.data.list;
if (that.params.biz_id_out > 0) {
var biz_id = '';
for (var i in that.outs.bizAry) {
if (that.params.biz_id_out == that.outs.bizAry[i].id) {
biz_id = that.params.biz_id_out;
break;
}
}
that.params.biz_id_out = biz_id;
}
}
}
});
}
},
'params.biz_id_out': function (nv, ov) {
var that = this;
if (nv == '') {
that.outs.list = [];
that.params.out_uid = '';
} else {
$.ajax({
type: 'post',
url: '/app/licheb/member/json_lists',
dataType: 'json',
data: {
biz_id: nv,
status: 1
},
success: function (response) {
if (response.code == 1) {
that.outs.list = response.data.list;
if (that.params.out_uid > 0) {
var out_uid = '';
for (var i in that.outs.list) {
if (that.params.out_uid == that.outs.list[i].id) {
out_uid = that.params.out_uid;
break;
}
}
that.params.out_uid = out_uid;
}
}
}
});
}
},
'params.city_id_in': function (nv, ov) {
var that = this;
if (nv == '') {
that.ins.countyAry = [];
that.params.county_id_in = '';
} else {
if (nv.substring(0, 4) != that.params.county_id_in.substring(0, 4)) {
that.params.county_id_in = '';
}
$.ajax({
type: 'get',
url: '/common/area',
dataType: 'json',
data: {
id: nv,
key: 'county',
type: 1
},
success: function (response) {
if (response.code == 1) {
that.ins.countyAry = response.data;
}
}
});
}
},
'params.county_id_in': function (nv, ov) {
var that = this;
if (nv == '') {
that.ins.bizAry = [];
that.params.biz_id_in = '';
} else {
$.ajax({
type: 'post',
url: '/biz/store/store/json_lists',
dataType: 'json',
data: {
city_id: that.params.city_id_in,
county_id: that.params.county_id_in,
status: 1
},
success: function (response) {
if (response.code == 1) {
that.ins.bizAry = response.data.list;
if (that.params.biz_id_in > 0) {
var biz_id = '';
for (var i in that.ins.bizAry) {
if (that.params.biz_id_in == that.ins.bizAry[i].id) {
biz_id = that.params.biz_id_in;
break;
}
}
that.params.biz_id_in = biz_id;
}
}
}
});
}
},
'params.biz_id_in': function (nv, ov) {
var that = this;
if (nv == '') {
that.ins.list = [];
that.params.in_uid = '';
} else {
$.ajax({
type: 'post',
url: '/app/licheb/member/json_lists',
dataType: 'json',
data: {
biz_id: nv,
status: 1
},
success: function (response) {
if (response.code == 1) {
that.ins.list = response.data.list;
if (that.params.in_uid > 0) {
var in_uid = '';
for (var i in that.ins.list) {
if (that.params.in_uid == that.ins.list[i].id) {
in_uid = that.params.in_uid;
break;
}
}
that.params.in_uid = in_uid;
}
}
}
});
}
}
}
});
<?php page_script($pager) ?>
$('#export').click(function () {
var count = <?=$pager['totle']?>;
if (count > 10000) {
layer.msg('单次导出数据不能超过10000');
return false;
}
var href = $.menu.parseUri(window.location.href);
var arr = href.split('?');
href = '/items/transfer/export?' + arr[1];
window.location.href = href;
});
$('#brand_id').change(function () {
$('#s_id').empty();
$('#v_id').empty();
$("#v_id").prepend("<option value='0'>选择车型</option>");
});
$('#s_id').change(function () {
$('#v_id').empty();
});
require(['laydate', 'autocomplete'], function (laydate) {
laydate.render({
elem: '#out_time', range: '~'
});
laydate.render({
elem: '#in_time', range: '~'
});
$('.id-day-btn').click(function () {
var type = $(this).data('date'), date = '', d_obj = new Date();
var source_id = $(this).data('source') || 'out_time';
switch (type) {
case 'today':
date = d_obj.Format('yyyy-MM-dd');
date = date + ' ~ ' + date;
break;
case 'yesterday':
date = (new Date(d_obj.getTime() - 86400000)).Format('yyyy-MM-dd');
date = date + ' ~ ' + date;
break;
case '7day':
date = (new Date(d_obj.getTime() - 86400000 * 7)).Format('yyyy-MM-dd') + ' ~ ' + d_obj.Format('yyyy-MM-dd');
break;
case '30day':
date = (new Date(d_obj.getTime() - 86400000 * 30)).Format('yyyy-MM-dd') + ' ~ ' + d_obj.Format('yyyy-MM-dd');
break;
}
$('#' + source_id).val(date);
});
});
});
</script>
+60 -11
View File
@@ -16,6 +16,53 @@ class Temp extends HD_Controller
$this->log_file = 'temp.log';
}
/**
* Notes:新增街道
* Created on: 2021/12/14 11:58
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/temp/add_street
* https://api.liche.cn/plan/temp/add_street
*/
public function add_street()
{
$this->load->model('sys/Sys_area_model', 'mdSysArea');
$this->load->model('sys/Sys_street_model', 'mdSysStreet');
$this->load->model('sys/Bs_street_model', 'mdBsStreet');//表已经删除
$param = $this->input->get();
$param['page'] = intval($param['page']);
$param['size'] = intval($param['size']);
!$param['size'] && $param['size'] = 5;
!$param['page'] && $param['page'] = 1;
$counts = intval($param['counts']);
ob_start(); //打开缓冲区
$res = $this->mdSysArea->select(['status' => 1], 'id ASC', $param['page'], $param['size'], 'county_id');
if (!$res) {
echo '<br>本次新增街道完成了:';
echo '<br><br>成功新增街道 <span style="color: red;">' . $counts . '</span> 条';
echo '<br><br><a href="/plan/temp/add_street">点击将再次新增街道>>></a>';
exit;
}
$log = array();
foreach ($res as $key => $value) {
$res_bs = $this->mdBsStreet->select(['AREA_CODE' => $value['county_id']], 'STREET_ID ASC', 0, 0, 'STREET_CODE,STREET_NAME');
$add = [];
foreach ($res_bs as $key2 => $value2) {
$add[] = ['county_id' => $value['county_id'], 'street_id' => $value2['STREET_CODE'], 'street_name' => $value2['STREET_NAME']];
$log[] = array('street_name' => $value2['STREET_NAME'], 'street_id' => $value2['STREET_CODE']);
$counts++;
}
if ($add) {
$this->mdSysStreet->add_batch($add);
}
}
echo '<br>成功更新:';
$log && print_r($log);
echo '<br><br>数据库获取:';
echo json_encode($res, JSON_UNESCAPED_UNICODE);
header('refresh:3;url=/plan/temp/add_street?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1));
ob_end_flush();//输出全部内容到浏览器
}
/**
* Notes:更新狸车宝渠道门店
* Created on: 2021/9/18 11:58
@@ -157,8 +204,10 @@ class Temp extends HD_Controller
header('refresh:3;url=/plan/temp/receiver_customer?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1));
ob_end_flush();//输出全部内容到浏览器
}
//更新下定时间
public function order_time(){
public function order_time()
{
$this->load->model('receiver/order/receiver_orders_model');
$this->load->model('app/liche/app_liche_orders_model');
@@ -173,19 +222,19 @@ class Temp extends HD_Controller
'order_time' => '0000-00-00 00:00:00',
];
$rows = $this->receiver_orders_model->select($where, 'id ASC', $param['page'], $param['size'], 'id');
if($rows){
foreach($rows as $key=>$val){
$pay_row = $this->app_liche_orders_model->get(['o_id'=>$val['id'],'status'=>1,'type'=>1]);
if(!$pay_row){
$pay_row = $this->app_liche_orders_model->get(['o_id'=>$val['id'],'status'=>1,'type'=>4]);
if ($rows) {
foreach ($rows as $key => $val) {
$pay_row = $this->app_liche_orders_model->get(['o_id' => $val['id'], 'status' => 1, 'type' => 1]);
if (!$pay_row) {
$pay_row = $this->app_liche_orders_model->get(['o_id' => $val['id'], 'status' => 1, 'type' => 4]);
}
if ($pay_row) {
$this->receiver_orders_model->update(['order_time' => $pay_row['pay_time']], ['id' => $val['id']]);
}
if($pay_row){
$this->receiver_orders_model->update(['order_time'=>$pay_row['pay_time']],['id'=>$val['id']]);
}
}
$ids = implode(',',array_column($rows,'id'));
$ids = implode(',', array_column($rows, 'id'));
echo "do:{$ids} ";
}else{
} else {
echo 'finish';
}
}
+139
View File
@@ -0,0 +1,139 @@
<?php
defined('WXAPP_APP') OR exit('No direct script access allowed');
/**
* Notes:店铺操作
* Created on: 2021/12/15 16:43
* Created by: dengbw
*/
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
class Biz extends Wxapp
{
function __construct($inputs, $app_key)
{
parent::__construct($inputs, $app_key);
$this->login_white = array();//登录白名单
$this->check_status = array();//用户状态校验
$this->check_mobile = array();//需要手机号
$this->check_headimg = array();//授权微信信息
$this->load->model("biz/biz_model", 'mdBiz');
$this->load->model("biz/biz_base_model", 'mdBizBase');
$this->load->model("biz/biz_sell_model", 'mdBizSell');
}
protected function get_situation_tabs()
{
return [['id' => 0, 'name' => '基础信息'], ['id' => 1, 'name' => '售卖情况']];
}
protected function get_situation()
{
$tabs_id = intval($this->input_param('tabs_id'));
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
$re_biz = $this->mdBiz->get(['id' => $biz_id, 'status' => 1]);
if (!$re_biz) {
throw new Hd_exception('店铺不存在!', API_CODE_FAIL);
}
$info = [];
if ($tabs_id == 1) {//售卖情况
$re_sell = $this->mdBizSell->get(['biz_id' => $biz_id]);
$fields = $this->mdBizSell->get_fields();
if ($re_sell) {
foreach ($fields as $key => $value) {
$re_sell[$key] && $fields[$key]['value'] = $re_sell[$key];
}
}
} else {//基础信息
$this->load->model('area_model');
$this->load->model('sys/sys_street_model', 'mdStreet');
$re_base = $this->mdBizBase->get(['biz_id' => $biz_id]);
$fields = $this->mdBizBase->get_fields();
foreach ($fields as $key => $value) {
if ($key == 'county' && $re_biz['city_id']) {//县区
$result = $this->area_model->county($re_biz['city_id'], 1);
$fields[$key]['list'] = array_merge($value['list'], $result);
$re_biz['county_id'] && $fields[$key]['value'] = $re_biz['county_id'];
} else if ($key == 'street' && $re_biz['county_id']) {//乡镇
$result = [];
$list = $this->mdStreet->select(['county_id' => $re_biz['county_id']], 'id ASC', 0, 0, 'street_id,street_name');
foreach ($list as $v) {
$result[$v['street_id']] = array('id' => $v['street_id'], 'name' => $v['street_name']);
}
$fields[$key]['list'] = array_merge($value['list'], $result);
$re_biz['street_id'] && $fields[$key]['value'] = $re_biz['street_id'];
} else if ($key == 'type' && $re_biz['type']) {//类型
$fields[$key]['value'] = $re_biz['type'];
} else if ($key == 'level') {//级别
$fields[$key]['value'] = $this->level($biz_id);
} else if ($re_base && $re_base[$key]) {//有字段赋值
$fields[$key]['value'] = $re_base[$key];
}
$setValue = $fields[$key];
$setValue['field'] = $key;
$info[] = $setValue;
}
}
return $info;
}
/**
* Notes:报备异常
* Created on: 2021/12/10 16:07
* Created by: dengbw
* @throws Exception
*/
protected function post()
{
}
private function level($biz_id = 0)
{
$str = '';
if ($biz_id) {
$this->load->model('receiver/order/receiver_orders_model', 'mdOrders');
$where = ['biz_id' => $biz_id, 'status<>' => -1, 'brand_id<>' => 3, 'biz_id<>' => 1];
$last_month_s = date("Y-m-01", strtotime("-1 month"));//上1个月1日
$last_month_e = date("Y-m-d", strtotime("$last_month_s +1 month -1 day")); //上1个月最后一天
$orders = $this->mdOrders->count(array_merge($where, ['c_time >=' => strtotime($last_month_s . ' 00:00:00')
, 'c_time <=' => strtotime($last_month_e . ' 23:59:59')]));
if ($orders >= 12) {
$str = 'A1';
} else if ($orders >= 9) {
$str = 'A2';
} else if ($orders >= 6) {
$str = 'A3';
} else if ($orders >= 5) {
$str = 'B1';
} else if ($orders >= 4) {
$str = 'B2';
} else if ($orders >= 3) {
$str = 'B3';
} else {
$month_s = date("Y-m-01", strtotime("-3 month")); //上3月1日
$month_e = date("Y-m-d", strtotime("$month_s +1 month -1 day")); //上3个月最后一天
$orders = $this->mdOrders->count(array_merge($where, ['c_time >=' => strtotime($month_s . ' 00:00:00')
, 'c_time <=' => strtotime($month_e . ' 23:59:59')]));
if ($orders && $orders <= 8) {
$str = 'C1';
} else {
$month_s = date("Y-m-d", strtotime("$last_month_s -15 day"));//45天前
$month_e = $last_month_e; //上个月最后一天
$orders = $this->mdOrders->count(array_merge($where, ['c_time >=' => strtotime($month_s . ' 00:00:00')
, 'c_time <=' => strtotime($month_e . ' 23:59:59')]));
if ($orders == 1) {
$str = 'C2';
} else if ($orders == 0) {
$this->load->model('items/items_model', 'mdItems');
$count_items = $this->mdItems->count(['status<>' => 0, 'biz_id' => $biz_id, 'brand_id<>' => 3, 'biz_id<>' => 1]);
!$count_items && $str = 'C3';//门店有样车未开单
}
}
}
}
return $str;
}
}
+309
View File
@@ -0,0 +1,309 @@
<?php
defined('WXAPP_APP') OR exit('No direct script access allowed');
/**
* Notes:车辆调拨
* Created on: 2021/12/10 16:43
* Created by: dengbw
*/
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
class Transfer extends Wxapp
{
function __construct($inputs, $app_key)
{
parent::__construct($inputs, $app_key);
$this->login_white = array();//登录白名单
$this->check_status = array();//用户状态校验
$this->check_mobile = array();//需要手机号
$this->check_headimg = array();//授权微信信息
$this->load->model('items/items_transfer_model', 'mdTransfer');
$this->load->model('items/items_transfer_remind_model', 'mdTransferRemind');
$this->load->model('app/licheb/app_licheb_users_model', 'mdUsers');
$this->load->model('items/items_model', 'mdItems');
$this->load->model('auto/auto_brand_model', 'mdAutoBrand');
$this->load->model('auto/auto_series_model', 'mdAutoSeries');
$this->load->model('auto/auto_attr_model', 'mdAutoAttr');
$this->load->model("biz/biz_model", 'mdBiz');
}
/**
* Notes:调拨提醒
* Created on: 2021/12/10 17:03
* Created by: dengbw
* @return array
*/
protected function get_remind()
{
if ($this->session['group_id'] == 4) {
$total = 0;
} else {
$total = $this->mdTransferRemind->count(['uid' => $this->myuid, 'status' => 1]);
}
$data = ['total' => $total];
return $data;
}
protected function get_lists()
{
$page = $this->input_param('page');
$size = $this->input_param('size');
$s_date = $this->input_param('s_date');
$e_date = $this->input_param('e_date');
!$page && $page = 1;
!$size && $size = 5;
if ($this->session['group_id'] == 4) {//渠道经理
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
!$biz_id && $biz_id = -1;
$where = ['status <>' => -1, "biz_id in({$biz_id})" => null];
$s_date && $where['c_time >='] = strtotime($s_date . ' 00:00:00');
$e_date && $where['c_time <='] = strtotime($e_date . ' 23:59:59');
$count = $this->mdTransfer->count($where);
} else {
$where = ['lc_items_transfer_remind.status' => 1, 'lc_items_transfer_remind.uid' => $this->myuid, 'lc_items_transfer.status<>' => -1];
$s_date && $where['lc_items_transfer_remind.c_time >='] = strtotime($s_date . ' 00:00:00');
$e_date && $where['lc_items_transfer_remind.c_time <='] = strtotime($e_date . ' 23:59:59');
$count = $this->db->select('lc_items_transfer_remind.tran_id')
->join('lc_items_transfer', 'lc_items_transfer.id = lc_items_transfer_remind.tran_id', 'left')
->where($where)
->count_all_results('lc_items_transfer_remind');
}
$url = '/pages/allot/detail/index?id=';
$lists = [];
if ($count) {
$offset = ($page - 1) * $size;
$limit = $size;
if ($this->session['group_id'] == 4) {//渠道经理
$res = $this->mdTransfer->select($where, 'id desc', $page, $limit, 'id,item_id,out_uid,in_uid,jsondata,c_time,biz_id');
} else {
$this->db->from('lc_items_transfer_remind');
$this->db->join('lc_items_transfer', "lc_items_transfer.id = lc_items_transfer_remind.tran_id", 'left');
$this->db->select('lc_items_transfer_remind.id,lc_items_transfer.item_id,lc_items_transfer.out_uid,lc_items_transfer.in_uid
,lc_items_transfer.jsondata,lc_items_transfer.c_time,lc_items_transfer.biz_id');
$this->db->where($where);
$this->db->order_by('lc_items_transfer_remind.id Desc');
$this->db->limit($limit, $offset);
$res = $this->db->get()->result_array();
}
$out_uids = array_unique(array_column($res, 'out_uid'));
$in_uids = array_unique(array_column($res, 'in_uid'));
$uids = $this->mdUsers->get_map_by_ids(array_merge($out_uids, $in_uids), 'id,uname');//用户
$bizs = $this->mdBiz->get_map_by_ids(array_unique(array_column($res, 'biz_id')), 'id,biz_name');//门店
foreach ($res as $key => $val) {
$jsondata = $val['jsondata'] ? json_decode($val['jsondata'], true) : [];
$item_info = $this->item_info($val['item_id']);
$setValue = $other_data = [];
$setValue['biz_name'] = $val['biz_id'] ? $bizs[$val['biz_id']][0]['biz_name'] : '';
$setValue['c_time'] = '调拨时间:' . date('Y-m-d H:i', $val['c_time']);
$other_data[] = ['title' => '品牌车型', 'value' => $item_info['title_1']];
$other_data[] = ['title' => '颜色型号', 'value' => $item_info['title_2']];
$other_data[] = ['title' => '车架号', 'value' => $item_info['vin']];
$other_data[] = ['title' => '调拨时间', 'value' => date('Y-m-d', $val['c_time'])];
$other_data[] = ['title' => '提车人', 'value' => $val['out_uid'] ? $uids[$val['out_uid']][0]['uname'] : '-'];
$other_data[] = ['title' => '接车人', 'value' => $val['in_uid'] ? $uids[$val['in_uid']][0]['uname'] : '-'];
$other_data[] = ['title' => '运输员', 'value' => $jsondata['transport']['name']];
$setValue['other_data'] = $other_data;
$setValue['url'] = $url ? '/pages/allot/detail/index?id=' . $val['id'] : '';
$lists[] = $setValue;
}
}
$data = [
'list' => $lists,
'total' => $count
];
return $data;
}
protected function get()
{
$id = intval($this->input_param('id'));
if (!$id) {
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
if ($this->session['group_id'] == 4) {//渠道不显示按钮
$btn = [];
$tran_id = $id;
} else {
$re_m = $this->mdTransferRemind->get(['id' => $id]);
if (!$re_m) {
throw new Exception('数据不存在', ERR_PARAMS_ERROR);
}
$tran_id = $re_m['tran_id'];
$btn[] = ['title' => '报备异常', 'id' => $re_m['tran_id'], 'type' => 1];
if ($re_m['type'] == 1 || $re_m['type'] == 2) {
$btn[] = ['title' => '确认发车', 'id' => $id, 'type' => 2];
} else {
$btn[] = ['title' => '确认接车', 'id' => $id, 'type' => 2];
}
}
$re = $this->mdTransfer->get(['id' => $tran_id]);
if (!$re) {
throw new Exception('车辆调拨不存在', ERR_PARAMS_ERROR);
}
$jsondata = $re['jsondata'] ? json_decode($re['jsondata'], true) : [];
$data['transport'] = ['title' => '运输负责人', 'name' => $jsondata['transport']['name']
, 'mobile' => $jsondata['transport']['mobile']];
$this->db->from('lc_items_transfer_remind');
$this->db->join('lc_app_licheb_users', "lc_app_licheb_users.id = lc_items_transfer_remind.uid", 'left');
$this->db->select('lc_items_transfer_remind.type,lc_app_licheb_users.uname');
$this->db->where(['lc_items_transfer_remind.tran_id' => $re_m['tran_id']]);
$this->db->order_by('lc_items_transfer_remind.type asc');
$this->db->limit(50);
$res_r = $this->db->get()->result_array();
$item_info = $this->item_info($re['item_id']);
$other_data[] = ['title' => '品牌车型', 'value' => $item_info['title_1']];
$other_data[] = ['title' => '颜色型号', 'value' => $item_info['title_2']];
$other_data[] = ['title' => '车架号', 'value' => $item_info['vin']];
foreach ($res_r as $key => $value) {
if ($value['type'] == 1) {
$other_data[] = ['title' => '提车人', 'value' => $value['uname']];
} else if ($value['type'] == 2) {
$other_data[] = ['title' => '备用提车人', 'value' => $value['uname']];
} else if ($value['type'] == 3) {
$other_data[] = ['title' => '接车人', 'value' => $value['uname']];
} else if ($value['type'] == 4) {
$other_data[] = ['title' => '备用接车人', 'value' => $value['uname']];
}
}
if ($re['arti_id']) {
$this->load->model('auto/auto_article_model', 'mdArticle');
$res_a = $this->mdArticle->select(["id in ({$re['arti_id']})" => null], 'id desc', 0, 0, 'title');
if ($res_a) {
$articles = array_unique(array_column($res_a, 'title'));
$other_data[] = ['title' => '随车物品', 'list' => $articles];
}
}
//异常显示
$abnormal = '';
if ($re['abnormal'] && $jsondata['abnormal']) {
$abnormal = $jsondata['abnormal'];
foreach ($abnormal['imgs'] as $key => $value) {
$abnormal['imgs'][$key] = $value ? build_qiniu_image_url($value) : '';
}
}
$data['abnormal'] = $abnormal;
$data['other_data'] = $other_data;
$data['btn'] = $btn;
return $data;
}
/**
* Notes:确认发车/接车
* Created on: 2021/12/10 15:41
* Created by: dengbw
* @throws Exception
*/
protected function put()
{
$id = intval($this->input_param('id'));
if (!$id) {
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
$re_m = $this->mdTransferRemind->get(['id' => $id]);
if (!$re_m) {
throw new Exception('数据不存在', ERR_PARAMS_ERROR);
}
if ($re_m['uid'] != $this->myuid) {
throw new Exception('无操作权限', ERR_PARAMS_ERROR);
}
$tran_id = $re_m['tran_id'];
if ($re_m['type'] == 1 || $re_m['type'] == 2) {//确认提车
$ret = $this->mdTransferRemind->update(['status' => 0], ['tran_id' => $tran_id, 'type in(1,2)' => null]);//隐藏
if ($ret) {
$this->mdTransferRemind->update(['status' => 1], ['tran_id' => $tran_id, 'type in(3,4)' => null]);//显示
$this->mdTransfer->update(['status' => 1, 'out_uid' => $this->myuid, 'out_time' => date("Y-m-d H:i:s")]
, ['id' => $tran_id]);//更新车辆调拨
//调拨接车人短信提醒
$res_tm = $this->mdTransferRemind->select(['status' => 1, 'tran_id' => $tran_id, 'type in(3,4)' => null], 'type asc', 0, 0, 'uid');
if ($res_tm) {
$uids_str = implode(',', array_unique(array_column($res_tm, 'uid')));
$res_u = $this->mdUsers->select(["id in({$uids_str})" => null], 'id desc', 0, 0, 'mobile');
$re_t = $this->mdTransfer->get(['id' => $re_m['tran_id']]);
$item_info = $this->item_info($re_t['item_id']);
foreach ($res_u as $key => $value) {
$car = $item_info['title_1'];
$item_info['title_2'] && $car .= '-' . $item_info['title_2'];
send_alisms(array('mobile' => $value['mobile'], 'template' => 'SMS_229648438'
, 'param' => ['car' => $car, 'vin' => $item_info['vin']]));
}
}
}
} else {//确认接车
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
$ret = $this->mdTransferRemind->update(['status' => 0], ['tran_id' => $tran_id, 'type in(3,4)' => null]);//隐藏
if ($ret) {
$this->mdTransfer->update(['status' => 2, 'biz_id' => $biz_id, 'in_uid' => $this->myuid, 'in_time' => date("Y-m-d H:i:s")]
, ['id' => $tran_id]);//更新车辆调拨
}
}
if ($ret) {
throw new Exception('确认成功', API_CODE_SUCCESS);
} else {
throw new Exception('确认失败', ERR_PARAMS_ERROR);
}
}
/**
* Notes:报备异常
* Created on: 2021/12/10 16:07
* Created by: dengbw
* @throws Exception
*/
protected function post()
{
$id = intval($this->input_param('id'));
if (!$id) {
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
$imgs = $this->input_param('imgs');
$note = $this->input_param('note');
if (!$imgs && !$note) {
throw new Exception('请拍照或填写备注信息', ERR_PARAMS_ERROR);
}
$re = $this->mdTransfer->get(['id' => $id]);
if (!$re) {
throw new Exception('车辆调拨不存在', ERR_PARAMS_ERROR);
}
$jsondata = $re['jsondata'] ? json_decode($re['jsondata'], true) : [];
!$note && $note = '';
!$imgs && $imgs = '';
$jsondata['abnormal'] = ['imgs' => $imgs, 'note' => $note];
$ret = $this->mdTransfer->update(['abnormal' => 1, 'jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE)], ['id' => $id]);
if ($ret) {
throw new Exception('报备成功', API_CODE_SUCCESS);
} else {
throw new Exception('报备失败', ERR_PARAMS_ERROR);
}
}
/**
* Notes:获取商品信息
* Created on: 2021/12/9 10:47
* Created by: dengbw
* @param $item_id
* @param int $type
* @return array
*/
private function item_info($item_id)
{
$re = $this->mdItems->get(array('id' => $item_id));
if (!$re || empty($re)) {
return [];
}
$re_b = $this->mdAutoBrand->get(array('id' => $re['brand_id']), 'name');
$re_s = $this->mdAutoSeries->get(array('id' => $re['s_id']), 'name');
$re_v = $this->mdAutoAttr->get(array('id' => $re['v_id']), 'title');
$re_cor = $this->mdAutoAttr->get(array('id' => $re['cor_id']), 'title');
$title_1 = $title_2 = '';
$re_b['name'] && $title_1 = $re_b['name'];
$re_s['name'] && $title_1 = $title_1 ? $title_1 . '-' . $re_s['name'] : $re_s['name'];
$re_v['title'] && $title_2 = $re_v['title'];
$re_cor['title'] && $title_2 = $title_2 ? $title_2 . '-' . $re_cor['title'] : $re_cor['title'];
$info['title_1'] = $title_1;
$info['title_2'] = $title_2;
$info['vin'] = $re['vin'];
return $info;
}
}
+18
View File
@@ -0,0 +1,18 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Created by PhpStorm.
* User: xuxb
* Date: 2021/8/25
* Time: 10:51
*/
class Auto_article_model extends HD_Model
{
private $table_name = 'lc_auto_article';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}
+34
View File
@@ -0,0 +1,34 @@
<?php
/**
* Notes:门店基础信息
* Created on: 2021/12/15 14:52
* Created by: dengbw
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class Biz_base_model extends HD_Model
{
private $table_name = 'lc_biz_base';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
public function get_fields()
{
$field['company'] = ['title' => '公司名称', 'type' => 'input', 'input_type' => 'text', 'value' => ''];
$field['county'] = ['title' => '县区', 'type' => 'select', 'list' => [0 => '选择县区'], 'value' => ''];
$field['street'] = ['title' => '乡镇', 'type' => 'select', 'list' => [0 => '选择乡镇'], 'value' => ''];
$field['type'] = ['title' => '类型', 'type' => 'select', 'list' => [0 => '选择类型', 1 => '品牌店', 2 => '形象店', 3 => '代理店'], 'value' => ''];
$field['level'] = ['title' => '级别', 'type' => 'text', 'value' => ''];
$field['lead'] = ['title' => '负责人', 'type' => 'select', 'list' => [0 => '选择负责人'], 'value' => ''];
$field['douyin'] = ['title' => '抖音号', 'type' => 'input', 'input_type' => 'text', 'value' => ''];
$field['address'] = ['title' => '位置', 'type' => 'input', 'input_type' => 'text', 'value' => ''];
$field['area'] = ['title' => '面积', 'type' => 'input', 'input_type' => 'int', 'value' => ''];
$field['rent'] = ['title' => '租金/月', 'type' => 'input', 'input_type' => 'int', 'value' => ''];
$field['imgs'] = ['title' => '门店照片', 'type' => 'img', 'value' => ''];
return $field;
}
}
+1 -1
View File
@@ -59,7 +59,7 @@ class Biz_model extends HD_Model
* @return mixed
*/
function type_ary($key = null){
$map = array('1' => '合伙店', '2' => '加盟店', '3' => '代理店');
$map = array('1' => '品牌店', '2' => '形象店', '3' => '代理店');
if(!is_null($key)){
return $map[$key];
+36
View File
@@ -0,0 +1,36 @@
<?php
/**
* Notes:门店售卖情况
* Created on: 2021/12/15 14:52
* Created by: dengbw
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class Biz_sell_model extends HD_Model
{
private $table_name = 'lc_biz_sell';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
public function get_fields()
{
$field['boss_sell'] = ['title' => '老板卖车', 'type' => 'radio', 'list' => [0 => '否', 1 => '是'], 'value' => 0];
$field['team_num'] = ['title' => '团队人数', 'type' => 'input', 'input_type' => 'int', 'value' => ''];
$field['sales'] = ['title' => '销量(台/上月)', 'type' => 'text', 'value' => ''];
$field['sale_cars'] = ['title' => '在售车型(当前)', 'type' => 'panel'];
$field['fuel_prop'] = ['title' => '燃油占比', 'type' => 'input', 'input_type' => 'int', 'tag' => '%', 'value' => ''];
$field['energy_prop'] = ['title' => '新能源占比', 'type' => 'input', 'input_type' => 'int', 'tag' => '%', 'value' => ''];
$field['competitor_car'] = ['title' => '竞品车型', 'type' => 'input', 'input_type' => 'text', 'value' => ''];
$field['cooperation_car'] = ['title' => '合作车型', 'type' => 'text', 'value' => ''];
$field['clues_channel'] = ['title' => '当前线索渠道', 'type' => 'panel'];
$field['introduce_prop'] = ['title' => '转介绍', 'type' => 'input', 'input_type' => 'int', 'tag' => '%', 'value' => ''];
$field['outside_prop'] = ['title' => '外拓外展', 'type' => 'input', 'input_type' => 'int', 'tag' => '%', 'value' => ''];
$field['network_prop'] = ['title' => '网络推广', 'type' => 'input', 'input_type' => 'int', 'tag' => '%', 'value' => ''];
$field['we_media_prop'] = ['title' => '自媒体', 'type' => 'input', 'input_type' => 'int', 'tag' => '%', 'value' => ''];
return $field;
}
}
@@ -0,0 +1,61 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notes:车辆调拨
* Created on: 2021/12/6 16:43
* Created by: dengbw
*/
class Items_transfer_model extends HD_Model
{
private $table_name = 'lc_items_transfer';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
/**
* Notes:状态
* Created on: 2021/12/6 16:47
* Created by: dengbw
* @return array
*/
public function statusAry()
{
return array(0 => '已调拨', 1 => '确认发车', 2 => '确认接车');
}
/**
* Notes:异常
* Created on: 2021/12/9 17:53
* Created by: dengbw
* @param string $id
* @return array
*/
public function abnormalAry($id = '')
{
$ary = [0 => '正常', 1 => '异常'];
if (strlen($id)) {
$ary = $ary[$id];
}
return $ary;
}
/**
* Notes:拖车费类型
* Created on: 2021/12/16 16:46
* Created by: dengbw
* @param string $id
* @return array|mixed
*/
public function feesTypeAry($id = '')
{
$ary = [1 => '直营店', 2 => '渠道'];
if (strlen($id)) {
$ary = $ary[$id];
}
return $ary;
}
}
@@ -0,0 +1,28 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notes:车辆调拨
* Created on: 2021/12/6 16:43
* Created by: dengbw
*/
class Items_transfer_remind_model extends HD_Model
{
private $table_name = 'lc_items_transfer_remind';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
/**
* Notes:类型
* Created on: 2021/12/6 16:47
* Created by: dengbw
* @return array
*/
public function typeAry()
{
return array(1 => '提车人', 2 => '备用提车人', 3 => '接车人', 4 => '备用接车人');
}
}
+18
View File
@@ -0,0 +1,18 @@
<?php
/**
* Notes:街道表
* Created on: 2021/12/14 13:46
* Created by: dengbw
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class Sys_street_model extends HD_Model
{
private $table_name = 'lc_sys_street';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}