"是否启用","in_ph"=>"参与排行","face"=>"登陆角色","path"=>"上级路径","title"=>"用户名称","username"=>"用户代码","dpsx"=>"店铺属性","dj"=>"店铺等级","password"=>"登陆密码","zb"=>"指标金额","zb_js"=>"指标件数","zb_ks"=>"指标款数","zb_kss"=>"指标款色数","charge_path"=>"区域经理权限","rfid"=>"绑定ID"); if($zk_type=="client") $arr_column_client["zk"]="折扣"; if($is_multi_price=="y"){ $arr_column_client["dp_price"]="吊牌价类型"; } if(is_array($sys_client_zd)){ foreach($sys_client_zd as $k1 => $v1){ $arr_column_client[$k1]=$v1; } } $json_data="{"; if($priv[0]=="n"){ //没有操作权限 $json_data.="\"error\":\"没有操作权限\",\"code\":0,\"msg\":\"\",\"count\":0,\"data\":[],"; }else{ $zb_type=get_set("zb_type"); $is_brand=get_set("is_brand"); $zb_type=$zb_type?$zb_type:"je"; $arr_zb_type=explode(",",$zb_type); $json_data.="\"uid\":".$uid.","; switch($_a){ case "checkzk": $tmp=""; $q="select id,username,title from ".$table_pre."client where face='3' or face='4'"; $r=$db->query($q); $i=0; $content="以下客户未设置折扣:
"; while($m=$db->fetch_array($r)){ $m1=get_db_msg("select count(*) 'num' from ".$table_pre."zk where cid='".$m["id"]."'"); if($m1["num"]<=0){ $tmp.="{\"client\":\"".$m["username"]."\",\"v\":\"".$m["title"]."(".$m["username"].")\"},"; $i++; } } if($i>0){ $str.="{\"cate\":\"以下客户未设置折扣:\",\"data\":[".deel_end($tmp)."]},"; } if(!$str){ $str.="{\"cate\":\"无误\",\"data\":[]},"; } $json_data.="\"error\":[".deel_end($str)."],"; break; case "getzNodes": if($id){ $msg=get_db_msg("select * from ".$table_pre."client where id='".$id."'"); $qyjl_confirm=(trim($msg["qyjl_confirm"])=="n")?"n":"y"; $qyjl_order=trim($msg["qyjl_order"])?trim($msg["qyjl_order"]):"n"; $qyjl_mod_dp=(trim($msg["rfid"])=="y")?"y":"n"; $path=$msg["path"]; $arr_charge_uid=explode(",",$msg["charge_uid"]); $arr_charge_path=explode(",",$msg["charge_path"]); } //取得树数据 $data_tree=""; $q="select * from ".$table_pre."client where face=3 or face=4 or face=9"; $r=$db->query($q); while($m=$db->fetch_array($r)){ if(in_array($m["path"]."-".$m["id"],$arr_charge_path)) $tmp_check="true"; else $tmp_check="false"; $data_tree.="{\"id\":\"".$m["id"]."\",\"abspath\":\"".$m["path"]."-".$m["id"]."\", \"pId\":\"".get_parent_id($m["path"])."\", \"name\":\"".$m["title"]."(".$m["username"].")"."\", \"checked\":\"".$tmp_check."\",\"open\":\"false\"},"; } if($data_tree) $data_tree=substr($data_tree,0,-1); $notes="{\"title\":\"".$msg["title"]."(".$msg["username"].")\",\"qyjl_confirm\":\"".$qyjl_confirm."\",\"qyjl_order\":\"".$qyjl_order."\",\"qyjl_mod_dp\":\"".$qyjl_mod_dp."\",\"str_path\":\"".$msg["charge_path"]."\",\"str_path_real\":\"".$msg["charge_path_real"]."\",\"data\":[".$data_tree."]}"; echo $notes; exit; break; case "save_set_priv_2": $arr_path=explode(",",$str_path); //----------------计算str_uid $str_uid=""; for($i=0;$i"; } //去掉多余 $arr_charge_path_real1=array(); for($i=0;$i"; $db->query($q); $json_data.="\"code\":1,"; break; case "add": $add_date=date("Y-m-d H:i:s"); $arr_client_brand=array(); if($id){ $msg=get_db_msg("select * from ".$table_pre."client where id='".$id."'"); $add_date=date("Y-m-d H:i:s",$msg["add_date"]); $path=$msg["path"]; $pre_id=get_parent_id($msg['path']); $pre_title=get_db_msg("select deep,title from ".$table_pre."client where id='".$pre_id."'"); $path_t=indent($pre_title["deep"]).$pre_title['title']; $face=$msg["face"]; if($is_brand=="y"){ //启用了多品牌 $q="select * from ".$table_pre."client_brand where cid='".$msg["id"]."'"; $r=$db->query($q); while($m=$db->fetch_array($r)){ $arr_client_brand[]=$m["brand"]; } } }else{ $face=4; $path_t=($path_t?$path_t:'总部'); $path=$path?$path:0; if($is_brand=="y"){ //默认选择所有品牌 $q="select * from ".$table_pre."keyword where cate='brand' order by ord"; $r=$db->query($q); $op=""; while($m=$db->fetch_array($r)){ $arr_client_brand[]=$m["no"]; } } } //是否启用 $select_available=""; if(is_array($arr_yn)){ foreach($arr_yn as $k=>$v){ $select_available.="{\"op_k\":\"".$k."\",\"op_v\":\"".$v."\"},"; } } if($select_available) $select_available=substr($select_available,0,-1); $json_data.="\"select_available\":[".$select_available."],"; $json_data.="\"available\":\"".$msg["available"]."\","; //是否禁言 $select_jy=""; if(is_array($arr_yn)){ foreach($arr_yn as $k=>$v){ $select_jy.="{\"op_k\":\"".$k."\",\"op_v\":\"".$v."\"},"; } } if($select_jy) $select_jy=substr($select_jy,0,-1); $json_data.="\"select_jy\":[".$select_jy."],"; $json_data.="\"is_jy\":\"".$msg["is_jy"]."\","; //参与排行 $select_in_ph=""; if(is_array($arr_yn)){ foreach($arr_yn as $k=>$v){ $select_in_ph.="{\"op_k\":\"".$k."\",\"op_v\":\"".$v."\"},"; } } if($select_in_ph) $select_in_ph=substr($select_in_ph,0,-1); $json_data.="\"select_in_ph\":[".$select_in_ph."],"; $json_data.="\"in_ph\":\"".$msg["in_ph"]."\","; //登陆角色 $select_face=""; if(is_array($arr_client_face)){ foreach($arr_client_face as $k=>$v){ $select_face.="{\"op_k\":\"".$k."\",\"op_v\":\"".$v."\"},"; } } if($select_face) $select_face=substr($select_face,0,-1); $json_data.="\"select_face\":[".$select_face."],"; $json_data.="\"face\":\"".$face."\","; //是否确认 $select_is_checked=""; if(is_array($arr_yn)){ foreach($arr_yn as $k=>$v){ $select_is_checked.="{\"op_k\":\"".$k."\",\"op_v\":\"".$v."\"},"; } } if($select_is_checked) $select_is_checked=substr($select_is_checked,0,-1); $json_data.="\"select_is_checked\":[".$select_is_checked."],"; $json_data.="\"is_checked\":\"".$msg["is_checked"]."\","; if($msg["face"]=="4"){ $json_data.="\"is_checked_show\":\"y\","; }else{ $json_data.="\"is_checked_show\":\"n\","; } //多品牌 if($is_brand=="y"){ $str_brand=""; //启用了多品牌 $q="select * from ".$table_pre."keyword where cate='brand' order by ord"; $r=$db->query($q); $op=""; while($m=$db->fetch_array($r)){ if(in_array($m["no"],$arr_client_brand)){ $op_check="y"; }else{ $op_check="n"; } $str_brand.="{\"brand\":\"".$m["no"]."\",\"title\":\"".$m["title"]."\",\"is_check\":\"".$op_check."\"},"; } if($str_brand) $str_brand=substr($str_brand,0,-1); $json_data.="\"select_brand\":[".$str_brand."],"; $json_data.="\"is_brand\":\"y\","; }else{ $json_data.="\"is_brand\":\"n\","; } //吊牌价类型 if($is_multi_price=="y"){ $json_data.="\"is_dp_price\":\"y\","; $select_dp_price=""; if(is_array($sys_multi_price)){ foreach($sys_multi_price as $k=>$v){ $select_dp_price.="{\"op_k\":\"".$k."\",\"op_v\":\"".$v."\"},"; } } if($select_dp_price) $select_dp_price=substr($select_dp_price,0,-1); $json_data.="\"select_dp_price\":[".$select_dp_price."],"; $json_data.="\"dp_price\":\"".$msg["dp_price"]."\","; }else{ $json_data.="\"is_dp_price\":\"n\","; } //订货指标 $zb_info=""; if(in_array("je",$arr_zb_type)) $zb_info.="{\"sign\":\"je\",\"key1\":\"zb\",\"val1\":\"".deel_num($msg["zb"])."\"},"; if(in_array("js",$arr_zb_type)) $zb_info.="{\"sign\":\"js\",\"key1\":\"zb_js\",\"val1\":\"".deel_num($msg["zb_js"])."\"},"; if(in_array("ks",$arr_zb_type)) $zb_info.="{\"sign\":\"ks\",\"key1\":\"zb_ks\",\"val1\":\"".deel_num($msg["zb_ks"])."\"},"; if(in_array("kss",$arr_zb_type)) $zb_info.="{\"sign\":\"kss\",\"key1\":\"zb_kss\",\"val1\":\"".deel_num($msg["zb_kss"])."\"},"; if($zb_info) $zb_info=substr($zb_info,0,-1); $json_data.="\"dhzb\":[".$zb_info."],"; //特殊字段 if(is_array($sys_client_zd)){ $str_zdall=""; foreach($sys_client_zd as $k1 => $v1){ $str_zdall.="{\"key\":\"".$k1."\",\"val\":\"".$msg[$k1]."\",\"title\":\"".$v1."\"},"; } if($str_zdall) $str_zdall=substr($str_zdall,0,-1); $json_data.="\"zdall\":[".$str_zdall."],"; } //上级路径 $json_data.="\"path_t\":\"".$path_t."\","; $json_data.="\"path\":\"".$path."\","; $json_data.="\"add_date\":\"".$add_date."\","; $json_data.="\"title\":\"".$msg["title"]."\","; $json_data.="\"username\":\"".$msg["username"]."\","; $json_data.="\"dpsx\":\"".$msg["dpsx"]."\","; $json_data.="\"dj\":\"".$msg["dj"]."\","; $json_data.="\"rfid\":\"".$msg["rfid"]."\","; $json_data.="\"password\":\"".$msg["password"]."\","; $json_data.="\"password_confirm\":\"".$msg["password"]."\","; $json_data.="\"thisid\":\"".$msg["id"]."\","; $json_data.="\"zk\":\"".$msg["zk"]."\","; $json_data.="\"zk_type\":\"".$zk_type."\","; break; case "save_add": //验证 $errormsg=""; $c=get_db_msg("select count(*) 'num' from ".$table_pre."client where username='".$username."' and id<>'".$id."'"); if($c["num"]>0){ $errormsg="该客户代码已经存在,请重新输入一个!"; } if(!$password || !$password_confirm){ $errormsg="请输入密码!"; } if($password!=$password_confirm){ $errormsg="2次输入的密码不一致!"; } $zk=$zk>0?$zk:1; if($errormsg){ $json_data.="\"code\":0,\"msg\":\"".$errormsg."\","; }else{ $deep=get_deep($path); $add_date=day_to_time($add_date); if($id){ $msg=get_db_msg("select * from ".$table_pre."client where id='".$id."'"); $old_path=$msg["path"]."-".$msg["id"]; $new_path=$path."-".$msg["id"]; // $log_action="修改"; if($msg["face"]=="4") $up_is_checked="is_checked='".$is_checked."',"; $up_password="password='".$password."',"; $up_zd=""; if(is_array($sys_client_zd)){ foreach($sys_client_zd as $k1 => $v1){ $up_zd.=$k1."='".mysql_escape_string($$k1)."',"; } } $query="update ".$table_pre."client set path='".$path."',deep='".$deep."',".$sql_charge_path."face='".$face."',title='".$title."',username='".$username."',dp_price='".$dp_price."',dj='".$dj."',dpsx='".$dpsx."',available='".$available."',in_ph='".$in_ph."',zb='".$zb."',zk='".$zk."',zb_js='".$zb_js."',zb_ks='".$zb_ks."',zb_kss='".$zb_kss."',".$up_password.$up_is_checked.$up_zd."rfid='".$rfid."',add_date='".$add_date."',is_jy='".$is_jy."' where id='".$id."'"; $db->query($query); $lid=$id; if($old_path!=$new_path){ //设置订单表 $arr_p1=explode("-",$path); $db->query("update ".$table_pre."order set upath='".$path."-".$id."',dl='".$arr_p1[2]."',qy='".$arr_p1[1]."' where uid='".$id."' and _key='".$_key."'"); //设置下级路径 $q1="select * from ".$table_pre."client where path='".$old_path."' or path like '".$old_path."-%'"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ $pp=str_replace("qq".$old_path,$new_path,"qq".$m1["path"]); $q2="update ".$table_pre."client set path='".$pp."' where id='".$m1["id"]."'"; //echo $q2."
"; $db->query($q2); //设置下级路径订单表 $pp1=$pp."-".$m1["id"]; $arr_p1=explode("-",$pp); $db->query("update ".$table_pre."order set upath='".$pp1."',dl='".$arr_p1[2]."',qy='".$arr_p1[1]."' where uid='".$m1["id"]."' and _key='".$_key."'"); } } if($zk_type=="client"){ $old_zk=deel_num($msg["zk"]); if($old_zk!=$zk){ //---------------------修改了折扣,修改缓存数据 if($msg["face"]=="4"){ //缓存订单表 $q1="select uid,iid,color,bx from ".$table_pre."order where _key='".$_key."' and uid='".$id."'"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ cache_order($m1["uid"],$m1["iid"],$m1["color"],$m1["bx"]); } set_order_total($id);//缓存客户表 }else if($msg["face"]=="3"){ //修改订单表代理结算金额 $q1="select uid,iid,color,bx from ".$table_pre."order where _key='".$_key."' and dl='".$id."'"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ cache_order($m1["uid"],$m1["iid"],$m1["color"],$m1["bx"]); } set_order_total($id);//缓存客户表 } $db->query($q1); } } }else{ $log_action="新增"; $tmp=get_db_msg("select max(ord) 'num' from ".$table_pre."client where path='".$path."'"); if($tmp[num]>0) $ord=$tmp[num]+1; else $ord=1; $query="insert ".$table_pre."client (ord,path,deep,face,title,username,dp_price,dj,dpsx,zk,zb,zb_js,zb_ks,zb_kss,available,in_ph,password,rfid,add_date,lastactivity,zd1,zd2,zd3,zd4,zd5,is_jy) values ('".$ord."','".$path."','".$deep."','".$face."','".$title."','".$username."','".$dp_price."','".$dj."','".$dpsx."','".$zk."','".$zb."','".$zb_js."','".$zb_ks."','".$zb_kss."','".$available."','".$in_ph."','".$password."','".$rfid."','".$add_date."','".time()."','".mysql_escape_string($zd1)."','".mysql_escape_string($zd2)."','".mysql_escape_string($zd3)."','".mysql_escape_string($zd4)."','".mysql_escape_string($zd5)."','".$is_jy."')"; $db->query($query); $lid=$db->insert_id(); //设置默认权限 $m1=get_db_msg("select * from ".$table_pre."client where id='".$lid."'"); $db->query("update ".$table_pre."client set charge_path='".$m1["path"]."-".$m1["id"]."' where id='".$lid."'"); //自动设置区经权限 $q1="select id from ".$table_pre."client where face='2' and concat(',',charge_path_real,',') like '%,".$path.",%'"; //echo $q1.""; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ add_qj_priv_by_dp($m1["id"],$lid); } } //保存多品牌信息 if($is_brand=="y"){ $m_client=get_db_msg("select id,face from ".$table_pre."client where id='".$lid."'"); if($m_client["face"]=="4" || $m_client["face"]=="3" || $m_client["face"]=="9"){//只有店铺、代理、区域才会有品牌权限 //取得原始品牌权限 $old_client_brand=array(); $q="select brand from ".$table_pre."client_brand where cid='".$m_client["id"]."'"; $r=$db->query($q); while($m=$db->fetch_array($r)){ $old_client_brand[]=$m["brand"]; } for($i=0;$iquery($q); } } for($i=0;$iquery($q); } } } } set_log($log_action."客户端",$title."|".$lid); $json_data.="\"code\":1,"; } break; case "cancel_jd": $msg=get_db_msg("select * from ".$table_pre."client where id='".$id."'"); //取消交单 $db->query("update ".$table_pre."client set is_jd='n',is_checked='n' where id='".$id."'"); update_order_state($uid,$id,"后台退回订单",""); set_log("后台退回订单",$msg["title"]."(".$msg["username"].")"); $json_data.="\"code\":1,"; break; //----------------------------------------------------------------------导入EXCEL case "import": //目录权限 $arr_path=array( "cache"=>"admin/cache" ); $json_data.="\"path_priv\":["; $tmp=""; foreach($arr_path as $path_real => $path_title){ $tmp.="{\"title\":\"".$path_title."\",\"priv\":"; if(new_is_writeable($path_real)==1){ $tmp.="\"y\""; }else{ $tmp.="\"n\""; } $tmp.="},"; } $json_data.=substr($tmp,0,-1)."],"; break; case "import_check": $file1=$_FILES["up_file"]; //echo $file1["name"]."--"; $tmp_file_name=save_tmp_file($file1); $tmp_content=get_tmp_content($tmp_file_name); $arr_content=explode("\n",$tmp_content); $arr_thead=get_table_thead($tmp_content); $arr_column=check_table_thead($arr_thead,$arr_column_client); $msg=""; if(count($arr_column[0])==0){ $msg.="未检测到可导入字段,请返回检查EXCEL文件!"; del_tmp_file($tmp_file_name); $json_data.="\"code\":0,\"msg\":\"".$msg."\","; }else{ // $column=""; foreach($arr_column_client as $k => $v){ $column.=$v.","; } if($column) $column=substr($column,0,-1); $msg1=array(); $msg1[0]=array("可导入正确字段",$column); // $column=""; for($i=0;$i".$arr_thead[$i].","; } if($column) $column=substr($column,0,-1); // $msg1[1]=array("检测到的有效字段",$column); // $total=count($arr_content)-1; $msg1[2]=array("记录条数",$total); $m1=""; for($i=0;$i0){ $sign="n"; }else{ $db->query("TRUNCATE TABLE ".$table_pre."client;"); $db->query("TRUNCATE TABLE ".$table_pre."order_state;"); } } if($sign=='y'){ //-------------------------------------------导入数据 $tmp_content=get_tmp_content($tmp_file_name); $arr_content=explode("\n",$tmp_content); $arr_thead=get_table_thead($tmp_content); $arr_column=check_table_thead($arr_thead,$arr_column_client); $insert_column=""; for($i=0;$i $v1){ if($v1>1) $repeat_str.=$k1.","; } if($repeat_str){ $repeat_str=substr($repeat_str,0,-1); $json_data.="\"code\":0,\"msg\":\"用户代码有重复,请检查(".$repeat_str.")!\",\"reload_type\":\"1\","; }else{ $json_data.="\"code\":1,\"reload_type\":\"1\","; for($i=1;$i0)?$tmp_arr[$ind]:1; $insert_value.="'".mysql_escape_string($zk)."',"; }else{ $insert_value.="'".mysql_escape_string(trim($tmp_arr[$ind]))."',"; } } $insert_value=substr($insert_value,0,-1); $q="insert into ".$table_pre."client (".$insert_column.",add_date,lastactivity) values (".$insert_value.",'".time()."',2)"; $db->query($q); } //处理path $r=$db->query("select * from ".$table_pre."client where lastactivity=2"); $i=1; while($m=$db->fetch_array($r)){ if($m["path"]){ $m1=get_db_msg("select * from ".$table_pre."client where username='".$m["path"]."'"); //echo "--".$m1["path"]."--
"; if($m1["path"]){ if($m1["lastactivity"]==1){ $q1="update ".$table_pre."client set path='".$m1["path"]."-".$m1["id"]."',deep='".($m1["deep"]+1)."',lastactivity=1 where id='".$m["id"]."'"; }else{ $m2=get_db_msg("select * from ".$table_pre."client where username='".$m1["path"]."'"); if($m2["path"]){ if($m2["lastactivity"]==1){ $q1="update ".$table_pre."client set path='".$m2["path"]."-".$m2["id"]."-".$m1["id"]."',deep='3',lastactivity=1 where id='".$m["id"]."'"; }else{ $m3=get_db_msg("select * from ".$table_pre."client where username='".$m2["path"]."'"); if($m3["path"]){ if($m3["lastactivity"]==1){ $q1="update ".$table_pre."client set path='".$m3["path"]."-".$m3["id"]."-".$m2["id"]."-".$m1["id"]."',deep='4',lastactivity=1 where id='".$m["id"]."'"; }else{ $q1="update ".$table_pre."client set path='0-".$m3["id"]."-".$m2["id"]."-".$m1["id"]."',deep=4,lastactivity=1 where id='".$m["id"]."'"; } }else{ $q1="update ".$table_pre."client set path='0-".$m3["id"]."-".$m2["id"]."-".$m1["id"]."',deep=4,lastactivity=1 where id='".$m["id"]."'"; } } }else{ $q1="update ".$table_pre."client set path='0-".$m2["id"]."-".$m1["id"]."',deep=3,lastactivity=1 where id='".$m["id"]."'"; } } }else{ $q1="update ".$table_pre."client set path='0-".$m1["id"]."',deep=2,lastactivity=1 where id='".$m["id"]."'"; } }else{ $q1="update ".$table_pre."client set path='0',deep=1,lastactivity=1 where id='".$m["id"]."'"; } //echo $i.".".$q1."
"; $db->query($q1); $i++; } //处理ord $q="select * from ".$table_pre."client where deep=1 order by ord"; $r=$db->query($q); $i1=1; while($m=$db->fetch_array($r)){ $db->query("update ".$table_pre."client set ord='".$i1."' where id='".$m["id"]."'"); $q1="select * from ".$table_pre."client where available='y' and path='".$m["path"]."-".$m["id"]."' order by ord"; $r1=$db->query($q1); $i2=1; while($m1=$db->fetch_array($r1)){ $db->query("update ".$table_pre."client set ord='".$i2."' where id='".$m1["id"]."'"); $q2="select * from ".$table_pre."client where available='y' and path='".$m1["path"]."-".$m1["id"]."' order by ord"; $r2=$db->query($q2); $i3=1; while($m2=$db->fetch_array($r2)){ $db->query("update ".$table_pre."client set ord='".$i3."' where id='".$m2["id"]."'"); $q3="select * from ".$table_pre."client where available='y' and path='".$m2["path"]."-".$m2["id"]."' order by ord"; $r3=$db->query($q3); $i4=1; while($m3=$db->fetch_array($r3)){ $db->query("update ".$table_pre."client set ord='".$i4."' where id='".$m3["id"]."'"); $i4++; } $i3++; } $i2++; } $i1++; } del_tmp_file($tmp_file_name); $log_remark=$import_flag; $db->query("update ".$table_pre."client set lastactivity='".time()."' where lastactivity=1"); $db->query("update ".$table_pre."client set lastactivity='".time()."' where lastactivity=2"); set_log("导入 客户数据",$log_remark); } }else{ $json_data.="\"code\":0,\"msg\":\"对不起,已经有订单,不允许清空导入操作!\",\"reload_type\":\"1\","; } break; //----------------------------------------------------------------------导出数据 case "export": $column=""; foreach($arr_column_client as $k => $v){ $column.="{\"k\":\"".$k."\",\"t\":\"".$v."\"},"; } if($column) $column=substr($column,0,-1); $json_data.="\"col\":[".$column."],"; break; case "export_do": //取得字段选择的值 foreach($arr_column_client as $k => $v){ $var="col_".$k; if($$var=="on"){ $ex_col[]=$k; } } $num=count($ex_col); if($num==0) alert_and_back("请至少选择一个要导出的字段"); for($i=0;$i<$num;$i++){ $data["col"][]='str'; $data["header"][0][]=get_main_value($arr_column_client,$ex_col[$i]); } $query="select * from ".$table_pre."client order by path,ord"; $r=$db->query($query); $row=0; while($m=$db->fetch_array($r)){ for($i=0;$i<$num;$i++){ $k=$ex_col[$i]; if($k=="available"){ $data["body"][$row][]=get_main_value($arr_yn,$m[$k]); }else if($k=="face"){ $data["body"][$row][]=get_main_value($arr_client_face,$m[$k]); }else if($k=="dp_price"){ $data["body"][$row][]=get_main_value($sys_multi_price,$m[$k]); }else if($k=="path"){ $tmp=get_db_msg("select * from ".$table_pre."client where id='".get_parent_id($m["path"])."'"); $data["body"][$row][]=$tmp["username"]; }else if($k=="dj" || $k=="dpsx"){ if($m["face"]=="4") $data["body"][$row][]=$m[$k]; else $data["body"][$row][]=""; }else{ $data["body"][$row][]=$m[$k]; } } $row++; } $file_name="client_".date("Y-m-d-H-i"); output_excel($file_name,$data); set_log("导出 客户信息"); exit; break; case "del": $id=(is_array($id))?$id:array($id); $num=count($id); //检查是否有订单 $error=""; for($i=0;$i<$num;$i++){ $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."order where uid='".$id[$i]."' and _key='".$_key."'"); if($tmp["num"]>0){ $tmp=get_db_msg("select username,title from ".$table_pre."client where id='".$id[$i]."'"); $error.=$tmp["title"]."(".$tmp["username"]."),"; } } if($error){ $json_data.="\"code\":0,\"msg\":\"以下客户有订单,请先删除订单:".substr($error,0,-1)."\""; }else{ for($i=0;$i<$num;$i++){ $tmp=get_db_msg("select * from ".$table_pre."client where id='".$id[$i]."'"); $lid.=$tmp["username"]."|".$id[$i].", "; $db->query("delete from ".$table_pre."client where id='".$id[$i]."'"); } $lid=substr($lid,0,-2); set_log("删除客户端",$lid); $json_data.="\"code\":1,"; } break; // case "available": $id=(is_array($id))?$id:array($id); $num=count($id); for($i=0;$i<$num;$i++){ $q="update ".$table_pre."client set available='y' where id='".$id[$i]."'"; $db->query($q); } $json_data.="\"code\":1,"; break; case "dis_available": $id=(is_array($id))?$id:array($id); $num=count($id); for($i=0;$i<$num;$i++){ $q="update ".$table_pre."client set available='n' where id='".$id[$i]."'"; $db->query($q); } $json_data.="\"code\":1,"; break; //二维码 case "ewm": $size=$size?$size:4; $s_path_t=$s_path_t?$s_path_t:"-所有路径-"; $s_path=$s_path?$s_path:""; if($s_path_t=="-所有路径-") $s_path=""; $json_data.="\"s_path\":\"".$s_path."\","; $json_data.="\"s_path_t\":\"".$s_path_t."\","; $json_data.="\"s_title\":\"".$s_title."\","; $json_data.="\"s_username\":\"".$s_username."\","; // $tmp_face=""; foreach($arr_client_face as $k => $v){ $tmp_face.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},"; } $tmp_face=deel_end($tmp_face); $json_data.="\"select_face\":{\"no\":\"s_face\",\"title\":\"登入角色\",\"value\":\"".$s_face."\",\"op\":[".$tmp_face."]},"; $arr_ewm_size=array("1"=>"1","2"=>"2","3"=>"3","4"=>"4","5"=>"5","6"=>"6","7"=>"7","8"=>"8","9"=>"9","10"=>"10"); $tmp_ewmcc=""; foreach($arr_ewm_size as $k1 => $v1){ $tmp_ewmcc.="{\"no\":\"".$k1."\",\"title\":\"".$v1."\"},"; } $tmp_ewmcc=deel_end($tmp_ewmcc); $json_data.="\"select_ewmcc\":{\"no\":\"size\",\"title\":\"图片尺寸\",\"value\":\"".$size."\",\"op\":[".$tmp_ewmcc."]},"; $sql_con=""; if($s_title || $s_username || $s_face || $s_path){ if($s_title) $sql_con.="title like '%".$s_title."%' and "; if($s_username) $sql_con.="username like '%".$s_username."%' and "; if($s_path) $sql_con.="(path like '".$s_path."-%' or path='".$s_path."') and "; if($s_face) $sql_con.="face='".$s_face."' and "; } if($sql_con) $sql_con="where ".substr($sql_con,0,-4); $json_data.="\"code\":0,\"msg\":\"\",\"data\":["; $str_tmp=""; $q="select * from ".$table_pre."client ".$sql_con." order by add_date desc"; $r=$db->query($q); $i=1; while($m=$db->fetch_array($r)){ $data=$m["username"].",".$m["password"]; $str_tmp.="{"; $str_tmp.="\"list\":\"".$i."\","; $str_tmp.="\"content1\":\"".$data."\","; $str_tmp.="\"title\":\"".$m["title"]."(".$m["username"].")\""; $str_tmp.="},"; $i++; } $json_data.=substr($str_tmp,0,-1)."],"; break; //-------------主界面 default: $s_path_t=$s_path_t?$s_path_t:"-所有路径-"; $s_path=$s_path?$s_path:""; if($s_path_t=="-所有路径-") $s_path=""; $json_data.="\"s_path\":\"".$s_path."\","; $json_data.="\"s_path_t\":\"".$s_path_t."\","; $json_data.="\"s_keyword\":\"".$s_keyword."\","; $json_data.="\"s_available\":\"".$s_available."\","; $json_data.="\"s_in_ph\":\"".$s_in_ph."\","; $json_data.="\"s_is_checked\":\"".$s_is_checked."\","; //是否有折扣 $is_zk="n"; if($zk_type){ $is_zk="y"; } $json_data.="\"is_zk\":\"".$is_zk."\","; $json_data.="\"zk_type\":\"".$zk_type."\","; $json_data.="\"lang_keyword\":\"关键字\","; $tmp_face=""; foreach($arr_client_face as $k => $v){ $tmp_face.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},"; } $tmp_face=deel_end($tmp_face); $json_data.="\"select_face\":{\"no\":\"s_face\",\"title\":\"登入角色\",\"value\":\"".$s_face."\",\"op\":[".$tmp_face."]},"; //属性 $tmp_dpsx=""; $q_1="select dpsx from ".$table_pre."client where dpsx<>'' group by dpsx order by dpsx"; $r_1=$db->query($q_1); $i=0; while($m_1=$db->fetch_array($r_1)){ $tmp_dpsx.="{\"no\":\"".$m_1["dpsx"]."\",\"title\":\"".$m_1["dpsx"]."\"},"; $i++; } $tmp_dpsx=deel_end($tmp_dpsx); $json_data.="\"select_dpsx\":{\"no\":\"s_dpsx\",\"title\":\"店铺属性\",\"value\":\"".$s_dpsx."\",\"op\":[".$tmp_dpsx."]},"; if($i>0){ $json_data.="\"show_dpsx\":\"y\","; }else{ $json_data.="\"show_dpsx\":\"n\","; } //等级 $tmp_dj=""; $q_2="select dj from ".$table_pre."client where dj<>'' group by dj order by dj"; $r_2=$db->query($q_2); $i=0; while($m_2=$db->fetch_array($r_2)){ $tmp_dj.="{\"no\":\"".$m_2["dj"]."\",\"title\":\"".$m_2["dj"]."\"},"; $i++; } $tmp_dj=deel_end($tmp_dj); $json_data.="\"select_dj\":{\"no\":\"s_dj\",\"title\":\"等级\",\"value\":\"".$s_dj."\",\"op\":[".$tmp_dj."]},"; if($i>0){ $json_data.="\"show_dj\":\"y\","; }else{ $json_data.="\"show_dj\":\"n\","; } // $page=$page>0?$page:1; $limit=$limit>0?$limit:10; $start=($page-1)*$limit; $end=$limit; $sql_con=""; if($s_keyword || $s_dj || $s_dpsx || $s_face || $s_available || $s_in_ph || $s_is_checked || $s_path){ if($s_keyword) $sql_con.="(title like '%".$s_keyword."%' or username like '%".$s_keyword."%') and "; if($s_dj) $sql_con.="dj='".$s_dj."' and "; if($s_dpsx) $sql_con.="dpsx='".$s_dpsx."' and "; if($s_path){ if($s_path=="0-") $sql_con.="(path='0') and "; else $sql_con.="(path like '".$s_path."-%' or path='".$s_path."') and "; } if($s_available) $sql_con.="available='".$s_available."' and "; if($s_in_ph) $sql_con.="in_ph='".$s_in_ph."' and "; if($s_is_checked) $sql_con.="is_checked='".$s_is_checked."' and "; if($s_face) $sql_con.="face='".$s_face."' and "; } if($sql_con) $sql_con="where ".substr($sql_con,0,-4); //取得总条数 $tmp=get_db_msg("select count(*) 'num' from web_client ".$sql_con); $total_num=$tmp["num"]; $json_data.="\"code\":0,\"msg\":\"\",\"count\":".$total_num.",\"data\":["; $count=0; $str_tmp=""; $sql="select * from web_client ".$sql_con." order by id limit ".$start.",".$end; $res=$db->query($sql); while($msg=$db->fetch_array($res)){ $client_title=""; $str_tmp.="{"; $str_tmp.="\"id\":\"".$msg["id"]."\","; $str_tmp.="\"faceid\":\"".$msg["face"]."\","; $str_tmp.="\"face\":\"".$arr_client_face[$msg["face"]]."\","; $str_tmp.="\"dpsx\":\"".$msg["dpsx"]."\","; $str_tmp.="\"dj\":\"".$msg["dj"]."\","; //限制 $str_tmp.="\"is_checked\":\"".$msg["is_checked"]."\","; $str_tmp.="\"is_jd\":\"".$msg["is_jd"]."\","; $str_tmp.="\"available\":\"".$msg["available"]."\","; $tmpzk=get_db_msg("select count(*) 'num' from ".$table_pre."zk where cid='".$msg["id"]."'"); $str_tmp.="\"is_zknum\":\"".$tmpzk["num"]."\","; $str_tmp.="\"is_zk\":\"".$is_zk."\","; $str_tmp.="\"is_jy\":\"".$msg["is_jy"]."\","; $str_tmp.="\"zk_type\":\"".$zk_type."\","; $str_tmp.="\"zk\":\"".$msg["zk"]."\","; $p=get_path_title($msg["path"],"-","web_client"); if($p) $p=$p."-"; $client_title.=$p.$msg["title"]."(".$msg["username"].")"; $str_tmp.="\"title\":\"".$client_title."\","; $str_tmp.="\"usertitle\":\"".$msg["username"]."\","; $str_tmp.="\"zb_type\":\"".$zb_type."\","; if($zb_type=="js"){ $str_tmp."\"zb_type\":\"js\","; $str_tmp.="\"zb_js\":\"".$msg["zb_js"]."\""; }else if($zb_type=="je"){ $str_tmp."\"zb_type\":\"je\","; $str_tmp.="\"zb\":\"".deel_num($msg["zb"])."\""; }else{ $str_tmp."\"zb_type\":\"js,je\","; $str_tmp.="\"zb_js\":\"".$msg["zb_js"]."\","; $str_tmp.="\"zb\":\"".deel_num($msg["zb"])."\""; } $str_tmp.="},"; $count++; } $json_data.=substr($str_tmp,0,-1)."],"; break; } } $json_data=substr($json_data,0,-1)."}"; echo $json_data; ?>