'sx' and no<>'zd1' and no<>'zd2' and no<>'zd3' order by ord";
$r=$db->query($q);
while($m=$db->fetch_array($r)){
if($m["no"]!="zd1" && $m["no"]!="zd2" && $m["no"]!="zd3"){
$arr_select_no1[]=$m["no"];
$arr_select_title1[]=$m["title"];
if($m["no"]!="designer"){
$arr_select_no2[]=$m["no"];
$arr_select_title2[]=$m["title"];
}
}
$arr_select_no[]=$m["no"];
$arr_select_title[]=$m["title"];
}
$arr_column_this=array("client"=>"客户代码","no"=>"款号","color"=>"颜色代码");
if($bx_sizegroup_id>0)
$arr_column_this["bx"]="杯型";
else if($child_sizegroup_id>0)
$arr_column_this["bx"]="款型";
if($is_gg!="n")
$arr_column_this["gg"]=d_translate("gg");
if($sys_ver_hy=="xz"){
$arr_column_this["xs"]="箱数";
}
switch($_a){
case "add" :
//--------------------------新增
$add_date=date("Y-m-d H:i:s");
if($id){
$msg=get_db_msg("select * from ".$table_pre."order where id='".$id."'");
$msg_kh=get_db_msg("select * from ".$table_pre."kh where id='".$msg["iid"]."'");
if($msg_kh["size_group"]==$bx_sizegroup_id){
$tmp=get_db_msg("select size from ".$table_pre."size_bx where no='".$msg_kh["no"]."' and bx='".$msg["bx"]."'");
$arr_size=explode(",",$tmp["size"]);
$bx_td="
杯型
";
$bx="杯型";
$bxf="y";
}else if($msg_kh["size_group"]==$child_sizegroup_id){
$tmp=get_db_msg("select size from ".$table_pre."size_bx where no='".$msg_kh["no"]."' and bx='".$msg["bx"]."'");
$arr_size=explode(",",$tmp["size"]);
$bx_td="
";
$z_time=date("Y-m-d-H-i-s");
}else{
$s_username="";
$file_name="";
$z_time="";
$s_time=date("Y-m-d H:i:s");
}
$json_data.="\"s_username\":\"".$s_username."\",";
$json_data.="\"file_name\":\"".$file_name."\",";
$json_data.="\"s_time\":\"".$s_time."\",";
$json_data.="\"z_time\":\"".$z_time."\",";
$json_data.="\"code\":1,";
//生成订单日志
/*$js_code="
";
$js_code.="";
$content="";
include template("blank");*/
break;
case "check":
//--------------------------------------------
$content="";
//
//检查颜色
$content.="款号颜色检查: ";
$q="select no,color,iid from ".$table_pre."order where _key='".$_key."' group by no,color";
$r=$db->query($q);
$i=1;
$tmp="";
while($m=$db->fetch_array($r)){
$m_kh=get_db_msg("select no,color from ".$table_pre."kh where id='".$m["iid"]."'");
$arr_color=explode(",",$m_kh["color"]);
if(!in_array($m["color"],$arr_color)){
$content.=$i.".".$m_kh["no"]."|".$m["color"]."--有误 ";
$tmp.="{\"kh\":\"".$m_kh["no"]."\",\"v\":\"".$m_kh["no"]."|".$m["color"]."--有误\"},";
$i++;
}
}
if($i==1)
$content.="款号颜色检查完毕,没有错误!";
if($i>1){
$str.="{\"f\":\"1\",\"cate\":\"款号颜色有误\",\"data\":[".deel_end($tmp)."]},";
}
//检查客户
$content.="客户检查: ";
$q="select uid from ".$table_pre."order where _key='".$_key."' group by uid";
$r=$db->query($q);
$i=1;
$tmp="";
while($m=$db->fetch_array($r)){
$m_client=get_db_msg("select title,username from ".$table_pre."client where id='".$m["uid"]."'");
if(trim($m_client["username"])==""){
$content.=$i.".uid=".$m["uid"]."--有误";
$tmp.="{\"dp\":\"".$m["uid"]."\",\"v\":\"uid=".$m["uid"]."--有误\"},";
$i++;
}
}
if($i==1)
$content.="客户检查完毕,没有错误! ";
if($i>1){
$str.="{\"f\":\"2\",\"cate\":\"客户有误\",\"data\":[".deel_end($tmp)."]},";
}
//检查异常重复记录
$content.="异常重复记录检查: ";
$q="select b.username 'username',a.no 'no',a.color 'color' ,a.bx 'bx' from ".$table_pre."order a,".$table_pre."client b where a.uid=b.id and a._key='".$_key."' group by a.uid,a.iid,a.color,a.bx having count(*)>1";
$r=$db->query($q);
$i=1;
$tmp="";
while($m=$db->fetch_array($r)){
$content.=$i.".".$m["username"]."|".$m["no"]."|".$m["color"]."|".$m["bx"]."有误 ";
$tmp.="{\"dp\":\"".$m["username"]."\",\"kh\":\"".$m["no"]."\",\"color\":\"".$m["color"]."\",\"v\":\"".$m["username"]."|".$m["no"]."|".$m["color"]."|".$m["bx"]."有误\"},";
$i++;
}
if($i==1)
$content.="异常重复检查完毕,没有错误! ";
if($i>1){
$str.="{\"f\":\"3\",\"cate\":\"异常重复记录检查\",\"data\":[".deel_end($tmp)."]},";
}
$json_data.="\"error\":[".deel_end($str)."],";
//include template("blank");
break;
case "mod_color":
if($step==1){
//-------------------检测
$q1="select * from ".$table_pre."order where iid='".$khid."' and color='".$color_from."' and _key='".$_key."'";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$check=get_db_msg("select * from ".$table_pre."order where iid='".$khid."' and color='".$color_to."' and bx='".$m1["bx"]."' and uid='".$m1["uid"]."' and _key='".$_key."'");
if($check["id"]>0){
//合并数据
for($s1=1;$s1<=$sys_size_num;$s1++){
$v1="num_".$s1;
$$v1=$check[$v1]+$m1[$v1];
}
$q="update ".$table_pre."order set ".get_size_sql("update")." where id='".$check["id"]."'";
$db->query("delete from ".$table_pre."order where id='".$m1["id"]."'");
//记录订单表sql日志
update_order_log($m1["uid"],"delete from ".$table_pre."order where id='".$m1["id"]."'");
}else{
$q="update ".$table_pre."order set color='".$color_to."' where id='".$m1["id"]."'";
}
$db->query($q);
//记录订单表sql日志
update_order_log($m1["uid"],$q);
//
cache_order($m1["uid"],$m1["iid"],$m1["color"],$m1["bx"]);
}
//
//
if($sys_ver_hy=="xz"){
$q2="select * from ".$table_pre."order_pm where _key='".$_key."' and iid='".$khid."' and color='".$color_from."'";
$r2=$db->query($q2);
while($m2=$db->fetch_array($r2)){
$check2=get_db_msg("select * from ".$table_pre."order_pm where _key='".$_key."' and iid='".$khid."' and color='".$color_to."' and pmid='".$m2["pmid"]."' and uid='".$m2["uid"]."'");
if($check2["id"]>0){
$is_xd_clothes="y";
$msg_kh_to=get_db_msg("select * from ".$table_pre."kh where id='".$khid."'");
$msg_size_group=get_db_msg("select title from ".$table_pre."keyword where cate='size' and id='".$msg_kh_to["size_group"]."'");
if(in_array($msg_size_group["title"],$sys_size_group_xz))
$is_xd_clothes="n";
//合并数据
if($is_xd_clothes=="n"){
$vvv=$check2["xs"]+$m2["xs"];
}else{
$vvv=1;
}
$db->query("update ".$table_pre."order_pm set xs='".$vvv."',color='".$color_to."' where id='".$check2["id"]."'");
$db->query("delete from ".$table_pre."order_pm where id='".$m2["id"]."'");
}else{
$db->query("update ".$table_pre."order_pm set color='".$color_to."' where id='".$m2["id"]."'");
}
}
}
//
$msg_kh=get_db_msg("select * from ".$table_pre."kh where id='".$khid."'");
if($del_kh=="y"){
//删除款号颜色
$tmp=explode(",",$msg_kh["color"]);
$new_color="";
for($i=0;$iquery("update ".$table_pre."kh set color='".$new_color."' where id='".$khid."'");
//删除款色表的颜色
$db->query("delete from ".$table_pre."kh_color where iid='".$khid."' and color='".$color_from."'");
}
set_log("订单颜色批量修改",$msg_kh["no"].":".$color_from."->".$color_to);
$json_data.="\"code\":1,";
//alert_and_redirect("修改成功!",$_SERVER[PHP_SELF]."?_m=".$_m."&_cid=".$_cid."&_a=".$_a);
}
//include template("report");
break;
case "pick_color" :
//
$msg_kh=get_db_msg("select * from ".$table_pre."kh where no='".$kh."'");
$tmp="";
$arr_color=explode(",",$msg_kh["color"]);
for($i=0;$i0){
if($gs_con=="*"){
$r=$num*$gs_num;
}else if($gs_con=="+"){
$r=$num+$gs_num;
}else if($gs_con=="-"){
$r=$num-$gs_num;
}else if($gs_con=="/"){
$r=$num/$gs_num;
}
}
$r=$r>0?round($r):0;
return $r;
}
$arr_cp_gs=array("*"=>"乘","+"=>"加","-"=>"减","/"=>"除");
//--------------------------------------------
//查询条件定制
$cp_gs_con=$cp_gs_con?$cp_gs_con:"*";
$cp_gs_num=$cp_gs_num?$cp_gs_num:1;
$login_by_select=get_set("login_by_select");
//取得店铺框
//取得不复制款的条件
//取得定制选项
$select_dz="";
$at=0;
for($i=0;$iquery("select no,title from ".$table_pre."keyword where cate='".$arr_select_no1[$i]."' order by no");
while($m1=$db->fetch_array($r1)){
$tmp.="{\"no\":\"".$m1["title"]."\",\"title\":\"".$m1["title"]."\"},";
}
$tmp=deel_end($tmp);
$var="s_".$arr_select_no1[$i];
$select_dz.="{\"id\":\"con_kh_".$at."\",\"no\":\"".$arr_select_no1[$i]."\",\"title\":\"".$arr_select_title1[$i]."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
$at++;
}
$select_dz=deel_end($select_dz);
$json_data.="\"select_dz\":[".$select_dz."],";
$json_data.="\"ctsd\":\"".$at."\",";
$select_dz1="";
//取得选项
$tmp="";
foreach($arr_cp_gs as $n => $t){
$tmp.="{\"no\":\"".$n."\",\"title\":\"".$t."\"},";
}
$tmp=deel_end($tmp);
$select_dz1.="{\"no\":\"cp_gs_con\",\"title\":\"规则\",\"value\":\"*\",\"op\":[".$tmp."]},";
$select_dz1=deel_end($select_dz1);
$json_data.="\"select_dz1\":[".$select_dz1."],";
if($step==1){
$sql_con_kh=deel_sql_con_kh($con_kh);
//-------------------检测
$con_test=1;
if($cp_gs_con=="*")
$con_test=1*$cp_gs_num;
else if($cp_gs_con=="+")
$con_test=1+$cp_gs_num;
else if($cp_gs_con=="/")
$con_test=1/$cp_gs_num;
if($con_test<=0){
alert_and_back("订单复制公式有误!");
}
if($dp_from){
$total_num=0;
$s_username=str_replace(",",",",$dp_from);
//去掉最后一个逗号
if(substr($s_username,strlen($s_username)-1,1)==",")
$s_username1=substr($s_username,0,-1);
else
$s_username1=$s_username;
$arr_username=explode(",",$s_username1);
//去掉重复值
$arr_username=array_unique($arr_username);
$confirm_str=$p_title=$error="";
for($i=0;$i'y' and uid='".$m_client["id"]."' and _key='".$_key."'".$sql_con_kh);
$total_num+=$tmp["num"];
}else{
$error.=$arr_username[$i].",";
}
}
}
if($p_title)
$p_title=substr($p_title,0,-1);
if($error)
$error=substr($error,0,-1);
$msg2=get_db_msg("select * from ".$table_pre."client where username='".$dp_to."'");
if(!$error && $msg2["id"]){
//
$msg.="您选择的来源店铺是".$p_title.",将复制订单总量".$total_num."件 ";
$msg.="您选择的目标店铺是".$msg2["title"]."(".$msg2["username"]."),当前订单总量".$msg2["order_num"]."件 ";
$json_data.="\"code\":1,\"msg\":\"".$msg."\",";
}else{
if($error)
$json_data.="\"code\":0,\"msg\":\"来源店铺错误(".$error.")!\",";
if(!$msg2["id"])
$json_data.="\"code\":0,\"msg\":\"目标店铺错误!\",";
}
if($m_client["id"]==$msg2["id"] && $cp_type!="1")
$json_data.="\"code\":0,\"msg\":\"条件错误(相同客户不能清空复制,这样操作相当于删除数据)!\",";
}else if($step==2){
//-------------------数据复制
$log_hd_ms="后台复制订单";
$ip=$_SERVER["REMOTE_ADDR"];
$add_date=date("Y-m-d H:i:s");
$sql_con_kh=deel_sql_con_kh($con_kh);
$msg_to=get_db_msg("select * from ".$table_pre."client where username='".$dp_to."'");
if($cp_type!="1"){
//先清空数据
$db->query("delete from ".$table_pre."order where uid='".$msg_to["id"]."' and ka<>'y' and _key='".$_key."'");
$db->query("delete from ".$table_pre."order_pm where _key='".$_key."' and uid='".$msg_to["id"]."'");
//记录订单表sql日志
update_order_log($msg_to["id"],"delete from ".$table_pre."order where uid='".$msg_to["id"]."' and ka<>'y' and _key='".$_key."'");
}
if($dp_from){
$s_username=str_replace(",",",",$dp_from);
//去掉最后一个逗号
if(substr($s_username,strlen($s_username)-1,1)==",")
$s_username1=substr($s_username,0,-1);
else
$s_username1=$s_username;
$arr_username=explode(",",$s_username1);
//去掉重复值
$arr_username=array_unique($arr_username);
$confirm_str=$p_title=$error="";
for($i=0;$i'y' and _key='".$_key."'".$con_u.$sql_con_kh;
//echo $q." ";
$r=$db->query($q);
while($m=$db->fetch_array($r)){
for($s1=1;$s1<=$sys_size_num;$s1++){
$v1="num_".$s1;
$$v1=get_gs_num($m[$v1],$cp_gs_con,$cp_gs_num);
}
if(get_size_sql("count_total")>0){
$c=get_db_msg("select * from ".$table_pre."order where no='".$m["no"]."' and color='".$m["color"]."' and bx='".$m["bx"]."' and uid='".$msg_to["id"]."' and _key='".$_key."'");
if($c["id"]>0){
$old_num=$c["num"];
$new_num=0;
for($s1=1;$s1<=$sys_size_num;$s1++){
$v1="num_".$s1;
$$v1+=$c[$v1];
$new_num+=$c[$v1];
}
$q1="update ".$table_pre."order set ".get_size_sql("update").",add_date='".time()."' where id='".$c["id"]."'";
$db->query($q1);
//行为记录log
$change_num=$new_num-$old_num;
$action="23";
$q="insert into ".$table_pre."log_hd (uid,iid,num,ip,action,ms,hd_type,add_date) values ('".$msg_to["id"]."','".$c["iid"]."','".$change_num."','".$ip."','".$action."','".$log_hd_ms."','','".$add_date."')";
$db->query($q);
//处理配码表
if($sys_ver_hy=="xz"){
$q2="select * from ".$table_pre."order_pm where _key='".$_key."' and iid='".$m["iid"]."' and uid='".$msg_to["id"]."' and color='".$m["color"]."' and bx='".$m["bx"]."'";
$r2=$db->query($q2);
while($m2=$db->fetch_array($r2)){
$c1=get_db_msg("select xs from ".$table_pre."order_pm where _key='".$_key."' and iid='".$m2["iid"]."' and uid='".$m["uid"]."' and color='".$m2["color"]."' and bx='".$m2["bx"]."' and pmid='".$m2["pmid"]."'");
$xs1=get_gs_num($c1["xs"],$cp_gs_con,$cp_gs_num);
$q1="update ".$table_pre."order_pm set xs=xs+".$xs1." where id='".$m2["id"]."'";
$db->query($q1);
}
}
}else{
$q1="insert into ".$table_pre."order (uid,upath,is_sp,iid,kh_dj,no,category,category1,season,sx,bc,series,brand,sxz,gender,theme,designer,price,price_zk,jgd,color,bx,size_group_id,".get_size_sql("insert1").",_key,add_date) values ('".$msg_to["id"]."','".$msg_to["path"]."-".$msg_to["id"]."','".$m["is_sp"]."','".$m["iid"]."','".$m["kh_dj"]."','".$m["no"]."','".$m["category"]."','".$m["category1"]."','".$m["season"]."','".$m["sx"]."','".$m["bc"]."','".$m["series"]."','".$m["brand"]."','".$m["sxz"]."','".$m["gender"]."','".$m["theme"]."','".$m["designer"]."','".$m["price"]."','".$m["price_zk"]."','".$m["jgd"]."','".$m["color"]."','".$m["bx"]."','".$m["size_group_id"]."',".get_size_sql("insert2").",'".$_key."','".time()."')";
$db->query($q1);
//行为记录log
$change_num=get_size_sql("count_total");
$action="21";
$q="insert into ".$table_pre."log_hd (uid,iid,num,ip,action,ms,hd_type,add_date) values ('".$msg_to["id"]."','".$m["iid"]."','".$change_num."','".$ip."','".$action."','".$log_hd_ms."','','".$add_date."')";
$db->query($q);
if($sys_ver_hy=="xz"){
//处理配码表
$q2="select * from ".$table_pre."order_pm where _key='".$_key."' and iid='".$m["iid"]."' and uid='".$m["uid"]."' and color='".$m["color"]."' and bx='".$m["bx"]."'";
$r2=$db->query($q2);
while($m2=$db->fetch_array($r2)){
//复制一份配码明细表
$m3=get_db_msg("select * from ".$table_pre."size_pm where id='".$m2["pmid"]."'");
$q4="insert into ".$table_pre."size_pm (title,uid,qyid,size_group_id,pm_dj,khid,gz,num) values ('".$m3["title"]."','".$msg_to["id"]."','".$m3["qyid"]."','".$m3["size_group_id"]."','".$m3["pm_dj"]."','".$m3["khid"]."','".$m3["gz"]."','".$m3["num"]."')";
$db->query($q4);
$pmid=$pmid=$db->insert_id();
//插入配码表记录
$xs1=get_gs_num($m2["xs"],$cp_gs_con,$cp_gs_num);
$q1="insert into ".$table_pre."order_pm (_key,uid,iid,color,bx,pmid,xs) values ('".$m2["_key"]."','".$msg_to["id"]."','".$m2["iid"]."','".$m2["color"]."','".$m2["bx"]."','".$pmid."','".$xs1."')";
$db->query($q1);
}
}
}
//echo $q1." ";
//记录订单表sql日志
update_order_log($msg_to["id"],$q1);
//
cache_order($msg_to["id"],$m["iid"],$m["color"],$m["bx"]);
}
}
set_order_total($msg_to["id"]);
$log_remark=$dp_from."到".$msg_to["username"].",".$msg_to["order_num"]."件";
set_log("复制订单",$log_remark);
$msg.="复制成功 ";
$msg_to=get_db_msg("select * from ".$table_pre."client where username='".$dp_to."'");
$msg.=$msg_to["title"].",当前订单总量".$msg_to["order_num"]."件 ";
$json_data.="\"code\":1,\"msg\":\"".$msg."\",";
}
//include template("report");
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_this);
$msg="";
//检测
$str_client=$str_no=$str_color=$str_bx=$str_size=$str_xs=$str_zxs="";
$ind_client=0;
$ind_no=1;
$ind_color=2;
$total_avail=0;
for($i=1;$i".$tmp_arr[0].",";
$avail="n";
}
//检测款号
$tmp=get_db_msg("select * from ".$table_pre."kh where no='".$tmp_arr[1]."'");
if($sys_ver_hy=="xz"){
$is_xd_clothes="y";
$msg_size_group=get_db_msg("select title from ".$table_pre."keyword where cate='size' and id='".$tmp["size_group"]."'");
if(in_array($msg_size_group["title"],$sys_size_group_xz))
$is_xd_clothes="n";
$xs=$tmp_arr[get_main_key($arr_thead,"箱数")];
if($is_xd_clothes!="n"){
//衣服箱数不允许大于一
if($xs>1){
$str_xs.="".$tmp_arr[1]."-".$tmp_arr[2].",";
$avail="n";
}
}
}
if($tmp["id"]>0){
//款号正确,检测颜色
$tmp1=get_db_msg("select * from ".$table_pre."keyword where cate='color' and no='".$tmp_arr[2]."'");
$arr_check_color=explode(",",$tmp["color"]);
if($tmp1["id"]>0 && in_array($tmp1["no"],$arr_check_color)){
//颜色正确
}else{
$str_color.="".$tmp_arr[1]."-".$tmp_arr[2].",";
$avail="n";
}
}else{
$str_no.="".$tmp_arr[1].",";
$avail="n";
}
//检测杯型
if($tmp["size_group"]>0 && $bx_sizegroup_id==$tmp["size_group"]){
$bx=deel_bx($tmp_arr[3]);
if($bx){
//杯型正确
}else{
//
$str_bx.="".$tmp_arr[3].",";
}
$size_start=4;
}else if($tmp["size_group"]>0 && $child_sizegroup_id==$tmp["size_group"]){
$bx=$tmp_arr[3];
if($bx){
//杯型正确
}else{
//
$str_bx.="".$tmp_arr[3].",";
}
$size_start=4;
}else{
if($bx_sizegroup_title!=""){
$size_start=4;
}else{
$size_start=3;
}
$bx="";
}
//检测规格
if($is_gg!="n"){
$is_gg_ks=is_gg_ks($tmp_arr[1],$tmp_arr[2]);
if($is_gg_ks=="y" && $tmp_arr[3]!=""){
$gg=get_gg_id($tmp_arr[3]);
if($gg>0){
//正确
}else{
//
$str_gg.="".$tmp_arr[1]."-".$tmp_arr[2]."-".$tmp_arr[3].",";
}
}else{
if($is_gg_ks!="y" && $tmp_arr[3]!=""){
$str_gg.="".$tmp_arr[1]."-".$tmp_arr[2]."不存在规格,";
}
}
$size_start=4;
}
if($avail=="y"){
if($sys_ver_hy=="xz"){
for($j=$size_start;$j0){
//检测这个尺码是否有效
if($tmp["size_group"]>0 && ($bx_sizegroup_id==$tmp["size_group"] || $child_sizegroup_id==$tmp["size_group"])){
$tmp_size=get_db_msg("select id,size from ".$table_pre."size_bx where no='".$tmp_arr[1]."' and bx='".$tmp_arr[3]."'");
if(!$tmp_size["id"]){
$tmp_size=get_db_msg("select size from ".$table_pre."kh where no='".$tmp_arr[1]."'");
}
}else{
$tmp_size=get_db_msg("select size from ".$table_pre."kh where no='".$tmp_arr[1]."'");
}
$tmp_size_arr=explode(",",$tmp_size["size"]);
if(in_array($s1,$tmp_size_arr)){
$sql_bx=$str_bx1="";
if($size_start==4){
$sql_bx=" and bx='".$tmp_arr[3]."'";
$str_bx1="-".$tmp_arr[3];
}
//检查不予下单尺码
$tmp_size_not=get_db_msg("select size from ".$table_pre."size_not where kh='".$tmp_arr[1]."' and color='".$tmp_arr[2]."'".$sql_bx);
$tmp_size_arr=explode(",",$tmp_size_not["size"]);
if(in_array($s1,$tmp_size_arr)){
//
$str_size.=$tmp_arr[1]."-".$tmp_arr[2].$str_bx1.":第".$s1."个尺码".$$v1."件 ";
}
}else{
$str_size.=$tmp_arr[1].":第".$s1."个尺码".$$v1."件 ";
}
}
}
//装箱数检查
if($sys_ver_hy=="xz"){
if($is_xd_clothes=="n"){
$arr_zxs=array();
$sql_zxs="select * from web_gz where cate='zxs' and kh='".$tmp_arr[1]."'";
$res_zxs=$db->query($sql_zxs);
while($msg_zxs=$db->fetch_array($res_zxs)){
$arr_zxs[]=$msg_zxs["num"];
}
if(is_array($arr_zxs)){
if(!in_array($num_tal,$arr_zxs)){
$str_zsx.="".$tmp_arr[1]."-".$tmp_arr[2].",";
}
}else{
$str_zsx.="".$tmp_arr[1]."-".$tmp_arr[2].",";
}
}
}
}
$str_check="";
if($str_client)
$str_check.="客户代码有误,请检查:".substr($str_client,0,-1)." ";
if($str_no)
$str_check.="款号有误,请检查:".substr($str_no,0,-1)." ";
if($str_color)
$str_check.="颜色代码有误,请检查:".substr($str_color,0,-1)." ";
if($str_bx)
$str_check.="杯型有误,请检查:".substr($str_bx,0,-1)." ";
if($str_gg)
$str_check.=d_translate("gg")."有误,请检查:".substr($str_gg,0,-1)." ";
if($str_size)
$str_check.="尺码有误,请检查:".substr($str_size,0,-1)." ";
if($str_xs)
$str_check.="箱数有误(衣服箱数不允许大于1),请检查:".substr($str_xs,0,-1)." ";
if($str_zsx)
$str_check.="装箱数有误,请检查:".substr($str_zsx,0,-1)." ";
$msg.=$str_check;
if(count($arr_column[0])==0){
$msg.="未检测到可导入字段,请返回检查EXCEL文件!";
del_tmp_file($tmp_file_name);
}
if($msg){
$json_data.="\"code\":0,\"msg\":\"".$msg."\",";
}else{
$msg1[0]=array("字段检测结果","无误");
//
$total=count($arr_content)-1;
$msg1[1]=array("本次有效订单总量",$total_avail);
$m1="";
for($i=0;$i$val2){
$tmp_client_ii=get_db_msg("select id from web_client where username='".$val2."'");
$db->query("delete from ".$table_pre."order where uid='".$tmp_client_ii["id"]."';");
//删除配码表
$db->query("delete from ".$table_pre."order_pm where uid='".$tmp_client_ii["id"]."'");
}
}
}
$log_hd_ms="后台导入订单";
$ip=$_SERVER["REMOTE_ADDR"];
$add_date=date("Y-m-d H:i:s");
//
$size_arr=array();
$res_size=$db->query("select id,title from ".$table_pre."keyword where cate='size'");
while($msg_size=$db->fetch_array($res_size)){
$size_arr[$msg_size["id"]]=$msg_size["title"];
}
$total_avail=0;
for($i=1;$i0){
//客户代码正确
$uid1=$tmp["id"];
}else{
$avail="n";
}
//检测款号
$tmp=get_db_msg("select * from ".$table_pre."kh where no='".$tmp_arr[1]."'");
$iid=$tmp["id"];
//鞋子版本箱数设置
if($sys_ver_hy=="xz"){
$is_xd_clothes="y";
if(in_array($size_arr[$tmp["size_group"]],$sys_size_group_xz))
$is_xd_clothes="n";
if($is_xd_clothes=="n"){
$xs=$tmp_arr[get_main_key($arr_thead,"箱数")];
}else{
$xs=1;
}
}
$m_kh=$tmp;
//款号正确,检测颜色
$tmp1=get_db_msg("select no from ".$table_pre."keyword where cate='color' and no='".$tmp_arr[2]."'");
$color=$tmp1["no"];
//检测杯型
if($bx_sizegroup_id==$tmp["size_group"]){
$bx=deel_bx($tmp_arr[3]);
if($bx){
//杯型正确
}else{
//
$avail="n";
}
$size_start=4;
}else if($child_sizegroup_id==$tmp["size_group"]){
$bx=$tmp_arr[3];
if($bx){
//杯型正确
}else{
//
$avail="n";
}
$size_start=4;
}else{
$bx="";
if($bx_sizegroup_title!=""){
$size_start=4;
}else{
$size_start=3;
}
}
//检测规格
if($is_gg=="y"){
$size_start=4;
}
if($avail=="y"){
if($sys_ver_hy=="xz"){
$pm_gz="";
$arr_size1=explode(",",$m_kh["size"]);
for($j=0;$j0){
$msg_to=get_db_msg("select * from ".$table_pre."client where id='".$uid1."'");
$m=get_db_msg("select * from ".$table_pre."kh where id='".$iid."'");
$c=get_db_msg("select * from ".$table_pre."order where iid='".$iid."' and color='".$color."' and bx='".$bx."' and uid='".$uid1."' and _key='".$_key."'");
//判断是否有规格
$is_ggk=is_ggk($iid);
$gg_color=$color;
$gg=$bx;
if($c["id"]>0){
$old_num=$c["num"];
$new_num=0;
for($s1=1;$s1<=$sys_size_num;$s1++){
$v1="num_".$s1;
$$v1+=$c[$v1];
$new_num+=$c[$v1];
}
//行为记录log
$change_num=$new_num-$old_num;
$action="23";
$q="insert into ".$table_pre."log_hd (uid,iid,num,ip,action,ms,hd_type,add_date) values ('".$msg_to["id"]."','".$c["iid"]."','".$change_num."','".$ip."','".$action."','".$log_hd_ms."','','".$add_date."')";
$db->query($q);
$q1="update ".$table_pre."order set ".get_size_sql("update").",add_date='".time()."' where id='".$c["id"]."'";
cache_order($uid1,$iid,$color,$bx);
}else{
//判断是否是删除款
$ka="n";
if($m["ka"]=="y"){
$ka="y";
}else{
$tmp=explode(",",$m["color_ka"]);
if(in_array($color,$tmp))
$ka="y";
}
//行为记录log
$change_num=get_size_sql("count_total");
$action="21";
$q="insert into ".$table_pre."log_hd (uid,iid,num,ip,action,ms,hd_type,add_date) values ('".$msg_to["id"]."','".$m["id"]."','".$change_num."','".$ip."','".$action."','".$log_hd_ms."','','".$add_date."')";
$db->query($q);
//
$q1="insert into ".$table_pre."order (uid,upath,iid,kh_dj,no,category,category1,season,sx,bc,series,brand,sxz,gender,theme,designer,price,price_zk,jgd,color,bx,ka,size_group_id,".get_size_sql("insert1").",_key,add_date) values ('".$uid1."','".$msg_to["path"]."-".$msg_to["id"]."','".$m["id"]."','".$m["kh_dj"]."','".$m["no"]."','".$m["category"]."','".$m["category1"]."','".$m["season"]."','".$m["sx"]."','".$m["bc"]."','".$m["series"]."','".$m["brand"]."','".$m["sxz"]."','".$m["gender"]."','".$m["theme"]."','".$m["designer"]."','".get_price_dp($uid1,$m["id"])."','".$m["price_zk"]."','".$m["jgd"]."','".$color."','".$bx."','".$ka."','".$m["size_group"]."',".get_size_sql("insert2").",'".$_key."','".time()."')";
}
//echo $q1." ";
$db->query($q1);
//判断是否采用服装版本下单
if($sys_ver_hy=="xz"){
//计算配码规则
if($pm_gz)
$pm_gz=substr($pm_gz,0,-1);
//取得配码id
$m_pm=get_db_msg("select id from ".$table_pre."size_pm where uid='".$uid1."' and gz='".$pm_gz."'");
if($m_pm["id"]>0){
$pmid=$m_pm["id"];
}else{
$pm_title="临时".get_rand_num(4);
$pm_num=count_pm_num($pm_gz);
$q="insert into ".$table_pre."size_pm (qyid,uid,size_group_id,pm_dj,khid,title,gz,num) values ('0','".$uid1."','".$m["size_group"]."','临时配码','".$m["id"]."','".$pm_title."','".$pm_gz."','".$pm_num."')";
//echo $q." ";
$db->query($q);
$pmid=$db->insert_id();
}
$tmp_ord_pm=get_db_msg("select id,xs from web_order_pm where _key='".$_key."' and uid='".$uid1."' and iid='".$m["id"]."' and color='".$color."' and bx='".$bx."' and pmid='".$pmid."' limit 0,1");
if($tmp_ord_pm["id"]>0){
if($is_xd_clothes=="n"){
$dqsx=$xs+$tmp_ord_pm["xs"];
$q="update ".$table_pre."order_pm set xs='".$dqsx."' where id='".$tmp_ord_pm["id"]."'";
}else{
$q="update ".$table_pre."order_pm set xs='1' where id='".$tmp_ord_pm["id"]."'";
}
$db->query($q);
}else{
$q="insert into ".$table_pre."order_pm (_key,uid,iid,color,bx,pmid,xs) values ('".$_key."','".$uid1."','".$m["id"]."','".$color."','".$bx."','".$pmid."','".$xs."')";
$db->query($q);
}
}
//记录订单表sql日志
update_order_log($uid1,$q1);
//
cache_order($uid1,$m["id"],$color,$bx);
//------------------------------导入订单配码表
}
set_order_total($uid1);
}
}
//
del_tmp_file($tmp_file_name);
$log_remark=$msg_to["username"].",".$total_avail."件";
set_log("导入订单",$log_remark);
break;
//----------------------------------------------------------------------/导入EXCEL
case "cache_order":
if($step==1){
$con_u=$con_kh="";
if($s_uid && $s_uid!="all"){
$m_client=get_db_msg("select * from ".$table_pre."client where id='".$s_uid."'");
if($m_client["face"]=="4")
$con_u=" and uid='".$m_client["id"]."'";
else
$con_u=" and upath like '".$m_client["path"]."-".$m_client["id"]."-%'";
}else{
$con_u="";
}
if($s_kh){
$tmp=get_db_msg("select id from ".$table_pre."kh where no='".$s_kh."'");
if($tmp["id"]>0)
$con_kh=" and iid='".$tmp["id"]."'";
}
//-------------------检测
$step=500;
//$step=1;
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."order where iid>0 and _key='".$_key."' ".$con_u.$con_kh." order by id");
//echo "select count(*) 'num' from ".$table_pre."order where iid>0 ".$con_u.$con_kh." order by id";
$total=$tmp["num"];
//$total=9;
$next=$next?$next:1;
$limit1=($next-1)*$step;
$q="select uid,iid,color,bx from ".$table_pre."order where iid>0 and _key='".$_key."' ".$con_u.$con_kh." order by id limit ".$limit1.",".$step;
if($total-$next*$step<0){
$r=$db->query($q);
while($m=$db->fetch_array($r)){
cache_order($m["uid"],$m["iid"],$m["color"],$m["bx"]);
}
$msg=$total."条订单缓存完成!";
$ok="y";
}else{
$r=$db->query($q);
while($m=$db->fetch_array($r)){
cache_order($m["uid"],$m["iid"],$m["color"],$m["bx"]);
}
$msg=($next*$step)."/".$total."条订单缓存完成,还在努力处理中...";
$next++;
//$url=$_SERVER["PHP_SELF"]."?_m=".$_m."&_cid=".$_cid."&s_uid=".$s_uid."&s_kh=".$s_kh."&_a=cache_order&step=1&&next=".$next;
//url_redirect($url);
$ok="n";
}
$json_data.="\"msg\":\"".$msg."\",";
$json_data.="\"s_uid\":\"".$s_uid."\",";
$json_data.="\"s_kh\":\"".$s_kh."\",";
$json_data.="\"next\":\"".$next."\",";
$json_data.="\"total\":\"".$total."\",";
$json_data.="\"ok\":\"".$ok."\",";
$json_data.="\"code\":1,";
}else{
//include template("report");
}
break;
case "cache_client":
if($step==1){
//重新缓存客户表的金额字段
if($s_uid && $s_uid!="all"){
$m_client=get_db_msg("select * from ".$table_pre."client where id='".$s_uid."'");
if($m_client["face"]=="4")
$con_u=" where id='".$m_client["id"]."'";
else
$con_u=" where (path like '".$m_client["path"]."-".$m_client["id"]."-%' or path='".$m_client["path"]."-".$m_client["id"]."')";
}else{
$con_u="";
}
//$json_data.="\"s_uid\":\"".$s_uid."\",";
$list=$list?$list:1;
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."client".$con_u);
//$json_data.="\"q\":\"select count(*) 'num' from ".$table_pre."client".$con_u."\",";
$total=$tmp["num"];
if(!$id){
//
$tmp=get_db_msg("select min(id) 'id' from ".$table_pre."client".$con_u);
$this_id=$tmp["id"];
}else{
if($con_u)
$tmp1=$con_u." and id>'".$id."'";
else
$tmp1=" where id>'".$id."'";
$tmp=get_db_msg("select min(id) 'id' from ".$table_pre."client ".$tmp1);
$this_id=$tmp["id"];
}
//取得最大id
$tmp=get_db_msg("select max(id) 'id' from ".$table_pre."client".$con_u);
if($id<$tmp["id"]){
$m_client=get_db_msg("select * from ".$table_pre."client where id='".$this_id."'");
set_order_total($this_id);
//echo $list."/".$total.":".$m_client["title"]."(".$m_client["username"]."),缓存完成,暂停 ";
//
$msg=$list."/".$total.":".$m_client["title"]."(".$m_client["username"]."),缓存完成";
$list++;
//$url=$_SERVER["PHP_SELF"]."?_m=".$_m."&_cid=".$_cid."&s_uid=".$s_uid."&step=1&_a=cache_client&id=".$this_id."&list=".$list;
//url_redirect($url);
$ok="n";
}else{
set_order_total($s_uid);
//echo $total."个客户缓存完成!返回";
$msg=$total."个客户缓存完成!";
$ok="y";
}
$json_data.="\"s_uid\":\"".$s_uid."\",";
$json_data.="\"list\":\"".$list."\",";
$json_data.="\"id\":\"".$this_id."\",";
$json_data.="\"msg\":\"".$msg."\",";
$json_data.="\"total\":\"".$total."\",";
$json_data.="\"ok\":\"".$ok."\",";
$json_data.="\"code\":1,";
}else{
//include template("report");
}
break;
case "cache_ph":
cache_ph();
//$json_data.="\"code\":1,";
break;
//-------------主界面
default :
//
$page=$page>0?$page:1;
$limit=$limit>0?$limit:10;
$start=($page-1)*$limit;
$end=$limit;
$order=$order?$order:"add_date!";
$s_key=$s_key?$s_key:$_key;
$s_ka=$s_ka?$s_ka:"n";
$sql_con="";
if($s_key)
$sql_con.="_key='".$s_key."' and ";
if($s_dp){
$tmp=get_db_msg("select * from ".$table_pre."client where username='".$s_dp."'");
if($tmp["id"]>0)
$sql_con.="uid='".$tmp["id"]."' and ";
else
alert_and_back("店铺代码有误,请检查!");
}
if($s_ka && $s_ka<>"show_all")
$sql_con.="ka='".$s_ka."' and ";
if($s_no)
$sql_con.="no like '%".$s_no."%' and ";
if($s_color)
$sql_con.="color='".$s_color."' and ";
if($s_uid)
$sql_con.="uid='".$s_uid."' and ";
if($sql_con)
$sql_con="where ".substr($sql_con,0,-4);
$sql_order=str_replace("!"," desc",$order);
$query="select count(*) 'total' from ".$table_pre."order ".$sql_con." and _key='".$_key."'";
$res=$db->query($query);
$msg=$db->fetch_array($res);
$total=$msg["total"];
$select_dz="";
//取得选项
$tmp="";
$tmp.="{\"no\":\"show_all\",\"title\":\"全部\"},";
foreach($arr_yn as $v => $t){
$tmp.="{\"no\":\"".$v."\",\"title\":\"".$t."\"},";
}
$tmp=deel_end($tmp);
$var="s_ka";
$select_dz.="{\"no\":\"ka\",\"title\":\"-是否删除款-\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
$tmp="";
$r1=$db->query("select * from ".$table_pre."keyword where cate='color' ");
while($m1=$db->fetch_array($r1)){
$tmp.="{\"no\":\"".$m1["no"]."\",\"title\":\"".$m1["title"]."\"},";
}
$tmp=deel_end($tmp);
$var="s_color";
$select_dz.="{\"no\":\"color\",\"title\":\"-颜色-\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
$select_dz=deel_end($select_dz);
$json_data.="\"select_dz\":[".$select_dz."],";
//------------
$query="select * from ".$table_pre."order ".$sql_con." and _key='".$_key."' order by ".$sql_order." limit ".$start.",".$end;
//echo $query." ";
$res=$db->query($query);
$count=0;
$json_data.="\"code\":0,\"msg\":\"\",\"count\":".$total.",\"data\":[";
$str_tmp="";
while($msg=$db->fetch_array($res)){
$list=$start+$count+1;
$content[$count][]=$list;
$content[$count][]=get_main_value($arr_yn,$msg["ka"]);
$tmp=get_db_msg("select username,title from ".$table_pre."client where id='".$msg["uid"]."'");
$str_tmp.="{";
$str_tmp.="\"id\":\"".$msg["id"]."\",";
$str_tmp.="\"cid\":\"".$msg["uid"]."\",";
$str_tmp.="\"xh\":\"".$list."\",";
$ka=get_main_value($arr_yn,$msg["ka"]);
$str_tmp.="\"ka\":\"".$ka."\",";
$str_tmp.="\"title\":\"".$tmp["title"]."\",";
$str_tmp.="\"username\":\"".$tmp["username"]."\",";
$dp=$tmp["title"]."(".$tmp["username"].")";
$str_tmp.="\"dp\":\"".$dp."\",";
$str_tmp.="\"kh\":\"".$msg["no"]."\",";
$color=$msg["color"]."-".get_cate_title_no("color",$msg["color"]);
$str_tmp.="\"color\":\"".$color."\",";
//$str_tmp.="\"color\":\"".$msg["color"]."\",";
if($bx_sizegroup_id>0 || $child_sizegroup_id>0)
$str_tmp.="\"bx\":\"".$msg["bx"]."\",";
if($is_gg!="n")
$str_tmp.="\"gg\":\"".get_gg_title($msg["bx"])."\",";
//$str_tmp.="\"color\":\"".$msg["color"]."\",";
$date=date("Y-m-d H:i",$msg["add_date"]);
$str_tmp.="\"date\":\"".$date."\",";
//
$content[$count][]=$tmp["title"]."(".$tmp["username"].")";
$content[$count][]="".$msg["no"]."";
$content[$count][]=$msg["color"]."-".get_cate_title_no("color",$msg["color"]);
if($bx_sizegroup_id>0 || $child_sizegroup_id>0)
$content[$count][]=$msg["bx"];
if($is_gg!="n")
$content[$count][]=get_gg_title($msg["bx"]);
$num=0;
$str_size_title="
";
$str_size_num="
";
$q1="select * from ".$table_pre."size where iid='".$msg["size_group_id"]."' order by no";
$r1=$db->query($q1);
$tmpn="";
while($m1=$db->fetch_array($r1)){
$str_size_title.="