Merchant.Class.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * 达达商户管理接口
  4. * Created by PhpStorm.
  5. * User: phperstar
  6. * Date: 2020/11/12
  7. * Time: 10:52 AM
  8. */
  9. namespace Util\DaDa;
  10. use Mall\Framework\Core\ResultWrapper;
  11. use Util\DaDa\Common;
  12. class Merchant
  13. {
  14. private $objCommon;
  15. // 基础域名
  16. private $baseUrl = 'http://newopen.qa.imdada.cn';
  17. //公共header头
  18. private $commonHeader = [
  19. CURLOPT_HTTPHEADER => [
  20. 'Content-Type: application/json'
  21. ],
  22. ];
  23. public function __construct($appKey='', $appSecret = '', $sourceId)
  24. {
  25. $this->objCommon = new Common($appKey, $appSecret, $sourceId);
  26. }
  27. /**
  28. * 官方文档地址: http://newopen.imdada.cn/#/development/file/cityList?_k=m88rtv
  29. * 获取城市信息列表
  30. *
  31. */
  32. public function cityCodeList()
  33. {
  34. $postData = $this->objCommon->CommonRequestParams();
  35. $postData['body'] = '';
  36. $postData['signature'] = $this->objCommon->getSignature($postData);
  37. $url = $this->baseUrl . '/api/cityCode/list';
  38. $response = request($url, json_encode($postData, JSON_UNESCAPED_UNICODE), 5, true, $this->commonHeader);
  39. $result = $this->objCommon->commonResponse($response);
  40. if (!$result->isSuccess()) {
  41. return ResultWrapper::fail($result->getData(), $result->getErrorCode());
  42. }
  43. return ResultWrapper::success($result->getData());
  44. }
  45. }