buycheck.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?
  2. $carid=$_GET[carid];
  3. if($carid==""){php_toheader("car.php");}
  4. $c=preg_split("/c/",$carid);
  5. $needmoney=0;
  6. $caridarr="";
  7. $zfbordertit=""; //支付宝订单名称
  8. for($i=0;$i<count($c);$i++){
  9. if($c[$i]!=""){
  10. $d=preg_split("/-/",$c[$i]);
  11. $id=$d[0];
  12. $caridarr=$caridarr.$id."xcf";
  13. $num=intval($d[1]);
  14. if($num<=0){Audit_alert("错误,购买数量不得少于1,返回重试","car.php");}
  15. while0("*","yjcode_car where userid=".$rowuser[id]." and id=".$id."");if(!$row=mysql_fetch_array($res)){php_toheader("car.php");}
  16. while1("*","yjcode_pro where bh='".$row[probh]."' and zt=0 and ifxj=0");if(!$row1=mysql_fetch_array($res1)){Audit_alert("商品已下架或未审核","car.php");}
  17. $zfbordertit=$zfbordertit.$row1[tit]." ";
  18. $money=returnyhmoney($row1[yhxs],$row1[money2],$row1[money3],$sj,$row1[yhsj1],$row1[yhsj2],$row1[id]);
  19. $kcnum=$row1[kcnum];
  20. $fhxsnum=$row1[fhxs];
  21. if(empty($row[tcid])){$zm=$money;$tcv="";$tcfhxs=0;}
  22. else{
  23. while2("*","yjcode_taocan where id=".$row[tcid]);if(!$row2=mysql_fetch_array($res2)){Audit_alert("套餐已下架,请联系客服","car.php");}
  24. $zm=$row2[money1];
  25. $tcfhxs=$row2[fhxs];
  26. if(!empty($row2[fhxs])){$kcnum=$row2[kcnum];}
  27. if($row2[admin]==2){$tcv=$row2[tit]." ".$row2[tit2];}else{$tcv=$row2[tit];}
  28. }
  29. if($kcnum<$num){Audit_alert("库存不够了","car.php");}
  30. if(!empty($row1[ifuserdj])){
  31. $sqlu2="select * from yjcode_user where uid='".$_SESSION[SHOPUSER]."'";mysql_query("SET NAMES 'GBK'");$resu2=mysql_query($sqlu2);$rowu2=mysql_fetch_array($resu2);
  32. if(!empty($rowu2[userdj])){$s=" and name1='".$rowu2[userdj]."'";$djname=$rowu2[userdj];}else{$s="";$djname="";}
  33. $sqlu4="select * from yjcode_prouserdj where probh='".$row[probh]."' and djname='".$djname."'";mysql_query("SET NAMES 'GBK'");$resu4=mysql_query($sqlu4);
  34. if($rowu4=mysql_fetch_array($resu4)){
  35. $zm=$zm*($rowu4[zhi]/10);
  36. }else{
  37. $sqlu3="select * from yjcode_userdj where zt=0".$s." order by xh asc limit 1";mysql_query("SET NAMES 'GBK'");$resu3=mysql_query($sqlu3);
  38. if($rowu3=mysql_fetch_array($resu3)){
  39. $zm=$zm*($rowu3[zhekou]/10);
  40. }
  41. }
  42. }
  43. $yf=0;
  44. if(!empty($row[shdzid]) && ($tcfhxs==5 || ($fhxsnum==5 && $tcfhxs==0))){
  45. $sqlu1="select * from yjcode_shdz where id=".$row[shdzid];mysql_query("SET NAMES 'GBK'");$resu1=mysql_query($sqlu1);if($rowu1=mysql_fetch_array($resu1)){
  46. $yf=returnyunfei($row1[userid],$row[shdzid],$num,$row1[bh]);
  47. $shdz=$rowu1[lxr]."(".$rowu1[mot].") ".$rowu1[add1v].$rowu1[add2v].$rowu1[add3v].$rowu1[addr]." 邮编:".$rowu1[yb];
  48. }
  49. }
  50. $needmoney=$needmoney+$zm*$num+$yf;
  51. updatetable("yjcode_car","num=".$num.",money1=".$zm.",tcv='".$tcv."',shdz='".$shdz."',yunfei=".$yf.",tcfhxs=".$tcfhxs." where id=".$id);
  52. }
  53. }
  54. $usermoney=$rowuser[money1];
  55. $sxf=0;
  56. if(!empty($rowcontrol[paysxf]) && $needmoney>$usermoney){
  57. $sxf=str_replace("0.00",0,sprintf("%.2f",($needmoney-$usermoney)*$rowcontrol[paysxf]));
  58. }
  59. $needmoney=$needmoney+$sxf;
  60. $usermoney=sprintf("%.2f",$usermoney);
  61. $needmoney=sprintf("%.2f",$needmoney);
  62. $zfbordertit=returntitdian($zfbordertit,100); //限制标题长度,否则支付宝会失败
  63. ?>