Files
fdesk/app/common/controller/FinPaymentApplyController.php
T

124 lines
5.3 KiB
PHP
Raw Normal View History

2025-09-23 15:13:56 +08:00
<?php
2025-09-23 16:45:06 +08:00
2025-09-23 15:13:56 +08:00
namespace app\common\controller;
use app\common\controller\BaseController;
2025-09-23 16:45:06 +08:00
use app\common\model\Country;
2025-09-23 18:26:17 +08:00
use app\common\model\FinPaymentStock;
2025-09-23 16:45:06 +08:00
use app\common\model\SysAccount;
use app\common\model\SysCurrency;
use app\common\model\SysDictItem;
use app\common\model\User;
2025-09-24 15:23:47 +08:00
use app\common\service\OssService;
2025-09-23 15:13:56 +08:00
use app\common\traits\crud\CrudControllerTrait;
use app\common\service\FinPaymentApplyService;
class FinPaymentApplyController extends BaseController
{
use CrudControllerTrait;
protected $service;
public function __construct()
{
$this->service = new FinPaymentApplyService();
}
/**
* 列表页数据格式化
*
* @param array $data
* @return array
*/
2025-09-23 16:45:06 +08:00
protected function indexFormat($data)
{
if (isset($data['doc_user_id'])) //内勤
2025-09-28 10:10:15 +08:00
$data['doc_user_name'] = User::where('id', $data['doc_user_id'])->value('name')??'';
2025-09-23 16:45:06 +08:00
if (isset($data['sales_user_id'])) //业务员
2025-09-28 10:10:15 +08:00
$data['sales_user_name'] = User::where('id', $data['doc_user_id'])->value('name')??'';
2025-09-23 16:45:06 +08:00
if (isset($data['corp_id'])) //公司(渠道)
2025-09-28 09:47:09 +08:00
$data['corp_name'] = SysDictItem::where('id', $data['corp_id'])->value('item_label')??'';
2025-10-09 10:24:13 +08:00
if (isset($data['account_id'])){ //收款账号
2025-09-28 09:47:09 +08:00
$data['account_name'] = SysAccount::where('id', $data['account_id'])->value('account_name')??'';
2025-10-09 10:24:13 +08:00
$data['account_short_desc'] = SysAccount::where('id', $data['account_id'])->value('short_desc')??'';
}
2025-09-23 16:45:06 +08:00
if (isset($data['country_id'])) //付款来源国家
2025-09-28 09:47:09 +08:00
$data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr')??'';
2025-09-23 16:45:06 +08:00
if (isset($data['currency_id'])) //付款币种
2025-09-28 09:47:09 +08:00
$data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name')??'';
2025-09-24 15:23:47 +08:00
$OssService = new OssService();
if (isset($data['submit_files'])){
2025-09-23 16:45:06 +08:00
$data['submit_files'] = json_decode($data['submit_files'], true);
2025-09-24 15:23:47 +08:00
foreach ($data['submit_files'] as $key => $value) {
$data['submit_files'][$key] = [
'file_src' => $value['file_src'],
'file_full' => $OssService->generatePrivateUrl($value['file_src']),
'file_name' => $value['file_name'],
];
}
}
2025-09-28 09:56:01 +08:00
if (!empty($data['voucher_file'])) {
2025-09-24 15:23:47 +08:00
$data['voucher_file_full'] = $OssService->generatePrivateUrl($data['voucher_file']);
2025-09-28 09:56:01 +08:00
} elseif (isset($data['voucher_file'])) {
$data['voucher_file_full'] = '';
}
2025-09-23 16:45:06 +08:00
if (isset($data['created_at']))
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
if (isset($data['updated_at']))
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
return $data;
}
/**
* 数据格式化
*
* @param array $data
* @return array
*/
2025-10-23 11:27:24 +08:00
public function showFormat($data)
2025-09-23 16:45:06 +08:00
{
if (isset($data['doc_user_id'])) //内勤
2025-09-28 10:10:15 +08:00
$data['doc_user_name'] = User::where('id', $data['doc_user_id'])->value('name')??'';
2025-09-23 16:45:06 +08:00
if (isset($data['sales_user_id'])) //业务员
2025-09-28 10:10:15 +08:00
$data['sales_user_name'] = User::where('id', $data['doc_user_id'])->value('name')??'';
2025-09-23 16:45:06 +08:00
if (isset($data['corp_id'])) //公司(渠道)
2025-09-28 09:47:09 +08:00
$data['corp_name'] = SysDictItem::where('id', $data['corp_id'])->value('item_label')??'';
2025-10-09 10:16:21 +08:00
if (isset($data['account_id'])){ //收款账号
2025-09-28 09:47:09 +08:00
$data['account_name'] = SysAccount::where('id', $data['account_id'])->value('account_name')??'';
2025-10-09 10:16:21 +08:00
$data['account_short_desc'] = SysAccount::where('id', $data['account_id'])->value('short_desc')??'';
}
2025-09-23 16:45:06 +08:00
if (isset($data['country_id'])) //付款来源国家
2025-09-28 09:47:09 +08:00
$data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr')??'';
2025-09-23 16:45:06 +08:00
if (isset($data['currency_id'])) //付款币种
2025-09-28 09:47:09 +08:00
$data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name')??'';
$OssService = new OssService();
if (isset($data['submit_files'])){
2025-09-23 16:45:06 +08:00
$data['submit_files'] = json_decode($data['submit_files'], true);
2025-09-28 09:47:09 +08:00
foreach ($data['submit_files'] as $key => $value) {
$data['submit_files'][$key] = [
'file_src' => $value['file_src'],
'file_full' => $OssService->generatePrivateUrl($value['file_src']),
'file_name' => $value['file_name'],
];
}
}
2025-09-28 09:56:01 +08:00
if (!empty($data['voucher_file'])) {
2025-09-28 09:47:09 +08:00
$data['voucher_file_full'] = $OssService->generatePrivateUrl($data['voucher_file']);
2025-09-28 09:56:01 +08:00
} elseif (isset($data['voucher_file'])) {
$data['voucher_file_full'] = '';
}
2025-09-23 16:45:06 +08:00
if (isset($data['created_at']))
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
if (isset($data['updated_at']))
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
2025-09-23 18:26:17 +08:00
$finPaymentStock = FinPaymentStock::where('payment_apply_id', $data['id'])->get();
$stock = [];
foreach ($finPaymentStock as $v) {
2025-10-09 10:16:21 +08:00
$stock[$v['pi_no']]['pi_no'] = $v['pi_no'];
$stock[$v['pi_no']]['stock_id'][] = [$v['stock_id']];
2025-09-23 18:26:17 +08:00
}
2025-09-23 18:30:13 +08:00
$data['stock'] = array_values($stock);
2025-09-23 16:45:06 +08:00
return $data;
}
2025-09-23 15:13:56 +08:00
}