|
|
@@ -1319,6 +1319,235 @@ class Boss extends Start_Controller
|
|
|
|
|
|
|
|
|
private function _spexceljs()
|
|
|
+ {
|
|
|
+
|
|
|
+ $tc = array();
|
|
|
+ $typeclass = $this->typeclass->find_all();
|
|
|
+ foreach ($typeclass as $v) {
|
|
|
+ $tc[$v['id']] = $v;
|
|
|
+ }
|
|
|
+ if (isset($_SESSION['api'])) {
|
|
|
+ $user = $this->user->get_api($_SESSION['api']);
|
|
|
+ $usp = $user;
|
|
|
+ $fgshop = "";
|
|
|
+ $sid = "";
|
|
|
+ $excelshop = "";
|
|
|
+ $usersp = explode('|', trim($user['shop'], '|'));
|
|
|
+ foreach ($usersp as $value) {
|
|
|
+ $fgshop .= " shop = " . $value . " or";
|
|
|
+ $sid .= " id = " . $value . " or";
|
|
|
+ }
|
|
|
+ $userexcel = explode('|', trim($user['excelshop'], '|'));
|
|
|
+ foreach ($userexcel as $value) {
|
|
|
+ $excelshop .= " shop = " . $value . " or";
|
|
|
+ }
|
|
|
+ if ($excelshop != "") {
|
|
|
+ $excelshop = "(" . rtrim($excelshop, 'or') . ")";
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ exit(json_encode(array('code' => 0, 'msg' => '登录信息异常')));
|
|
|
+ }
|
|
|
+ $tcall = $this->typeclass->find_all();
|
|
|
+ $typeclass = array();
|
|
|
+ foreach ($tcall as $v) {
|
|
|
+ $tcjm[$v['id']] = array($v['jm'], $v['classid']);
|
|
|
+ $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'jm' => $v['jm']);
|
|
|
+ }
|
|
|
+ $classid = $this->classid->sku();
|
|
|
+ if (isset($_GET['category'])) {
|
|
|
+ $timetk = $this->input->get('timetk', true);
|
|
|
+ $timetj = $this->input->get('timetj', true);
|
|
|
+ $color = $this->input->get('color', true);
|
|
|
+ $lowe = $this->input->get('lowe', true);
|
|
|
+ $size = $this->input->get('size', true);
|
|
|
+ $grade = $this->input->get('grade', true);
|
|
|
+ $lacetype = $this->input->get('lacetype', true);
|
|
|
+ $category = $this->input->get('category', true);
|
|
|
+ $shop = $this->input->get('shop', true);
|
|
|
+ $density = $this->input->get('density', true);
|
|
|
+ $warehouse = $this->input->get('warehouse', true);
|
|
|
+ $time = $this->input->get('time', true);
|
|
|
+ $timetk = strtotime($timetk);
|
|
|
+ $timetj = strtotime($timetj);
|
|
|
+ $where = "";
|
|
|
+ if ($warehouse) {
|
|
|
+ $where .= " type = " . $warehouse . " and ";
|
|
|
+ }
|
|
|
+ if ($category) {
|
|
|
+ $where .= "fpdata like '%-" . $category . "-%' and ";
|
|
|
+ }
|
|
|
+ if ($color) {
|
|
|
+ $where .= "fpdata like '%-" . $color . "-%' and ";
|
|
|
+ }
|
|
|
+ if ($size) {
|
|
|
+ $where .= "fpdata like '%-" . $size . "-%' and ";
|
|
|
+ }
|
|
|
+ if ($grade) {
|
|
|
+ $where .= "fpdata like '%-" . $grade . "-%' and ";
|
|
|
+ }
|
|
|
+ if ($shop) {
|
|
|
+ $where .= "shop = '$shop' and ";
|
|
|
+ } else {
|
|
|
+ $where .= $excelshop . " and ";
|
|
|
+ }
|
|
|
+ if ($lowe) {
|
|
|
+ $where .= "fpdata like '%-" . $lowe . "-%' and ";
|
|
|
+ }
|
|
|
+ if ($density) {
|
|
|
+ $where .= "fpdata like '%-" . $density . "-%' and ";
|
|
|
+ }
|
|
|
+ if ($lacetype) {
|
|
|
+ $where .= "fpdata like '%-" . $lacetype . "-%' and ";
|
|
|
+ }
|
|
|
+ $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();
|
|
|
+ $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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($color) {
|
|
|
+ if (stripos($v, '-' . $color . '-') === false) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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]);
|
|
|
+ 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);
|
|
|
+ $title = "商品统计" . date('Y-m-d H-i-s', time());
|
|
|
+ echo json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $sp,'filename'=>$title));
|
|
|
+ die;
|
|
|
+ }else{
|
|
|
+ exit(json_encode(array('code' => 0, 'msg' => '参数异常')));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private function _spexceljsbak()
|
|
|
{
|
|
|
$tcjm = $tmp_typeclass = $tc = [];
|
|
|
$typeclass = $this->typeclass->find_all();
|
|
|
@@ -1539,6 +1768,12 @@ class Boss extends Start_Controller
|
|
|
die;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public function getCate($str)
|
|
|
{
|
|
|
//就是为了匹配类型的导出的一个定义数组
|