- 报销佣金人员改为工作台维护(新增 / 移除 / 追加导入 / 导出),首次读取时自动导入以前上传的历史名单 - 去掉「去聚工单人工核对、勾选已核对」:改为放行检查(聚工单 20 分钟内同步过、额度已校验、 规则不为空、自检全过、有可报销单),不通过不许导出 / 发通知 / 提交,并在页面列出原因 - 每天 11:20 汇总任务放行检查通过后自动发不予报销通知(@ 发起人,同一批不重发) - 一键提交钉钉「种菜报销流程」(PROC-C5159B8D…):发起人李斯(按钉钉花名册查 userId), 按钉钉表单实际结构自动填(收款费用明细 / 收款合计 / 收款人·开户行·账号=账号详见附件 / 付款明细 / 报销类型=种菜核销),打款明细 xlsx 上传审批钉盘作附件;先可预览, 缺必填 / 选项不匹配不许提交;同一账单日只提交一次,结果不确定记待核查 - 新配置 config/planting_reimbursement.php(凭据默认沿用快递入驻的财务系统钉钉应用, 需补 PLANTING_DINGTALK_AGENT_ID) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNTa9ohkCsVFACqjz3KMcG
53 lines
2.4 KiB
PHP
53 lines
2.4 KiB
PHP
<?php
|
||
|
||
namespace Modules\EcommerceFinance\Services;
|
||
|
||
use Illuminate\Support\Carbon;
|
||
|
||
/**
|
||
* 种菜报销批次放行检查(2026-12-01 起替代「去聚工单人工核对条数和金额、勾选已核对」):
|
||
* 导出、发群通知、提交钉钉流程前,以下全部满足才放行;不满足时给出原因。
|
||
* - 聚工单镜像最近 20 分钟内同步成功(数据是最新的);
|
||
* - 种菜额度已校验(经营分析副本库可用);
|
||
* - 额度规则不为空;
|
||
* - 金额与条数自检全部通过;
|
||
* - 本批有可报销的工单(导出 / 提交时)。
|
||
* 纯计算类。
|
||
*/
|
||
final class PlantingReimbursementGate
|
||
{
|
||
public const STALE_MINUTES = 20;
|
||
|
||
/**
|
||
* @param array<string,mixed> $result PlantingReimbursementWorkbench::build() 的结果
|
||
* @return array{ok:bool,reasons:list<string>}
|
||
*/
|
||
public static function check(array $result, bool $requirePass = true, ?Carbon $now = null): array
|
||
{
|
||
$now ??= now();
|
||
$reasons = [];
|
||
$sync = $result['sync'] ?? ['code' => 'unavailable', 'last_succeeded_at' => null];
|
||
$last = $sync['last_succeeded_at'] ?? null;
|
||
if (($sync['code'] ?? '') !== 'ready' || $last === null) {
|
||
$reasons[] = '聚工单数据同步异常(最后成功:' . ($last ? substr((string) $last, 0, 16) : '无') . ')';
|
||
} elseif ($now->diffInMinutes(Carbon::parse((string) $last), true) > self::STALE_MINUTES) {
|
||
$reasons[] = '聚工单数据超过 ' . self::STALE_MINUTES . ' 分钟没同步(最后成功:' . substr((string) $last, 0, 16) . ')';
|
||
}
|
||
if (trim((string) ($result['quota_error'] ?? '')) !== '') {
|
||
$reasons[] = '种菜额度没有校验(' . $result['quota_error'] . ')';
|
||
}
|
||
if (($result['quota_rules']['count'] ?? 1) === 0) {
|
||
$reasons[] = '没有种菜额度规则';
|
||
}
|
||
$failed = array_column(array_filter($result['summary']['checks'] ?? [], static fn (array $check): bool => ! $check['ok']), 'label');
|
||
if ($failed !== []) {
|
||
$reasons[] = '自检未通过:' . implode('、', $failed);
|
||
}
|
||
if ($requirePass && (int) ($result['summary']['counts'][PlantingReimbursementAuditor::DECISION_PASS] ?? 0) === 0) {
|
||
$reasons[] = '本批没有可报销的工单';
|
||
}
|
||
|
||
return ['ok' => $reasons === [], 'reasons' => $reasons];
|
||
}
|
||
}
|