Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
meibuyu-rpc
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
without authentication
meibuyu-rpc
Commits
2de11d90
Commit
2de11d90
authored
Jun 19, 2020
by
DESKTOP-PVAUUNL\Administrator
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git.huaperfect.com:hwq/micro
parents
0fb08b12
ae8b3c68
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
5 deletions
+76
-5
MaterialServiceInterface.php
src/Service/Interfaces/MaterialServiceInterface.php
+46
-0
MaterialServiceInterface.php
src/Service/Interfaces/Product/MaterialServiceInterface.php
+8
-0
functions.php
src/functions.php
+22
-5
No files found.
src/Service/Interfaces/MaterialServiceInterface.php
0 → 100644
View file @
2de11d90
<?php
/**
* Created by PhpStorm.
* User: 梁俊杰
* Date: 2020/5/15
* Time: 15:07
*/
namespace
Meibuyu\Micro\Service\Interfaces
;
interface
MaterialServiceInterface
{
/**
* 获取单个数据
* @param int $id 原料id
* @param array $columns 原料表的字段,默认显示全部
* @return array|null
*/
public
function
get
(
$id
,
array
$columns
=
[
'*'
]);
/**
* 通过id列表获取原料数组
* @param array $idList 原料id的列表, 默认去重
* @param array $columns 原料表的字段,默认显示全部
* @return array 默认keyBy('id')
*/
public
function
getByIdList
(
array
$idList
,
array
$columns
=
[
'*'
])
:
array
;
/**
* 通过内部code列表获取原料列表
* @param array $codeList 默认去重
* @param array $columns
* @return array 默认keyBy('internal_code')
*/
public
function
getByCodeList
(
array
$codeList
,
array
$columns
=
[
'id'
]);
/**
* 通过原料品名id列表获取原料品名数组
* @param array $idList 原料品名id的列表, 默认去重
* @param array $columns 原料品名表的字段,默认显示全部
* @return array 默认keyBy('id')
*/
public
function
getMaterialNamesByIdList
(
array
$idList
,
array
$columns
=
[
'*'
])
:
array
;
}
src/Service/Interfaces/Product/MaterialServiceInterface.php
View file @
2de11d90
...
...
@@ -35,4 +35,12 @@ interface MaterialServiceInterface
*/
public
function
getByCodeList
(
array
$codeList
,
array
$columns
=
[
'id'
]);
/**
* 通过原料品名id列表获取原料品名数组
* @param array $idList 原料品名id的列表, 默认去重
* @param array $columns 原料品名表的字段,默认显示全部
* @return array 默认keyBy('id')
*/
public
function
getMaterialNamesByIdList
(
array
$idList
,
array
$columns
=
[
'*'
])
:
array
;
}
src/functions.php
View file @
2de11d90
...
...
@@ -477,7 +477,7 @@ if (!function_exists('empty_string_2_null')) {
if
(
!
function_exists
(
'get_collection_values'
))
{
/**
* 从集合中提取深层数据
* @param $collection 数据集合
* @param
mixed
$collection 数据集合
* @param string $key 集合中键 支持多层提取,例如"a.b.c"
* @return array | collection
*/
...
...
@@ -495,6 +495,13 @@ if (!function_exists('get_collection_values')) {
$values
[]
=
$value
;
}
}
else
{
if
(
is_array
(
$value
)
||
is_countable
(
$collection
[
$t
]))
{
foreach
(
$value
as
$vv
)
{
if
(
isset
(
$vv
[
$ik
]))
{
$values
[]
=
$vv
[
$ik
];
}
}
}
break
;
}
}
...
...
@@ -524,8 +531,12 @@ if (!function_exists('put_collection_values')) {
}
$valueList
=
$valueList
->
keyBy
(
$valueKey
);
}
foreach
(
$collection
as
$index
=>
$value
)
{
$collection
[
$index
]
=
private_put_collection_values
(
$value
,
$itemKeys
,
$valueList
,
$collectionNewKey
);
if
(
isset
(
$collection
[
0
]))
{
foreach
(
$collection
as
$index
=>
$value
)
{
$collection
[
$index
]
=
private_put_collection_values
(
$value
,
$itemKeys
,
$valueList
,
$collectionNewKey
);
}
}
else
{
private_put_collection_values
(
$collection
,
$itemKeys
,
$valueList
,
$collectionNewKey
);
}
}
return
$collection
;
...
...
@@ -548,7 +559,13 @@ if (!function_exists('private_put_collection_values')) {
$t
=
$itemKeys
[
0
];
unset
(
$itemKeys
[
0
]);
$itemKeys
=
array_values
(
$itemKeys
);
$collection
[
$t
]
=
private_put_collection_values
(
$collection
[
$t
],
$itemKeys
,
$valueList
,
$collectionNewKey
);
if
(
is_array
(
$collection
[
$t
])
||
is_countable
(
$collection
[
$t
]))
{
foreach
(
$collection
[
$t
]
as
$k
=>
$v
)
{
$collection
[
$t
][
$k
]
=
private_put_collection_values
(
$v
,
$itemKeys
,
$valueList
,
$collectionNewKey
);
}
}
else
{
$collection
[
$t
]
=
private_put_collection_values
(
$collection
[
$t
],
$itemKeys
,
$valueList
,
$collectionNewKey
);
}
}
else
{
if
(
isset
(
$valueList
[
$collection
[
$itemKeys
[
0
]]]))
{
$collection
[
$collectionNewKey
]
=
$valueList
[
$collection
[
$itemKeys
[
0
]]];
...
...
@@ -568,7 +585,7 @@ if (!function_exists('human_time')) {
*/
function
human_time
(
$time
)
{
if
(
is_numeric
(
$time
))
{
if
(
!
is_numeric
(
$time
))
{
$time
=
strtotime
(
$time
);
}
$time
=
abs
(
$time
);
...
...
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