ApiShop.Class.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace JinDouYun\Controller\Shop;
  3. use JinDouYun\Controller\BaseController;
  4. use JinDouYun\Controller\DingController;
  5. use JinDouYun\Model\Shop\MShop;
  6. use Mall\Framework\Core\ErrorCode;
  7. use Mall\Framework\Core\Ding;
  8. class ApiShop extends BaseController
  9. {
  10. private $objMShop;
  11. public function __construct($isCheckAcl = true, $isMustLogin = false, $checkToken = true, $getAreaCode = false, $checkShopToken = true, $checkSupplierToken = true)
  12. {
  13. parent::__construct($isCheckAcl, $isMustLogin, $checkToken, $getAreaCode, $checkShopToken, $checkSupplierToken);
  14. $authorization = $this->request->getServerParam('HTTP_AUTHORIZATION');
  15. if (!empty($authorization)) {
  16. self::getUserIdByAuthorization();
  17. }
  18. $this->objMShop = new MShop($this->onlineEnterpriseId,$this->onlineUserId);
  19. }
  20. /**
  21. * Doc: (des="门店")
  22. * User: XMing
  23. * Date: 2021/1/28
  24. * Time: 3:52 下午
  25. * @throws \Exception
  26. */
  27. public function getAll()
  28. {
  29. $params = $this->request->getRawJson();
  30. if( empty($params) ){
  31. $this->sendOutput('参数为空', ErrorCode::$paramError );
  32. }
  33. $selectParams = [
  34. 'name' => isset($params['name']) ? $params['name'] : '',
  35. 'shopType' => isset($params['shopType']) ? $params['shopType'] : '',
  36. 'enableStatus' => isset($params['enableStatus']) ? $params['enableStatus'] : '',
  37. ];
  38. $pageParams = pageToOffset($params['page']?:1, $params['pageSize']?:10);
  39. $selectParams['limit'] = $pageParams['limit'];
  40. $selectParams['offset'] = $pageParams['offset'];
  41. //longitude 经度
  42. //latitude 纬度
  43. $selectParams['longitude'] = getArrayItem($params,'longitude',0);
  44. $selectParams['latitude'] = getArrayItem($params,'latitude',0);
  45. $result = $this->objMShop->getAll($selectParams);
  46. if($result->isSuccess()){
  47. $returnData = $result->getData();
  48. $pageData = [
  49. 'pageIndex' => $params['page'],
  50. 'pageSize' => $params['pageSize'],
  51. 'pageTotal' => $returnData['total'],
  52. ];
  53. parent::sendOutput($returnData['data'], 0, $pageData);
  54. }else{
  55. parent::sendOutput($result->getData(), $result->getErrorCode());
  56. }
  57. }
  58. }