663 lines
30 KiB
PHP
663 lines
30 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class Orders extends HD_Controller
|
|
{
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('receiver/order/receiver_orders_model');
|
|
$this->load->model('receiver/order/receiver_order_datas_model');
|
|
// $this->load->model('receiver/order/receiver_order_oplogs_model','order_oplogs_model');
|
|
$this->load->model('receiver/receiver_customers_model', 'customers_model');
|
|
$this->load->model('auto/auto_series_model');
|
|
$this->load->model('auto/auto_brand_model');
|
|
$this->load->model('auto/auto_cars_model');
|
|
$this->load->model("sys/sys_area_model");
|
|
|
|
// $this->load->library('receiver/orders_entity');
|
|
// $this->load->library('receiver/orders_v2_entity');
|
|
// $this->load->library('receiver/orders_status_entity');
|
|
$this->load->library('OrdersList');
|
|
$this->load->library('receiver/order_datas_entity');
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$this->lists();
|
|
}
|
|
|
|
public function lists()
|
|
{
|
|
$params = $this->input->get();
|
|
$statusAry = $this->receiver_orders_model->get_status();
|
|
$status_arr = array();
|
|
foreach ($statusAry as $key => $value) {
|
|
$where = ['status' => $key];
|
|
if ($this->admin_biz_str) {
|
|
$where["biz_id in ($this->admin_biz_str)"] = null;
|
|
}
|
|
$count = $this->receiver_orders_model->count($where);
|
|
$status_arr[] = array("id" => $key, "name" => $value, "cate" => [], "count" => $count);
|
|
}
|
|
$where = ['status>=' => 0];
|
|
if($this->admin_biz_str){
|
|
$where["biz_id in ($this->admin_biz_str)"] = null;
|
|
}
|
|
$params['count_all'] = $this->receiver_orders_model->count($where);//全部
|
|
$params['list_type'] = 'all';
|
|
if($this->admin_biz_str){
|
|
$params['admin_biz_str'] = $this->admin_biz_str;
|
|
}
|
|
$result = $this->orderslist->lists($params['status_pid'], $params);
|
|
$this->data = $result;
|
|
//获取品牌
|
|
$brand_rows = $this->auto_brand_model->select(['status>'=>0], 'initial asc', 0, 0, 'id,name');
|
|
$brands = [];
|
|
if($brand_rows){
|
|
foreach ($brand_rows as $v) {
|
|
$brands[] = array(
|
|
'id' => $v['id'],
|
|
'name' => $v['name'],
|
|
);
|
|
}
|
|
}
|
|
$this->data['brands'] = $brands;
|
|
$this->data['provinces'] = $this->province_ary();
|
|
$this->data['status_arr'] = $status_arr;
|
|
$this->data['cps_types'] = Receiver_orders_model::CPS_TYPES;
|
|
$this->data['_title'] = '订单列表';
|
|
return $this->show_view('receiver/order/lists', true);
|
|
}
|
|
|
|
public function lists_aggs()
|
|
{
|
|
# http://admin.dev.liche.cn/#/receiver/orderv2/orders/lists_aggs?today_start=2021-12-01&today_end=2022-06-06&total_start=2021-12-01&title_today=start 2021-12-01&title_ding_today=当日订单&title_piao_today=当日开票
|
|
# http://admin.dev.liche.cn/#/receiver/orderv2/orders/lists_aggs?today_start=2022-01-01&today_end=2022-07-01&total_start=2022-01-01&total_end=2023-01-01&title_today=start 2022-01~06&title_ding_today=上半年订单&title_ding=全年订单&title_piao_today=上半年开票&title_piao=全年开票
|
|
# http://admin.dev.liche.cn/#/receiver/orderv2/orders/lists_aggs?today_start=2022-12-01&today_end=2023-01-01&total_start=2022-10-01&total_end=2023-01-01&title_today=start 2022-12&title_ding_today=12月订单&title_ding=季度订单&title_piao_today=12月开票&title_piao=季度开票
|
|
$today_start = date('Y-m-d 00:00:00');
|
|
$today_end = date('Y-m-d 00:00:00', strtotime('+1 day'));
|
|
$total_start = date('Y-m-01 00:00:00');
|
|
$total_end = date('Y-m-01 00:00:00', strtotime('+1 month'));
|
|
//$title_today = date('m月d日');
|
|
$title_today = '来源';
|
|
$title_ding_today = '当日订单';
|
|
$title_ding = '月累计订单';
|
|
$title_piao_today = '当日开票';
|
|
$title_piao = '月累计开票';
|
|
|
|
$params = $this->input->get();
|
|
$params['today_start'] && $today_start = $params['today_start'];
|
|
$params['today_end'] && $today_end = $params['today_end'];
|
|
$params['total_start'] && $total_start = $params['total_start'];
|
|
$params['total_end'] && $total_end = $params['total_end'];
|
|
$params['title_today'] && $title_today = $params['title_today'];
|
|
$params['title_ding_today'] && $title_ding_today = $params['title_ding_today'];
|
|
$params['title_ding'] && $title_ding = $params['title_ding'];
|
|
$params['title_piao_today'] && $title_piao_today = $params['title_piao_today'];
|
|
$params['title_piao'] && $title_piao = $params['title_piao'];
|
|
|
|
$data = $this->orders_v2_entity->aggs_biz_ding_piao_rpt($today_start, $today_end, $total_start, $total_end,
|
|
$title_today, $title_ding_today, $title_ding, $title_piao_today, $title_piao, $create_table_image = true);
|
|
$biz_aggs = $data['biz_aggs'];
|
|
$indexs = $data['indexs'];
|
|
$img_path = $data['img_path'] ? $data['img_path'] : '';
|
|
$img_path_ding = $data['img_path_ding'] ? $data['img_path_ding'] : '';
|
|
$img_path_piao = $data['img_path_piao'] ? $data['img_path_piao'] : '';
|
|
|
|
if ($export = $params['export']) {
|
|
if (!$biz_aggs) {
|
|
echo 'no data';
|
|
exit();
|
|
}
|
|
array_unshift($biz_aggs, $indexs);
|
|
$this->load->library('excel');
|
|
#$filename = "lists_aggs_" . date('YmdHis');
|
|
$filename = "lists_aggs";
|
|
if ($export == 'csv') {
|
|
return $this->excel->out_csv($biz_aggs, $indexs, $filename);
|
|
}
|
|
if ($export == 'image' || $export == 'img') {
|
|
if ($img_path) {
|
|
#$http = $_SERVER['HTTPS'] ? 'https://' : 'http://';
|
|
#$img_path = $http.$_SERVER['HTTP_HOST'].'/'.$img_path;
|
|
echo '<img src="/' . $img_path . '"/><br>';
|
|
if ($img_path_ding) echo '<img src="/' . $img_path_ding . '"/><br>';
|
|
if ($img_path_piao) echo '<img src="/' . $img_path_piao . '"/><br>';
|
|
exit();
|
|
}
|
|
return $this->excel->out_csv($biz_aggs, $indexs, $filename);
|
|
}
|
|
|
|
if ($export == 'excel2') {
|
|
#var_dump($indexs);echo('<br>');var_dump($biz_aggs[0]);echo('<br>');var_dump($biz_aggs[1]);exit();
|
|
|
|
#生成品牌对应的系列数,用于表头合并列
|
|
$series_names = $data['series_names'];
|
|
$indexs_keys = array_keys($indexs);
|
|
$brand_series_nums = array();
|
|
foreach ($series_names as $k => $v) {
|
|
$nums = 0;
|
|
if (in_array($k . '_ding', $indexs_keys)) {
|
|
$nums++;
|
|
}
|
|
foreach ($v as $k2 => $v2) {
|
|
if (in_array($k . '_' . $v2 . '_ding', $indexs_keys)) {
|
|
$nums++;
|
|
}
|
|
}
|
|
$nums && $brand_series_nums[$k . '_ding'] = $nums;
|
|
|
|
$nums = 0;
|
|
if (in_array($k . '_piao', $indexs_keys)) {
|
|
$nums++;
|
|
}
|
|
foreach ($v as $k2 => $v2) {
|
|
if (in_array($k . '_' . $v2 . '_piao', $indexs_keys)) {
|
|
$nums++;
|
|
}
|
|
}
|
|
$nums && $brand_series_nums[$k . '_piao'] = $nums;
|
|
}
|
|
#var_dump($brand_series_nums);exit();
|
|
|
|
#require_once COMMPATH . 'third_party/PHPExcel.php';
|
|
set_time_limit(0); // 设置页面等待时间
|
|
ini_set('memory_limit', -1); // 不限制内存
|
|
$objPHPExcel = new PHPExcel();
|
|
#$objPHPExcel->getDefaultStyle()->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
$objPHPExcel->getDefaultStyle()->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); // 单元格整体居右
|
|
$objPHPExcel->setActiveSheetIndex(0); // 选中默认的第一个sheet
|
|
$objPHPExcel->getActiveSheet()->setTitle('小狸播报'); // 给 Sheet 设置名字
|
|
|
|
# 先生成表头
|
|
$i = 0;
|
|
foreach ($indexs as $k => $v) {
|
|
$columnkey = PHPExcel_Cell::stringFromColumnIndex($i);
|
|
if ((strpos($k, '_ding') !== false || strpos($k, '_piao') !== false) && !in_array($k, array('doc_ding_today', 'doc_ding', 'doc_piao_today', 'doc_piao'))) {
|
|
if ($brand_series_nums[$k]) {
|
|
# 第一行需合并多列的列
|
|
$columnkey2 = PHPExcel_Cell::stringFromColumnIndex($i + $brand_series_nums[$k] - 1);
|
|
$pRange = $columnkey . '1:' . $columnkey2 . '1';
|
|
$pCoordinate = $columnkey . '1';
|
|
$objPHPExcel->getActiveSheet()->mergeCells($pRange);
|
|
$objPHPExcel->setActiveSheetIndex(0)->setCellValue($pCoordinate, $v);
|
|
|
|
# PHPExcel常用属性使用 http://t.zoukankan.com/lglblogadd-p-7117486.html
|
|
# 水平居中
|
|
$objStyle = $objPHPExcel->getActiveSheet()->getStyle($pCoordinate); //获取要设置单元格的样式,括号里的内容也可是:('A1:E1')
|
|
$objAlign = $objStyle->getAlignment(); //用来设置对齐属性和单元格内文本换行的一个变量
|
|
$objAlign->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
}
|
|
|
|
# 第二行的列
|
|
$pCoordinate = $columnkey . '2';
|
|
$objPHPExcel->setActiveSheetIndex(0)->setCellValue($pCoordinate, $v);
|
|
} else {
|
|
# 第一二行需合并的列
|
|
$pRange = $columnkey . '1:' . $columnkey . '2';
|
|
$pCoordinate = $columnkey . '1';
|
|
$objPHPExcel->getActiveSheet()->mergeCells($pRange);
|
|
$objPHPExcel->setActiveSheetIndex(0)->setCellValue($pCoordinate, $v);
|
|
|
|
# 垂直居中
|
|
$objStyle = $objPHPExcel->getActiveSheet()->getStyle($pCoordinate);
|
|
$objAlign = $objStyle->getAlignment();
|
|
$objAlign->setVertical(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
}
|
|
$i++;
|
|
}
|
|
|
|
# 再生成数据
|
|
$biz_aggs = array_slice($biz_aggs, 1);
|
|
$j = 3;
|
|
foreach ($biz_aggs as $val) {
|
|
$i = 0;
|
|
// 内循环产生每一行
|
|
foreach ($indexs as $k => $v) {
|
|
// 数字列转换为字母列 如:27变为AA
|
|
$objPHPExcel->getActiveSheet()->setCellValue(PHPExcel_Cell::stringFromColumnIndex($i) . $j, $val[$k]);
|
|
$i++;
|
|
}
|
|
$j++;
|
|
}
|
|
|
|
$filename = iconv('UTF-8', 'UTF-8', $filename) . '.xls';
|
|
header('Pragma: public');
|
|
header('Expires: 0');
|
|
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
|
header('Content-Type: application/force-download');
|
|
header('Content-Type: application/vnd.ms-execl');
|
|
header('Content-Type: application/octet-stream');
|
|
header('Content-Type: application/download');
|
|
header("Content-Disposition: attachment; filename=$filename");
|
|
header('Content-Transfer-Encoding: binary');
|
|
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
|
return $objWriter->save('php://output');
|
|
}
|
|
|
|
if (count($indexs) <= 26) {
|
|
return $this->excel->out($biz_aggs, $indexs, $filename);
|
|
}
|
|
|
|
$sheet['小狸播报'] = array();
|
|
foreach ($biz_aggs as $k => $v) {
|
|
$list[1] = array();
|
|
foreach ($indexs as $k2 => $v2) {
|
|
$list[1][] = $v[$k2];
|
|
}
|
|
$sheet['小狸播报'][] = $list[1];
|
|
}
|
|
return $this->excel->exportExcel($sheet, $filename);
|
|
}
|
|
|
|
#var_dump($indexs);var_dump($biz_aggs[0]);
|
|
$this->data['_title'] = '小狸播报';
|
|
$this->data['fieldAry'] = $indexs;
|
|
$this->data['lists'] = $biz_aggs;
|
|
$this->data['img_path'] = $img_path;
|
|
$this->data['img_path_ding'] = $img_path_ding;
|
|
$this->data['img_path_piao'] = $img_path_piao;
|
|
return $this->show_view('receiver/orderv2/lists_aggs', true);
|
|
}
|
|
|
|
public function get()
|
|
{
|
|
$id = $this->input->get('id');
|
|
|
|
$row = $this->receiver_orders_model->get(['id' => $id]);
|
|
$customers = $this->customers_model->get(['id' => $row['customer_id']]);
|
|
if (!$row) {
|
|
return $this->show_json(SYS_CODE_FAIL, '订单不存在!');
|
|
}
|
|
if ($customers['of_id']) {//客户来源
|
|
$of_ary = $this->customers_model->offlineSources($customers['of_id']);
|
|
$of_title = $of_ary['name'];
|
|
$customers['of2_id'] && $of_title .= '-' . $of_ary['list'][$customers['of2_id']];
|
|
$row['of_title'] = $of_title;
|
|
}
|
|
$row['p_time'] = date('Y-m-d', strtotime($customers['p_time']));
|
|
$row['money_json'] = json_decode($row['money_json'], true);
|
|
$jsondata = $row['jsondata'] ? json_decode($row['jsondata'], true) : array();
|
|
$row['status'] = intval($row['status']);
|
|
$row['c_time'] = date('Y-m-d', $row['c_time']);
|
|
$row['payway'] = intval($row['payway']);
|
|
$row['note'] = $jsondata['note'] ? $jsondata['note'] : '';
|
|
//获取车信息
|
|
$brand = $this->auto_brand_model->get(['id' => $row['brand_id']], 'name');
|
|
$series = $this->auto_series_model->get(['id' => $row['series_id']], 'name');
|
|
$car = $this->auto_cars_model->get(['id' => $row['car_id']], 'name');
|
|
$row['brand_name'] = $brand['name'];
|
|
$row['s_name'] = $series['name'];
|
|
$row['car_name'] = $car['name'];
|
|
$row['delry_time'] = $row['delry_time'] != '0000-00-00 00:00:00'
|
|
? str_replace(" 00:00:00", "", $row['delry_time']) : '';
|
|
$row['downpayment_type_cn'] = $this->receiver_orders_model->downpayment_type($row['downpayment_type']);
|
|
//获取审核资料信息
|
|
$img_data = $this->order_datas_entity->get_row($row['id']);
|
|
$img_data['business_licence'] && $img_data['business_licence'] = build_qiniu_image_url($img_data['business_licence']);
|
|
$img_data['cardida'] && $img_data['cardida'] = build_qiniu_image_url($img_data['cardida']);
|
|
$img_data['cardidb'] && $img_data['cardidb'] = build_qiniu_image_url($img_data['cardidb']);
|
|
$img_data['pay_img'] && $img_data['pay_img'] = build_qiniu_image_url($img_data['pay_img']);
|
|
$contract_img = [];
|
|
if ($img_data['contract_img']) {
|
|
$img_array = explode(',', $img_data['contract_img']);
|
|
foreach ($img_array as $value) {
|
|
$contract_img[] = build_qiniu_image_url($value);
|
|
}
|
|
}
|
|
$equity_ck_img = [];
|
|
if ($img_data['equity_ck_img']) {
|
|
$img_array = explode(',', $img_data['equity_ck_img']);
|
|
foreach ($img_array as $value) {
|
|
$equity_ck_img[] = build_qiniu_image_url($value);
|
|
}
|
|
}
|
|
$img_data['equity_ck_img'] = $equity_ck_img;
|
|
$img_data['contract_img'] = $contract_img;
|
|
$img_data['car_img'] && $img_data['car_img'] = build_qiniu_image_url($img_data['car_img']);
|
|
$img_data['car_auth_img'] && $img_data['car_auth_img'] = build_qiniu_image_url($img_data['car_auth_img']);
|
|
$img_data['delivery_ck_img'] && $img_data['delivery_ck_img'] = build_qiniu_image_url($img_data['delivery_ck_img']);
|
|
$img_data['bill_img'] && $img_data['bill_img'] = build_qiniu_image_url($img_data['bill_img']);
|
|
|
|
if($img_data['insurance_img']){
|
|
$img_data['insurance_img'] = build_qiniu_image_url($img_data['insurance_img']);
|
|
strstr($img_data['insurance_img'],'.pdf') && $img_data['insurance_pdf'] = $img_data['insurance_img'];
|
|
}
|
|
|
|
if($img_data['business_img']){
|
|
$img_data['business_img'] = build_qiniu_image_url($img_data['business_img']);
|
|
strstr($img_data['business_img'],'.pdf') && $img_data['business_pdf'] = $img_data['business_img'];
|
|
}
|
|
|
|
$row['img_data'] = $img_data;
|
|
//获取销售员
|
|
if ($row['sale_id']) {
|
|
$this->load->model('app/licheb/app_licheb_users_model', 'licheb_users_model');
|
|
$this->load->model("biz/biz_model");
|
|
$this->load->model("sys/sys_city_model", 'mdSysCity');
|
|
$row_admin = $this->licheb_users_model->get(array('id' => $row['sale_id']));
|
|
if ($row_admin['group_id'] == 4) {
|
|
$row_city = $this->mdSysCity->get(['city_id' => $row_admin['city_id']]);
|
|
$city_name = $row_city['name'] ? str_replace('市', '', $row_city['name']) . '渠道 ' : '';
|
|
$admin_name = $row_admin ? "{$city_name}{$row_admin['uname']}" : "";
|
|
} else {
|
|
$biz_id = $row_admin['biz_id'];
|
|
$row_biz = array();
|
|
if ($biz_id) {
|
|
$row_biz = $this->biz_model->get(array('id' => $biz_id));
|
|
}
|
|
$admin_name = $row_admin ? "{$row_biz['biz_name']} {$row_admin['uname']}" : "";
|
|
}
|
|
$row['admin_name'] = $admin_name;
|
|
}
|
|
$row['status_name'] = $this->receiver_orders_model->get_status($row['status']);
|
|
//日志
|
|
$logs = [];
|
|
$row['is_admin'] = $this->role == SUPER_ADMIN ? true : false;
|
|
|
|
$info = $row;
|
|
$this->data['info'] = $info;
|
|
$this->data['logs'] = $logs;
|
|
|
|
$this->data['_title'] = '订单详情';
|
|
return $this->show_view('receiver/order/get/index', true);
|
|
}
|
|
|
|
//添加单条数据
|
|
public function add()
|
|
{
|
|
}
|
|
|
|
//编辑单条数据
|
|
public function edit()
|
|
{
|
|
$params = $this->input->post();
|
|
if (!$params['id']) {
|
|
return $this->show_json(SYS_CODE_FAIL, '参数错误!');
|
|
}
|
|
$result = '';
|
|
if ($params['type'] == 1) {//修改备注
|
|
$re = $this->receiver_orders_v2_model->get(['id' => $params['id']]);
|
|
$jsondata = json_decode($re['jsondata'], true);
|
|
$jsondata['note'] = $params['note'];
|
|
$upd = array('jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE));
|
|
$result = $this->receiver_orders_v2_model->update($upd, ['id' => $params['id']]);
|
|
} else if ($params['type'] == 2) {//修改营业执照
|
|
if (!$params['business_licence']) {
|
|
return $this->show_json(SYS_CODE_FAIL, '请上传营业执照');
|
|
}
|
|
if (!$this->order_bills_model->get(['o_id' => $params['id']])) {
|
|
$this->order_bills_model->add(['o_id' => $params['id'], 'c_time' => time()]);
|
|
}
|
|
$result = $this->order_bills_model->update(array('business_licence' => $params['business_licence']), ['o_id' => $params['id']]);
|
|
}
|
|
if ($result) {
|
|
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
|
|
} else {
|
|
return $this->show_json(SYS_CODE_FAIL, '保存失败');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 更新身份证信息
|
|
* @return bool
|
|
*/
|
|
function edit_cardID()
|
|
{
|
|
$o_id = $this->input->post('o_id');
|
|
$cardidA = $this->input->post('cardidA');
|
|
$cardidB = $this->input->post('cardidB');
|
|
if (!$this->receiver_order_datas_model->get(['o_id' => $o_id])) {
|
|
$this->order_bills_model->add(['o_id' => $o_id, 'c_time' => time()]);
|
|
}
|
|
if (!$cardidA || !$cardidB) {
|
|
return $this->show_json(SYS_CODE_FAIL, '请上传身份证照片');
|
|
}
|
|
|
|
$cardidA_src = build_qiniu_image_url($cardidA);
|
|
$result = $this->tcorc->IdentityCard($cardidA_src);
|
|
if (!$result['code']) {
|
|
return $this->show_json(SYS_CODE_FAIL, '身份证校验不通过');
|
|
} else {
|
|
//校验姓名
|
|
$uname = $result['data']['Name'];
|
|
$idnum = $result['data']['IdNum'];
|
|
$row_order = $this->receiver_orders_v2_model->get(['id' => $o_id]);
|
|
$info_json = json_decode($row_order['info_json'], true);
|
|
if ($uname != $row_order['name']) {
|
|
return $this->show_json(SYS_CODE_FAIL, '身份证姓名与客户不一致');
|
|
}
|
|
if ($idnum != $info_json['c_owner_cardid']) {
|
|
return $this->show_json(SYS_CODE_FAIL, '身份证号码与客户不一致');
|
|
}
|
|
}
|
|
|
|
$upd = array(
|
|
'cardidA' => $cardidA,
|
|
'cardidB' => $cardidB,
|
|
'status' => 1
|
|
);
|
|
$result = $this->order_bills_model->update($upd, ['o_id' => $o_id]);
|
|
if ($result) {
|
|
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
|
|
} else {
|
|
return $this->show_json(SYS_CODE_FAIL, '保存失败');
|
|
}
|
|
}
|
|
|
|
//删除单条数据
|
|
public function del()
|
|
{
|
|
|
|
}
|
|
|
|
//批量操作(默认修改状态)
|
|
public function batch()
|
|
{
|
|
|
|
}
|
|
|
|
//导出数据列表
|
|
public function export()
|
|
{
|
|
$params = $this->input->get();
|
|
$params['page'] = 1;
|
|
$params['size'] = 10000;
|
|
$indexs = [];
|
|
$params['status_pid'] == 5 && $params['status'] = 1;
|
|
$fieldAry = $this->orderslist->get_fields($params['status_pid'], 1);
|
|
foreach ($fieldAry as $key => $value) {
|
|
$indexs[$key] = $value['title'];
|
|
}
|
|
$result = $this->orderslist->lists($params['status_pid'], $params);
|
|
$fileName = $result['_title'];
|
|
foreach ($result['lists'] as $key => $value) {
|
|
$temp = array();
|
|
foreach ($fieldAry as $key2 => $value2) {
|
|
$temp[$key2] = $value[$key2];
|
|
}
|
|
$data[] = $temp;
|
|
}
|
|
array_unshift($data, $indexs);
|
|
$this->load->library('excel');
|
|
return $this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis'));
|
|
}
|
|
|
|
//修改图片
|
|
public function edit_imgs()
|
|
{
|
|
$id = $this->input->post('id');
|
|
$field = $this->input->post('filed');
|
|
$save_value = $value = $this->input->post('value');
|
|
$row = $this->receiver_orders_model->get(['id' => $id]);
|
|
if (!$row) {
|
|
return $this->show_json(SYS_CODE_FAIL, '参数错误');
|
|
}
|
|
$re_data = $this->receiver_order_datas_model->get(['o_id' => $id]);
|
|
if (!$re_data) {
|
|
$re_data_id = $this->receiver_order_datas_model->add(['c_time' => time(), 'o_id' => $id]);
|
|
} else {
|
|
$re_data_id = $re_data['id'];
|
|
}
|
|
if ($field == 'contract_img' || $field == 'equity_ck_img') {
|
|
$save_value = $re_data[$field] ? $re_data[$field] . ',' . $value : $value;
|
|
}
|
|
if ($field == 'ins_img') {
|
|
$val_arr = json_decode($re_data[$field], true);
|
|
$val_arr[] = $value;
|
|
$save_value = json_encode($val_arr, JSON_UNESCAPED_UNICODE);
|
|
}
|
|
$update = [
|
|
$field => $save_value
|
|
];
|
|
|
|
$res = $this->receiver_order_datas_model->update($update, ['id' => $re_data_id]);
|
|
if ($res) {
|
|
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
|
|
} else {
|
|
return $this->show_json(SYS_CODE_FAIL, '保存失败');
|
|
}
|
|
}
|
|
|
|
//修改支付订单状态
|
|
public function edit_status()
|
|
{
|
|
if ($this->input->method() == 'post') {
|
|
$id = $this->input->post('id');
|
|
$sid = $this->input->post('sid');
|
|
if (!$id && !$sid) {
|
|
return $this->show_json(SYS_CODE_FAIL, '订单id 与 订单号,必须填写一个');
|
|
}
|
|
$row = array();
|
|
if ($id && $sid) {
|
|
$row = $this->receiver_orders_v2_model->get(['id' => $id, 'sid' => $sid]);
|
|
} else {
|
|
$id && $row = $this->receiver_orders_v2_model->get(['id' => $id]);
|
|
$sid && $row = $this->receiver_orders_v2_model->get(['sid' => $sid]);
|
|
}
|
|
if (!$row) {
|
|
return $this->show_json(SYS_CODE_FAIL, '订单不存在');
|
|
}
|
|
$res = $this->receiver_orders_v2_model->update(['status' => 2, 'refund_time' => date('Y-m-d H:i:s')], ['id' => $row['id']]);
|
|
if ($res) {
|
|
$this->app_liche_orders_model->update(['status' => -1], ['o_id' => $row['id'], 'pid' => 0]);
|
|
return $this->show_json(SYS_CODE_SUCCESS, '修改成功');
|
|
} else {
|
|
return $this->show_json(SYS_CODE_FAIL, '保存失败');
|
|
}
|
|
}
|
|
return $this->show_view('receiver/orderv2/edit_status');
|
|
}
|
|
|
|
|
|
//图片上传七牛
|
|
private function up_qiniu($imgs)
|
|
{
|
|
$this->load->library('qiniu');
|
|
//上传七牛并保存
|
|
foreach ($imgs as $key => $val) {
|
|
$file_name = date('Ym') . "/" . md5($val) . '.jpg';
|
|
$result = $this->qiniu->fetch($val, $file_name);
|
|
if ($result) {
|
|
$imgs[$key] = $result['file'];
|
|
}
|
|
}
|
|
return $imgs;
|
|
}
|
|
|
|
public function del_img()
|
|
{
|
|
$info = $this->input->post();
|
|
if (!$info['type'] || !$info['field']) {
|
|
return $this->show_json(SYS_CODE_FAIL, '参数错误');
|
|
}
|
|
$res = false;
|
|
if ($info['type'] == 'data') {
|
|
$row = $this->receiver_order_datas_model->get(['o_id' => $info['id']]);
|
|
if (!$row) {
|
|
return $this->show_json(SYS_CODE_FAIL, '参数错误');
|
|
}
|
|
if ($info['field'] == 'contract_img' || $info['field'] == 'equity_ck_img') {
|
|
$img_array = explode(',', $row[$info['field']]);
|
|
$new_imgs = [];
|
|
foreach ($img_array as $item) {
|
|
strpos($info['value'], $item) === false && $new_imgs[] = $item;
|
|
}
|
|
$update = [
|
|
$info['field'] => implode(',', $new_imgs)
|
|
];
|
|
} elseif ($info['field'] == 'insurance_img' || $info['field'] == 'business_img' || $info['field'] == 'accident_img' || $info['field'] == 'bill_ck_img') {
|
|
$update = [
|
|
$info['field'] => json_encode([])
|
|
];
|
|
|
|
# 0612各保单支持返点系数, 保留系数
|
|
$insurance_img = json_decode($row['insurance_img'], true);
|
|
$business_img = json_decode($row['business_img'], true);
|
|
$accident_img = json_decode($row['accident_img'], true);
|
|
if ($info['field'] == 'insurance_img' && $insurance_img['rebate']) {
|
|
$update = [
|
|
$info['field'] => json_encode(['rebate' => $insurance_img['rebate']])
|
|
];
|
|
} elseif ($info['field'] == 'business_img' && $business_img['rebate']) {
|
|
$update = [
|
|
$info['field'] => json_encode(['rebate' => $business_img['rebate']])
|
|
];
|
|
} elseif ($info['field'] == 'accident_img' && $accident_img['rebate']) {
|
|
$update = [
|
|
$info['field'] => json_encode(['rebate' => $accident_img['rebate']])
|
|
];
|
|
}
|
|
} else {
|
|
$update = [
|
|
$info['field'] => ''
|
|
];
|
|
}
|
|
$res = $this->receiver_order_datas_model->update($update, ['o_id' => $info['id']]);
|
|
} elseif ($info['type'] == 'load_info') {
|
|
$row = $this->order_loans_model->get(['o_id' => $info['id']]);
|
|
if (!$row) {
|
|
return $this->show_json(SYS_CODE_FAIL, '参数错误');
|
|
}
|
|
if ($info['field'] == 'notify_file') {
|
|
$notify_file_lists = explode(',', $row['notify_file']);
|
|
unset($notify_file_lists[$info['value']]);
|
|
$update = [
|
|
$info['field'] => implode(',', $notify_file_lists)
|
|
];
|
|
} else {
|
|
$update = [
|
|
$info['field'] => ''
|
|
];
|
|
}
|
|
$res = $this->order_loans_model->update($update, ['o_id' => $info['id']]);
|
|
} elseif ($info['type'] == 'load_info0') {
|
|
// 首付按揭
|
|
$row = $this->order_loans0_model->get(['o_id' => $info['id']]);
|
|
if (!$row) {
|
|
return $this->show_json(SYS_CODE_FAIL, '参数错误');
|
|
}
|
|
if ($info['field'] == 'notify_file') {
|
|
$notify_file_lists = explode(',', $row['notify_file']);
|
|
unset($notify_file_lists[$info['value']]);
|
|
$update = [
|
|
$info['field'] => implode(',', $notify_file_lists)
|
|
];
|
|
} else {
|
|
$update = [
|
|
$info['field'] => ''
|
|
];
|
|
}
|
|
$res = $this->order_loans0_model->update($update, ['o_id' => $info['id']]);
|
|
}
|
|
|
|
if ($res) {
|
|
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
|
|
} else {
|
|
return $this->show_json(SYS_CODE_FAIL, '保存失败');
|
|
}
|
|
}
|
|
}
|