|
|
@@ -94,6 +94,8 @@ class Boss extends Start_Controller
|
|
|
$this->_dycs();
|
|
|
}else if($arg =='yxdpdck'){
|
|
|
$this->_yxDPDchuku();
|
|
|
+ }else if($arg == 'spexceljs'){
|
|
|
+ $this->_spexceljs();
|
|
|
} else {
|
|
|
$this->_index();
|
|
|
}
|
|
|
@@ -1314,6 +1316,229 @@ class Boss extends Start_Controller
|
|
|
$this->excel->get_fz2($sp, $titlename, $filename, $tail);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ private function _spexceljs()
|
|
|
+ {
|
|
|
+ $tcjm = $tmp_typeclass = $tc = [];
|
|
|
+ $typeclass = $this->typeclass->find_all();
|
|
|
+ foreach ($typeclass as $v) {
|
|
|
+ $tc[$v['id']] = $v;
|
|
|
+ $tcjm[$v['id']] = array($v['jm'], $v['classid']);
|
|
|
+ $tmp_typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'jm' => $v['jm']);
|
|
|
+ }
|
|
|
+ $typeclass = $tmp_typeclass;
|
|
|
+ if(isset($_SESSION['api'])){
|
|
|
+ $user = $this->user->get_api($_SESSION['api']);
|
|
|
+ if(empty($user)){
|
|
|
+ exit(json_encode(array('code' => 0, 'data' => '登录信息异常')));
|
|
|
+ }
|
|
|
+ if(empty($user['shop'])){
|
|
|
+ exit(json_encode(array('code' => 0, 'data' => '该账号没有所属店铺excel导出权限')));
|
|
|
+ }
|
|
|
+ $excelshop = explode('|', trim($user['shop'], '|'));
|
|
|
+ }else{
|
|
|
+ exit(json_encode(array('code' => 0, 'data' => '请先登录')));
|
|
|
+ }
|
|
|
+ $classid = $this->classid->sku();
|
|
|
+
|
|
|
+ $post = $this->input->post(NULL, TRUE);
|
|
|
+ $timetk = strtotime($post['timetk']);
|
|
|
+ $timetj = strtotime($post['timetj']);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $where = $post['time']." > ".$timetk." and ".$post['time']." < ".$timetj." ";
|
|
|
+
|
|
|
+ if(!empty($post['warehouse'])){
|
|
|
+ $where .= " and type = ".$post['warehouse']." ";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!empty($post['shop'])){
|
|
|
+ $where .= " and shop = ".$post['shop']." ";
|
|
|
+ }else{
|
|
|
+ $where .= " and shop in (".implode(',',$excelshop).") ";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!empty($post['category'])){
|
|
|
+ $where .=" and fpdata like '%-".$post['category']."-%' ";
|
|
|
+ }
|
|
|
+ if(!empty($post['color'])){
|
|
|
+ $where .=" and fpdata like '%-".$post['color']."-%' ";
|
|
|
+ }
|
|
|
+ if(!empty($post['size'])){
|
|
|
+ $where .=" and fpdata like '%-".$post['size']."-%' ";
|
|
|
+ }
|
|
|
+ if(!empty($post['grade'])){
|
|
|
+ $where .=" and fpdata like '%-".$post['grade']."-%' ";
|
|
|
+ }
|
|
|
+ if(!empty($post['lowe'])){
|
|
|
+ $where .=" and fpdata like '%-".$post['lowe']."-%' ";
|
|
|
+ }
|
|
|
+ if(!empty($post['density'])){
|
|
|
+ $where .=" and fpdata like '%-".$post['density']."-%' ";
|
|
|
+ }
|
|
|
+ if(!empty($post['lacetype'])){
|
|
|
+ $where .=" and fpdata like '%-".$post['lacetype']."-%' ";
|
|
|
+ }
|
|
|
+
|
|
|
+ $filed_list = "fpdata,number,whlabel,type";
|
|
|
+
|
|
|
+ $data_dlz = $this->db->from('fullorder')->where($where)->select($filed_list)->order_by('id desc')->get()->result_array();
|
|
|
+ $data_smt = $this->db->from('fullordersmt')->where($where." and shop != '9'")->select($filed_list)->order_by('id desc')->get()->result_array();
|
|
|
+ $data_tt = $this->db->from('fullordertt')->where($where)->select($filed_list)->order_by('id desc')->get()->result_array();
|
|
|
+ $data_amz = $this->db->from('fullorderamz')->where($where)->select($filed_list)->order_by('id desc')->get()->result_array();
|
|
|
+
|
|
|
+ $data = $data_dlz + $data_smt + $data_tt + $data_amz;
|
|
|
+ if(empty($data)){
|
|
|
+ exit(json_encode(array('code' => 0, 'data' => '暂无数据')));
|
|
|
+ }
|
|
|
+ if(count($data) >= 65535){
|
|
|
+ exit(json_encode(array('code' => 0, 'data' => '数据量超过65535条,请缩小查询范围')));
|
|
|
+ }
|
|
|
+
|
|
|
+ $warehouses = $this->warehouse->find_all('1=1', 'id,title');
|
|
|
+ $warehouses = array_column($warehouses, 'title', 'id');
|
|
|
+ $sp = [];
|
|
|
+
|
|
|
+ foreach ($data as $val) {
|
|
|
+ $f = explode(';', trim($val['fpdata'], ';'));
|
|
|
+ $w = explode('|', trim($val['whlabel'], '|'));
|
|
|
+ foreach ($f as $k => $v) {
|
|
|
+ if(!empty($post['category'])){
|
|
|
+ if(stripos($v,'-'.$post['category'].'-') === false){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!empty($post['color'])){
|
|
|
+ if(stripos($v,'-'.$post['color'].'-') === false){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!empty($post['lowe'])){
|
|
|
+ if(stripos($v,'-'.$post['lowe'].'-') === false){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!empty($post['size'])){
|
|
|
+ if(stripos($v,'-'.$post['size'].',') === false){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!empty($post['grade'])){
|
|
|
+ if(stripos($v,'-'.$post['grade'].'-') === false){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!empty($post['lacetype'])){
|
|
|
+ if(stripos($v,'-'.$post['lacetype'].'-') === false){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!empty($post['density'])){
|
|
|
+ if(stripos($v,'-'.$post['density'].'-') === false){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $title = explode('|', $v);
|
|
|
+ $fg = str_replace(array('-163-', '-164-', '-165-', '-166-', '-0-', '-126-', '-127-', '-128-', '-197-', '-195-'), '-', $title[0]);
|
|
|
+ $fg = explode(',', $fg);
|
|
|
+ $tmp_c = $this->getCate($title[0]);
|
|
|
+ if (isset($fg[1])) {
|
|
|
+ $fg = explode('-', trim($fg[1] . $fg[0], '-'));
|
|
|
+ } else {
|
|
|
+ $fg = [];
|
|
|
+ }
|
|
|
+ $pm = array();
|
|
|
+ foreach ($fg as $vv) {
|
|
|
+ if (isset($tc[$vv]['zh'])) {
|
|
|
+ $zh = explode('|', trim($tc[$vv]['zh'], '|'));
|
|
|
+ $pm[$tc[$vv]['classid']] = $zh[0];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $v);
|
|
|
+
|
|
|
+ $tsk = explode('|', trim($features, '|'));
|
|
|
+ if (stripos($tsk[0], ',') !== false) {
|
|
|
+ $ftt = explode(',', $tsk[0]);
|
|
|
+ $features = explode('-', trim($ftt[1], '-'));
|
|
|
+ $features[] = $ftt[0];
|
|
|
+ } else {
|
|
|
+ $features = explode('-', trim($tsk[0], '-'));
|
|
|
+ }
|
|
|
+ $jm = $classid;
|
|
|
+ $jm = $classid;
|
|
|
+ foreach ($features as $vv) {
|
|
|
+ if ($vv != 0) {
|
|
|
+ if (!isset($typeclass[$vv])) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (isset($jm[$typeclass[$vv]['classid']])) {
|
|
|
+ if ($typeclass[$vv]['jm']) {
|
|
|
+ $jm[$typeclass[$vv]['classid']] = $typeclass[$vv]['jm'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $jm = array_filter($jm); //去除空值
|
|
|
+ $jm = implode("-", $jm);
|
|
|
+ $zh = implode(" ", $pm);
|
|
|
+ $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
|
|
|
+ $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
|
|
|
+ if (isset($title[1])) {
|
|
|
+ if (isset($sp[$title[1]])) {
|
|
|
+ $sp[$title[1]]['n'] += $title[2];
|
|
|
+ if (isset($sp[$title[1]]['warehouse'][$val['type']])) {
|
|
|
+ $sp[$title[1]]['warehouse'][$val['type']] += $title[2];
|
|
|
+ } else {
|
|
|
+ $sp[$title[1]]['warehouse'][$val['type']] = $title[2];
|
|
|
+ }
|
|
|
+ //美仓
|
|
|
+ if ($val['type'] == 5) {
|
|
|
+ $sp[$title[1]]['mc'] += $title[2];
|
|
|
+ } elseif ($val['type'] == 13) { //许昌仓
|
|
|
+ $sp[$title[1]]['xcc'] += $title[2];
|
|
|
+ } elseif ($val['type'] == 16) { //定制仓
|
|
|
+ $sp[$title[1]]['dzc'] += $title[2];
|
|
|
+ } else {
|
|
|
+ $sp[$title[1]]['qtc'] += $title[2];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $wh = explode('-', $w[$k]);
|
|
|
+ $wsku = $this->whlabel->find_all("number = '" . $wh[0] . "' and sku != 'Preset'");
|
|
|
+ $whs = (isset($wsku[0]['sku'])) ? $wsku[0]['sku'] : '';
|
|
|
+ $sp[$title[1]] = array('t' => $title[1], 'z' => $zh, 'c' => $tmp_c, 'w' => $whs, 'j' => $jm, 'n' => isset($title[2]) ? $title[2] : "异常 ", "warehouse" => [
|
|
|
+ $val['type'] => isset($title[2])? $title[2]:" 异常",
|
|
|
+ ], "warehouse_show" => "", "xcc" => 0, "mc" => 0, "dzc" => 0, "qtc" => 0);
|
|
|
+ //美仓
|
|
|
+ if ($val['type'] == 5) {
|
|
|
+ $sp[$title[1]]['mc'] = isset($title[2])? $title[2]:" 异常";
|
|
|
+ } elseif ($val['type'] == 13) { //许昌仓
|
|
|
+ $sp[$title[1]]['xcc'] = isset($title[2])? $title[2]:" 异常";
|
|
|
+ } elseif ($val['type'] == 16) { //定制仓
|
|
|
+ $sp[$title[1]]['dzc'] = isset($title[2])? $title[2]:" 异常";
|
|
|
+ } else {
|
|
|
+ $sp[$title[1]]['qtc'] = isset($title[2])? $title[2]:" 异常";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ foreach ($sp as $k => $v) {
|
|
|
+
|
|
|
+ unset($sp[$k]['warehouse']);
|
|
|
+ unset($sp[$k]['warehouse_show']);
|
|
|
+ }
|
|
|
+ $sp = array_values($sp);
|
|
|
+
|
|
|
+
|
|
|
+ echo json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $sp));
|
|
|
+ die;
|
|
|
+ }
|
|
|
+
|
|
|
public function getCate($str)
|
|
|
{
|
|
|
//就是为了匹配类型的导出的一个定义数组
|