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
5148057d
Commit
5148057d
authored
Oct 30, 2018
by
wwccw0591
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
temp
parent
7538529c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
152 additions
and
10 deletions
+152
-10
CommentService.php
application/models/Business/Goods/CommentService.php
+0
-0
GoodsCommonService.php
application/models/Business/Goods/GoodsCommonService.php
+36
-4
RefundService.php
application/models/Business/Order/RefundService.php
+54
-0
Goods.php
application/models/DAO/Goods.php
+26
-2
GoodsCommon.php
application/models/DAO/GoodsCommon.php
+18
-0
Shopkeeper.php
application/modules/Client/controllers/Shopkeeper.php
+18
-4
No files found.
application/models/Business/Goods/CommentService.php
100755 → 100644
View file @
5148057d
File mode changed from 100755 to 100644
application/models/Business/Goods/GoodsCommonService.php
View file @
5148057d
...
...
@@ -8,23 +8,53 @@ use Zend\Json\Server\Exception\ErrorException;
class
GoodsCommonServiceModel
extends
\Business\AbstractModel
{
private
$goodsStorageField
=
'goods_id goodsId,goods_name goodsName,goods_verify goodsVerify,goods_state goodsState,goods_image goodsImage,goods_price goodsPrice,goods_storage goodsStorage,goods_spec goodsAttr'
;
private
$setStorageType
=
array
(
'add'
=>
1
,
'set'
=>
2
);
public
function
init
()
{
}
public
function
setGoodsStorage
(
$storeId
,
$goodsId
,
$num
=
0
,
$type
=
'set'
)
{
if
(
$goodsId
===
0
){
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
commonError
);
}
$goodsDao
=
\DAO\GoodsModel
::
getInstance
();
$commonDao
=
\DAO\GoodsCommonModel
::
getInstance
();
$where
=
array
();
$where
[
'store_id'
]
=
$storeId
;
$where
[
'goods_id'
]
=
$goodsId
;
$data
=
$goodsDao
->
find
(
$where
,
'goods_id, goods_commonid'
);
if
(
!
$data
)
{
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
goodsNotExist
);
}
$op
=
isset
(
$this
->
setStorageType
[
$type
])
?
$this
->
setStorageType
[
$type
]
:
2
;
//默认设置库存
$goodsDao
->
db
->
doTransaction
();
$ret1
=
$goodsDao
->
updateStorage
(
$goodsId
,
$num
,
$op
);
$ret2
=
$commonDao
->
updateStorage
(
$data
[
'goods_commonid'
]);
if
(
!
$ret1
||
!
$ret2
)
{
$goodsDao
->
db
->
doRollback
();
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
updateGoodsStorageForOrder
);
}
$goodsDao
->
db
->
doCommit
();
return
array
();
}
/**
* 获取商品库存方法
*
*
@author king
*/
public
function
getGoodsStorageList
(
$storeId
,
$pageIndex
=
ApiConst
::
zero
,
$pageSize
=
ApiConst
::
pageSize
)
{
$goodsDao
=
\DAO\GoodsModel
::
getInstance
(
DbNameConst
::
salveDBConnectName
);
$goodsDao
=
\DAO\GoodsModel
::
getInstance
();
$where
=
array
();
$where
[]
=
'store_id = '
.
$storeId
;
$where
[]
=
'goods_storage<=goods_storage_alarm'
;
//获得列表
$datas
=
$goodsDao
->
getListPage
(
implode
(
$where
,
' and '
),
$this
->
goodsStorageField
,
$pageIndex
,
$pageSize
);
if
(
$datas
=
$goodsDao
->
getList
(
implode
(
$where
,
' and '
),
$this
->
goodsStorageField
))
{
foreach
(
$datas
as
$key
=>
$val
)
{
$datas
[
$key
][
'goodsAttr'
]
=
$goodsDao
->
getFormatGoodsAttr
(
$val
[
'goodsAttr'
]);
}
}
//获得售后商品列表getOrderGoodsByRecIds
if
(
!
empty
(
$datas
))
{
...
...
@@ -1230,6 +1260,8 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
}
private
static
$_instance
=
null
;
/**
...
...
application/models/Business/Order/RefundService.php
View file @
5148057d
...
...
@@ -58,6 +58,60 @@ class RefundServiceModel extends \Business\AbstractModel
return
$this
->
orderGoodsField
.
',goods_commonid as goodsCommonid,goods_commonid as goodsCommonId,goods_spec as goodsSpec '
;
}
/**
* 店铺退款列表
* @param $storeId
* @param int $type
* @param int $pageIndex
* @param int $pageSize
* @return \stdClass
*/
public
function
getStoreRefundList
(
$storeId
,
$type
=
0
,
$pageIndex
=
ApiConst
::
zero
,
$pageSize
=
ApiConst
::
pageSize
)
{
$refundReturnDao
=
\DAO\Order\RefundReturnModel
::
getInstance
(
DbNameConst
::
salveDBConnectName
);
$orderGoodsDao
=
\DAO\Order\OrderGoodsModel
::
getInstance
(
DbNameConst
::
salveDBConnectName
);
$goodsDao
=
\DAO\GoodsModel
::
getInstance
(
DbNameConst
::
salveDBConnectName
);
$where
[
'store_id'
]
=
$storeId
;
$order
=
array
(
'add_time'
=>
'desc'
);
switch
(
$type
)
{
case
1
:
$where
[
'refund_state'
]
=
1
;
break
;
case
2
:
$where
[
'refund_state'
]
=
2
;
$where
[
'refund_type'
]
=
2
;
$order
=
array
(
'receive_time'
=>
'asc'
);
break
;
}
//获得售后列表
$refundReturns
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db5\OrderRedisModel
::
getInstance
(),
array
(
&
$refundReturnDao
,
'getList'
),
array
(
$where
,
$this
->
refundReturnField
,
$pageIndex
,
$pageSize
,
$order
),
\Our\ApiConst
::
oneDaySecond
,
array
(
$memberId
));
$orderGoodsId
=
array_column
(
$refundReturns
[
'list'
],
'orderGoodsId'
);
//获得售后商品列表getOrderGoodsByRecIds
if
(
!
empty
(
$orderGoodsId
))
{
$orderGoods
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db5\OrderRedisModel
::
getInstance
(),
array
(
&
$orderGoodsDao
,
'getOrderGoodsByRecIds'
),
array
(
$orderGoodsId
,
$this
->
orderGoodsField
),
\Our\ApiConst
::
oneDaySecond
,
array
(
$memberId
));
$refundMerge
=
Common
::
intergrateOneToOne
(
$refundReturns
[
'list'
],
$orderGoods
,
'orderGoodsId'
,
'recId'
);
foreach
(
$refundMerge
as
&
$value
)
{
$value
[
'refundStateName'
]
=
$refundReturnDao
->
getRefundTextStatus
(
$value
);
$value
[
'blId'
]
=
isset
(
$value
[
'blId'
])
?
(
!
is_null
(
$value
[
'blId'
])
?
$value
[
'blId'
]
:
ApiConst
::
zero
)
:
ApiConst
::
zero
;
$value
[
'canPlatformIn'
]
=
$refundReturnDao
->
isPlatformIn
(
$value
)
?
ApiConst
::
one
:
ApiConst
::
zero
;
$value
[
'canSendShippingType'
]
=
$refundReturnDao
->
checkIsAddReturnShipping
(
$value
)
?
ApiConst
::
one
:
ApiConst
::
zero
;
$value
[
'goodsImage'
]
=
ImageUtil
::
getGoodsImgUrl
(
$value
[
'goodsImage'
],
ApiConst
::
goodsSmallSize
);
$value
[
'goodsAttr'
]
=
$goodsDao
->
getFormatGoodsAttr
(
$value
[
'goodsSpec'
]);
$goodGroup
=
unserialize
(
$value
[
'goodsGroup'
]);
$value
[
'goodsGroup'
]
=!
empty
(
$goodGroup
)
?
$goodGroup
:
[];
unset
(
$value
[
'goodsSpec'
]);
unset
(
$value
[
'picInfo'
]);
}
$returnData
[
'refundReturns'
]
=
$refundMerge
;
$returnData
[
'totalCount'
]
=
$refundReturns
[
'totalCount'
];
return
$returnData
;
}
else
{
return
new
\stdClass
();
}
}
/**
* 退款列表
*
...
...
application/models/DAO/Goods.php
View file @
5148057d
...
...
@@ -29,6 +29,25 @@ class GoodsModel extends \DAO\AbstractModel {
public
function
init
(){
}
/**
* 更新商品表商品库存
* @param $goodsId 商品ID
* @param $num 库存数量
* @param $op 1增加 2设置
* @return mixed
*/
public
function
updateStorage
(
$goodsId
,
$num
,
$op
)
{
$this
->
setDb
();
$whereSql
=
'goods_id='
.
$goodsId
;
if
(
$op
==
1
){
$updateSql
=
'goods_storage = goods_storage'
.
(
$num
<
0
?
'-'
.
(
-
$num
)
:
'+'
.
$num
);
}
else
{
$updateSql
=
'goods_storage ='
.
$num
;
}
$updateAllSql
=
"UPDATE
{
$this
->
_tableName
}
set
{
$updateSql
}
where
{
$whereSql
}
"
;
return
$this
->
db
->
update
(
$this
->
_tableName
)
->
query
(
$updateAllSql
);
}
/**
*
* 分页获取商品列表
...
...
@@ -44,7 +63,7 @@ class GoodsModel extends \DAO\AbstractModel {
$this
->
setDb
(
$this
->
dbName
);
if
(
$datas
=
$this
->
lists
(
$where
,
$order
,
$field
,
$pageIndex
,
$pageSize
))
{
foreach
(
$datas
[
'list'
]
as
$key
=>
$val
)
{
$datas
[
'list'
][
$key
][
'goodsAttr'
]
=
$this
->
getFormatGoodsAttr
(
$val
[
'goodsAttr
s
'
]);
$datas
[
'list'
][
$key
][
'goodsAttr'
]
=
$this
->
getFormatGoodsAttr
(
$val
[
'goodsAttr'
]);
}
}
return
$datas
?
$datas
:
array
();
...
...
@@ -330,7 +349,12 @@ class GoodsModel extends \DAO\AbstractModel {
return
$goodsList
;
}
/**
* 更新库存
* @param $dataList
* @param int $op
* @return bool
*/
public
function
updateGoodsStorage
(
$dataList
,
$op
=
\Our\ApiConst
::
zero
){
$datas
=
array_values
(
$dataList
);
$this
->
setDb
(
\Our\DbNameConst
::
masterDBConnectName
);
...
...
application/models/DAO/GoodsCommon.php
View file @
5148057d
...
...
@@ -2,6 +2,7 @@
namespace
DAO
;
use
\Our\Common
;
use
Our\CommonExtension
;
...
...
@@ -14,6 +15,7 @@ class GoodsCommonModel extends \DAO\AbstractModel {
* @var string
*/
protected
$_tableName
=
'han_goods_common'
;
protected
$_child_tableName
=
'han_goods'
;
/**
* 主键
...
...
@@ -25,6 +27,22 @@ class GoodsCommonModel extends \DAO\AbstractModel {
public
function
init
(){
}
/**
* 更新商品主表商品库存
* @param $goodsId 商品ID
* @param $num 库存数量
* @param $op 1增加 2设置
* @return mixed
*/
public
function
updateStorage
(
$goodsCommonid
)
{
$this
->
setDb
();
$whereSql
=
'goods_commonid='
.
$goodsCommonid
;
$updateSql
=
'goods_storage = (select sum(t.goods_storage) from '
.
$this
->
_child_tableName
.
' t where t.goods_commonid='
.
$goodsCommonid
.
')'
;
$updateAllSql
=
"UPDATE
{
$this
->
_tableName
}
set
{
$updateSql
}
where
{
$whereSql
}
"
;
return
$this
->
db
->
update
(
$this
->
_tableName
)
->
query
(
$updateAllSql
);
}
public
function
getOneById
(
$goodsCommonId
,
$field
=
\Our\NameConst
::
allField
){
$this
->
setDb
(
$this
->
dbName
);
return
$this
->
db
->
select
(
$field
)
->
from
(
$this
->
_tableName
)
->
where
(
array
(
'goods_commonid'
=>
$goodsCommonId
))
->
fetchOne
();
...
...
application/modules/Client/controllers/Shopkeeper.php
View file @
5148057d
...
...
@@ -220,15 +220,29 @@ class ShopkeeperController extends \Our\Controller_AbstractClient {
$res
=
$res
?
$res
:
new
\stdClass
();
$this
->
success
(
$res
,
\Our\DescribeConst
::
successMessage
);
}
/**
* 单一属性商品库存预警
*/
/**
* 单一属性商品库存预警
* @author king
*/
public
function
warningAction
(){
$goodsCommonService
=
\Business\Goods\GoodsCommonServiceModel
::
getInstance
();
$pageIndex
=
$this
->
getPageIndex
();
$pageSize
=
$this
->
getPageSize
();
$res
=
$goodsCommonService
->
getGoodsStorageList
(
$this
->
store_id
,
$pageIndex
,
$pageSize
);
$res
=
$goodsCommonService
->
getGoodsStorageList
(
$this
->
storeId
,
$pageIndex
,
$pageSize
);
$this
->
success
(
$res
);
}
/**
* 添加库存
* @author king
*/
public
function
addStockAction
(){
$goodsCommonService
=
\Business\Goods\GoodsCommonServiceModel
::
getInstance
();
$goodsId
=
(
int
)
$this
->
req
[
'data'
][
'goodsId'
];
$num
=
(
int
)
$this
->
req
[
'data'
][
'num'
];
$type
=
trim
(
$this
->
req
[
'data'
][
'type'
]);
$res
=
$goodsCommonService
->
setGoodsStorage
(
$this
->
storeId
,
$goodsId
,
$num
,
$type
);
$this
->
success
(
$res
);
}
...
...
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