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
2ef15e40
authored
Mar 02, 2026
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix
parent
8b22f616
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
60 deletions
app/Http/Services/SupplierService.php
app/Http/Services/SupplierService.php
View file @
2ef15e40
...
@@ -1320,7 +1320,7 @@ class SupplierService
...
@@ -1320,7 +1320,7 @@ class SupplierService
$suppliers
=
$query
->
get
();
$suppliers
=
$query
->
get
();
\dump
(
"一共处理供应商 : "
.
count
(
$suppliers
->
toArray
()));
// 记录总数但不使用dump避免输出问题
$result
=
[
$result
=
[
'mode'
=>
$isProdMode
?
'production'
:
'debug'
,
'mode'
=>
$isProdMode
?
'production'
:
'debug'
,
...
@@ -1333,60 +1333,85 @@ class SupplierService
...
@@ -1333,60 +1333,85 @@ class SupplierService
];
];
foreach
(
$suppliers
as
$supplier
)
{
foreach
(
$suppliers
as
$supplier
)
{
$result
[
'total'
]
++
;
try
{
$supplierId
=
$supplier
->
supplier_id
;
// 数据库重连,防止长时间运行断开
$yunxinChannelUid
=
$supplier
->
yunxin_channel_uid
;
if
(
$result
[
'total'
]
>
0
&&
$result
[
'total'
]
%
100
==
0
)
{
\DB
::
reconnect
(
'web'
);
}
// 调用autoAssignPurchaseUser处理分配逻辑
$result
[
'total'
]
++
;
$assignResult
=
$supplierService
->
autoAssignPurchaseUser
(
$supplierId
,
$yunxinChannelUid
,
$isProdMode
);
$supplierId
=
$supplier
->
supplier_id
;
$yunxinChannelUid
=
$supplier
->
yunxin_channel_uid
;
if
(
$assignResult
[
'success'
])
{
// 调用autoAssignPurchaseUser处理分配逻辑
// 判断是跳过还是真正分配了
$assignResult
=
$supplierService
->
autoAssignPurchaseUser
(
$supplierId
,
$yunxinChannelUid
,
$isProdMode
);
if
(
strpos
(
$assignResult
[
'reason'
],
'跳过'
)
!==
false
)
{
$result
[
'skipped'
]
++
;
$result
[
'debug_info'
][]
=
[
'supplier_id'
=>
$supplierId
,
'supplier_code'
=>
$supplier
->
supplier_code
,
'supplier_name'
=>
$supplier
->
supplier_name
,
'skip_reason'
=>
$assignResult
[
'reason'
],
];
if
(
$progressCallback
)
{
if
(
$assignResult
[
'success'
])
{
$progressCallback
([
// 判断是跳过还是真正分配了
if
(
strpos
(
$assignResult
[
'reason'
],
'跳过'
)
!==
false
)
{
$result
[
'skipped'
]
++
;
$result
[
'debug_info'
][]
=
[
'supplier_id'
=>
$supplierId
,
'supplier_id'
=>
$supplierId
,
'supplier_code'
=>
$supplier
->
supplier_code
,
'supplier_name'
=>
$supplier
->
supplier_name
,
'supplier_name'
=>
$supplier
->
supplier_name
,
'action'
=>
'跳过:'
.
$assignResult
[
'reason'
],
'skip_reason'
=>
$assignResult
[
'reason'
],
'status'
=>
'skip'
,
];
]);
}
if
(
$progressCallback
)
{
}
else
{
$progressCallback
([
$result
[
'success'
]
++
;
'supplier_id'
=>
$supplierId
,
$assignCodeIds
=
isset
(
$assignResult
[
'debug_info'
][
'assign_code_ids'
])
?
$assignResult
[
'debug_info'
][
'assign_code_ids'
]
:
[];
'supplier_name'
=>
$supplier
->
supplier_name
,
$assignNames
=
array_map
(
function
(
$codeId
)
use
(
$adminUserService
)
{
'action'
=>
'跳过:'
.
$assignResult
[
'reason'
],
return
$adminUserService
->
getAdminUserNameByCodeId
(
$codeId
);
'status'
=>
'skip'
,
},
$assignCodeIds
);
]);
}
}
else
{
$result
[
'success'
]
++
;
$assignCodeIds
=
isset
(
$assignResult
[
'debug_info'
][
'assign_code_ids'
])
?
$assignResult
[
'debug_info'
][
'assign_code_ids'
]
:
[];
$assignNames
=
array_map
(
function
(
$codeId
)
use
(
$adminUserService
)
{
return
$adminUserService
->
getAdminUserNameByCodeId
(
$codeId
);
},
$assignCodeIds
);
// 获取需要分配的数量
// 获取需要分配的数量
$needAssignLiexin
=
isset
(
$assignResult
[
'debug_info'
][
'need_assign_liexin'
])
?
$assignResult
[
'debug_info'
][
'need_assign_liexin'
]
:
array
();
$needAssignLiexin
=
isset
(
$assignResult
[
'debug_info'
][
'need_assign_liexin'
])
?
$assignResult
[
'debug_info'
][
'need_assign_liexin'
]
:
array
();
$needAssignDataFollower
=
isset
(
$assignResult
[
'debug_info'
][
'need_assign_data_follower'
])
?
$assignResult
[
'debug_info'
][
'need_assign_data_follower'
]
:
array
();
$needAssignDataFollower
=
isset
(
$assignResult
[
'debug_info'
][
'need_assign_data_follower'
])
?
$assignResult
[
'debug_info'
][
'need_assign_data_follower'
]
:
array
();
$liexinCount
=
count
(
$needAssignLiexin
);
$liexinCount
=
count
(
$needAssignLiexin
);
$followerCount
=
count
(
$needAssignDataFollower
);
$followerCount
=
count
(
$needAssignDataFollower
);
// 判断是新增还是补充
// 判断是新增还是补充
$isNew
=
(
$liexinCount
==
count
(
$assignCodeIds
)
&&
$followerCount
==
count
(
$assignCodeIds
));
$isNew
=
(
$liexinCount
==
count
(
$assignCodeIds
)
&&
$followerCount
==
count
(
$assignCodeIds
));
$action
=
'新增'
.
$liexinCount
.
'个猎芯采购,'
.
$followerCount
.
'个数据跟单员'
;
$action
=
'新增'
.
$liexinCount
.
'个猎芯采购,'
.
$followerCount
.
'个数据跟单员'
;
$result
[
'details'
][]
=
[
$result
[
'details'
][]
=
[
'supplier_id'
=>
$supplierId
,
'supplier_code'
=>
$supplier
->
supplier_code
,
'supplier_name'
=>
$supplier
->
supplier_name
,
'action'
=>
$action
,
'assign_code_ids'
=>
$assignCodeIds
,
'assign_names'
=>
$assignNames
,
'is_new'
=>
$isNew
,
'need_assign_liexin'
=>
$liexinCount
,
'need_assign_follower'
=>
$followerCount
,
];
// 回调进度
if
(
$progressCallback
)
{
$progressCallback
([
'supplier_id'
=>
$supplierId
,
'supplier_name'
=>
$supplier
->
supplier_name
,
'action'
=>
'成功:'
.
$action
,
'status'
=>
'success'
,
]);
}
}
}
else
{
$result
[
'failed'
]
++
;
$result
[
'debug_info'
][]
=
[
'supplier_id'
=>
$supplierId
,
'supplier_id'
=>
$supplierId
,
'supplier_code'
=>
$supplier
->
supplier_code
,
'supplier_code'
=>
$supplier
->
supplier_code
,
'supplier_name'
=>
$supplier
->
supplier_name
,
'supplier_name'
=>
$supplier
->
supplier_name
,
'action'
=>
$action
,
'fail_reason'
=>
$assignResult
[
'reason'
],
'assign_code_ids'
=>
$assignCodeIds
,
'assign_names'
=>
$assignNames
,
'is_new'
=>
$isNew
,
'need_assign_liexin'
=>
$liexinCount
,
'need_assign_follower'
=>
$followerCount
,
];
];
// 回调进度
// 回调进度
...
@@ -1394,29 +1419,19 @@ class SupplierService
...
@@ -1394,29 +1419,19 @@ class SupplierService
$progressCallback
([
$progressCallback
([
'supplier_id'
=>
$supplierId
,
'supplier_id'
=>
$supplierId
,
'supplier_name'
=>
$supplier
->
supplier_name
,
'supplier_name'
=>
$supplier
->
supplier_name
,
'action'
=>
'
成功:'
.
$action
,
'action'
=>
'
失败:'
.
$assignResult
[
'reason'
]
,
'status'
=>
'
success
'
,
'status'
=>
'
failed
'
,
]);
]);
}
}
}
}
}
else
{
}
catch
(
\Exception
$e
)
{
$result
[
'failed'
]
++
;
$result
[
'failed'
]
++
;
$result
[
'debug_info'
][]
=
[
$result
[
'debug_info'
][]
=
[
'supplier_id'
=>
$supplierId
,
'supplier_id'
=>
isset
(
$supplierId
)
?
$supplierId
:
0
,
'supplier_code'
=>
$supplier
->
supplier_code
,
'supplier_code'
=>
isset
(
$supplier
->
supplier_code
)
?
$supplier
->
supplier_code
:
''
,
'supplier_name'
=>
$supplier
->
supplier_name
,
'supplier_name'
=>
isset
(
$supplier
->
supplier_name
)
?
$supplier
->
supplier_name
:
''
,
'fail_reason'
=>
$assignResult
[
'reason'
]
,
'fail_reason'
=>
'异常: '
.
$e
->
getMessage
()
,
];
];
// 回调进度
if
(
$progressCallback
)
{
$progressCallback
([
'supplier_id'
=>
$supplierId
,
'supplier_name'
=>
$supplier
->
supplier_name
,
'action'
=>
'失败:'
.
$assignResult
[
'reason'
],
'status'
=>
'failed'
,
]);
}
}
}
}
}
...
...
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