181 lines
7.3 KiB
PHP
181 lines
7.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace app\common\controller;
|
||
|
|
|
||
|
|
use app\common\controller\BaseController;
|
||
|
|
use app\common\model\Country;
|
||
|
|
use app\common\model\FinPaymentStock;
|
||
|
|
use app\common\model\StockOrders;
|
||
|
|
use app\common\model\SysAccount;
|
||
|
|
use app\common\model\SysCurrency;
|
||
|
|
use app\common\model\SysDictItem;
|
||
|
|
use app\common\model\User;
|
||
|
|
use app\common\service\OssService;
|
||
|
|
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
|
||
|
|
*/
|
||
|
|
protected function indexFormat($data)
|
||
|
|
{
|
||
|
|
if (isset($data['doc_user_id'])) //内勤
|
||
|
|
$data['doc_user_name'] = User::where('id', $data['doc_user_id'])->value('name')??'';
|
||
|
|
if (isset($data['sales_user_id'])) //业务员
|
||
|
|
$data['sales_user_name'] = User::where('id', $data['doc_user_id'])->value('name')??'';
|
||
|
|
if (isset($data['corp_id'])) //公司(渠道)
|
||
|
|
$data['corp_name'] = SysDictItem::where('id', $data['corp_id'])->value('item_label')??'';
|
||
|
|
if (isset($data['account_id'])){ //收款账号
|
||
|
|
$data['account_name'] = SysAccount::where('id', $data['account_id'])->value('account_name')??'';
|
||
|
|
$data['account_short_desc'] = SysAccount::where('id', $data['account_id'])->value('short_desc')??'';
|
||
|
|
}
|
||
|
|
if (isset($data['country_id'])) //付款来源国家
|
||
|
|
$data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr')??'';
|
||
|
|
if (isset($data['currency_id'])) //付款币种
|
||
|
|
$data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name')??'';
|
||
|
|
$OssService = new OssService();
|
||
|
|
if (!empty($data['submit_files'])){
|
||
|
|
$data['submit_files'] = json_decode($data['submit_files'], true);
|
||
|
|
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'],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}else{
|
||
|
|
$data['submit_files'] = [];
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!empty($data['voucher_file'])){
|
||
|
|
$data['voucher_file'] = json_decode($data['voucher_file'], true);
|
||
|
|
foreach ($data['voucher_file'] as $key => $value) {
|
||
|
|
$data['voucher_file'][$key] = [
|
||
|
|
'file_src' => $value['file_src'],
|
||
|
|
'file_full' => $OssService->generatePrivateUrl($value['file_src']),
|
||
|
|
'file_name' => $value['file_name'],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}else{
|
||
|
|
$data['voucher_file'] = [];
|
||
|
|
}
|
||
|
|
|
||
|
|
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['claimed_at'])){
|
||
|
|
$data['enter_file_last'] = date('Y-m-d H:i:s', ($data['claimed_at']+86400)); //入账资料最后提交时间
|
||
|
|
$data['claimed_at'] = date('Y-m-d H:i:s', $data['claimed_at']); //认领时间
|
||
|
|
}
|
||
|
|
if (isset($data['id'])){
|
||
|
|
$finPaymentStock = FinPaymentStock::where('payment_apply_id', $data['id'])->get();
|
||
|
|
$stock = [];
|
||
|
|
$stock_order_no = [];
|
||
|
|
foreach ($finPaymentStock as $v) {
|
||
|
|
$stock[$v['pi_no']]['pi_no'] = $v['pi_no'];
|
||
|
|
$stock[$v['pi_no']]['stock_id'][] = [$v['stock_id']];
|
||
|
|
$stockOrders = StockOrders::where('id', $v['stock_id'])->first();
|
||
|
|
$stock_order_no[] = $stockOrders['order_no'];
|
||
|
|
}
|
||
|
|
$data['stock'] = array_values($stock);
|
||
|
|
$data['stock_order_no'] = $stock_order_no;
|
||
|
|
}
|
||
|
|
|
||
|
|
return $data;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 数据格式化
|
||
|
|
*
|
||
|
|
* @param array $data
|
||
|
|
* @return array
|
||
|
|
*/
|
||
|
|
public function showFormat($data)
|
||
|
|
{
|
||
|
|
if (isset($data['doc_user_id'])) //内勤
|
||
|
|
$data['doc_user_name'] = User::where('id', $data['doc_user_id'])->value('name')??'';
|
||
|
|
if (isset($data['sales_user_id'])) //业务员
|
||
|
|
$data['sales_user_name'] = User::where('id', $data['doc_user_id'])->value('name')??'';
|
||
|
|
if (isset($data['corp_id'])) //公司(渠道)
|
||
|
|
$data['corp_name'] = SysDictItem::where('id', $data['corp_id'])->value('item_label')??'';
|
||
|
|
if (isset($data['account_id'])){ //收款账号
|
||
|
|
$data['account_name'] = SysAccount::where('id', $data['account_id'])->value('account_name')??'';
|
||
|
|
$data['account_short_desc'] = SysAccount::where('id', $data['account_id'])->value('short_desc')??'';
|
||
|
|
}
|
||
|
|
if (isset($data['country_id'])) //付款来源国家
|
||
|
|
$data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr')??'';
|
||
|
|
if (isset($data['currency_id'])) //付款币种
|
||
|
|
$data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name')??'';
|
||
|
|
$OssService = new OssService();
|
||
|
|
if (!empty($data['submit_files'])){
|
||
|
|
$data['submit_files'] = json_decode($data['submit_files'], true);
|
||
|
|
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'],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}else{
|
||
|
|
$data['submit_files'] = [];
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!empty($data['voucher_file'])){
|
||
|
|
$data['voucher_file'] = json_decode($data['voucher_file'], true);
|
||
|
|
foreach ($data['voucher_file'] as $key => $value) {
|
||
|
|
$data['voucher_file'][$key] = [
|
||
|
|
'file_src' => $value['file_src'],
|
||
|
|
'file_full' => $OssService->generatePrivateUrl($value['file_src']),
|
||
|
|
'file_name' => $value['file_name'],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}else{
|
||
|
|
$data['voucher_file'] = [];
|
||
|
|
}
|
||
|
|
|
||
|
|
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']);
|
||
|
|
|
||
|
|
$finPaymentStock = FinPaymentStock::where('payment_apply_id', $data['id'])->get();
|
||
|
|
$stock = [];
|
||
|
|
foreach ($finPaymentStock as $v) {
|
||
|
|
$stock[$v['pi_no']]['pi_no'] = $v['pi_no'];
|
||
|
|
$stock[$v['pi_no']]['stock_id'][] = [$v['stock_id']];
|
||
|
|
}
|
||
|
|
$data['stock'] = array_values($stock);
|
||
|
|
return $data;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 作废
|
||
|
|
* @param Request $request
|
||
|
|
* @return \support\Response
|
||
|
|
*/
|
||
|
|
public function delete(Request $request)
|
||
|
|
{
|
||
|
|
try {
|
||
|
|
$id = $request->input('id');
|
||
|
|
$raw = $this->service->delete($id);
|
||
|
|
return $this->success($raw);
|
||
|
|
} catch (\Throwable $e) {
|
||
|
|
return $this->error($e->getMessage());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|