-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.php
334 lines (295 loc) · 10 KB
/
api.php
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
<?php
//增加接口调用
define('IN_SYS', true);
error_reporting(E_ALL ^ ~E_NOTICE ^ E_WARNING);
require './framework/bootstrap.inc.php';
load()->web('business');
load()->web('app');
disableWebCache();
$func = strtolower($_GPC['func']);
$params = $_GPC['params'];
if (is_array($params)) {
$params = array_change_key_case($params, CASE_LOWER);
}
$res = array('result' => false, 'msg' => '无效的功能调用');
//检查调用IP?
//cache()->flush();
if ($func == 'calllnum') {
$res['msg'] = '';
$res['result'] = true;
$num = memcached_get('callnum');
$res['data'] = sprintf('%03d', intval($num));
returnJson($res);
}
if ($func == 'login') {
$user = biz_login($params['usercode'], $params['password']);
if (!empty($user)) {
unset($user['Password']);
$res['msg'] = '登录成功';
$res['result'] = true;
$res['data']['user'] = $user;
} else {
$res['msg'] = '无效的用户名或密码!';
}
returnJson($res);
}
//检查用户是否存在
if (empty($_GPC['info'])) {
returnJson($res);
}
$user = biz_getUser($_GPC['info']['token']);
if (empty($user)) {
$res['msg'] = '用户登录过期';
$res['code'] = -1;
returnJson($res);
}
if ($func == 'sign') {
//检查开盘状态
if (empty($params['qrcode'])) {
$res['msg'] = '空参数';
returnJson($res);
}
$project = biz_getProject($params['projguid'], true);
if (empty($project)) {
$res['msg'] = '无效项目信息';
returnJson($res);
}
$sign = App_Sign_getGroup(trim($params['qrcode']), $project);
if (empty($sign) || empty($sign['sign'])) {
$res['msg'] = $sign['msg'];
} else {
$res['result'] = true;
$sign['sign']['signtime'] = date('Y-m-d H:i:s', $sign['sign']['signtime']);
$res['data'] = $sign['sign'];
$res['first'] = isset($sign['group']);
$res['msg'] = $res['first'] ? '签到成功' : '此单已签到,不能重复签到';
}
returnJson($res);
}
if($func=='lucky'){
if (empty($params['qrcode'])) {
$res['msg'] = '空参数';
returnJson($res);
}
$project=biz_getProject($params['projguid']);
$chips = biz_getChipsByQrcode($params['qrcode']);
if (empty($chips)||($chips['projguid']!=$project['projguid'])) {
$res['msg'] = '无效认筹单';
returnJson($res);
}
$res['data']=array_elements(array('cname','cardid','signed'),$chips);
if (empty($chips['lucky'])) {
//未中签处理,1、未签处理,2已签到,未叫号、已叫号
if (empty($chips['signed'])) {
//获取预设组
$res['msg'] = '此单未签到、未中签!';
$res['result'] = false;
} else {
$called = biz_getCalledGroupNum($project);
if(in_array($chips['signed'],$called)){
pdo_update('chips', array('lucky' => 1), array('id' => $chips['id']));
$res['msg'] ="此单号签到组号{$chips['signed']}组,中签登记成功";
$res['result'] = true;
}else{
$res['msg'] ="此单号签到组号{$chips['signed']}组,未中签!";
}
}
}else{
$res['msg'] = '此单已经确认中签!';
$res['result'] = true;
}
returnJson($res);
}
if ($func == 'projlist') {
$res['result'] = true;
$res['msg'] = '';
$res['data'] = App_getProjects($user, false);
returnJson($res);
}
if ($func == 'buildlist') {
if (empty($params['projguid'])) {
$res['result'] = false;
$res['msg'] = '无效的项目参数';
} else {
load()->web('right');
$res['data'] = App_getBuilds($params['projguid']);
$right = biz_getUserProjectRight($user['UserGUID'], $params['projguid']);
$res['right'] = isset($right['Permission']) ? $right['Permission']['app'] : array();
$res['result'] = true;
$res['msg'] = '';
}
returnJson($res);
}
if ($func == 'roominfo') {
$res['result'] = true;
$res['data'] = APP_getRoomInfo($params['projguid'], $params['bldguid']);
$res['msg'] = '';
returnJson($res);
}
if ($func == 'selectroom') {
$room = APP_getRoomStatus($params['projguid'], $params['bldguid'], $params['roomguid']);
if (!empty($room)) {
if (($room['Status'] == '待售') && empty($room['ChooseRoom'])) {
$chips = biz_getChipsByQrcode($params['qrcode']);
if ($chips['projguid'] != $room['ProjGUID']) {
$res['msg'] = '认筹单与所选房间非同一项目';
returnJson($res);
}
//认筹单没有选房
if (!empty($chips)) {
if (empty($chips['roomstatus'])) {
$room['NewStatus'] = '选房';
if (APP_updateRoomStatus($room, $chips, 1)) {
$res['result'] = true;
$res['msg'] = '选房成功';
} else {
$res['msg'] = '选房失败';
}
} else {
$res['msg'] = '此单不可再选房,如已选房请先退房';
}
} else {
$res['msg'] = '无效的认筹单';
}
} else {
$res['msg'] = '房间非待售状态';
}
} else {
$res['msg'] = '无效房间参数';
}
returnJson($res);
}
if ($func == 'unselectroom') {
$res['msg'] = '';
$chips = biz_getChipsByQrcode($params['qrcode']);
if (!empty($chips)) {
$room = APP_getRoomStatus($params['projguid'], $params['bldguid'], $params['roomguid']);
if (!empty($room) && ($chips['roomguid'] == $room['RoomGUID'])) {
if (($chips['roomstatus'] == 1) &&($room['Status']=='选房')) {
//认筹单没有选房
$room['NewStatus'] = '待售';
if (APP_updateRoomStatus($room, $chips, 0)) {
$res['result'] = true;
$res['msg'] = '退房成功';
} else {
$res['msg'] = '退房失败';
}
} else {
$res['msg'] = '此单非选房状态,不能退房';
}
} else {
$res['msg'] = '无效的房间信息,与订单信息不匹配';
}
} else {
$res['msg'] = '无效的认筹单';
}
returnJson($res);
}
if ($func == 'report') {
if (!empty($params['projguid'])) {
$data = App_getStats($params['projguid']);
$res['msg'] = '';
$res['result'] = true;
$res['data'] = $data;
} else {
$res['msg'] = '无效参数';
}
//统计报表
returnJson($res);
}
if ($func == 'turn_room') {
$res['msg'] = '';
$room = APP_getRoomStatus($params['projguid'], $params['bldguid'], $params['roomguid']);
if (!empty($room)) {
if (in_array($room['Status'], array('预留', '预约'))) {
//empty($room['ChooseRoom'])
$chips = biz_getChipsByQrcode($params['qrcode']);
//认筹单没有选房
if (!empty($chips)) {
if (empty($chips['roomstatus'])) {
$room['NewStatus'] = '确认';
if (APP_updateRoomStatus($room, $chips, 1)) {
$res['result'] = true;
$res['msg'] = '转认购成功';
} else {
$res['msg'] = '转认购失败';
}
} else {
$res['msg'] = '此单不可再选房,如已选房请先退房';
}
} else {
$res['msg'] = '无效的认筹单';
}
} else {
$res['msg'] = '房间非预留、预约状态';
}
} else {
$res['msg'] = '无效参数';
}
returnJson($res);
//$params['projguid'], $params['bldguid'], $params['roomguid']
//直接选房
}
if ($func == 'nei_unselect_room') {
$res['msg'] = '';
//选房过期未交款;内控退房
$room = APP_getRoomStatus($params['projguid'], $params['bldguid'], $params['roomguid']);
//检查超时 ,状态为超时
if (!empty($room) && !empty($room['ChooseRoomCstName'])) {
$chips = db_getChipsByRoom($room);
// if (!empty($chips) && ($chips['printstatus'] >= 4)) {
// $res['msg'] = '房间对应认筹单已认购不能退房';
// returnJson($res);
// }
if ($room['Status'] == '超时') {
//认筹单没有选房
$room['NewStatus']='待售';
if (APP_updateRoomStatus($room, $chips, 0)) {
$res['result'] = true;
$res['msg'] = '退房成功';
} else {
$res['msg'] = '退房失败';
}
} else {
$res['msg'] = '此单非超时状态,不能退房';
}
} else {
$res['msg'] = '无效的房间信息';
}
returnJson($res);
}
if ($func == 'changestatus') {
$res['msg'] = '';
//要获取状态
$status = trim($params['status']);
if (!in_array($status,array('待售', '销控'))) {
$res['msg'] = '无效的状态参数';
returnJson($res);
}
$room = APP_getRoomStatus($params['projguid'], $params['bldguid'], $params['roomguid']);
//选房时间大于10分钟以上
if (empty($room)) {
$res['msg'] = '无效的房间信息';
returnJson($res);
}
if (($room['Status'] == $status)) {
$status= $status=='待售'?'销控':'待售';
$res['result']=App_changeRoomSTatus($room ,$status);
$res['msg']='转换到'.$status.'状态'. ($res['result']?'成功':'失败');
} else {
$res['msg'] = '房间信息状态不匹配';
}
returnJson($res);
}
if ($func == 'chipsinfo') {
$res['msg'] = '';
//要获取状态
$chips = App_getChipsStatus($params['qrcode']);
if (!empty($chips)) {
$res['result'] = true;
$res['data'] = $chips;
} else {
$res['msg'] = '无效的认筹单';
}
returnJson($res);
}