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
c625f75a
authored
Oct 31, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
各种审核判断逻辑
parent
869bf8a2
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
79 additions
and
31 deletions
app/Http/Controllers/Api/SupplierApiController.php
app/Http/Services/CompanyService.php
app/Http/Services/SupplierService.php
app/Http/Services/SyncSupplierService.php
app/Http/Validators/SupplierValidator.php
app/Http/routes.php
resources/views/script/AddSupplierScript.blade.php
app/Http/Controllers/Api/SupplierApiController.php
View file @
c625f75a
...
@@ -122,6 +122,8 @@ class SupplierApiController extends Controller
...
@@ -122,6 +122,8 @@ class SupplierApiController extends Controller
if
(
$validateResult
)
{
if
(
$validateResult
)
{
$this
->
response
(
-
1
,
$validateResult
);
$this
->
response
(
-
1
,
$validateResult
);
}
}
$channelMap
=
$this
->
channelMap
;
$channelMap
=
$this
->
channelMap
;
$channelMap
=
array_merge
(
$channelMap
,
[
$channelMap
=
array_merge
(
$channelMap
,
[
'supplier_consignee'
,
'supplier_consignee'
,
...
@@ -150,6 +152,19 @@ class SupplierApiController extends Controller
...
@@ -150,6 +152,19 @@ class SupplierApiController extends Controller
'swift_code'
,
'swift_code'
,
]);
]);
$channel
=
$request
->
only
(
$channelMap
);
$channel
=
$request
->
only
(
$channelMap
);
//校验一体化实体名单
$businessLicense
=
''
;
$checkCompanyEntity
=
(
new
CompanyService
())
->
checkCompanyEntity
(
$channel
[
'supplier_name'
],
$channel
[
'supplier_name_en'
],
$channel
[
'supplier_address'
],
$businessLicense
);
$checkCompanyEntity
=
1
;
//待确认要透传到数据库里面去
if
(
$checkCompanyEntity
==
0
)
{
$channel
[
'is_entity'
]
=
0
;
}
if
(
$checkCompanyEntity
==
-
1
)
{
$this
->
response
(
-
1
,
'该供应商为实体名单,不允许建档'
);
}
//如果是有直接新增权限的(绕过天眼查等校验)
//如果是有直接新增权限的(绕过天眼查等校验)
if
(
checkPerm
(
'IgnoreCompanyCheck'
))
{
if
(
checkPerm
(
'IgnoreCompanyCheck'
))
{
$channel
[
'is_standard_add'
]
=
-
1
;
$channel
[
'is_standard_add'
]
=
-
1
;
...
@@ -331,12 +346,6 @@ class SupplierApiController extends Controller
...
@@ -331,12 +346,6 @@ class SupplierApiController extends Controller
}
}
}
}
//还要去校验实体名单,和上面的一体化黑名单不一样
$checkCompanyEntity
=
(
new
CompanyService
())
->
checkCompanyEntity
(
$supplierName
);
if
(
$checkCompanyEntity
!==
true
)
{
$this
->
response
(
-
3
,
$checkCompanyEntity
);
}
$company
=
[];
$company
=
[];
//判断用户选的地区是不是需要校验的,不需要直接返回即可
//判断用户选的地区是不是需要校验的,不需要直接返回即可
if
(
in_array
(
$region
,
config
(
'field.NeedCheckCompanyRegion'
)))
{
if
(
in_array
(
$region
,
config
(
'field.NeedCheckCompanyRegion'
)))
{
...
@@ -726,7 +735,7 @@ class SupplierApiController extends Controller
...
@@ -726,7 +735,7 @@ class SupplierApiController extends Controller
{
{
$supplierName
=
trim
(
$request
->
input
(
'supplier_name'
));
$supplierName
=
trim
(
$request
->
input
(
'supplier_name'
));
if
(
!
$supplierName
)
{
if
(
!
$supplierName
)
{
$this
->
response
(
-
1
,
'供应商名称不能为空'
);
$this
->
response
(
-
1
,
'供应商名称不能为空'
);
}
}
$supplier
=
(
new
SupplierService
())
->
querySupplier
(
$supplierName
);
$supplier
=
(
new
SupplierService
())
->
querySupplier
(
$supplierName
);
$this
->
response
(
0
,
'查询成功'
,
$supplier
);
$this
->
response
(
0
,
'查询成功'
,
$supplier
);
...
@@ -737,7 +746,7 @@ class SupplierApiController extends Controller
...
@@ -737,7 +746,7 @@ class SupplierApiController extends Controller
{
{
$standardBrandNames
=
$request
->
input
(
'standard_brand_names'
);
$standardBrandNames
=
$request
->
input
(
'standard_brand_names'
);
$result
=
(
new
StandardBrandService
())
->
getBatchAddMainBrandsData
(
$standardBrandNames
);
$result
=
(
new
StandardBrandService
())
->
getBatchAddMainBrandsData
(
$standardBrandNames
);
$this
->
response
(
0
,
'ok'
,
$result
);
$this
->
response
(
0
,
'ok'
,
$result
);
}
}
}
}
app/Http/Services/CompanyService.php
View file @
c625f75a
...
@@ -93,14 +93,7 @@ class CompanyService
...
@@ -93,14 +93,7 @@ class CompanyService
$result
=
curl
(
$url
,
$params
);
$result
=
curl
(
$url
,
$params
);
$result
=
json_decode
(
$result
,
true
);
$result
=
json_decode
(
$result
,
true
);
if
(
array_get
(
$result
,
'code'
)
===
0
)
{
if
(
array_get
(
$result
,
'code'
)
===
0
)
{
if
(
$result
[
'data'
][
'result'
]
==
-
1
)
{
return
$result
[
'data'
][
'result'
];
return
'该供应商为实体名单,不允许建档'
;
}
if
(
$result
[
'data'
][
'result'
]
==
0
)
{
return
true
;
}
return
true
;
}
}
return
'一体化校验实体名单失败,请联系管理员'
;
return
'一体化校验实体名单失败,请联系管理员'
;
...
...
app/Http/Services/SupplierService.php
View file @
c625f75a
...
@@ -80,6 +80,8 @@ class SupplierService
...
@@ -80,6 +80,8 @@ class SupplierService
//判断是否要审核,默认是要审核的
//判断是否要审核,默认是要审核的
$needAudit
=
true
;
$needAudit
=
true
;
$isDirectApply
=
request
()
->
get
(
'direct_apply'
);
//走事务
//走事务
$supplierId
=
DB
::
connection
(
'web'
)
->
transaction
(
function
()
use
(
$channel
,
$model
,
$oldSupplier
,
&
$needAudit
)
{
$supplierId
=
DB
::
connection
(
'web'
)
->
transaction
(
function
()
use
(
$channel
,
$model
,
$oldSupplier
,
&
$needAudit
)
{
...
@@ -185,6 +187,8 @@ class SupplierService
...
@@ -185,6 +187,8 @@ class SupplierService
//插入供应商返回供应商id
//插入供应商返回供应商id
$supplierId
=
$this
->
newSupplierId
=
$model
->
insertGetId
(
$channel
);
$supplierId
=
$this
->
newSupplierId
=
$model
->
insertGetId
(
$channel
);
//插入sku上传规则
$this
->
saveSkuUploadRulerToRedis
(
$supplierId
,
$channel
[
'sku_upload_ruler'
]);
$this
->
saveSkuUploadRulerToRedis
(
$supplierId
,
$channel
[
'sku_upload_ruler'
]);
//添加联系人
//添加联系人
...
@@ -253,6 +257,7 @@ class SupplierService
...
@@ -253,6 +257,7 @@ class SupplierService
}
}
$channel
[
'system_tags'
]
=
trim
(
implode
(
','
,
$channel
[
'system_tags'
]),
','
);
$channel
[
'system_tags'
]
=
trim
(
implode
(
','
,
$channel
[
'system_tags'
]),
','
);
$model
->
where
(
'supplier_id'
,
$supplierId
)
->
update
(
$channel
);
$model
->
where
(
'supplier_id'
,
$supplierId
)
->
update
(
$channel
);
//保存地址
//保存地址
$supplierAddressService
=
new
SupplierAddressService
();
$supplierAddressService
=
new
SupplierAddressService
();
...
@@ -346,12 +351,32 @@ class SupplierService
...
@@ -346,12 +351,32 @@ class SupplierService
]));
]));
}
}
$isAudit
=
(
bool
)
request
()
->
input
(
'is_audit'
);
//这里还要判断一体化实体名单,如果是待确认,那么也不能修改状态为审核中
//新增的时候,一体化是待确认
if
(
$newSupplier
[
'is_entity'
]
==
0
&&
(
$isDirectApply
||
$isAudit
))
{
//这里还涉及到一体化的状态变更,要去判断is_entity字段
//如果是0的话,那么就要去禁用,并且记录禁用前的原始状态
$reason
=
'待确认实体名单,系统自动拉入禁止交易,请联系“风控部门”进行确认;'
;
// 禁用供应商
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
update
([
'update_time'
=>
time
(),
'disable_reason'
=>
$reason
,
'status'
=>
SupplierChannelModel
::
STATUS_DISABLE
,
]);
$logService
=
new
LogService
();
$logService
->
AddLog
(
$this
->
newSupplierId
,
LogModel
::
UPDATE_OPERATE
,
'实体名单设置'
,
$reason
);
// 记录禁用前的原始状态
$redis
=
new
RedisModel
();
$redis
->
hset
(
'supplier_status_before_disable'
,
$supplierId
,
$newSupplier
[
'status'
]);
}
//这里有个申请审核的判断逻辑
//这里有个申请审核的判断逻辑
//如果是申请审核,并且原来的状态不是已通过,无论什么情况,都要变成审核中,如果是已通过,那么就要走下面的判断是否要忽略审核流程
//如果是申请审核,并且原来的状态不是已通过,无论什么情况,都要变成审核中,如果是已通过,那么就要走下面的判断是否要忽略审核流程
$isAudit
=
(
bool
)
request
()
->
input
(
'is_audit'
);
if
(
$isAudit
&&
$oldSupplier
[
'status'
]
==
SupplierChannelModel
::
STATUS_PASSED
&&
!
$needAudit
&&
!
empty
(
$channel
[
'supplier_id'
]))
{
if
(
$isAudit
&&
$oldSupplier
[
'status'
]
==
SupplierChannelModel
::
STATUS_PASSED
&&
!
$needAudit
&&
!
empty
(
$channel
[
'supplier_id'
]))
{
}
else
if
(
$isAudit
)
{
//什么都不需要操作
}
else
if
(
$isAudit
&&
$newSupplier
[
'is_entity'
]
!=
0
)
{
$auditData
[]
=
[
$auditData
[]
=
[
'supplier_id'
=>
$supplierId
,
'supplier_id'
=>
$supplierId
,
//供应商类型为临时供应商,才会去存申请理由
//供应商类型为临时供应商,才会去存申请理由
...
...
app/Http/Services/SyncSupplierService.php
View file @
c625f75a
...
@@ -217,8 +217,9 @@ class SyncSupplierService
...
@@ -217,8 +217,9 @@ class SyncSupplierService
//加入实体名单后,要做很多事情,比如禁用供应商,也要禁用供应商账号等等,还要记录禁用之前的状态,等到移除实体名单以后,要恢复之前的状态
//加入实体名单后,要做很多事情,比如禁用供应商,也要禁用供应商账号等等,还要记录禁用之前的状态,等到移除实体名单以后,要恢复之前的状态
public
function
receiveEntityResult
(
$supplierName
,
$result
)
public
function
receiveEntityResult
(
$supplierName
,
$result
)
{
{
//先找到对应的供应商,如果没有那跳过
//先找到对应的供应商(草稿的跳过),如果没有那跳过
$supplier
=
SupplierChannelModel
::
where
(
'supplier_name'
,
$supplierName
)
->
first
();
$supplier
=
SupplierChannelModel
::
where
(
'supplier_name'
,
$supplierName
)
->
where
(
'status'
,
'!='
,
SupplierChannelModel
::
STATUS_PENDING
)
->
first
();
if
(
empty
(
$supplier
))
{
if
(
empty
(
$supplier
))
{
return
;
return
;
}
}
...
...
app/Http/Validators/SupplierValidator.php
View file @
c625f75a
...
@@ -74,9 +74,6 @@ class SupplierValidator
...
@@ -74,9 +74,6 @@ class SupplierValidator
}
}
}
}
//去一体化那边判断是否是合法实体名单审核
$businessLicense
=
''
;
//这个supplierId是用来判断是新增还是修改的
//这个supplierId是用来判断是新增还是修改的
$supplierId
=
array_get
(
$validateData
,
'supplier_id'
);
$supplierId
=
array_get
(
$validateData
,
'supplier_id'
);
//如果是修改直接提交,不是点申请审核的,只需要校验供应商名称和采购员是否完整即可
//如果是修改直接提交,不是点申请审核的,只需要校验供应商名称和采购员是否完整即可
...
...
app/Http/routes.php
View file @
c625f75a
...
@@ -82,5 +82,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
...
@@ -82,5 +82,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
});
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
(
new
\App\Http\Services\SyncSupplierService
())
->
receiveEntityResult
(
'
SPARKLAND ELECTRONICS CO., LIMITED'
,
0
);
(
new
\App\Http\Services\SyncSupplierService
())
->
receiveEntityResult
(
'
城茗(國際)有限公司'
,
1
);
});
});
resources/views/script/AddSupplierScript.blade.php
View file @
c625f75a
...
@@ -96,13 +96,19 @@
...
@@ -96,13 +96,19 @@
}
}
form
.
on
(
'submit(addSupplier)'
,
function
(
data
)
{
form
.
on
(
'submit(addSupplier)'
,
function
(
data
)
{
admin
.
showLoading
({
type
:
3
,
admin
.
showLoading
();
});
admin
.
showLoading
(
'.layui-layer-btn0'
);
data
=
getAttachmentData
(
data
);
$
.
ajax
({
let
url
=
'/api/supplier/AddSupplier'
;
url
:
'/api/supplier/AddSupplier'
,
let
res
=
ajax
(
url
,
data
.
field
);
type
:
'POST'
,
async
:
true
,
data
:
data
.
field
,
dataType
:
'json'
,
timeout
:
20000
,
success
:
function
(
res
)
{
if
(
!
res
)
{
if
(
!
res
)
{
admin
.
showLoading
(
'.layui-layer-btn0'
);
admin
.
removeLoading
();
admin
.
removeLoading
();
layer
.
msg
(
'网络错误,请重试'
,
{
icon
:
6
});
layer
.
msg
(
'网络错误,请重试'
,
{
icon
:
6
});
}
else
{
}
else
{
...
@@ -113,10 +119,19 @@
...
@@ -113,10 +119,19 @@
location
.
href
=
"/supplier/SupplierList"
location
.
href
=
"/supplier/SupplierList"
},
1000
);
},
1000
);
}
else
{
}
else
{
admin
.
showLoading
(
'.layui-layer-btn0'
);
admin
.
removeLoading
();
admin
.
removeLoading
();
layer
.
msg
(
res
.
err_msg
,
{
icon
:
5
});
layer
.
msg
(
res
.
err_msg
,
{
icon
:
5
});
}
}
}
}
admin
.
showLoading
(
'.layui-layer-btn0'
);
admin
.
removeLoading
();
},
error
:
function
()
{
admin
.
removeLoading
();
layer
.
msg
(
'网络错误'
,
{
icon
:
5
});
}
});
return
false
;
return
false
;
});
});
...
@@ -126,7 +141,6 @@
...
@@ -126,7 +141,6 @@
form
.
on
(
'submit(addAndApplySupplier)'
,
function
(
data
)
{
form
.
on
(
'submit(addAndApplySupplier)'
,
function
(
data
)
{
data
=
getAttachmentData
(
data
);
data
=
getAttachmentData
(
data
);
console
.
log
(
data
.
field
.
field_name
);
let
fieldNameList
=
data
.
field
.
field_name
?
data
.
field
.
field_name
:
[];
let
fieldNameList
=
data
.
field
.
field_name
?
data
.
field
.
field_name
:
[];
//提交先提示是否要转换供应商类型
//提交先提示是否要转换供应商类型
let
radioObj
=
$
(
'input[name="supplier_type"]'
);
let
radioObj
=
$
(
'input[name="supplier_type"]'
);
...
@@ -209,6 +223,7 @@
...
@@ -209,6 +223,7 @@
function
addSupplier
(
data
)
{
function
addSupplier
(
data
)
{
admin
.
showLoading
();
admin
.
showLoading
();
admin
.
showLoading
(
'.layui-layer-btn0'
);
$
.
ajax
({
$
.
ajax
({
url
:
'/api/supplier/AddSupplier?direct_apply=1'
,
url
:
'/api/supplier/AddSupplier?direct_apply=1'
,
type
:
'POST'
,
type
:
'POST'
,
...
@@ -219,6 +234,8 @@
...
@@ -219,6 +234,8 @@
success
:
function
(
res
)
{
success
:
function
(
res
)
{
if
(
!
res
)
{
if
(
!
res
)
{
admin
.
removeLoading
();
admin
.
removeLoading
();
admin
.
showLoading
(
'.layui-layer-btn0'
);
layer
.
msg
(
'网络错误,请重试'
,
{
icon
:
6
});
layer
.
msg
(
'网络错误,请重试'
,
{
icon
:
6
});
}
else
{
}
else
{
if
(
res
.
err_code
===
0
)
{
if
(
res
.
err_code
===
0
)
{
...
@@ -231,6 +248,8 @@
...
@@ -231,6 +248,8 @@
let
errMsg
=
res
.
err_msg
;
let
errMsg
=
res
.
err_msg
;
let
msg
=
''
;
let
msg
=
''
;
admin
.
removeLoading
();
admin
.
removeLoading
();
admin
.
showLoading
(
'.layui-layer-btn0'
);
$
.
each
(
errMsg
.
split
(
'|'
),
function
(
index
,
value
)
{
$
.
each
(
errMsg
.
split
(
'|'
),
function
(
index
,
value
)
{
msg
+=
"
<
span
>
" + value + "
<
/span><br>
"
msg
+=
"
<
span
>
" + value + "
<
/span><br>
"
});
});
...
@@ -238,9 +257,13 @@
...
@@ -238,9 +257,13 @@
}
}
}
}
admin
.
removeLoading
();
admin
.
removeLoading
();
admin
.
showLoading
(
'.layui-layer-btn0'
);
},
},
error
:
function
()
{
error
:
function
()
{
admin
.
removeLoading
();
admin
.
removeLoading
();
admin
.
showLoading
(
'.layui-layer-btn0'
);
layer
.
msg
(
'网络错误'
,
{
icon
:
5
});
layer
.
msg
(
'网络错误'
,
{
icon
:
5
});
}
}
});
});
...
...
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