Enter.php
6.3 KB
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
87
88
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2020/4/29
* Time: 15:08
*/
namespace app\index\controller;
use app\common\controller\Frontend;
use app\index\model\Firmstores;
use app\index\model\Minestore;
use app\index\model\Store;
use app\index\model\Viporder;
use think\Db;
class Enter extends Frontend
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
public function _initialize()
{
parent::_initialize(); // TODO: Change the autogenerated stub
$this->view->assign('is_search', 0);
$this->view->assign('is_active', 0);
}
/**
* 申请入驻页面
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function index(){
$user_id = $this->auth->id;
$viporderModel = new Viporder();
$vip_order = $viporderModel->where(['user_id'=>$user_id])->order("createtime desc")->find();
if(!empty($vip_order)){
if(in_array($vip_order['audit'],[1,2])){
$this->redirect('index/vip/index');
}
}
$userModel = new \app\index\model\User();
$user = $userModel->findData(['id'=>$user_id]);
if(empty($user)){
$this->error('查无此人','','','');
}
if($user['identity'] != '0'){
$this->redirect('index/index');
}
$this->assign('title', '入驻申请');
return $this->fetch();
}
/**
* 申请个人店铺
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function apply_personage(){
$user_id = $this->auth->id;
$viporderModel = new Viporder();
$vip_order = $viporderModel->where(['user_id'=>$user_id])->order("createtime desc")->find();
if(!empty($vip_order)){
if(in_array($vip_order['audit'],[1,2])){
$this->redirect('index/vip/index');
}
}
$userModel = new \app\index\model\User();
$user = $userModel->findData(['id'=>$user_id]);
if(empty($user)){
$this->error('查无此人','','','');
}
if($user['identity'] != '0'){
$this->redirect('index/index');
}
$this->assign('title',"申请个人店铺");
return $this->fetch();
}
/**
* 申请企业店铺
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function apply_company(){
$user_id = $this->auth->id;
$viporderModel = new Viporder();
$vip_order = $viporderModel->where(['user_id'=>$user_id])->order("createtime desc")->find();
if(!empty($vip_order)){
if(in_array($vip_order['audit'],[1,2])){
$this->redirect('index/vip/index');
}
}
$userModel = new \app\index\model\User();
$user = $userModel->findData(['id'=>$user_id]);
if(empty($user)){
$this->error('查无此人','','','');
}
if($user['identity'] != '0'){
$this->redirect('index/index');
}
$this->assign('title',"申请企业店铺");
return $this->fetch();
}
public function submit_personage(){
$user_id = $this->auth->id;
$userModel = new \app\index\model\User();
$user = $userModel->findData(['id'=>$user_id]);
if(empty($user)){
$this->error('查无此人','','','');
}
if($user['identity'] != '0'){
$this->error('您已成为个人店铺或企业店铺');
}
$param = $this->request->param();
$validate = new \think\Validate([
'linkname' => 'require',
'idcard' => 'require',
'card_images' => 'require',
'phone' => 'require',
'address' => 'require',
'lng' => 'require',
'lat' => 'require',
'thumbnail' => 'require',
]);
if (!$validate->check($param)) {
$this->error($validate->getError());
}
$minestoreModel = new Minestore();
$data = $minestoreModel->findData(['user_id'=>$user_id]);
$param['user_id'] = $user_id;
$param['updatetime'] = time();
if(empty($data)){
$param['createtime'] = time();
$result = $minestoreModel->insertData($param);
}else{
$result = $minestoreModel->updateData(['id'=>$data['id']],$param);
}
if(empty($result)){
$this->error('sql执行失败');
}
$this->success('SUCCESS');
}
public function submit_company(){
$user_id = $this->auth->id;
$userModel = new \app\index\model\User();
$user = $userModel->findData(['id'=>$user_id]);
if(empty($user)){
$this->error('查无此人','','','');
}
if($user['identity'] != '0'){
$this->error('您已成为个人店铺或企业店铺');
}
$param = $this->request->param();
$validate = new \think\Validate([
'name' => 'require',
'companyname' => 'require',
'business' => 'require',
'companytype' => 'require',
'companyscale' => 'require',
'linkname' => 'require',
'phone' => 'require',
'address' => 'require',
'lng' => 'require',
'lat' => 'require',
]);
if (!$validate->check($param)) {
$this->error($validate->getError());
}
$firmstoresModel = new Firmstores();
$data = $firmstoresModel->findData(['user_id'=>$user_id]);
$param['user_id'] = $user_id;
$param['updatetime'] = time();
if(empty($data)){
$param['createtime'] = time();
$result = $firmstoresModel->insertData($param);
}else{
$result = $firmstoresModel->updateData(['id'=>$data['id']],$param);
}
if(empty($result)){
$this->error('sql执行失败');
}
$this->success('SUCCESS');
}
}