|
@@ -98,6 +98,8 @@ class Boss extends Start_Controller
|
|
|
$this->_bossyxdpdcx();
|
|
$this->_bossyxdpdcx();
|
|
|
}else if($arg == 'spexceljs'){
|
|
}else if($arg == 'spexceljs'){
|
|
|
$this->_spexceljs();
|
|
$this->_spexceljs();
|
|
|
|
|
+ }else if($arg == 'excellkhjs'){
|
|
|
|
|
+ $this->_excellkhjs();
|
|
|
} else {
|
|
} else {
|
|
|
$this->_index();
|
|
$this->_index();
|
|
|
}
|
|
}
|
|
@@ -1546,228 +1548,74 @@ class Boss extends Start_Controller
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- private function _spexceljsbak()
|
|
|
|
|
- {
|
|
|
|
|
- $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'])){
|
|
|
|
|
|
|
+ private function _excellkhjs(){
|
|
|
|
|
+ if (isset($_SESSION['api'])) {
|
|
|
$user = $this->user->get_api($_SESSION['api']);
|
|
$user = $this->user->get_api($_SESSION['api']);
|
|
|
- if(empty($user)){
|
|
|
|
|
- exit(json_encode(array('code' => 0, 'msg' => '登录信息异常')));
|
|
|
|
|
- }
|
|
|
|
|
- if(empty($user['shop'])){
|
|
|
|
|
- exit(json_encode(array('code' => 0, 'msg' => '该账号没有所属店铺excel导出权限')));
|
|
|
|
|
|
|
+ $usp = $user;
|
|
|
|
|
+ $fgshop = "";
|
|
|
|
|
+ $sid = "";
|
|
|
|
|
+ $user = explode('|', trim($user['shop'], '|'));
|
|
|
|
|
+ foreach ($user as $value) {
|
|
|
|
|
+ if ($value != '18' && $value != '19' && $value != '12' && $value != '13' && $value != '9' && $value != '15' && $value != '27') {
|
|
|
|
|
+ $fgshop .= " shop = " . $value . " or"; //去掉指定的店铺
|
|
|
|
|
+ }
|
|
|
|
|
+ $sid .= " id = " . $value . " or";
|
|
|
}
|
|
}
|
|
|
- $excelshop = explode('|', trim($user['shop'], '|'));
|
|
|
|
|
- }else{
|
|
|
|
|
- exit(json_encode(array('code' => 0, 'msg' => '请先登录')));
|
|
|
|
|
}
|
|
}
|
|
|
- $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, 'msg' => '暂无数据')));
|
|
|
|
|
- }
|
|
|
|
|
- if(count($data) >= 65535){
|
|
|
|
|
- exit(json_encode(array('code' => 0, 'msg' => '数据量超过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'];
|
|
|
|
|
|
|
+ if (isset($_GET['time'])) {
|
|
|
|
|
+ $s = $this->input->get('shop', true);
|
|
|
|
|
+ $time = $this->input->get('time', true);
|
|
|
|
|
+ $timetk = $this->input->get('timetk', true);
|
|
|
|
|
+ $timetj = $this->input->get('timetj', true);
|
|
|
|
|
+ $timetk = strtotime($timetk);
|
|
|
|
|
+ $timetj = strtotime($timetj);
|
|
|
|
|
+ if ($s) {
|
|
|
|
|
+ $shop = $this->shop->find_all("id = '$shop'");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $shop = $this->shop->find_all("(type = 269 or type = 2768 ) and (" . rtrim($sid, 'or') . ')');
|
|
|
|
|
+ }
|
|
|
|
|
+ $d = array();
|
|
|
|
|
+ $k = $timetk - 24 * 3600; //少一天为增加选择开始天时间
|
|
|
|
|
+ $j = $timetj;
|
|
|
|
|
+ $n = ($j - $k) / (24 * 3600);
|
|
|
|
|
+ if ($n < 1) {
|
|
|
|
|
+ $n = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ for ($i = 1; $i < $n; $i++) {
|
|
|
|
|
+ $t = $j - ($n * 24 * 60 * 60) + ($i * 24 * 60 * 60);
|
|
|
|
|
+ foreach ($shop as $val) {
|
|
|
|
|
+ $data = $this->fullorder->find_all("source != 1 and $time > '$t' and $time < '" . ($t + 24 * 3600) . "' and shop = '" . $val['id'] . "'");
|
|
|
|
|
+ $dd = 0;
|
|
|
|
|
+ $m = 0;
|
|
|
|
|
+ foreach ($data as $v) {
|
|
|
|
|
+ $customer = $this->customer->get_email($v['email'], $v['shop']);
|
|
|
|
|
+ $customernum = $this->fullorder->find_count("$time < '" . ($t + 24 * 3600) . "' and email = '" . $v['email'] . "' and shop = '" . $v['shop'] . "' and extra_status = 0 ");
|
|
|
|
|
+ preg_match_all('/[0-9]/u', $v['phone'], $result);
|
|
|
|
|
+ $numphone = join('', $result[0]);
|
|
|
|
|
+ //$customerc = $this->customer->find_all("shop = '".$v['shop']."' and address = '".$v['address']."' and numphone = '".$numphone."'",'*','id desc');
|
|
|
|
|
+ if ($customer) {
|
|
|
|
|
+ if ($customernum > 1) // || (isset($customerc[0]['num']) && $customerc[0]['num'] > 1) // || $customerc['type'] == 1 && $customerc['num'] > 1
|
|
|
|
|
+ {
|
|
|
|
|
+ $dd++;
|
|
|
|
|
+ $m += $v['shouldmoney'];
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ $ddzb = ($dd == 0 || count($data) == 0) ? 0 : sprintf("%01.2f", $dd / count($data) * 100) . '%';
|
|
|
|
|
+ $ddjezb = ($m == 0 || array_sum(array_column($data, 'shouldmoney')) == 0) ? 0 : sprintf("%01.2f", $m / array_sum(array_column($data, 'shouldmoney')) * 100) . '%';
|
|
|
|
|
+ $d[] = array(date('Y-m-d', $t), $val['shopname'], count($data), sprintf("%01.2f", array_sum(array_column($data, 'shouldmoney'))), $dd, $m, $ddzb, $ddjezb);
|
|
|
}
|
|
}
|
|
|
- $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) {
|
|
|
|
|
|
|
+ if(empty($d)){
|
|
|
|
|
+ exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $d = array_values($d);
|
|
|
|
|
+ $title = "老客户数据统计" . date('Y-m-d H-i-s', time());
|
|
|
|
|
+ echo json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $d,'filename'=>$title));
|
|
|
|
|
+ die;
|
|
|
|
|
|
|
|
- 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;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|