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
06293089
Commit
06293089
authored
Feb 12, 2019
by
zhz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加商品快照
parent
f263cd0b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
1 deletion
+85
-1
Goods.php
application/models/DAO/Goods.php
+5
-1
GoodsSnapshot.php
application/models/DAO/Goods/GoodsSnapshot.php
+65
-0
updateGoodsSnapshot.php
scripts/crontab/goods/updateGoodsSnapshot.php
+15
-0
No files found.
application/models/DAO/Goods.php
100755 → 100644
View file @
06293089
...
...
@@ -483,7 +483,11 @@ class GoodsModel extends \DAO\AbstractModel {
return
true
;
}
public
function
update
(
$data
,
$where
){
$this
->
setDb
(
\Our\DbNameConst
::
masterDBConnectName
);
$result
=
$this
->
db
->
update
(
$this
->
_tableName
)
->
rows
(
$data
)
->
where
(
$where
)
->
execute
();
return
$result
;
}
/**
* 获取格式化的规格值
...
...
application/models/DAO/Goods/GoodsSnapshot.php
0 → 100644
View file @
06293089
<?php
namespace
DAO\Goods
;
class
GoodsSnapshotModel
extends
\DAO\AbstractModel
{
/**
* 表名
*
* @var string
*/
protected
$_tableName
=
'han_goods_snapshot'
;
/**
* 主键
*
* @var string
*/
protected
$_primaryKey
=
'id'
;
public
function
init
()
{
}
public
function
insert
(
$data
)
{
$this
->
setDb
(
\Our\DbNameConst
::
masterDBConnectName
);
return
$this
->
db
->
insert
(
$this
->
_tableName
)
->
rows
(
$data
)
->
execute
();
}
public
function
save
(
$data
,
$where
){
$this
->
setDb
(
\Our\DbNameConst
::
masterDBConnectName
);
$result
=
$this
->
db
->
update
(
$this
->
_tableName
)
->
rows
(
$data
)
->
where
(
$where
)
->
execute
();
return
$result
;
}
/**
* 类实例
*
* @var \DAO\UserModel
*/
private
static
$_instance
=
null
;
/**
* 获取类实例
*
* @return \DAO\UserModel
*/
public
static
function
getInstance
()
{
if
(
!
(
self
::
$_instance
instanceof
self
))
{
self
::
$_instance
=
new
self
();
}
return
self
::
$_instance
;
}
}
scripts/crontab/goods/updateGoodsSnapshot.php
0 → 100644
View file @
06293089
<?php
/**
* 添加商品快照
* 执行一次
*/
define
(
"APPLICATION_PATH"
,
realpath
(
dirname
(
__FILE__
)
.
'/../../../'
));
//指向public的上一级
require
APPLICATION_PATH
.
'/scripts/crontab/common.php'
;
$goodsList
=
\DAO\GoodsModel
::
getInstance
()
->
getList
(
array
(
'snapshot_id'
=>
0
),
'*'
);
foreach
(
$goodsList
as
$goods
)
{
$snaId
=
\DAO\Goods\GoodsSnapshotModel
::
getInstance
()
->
insert
(
array
(
'content'
=>
serialize
(
$goods
),
'type'
=>
1
));
\DAO\GoodsModel
::
getInstance
()
->
update
(
array
(
'snapshot_id'
=>
$snaId
),
array
(
'goods_id'
=>
$goods
[
'goods_id'
]));
}
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