Shops.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. //获取规格
  29. public function getSpec(ShopList $shopList){
  30. $shop_id = $this->request->post('shop_id/d');
  31. if( empty($shop_id)){
  32. $this->error('参数有误');
  33. }
  34. return $this->success('ok', json_decode($shopList->where('id', $shop_id)->value('type_spec'), true));
  35. }
  36. function doCurlPostRequest($url = '',Array $data = array())
  37. {
  38. $data_string = json_encode($data,JSON_UNESCAPED_UNICODE);
  39. // $data_string = $data;
  40. $curl_con = curl_init();
  41. curl_setopt($curl_con, CURLOPT_URL,$url);
  42. curl_setopt($curl_con, CURLOPT_HEADER, false);
  43. curl_setopt($curl_con, CURLOPT_POST, true);
  44. curl_setopt($curl_con, CURLOPT_RETURNTRANSFER, TRUE);
  45. curl_setopt($curl_con, CURLOPT_CONNECTTIMEOUT, 5);
  46. curl_setopt($curl_con, CURLOPT_HTTPHEADER, array(
  47. 'Content-Type: application/json',
  48. 'Content-Length: ' . strlen($data_string))
  49. );
  50. curl_setopt($curl_con, CURLOPT_POSTFIELDS, $data_string);
  51. $res = curl_exec($curl_con);
  52. $status = curl_getinfo($curl_con);
  53. curl_close($curl_con);
  54. if (isset($status['http_code']) && $status['http_code'] == 200) {
  55. return $res;
  56. } else {
  57. return FALSE;
  58. }
  59. }
  60. }