fix: 补齐财务代传入口与标准模板解析
This commit is contained in:
parent
8856b6b51c
commit
2b896f2176
@ -490,7 +490,9 @@ final class CourierBillStore
|
||||
$db->table('courier_bill_lines')->where('file_id', $fileId)->delete();
|
||||
}
|
||||
$db->table('courier_bill_surcharges')->where('file_id', $fileId)->delete();
|
||||
$overrides = ['waybill_header' => $group->waybill_header, 'amount_header' => $group->amount_header, 'weight_header' => $group->weight_header];
|
||||
$overrides = $portal
|
||||
? ['waybill_header' => '单号', 'amount_header' => '运费', 'weight_header' => '重量']
|
||||
: ['waybill_header' => $group->waybill_header, 'amount_header' => $group->amount_header, 'weight_header' => $group->weight_header];
|
||||
foreach ($this->parser->parse($path, $extension, $overrides) as $item) {
|
||||
if ($item['type'] === 'sheet') {
|
||||
$sheets[] = isset($item['skipped'])
|
||||
|
||||
@ -37,6 +37,19 @@ final class PortalFreightBills
|
||||
}
|
||||
}
|
||||
|
||||
/** 财务代传入口包含尚未上传货款对账单的代发厂家与快递。 */
|
||||
public function names(): array
|
||||
{
|
||||
try {
|
||||
return array_values(array_unique([
|
||||
...array_map(static fn ($f) => (string) $f->name, $this->dropship->factories()),
|
||||
...array_map(static fn ($g) => (string) $g->name, $this->courier->groups()),
|
||||
]));
|
||||
} catch (Throwable) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 钉钉组织里能认作「快递」的部门名:快递对账分组名和小汇总承运商名。
|
||||
*
|
||||
|
||||
13
docs/厂家门户运费账单上传.md
Normal file
13
docs/厂家门户运费账单上传.md
Normal file
@ -0,0 +1,13 @@
|
||||
# 厂家门户上传运费账单
|
||||
|
||||
厂家和快递通过原有钉钉入口进入门户,下载统一模板后提交账单。账号仅能给绑定的厂家或快递上传。财务账号沿用原页面权限,可为选定对象代传。
|
||||
|
||||
模板第一行依次为:单号、省、重量、运费、送货备注、面单、费率。仅一张可见账单表,单号及运费必填;单号须完整,数字列须为有效数字。支持 XLSX、XLS、CSV,单份最多50MB、100,000行;XLS沿用现有读取器20MB限制。
|
||||
|
||||
网页只保存文件并显示等待处理。服务器每分钟通过现有独立批容器执行 `portal-freight:import-pending`,每次处理一份。使用共享同步锁,1 CPU、1GiB容器内存、PHP512MiB和一小时上限。无待办时不启动容器。校验失败在上传记录显示原因;进程中断不自动重导,下一次标记失败,财务核对已有记录后再决定重传。
|
||||
|
||||
后台继续使用现有代发/快递账单读取与对账规则,重复上传、已结算月份等限制仍生效。门户快递上传不会通过文件名或合并分组设置扩大目标范围。成功回执使用实际读入行数和金额;未配置群机器人时不发送。
|
||||
|
||||
不新增数据库表。任务文件沿用私有共享storage目录,原账单由现有账单存储流程留存。页面仅查当前对象的近期任务及最近10份已读入账单。
|
||||
|
||||
验证需包含:两类门户上传、未授权对象拒绝、停用账号拒绝、模板错误、多表拒绝、后台隔离、重复导入和原有对账回归。性能基准以线上已有约7,500行账单为参照,使用10,000行合成账单在隔离环境测量,不向真实厂家群发送测试消息。
|
||||
@ -331,6 +331,9 @@ class SupplierReconciliationPageData
|
||||
) as $name) {
|
||||
$suppliers[$name] = true;
|
||||
}
|
||||
foreach (app(\App\Support\CourierBills\PortalFreightBills::class)->names() as $name) {
|
||||
$suppliers[$name] = true;
|
||||
}
|
||||
$supplierNames = array_keys($suppliers);
|
||||
sort($supplierNames);
|
||||
|
||||
|
||||
@ -6,9 +6,9 @@
|
||||
$defaultMonth = $accountingMonthKey ?? now()->startOfMonth()->subMonth()->format('Y-m');
|
||||
@endphp
|
||||
<style>
|
||||
.fb-panel { margin: 12px 0; padding: 14px 16px; border: 1px solid #ded7c9; border-radius: 10px; background: #fff; }
|
||||
.fb-panel h3 { margin: 0 0 4px; font-size: 15px; font-weight: 700; }
|
||||
.fb-panel p { margin: 0 0 10px; color: #686053; font-size: 12px; line-height: 1.6; }
|
||||
.fb-panel { margin: 12px 0; padding: 16px; border: 1px solid #d8d2c7; border-radius: 12px; background: #fff; }
|
||||
.fb-panel h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
|
||||
.fb-panel p { margin: 0 0 10px; color: #595959; font-size: 12px; line-height: 1.6; }
|
||||
.fb-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
|
||||
.fb-form label { display: grid; gap: 4px; font-size: 12px; color: #5c5548; }
|
||||
.fb-form select, .fb-form input[type=month], .fb-form input[type=file] { min-height: 34px; padding: 4px 8px; border: 1px solid #d8d2c7; border-radius: 8px; background: #fff; }
|
||||
|
||||
@ -140,7 +140,7 @@ final class PortalFreightBillTest extends FeatureTestCase
|
||||
{
|
||||
Storage::fake('local');
|
||||
$db = CourierBillMatcher::db();
|
||||
$a = $db->table('courier_bill_groups')->insertGetId(['name' => '本家快递', 'express_names' => '["本家快递"]', 'bundle' => '同一合并账单', 'created_at' => now(), 'updated_at' => now()]);
|
||||
$a = $db->table('courier_bill_groups')->insertGetId(['name' => '本家快递', 'express_names' => '["本家快递"]', 'bundle' => '同一合并账单', 'waybill_header' => '旧单号列', 'amount_header' => '旧金额列', 'weight_header' => '旧重量列', 'created_at' => now(), 'updated_at' => now()]);
|
||||
$b = $db->table('courier_bill_groups')->insertGetId(['name' => '另一家快递', 'express_names' => '["另一家快递"]', 'bundle' => '同一合并账单', 'created_at' => now(), 'updated_at' => now()]);
|
||||
$db->table('jst_oms_shipping')->insert(['source_id' => 888001, 'sku_source_id' => 1, 'express_no' => 'SF12345678', 'express_name1' => '另一家快递', 'ship_time' => '2026-11-10']);
|
||||
$file = new UploadedFile($this->xlsx([self::H, ['SF12345678', '江苏', 1, 8]]), '本家快递与另一家快递.xlsx', null, null, true);
|
||||
@ -150,6 +150,15 @@ final class PortalFreightBillTest extends FeatureTestCase
|
||||
$this->assertNull($db->table('courier_bill_files')->find($id)->extra_group_ids);
|
||||
}
|
||||
|
||||
public function test_finance_can_choose_a_courier_without_supplier_statements(): void
|
||||
{
|
||||
$db = CourierBillMatcher::db();
|
||||
$db->table('courier_bill_groups')->insert(['name' => '测试财务快递', 'express_names' => '[]', 'created_at' => now(), 'updated_at' => now()]);
|
||||
$this->user->attachPermission(Permission::where('name', 'read-admin-panel')->firstOrFail());
|
||||
$this->loginAs()->get(route('business.pages.show', ['section' => 'supplier-reconciliation', 'page' => 'supplier-data', 'supplier' => '测试财务快递']))
|
||||
->assertOk()->assertSeeText('上传运费账单')->assertSeeText('快递账单');
|
||||
}
|
||||
|
||||
public function test_courier_department_in_dingtalk_resolves_to_a_portal_binding(): void
|
||||
{
|
||||
CourierBillMatcher::db()->table('courier_bill_groups')->insert(['name' => '曹县韵达小件', 'summary_carrier' => '曹县韵达',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user