This repository has been archived on 2026-06-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
wsh5485 7e47ce238b chore: 添加多个图片和资源文件
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
2025-06-15 13:04:37 +08:00

135 lines
5.4 KiB
PHP

<?php
//3维订货深度分析
//可配置参数:zd1|series|维度1,zd2|category|维度2,zd3|bc|维度3
//20181211 by hehe
//-----参数配置
//横向维度
$zd1=get_plugin_set("zd1","series");
$zd2=get_plugin_set("zd2","category");
$zd3=get_plugin_set("zd3","bc");
//查询条件
$select_client_type="y";//dp:允许筛选店铺
$use_layui_datatable="n";//使用标准layui datatable格式数据
$con_other=" and ka<>'y'";//排除条件
//店铺查询条件
$con="";
if($msg_client["face"]=="4"){
$s_username=$msg_client["username"];
$con=" and uid='".$msg_client["id"]."'";
}else{
if($s_username){
$m2=get_db_msg("select id,face,path from ".$table_pre."client where username='".$s_username."'");
if($m2["face"]=="4"){
$con=" and uid='".$m2["id"]."'";
}else{
$con=" and (upath='".$m2["path"]."-".$m2["id"]."' or upath like '".$m2["path"]."-".$m2["id"]."-%')";
}
}else if($msg_client["face"]=="2"){
//区经角色所有客户
$con=get_qj_ucon_all($msg_client["charge_path_real"]);
}else{
//代理角色所有客户
$con=" and (upath='".$msg_client["path"]."-".$msg_client["id"]."' or upath like '".$msg_client["path"]."-".$msg_client["id"]."-%')";
}
}
//取得选项的值
$tmp_arr=array($zd1,$zd2,$zd3);
for($i=0;$i<count($tmp_arr);$i++){
$v1=$tmp_arr[$i]."_title";
$v2=$tmp_arr[$i]."_arr";
//取得对应字段的名称
$$v1=get_cate_title_no("arr_select",$tmp_arr[$i]);
//取得字段的选项值
$q1="select no,title from ".$table_pre."keyword where cate='".$tmp_arr[$i]."' order by no";
$r1=$db->query($q1);
$arr_tmp1=array();
while($m1=$db->fetch_array($r1)){
$arr_tmp1[$m1["no"]]=$m1["title"];
}
$$v2=$arr_tmp1;
}
//
$content_data.="<table border='0' cellspacing='1' cellpadding='4' class='layui-table'><thead>";
//----------------取得款号表数据
$arr_kh_data=array();
$q="select ".$zd1.",".$zd2.",".$zd3.",count(*) 'ks',sum(price)/count(*) 'jj' from ".$table_pre."kh where ka<>'y'".$con_other.$con_sx." group by ".$zd1.",".$zd2.",".$zd3;
//echo $q."<br>";
$r=$db->query($q);
while($m=$db->fetch_array($r)){
//取得sku
$q1="select color,color_ka from ".$table_pre."kh where ka<>'y'".$con_other.$con_sx." and ".$zd1."='".$m[$zd1]."' and ".$zd2."='".$m[$zd2]."' and ".$zd3."='".$m[$zd3]."'";
//echo $q1."<br>";
$r1=$db->query($q1);
$tmp_sku=0;
while($m1=$db->fetch_array($r1)){
if(trim($m1["color_ka"]))
$num1=count(explode(",",$m1["color_ka"]));
else
$num1=0;
$tmp_sku+=count(explode(",",$m1["color"]))-$num1;
}
//
$arr_kh_data[$m[$zd1]][$m[$zd2]][$m[$zd3]]=array($m["ks"],$tmp_sku,$m["jj"]);
}
//----------------取得订单表数据
$arr_order_data=array();
$q="select ".$zd1.",".$zd2.",".$zd3.",count(distinct iid,color) 'sku',max(num) 'num_max',min(num) 'num_min',sum(num)/count(distinct iid,color) 'num_pj' from ".$table_pre."order where id<>'0'".$con_other.$con_sx.$con." group by ".$zd1.",".$zd2.",".$zd3;
//echo $q."<br>";
$r=$db->query($q);
while($m=$db->fetch_array($r)){
$arr_order_data[$m[$zd1]][$m[$zd2]][$m[$zd3]]=array($m["sku"],deel_num(keep_float($m["num_pj"],1)),deel_num($m["num_max"]),deel_num($m["num_min"]));
}
//计算第一维度小计,用于计算占比
$var1=$zd1."_arr";
$var2=$zd2."_arr";
$var3=$zd3."_arr";
$arr_kh_data_xj=array();
$arr_order_date_xj=array();
$total_yd_sku=0;
$total_ks=$total_sku=0;
foreach($$var1 as $k1=>$v1){
$xj1=$xj2=0;
$xj11=$xj12=$xj13=$xj14=$xj15=0;
foreach($$var2 as $k2=>$v2){
foreach($$var3 as $k3=>$v3){
$xj1+=$arr_kh_data[$k1][$k2][$k3][0];
$xj2+=$arr_kh_data[$k1][$k2][$k3][1];
$total_ks+=$arr_kh_data[$k1][$k2][$k3][0];
$total_sku+=$arr_kh_data[$k1][$k2][$k3][1];
$xj11+=$arr_order_data[$k1][$k2][$k3][0];
$total_yd_sku+=$arr_order_data[$k1][$k2][$k3][0];
}
}
$arr_kh_data_xj[$k1]=array($xj1,$xj2);
$arr_order_data_xj[$k1]=array($xj11);
}
//-----------------------------表头第一行
$var_t1=$zd1."_title";
$var_t2=$zd2."_title";
$var_t3=$zd3."_title";
$content_data.="<tr>";
$content_data.="<th align='center'><strong>".$$var_t1."</strong></th><th align='center'><strong>".$$var_t2."</strong></th><th align='center'><strong>".$$var_t3."</strong></th><th align='center'><strong>开发SKU</strong></th><th align='center'><strong>开发SKU占比</strong></th><th align='center'><strong>订货SKU</strong></th><th align='center'><strong>平均值</strong></th><th align='center'><strong>最大值</strong></th><th align='center'><strong>最小值</strong></th>";
$content_data.="</tr>";
$content_data.="</thead>";
//--------------------输出报表-----------------------------------------------
$content_data.="<tbody>";
$var1=$zd1."_arr";
$var2=$zd2."_arr";
$var3=$zd3."_arr";
$count=0;
foreach($$var1 as $k1 => $v1){
foreach($$var2 as $k2 => $v2){
foreach($$var3 as $k3 => $v3){
if($arr_kh_data[$k1][$k2][$k3][0]>0){
$content_data.="<tr>";
$content_data.="<td align='center'>".$v1."</td><td align='center'>".$v2."</td><td align='center'>".$v3."</td><td align='center'>".deel_0($arr_kh_data[$k1][$k2][$k3][1])."</td><td align='center'>".deel_bfb($arr_kh_data[$k1][$k2][$k3][1],$total_sku)."</td><td align='center'>".deel_0($arr_order_data[$k1][$k2][$k3][0])."</td><td align='center'>".deel_0($arr_order_data[$k1][$k2][$k3][1])."</td><td align='center'>".deel_0($arr_order_data[$k1][$k2][$k3][2])."</td><td align='center'>".deel_0($arr_order_data[$k1][$k2][$k3][3])."</td>";
$content_data.="</tr>";
$count++;
}
}
}
}
$content_data.="</tbody>";
$content_data.="</table>";
$json_data.="\"table_html\":\"".$content_data."\",";
?>