ZxcZxc123 1 year ago
parent
commit
ce73a4643b
3 changed files with 31 additions and 6 deletions
  1. 17 0
      app/api/controller/PublicController.php
  2. 12 5
      app/models/store/StoreProduct.php
  3. 2 1
      composer.json

+ 17 - 0
app/api/controller/PublicController.php

@@ -299,6 +299,23 @@ class PublicController
         return app('json')->successful($data);
     }
 
+
+
+    public function store_detail(Request $request, $id)
+    {
+        list($latitude, $longitude) = UtilService::getMore([
+            ['latitude', ''],
+            ['longitude', ''],
+        ], $request, true);
+        $info = SystemStore::get($id);
+        $info['distance'] = sqrt((pow((($latitude - $info['latitude']) * 111000), 2)) + (pow((($longitude - $info['longitude']) * 111000), 2)));
+        //转换单位
+        $info['range'] = bcdiv($info['distance'], 1000, 1);
+        return app('json')->successful('ok',compact('info'));
+    }
+
+
+
     /**
      * 查找城市数据
      * @param Request $request

+ 12 - 5
app/models/store/StoreProduct.php

@@ -14,9 +14,11 @@ use crmeb\basic\BaseModel;
 use crmeb\services\GroupDataService;
 use crmeb\services\workerman\ChannelService;
 use crmeb\traits\ModelTrait;
+use PDOStatement;
 use app\models\store\{
     StoreBargain, StoreCombination, StoreSeckill
 };
+use think\Collection;
 
 /**
  * TODO 产品Model
@@ -172,7 +174,7 @@ class StoreProduct extends BaseModel
      * 新品产品
      * @param string $field
      * @param int $limit
-     * @return false|\PDOStatement|string|\think\Collection
+     * @return false|PDOStatement|string|Collection
      */
     public static function getNewProduct($field = '*', $limit = 0, $uid = 0, bool $bool = true)
     {
@@ -195,7 +197,7 @@ class StoreProduct extends BaseModel
      * 热卖产品
      * @param string $field
      * @param int $limit
-     * @return false|\PDOStatement|string|\think\Collection
+     * @return false|PDOStatement|string|Collection
      */
     public static function getHotProduct($field = '*', $limit = 0, $uid = 0)
     {
@@ -218,7 +220,7 @@ class StoreProduct extends BaseModel
      * @param string $field
      * @param int $page
      * @param int $limit
-     * @return array|\think\Collection
+     * @return array|Collection
      * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\ModelNotFoundException
      * @throws \think\exception\DbException
@@ -239,7 +241,12 @@ class StoreProduct extends BaseModel
      * 精品产品
      * @param string $field
      * @param int $limit
-     * @return false|\PDOStatement|string|\think\Collection
+     * @param int $uid
+     * @param bool $bool
+     * @return false|PDOStatement|string|Collection|array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     public static function getBestProduct($field = '*', $limit = 0, $uid = 0, bool $bool = true)
     {
@@ -302,7 +309,7 @@ class StoreProduct extends BaseModel
      * 优惠产品
      * @param string $field
      * @param int $limit
-     * @return false|\PDOStatement|string|\think\Collection
+     * @return false|PDOStatement|string|Collection
      */
     public static function getBenefitProduct($field = '*', $limit = 0)
     {

+ 2 - 1
composer.json

@@ -40,7 +40,8 @@
         "topthink/think-multi-app": "^1.0",
         "topthink/think-template": "^2.0",
         "overtrue/pinyin": "^4.0",
-        "alibabacloud/dysmsapi-20170525": "2.0.20"
+        "alibabacloud/dysmsapi-20170525": "2.0.20",
+      "ext-pdo": "*"
     },
     "autoload": {
         "psr-4": {