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
98f56bd5
authored
Jun 23, 2022
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
暂存
parent
b0aa33f2
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
138 additions
and
82 deletions
app/Http/Controllers/Api/CommonApiController.php
app/Http/Controllers/Api/SupplierApiController.php
app/Http/Controllers/Filter/SupplierFilter.php
app/Http/Services/CompanyService.php
app/Http/Transformers/SupplierTransformer.php
config/field.php
config/website.php
resources/views/script/SupplierDetailScript.blade.php
resources/views/script/SupplierListScript.blade.php
resources/views/script/UpdateSupplierScript.blade.php
resources/views/script/supplier/SupplierBaseScript.blade.php
resources/views/web/supplier/SupplierListCommon.blade.php
app/Http/Controllers/Api/CommonApiController.php
View file @
98f56bd5
...
...
@@ -4,8 +4,8 @@ namespace App\Http\Controllers\Api;
use
App\Http\Controllers\Controller
;
use
App\Http\Services\AdminUserService
;
use
App\Http\Services\CompanyService
;
use
App\Model\BrandModel
;
use
App\Model\SelfClassifyModel
;
use
App\Model\StandardBrandModel
;
use
Illuminate\Http\Request
;
use
GuzzleHttp\Client
;
...
...
@@ -19,13 +19,6 @@ class CommonApiController extends Controller
$this
->
$id
(
$request
,
$id
);
}
//获取分类列表(自营专属)
public
function
getSelfClassList
(
$request
)
{
$model
=
new
SelfClassifyModel
();
$result
=
$model
->
getClassList
();
return
$this
->
response
(
0
,
'ok'
,
$result
);
}
//获取所有品牌
public
function
getBrandList
(
$request
)
...
...
@@ -35,7 +28,7 @@ class CommonApiController extends Controller
$type
=
$type
?:
1
;
$model
=
new
BrandModel
();
$brandList
=
$model
->
getBrandListByType
(
$type
);
return
$this
->
response
(
0
,
'ok'
,
$brandList
);
$this
->
response
(
0
,
'ok'
,
$brandList
);
}
//获取标准品牌
...
...
@@ -43,32 +36,7 @@ class CommonApiController extends Controller
{
$model
=
new
BrandModel
();
$brandList
=
$model
->
getStandardBrandList
();
return
$this
->
response
(
0
,
'ok'
,
$brandList
);
}
//搜索标准品牌
public
function
SearchStandardBrand
(
$request
)
{
$brandName
=
$request
->
input
(
'brand_name'
);
$standardBrandModel
=
new
StandardBrandModel
();
$query
=
$standardBrandModel
->
where
(
'status'
,
1
);
if
(
$brandName
)
{
$query
=
$query
->
where
(
'brand_name'
,
'like'
,
$brandName
.
'%'
);
}
$count
=
$query
->
count
();
$list
=
$query
->
select
(
'brand_name'
,
'brand_id'
)
->
paginate
(
17
);
$list
=
$list
?
$list
->
toArray
()
:
[];
$data
=
array_get
(
$list
,
'data'
);
$lastPage
=
array_get
(
$list
,
'last_page'
);
echo
json_encode
([
'errcode'
=>
0
,
'errmsg'
=>
'ok'
,
'total'
=>
$count
,
'count'
=>
$count
,
'data'
=>
$data
,
'last_page'
=>
$lastPage
]);
$this
->
response
(
0
,
'ok'
,
$brandList
);
}
private
function
SearchBrand
(
$request
)
...
...
@@ -99,10 +67,17 @@ class CommonApiController extends Controller
]);
}
public
function
test
(
$request
)
public
function
checkCompanyInfo
(
$request
)
{
$as
=
new
AdminUserService
();
$as
->
getPurchaseUsers
();
//请求天眼查校验接口
$supplierName
=
$request
->
get
(
'supplier_name'
);
$taxNumber
=
$request
->
get
(
'tax_number'
);
$company
=
(
new
CompanyService
())
->
getCompanyInfo
(
$supplierName
,
$taxNumber
);
if
(
!
$company
)
{
$this
->
response
(
-
1
,
'获取不到公司'
);
}
$this
->
response
(
0
,
'ok'
,
$company
);
}
}
app/Http/Controllers/Api/SupplierApiController.php
View file @
98f56bd5
...
...
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api;
use
App\Http\Controllers\Controller
;
use
App\Http\Controllers\Filter\SupplierFilter
;
use
App\Http\Services\AdminUserService
;
use
App\Http\Services\CompanyService
;
use
App\Http\Services\LogService
;
use
App\Http\Services\SupplierAuditService
;
use
App\Http\Services\SupplierService
;
...
...
@@ -278,52 +279,49 @@ class SupplierApiController extends Controller
$this
->
response
(
0
,
'修改状态成功'
);
}
//导出供应商信息申请表到word
public
function
ExportSupplierToWord
(
$request
)
{
$supplierId
=
$request
->
get
(
'supplier_id'
);
$exporter
=
new
SupplierWordExporter
();
$exporter
->
export
(
$supplierId
);
}
//检查供应商名称是否相似或者重复
public
function
CheckSupplierName
(
$request
)
{
$supplierName
=
$request
->
get
(
'supplier_name'
);
$supplierName
=
trim
(
$request
->
get
(
'supplier_name'
));
$taxNumber
=
$request
->
get
(
'tax_number'
);
$supplierId
=
$request
->
get
(
'supplier_id'
);
$model
=
new
SupplierChannelModel
();
//如果是编辑操作,则要忽略非当前
if
(
$supplierId
)
{
$originSupplierName
=
$model
->
where
(
'supplier_id'
,
$supplierId
)
->
value
(
'supplier_name'
);
$existedSupplierName
=
$model
->
where
(
'supplier_name'
,
$supplierName
)
->
where
(
'supplier_name'
,
'!='
,
$originSupplierName
)
$existedSupplierName
=
$model
->
where
(
'supplier_name'
,
$supplierName
)
->
where
(
'supplier_name'
,
'!='
,
$originSupplierName
)
->
value
(
'supplier_name'
);
if
(
$supplierName
!==
$existedSupplierName
)
{
$supplierName
=
$model
->
where
(
'supplier_name'
,
'like'
,
"%
$supplierName
%"
)
->
limit
(
1
)
->
value
(
'supplier_name'
);
if
(
!
empty
(
$supplierName
))
{
$this
->
response
(
-
2
,
'存在类似的供应商名称'
,
$supplierName
);
}
}
else
{
$this
->
response
(
-
1
,
'该供应商名称已经存在
'
);
//
$supplierName = $model->where('supplier_name', 'like',
//
"%$supplierName%")->limit(1)->value('supplier_name');
//
if (!empty($supplierName)) {
//
$this->response(-2, '存在类似的供应商名称', $supplierName);
//
}
}
else
{
$this
->
response
(
-
1
,
'供应商已存在,请重新输入或者咨询审批人
'
);
}
}
else
{
$existedSupplierName
=
$model
->
where
(
'supplier_name'
,
$supplierName
)
->
value
(
'supplier_name'
);
if
(
$existedSupplierName
)
{
$this
->
response
(
-
1
,
'
已经有重复的供应商名称
'
);
$this
->
response
(
-
1
,
'
供应商已存在,请重新输入或者咨询审批人
'
);
}
else
{
$supplierName
=
$model
->
where
(
'supplier_name'
,
'like'
,
"%
$supplierName
%"
)
->
limit
(
1
)
->
value
(
'supplier_name'
);
if
(
!
empty
(
$supplierName
))
{
$this
->
response
(
-
2
,
'存在类似的供应商名称'
,
$supplierName
);
}
//
$supplierName = $model->where('supplier_name', 'like',
//
"%$supplierName%")->limit(1)->value('supplier_name');
//
if (!empty($supplierName)) {
//
$this->response(-2, '存在类似的供应商名称', $supplierName);
//
}
}
}
//去请求天眼查获取资料
$this
->
response
(
0
,
'供应商名称合理'
);
//还要去请求天眼查获取资料
$company
=
(
new
CompanyService
())
->
getCompanyInfo
(
$supplierName
,
$taxNumber
);
if
(
!
$company
)
{
$this
->
response
(
-
1
,
'公司未进行工商注册,请修改后重新提交'
);
}
$this
->
response
(
0
,
'供应商名称合理'
,
$company
);
}
//审核供应商
...
...
app/Http/Controllers/Filter/SupplierFilter.php
View file @
98f56bd5
...
...
@@ -35,9 +35,15 @@ class SupplierFilter
$codes
=
explode
(
','
,
$map
[
'supplier_code'
]);
$query
->
whereIn
(
'supplier_code'
,
$codes
);
}
if
(
!
empty
(
$map
[
'group_code'
]))
{
$query
->
where
(
'group_code'
,
'like'
,
"%
{
$map
[
'group_code'
]
}
%"
);
}
if
(
!
empty
(
$map
[
'supplier_group'
])
||
(
isset
(
$map
[
'supplier_group'
])
&&
$map
[
'supplier_group'
]
===
'0'
))
{
$query
->
where
(
'supplier_group'
,
$map
[
'supplier_group'
]);
}
if
(
!
empty
(
$map
[
'company_nature'
]))
{
$query
->
where
(
'company_nature'
,
$map
[
'company_nature'
]);
}
if
(
!
empty
(
$map
[
'stockup_type'
]))
{
$query
->
where
(
'stockup_type'
,
'like'
,
"%
{
$map
[
'stockup_type'
]
}
%"
);
}
...
...
@@ -58,7 +64,7 @@ class SupplierFilter
$query
->
where
(
'create_uid'
,
$adminId
);
}
if
((
isset
(
$map
[
'status'
])
&&
$map
[
'status'
]
===
"0"
)
||
!
empty
(
$map
[
'status'
]))
{
$query
->
whereIn
(
'status'
,
explode
(
','
,
$map
[
'status'
]));
$query
->
whereIn
(
'status'
,
explode
(
','
,
$map
[
'status'
]));
}
if
(
!
empty
(
$map
[
'is_type'
]))
{
...
...
app/Http/Services/CompanyService.php
0 → 100644
View file @
98f56bd5
<?php
namespace
App\Http\Services
;
//后台用户相关信息服务
use
App\Model\IntracodeModel
;
use
App\Model\UserDepartmentModel
;
use
App\Model\UserInfoModel
;
use
Illuminate\Support\Facades\DB
;
class
CompanyService
{
public
function
getCompanyInfo
(
$supplierName
,
$taxNumber
)
{
$params
=
[
'keyword'
=>
$supplierName
?:
$taxNumber
,
'region'
=>
1
,
'select_type'
=>
1
,
];
$url
=
config
(
'website.InternalApiDomain'
)
.
'/companyInfo'
;
$result
=
curl
(
$url
,
$params
,
true
);
$result
=
json_decode
(
$result
,
true
);
$company
=
[];
if
(
array_get
(
$result
,
'code'
)
===
0
)
{
$companyInfo
=
array_get
(
$result
[
'data'
],
0
);
$company
=
[
'supplier_name'
=>
$companyInfo
[
'com_name'
],
'registered_capital'
=>
$companyInfo
[
'registered_capital'
],
'supplier_address'
=>
$companyInfo
[
'com_address'
],
'tax_number'
=>
$companyInfo
[
'tyc_info'
][
'taxNumber'
],
'phone'
=>
$companyInfo
[
'tyc_info'
][
'phoneNumber'
],
];
}
return
$company
;
}
}
\ No newline at end of file
app/Http/Transformers/SupplierTransformer.php
View file @
98f56bd5
...
...
@@ -38,6 +38,7 @@ class SupplierTransformer
$supplier
[
'purchase_username'
]
=
array_get
(
$users
,
$supplier
[
'purchase_uid'
]);
$supplier
[
'status_name'
]
=
array_get
(
config
(
'fixed.SupplierStatus'
),
$supplier
[
'status'
]);
$supplier
[
'supplier_type_name'
]
=
array_get
(
config
(
'field.SupplierType'
),
$supplier
[
'supplier_type'
]);
$supplier
[
'company_nature_name'
]
=
array_get
(
config
(
'field.CompanyNature'
),
$supplier
[
'company_nature'
]);
$supplier
[
'region_name'
]
=
array_get
(
config
(
'fixed.Region'
),
$supplier
[
'region'
],
'暂无'
);
$supplier
[
'contact_num'
]
=
$this
->
getContactNum
(
$supplier
[
'supplier_id'
]);
$supplier
[
'has_sku'
]
=
$supplier
[
'sku_num'
]
?
'是'
:
'否'
;
...
...
config/field.php
View file @
98f56bd5
...
...
@@ -168,5 +168,14 @@ return [
"深圳市九州电子之家有限公司"
,
"深圳前海硬之城信息技术有限公司"
,
"北京京北通宇电子元件有限公司济南分公司"
],
'CompanyNature'
=>
[
'其它'
=>
'其它'
,
'代理商'
=>
'代理商'
,
'现货商'
=>
'现货商'
,
'方案商'
=>
'方案商'
,
'原厂'
=>
'原厂'
,
'分销平台'
=>
'分销平台'
,
'代工厂'
=>
'代工厂'
,
]
];
\ No newline at end of file
config/website.php
View file @
98f56bd5
...
...
@@ -21,6 +21,7 @@ return [
'UploadUrl'
=>
env
(
'API_DOMAIN'
)
.
'/oss/upload'
,
'UploadKey'
=>
'fh6y5t4rr351d2c3bryi'
,
'QueueDomain'
=>
'http://192.168.1.252:16590/mq/push'
,
'InternalApiDomain'
=>
'http://192.168.1.192:8200'
,
'WarningRobot'
=>
'https://oapi.dingtalk.com/robot/send?access_token=7ff88e1ee208e3a637c17bc51c1c879bccbf101fef5885d22ad70d21ea2f966a'
,
'CSWarningRobot'
=>
'https://oapi.dingtalk.com/robot/send?access_token=92917a6e090a8a39832c4843a579d6c6f9dfecc46fa275f8753ddee2b4399045'
,
...
...
resources/views/script/SupplierDetailScript.blade.php
View file @
98f56bd5
<script>
layui
.
use
([
'table'
,
'form'
,
'element'
,
'layer'
,
'admin'
,
'upload'
,
'index'
],
function
()
{
let
layer
=
layui
.
layer
;
let
admin
=
layui
.
admin
;
let
supplierId
=
getQueryVariable
(
'supplier_id'
)
$
(
'#updateSupplierUrl'
).
click
(
function
()
{
layer
.
load
(
1
);
admin
.
showLoading
({
type
:
3
,
});
let
tabName
=
$
(
'.layui-this'
).
attr
(
'id'
);
window
.
location
.
href
=
"/supplier/UpdateSupplier?view=iframe&supplier_id={{$supplier['supplier_id']}}&tab="
+
tabName
;
})
...
...
@@ -14,7 +17,7 @@
let
supplierId
=
getQueryVariable
(
'supplier_id'
);
let
res
=
ajax
(
'/api/supplier/CancelBlockSupplier'
,
{
supplier_id
:
supplierId
,
is_type
:
0
})
if
(
res
.
err_code
===
0
)
{
layer
.
closeAll
();
admin
.
removeLoading
();
layer
.
msg
(
res
.
err_msg
,
{
icon
:
6
})
location
.
reload
();
}
else
{
...
...
@@ -29,7 +32,7 @@
let
supplierId
=
getQueryVariable
(
'supplier_id'
);
let
res
=
ajax
(
'/api/supplier/CancelDisableSupplier'
,
{
supplier_id
:
supplierId
,
is_type
:
0
})
if
(
res
.
err_code
===
0
)
{
layer
.
closeAll
();
admin
.
removeLoading
();
layer
.
msg
(
res
.
err_msg
,
{
icon
:
6
})
location
.
reload
();
}
else
{
...
...
resources/views/script/SupplierListScript.blade.php
View file @
98f56bd5
...
...
@@ -42,6 +42,7 @@
}
})
}
supplierStatistics
(
true
);
//罗盘隐藏
...
...
@@ -111,8 +112,9 @@
"'
class
=
'list-href'
ew
-
title
=
'供应商详情 - " + data.supplier_code + "'
>
" + data.supplier_code + "
<
/a>
"
}
},
{
field
:
'group_code'
,
title
:
'集团编码'
,
align
:
'center'
,
width
:
90
},
{
field
:
'supplier_name'
,
title
:
'供应商名称'
,
align
:
'
center
'
,
width
:
180
,
templet
:
function
(
data
)
{
field
:
'supplier_name'
,
title
:
'供应商名称'
,
align
:
'
left
'
,
width
:
180
,
templet
:
function
(
data
)
{
if
(
data
.
status
===
-
3
)
{
return
"
<
span
title
=
'" + data.block_reason + "'
>
" + data.supplier_name + "
<
/span>
"
}
else
{
...
...
@@ -121,6 +123,7 @@
}
},
{
field
:
'supplier_group'
,
title
:
'供应商性质'
,
align
:
'center'
,
width
:
115
},
{
field
:
'company_nature'
,
title
:
'公司实际性质'
,
align
:
'center'
,
width
:
125
},
{
field
:
'level'
,
title
:
'等级'
,
align
:
'center'
,
width
:
60
,
templet
:
function
(
d
)
{
return
d
.
level
?
d
.
level
:
'-'
;
...
...
resources/views/script/UpdateSupplierScript.blade.php
View file @
98f56bd5
...
...
@@ -7,7 +7,9 @@
let
element
=
layui
.
element
;
$
(
'#supplierDetailUrl'
).
click
(
function
()
{
layer
.
load
(
1
);
admin
.
showLoading
({
type
:
3
,
});
});
...
...
resources/views/script/supplier/SupplierBaseScript.blade.php
View file @
98f56bd5
...
...
@@ -18,18 +18,28 @@
$
(
"#supplier_name"
).
blur
(
function
()
{
const
supplier_name
=
$
(
this
).
val
();
const
supplier_id
=
supplierId
;
const
taxNumber
=
$
(
'#tax_number'
).
val
();
$
(
'#supplier_check_tip'
).
remove
();
let
url
=
'/api/supplier/CheckSupplierName?supplier_name='
+
supplier_name
+
'&supplier_id='
+
supplier_id
;
let
url
=
'/api/supplier/CheckSupplierName?supplier_name='
+
supplier_name
+
'&supplier_id='
+
supplier_id
+
'&tax_number='
+
taxNumber
;
let
res
=
ajax
(
url
);
if
(
!
res
)
{
layer
.
msg
(
'网络错误,请重试'
,
{
icon
:
5
});
}
else
{
if
(
supplier_name
!==
''
)
{
if
(
res
.
err_code
===
-
1
)
{
$
(
this
).
after
(
"
<
div
id
=
'supplier_check_tip'
style
=
'margin-top: 10px'
>
" +
"
<
p
style
=
'color: red;'
>
供应商已存在,请重新输入或者咨询审批人
<
/p></
div
>
");
layer
.
msg
(
res
.
err_msg
,
{
icon
:
5
});
$
(
this
).
after
(
"
<
div
id
=
'supplier_check_tip'
style
=
'margin-top: 5px'
>
" +
"
<
p
style
=
'color: red;'
>
" + res.err_msg + "
<
/p></
div
>
");
$('#supplier_name').prop('disabled', false);
} else {
} else if (res.err_code === 0) {
//如果供应商没有问题,就要去自动填补部分资料
let companyInfo = res.data;
$('#supplier_name').val(companyInfo.supplier_name);
$('#tax_number').val(companyInfo.tax_number);
$('#phone').val(companyInfo.phone);
$('#supplier_address').val(companyInfo.supplier_address);
$('#registered_capital').val(companyInfo.registered_capital);
layer.msg('校验公司信息通过,自动补全相关数据', {icon: 6})
}
}
}
...
...
@@ -218,8 +228,10 @@
$('#recheck_company_info').click(function () {
let supplierName = $('#supplier_name').val();
let taxNumber = $('#tax_number').val();
console.log(supplierName);
console.log(taxNumber);
admin.btnLoading('#recheck_company_info', '正在查验公司信息,请稍后');
if (!supplierName
||
!taxNumber) {
if (!supplierName
&&
!taxNumber) {
layer.msg('请填写供应商名称或者税号后再进行查验', {icon: 5});
admin.btnLoading('#recheck_company_info', false);
return false;
...
...
@@ -228,16 +240,24 @@
let url = '/api/common/checkCompanyInfo?supplier_name=' + supplierName + '&tax_number=' + taxNumber;
let res = ajax(url);
if (!res) {
admin.btnLoading('#recheck_company_info', false);
layer.msg('网络错误,请重试', {icon: 5});
} else {
if (res.err_code === 0) {
admin.btnLoading('#recheck_company_info', false);
let companyInfo = res.data;
$('#supplier_name').val(companyInfo.supplier_name);
$('#tax_number').val(companyInfo.tax_number);
$('#phone').val(companyInfo.phone);
$('#supplier_address').val(companyInfo.supplier_address);
$('#registered_capital').val(companyInfo.registered_capital);
layer.msg('校验公司信息通过,自动补全相关数据', {icon: 6})
} else {
admin.btnLoading('#recheck_company_info', false);
$('#supplier_name').after("
<
div
id
=
'supplier_check_tip'
style
=
'margin-top: 10px'
>
" +
"
<
p
style
=
'color: red;'
>
公司未进行工商注册,请修改后重新提交
<
/p></
div
>
"
);
layer
.
msg
(
'公司未进行工商注册,请修改后重新提交'
,
{
icon
:
5
})
}
admin
.
btnLoading
(
'#recheck_company_info'
,
false
);
}
});
});
...
...
resources/views/web/supplier/SupplierListCommon.blade.php
View file @
98f56bd5
...
...
@@ -143,17 +143,15 @@
?>
<div
class=
"layui-row"
>
<div
class=
"layui-inline"
>
@inject('
statusPresenter','App\Presenters\Status
Presenter')
{!! $
statusPresenter->render('supplier_group','供应商性质',''
,
config('fixed.SupplierGroup')
) !!}
@inject('
multiTransformableSelectPresenter','App\Presenters\Filter\MultiTransformableSelect
Presenter')
{!! $
multiTransformableSelectPresenter->render(['supplier_group'=>'供应商性质','company_nature'=>'公司实际性质']
,
['supplier_group'=>config('fixed.SupplierGroup'),'company_nature'=>config('field.CompanyNature')]
) !!}
</div>
<div
class=
"layui-inline"
>
@inject('transformableInputPresenter','App\Presenters\Filter\TransformableInputPresenter')
{!! $transformableInputPresenter->render(['supplier_name'=>'供应商名称','supplier_code'=>'供应商编码','supplier_id'=>'供应商ID']) !!}
{!! $transformableInputPresenter->render(['supplier_name'=>'供应商名称','supplier_code'=>'供应商编码','
group_code'=>'集团编码','
supplier_id'=>'供应商ID']) !!}
</div>
<div
class=
"layui-inline"
>
{{-- @inject('statusPresenter','App\Presenters\StatusPresenter')--}}
{{-- {!! $statusPresenter->render('status','供应商状态','',config('fixed.SupplierStatus')) !!}--}}
@inject('multiSelectorPresenter','App\Presenters\MultiSelectorPresenter')
{!! $multiSelectorPresenter->render('status','供应商状态','',$statusData) !!}
</div>
...
...
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