待入账列表

This commit is contained in:
2025-11-01 08:56:48 +08:00
parent 29ba35f9b6
commit f7faf79809
4 changed files with 45 additions and 6 deletions
+9
View File
@@ -62,4 +62,13 @@ class FinPaymentApply extends Model
{ {
return $this->belongsToMany(StockOrders::class, 'fin_payment_stock', 'payment_apply_id', 'stock_id'); 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');
}
} }
+17 -1
View File
@@ -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'); 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');
}
} }
@@ -127,6 +127,13 @@ class FinPaymentApplyService
return $data; 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位字母数字组合 * 格式:PA + 日期 + 6位字母数字组合
+12 -5
View File
@@ -218,17 +218,22 @@ class FinReceiptService
// 构建查询 // 构建查询
$query = $this->modelClass::where($where); $query = $this->modelClass::where($where);
// 没有付款记录的收款记录 // 收款记录绑定情况
if (isset($param['payment_apply']) && $param['payment_apply'] == 'not') { 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') { } 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') { //超时未认领 } 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); $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); return $query->paginate($limit, ['*'], 'page', $page);
} }
@@ -308,8 +313,10 @@ class FinReceiptService
$payment = FinPaymentApply::where('id', $payment_apply_id)->first(); $payment = FinPaymentApply::where('id', $payment_apply_id)->first();
$receipt = FinReceipt::find($id); $receipt = FinReceipt::find($id);
$data['discount_amount'] = $payment->amount - $receipt->amount ?? 0; $data['discount_amount'] = $payment->amount - $receipt->amount ?? 0;
$data['submit_files'] = $payment->submit_files ?? '';
$updated = $this->logicUpdateBy($config, $data); $updated = $this->logicUpdateBy($config, $data);
return $this->postProcess(ucfirst($scene), $data); return $this->postProcess(ucfirst($scene), $data);
} }
} }