Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_supplier
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
12a34922
authored
Nov 11, 2021
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
搜索供应商的需求
parent
b216f1a4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
11 deletions
app/Http/Controllers/Api/SupplierApiController.php
app/Http/Controllers/Filter/SupplierFilter.php
app/Http/Services/SupplierService.php
app/Http/Transformers/SupplierTransformer.php
app/Model/SupplierChannelModel.php
app/Http/Controllers/Api/SupplierApiController.php
View file @
12a34922
...
...
@@ -147,7 +147,7 @@ class SupplierApiController extends Controller
$model
=
new
SupplierChannelModel
();
$query
=
$model
->
orderBy
(
'update_time'
,
'desc'
);
$filter
=
new
SupplierFilter
();
$query
=
$filter
->
listFilter
(
$request
,
$query
);
$query
=
$filter
->
listFilter
(
$request
->
all
()
,
$query
);
$limit
=
$request
->
get
(
'limit'
,
10
);
$list
=
$query
->
paginate
(
$limit
)
->
toArray
();
$transformer
=
new
SupplierTransformer
();
...
...
@@ -497,4 +497,15 @@ class SupplierApiController extends Controller
$supplierService
->
batchApplyInReviewSupplier
(
$supplierIds
);
$this
->
response
(
0
,
'申请审核成功'
);
}
//搜索供应商
public
function
searchSupplier
(
$request
)
{
$map
=
$request
->
only
([
'supplier_name'
]);
if
(
empty
(
$map
[
'supplier_name'
]))
{
$this
->
response
(
-
1
,
'搜索的供应商名称不能为空'
);
}
$suppliers
=
SupplierService
::
searchSupplier
(
$map
);
$this
->
response
(
0
,
'ok'
,
$suppliers
[
'data'
],
$suppliers
[
'total'
]);
}
}
app/Http/Controllers/Filter/SupplierFilter.php
View file @
12a34922
...
...
@@ -12,14 +12,15 @@ use Illuminate\Support\Facades\DB;
class
SupplierFilter
{
//查询条件
public
function
listFilter
(
$
request
,
$query
)
public
function
listFilter
(
$
map
,
$query
)
{
$map
=
$request
->
all
();
$map
=
array_map
(
function
(
$item
)
{
return
trim
(
$item
);
},
$map
);
//显示默认的数据(有权限逻辑)
$query
=
$this
->
defaultFilter
(
$query
,
$map
[
'source_type'
]);
if
(
!
empty
(
$map
[
'source_type'
]))
{
//显示默认的数据(有权限逻辑)
$query
=
$this
->
defaultFilter
(
$query
,
$map
[
'source_type'
]);
}
//判断筛选参数
if
(
!
empty
(
$map
[
'supplier_id'
]))
{
$query
->
where
(
'supplier_channel.supplier_id'
,
$map
[
'supplier_id'
]);
...
...
app/Http/Services/SupplierService.php
View file @
12a34922
...
...
@@ -3,6 +3,7 @@
namespace
App\Http\Services
;
use
App\Http\Controllers\Filter\SupplierFilter
;
use
App\Http\Transformers\SupplierTransformer
;
use
App\Model\LogModel
;
use
App\Model\RedisModel
;
...
...
@@ -83,7 +84,7 @@ class SupplierService
$channel
[
'us_delivery_time_period'
],
$channel
[
'attachment'
]);
//获取付款类型有关的数据
$payTypeData
=
array_only
(
$channel
,
[
'pay_type'
,
'pay_type_value'
,
'pay_type_extra'
]);
$payTypeData
=
array_only
(
$channel
,
[
'pay_type'
,
'pay_type_value'
,
'pay_type_extra'
]);
unset
(
$channel
[
'pay_type'
],
$channel
[
'pay_type_value'
],
$channel
[
'pay_type_extra'
]);
$skuAuditRulerService
=
new
SupplierSkuAuditRulerService
();
...
...
@@ -142,7 +143,7 @@ class SupplierService
$supplierId
=
$this
->
newSupplierId
=
$channel
[
'supplier_id'
];
//要做进一步判断,部分字段修改不需要审核
$auditService
=
new
SupplierAuditService
();
$needAudit
=
$auditService
->
checkNeedAudit
(
$supplierId
,
$channel
,
$attachment
,
$payTypeData
);
$needAudit
=
$auditService
->
checkNeedAudit
(
$supplierId
,
$channel
,
$attachment
,
$payTypeData
);
if
(
$needAudit
)
{
$channel
[
'status'
]
=
SupplierChannelModel
::
STATUS_PENDING
;
}
...
...
@@ -446,9 +447,26 @@ class SupplierService
'status'
=>
SupplierChannelModel
::
STATUS_PENDING
,
'is_type'
=>
0
]);
// $searchTagService = new SupplierSearchTagService();
// $searchTagService->saveSupplierSearchTags($supplier['supplier_id']);
}
}
//搜索供应商
public
static
function
searchSupplier
(
$params
)
{
$filter
=
new
SupplierFilter
();
$limit
=
array_get
(
$params
,
'limit'
,
10
);
$query
=
SupplierChannelModel
::
with
(
'pay_type'
)
->
select
([
'supplier_id'
,
'supplier_code'
,
'supplier_name'
,
'pay_type'
]);
$query
=
$filter
->
listFilter
(
$params
,
$query
);
$suppliers
=
$query
->
paginate
(
$limit
);
$suppliers
=
$suppliers
->
toArray
();
$suppliers
[
'data'
]
=
SupplierTransformer
::
transformSearch
(
$suppliers
[
'data'
]);
return
$suppliers
;
}
}
\ No newline at end of file
app/Http/Transformers/SupplierTransformer.php
View file @
12a34922
...
...
@@ -129,8 +129,8 @@ class SupplierTransformer
$log
[
'add_time'
])
:
'无'
;
$supplier
[
'has_certification_name'
]
=
array_get
(
config
(
'fixed.CertificationStatus'
),
array_get
(
$supplier
,
'has_certification'
,
''
),
''
);
$supplier
[
'sku_tag_name'
]
=
array_get
(
config
(
'field.SkuTag'
),
array_get
(
$supplier
,
'sku_tag'
,
''
),
'无'
);
$supplier
[
'sku_mode_name'
]
=
array_get
(
config
(
'field.SkuMode'
),
array_get
(
$supplier
,
'sku_mode'
,
''
),
'无'
);
$supplier
[
'sku_tag_name'
]
=
array_get
(
config
(
'field.SkuTag'
),
array_get
(
$supplier
,
'sku_tag'
,
''
),
'无'
);
$supplier
[
'sku_mode_name'
]
=
array_get
(
config
(
'field.SkuMode'
),
array_get
(
$supplier
,
'sku_mode'
,
''
),
'无'
);
return
$supplier
;
}
...
...
@@ -251,4 +251,18 @@ class SupplierTransformer
return
$channel
;
}
public
static
function
transformSearch
(
$suppliers
)
{
if
(
!
empty
(
$suppliers
))
{
foreach
(
$suppliers
as
&
$supplier
)
{
foreach
(
$supplier
[
'pay_type'
]
as
&
$payType
)
{
$payType
[
'pay_type_name'
]
=
array_get
(
config
(
'fixed.SupplierPayType'
),
$payType
[
'pay_type'
]);
}
unset
(
$payType
);
}
unset
(
$supplier
);
}
return
$suppliers
;
}
}
\ No newline at end of file
app/Model/SupplierChannelModel.php
View file @
12a34922
...
...
@@ -42,4 +42,10 @@ class SupplierChannelModel extends Model
{
return
$this
->
hasOne
(
SupplierAttachmentModel
::
class
,
'supplier_id'
,
'supplier_id'
);
}
//交易方式
public
function
pay_type
()
{
return
$this
->
hasMany
(
SupplierPayTypeModel
::
class
,
'supplier_id'
,
'supplier_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