Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
ic_server_welfare
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4f4c8fa3
authored
Aug 28, 2019
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
添加可使用库存字段
parent
4c13de3c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
app/Models/ExchangeSetting.php
app/Models/ExchangeSetting.php
View file @
4f4c8fa3
...
...
@@ -41,7 +41,6 @@ class ExchangeSetting extends Model
//先从redis里面查询是否有列表,没有的话从MySQL里面取出并且放入redis
$redis
=
new
RedisModel
();
$settings
=
$this
->
getExchangeSettingsFromRedis
();
$count
=
0
;
if
(
!
$settings
)
{
$result
=
$this
->
addExchangeSettingListToRedis
();
if
(
!
$result
)
{
...
...
@@ -49,7 +48,8 @@ class ExchangeSetting extends Model
$settings
=
$this
->
getExchangeSettingsFromRedis
();
}
}
//这边还要去redis获取每项的可使用库存
$settings
=
$this
->
getAvailableStock
(
$settings
);
//如果需要过滤type
if
(
$map
[
'type'
])
{
$settings
=
array_filter
(
$settings
,
function
(
$value
)
use
(
$map
)
{
...
...
@@ -138,6 +138,18 @@ class ExchangeSetting extends Model
}
}
public
function
getAvailableStock
(
$settings
=
[])
{
$redis
=
new
RedisModel
();
foreach
(
$settings
as
$key
=>
&
$setting
)
{
$key
=
'ic_exchange_settings_'
.
$setting
[
'id'
];
$setting
[
'available_stock'
]
=
$redis
->
llen
(
$key
);
}
unset
(
$setting
);
return
$settings
;
}
public
function
updateExchangeSetting
(
$id
,
$data
=
[])
{
$result
=
DB
::
transaction
(
function
()
use
(
$id
,
$data
)
{
...
...
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