quanwei
2025-11-11 0d04d60f456b1902c1e27b9586652649df3963d4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
 
namespace app\api\controller\store;
 
use app\api\controller\Controller;
use app\api\model\user\Favorite as FavoriteModel;
use app\common\library\easywechat\AppMp;
use app\api\model\store\Store as StoreModel;
use app\api\model\supplier\Supplier as SupplierModel;
use app\api\model\page\Ad as AdModel;
/**
 * 门店列表
 */
class Store extends Controller
{
    /**
     * 门店列表
     */
    public function lists($longitude = '', $latitude = '', $url = '', $shop_supplier_id = 0, $is_check = true)
    {
        $model = new StoreModel;
        $list = $model->getList($is_check, $longitude, $latitude, false, $shop_supplier_id);
        $signPackage = '';
        if($url != ''){
            $app = AppMp::getApp($this->app_id);
            $app->jssdk->setUrl($url);
            $signPackage = $app->jssdk->buildConfig(array('getLocation', 'openLocation'), false);
        }
        return $this->renderSuccess('', compact('list', 'signPackage'));
    }
 
    /**
     * 门店详情
     */
    public function detail($store_id)
    {
        $detail = StoreModel::detail($store_id);
        //获取商户营业时间
        if(!empty($detail)){
            $supplier = SupplierModel::detail($detail["shop_supplier_id"]);
            if(!empty($supplier)){
                $detail["shop_hours"] = $supplier["business_start_time"]."至".$supplier["business_end_time"];
            }
        }
        //banner图
        $AdModel = new AdModel;
        $adList = $AdModel->getIndex(['shop_supplier_id' => $detail['shop_supplier_id'], 'status' => 1], 5);
        $is_collect = 0;
        // 用户信息
        $user = $this->getUser(false);
        if ($user) {
            if (FavoriteModel::detail($detail['shop_supplier_id'], 10, $user['user_id'])) {
                $is_collect= 1;
            }
        }
        return $this->renderSuccess('', compact('detail','adList','is_collect'));
    }
 
    /**
     * 门店列表(分页)
     */
    public function storelist()
    {
        $model = new StoreModel;
        $list = $model->storeList($this->postData());
        return $this->renderSuccess('', compact('list'));
    }
    /**
     * 虚拟商品可核销门店列表
     */
    public function verifyLists($storeIds, $longitude = '', $latitude = '')
    {
        $storeIds = json_decode(htmlspecialchars_decode($storeIds), true);
        if (is_array($storeIds)) {
            $storeIds = implode(',', $storeIds);
        }
        $model = new StoreModel;
        $list = $storeIds ? $model->getListByStoreIds($storeIds, $longitude, $latitude) : $model->getList(true, $longitude, $latitude);
        return $this->renderSuccess('', compact('list'));
    }
    public function getUserStore($user_id)
    {
        $list = SupplierModel::getUserStore($user_id);
        return $this->renderSuccess('', compact('list'));
    }
}