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
80ad46f6
authored
Mar 02, 2026
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'yxs-新建供应商默认数据跟单员规则-20260304'
parents
3bff4201
53b7e656
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
3 deletions
app/Console/Commands/RefreshHistoryPurchaseUser.php
app/Http/Controllers/Api/SupplierApiController.php
app/Http/Services/SupplierService.php
app/Console/Commands/RefreshHistoryPurchaseUser.php
0 → 100644
View file @
80ad46f6
<?php
namespace
App\Console\Commands
;
use
App\Http\Services\SupplierService
;
use
Illuminate\Console\Command
;
// 刷新历史数据:自动分配猎芯采购和数据跟单员
class
RefreshHistoryPurchaseUser
extends
Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected
$signature
=
'refresh:history_purchase_user {--mode=prod : 运行模式(prod=生产模式执行更新,debug=调试模式仅打印)} {--num=0 : 处理数量限制(0=不限制)}'
;
/**
* The console command description.
*
* @var string
*/
protected
$description
=
'刷新历史数据:自动分配猎芯采购和数据跟单员'
;
/**
* Execute the console command.
*
* @return mixed
*/
public
function
handle
()
{
$mode
=
$this
->
option
(
'mode'
);
$num
=
(
int
)
$this
->
option
(
'num'
);
$isProdMode
=
(
$mode
===
'prod'
);
$this
->
info
(
'========================================'
);
$this
->
info
(
'开始刷新历史数据'
);
$this
->
info
(
'模式: '
.
(
$isProdMode
?
'生产模式(执行更新)'
:
'调试模式(仅打印)'
));
$this
->
info
(
'处理数量: '
.
(
$num
>
0
?
$num
:
'不限制'
));
$this
->
info
(
'========================================'
);
// 调用服务方法
$result
=
SupplierService
::
refreshHistoryPurchaseUserWithProgress
(
$mode
,
$num
,
function
(
$progress
)
{
$this
->
outputProgress
(
$progress
);
});
// 输出最终结果
$this
->
info
(
''
);
$this
->
info
(
'========================================'
);
$this
->
info
(
'处理完成'
);
$this
->
info
(
'总计: '
.
$result
[
'total'
]);
$this
->
info
(
'成功: '
.
$result
[
'success'
]);
$this
->
info
(
'失败: '
.
$result
[
'failed'
]);
$this
->
info
(
'跳过: '
.
$result
[
'skipped'
]);
$this
->
info
(
'========================================'
);
// 如果有失败记录,打印详情
if
(
!
empty
(
$result
[
'debug_info'
]))
{
$this
->
info
(
''
);
$this
->
warn
(
'失败/跳过详情:'
);
foreach
(
$result
[
'debug_info'
]
as
$info
)
{
$this
->
warn
(
sprintf
(
' [ID:%d] %s - %s'
,
$info
[
'supplier_id'
],
$info
[
'supplier_name'
]
??
''
,
$info
[
'fail_reason'
]
??
$info
[
'skip_reason'
]
??
''
));
}
}
return
0
;
}
/**
* 输出进度信息
*/
private
function
outputProgress
(
$progress
)
{
$supplierId
=
$progress
[
'supplier_id'
];
$supplierName
=
$progress
[
'supplier_name'
];
$action
=
$progress
[
'action'
]
??
''
;
$status
=
$progress
[
'status'
]
??
''
;
$statusIcon
=
$status
===
'success'
?
'✓'
:
(
$status
===
'skip'
?
'-'
:
'✗'
);
$statusColor
=
$status
===
'success'
?
'info'
:
(
$status
===
'skip'
?
'comment'
:
'error'
);
$this
->
$statusColor
(
sprintf
(
' [%s] ID:%d %s - %s'
,
$statusIcon
,
$supplierId
,
$supplierName
,
$action
));
}
}
app/Http/Controllers/Api/SupplierApiController.php
View file @
80ad46f6
...
@@ -886,10 +886,10 @@ class SupplierApiController extends Controller
...
@@ -886,10 +886,10 @@ class SupplierApiController extends Controller
//刷新历史数据:自动分配猎芯采购和数据跟单员
//刷新历史数据:自动分配猎芯采购和数据跟单员
public
function
RefreshHistoryPurchaseUser
(
$request
)
public
function
RefreshHistoryPurchaseUser
(
$request
)
{
{
$
updateData
=
$request
->
get
(
'update_data'
,
false
);
$
mode
=
$request
->
get
(
'mode'
,
'debug'
);
// prod=生产模式执行数据处理,其他=调试模式
$
limit
=
$request
->
get
(
'limit'
,
100
);
$
num
=
$request
->
get
(
'num'
,
50
);
// 处理数量限制
$result
=
SupplierService
::
refreshHistoryPurchaseUser
(
$
updateData
,
$limit
);
$result
=
SupplierService
::
refreshHistoryPurchaseUser
(
$
mode
,
$num
);
$this
->
response
(
0
,
'刷新完成'
,
$result
);
$this
->
response
(
0
,
'刷新完成'
,
$result
);
}
}
...
...
app/Http/Services/SupplierService.php
View file @
80ad46f6
This diff is collapsed.
Click to expand it.
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