付款申请查询相关字段名

This commit is contained in:
2025-09-23 16:45:06 +08:00
parent 4717bb01ca
commit e6d3cc3f04
4 changed files with 89 additions and 12 deletions
@@ -1,7 +1,13 @@
<?php
namespace app\common\controller;
use app\common\controller\BaseController;
use app\common\model\Country;
use app\common\model\SysAccount;
use app\common\model\SysCurrency;
use app\common\model\SysDictItem;
use app\common\model\User;
use app\common\traits\crud\CrudControllerTrait;
use app\common\service\FinPaymentApplyService;
@@ -22,12 +28,55 @@ class FinPaymentApplyController extends BaseController
* @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']);
// return $data;
// }
protected function indexFormat($data)
{
if (isset($data['doc_user_id'])) //内勤
$data['doc_user_name'] = User::where('id', $data['doc_user_id'])->first()->name;
if (isset($data['sales_user_id'])) //业务员
$data['sales_user_name'] = User::where('id', $data['doc_user_id'])->first()->name;
if (isset($data['corp_id'])) //公司(渠道)
$data['corp_name'] = SysDictItem::where('id', $data['corp_id'])->first()->item_label;
if (isset($data['account_id'])) //收款账号
$data['account_name'] = SysAccount::where('id', $data['account_id'])->first()->account_name;
if (isset($data['country_id'])) //付款来源国家
$data['country_name'] = Country::where('id', $data['currency_id'])->first()->cn_addr;
if (isset($data['currency_id'])) //付款币种
$data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->first()->currency_name;
if (isset($data['submit_files']))
$data['submit_files'] = json_decode($data['submit_files'], true);
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
*/
protected function showFormat($data)
{
if (isset($data['doc_user_id'])) //内勤
$data['doc_user_name'] = User::where('id', $data['doc_user_id'])->first()->name;
if (isset($data['sales_user_id'])) //业务员
$data['sales_user_name'] = User::where('id', $data['doc_user_id'])->first()->name;
if (isset($data['corp_id'])) //公司(渠道)
$data['corp_name'] = SysDictItem::where('id', $data['corp_id'])->first()->item_label;
if (isset($data['account_id'])) //收款账号
$data['account_name'] = SysAccount::where('id', $data['account_id'])->first()->account_name;
if (isset($data['country_id'])) //付款来源国家
$data['country_name'] = Country::where('id', $data['currency_id'])->first()->cn_addr;
if (isset($data['currency_id'])) //付款币种
$data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->first()->currency_name;
if (isset($data['submit_files']))
$data['submit_files'] = json_decode($data['submit_files'], true);
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;
}
}
@@ -65,7 +65,7 @@ class FinPaymentApplyService
$data['apply_no'] = $this->generateUniqueApplyNo();
$data['doc_user_id'] = $request->user->uid;
$data['submit_files'] = json_encode($data['submit_files']);
redis::set('stock'.$data['doc_user_id'],json_encode($request->post('stock')));
redis::set('stock_' . $data['doc_user_id'], json_encode($request->post('stock')), 'EX', 30);
return $data;
}
@@ -75,8 +75,8 @@ class FinPaymentApplyService
$data = [
'payment_apply_id' => $res['id'],
];
$stock = json_decode(redis::get('stock'.$res['doc_user_id']), true);
redis::del('stock');
$stock = json_decode(redis::get('stock_' . $res['doc_user_id']), true);
redis::del('stock' . $res['doc_user_id']);
foreach ($stock as $k => $v) {
$data['stock_id'] = $v['stock_id'];
$data['pi_no'] = $v['pi_on'];
+28
View File
@@ -2,6 +2,7 @@
namespace app\common\service;
use app\common\model\FinReceiptHis;
use app\common\validate\FinReceiptValidate;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\FinReceipt;
@@ -50,10 +51,22 @@ class FinReceiptService
if (isset($p['country_id']) && !empty($p['country_id'])) {
$config['where']['country_id'] = $p['country_id'];
}
// 没有付款记录的收款记录
if (isset($p['payment_apply']) && $p['payment_apply'] == 'not') {
$config['where']['payment_apply_id'] = ['not null'];
}
// 收款账户筛选
if (isset($p['payment_apply_id']) && !empty($p['payment_apply_id'])) {
$config['where']['payment_apply_id'] = $p['payment_apply_id'];
}
// 收款账户筛选
if (isset($p['account_id']) && !empty($p['account_id'])) {
$config['where']['account_id'] = $p['account_id'];
}
// 关键字
if (isset($p['keyword']) && $p['keyword']) {
$k = '%' . $p['keyword'] . '%';
@@ -85,6 +98,14 @@ class FinReceiptService
return $data;
}
public function afterServiceStore($res)
{
$receipt = FinReceipt::where('id',$res->id)->first()->toArray();
$receipt = array_merge($receipt,['receipt_id' => $res->id]);
unset($receipt['id']);
FinReceiptHis::create($receipt);
}
public function beforeServiceUpdate($data, Request $request)
{
$data['updated_by'] = $request->user->uid;
@@ -92,6 +113,13 @@ class FinReceiptService
$data['received_at'] = strtotime( $data['received_at']);
return $data;
}
public function afterServiceUpdate($res)
{
$receipt = FinReceipt::where('id',$res->id)->first()->toArray();
$receipt = array_merge($receipt,['receipt_id' => $res->id]);
unset($receipt['id']);
FinReceiptHis::create($receipt);
}
/**
+1 -1
View File
@@ -361,7 +361,7 @@ Route::group('/admin', function () {
Route::any('/destroy', [app\common\controller\FinReceiptController::class, 'destroy']);
});
// 收款记录
// 付款申请
Route::group('/payment', function () {
Route::any('/list', [app\common\controller\FinPaymentApplyController::class, 'index']);
Route::any('/show', [app\common\controller\FinPaymentApplyController::class, 'show']);