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
EDT/plugin/client_bb/ls1.php
T
wsh5485 7e47ce238b chore: 添加多个图片和资源文件
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
2025-06-15 13:04:37 +08:00

117 lines
5.6 KiB
PHP

<?php
//1维历史数据分析
//可配置参数:keyword_zd1|category|维度
//2018-12-12 by hehe
//------横向维度:zd1,zd2
//-----参数配置
//横向维度
$zd1=get_plugin_set("keyword_zd1","category");
$select_client_type="y";//dp:允许筛选店铺
$use_layui_datatable="n";//使用标准layui datatable格式数据
//其他条件
//$con_other=" and brand='11'";
//
if(check_table_exist($table_pre."plugin_ls1")=="n"){
//
$code=0;
$error_msg="请先导入历史数据!";
}else{
//店铺查询条件
$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"]."-%')";
}
}
//
$con_this=$con;
for($i=1;$i<2;$i++){
$v="zd".$i;
$v1="zd_title".$i;
$v2="arr_zd".$i;
//取得对应字段的名称
$$v1=get_cate_title_no("arr_select",$$v);
//取得字段的选项值
$q1="select no,title from ".$table_pre."keyword where cate='".$$v."' order by no";
$r1=$db->query($q1);
$arr_tmp=array();
while($m1=$db->fetch_array($r1)){
$arr_tmp[$m1["no"]]=$m1["title"];
}
$$v2=$arr_tmp;
}
$content_data.="<table border='0' cellspacing='1' cellpadding='4' class='layui-table'><thead>";
//第一行
$content_data.="<tr>";
$content_data.="<th align='center' rowspan='2'><strong>".$zd_title1."</strong></th><th align='center' colspan='3'><strong>往年销售</strong></th><th align='center' colspan='4'><strong>实际订单</strong></th><th align='center' colspan='3'><strong>差异</strong></th>";
$content_data.="</tr>";
$content_data.="<tr><th align='center'><strong>销售款数</strong></th><th align='center'><strong>销售件数</strong></th><th align='center'><strong>销售金额</strong></th><th align='center'><strong>订单款数</strong></th><th align='center'><strong>订单件数</strong></th><th align='center'><strong>订单金额</strong></th><th align='center'><strong>金额占%</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>";
//-----------取得报表数据
$total_yd_je=$total_yd_js=$total_yd_ks=0;
//订单表数据
$q3="select ".$zd1.",count(distinct iid) 'ks',sum(num) 'js',sum(jsje) 'je' from ".$table_pre."order where ka<>'y'".$con_other.$con_this." group by ".$zd1;
$r3=$db->query($q3);
$arr_data_je=$arr_data_js=$arr_data_ks=array();
while($m3=$db->fetch_array($r3)){
$arr_data_je[$m3[$zd1]]=deel_num($m3["je"]);
$arr_data_js[$m3[$zd1]]=$m3["js"];
$arr_data_ks[$m3[$zd1]]=$m3["ks"];
$total_yd_je+=$m3["je"];
$total_yd_js+=$m3["js"];
$total_yd_ks+=$m3["ks"];
}
//sku
$q3="select ".$zd1.",color,color_ka from ".$table_pre."kh where ka<>'y'";
$r3=$db->query($q3);
$arr_data_sku=array();
while($m3=$db->fetch_array($r3)){
if(trim($m3["color_ka"]))
$num1=count(explode(",",$m3["color_ka"]));
else
$num1=0;
$arr_data_sku[$m3[$zd1]]+=count(explode(",",$m3["color"]))-$num1;
}
//总历史数据
$tmp=get_db_msg("select sum(js) 'js',sum(je) 'je',sum(ks) 'ks' from ".$table_pre."plugin_ls1 where c1<>''".$con_this);
$total_ls_je=$tmp["je"];
$total_ls_js=$tmp["js"];
$total_ls_ks=$tmp["ks"];
//--------------------输出报表-----------------------------------------------
$content_data.="<tbody>";
foreach($arr_zd1 as $key1=>$value1){
//取得指标数据
$m_ls=get_db_msg("select sum(js) 'js',sum(je) 'je',sum(ks) 'ks' from ".$table_pre."plugin_ls1 where c1='".$value1."'".$con_this);
if($arr_data_sku[$key1]>0){
$content_data.="<tr>";
$content_data.="<td align='center'>".$value1."</td><td align='center'>".deel_0($m_ls["ks"])."</td><td align='center'>".deel_0($m_ls["js"])."</td><td align='center'>".deel_0($m_ls["je"])."</td><td align='center'>".deel_0($arr_data_ks[$key1])."</td><td align='center'>".deel_0($arr_data_js[$key1])."</td><td align='center'>".deel_0($arr_data_je[$key1])."</td><td align='center'>".deel_bfb($arr_data_je[$key1],$total_yd_je)."</td><td align='center'>".deel_0($m_ls["ks"]-$arr_data_ks[$key1])."</td><td align='center'>".deel_0($m_ls["js"]-$arr_data_js[$key1])."</td><td align='center'>".deel_0($m_ls["je"]-$arr_data_je[$key1])."</td>";
$total_1+=$m_ls["ks"];
$total_2+=$m_ls["js"];
$total_3+=$m_ls["je"];
$total_4+=$arr_data_ks[$key1];
$total_5+=$arr_data_js[$key1];
$total_6+=$arr_data_je[$key1];
$content_data.="</tr>";
$count++;
}
}
$content_data.="<tr><td align='center'><b>合计</b></td><td align='center'><b>".deel_0($total_1)."</b></td><td align='center'><b>".deel_0($total_2)."</b></td><td align='center'><b>".deel_0($total_3)."</b></td><td align='center'><b>".deel_0($total_4)."</b></td><td align='center'><b>".deel_0($total_5)."</b></td><td align='center'><b>".deel_0($total_6)."</b></td><td align='center'><b>100%</b></td><td align='center'><b>".deel_0($total_1-$total_4)."</b></td><td align='center'><b>".deel_0($total_2-$total_5)."</b></td><td align='center'><b>".deel_0($total_3-$total_6)."</b></td></tr>";
$content_data.="</tbody></table>";
}
$json_data.="\"table_html\":\"".$content_data."\",";
?>