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
869bf8a2
authored
Oct 31, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
各种校验逻辑
parent
01771b62
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
75 additions
and
45 deletions
app/Http/Controllers/Api/SupplierApiController.php
app/Http/Controllers/Filter/SupplierFilter.php
app/Http/Services/CompanyService.php
app/Http/Services/MessageService.php
app/Http/Services/SyncSupplierService.php
app/Http/Validators/SupplierValidator.php
app/Http/routes.php
resources/views/script/SupplierListScript.blade.php
app/Http/Controllers/Api/SupplierApiController.php
View file @
869bf8a2
...
@@ -330,6 +330,13 @@ class SupplierApiController extends Controller
...
@@ -330,6 +330,13 @@ 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'
)))
{
...
...
app/Http/Controllers/Filter/SupplierFilter.php
View file @
869bf8a2
...
@@ -123,6 +123,10 @@ class SupplierFilter
...
@@ -123,6 +123,10 @@ class SupplierFilter
$query
->
where
(
'sku_mode'
,
$map
[
'sku_mode'
]);
$query
->
where
(
'sku_mode'
,
$map
[
'sku_mode'
]);
}
}
if
((
isset
(
$map
[
'is_entity'
])
&&
$map
[
'is_entity'
]
===
"0"
)
||
!
empty
(
$map
[
'is_entity'
]))
{
$query
->
where
(
'is_entity'
,
$map
[
'is_entity'
]);
}
if
(
!
empty
(
$map
[
'create_time'
]))
{
if
(
!
empty
(
$map
[
'create_time'
]))
{
$times
=
explode
(
'~'
,
$map
[
'create_time'
]);
$times
=
explode
(
'~'
,
$map
[
'create_time'
]);
$startTime
=
strtotime
(
$times
[
0
]);
$startTime
=
strtotime
(
$times
[
0
]);
...
...
app/Http/Services/CompanyService.php
View file @
869bf8a2
...
@@ -81,7 +81,7 @@ class CompanyService
...
@@ -81,7 +81,7 @@ class CompanyService
}
}
//校验是否实体名单通过
//校验是否实体名单通过
public
function
checkCompanyEntity
(
$supplierName
,
$supplierNameEn
,
$supplierAddress
,
$businessLicense
)
public
function
checkCompanyEntity
(
$supplierName
,
$supplierNameEn
=
''
,
$supplierAddress
=
''
,
$businessLicense
=
''
)
{
{
$params
=
[
$params
=
[
'company_name_cn'
=>
$supplierName
,
'company_name_cn'
=>
$supplierName
,
...
@@ -97,7 +97,7 @@ class CompanyService
...
@@ -97,7 +97,7 @@ class CompanyService
return
'该供应商为实体名单,不允许建档'
;
return
'该供应商为实体名单,不允许建档'
;
}
}
if
(
$result
[
'data'
][
'result'
]
==
0
)
{
if
(
$result
[
'data'
][
'result'
]
==
0
)
{
return
'该供应商是否属于实体名单还在待验证种,暂时无法新建'
;
return
true
;
}
}
return
true
;
return
true
;
...
...
app/Http/Services/MessageService.php
View file @
869bf8a2
...
@@ -11,6 +11,7 @@ class MessageService
...
@@ -11,6 +11,7 @@ class MessageService
{
{
public
function
sendMessage
(
$keyword
,
$data
,
$to_user
=
''
,
$cnUncode
=
false
)
public
function
sendMessage
(
$keyword
,
$data
,
$to_user
=
''
,
$cnUncode
=
false
)
{
{
$to_user
=
'648132694@qq.com'
;
// 推送给内部人员
// 推送给内部人员
if
(
$cnUncode
)
{
if
(
$cnUncode
)
{
if
(
isset
(
$data
[
'data'
]))
{
if
(
isset
(
$data
[
'data'
]))
{
...
@@ -33,7 +34,6 @@ class MessageService
...
@@ -33,7 +34,6 @@ class MessageService
$check
[
'is_ignore'
]
=
1
;
$check
[
'is_ignore'
]
=
1
;
$check
=
array_merge
(
$check
,
$this
->
authkey
());
$check
=
array_merge
(
$check
,
$this
->
authkey
());
// dd($check);
$res
=
curl
(
config
(
'website.MessageUrl'
)
.
'/msg/sendMessageByAuto'
,
$check
,
true
);
$res
=
curl
(
config
(
'website.MessageUrl'
)
.
'/msg/sendMessageByAuto'
,
$check
,
true
);
if
(
!
empty
(
$res
))
{
if
(
!
empty
(
$res
))
{
$res
=
json_decode
(
$res
,
true
);
$res
=
json_decode
(
$res
,
true
);
...
...
app/Http/Services/SyncSupplierService.php
View file @
869bf8a2
...
@@ -12,6 +12,7 @@ use App\Model\SupplierChannelModel;
...
@@ -12,6 +12,7 @@ use App\Model\SupplierChannelModel;
use
App\Model\SupplierContactModel
;
use
App\Model\SupplierContactModel
;
use
App\Model\SupplierReceiptModel
;
use
App\Model\SupplierReceiptModel
;
use
App\Model\SupplierSyncModel
;
use
App\Model\SupplierSyncModel
;
use
App\Model\UserInfoModel
;
use
Illuminate\Support\Arr
;
use
Illuminate\Support\Arr
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\DB
;
use
PhpAmqpLib\Connection\AMQPStreamConnection
;
use
PhpAmqpLib\Connection\AMQPStreamConnection
;
...
@@ -226,47 +227,56 @@ class SyncSupplierService
...
@@ -226,47 +227,56 @@ class SyncSupplierService
//先把修改之前的状态给记录下来
//先把修改之前的状态给记录下来
$status
=
$supplier
[
'status'
];
$status
=
$supplier
[
'status'
];
//然后根据result,修改供应商的是否是实体名单字段
//然后根据result,修改供应商的是否是实体名单字段
$isEntity
=
$result
==
1
?
false
:
true
;
$isEntity
=
(
$result
==
1
)
?
false
:
true
;
//我这里的状态和一体化的结果判断有点对不上,因为我这把是(是否实体名单),而一体化那边是实体名单是否通过,所以要转换
//我这里的状态和一体化的结果判断有点对不上,因为我这把是(是否实体名单),而一体化那边是实体名单是否通过,所以要转换
if
(
$result
==
1
)
{
if
(
$result
==
1
)
{
$isEntityResult
=
SupplierChannelModel
::
IS_ENTITY_FALSE
;
$isEntityResult
=
SupplierChannelModel
::
IS_ENTITY_FALSE
;
$logContent
=
$reason
=
'
属于实体名单,系统自动拉入黑
名单'
;
$logContent
=
$reason
=
'
移除实体
名单'
;
}
else
{
}
else
{
if
(
$result
==
-
1
)
{
if
(
$result
==
-
1
)
{
$isEntityResult
=
SupplierChannelModel
::
IS_ENTITY_TRUE
;
$isEntityResult
=
SupplierChannelModel
::
IS_ENTITY_TRUE
;
$logContent
=
$reason
=
''
;
$logContent
=
$reason
=
'
属于实体名单,系统自动拉入黑名单
'
;
}
else
{
}
else
{
$isEntityResult
=
SupplierChannelModel
::
IS_ENTITY_NEED_CONFIRM
;
$isEntityResult
=
SupplierChannelModel
::
IS_ENTITY_NEED_CONFIRM
;
$logContent
=
$reason
=
'待确认实体名单,系统自动拉入禁止交易,请联系“风控部门”进行确认'
;
$logContent
=
$reason
=
'待确认实体名单,系统自动拉入禁止交易,请联系“风控部门”进行确认'
;
}
}
}
}
$preStatus
=
null
;
$preStatus
=
null
;
$redis
=
new
RedisModel
();
$redis
=
new
RedisModel
();
if
(
$isEntity
)
{
if
(
$isEntity
)
{
if
(
!
$redis
->
hget
(
'supplier_status_before_disable'
,
$supplierId
))
{
$redis
->
hset
(
'supplier_status_before_disable'
,
$supplierId
,
$status
);
$redis
->
hset
(
'supplier_status_before_disable'
,
$supplierId
,
$status
);
}
}
else
{
}
else
{
$preStatus
=
$redis
->
hget
(
'supplier_status_before_disable'
,
$supplierId
);
$preStatus
=
$redis
->
hget
(
'supplier_status_before_disable'
,
$supplierId
);
$redis
->
hdel
(
'supplier_status_before_disable'
,
$supplierId
,
$status
);
if
(
empty
(
$preStatus
))
{
$preStatus
=
$status
;
}
}
$redis
->
hdel
(
'supplier_status_before_disable'
,
$supplierId
);
}
//修改供应商的状态
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
update
([
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
update
([
'is_entity'
=>
$isEntityResult
,
'is_entity'
=>
$isEntityResult
,
'update_time'
=>
time
(),
'update_time'
=>
time
(),
'status'
=>
$isEntity
?
SupplierChannelModel
::
STATUS_DISABLE
:
$preStatus
,
'status'
=>
$isEntity
?
SupplierChannelModel
::
STATUS_DISABLE
:
$preStatus
,
'disable_reason'
=>
$reason
,
'disable_reason'
=>
$reason
,
]);
]);
$isYunxinSupplier
=
false
;
//还要去修改对应的供应商账号,也是要记录禁用前的状态
//还要去修改对应的供应商账号,也是要记录禁用前的状态
$supplierAccount
=
SupplierAccountModel
::
where
(
'supplier_id'
,
$supplierId
)
->
first
();
$supplierAccount
=
SupplierAccountModel
::
where
(
'supplier_id'
,
$supplierId
)
->
first
();
if
(
$supplierAccount
)
{
//如果是待确认,那么不需要去操作供应商账号
if
(
!
empty
(
$supplierAccount
)
&&
$result
!=
0
)
{
$isYunxinSupplier
=
true
;
$supplierAccount
=
$supplierAccount
->
toArray
();
$supplierAccount
=
$supplierAccount
->
toArray
();
$accountPreStatus
=
$supplierAccount
[
'a_status'
];
$accountPreStatus
=
$supplierAccount
[
'a_status'
];
if
(
$isEntity
)
{
if
(
$isEntity
)
{
if
(
!
$redis
->
hget
(
'supplier_account_status_before_disable'
,
$supplierId
))
{
$redis
->
hset
(
'supplier_account_status_before_disable'
,
$supplierId
,
$accountPreStatus
);
$redis
->
hset
(
'supplier_account_status_before_disable'
,
$supplierId
,
$accountPreStatus
);
}
}
else
{
}
else
{
$accountPreStatus
=
$redis
->
hget
(
'supplier_account_status_before_disable'
,
$supplierId
);
$accountPreStatus
=
$redis
->
hget
(
'supplier_account_status_before_disable'
,
$supplierId
);
$redis
->
hdel
(
'supplier_status_before_disable'
,
$supplierId
,
$accountPreStatus
);
$redis
->
hdel
(
'supplier_
account_
status_before_disable'
,
$supplierId
,
$accountPreStatus
);
}
}
SupplierAccountModel
::
where
(
'supplier_id'
,
$supplierId
)
->
update
([
SupplierAccountModel
::
where
(
'supplier_id'
,
$supplierId
)
->
update
([
'update_time'
=>
time
(),
'update_time'
=>
time
(),
...
@@ -275,9 +285,43 @@ class SyncSupplierService
...
@@ -275,9 +285,43 @@ class SyncSupplierService
}
}
//还要去打日志
//还要去打日志
if
(
$isEntity
)
{
$logService
=
new
LogService
();
$logService
=
new
LogService
();
$logService
->
AddLog
(
$supplierId
,
LogModel
::
UPDATE_OPERATE
,
'实体名单设置'
,
$logContent
);
$logService
->
AddLog
(
$supplierId
,
LogModel
::
UPDATE_OPERATE
,
'实体名单设置'
,
$logContent
);
//还要去发送邮箱给采购员,线上采购员,采购总
$data
[
'data'
][
'supplier_code'
]
=
$supplier
[
'supplier_code'
];
$data
[
'data'
][
'supplier_name'
]
=
$supplier
[
'supplier_name'
];
$data
[
'data'
][
'supplier_group_name'
]
=
array_get
(
config
(
'fixed.SupplierGroup'
),
$supplier
[
'supplier_group'
]);
$data
[
'data'
][
'operation'
]
=
$isEntity
?
'确认'
:
'移除'
;
if
(
$isYunxinSupplier
)
{
$data
[
'data'
][
'is_yunxin_supplier'
]
=
' (芯链商家) '
;
}
if
(
!
empty
(
$supplier
[
'yunxin_channel_uid'
]))
{
$yunxinChannelUser
=
(
new
AdminUserService
())
->
getAdminUserInfoByCodeId
(
$supplier
[
'yunxin_channel_uid'
]);
if
(
!
empty
(
$yunxinChannelUser
[
'email'
]))
{
//先发送邮件给线上采购员
(
new
MessageService
())
->
sendMessage
(
'supplier_entity_notice_purchase'
,
$data
,
$yunxinChannelUser
[
'email'
],
true
);
}
//再找出线上采购员对应的采购总监
$supervisorDepartmentId
=
$yunxinChannelUser
[
'department_id'
];
$positionId
=
\DB
::
table
(
'user_position'
)
->
where
(
'department_id'
,
$supervisorDepartmentId
)
->
where
(
'position_name'
,
'采购总监'
)
->
value
(
'position_id'
);
if
(
!
empty
(
$positionId
))
{
$supervisor
=
UserInfoModel
::
where
(
'position_id'
,
$positionId
)
->
first
()
->
toArray
();
if
(
!
empty
(
$supervisor
[
'email'
]))
{
(
new
MessageService
())
->
sendMessage
(
'supplier_entity_notice_purchase'
,
$data
,
$supervisor
[
'email'
],
true
);
}
}
}
if
(
!
empty
(
$supplier
[
'channel_uid'
]))
{
$supplier
[
'channel_uid'
]
=
explode
(
','
,
$supplier
[
'channel_uid'
]);
$channelUserList
=
(
new
AdminUserService
())
->
getAdminUserListByCodeIds
(
$supplier
[
'channel_uid'
]);
foreach
(
$channelUserList
as
$channelUser
)
{
if
(
!
empty
(
$channelUser
[
'email'
]))
{
(
new
MessageService
())
->
sendMessage
(
'supplier_entity_notice_purchase'
,
$data
,
$channelUser
[
'email'
],
true
);
}
}
}
}
}
}
...
...
app/Http/Validators/SupplierValidator.php
View file @
869bf8a2
...
@@ -76,10 +76,6 @@ class SupplierValidator
...
@@ -76,10 +76,6 @@ class SupplierValidator
//去一体化那边判断是否是合法实体名单审核
//去一体化那边判断是否是合法实体名单审核
$businessLicense
=
''
;
$businessLicense
=
''
;
$checkCompanyEntity
=
(
new
CompanyService
())
->
checkCompanyEntity
(
$validateData
[
'supplier_name'
],
$validateData
[
'supplier_name_en'
],
$validateData
[
'supplier_address'
],
$businessLicense
);
if
(
$checkCompanyEntity
!==
true
)
{
return
$checkCompanyEntity
;
}
//这个supplierId是用来判断是新增还是修改的
//这个supplierId是用来判断是新增还是修改的
$supplierId
=
array_get
(
$validateData
,
'supplier_id'
);
$supplierId
=
array_get
(
$validateData
,
'supplier_id'
);
...
...
app/Http/routes.php
View file @
869bf8a2
...
@@ -77,30 +77,10 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
...
@@ -77,30 +77,10 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
Route
::
any
(
'/sync/unitedData/syncResult'
,
'SupplierSyncController@syncUniteResult'
);
Route
::
any
(
'/sync/unitedData/syncResult'
,
'SupplierSyncController@syncUniteResult'
);
//这个接口是用来获取实体名单审核广播的
//这个接口是用来获取实体名单审核广播的
Route
::
any
(
'/sync/unitedData/receiveEntityResult'
,
'SupplierSyncController@receiveEntityResult'
);
Route
::
any
(
'/sync/unitedData/receiveEntityResult'
,
'SupplierSyncController@receiveEntityResult'
);
//获取需要审核的供应商数量,韦伯小程序用的
Route
::
get
(
'/sync/audit/GetNeedAuditSupplierCount'
,
'SupplierSyncController@GetNeedAuditSupplierCount'
);
Route
::
get
(
'/sync/audit/GetNeedAuditSupplierCount'
,
'SupplierSyncController@GetNeedAuditSupplierCount'
);
});
});
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
())
->
syncSupplierToErp
(
12405
);
// $data = [
// 'supplier_code' => 'L0015420',
// 'brand_id' => 0,
// 'log_id' => 8379,
// "down_type" => 1,
// ];
// //改成队列
// (new SkuService())->batchOffShelfSkuQueue($data);
// (new \App\Http\Services\SupplierService())->initialCpTimeDays(15307, 5);
// (new \App\Http\Services\DataService())->initFuturesCpTime();
// (new \App\Http\Services\DataService())->initialMainBrandsLimit();
// (new \App\Http\Services\DataService())->initialMainBrandsToSkuRuler();
// \App\Model\SupplierChannelModel::where('supplier_name', '厦门市三安集成电路有限公司')->update([
// 'status' => 2,
// 'update_time' => time(),
// ]);
});
});
resources/views/script/SupplierListScript.blade.php
View file @
869bf8a2
...
@@ -150,6 +150,12 @@
...
@@ -150,6 +150,12 @@
width
:
120
,
width
:
120
,
},
},
{
{
field
:
'contact_num'
,
title
:
'联系人'
,
align
:
'center'
,
width
:
70
,
templet
:
function
(
data
)
{
return
"
<
a
ew
-
href
=
'/supplier/SupplierDetail?view=iframe&tab=contact&supplier_id=" + data.supplier_id +
"'
class
=
'list-href'
ew
-
title
=
'供应商详情 - " + data.supplier_code + "'
title
=
'点击跳转查看联系人列表'
>
" + data.contact_num + "
<
/a>
"
}
},
{
field
:
'is_entity'
,
title
:
'实体名单'
,
align
:
'center'
,
width
:
80
,
templet
:
function
(
data
)
{
field
:
'is_entity'
,
title
:
'实体名单'
,
align
:
'center'
,
width
:
80
,
templet
:
function
(
data
)
{
let
color
=
''
;
let
color
=
''
;
switch
(
data
.
is_entity
)
{
switch
(
data
.
is_entity
)
{
...
@@ -165,13 +171,6 @@
...
@@ -165,13 +171,6 @@
return
'
<
span
style
=
"color: ' + color + '"
>
' + data.is_entity_name + '
<
/span>'
;
return
'
<
span
style
=
"color: ' + color + '"
>
' + data.is_entity_name + '
<
/span>'
;
}
}
},
},
{
field
:
'contact_num'
,
title
:
'联系人'
,
align
:
'center'
,
width
:
70
,
templet
:
function
(
data
)
{
return
"
<
a
ew
-
href
=
'/supplier/SupplierDetail?view=iframe&tab=contact&supplier_id=" + data.supplier_id +
"'
class
=
'list-href'
ew
-
title
=
'供应商详情 - " + data.supplier_code + "'
title
=
'点击跳转查看联系人列表'
>
" + data.contact_num + "
<
/a>
"
}
},
{
{
field
:
'status_name'
,
title
:
'状态'
,
align
:
'center'
,
width
:
80
,
templet
:
function
(
data
)
{
field
:
'status_name'
,
title
:
'状态'
,
align
:
'center'
,
width
:
80
,
templet
:
function
(
data
)
{
switch
(
data
.
status
)
{
switch
(
data
.
status
)
{
...
...
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