Blame view

app-ht/modules/maintainer/controllers/UserController.php 3.18 KB
d11ff394   xu   app-ht(v0.0.1 bui...
1
2
3
4
<?php

namespace app\ht\modules\maintainer\controllers;

d11ff394   xu   app-ht(v0.0.1 bui...
5
use common\helpers\ImageManager;
afd2f743   xu   app-ht(v0.0.1 bui...
6
use Yii;
d11ff394   xu   app-ht(v0.0.1 bui...
7
8
use yii\data\Pagination;
use app\ht\controllers\BaseController;
afd2f743   xu   app-ht(v0.0.1 bui...
9
10

use domain\user\UserRepository;
d11ff394   xu   app-ht(v0.0.1 bui...
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
use stdClass;
use function strtotime;

/**
 * 维修厂管理
 */
class UserController extends BaseController
{

    /**
     * @return string
     */
    public function actionIndex()
    {
        $params = $this->dataList(1);
        /**
         * 渲染模板
         */
        return $this->render('index', $params);
    }

    /**
     * 查询数据列表
     */
    protected function dataList($type = '')
    {
        $request        = Yii::$app->request;
        $createTime     = $request->get('createTime');
        $endTime        = $request->get('endTime');
        $mobile         = $request->get('mobile');
        $name           = $request->get('name');

afd2f743   xu   app-ht(v0.0.1 bui...
43
        $gets = [
d11ff394   xu   app-ht(v0.0.1 bui...
44
45
46
47
48
49
            'createTime'    => $createTime,
            'endTime'       => $endTime,
            'mobile'        => $mobile,
            'name'          => $name,
        ];

afd2f743   xu   app-ht(v0.0.1 bui...
50
        $where = ['and'];
d11ff394   xu   app-ht(v0.0.1 bui...
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
        if ($createTime) {
            $createTime = strtotime($createTime);
            $where[] = ['>=', 'user.created_at', $createTime];
        }
        if ($endTime) {
            $endTime = strtotime($endTime) + 86400;
            $where[] = ['<=', 'user.created_at', $endTime];
        }
        if ($mobile) {
            $where[] = ['like', 'user.mobile', $mobile];
        }
        if ($name) {
            $where[] = ['like', 'user.name', $name];
        }


        if ($type == 0) {
afd2f743   xu   app-ht(v0.0.1 bui...
68
69
70
            $pageList = UserRepository::getAdminUserList(0, 0, $where);
            $pages = null;
        } else {
d11ff394   xu   app-ht(v0.0.1 bui...
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
            $pageSize = 20;
            $pages = new Pagination(['totalCount' => UserRepository::getAdminUserListCount($where), 'pageSize' => $pageSize]);
            $pageList = UserRepository::getAdminUserList($pages->offset, $pages->limit, $where);
        }

        /**
         * 数据整理
         */
        return [
            'listdata'   => $pageList,
            'pages'      => $pages,
            'gets'       => $gets
        ];
    }
    /**
     * 导出订单数据
afd2f743   xu   app-ht(v0.0.1 bui...
87
88
     * @return string
     */
d11ff394   xu   app-ht(v0.0.1 bui...
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
    public function actionExportDa()
    {
        $data = $this->dataList(0);

        return $this->renderPartial("exportDa", $data);
    }

    /**
     * @return string
     */
    public function actionInfo()
    {
        $id = $this->request->get('id');

        $userModel = UserRepository::findOne(['id' => $id]);
        if (empty($userModel)) {
            $params = [];
            return $this->render('info', $params);
        }

        $user = [
            'id'            => $userModel->id,
            'uuid'          => $userModel->uuid,
            'mobile'        => $userModel->mobile,
            'username'      => $userModel->user_name,
            'name'          => $userModel->name,
afd2f743   xu   app-ht(v0.0.1 bui...
115
            'licensePic'    => ImageManager::getUrl($userModel->license_pic),
d11ff394   xu   app-ht(v0.0.1 bui...
116
117
118
119
120
121
            'licensePicMin' => ImageManager::getUrl($userModel->license_pic, 'min'),
            'created_at'    => $userModel->created_at
        ];
        $params['user'] = $user;

        return $this->render('info', $params);
afd2f743   xu   app-ht(v0.0.1 bui...
122
    }
955204e8   xu   app-ht(v0.0.1 bui...
123
}
afd2f743   xu   app-ht(v0.0.1 bui...

bb9baa4c   xu   app-wx v0.1.0 bui...

afd2f743   xu   app-ht(v0.0.1 bui...

bb9baa4c   xu   app-wx v0.1.0 bui...

d11ff394   xu   app-ht(v0.0.1 bui...

afd2f743   xu   app-ht(v0.0.1 bui...

d11ff394   xu   app-ht(v0.0.1 bui...