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

612 lines
25 KiB
PHP

<?php
//-------------------------------单款订货
/*
店铺和区经角色
*/
header("Content-type: text/html; charset=utf-8");
$json_data="{";
if(THIS_IN!="edt_ipad")
exit("错误的访问!");
$uid=check_cookie_jxs();
//$db=_mysql_connect();
//系统变量
$sys_close=get_set("sys_close");
$sys_close_image=get_set("sys_close_image");
$is_session=get_set("is_session");
$zb_type=get_set("zb_type");
$is_spk=get_set("is_spk");
$zbxf=get_set("zbxf");
$zbxf_type=get_set("zbxf_type");
$sys_ms=get_set("sys_ms");
$is_msg=get_set("is_msg");
$is_ewm=get_set("is_ewm");
$is_window="y";
$zk_type=get_set("zk_type");
$is_hd_log=get_set("is_hd_log");
$xh_ms=get_set("xh_ms");
$order_session=get_set("order_session");
$sys_size_num=get_max_size_num();
$theme_path=get_theme_path();
$is_sy=get_set("is_sy");
$sys_ck_input=get_set("sys_ck_input");
$tmpl_m1_page_size=12;
$tmpl_m1_lie=4;
$tmpl_m1_pic_width=188;
$tmpl_m1_pic_height=250;
$tmpl_m1_search_con_num=5;
$tmpl_m2_dp_pic_width=400;
$tmpl_m2_dp_pic_height=300;
$json_data.="\"sys_ver_hy\":\"".$sys_ver_hy."\",";
$msg_login=get_db_msg("select * from ".$table_pre."client where id='".$uid."'");
if($msg_login["available"]!="y"){
$json_data.="\"error\":\"用户已被禁用\",\"code\":0,\"msg\":\"\",\"count\":0,\"data\":[],";
}else{
$json_data.="\"face\":\"".$msg_login["face"]."\",";
$json_data.="\"uid\":\"".$msg_login["id"]."\",";
$s_key=$s_key?$s_key:$_key;
$rurl=$rurl?$rurl:get_this_url();
$check_md=get_db_msg("select count(*) 'num' from ".$table_pre."kh_md");
$zb_client_show=get_set("zb_client_show");
if($zb_client_show=="y")
$arr_zb_type=explode(",",$zb_type);
else
$arr_zb_type=array();
$is_brand=is_brand();
$show_jd=get_set("show_jd");
$is_dkds=get_set("is_dkds");
$is_multi_price=get_set("is_multi_price");
$order_close=get_set("order_close");
$search_type=get_set("search_type");
$json_data.="\"show_jd\":\"".$show_jd."\",";
$json_data.="\"is_dkds\":\"".$is_dkds."\",";
$json_data.="\"is_brand\":\"".$is_brand."\",";
$json_data.="\"is_multi_price\":\"".$is_multi_price."\",";
$json_data.="\"username\":\"".$msg_login["username"]."\",";
$json_data.="\"is_sy\":\"".$is_sy."\",";
if($is_brand=="y")
$link_var_brand="&s_brand=".$s_brand;
else
$link_var_brand="";
$title_brand=$con_brand="";
if($s_brand){
$arr_s_brand=explode(",",$s_brand);
for($i=0;$i<count($arr_s_brand);$i++){
$con_brand.="brand='".$arr_s_brand[$i]."' or ";
$title_brand.=get_cate_title_no("brand",$arr_s_brand[$i]).",";
}
if($title_brand)
$title_brand=substr($title_brand,0,-1);
if($con_brand)
$con_brand=" and (".substr($con_brand,0,-3).")";
}
//取得选项
$arr_select_no=array();
$arr_select_title=array();
$q="select no,title from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and flag_bd='n' and no<>'sx' and no<>'zd1' and no<>'zd2' and no<>'zd3' order by ord";
$r=$db->query($q);
while($m=$db->fetch_array($r)){
$arr_select_no[]=$m["no"];
$arr_select_title[]=$m["title"];
}
//文胸
if($bx_sizegroup_title){
$tmp=get_db_msg("select id from ".$table_pre."keyword where cate='size' and title='".$bx_sizegroup_title."' limit 0,1");
$bx_sizegroup_id=$tmp["id"];
}else{
$bx_sizegroup_id=0;
}
//童装
if($child_sizegroup_title){
$tmp=get_db_msg("select id from ".$table_pre."keyword where cate='size' and title='".$child_sizegroup_title."' limit 0,1");
$child_sizegroup_id=$tmp["id"];
}else{
$child_sizegroup_id=0;
}
$con_spk=($is_spk=="y")?" and is_sp<>'y'":"";
$flag_spk=($is_spk=="y")?"1":"";
//------------------------------------包含定制模块,店铺界面,顶部已订数和完成率的显示
//include_once $path_dz."/dp/wcl.php";
//
//--------------交单按钮
$jd_password=get_set("jd_password");
if($is_brand<>"y"){
$tmp=$msg_login;
$is_jd=$msg_login["is_jd"];
$is_checked=$msg_login["is_checked"];
}else{
$tmp=get_db_msg("select is_jd from ".$table_pre."client_brand where cid='".$uid."'".$con_brand." order by is_jd limit 0,1");
$is_jd=$tmp["is_jd"];
$tmp=get_db_msg("select is_checked from ".$table_pre."client_brand where cid='".$uid."'".$con_brand." order by is_checked limit 0,1");
$is_checked=$tmp["is_checked"];
}
if($show_jd=="y"){
if($is_jd=="y")
$jd_button="已交单|";
if($is_checked=="y")
$jd_button="已确认|";
if($is_brand=="y"){
$jd_button="交单|go_url('".$_SERVER[PHP_SELF]."?_m=".$_m."&_a=o&s_tab=wcl')";
}else{
if($is_jd!="y" && $is_checked!="y")
$jd_button="交单|do_jd('".$jd_password."','".$_SERVER[PHP_SELF]."?_m=".$_m."&_a=jd".$link_var_brand."')";
}
}else{
$jd_button="|";
}
//计算订货规则按钮
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."gz where dj='' or dj='".$msg_login["dj"]."'");
if($tmp["num"]>0)
$menu_dhgz="订货规则";
else
$menu_dhgz="";
switch($_a){
case "single":
$msg_err="";
$msg_cc=get_db_msg("select * from ".$table_pre."kh_cc where zsh='".$zsh."'");
/*if(!$msg_cc["id"]){
//echo_wrong("数据不存在!");
$msg_err="数据不存在!";
}
if($msg_err){
$json_data.="\"error\":\"".$msg_err."\",";
}else{*/
$s_title=trim($s_title);
if($s_title){
$msg_dp=get_db_msg("select * from ".$table_pre."kh_cc where title like '%".$s_title."%' order by zsh,ord limit 0,1");
$m1=get_db_msg("select count(distinct zsh) 'num' from ".$table_pre."kh_cc where title like '%".$s_title."%'");
$q1="select * from ".$table_pre."kh_cc where title like '%".$s_title."%' group by zsh order by zsh";
//
$tmp=get_db_msg("select min(zsh) 'zsh' from ".$table_pre."kh_cc where title like '%".$s_title."%'");
$zsh=$tmp["zsh"];
}else{
if($zsh){
$msg_dp=get_db_msg("select * from ".$table_pre."kh_cc where zsh='".$zsh."' order by ord");
}else{
$tmp=get_db_msg("select min(zsh) 'zsh' from ".$table_pre."kh_cc");
$zsh=$tmp["zsh"];
$msg_dp=get_db_msg("select * from ".$table_pre."kh_cc where zsh='".$zsh."' order by ord");
}
$m1=get_db_msg("select count(distinct zsh) 'num' from ".$table_pre."kh_cc where zsh='".$zsh."'");
$q1="select * from ".$table_pre."kh_cc where zsh='".$zsh."' group by zsh order by zsh";
}
//if(!$msg_dp["id"])
//echo_wrong("记录不存在!");
$str_title="";
if($m1["num"]>1){
$r2=$db->query($q1);
while($m2=$db->fetch_array($r2)){
//$str_title.="<a href=\"?_m=dp_single&zsh=".$m2["zsh"]."&rurl=".urlencode($back_url)."\">".$m2["zsh"]."#".$m2["title"]."</a> &nbsp;&nbsp;&nbsp; ";
$msg_err.=$m2["zsh"]."#".$m2["title"]."|";
$str_title.="{\"zsh\":\"".$m2["zsh"]."\",\"title\":\"".$m2["zsh"]."#".$m2["title"]."\"},";
}
if($msg_err){
$str_title=deel_end($str_title);
$msg_err="存在以下符合条件的多个款:".$msg_err;
}
//echo_wrong("<div width=\"100%\" align=\"left\" style=\"line-height:25px;\">找到以下符合条件的多项,请选择:<br>".$str_title."<div>");
}
if(!$msg_dp["id"]){
$msg_err="记录不存在";
}
if($msg_err){
if($str_title){
$json_data.="\"code\":101,";
$json_data.="\"msg\":[".$str_title."],";
}else{
$json_data.="\"code\":102,";
$json_data.="\"msg\":\"".$msg_err."\",";
}
}else{
$json_data.="\"code\":100,";
$json_data.="\"sys_ck_input\":\"".$sys_ck_input."\",";
//橱窗选项
$q="select * from ".$table_pre."kh_cc group by zsh order by zsh";
$r=$db->query($q);
$op_cc="";
$select_dz="";
$tmp="";
while($m=$db->fetch_array($r)){
$op_cc.="<option value=\"".$m["zsh"]."\"";
if($zsh==$m["zsh"]){
$op_cc.=" selected";
}
$op_cc.=">".$m["title"]."</option>";
$tmp.="{\"no\":\"".$m["zsh"]."\",\"title\":\"".$m["title"]."\"},";
}
$tmp=deel_end($tmp);
$select_dz="{\"no\":\"cc\",\"title\":\"橱窗\",\"value\":\"".$zsh."\",\"op\":[".$tmp."]},";
$select_dz=deel_end($select_dz);
$json_data.="\"select_cc\":[".$select_dz."],";
//
$dis="";
if($msg_login["is_jd"]=="y" || $msg_login["is_checked"]=="y")
$dis=" disabled";
$json_data.="\"btn_dis\":\"".$dis."\",";
$json_data.="\"zsh\":\"".$zsh."\",";
//取得内容
$content="<div id='content' style='background-color:#ffffff;color:#000000;padding:10px;' width='100%'>";
$content.="<div align=\"left\" style='padding:4px;'>批量<input type=\"number\" name=\"pl_num\" id=\"pl_num\" value=\"\" style=\"width:40px;height:25px;\"".$dis."> <input type=\"button\" value=\" 应 用 \" onclick=\"set_cc_pl()\"".$dis."><input type=\"reset\" value=\" 还 原 \"".$dis."></div>";
$content.="<table border=\"0\" cellspacing=\"1\" cellpadding=\"3\" width=\"100%\" bgcolor=\"#333333\">";
$content.="<tr bgcolor=\"#cccccc\"><td>图片</td><td>款号信息</td><td>尺码明细</td></tr>";
$q="select * from ".$table_pre."kh_cc where zsh='".$zsh."' order by ord";
$r=$db->query($q);
$str_js_arr="";
while($m=$db->fetch_array($r)){
//验证款号,颜色是否存在
$m_kh=get_db_msg("select * from ".$table_pre."kh where no='".$m["kh"]."' and ka<>'y'");
$msg_pj=get_db_msg("select * from ".$table_pre."client_pj where khid='".$m_kh["id"]."' and cid='".$uid."'");
if($msg_pj["id"]>0){
$pj_remark=dhtmlchars($msg_pj["remark"]);
$race=$msg_pj["race"];
}else{
$pj_remark="";
$race=0;
}
$arr_color=explode(",",$m_kh["color"]);
$arr_color_ka=explode(",",$m_kh["color_ka"]);
if(in_array($m["color"],$arr_color,true) && !in_array($m["color"],$arr_color_ka,true)){
//款号颜色存在,且没有被设置删除
$arr_size=explode(",",$m["size"]);
$arr_size_check=explode(",",$m_kh["size"]);
$tmp1="";
$str_size="<table><tr>";
$js_str_size="";
for($k=0;$k<count($arr_size);$k++){
//
$m_size=get_db_msg("select * from ".$table_pre."size where iid='".$m_kh["size_group"]."' and title='".$arr_size[$k]."'");
if(in_array($m_size["no"],$arr_size_check)){
//取得已订数量
$tmp=get_db_msg("select * from ".$table_pre."order where uid='".$uid."' and iid='".$m_kh["id"]."' and color='".$m["color"]."' and _key='".$_key."'");
$str_size.="<td>".$arr_size[$k]."</td><td><input type=\"number\" style=\"width:30px;height:20px;\" name=\"num_".$m_kh["id"]."_".$m["color"]."_".$m_size["no"]."\" id=\"num_".$m_kh["id"]."_".$m["color"]."_".$m_size["no"]."\" value=\"".deel_0($tmp["num_".$m_size["no"]])."\"".$dis.">&nbsp;</td>";
//$js_str_size.=$m_size["no"].",";
$js_str_size.="{\"id\":\"num_".$m_kh["id"]."_".$m["color"]."_".$m_size["no"]."\",\"no\":\"".$m_size["no"]."\",\"cm\":\"".$arr_size[$k]."\",\"value\":\"".deel_0($tmp["num_".$m_size["no"]])."\"},";
}
}
$js_str_size=deel_end($js_str_size);
$str_size.="</tr></table>";
$pic=get_kh_picture($m["kh"],$m_kh["main_pic"],$m["color"]);
$content.="<tr bgcolor=\"#ffffff\"><td width=\"110\" align=\"center\" style=\"cursor:pointer;\" onclick=\"window.location.href='?_m=order_single&id=".$m_kh["id"]."&color=".$m["color"]."&rurl=".urlencode("?_m=".$_m."&zsh=".$zsh)."'\">".out_good_pic($pic,60,60)."</td>";
$content.="<td>".get_kh_xh($m_kh,$m["color"])."#".$m["kh"]."<br>".$m["color"]."-".get_cate_title_no("color",$m["color"])."</span></td><td>".$str_size."</td>";
$content.="</tr>";
//$str_js_arr.="".$m_kh["id"].",";
//$str_js_arr.="\"".$m["color"]."\",";
//$str_js_arr.="[".$js_str_size."],";
$ck=out_good_pic_set_arr($pic,60,60);
$str_js_arr.="{\"khid\":".$m_kh["id"].",\"color\":\"".$m["color"]."\",\"colort\":\"".get_cate_title_no("color",$m["color"])."\",\"xj\":\"".$race."\",\"pjwz\":\"".$pj_remark."\",\"xh\":\"".get_kh_xh($m_kh,$m["color"])."\",\"kh\":\"".$m["kh"]."\",\"pic\":\"".$pic."\",\"pic_w\":".$ck[0].",\"pic_h\":".$ck[1].",\"data\":[".$js_str_size."]},";
}
}
$str_js_arr=deel_end($str_js_arr);
$json_data.="\"ccs\":[".$str_js_arr."],";
$content.="</table><div align=\"center\" style=\"padding:4px;\"><input type=\"submit\" id=\"save1\" value=\" 保 存 订 单 \"".$dis."></div>";
$content.="</div>";
$content.="</div>";
/*//橱窗选项
$q="select zsh,title from ".$table_pre."kh_cc group by zsh order by zsh";
$r=$db->query($q);
$op_cc="";
while($m=$db->fetch_array($r)){
$t=trim($m["title"])?$m["zsh"].".".$m["title"]:$m["zsh"];
$op_cc.="<option value=\"".$m["zsh"]."\"";
if($m["zsh"]==$zsh)
$op_cc.=" selected";
$op_cc.=">".$t."</option>";
}*/
//上一组、下一组
$pre_xh=get_db_msg("select zsh from ".$table_pre."kh_cc where zsh<'".$zsh."' order by zsh desc limit 0,1");
$tmp_click=($pre_xh["zsh"])>0?"window.location.href='".$_SERVER[PHP_SELF]."?_m=".$_m."&zsh=".$pre_xh["zsh"]."&rurl=".urlencode($rurl)."'":"alert('已经是第一组了!')";
$button_syz="<input type=\"button\" class=\"order_single_button\" style=\"background:url(".$theme_path."/images/order_single_button_bg.png) center center no-repeat;\" value=\"上一组\" onclick=\"".$tmp_click."\">";
$next_xh=get_db_msg("select zsh from ".$table_pre."kh_cc where zsh>'".$zsh."' order by zsh limit 0,1");
$tmp_click=($next_xh["zsh"])>0?"window.location.href='".$_SERVER[PHP_SELF]."?_m=".$_m."&zsh=".$next_xh["zsh"]."&rurl=".urlencode($rurl)."'":"alert('已经是最后一组了!')";
$button_xyz="<input type=\"button\" class=\"order_single_button\" style=\"background:url(".$theme_path."/images/order_single_button_bg.png) center center no-repeat;\" value=\"下一组\" onclick=\"".$tmp_click."\">";
$json_data.="\"prev\":\"".$pre_xh["zsh"]."\",";
$json_data.="\"next\":\"".$next_xh["zsh"]."\",";
//include template("cc_single");
$ccpic=get_kh_cc_big($msg_cc["pic"],$flag_pad_offline);
$tmppic=out_good_pic_set_arr($ccpic,400,300);
$json_data.="\"pic_big\":\"".$ccpic."\",";
$json_data.="\"pic_big_w\":\"".$tmppic[0]."\",";
$json_data.="\"pic_big_h\":\"".$tmppic[1]."\",";
}
break;
case "save":
$msg_err="";
if($order_close=="y"){
//alert_and_back("订单保存失败,原因是系统订单已经关闭!");
$msg_err="订单保存失败,原因是系统订单已经关闭!";
}
if($msg_login["is_checked"]=="y" && !$msg_err){
//alert_and_back("订单保存失败,原因是本用户订单已经确认!");
$msg_err="订单保存失败,原因是本用户订单已经确认!";
}
if($msg_login["is_jd"]=="y" && !$msg_err){
//alert_and_back("订单保存失败,原因是本用户订单已经提交!");
$msg_err="订单保存失败,原因是本用户订单已经提交!";
}
//判断代理
$dl_uid=get_dl_id($msg_login["path"]);
if($dl_uid>0){
$msg_dl=get_db_msg("select * from ".$table_pre."client where id='".$dl_uid."'");
if($msg_dl["is_jd"]=="y" && !$msg_err){
//alert_and_back("订单保存失败,原因是您的代理已经提交!");
$msg_err="订单保存失败,原因是您的代理已经提交!";
}
if($msg_dl["is_checked"]=="y" && !$msg_err){
//alert_and_back("订单保存失败,原因是您的代理订单已经确认!");
$msg_err="订单保存失败,原因是您的代理订单已经确认!";
}
}
/*//---------------判断订货规则
$errm="";
$q="select * from ".$table_pre."kh_cc where zsh='".$zsh."' order by ord";
$r=$db->query($q);
while($m=$db->fetch_array($r)){
//验证款号,颜色是否存在
$m_kh=get_db_msg("select * from ".$table_pre."kh where no='".$m["kh"]."' and ka<>'y'");
$arr_color=explode(",",$m_kh["color"]);
$arr_color_ka=explode(",",$m_kh["color_ka"]);
$arr_size_check=explode(",",$m_kh["size"]);
if(in_array($m["color"],$arr_color,true) && !in_array($m["color"],$arr_color_ka,true)){
$num1=0;
for($k=0;$k<count($arr_size_check);$k++){
$var="num_".$m_kh["id"]."_".$m["color"]."_".$arr_size_check[$k];
$num1+=$$var;
}
$errm.=check_dhgz_bdks($m_kh,$m["color"],$num1);
$errm.=check_dhgz_qdl($m_kh,$m["color"],$num1);
//检查款号规则
$tmp=get_db_msg("select sum(num) 'num' from ".$table_pre."order where uid='".$uid."' and no='".$m["kh"]."' and color<>'".$m["color"]."' and _key='".$_key."'");
$tmp_kh_num=$tmp["num"]+$num1;
$errm.=check_dhgz_bdk($m_kh,$tmp_kh_num);
$errm.=check_dhgz_qdl($m_kh,"",$tmp_kh_num);
$errm.=check_dhgz_glk($m_kh["no"],$tmp_kh_num,$str_kh_num);
}
}
for($i=0;$i<count($arr_ks_bx_num);$i++){
$v_khid="khid_".$i;
$v_color="color_".$i;
$msg=get_db_msg("select * from ".$table_pre."kh where id='".$$v_khid."'");
$num1=0;
for($j=0;$j<$arr_ks_bx_num[$i];$j++){
for($s1=1;$s1<=$sys_size_num;$s1++){
$var1="num".$k."_".$s1;
$num1+=$$var1;
}
$k++;
}
$errm.=check_dhgz_bdks($msg,$$v_color,$num1);
$errm.=check_dhgz_qdl($msg,$$v_color,$num1);
//检查款号规则
$tmp=get_db_msg("select sum(num) 'num' from ".$table_pre."order where uid='".$uid."' and iid='".$$v_khid."' and color<>'".$$v_color."' and _key='".$_key."'");
$tmp_kh_num=$tmp["num"]+$num1;
$errm.=check_dhgz_bdk($msg,$tmp_kh_num);
$errm.=check_dhgz_qdl($msg,"",$tmp_kh_num);
$errm.=check_dhgz_glk($msg["no"],$tmp_kh_num,$str_kh_num);
}
if(!$msg_err){
$msg_err=$errm;
}*/
if($msg_err){
//echo $msg_err;
$json_data.="\"code\":0,\"msg\":\"".$msg_err."\",";
}else{
//取得选项
$arr_select_no=array();
$q1="select no from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'jgd' and no<>'sx' and no<>'zd1' and no<>'zd2' and no<>'zd3' order by ord";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$arr_select_no[]=$m1["no"];
}
//保存订单
$q="select * from ".$table_pre."kh_cc where zsh='".$zsh."' order by ord";
$r=$db->query($q);
while($m=$db->fetch_array($r)){
//验证款号,颜色是否存在
$m_kh=get_db_msg("select * from ".$table_pre."kh where no='".$m["kh"]."' and ka<>'y'");
$arr_color=explode(",",$m_kh["color"]);
$arr_color_ka=explode(",",$m_kh["color_ka"]);
if(in_array($m["color"],$arr_color,true) && !in_array($m["color"],$arr_color_ka,true)){
//
$tmp_total_num=0;
//款号颜色存在,且没有被设置删除
$arr_size=explode(",",$m["size"]);
$arr_size_check=explode(",",$m_kh["size"]);
//
$sql1=$sql2="";
for($i1=0;$i1<count($arr_select_no);$i1++){
$sql1.=$arr_select_no[$i1].",";
$sql2.="'".$m_kh[$arr_select_no[$i1]]."',";
}
//
$sql_size2=$sql_size3="";
for($k=0;$k<count($arr_size_check);$k++){
$var="num_".$m_kh["id"]."_".$m["color"]."_".$arr_size_check[$k];
$sql_size2.=",'".deel_num($$var)."'";
$tmp_total_num+=$$var;
$sql_size3.=",num_".$arr_size_check[$k];
}
$tmp_old=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where uid='".$uid."' and iid='".$m_kh["id"]."' and _key='".$_key."'");
$log_hd_old_num1=$tmp_old["num"];
$log_hd_old_num=0;
for($k=0;$k<count($arr_size);$k++){
//
$m_size=get_db_msg("select * from ".$table_pre."size where iid='".$m_kh["size_group"]."' and title='".$arr_size[$k]."'");
$check=get_db_msg("select id from ".$table_pre."order where uid='".$uid."' and iid='".$m_kh["id"]."' and color='".$m["color"]."' and _key='".$_key."'");
if(in_array($m_size["no"],$arr_size_check)){
$tmp=get_db_msg("select num_".$m_size["no"]." from ".$table_pre."order where uid='".$uid."' and iid='".$m_kh["id"]."' and _key='".$_key."'");
$log_hd_old_num+=$tmp["num_".$m_size["no"]];
//
$var="num_".$m_kh["id"]."_".$m["color"]."_".$m_size["no"];
if($check["id"]>0){
$q1="update ".$table_pre."order set num_".$m_size["no"]."='".$$var."' where id='".$check["id"]."'";
$db->query($q1);
update_order_log($uid,"update ".$table_pre."order set num_".$m_size["no"]."='".$$var."' where uid='".$uid."' and iid='".$m_kh["id"]."' and color='".$m["color"]."' and _key='".$_key."'");
}else{
if($$var>0){
$q1="insert into ".$table_pre."order (uid,upath,iid,no,".$sql1."jgd,color,bx,is_sp,size_group_id".$sql_size3.",_key,sx,add_date) values ('".$uid."','".$upath."','".$m_kh["id"]."','".$m_kh["no"]."',".$sql2."'".get_jgd($m_kh["price"])."','".$m["color"]."','','".$m_kh["is_sp"]."','".$m_kh["size_group"]."'".$sql_size2.",'".$_key."','".get_sx($m["color"])."','".time()."')";
$db->query($q1);
update_order_log($uid,"insert into ".$table_pre."order (uid,upath,iid,no,".$sql1."jgd,color,bx,is_sp,size_group_id".$sql_size3.",_key,sx,add_date) values ('".$uid."','".$upath."','".$m_kh["id"]."','".$m_kh["no"]."',".$sql2."'".get_jgd($m_kh["price"])."','".$m["color"]."','','".$m_kh["is_sp"]."','".$m_kh["size_group"]."'".$sql_size2.",'".$_key."','".get_sx($m["color"])."','".time()."')");
}
}
//echo $q1."<br>";
}
}
$flag_action="";
$khid=$m_kh["id"];
$log_hd_num=$tmp_total_num-$log_hd_old_num;
if($log_hd_num!=0){
if($log_hd_num>0){
if($log_hd_old_num1==0)
$flag_action="21";
else
$flag_action="23";
}else{
$flag_action="22";
}
//删除为0的数据
if($check["id"]>0){
$tmp=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where uid='".$uid."' and iid='".$m_kh["id"]."' and color='".$m["color"]."' and _key='".$_key."'");
if($tmp["num"]==0){
$db->query("delete from ".$table_pre."order where id='".$check["id"]."'");
update_order_log($uid,"delete from ".$table_pre."order where uid='".$uid."' and iid='".$m_kh["id"]."' and color='".$m["color"]."'");
$flag_action="24";
}
}
update_log_hd();
}
cache_order($uid,$m_kh["id"],$m["color"],'');
count_ph($uid,$m_kh["id"],$m["color"]);
}
}
set_order_total($uid);
$json_data.="\"code\":101,";
}
//$url=$_SERVER[PHP_SELF]."?_m=cc_single&zsh=".$zsh;
//alert_and_redirect("订单保存成功!",$url);
break;
default:
//----------------------------------------------橱窗模式
$page=$page>0?$page:1;
$limit=$limit>0?$limit:6;
$start=($page-1)*$limit;
$end=$limit;
$query="select count(distinct zsh) 'total' from ".$table_pre."kh_cc ";
$res=$db->query($query);
$msg=$db->fetch_array($res);
$total=$msg["total"];
//定制条件
$query="select * from ".$table_pre."kh_cc group by zsh order by zsh";
//echo $query."<br>";
$res=$db->query($query);
$pic_background=get_set("pic_background");
$pic_background=$pic_background?$pic_background:"#ffffff";
$content_set="[\"".$pic_background."\"]";
$json_data.="\"content_set\":\"".$pic_background."\",";
$count=0;
$rnum=0;
$content_list="";
$cc_yd=$cc_zj=0;
$json_data.="\"content_list\":[";
$data_str="";
while($msg=$db->fetch_array($res)){
//取得已订套数
$arr_num=array();
$q1="select * from ".$table_pre."kh_cc where zsh='".$msg["zsh"]."'";
$r1=$db->query($q1);
$j=0;
while($m1=$db->fetch_array($r1)){
$m2=get_db_msg("select id,size_group,category,category1 from ".$table_pre."kh where no='".$m1["kh"]."'");
//if($m2["category"]!="50"){//排除某个大类
$arr_size=explode(",",$m1["size"]);
$sql_size="";
for($k=0;$k<count($arr_size);$k++){
$tmp=get_db_msg("select * from ".$table_pre."size where iid='".$m2["size_group"]."' and title='".$arr_size[$k]."'");
if($tmp["id"]>0)
$sql_size.="num_".$tmp["no"]."+";
}
if($sql_size){
$sql_size=substr($sql_size,0,-1);
$tmp=get_db_msg("select sum(".$sql_size.") 'num' from ".$table_pre."order where uid='".$uid."' and iid='".$m2["id"]."' and color='".$m1["color"]."' and _key='".$_key."'");
$arr_num[$j]=$tmp["num"];
$j++;
}
//}
}
if(count($arr_num)>0){
$n1=min($arr_num);
}else{
$n1=0;
}
if($n1>0)
$cc_yd++;
//图片获取规则
$pic=get_kh_cc_mini($msg["pic"]);
$content_list.=$msg["zsh"].",\"".$msg["title"]."\",\"".$pic."\",\"".str_replace("\"","'",out_good_pic_set($pic,$tmpl_m1_pic_width,$tmpl_m1_pic_height))."\",".$n1.",";
$ck=out_good_pic_set_arr($pic,$tmpl_m1_pic_width,$tmpl_m1_pic_height);
$data_str.="{\"zsh\":".$msg["zsh"].",\"title\":\"".$msg["title"]."\",\"pic\":\"".$pic."\",\"pic_w\":".$ck[0].",\"pic_h\":".$ck[1].",\"n1\":".deel_num($n1)."},";
$rnum++;
$count++;
$cc_zj++;
}
$json_data.=substr($data_str,0,-1)."],";
$json_data.="\"rnum\":\"".$rnum."\",";
$json_data.="\"cc_zj\":\"".$cc_zj."\",";
$json_data.="\"count\":\"".$count."\",";
$total_page=ceil($total/$limit);
$json_data.="\"total_page\":".$total_page.",";
$json_data.="\"page\":".$page.",";
//$content_list.="]";
break;
}
}
//取得图片长宽参数
function out_good_pic_set1($pic,$width,$height){
if(is_file($pic)){
$wh=GetImageSize($pic);
}else{
$pic1=str_replace("content://com.muchuang.edt/","../",$pic).".jpg";
if(is_file($pic1))
$wh=GetImageSize($pic1);
}
$tmp=array();
if(($width>0 && $width<$wh[0]) || ($height>0 && $height<$wh[1])){
if(($wh[0]/$width)>($wh[1]/$height)){
//$tmp=" ".$width.",".round($wh[1]*$width/$wh[0]);
$tmp[0]=$width;
$tmp[1]=round($wh[1]*$width/$wh[0]);
}else{
//$tmp="".round($wh[0]*$height/$wh[1]).",".$height;
$tmp[0]=round($wh[0]*$height/$wh[1]);
$tmp[1]=$height;
}
}else{
//$tmp="".$wh[0].",".$wh[1];
$tmp[0]=$wh[0];
$tmp[1]=$wh[1];
}
//print_r($tmp);
return $tmp;
}
$json_data=substr($json_data,0,-1)."}";
echo $json_data;
?>