934 lines
45 KiB
PHP
934 lines
45 KiB
PHP
<?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('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("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()
|
||
{
|
||
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['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);
|
||
}
|
||
|
||
private function dataSelect($params)
|
||
{
|
||
$statusAry = $this->mdTransfer->statusAry();
|
||
$where = [];
|
||
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_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 {
|
||
if ($params['out_uid']) {
|
||
$where['out_uid'] = $params['out_uid'];
|
||
$where['out_type'] = $params['out_type'];
|
||
} else {
|
||
$params['out_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 {
|
||
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;
|
||
}
|
||
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';
|
||
}
|
||
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 = $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);
|
||
$out_uid_title = $in_uid_title = '-';
|
||
$tag = $params['size'] == 10000 ? '/' : '<br>';
|
||
$out_addr_name = $in_addr_name = '';
|
||
if ($v['out_uid']) {
|
||
$biz_id = $addr_id = 0;
|
||
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']));
|
||
$re_out = $this->mdTransferRemind->get(['tran_id' => $v['id'], 'uid' => $v['out_uid'], 'type in(1,2)']);
|
||
$biz_id = $re_out['biz_id'];
|
||
} 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']));
|
||
$re_out = $this->mdTransferAdmin->get(['tran_id' => $v['id'], 'uid' => $v['out_uid'], 'type in(1,2)']);
|
||
$addr_id = $re_out['addr_id'];
|
||
}
|
||
$out_addr_name = $this->take_biz(['uid' => $v['out_uid'], 'biz_id' => $biz_id, 'addr_id' => $addr_id], $v['out_type']);
|
||
}
|
||
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']));
|
||
}
|
||
$in_addr_name = $this->take_biz(['uid' => $v['in_uid'], 'biz_id' => $v['biz_id'], 'addr_id' => $v['addr_id']], $v['in_type']);
|
||
}
|
||
$setValue = [
|
||
'id' => $v['id'],
|
||
'title' => $item_info['title'],
|
||
'vin' => $item_info['vin'],
|
||
'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']],
|
||
'out_addr_name' => $out_addr_name,
|
||
'in_addr_name' => $in_addr_name,
|
||
];
|
||
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['trailer_fees'] = $v['trailer_fees'];
|
||
$setValue['fees'] = $trailer_fees;
|
||
$setValue['reason'] = $jsondata['reason'] ? $jsondata['reason'] : '';
|
||
}
|
||
$lists[] = $setValue;
|
||
}
|
||
}
|
||
$data['lists'] = $lists;
|
||
$data['params'] = $params;
|
||
$data['takeCar'] = $takeCar;
|
||
$data['total'] = $total;
|
||
return $data;
|
||
}
|
||
|
||
public function get()
|
||
{
|
||
$id = intval($this->input->get('id'));
|
||
$info = [];
|
||
if ($id) {
|
||
$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']);
|
||
$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;
|
||
}
|
||
}
|
||
}
|
||
//信息员
|
||
$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']];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
$jsondata = $re['jsondata'] ? json_decode($re['jsondata'], true) : [];
|
||
$fields[] = ['title' => '提车信息', 'value' => $out_content . $out_content_bak];
|
||
$fields[] = ['title' => '接车信息', 'value' => $in_content . $in_content_bak];
|
||
$fields[] = ['title' => '运输人员', 'value' => $jsondata['transport']['name'] . ' ' .
|
||
$jsondata['transport']['mobile'] . ' 身份证:' . $jsondata['transport']['cardid']];
|
||
if ($jsondata['transport']) {
|
||
$transport = $jsondata['transport'];
|
||
$imgs = [];
|
||
if ($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(' ', 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'];
|
||
$imgs = [];
|
||
if ($abnormal['imgs']) {
|
||
foreach ($abnormal['imgs'] as $key => $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 .= ' 费用承担人:' . $this->mdTransfer->feesTypeAry($re['fees_type']);
|
||
if ($re['fees_city']) {
|
||
$re_area = $this->mdArea->get(array('city_id' => $re['fees_city']));
|
||
$trailer_fees .= ' ' . $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 .= ' ' . $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' => $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);
|
||
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['_title'] = $title;
|
||
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');
|
||
$trailer_fees = intval($info['trailer_fees']);
|
||
if ($info['status'] != -1) {//提交判断
|
||
if (!$info['arti_id']) {
|
||
return $this->show_json(SYS_CODE_FAIL, '请选择随车物品');
|
||
}
|
||
if (!$takeCar[1]['uid'] && !$takeCar[1]['addr_id']) {
|
||
return $this->show_json(SYS_CODE_FAIL, '请选择提车人');
|
||
}
|
||
if (!$takeCar[3]['uid'] && !$takeCar[3]['addr_id']) {
|
||
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, '请输入运输人员姓名/电话/身份证号');
|
||
}
|
||
}
|
||
$re = $this->mdTransfer->get(['item_id' => $info['item_id'], 'status in(0,1)' => null]);
|
||
if ($re) {
|
||
return $this->show_json(SYS_CODE_FAIL, '操作失败,车辆正在调拨中...');
|
||
}
|
||
$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_biz_id' => intval($info['fees_biz_id']),
|
||
'out_type' => $takeCar[1]['type'],
|
||
'in_type' => $takeCar[3]['type'],
|
||
'status' => intval($info['status'])
|
||
];
|
||
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, '添加失败');
|
||
}
|
||
}
|
||
//常用运输人员
|
||
$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);
|
||
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()
|
||
{
|
||
$id = $this->input->post('id');
|
||
$re = $this->mdTransfer->get(array('id' => $id));
|
||
if ($re && ($re['status'] <> -1)) {
|
||
return $this->show_json(SYS_CODE_FAIL, '调拨已提交,不能删除');
|
||
}
|
||
$this->mdTransfer->delete(['id' => $id]);
|
||
return $this->show_json(SYS_CODE_SUCCESS, '删除成功!');
|
||
}
|
||
|
||
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['out_addr_name'] = $value['out_addr_name'];
|
||
$temp['in_uid_title'] = $value['in_uid_title'];
|
||
$temp['in_addr_name'] = $value['in_addr_name'];
|
||
$temp['abnormal'] = $value['abnormal'];
|
||
$temp['status_name'] = $value['status_name'];
|
||
$temp['trailer_fees'] = $value['trailer_fees'];
|
||
$temp['fees'] = $value['fees'];
|
||
$temp['reason'] = $value['reason'];
|
||
$data[] = $temp;
|
||
}
|
||
$indexs = [
|
||
'title' => '车辆',
|
||
'vin' => '车架号',
|
||
'transport_name' => '运输人员',
|
||
'c_time' => '调拨时间',
|
||
'out_uid_title' => '提车人',
|
||
'out_addr_name' => '提车地址',
|
||
"in_uid_title" => "接车人",
|
||
'in_addr_name' => '存放地址',
|
||
"abnormal" => "异常",
|
||
"status_name" => "状态",
|
||
"trailer_fees" => "运输费用",
|
||
"fees" => "费用承担方",
|
||
"reason" => "调拔理由",
|
||
];
|
||
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;
|
||
}
|
||
|
||
/**
|
||
* 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 => ' 备用提车人', 3 => '接车人', 4 => ' 备用接车人'];
|
||
if ($type == 1) {//门店
|
||
$re_user = $this->mdUsers->get(array('id' => $params['uid']));
|
||
$biz_id = $params['biz_id'] ? $params['biz_id'] : intval($re_user['biz_id']);
|
||
$re_biz = $this->mdBiz->get(array('id' => $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 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']} {$re_user['mobile']} {$city_name} {$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'] . ' ' . $re_addr['county_name'] . ' ' . $re_addr['title'];
|
||
}
|
||
$content = $titleAry[$params['type']] . "({$re_admin['username']} {$re_admin['mobile']} {$city_name})";
|
||
}
|
||
return $content;
|
||
}
|
||
|
||
/**
|
||
* Notes:提车/接车人地址
|
||
* Created on: 2021/12/30 10:16
|
||
* Created by: dengbw
|
||
* @param $params
|
||
* @param int $type
|
||
* @return string
|
||
*/
|
||
private function take_biz($params, $type = 1)
|
||
{
|
||
$content = $city_name = $title = '';
|
||
if ($type == 1) {//门店
|
||
if ($params['biz_id']) {
|
||
$biz_id = $params['biz_id'];
|
||
} else {
|
||
$re_user = $this->mdUsers->get(array('id' => $params['uid']));
|
||
$biz_id = intval($re_user['biz_id']);
|
||
}
|
||
$re_biz = $this->mdBiz->get(array('id' => $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 if ($re_biz['city_id']) {
|
||
$re_area = $this->mdArea->get(array('city_id' => $re_biz['city_id']));
|
||
$city_name = $re_area['city_name'];
|
||
}
|
||
$content = "{$city_name}-{$re_biz['biz_name']}";
|
||
} else if ($type == 2) {
|
||
$re_addr = $this->mdAddr->get(array('id' => $params['addr_id']));
|
||
if ($re_addr) {
|
||
$content = $re_addr['city_name'] . '-' . $re_addr['county_name'] . '-' . $re_addr['title'];
|
||
}
|
||
}
|
||
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']]));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
} |