doPost.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. //查询配置
  3. include_once("../../untils/conn.php");
  4. $sql = "SELECT * FROM kefu";
  5. $result = mysqli_query($con, $sql);
  6. if ($result) {
  7. $row = mysqli_fetch_assoc($result);
  8. $appid = $row['appid'];
  9. $key = $row['key'];
  10. }
  11. // 获取表单数据
  12. $user_id = $appid;
  13. $timestamp = time();
  14. $name = $_POST['name'];
  15. $phone = $_POST['phone'];
  16. $idcard = $_POST['uid'];
  17. $province = $_POST['sf'];
  18. $city = $_POST['city'];
  19. $area = $_POST['xian'];
  20. $address = $_POST['dizhi'];
  21. $product_id = $_POST['haokaid'];
  22. $down_order_id = $_POST['oderid'];
  23. $third_phone = "";
  24. $secret = $key;
  25. // 计算签名
  26. $user_sign = md5(
  27. "Address=" . $address .
  28. "&Area=" . $area .
  29. "&City=" . $city .
  30. "&DownOrderID=" . $down_order_id .
  31. "&IDCard=" . $idcard .
  32. "&Name=" . $name .
  33. "&Phone=" . $phone .
  34. "&ProductID=" . $product_id .
  35. "&Province=" . $province .
  36. "&ThirdPhone=" . $third_phone .
  37. "&Timestamp=" . $timestamp .
  38. "&user_id=" . $user_id .
  39. $secret);
  40. // 构造请求参数
  41. $post_data = array(
  42. 'user_id' => $user_id,
  43. 'Timestamp' => $timestamp,
  44. 'Name' => $name,
  45. 'Phone' => $phone,
  46. 'IDCard' => $idcard,
  47. 'Province' => $province,
  48. 'City' => $city,
  49. 'Area' => $area,
  50. 'Address' => $address,
  51. 'ProductID' => $product_id,
  52. 'DownOrderID' => $down_order_id,
  53. 'ThirdPhone' => $third_phone,
  54. 'user_sign' => $user_sign.$secret
  55. );
  56. $json_data = json_encode($post_data);
  57. echo $json_data;
  58. // 提交请求
  59. // $url = "https://haokaopenapi.lot-ml.com/api/order/ApiToOrder";
  60. // $ch = curl_init();
  61. // curl_setopt($ch, CURLOPT_URL, $url);
  62. // curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  63. // curl_setopt($ch, CURLOPT_POST, 1);
  64. // curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
  65. // $output = curl_exec($ch);
  66. // curl_close($ch);
  67. // 解析返回结果
  68. $result = json_decode($output, true);
  69. if ($result['code'] == 0) {
  70. echo "下单成功,订单号:" . $result['message'];
  71. } else {
  72. echo "下单失败,错误信息:" . $result['message'];
  73. }
  74. ?>