lvhao 1 هفته پیش
والد
کامیت
f3761030bf
3فایلهای تغییر یافته به همراه2652 افزوده شده و 0 حذف شده
  1. 225 0
      core/CoreApp/controllers/Boss.php
  2. 2105 0
      core/CoreApp/controllers/Bosstwo.php
  3. 322 0
      template/erp/boss_qtcs.html

+ 225 - 0
core/CoreApp/controllers/Boss.php

@@ -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)
 	{
 		//就是为了匹配类型的导出的一个定义数组

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 2105 - 0
core/CoreApp/controllers/Bosstwo.php


+ 322 - 0
template/erp/boss_qtcs.html

@@ -0,0 +1,322 @@
+{Template header}
+<style>
+.new_bossok {
+    width: 70px;
+    height: 30px;
+    line-height: 30px;
+    background: #2ca8a1;
+    text-align: center;
+    color: #fff;
+    border-radius: 5px;
+    display: inline-block;
+    margin-left: 20px;
+    cursor: pointer;
+}
+</style>
+<div class="warp">
+<ul class="search bossspexcel" style="border-bottom: 1px solid #ccc;padding:16px 0" id="bossspexcel">
+<p style="color:#F00;font-size: 18px;line-height:50px;">单次导出数据条数不可超过65535条!</p>
+<p style="color:#333;font-size: 18px;line-height:50px;">按订单商品排列下载</p>
+<li>
+店铺:<select name="shop" class="select">
+<option value="">请选择</option>
+{loop usershop() as $val}
+<option value="{$val['id']}">{$val['shopname']}</option>
+{/loop}</select>
+</select>
+</li>
+<li>
+类型:<select name="category" class="select">
+<option value="128">Wigs</option>
+{loop typeclass(16) as $val}
+{if $val['id'] != 128}
+<option value="{$val['id']}">{$val['title']} - {$val['zh']}</option>
+{/if}
+{/loop}
+<option value="">全部</option>
+</select>
+</li>
+<li>
+颜色:<select name="color" class="select">
+<option value="">请选择</option>
+<option value="57">Natural Black</option>
+{loop typeclassyc(8) as $val}
+{if $val['id'] != 57}
+<option value="{$val['id']}">{$val['title']} - {$val['zh']}</option>
+{/if}
+{/loop}
+</select>
+</li>
+<li>
+等级:<select name="grade" class="select">
+<option value="">请选择</option>
+{loop typeclass(13) as $val}
+<option value="{$val['id']}">{$val['title']} - {$val['zh']}</option>
+{/loop}
+</select>
+</li>
+<li>
+曲度:<select name="lowe" class="select">
+<option value="">请选择</option>
+{loop typeclassyc(15) as $val}
+<option value="{$val['id']}">{$val['title']} - {$val['zh']}</option>
+{/loop}
+</select>
+</li>
+<li>
+密度:<select name="density" class="select">
+<option value="">请选择</option>
+{loop typeclassyc(10) as $val}
+<option value="{$val['id']}">{$val['title']} - {$val['zh']}</option>
+{/loop}
+</select>
+</li>
+<li>
+头套种类:<select name="lacetype" class="select">
+<option value="">请选择</option>
+{loop typeclassyc(18) as $val}
+<option value="{$val['id']}">{$val['title']} - {$val['zh']}</option>
+{/loop}
+</select>
+</li>
+<li>
+长度:<select name="size" class="select">
+<option value="">请选择</option>
+{loop typeclassyc(14) as $val} <!-- 这个是不显示部分曲度 -->
+<option value="{$val['id']}">{$val['title']}</option>
+{/loop}
+</select>
+</li>
+<li>
+仓库:<select name="warehouse" class="select">
+<option value="">请选择</option>
+{loop $wh as  $val} <!-- 这个是不显示部分曲度 -->
+<option value="{$val['id']}">{$val['title']}</option>
+{/loop}
+</select>
+</li>
+<li><select name="time" class="select">
+<option value="librarytime">出库时间</option>
+<option value="dtime">订单时间</option>
+</select> :<input id="outk"  value="{date('Y-m-d',time()-30*24*3600)} 0:00" name="timetk" type="text" onClick="laydate({istime: true,format:'YYYY-MM-DD hh:mm'})" readonly>
+至&nbsp;&nbsp;&nbsp;&nbsp; <input id="outj" value="{date('Y-m-d',time())} 23:59" name="timetj" type="text" onClick="laydate({istime: true,format:'YYYY-MM-DD hh:mm'})" readonly></li>
+<li><font class="new_bossok" onclick="bossspexcel('bossspexcel')">下载结果</font></li>
+</ul>
+
+<ul class="search excellkh" style="border-bottom: 1px solid #ccc;padding:16px 0">
+<p style="color:#333;font-size: 18px;line-height:50px;">下载老客户数据: <font style="color:#888;font-size: 16px;">数据仅包含店内订单。分母:店内全部订单,分子:购买次数大于1的店内订单</font></p>
+<li>
+店铺:<select name="shop" class="select">
+<option value="">全部</option>
+{loop usershop() as $val}
+<option value="{$val['id']}">{$val['shopname']}</option>
+{/loop}</select>
+</select>
+</li>
+<li><select name="time" class="select">
+<option value="dtime">订单时间</option>
+</select> :<input id="lkhk"  value="{date('Y-m-d',time()-24*3600)} 0:00" name="timetk" type="text" onClick="laydate({istime: true,format:'YYYY-MM-DD hh:mm'})" readonly>
+至&nbsp;&nbsp;&nbsp;&nbsp; <input id="lkhj" value="{date('Y-m-d',time())} 23:59" name="timetj" type="text" onClick="laydate({istime: true,format:'YYYY-MM-DD hh:mm'})" readonly></li>
+<li><font class="bossok" data-c="excellkh" data-u="excellkh" data-e="1">下载结果</font></li>
+</ul>
+
+<ul class="search excelshop" style="border-bottom: 1px solid #ccc;padding:16px 0">
+<p style="color:#333;font-size: 18px;line-height:50px;">下载店铺数据: <font style="color:#888;font-size: 16px;">数据包含本店全部订单,含店内单和线下单。</font></p>
+<li>
+店铺:<select name="shop" class="select">
+<option value="">全部</option>
+{loop usershop() as $val}
+<option value="{$val['id']}">{$val['shopname']}</option>
+{/loop}</select>
+</select>
+</li>
+<li><select name="time" class="select">
+<option value="dtime">订单时间</option>
+</select> :<input id="outk"  value="{date('Y-m-d',time()-24*3600)} 0:00" name="timetk" type="text" onClick="laydate({istime: true,format:'YYYY-MM-DD hh:mm'})" readonly>
+至&nbsp;&nbsp;&nbsp;&nbsp; <input id="outj" value="{date('Y-m-d',time())} 23:59" name="timetj" type="text" onClick="laydate({istime: true,format:'YYYY-MM-DD hh:mm'})" readonly></li>
+<li><font class="bossok" data-c="excelshop" data-u="excelshop" data-e="1">下载结果</font></li>
+</ul>
+
+<ul class="search excelpass" style="border-bottom: 1px solid #ccc;padding:16px 0">
+<p style="color:#333;font-size: 18px;line-height:50px;">Excel密码</p>
+<li>Excel密码:<input value="{$excelpass}" name="excelpass" type="text"></li>
+<li>每个账号每天使用解密次数:<input value="{$excelusernum}" name="excelusernum" type="text"></li>
+<li>每个账号每次解密数量:<input value="{$exceljmnum}" name="exceljmnum" type="text"></li>
+<li><font class="bossok" data-c="excelpass" data-u="setting">修改密码</font></li>
+</ul>
+
+<ul class="search dpay" style="border-bottom: 1px solid #ccc;padding:16px 0">
+<p style="color:#333;font-size: 18px;line-height:50px;">调整费率</p>
+<li>订单时间:<input id="outk"  value="{date('Y-m-d',time()-30*24*3600)} 0:00" name="timetk" type="text" onClick="laydate({istime: true,format:'YYYY-MM-DD hh:mm'})" readonly>
+至&nbsp;&nbsp;&nbsp;&nbsp; <input id="outk" value="{date('Y-m-d',time())} 23:59" name="timetj" type="text" onClick="laydate({istime: true,format:'YYYY-MM-DD hh:mm'})" readonly></li>
+<li>支付类型:<select name="pay" class="select" style="width:90px">
+<option value="">请选择</option>
+{loop typeclass(4,3) as $val}
+<option value="{$val['id']}">{$val['title']}</option>
+{/loop}
+</select></li>
+<li><font class="bossok" data-c="dpay" data-u="dpay">确定调整</font></li>
+</ul>
+
+<ul class="search sctime" style="border-bottom: 1px solid #ccc;padding:16px 0">
+<p style="color:#333;font-size: 18px;line-height:50px;">订单时差</p>
+<li>需要减去的时间(小时):<input value="{$sctime}" name="sctime" type="text" style="width:150px;text-align: center;"></li>
+<li><font class="bossok" data-c="sctime" data-u="sctime">确定</font></li>
+</ul>
+</div>
+<script type="text/javascript" src="{$theme}js/laydate2.js"></script>
+<script>
+$("select[name='en']").change(function(){
+    var index = $(this).find("option:selected").index();
+	$(this).parent("li").find("select[name='zh'] option:eq("+index+")").prop('selected','selected'); 
+	$(this).parent("li").find("select[name='hg'] option:eq("+index+")").prop('selected','selected'); 
+ });
+$("select[name='zh']").change(function(){
+    var index = $(this).find("option:selected").index();
+	$(this).parent("li").find("select[name='en'] option:eq("+index+")").prop('selected','selected'); 
+	$(this).parent("li").find("select[name='hg'] option:eq("+index+")").prop('selected','selected'); 
+ });
+ $("select[name='hg']").change(function(){
+    var index = $(this).find("option:selected").index();
+	$(this).parent("li").find("select[name='zh'] option:eq("+index+")").prop('selected','selected'); 
+	$(this).parent("li").find("select[name='en'] option:eq("+index+")").prop('selected','selected'); 
+ });
+ 
+ $(".sc").click(function() {
+	 $(this).parent("li").remove();
+ });
+ 
+ $(".bossdpex").click(function() {
+var f = {}; var i = 0;
+ $(".dpexxq li").each(function() {
+	 var v = {};
+	 $(this).find('input').each(function() {
+       v[$(this).attr("name")] = $(this).val();
+    });
+	$(this).find('.select').each(function() {
+        v[$(this).attr("name")] = $(this).children("option:selected").val();
+    });
+	f[i] = v;
+	i++;
+ });
+   var d = "n=" + $(".dpex input[name='number']").val() + "&postdata="+JSON.stringify(f);
+   
+        layx.load('loadId','处理中,请稍后');
+        $.ajax({
+        url: "/boss/dpex",
+        data: d,
+        type: "POST",
+        dataType: "json",
+        success: function(a) {
+			layx.destroy('loadId');
+            if (a && a.success) {
+                $(".dpexyd").html(a.msg);
+            } else {
+               $(".express p:eq(0)").html(a.msg);
+				$(".express p:eq(1)").html("<font class='esc'>确 定</font>");
+                $(".express").show();
+            }
+        }
+        });
+	
+});
+ </script>
+ <script>
+    function bossspexcel(id_name){
+        let obj = {}
+        let shop = $("select[name='shop']").val();
+        if(shop){
+            obj.shop = shop;
+        }
+        let category = $("select[name='category']").val();
+        if(category){
+            obj.category = category;
+        }
+        let color = $("select[name='color']").val();
+        if(color){
+            obj.color = color;
+        }
+        let grade = $("select[name='grade']").val();
+        if(grade){
+            obj.grade = grade;
+        }
+        let lowe = $("select[name='lowe']").val();
+        if(lowe){
+            obj.lowe = lowe;
+        }
+        let density = $("select[name='density']").val();
+        if(density){
+            obj.density = density;
+        }
+        let lacetype = $("select[name='lacetype']").val();
+        if(lacetype){
+            obj.lacetype = lacetype;
+        }
+        let size = $("select[name='size']").val();
+        if(size){
+            obj.size = size;
+        }
+        let warehouse = $("select[name='warehouse']").val();
+        if(warehouse){
+            obj.warehouse = warehouse;
+        }
+        let time = $("select[name='time']").val();
+        if(time){
+            obj.time = time;
+        }
+        let timetk = $("input[name='timetk']").val();
+        if(timetk){
+            obj.timetk = timetk;
+        }
+        let timetj = $("input[name='timetj']").val();
+        if(timetj){
+            obj.timetj = timetj;
+        }
+        layx.load('loadId','处理中,请稍后');
+        $.post("/boss/spexceljs",obj,function(res){
+            if(res.code==0){
+                layx.destroy('loadId');
+                layx.confirm('提示',res.msg,null,{
+                    buttons:[
+                        {
+                            label:'确定',
+                            callback:function(id, button, event){
+                            
+                                layx.destroy(id);
+                            }
+                        }
+                    ],dialogIcon:'error',shadable:0.6
+                });
+            }else{
+                const fileName = '员工数据.xlsx' ;
+                // 将数据转换为工作表
+                const worksheet = XLSX.utils.json_to_sheet(res.data);
+                // 创建工作簿
+                const workbook = XLSX.utils.book_new();
+            
+                worksheet['!cols'] = 
+                [
+                    { wch: 80 }, 
+                    { wch: 80 },  
+                    { wch: 20 },  
+                    { wch: 20 },  
+                    { wch: 20 },  
+                    { wch: 10 },  
+                    { wch: 10 },
+                    { wch: 10 },
+                    { wch: 10 },
+                    { wch: 10 },
+                ];
+                
+                // 将工作表添加到工作簿
+                XLSX.utils.book_append_sheet(workbook, worksheet, '员工数据');
+                
+                // 导出文件
+                XLSX.writeFile(workbook, fileName);
+                layx.destroy('loadId');
+            }
+        },'json')
+    }
+ </script>
+ <script type="text/javascript" src="{$theme}js/excel/xlxs.js" ></script>
+{Template footer}