ApiProcess.php
3.78 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
<? include_once $_SERVER["DOCUMENT_ROOT"] . "/common/classes/ApiBase.php" ; ?>
<?php
if (! class_exists("ApiProcess"))
{
class ApiProcess extends ApiBase
{
function __construct($req)
{
parent::__construct($req);
}
function processRunGate()
{
$logData = "Call API : processRunGate";
$this->writeFileLog($logData, 'processRunGate');
$this->sendBiPush();
}
function getBulkPushData($push_code)
{
$sql = "
SELECT *
FROM tbl_push_target_bulk
WHERE push_code = '{$push_code}'
";
$result = $this->getArray($sql);
$sql = "
DELETE FROM tbl_push_target_bulk WHERE push_code = '{$push_code}'
";
$this->update($sql);
return $result;
}
function sendBulkPush()
{
$targetList = $this->req["targetList"];
for ($i=0; $i<sizeof($targetList); $i++)
{
$targetList[$i] = json_decode($targetList[$i], true);
}
$pushObj = new Push();
$pushObj->pushFlag = $this->req["push_type"];
$pushObj->pushNo = $this->req["push_no"];
$pushObj->pushMessage = $this->req["push_msg"];
$pushObj->sendPushArray($targetList);
}
/**
* 정보공유 푸시 전송
* 스케줄러 (1분)
*/
function sendBiPush()
{
$sql = "
SELECT group_code, board_no, push_msg
FROM tbl_bi_push
WHERE status = 1
GROUP BY group_code, board_no, push_msg
";
$groupCodeList = $this->getArray($sql);
if(sizeof($groupCodeList) > 0)
{
$sql = "
UPDATE tbl_bi_push
SET status = 2
";
$this->update($sql);
$pushObj = new Push();
for($i = 0; $i<sizeof($groupCodeList); $i++)
{
$sql = "
SELECT U.registrationKey, U.deviceTypeID
FROM tbl_bi_push P
JOIN tbl_user U ON(P.user_fk = U.no)
WHERE
P.group_code = '{$groupCodeList[$i]["group_code"]}'
AND U.status = 'Y'
AND U.is_push = 1
AND U.info_push = 1
AND U.registrationKey IS NOT NULL
AND U.registration_key != ''
";
$pushTargetList = $this->getArray($sql);
if(sizeof($pushTargetList) > 0)
{
$pushObj->pushFlag = $pushObj->PUSH_TYPE_BI;
$pushObj->pushNo = $groupCodeList[i]["board_no"];
$pushObj->pushMessage = $groupCodeList[i]["push_msg"];
$pushObj->sendPushArray($pushTargetList);
}
}
}
}
/**
* 포인트 충전 차감
* 스케줄러(매월1일 00시)
*/
function reChargePoint()
{
// 남은 포인트 차감
$sql = "
SELECT user_fk, group_fk, IFNULL(SUM(CASE trans_type WHEN 'I' THEN amt ELSE (amt*-1) END ), 0) AS balanceAmt
FROM tbl_point_trans
GROUP BY user_fk
HAVING(balanceAmt > 0)
";
$targetList = $this->getArray($sql);
for($i=0; $i<sizeof($targetList); $i++)
{
$this->inFn_Common_savePointTrans("O", $targetList[$i]["user_fk"], $targetList[$i]["balanceAmt"], $targetList[$i]["group_fk"], 0, $this->PAY_TYPE_RETRIEVE);
}
$sql = "
INSERT INTO tbl_point_trans(user_fk, group_fk, trans_type, amt, pay_type, reg_dt, reg_date)
(
SELECT U.user_fk, U.group_fk, 'I', G.group_point, '{$this->PAY_TYPE_ADMIN}', NOW(), CURDATE()
FROM tbl_user U
JOIN tbl_user_group G ON(U.group_fk = G.no)
WHERE U.status = 'Y' AND U.member_type = 'M' AND G.status = 'Y' AND G.group_point > 0
)
";
$this->update($sql);
}
function testPush() {
//$targetList = $this->req["targetList"];
$targetList[] = array("registration_key" => "afe8b1ad4fb71723be75eadbfb9d14728175a7fb27c0f96184198a2cda513098", "device_type_id" => "2");
$pushObj = new Push();
$pushObj->pushFlag = $this->PUSH_TYPE_ADMIN;
$pushObj->pushNo = $this->req["push_no"];
$pushObj->pushMessage = "TEST";
$pushObj->sendPushArray($targetList);
}
} //클래스 종료
}
?>