6352bedad45a83b538c0b1a33983596e34bb4af5.svn-base
12.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
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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
<? include $_SERVER["DOCUMENT_ROOT"] . "/common/classes/ApiBase.php" ;?>
<?
/*
* Admin process
* add by dev.lee
*/
if (! class_exists("ApiUser"))
{
class ApiUser extends ApiBase
{
function __construct($req)
{
parent::__construct($req);
}
// 회원 포인트 조회 (http://106.240.232.36:8004/action_front.php?cmd=ApiUser.getInfoOfAvailPoint)
function getInfoOfAvailPoint()
{
$no = $this->appUser["no"];
$sql = "
SELECT
CASE
WHEN SUM(AMT) IS NULL
THEN 0
ELSE SUM(AMT)
END AS AVAIL_AMT
FROM tbl_point_trans
WHERE user_fk = '{$no}' AND trans_type='I'
";
$avail_amt = $this->getValue($sql, "AVAIL_AMT");
$sql = "
SELECT
CASE
WHEN SUM(AMT) IS NULL
THEN 0
ELSE SUM(AMT)
END AS PAY_AMT
FROM tbl_point_trans
WHERE user_fk = '{$no}' AND trans_type='O'
";
$pay_amt = $this->getValue($sql, "PAY_AMT");
$use_amt = $avail_amt - $pay_amt;
return $this->makeResultJson("1", "", $use_amt);
}
// 회원가입 여부 판단 (http://106.240.232.36:8004/action_front.php?cmd=ApiUser.initLogin&id=aa)
function initLogin()
{
$id = $this->req["id"];
$sql = "
SELECT id
FROM v_alive_user
WHERE id='{$id}'
LIMIT 0,1
";
$id = $this->getValue($sql, "id");
$returnCode = - 1;
if ($id != "")
{
$returnCode = 1;
}
return $this->makeResultJson($returnCode, "");
}
// 회원 그룹 (http://106.240.232.36:8004/action_front.php?cmd=ApiUser.getListOfMemberGroup)
function getListOfMemberGroup()
{
$name = $this->req["name"];
$addQuery = "";
if ($name != "")
$addQuery .= " AND name like '%" . $name . "%'";
$sql = "
SELECT *
FROM v_alive_user_group
WHERE 1=1 {$addQuery}
";
$list = $this->getArray($sql);
if (sizeof($list) > 0)
return $this->makeResultJson("1", "", $list);
else
return $this->makeResultJson("-1000", "내역이 없습니다.");
}
// 회원 가입 (http://106.240.232.36:8004/action_front.php?cmd=ApiUser.memberJoin)
function memberJoin()
{
$id = $this->req["id"];
$name = $this->req["name"];
$tel = str_replace(" ", "", $this->req["tel"]);
$app_type = $this->req["app_type"];
$group_fk = $this->req["group_fk"];
$regiType = $this->req["regiType"];
$memType = $this->req["memType"];
$deviceID = $this->req["deviceID"];
$deviceTypeID = $this->req["deviceTypeID"];
$storeTypeID = $this->req["storeTypeID"];
$registrationKey = $this->req["registrationKey"];
$appVersion = $this->req["appVersion"];
// $status = ($memType == this.MEM_TYPE_NOMAL) ? "" : "" ;
$sql = "
SELECT *
FROM tbl_user
WHERE `id` = '{$id}' AND `status` = 'Y'
LIMIT 1
";
$regInfo = $this->getRow($sql);
if($regInfo != null)
return $this->makeResultJson(-100, "이미 회원가입을 하셨습니다.");
// 멤버십 회원 가입 일경우 전화번호 필수
if ($this->MEM_TYPE_HOLD == $memType)
{
if($tel == "")
return $this->makeResultJson(-101, "제휴회원 요청시 전화번호는 필수 입력사항입니다.");
$sql = "
SELECT *
FROM tbl_user
WHERE `tel` = '{$tel}' AND `status` = 'Y' AND `member_type` != '{$this->MEM_TYPE_NOMAL}'
LIMIT 1
";
$telResult = $this->getRow($sql);
if($telResult != null)
return $this->makeResultJson(-102, "이미 가입된 멤버십 회원이십니다.");
}
$insAssoc = Array(
"id" => $id,
"name" => $name,
"tel" => $tel,
"app_type" => $app_type,
"group_fk" => $group_fk,
"member_type" => $memType,
"regi_type" => $regiType,
"device_id" => $deviceID,
"device_type_id" => $deviceTypeID,
"storeType_id" => $storeTypeID,
"reg_dt" => "now()",
"app_version" => $appVersion,
"registration_key" => $registrationKey,
"status" => "Y"
);
$result = $this->techOfInsertForUpdate("tbl_user", $insAssoc);
$no = $this->mysql_insert_id();
$file_vir_name = "";
$file_org_name = "";
if ($this->MEM_REGI_EMAIL == $regiType)
{
$updateFileData = $this->inFn_Common_fileSave($_FILES);
$file_vir_name = $updateFileData["file"]["saveURL"];
$file_org_name = $updateFileData["file"]["name"];
}
else
{
$file_vir_name = $this->req["fileName"];
}
$insFile = Array(
"file_org_name" => $file_org_name,
"file_vir_name" => $file_vir_name,
"reg_dt" => "now()",
"pa_no" => $no,
"file_type" => "ME"
);
$fileResult = $this->techOfInsertForUpdate("tbl_file", $insFile);
if ($result > 0)
{
$returnCode = "1";
$returnMessage = "가입되었습니다.";
}
else
{
$returnCode = "-1";
$returnMessage = "오류가 발생했습니다.";
}
return $this->makeResultJson($returnCode, $returnMessage, $userInfo);
}
/**
* 멤버쉽 신청
* @return string
*/
function reqMembership()
{
$memType=$this->req["memType"];
$name = $this->req["name"];
$tel = str_replace(" ", "", $this->req["tel"]);
$group_fk = $this->req["group_fk"];
$no = $this->appUser["no"];
$sql = "
SELECT *
FROM tbl_user
WHERE `no` = '{$no}' AND `status` = 'Y'
LIMIT 1
";
$userInfo = $this->getRow($sql);
if($userInfo == null)
{
return $this->makeResultJson("-10", "비정상 접근");
}
else if($userInfo["member_type"] != 'N')
{
return $this->makeResultJson("-100", "이미 멤버쉽을 신청하였습니다.");
}
else if($tel == "")
{
return $this->makeResultJson(-101, "제휴회원 요청시 전화번호는 필수 입력사항입니다.");
}
else
{
$sql = "
SELECT *
FROM tbl_user
WHERE `tel` = '{$tel}' AND `status` = 'Y' AND `member_type` != '{$this->MEM_TYPE_NOMAL}'
LIMIT 1
";
$telResult = $this->getRow($sql);
if($telResult != null)
return $this->makeResultJson(-102, "이미 가입된 멤버십 회원이십니다.");
// 파일 업로드
if ($_FILES != null && sizeof($_FILES) > 0)
{
// 삭제함
$sql = "
DELETE FROM tbl_file WHERE pa_no = '{$no}' AND file_type = '{$this->FILE_TYPE_MEM}'
";
$this->update($sql);
$updateFileData = $this->inFn_Common_fileSave($_FILES);
$file_vir_name = $updateFileData["file"]["saveURL"];
$file_org_name = $updateFileData["file"]["name"];
$insFile = Array(
"file_org_name" => $file_org_name,
"file_vir_name" => $file_vir_name,
"reg_dt" => "now()",
"pa_no" => $no,
"file_type" => $this->FILE_TYPE_MEM
);
$fileResult = $this->techOfInsertForUpdate("tbl_file", $insFile);
}
$sql = "
UPDATE tbl_user
SET
name = '{$name}'
, tel = '{$tel}'
, group_fk = '{$group_fk}'
, member_type = '{$memType}'
WHERE `no` = '{$no}'
";
$this->update($sql);
return $this->makeResultJson("1", "저장되었습니다.", $this->inFn_ApiBase_getInfoOfUser($no));
}
}
// 회원 로그인 (http://106.240.232.36:8004/action_front.php?cmd=ApiUser.userLogin)
function userLogin()
{
$id = $this->req["id"];
$app_type = $this->req["app_type"];
$deviceID = $this->req["deviceID"];
$deviceTypeID = $this->req["deviceTypeID"];
$storeTypeID = $this->req["storeTypeID"];
$registrationKey = $this->req["registrationKey"];
$appVersion = $this->req["appVersion"];
$param = Array(
$id,
$app_type,
$deviceID,
$deviceTypeID,
$registrationKey,
$storeTypeID,
$appVersion
);
$sql = $this->strCallProc3("uspU_loginUser", $param);
$result = $this->getMultiArray($sql);
if ($result[0][0]["v_returnCode"] > 0)
{
$userInfo = $this->inFn_ApiBase_getInfoOfUser($result[0][0]["v_userNumber"]);
LoginUtil::doAppLogin($userInfo);
return $this->makeResultJson($result[0][0]["v_returnCode"], $result[0][0]["v_returnMsg"], $userInfo);
}
else
{
return $this->makeResultJson($result[0][0]["v_returnCode"], $result[0][0]["v_returnMsg"]);
}
}
// 비동기 푸시키 갱신 API
function setUserRegistrationKey()
{
$no = $this->appUser["no"];
$registration_key = $this->req["registration_key"];
if ($no != "-1")
{
$sql = "
UPDATE tbl_user
SET registration_key = '{$registration_key}'
WHERE no = '{$no}'
";
$this->update($sql);
}
}
// 민원 정보공유 푸시 설정
function setCommentPushOnOff()
{
$no = $this->appUser["no"];
$is_push = $this->req["is_push"];
$sql = "
UPDATE tbl_user
SET comm_push = '{$is_push}'
WHERE `no` = '{$no}'
";
$result = $this->update($sql);
return $this->makeResultJson("1", "");
}
// 민원 정보공유 푸시 설정
function setInfoPushOnOff()
{
$no = $this->appUser["no"];
$is_push = $this->req["is_push"];
$sql = "
UPDATE tbl_user
SET info_push = '{$is_push}'
WHERE `no` = '{$no}'
";
$result = $this->update($sql);
return $this->makeResultJson("1", "");
}
// 푸시 설정
function setPushOnOff()
{
$no = $this->appUser["no"];
$is_push = $this->req["is_push"];
$sql = "
UPDATE tbl_user
SET is_push = '{$is_push}'
WHERE `no` = '{$no}'
";
$result = $this->update($sql);
return $this->makeResultJson("1", "");
}
// 렌트 푸시 설정
function setRentOnOff()
{
$no = $this->appUser["no"];
$is_rent = $this->req["is_push"];
$sql = "
UPDATE tbl_user
SET is_rent = '{$is_rent}'
WHERE `no` = '{$no}'
";
$result = $this->update($sql);
return $this->makeResultJson("1", "");
}
// 로그아웃
function userLogout()
{
$no = $this->appUser["no"];
// 푸시키 초기화
$sql = "
UPDATE tbl_user
SET registration_key = ''
WHERE no = '{$no}'
";
$this->update($sql);
return $this->makeResultJson("1", "");
}
// 정보수정
function modifyUserInfo()
{
$userNo = $this->appUser["no"];
$name = $this->req["name"];
$tel = $this->req["tel"];
$group_fk = $this->req["group_fk"] ;
$groupName = $this->req["groupName"] ;
$is_file_change = $this->req["is_file_change"]; // NEW / DEL / NON
// 삭제함
if ($is_file_change != "NON")
{
$sql = "
DELETE FROM tbl_file WHERE pa_no = '{$userNo}' AND file_type = '{$this->FILE_TYPE_MEM}'
";
$this->update($sql);
}
// 파일 업로드
if ($is_file_change == "NEW" && ($_FILES != null && sizeof($_FILES) > 0))
{
$updateFileData = $this->inFn_Common_fileSave($_FILES);
$file_vir_name = $updateFileData["file"]["saveURL"];
$file_org_name = $updateFileData["file"]["name"];
$insFile = Array(
"file_org_name" => $file_org_name,
"file_vir_name" => $file_vir_name,
"reg_dt" => "now()",
"pa_no" => $userNo,
"file_type" => $this->FILE_TYPE_MEM
);
$fileResult = $this->techOfInsertForUpdate("tbl_file", $insFile);
}
$sql = "
UPDATE tbl_user
SET
name = '{$name}'
, group_fk = '{$group_fk}'
, tel = '{$tel}'
WHERE `no` = '{$userNo}'
";
$this->update($sql);
return $this->makeResultJson("1", "저장되었습니다.", $this->inFn_ApiBase_getInfoOfUser($userNo));
}
/**
* 회원 사용 포인트 내역 조회
*
* @return string
*/
function getListOfUserPoint()
{
$userNo = $this->appUser["no"];
$this->initPage();
$sql = "
SELECT COUNT(*)
FROM tbl_point_trans PT
JOIN tbl_shop S ON(PT.shop_fk = S.no)
WHERE PT.user_fk = '{$userNo}' AND PT.trans_type = 'O' AND PT.pay_type = '{$this->PAY_TYPE_USE}'
";
$this->rownum = $this->getValue($sql, "rn");
$this->setPage($this->rownum);
$sql = "
SELECT
PT.*
, S.name AS shop_name
FROM tbl_point_trans PT
JOIN tbl_shop S ON(PT.shop_fk = S.no)
WHERE PT.user_fk = '{$userNo}' AND PT.trans_type = 'O' AND PT.pay_type = '{$this->PAY_TYPE_USE}'
ORDER BY PT.no DESC
LIMIT {$this->startNum}, {$this->endNum}
";
$list = $this->getArray($sql);
$addData = Array(
"start_date" => date('Y.m.01', time()),
"end_date" => date('Y.m', time()) . "." . date('t', time()),
"avail_point" => $this->inFn_Common_getUserPointBalance($userNo)
);
if (sizeof($list) > 0)
return $this->makeResultJson("1", "", $list, $addData);
else
return $this->makeResultJson("-1000", "내역이 없습니다.", "", $addData);
}
/**
* 회원 정보 조회
*/
function getUserInfo()
{
$no = $this->req["no"];
$userInfo = $this->inFn_ApiBase_getInfoOfUser($no);
$addData = Array("avail_point" => $this->inFn_Common_getUserPointBalance($no));
return $this->makeResultJson("1", "", $userInfo, $addData);
}
} // 클래스 종료
}
?>