proxyyue.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. include_once("../../untils/conn.php");
  3. $proxy_id = $_POST['proxy_id'];
  4. $oderid = $_POST['oderid'];
  5. $price = $_POST['price'];
  6. $type = $_POST['type'];
  7. $notes = $_POST['notes'];
  8. $sutime = time();
  9. // 查询proxy表中proxy_sta等于$proxy_id的数据
  10. $sql = "SELECT * FROM proxy WHERE proxy_id = $proxy_id";
  11. $result = mysqli_query($con, $sql);
  12. // 检查查询结果
  13. if (mysqli_num_rows($result) > 0) {
  14. $row = mysqli_fetch_assoc($result);
  15. $proxy_acc = $row['proxy_acc'];
  16. $proxy_balance = $row['proxy_balance'];
  17. // 根据type进行不同的操作
  18. if ($type == 0) {
  19. $new_balance = $proxy_balance + $price;
  20. $update_sql = "UPDATE proxy SET proxy_balance = $new_balance WHERE proxy_id = $proxy_id";
  21. mysqli_query($con, $update_sql);
  22. // 在revenue表中新增数据
  23. $insert_sql = "INSERT INTO revenue (account, oderid, type, price, beizhu, fund_notes, oder_sta, state, cr_time, dz_time) VALUES ('$proxy_acc', '$oderid', $type, $price, '$notes', '$notes', 3, 2, $sutime, $sutime)";
  24. mysqli_query($con, $insert_sql);
  25. } elseif ($type == 1) {
  26. $new_balance = $proxy_balance - $price;
  27. $update_sql = "UPDATE proxy SET proxy_balance = $new_balance WHERE proxy_id = $proxy_id";
  28. mysqli_query($con, $update_sql);
  29. // 在revenue表中新增数据
  30. $insert_sql = "INSERT INTO revenue (account, oderid, type, price, beizhu, fund_notes, oder_sta, state, cr_time, dz_time) VALUES ('$proxy_acc', '$oderid', $type, $price, '$notes', '$notes', 3, 3, $sutime, $sutime)";
  31. mysqli_query($con, $insert_sql);
  32. }
  33. // 在revenue表中新增数据
  34. // $insert_sql = "INSERT INTO revenue (account, oderid, type, price, beizhu, fund_notes, oder_sta, state, cr_time, dz_time) VALUES ('$proxy_acc', '$oderid', $type, $price, '$notes', '$notes', 3, 3, $sutime, $sutime)";
  35. // mysqli_query($con, $insert_sql);
  36. // 执行成功后的操作
  37. echo "<script>alert('操作成功');setTimeout(function(){window.location.href='../proxylist.php';}, 1000);</script>";
  38. } else {
  39. // 商品不存在的操作
  40. echo "<script>alert('操作失败');setTimeout(function(){window.location.href='../proxylist.php';}, 1000);</script>";
  41. }
  42. mysqli_close($con);
  43. ?>