Order.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. session_start();
  3. include_once("../../untils/conn.php");
  4. mysqli_query($con, "set names utf8");
  5. // 获取当前正在登录的账号信息的代理
  6. $proxy_acc = $_SESSION["account"];
  7. // 防止 SQL 注入攻击
  8. $proxy_acc = mysqli_real_escape_string($con, $proxy_acc);
  9. // 查询 proxy 表,找到符合条件的数据并输出给前端
  10. $sql = "SELECT * FROM proxy WHERE proxy_acc = '$proxy_acc'";
  11. $result = mysqli_query($con, $sql);
  12. if ($result) {
  13. $rows = mysqli_fetch_assoc($result);
  14. $id = $rows["proxy_id"];
  15. // 防止 SQL 注入攻击
  16. $id = mysqli_real_escape_string($con, $id);
  17. // 查询 proxy 表,根据 proxy_upid 来查找数据并将数据存储在数组中
  18. $sql = "SELECT proxy_id, proxy_acc FROM proxy WHERE proxy_upid = '$id'";
  19. $result = mysqli_query($con, $sql);
  20. if ($result) {
  21. $proxyIds = array();
  22. $proxyAccounts = array();
  23. // 循环遍历数据并将每个 proxy_id 和 proxy_acc 存储在数组中
  24. while($row = mysqli_fetch_assoc($result)) {
  25. $proxyIds[] = $row['proxy_id'];
  26. $proxyAccounts[$row['proxy_id']] = $row['proxy_acc'];
  27. }
  28. // 添加当前代理的 proxy_id 和 proxy_acc 到数组中
  29. $proxyIds[] = $id;
  30. $proxyAccounts[$id] = $proxy_acc;
  31. // 将代理ID数组转换为逗号分隔的字符串
  32. $proxyIdsStr = implode(",", $proxyIds);
  33. // 查询 order 表,根据 proxy_id 来查找数据并将数据存储在数组中
  34. $sql = "SELECT * FROM oder WHERE proxy_id IN ($proxyIdsStr)";
  35. $result = mysqli_query($con, $sql);
  36. if ($result) {
  37. $data = array();
  38. // 循环遍历数据并将每条数据存储在一个数组中
  39. while($row = mysqli_fetch_assoc($result)) {
  40. $oderid = $row['oderid'];
  41. $goods = $row['goods'];
  42. $name = $row['name'];
  43. $phone = $row['phone'];
  44. $card_sta = $row['card_sta'];
  45. $oder_sta = $row['status'];
  46. $notes = $row['beizhu'];
  47. $dn_time = $row['time'];
  48. $timestamp = date('Y-m-d H:i:s', $dn_time);
  49. $proxy_id = $row['proxy_id'];
  50. $account = $proxyAccounts[$proxy_id];
  51. $data[] = array(
  52. "order_id" => $oderid,
  53. "goods_name" => $goods,
  54. "account" => $account,
  55. "name" => $name,
  56. "phone" => $phone,
  57. "card_sta" => $card_sta,
  58. "order_sta" => $oder_sta,
  59. "notes" => $notes,
  60. "order_time" => $timestamp
  61. );
  62. }
  63. // 将数据转换为 JSON 格式并输出到前端
  64. echo json_encode($data);
  65. } else {
  66. // 输出错误信息到前端
  67. echo "查询失败,请稍后重试!";
  68. }
  69. } else {
  70. // 输出错误信息到前端
  71. echo "查询失败,请稍后重试!";
  72. }
  73. } else {
  74. // 输出错误信息到前端
  75. echo "查询失败,请稍后重试!";
  76. }
  77. // 关闭数据库连接
  78. mysqli_close($con);