|
@@ -61,7 +61,6 @@ class Bosstwo extends Start_Controller
|
|
|
$this->load->_model("Model_check","check");
|
|
$this->load->_model("Model_check","check");
|
|
|
$this->load->_model("Model_logic_express","logic_express");
|
|
$this->load->_model("Model_logic_express","logic_express");
|
|
|
$this->load->_model("Model_ck","ck");
|
|
$this->load->_model("Model_ck","ck");
|
|
|
- $this->load->_model("Model_excelxh","excelxh");
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
//定义方法的调用规则 获取URI第二段值
|
|
//定义方法的调用规则 获取URI第二段值
|
|
@@ -1056,87 +1055,195 @@ class Bosstwo extends Start_Controller
|
|
|
if ($lacetype) {
|
|
if ($lacetype) {
|
|
|
$where .= "fpdata like '%-" . $lacetype . "-%' and ";
|
|
$where .= "fpdata like '%-" . $lacetype . "-%' and ";
|
|
|
}
|
|
}
|
|
|
- $final_all = [];
|
|
|
|
|
- // 生成 SQL
|
|
|
|
|
- $this->db->from('fullorder')
|
|
|
|
|
- ->where($where . $time . " > '$timetk' and " . $time . " < '$timetj'")
|
|
|
|
|
- ->select('fpdata,number,whlabel,type')
|
|
|
|
|
- ->order_by('id desc');
|
|
|
|
|
- $sql = $this->db->get_compiled_select();
|
|
|
|
|
- $this->db->reset_query();
|
|
|
|
|
-
|
|
|
|
|
- // 检查连接
|
|
|
|
|
- $mysqli = $this->db->conn_id;
|
|
|
|
|
- if (!$mysqli instanceof mysqli) {
|
|
|
|
|
- die('数据库连接不是 mysqli 对象');
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 执行非缓冲查询
|
|
|
|
|
- $result = $mysqli->query($sql, MYSQLI_USE_RESULT);
|
|
|
|
|
- if (!$result) {
|
|
|
|
|
- // 查询失败,输出详细错误
|
|
|
|
|
- echo 'MySQL 查询失败:<br>';
|
|
|
|
|
- // echo '错误信息:' . $mysqli->error . '<br>';
|
|
|
|
|
- // echo '执行的 SQL:' . $sql;
|
|
|
|
|
- exit;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- $list = [];
|
|
|
|
|
- $column_list = [
|
|
|
|
|
- 't'=>'','zh'=>'','cate'=>'','sku'=>'','features'=>'','jm'=>'','total'=>0,'xc'=>0,'mc'=>0,'dzc'=>0,'qt'=>0,
|
|
|
|
|
- ];
|
|
|
|
|
- $params = [
|
|
|
|
|
- 'category'=>$category,
|
|
|
|
|
- 'color'=>$color,
|
|
|
|
|
- 'lowe'=>$lowe,
|
|
|
|
|
- 'size'=>$size,
|
|
|
|
|
- 'grade'=>$grade,
|
|
|
|
|
- 'lacetype'=>$lacetype,
|
|
|
|
|
- 'density'=>$density,
|
|
|
|
|
- ];
|
|
|
|
|
- while ($row = $result->fetch_assoc()) {
|
|
|
|
|
-
|
|
|
|
|
- $tmp_info = $this->dataTransfer($row,$params,$classid,$typeclass);
|
|
|
|
|
- foreach($tmp_info as $k=>$v){
|
|
|
|
|
-
|
|
|
|
|
- if(isset($list[$v['title']])){
|
|
|
|
|
- $ck_type = '';
|
|
|
|
|
- if($v['type'] == 13){
|
|
|
|
|
- $ck_type = 'xc';
|
|
|
|
|
- }elseif($v['type'] == 5){
|
|
|
|
|
- $ck_type = 'mc';
|
|
|
|
|
- }elseif($v['type'] == 16){
|
|
|
|
|
- $ck_type = 'dzc';
|
|
|
|
|
- }else{
|
|
|
|
|
- $ck_type = 'qt';
|
|
|
|
|
|
|
+ $dataa = $this->fullorder->find_all($where . $time . " > '$timetk' and " . $time . " < '$timetj'", 'fpdata,number,whlabel,type', 'id desc');
|
|
|
|
|
+ $datab = $this->fullordersmt->find_all($where . $time . " > '$timetk' and " . $time . " < '$timetj' and shop != '9'", 'fpdata,number,whlabel,type', 'id desc');
|
|
|
|
|
+ $datac = $this->fullordertt->find_all($where . $time . " > '$timetk' and " . $time . " < '$timetj'", 'fpdata,number,whlabel,type', 'id desc');
|
|
|
|
|
+ $data = array_merge($dataa, $datab, $datac);
|
|
|
|
|
+ $sp = array();
|
|
|
|
|
+ $cs = array();
|
|
|
|
|
+ $warehouses = $this->warehouse->find_all('1=1', 'id,title');
|
|
|
|
|
+ $warehouses = array_column($warehouses, 'title', 'id');
|
|
|
|
|
+ foreach ($data as $val) {
|
|
|
|
|
+ $f = explode(';', trim($val['fpdata'], ';'));
|
|
|
|
|
+ $w = explode('|', trim($val['whlabel'], '|'));
|
|
|
|
|
+ foreach ($f as $k => $v) {
|
|
|
|
|
+ if ($category) {
|
|
|
|
|
+ if (stripos($v, '-' . $category . '-') === false) {
|
|
|
|
|
+ continue;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- $list[$v['title']]['total'] += $v['num'];
|
|
|
|
|
- $list[$v['title']][$ck_type] += $v['num'];
|
|
|
|
|
- }else{
|
|
|
|
|
- $tmp_sp = [
|
|
|
|
|
- 't'=>$v['title'],'zh'=>'','cate'=>'','sku'=>'','features'=>$v['features'],'jm'=>'','total'=>$v['num'],'xc'=>0,'mc'=>0,'dzc'=>0,'qt'=>0,
|
|
|
|
|
- ];
|
|
|
|
|
- $ck_type = '';
|
|
|
|
|
- if($v['type'] == 13){
|
|
|
|
|
- $ck_type = 'xc';
|
|
|
|
|
- }elseif($v['type'] == 5){
|
|
|
|
|
- $ck_type = 'mc';
|
|
|
|
|
- }elseif($v['type'] == 16){
|
|
|
|
|
- $ck_type = 'dzc';
|
|
|
|
|
- }else{
|
|
|
|
|
- $ck_type = 'qt';
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($color) {
|
|
|
|
|
+ if (stripos($v, '-' . $color . '-') === false) {
|
|
|
|
|
+ continue;
|
|
|
}
|
|
}
|
|
|
- $tmp_sp[$ck_type] = $v['num'];
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($lowe) {
|
|
|
|
|
+ if (stripos($v, '-' . $lowe . '-') === false) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($size) {
|
|
|
|
|
+ if (stripos($v, $size . ',') === false) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($grade) {
|
|
|
|
|
+ if (stripos($v, '-' . $grade . '-') === false) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($lacetype) {
|
|
|
|
|
+ if (stripos($v, '-' . $lacetype . '-') === false) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($density) {
|
|
|
|
|
+ if (stripos($v, '-' . $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]);
|
|
|
|
|
+ //$fg = explode('-',trim($fg[1].$fg[0],'-'));
|
|
|
|
|
+ if (isset($fg[1])) {
|
|
|
|
|
+ $fg = explode('-', trim($fg[1] . $fg[0], '-'));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $fg = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ $pm = array();
|
|
|
|
|
+ //$pm = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',35=>'','dc'=>'','c'=>'',12=>'',25=>'',26=>'',14=>'',27=>'',10=>'',6=>'',9=>'',39=>'',999=>'',9999=>'');//品名顺序
|
|
|
|
|
+ foreach ($fg as $vv) {
|
|
|
|
|
+ if (isset($tc[$vv]['zh'])) {
|
|
|
|
|
+ $zh = explode('|', trim($tc[$vv]['zh'], '|'));
|
|
|
|
|
+ $pm[$tc[$vv]['classid']] = $zh[0];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- $list[$v['title']] =$tmp_sp;
|
|
|
|
|
-
|
|
|
|
|
|
|
+ $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]:" 异常";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- // 释放结果集
|
|
|
|
|
- $result->free();
|
|
|
|
|
|
|
|
|
|
|
|
+ //由于原来的按照品名分组可能会有异常 这里将品名转化为skuid为分组依据
|
|
|
|
|
+ // $wh = explode('-',$w[$k]);
|
|
|
|
|
+ // if(isset($wh[0])){
|
|
|
|
|
+ // if(isset($sp[$wh[0]]))
|
|
|
|
|
+ // {
|
|
|
|
|
+ // $sp[$wh[0]]['n'] += $title[2];
|
|
|
|
|
+ // if(isset($sp[$wh[0]]['warehouse'][$val['type']])){
|
|
|
|
|
+ // $sp[$wh[0]]['warehouse'][$val['type']] += $title[2];
|
|
|
|
|
+ // }else{
|
|
|
|
|
+ // $sp[$wh[0]]['warehouse'][$val['type']] = $title[2];
|
|
|
|
|
+ // }
|
|
|
|
|
+ // //美仓
|
|
|
|
|
+ // if($val['type'] == 5){
|
|
|
|
|
+ // $sp[$wh[0]]['mc'] += $title[2];
|
|
|
|
|
+ // }elseif($val['type'] == 13){//许昌仓
|
|
|
|
|
+ // $sp[$wh[0]]['xcc'] += $title[2];
|
|
|
|
|
+ // }elseif($val['type'] == 16){//定制仓
|
|
|
|
|
+ // $sp[$wh[0]]['dzc'] += $title[2];
|
|
|
|
|
+ // }else{
|
|
|
|
|
+ // $sp[$wh[0]]['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[$wh[0]] = array('t'=>$title[1],'z'=>$zh,'c'=>$tmp_c,'w'=>$whs,'j'=>$jm,'n'=>$title[2],"warehouse"=>[
|
|
|
|
|
+ // $val['type'] =>$title[2],
|
|
|
|
|
+ // ],"warehouse_show"=>"","xcc"=>0,"mc"=>0,"dzc"=>0,"qtc"=>0);
|
|
|
|
|
+ // //美仓
|
|
|
|
|
+ // if($val['type'] == 5){
|
|
|
|
|
+ // $sp[$wh[0]]['mc'] = $title[2];
|
|
|
|
|
+ // }elseif($val['type'] == 13){//许昌仓
|
|
|
|
|
+ // $sp[$wh[0]]['xcc'] = $title[2];
|
|
|
|
|
+ // }elseif($val['type'] == 16){//定制仓
|
|
|
|
|
+ // $sp[$wh[0]]['dzc'] = $title[2];
|
|
|
|
|
+ // }else{
|
|
|
|
|
+ // $sp[$wh[0]]['qtc'] = $title[2];
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ foreach ($sp as $k => $v) {
|
|
|
|
|
+ // foreach($sp[$k]['warehouse'] as $kk =>$vv){
|
|
|
|
|
+ // $warehouse_name = isset($warehouses[$kk])?$warehouses[$kk]:"异常仓库-".$kk;
|
|
|
|
|
+ // $sp[$k]['warehouse_show'] .=$warehouse_name.":".$vv."<br />";
|
|
|
|
|
+ // }
|
|
|
|
|
+ unset($sp[$k]['warehouse']);
|
|
|
|
|
+ unset($sp[$k]['warehouse_show']);
|
|
|
|
|
+ }
|
|
|
|
|
+ $sp = array_values($sp);
|
|
|
$title = "商品统计" . date('Y-m-d H-i-s', time());
|
|
$title = "商品统计" . date('Y-m-d H-i-s', time());
|
|
|
$titlename = "<table border=1>
|
|
$titlename = "<table border=1>
|
|
|
<tr>
|
|
<tr>
|
|
@@ -1154,65 +1261,10 @@ class Bosstwo extends Start_Controller
|
|
|
</table>";
|
|
</table>";
|
|
|
$filename = $title . ".xls";
|
|
$filename = $title . ".xls";
|
|
|
$tail = "\n";
|
|
$tail = "\n";
|
|
|
- $this->excelxh->get_fz2($list, $titlename, $filename, $tail);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ $this->excel->get_fz2($sp, $titlename, $filename, $tail);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //数据处理
|
|
|
|
|
- private function dataTransfer($row,$params){
|
|
|
|
|
- $list =[];
|
|
|
|
|
- $f = explode(';', trim($row['fpdata'], ';'));
|
|
|
|
|
- foreach ($f as $k => $v) {
|
|
|
|
|
- if ($params['category']) {
|
|
|
|
|
- if (stripos($v, '-' . $params['category'] . '-') === false) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if ($params['color']) {
|
|
|
|
|
- if (stripos($v, '-' . $params['color'] . '-') === false) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if ($params['lowe']) {
|
|
|
|
|
- if (stripos($v, '-' . $params['lowe'] . '-') === false) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if ($params['size']) {
|
|
|
|
|
- if (stripos($v, $params['size'] . ',') === false) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if ($params['grade']) {
|
|
|
|
|
- if (stripos($v, '-' . $params['grade'] . '-') === false) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if ($params['lacetype']) {
|
|
|
|
|
- if (stripos($v, '-' . $params['lacetype'] . '-') === false) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if ($params['density']) {
|
|
|
|
|
- if (stripos($v, '-' . $params['density'] . '-') === false) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- $tmp_arr = explode('|', $v);
|
|
|
|
|
- $fe = $this->logic_u9tools->getGoodFeatureAlone($tmp_arr[0]);
|
|
|
|
|
- $list[] = [
|
|
|
|
|
- 'title'=>$tmp_arr[1],
|
|
|
|
|
- 'features'=>$fe,
|
|
|
|
|
- 'type'=>$row['type'],
|
|
|
|
|
- 'num'=>$tmp_arr[2]
|
|
|
|
|
- ];
|
|
|
|
|
- }
|
|
|
|
|
- return $list;
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
private function _spexceljs()
|
|
private function _spexceljs()
|
|
|
{
|
|
{
|