Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rpc
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lambda
rpc
Commits
baf04151
Commit
baf04151
authored
May 12, 2017
by
TingSong-Syu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement static useful functions for Feature
parent
76395f16
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
6 deletions
+34
-6
Feature.php
src/pay_center/Feature.php
+28
-0
Product.php
src/pay_center/Product.php
+6
-6
No files found.
src/pay_center/Feature.php
View file @
baf04151
...
...
@@ -10,6 +10,7 @@ namespace neoteched\rpc\pay_center;
use
x2ts\IAssignable
;
use
x2ts\rpc\RPCWrapper
;
class
Feature
implements
IAssignable
{
use
AssignTrait
;
...
...
@@ -20,6 +21,8 @@ class Feature implements IAssignable {
self
::
TYPE_CARD
,
];
private
static
$userBought
=
[];
public
$name
=
''
;
public
$description
=
''
;
...
...
@@ -29,4 +32,28 @@ class Feature implements IAssignable {
public
$ctime
=
0
;
public
$mtime
=
0
;
public
static
function
boughtFeatureNames
(
int
$userId
)
:
array
{
return
array_keys
(
self
::
userBought
(
$userId
));
}
public
static
function
userBought
(
int
$userId
)
{
if
(
!
array_key_exists
(
$userId
,
self
::
$userBought
))
{
self
::
$userBought
[
$userId
]
=
RPCWrapper
::
rpc
(
'pay_center'
)
->
call
(
'boughtFeatureHash'
,
$userId
);
}
return
self
::
$userBought
[
$userId
];
}
public
static
function
boughtFeatures
(
int
$userId
)
:
array
{
return
RPCWrapper
::
rpc
(
'pay_center'
)
->
call
(
'boughtFeatures'
,
$userId
);
}
public
static
function
boughtFeatureCount
(
int
$userId
)
:
int
{
return
count
(
self
::
userBought
(
$userId
));
}
public
static
function
hasBought
(
string
$name
,
int
$userId
)
:
bool
{
return
array_key_exists
(
$name
,
self
::
userBought
(
$userId
));
}
}
\ No newline at end of file
src/pay_center/Product.php
View file @
baf04151
...
...
@@ -14,6 +14,8 @@ use x2ts\rpc\RPCWrapper;
class
Product
implements
IAssignable
{
use
AssignTrait
;
private
static
$userBought
=
[];
public
$name
=
''
;
public
$price
=
0
;
...
...
@@ -28,7 +30,9 @@ class Product implements IAssignable {
public
$mtime
=
0
;
private
static
$userBought
=
[];
public
static
function
boughtProductNames
(
int
$userId
)
:
array
{
return
array_keys
(
self
::
userBought
(
$userId
));
}
public
static
function
userBought
(
int
$userId
)
{
if
(
!
array_key_exists
(
$userId
,
self
::
$userBought
))
{
...
...
@@ -38,11 +42,7 @@ class Product implements IAssignable {
return
self
::
$userBought
[
$userId
];
}
public
static
function
boughtProductNames
(
int
$userId
)
:
array
{
return
array_keys
(
self
::
userBought
(
$userId
));
}
public
static
function
boughtProducts
(
int
$userId
)
{
public
static
function
boughtProducts
(
int
$userId
)
:
array
{
return
RPCWrapper
::
rpc
(
'pay_center'
)
->
call
(
'boughtProducts'
,
$userId
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment