diff --git a/backstage/application/backstage/controllers/Report.php b/backstage/application/backstage/controllers/Report.php index 6eaab79..95f03ec 100644 --- a/backstage/application/backstage/controllers/Report.php +++ b/backstage/application/backstage/controllers/Report.php @@ -110,7 +110,7 @@ class Report extends CI_Controller { $this->lw_load->normalLoad($data,'report/jd/index'); } - public function checkExcelData() + public function checkExcelData_old() { set_time_limit(0); ini_set('max_execution_time', 1000); @@ -191,6 +191,92 @@ class Report extends CI_Controller { $data = array('success' => true, 'msg' => $truePath); echo json_encode($data); } + public function checkExcelData() + { + set_time_limit(0); + ini_set('max_execution_time', 1000); + ini_set('memory_limit', '1024M'); + + $post = $GLOBALS['original_post']; + $excel_data = $post['excel_data']; + if (empty($excel_data)) { + $data = array('success' => false, 'msg' => '内容不能为空'); + echo json_encode($data); + exit; + } + + $data_arr = explode("\n", $excel_data); + + $new_data = array(); + foreach ($data_arr as $k => $v) { + $column_arr = explode("\t", $v); +// array_push($column_arr,$this->session->companyId); + $res = $this->report_model->checkOrder($column_arr); + $new_data[] = $res; + } + + + $this->load->helper('excel'); + $this->load->library('lw_string'); + $title = array( + '用户账号', + '子订单号', + '原始订单号', + '下单时间', + '完成时间', + '订单类型', + '订单状态', + '商品总金额', + '订单应收金额', + '订单总运费', + '账单编号(金采)', + '结清状态(金采)', + '待还本金(金采)', + '出账状态(金采)', + '出账时间(金采)', + '应还日期(金采)', + '订单逾期天数', + '退款金额', + '订单应开金额', + '订单已开金额', + '订单待开金额', + '发票号码', + '发票金额', + '支付方式', + '支付金额', + '订单金额(金采)', + '还款金额(金采)', + '退款金额(金采)', + '结清时间(金采)', + '是否退货完成', + '实开发票抬头', + '场景活动编号', + '收票人', + '收票人电话', + '收票人地址', + '场景活动名称', + '采购人账号', + '采购人电话', + '采购人名称', + '下单人手机号码', + '下单人信息' + ); + for ($i = 0; $i < sizeof($title); $i++) { + $width[$i] = 30; + } + + $date = date('Y', time()); + $uniStr = $this->lw_string->getUniName(); + $path = "outputExcel/jdOrder/" . $date; + if (!is_dir($path)) { + mkdir($path, 0777, true); + } + $fn = $path . "/" . $uniStr . ".xls"; + getExcel($title, $width, $new_data, $fn); + $truePath = base_url($fn); + $data = array('success' => true, 'msg' => $truePath); + echo json_encode($data); + } // 获取任务列表 public function jdTaskListAjax($page) diff --git a/backstage/application/backstage/models/Report_model.php b/backstage/application/backstage/models/Report_model.php index a250171..2df7e9c 100644 --- a/backstage/application/backstage/models/Report_model.php +++ b/backstage/application/backstage/models/Report_model.php @@ -40,7 +40,7 @@ class Report_model extends CI_Model { lwReturn(true, array('msg' => "创建任务成功",'id'=>$insert_id)); } - public function checkOrder($arr){ + public function checkOrder_old($arr){ $orderId = $arr[0]; $price = $arr[5]; $len = count($arr); @@ -84,6 +84,61 @@ class Report_model extends CI_Model { // $childOrderId = $arr[1]; // $item = $this->db->query("select a.* from tb_goods_wg_order_childs a ,tb_area b where a.childOrderId = '{$childOrderId}' and b.company_id='{$company_id}'")->row_array(); // if(empty($item)) $arr[$len+1] = "子单号匹配失败"; +// } + else{ + if($item['orderPrice'] == $price){ + $arr[$len+1] = "子单号金额匹配"; + }else{ + $arr[$len+1] = "子单号金额不匹配"; + } + } + } + return $arr; + } + public function checkOrder($arr){ + $orderId = $arr[1]; + $price = $arr[12]; + $len = count($arr); + $company_id = $this->session->companyId; + + // 获取区域 + $area_info = $this->db->query("select + c.areaname + from + tb_goods_order a, + tb_goods_wg_order b, + tb_area c + where + a.jdwg_id=b.id and + a.user_area_id=c.id and + b.orderId='{$arr[2]}' and + c.company_id='{$company_id}' + ")->row_array(); + $arr[$len] = $area_info['areaname']; + + $trs = $this->db->query("select * from tb_goods_wg_order a, tb_area b where a.orderId = '{$orderId}' and b.company_id='{$company_id}'")->row_array(); + + if($trs){ + // 主单号 + $jdwg_id = $trs['id']; + $item = $this->db->query("select * from tb_goods_order a,tb_area b where b.company_id = '{$company_id}' and a.jdwg_id = ".$jdwg_id)->row_array(); + if(empty($item)){ + $arr[$len+1] = "主单号匹配失败"; + }else{ + if($trs['totalMoney'] == $price){ + $arr[$len+1] = "主单号金额匹配"; + }else{ + $arr[$len+1] = "主单号金额不匹配"; + } + } + }else{ + // 子单号 + $item = $this->db->query("select a.* from tb_goods_wg_order_childs a ,tb_area b where a.childOrderId = '{$orderId}' and b.company_id='{$company_id}'")->row_array(); + if(empty($item)) $arr[$len+1] = "子单号匹配失败"; +// if(empty($item)){ +// $childOrderId = $arr[1]; +// $item = $this->db->query("select a.* from tb_goods_wg_order_childs a ,tb_area b where a.childOrderId = '{$childOrderId}' and b.company_id='{$company_id}'")->row_array(); +// if(empty($item)) $arr[$len+1] = "子单号匹配失败"; // } else{ if($item['orderPrice'] == $price){