From f7faf798091967fdbbc84faf48a970ae1a75c447 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Sat, 1 Nov 2025 08:56:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=85=E5=85=A5=E8=B4=A6=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/model/FinPaymentApply.php | 9 +++++++++ app/common/model/FinReceipt.php | 18 +++++++++++++++++- app/common/service/FinPaymentApplyService.php | 7 +++++++ app/common/service/FinReceiptService.php | 17 ++++++++++++----- 4 files changed, 45 insertions(+), 6 deletions(-) diff --git a/app/common/model/FinPaymentApply.php b/app/common/model/FinPaymentApply.php index 0f4d157..8dbe4f9 100644 --- a/app/common/model/FinPaymentApply.php +++ b/app/common/model/FinPaymentApply.php @@ -62,4 +62,13 @@ class FinPaymentApply extends Model { return $this->belongsToMany(StockOrders::class, 'fin_payment_stock', 'payment_apply_id', 'stock_id'); } + + /** + * 查询 submit_files 不为空的记录 + */ + public function scopeWithNonEmptyFiles($query) + { + return $query->whereNotNull('submit_files') + ->whereRaw('JSON_LENGTH(submit_files) > 0'); + } } \ No newline at end of file diff --git a/app/common/model/FinReceipt.php b/app/common/model/FinReceipt.php index 7347be0..88d3090 100644 --- a/app/common/model/FinReceipt.php +++ b/app/common/model/FinReceipt.php @@ -40,7 +40,7 @@ class FinReceipt extends Model /** * 允许自动填充模型字段 */ - protected $fillable = ['id', 'receipt_no', 'payment_apply_id', 'country_id', 'remitter', 'account_id', 'currency_id', 'amount', 'discount_amount', 'total_amount_cny', 'exchange_rate', 'arrived_at', 'received_at', 'voucher_no', 'fx_receipt_file', 'fx_receipt_file_name', 'is_domestic_return', 'created_by', 'updated_by', 'created_at', 'updated_at']; + protected $fillable = ['id', 'receipt_no', 'payment_apply_id', 'country_id', 'remitter', 'account_id', 'currency_id', 'amount', 'discount_amount', 'total_amount_cny', 'exchange_rate', 'arrived_at', 'received_at', 'voucher_no', 'fx_receipt_file', 'fx_receipt_file_name', 'is_domestic_return', 'submit_files', 'created_by', 'updated_by', 'created_at', 'updated_at']; /** * 不允许自动填充模型字段 @@ -62,4 +62,20 @@ class FinReceipt extends Model { return $this->belongsToMany(StockOrders::class, 'fin_payment_stock', 'receipt_id', 'stock_id'); } + + /** + * 关联付款申请 + */ +// public function finPaymentApply() +// { +// return $this->hasOne(FinPaymentApply::class, 'receipt_id', 'id'); +// } + + /** + * 关联付款申请表 + */ + public function paymentApply() + { + return $this->belongsTo(FinPaymentApply::class, 'payment_apply_id', 'id'); + } } \ No newline at end of file diff --git a/app/common/service/FinPaymentApplyService.php b/app/common/service/FinPaymentApplyService.php index e55b6a7..e659a86 100644 --- a/app/common/service/FinPaymentApplyService.php +++ b/app/common/service/FinPaymentApplyService.php @@ -127,6 +127,13 @@ class FinPaymentApplyService return $data; } + + public function afterServiceUpdate($res, Request $request) + { + if($res->submit_files != '' && $res->receipt_id != 0) + FinReceipt::where('id', $res->receipt_id)->update(['submit_files' => $res->submit_files]); + } + /** * 生成唯一的付款申请编码 * 格式:PA + 日期 + 6位字母数字组合 diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php index 775d77d..6dd69a7 100644 --- a/app/common/service/FinReceiptService.php +++ b/app/common/service/FinReceiptService.php @@ -218,17 +218,22 @@ class FinReceiptService // 构建查询 $query = $this->modelClass::where($where); - // 没有付款记录的收款记录 + // 收款记录绑定情况 if (isset($param['payment_apply']) && $param['payment_apply'] == 'not') { - $query->whereNull('payment_apply_id'); + $query->where('payment_apply_id', '0'); } elseif (isset($param['payment_apply']) && $param['payment_apply'] == 'already') { - $query->whereNotNull('payment_apply_id'); + $query->where('payment_apply_id', '>' ,'0'); } elseif (isset($param['payment_apply']) && $param['payment_apply'] == 'timeout') { //超时未认领 - $query->whereNull('payment_apply_id'); + $query->where('payment_apply_id', '0'); $query->where('created_at', '<' ,time() - 24*60*60); } - if (isset($param['scene']) && $param['scene'] == 'list') { + if($param['scene'] == 'pending'){ //待入账列表 + $query->where('payment_apply_id', '>' ,'0'); + $query->where('submit_files','!=',''); + } + + if (isset($param['scene']) && ($param['scene'] == 'list' ||$param['scene'] == 'pending')) { return $query->paginate($limit, ['*'], 'page', $page); } @@ -308,8 +313,10 @@ class FinReceiptService $payment = FinPaymentApply::where('id', $payment_apply_id)->first(); $receipt = FinReceipt::find($id); $data['discount_amount'] = $payment->amount - $receipt->amount ?? 0; + $data['submit_files'] = $payment->submit_files ?? ''; $updated = $this->logicUpdateBy($config, $data); return $this->postProcess(ucfirst($scene), $data); } + } \ No newline at end of file