transfer_1228

This commit is contained in:
dengbw
2021-12-28 15:49:37 +08:00
parent da2249aeb3
commit 7d192cce94
12 changed files with 2052 additions and 534 deletions
+2 -1
View File
@@ -423,7 +423,7 @@ class Common extends CI_Controller
$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');
$type = intval($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'));
@@ -444,6 +444,7 @@ class Common extends CI_Controller
$brand_id && $where['brand_id'] = $brand_id;
$city_id && $where['city_id'] = $city_id;
$county_id && $where['county_id'] = $county_id;
$type && $where['type'] = $type;
$ids && $where['id not in (' . $ids . ')'] = null;
$count = $this->mdBiz->count($where);
if ($count) {
+578 -107
View File
@@ -15,6 +15,7 @@ class Transfer extends HD_Controller
parent::__construct();
$this->load->model('items/items_transfer_model', 'mdTransfer');
$this->load->model('items/items_transfer_remind_model', 'mdTransferRemind');
$this->load->model('items/items_transfer_admin_model', 'mdTransferAdmin');
$this->load->model('app/licheb/app_licheb_users_model', 'mdUsers');
$this->load->model('items/items_model', 'mdItems');
@@ -24,6 +25,7 @@ class Transfer extends HD_Controller
$this->load->model("sys/sys_addr_model", 'mdAddr');
$this->load->model("biz/biz_model", 'mdBiz');
$this->load->model('area_model', 'mdArea');
$this->load->model('sys/Sys_admin_model', 'mdSysAdmin');
}
public function index()
@@ -53,6 +55,7 @@ class Transfer extends HD_Controller
$this->data['statusAry'] = $this->mdTransfer->statusAry();
$this->data['abnormalAry'] = $this->mdTransfer->abnormalAry();
$this->data['autoList'] = $autoList;
$this->data['showInfo'] = ['uidTypeAry' => $this->mdTransfer->uidTypeAry(), 'takeCar' => $re['takeCar']];
$this->data['pager'] = array('count' => ceil($total / $params['size']), 'curr' => $params['page'], 'totle' => $total);
$this->data['_title'] = '车辆调拨';
$this->show_view('items/transfer/lists', true);
@@ -61,7 +64,7 @@ class Transfer extends HD_Controller
private function dataSelect($params)
{
$statusAry = $this->mdTransfer->statusAry();
$where = ['status<>' => -1];
$where = [];
if (strlen($params['status'])) {
$where['status'] = $params['status'];
} else {
@@ -72,22 +75,54 @@ class Transfer extends HD_Controller
} else {
$params['abnormal'] = '';
}
if ($params['out_uid']) {
$where['out_uid'] = $params['out_uid'];
if ($params['out_type'] == 2) {
if ($params['out_addr_id']) {
$where['addr_id'] = $params['out_addr_id'];
$where['out_type'] = $params['out_type'];
} else {
$params['out_addr_id'] = '';
}
} 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['out_uid']) {
$where['out_uid'] = $params['out_uid'];
$where['out_type'] = $params['out_type'];
} else {
$params['out_uid'] = '';
}
}
if ($params['in_uid']) {
$where['in_uid'] = $params['in_uid'];
!$params['out_city_id'] && $params['out_city_id'] = '';
!$params['out_county_id'] && $params['out_county_id'] = '';
!$params['out_admin_id'] && $params['out_admin_id'] = '';
!$params['out_biz_id'] && $params['out_biz_id'] = '';
!$params['out_type'] && $params['out_type'] = 1;
$takeCar[1] = ['city_id' => $params['out_city_id'], 'county_id' => $params['out_county_id'], 'type' => $params['out_type']
, 'biz_id' => $params['out_biz_id'], 'uid' => $params['out_uid'], 'admin_id' => $params['out_admin_id'], 'addr_id' => $params['out_addr_id']
, 'cityList' => [], 'countyList' => [], 'bizList' => [], 'uidList' => [], 'adminList' => [], 'addrList' => []];
if ($params['in_type'] == 2) {
if ($params['in_addr_id']) {
$where['in_id'] = $params['in_addr_id'];
$where['in_type'] = $params['in_type'];
} else {
$params['in_addr_id'] = '';
}
} 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['in_uid']) {
$where['in_uid'] = $params['in_uid'];
$where['in_type'] = $params['in_type'];
} else {
$params['in_uid'] = '';
}
}
!$params['in_city_id'] && $params['in_city_id'] = '';
!$params['in_county_id'] && $params['in_county_id'] = '';
!$params['in_admin_id'] && $params['in_admin_id'] = '';
!$params['in_biz_id'] && $params['in_biz_id'] = '';
!$params['in_type'] && $params['in_type'] = 1;
$takeCar[3] = ['city_id' => $params['in_city_id'], 'county_id' => $params['in_county_id'], 'type' => $params['in_type']
, 'biz_id' => $params['in_biz_id'], 'uid' => $params['in_uid'], 'admin_id' => $params['in_admin_id'], 'addr_id' => $params['in_addr_id']
, 'cityList' => [], 'countyList' => [], 'bizList' => [], 'uidList' => [], 'adminList' => [], 'addrList' => []];
if ($params['title']) {
$where["item_id in (select id from lc_items where vin like '%{$params['title']}%')"] = null;
}
@@ -107,96 +142,193 @@ class Transfer extends HD_Controller
$in_time[0] && $where["in_time >="] = $in_time[0] . ' 00:00:00';
$in_time[1] && $where["in_time <="] = $in_time[1] . ' 23:59:59';
}
if ($params['out_type']) {
$params['out_uid'] && $where["out_type"] = $params['out_type'];
} else {
$params['out_type'] = 1;
}
if ($params['in_type']) {
$params['in_uid'] && $where["in_type"] = $params['in_type'];
} else {
$params['in_type'] = 1;
}
$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'));
$out_uids = $in_uids = [];
$out_uids_ad = $in_uids_ad = [];
foreach ($rows as $v2) {
if ($v2['out_uid']) {
if ($v2['out_type'] == 1) {
$out_uids[] = $v2['out_uid'];
} else if ($v2['out_type'] == 2) {
$out_uids_ad[] = $v2['out_uid'];
}
}
if ($v2['in_uid']) {
if ($v2['in_type'] == 1) {
$in_uids[] = $v2['in_uid'];
} else if ($v2['in_type'] == 2) {
$in_uids_ad[] = $v2['in_uid'];
}
}
}
$uids_arr = array_merge($out_uids, $in_uids);
$uids_ad_arr = array_merge($out_uids_ad, $in_uids_ad);
$uids = $this->mdUsers->get_map_by_ids($uids_arr, 'id,uname');
$uids_ad = $this->mdSysAdmin->get_map_by_ids($uids_ad_arr, 'id,username as uname');
foreach ($rows as $v) {
$jsondata = $v['jsondata'] ? json_decode($v['jsondata'], true) : [];
$item_info = $this->item_info($v['item_id'], 1);
$lists[] = array(
$out_uid_title = $in_uid_title = '-';
$tag = $params['size'] == 10000 ? '/' : '<br>';
if ($v['out_uid']) {
if ($v['out_type'] == 1) {
$out_uid_title = $uids[$v['out_uid']][0]['uname'] . $tag . date('Y-m-d H:i', strtotime($v['out_time']));
} else if ($v['out_type'] == 2) {
$out_uid_title = $uids_ad[$v['out_uid']][0]['uname'] . $tag . date('Y-m-d H:i', strtotime($v['out_time']));
}
}
if ($v['in_uid']) {
if ($v['in_type'] == 1) {
$in_uid_title = $uids[$v['in_uid']][0]['uname'] . $tag . date('Y-m-d H:i', strtotime($v['in_time']));
} else if ($v['in_type'] == 2) {
$in_uid_title = $uids_ad[$v['in_uid']][0]['uname'] . $tag . date('Y-m-d H:i', strtotime($v['in_time']));
}
}
$setValue = [
'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'])) : '-',
'out_uid_title' => $out_uid_title,
'in_uid_title' => $in_uid_title,
'transport_name' => $jsondata['transport']['name'],
'abnormal' => $this->mdTransfer->abnormalAry($v['abnormal']),
'c_time' => date('Y.m.d H:i', $v['c_time']),
'status' => $v['status'],
'status_name' => $statusAry[$v['status']],
);
];
$city_name = $county_name = $biz_name = '';
if ($v['biz_id'] > 0) {
$re_biz = $this->mdBiz->get(array('id' => $v['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'];
$county_name = $re_area['county_name'];
} else if ($re_biz['city_id']) {
$re_area = $this->mdArea->get(array('city_id' => $re_biz['city_id']));
$city_name = $re_area['city_name'];
}
$biz_name = $re_biz['biz_name'] ? $re_biz['biz_name'] : '';
} else if ($v['addr_id']) {
$re_addr = $this->mdAddr->get(array('id' => $v['addr_id']));
if ($re_addr) {
$city_name = $re_addr['city_name'];
$county_name = $re_addr['county_name'];
$biz_name = $re_addr['title'];
}
}
if ($params['size'] == 10000) {//导出
$jsondata = $v['jsondata'] ? json_decode($v['jsondata'], true) : [];
$trailer_fees = $this->mdTransfer->feesTypeAry($v['fees_type']);
if ($v['fees_city']) {
$re_area = $this->mdArea->get(array('city_id' => $v['fees_city']));
$trailer_fees .= '-' . $re_area['city_name'];
}
if ($v['fees_type'] == 1 && $v['fees_biz_id']) {
$re_biz = $this->mdBiz->get(array('id' => $v['fees_biz_id']));
$trailer_fees .= '-' . $re_biz['biz_name'];
}
$setValue['city'] = $city_name;
$setValue['county'] = $county_name;
$setValue['biz_name'] = $biz_name;
$setValue['trailer_fees'] = $v['trailer_fees'];
$setValue['fees'] = $trailer_fees;
$setValue['reason'] = $jsondata['reason'] ? $jsondata['reason'] : '';
} else {
$setValue['addr_name'] = "{$city_name}-{$county_name}-$biz_name";
}
$lists[] = $setValue;
}
}
$data['lists'] = $lists;
$data['params'] = $params;
$data['takeCar'] = $takeCar;
$data['total'] = $total;
return $data;
}
public function get()
{
$id = $this->input->get('id');
$id = intval($this->input->get('id'));
$info = [];
if ($id) {
$re = $this->mdTransfer->get(array('id' => $id, 'status <>' => -1));
$re = $this->mdTransfer->get(array('id' => $id));
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 = $out_content_bak = $in_content = $in_content_bak = $arti_content = $abnormal = $transport = '';
//门店
$res_r = $this->mdTransferRemind->select(['tran_id' => $id], 'type asc', 0, 0, 'uid,type,biz_id');
if ($res_r) {
foreach ($res_r as $key => $value) {
$content = $this->take_car($value, 1);
if ($value['type'] == 1) {
$out_content = $content;
} else if ($value['type'] == 2) {
$out_content_bak = $content;
} else if ($value['type'] == 3) {
$in_content = $content;
} else if ($value['type'] == 4) {
$in_content_bak = $content;
}
$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'];
}
}
//信息员
$opt_btn = ['title' => '', 'type' => 0];//type1确认发车2确认接车
$res_a = $this->mdTransferAdmin->select(['tran_id' => $id], 'type asc', 0, 0, 'uid,type,addr_id,status');
if ($res_a) {
foreach ($res_a as $key => $value) {
$content = $this->take_car($value, 2);
if ($value['type'] == 1 || $value['type'] == 2) {
if ($value['type'] == 1) {
$out_content = $content;
} else {
$out_content_bak = $content;
}
if ($value['status'] == 1 && $value['uid'] == $this->uid) {//未操作且是自己
$opt_btn = ['title' => '确认发车', 'type' => 1, 'tran_id' => $id, 'addr_id' => $value['addr_id']];
}
} else if ($value['type'] == 3 || $value['type'] == 4) {
if ($value['type'] == 3) {
$in_content = $content;
} else {
$in_content_bak = $content;
}
if ($value['status'] == 1 && $value['uid'] == $this->uid) {//未操作且是自己
$opt_btn = ['title' => '确认接车', 'type' => 2, 'tran_id' => $id, 'addr_id' => $value['addr_id']];
}
}
$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' => $out_content . $out_content_bak];
$fields[] = ['title' => '接车信息', 'value' => $in_content . $in_content_bak];
$fields[] = ['title' => '运输人员', 'value' => $jsondata['transport']['name'] . '&nbsp;&nbsp;&nbsp;' .
$jsondata['transport']['mobile'] . '&nbsp;&nbsp;&nbsp;身份证:' . $jsondata['transport']['cardid']];
if ($jsondata['transport']) {
$transport = $jsondata['transport'];
$imgs = [];
foreach ($transport['imgs'] as $key => $value) {
$value && $imgs[] = ['src' => build_qiniu_image_url($value), 'value' => $value];
}
$transport['imgs'] = $imgs;
}
$jsondata['reason'] && $fields[] = ['title' => '调拨理由', 'value' => $jsondata['reason']];
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')));
@@ -205,22 +337,44 @@ class Transfer extends HD_Controller
$fields[] = ['title' => '车辆异常', 'value' => $this->mdTransfer->abnormalAry()[$re['abnormal']]];
if ($re['abnormal'] && $jsondata['abnormal']) {
$abnormal = $jsondata['abnormal'];
$imgs = [];
foreach ($abnormal['imgs'] as $key => $value) {
$abnormal['imgs'][$key] = $value ? build_qiniu_image_url($value) : '';
$value && $imgs[] = ['src' => build_qiniu_image_url($value), 'value' => $value];
}
$abnormal['imgs'] = $imgs;
}
if ($re['trailer_fees']) {
$trailer_fees = $re['trailer_fees'] ? $re['trailer_fees'] . '元' : '';
$trailer_fees .= '&nbsp;&nbsp;费用承担人:' . $this->mdTransfer->feesTypeAry($re['fees_type']);
if ($re['fees_city']) {
$re_area = $this->mdArea->get(array('city_id' => $re['fees_city']));
$trailer_fees .= '&nbsp;&nbsp;' . $re_area['city_name'];
}
if ($re['fees_type'] == 1 && $re['fees_biz_id']) {
$re_biz = $this->mdBiz->get(array('id' => $re['fees_biz_id']));
$trailer_fees .= '&nbsp;&nbsp;' . $re_biz['biz_name'];
}
$fields[] = ['title' => '运输费用', 'value' => $trailer_fees];
}
if (!$abnormal && $opt_btn['type']) {//1确认发车2确认接车可发异常
$abnormal = ['imgs' => [], 'note' => ''];
}
$this->data['fields'] = $fields;
$this->data['opt_btn'] = $opt_btn;
$this->data['abnormal'] = $abnormal;
$this->data['transport'] = $transport;
$title = '车辆调拨详情';
$view = 'items/transfer/get';
} else {
$title = '新增车辆调拨';
$vin = $this->input->get('vin');
!$vin && $vin = '';
$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' => '']];
//常用运输人
$showInfo = ['vin' => $vin, 'items_info' => ['id' => 0, 'title' => '', 'vin' => '', 'cor' => '', 'address' => ''],
'feesTypeAry' => $this->mdTransfer->feesTypeAry(), 'feesBizList' => [], 'uidTypeAry' => $this->mdTransfer->uidTypeAry()];
$info = ['id' => 0, 'status' => 0, 'item_id' => 0, 'arti_id' => [], 'out_bak' => 0, 'in_bak' => 0, 'trailer_fees' => '', 'fees_city' => '', 'trailer_fees' => 0,
'fees_type' => 1, 'fees_biz_id' => '', 'transport' => ['name' => '', 'mobile' => '', 'cardid' => ''], 'reason' => ''];
//常用运输人
$transports = [];
$cache = &load_cache('redis');
$cache_transports = $cache->get($this->cacheKeyTransports);
@@ -242,25 +396,106 @@ class Transfer extends HD_Controller
return $this->show_view($view, true);
}
public function get_edit()
{
$id = intval($this->input->get('id'));
if (!$id) {
return $this->show_json(SYS_CODE_FAIL, '参数错误!');
}
$re = $this->mdTransfer->get(array('id' => $id));
if (!$re || empty($re)) {
return $this->show_json(SYS_CODE_FAIL, '车辆调拨不存在!');
}
if ($re['status'] != -1) {
return $this->show_json(SYS_CODE_FAIL, '车辆调拨已提交,不能修改!');
}
$item_id = $re['item_id'] ? $re['item_id'] : 0;
$re_items = $this->mdItems->get(['id' => $item_id]);
$jsondata = $re['jsondata'] ? json_decode($re['jsondata'], true) : [];
$showInfo = ['vin' => $re_items['vin'], 'items_info' => ['id' => 0, 'title' => '', 'vin' => '', 'cor' => '', 'address' => ''],
'feesTypeAry' => $this->mdTransfer->feesTypeAry(), 'feesBizList' => [], 'uidTypeAry' => $this->mdTransfer->uidTypeAry()];
$info = ['id' => $id, 'status' => $re['status'], 'out_bak' => 0, 'in_bak' => 0
, 'item_id' => $item_id
, 'arti_id' => $re['arti_id'] ? explode(',', $re['arti_id']) : []
, 'trailer_fees' => $re['trailer_fees'] ? $re['trailer_fees'] : ''
, 'fees_city' => $re['fees_city'] ? $re['fees_city'] : ''
, 'fees_type' => $re['fees_type']
, 'fees_biz_id' => $re['fees_biz_id'] ? $re['fees_biz_id'] : ''
, 'transport' => ['name' => $jsondata['transport']['name'] ? $jsondata['transport']['name'] : ''
, 'mobile' => $jsondata['transport']['mobile'] ? $jsondata['transport']['mobile'] : ''
, 'cardid' => $jsondata['transport']['mobile'] ? $jsondata['transport']['cardid'] : '']
, 'reason' => $jsondata['reason'] ? $jsondata['reason'] : ''];
$takeCar[1] = $takeCar[2] = $takeCar[3] = $takeCar[4] = ['city_id' => "", 'county_id' => "", 'type' => 1, 'biz_id' => "", 'uid' => "", 'admin_id' => ""
, 'addr_id' => "", 'cityList' => [], 'countyList' => [], 'bizList' => [], 'uidList' => [], 'adminList' => [], 'addrList' => []];
if ($jsondata['take_car']) {
foreach ($jsondata['take_car'] as $key => $value) {
$takeCar[$key]['type'] = $value['type'];
if ($value['type'] == 2) {
$re_addr = $this->mdAddr->get(array('id' => $value['addr_id']));
$takeCar[$key]['city_id'] = $re_addr['city_id'] ? $re_addr['city_id'] : "";
$takeCar[$key]['county_id'] = $re_addr['county_id'] ? $re_addr['county_id'] : "";
$takeCar[$key]['admin_id'] = $value['admin_id'] ? $value['admin_id'] : '';
$takeCar[$key]['addr_id'] = $value['addr_id'] ? $value['addr_id'] : '';
} else {
$re_biz = $this->mdBiz->get(array('id' => $value['biz_id']));
$takeCar[$key]['city_id'] = $re_biz['city_id'] ? $re_biz['city_id'] : "";
$takeCar[$key]['county_id'] = $re_biz['county_id'] ? $re_biz['county_id'] : "";
$takeCar[$key]['uid'] = $value['uid'] ? $value['uid'] : '';
$takeCar[$key]['biz_id'] = $value['biz_id'] ? $value['biz_id'] : '';
}
$key == 2 && $info['out_bak'] = 1;//备用提车人
$key == 4 && $info['in_bak'] = 1;//备用接车人
}
}
$showInfo['takeCar'] = $takeCar;
//常用运输人
$transports = [];
$cache = &load_cache('redis');
$cache_transports = $cache->get($this->cacheKeyTransports);
if ($cache_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['edit_url'] = '/items/transfer/edit_info';
$this->data['_title'] = '修改车辆调拨';
return $this->show_view('items/transfer/get_add', true);
}
/**
* 新增物品
* 新增/修改调拨
* @return bool
*/
public function add()
{
$info = $this->input->post('info');
$takeCar = $this->input->post('takeCar');
if (!$info['arti_id']) {
return $this->show_json(SYS_CODE_FAIL, '请选择随车物品');
}
if (!$info['out_uid']) {
if (!$takeCar[1]['uid'] && !$takeCar[1]['addr_id']) {
return $this->show_json(SYS_CODE_FAIL, '请选择提车人');
}
if (!$info['in_uid']) {
if (!$takeCar[3]['uid'] && !$takeCar[3]['addr_id']) {
return $this->show_json(SYS_CODE_FAIL, '请选择接车人');
}
$trailer_fees = intval($info['trailer_fees']);
if (!$trailer_fees) {
return $this->show_json(SYS_CODE_FAIL, '请输入运输费用');
if ($trailer_fees) {
if (!$info['fees_city']) {
return $this->show_json(SYS_CODE_FAIL, '请选择费用承担城市');
}
if ($info['fees_type'] == 1 && !$info['fees_biz_id']) {
return $this->show_json(SYS_CODE_FAIL, '请选择费用承担门店');
}
}
if (!$info['transport']['name'] || !$info['transport']['mobile'] || !$info['transport']['cardid']) {
return $this->show_json(SYS_CODE_FAIL, '请输入运输人员姓名/电话/身份证号');
@@ -269,44 +504,57 @@ class Transfer extends HD_Controller
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'];
$jsondata['transport'] = $info['transport'];//运输人员
$jsondata['reason'] = $info['reason'];//调拨理由
$c_time = time();
if ($takeCar[3]['type'] == 2) {//接收信息员
$biz_id = -1;
$addr_id = $takeCar[3]['addr_id'];
} else {//接收门店
$biz_id = $takeCar[3]['biz_id'];
$addr_id = 0;
}
$info['fees_biz_id'] = $info['fees_type'] == 1 ? intval($info['fees_biz_id']) : 0;
if ($info['status'] == -1) {//保存临时调拨人
$json_takeCar = [];
foreach ($takeCar as $key => $value) {
if ($key) {
if ($key == 2 || $key == 4) {
$info['out_bak'] == 1 && $json_takeCar[$key] = $value;
$info['in_bak'] == 1 && $json_takeCar[$key] = $value;
} else {
$json_takeCar[$key] = $value;
}
}
}
$jsondata['take_car'] = $json_takeCar;
} else {
if ($info['id']) {
unset($jsondata['take_car']);//删除临时调拨人
}
}
$add = [
'item_id' => $info['item_id'],
'biz_id' => $biz_id,
'addr_id' => $addr_id,
'arti_id' => $info['arti_id'] ? implode(',', $info['arti_id']) : '',
'jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE),
'trailer_fees' => $trailer_fees,
'fees_type' => intval($info['fees_type']),
'fees_city' => intval($info['fees_city']),
'fees_type' => $info['fees_type'],
'c_time' => $c_time,
'fees_biz_id' => $info['fees_biz_id'],
'out_type' => $takeCar[1]['type'],
'in_type' => $takeCar[3]['type'],
'status' => intval($info['status'])
];
$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']]));
if ($info['id']) {
$id = $info['id'];
$this->mdTransfer->update($add, ['id' => $id]);
} else {
$add['c_time'] = $c_time;
$id = $this->mdTransfer->add($add);
if (!$id) {
return $this->show_json(SYS_CODE_FAIL, '添加失败');
}
}
//常用运输人员
@@ -324,15 +572,158 @@ class Transfer extends HD_Controller
$cache_transports[] = $info['transport'];
}
$cache->save($this->cacheKeyTransports, $cache_transports);
return $this->show_json(SYS_CODE_SUCCESS, '添加成功');
if ($info['status'] == -1) {
return $this->show_json(SYS_CODE_SUCCESS, '保存成功', "/items/transfer");
}
//提车人操作
$send_uids = $send_admins = $addRemind = $addAdmin = [];
//提车人
if ($takeCar[1]['type'] == 2) {
$send_admins[] = $takeCar[1]['admin_id'];
$addAdmin[] = ['tran_id' => $id, 'uid' => $takeCar[1]['admin_id'], 'type' => 1, 'addr_id' => $takeCar[1]['addr_id'], 'status' => 1, 'c_time' => $c_time];
} else {
$send_uids[] = $takeCar[1]['uid'];
$addRemind[] = ['tran_id' => $id, 'uid' => $takeCar[1]['uid'], 'type' => 1, 'biz_id' => $takeCar[1]['biz_id'], 'status' => 1, 'c_time' => $c_time];
}
//备用提车人
if ($info['out_bak'] == 1) {
if ($takeCar[2]['type'] == 2) {
$send_admins[] = $takeCar[2]['admin_id'];
$addAdmin[] = ['tran_id' => $id, 'uid' => $takeCar[2]['admin_id'], 'type' => 2, 'addr_id' => $takeCar[2]['addr_id'], 'status' => 1, 'c_time' => $c_time];
} else {
$send_uids[] = $takeCar[2]['uid'];
$addRemind[] = ['tran_id' => $id, 'uid' => $takeCar[2]['uid'], 'type' => 2, 'biz_id' => $takeCar[2]['biz_id'], 'status' => 1, 'c_time' => $c_time];
}
}
//接车人
if ($takeCar[3]['type'] == 2) {
$addAdmin[] = ['tran_id' => $id, 'uid' => $takeCar[3]['admin_id'], 'type' => 3, 'addr_id' => $takeCar[3]['addr_id'], 'status' => 0, 'c_time' => $c_time];
} else {
$addRemind[] = ['tran_id' => $id, 'uid' => $takeCar[3]['uid'], 'type' => 3, 'biz_id' => $takeCar[3]['biz_id'], 'status' => 0, 'c_time' => $c_time];
}
//备用接车人
if ($info['in_bak'] == 1) {
if ($takeCar[4]['type'] == 2) {
$addAdmin[] = ['tran_id' => $id, 'uid' => $takeCar[4]['admin_id'], 'type' => 4, 'addr_id' => $takeCar[4]['addr_id'], 'status' => 0, 'c_time' => $c_time];
} else {
$addRemind[] = ['tran_id' => $id, 'uid' => $takeCar[4]['uid'], 'type' => 4, 'biz_id' => $takeCar[4]['biz_id'], 'status' => 0, 'c_time' => $c_time];
}
}
if ($addRemind) {
$this->mdTransferRemind->add_batch($addRemind);
}
if ($addAdmin) {
$this->mdTransferAdmin->add_batch($addAdmin);
}
$item_info = $this->input->post('items_info');
//门店调拨短信提醒
$this->send_alisms(['uids' => $send_uids, 'type' => 1, 'item_info' => $item_info]);
//信息员调拨短信提醒
$this->send_alisms(['uids' => $send_admins, 'type' => 2, 'item_info' => $item_info]);
return $this->show_json(SYS_CODE_SUCCESS, '提交成功', "/items/transfer");
}
/**
* 编辑
* Notes:确认调拨
* Created on: 2021/12/17 15:52
* Created by: dengbw
* @return bool
*/
public function edit()
{
$opt_btn = $this->input->post('opt_btn');
$abnormal = $this->input->post('abnormal');
$transport = $this->input->post('transport');
if (!$opt_btn['type']) {
return $this->show_json(SYS_CODE_FAIL, '确认失败');
}
$tran_id = $opt_btn['tran_id'];
$re_tr = $this->mdTransfer->get(['id' => $tran_id]);
$item_id = intval($re_tr['item_id']);
if (!$re_tr) {
return $this->show_json(ERR_PARAMS_ERROR, '数据不存在');
}
//更新异常
$jsondata = $re_tr['jsondata'] ? json_decode($re_tr['jsondata'], true) : [];
$jsondata['abnormal']['note'] = $abnormal['note'] ? $abnormal['note'] : '';
$abnor_imgs = '';
if ($abnormal['imgs']) {
foreach ($abnormal['imgs'] as $key => $value) {
$abnor_imgs[] = $value['value'];
}
}
$jsondata['abnormal']['imgs'] = $abnor_imgs;
//运输单号
$tran_imgs = '';
if ($transport['imgs']) {
foreach ($transport['imgs'] as $key => $value) {
$tran_imgs[] = $value['value'];
}
}
$transport_json = $jsondata['transport'] ? $jsondata['transport'] : [];
$transport_json['imgs'] = $tran_imgs;
$jsondata['transport'] = $transport_json;
$this->mdTransfer->update(['abnormal' => 1, 'jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE)], ['id' => $tran_id]);
$ret = '';
if ($opt_btn['type'] == 1) {//确认发车
$ret = $this->mdTransferAdmin->update(['status' => 2], ['tran_id' => $tran_id, 'type in(1,2)' => null]);//信息员已完成
if ($ret) {
$this->mdTransferRemind->update(['status' => 2], ['tran_id' => $tran_id, 'type in(1,2)' => null]);//门店已完成
$this->mdTransferAdmin->update(['status' => 1], ['tran_id' => $tran_id, 'type in(3,4)' => null]);//信息员显示
$this->mdTransferRemind->update(['status' => 1], ['tran_id' => $tran_id, 'type in(3,4)' => null]);//门店显示
//更新车辆调拨
$this->mdTransfer->update(['status' => 1, 'out_type' => 2, 'out_uid' => $this->uid
, 'out_time' => date("Y-m-d H:i:s")], ['id' => $tran_id]);
//调拨接车人短信提醒
$res_r = $this->mdTransferRemind->select(['status' => 1, 'tran_id' => $tran_id, 'type in(3,4)' => null], 'type asc', 0, 0, 'uid');
$res_a = $this->mdTransferAdmin->select(['status' => 1, 'tran_id' => $tran_id, 'type in(3,4)' => null], 'type asc', 0, 0, 'uid');
$item_info = $this->item_info($re_tr['item_id'], 1);
if ($res_r) {//门店调拨短信提醒
$send_uids = array_unique(array_column($res_r, 'uid'));
$this->send_alisms(['uids' => $send_uids, 'type' => 1, 'item_info' => $item_info]);
}
if ($res_a) {//信息员调拨短信提醒
$send_admins = array_unique(array_column($res_a, 'uid'));
$this->send_alisms(['uids' => $send_admins, 'type' => 2, 'item_info' => $item_info]);
}
}
} else if ($opt_btn['type'] == 2) {//确认接车
$ret = $this->mdTransferAdmin->update(['status' => 2], ['tran_id' => $tran_id, 'type in(3,4)' => null]);//信息员已完成
if ($ret) {
$addr_id = $opt_btn['addr_id'];
$this->mdTransferRemind->update(['status' => 2], ['tran_id' => $tran_id, 'type in(3,4)' => null]);//门店已完成
//更新车辆调拨
$this->mdTransfer->update(['status' => 2, 'in_type' => 2, 'in_uid' => $this->uid, 'addr_id' => $addr_id, 'biz_id' => -1
, 'in_time' => date("Y-m-d H:i:s")], ['id' => $tran_id]);
//更新车辆存放地
$re_items = $this->mdItems->get(['id' => $item_id]);
$com_time = date('Y-m-d H:i:s');
$ret_i = $this->mdItems->update(['biz_id' => -1, 'addr_id' => $addr_id], ['id' => $item_id]);
//添加车辆存放日志
if ($ret_i) {
$this->load->library('entity/items_entity');
if ($re_items['biz_id'] > 0) {//门店转地址变化
if ($addr_id) {
$params = array('item_id' => $item_id, 'type' => 2, 'uid' => $this->uid, 'uname' => $this->username
, 'com_time' => $com_time, 'biz_id' => $re_items['biz_id'], 'addr_id_to' => $addr_id);
$this->items_entity->add_log($params);
}
} else if ($re_items['biz_id'] == -1) {//地址间变化
if ($re_items['addr_id'] != $addr_id) {
$params = array('item_id' => $item_id, 'type' => 2, 'uid' => $this->uid, 'uname' => $this->username
, 'com_time' => $com_time, 'biz_id' => -1, 'addr_id' => $re_items['addr_id'], 'addr_id_to' => $addr_id);
$this->items_entity->add_log($params);
}
}
}
}
}
if ($ret) {
return $this->show_json(SYS_CODE_SUCCESS, '确认成功');
} else {
return $this->show_json(SYS_CODE_FAIL, '确认失败');
}
}
public function del()
@@ -361,6 +752,12 @@ class Transfer extends HD_Controller
$temp['in_uid_title'] = $value['in_uid_title'];
$temp['abnormal'] = $value['abnormal'];
$temp['status_name'] = $value['status_name'];
$temp['city'] = $value['city'];
$temp['county'] = $value['county'];
$temp['biz_name'] = $value['biz_name'];
$temp['trailer_fees'] = $value['trailer_fees'];
$temp['fees'] = $value['fees'];
$temp['reason'] = $value['reason'];
$data[] = $temp;
}
$indexs = [
@@ -368,10 +765,16 @@ class Transfer extends HD_Controller
'vin' => '车架号',
'transport_name' => '运输人员',
'c_time' => '调拨时间',
'out_uid_title' => '提车人/提车时间',
"in_uid_title" => "接车人/接车时间",
"abnormal" => "是否异常",
'out_uid_title' => '提车人',
"in_uid_title" => "接车人",
"abnormal" => "异常",
"status_name" => "状态",
"city" => "城市",
"county" => "区域",
"biz_name" => "店名",
"trailer_fees" => "运输费用",
"fees" => "费用承担方",
"reason" => "调拔理由",
];
array_unshift($data, $indexs);
$this->load->library('excel');
@@ -427,4 +830,72 @@ class Transfer extends HD_Controller
}
return $info;
}
/**
* Notes:提车/接车人信息
* Created on: 2021/12/23 10:11
* Created by: dengbw
* @param $params
* @param int $type
* @return string
*/
private function take_car($params, $type = 1)
{
$content = $city_name = $title = '';
$titleAry = [1 => '提车人', 2 => '&nbsp;&nbsp;备用提车人', 3 => '接车人', 4 => '&nbsp;&nbsp;备用接车人'];
if ($type == 1) {//门店
$re_user = $this->mdUsers->get(array('id' => $params['uid']));
$re_biz = $this->mdBiz->get(array('id' => $params['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'] . '&nbsp;&nbsp;' . $re_area['county_name'];
} else if ($re_biz['city_id']) {
$re_area = $this->mdArea->get(array('city_id' => $re_biz['city_id']));
$city_name = $re_area['city_name'];
}
$content = $titleAry[$params['type']] . "{$re_user['uname']}&nbsp;&nbsp;{$re_user['mobile']}&nbsp;&nbsp;{$city_name}&nbsp;&nbsp;{$re_biz['biz_name']}";
} else if ($type == 2) {
$re_admin = $this->mdSysAdmin->get(array('id' => $params['uid']));
$re_addr = $this->mdAddr->get(array('id' => $params['addr_id']));
$city_name = '';
if ($re_addr) {
$city_name = $re_addr['city_name'] . '&nbsp;&nbsp;' . $re_addr['county_name'] . '&nbsp;&nbsp;' . $re_addr['title'];
}
$content = $titleAry[$params['type']] . "{$re_admin['username']}&nbsp;&nbsp;{$re_admin['mobile']}&nbsp;&nbsp;{$city_name}";
}
return $content;
}
/**
* Notes:短信提醒
* Created on: 2021/12/23 10:42
* Created by: dengbw
* @param array $params
*/
private function send_alisms($params = [])
{
$uids = $params['uids'];
$type = $params['type'];
$item_info = $params['item_info'];
$car = $item_info['title'];
$item_info['cor'] && $car .= '-' . $item_info['cor'];
if ($uids && (count($uids) > 0)) {
if ($type == 1) { //门店调拨短信提醒
$uids_str = implode(',', $uids);
$res_u = $this->mdUsers->select(["id in({$uids_str})" => null], 'id desc', 0, 0, 'mobile');
foreach ($res_u as $key => $value) {
send_alisms(array('mobile' => $value['mobile'], 'template' => 'SMS_230960539'
, 'param' => ['car' => $car, 'vin' => $item_info['vin']]));
}
} else if ($type == 2) { //信息员调拨短信提醒
$uids_str = implode(',', $uids);
$res_u = $this->mdSysAdmin->select(["id in({$uids_str})" => null], 'id desc', 0, 0, 'mobile');
foreach ($res_u as $key => $value) {
send_alisms(array('mobile' => $value['mobile'], 'template' => 'SMS_231435509'
, 'param' => ['car' => $car, 'vin' => $item_info['vin']]));
}
}
}
}
}
+4
View File
@@ -226,6 +226,9 @@
<td>{{v.auto_fine}}</td>
<td>{{v.company_name}}</td>
<td><a href="javascript:void(0);"
:data-open="'/items/transfer/get?vin='+v.vin"
class="am-btn am-btn-primary am-btn-xs">调拨</a>
<a href="javascript:void(0);"
:data-open="'/items/goods/logs/get?id='+v.id+'&title='+v.title"
class="am-btn am-btn-primary am-btn-xs">轨迹</a>
<a href="javascript:void(0);"
@@ -341,6 +344,7 @@
$('#order-lists-time').val(date);
});
});
function load_goods() {
var file = $("#goods-file");
if (file.val() == '') {
+93 -24
View File
@@ -25,34 +25,67 @@
<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']) { ?>
<? if ($value['title'] == '车辆异常' && $abnormal) { ?>
<div class="am-form-inline" style="line-height: 37px;font-size: 1.6rem;margin-bottom: 8px;">
<?= $value['title'] ?><?= $value['value'] ?>
<button type="button" class="am-btn am-btn-default am-btn-sm" data-file="99"
data-type="jpg,png,gif,png,jpeg" data-uptype="qiniu"
data-field="img_rheight" data-params-source="vue_obj.abnormal.imgs"
v-if="opt_btn.type" style="margin-left: 8px;">
<i class="am-icon-cloud-upload"></i> 上传异常图片
</button>
</div>
<div class="am-form-inline">
<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 class="photo-upload-item" v-for="(v,i) in abnormal.imgs">
<img :src="v.src" class="img-thumbnail" :data-value="v.value" data-tips-image
style="width:100px;height:100px;">
<span class="photo-upload-item-remove" v-if="opt_btn.type">
<i class="fa fa-remove" data-rm-vue="vue_obj.abnormal.imgs" :data-index="i"></i>
</span>
</div>
</div>
<? } ?>
</div>
<? if ($abnormal['note']) { ?>
<div class="am-form-inline">
<textarea rows="5" disabled style="width: 50%"><?= $abnormal['note'] ?></textarea>
</div>
<? } ?>
</div>
<div class="am-form-inline" v-if="opt_btn.type">
<textarea v-if="opt_btn.type" rows="5" style="width: 50%" v-model="abnormal.note"
placeholder="请填写异常备注"></textarea>
</div>
<div class="am-form-inline" v-else-if="abnormal.note">
<textarea rows="5" disabled style="width: 50%" v-model="abnormal.note"></textarea>
</div>
<? } else if ($value['title'] == '运输人员' && $transport) { ?>
<div class="am-form-inline" style="line-height: 37px;font-size: 1.6rem;margin-bottom: 8px;">
<?= $value['title'] ?><?= $value['value'] ?>
<button type="button" class="am-btn am-btn-default am-btn-sm" data-file="99"
data-type="jpg,png,gif,png,jpeg" data-uptype="qiniu"
data-field="img_rheight" data-params-source="vue_obj.transport.imgs"
v-if="opt_btn.type" style="margin-left: 8px;">
<i class="am-icon-cloud-upload"></i> 上传运输单号
</button>
</div>
<div class="am-form-inline">
<div class="photo-upload">
<div class="photo-upload-item" v-for="(v,i) in transport.imgs">
<img :src="v.src" class="img-thumbnail" :data-value="v.value" data-tips-image
style="width:100px;height:100px;">
<span class="photo-upload-item-remove" v-if="opt_btn.type">
<i class="fa fa-remove" data-rm-vue="vue_obj.transport.imgs" :data-index="i"></i>
</span>
</div>
</div>
</div>
<? } else { ?>
<div class="am-form-inline" style="line-height: 37px;font-size: 1.6rem;">
<?= $value['title'] ?><?= $value['value'] ?>
</div>
<? } ?>
<? } ?>
</div>
</div>
<div class="am-form-group" v-if="opt_btn.type">
<a href="javascript:void(0);" @click='saveEdit();' style="margin-left: 3.5rem;margin-top: 2rem;"
class="am-btn ml20 am-btn-sm am-btn-success w100">{{opt_btn.title}}</a>
</div>
</div>
<script>
var vue_obj;
@@ -61,12 +94,48 @@
el: '#vue-edit',
data: {
info: {'items_info': {}},
abnormal: {},
transport: {},
opt_btn: {},
},
mounted: function () {
var vm = this;
vm.info = <?=json_encode($info)?>;
vm.opt_btn = <?=json_encode($opt_btn)?>;
vm.abnormal = <?=json_encode($abnormal)?>;
vm.transport = <?=json_encode($transport)?>;
},
methods: {
saveEdit: function () {
var vm = this;
$.ajax({
url: '/items/transfer/edit',
type: 'post',
dataType: 'json',
data: {opt_btn: vm.opt_btn, abnormal: vm.abnormal, transport: vm.transport},
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');
}
});
}
},
methods: {},
watch: {}
});
});
File diff suppressed because it is too large Load Diff
+360 -214
View File
@@ -72,41 +72,9 @@
</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>
<label class="am-para-label w80">提车时间</label>
<div class="am-form-group fl">
<div class="am-para-inline w220">
<div class="am-para-inline w200">
<input id="out_time" name="out_time" type="text" value="<?= $params['out_time'] ?>"
placeholder="提车时间范围" autocomplete="off"/>
</div>
@@ -122,43 +90,68 @@
</div>
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w70">提车人:</label>
<div class="am-para-inline w100">
<select name="out_city_id" v-model="takeCar1.city_id">
<option value="">选择城市</option>
<option :value="v.id" v-for="(v,i) in takeCar1.cityList">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w100">
<select name="out_county_id" v-model="takeCar1.county_id">
<option value="">选择行政区</option>
<option :value="v.id" v-for="(v,i) in takeCar1.countyList">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w100">
<select name="out_type" v-model="takeCar1.type">
<option :value="i" v-for="(v,i) in showInfo.uidTypeAry">{{v}}</option>
</select>
</div>
<template v-if="takeCar1.type==2">
<div class="am-para-inline w100">
<select name="out_admin_id" v-model="takeCar1.admin_id">
<option value="">选择信息员</option>
<template v-for="(v,i) in takeCar1.adminList">
<option :value="v.id">{{v.title}}</option>
</template>
</select>
</div>
<div class="am-para-inline w150">
<select name="out_addr_id" v-model="takeCar1.addr_id">
<option value="">选择存放地</option>
<template v-for="(v,i) in takeCar1.addrList">
<option :value="v.id">{{v.title}}</option>
</template>
</select>
</div>
</template>
<template v-else>
<div class="am-para-inline w150">
<select name="out_biz_id" v-model="takeCar1.biz_id">
<option value="">选择门店</option>
<template v-for="(v,i) in takeCar1.bizList">
<option :value="v.id">{{v.title}}</option>
</template>
</select>
</div>
<div class="am-para-inline w100">
<select name="out_uid" v-model="takeCar1.uid">
<option value="">提车人</option>
<template v-for="(v,i) in takeCar1.uidList">
<option :value="v.id">{{v.title}}</option>
</template>
</select>
</div>
</template>
</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>
<label class="am-para-label w80">接车时间</label>
<div class="am-form-group fl">
<div class="am-para-inline w220">
<div class="am-para-inline w200">
<input id="in_time" name="in_time" type="text" value="<?= $params['in_time'] ?>"
placeholder="接车时间范围" autocomplete="off"/>
</div>
@@ -174,6 +167,62 @@
</div>
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w70">接车人:</label>
<div class="am-para-inline w100">
<select name="in_city_id" v-model="takeCar3.city_id">
<option value="">选择城市</option>
<option :value="v.id" v-for="(v,i) in takeCar3.cityList">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w100">
<select name="in_county_id" v-model="takeCar3.county_id">
<option value="">选择行政区</option>
<option :value="v.id" v-for="(v,i) in takeCar3.countyList">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w100">
<select name="in_type" v-model="takeCar3.type">
<option :value="i" v-for="(v,i) in showInfo.uidTypeAry">{{v}}</option>
</select>
</div>
<template v-if="takeCar3.type==2">
<div class="am-para-inline w100">
<select name="in_admin_id" v-model="takeCar3.admin_id">
<option value="">选择信息员</option>
<template v-for="(v,i) in takeCar3.adminList">
<option :value="v.id">{{v.title}}</option>
</template>
</select>
</div>
<div class="am-para-inline w150">
<select name="in_addr_id" v-model="takeCar3.addr_id">
<option value="">选择存放地</option>
<template v-for="(v,i) in takeCar3.addrList">
<option :value="v.id">{{v.title}}</option>
</template>
</select>
</div>
</template>
<template v-else>
<div class="am-para-inline w150">
<select name="in_biz_id" v-model="takeCar3.biz_id">
<option value="">选择门店</option>
<template v-for="(v,i) in takeCar3.bizList">
<option :value="v.id">{{v.title}}</option>
</template>
</select>
</div>
<div class="am-para-inline w100">
<select name="in_uid" v-model="takeCar3.uid">
<option value="">提车人</option>
<template v-for="(v,i) in takeCar3.uidList">
<option :value="v.id">{{v.title}}</option>
</template>
</select>
</div>
</template>
</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>
@@ -195,27 +244,39 @@
<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="12%"><span>提车人</span></th>
<th width="12%"><span>接车人</span></th>
<th width="12%"><span>车辆存放地</span></th>
<th width="5%"><span>异常</span></th>
<th width="7%"><span>状态</span></th>
<th width="7%"><span>操作</span></th>
<th width="5%"><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>
<? if ($lists) {
foreach ($lists as $v) { ?>
<tr>
<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['addr_name'] ?></td>
<td><?= $v['abnormal'] ?></td>
<td><?= $v['status_name'] ?></td>
<td>
<? if ($v['status'] == -1) { ?>
<a href="javascript:void(0);" data-open="items/transfer/get_edit?id=<?= $v['id'] ?>"
>修改</a>
<? } else { ?>
<a href="javascript:void(0);" data-open="items/transfer/get?id=<?= $v['id'] ?>"
>详情</a>
<? } ?>
</td>
</tr>
<? }
} ?>
</tbody>
</table>
</div>
@@ -237,17 +298,25 @@
params: [],
statusAry: [],
abnormalAry: [],
outs: {cityAry: [], countyAry: [], bizAry: [], list: []},
ins: {cityAry: [], countyAry: [], bizAry: [], list: []},
lists: []
takeCar1: {
city_id: "", county_id: "", type: 1, biz_id: "", uid: "", admin_id: "", addr_id: "", cityList: []
, countyList: [], bizList: [], uidList: [], adminList: [], addrList: []
},
takeCar3: {
city_id: "", county_id: "", type: 1, biz_id: "", uid: "", admin_id: "", addr_id: "", cityList: []
, countyList: [], bizList: [], uidList: [], adminList: [], addrList: []
},
showInfo: [],
},
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.showInfo = <?=json_encode($showInfo)?>;
vm.init_citys();
vm.takeCar1 = vm.showInfo.takeCar[1];
vm.takeCar3 = vm.showInfo.takeCar[3];
},
methods: {
reset: function () {
@@ -260,14 +329,38 @@
$('#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 = '';
that.takeCar1 = {
city_id: "",
county_id: "",
type: 1,
biz_id: "",
uid: "",
admin_id: "",
addr_id: "",
cityList: []
,
countyList: [],
bizList: [],
uidList: [],
adminList: [],
addrList: []
};
that.takeCar3 = {
city_id: "",
county_id: "",
type: 1,
biz_id: "",
uid: "",
admin_id: "",
addr_id: "",
cityList: []
,
countyList: [],
bizList: [],
uidList: [],
adminList: [],
addrList: []
};
},
init_citys: function () {
var vm = this;
@@ -282,196 +375,249 @@
},
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));
vm.takeCar1.cityList = JSON.parse(JSON.stringify(response.data));
vm.takeCar3.cityList = JSON.parse(JSON.stringify(response.data));
}
}
});
},
chooseCountyId: function (type, nv) {
var that = this;
if (type == 1) {
if (nv == '') {
if (that.takeCar1.type == 2) {
that.takeCar1.adminList = [];
that.takeCar1.admin_id = '';
that.takeCar1.addrList = [];
that.takeCar1.addr_id = '';
} else {
that.takeCar1.bizList = [];
that.takeCar1.biz_id = '';
}
}
if (that.takeCar1.city_id && that.takeCar1.county_id) {
if (that.takeCar1.type == 2) {
$.ajax({
type: 'post',
url: '/common/admin_app',
dataType: 'json',
data: {role_id: 33},
success: function (response) {
if (response.code == 1) {
var items = [];
response.data['commonList'].map(function (value) {
items.push({id: value.id, title: value.name});
});
that.takeCar1.adminList = items;
}
}
});
$.ajax({
type: 'get',
url: '/sys/addr/json_lists',
dataType: 'json',
data: {
city_id: that.takeCar1.city_id,
county_id: that.takeCar1.county_id,
status: 1
},
success: function (response) {
if (response.code == 1) {
that.takeCar1.addrList = response.data.lists;
}
}
});
} else {
$.ajax({
type: 'post',
url: '/biz/store/store/json_lists',
dataType: 'json',
data: {
city_id: that.takeCar1.city_id,
county_id: that.takeCar1.county_id,
status: 1
},
success: function (response) {
if (response.code == 1) {
that.takeCar1.bizList = response.data.list;
}
}
});
}
}
} else if (type == 3) {
if (nv == '') {
if (that.takeCar3.type == 2) {
that.takeCar3.adminList = [];
that.takeCar3.admin_id = '';
that.takeCar3.addrList = [];
that.takeCar3.addr_id = '';
} else {
that.takeCar3.bizList = [];
that.takeCar3.biz_id = '';
}
}
if (that.takeCar3.city_id && that.takeCar3.county_id) {
if (that.takeCar3.type == 2) {
$.ajax({
type: 'post',
url: '/common/admin_app',
dataType: 'json',
data: {role_id: 33},
success: function (response) {
if (response.code == 1) {
var items = [];
response.data['commonList'].map(function (value) {
items.push({id: value.id, title: value.name});
});
that.takeCar3.adminList = items;
}
}
});
$.ajax({
type: 'get',
url: '/sys/addr/json_lists',
dataType: 'json',
data: {
city_id: that.takeCar3.city_id,
county_id: that.takeCar3.county_id,
status: 1
},
success: function (response) {
if (response.code == 1) {
that.takeCar3.addrList = response.data.lists;
}
}
});
} else {
$.ajax({
type: 'post',
url: '/biz/store/store/json_lists',
dataType: 'json',
data: {
city_id: that.takeCar3.city_id,
county_id: that.takeCar3.county_id,
status: 1
},
success: function (response) {
if (response.code == 1) {
that.takeCar3.bizList = response.data.list;
}
}
});
}
}
}
},
},
watch: {
'params.city_id_out': function (nv, ov) {
'takeCar1.city_id': 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 = '';
}
that.takeCar1.countyList = [];
that.takeCar1.county_id = '';
}
if (that.takeCar1.city_id) {
$.ajax({
type: 'get',
url: '/common/area',
dataType: 'json',
data: {
id: nv,
id: that.takeCar1.city_id,
key: 'county',
type: 1
},
success: function (response) {
if (response.code == 1) {
that.outs.countyAry = response.data;
that.takeCar1.countyList = 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;
}
}
}
});
}
'takeCar1.county_id': function (nv, ov) {
this.chooseCountyId(1, nv);
},
'params.biz_id_out': function (nv, ov) {
'takeCar1.type': function (nv, ov) {
this.chooseCountyId(1, nv);
},
'takeCar1.biz_id': function (nv, ov) {
var that = this;
if (nv == '') {
that.outs.list = [];
that.params.out_uid = '';
} else {
that.takeCar1.uidList = [];
that.takeCar1.uid = '';
}
if (that.takeCar1.biz_id) {
$.ajax({
type: 'post',
url: '/app/licheb/member/json_lists',
dataType: 'json',
data: {
biz_id: nv,
biz_id: that.takeCar1.biz_id,
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;
}
that.takeCar1.uidList = response.data.list;
}
}
});
}
},
'params.city_id_in': function (nv, ov) {
'takeCar3.city_id': 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 = '';
}
that.takeCar3.countyList = [];
that.takeCar3.county_id = '';
}
if (that.takeCar3.city_id) {
$.ajax({
type: 'get',
url: '/common/area',
dataType: 'json',
data: {
id: nv,
id: that.takeCar3.city_id,
key: 'county',
type: 1
},
success: function (response) {
if (response.code == 1) {
that.ins.countyAry = response.data;
that.takeCar3.countyList = 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;
}
}
}
});
}
'takeCar3.county_id': function (nv, ov) {
this.chooseCountyId(3);
},
'params.biz_id_in': function (nv, ov) {
'takeCar3.type': function (nv, ov) {
this.chooseCountyId(3);
},
'takeCar3.biz_id': function (nv, ov) {
var that = this;
if (nv == '') {
that.ins.list = [];
that.params.in_uid = '';
} else {
that.takeCar3.uidList = [];
that.takeCar3.uid = '';
}
if (that.takeCar3.biz_id) {
$.ajax({
type: 'post',
url: '/app/licheb/member/json_lists',
dataType: 'json',
data: {
biz_id: nv,
biz_id: that.takeCar3.biz_id,
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;
}
that.takeCar3.uidList = response.data.list;
}
}
});
}
}
},
}
});
+218 -39
View File
@@ -21,12 +21,19 @@ class Transfer extends Wxapp
$this->check_headimg = array();//授权微信信息
$this->load->model('items/items_transfer_model', 'mdTransfer');
$this->load->model('items/items_transfer_remind_model', 'mdTransferRemind');
$this->load->model('items/items_transfer_admin_model', 'mdTransferAdmin');
$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');
$this->load->model('sys/Sys_admin_model', 'mdSysAdmin');
}
protected function get_tabs()
{
return [['id' => 1, 'name' => '进行中'], ['id' => 2, 'name' => '已完成']];
}
/**
@@ -52,6 +59,7 @@ class Transfer extends Wxapp
$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) {//渠道经理
@@ -62,12 +70,25 @@ class Transfer extends Wxapp
$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];
$type = intval($this->input_param('type'));
$tabs_id = intval($this->input_param('tabs_id'));
$where = ['lc_items_transfer_remind.uid' => $this->myuid, 'lc_items_transfer.status<>' => -1];
if ($type == 1) {//提车人/备用提车人
$where['lc_items_transfer_remind.type in(1,2)'] = null;
} else if ($type == 2) {//接车人/备用接车人
$where['lc_items_transfer_remind.type in(3,4)'] = null;
}
if ($tabs_id == 2) {//已完成
$where['lc_items_transfer_remind.status'] = 2;
} else {//进行中
$where['lc_items_transfer_remind.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)
->group_by('lc_items_transfer_remind.tran_id')
->count_all_results('lc_items_transfer_remind');
}
$url = '/pages/allot/detail/index?id=';
@@ -81,15 +102,35 @@ class Transfer extends Wxapp
$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');
,lc_items_transfer.jsondata,lc_items_transfer.c_time,lc_items_transfer.biz_id,lc_items_transfer.out_type,lc_items_transfer.in_type');
$this->db->where($where);
$this->db->order_by('lc_items_transfer_remind.id Desc');
$this->db->group_by('lc_items_transfer_remind.tran_id');
$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');//用户
$out_uids = $in_uids = [];
$out_uids_ad = $in_uids_ad = [];
foreach ($res as $v2) {
if ($v2['out_uid']) {
if ($v2['out_type'] == 1) {
$out_uids[] = $v2['out_uid'];
} else if ($v2['out_type'] == 2) {
$out_uids_ad[] = $v2['out_uid'];
}
}
if ($v2['in_uid']) {
if ($v2['in_type'] == 1) {
$in_uids[] = $v2['in_uid'];
} else if ($v2['in_type'] == 2) {
$in_uids_ad[] = $v2['in_uid'];
}
}
}
$uids_arr = array_merge($out_uids, $in_uids);
$uids_ad_arr = array_merge($out_uids_ad, $in_uids_ad);
$uids = $this->mdUsers->get_map_by_ids($uids_arr, 'id,uname');
$uids_ad = $this->mdSysAdmin->get_map_by_ids($uids_ad_arr, 'id,username as 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) : [];
@@ -97,12 +138,27 @@ class Transfer extends Wxapp
$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']);
$out_uid_title = $in_uid_title = '-';
if ($val['out_uid']) {
if ($val['out_type'] == 1) {
$out_uid_title = $uids[$val['out_uid']][0]['uname'];
} else if ($val['out_type'] == 2) {
$out_uid_title = $uids_ad[$val['out_uid']][0]['uname'];
}
}
if ($val['in_uid']) {
if ($val['in_type'] == 1) {
$in_uid_title = $uids[$val['in_uid']][0]['uname'];
} else if ($val['in_type'] == 2) {
$in_uid_title = $uids_ad[$val['in_uid']][0]['uname'];
}
}
$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' => $out_uid_title];
$other_data[] = ['title' => '接车人', 'value' => $in_uid_title];
$other_data[] = ['title' => '运输员', 'value' => $jsondata['transport']['name']];
$setValue['other_data'] = $other_data;
$setValue['url'] = $url ? '/pages/allot/detail/index?id=' . $val['id'] : '';
@@ -122,8 +178,9 @@ class Transfer extends Wxapp
if (!$id) {
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
$btn = [];
$status = 0;
if ($this->session['group_id'] == 4) {//渠道不显示按钮
$btn = [];
$tran_id = $id;
} else {
$re_m = $this->mdTransferRemind->get(['id' => $id]);
@@ -131,11 +188,14 @@ class Transfer extends Wxapp
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];
$status = $re_m['status'];
if ($re_m['status'] == 1) {
$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]);
@@ -143,12 +203,18 @@ class Transfer extends Wxapp
throw new Exception('车辆调拨不存在', ERR_PARAMS_ERROR);
}
$jsondata = $re['jsondata'] ? json_decode($re['jsondata'], true) : [];
$transport_imgs = [];
if ($jsondata['transport']['imgs']) {//运输单
foreach ($jsondata['transport']['imgs'] as $key => $value) {
$value && $transport_imgs[] = ['value' => $value, 'src' => build_qiniu_image_url($value)];
}
}
$data['transport'] = ['title' => '运输负责人', 'name' => $jsondata['transport']['name']
, 'mobile' => $jsondata['transport']['mobile']];
, 'mobile' => $jsondata['transport']['mobile'], 'imgs' => $transport_imgs];
$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->where(['lc_items_transfer_remind.tran_id' => $tran_id]);
$this->db->order_by('lc_items_transfer_remind.type asc');
$this->db->limit(50);
$res_r = $this->db->get()->result_array();
@@ -156,17 +222,36 @@ class Transfer extends Wxapp
$other_data[] = ['title' => '品牌车型', 'value' => $item_info['title_1']];
$other_data[] = ['title' => '颜色型号', 'value' => $item_info['title_2']];
$other_data[] = ['title' => '车架号', 'value' => $item_info['vin']];
$uname1 = $uname2 = $uname3 = $uname4 = '';
foreach ($res_r as $key => $value) {
if ($value['type'] == 1) {
$other_data[] = ['title' => '提车人', 'value' => $value['uname']];
$uname1 = $value['uname'];
} else if ($value['type'] == 2) {
$other_data[] = ['title' => '备用提车人', 'value' => $value['uname']];
$uname2 = $value['uname'];
} else if ($value['type'] == 3) {
$other_data[] = ['title' => '接车人', 'value' => $value['uname']];
$uname3 = $value['uname'];
} else if ($value['type'] == 4) {
$other_data[] = ['title' => '备用接车人', 'value' => $value['uname']];
$uname4 = $value['uname'];
}
}
$res_a = $this->mdTransferAdmin->select(['tran_id' => $tran_id], 'type asc', 0, 0, 'uid,type');
foreach ($res_a as $key => $value) {
$re_admin = $this->mdSysAdmin->get(array('id' => $value['uid']));
$username = $re_admin['username'] ? $re_admin['username'] : '';
if ($value['type'] == 1) {
$uname1 = $username;
} else if ($value['type'] == 2) {
$uname2 = $username;
} else if ($value['type'] == 3) {
$uname3 = $username;
} else if ($value['type'] == 4) {
$uname4 = $username;
}
}
$other_data[] = ['title' => '提车人', 'value' => $uname1];
$uname2 && $other_data[] = ['title' => '备用提车人', 'value' => $uname2];
$other_data[] = ['title' => '接车人', 'value' => $uname3];
$uname4 && $other_data[] = ['title' => '备用接车人', 'value' => $uname4];
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');
@@ -183,9 +268,11 @@ class Transfer extends Wxapp
$abnormal['imgs'][$key] = $value ? build_qiniu_image_url($value) : '';
}
}
$data['btn'] = $btn;
$data['abnormal'] = $abnormal;
$data['other_data'] = $other_data;
$data['btn'] = $btn;
$data['id'] = $tran_id;
$data['status'] = $status;
return $data;
}
@@ -205,37 +292,64 @@ class Transfer extends Wxapp
if (!$re_m) {
throw new Exception('数据不存在', ERR_PARAMS_ERROR);
}
if ($re_m['status'] != 1) {
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]);//隐藏
$ret = $this->mdTransferRemind->update(['status' => 2], ['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]);//更新车辆调拨
$this->mdTransferAdmin->update(['status' => 2], ['tran_id' => $tran_id, 'type in(1,2)' => null]);//信息员已完成
//更新有门店/信息员确认接车
$this->mdTransferRemind->update(['status' => 1], ['tran_id' => $tran_id, 'type in(3,4)' => null]);//门店显示
$this->mdTransferAdmin->update(['status' => 1], ['tran_id' => $tran_id, 'type in(3,4)' => null]);//信息员显示
//更新车辆调拨
$this->mdTransfer->update(['status' => 1, 'out_type' => 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']]));
}
$res_r = $this->mdTransferRemind->select(['status' => 1, 'tran_id' => $tran_id, 'type in(3,4)' => null], 'type asc', 0, 0, 'uid');
$res_a = $this->mdTransferAdmin->select(['status' => 1, 'tran_id' => $tran_id, 'type in(3,4)' => null], 'type asc', 0, 0, 'uid');
$re_t = $this->mdTransfer->get(['id' => $tran_id]);
$item_info = $this->item_info($re_t['item_id']);
if ($res_r) {//门店调拨短信提醒
$send_uids = array_unique(array_column($res_r, 'uid'));
$this->send_alisms(['uids' => $send_uids, 'type' => 1, 'item_info' => $item_info]);
}
if ($res_a) {//信息员调拨短信提醒
$send_admins = array_unique(array_column($res_a, 'uid'));
$this->send_alisms(['uids' => $send_admins, 'type' => 2, 'item_info' => $item_info]);
}
}
} 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]);//隐藏
$ret = $this->mdTransferRemind->update(['status' => 2], ['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]);//更新车辆调拨
$this->mdTransferAdmin->update(['status' => 2], ['tran_id' => $tran_id, 'type in(3,4)' => null]);//信息员已完成
$this->mdTransfer->update(['status' => 2, 'in_type' => 1, 'in_uid' => $this->myuid, 'biz_id' => $biz_id, 'addr_id' => 0
, 'in_time' => date("Y-m-d H:i:s")], ['id' => $tran_id]);//更新车辆调拨
//更新车辆存放地
$re_t = $this->mdTransfer->get(['id' => $tran_id]);
$item_id = intval($re_t['item_id']);
$re_items = $this->mdItems->get(['id' => $item_id]);
$com_time = date('Y-m-d H:i:s');
$ret_i = $this->mdItems->update(['biz_id' => $biz_id, 'addr_id' => 0], ['id' => $item_id]);//更新车辆调拨
//添加车辆存放日志
if ($ret_i) {
$this->load->library('entity/items_entity');
$uname = $this->session['uname'] ? $this->session['uname'] : '';
if ($re_items['biz_id'] > 0) {//门店间变化
$params = array('item_id' => $item_id, 'type' => 2, 'uid' => -$this->myuid, 'uname' => $uname
, 'com_time' => $com_time, 'biz_id' => $re_items['biz_id'], 'biz_id_to' => $biz_id);
$this->items_entity->add_log($params);
} else if ($re_items['biz_id'] == -1) {//地址转门店变化
$params = array('item_id' => $item_id, 'type' => 2, 'uid' => -$this->myuid, 'uname' => $uname
, 'com_time' => $com_time, 'biz_id' => -1, 'addr_id' => $re_items['addr_id'], 'biz_id_to' => $biz_id);
$this->items_entity->add_log($params);
}
}
}
}
if ($ret) {
@@ -278,6 +392,38 @@ class Transfer extends Wxapp
}
}
/**
* Notes:上传运输单
* Created on: 2021/12/27 16:19
* Created by: dengbw
* @throws Exception
*/
protected function post_transport()
{
$id = intval($this->input_param('id'));
if (!$id) {
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
$imgs = $this->input_param('imgs');
// if (!$imgs) {
// 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) : [];
$transport = $jsondata['transport'] ? $jsondata['transport'] : [];
$transport['imgs'] = $imgs ? $imgs : '';
$jsondata['transport'] = $transport;
$ret = $this->mdTransfer->update(['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
@@ -306,4 +452,37 @@ class Transfer extends Wxapp
$info['vin'] = $re['vin'];
return $info;
}
/**
* Notes:短信提醒
* Created on: 2021/12/23 10:42
* Created by: dengbw
* @param array $params
*/
private function send_alisms($params = [])
{
$uids = $params['uids'];
$type = $params['type'];
$item_info = $params['item_info'];
$car = $item_info['title_1'];
$item_info['title_2'] && $car .= '-' . $item_info['title_2'];
if ($uids && (count($uids) > 0)) {
if ($type == 1) { //门店调拨短信提醒
$uids_str = implode(',', $uids);
$res_u = $this->mdUsers->select(["id in({$uids_str})" => null], 'id desc', 0, 0, 'mobile');
foreach ($res_u as $key => $value) {
send_alisms(array('mobile' => $value['mobile'], 'template' => 'SMS_230960539'
, 'param' => ['car' => $car, 'vin' => $item_info['vin']]));
}
} else if ($type == 2) { //信息员调拨短信提醒
$uids_str = implode(',', $uids);
$res_u = $this->mdSysAdmin->select(["id in({$uids_str})" => null], 'id desc', 0, 0, 'mobile');
foreach ($res_u as $key => $value) {
send_alisms(array('mobile' => $value['mobile'], 'template' => 'SMS_231435509'
, 'param' => ['car' => $car, 'vin' => $item_info['vin']]));
}
}
}
}
}
+2 -1
View File
@@ -148,7 +148,8 @@ class User extends Wxapp
$this->load->model('receiver/receiver_customers_visit_model', 'mdCustomersVisit');
$where = [
"cont_time = '0000-00-00 00:00:00'" => null,
'biz_id' => $biz_id
'biz_id' => $biz_id,
'status<>' => 3
];
$group_id == 1 && $where['admin_id'] = $uid;
$group_id == 4 && $where['brand_id!='] = 3; //渠道经理过滤
+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' => '代理店', '4' => '合作店');
if(!is_null($key)){
return $map[$key];
@@ -0,0 +1,28 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notes:车辆调拨
* Created on: 2021/12/17 16:43
* Created by: dengbw
*/
class Items_transfer_admin_model extends HD_Model
{
private $table_name = 'lc_items_transfer_admin';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
/**
* Notes:类型
* Created on: 2021/12/17 16:47
* Created by: dengbw
* @return array
*/
public function typeAry()
{
return array(1 => '提车人', 2 => '接车人');
}
}
+17 -1
View File
@@ -23,7 +23,7 @@ class Items_transfer_model extends HD_Model
*/
public function statusAry()
{
return array(0 => '已调拨', 1 => '确认发车', 2 => '确认接车');
return array(-1 => '未提交',0 => '已调拨', 1 => '确认发车', 2 => '确认接车');
}
/**
@@ -58,4 +58,20 @@ class Items_transfer_model extends HD_Model
return $ary;
}
/**
* Notes:提车人/接车人类型
* Created on: 2021/12/16 16:46
* Created by: dengbw
* @param string $id
* @return array|mixed
*/
public function uidTypeAry($id = '')
{
$ary = [1 => '门店', 2 => '信息员'];
if (strlen($id)) {
$ary = $ary[$id];
}
return $ary;
}
}
+16 -2
View File
@@ -5,9 +5,9 @@
* Date: 2018/11/5
* Time: 13:47
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class Sys_admin_model extends HD_Model
{
private $table_name = 'lc_sys_admin';
@@ -16,4 +16,18 @@ class Sys_admin_model extends HD_Model
{
parent::__construct($this->table_name, 'default');
}
public function get_map_by_ids($ids, $fileds = '')
{
$rows = [];
$ids = array_filter($ids);
if ($ids) {
$cf_ids = implode(',', $ids);
$where = [
"id in ($cf_ids)" => null
];
$rows = $this->map('id', '', $where, '', '', '', $fileds);
}
return $rows;
}
}