Files
OMS/app/financebase/lib/expenses/split/import.php
chenping 61783b7d01 1. 【新增】售后单售后原因类型支持搜索
2. 【新增】手工创建订单折扣可输入正数

3. 【优化】盘点申请单确认

4. 【修复】采购退货单模拟出库失败问题

5. 【新增】订单金额客户实付与结算金额

6. 【优化】仓库发货统计报表物料名称显示

7. 【优化】自有仓储虚拟发货逻辑

8. 【修复】基础物料分类管理问题
2026-04-01 11:59:17 +08:00

69 lines
2.4 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
class financebase_expenses_split_import {
const IMPORT_TITLE = [
'拆分单号' => 'split_bn',
'是否已记账' => 'is_accounted',
];
public function getExcelTitle()
{
return ['费用拆分记账导入模板.xlsx',[
array_keys(self::IMPORT_TITLE)
]];
}
/**
* 处理Excel导入行数据
*
* @param string $import_file 导入文件路径
* @param array $post 提交参数
* @return array
* @author
**/
public function processExcelRow($import_file, $post)
{
$format = [];
// 读取文件
return kernel::single('omecsv_phpoffice')->import($import_file, function ($line, $buffer, $post, $highestRow) {
static $title;
if ($line == 1) {
$title = $buffer;
// 验证模板是否正确
if (array_filter($title) != array_keys(self::IMPORT_TITLE)) {
return [false, '导入模板不正确'];
}
return [true];
}
// 将Excel行数据转换为关联数组
$buffer = array_combine(self::IMPORT_TITLE, array_slice($buffer, 0, count(self::IMPORT_TITLE)));
if (empty($buffer['is_accounted'])) {
return [false, '“是否已记账”字段不能为空'];
}
if (empty($buffer['split_bn'])) {
return [false, '“拆分单号”字段不能为空'];
}
$buffer['is_accounted'] = $buffer['is_accounted'] == '是' ? '1' : '0';
$expensesSplitModel = app::get('financebase')->model('expenses_split');
$existRow = $expensesSplitModel->db_dump(['split_bn' => $buffer['split_bn']], 'id');
if (!$existRow) {
return [false, '拆分单号不存在:' . $buffer['split_bn']];
}
$updateData = [
'is_accounted' => $buffer['is_accounted'],
];
// 如果已记账,记录记账时间
if ($buffer['is_accounted'] == '1') {
$updateData['accounted_time'] = time();
} else {
// 如果未记账将记账时间设置为0
$updateData['accounted_time'] = 0;
}
$expensesSplitModel->update($updateData, ['id' => $existRow['id']]);
return [true];
}, $post, $format);
}
}