Index.php
9.9 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<?php
namespace app\api\controller;
use app\common\controller\Api;
use think\Db;
/**
* 首页接口
*/
class Index extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
/**
* 首页接口
* @ApiTitle (服务商申请)
* @ApiSummary (服务商申请)
* @ApiMethod (POST)
* @ApiRoute (/api/Index/SellerStatus)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="CompanyMain", type="integer", required=true, description="公司主营业务")
* @ApiParams (name="CompanyType", type="string", required=true, description="申请业务类型:1=换电商,2=经营商,3=维修商,4=代理商")
* @ApiParams (name="Person", type="string", required=true, description="负责人")
* @ApiParams (name="Mobile", type="string", required=true, description="联系电话")
* @ApiParams (name="PersonEmail", type="string", required=true, description="负责人邮箱地址")
* @ApiParams (name="BusinessPeople", type="string", required=true, description="业务专员")
* @ApiParams (name="BusinessPeopleEmail", type="string", required=true, description="业务专员邮箱地址")
* @ApiParams (name="OpenBank", type="string", required=true, description="开户银行")
* @ApiParams (name="Number", type="string", required=true, description="账号")
* @ApiParams (name="LastYearMoney", type="string", required=true, description="上年营业额")
* @ApiParams (name="CompanyPeopleNum", type="string", required=true, description="公司员工数")
* @ApiParams (name="image", type="string", required=true, description="营业执照或负责人身份证照片")
* @ApiParams (name="Status", type="string", required=true, description="审核状态:0=待审核,1=审核通过,2=审核未通过")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
'data':{
})
*/
public function SellerStatus()
{
$UserId = $this->IsToken($this->request->header());
//验证申请是否唯一
$this->OnlySeller($UserId);
$params = $this->MyParams();
$params['user_id'] = $UserId;
$params['Status'] = 0;
$params['createtime'] = time();
$params['updatetime'] = time();
try {
$Res = Db::name('seller')->insert($params);
} catch (\Exception $e) {
$this->error($e->getMessage());
}
$this->Res($Res);
}
/**
* 首页接口
* @ApiTitle (新增/更改门店)
* @ApiSummary (新增/更改门店)
* @ApiMethod (POST)
* @ApiRoute (/api/Index/InsertUpdateStor)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="type", type="integer", required=true, description="类型:1=新增,2=更改")
* @ApiParams (name="id", type="integer", required=true, description="门店ID/新增时不传")
* @ApiParams (name="avatar", type="string", required=true, description="门牌照")
* @ApiParams (name="name", type="string", required=true, description="店铺名称")
* @ApiParams (name="address", type="string", required=true, description="店铺位置")
* @ApiParams (name="lng", type="string", required=true, description="经度")
* @ApiParams (name="lat", type="string", required=true, description="纬度")
* @ApiParams (name="address_con", type="string", required=true, description="详细地址")
* @ApiParams (name="mobile", type="string", required=true, description="联系电话")
* @ApiParams (name="hours", type="string", required=true, description="营业时间")
* @ApiParams (name="Battery", type="string", required=true, description="电池分类Json数组['type_id':'1','num':'10']")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
'data':{
})
*/
public function InsertUpdateStor()
{
$UserId = $this->IsToken($this->request->header());
$params = $this->request->param();
if ($params['type'] == 1) {
$data = [
'user_id' => $UserId,
'createtime' => time(),
'updatetime' => time(),
'avatar' => $params['avatar'],
'name' => $params['name'],
'address' => $params['address'],
'lng' => $params['lng'],
'lat' => $params['lat'],
'address_con' => $params['address_con'],
'mobile' => $params['mobile'],
'hours' => $params['hours'],
'Battery' => $params['Battery'],
];
$Res = Db::name('stor')->insert($data);
} else {
$data = [
'updatetime' => time(),
'avatar' => $params['avatar'],
'name' => $params['name'],
'address' => $params['address'],
'lng' => $params['lng'],
'lat' => $params['lat'],
'address_con' => $params['address_con'],
'mobile' => $params['mobile'],
'hours' => $params['hours'],
'Battery' => $params['Battery'],
];
$Res = Db::name('stor')->where('id', $params['id'])->update($data);
}
$this->Res($Res);
}
/**
* 首页接口
* @ApiTitle (门店更改回显)
* @ApiSummary (门店更改回显)
* @ApiMethod (POST)
* @ApiRoute (/api/Index/UpdateStorBack)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="id", type="integer", required=true, description="门店ID")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
'data':{
})
*/
public function UpdateStorBack()
{
$UserId = $this->IsToken($this->request->header());
$ID = input('id');
$Arr = Db::name('stor')->where('id', $ID)->where('user_id', $UserId)->find();
if (empty($Arr)) {
$this->error('参数错误', 0);
}
$BatteryArr = json_decode($Arr['Battery'], true);
$data = [
'avatar' => cdnurl($Arr['avatar']),
'name' => $Arr['name'],
'address' => $Arr['address'],
'lng' => $Arr['lng'],
'lat' => $Arr['lat'],
'address_con' => $Arr['address_con'],
'mobile' => $Arr['mobile'],
'hours' => $Arr['hours'],
'Battery' => $BatteryArr,
];
$this->success('成功', $data);
}
/**
* 首页接口
* @ApiTitle (我的门店)
* @ApiSummary (我的门店)
* @ApiMethod (POST)
* @ApiRoute (/api/Index/MyStor)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="keywords", type="string", required=true, description="搜索关键字")
* @ApiParams (name="start", type="string", required=true, description="开始日期")
* @ApiParams (name="end", type="string", required=true, description="结束日期")
* @ApiParams (name="pages", type="string", required=true, description="pages")
* @ApiParams (name="rows", type="string", required=true, description="rows")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
'data':{
})
*/
public function MyStor()
{
$UserId = $this->IsToken($this->request->header());
$params = $this->request->param();
$mapA = [];
$mapB = [];
$mapC = [];
if (!empty($params['keywords']) || $params['keywords'] != '' || $params['keywords'] != "" || $params['keywords'] != null) {
$mapA['name'] = ['LIKE', '%' . $params['keywords'] . '%'];
}
if (!empty($params['start']) || $params['start'] != '' || $params['start'] != "" || $params['start'] != null) {
$StartTime = strtotime($params['start']);
$mapB['createtime'] = ['GT', $StartTime];
}
if (!empty($params['end']) || $params['end'] != '' || $params['end'] != "" || $params['end'] != null) {
$EndTime = strtotime($params['end']);
$mapC['createtime'] = ['LT', $EndTime];
}
$Arr = Db::name('stor')->where('user_id', $UserId)->where($mapA)->where($mapB)->where($mapC)->order('createtime desc')->page($params['pages'], $params['rows'])->select();
$Count = Db::name('stor')->where('user_id', $UserId)->where($mapA)->where($mapB)->where($mapC)->order('createtime desc')->select();
$StorCount = Db::name('stor')->where('user_id', $UserId)->select();
if (empty($Arr)) {
$data = [
'StorCount' => count($StorCount),
'Count' => 0,
'List' => []
];
} else {
foreach ($Arr as $k => $v) {
$List[$k]['id'] = $v['id'];
$List[$k]['name'] = $v['name'];
$List[$k]['createtime'] = date('Y.m.d', $v['createtime']);
}
$data = [
'StorCount' => count($StorCount),
'Count' => count($Count),
'List' => $List
];
}
$this->success('成功', $data);
}
}