bhq@iemsoft.cn
2018-11-27 e2b48dac099e43f4b3243cdf19a7522e4b5eccbe
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
<?php
    /*
     *
     *店铺街页面
     *  jx  2015-05-29
     *
     *
     */
    define('IN_ECS', true);
    require('includes/init.php');
    $user_id = $_GET['user_id'];
    $act = isset($_REQUEST['act'])  ? trim($_REQUEST['act']) : '';
    //店铺街列表
    if(empty($act))
    {
        //得到所有审核通过的店铺
        $sql = "select * from ".$GLOBALS['ecs']->table('supplier_street')." where status=1 and is_show=1";
        $shop_list = $GLOBALS['db']->getAll($sql);
        foreach($shop_list as $key=>$value)
        {
            $sql = "select code,value from ".$GLOBALS['ecs']->table('supplier_shop_config')."where supplier_id = ".$value['supplier_id'];
            $shop = $GLOBALS['db']->getAll($sql);
            foreach($shop as $k=>$v)
            {
                $shop_list[$key][$v['code']] = $v['value'];
            }
            if($user_id != '0')
            {//如果用户登陆,获取到对应用户关注的店铺
                $sql = "select * from ".$GLOBALS['ecs']->table('supplier_guanzhu')." where userid = $user_id and supplierid = ".$value['supplier_id'];
                $gshop = $GLOBALS['db']->getOne($sql);
                if(!empty($gshop))
                {
                    $shop_list[$key]['guanzhu'] = '1';
                }else
                {
                    $shop_list[$key]['guanzhu'] = '0';
                }
                
            }else
            {
                $shop_list[$key]['guanzhu'] = '0';
            }
        }
        
        //file_put_contents('./12.txt',var_export($shop_list,true));
        print_r(json_encode($shop_list));exit;
    
    }elseif($act == 'attention')//关注店铺
    {
        $supplier_id = $_GET['supplier_id'];
        $sql = "INSERT INTO ". $GLOBALS['ecs']->table('supplier_guanzhu') . " (`userid`, `supplierid`, `addtime`) VALUES ('$user_id','$supplier_id]',".time().")";
        $GLOBALS['db']->query($sql);
        $result['error'] = 1;
        $result['info'] = '关注成功!';
        print_r(json_encode($result));exit;
    }
?>