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

99 lines
4.0 KiB
PHP
Raw Normal View History

2025-09-23 15:13:56 +08:00
<?php
namespace app\common\controller;
use app\common\controller\BaseController;
2025-09-23 17:33:09 +08:00
use app\common\model\Country;
2025-10-23 11:27:24 +08:00
use app\common\model\FinPaymentApply;
use app\common\model\FinPaymentStock;
2025-09-23 17:33:09 +08:00
use app\common\model\SysAccount;
use app\common\model\SysCurrency;
2025-10-23 11:27:24 +08:00
use app\common\model\SysDictItem;
use app\common\model\User;
2025-09-24 17:49:14 +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\FinReceiptService;
class FinReceiptController extends BaseController
{
use CrudControllerTrait;
protected $service;
public function __construct()
{
$this->service = new FinReceiptService();
}
/**
* 列表页数据格式化
*
* @param array $data
* @return array
*/
protected function indexFormat($data)
{
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']);
if (isset($data['arrived_at']))
$data['arrived_at'] = date('Y-m-d H:i:s', $data['arrived_at']);
if (isset($data['received_at']))
$data['received_at'] = date('Y-m-d H:i:s', $data['received_at']);
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 17:33:09 +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 17:33:09 +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-28 09:56:01 +08:00
if (!empty($data['fx_receipt_file'])){
2025-09-24 17:49:14 +08:00
$data['fx_receipt_file_full'] = (new OssService)->generatePrivateUrl($data['fx_receipt_file']);
2025-09-28 09:56:01 +08:00
}elseif (isset($data['fx_receipt_file'])){
$data['fx_receipt_file_full'] = '';
}
2025-09-23 15:13:56 +08:00
return $data;
}
/**
* 数据格式化
*
* @param array $data
* @return array
*/
protected function showFormat($data)
{
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']);
if (isset($data['arrived_at']))
$data['arrived_at'] = date('Y-m-d H:i:s', $data['arrived_at']);
if (isset($data['received_at']))
$data['received_at'] = date('Y-m-d H:i:s', $data['received_at']);
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 17:33:09 +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 17:33:09 +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-28 09:56:01 +08:00
if (!empty($data['fx_receipt_file'])) {
2025-09-24 17:49:14 +08:00
$data['fx_receipt_file_full'] = (new OssService)->generatePrivateUrl($data['fx_receipt_file']);
2025-09-28 09:56:01 +08:00
} elseif (isset($data['fx_receipt_file'])) {
$data['fx_receipt_file_full'] = '';
}
2025-10-23 11:27:24 +08:00
if (!empty($data['payment_apply_id'])) {
2025-10-23 16:25:02 +08:00
$paymentApply = FinPaymentApply::where('id', $data['payment_apply_id'])->first();
if(!$paymentApply)
return $data;
$paymentApply = $paymentApply->toArray();
2025-10-23 11:27:24 +08:00
$paymentApply = (new FinPaymentApplyController())->showFormat($paymentApply);
$data['payment_apply'] = $paymentApply;
}
2025-09-23 15:13:56 +08:00
return $data;
}
}