query($q); $json_data.="\"code\":0,"; break; case 'qst': //趋势图 $sql_create_table="CREATE TABLE web_qst_temp ( `id` int(10) unsigned NOT NULL auto_increment, `time` varchar(255) NOT NULL default '', `num` int(10) unsigned NOT NULL default '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"; if(check_table_exist("web_qst_temp")!="y"){ $db->query($sql_create_table); } $time_now=date("Y-m-d H:i:s"); $time_bigen=strtotime($time_now."-1 hour"); //$json_data.="\"time_now\":\"".$time_now."\","; //$json_data.="\"time_bigen\":\"".$time_bigen."\","; $tmp2=date("Y-m-d H:i",$time_bigen); $tmp2=$tmp2.":00"; $data_str=""; $data_str1=""; for($i=0;$i<360;$i++){ $tmp1=$i*10; $tmp_t=strtotime($tmp2."+".$tmp1." seconds"); $tmp_time=date("H:i:s",$tmp_t); $tmp_time1=date("Y-m-d",$tmp_t); $sqltime=$tmp_time1." ".$tmp_time; $tmplog=get_db_msg("select * from web_qst_temp where time='".$sqltime."' "); if($tmplog["id"]){ $data_str.="\"".$tmp_time."\","; $data_str1.="\"".$tmplog["num"]."\","; }else{ $num_add=get_db_msg("select sum(num) num from web_log_hd where unix_timestamp(add_date)<".$tmp_t." and (action='21' or action='23') "); $num_subtract=get_db_msg("select sum(num) num from web_log_hd where unix_timestamp(add_date)<".$tmp_t." and (action='22' or action='24')"); $num=$num_add["num"]-$num_subtract["num"]; $db->query("insert into web_qst_temp (time,num) values ('".$sqltime."','".$num."');"); //$data_str.="{"; $data_str.="\"".$tmp_time."\","; //$data_str.="},"; //$data_str1.="{"; $data_str1.="\"".$num."\","; //$data_str1.="},"; } } $json_data.="\"code\":0,"; $json_data.="\"title\":[".deel_end($data_str)."],"; $json_data.="\"js\":[".deel_end($data_str1)."],"; break; case 'ddgl': //订单概览 $tmp_o=get_db_msg("select sum(num) num,sum(je) je,sum(jsje) jsje from web_order where ka<>'y'"); $tmp_c=get_db_msg("select sum(zb_js) zb_js,sum(zb) zb from web_client where available='y' and face='4'"); $json_data.="\"code\":0,"; $json_data.="\"ydjs\":\"".$tmp_o["num"]."\","; $je=keep_float(deel_cf($tmp_o["je"],10000),2); $json_data.="\"ydje\":\"".$je."\","; $jsje=keep_float(deel_cf($tmp_o["jsje"],10000),2); $json_data.="\"ydjsje\":\"".$jsje."\","; $zb=$tmp_c["zb"]*10000; $json_data.="\"zbjs\":\"".$tmp_c["zb_js"]."\","; $json_data.="\"zb\":\"".keep_float($tmp_c["zb"],2)."\","; $wcl_js=keep_float((deel_cf($tmp_o["num"],$tmp_c["zb_js"])*100),2); $wcl_je=keep_float((deel_cf($tmp_o["jsje"],$zb)*100),2); $json_data.="\"wcl_js\":\"".$wcl_js."%\","; $json_data.="\"wcl_je\":\"".$wcl_je."%\","; break; case 'spgl': //商品概览 $q="select * from web_kh"; $r=$db->query($q); $sku=$skc=$sck=$scks=0; while($m=$db->fetch_array($r)){ $arr_color=explode(",",$m["color"]); $arr_color_ka=explode(",",$m["color_ka"]); if($m["ka"]!="y"){ $sku++; foreach($arr_color as $n=>$t){ if(in_array($t,$arr_color_ka)){ $scks++; }else{ $skc++; } } }else{ $sck++; foreach($arr_color as $n=>$t){ $scks++; } } } $tmp=get_db_msg("select count(DISTINCT no) ks from web_order where ka<>'y'"); $wdk=$sku-$tmp["ks"]; $json_data.="\"code\":0,"; $json_data.="\"sku\":\"".$sku."\","; $json_data.="\"skc\":\"".$skc."\","; $json_data.="\"sck\":\"".$sck."\","; $json_data.="\"scks\":\"".$scks."\","; $json_data.="\"wdk\":\"".$wdk."\","; break; case 'khgl': //客户概览 $tmp_o=get_db_msg("select count(DISTINCT uid) dps from web_order where ka<>'y'"); $tmp_c=get_db_msg("select count(*) dps from web_client where available='y' and face='4'"); $tmp_zx=get_db_msg("select count(*) dps from web_session where uid in(select id from web_client where available='y' and face='4')"); $tmp_jd=get_db_msg("select count(*) dps from web_client where available='y' and is_jd='y' and face='4'"); $json_data.="\"code\":0,"; $json_data.="\"chdps\":\"".$tmp_c["dps"]."\","; $json_data.="\"xddps\":\"".$tmp_o["dps"]."\","; $json_data.="\"zxdps\":\"".$tmp_zx["dps"]."\","; $json_data.="\"jddps\":\"".$tmp_jd["dps"]."\","; break; case 'dqph': //大区排行 $q="select * from web_client where face='9' and available='y'"; $r=$db->query($q); $arr_dq=array(); $arr_dq_path=array(); while($m=$db->fetch_array($r)){ $arr_dq[$m["id"]]=$m["title"]; $path=$m["path"]."-".$m["id"]; $arr_dq_path[$m["id"]]=$path; } $arr_ph_js=$arr_ph_je=$arr_ph_jsje=array(); foreach($arr_dq as $n=>$t){ $tmp_o=get_db_msg("select sum(num) num,sum(je) je,sum(jsje) jsje from web_order where ka<>'y' and (upath='".$arr_dq_path[$n]."' or upath like '".$arr_dq_path[$n]."-%')"); $arr_ph_js[$n]=$tmp_o["num"]; $arr_ph_je[$n]=$tmp_o["je"]; $arr_ph_jsje[$n]=$tmp_o["jsje"]; } arsort($arr_ph_js); $json_data.="\"code\":0,"; $data_str=""; $px=1; foreach($arr_ph_js as $n=>$t){ if($hs>=$px){ $data_str.="{"; $data_str.="\"px\":\"".$px++."\","; $data_str.="\"title\":\"".$arr_dq[$n]."\","; $data_str.="\"js\":\"".$t."\","; $je=keep_float(deel_cf($arr_ph_je[$n],10000),2); $data_str.="\"je\":\"".$je."\","; $jsje=keep_float(deel_cf($arr_ph_jsje[$n],10000),2); $data_str.="\"jsje\":\"".$jsje."\""; $data_str.="},"; } } $json_data.="\"data\":[".deel_end($data_str)."],"; break; case 'dlph': //代理排行 $q="select * from web_client where face='3' and available='y'"; $r=$db->query($q); $arr_dl=array(); $arr_dl_path=array(); while($m=$db->fetch_array($r)){ $arr_dl[$m["id"]]=$m["title"]; $path=$m["path"]."-".$m["id"]; $arr_dl_path[$m["id"]]=$path; } $arr_ph_js=$arr_ph_je=$arr_ph_jsje=array(); foreach($arr_dl as $n=>$t){ $tmp_o=get_db_msg("select sum(num) num,sum(je) je,sum(jsje) jsje from web_order where ka<>'y' and (upath='".$arr_dl_path[$n]."' or upath like '".$arr_dl_path[$n]."-%')"); $arr_ph_js[$n]=$tmp_o["num"]; $arr_ph_je[$n]=$tmp_o["je"]; $arr_ph_jsje[$n]=$tmp_o["jsje"]; } arsort($arr_ph_js); $json_data.="\"code\":0,"; $data_str=""; $px=1; foreach($arr_ph_js as $n=>$t){ if($hs>=$px){ $data_str.="{"; $data_str.="\"px\":\"".$px++."\","; $data_str.="\"title\":\"".$arr_dl[$n]."\","; $data_str.="\"js\":\"".$t."\","; $je=keep_float(deel_cf($arr_ph_je[$n],10000),2); $data_str.="\"je\":\"".$je."\","; $jsje=keep_float(deel_cf($arr_ph_jsje[$n],10000),2); $data_str.="\"jsje\":\"".$jsje."\""; $data_str.="},"; } } $json_data.="\"data\":[".deel_end($data_str)."],"; break; case 'mdph': //门店排行 $q="select * from web_client where face='4' and available='y'"; $r=$db->query($q); $arr_dp=array(); while($m=$db->fetch_array($r)){ $arr_dp[$m["id"]]=$m["title"]; } $arr_ph_js=$arr_ph_je=$arr_ph_jsje=array(); foreach($arr_dp as $n=>$t){ $tmp_o=get_db_msg("select sum(num) num,sum(je) je,sum(jsje) jsje from web_order where ka<>'y' and uid='".$n."'"); $arr_ph_js[$n]=$tmp_o["num"]; $arr_ph_je[$n]=$tmp_o["je"]; $arr_ph_jsje[$n]=$tmp_o["jsje"]; } arsort($arr_ph_js); $json_data.="\"code\":0,"; $data_str=""; $px=1; foreach($arr_ph_js as $n=>$t){ if($hs>=$px){ $data_str.="{"; $data_str.="\"px\":\"".$px++."\","; $data_str.="\"title\":\"".$arr_dp[$n]."\","; $data_str.="\"js\":\"".$t."\","; $je=keep_float(deel_cf($arr_ph_je[$n],10000),2); $data_str.="\"je\":\"".$je."\","; $jsje=keep_float(deel_cf($arr_ph_jsje[$n],10000),2); $data_str.="\"jsje\":\"".$jsje."\""; $data_str.="},"; } } $json_data.="\"data\":[".deel_end($data_str)."],"; break; case 'dkph': //单款排行 $q="select no,sum(num) num,sum(je) je,sum(jsje) jsje from web_order where ka<>'y' group by no order by num desc"; $r=$db->query($q); $data_str=""; $px=1; while($m=$db->fetch_array($r)){ if($hs>=$px){ $msg=get_db_msg("select * from web_kh where no='".$m["no"]."'"); $pic=get_kh_picture($msg["no"],$msg["main_pic"],$msg["color"],$flag_pad_offline); $pic_b=get_kh_picture_big($msg["no"],$msg["main_pic"],$msg["color"],$flag_pad_offline); $data_str.="{"; $data_str.="\"px\":\"".$px++."\","; $data_str.="\"no\":\"".$m["no"]."\","; $data_str.="\"pic\":\"".$pic."\","; $data_str.="\"pic_big\":\"".$pic_b."\","; $data_str.="\"js\":\"".$m["num"]."\","; $je=keep_float(deel_cf($m["je"],10000),2); $data_str.="\"je\":\"".$je."\","; $jsje=keep_float(deel_cf($m["jsje"],10000),2); $data_str.="\"jsje\":\"".$jsje."\""; $data_str.="},"; } } $json_data.="\"code\":0,"; $json_data.="\"data\":[".deel_end($data_str)."],"; break; case 'ksph': //单色排行 $q="select no,color,sum(num) num,sum(je) je,sum(jsje) jsje from web_order where ka<>'y' group by no,color order by num desc"; $r=$db->query($q); $data_str=""; $px=1; while($m=$db->fetch_array($r)){ if($hs>=$px){ $pic=get_kh_color_picture($m["no"],$m["color"],$flag_pad_offline); $pic_b=get_kh_color_picture_big($m["no"],$m["color"],$flag_pad_offline); $data_str.="{"; $data_str.="\"px\":\"".$px++."\","; $data_str.="\"no\":\"".$m["no"]."\","; $data_str.="\"color\":\"".$m["color"]."\","; $data_str.="\"color_title\":\"".get_cate_title_no("color",$m["color"])."\","; $data_str.="\"pic\":\"".$pic."\","; $data_str.="\"pic_big\":\"".$pic_b."\","; $data_str.="\"js\":\"".$m["num"]."\","; $je=keep_float(deel_cf($m["je"],10000),2); $data_str.="\"je\":\"".$je."\","; $jsje=keep_float(deel_cf($m["jsje"],10000),2); $data_str.="\"jsje\":\"".$jsje."\""; $data_str.="},"; } } $json_data.="\"code\":0,"; $json_data.="\"data\":[".deel_end($data_str)."],"; break; case 'ddzz': //大单追踪 $zzl=100; $time_now=date("Y-m-d"); $t1=$time_now." 00:00:00"; $t2=$time_now." 23:59:59"; $q="select * from web_log_hd where num>".$zzl." and (add_date between '".$t1."' and '".$t2."' )"; $r=$db->query($q); $data_str=""; $px=1; while($m=$db->fetch_array($r)){ if($hs>=$px){ $msg=get_db_msg("select * from web_kh where id='".$m["iid"]."'"); $dp=get_db_msg("select * from web_client where id='".$m["uid"]."'"); $pic=get_kh_picture($msg["no"],$msg["main_pic"],$msg["color"],$flag_pad_offline); $pic_b=get_kh_picture_big($msg["no"],$msg["main_pic"],$msg["color"],$flag_pad_offline); $data_str.="{"; $data_str.="\"px\":\"".$px++."\","; $data_str.="\"no\":\"".$msg["no"]."\","; $data_str.="\"pic\":\"".$pic."\","; $data_str.="\"pic_big\":\"".$pic_b."\","; $data_str.="\"js\":\"".$m["num"]."\","; $data_str.="\"dp\":\"".$dp["title"]."\","; $data_str.="\"time\":\"".$m["add_date"]."\""; $data_str.="},"; } } $json_data.="\"code\":0,"; $json_data.="\"data\":[".deel_end($data_str)."],"; break; default: break; } $json_data=substr($json_data,0,-1)."}"; echo $json_data; ?>