IndexController.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\plugins\food\controllers\client;
  8. use app\models\Option;
  9. use app\models\Store;
  10. use app\plugins\food\controllers\BaseController;
  11. use app\plugins\food\models\client\IndexForm;
  12. use yii\base\BaseObject;
  13. use yii\helpers\Json;
  14. use yii\web\Controller;
  15. class IndexController extends BaseController
  16. {
  17. /**
  18. * 商户信息 & 轮播图 & 商家推荐
  19. */
  20. public function actionMainInfo() {
  21. $form = new IndexForm();
  22. $form->store_id = get_store_id();
  23. return $form->getInfo();
  24. }
  25. /**
  26. * 商品列表
  27. */
  28. public function actionGoodsList() {
  29. $form = new IndexForm();
  30. $form->store_id = get_store_id();
  31. return $form->getGoodsList();
  32. }
  33. /**
  34. * 店铺信息
  35. */
  36. public function actionStore() {
  37. $store_id = get_store_id();
  38. $store_info = Store::find()->where(['id' => $store_id, 'is_delete' => 0])->asArray()->one();
  39. if (!$store_info) {
  40. return [
  41. 'code' => 1,
  42. 'msg' => '该店铺不存在'
  43. ];
  44. }
  45. $food_config = Option::getFoodBookConfig();
  46. $store_info['name'] = $food_config['name'];
  47. $store_info['phone'] = $food_config['phone'];
  48. $store_info['address'] = $food_config['address'];
  49. $store_info['category'] = IndexForm::$validCategory[$food_config['category']];
  50. $store_info['logo'] = $food_config['logo'];
  51. $store_info['pic'] = Json::decode(Option::get('food_book', $store_id, 'store')['value'])['store_pic'];
  52. $store_info['open_time'] = $food_config['open_time'];
  53. $store_info['latitude'] = explode(',', $store_info['coordinate'])[0] ?: '';
  54. $store_info['longitude'] = explode(',', $store_info['coordinate'])[1] ?: '';
  55. $store_info['service'] = $food_config['service'];
  56. return [
  57. 'code' => 0,
  58. 'msg' => 'success',
  59. 'data' => $store_info
  60. ];
  61. }
  62. }