Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lzzzzl
/
liexin_scm_service
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
64955193
authored
May 18, 2020
by
lzzzzl
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
测试
parent
c2721cf4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
8 deletions
app/Http/Model/GoodsModel.php
app/Http/Model/GoodsModel.php
View file @
64955193
...
...
@@ -57,12 +57,15 @@ class GoodsModel extends Model
* 写入DB物料
*/
public
function
InsertGoodsInfo
(
$arr
)
{
$str
=
DB
::
connection
(
$this
->
connection
)
->
transaction
(
function
()
use
(
$arr
){
$start
=
microtime
(
true
);
$str
=
DB
::
connection
(
$this
->
connection
)
->
transaction
(
function
()
use
(
$arr
,
$start
){
$end1
=
microtime
(
true
);
$brand_name
=
$arr
[
'brand_name'
];
$admin_name
=
$arr
[
'admin_name'
];
$admin_id
=
$arr
[
'admin_id'
];
$erp_id
=
$arr
[
'erp_goods_id'
];
$brand_exist
=
DB
::
connection
(
'mysql'
)
->
table
(
'brand'
)
->
select
(
'brand_id'
)
->
where
(
'brand_name'
,
'='
,
$brand_name
)
->
first
();
$brand_exist
=
$this
->
redis
->
hget
(
'scm_brand_name'
,
md5
(
$brand_name
));
$end2
=
microtime
(
true
);
// 品牌参数
$brand_params
=
array
(
'brand_name'
=>
$brand_name
,
...
...
@@ -75,13 +78,12 @@ class GoodsModel extends Model
if
(
!
$brand_exist
)
{
$brand_id
=
DB
::
connection
(
'mysql'
)
->
table
(
'brand'
)
->
insertGetId
(
$brand_params
);
}
else
{
$brand_id
=
$brand_exist
->
brand_id
;
$brand_id
=
$brand_exist
;
}
$end3
=
microtime
(
true
);
$arr
[
'brand_id'
]
=
$brand_id
;
$start
=
microtime
();
$arr
[
'goods_sn'
]
=
(
new
SnModel
())
->
sn
(
"goods_sn"
);
$end
=
microtime
();
Log
::
error
(
$end
-
$start
);
$end4
=
microtime
(
true
);
// 判断goods_sn,没有正常生成,则退出
if
(
empty
(
$arr
[
'goods_sn'
]))
return
false
;
...
...
@@ -89,7 +91,8 @@ class GoodsModel extends Model
// 写入DB
$goods_id
=
$this
->
insertGetId
(
$arr
);
$end5
=
microtime
(
true
);
// 品牌不存在
if
(
!
$brand_exist
)
{
// 缓存品牌->品牌Id
...
...
@@ -103,7 +106,15 @@ class GoodsModel extends Model
// GOODSID GOODS REDIS
// $this->goodsId2Goods($goods_id,json_encode($arr));
$end6
=
microtime
(
true
);
Log
::
error
(((
$end1
-
$start
)
*
1000
)
.
'ms'
);
Log
::
error
(((
$end2
-
$start
)
*
1000
)
.
'ms'
);
Log
::
error
(((
$end3
-
$start
)
*
1000
)
.
'ms'
);
Log
::
error
(((
$end4
-
$start
)
*
1000
)
.
'ms'
);
Log
::
error
(((
$end5
-
$start
)
*
1000
)
.
'ms'
);
Log
::
error
(((
$end6
-
$start
)
*
1000
)
.
'ms'
);
return
true
;
});
...
...
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