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
b2810e34
Commit
b2810e34
authored
Sep 05, 2018
by
liuyuzhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试数据
parent
b047d4e4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
109 additions
and
1 deletion
+109
-1
GoodsCommonService.php
application/models/Business/Goods/GoodsCommonService.php
+39
-0
StoreOnlineGoodsClass.php
application/models/DAO/GoodsClass/StoreOnlineGoodsClass.php
+54
-0
Abstract.php
application/models/Redis/Db6/Abstract.php
+16
-0
StoreOnlineGoodsClassRedis.php
application/models/Redis/Db6/StoreOnlineGoodsClassRedis.php
+0
-1
No files found.
application/models/Business/Goods/GoodsCommonService.php
View file @
b2810e34
...
...
@@ -1021,6 +1021,45 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
}
/**
* 店铺在售商品分类定时器
*/
public
function
storeOnlineGoodsClass
(){
$storeOnlineGoodsClassDao
=
\DAO\GoodsClass\StoreOnlineGoodsClassModel
::
getInstance
();
$addGoodsClassList
=
$storeOnlineGoodsClassDao
->
getChangedGoodsClass
(
0
,
2000
,
\Our\ApiConst
::
plus
);
if
(
$addGoodsClassList
){
foreach
(
$addGoodsClassList
as
$goodsClassStr
){
$goodsClass
=
unserialize
(
$goodsClassStr
);
$this
->
checkExistOnlineGoodsClass
(
$goodsClass
);
}
}
$minusGoodsClassList
=
$storeOnlineGoodsClassDao
->
getChangedGoodsClass
(
0
,
2000
,
\Our\ApiConst
::
minus
);
if
(
$minusGoodsClassList
){
foreach
(
$minusGoodsClassList
as
$goodsClassStr
){
$goodsClass
=
unserialize
(
$goodsClassStr
);
$this
->
checkRemoveOnlineGoodsClass
(
$goodsClass
);
}
}
}
/**
* 获取新增商品对应的商品分类是否在店铺在售商品分类表,如果在则忽略,不在将分类增加到在售商品分类表
* @param $goodsClass
* @return bool
*/
public
function
checkExistOnlineGoodsClass
(
$goodsClass
){
$storeOnlineGoodsClassDao
=
\DAO\GoodsClass\StoreOnlineGoodsClassModel
::
getInstance
();
$oldTemp
=
$storeOnlineGoodsClassDao
->
find
(
$goodsClass
);
if
(
!
$oldTemp
){
$storeOnlineGoodsClassDao
->
insert
(
$goodsClass
);
}
return
true
;
}
public
function
checkRemoveOnlineGoodsClass
(
$goodsClass
){
}
private
static
$_instance
=
null
;
...
...
application/models/DAO/GoodsClass/StoreOnlineGoodsClass.php
100755 → 100644
View file @
b2810e34
...
...
@@ -25,6 +25,25 @@ class StoreOnlineGoodsClassModel extends \DAO\AbstractModel{
}
public
function
findByWhere
(
$where
){
$this
->
setDb
(
\Our\DbNameConst
::
salveDBConnectName
);
$address
=
$this
->
db
->
from
(
$this
->
_tableName
)
->
where
(
$where
)
->
fetchOne
();
return
$address
;
}
public
function
insert
(
$data
){
$this
->
setDb
(
\Our\DbNameConst
::
masterDBConnectName
);
$data
[
'gmt_create'
]
=
TIMESTAMP
;
$result
=
$this
->
db
->
insert
(
$this
->
_tableName
)
->
rows
(
$data
)
->
execute
();
if
(
$result
){
$storeId
=
$data
[
'store_id'
];
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db6\StoreOnlineGoodsClassRedisModel
::
getInstance
(),
array
(
&
$this
,
'getList'
),
array
(),
array
(
$storeId
));
}
return
$result
;
}
public
function
getList
(
$where
,
$field
=
\Our\NameConst
::
allField
){
$this
->
setDb
(
$this
->
dbName
);
$result
=
$this
->
db
->
select
(
$field
)
->
from
(
$this
->
_tableName
)
->
where
(
$where
)
->
fetchAll
();
...
...
@@ -82,6 +101,41 @@ class StoreOnlineGoodsClassModel extends \DAO\AbstractModel{
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
emtpyGcIdForOnlineChildrenClass
);
}
}
public
function
addChangedGoodsClass
(
$goodsClass
,
$type
=
\Our\ApiConst
::
plus
){
$key
=
'changedAddGoodsClass'
;
if
(
$type
==
\Our\ApiConst
::
minus
){
$key
=
'changedMinusGoodsClass'
;
}
$storeOnlineClassRedisModel
=
\Redis\Db6\StoreOnlineGoodsClassRedisModel
::
getInstance
();
$storeOnlineClassRedisModel
->
tableLPush
(
$key
,
$goodsClass
);
}
public
function
getChangedGoodsClass
(
$type
=
\Our\ApiConst
::
plus
){
$key
=
'changedAddGoodsClass'
;
if
(
$type
==
\Our\ApiConst
::
minus
){
$key
=
'changedMinusGoodsClass'
;
}
$storeOnlineClassRedisModel
=
\Redis\Db6\StoreOnlineGoodsClassRedisModel
::
getInstance
();
return
$storeOnlineClassRedisModel
->
tableLPop
(
$key
);
}
/**
* 获取更改商品
* @param $start 记录开始条数
* @param $end 记录结束条数
* @return \Redis\mix
*/
public
function
getChangedGoodsClasses
(
$start
,
$end
,
$type
=
\Our\ApiConst
::
plus
){
$key
=
'changedAddGoodsClass'
;
if
(
$type
==
\Our\ApiConst
::
minus
){
$key
=
'changedMinusGoodsClass'
;
}
$storeOnlineClassRedisModel
=
\Redis\Db6\StoreOnlineGoodsClassRedisModel
::
getInstance
();
return
$storeOnlineClassRedisModel
->
tableLRange
(
$key
,
$start
,
$end
);
}
/**
* 类实例
*/
...
...
application/models/Redis/Db6/Abstract.php
100755 → 100644
View file @
b2810e34
...
...
@@ -70,4 +70,20 @@ class AbstractModel extends \Redis\AbstractModel {
public
function
tableDecr
(
$h
)
{
return
$this
->
decr
(
$this
->
calcKey
(
$h
));
}
public
function
tableLPush
(
$id
,
$data
){
$res
=
$this
->
lpush
(
$this
->
calcKey
(
$id
),
$data
);
return
$res
;
}
public
function
tableLPop
(
$id
){
$res
=
$this
->
lpop
(
$this
->
calcKey
(
$id
));
return
$res
;
}
public
function
tableLRange
(
$key
,
$start
,
$end
){
$res
=
$this
->
lrange
(
$this
->
calcKey
(
$key
),
$start
,
$end
);
return
$res
;
}
}
application/models/Redis/Db6/StoreOnlineGoodsClassRedis.php
100755 → 100644
View file @
b2810e34
...
...
@@ -25,7 +25,6 @@ class StoreOnlineGoodsClassRedisModel extends \Redis\Db6\AbstractModel {
return
$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