-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess.class.php
279 lines (156 loc) · 6.55 KB
/
process.class.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
<?php
class Videoplus_Service_Process extends Phpfox_Service
{
public function getUsers($iTotal)
{
return $this->database()->select('u.full_name')
->from(Phpfox::getT('user'), 'u')
->limit($iTotal)
->execute('getRows');
}
public function get_last_prod_date($avalues)
{
$time = '50';
//$days = '7';
$lastdate = $this->database()->select('u.prod_sales_kill_date')
->from(Phpfox::getT('abstract_store_prod_sales'), 'u')
->where('prod_sales_buyer_id = ' . Phpfox::getUserId() . ' AND prod_sales_status_payment = 3 AND prod_sales_prod_id = '.$avalues['prod_id'])
->order('prod_sales_id DESC')
->execute('getfield');
if($lastdate < $time )
{
$lastdate = $time;
}
$lastdate = (int)$lastdate + (int)$avalues['days'];
return $lastdate;
}
public function assign_due_date($lavashvalues)
{
$myrow = $this->database()->select('u.*')
->from(Phpfox::getT('abstract_cart_carts'), 'u')
->where('carts_id = ' . $lavashvalues['iCartId'] )
->execute('getrows');
$mrow = $myrow[0];
if($mrow['carts_due_time'] > 0){
$start_time = $mrow['carts_due_time'];
}else{
$start_time = time();
}
if($mrow['carts_payment_cycle_lavash'] == 0){
$carts_payment_cycle = $lavashvalues['prod_pay_cycle_lavash'];
}else{
$carts_payment_cycle = $mrow['carts_payment_cycle_lavash'];
}
$carts_paid_num = $mrow['carts_paid_num_lavash'] + 1;
$carts_due_time = $start_time + ($lavashvalues['prod_duration_lavash'] * 86400);
$carts_due_reminders_time = $carts_due_time - (3 * 86400);
//$carts_due_reminders = 2 ;
if($carts_payment_cycle == $carts_paid_num AND $lavashvalues['prod_duration_lavash'] > 0 ){
$mcarts_status_paid = 3;
$mcarts_type = 0;
}else{
$mcarts_status_paid = 1;
$mcarts_type = 1;
}
$this->database()->update(Phpfox::getT('abstract_cart_carts'),
array(
'carts_paid_num_lavash' => $carts_paid_num,
'carts_due_time' => $carts_due_time,
'carts_payment_cycle_lavash' => $carts_payment_cycle,
'carts_due_reminders_time' => $carts_due_reminders_time,
'carts_status_paid' => $mcarts_status_paid,
'carts_type' => $mcarts_type),
'carts_id = ' .$lavashvalues['iCartId']);
$this->sendmail(1,Phpfox::getUserId(),'my purchase id',$lavashvalues['prod_pay_cycle_lavash'].' you just purchased a '.$lavashvalues['prod_duration_lavash'].' day(s) subscription',$mrow['carts_due_time'].' A subscription purchase made. ' ) ;
}
public function getprodfile($prod_id,$album_id)
{
$asale = $this->database()->select('u.prod_files_save_name')
->from(Phpfox::getT('abstract_store_prod_sales'), 'u')
->where('prod_files_prod_id = ' . $prod_id . ' AND prod_files_prod_files_album = '.$album_id)
->order('prod_files_id DESC')
->execute('getfields');
$this->sendmail(1,Phpfox::getUserId(),'my purchase id',$asale,'my sales purchase id' ) ;
}
public function getsales_id($prod_id)
{
$asale = $this->database()->select('u.prod_sales_id')
->from(Phpfox::getT('abstract_store_prod_sales'), 'u')
->where('prod_sales_buyer_id = ' . Phpfox::getUserId() . ' AND prod_sales_status_payment = 3 AND prod_sales_prod_id = '.$prod_id)
->order('prod_sales_id DESC')
->execute('getfield');
//$this->sendmail(1,Phpfox::getUserId(),'my purchase id',$asale,'my sales purchase id' ) ;
return $asale ;
}
public function makepin($aval )
{
$auser['iUserId'] = Phpfox::getUserId();
$userpoint = Phpfox::getService('abstractbridge.activity')->getUserPoints($auser);
$quantity = $aval['quantity'];
$price = $aval['price'];
$product_id = $aval['product_id'];
$length = 15 ;
$lTotalPoints = (int)$price*(int)$quantity;
if($lTotalPoints <=(int)$userpoint)
{
for ($i = 0; $i < (int)$quantity; $i++) {
$pin = substr(str_shuffle("012345678901234567890123456789789012345678901234"), 0, $length);
$spin = $spin." <br><br> ".$pin ;
$this->database()->insert(Phpfox::getT('lavash_pins'), array('time_created' => PHPFOX_TIME,'pin' => $pin,'pin_price' => (int)$price ,'pin_owner' => (int)$auser['iUserId']));
}
$lNewPoints = (int)$userpoint - $lTotalPoints ;
$this->database()->update(Phpfox::getT('user_activity'), array('activity_points' => (int) $lNewPoints), 'user_id = ' . (int)$auser['iUserId']);
$message = $spin ." <br><br><br><br> "."......THANK YOU FOR PURCHASING ".$quantity." HOOKCELL.COM VOUCHER(S) WORTH ".$price." POINTS EACH, FROM OUR STORE.";
$Subject = "VOUCHER DELIVERY SERVICE";
$preview = "YOUR VOUCHER PURCHASE IS HERE";
$to = (int)Phpfox::getUserId();
$from = 1;
$this->sendmail($from,$to,$preview,$message,$Subject ) ;
$iresponce = "YOUR BALANCE IS NOW ".$lNewPoints." POINTS.<br><br>THANK YOU FOR PURCHASING ".$quantity." HOOKCELL.COM VOUCHER(S) WORTH ".$price." POINTS EACH, FROM OUR STORE. YOUR PINS ARE DELIVERED TO YOUR INBOX".$ltotalamt;
}
else {
$iresponce = 'SORRY YOU DONT HAVE ENOUGH POINTS TO MAKE THIS PURCHASE.';
}
return $iresponce;
}
public function sendmail($from,$to,$preview,$message,$Subject )
{
$aInsert = array(
'parent_id' => 0,
'subject' => $Subject,
'preview' => $preview,
'owner_user_id' => $from,
'viewer_user_id' => $to,
'viewer_is_new' => 1,
'time_stamp' => PHPFOX_TIME,
'time_updated' => PHPFOX_TIME,
'total_attachment' => 0,
);
$iMailId = $this->database()->insert(Phpfox::getT('mail'), $aInsert);
$aContent = array(
'mail_id' => $iMailId,
'text' => $preview,
'text_parsed' => $message
);
$this->database()->insert(Phpfox::getT('mail_text'), $aContent);
}
public function loadpin($ipin)
{
$pi = $ipin;//"702409515418897";
$op = "pin = ";
$pinum = $op.$pi;
$pinprice = (int) $this->database()->select('pin_price')
->from(Phpfox::getT('lavash_pins'))
->where("pin = ".$pi. " AND time_loaded = 0")
->execute('getSlaveField');
$iTotalPoints = (int) $this->database()->select('activity_points')
->from(Phpfox::getT('user_activity'))
->where('user_id = ' . (int) Phpfox::getUserId())
->execute('getSlaveField');
$iNewPoints = $pinprice += $iTotalPoints ;
$this->database()->update(Phpfox::getT('user_activity'), array('activity_points' => (int) $iNewPoints), 'user_id = ' . (int)Phpfox::getUserId());
$this->database()->update(Phpfox::getT('lavash_pins'), array('time_loaded' => PHPFOX_TIME,'pin_loader' => (int)Phpfox::getUserId()), 'pin = ' .$pi);
return $iNewPoints ;
}
}
?>