审查视图

app/index/controller/IndexController.php 1.9 KB
lihan authored
1 2
<?php
namespace app\index\controller;
3
use app\goods\model\GoodsModel;
lihan authored
4
use cmf\controller\HomeBaseController;
5
use think\Db;
lihan authored
6 7 8

class IndexController extends HomeBaseController
{
9
lihan authored
10 11
    public function index()
    {
12 13
        $goods = new GoodsModel;
        $goodsList = $goods->getGoods(2);
14 15 16 17 18
        $id=[];
        foreach ($goodsList as $k=>$v){
            $id[$k]=$v['id'];
        }
        $num=Db::name('zj_evaluate')->where(['delete_time'=>'0','is_sta'=>'2','gid'=>['in',$id]])->group('gid')
lihan authored
19
            ->field("count('gid') as num,gid")->select()->toArray();
20
        foreach ($goodsList as $k=>$v){
lihan authored
21 22 23 24 25 26 27 28
            if(!empty($num)) {
                foreach ($num as $val) {
                    if ($v['id'] == $val['gid']) {
                        $goodsList[$k]['eva'] = $val['num'];
                        break;
                    } else {
                        $goodsList[$k]['eva'] = 0;
                    }
29
                }
lihan authored
30 31
            }else {
                $goodsList[$k]['eva'] = 0;
32 33 34
            }
        }
        $notice=Db::name('zj_news')->where(['delete_time'=>0,'is_sta'=>1])->find();
35
        $return = [
36
            'notice' => $notice,
37 38 39 40 41 42
            'banner' => getBanner(),
            'goodsList' => $goodsList
        ];
        return $this->fetch('', [
            'data' => $return
        ]);
lihan authored
43
    }
44
lihan authored
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
    /**
     * 易连云打印机demo
     */
    public function demo()
    {
        //调用打印机
        //1.配置信息
        $config = [
            'partner' => '27606',
            'machine_code' => '4004564414',
            'apiKey' => '1580c3fc2adca994e18b0982b42af850518011d0',
            'msign' => '6kdjyzsr4sf3'
        ];
        //2.打印内容(以一行三列的表格为例,内容不允许出现回车换行,切记!)
        $content = '<table><tr><td>银河百荣科技</td><td>demo</td><td>By Soul of Cinder</td></tr></table>';
        printer($config, $content);
    }
lihan authored
63
}