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
eb3dc441
authored
Mar 02, 2026
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix
parent
860fcb1f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
153 deletions
app/Console/Commands/RefreshHistoryPurchaseUser.php
app/Http/Services/SupplierService.php
app/Console/Commands/RefreshHistoryPurchaseUser.php
View file @
eb3dc441
...
@@ -47,7 +47,7 @@ class RefreshHistoryPurchaseUser extends Command
...
@@ -47,7 +47,7 @@ class RefreshHistoryPurchaseUser extends Command
$this
->
info
(
'处理数量: '
.
(
$num
>
0
?
$num
:
'不限制'
));
$this
->
info
(
'处理数量: '
.
(
$num
>
0
?
$num
:
'不限制'
));
$this
->
info
(
'========================================'
);
$this
->
info
(
'========================================'
);
// 调用服务方法
,不使用实时回调输出
// 调用服务方法
$result
=
SupplierService
::
refreshHistoryPurchaseUserWithProgress
(
$mode
,
$num
);
$result
=
SupplierService
::
refreshHistoryPurchaseUserWithProgress
(
$mode
,
$num
);
// 输出最终结果
// 输出最终结果
...
@@ -60,112 +60,6 @@ class RefreshHistoryPurchaseUser extends Command
...
@@ -60,112 +60,6 @@ class RefreshHistoryPurchaseUser extends Command
$this
->
info
(
'跳过: '
.
$result
[
'skipped'
]);
$this
->
info
(
'跳过: '
.
$result
[
'skipped'
]);
$this
->
info
(
'========================================'
);
$this
->
info
(
'========================================'
);
// 只打印有数据变更的公司(成功的)
if
(
!
empty
(
$result
[
'details'
]))
{
$this
->
info
(
''
);
$this
->
info
(
'数据变更详情('
.
count
(
$result
[
'details'
])
.
'条):'
);
// 限制输出数量,避免过多输出
$outputLimit
=
50
;
$details
=
array_slice
(
$result
[
'details'
],
0
,
$outputLimit
);
foreach
(
$details
as
$detail
)
{
$supplierId
=
$detail
[
'supplier_id'
];
$supplierCode
=
isset
(
$detail
[
'supplier_code'
])
?
$detail
[
'supplier_code'
]
:
''
;
$supplierName
=
isset
(
$detail
[
'supplier_name'
])
?
$detail
[
'supplier_name'
]
:
''
;
$action
=
isset
(
$detail
[
'action'
])
?
$detail
[
'action'
]
:
''
;
$isNew
=
isset
(
$detail
[
'is_new'
])
?
$detail
[
'is_new'
]
:
false
;
// 获取分配的采购员信息
$assignInfo
=
''
;
if
(
isset
(
$detail
[
'assign_names'
])
&&
!
empty
(
$detail
[
'assign_names'
]))
{
$assignInfo
=
' 采购员: '
.
implode
(
','
,
$detail
[
'assign_names'
]);
}
elseif
(
isset
(
$detail
[
'assign_code_ids'
])
&&
!
empty
(
$detail
[
'assign_code_ids'
]))
{
$assignInfo
=
' 采购员codeId: '
.
implode
(
','
,
$detail
[
'assign_code_ids'
]);
}
$newFlag
=
$isNew
?
'[新增]'
:
'[补充]'
;
$this
->
info
(
sprintf
(
' %s [ID:%d %s] %s - %s%s'
,
$newFlag
,
$supplierId
,
$supplierCode
,
$supplierName
,
$action
,
$assignInfo
));
}
if
(
count
(
$result
[
'details'
])
>
$outputLimit
)
{
$this
->
info
(
' ... 还有 '
.
(
count
(
$result
[
'details'
])
-
$outputLimit
)
.
' 条记录未显示'
);
}
}
// 打印失败的记录,限制数量
if
(
!
empty
(
$result
[
'debug_info'
]))
{
$failCount
=
0
;
foreach
(
$result
[
'debug_info'
]
as
$info
)
{
if
(
isset
(
$info
[
'fail_reason'
])
&&
$info
[
'fail_reason'
])
{
$failCount
++
;
}
}
if
(
$failCount
>
0
)
{
$this
->
info
(
''
);
$this
->
warn
(
'失败详情('
.
$failCount
.
'条):'
);
$failOutputLimit
=
20
;
$outputCount
=
0
;
foreach
(
$result
[
'debug_info'
]
as
$info
)
{
$failReason
=
isset
(
$info
[
'fail_reason'
])
?
$info
[
'fail_reason'
]
:
''
;
if
(
$failReason
&&
$outputCount
<
$failOutputLimit
)
{
$supplierName
=
isset
(
$info
[
'supplier_name'
])
?
$info
[
'supplier_name'
]
:
''
;
$supplierCode
=
isset
(
$info
[
'supplier_code'
])
?
$info
[
'supplier_code'
]
:
''
;
$this
->
warn
(
sprintf
(
' [ID:%d %s] %s - %s'
,
$info
[
'supplier_id'
],
$supplierCode
,
$supplierName
,
$failReason
));
$outputCount
++
;
}
}
if
(
$failCount
>
$failOutputLimit
)
{
$this
->
warn
(
' ... 还有 '
.
(
$failCount
-
$failOutputLimit
)
.
' 条失败记录未显示'
);
}
}
}
return
0
;
return
0
;
}
}
/**
* 输出进度信息
*/
private
function
outputProgress
(
$progress
)
{
$supplierId
=
$progress
[
'supplier_id'
];
$supplierName
=
isset
(
$progress
[
'supplier_name'
])
?
$progress
[
'supplier_name'
]
:
''
;
$action
=
isset
(
$progress
[
'action'
])
?
$progress
[
'action'
]
:
''
;
$status
=
isset
(
$progress
[
'status'
])
?
$progress
[
'status'
]
:
''
;
// 只打印有变更的记录(成功和失败),跳过的不打印
if
(
$status
===
'skip'
)
{
return
;
}
$statusIcon
=
$status
===
'success'
?
'OK'
:
'XX'
;
$statusColor
=
$status
===
'success'
?
'info'
:
'error'
;
$message
=
sprintf
(
' [%s] ID:%d %s - %s'
,
$statusIcon
,
$supplierId
,
$supplierName
,
$action
);
if
(
$statusColor
===
'info'
)
{
$this
->
info
(
$message
);
}
else
{
$this
->
error
(
$message
);
}
}
}
}
app/Http/Services/SupplierService.php
View file @
eb3dc441
...
@@ -1328,8 +1328,6 @@ class SupplierService
...
@@ -1328,8 +1328,6 @@ class SupplierService
'success'
=>
0
,
'success'
=>
0
,
'failed'
=>
0
,
'failed'
=>
0
,
'skipped'
=>
0
,
'skipped'
=>
0
,
'details'
=>
[],
'debug_info'
=>
[],
];
];
foreach
(
$suppliers
as
$supplier
)
{
foreach
(
$suppliers
as
$supplier
)
{
...
@@ -1339,7 +1337,7 @@ class SupplierService
...
@@ -1339,7 +1337,7 @@ class SupplierService
$yunxinChannelUid
=
$supplier
->
yunxin_channel_uid
;
$yunxinChannelUid
=
$supplier
->
yunxin_channel_uid
;
// 检查今天6点后是否有新增联系人,有则跳过
// 检查今天6点后是否有新增联系人,有则跳过
$today6pm
=
strtotime
(
date
(
'Y-m-d'
)
.
' 1
7:3
0:00'
);
$today6pm
=
strtotime
(
date
(
'Y-m-d'
)
.
' 1
8:0
0:00'
);
$hasNewContact
=
SupplierContactModel
::
where
(
'supplier_id'
,
$supplierId
)
$hasNewContact
=
SupplierContactModel
::
where
(
'supplier_id'
,
$supplierId
)
->
where
(
'add_time'
,
'>'
,
$today6pm
)
->
where
(
'add_time'
,
'>'
,
$today6pm
)
->
exists
();
->
exists
();
...
@@ -1360,63 +1358,21 @@ class SupplierService
...
@@ -1360,63 +1358,21 @@ class SupplierService
if
(
strpos
(
$assignResult
[
'reason'
],
'跳过'
)
!==
false
)
{
if
(
strpos
(
$assignResult
[
'reason'
],
'跳过'
)
!==
false
)
{
$result
[
'skipped'
]
++
;
$result
[
'skipped'
]
++
;
echo
"跳过
\n
"
;
echo
"跳过
\n
"
;
$result
[
'debug_info'
][]
=
[
'supplier_id'
=>
$supplierId
,
'supplier_code'
=>
$supplier
->
supplier_code
,
'supplier_name'
=>
$supplier
->
supplier_name
,
'skip_reason'
=>
$assignResult
[
'reason'
],
];
}
else
{
}
else
{
$result
[
'success'
]
++
;
$result
[
'success'
]
++
;
$assignCodeIds
=
isset
(
$assignResult
[
'debug_info'
][
'assign_code_ids'
])
?
$assignResult
[
'debug_info'
][
'assign_code_ids'
]
:
[];
$assignCodeIds
=
isset
(
$assignResult
[
'debug_info'
][
'assign_code_ids'
])
?
$assignResult
[
'debug_info'
][
'assign_code_ids'
]
:
[];
$assignNames
=
array_map
(
function
(
$codeId
)
use
(
$adminUserService
)
{
$assignNames
=
array_map
(
function
(
$codeId
)
use
(
$adminUserService
)
{
return
$adminUserService
->
getAdminUserNameByCodeId
(
$codeId
);
return
$adminUserService
->
getAdminUserNameByCodeId
(
$codeId
);
},
$assignCodeIds
);
},
$assignCodeIds
);
echo
"成功 采购员:"
.
implode
(
','
,
$assignNames
)
.
"
\n
"
;
// 获取需要分配的数量
$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
();
$liexinCount
=
count
(
$needAssignLiexin
);
$followerCount
=
count
(
$needAssignDataFollower
);
// 判断是新增还是补充
$isNew
=
(
$liexinCount
==
count
(
$assignCodeIds
)
&&
$followerCount
==
count
(
$assignCodeIds
));
$action
=
'新增'
.
$liexinCount
.
'个猎芯采购,'
.
$followerCount
.
'个数据跟单员'
;
echo
"成功
{
$action
}
采购员:"
.
implode
(
','
,
$assignNames
)
.
"
\n
"
;
$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
,
];
}
}
}
else
{
}
else
{
$result
[
'failed'
]
++
;
$result
[
'failed'
]
++
;
echo
"失败:
{
$assignResult
[
'reason'
]
}
\n
"
;
echo
"失败:
{
$assignResult
[
'reason'
]
}
\n
"
;
$result
[
'debug_info'
][]
=
[
'supplier_id'
=>
$supplierId
,
'supplier_code'
=>
$supplier
->
supplier_code
,
'supplier_name'
=>
$supplier
->
supplier_name
,
'fail_reason'
=>
$assignResult
[
'reason'
],
];
}
}
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
$result
[
'failed'
]
++
;
$result
[
'failed'
]
++
;
echo
"异常: "
.
$e
->
getMessage
()
.
"
\n
"
;
echo
"异常: "
.
$e
->
getMessage
()
.
"
\n
"
;
$result
[
'debug_info'
][]
=
[
'supplier_id'
=>
isset
(
$supplierId
)
?
$supplierId
:
0
,
'supplier_code'
=>
isset
(
$supplier
->
supplier_code
)
?
$supplier
->
supplier_code
:
''
,
'supplier_name'
=>
isset
(
$supplier
->
supplier_name
)
?
$supplier
->
supplier_name
:
''
,
'fail_reason'
=>
'异常: '
.
$e
->
getMessage
(),
];
}
}
}
}
...
...
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