Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
my-yaf-project
Project
Project
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenchuanwen
my-yaf-project
Commits
161e49d4
Commit
161e49d4
authored
Nov 01, 2018
by
wwccw0591
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upd
parent
03b8eaa8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
5 deletions
+18
-5
GoodsCommonService.php
application/models/Business/Goods/GoodsCommonService.php
+12
-3
GoodsCommon.php
application/models/DAO/GoodsCommon.php
+6
-2
GoodsClassRedis.php
application/models/Redis/Db6/GoodsClassRedis.php
+0
-0
No files found.
application/models/Business/Goods/GoodsCommonService.php
View file @
161e49d4
...
...
@@ -14,7 +14,16 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
}
public
function
setGoodsStorage
(
$storeId
,
$goodsId
,
$num
=
0
,
$type
=
'set'
)
{
/**
* 设置库存
* @param $storeId
* @param $goodsId
* @param int $num
* @param string $type
* @return array
* @throws \Exception
*/
public
function
setGoodsStorage
(
$storeId
,
$goodsId
,
$num
=
0
,
$type
=
'add'
)
{
if
(
$goodsId
===
0
){
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
commonError
);
}
...
...
@@ -27,12 +36,12 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
if
(
!
$data
)
{
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
goodsNotExist
);
}
$op
=
isset
(
$this
->
setStorageType
[
$type
])
?
$this
->
setStorageType
[
$type
]
:
2
;
//默认设置
库存
$op
=
isset
(
$this
->
setStorageType
[
$type
])
?
$this
->
setStorageType
[
$type
]
:
1
;
//默认增加
库存
$goodsDao
->
db
->
doTransaction
();
$ret1
=
$goodsDao
->
updateStorage
(
$goodsId
,
$num
,
$op
);
$ret2
=
true
;
if
(
$op
==
1
)
{
//如果就库存调整
$ret2
=
$commonDao
->
updateStorage
(
$data
[
'goods_commonid'
]);
$ret2
=
$commonDao
->
updateStorage
(
$data
[
'goods_commonid'
]
,
$op
);
}
if
(
!
$ret1
||
!
$ret2
)
{
...
...
application/models/DAO/GoodsCommon.php
View file @
161e49d4
...
...
@@ -35,10 +35,14 @@ class GoodsCommonModel extends \DAO\AbstractModel {
* @param $op 1增加 2设置
* @return mixed
*/
public
function
updateStorage
(
$goodsCommonid
)
{
public
function
updateStorage
(
$goodsCommonid
,
$op
=
1
)
{
$this
->
setDb
();
$whereSql
=
'goods_commonid='
.
$goodsCommonid
;
$updateSql
=
'goods_storage = (select sum(t.goods_storage) from '
.
$this
->
_child_tableName
.
' t where t.goods_commonid='
.
$goodsCommonid
.
')'
;
if
(
$op
==
1
){
$updateSql
=
'goods_storage = (select sum(t.goods_storage) from '
.
$this
->
_child_tableName
.
' t where t.goods_commonid='
.
$goodsCommonid
.
')'
;
}
else
{
$updateSql
=
'goods_storage_alarm = 0'
;
}
$updateAllSql
=
"UPDATE
{
$this
->
_tableName
}
set
{
$updateSql
}
where
{
$whereSql
}
"
;
return
$this
->
db
->
update
(
$this
->
_tableName
)
->
query
(
$updateAllSql
);
}
...
...
application/models/Redis/Db6/GoodsClassRedis.php
100755 → 100644
View file @
161e49d4
File mode changed from 100755 to 100644
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