doWtin.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. $id = $_POST['id'];
  3. $state = $_POST['state'];
  4. $tx_price = $_POST['tx_price'];
  5. $proxy_acc = $_POST['proxy_acc'];
  6. $dk_price = $_POST['dk_price'];
  7. $notes = $_POST['notes'];
  8. $cl_time = $_POST['cl_time'];
  9. include_once("../../untils/conn.php");
  10. if ($con) {
  11. mysqli_query($con, "set names utf8");
  12. // 更新 withdrawal 表
  13. $stmt = $con->prepare("UPDATE withdrawal SET state=?, dk_price=?, notes=?, cl_time=? WHERE id=?");
  14. $stmt->bind_param("ssssi", $state, $dk_price, $notes, $cl_time, $id);
  15. $stmt->execute();
  16. if ($stmt->affected_rows > 0) {
  17. if ($state == 2) {
  18. // 查询代理账户余额
  19. $query = $con->prepare("SELECT proxy_balance FROM proxy WHERE proxy_acc=?");
  20. $query->bind_param("s", $proxy_acc);
  21. $query->execute();
  22. $result = $query->get_result();
  23. if ($result->num_rows > 0) {
  24. $row = $result->fetch_assoc();
  25. $proxy_balance = $row['proxy_balance'];
  26. // 更新代理账户余额
  27. $new_proxy_balance = $proxy_balance + $tx_price;
  28. $update = $con->prepare("UPDATE proxy SET proxy_balance=? WHERE proxy_acc=?");
  29. $update->bind_param("ds", $new_proxy_balance, $proxy_acc);
  30. $update->execute();
  31. if ($update->affected_rows > 0) {
  32. echo "<script>alert('操作成功');window.location.href='../withdrawal.php'</script> ";
  33. } else {
  34. echo ("<script>alert('更新代理账户余额失败');window.location.replace(document.referrer)</script>");
  35. }
  36. } else {
  37. echo ("<script>alert('代理账户不存在');window.location.replace(document.referrer)</script>");
  38. }
  39. } else {
  40. echo "<script>alert('操作成功');window.location.href='../withdrawal.php'</script> ";
  41. }
  42. } else {
  43. echo ("<script>alert('操作失败');window.location.replace(document.referrer)</script>");
  44. }
  45. }
  46. $con->close();
  47. ?>