add_refer.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. include_once "../../include/DB.php";
  3. $RiderID="";
  4. $SwapReferCount="";
  5. if (isset($_POST["RiderID"]) && !empty($_POST["RiderID"])) {
  6. $RiderID=$_POST["RiderID"];
  7. }
  8. if (isset($_POST["SwapReferCount"]) && !empty($_POST["SwapReferCount"])) {
  9. $SwapReferCount=$_POST["SwapReferCount"];
  10. }
  11. /////////////////////////////////////////////////////////////////////////////////////////////////////
  12. $RiderPostData = array(
  13. 'RiderID' => $RiderID
  14. );
  15. $CheckRidertURL = "http://localhost/cygnusa/batterySwap/api/User/";
  16. $CheckRidertCURL = curl_init($CheckRidertURL);
  17. curl_setopt($CheckRidertCURL, CURLOPT_HEADER, false);
  18. curl_setopt($CheckRidertCURL, CURLOPT_RETURNTRANSFER, true);
  19. curl_setopt($CheckRidertCURL, CURLOPT_POST, true);
  20. curl_setopt($CheckRidertCURL, CURLOPT_POSTFIELDS, $RiderPostData);
  21. $CheckRidertJsonResponse = curl_exec($CheckRidertCURL);
  22. $RiderResult = json_decode($CheckRidertJsonResponse, true);
  23. $TotalReferdSwapCount=$RiderResult["SwapData"]["ReferData"]["Total"];
  24. $UsedReferdSwapCount=$RiderResult["SwapData"]["ReferData"]["Used"];
  25. $AvailableReferdSwapCount=$RiderResult["SwapData"]["ReferData"]["Available"];
  26. $SwapReferID=$RiderResult["SwapData"]["ReferData"]["SwapReferID"];
  27. //////////////////////////////////////////////////////////////////////////////////////////////////
  28. $ReferPostData = array(
  29. 'SwapReferID' => $SwapReferID,
  30. 'TotalReferdSwapCount' => ($TotalReferdSwapCount+$SwapReferCount),
  31. 'UsedReferdSwapCount' => $UsedReferdSwapCount,
  32. 'AvailableReferdSwapCount' => ($AvailableReferdSwapCount+$SwapReferCount),
  33. );
  34. $ReferURL = "http://localhost/cygnusa/batterySwap/api/Admin/Refer/";
  35. $ReferCURL = curl_init($ReferURL);
  36. curl_setopt($ReferCURL, CURLOPT_HEADER, false);
  37. curl_setopt($ReferCURL, CURLOPT_RETURNTRANSFER, true);
  38. curl_setopt($ReferCURL, CURLOPT_POST, true);
  39. curl_setopt($ReferCURL, CURLOPT_POSTFIELDS, $ReferPostData);
  40. $ReferJsonResponse = curl_exec($ReferCURL);
  41. $ReferResult = json_decode($ReferJsonResponse, true);
  42. $value = array(
  43. "RiderID"=>$RiderID,
  44. "Refer"=>$ReferResult,
  45. "Message"=>"Swap Data saved successfully",
  46. );
  47. // Use json_encode() function
  48. $json = json_encode($value);
  49. // Display the output
  50. echo ($json);
  51. $conn->close();