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
16f63aa2
Commit
16f63aa2
authored
Jun 05, 2020
by
梁俊杰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
产品接口更新,新方法提取
parent
2e19bdf8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
178 additions
and
0 deletions
+178
-0
PlatformProductServiceInterface.php
...ce/Interfaces/Product/PlatformProductServiceInterface.php
+46
-0
ProductServiceInterface.php
src/Service/Interfaces/Product/ProductServiceInterface.php
+97
-0
functions.php
src/functions.php
+35
-0
No files found.
src/Service/Interfaces/Product/PlatformProductServiceInterface.php
0 → 100644
View file @
16f63aa2
<?php
/**
* Created by PhpStorm.
* User: 王源
* Date: 2020/1/9
* Time: 15:07
*/
namespace
Meibuyu\Micro\Service\Interfaces\Product
;
interface
PlatformProductServiceInterface
{
/**
* 获取单个数据
* @param int $id 平台产品id
* @param array $relations 平台产品的关联关系,支持:["status","product","amazon_warehouse","platform_product_children"]
* @param array $columns 平台产品表的字段,默认['id', 'sku', 'product_id', 'name', 'team_id', 'site_id', 'price'
* , 'currency_id', 'platform_product_status_id', 'creator_id', 'asin', 'amazon_warehouse_id', 'info_completed']
* @return array
*/
public
function
get
(
$id
,
array
$relations
=
[]
,
$columns
=
[
'id'
,
'sku'
,
'product_id'
,
'name'
,
'team_id'
,
'site_id'
,
'price'
,
'currency_id'
,
'platform_product_status_id'
,
'creator_id'
,
'asin'
,
'amazon_warehouse_id'
,
'info_completed'
])
:
array
;
/**
* 通过id列表获取平台产品数组
* @param array $idList 平台产品id的列表
* @param array $relations 平台产品的关联关系,支持["status","product","amazon_warehouse","platform_product_children"]
* @param array $columns 平台产品表的字段,默认['id', 'sku', 'product_id', 'name', 'team_id', 'site_id', 'price'
* , 'currency_id', 'platform_product_status_id', 'creator_id', 'asin', 'amazon_warehouse_id', 'info_completed']
* @return array
*/
public
function
getByIdList
(
array
$idList
,
array
$relations
=
[]
,
$columns
=
[
'id'
,
'sku'
,
'product_id'
,
'name'
,
'team_id'
,
'site_id'
,
'price'
,
'currency_id'
,
'platform_product_status_id'
,
'creator_id'
,
'asin'
,
'amazon_warehouse_id'
,
'info_completed'
])
:
array
;
/**
* 获取全部平台产品状态列表
* @param array $columns 默认['id', 'name']
* @return array
*/
public
function
platformProductStatus
(
array
$columns
=
[
'id'
,
'name'
])
:
array
;
}
src/Service/Interfaces/ProductServiceInterface.php
→
src/Service/Interfaces/Product
/Product
ServiceInterface.php
View file @
16f63aa2
...
...
@@ -6,7 +6,7 @@
* Time: 15:07
*/
namespace
Meibuyu\Micro\Service\Interfaces
;
namespace
Meibuyu\Micro\Service\Interfaces
\Product
;
interface
ProductServiceInterface
{
...
...
@@ -15,108 +15,83 @@ interface ProductServiceInterface
* 获取单个数据
* @param int $id 产品id
* @param array $relations 产品的关联关系,支持:["brand","category","ingredient","product_name","status","type","images","price_info","product_children"]
* @param array $columns 产品表的字段,默认['id', 'sku', 'name', 'en_name', 'brand_id'
* , 'team_id', 'hs_code', 'origin_country_id', 'production_address', 'unit', 'category_id'
* , 'ingredient_id', 'product_name_id', 'type_id', 'status_id', 'style', 'info_completed'
* , 'bar_code', 'bar_code_image', 'creator_id', 'hot']
* @return array
*/
public
function
get
(
$id
,
array
$relations
=
[])
:
array
;
public
function
get
(
$id
,
array
$relations
=
[]
,
$columns
=
[
'id'
,
'sku'
,
'name'
,
'en_name'
,
'brand_id'
,
'team_id'
,
'hs_code'
,
'origin_country_id'
,
'production_address'
,
'unit'
,
'category_id'
,
'ingredient_id'
,
'product_name_id'
,
'type_id'
,
'status_id'
,
'style'
,
'info_completed'
,
'bar_code'
,
'bar_code_image'
,
'creator_id'
,
'hot'
])
:
array
;
/**
* 通过id列表获取产品数组
* @param array $idList 产品id的列表
* @param array $relations 产品的关联关系,支持["brand","category","ingredient","product_name","status","type","images","price_info","product_children"]
* @param array $columns 产品表的字段,默认显示全部
* @param array $columns 产品表的字段,默认['id', 'sku', 'name', 'en_name', 'brand_id'
* , 'team_id', 'hs_code', 'origin_country_id', 'production_address', 'unit', 'category_id'
* , 'ingredient_id', 'product_name_id', 'type_id', 'status_id', 'style', 'info_completed'
* , 'bar_code', 'bar_code_image', 'creator_id', 'hot']
* @return array
*/
public
function
getByIdList
(
array
$idList
,
array
$relations
=
[],
array
$columns
=
[
'*'
])
:
array
;
public
function
getByIdList
(
array
$idList
,
array
$relations
=
[]
,
array
$columns
=
[
'id'
,
'sku'
,
'name'
,
'en_name'
,
'brand_id'
,
'team_id'
,
'hs_code'
,
'origin_country_id'
,
'production_address'
,
'unit'
,
'category_id'
,
'ingredient_id'
,
'product_name_id'
,
'type_id'
,
'status_id'
,
'style'
,
'info_completed'
,
'bar_code'
,
'bar_code_image'
,
'creator_id'
,
'hot'
])
:
array
;
/**
* 通过产品列表
* @param int $page 第几页数据,默认:1
* @param array $relations 产品的关联关系,支持["brand","category","ingredient","product_name","status","type","images","price_info","product_children"]
* @param int $pageSize 每页产品数默认:15,最大支持100
* @param array $columns 产品表的字段,默认显示全部
* @return array
*/
public
function
list
(
$page
=
1
,
array
$relations
=
[],
$pageSize
=
15
,
array
$columns
=
[
'*'
])
:
array
;
/**
* 获取某个产品的子产品,包含颜色和尺码
* @param int $productId 产品编号
* @return array
*/
public
function
getProductChildren
(
$productId
)
:
array
;
/** 获取某个产品的平台产品,包含颜色和尺码
* @param int $productId 产品编号
* @param int $site_id 站点id,可选,默认为空
* @return array
*/
public
function
getPlatformProduct
(
$productId
,
$site_id
=
null
)
:
array
;
/**
* 获取平台产品的子产品
* @param int $platformProductId 平台产品id
* @return array
*/
public
function
getPlatformProductChildren
(
$platformProductId
)
:
array
;
/**
* 获取某个站点的所有平台产品
* @param int $site_id 站点id
* @param int $page 第几页数据,默认:1
* @param array $relations 平台产品的关联关系,支持["product","amazon_warehouse","platform_product_images","platform_product_children"]
* @param int $pageSize 每页列表数默认:15,最大支持100
* @param array $columns 平台产品表的字段,默认显示全部
* @return array
*/
public
function
getPlatformProductListBySite
(
$site_id
,
$page
=
1
,
array
$relations
=
[],
$pageSize
=
15
,
array
$columns
=
[
'*'
])
:
array
;
/**
* 获取全部尺码列表
* @param array $columns 默认['id', 'name']
* @return array
*/
public
function
sizes
()
:
array
;
public
function
sizes
(
array
$columns
=
[
'id'
,
'name'
]
)
:
array
;
/**
* 获取全部颜色列表
* @param array $columns 默认['id', 'code', 'cn_name', 'en_name']
* @return array
*/
public
function
colors
()
:
array
;
public
function
colors
(
array
$columns
=
[
'id'
,
'code'
,
'cn_name'
,
'en_name'
]
)
:
array
;
/**
* 获取全部品类列表
* @param bool $asTree 是否作为树返回
* @param array $columns 默认['id', 'name', 'parent_id']
* @return array
*/
public
function
categories
()
:
array
;
public
function
categories
(
$asTree
=
false
,
array
$columns
=
[
'id'
,
'name'
,
'parent_id'
]
)
:
array
;
/**
* 获取全部品牌列表
* @param array $columns 默认['id', 'name']
* @return array
*/
public
function
brands
()
:
array
;
public
function
brands
(
array
$columns
=
[
'id'
,
'name'
]
)
:
array
;
/**
* 获取全部报关品名列表
* @param array $columns 默认['id', 'name','en_name']
* @return array
*/
public
function
productNames
()
:
array
;
public
function
productNames
(
array
$columns
=
[
'id'
,
'name'
,
'en_name'
]
)
:
array
;
/**
* 获取全部成分列表
* @param array $columns 默认['id', 'name']
* @return array
*/
public
function
ingredients
()
:
array
;
public
function
ingredients
(
array
$columns
=
[
'id'
,
'name'
,
'en_name'
]
)
:
array
;
/**
* 获取全部产品状态列表
* @param array $columns 默认['id', 'name']
* @return array
*/
public
function
productStatus
()
:
array
;
public
function
productStatus
(
array
$columns
=
[
'id'
,
'name'
]
)
:
array
;
/**
* 获取全部平台产品状态列表
* @return array
*/
public
function
platformProductStatus
()
:
array
;
}
src/functions.php
View file @
16f63aa2
...
...
@@ -606,6 +606,41 @@ if (!function_exists('info')) {
}
}
if
(
!
function_exists
(
'make_belong_relation_function'
))
{
/**
* 创建我属于关联关系的函数
* @param string $relationName 关联关系的名字
* @param array $mainModelColumns 使用关联关系的主表要筛选的列
* @param array $relationColumns 关联关系的列 默认['id', 'name']
* @param string $mainModelRelationKey 主表和关联关系对应的字段 空的话为$relationName+"_id"
* @param callable|null $callback 内嵌级联调用
* @return Closure 返回关联关系的匿名函数
*/
function
make_belong_lation_function
(
$relationName
,
array
&
$mainModelColumns
,
$relationColumns
=
[
'id'
,
'name'
],
$mainModelRelationKey
=
""
,
callable
$callback
=
null
)
{
$key
=
$mainModelRelationKey
?
$mainModelRelationKey
:
$relationName
.
"_id"
;
if
(
!
in_array
(
$key
,
$mainModelColumns
))
array_push
(
$mainModelColumns
,
$key
);
return
make_has_relation_function
(
$relationColumns
,
$callback
);
}
}
if
(
!
function_exists
(
'make_has_relation_function'
))
{
/**
* 创建我有关联关系的函数
* @param array $relationColumns 关联关系的列 默认['id', 'name']
* @return Closure 返回关联关系的匿名函数
* @param callable|null $callback 内嵌级联调用
* @return Closure
*/
function
make_has_relation_function
(
$relationColumns
=
[
'id'
,
'name'
],
callable
$callback
=
null
)
{
return
function
(
$q
)
use
(
$relationColumns
,
$callback
)
{
$q
->
select
(
$relationColumns
);
if
(
is_callable
(
$callback
))
{
$callback
(
$q
);
}
};
}
}
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