Shops.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\model\ApiUser;
  4. use app\common\model\Orders;
  5. use app\common\model\ShopList;
  6. use think\facade\Db;
  7. use think\Exception;
  8. use think\facade\Request;
  9. use think\Log;
  10. class Shops extends Base
  11. {
  12. // protected $noNeedLogin = [''];
  13. /**
  14. * @return void 全部平台
  15. */
  16. public function getPlatform(){
  17. $list = site_config('addonsd.platform_list');
  18. $this->success('提交成功', $list);
  19. }
  20. //获取店铺
  21. public function getShop(ShopList $shopList){
  22. $platform_id = $this->request->post('platform_id/d');
  23. if(empty($platform_id)){
  24. $this->error('参数有误');
  25. }
  26. return $this->success('ok', $shopList->where('platform', $platform_id)->column('name', 'id'));
  27. }
  28. public function createAddress(){
  29. $tx_hash = Request::post('tx_hash');
  30. $api_url = 'http://127.0.0.1:3389/api/txDetail';
  31. if(empty($tx_hash)){
  32. $this->error('参数有误');
  33. }
  34. $data = [
  35. 'api_id' => 1,
  36. 'coin_type' => 'BEP20',
  37. 'user_no' => 1,
  38. 'time_stamp' => 1122,
  39. 'reset' => true
  40. ];
  41. $body = $this->doCurlPostRequest($api_url, $data);
  42. //dump($body);
  43. $info = json_decode($body, true);
  44. //dump($body);
  45. //$body = $this->getInfoByTransactionHash($txhash);
  46. if($info['code'] == 200){
  47. $this->success('', $info['data']);
  48. }
  49. $this->error($info['message']);
  50. }
  51. function doCurlPostRequest($url = '',Array $data = array())
  52. {
  53. $data_string = json_encode($data,JSON_UNESCAPED_UNICODE);
  54. // $data_string = $data;
  55. $curl_con = curl_init();
  56. curl_setopt($curl_con, CURLOPT_URL,$url);
  57. curl_setopt($curl_con, CURLOPT_HEADER, false);
  58. curl_setopt($curl_con, CURLOPT_POST, true);
  59. curl_setopt($curl_con, CURLOPT_RETURNTRANSFER, TRUE);
  60. curl_setopt($curl_con, CURLOPT_CONNECTTIMEOUT, 5);
  61. curl_setopt($curl_con, CURLOPT_HTTPHEADER, array(
  62. 'Content-Type: application/json',
  63. 'Content-Length: ' . strlen($data_string))
  64. );
  65. curl_setopt($curl_con, CURLOPT_POSTFIELDS, $data_string);
  66. $res = curl_exec($curl_con);
  67. $status = curl_getinfo($curl_con);
  68. curl_close($curl_con);
  69. if (isset($status['http_code']) && $status['http_code'] == 200) {
  70. return $res;
  71. } else {
  72. return FALSE;
  73. }
  74. }
  75. }