0?$tid:0;//$tid来自于浏览器URL$tid //取得当前展示号 $tmp=get_db_msg("select zsh from ".$table_pre."kh_tb where tid='".$tid."' and is_show='y' order by zsh"); if($tmp["zsh"]>0){ $dq_zsh=$tmp['zsh']; //大于当前展示号的顺延 $db->query("update ".$table_pre."kh_tb set zsh=zsh+1 where zsh>'".$dq_zsh."' and tid='".$tid."'"); }else{ $tmp=get_db_msg("select MAX(zsh) 'zsh' from ".$table_pre."kh_tb where tid='".$tid."'"); $dq_zsh=$tmp['zsh']?$tmp['zsh']:0; } // $ord=1; if($s_zsh){ $tmp_dph=get_db_msg("select * from web_kh_dp where zsh='".$s_zsh."' limit 0,1"); $s_dir=$order_session?$order_session."/":""; $pic="dp/".$s_dir."big/".$tmp_dph["pic"].".jpg"; $sql="insert into ".$table_pre."kh_tb (tid,zsh,pic,iid,color,ord,is_show) values "; foreach($arr_khno as $khno){ $arr_tmp=explode("|",$khno); $sql.="(".$tid.",".($dq_zsh+1).",'".$pic."',".$arr_tmp[0].",'".$arr_tmp[1]."',".$ord++.",'y'),"; } }else{ $sql="insert into ".$table_pre."kh_tb (tid,zsh,iid,color,ord,is_show) values "; foreach($arr_khno as $khno){ $arr_tmp=explode("|",$khno); $sql.="(".$tid.",".($dq_zsh+1).",".$arr_tmp[0].",'".$arr_tmp[1]."',".$ord++.",'y'),"; } } $sql=substr($sql,0,-1).";"; $json_data.="\"q\":\"".$sql."\","; $db->query($sql); if($tid>0){ $db->query("update ".$table_pre."kh_tb set is_show='n' where zsh<>'".($dq_zsh+1)."' and tid='".$tid."'"); }else{ $db->query("update ".$table_pre."kh_tb set is_show='n' where zsh<>'".($dq_zsh+1)."'"); } $str="y"; $json_data.="\"code\":101,"; break; case "tb_search": $w2=$tmpl_m5_pic_width; $h2=$tmpl_m5_pic_height; $arr_ksh=explode(",",$wanted_kh); //默认展厅后新添加自定义推送的单款 $sql="select * from ".$table_pre."kh where no='".$arr_ksh[0]."'"; $str=""; $str_dk=""; $msg=get_db_msg($sql); if($msg['id']>0){ if($msg["ka"]=="y"){ $c=$ka_color; }else{ $c=get_set_value_dote($style_title_color,$msg["kh_dj"]); } //取得搜索结果的款号图片 if($arr_ksh[1]){ $pic=get_kh_color_picture($msg["no"],$arr_ksh[1]); }else{ $pic=get_kh_picture($msg["no"],$msg["main_pic"],$msg["color"],$flag_pad_offline); } //单款信息拼接 $str.=$msg["id"].",".get_kh_xh($msg).",".$msg["no"].",".$arr_ksh[1].",".$msg["price"].",".$pic.",".str_replace("\"","'",out_good_pic_set($pic,$w2,$h2)); $tmpwh=out_good_pic_set_arr($pic,$w2,$h2); $str_dk.="{\"khid\":\"".$msg["id"]."\",\"xh\":\"".get_kh_xh($msg)."\",\"kh\":\"".$msg["no"]."\",\"color\":\"".$arr_ksh[1]."\",\"colort\":\"".get_cate_title_no("color",$arr_ksh[1])."\",\"price\":\"".$msg["price"]."\",\"pic\":\"".$pic."\",\"pic_w\":".deel_num($tmpwh[0]).",\"pic_h\":".deel_num($tmpwh[1])."},"; } $str_dk=substr($str_dk,0,-1); $json_data.="\"arr_dk\":[".$str_dk."],"; //------------------------------ break; case "tb_search_dp": $w2=$tmpl_m5_pic_width; $h2=$tmpl_m5_pic_height; if($s_zsh){ $dph=$s_zsh; } $arr_ksh=explode(",",$wanted_kh); //默认展厅后新添加自定义推送的单款 $query="select * from ".$table_pre."kh_dp where zsh='".$dph."'"; //echo $query."
"; $res=$db->query($query); $str=""; $str_dp=""; $dp_pic=""; while($msg1=$db->fetch_array($res)){ $dp_pic=$msg1["pic"]; $msg=get_db_msg("select * from ".$table_pre."kh where no='".$msg1["kh"]."' "); if($msg["ka"]=="y"){ $c=$ka_color; }else{ $c=get_set_value_dote($style_title_color,$msg["kh_dj"]); } //取得搜索结果的款号图片 $pic=get_kh_color_picture($msg["no"],$msg1["color"]); //单款信息拼接 //$str.=$msg["id"].",".get_kh_xh($msg).",".$msg["no"].",".$arr_ksh[1].",".$msg["price"].",".$pic.",".str_replace("\"","'",out_good_pic_set($pic,$w2,$h2)); $tmpwh=out_good_pic_set_arr($pic,$w2,$h2); $str_dp.="{\"khid\":\"".$msg["id"]."\",\"xh\":\"".get_kh_xh($msg)."\",\"kh\":\"".$msg["no"]."\",\"color\":\"".$msg1["color"]."\",\"colort\":\"".get_cate_title_no("color",$msg1["color"])."\",\"price\":\"".$msg["price"]."\",\"pic\":\"".$pic."\",\"pic_w\":".deel_num($tmpwh[0]).",\"pic_h\":".deel_num($tmpwh[1])."},"; } $str_dp=substr($str_dp,0,-1); $json_data.="\"arr_dk\":[".$str_dp."],"; //------------------------------ break; case "tb_pre": //设置上一组同步 $tmp=get_db_msg("select zsh from ".$table_pre."kh_tb where tid='".$tid."' and is_show='y' group by zsh order by zsh desc limit 0,1"); if($tmp["zsh"]>0){ $tmp1=get_db_msg("select zsh from ".$table_pre."kh_tb where tid='".$tid."' and zsh<'".$tmp["zsh"]."' group by zsh order by zsh desc limit 0,1"); }else{ $tmp1=get_db_msg("select zsh from ".$table_pre."kh_tb where tid='".$tid."' group by zsh order by zsh limit 0,1"); } if($tmp1["zsh"]){ $db->query("update ".$table_pre."kh_tb set is_show='y' where tid='".$tid."' and zsh='".$tmp1["zsh"]."'"); $db->query("update ".$table_pre."kh_tb set is_show='n' where tid='".$tid."' and zsh<>'".$tmp1["zsh"]."' and is_show='y'"); $str="y"; $json_data.="\"code\":101,"; }else{ $str="n"; $json_data.="\"code\":0,"; } break; case "tb_next": //设置下一组同步 $tmp=get_db_msg("select zsh from ".$table_pre."kh_tb where tid='".$tid."' and is_show='y' group by zsh order by zsh desc limit 0,1"); if($tmp["zsh"]>0){ $tmp1=get_db_msg("select zsh from ".$table_pre."kh_tb where tid='".$tid."' and zsh>'".$tmp["zsh"]."' group by zsh order by zsh limit 0,1"); }else{ $tmp1=get_db_msg("select zsh from ".$table_pre."kh_tb where tid='".$tid."' group by zsh order by zsh limit 0,1"); } if($tmp1["zsh"]){ $db->query("update ".$table_pre."kh_tb set is_show='y' where tid='".$tid."' and zsh='".$tmp1["zsh"]."'"); $db->query("update ".$table_pre."kh_tb set is_show='n' where tid='".$tid."' and zsh<>'".$tmp1["zsh"]."' and is_show='y'"); $str="y"; $json_data.="\"code\":101,"; }else{ $str="n"; $json_data.="\"code\":0,"; } break; case "tb_zsh": //设置特定展示号同步 $tmp=get_db_msg("select id from ".$table_pre."kh_tb where tid='".$tid."' and zsh='".$zsh."' limit 0,1"); if($tmp["id"]>0){ $db->query("update ".$table_pre."kh_tb set is_show='y' where tid='".$tid."' and zsh='".$zsh."'"); $db->query("update ".$table_pre."kh_tb set is_show='n' where tid='".$tid."' and zsh<>'".$zsh."' and is_show='y'"); $str="y"; $json_data.="\"code\":101,"; }else{ $str="n"; $json_data.="\"code\":0,"; } break; case "del_zsh": //删除特定展示组 $tmp=get_db_msg("select id from ".$table_pre."kh_tb where tid='".$tid."' and zsh='".$zsh."' limit 0,1"); if($tmp["id"]>0){ $db->query("delete from ".$table_pre."kh_tb where tid='".$tid."' and zsh='".$zsh."'"); $str="y"; $json_data.="\"code\":101,"; }else{ $str="不存在"; $json_data.="\"code\":0,"; $json_data.="\"msg\":\"不存在\","; } break; case "kh_color" : // $sql_con=""; if($q){ $sql_con.=" and no like '%".$q."%'"; } //$json_data.="\"q\":\"".$q."\","; $query="select * from ".$table_pre."kh where id>0 ".$sql_con." order by no"; //echo $query."
"; $res=$db->query($query); $count=0; $data=array(); $str_tmp=""; $i=0; while($msg=$db->fetch_array($res)){ $color=explode(",",$msg["color"]); $colork=explode(",",$msg["color_ka"]); $str_tmp.="{\"id\":\"".$msg["id"]."\",\"no\":\"".$msg["no"]."\",\"xh\":\"".get_kh_xh($msg)."\"},"; foreach($color as $k => $v){ if(!in_array($v,$colork)){ $str_tmp.="{\"id\":\"".$msg["id"]."\",\"no\":\"".$msg["no"]."\",\"xh\":\"".get_kh_xh($msg,$v)."\",\"color\":\"".$v."\",\"colort\":\"".get_cate_title_no("color",$v)."\"},"; } } $i++; } $json_data.="\"data\":[".deel_end($str_tmp)."],"; break; case "kh_color1" : // $sql_con=""; if($q){ $sql_con.=" and xh='".$q."'"; } //$json_data.="\"q\":\"".$q."\","; $query="select * from ".$table_pre."kh where id>0 ".$sql_con." order by no"; //echo $query."
"; $res=$db->query($query); $count=0; $data=array(); $str_tmp=""; $i=0; while($msg=$db->fetch_array($res)){ $color=explode(",",$msg["color"]); $colork=explode(",",$msg["color_ka"]); $str_tmp.="{\"id\":\"".$msg["id"]."\",\"no\":\"".$msg["no"]."\",\"xh\":\"".get_kh_xh($msg)."\"},"; foreach($color as $k => $v){ if(!in_array($v,$colork)){ $str_tmp.="{\"id\":\"".$msg["id"]."\",\"no\":\"".$msg["no"]."\",\"xh\":\"".get_kh_xh($msg,$v)."\",\"color\":\"".$v."\",\"colort\":\"".get_cate_title_no("color",$v)."\"},"; } } $i++; } $json_data.="\"data\":[".deel_end($str_tmp)."],"; break; case "get_dph" : // $sql_con=""; if($q){ $sql_con.=" and zsh like '%".$q."%'"; } $query="select DISTINCT zsh,title from ".$table_pre."kh_dp where id>0 ".$sql_con." order by zsh"; //echo $query."
"; $res=$db->query($query); $count=0; $data=array(); $str_tmp=""; $i=0; while($msg=$db->fetch_array($res)){ $str_tmp.="{\"zsh\":\"".$msg["zsh"]."\",\"title\":\"".$msg["title"]."\"},"; $i++; } $json_data.="\"data\":[".deel_end($str_tmp)."],"; break; case "pj": $q1="select * from ".$table_pre."client_pj where khid='".$khid."'"; $r1=$db->query($q1); $ct1=1; while($m1=$db->fetch_array($r1)){ $client=get_db_msg("select * from web_client where id='".$m1["cid"]."'"); $tbyd.=""; $tbyd.="".$ct1.""; $tbyd.="".$client["title"].""; $tbyd.="".$m1["race"]."星"; $tbyd.="".$m1["remark"].""; $tbyd.=""; $ct1++; } $tbyd="".$tbyd."
序号客户评价星级评价内容
"; $json_data.="\"tbyd\":\"".$tbyd."\","; break; default: //----------------------------同步 $w2=$tmpl_m5_pic_width; $h2=$tmpl_m5_pic_height; if($s_tid){ $tid=$s_tid; } //取得默认展厅 $tmp=get_db_msg("select id from ".$table_pre."kh_tb_t limit 0,1"); $tid=$tid?$tid:$tmp["id"]; if($tid){ $tid_con="and tid='".$tid."'"; }else{ $tid_con=''; } $json_data.="\"tid\":\"".$tid."\","; $q1="select * from ".$table_pre."kh_tb_t "; $r1=$db->query($q1); $arr_tid=""; while($m1=$db->fetch_array($r1)){ $arr_tid.="{\"no\":\"".$m1["id"]."\",\"value\":\"".$m1["title"]."\"},"; } $arr_tid=deel_end($arr_tid); $json_data.="\"zt\":[".$arr_tid."],"; // //$m=get_db_msg("select zsh,pic from ".$table_pre."kh_tb where tid='".$tid."' and is_show='y' group by zsh order by zsh desc limit 0,1"); $m=get_db_msg("select zsh,pic from ".$table_pre."kh_tb where is_show='y' ".$tid_con." group by zsh order by zsh desc limit 0,1"); //$json_data.="\"q\":\"select zsh,pic from ".$table_pre."kh_tb where is_show='y' ".$tid_con." group by zsh order by zsh desc limit 0,1\","; if($m["zsh"]>0){ //$str=$m["zsh"]."||"; $json_data.="\"zsh\":\"".$m["zsh"]."\","; //图片 $pic1=""; if(trim($m["pic"])){ $pic1=get_picture($m["pic"],$flag_pad_offline); if(!$pic1){ $pic1="images/no_pic.png"; } //$str.=$pic1."|".str_replace("\"","'",out_good_pic_set($pic1,$tmpl_m5_cl_pic_width,$tmpl_m5_cl_pic_height)); $tmpwh=out_good_pic_set_arr($pic1,$tmpl_m5_cl_pic_width,$tmpl_m5_cl_pic_height); $json_data.="\"pic\":\"".$pic1."\","; $json_data.="\"pic_w\":".deel_num($tmpwh[0]).","; $json_data.="\"pic_h\":".deel_num($tmpwh[1]).","; } //$str.="||"; //$query="select iid from ".$table_pre."kh_tb where tid='".$tid."' and zsh='".$m["zsh"]."' order by ord"; $query="select iid,color from ".$table_pre."kh_tb where zsh='".$m["zsh"]."' ".$tid_con." order by ord"; $res=$db->query($query); $style_title_color=get_set("style_title_color"); $ka_color=get_set("ka_color"); //$str.="var arr_content=["; $str_arr_content=""; while($msg=$db->fetch_array($res)){ $m_kh=get_db_msg("select * from ".$table_pre."kh where id='".$msg["iid"]."'"); if($m_kh["ka"]=="y"){ $c=$ka_color; }else{ $c=get_set_value_dote($style_title_color,$m_kh["kh_dj"]); } if($msg["iid"]>0){ //图片获取规则 if($msg["color"]){ $pic=get_kh_color_picture($m_kh["no"],$msg["color"]); $con_color_tmp=" and color='".$msg["color"]."'"; $color_str=",".$msg["color"]; }else{ $pic=get_kh_picture($m_kh["no"],$m_kh["main_pic"],$m_kh["color"],$flag_pad_offline); $con_color_tmp=""; $color_str=""; } $n1=0; //----取得评价 $tmp=get_db_msg("select sum(race) 'num' from ".$table_pre."client_pj where khid='".$msg["iid"]."' "); $pj_num=add_0($tmp["num"]); $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."client_pj where khid='".$msg["iid"]."' "); $pj_clients=add_0($tmp["num"]); //----取得订单 $tmp=get_db_msg("select sum(num) 'num' from ".$table_pre."order where iid='".$msg["iid"]."' and _key='".$_key."'".$con_color_tmp); $order_num=add_0($tmp["num"]); $tmp=get_db_msg("select count(distinct uid) 'num' from ".$table_pre."order where iid='".$msg["iid"]."' and _key='".$_key."'".$con_color_tmp); $order_clients=add_0($tmp["num"]); // $ppf=$pj_clients>0?keep_float($pj_num/$pj_clients,1):0; //$str.="".$m_kh["id"].",\"".get_kh_xh($m_kh,$msg["color"])."\",\"".$m_kh["no"].$color_str."\",".deel_num($m_kh["price"]).",\"".$pic."\",\"".str_replace("\"","'",out_good_pic_set($pic,$w2,$h2))."\",".$n1.",\"".$c."\",\"".$order_num."|".$order_clients."|".$ppf."|".$pj_clients."\","; $tmpwh=out_good_pic_set_arr($pic,$w2,$h2); $str_arr_content.="{\"khid\":\"".$m_kh["id"]."\",\"xh\":\"".get_kh_xh($m_kh,$msg["color"])."\",\"kh\":\"".$m_kh["no"]."\",\"color\":\"".$msg["color"]."\",\"colort\":\"".get_cate_title_no("color",$msg["color"])."\",\"price\":\"".deel_num($m_kh["price"])."\",\"pic\":\"".$pic."\",\"pic_w\":".deel_num($tmpwh[0]).",\"pic_h\":".deel_num($tmpwh[1]).",\"num\":".$n1.",\"style_color\":\"".$c."\",\"order_num\":".$order_num.",\"order_clients\":\"".$order_clients."\",\"ppf\":\"".$ppf."\",\"pj_clients\":\"".$pj_clients."\"},"; } } //$str.="]||"; $str_arr_content=substr($str_arr_content,0,-1); $json_data.="\"tsz\":[".$str_arr_content."],"; }else{ //$str="0||pic||kh||"; $json_data.="\"msg\":\"暂无数据\","; } //--------------------------候选 $this_zsh=$m["zsh"]>0?$m["zsh"]:0; $arr_zsh1=array(); $q1="select zsh from ".$table_pre."kh_tb where tid='".$tid."' and zsh<".$this_zsh." group by zsh order by zsh desc limit 0,2"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ $arr_zsh1[]=$m1["zsh"]; } $arr_zsh2=array(); $q1="select zsh from ".$table_pre."kh_tb where tid='".$tid."' and zsh>".$this_zsh." group by zsh order by zsh limit 0,2"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ $arr_zsh2[]=$m1["zsh"]; } if(count($arr_zsh1)<2 && count($arr_zsh2)<2){ $query="select zsh,pic,title from ".$table_pre."kh_tb where tid='".$tid."' group by zsh order by zsh"; }else if(count($arr_zsh1)<2){ if($arr_zsh1[0]>0) $query="select zsh,pic,title from ".$table_pre."kh_tb where tid='".$tid."' and zsh>='".$arr_zsh1[0]."' group by zsh order by zsh limit 0,5"; else $query="select zsh,pic,title from ".$table_pre."kh_tb where tid='".$tid."' group by zsh order by zsh limit 0,5"; }else if(count($arr_zsh2)<2){ if($arr_zsh2[0]>0) $q1="select count(distinct zsh) 'num' from ".$table_pre."kh_tb where tid='".$tid."' and zsh<='".$arr_zsh2[0]."'"; else $q1="select count(distinct zsh) 'num' from ".$table_pre."kh_tb where tid='".$tid."'"; $m1=get_db_msg($q1); $limit_s=($m1["num"]-5)>0?($m1["num"]-5):0; if($arr_zsh2[0]>0) $query="select zsh,pic,title from ".$table_pre."kh_tb where tid='".$tid."' and zsh<='".$arr_zsh2[0]."' group by zsh order by zsh limit ".$limit_s.",5"; else $query="select zsh,pic,title from ".$table_pre."kh_tb where tid='".$tid."' group by zsh order by zsh limit ".$limit_s.",5"; }else{ $query="select zsh,pic,title from ".$table_pre."kh_tb where tid='".$tid."' and zsh>='".$arr_zsh1[1]."' group by zsh order by zsh limit 0,5"; } //echo $query."--
"; $re=$db->query($query); //$str.="arr_content_yl=["; $arr_content_yl=""; while($rows=$db->fetch_array($re)){ $arr_tmp=array(); $tmp=get_db_msg("select count(distinct iid,color) 'num' from ".$table_pre."kh_tb where zsh=".$rows['zsh']." and tid='".$tid."'"); $r=$db->query("select * from ".$table_pre."kh_tb where zsh=".$rows['zsh']." and tid='".$tid."'"); $i=0; while($m1=$db->fetch_array($r)){ $arr_tmp[$i]['titile']=$m1['titile']; $arr_tmp[$i]['pic']=$m1['pic']; $arr_tmp[$i]['iid']=$m1['iid']; $arr_tmp[$i]['color']=$m1['color']; $i++; } $pic=""; $pic_w=$pic_h=0; $tmp2=get_db_msg("select * from ".$table_pre."kh where id='".$arr_tmp[0]["iid"]."' limit 0,1"); if($rows['pic']!=""){ //$rows['pic']=str_replace("\"","'",out_good_pic("../attachments/".$rows['pic'],110,110)); $pic="../attachments/".$rows['pic']; $ck=out_good_pic_set_arr($pic,110,110); $pic_w=$ck[0]; $pic_h=$ck[1]; } if($rows['pic']==""){ //$rows['pic']=""; $pic="images/no_pic.png"; //$pic=""; $pic_w=110; $pic_h=110; } if($tmp['num']==1 && $rows['pic']==""){ if($arr_tmp[0]["color"]){ //$rows['pic']=str_replace("\"","'",out_good_pic(get_kh_color_picture($tmp2["no"],$arr_tmp[0]["color"]),110,110)); $pic=get_kh_color_picture($tmp2["no"],$arr_tmp[0]["color"]); $ck=out_good_pic_set_arr($pic,110,110); $pic_w=$ck[0]; $pic_h=$ck[1]; }else{ //$rows['pic']=str_replace("\"","'",out_good_pic(get_kh_picture($tmp2["no"],$tmp2["main_pic"],$tmp2["color"]),110,110)); $pic=get_kh_picture($tmp2["no"],$tmp2["main_pic"],$tmp2["color"]); $ck=out_good_pic_set_arr($pic,110,110); $pic_w=$ck[0]; $pic_h=$ck[1]; } } $info="
"; foreach($arr_tmp as $key => $value){ $tmp=get_db_msg("select no from ".$table_pre."kh where id=".$value["iid"]); $info.=$tmp['no']; if ($value['color']) { $info.=",".$value['color']; }else{ $info.=""; } $info.="
"; } //$str.="\"".$rows['zsh']."-".$rows['pic']."-".$info; //$str.="\","; $arr_content_yl.="{\"tsh\":\"".$rows['zsh']."\",\"pic\":\"".$pic."\",\"pic_w\":".deel_num($pic_w).",\"pic_h\":".deel_num($pic_h).",\"info\":\"".$info."\"},"; } $arr_content_yl=substr($arr_content_yl,0,-1); $json_data.="\"zjs\":[".$arr_content_yl."],"; //$str=substr($str, 0, -1); //$str.="]"; break; } $json_data=substr($json_data,0,-1)."}"; echo $json_data; ?>