diff --git a/admin/controllers/Common.php b/admin/controllers/Common.php index a80cfb09..61f3327d 100644 --- a/admin/controllers/Common.php +++ b/admin/controllers/Common.php @@ -46,6 +46,18 @@ class Common extends CI_Controller case 'county': $this->data = $this->area_model->county($id, $type); break; + case 'street': + $this->load->model('sys/sys_street_model', 'mdStreet'); + $result = []; + $type == 0 && $result[] = array('name' => '街道/乡镇', 'id' => ''); + $list = $this->mdStreet->select(['county_id' => $id], 'id ASC', 0, 0, 'street_id,street_name'); + if ($list) { + foreach ($list as $v) { + $result[$v['street_id']] = array('id' => $v['street_id'], 'name' => $v['street_name']); + } + } + $this->data = $result; + break; default: $this->data = $this->area_model->province(); break; @@ -942,7 +954,7 @@ class Common extends CI_Controller $this->load->library('hdwechat', $wxconfig); $result = $this->hdwechat->qrcode($filename, $scene, $page, $width); if ($result) { - $this->data['qrcode'] = http_host_com() .'/'. $result['url']; + $this->data['qrcode'] = http_host_com() . '/' . $result['url']; } // $scene = 82; // $url_params = array('path' => '/' . $page, 'query' => 'id=' . $scene . '&form=auth&_um_campaign=604823e96ee47d382b7a2b79&_um_channel=604823e96ee47d382b7a2b7a', diff --git a/admin/controllers/auto/Article.php b/admin/controllers/auto/Article.php new file mode 100644 index 00000000..ec28740b --- /dev/null +++ b/admin/controllers/auto/Article.php @@ -0,0 +1,256 @@ +load->model('auto/auto_article_model'); + + $this->log_dir = "auto_" . get_class($this); + } + + public function index() + { + return $this->lists(); + } + + public function lists() + { + $params = $this->input->get(); + + $statusAry = array(0 => '关闭', 1 => '开启'); + + $where = array(); + + if ($params['title']) { + $where["title like '%{$params['title']}%'"] = null; + } + if (strlen($params['status']) > 0) { + $where['status'] = $params['status']; + } else { + $where['status>-1'] = null; + $params['status'] = ''; + } + + $page = $params['page']; + $page = !$page ? 1 : $page; + $size = $params['size']; + $size = !$size ? 20 : $size; + + $total = $this->auto_article_model->count($where); + $lists = array(); + if ($total) { + $orderby = 'id desc'; + $select = 'id, title, status'; + $rows = $this->auto_article_model->select($where, $orderby, $page, $size, $select); + foreach ($rows as $v) { + $lists[] = array( + 'id' => $v['id'], + 'title' => $v['title'], + 'status' => $v['status'], + 'status_name' => $statusAry[$v['status']], + ); + } + } + + $this->data['params'] = $params; + $this->data['lists'] = $lists; + $this->data['statusAry'] = $statusAry; + $this->data['pager'] = array('count' => ceil($total / $size), 'curr' => $page, 'totle' => $total); + $this->data['_title'] = '随车物品管理'; + $this->show_view('auto/article/lists', true); + } + + public function get() + { + $id = $this->input->get('id'); + if ($id) { + $row = $this->auto_article_model->get(array('id' => $id)); + $info = array( + 'id' => $row['id'], + 'title' => $row['title'], + 'status' => $row['status'] + ); + $title = '编辑随车物品'; + $action = 'auto/article/edit'; + } else { + $info = array( + 'title' => '', + 'status' => 1, + ); + $title = '新增随车物品'; + $action = 'auto/article/add'; + } + + $statusAry = array(0 => '关闭', 1 => '开启'); + + $this->data['info'] = $info; + $this->data['statusAry'] = $statusAry; + $this->data['action'] = $action; + $this->data['_title'] = $title; + $this->show_view('auto/article/get'); + } + + /** + * 新增物品 + * @return bool + */ + public function add() + { + $info = $this->input->post('info'); + if (!$info['title']) { + return $this->show_json(SYS_CODE_FAIL, '请输入物品名称'); + } + + $where = array("title" => trim($info['title'])); + $old = $this->auto_article_model->get($where); + if ($old && $old['status'] > -1) { + return $this->show_json(SYS_CODE_FAIL, '物品已经存在'); + } else if (-1 == $old['status']) { + //旧数据存在,更新 + $upd = array('status' => $info['status']); + $ret = $this->auto_article_model->update($upd, array('id' => $old['id'])); + if (!$ret) { + debug_log('[error]# update fail; ' . $this->auto_article_model->db->last_query(), __FUNCTION__, $this->log_dir); + return $this->show_json(SYS_CODE_FAIL, '添加失败'); + } + } else { + $add = array( + 'title' => $info['title'], + 'status' => $info['status'], + 'c_time' => time(), + ); + $ret = $this->auto_article_model->add($add); + if (!$ret) { + debug_log('[error]# add fail; ' . $this->auto_article_model->db->last_query(), __FUNCTION__, $this->log_dir); + return $this->show_json(SYS_CODE_FAIL, '添加失败'); + } + } + + return $this->show_json(SYS_CODE_SUCCESS, '添加成功'); + } + + /** + * 编辑 + * @return bool + */ + public function edit() + { + $info = $this->input->post('info'); + if (!$info['title']) { + return $this->show_json(SYS_CODE_FAIL, '请输入物品名称'); + } + + $where = array( + "title" => trim($info['title']), + "id<>{$info['id']}" => null, + "status>-1" => null + ); + $old = $this->auto_article_model->get($where); + if ($old) { + return $this->show_json(SYS_CODE_FAIL, '物品已经存在'); + } + + $upd = array('title' => $info['title'], 'status' => $info['status']); + $ret = $this->auto_article_model->update($upd, array('id' => $info['id'])); + if (!$ret) { + debug_log('[error]# update fail; ' . $this->auto_article_model->db->last_query(), __FUNCTION__, $this->log_dir); + return $this->show_json(SYS_CODE_FAIL, '添加失败'); + } + + return $this->show_json(SYS_CODE_SUCCESS, '添加成功'); + } + + function edit_status() + { + $id = $this->input->post('id'); + $stauts = $this->input->post('status'); + if (!$id) { + $this->show_json(SYS_CODE_FAIL, '参数错误'); + } + $where = array('id' => $id); + $this->auto_article_model->update(array('status' => $stauts), $where); + return $this->show_json(SYS_CODE_SUCCESS, '操作成功'); + } + + public function del() + { + $id = $this->input->post('id'); + if (!$id) { + $this->show_json(SYS_CODE_FAIL, '参数错误'); + } + $where = array('id' => $id); + $ret = $this->auto_article_model->update(array('status' => -1), $where); + return $this->show_json(SYS_CODE_SUCCESS, '操作成功'); + } + + public function batch() + { + // TODO: Implement batch() method. + } + + public function export() + { + // TODO: Implement export() method. + } + + /** + * @return bool + */ + function json_lists() + { + $id = $this->input->post('id'); + $title = trim($this->input->post('title')); + $status = $this->input->post('status'); + $page = $this->input->post('page'); + $size = $this->input->post('size'); + + $where = array(); + if ($id) { + if (is_numeric($id)) { + $where['id'] = $id; + } else { + if (is_array($id)) { + $id = implode(',', $id); + } + $where["id in ({$id})"] = null; + } + } else { + $title && $where["title like '%{$title}%'"] = null; + if (strlen($status) > 0) { + $where['status'] = $status; + } else { + $where['status>-1'] = null; + } + } + + $total = $this->auto_article_model->count($where); + $lists = array(); + if ($total) { + $orderby = 'id desc'; + $select = 'id, title'; + $rows = $this->auto_article_model->select($where, $orderby, $page, $size, $select); + + foreach ($rows as $v) { + $lists[] = array( + 'id' => $v['id'], + 'title' => $v['title'], + ); + } + } + + $this->data = array('total' => $total, 'list' => $lists); + return $this->show_json(SYS_CODE_SUCCESS); + } +} \ No newline at end of file diff --git a/admin/controllers/items/Transfer.php b/admin/controllers/items/Transfer.php new file mode 100644 index 00000000..f5cdd9b2 --- /dev/null +++ b/admin/controllers/items/Transfer.php @@ -0,0 +1,428 @@ +load->model('items/items_transfer_model', 'mdTransfer'); + $this->load->model('items/items_transfer_remind_model', 'mdTransferRemind'); + $this->load->model('app/licheb/app_licheb_users_model', 'mdUsers'); + $this->load->model('items/items_model', 'mdItems'); + + $this->load->model('auto/auto_brand_model', 'mdAutoBrand'); + $this->load->model('auto/auto_series_model', 'mdAutoSeries'); + $this->load->model('auto/auto_attr_model', 'mdAutoAttr'); + $this->load->model("sys/sys_addr_model", 'mdAddr'); + $this->load->model("biz/biz_model", 'mdBiz'); + $this->load->model('area_model', 'mdArea'); + } + + public function index() + { + return $this->lists(); + } + + public function lists() + { + $this->load->model('auto/auto_brand_model', 'mdAutoBrand'); + $this->load->model('auto/auto_series_model', 'mdAutoSeries'); + $this->load->model('auto/auto_attr_model', 'mdAutoAttr'); + $params = $this->input->get(); + $params['page'] = $params['page'] ? intval($params['page']) : 1; + $params['size'] = $params['size'] ? intval($params['size']) : 20; + $re = $this->dataSelect($params); + $autoList[1] = $this->mdAutoBrand->select(array('status' => 1), 'id desc', 0, 0, 'id,name'); + if ($params['brand_id']) { + $autoList[2] = $this->mdAutoSeries->select(array('status' => 1, 'brand_id' => $params['brand_id']), 'id desc', 0, 0, 'id,name'); + } + if ($params['s_id']) { + $autoList[3] = $this->mdAutoAttr->select(array('type' => 1, 's_id' => $params['s_id']), 'id desc', 0, 0, 'id,title as name'); + } + $total = $re['total']; + $this->data['params'] = $re['params']; + $this->data['lists'] = $re['lists']; + $this->data['statusAry'] = $this->mdTransfer->statusAry(); + $this->data['abnormalAry'] = $this->mdTransfer->abnormalAry(); + $this->data['autoList'] = $autoList; + $this->data['pager'] = array('count' => ceil($total / $params['size']), 'curr' => $params['page'], 'totle' => $total); + $this->data['_title'] = '车辆调拨'; + $this->show_view('items/transfer/lists', true); + } + + private function dataSelect($params) + { + $statusAry = $this->mdTransfer->statusAry(); + $where = ['status<>' => -1]; + if (strlen($params['status'])) { + $where['status'] = $params['status']; + } else { + $params['status'] = ''; + } + if (strlen($params['abnormal'])) { + $where['abnormal'] = $params['abnormal']; + } else { + $params['abnormal'] = ''; + } + if ($params['out_uid']) { + $where['out_uid'] = $params['out_uid']; + } else { + $params['out_uid'] = ''; + !$params['city_id_out'] && $params['city_id_out'] = ''; + !$params['county_id_out'] && $params['county_id_out'] = ''; + !$params['biz_id_out'] && $params['biz_id_out'] = ''; + } + if ($params['in_uid']) { + $where['in_uid'] = $params['in_uid']; + } else { + $params['in_uid'] = ''; + !$params['city_id_in'] && $params['city_id_in'] = ''; + !$params['county_id_in'] && $params['county_id_in'] = ''; + !$params['biz_id_in'] && $params['biz_id_in'] = ''; + } + if ($params['title']) { + $where["item_id in (select id from lc_items where vin like '%{$params['title']}%')"] = null; + } + if ($params['brand_id'] || $params['s_id'] || $params['v_id']) { + $where_items = "brand_id = {$params['brand_id']}"; + $params['s_id'] && $where_items .= " and s_id = {$params['s_id']}"; + $params['v_id'] && $where_items .= " and v_id = {$params['v_id']}"; + $where["item_id in (select id from lc_items where $where_items)"] = null; + } + if ($params['out_time']) { + $out_time = explode(' ~ ', $params['out_time']); + $out_time[0] && $where["out_time >="] = $out_time[0] . ' 00:00:00'; + $out_time[1] && $where["out_time <="] = $out_time[1] . ' 23:59:59'; + } + if ($params['in_time']) { + $in_time = explode(' ~ ', $params['in_time']); + $in_time[0] && $where["in_time >="] = $in_time[0] . ' 00:00:00'; + $in_time[1] && $where["in_time <="] = $in_time[1] . ' 23:59:59'; + } + $total = $this->mdTransfer->count($where); + $lists = array(); + if ($total) { + $rows = $this->mdTransfer->select($where, 'id desc', $params['page'], $params['size']); + $out_uids = array_unique(array_column($rows, 'out_uid')); + $in_uids = array_unique(array_column($rows, 'in_uid')); + $uids_arr = array_merge($out_uids, $in_uids); + $uids = $this->mdUsers->get_map_by_ids($uids_arr, 'id,uname'); + foreach ($rows as $v) { + $jsondata = $v['jsondata'] ? json_decode($v['jsondata'], true) : []; + $item_info = $this->item_info($v['item_id'], 1); + $lists[] = array( + 'id' => $v['id'], + 'title' => $item_info['title'], + 'vin' => $item_info['vin'], + 'out_uid_title' => $v['out_uid'] ? $uids[$v['out_uid']][0]['uname'] . '/' . date('Y.m.d H:i', strtotime($v['out_time'])) : '-', + 'in_uid_title' => $v['in_uid'] ? $uids[$v['in_uid']][0]['uname'] . '/' . date('Y.m.d H:i', strtotime($v['in_time'])) : '-', + 'transport_name' => $jsondata['transport']['name'], + 'abnormal' => $this->mdTransfer->abnormalAry($v['abnormal']), + 'c_time' => date('Y.m.d H:i', $v['c_time']), + 'status_name' => $statusAry[$v['status']], + ); + } + } + $data['lists'] = $lists; + $data['params'] = $params; + $data['total'] = $total; + return $data; + } + + public function get() + { + $id = $this->input->get('id'); + $info = []; + if ($id) { + $re = $this->mdTransfer->get(array('id' => $id, 'status <>' => -1)); + if (!$re || empty($re)) { + return $this->show_json(SYS_CODE_FAIL, '车辆调拨不存在!'); + } + $this->load->model('auto/auto_article_model', 'mdArticle'); + $info['item_id'] = $re['item_id']; + $info['items_info'] = $this->item_info($re['item_id']); + $res_r = $this->mdTransferRemind->select(['tran_id' => $id], 'type asc', 0, 0, 'uid,type'); + $out_content = $in_content = $arti_content = $abnormal = ''; + foreach ($res_r as $key => $value) { + if ($value['type'] == 1) { + $re_user = $this->mdUsers->get(array('id' => $value['uid'])); + $re_biz = $this->mdBiz->get(array('id' => $re_user['biz_id'])); + if ($re_biz['county_id']) { + $re_area = $this->mdArea->get(array('county_id' => $re_biz['county_id'])); + $city_name = $re_area['city_name'] . ' ' . $re_area['county_name']; + } else { + $re_area = $this->mdArea->get(array('city_id' => $re_biz['city_id'])); + $city_name = $re_area['city_name']; + } + $out_content = $city_name . ' ' . $re_biz['biz_name'] . '    提车人:' . $re_user['uname'] + . '  ' . $re_user['mobile']; + } else if ($value['type'] == 2) { + $re_user = $this->mdUsers->get(array('id' => $value['uid'])); + $out_content .= '    备用提车人:' . $re_user['uname'] . '  ' . $re_user['mobile']; + } else if ($value['type'] == 3) { + $re_user = $this->mdUsers->get(array('id' => $value['uid'])); + $re_biz = $this->mdBiz->get(array('id' => $re_user['biz_id'])); + if ($re_biz['county_id']) { + $re_area = $this->mdArea->get(array('county_id' => $re_biz['county_id'])); + $city_name = $re_area['city_name'] . ' ' . $re_area['county_name']; + } else { + $re_area = $this->mdArea->get(array('city_id' => $re_biz['city_id'])); + $city_name = $re_area['city_name']; + } + $in_content = $city_name . ' ' . $re_biz['biz_name'] . '    接车人:' . $re_user['uname'] + . '  ' . $re_user['mobile']; + } else if ($value['type'] == 4) { + $re_user = $this->mdUsers->get(array('id' => $value['uid'])); + $in_content .= '    备用接车人:' . $re_user['uname'] . '  ' . $re_user['mobile']; + } + } + $jsondata = $re['jsondata'] ? json_decode($re['jsondata'], true) : []; + $trailer_fees = $re['trailer_fees'] ? $re['trailer_fees'] . '元' : ''; + $trailer_fees .= '  费用承担人:'; + if ($re['fees_city']) { + $re_area = $this->mdArea->get(array('city_id' => $re['fees_city'])); + $trailer_fees .= $re_area['city_name']; + } + $trailer_fees .= '  ' . $this->mdTransfer->feesTypeAry($re['fees_type']); + $fields[] = ['title' => '提车信息', 'value' => $out_content]; + $fields[] = ['title' => '接车信息', 'value' => $in_content]; + $fields[] = ['title' => '运输费用', 'value' => $trailer_fees]; + $fields[] = ['title' => '运输人员', 'value' => $jsondata['transport']['name'] . '   ' . + $jsondata['transport']['mobile'] . '   身份证:' . $jsondata['transport']['cardid']]; + if ($re['arti_id']) { + $res_a = $this->mdArticle->select(["id in ({$re['arti_id']})" => null], 'id desc', 0, 0, 'title'); + $res_a && $arti_content = implode('   ', array_unique(array_column($res_a, 'title'))); + } + $fields[] = ['title' => '随身物品', 'value' => $arti_content]; + $fields[] = ['title' => '车辆异常', 'value' => $this->mdTransfer->abnormalAry()[$re['abnormal']]]; + if ($re['abnormal'] && $jsondata['abnormal']) { + $abnormal = $jsondata['abnormal']; + foreach ($abnormal['imgs'] as $key => $value) { + $abnormal['imgs'][$key] = $value ? build_qiniu_image_url($value) : ''; + } + } + $this->data['fields'] = $fields; + $this->data['abnormal'] = $abnormal; + $title = '车辆调拨详情'; + $view = 'items/transfer/get'; + } else { + $title = '新增车辆调拨'; + $view = 'items/transfer/get_add'; + $showInfo = ['vin' => '', 'items_info' => ['id' => 0, 'title' => '', 'vin' => '', 'cor' => '', 'address' => ''], + 'feesTypeAry' => $this->mdTransfer->feesTypeAry()]; + $info = ['item_id' => 0, 'arti_id' => [], 'out_uid' => '', 'out_uid_bak' => '', 'in_uid' => '', 'in_uid_bak' => '' + , 'out_bak' => 0, 'in_bak' => 0, 'trailer_fees' => '', 'fees_city' => '', 'fees_type' => 1, 'transport' => ['name' => '', 'mobile' => '', 'cardid' => '']]; + //常用运输人员 + $cache = &load_cache('redis'); + $cache_transports = $cache->get($this->cacheKeyTransports); + $transports = []; + $time = date('Y-m-d', strtotime("-1 month")); + foreach ($cache_transports as $key => $value) { + if ($value['time'] >= $time) {//小于1个月过期不显示 + $transports[] = $value; + } + } + $cache->save($this->cacheKeyTransports, $transports); + $transports && $transports = array_reverse($transports);//倒序 + $this->data['transports'] = $transports;//常用运输人员 + $this->data['showInfo'] = $showInfo; + } + $this->data['info'] = $info; + $this->data['_title'] = $title; + return $this->show_view($view, true); + } + + /** + * 新增物品 + * @return bool + */ + public function add() + { + $info = $this->input->post('info'); + if (!$info['arti_id']) { + return $this->show_json(SYS_CODE_FAIL, '请选择随车物品'); + } + if (!$info['out_uid']) { + return $this->show_json(SYS_CODE_FAIL, '请选择提车人'); + } + if (!$info['in_uid']) { + return $this->show_json(SYS_CODE_FAIL, '请选择接车人'); + } + $trailer_fees = intval($info['trailer_fees']); + if (!$trailer_fees) { + return $this->show_json(SYS_CODE_FAIL, '请输入运输费用'); + } + if (!$info['transport']['name'] || !$info['transport']['mobile'] || !$info['transport']['cardid']) { + return $this->show_json(SYS_CODE_FAIL, '请输入运输人员姓名/电话/身份证号'); + } + $re = $this->mdTransfer->get(['item_id' => $info['item_id'], 'status in(0,1)' => null]); + if ($re) { + return $this->show_json(SYS_CODE_FAIL, '添加失败,车辆正在调拨中...'); + } + $re_user = $this->mdUsers->get(array('id' => $info['in_uid']));//查找用户负责门店 + $biz_id = $re_user['biz_id'] ? $re_user['biz_id'] : 0; + $jsondata['transport'] = $info['transport']; + $c_time = time(); + $add = [ + 'item_id' => $info['item_id'], + 'biz_id' => $biz_id, + 'arti_id' => $info['arti_id'] ? implode(',', $info['arti_id']) : '', + 'jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE), + 'trailer_fees' => $trailer_fees, + 'fees_city' => intval($info['fees_city']), + 'fees_type' => $info['fees_type'], + 'c_time' => $c_time, + ]; + $id = $this->mdTransfer->add($add); + if (!$id) { + return $this->show_json(SYS_CODE_FAIL, '添加失败'); + } + //车辆调拨提醒 + $send_uids[] = $info['out_uid']; + $addRemind[] = ['tran_id' => $id, 'uid' => $info['out_uid'], 'type' => 1, 'status' => 1, 'c_time' => $c_time];//提车人 + if ($info['out_uid_bak']) { + $addRemind[] = ['tran_id' => $id, 'uid' => $info['out_uid_bak'], 'type' => 2, 'status' => 1, 'c_time' => $c_time];//备用提车人 + $send_uids[] = $info['out_uid_bak']; + } + $addRemind[] = ['tran_id' => $id, 'uid' => $info['in_uid'], 'type' => 3, 'status' => 0, 'c_time' => $c_time];//接车人 + $info['in_uid_bak'] && $addRemind[] = ['tran_id' => $id, 'uid' => $info['in_uid_bak'], 'type' => 4, 'status' => 0, 'c_time' => $c_time];//备用接车人 + $this->mdTransferRemind->add_batch($addRemind); + //调拨短信提醒 + if ($send_uids) { + $item_info = $this->input->post('items_info'); + $uids_str = implode(',', $send_uids); + $res_u = $this->mdUsers->select(["id in({$uids_str})" => null], 'id desc', 0, 0, 'mobile'); + foreach ($res_u as $key => $value) { + $car = $item_info['title']; + $item_info['cor'] && $car .= '-' . $item_info['cor']; + send_alisms(array('mobile' => $value['mobile'], 'template' => 'SMS_229648438' + , 'param' => ['car' => $car, 'vin' => $item_info['vin']])); + } + } + //常用运输人员 + $cache = &load_cache('redis'); + $cache_transports = $cache->get($this->cacheKeyTransports); + $addTransports = true; + foreach ($cache_transports as $key => $value) { + if ($value['mobile'] == $info['transport']['mobile']) { + $value['time'] = date('Y-m-d'); + $addTransports = false; + } + } + if ($addTransports) { + $info['transport']['time'] = date('Y-m-d'); + $cache_transports[] = $info['transport']; + } + $cache->save($this->cacheKeyTransports, $cache_transports); + return $this->show_json(SYS_CODE_SUCCESS, '添加成功'); + } + + /** + * 编辑 + * @return bool + */ + public function edit() + { + } + + public function del() + { + } + + public function batch() + { + // TODO: Implement batch() method. + } + + public function export() + { + $params = $this->input->get(); + $params['page'] = 1; + $params['size'] = 10000; + $data = $indexs = array(); + $res = $this->dataSelect($params); + $fileName = "车辆调拨"; + foreach ($res['lists'] as $key => $value) { + $temp['title'] = $value['title']; + $temp['vin'] = $value['vin']; + $temp['transport_name'] = $value['transport_name']; + $temp['c_time'] = $value['c_time']; + $temp['out_uid_title'] = $value['out_uid_title']; + $temp['in_uid_title'] = $value['in_uid_title']; + $temp['abnormal'] = $value['abnormal']; + $temp['status_name'] = $value['status_name']; + $data[] = $temp; + } + $indexs = [ + 'title' => '车辆', + 'vin' => '车架号', + 'transport_name' => '运输人员', + 'c_time' => '调拨时间', + 'out_uid_title' => '提车人/提车时间', + "in_uid_title" => "接车人/接车时间", + "abnormal" => "是否异常", + "status_name" => "状态", + ]; + array_unshift($data, $indexs); + $this->load->library('excel'); + $this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis')); + } + + /** + * Notes:获取商品信息 + * Created on: 2021/12/9 10:47 + * Created by: dengbw + * @param $item_id + * @param int $type + * @return array + */ + private function item_info($item_id, $type = 0) + { + $re = $this->mdItems->get(array('id' => $item_id)); + if (!$re || empty($re)) { + return []; + } + $re_b = $this->mdAutoBrand->get(array('id' => $re['brand_id']), 'name'); + $re_s = $this->mdAutoSeries->get(array('id' => $re['s_id']), 'name'); + $re_v = $this->mdAutoAttr->get(array('id' => $re['v_id']), 'title'); + $re_cor = $this->mdAutoAttr->get(array('id' => $re['cor_id']), 'title'); + $title = ''; + $re_b['name'] && $title = $re_b['name']; + $re_s['name'] && $title = $title ? $title . '-' . $re_s['name'] : $re_s['name']; + $re_v['title'] && $title = $title ? $title . '-' . $re_v['title'] : $re_v['title']; + if ($type == 1) { + $re_cor['title'] && $title = $title ? $title . '-' . $re_cor['title'] : $re_cor['title']; + } + $info['title'] = $title; + $info['vin'] = $re['vin']; + if ($type == 0) { + $info['id'] = $re['id']; + $info['cor'] = $re_cor['title'] ? $re_cor['title'] : ''; + $address = ''; + if ($re['biz_id'] > 0) { + $re_biz = $this->mdBiz->get(array('id' => $re['biz_id'])); + $re_biz && $address = $re_biz['biz_name']; + if ($re_biz['county_id']) { + $re_area = $this->mdArea->get(array('county_id' => $re_biz['county_id'])); + $re_area && $address = "{$re_area['city_name']} {$re_area['county_name']} {$address}"; + } else if ($re_biz['city_id']) { + $re_area = $this->mdArea->get(array('city_id' => $re_biz['city_id'])); + $re_area && $address = "{$re_area['city_name']} {$address}"; + } + } else if ($re['biz_id'] == -1 && $re['addr_id']) { + $row_addr = $this->mdAddr->get(array('id' => $re['addr_id'])); + $row_addr && $address = "{$row_addr['city_name']} {$row_addr['county_name']} 其它 {$row_addr['title']}"; + } + $info['address'] = $address; + } + return $info; + } +} \ No newline at end of file diff --git a/admin/controllers/items/goods/Goods.php b/admin/controllers/items/goods/Goods.php index e06b6735..2e49f5fa 100644 --- a/admin/controllers/items/goods/Goods.php +++ b/admin/controllers/items/goods/Goods.php @@ -1258,4 +1258,49 @@ class Goods extends HD_Controller } } + function json_info() + { + $vin = trim($this->input->post('vin')); + $item_id = intval($this->input->post('item_id')); + if ($vin) { + $re = $this->mdItems->get(array('vin' => $vin)); + } else { + $re = $this->mdItems->get(array('id' => $item_id)); + } + if (!$re || empty($re)) { + return $this->show_json(SYS_CODE_FAIL, '车辆不存在!'); + } + $re_b = $this->mdAutoBrand->get(array('id' => $re['brand_id']), 'name'); + $re_s = $this->mdAutoSeries->get(array('id' => $re['s_id']), 'name'); + $re_v = $this->mdAutoAttr->get(array('id' => $re['v_id']), 'title'); + $re_cor = $this->mdAutoAttr->get(array('id' => $re['cor_id']), 'title'); + $title = ''; + $re_b['name'] && $title = $re_b['name']; + $re_s['name'] && $title = $title ? $title . '-' . $re_s['name'] : $re_s['name']; + $re_v['title'] && $title = $title ? $title . '-' . $re_v['title'] : $re_v['title']; + + $info['id'] = $re['id']; + $info['title'] = $title; + $info['vin'] = $re['vin']; + $info['cor'] = $re_cor['title'] ? $re_cor['title'] : ''; + $address = ''; + if ($re['biz_id'] > 0) { + $re_biz = $this->mdBiz->get(array('id' => $re['biz_id'])); + $re_biz && $address = $re_biz['biz_name']; + if ($re_biz['county_id']) { + $re_area = $this->mdArea->get(array('county_id' => $re_biz['county_id'])); + $re_area && $address = "{$re_area['city_name']} {$re_area['county_name']} {$address}"; + } else if ($re_biz['city_id']) { + $re_area = $this->mdArea->get(array('city_id' => $re_biz['city_id'])); + $re_area && $address = "{$re_area['city_name']} {$address}"; + } + } else if ($re['biz_id'] == -1 && $re['addr_id']) { + $row_addr = $this->addr_model->get(array('id' => $re['addr_id'])); + $row_addr && $address = "{$row_addr['city_name']} {$row_addr['county_name']} 其它 {$row_addr['title']}"; + } + $info['address'] = $address; + $this->data = $info; + return $this->show_json(SYS_CODE_SUCCESS); + } + } diff --git a/admin/views/auto/article/get.php b/admin/views/auto/article/get.php new file mode 100644 index 00000000..fd5d9f64 --- /dev/null +++ b/admin/views/auto/article/get.php @@ -0,0 +1,76 @@ +
+
+ +
+
+
+ +
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/admin/views/auto/article/lists.php b/admin/views/auto/article/lists.php new file mode 100644 index 00000000..f184d4eb --- /dev/null +++ b/admin/views/auto/article/lists.php @@ -0,0 +1,90 @@ + +
+
+ +
+
+
共有条数据
+ + + + + + + + + + + + + + + + + +
ID名称状态操作
{{v.id}}{{v.title}}{{v.status_name}} + 编辑 + 关闭 + 开启 + 删除 +
+
+
+
+
+
+ +
+
+
+ + diff --git a/admin/views/auto/fine/lists.php b/admin/views/auto/fine/lists.php index eea60f43..e0b1c1c9 100644 --- a/admin/views/auto/fine/lists.php +++ b/admin/views/auto/fine/lists.php @@ -31,7 +31,7 @@ ID - 名称 + 名称 状态 操作 diff --git a/admin/views/biz/store/edit.php b/admin/views/biz/store/edit.php index 6ca901b4..59116743 100755 --- a/admin/views/biz/store/edit.php +++ b/admin/views/biz/store/edit.php @@ -161,7 +161,7 @@
-
@@ -296,7 +306,7 @@
@@ -443,22 +453,23 @@ typeAry:, companyAry:, info:, - auto_brands:[] + auto_brands: [] }, - mounted:function(){ + mounted: function () { var vm = this; console.log(vm.info); vm.init_auto_brands(); }, methods: { - init_auto_brands:function(){ + init_auto_brands: function () { var vm = this; $.ajax({ url: '/auto/brand/json_lists', type: 'post', dataType: 'json', - data: {status:1}, - beforeSend: function () {}, + data: {status: 1}, + beforeSend: function () { + }, success: function (data) { if (1 == data.code) { vm.auto_brands = data.data.list; @@ -473,12 +484,13 @@ }, created: function () { }, - watch:{ - 'info.auto_brands':function(nv, ov){ + watch: { + 'info.auto_brands': function (nv, ov) { console.log(nv); } } }); + /** * 根据地址定位 * @param addr diff --git a/admin/views/items/transfer/get.php b/admin/views/items/transfer/get.php new file mode 100644 index 00000000..78f546d6 --- /dev/null +++ b/admin/views/items/transfer/get.php @@ -0,0 +1,73 @@ +
+
+
+ + + + + + + + + + + + + + + + + +
车辆车架号颜色存放信息
{{info.items_info.title}}{{info.items_info.vin}}{{info.items_info.cor}}{{info.items_info.address}}
+
+
+
+
调拨信息
+
+ $value) { ?> +
+ +
+ + +
+ +
+ $val) { ?> +
+ + + +
+ +
+ +
+ +
+ +
+ + +
+
+
+ \ No newline at end of file diff --git a/admin/views/items/transfer/get_add.php b/admin/views/items/transfer/get_add.php new file mode 100644 index 00000000..12dcfb49 --- /dev/null +++ b/admin/views/items/transfer/get_add.php @@ -0,0 +1,468 @@ +
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + +
车辆车架号颜色存放信息操作
{{showInfo.items_info.title}}{{showInfo.items_info.vin}}{{showInfo.items_info.cor}}{{showInfo.items_info.address}}已选择选择
+
+
+
+
调拨信息
+
+
+ +
+
+ +
+
+
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ +
+ +
+ +
+ +
+
+ +
+
+
+ +
+ +
+
+ +
+
+ +
+
+
+ 常用运输人员: + +
+
+ 保存 +
+
+
+
+ \ No newline at end of file diff --git a/admin/views/items/transfer/lists.php b/admin/views/items/transfer/lists.php new file mode 100644 index 00000000..74bd4ed6 --- /dev/null +++ b/admin/views/items/transfer/lists.php @@ -0,0 +1,529 @@ +
+
+ +
+
+
共有条数据
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
车辆车架号运输人员调拨时间提车人/提车时间接车人/接车时间是否异常状态操作
{{v.title}}{{v.vin}}{{v.transport_name}}{{v.c_time}}{{v.out_uid_title}}{{v.in_uid_title}}{{v.abnormal}}{{v.status_name}} + 查看详情 +
+
+
+
+
+
+ +
+
+
+ + diff --git a/api/controllers/plan/Temp.php b/api/controllers/plan/Temp.php index 894915a4..a968bf07 100644 --- a/api/controllers/plan/Temp.php +++ b/api/controllers/plan/Temp.php @@ -16,6 +16,53 @@ class Temp extends HD_Controller $this->log_file = 'temp.log'; } + /** + * Notes:新增街道 + * Created on: 2021/12/14 11:58 + * Created by: dengbw + * https://liche-api-dev.xiaoyu.com/plan/temp/add_street + * https://api.liche.cn/plan/temp/add_street + */ + public function add_street() + { + $this->load->model('sys/Sys_area_model', 'mdSysArea'); + $this->load->model('sys/Sys_street_model', 'mdSysStreet'); + $this->load->model('sys/Bs_street_model', 'mdBsStreet');//表已经删除 + $param = $this->input->get(); + $param['page'] = intval($param['page']); + $param['size'] = intval($param['size']); + !$param['size'] && $param['size'] = 5; + !$param['page'] && $param['page'] = 1; + $counts = intval($param['counts']); + ob_start(); //打开缓冲区 + $res = $this->mdSysArea->select(['status' => 1], 'id ASC', $param['page'], $param['size'], 'county_id'); + if (!$res) { + echo '
本次新增街道完成了:'; + echo '

成功新增街道 ' . $counts . ' 条'; + echo '

点击将再次新增街道>>>'; + exit; + } + $log = array(); + foreach ($res as $key => $value) { + $res_bs = $this->mdBsStreet->select(['AREA_CODE' => $value['county_id']], 'STREET_ID ASC', 0, 0, 'STREET_CODE,STREET_NAME'); + $add = []; + foreach ($res_bs as $key2 => $value2) { + $add[] = ['county_id' => $value['county_id'], 'street_id' => $value2['STREET_CODE'], 'street_name' => $value2['STREET_NAME']]; + $log[] = array('street_name' => $value2['STREET_NAME'], 'street_id' => $value2['STREET_CODE']); + $counts++; + } + if ($add) { + $this->mdSysStreet->add_batch($add); + } + } + echo '
成功更新:'; + $log && print_r($log); + echo '

数据库获取:'; + echo json_encode($res, JSON_UNESCAPED_UNICODE); + header('refresh:3;url=/plan/temp/add_street?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1)); + ob_end_flush();//输出全部内容到浏览器 + } + /** * Notes:更新狸车宝渠道门店 * Created on: 2021/9/18 11:58 @@ -157,8 +204,10 @@ class Temp extends HD_Controller header('refresh:3;url=/plan/temp/receiver_customer?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1)); ob_end_flush();//输出全部内容到浏览器 } + //更新下定时间 - public function order_time(){ + public function order_time() + { $this->load->model('receiver/order/receiver_orders_model'); $this->load->model('app/liche/app_liche_orders_model'); @@ -173,19 +222,19 @@ class Temp extends HD_Controller 'order_time' => '0000-00-00 00:00:00', ]; $rows = $this->receiver_orders_model->select($where, 'id ASC', $param['page'], $param['size'], 'id'); - if($rows){ - foreach($rows as $key=>$val){ - $pay_row = $this->app_liche_orders_model->get(['o_id'=>$val['id'],'status'=>1,'type'=>1]); - if(!$pay_row){ - $pay_row = $this->app_liche_orders_model->get(['o_id'=>$val['id'],'status'=>1,'type'=>4]); + if ($rows) { + foreach ($rows as $key => $val) { + $pay_row = $this->app_liche_orders_model->get(['o_id' => $val['id'], 'status' => 1, 'type' => 1]); + if (!$pay_row) { + $pay_row = $this->app_liche_orders_model->get(['o_id' => $val['id'], 'status' => 1, 'type' => 4]); + } + if ($pay_row) { + $this->receiver_orders_model->update(['order_time' => $pay_row['pay_time']], ['id' => $val['id']]); } - if($pay_row){ - $this->receiver_orders_model->update(['order_time'=>$pay_row['pay_time']],['id'=>$val['id']]); - } } - $ids = implode(',',array_column($rows,'id')); + $ids = implode(',', array_column($rows, 'id')); echo "do:{$ids} "; - }else{ + } else { echo 'finish'; } } diff --git a/api/controllers/wxapp/licheb/Biz.php b/api/controllers/wxapp/licheb/Biz.php new file mode 100644 index 00000000..6bb0a8d7 --- /dev/null +++ b/api/controllers/wxapp/licheb/Biz.php @@ -0,0 +1,139 @@ +login_white = array();//登录白名单 + $this->check_status = array();//用户状态校验 + $this->check_mobile = array();//需要手机号 + $this->check_headimg = array();//授权微信信息 + $this->load->model("biz/biz_model", 'mdBiz'); + $this->load->model("biz/biz_base_model", 'mdBizBase'); + $this->load->model("biz/biz_sell_model", 'mdBizSell'); + } + + protected function get_situation_tabs() + { + return [['id' => 0, 'name' => '基础信息'], ['id' => 1, 'name' => '售卖情况']]; + } + + protected function get_situation() + { + $tabs_id = intval($this->input_param('tabs_id')); + $biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']); + $re_biz = $this->mdBiz->get(['id' => $biz_id, 'status' => 1]); + if (!$re_biz) { + throw new Hd_exception('店铺不存在!', API_CODE_FAIL); + } + $info = []; + if ($tabs_id == 1) {//售卖情况 + $re_sell = $this->mdBizSell->get(['biz_id' => $biz_id]); + $fields = $this->mdBizSell->get_fields(); + if ($re_sell) { + foreach ($fields as $key => $value) { + $re_sell[$key] && $fields[$key]['value'] = $re_sell[$key]; + } + } + } else {//基础信息 + $this->load->model('area_model'); + $this->load->model('sys/sys_street_model', 'mdStreet'); + $re_base = $this->mdBizBase->get(['biz_id' => $biz_id]); + $fields = $this->mdBizBase->get_fields(); + foreach ($fields as $key => $value) { + if ($key == 'county' && $re_biz['city_id']) {//县区 + $result = $this->area_model->county($re_biz['city_id'], 1); + $fields[$key]['list'] = array_merge($value['list'], $result); + $re_biz['county_id'] && $fields[$key]['value'] = $re_biz['county_id']; + } else if ($key == 'street' && $re_biz['county_id']) {//乡镇 + $result = []; + $list = $this->mdStreet->select(['county_id' => $re_biz['county_id']], 'id ASC', 0, 0, 'street_id,street_name'); + foreach ($list as $v) { + $result[$v['street_id']] = array('id' => $v['street_id'], 'name' => $v['street_name']); + } + $fields[$key]['list'] = array_merge($value['list'], $result); + $re_biz['street_id'] && $fields[$key]['value'] = $re_biz['street_id']; + } else if ($key == 'type' && $re_biz['type']) {//类型 + $fields[$key]['value'] = $re_biz['type']; + } else if ($key == 'level') {//级别 + $fields[$key]['value'] = $this->level($biz_id); + } else if ($re_base && $re_base[$key]) {//有字段赋值 + $fields[$key]['value'] = $re_base[$key]; + } + $setValue = $fields[$key]; + $setValue['field'] = $key; + $info[] = $setValue; + } + } + return $info; + } + + + /** + * Notes:报备异常 + * Created on: 2021/12/10 16:07 + * Created by: dengbw + * @throws Exception + */ + protected function post() + { + } + + private function level($biz_id = 0) + { + $str = ''; + if ($biz_id) { + $this->load->model('receiver/order/receiver_orders_model', 'mdOrders'); + $where = ['biz_id' => $biz_id, 'status<>' => -1, 'brand_id<>' => 3, 'biz_id<>' => 1]; + $last_month_s = date("Y-m-01", strtotime("-1 month"));//上1个月1日 + $last_month_e = date("Y-m-d", strtotime("$last_month_s +1 month -1 day")); //上1个月最后一天 + $orders = $this->mdOrders->count(array_merge($where, ['c_time >=' => strtotime($last_month_s . ' 00:00:00') + , 'c_time <=' => strtotime($last_month_e . ' 23:59:59')])); + if ($orders >= 12) { + $str = 'A1'; + } else if ($orders >= 9) { + $str = 'A2'; + } else if ($orders >= 6) { + $str = 'A3'; + } else if ($orders >= 5) { + $str = 'B1'; + } else if ($orders >= 4) { + $str = 'B2'; + } else if ($orders >= 3) { + $str = 'B3'; + } else { + $month_s = date("Y-m-01", strtotime("-3 month")); //上3月1日 + $month_e = date("Y-m-d", strtotime("$month_s +1 month -1 day")); //上3个月最后一天 + $orders = $this->mdOrders->count(array_merge($where, ['c_time >=' => strtotime($month_s . ' 00:00:00') + , 'c_time <=' => strtotime($month_e . ' 23:59:59')])); + if ($orders && $orders <= 8) { + $str = 'C1'; + } else { + $month_s = date("Y-m-d", strtotime("$last_month_s -15 day"));//45天前 + $month_e = $last_month_e; //上个月最后一天 + $orders = $this->mdOrders->count(array_merge($where, ['c_time >=' => strtotime($month_s . ' 00:00:00') + , 'c_time <=' => strtotime($month_e . ' 23:59:59')])); + if ($orders == 1) { + $str = 'C2'; + } else if ($orders == 0) { + $this->load->model('items/items_model', 'mdItems'); + $count_items = $this->mdItems->count(['status<>' => 0, 'biz_id' => $biz_id, 'brand_id<>' => 3, 'biz_id<>' => 1]); + !$count_items && $str = 'C3';//门店有样车未开单 + } + } + } + } + return $str; + } +} diff --git a/api/controllers/wxapp/licheb/Transfer.php b/api/controllers/wxapp/licheb/Transfer.php new file mode 100644 index 00000000..9553b118 --- /dev/null +++ b/api/controllers/wxapp/licheb/Transfer.php @@ -0,0 +1,309 @@ +login_white = array();//登录白名单 + $this->check_status = array();//用户状态校验 + $this->check_mobile = array();//需要手机号 + $this->check_headimg = array();//授权微信信息 + $this->load->model('items/items_transfer_model', 'mdTransfer'); + $this->load->model('items/items_transfer_remind_model', 'mdTransferRemind'); + $this->load->model('app/licheb/app_licheb_users_model', 'mdUsers'); + $this->load->model('items/items_model', 'mdItems'); + $this->load->model('auto/auto_brand_model', 'mdAutoBrand'); + $this->load->model('auto/auto_series_model', 'mdAutoSeries'); + $this->load->model('auto/auto_attr_model', 'mdAutoAttr'); + $this->load->model("biz/biz_model", 'mdBiz'); + } + + /** + * Notes:调拨提醒 + * Created on: 2021/12/10 17:03 + * Created by: dengbw + * @return array + */ + protected function get_remind() + { + if ($this->session['group_id'] == 4) { + $total = 0; + } else { + $total = $this->mdTransferRemind->count(['uid' => $this->myuid, 'status' => 1]); + } + $data = ['total' => $total]; + return $data; + } + + protected function get_lists() + { + $page = $this->input_param('page'); + $size = $this->input_param('size'); + $s_date = $this->input_param('s_date'); + $e_date = $this->input_param('e_date'); + !$page && $page = 1; + !$size && $size = 5; + if ($this->session['group_id'] == 4) {//渠道经理 + $biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']); + !$biz_id && $biz_id = -1; + $where = ['status <>' => -1, "biz_id in({$biz_id})" => null]; + $s_date && $where['c_time >='] = strtotime($s_date . ' 00:00:00'); + $e_date && $where['c_time <='] = strtotime($e_date . ' 23:59:59'); + $count = $this->mdTransfer->count($where); + } else { + $where = ['lc_items_transfer_remind.status' => 1, 'lc_items_transfer_remind.uid' => $this->myuid, 'lc_items_transfer.status<>' => -1]; + $s_date && $where['lc_items_transfer_remind.c_time >='] = strtotime($s_date . ' 00:00:00'); + $e_date && $where['lc_items_transfer_remind.c_time <='] = strtotime($e_date . ' 23:59:59'); + $count = $this->db->select('lc_items_transfer_remind.tran_id') + ->join('lc_items_transfer', 'lc_items_transfer.id = lc_items_transfer_remind.tran_id', 'left') + ->where($where) + ->count_all_results('lc_items_transfer_remind'); + } + $url = '/pages/allot/detail/index?id='; + $lists = []; + if ($count) { + $offset = ($page - 1) * $size; + $limit = $size; + if ($this->session['group_id'] == 4) {//渠道经理 + $res = $this->mdTransfer->select($where, 'id desc', $page, $limit, 'id,item_id,out_uid,in_uid,jsondata,c_time,biz_id'); + } else { + $this->db->from('lc_items_transfer_remind'); + $this->db->join('lc_items_transfer', "lc_items_transfer.id = lc_items_transfer_remind.tran_id", 'left'); + $this->db->select('lc_items_transfer_remind.id,lc_items_transfer.item_id,lc_items_transfer.out_uid,lc_items_transfer.in_uid + ,lc_items_transfer.jsondata,lc_items_transfer.c_time,lc_items_transfer.biz_id'); + $this->db->where($where); + $this->db->order_by('lc_items_transfer_remind.id Desc'); + $this->db->limit($limit, $offset); + $res = $this->db->get()->result_array(); + } + $out_uids = array_unique(array_column($res, 'out_uid')); + $in_uids = array_unique(array_column($res, 'in_uid')); + $uids = $this->mdUsers->get_map_by_ids(array_merge($out_uids, $in_uids), 'id,uname');//用户 + $bizs = $this->mdBiz->get_map_by_ids(array_unique(array_column($res, 'biz_id')), 'id,biz_name');//门店 + foreach ($res as $key => $val) { + $jsondata = $val['jsondata'] ? json_decode($val['jsondata'], true) : []; + $item_info = $this->item_info($val['item_id']); + $setValue = $other_data = []; + $setValue['biz_name'] = $val['biz_id'] ? $bizs[$val['biz_id']][0]['biz_name'] : ''; + $setValue['c_time'] = '调拨时间:' . date('Y-m-d H:i', $val['c_time']); + $other_data[] = ['title' => '品牌车型', 'value' => $item_info['title_1']]; + $other_data[] = ['title' => '颜色型号', 'value' => $item_info['title_2']]; + $other_data[] = ['title' => '车架号', 'value' => $item_info['vin']]; + $other_data[] = ['title' => '调拨时间', 'value' => date('Y-m-d', $val['c_time'])]; + $other_data[] = ['title' => '提车人', 'value' => $val['out_uid'] ? $uids[$val['out_uid']][0]['uname'] : '-']; + $other_data[] = ['title' => '接车人', 'value' => $val['in_uid'] ? $uids[$val['in_uid']][0]['uname'] : '-']; + $other_data[] = ['title' => '运输员', 'value' => $jsondata['transport']['name']]; + $setValue['other_data'] = $other_data; + $setValue['url'] = $url ? '/pages/allot/detail/index?id=' . $val['id'] : ''; + $lists[] = $setValue; + } + } + $data = [ + 'list' => $lists, + 'total' => $count + ]; + return $data; + } + + protected function get() + { + $id = intval($this->input_param('id')); + if (!$id) { + throw new Exception('参数错误', ERR_PARAMS_ERROR); + } + if ($this->session['group_id'] == 4) {//渠道不显示按钮 + $btn = []; + $tran_id = $id; + } else { + $re_m = $this->mdTransferRemind->get(['id' => $id]); + if (!$re_m) { + throw new Exception('数据不存在', ERR_PARAMS_ERROR); + } + $tran_id = $re_m['tran_id']; + $btn[] = ['title' => '报备异常', 'id' => $re_m['tran_id'], 'type' => 1]; + if ($re_m['type'] == 1 || $re_m['type'] == 2) { + $btn[] = ['title' => '确认发车', 'id' => $id, 'type' => 2]; + } else { + $btn[] = ['title' => '确认接车', 'id' => $id, 'type' => 2]; + } + } + $re = $this->mdTransfer->get(['id' => $tran_id]); + if (!$re) { + throw new Exception('车辆调拨不存在', ERR_PARAMS_ERROR); + } + $jsondata = $re['jsondata'] ? json_decode($re['jsondata'], true) : []; + $data['transport'] = ['title' => '运输负责人', 'name' => $jsondata['transport']['name'] + , 'mobile' => $jsondata['transport']['mobile']]; + $this->db->from('lc_items_transfer_remind'); + $this->db->join('lc_app_licheb_users', "lc_app_licheb_users.id = lc_items_transfer_remind.uid", 'left'); + $this->db->select('lc_items_transfer_remind.type,lc_app_licheb_users.uname'); + $this->db->where(['lc_items_transfer_remind.tran_id' => $re_m['tran_id']]); + $this->db->order_by('lc_items_transfer_remind.type asc'); + $this->db->limit(50); + $res_r = $this->db->get()->result_array(); + $item_info = $this->item_info($re['item_id']); + $other_data[] = ['title' => '品牌车型', 'value' => $item_info['title_1']]; + $other_data[] = ['title' => '颜色型号', 'value' => $item_info['title_2']]; + $other_data[] = ['title' => '车架号', 'value' => $item_info['vin']]; + foreach ($res_r as $key => $value) { + if ($value['type'] == 1) { + $other_data[] = ['title' => '提车人', 'value' => $value['uname']]; + } else if ($value['type'] == 2) { + $other_data[] = ['title' => '备用提车人', 'value' => $value['uname']]; + } else if ($value['type'] == 3) { + $other_data[] = ['title' => '接车人', 'value' => $value['uname']]; + } else if ($value['type'] == 4) { + $other_data[] = ['title' => '备用接车人', 'value' => $value['uname']]; + } + } + if ($re['arti_id']) { + $this->load->model('auto/auto_article_model', 'mdArticle'); + $res_a = $this->mdArticle->select(["id in ({$re['arti_id']})" => null], 'id desc', 0, 0, 'title'); + if ($res_a) { + $articles = array_unique(array_column($res_a, 'title')); + $other_data[] = ['title' => '随车物品', 'list' => $articles]; + } + } + //异常显示 + $abnormal = ''; + if ($re['abnormal'] && $jsondata['abnormal']) { + $abnormal = $jsondata['abnormal']; + foreach ($abnormal['imgs'] as $key => $value) { + $abnormal['imgs'][$key] = $value ? build_qiniu_image_url($value) : ''; + } + } + $data['abnormal'] = $abnormal; + $data['other_data'] = $other_data; + $data['btn'] = $btn; + return $data; + } + + /** + * Notes:确认发车/接车 + * Created on: 2021/12/10 15:41 + * Created by: dengbw + * @throws Exception + */ + protected function put() + { + $id = intval($this->input_param('id')); + if (!$id) { + throw new Exception('参数错误', ERR_PARAMS_ERROR); + } + $re_m = $this->mdTransferRemind->get(['id' => $id]); + if (!$re_m) { + throw new Exception('数据不存在', ERR_PARAMS_ERROR); + } + if ($re_m['uid'] != $this->myuid) { + throw new Exception('无操作权限', ERR_PARAMS_ERROR); + } + $tran_id = $re_m['tran_id']; + if ($re_m['type'] == 1 || $re_m['type'] == 2) {//确认提车 + $ret = $this->mdTransferRemind->update(['status' => 0], ['tran_id' => $tran_id, 'type in(1,2)' => null]);//隐藏 + if ($ret) { + $this->mdTransferRemind->update(['status' => 1], ['tran_id' => $tran_id, 'type in(3,4)' => null]);//显示 + $this->mdTransfer->update(['status' => 1, 'out_uid' => $this->myuid, 'out_time' => date("Y-m-d H:i:s")] + , ['id' => $tran_id]);//更新车辆调拨 + //调拨接车人短信提醒 + $res_tm = $this->mdTransferRemind->select(['status' => 1, 'tran_id' => $tran_id, 'type in(3,4)' => null], 'type asc', 0, 0, 'uid'); + if ($res_tm) { + $uids_str = implode(',', array_unique(array_column($res_tm, 'uid'))); + $res_u = $this->mdUsers->select(["id in({$uids_str})" => null], 'id desc', 0, 0, 'mobile'); + $re_t = $this->mdTransfer->get(['id' => $re_m['tran_id']]); + $item_info = $this->item_info($re_t['item_id']); + foreach ($res_u as $key => $value) { + $car = $item_info['title_1']; + $item_info['title_2'] && $car .= '-' . $item_info['title_2']; + send_alisms(array('mobile' => $value['mobile'], 'template' => 'SMS_229648438' + , 'param' => ['car' => $car, 'vin' => $item_info['vin']])); + } + } + } + } else {//确认接车 + $biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']); + $ret = $this->mdTransferRemind->update(['status' => 0], ['tran_id' => $tran_id, 'type in(3,4)' => null]);//隐藏 + if ($ret) { + $this->mdTransfer->update(['status' => 2, 'biz_id' => $biz_id, 'in_uid' => $this->myuid, 'in_time' => date("Y-m-d H:i:s")] + , ['id' => $tran_id]);//更新车辆调拨 + } + } + if ($ret) { + throw new Exception('确认成功', API_CODE_SUCCESS); + } else { + throw new Exception('确认失败', ERR_PARAMS_ERROR); + } + } + + /** + * Notes:报备异常 + * Created on: 2021/12/10 16:07 + * Created by: dengbw + * @throws Exception + */ + protected function post() + { + $id = intval($this->input_param('id')); + if (!$id) { + throw new Exception('参数错误', ERR_PARAMS_ERROR); + } + $imgs = $this->input_param('imgs'); + $note = $this->input_param('note'); + if (!$imgs && !$note) { + throw new Exception('请拍照或填写备注信息', ERR_PARAMS_ERROR); + } + $re = $this->mdTransfer->get(['id' => $id]); + if (!$re) { + throw new Exception('车辆调拨不存在', ERR_PARAMS_ERROR); + } + $jsondata = $re['jsondata'] ? json_decode($re['jsondata'], true) : []; + !$note && $note = ''; + !$imgs && $imgs = ''; + $jsondata['abnormal'] = ['imgs' => $imgs, 'note' => $note]; + $ret = $this->mdTransfer->update(['abnormal' => 1, 'jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE)], ['id' => $id]); + if ($ret) { + throw new Exception('报备成功', API_CODE_SUCCESS); + } else { + throw new Exception('报备失败', ERR_PARAMS_ERROR); + } + } + + /** + * Notes:获取商品信息 + * Created on: 2021/12/9 10:47 + * Created by: dengbw + * @param $item_id + * @param int $type + * @return array + */ + private function item_info($item_id) + { + $re = $this->mdItems->get(array('id' => $item_id)); + if (!$re || empty($re)) { + return []; + } + $re_b = $this->mdAutoBrand->get(array('id' => $re['brand_id']), 'name'); + $re_s = $this->mdAutoSeries->get(array('id' => $re['s_id']), 'name'); + $re_v = $this->mdAutoAttr->get(array('id' => $re['v_id']), 'title'); + $re_cor = $this->mdAutoAttr->get(array('id' => $re['cor_id']), 'title'); + $title_1 = $title_2 = ''; + $re_b['name'] && $title_1 = $re_b['name']; + $re_s['name'] && $title_1 = $title_1 ? $title_1 . '-' . $re_s['name'] : $re_s['name']; + $re_v['title'] && $title_2 = $re_v['title']; + $re_cor['title'] && $title_2 = $title_2 ? $title_2 . '-' . $re_cor['title'] : $re_cor['title']; + $info['title_1'] = $title_1; + $info['title_2'] = $title_2; + $info['vin'] = $re['vin']; + return $info; + } +} diff --git a/common/models/auto/Auto_article_model.php b/common/models/auto/Auto_article_model.php new file mode 100644 index 00000000..d3aa0cfc --- /dev/null +++ b/common/models/auto/Auto_article_model.php @@ -0,0 +1,18 @@ +table_name, 'default'); + } +} \ No newline at end of file diff --git a/common/models/biz/Biz_base_model.php b/common/models/biz/Biz_base_model.php new file mode 100644 index 00000000..d43d53ec --- /dev/null +++ b/common/models/biz/Biz_base_model.php @@ -0,0 +1,34 @@ +table_name, 'default'); + } + + public function get_fields() + { + $field['company'] = ['title' => '公司名称', 'type' => 'input', 'input_type' => 'text', 'value' => '']; + $field['county'] = ['title' => '县区', 'type' => 'select', 'list' => [0 => '选择县区'], 'value' => '']; + $field['street'] = ['title' => '乡镇', 'type' => 'select', 'list' => [0 => '选择乡镇'], 'value' => '']; + $field['type'] = ['title' => '类型', 'type' => 'select', 'list' => [0 => '选择类型', 1 => '品牌店', 2 => '形象店', 3 => '代理店'], 'value' => '']; + $field['level'] = ['title' => '级别', 'type' => 'text', 'value' => '']; + $field['lead'] = ['title' => '负责人', 'type' => 'select', 'list' => [0 => '选择负责人'], 'value' => '']; + $field['douyin'] = ['title' => '抖音号', 'type' => 'input', 'input_type' => 'text', 'value' => '']; + $field['address'] = ['title' => '位置', 'type' => 'input', 'input_type' => 'text', 'value' => '']; + $field['area'] = ['title' => '面积', 'type' => 'input', 'input_type' => 'int', 'value' => '']; + $field['rent'] = ['title' => '租金/月', 'type' => 'input', 'input_type' => 'int', 'value' => '']; + $field['imgs'] = ['title' => '门店照片', 'type' => 'img', 'value' => '']; + return $field; + } + +} diff --git a/common/models/biz/Biz_model.php b/common/models/biz/Biz_model.php index 4864d66c..6383fff0 100755 --- a/common/models/biz/Biz_model.php +++ b/common/models/biz/Biz_model.php @@ -59,7 +59,7 @@ class Biz_model extends HD_Model * @return mixed */ function type_ary($key = null){ - $map = array('1' => '合伙店', '2' => '加盟店', '3' => '代理店'); + $map = array('1' => '品牌店', '2' => '形象店', '3' => '代理店'); if(!is_null($key)){ return $map[$key]; diff --git a/common/models/biz/Biz_sell_model.php b/common/models/biz/Biz_sell_model.php new file mode 100644 index 00000000..4fc25623 --- /dev/null +++ b/common/models/biz/Biz_sell_model.php @@ -0,0 +1,36 @@ +table_name, 'default'); + } + + public function get_fields() + { + $field['boss_sell'] = ['title' => '老板卖车', 'type' => 'radio', 'list' => [0 => '否', 1 => '是'], 'value' => 0]; + $field['team_num'] = ['title' => '团队人数', 'type' => 'input', 'input_type' => 'int', 'value' => '']; + $field['sales'] = ['title' => '销量(台/上月)', 'type' => 'text', 'value' => '']; + $field['sale_cars'] = ['title' => '在售车型(当前)', 'type' => 'panel']; + $field['fuel_prop'] = ['title' => '燃油占比', 'type' => 'input', 'input_type' => 'int', 'tag' => '%', 'value' => '']; + $field['energy_prop'] = ['title' => '新能源占比', 'type' => 'input', 'input_type' => 'int', 'tag' => '%', 'value' => '']; + $field['competitor_car'] = ['title' => '竞品车型', 'type' => 'input', 'input_type' => 'text', 'value' => '']; + $field['cooperation_car'] = ['title' => '合作车型', 'type' => 'text', 'value' => '']; + $field['clues_channel'] = ['title' => '当前线索渠道', 'type' => 'panel']; + $field['introduce_prop'] = ['title' => '转介绍', 'type' => 'input', 'input_type' => 'int', 'tag' => '%', 'value' => '']; + $field['outside_prop'] = ['title' => '外拓外展', 'type' => 'input', 'input_type' => 'int', 'tag' => '%', 'value' => '']; + $field['network_prop'] = ['title' => '网络推广', 'type' => 'input', 'input_type' => 'int', 'tag' => '%', 'value' => '']; + $field['we_media_prop'] = ['title' => '自媒体', 'type' => 'input', 'input_type' => 'int', 'tag' => '%', 'value' => '']; + return $field; + } + +} diff --git a/common/models/items/Items_transfer_model.php b/common/models/items/Items_transfer_model.php new file mode 100644 index 00000000..e806bac1 --- /dev/null +++ b/common/models/items/Items_transfer_model.php @@ -0,0 +1,61 @@ +table_name, 'default'); + } + + /** + * Notes:状态 + * Created on: 2021/12/6 16:47 + * Created by: dengbw + * @return array + */ + public function statusAry() + { + return array(0 => '已调拨', 1 => '确认发车', 2 => '确认接车'); + } + + /** + * Notes:异常 + * Created on: 2021/12/9 17:53 + * Created by: dengbw + * @param string $id + * @return array + */ + public function abnormalAry($id = '') + { + $ary = [0 => '正常', 1 => '异常']; + if (strlen($id)) { + $ary = $ary[$id]; + } + return $ary; + } + + /** + * Notes:拖车费类型 + * Created on: 2021/12/16 16:46 + * Created by: dengbw + * @param string $id + * @return array|mixed + */ + public function feesTypeAry($id = '') + { + $ary = [1 => '直营店', 2 => '渠道']; + if (strlen($id)) { + $ary = $ary[$id]; + } + return $ary; + } + +} \ No newline at end of file diff --git a/common/models/items/Items_transfer_remind_model.php b/common/models/items/Items_transfer_remind_model.php new file mode 100644 index 00000000..ec3aa7d2 --- /dev/null +++ b/common/models/items/Items_transfer_remind_model.php @@ -0,0 +1,28 @@ +table_name, 'default'); + } + + /** + * Notes:类型 + * Created on: 2021/12/6 16:47 + * Created by: dengbw + * @return array + */ + public function typeAry() + { + return array(1 => '提车人', 2 => '备用提车人', 3 => '接车人', 4 => '备用接车人'); + } +} \ No newline at end of file diff --git a/common/models/sys/Sys_street_model.php b/common/models/sys/Sys_street_model.php new file mode 100644 index 00000000..8bcca2e6 --- /dev/null +++ b/common/models/sys/Sys_street_model.php @@ -0,0 +1,18 @@ +table_name, 'default'); + } +}