diff --git a/app/common/model/FinPaymentApply.php b/app/common/model/FinPaymentApply.php index 82f81cb..0f4d157 100644 --- a/app/common/model/FinPaymentApply.php +++ b/app/common/model/FinPaymentApply.php @@ -40,7 +40,7 @@ class FinPaymentApply extends Model /** * 允许自动填充模型字段 */ - protected $fillable = ['id', 'apply_no', 'doc_user_id', 'sales_user_id', 'corp_id', 'account_id', 'payment_account', 'payment_entity', 'entity_type', 'currency_id', 'amount', 'swift', 'remit_bank', 'country_id', 'remitter', 'exchange_rate', 'total_amount_cny', 'voucher_file', 'voucher_name', 'submit_files','receipt_id','claimed_at', 'created_at', 'updated_at']; + protected $fillable = ['id', 'apply_no', 'doc_user_id', 'sales_user_id', 'corp_id', 'account_id', 'payment_account', 'payment_entity', 'entity_type', 'currency_id', 'amount', 'swift', 'remit_bank', 'country_id', 'remitter', 'exchange_rate', 'total_amount_cny', 'voucher_file', 'voucher_name', 'submit_files','receipt_id','claimed_at','warn', 'created_at', 'updated_at', 'claimed_by',]; /** * 不允许自动填充模型字段 diff --git a/app/common/service/FinPaymentApplyService.php b/app/common/service/FinPaymentApplyService.php index f451ce4..19a2f3f 100644 --- a/app/common/service/FinPaymentApplyService.php +++ b/app/common/service/FinPaymentApplyService.php @@ -174,11 +174,11 @@ class FinPaymentApplyService // 构建查询 $query = $this->modelClass::where($where); - // 应用是否有关联收款记录的筛选 + // 是否已关联收款记录的筛选 $correlation = $param['correlation']??''; - if ($correlation === 'receipt') { + if ($correlation === 'receipt') { //已关联 $query->whereHas('receipt'); - } elseif ($correlation === 'unbind') { + } elseif ($correlation === 'unbind') { //未关联 $query->whereDoesntHave('receipt'); } @@ -186,7 +186,7 @@ class FinPaymentApplyService return $query->paginate($limit, ['*'], 'page', $page); } - // 计算七天前的时间戳 + // 计算十天前的时间戳 $sevenDaysAgo = time() - (10 * 24 * 60 * 60); // 构建相似度排序逻辑 @@ -197,8 +197,18 @@ class FinPaymentApplyService $similarityOrder[] = "CASE WHEN account_id = {$param['account_id']} THEN 0 ELSE 1 END"; } - if (isset($param['country_id']) && !empty($param['country_id'])) { - $similarityOrder[] = "CASE WHEN country_id = {$param['country_id']} THEN 0 ELSE 1 END"; + if (isset($param['currency_id']) && !empty($param['currency_id'])) { + $similarityOrder[] = "CASE WHEN currency_id = {$param['currency_id']} THEN 0 ELSE 1 END"; + } + + if (isset($param['remitter']) && !empty($param['remitter'])) { + $similarityOrder[] = "CASE WHEN remitter = {$param['remitter']} THEN 0 ELSE 1 END"; + } + + if (isset($param['amount']) && !empty($param['amount'])) { + $amount = (float)$param['amount']; + $similarityOrder[] = "ABS(amount - {$amount}) ASC"; + $similarityOrder[] = "CASE WHEN (ABS(amount - {$amount}) / {$amount} * 100) <= 5 THEN 0 ELSE 1 END"; } if (isset($param['keyword']) && $param['keyword']) { @@ -206,11 +216,6 @@ class FinPaymentApplyService $similarityOrder[] = "CASE WHEN remitter LIKE '%{$keyword}%' THEN 0 ELSE 1 END"; } - if (isset($param['amount']) && !empty($param['amount'])) { - $amount = (float)$param['amount']; - $similarityOrder[] = "ABS(amount - {$amount})"; - } - // 构建排序SQL $orderByClause = ""; if (!empty($similarityOrder)) { diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php index 48f9832..91db094 100644 --- a/app/common/service/FinReceiptService.php +++ b/app/common/service/FinReceiptService.php @@ -291,7 +291,7 @@ class FinReceiptService $id = $request->input('id'); $data = $this->preProcess(ucfirst($scene), $data, $request); $config = $this->buildQueryConfig($request, $scene); - FinPaymentApply::where('id', $payment_apply_id)->update(['receipt_id' => $id, 'claimed_at' => time()]); + FinPaymentApply::where('id', $payment_apply_id)->update(['receipt_id' => $id, 'claimed_at' => time(), 'claimed_by' => $request->user->uid]); //折让金额 $payment = FinPaymentApply::where('id', $payment_apply_id)->first(); diff --git a/app/common/utils/scaffold/templates/paymentFiles.stub b/app/common/utils/scaffold/templates/paymentFiles.stub new file mode 100644 index 0000000..6c9cded --- /dev/null +++ b/app/common/utils/scaffold/templates/paymentFiles.stub @@ -0,0 +1,103 @@ + + +
+ + +
+ 付款单提醒+ |
+
|
+ 您好, +您有新的付款单待处理。请及时查看: + +
请点击下方按钮立即查看详情: + +
+ 立即查看
+
+
+
+ |
+
|
+ © 2025 河南新友合科技有限公司. 保留所有权利。 +这是系统自动发送的邮件,请勿直接回复。 + |
+