From 43fe263df1e441047237cded74ea391f7e1b0eb5 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Fri, 31 Oct 2025 10:17:41 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E5=A4=87=E8=B4=A7=E5=8D=95=E7=BC=96?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/FinPaymentApplyController.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/common/controller/FinPaymentApplyController.php b/app/common/controller/FinPaymentApplyController.php index 0939646..d58c1d6 100644 --- a/app/common/controller/FinPaymentApplyController.php +++ b/app/common/controller/FinPaymentApplyController.php @@ -5,6 +5,7 @@ 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; @@ -84,11 +85,15 @@ class FinPaymentApplyController extends BaseController 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; From 29ba35f9b6309c04c9c2beac1420d71963e64d45 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Fri, 31 Oct 2025 16:22:28 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E6=94=B6=E4=BB=98=E6=AC=BE=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard/FinStatisticsController.php | 83 +++++++++++++++++-- 1 file changed, 76 insertions(+), 7 deletions(-) diff --git a/app/admin/controller/dashboard/FinStatisticsController.php b/app/admin/controller/dashboard/FinStatisticsController.php index 95cf09d..59965da 100644 --- a/app/admin/controller/dashboard/FinStatisticsController.php +++ b/app/admin/controller/dashboard/FinStatisticsController.php @@ -3,7 +3,9 @@ namespace app\admin\controller\dashboard; use app\common\controller\BaseController; +use app\common\model\FinPaymentApply; use app\common\model\FinReceipt; +use app\common\model\SysCurrency; use support\Request; class FinStatisticsController extends BaseController @@ -16,33 +18,100 @@ class FinStatisticsController extends BaseController public function statistics(Request $request) { try { + $currency = SysCurrency::where('status',1)->get(); $query = FinReceipt::where('payment_apply_id','>',0); $result = []; //已认领数量 $result['claimed_num'] = $query->count(); //已认领金额 - $result['claimed_amount'] = $query->sum('amount'); +// $result['claimed_amount'] = $query->sum('amount'); + $result['claimed_amount'] = array_values($this->receiptStatisticsSum($query, $currency)); //各币种的已认领金额 + $result['claimed_amount_sum'] =$this->amountSum($result['claimed_amount']); //已认领的人民币总金额 //未入账数量 - $result['unreceived_num'] = FinReceipt::whereNull('received_at')->count(); + $query2 = FinReceipt::whereNull('received_at'); + $result['unreceived_num'] = $query2->count(); //未入账金额 - $result['unreceived_amount'] = FinReceipt::whereNull('received_at')->sum('amount'); +// $result['unreceived_amount'] = $query2->sum('amount'); + $result['unreceived_amount'] = array_values($this->receiptStatisticsSum($query2, $currency)); //各币种的未入账金额 + $result['unreceived_amount_sum'] = $this->amountSum($result['unreceived_amount']); //未入账的已认领的人民币总金额 - $query = FinReceipt::whereNull('payment_apply_id'); + $query3 = FinReceipt::whereNull('payment_apply_id'); //未认领数量 - $result['unclaimed_num'] = $query->count(); + $result['unclaimed_num'] = $query3->count(); //未认领金额 - $result['unclaimed_amount'] = $query->sum('amount'); +// $result['unclaimed_amount'] = $query3->sum('amount'); + $result['unclaimed_amount'] = $this->receiptStatisticsSum($query3, $currency); //各币种的未认领金额 + $result['unclaimed_amount_sum'] = $this->amountSum($result['unclaimed_amount']); //未认领的已认领的人民币总金额 //已超时未认领数量 - $result['timeout'] = $query->where('created_at','<',time()-24*3600)->count(); + $query4 = $query3->where('created_at','<',time()-24*3600); + $result['timeout'] = $query4->count(); + //在途资金 + //1、没有认领的付款资金 + $query5 = FinPaymentApply::where('receipt_id', '=', 0); + $unclaimed_payment_amount = $this->receiptStatisticsSum($query5, $currency); + foreach ($unclaimed_payment_amount as $key => &$value) { + $value['amount'] = $value['amount'] - $result['unclaimed_amount'][$key]['amount']; + } + $result['unclaimed_payment_amount'] = array_values($result['unclaimed_payment_amount']); + $result['unclaimed_payment_amount_sum'] = $this->amountSum($result['unclaimed_payment_amount']); + //在途资金 = 没有认领的付款资金-未认领的收款资金 + $result['intransit_amount'] = $result['unclaimed_payment_amount_sum'] - $result['unclaimed_amount_sum']; + + //在途数量 = 没有认领的付款数量-未认领的收款数量 + $result['intransit_count'] = count($result['unclaimed_payment_amount']) - count($result['unclaimed_amount']); + + //未认领金额重新组织索引 + $result['unclaimed_amount'] = array_values($result['unclaimed_amount']); return $this->success($result); } catch (\Throwable $e) { return $this->error($e->getMessage()); } } + /** + * 根据不同条件查询收款金额 + * @param $query + * @param $currency + * @return array + */ + public function receiptStatisticsSum($query, $currency) + { + $amount = []; + foreach ($currency as $k => $v) { + $amount[$v->currency_code] = [ + 'currency_code' => $v->currency_code, + 'exchange_rate' => $v->exchange_rate, + 'amount' => $query->where('currency_id',$v->id)->sum('amount'), + ]; + } + return $amount; + } + + /** + * 不同币种汇率换算之后求和 + * @param $query + * @param $currency + */ + public function amountSum($amount) + { + $amountSum = 0; + foreach ($amount as $v) { + // 转换为整数(乘以100避免浮点数问题) + $v['amount'] = (int) round($v['amount'] * 100); + $v['exchange_rate'] = (int) round($v['exchange_rate'] * 10000); // 汇率保留4位小数 + $amountSum += $v['amount'] * $v['exchange_rate']; + } + + // 转换回金额(除以1000000,因为汇率乘了10000) + $result = $amountSum / 1000000; + + // 四舍五入到2位小数 + return round($amountSum, 2); + } + } \ No newline at end of file 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 03/13] =?UTF-8?q?=E5=BE=85=E5=85=A5=E8=B4=A6=E5=88=97?= =?UTF-8?q?=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 From 139d3509f44973f8468fe7bf28b4f4d4362c0047 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Sat, 1 Nov 2025 09:45:41 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E4=BD=9C=E5=BA=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/FinReceiptController.php | 16 ++++++++++++++++ app/common/model/FinReceipt.php | 2 ++ app/common/service/FinReceiptService.php | 13 +++++++++++++ config/route.php | 2 +- 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/app/common/controller/FinReceiptController.php b/app/common/controller/FinReceiptController.php index cade259..aeca0eb 100644 --- a/app/common/controller/FinReceiptController.php +++ b/app/common/controller/FinReceiptController.php @@ -41,6 +41,22 @@ class FinReceiptController extends BaseController } } + /** + * 确认入账 + * @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()); + } + } + public function show(Request $request) { try { diff --git a/app/common/model/FinReceipt.php b/app/common/model/FinReceipt.php index 88d3090..099697f 100644 --- a/app/common/model/FinReceipt.php +++ b/app/common/model/FinReceipt.php @@ -2,10 +2,12 @@ namespace app\common\model; +use Illuminate\Database\Eloquent\SoftDeletes; use support\Model; class FinReceipt extends Model { + use SoftDeletes; /** * The connection name for the model. * diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php index 6dd69a7..5b04368 100644 --- a/app/common/service/FinReceiptService.php +++ b/app/common/service/FinReceiptService.php @@ -233,6 +233,12 @@ class FinReceiptService $query->where('submit_files','!=',''); } + if($param['scene'] == 'delete'){ //查询作废数据 + $query->onlyTrashed(); + }elseif ($param['scene'] == 'all'){ //查询包含作废数据的全量数据 + $query->withTrashed(); + } + if (isset($param['scene']) && ($param['scene'] == 'list' ||$param['scene'] == 'pending')) { return $query->paginate($limit, ['*'], 'page', $page); } @@ -293,6 +299,13 @@ class FinReceiptService return $res; } + + public function delete($id) + { + $res = FinReceipt::where('id', $id)->delete(); + return $res; + } + /** * 更新:绑定收款记录,计算折让金额 * @param Request $request diff --git a/config/route.php b/config/route.php index ec7d821..e313549 100644 --- a/config/route.php +++ b/config/route.php @@ -359,8 +359,8 @@ Route::group('/admin', function () { Route::any('/store', [app\common\controller\FinReceiptController::class, 'store']); Route::any('/update', [app\common\controller\FinReceiptController::class, 'update']); Route::any('/payment', [app\common\controller\FinReceiptController::class, 'payment']); - Route::any('/destroy', [app\common\controller\FinReceiptController::class, 'destroy']); Route::any('/credit', [app\common\controller\FinReceiptController::class, 'credit']); + Route::any('/delete', [app\common\controller\FinReceiptController::class, 'delete']); }); // 收款记录历史 Route::group('/receipt/his', function () { From 18eb3e7c5dd01ce2934395b9ee606d935279f854 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Sat, 1 Nov 2025 11:32:10 +0800 Subject: [PATCH 05/13] =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/dashboard/FinStatisticsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/controller/dashboard/FinStatisticsController.php b/app/admin/controller/dashboard/FinStatisticsController.php index 59965da..3a66c8c 100644 --- a/app/admin/controller/dashboard/FinStatisticsController.php +++ b/app/admin/controller/dashboard/FinStatisticsController.php @@ -57,7 +57,7 @@ class FinStatisticsController extends BaseController foreach ($unclaimed_payment_amount as $key => &$value) { $value['amount'] = $value['amount'] - $result['unclaimed_amount'][$key]['amount']; } - $result['unclaimed_payment_amount'] = array_values($result['unclaimed_payment_amount']); + $result['unclaimed_payment_amount'] = array_values($unclaimed_payment_amount); $result['unclaimed_payment_amount_sum'] = $this->amountSum($result['unclaimed_payment_amount']); //在途资金 = 没有认领的付款资金-未认领的收款资金 $result['intransit_amount'] = $result['unclaimed_payment_amount_sum'] - $result['unclaimed_amount_sum']; From 6493bdebb115a3da14dd9f7c0a23267c44d782f9 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Sat, 1 Nov 2025 11:34:49 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E5=BE=85=E5=85=A5=E8=B4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/service/FinReceiptService.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php index 062d3ee..b93b074 100644 --- a/app/common/service/FinReceiptService.php +++ b/app/common/service/FinReceiptService.php @@ -228,14 +228,14 @@ class FinReceiptService $query->where('created_at', '<' ,time() - 24*60*60); } - if($param['scene'] == 'pending'){ //待入账列表 + if(isset($param['scene']) && $param['scene'] == 'pending'){ //待入账列表 $query->where('payment_apply_id', '>' ,'0'); $query->where('submit_files','!=',''); } - if($param['scene'] == 'delete'){ //查询作废数据 + if(isset($param['scene']) && $param['scene'] == 'delete'){ //查询作废数据 $query->onlyTrashed(); - }elseif ($param['scene'] == 'all'){ //查询包含作废数据的全量数据 + }elseif (isset($param['scene']) && $param['scene'] == 'all'){ //查询包含作废数据的全量数据 $query->withTrashed(); } From 74ac8941ea0717d01b321570693cd3e098b2e522 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Sat, 1 Nov 2025 13:20:33 +0800 Subject: [PATCH 07/13] =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard/FinStatisticsController.php | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/app/admin/controller/dashboard/FinStatisticsController.php b/app/admin/controller/dashboard/FinStatisticsController.php index 3a66c8c..6901082 100644 --- a/app/admin/controller/dashboard/FinStatisticsController.php +++ b/app/admin/controller/dashboard/FinStatisticsController.php @@ -37,7 +37,17 @@ class FinStatisticsController extends BaseController $result['unreceived_amount'] = array_values($this->receiptStatisticsSum($query2, $currency)); //各币种的未入账金额 $result['unreceived_amount_sum'] = $this->amountSum($result['unreceived_amount']); //未入账的已认领的人民币总金额 - $query3 = FinReceipt::whereNull('payment_apply_id'); + //今日入账 + $query6 = FinReceipt::where('received_at','>',strtotime(date("Y-m-d"))); + //今日入账数量 + $result['received_num'] = $query6->count(); + //未入账金额 +// $result['unreceived_amount'] = $query2->sum('amount'); + $result['received_amount'] = array_values($this->receiptStatisticsSum($query6, $currency)); //各币种的未入账金额 + $result['received_amount_sum'] = $this->amountSum($result['unreceived_amount']); //未入账的已认领的人民币总金额 + + + $query3 = FinReceipt::where('payment_apply_id',0); //未认领数量 $result['unclaimed_num'] = $query3->count(); @@ -57,13 +67,20 @@ class FinStatisticsController extends BaseController foreach ($unclaimed_payment_amount as $key => &$value) { $value['amount'] = $value['amount'] - $result['unclaimed_amount'][$key]['amount']; } + $result['unclaimed_payment_num'] = $query5->count(); $result['unclaimed_payment_amount'] = array_values($unclaimed_payment_amount); $result['unclaimed_payment_amount_sum'] = $this->amountSum($result['unclaimed_payment_amount']); //在途资金 = 没有认领的付款资金-未认领的收款资金 - $result['intransit_amount'] = $result['unclaimed_payment_amount_sum'] - $result['unclaimed_amount_sum']; - + $result['intransit_amount_sum'] = $result['unclaimed_payment_amount_sum'] - $result['unclaimed_amount_sum']; + $intransit_amount_amount = []; + //在途资金各币种明细 + foreach ($unclaimed_payment_amount as $key => $value) { + $value['amount'] = $value['amount'] - $result['unclaimed_amount'][$key]['amount']; + $intransit_amount_amount[] = $value; + } + $result['intransit_amount_amount'] = $intransit_amount_amount; //在途数量 = 没有认领的付款数量-未认领的收款数量 - $result['intransit_count'] = count($result['unclaimed_payment_amount']) - count($result['unclaimed_amount']); + $result['intransit_count'] = $result['unclaimed_payment_num'] - $result['unclaimed_num']; //未认领金额重新组织索引 $result['unclaimed_amount'] = array_values($result['unclaimed_amount']); From 1094bc406f093040c3ab5a0e039fbf3390b7b0cc Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Sat, 1 Nov 2025 13:22:45 +0800 Subject: [PATCH 08/13] =?UTF-8?q?Revert=20"=E4=BD=9C=E5=BA=9F"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 139d3509f44973f8468fe7bf28b4f4d4362c0047. --- app/common/controller/FinReceiptController.php | 16 ---------------- app/common/model/FinReceipt.php | 2 -- app/common/service/FinReceiptService.php | 13 ------------- config/route.php | 2 +- 4 files changed, 1 insertion(+), 32 deletions(-) diff --git a/app/common/controller/FinReceiptController.php b/app/common/controller/FinReceiptController.php index aeca0eb..cade259 100644 --- a/app/common/controller/FinReceiptController.php +++ b/app/common/controller/FinReceiptController.php @@ -41,22 +41,6 @@ class FinReceiptController extends BaseController } } - /** - * 确认入账 - * @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()); - } - } - public function show(Request $request) { try { diff --git a/app/common/model/FinReceipt.php b/app/common/model/FinReceipt.php index 099697f..88d3090 100644 --- a/app/common/model/FinReceipt.php +++ b/app/common/model/FinReceipt.php @@ -2,12 +2,10 @@ namespace app\common\model; -use Illuminate\Database\Eloquent\SoftDeletes; use support\Model; class FinReceipt extends Model { - use SoftDeletes; /** * The connection name for the model. * diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php index 5b04368..6dd69a7 100644 --- a/app/common/service/FinReceiptService.php +++ b/app/common/service/FinReceiptService.php @@ -233,12 +233,6 @@ class FinReceiptService $query->where('submit_files','!=',''); } - if($param['scene'] == 'delete'){ //查询作废数据 - $query->onlyTrashed(); - }elseif ($param['scene'] == 'all'){ //查询包含作废数据的全量数据 - $query->withTrashed(); - } - if (isset($param['scene']) && ($param['scene'] == 'list' ||$param['scene'] == 'pending')) { return $query->paginate($limit, ['*'], 'page', $page); } @@ -299,13 +293,6 @@ class FinReceiptService return $res; } - - public function delete($id) - { - $res = FinReceipt::where('id', $id)->delete(); - return $res; - } - /** * 更新:绑定收款记录,计算折让金额 * @param Request $request diff --git a/config/route.php b/config/route.php index e313549..ec7d821 100644 --- a/config/route.php +++ b/config/route.php @@ -359,8 +359,8 @@ Route::group('/admin', function () { Route::any('/store', [app\common\controller\FinReceiptController::class, 'store']); Route::any('/update', [app\common\controller\FinReceiptController::class, 'update']); Route::any('/payment', [app\common\controller\FinReceiptController::class, 'payment']); + Route::any('/destroy', [app\common\controller\FinReceiptController::class, 'destroy']); Route::any('/credit', [app\common\controller\FinReceiptController::class, 'credit']); - Route::any('/delete', [app\common\controller\FinReceiptController::class, 'delete']); }); // 收款记录历史 Route::group('/receipt/his', function () { From 8674063e6e0a8254781ce1a26f8383310fedb291 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Sat, 1 Nov 2025 13:36:18 +0800 Subject: [PATCH 09/13] =?UTF-8?q?=E4=BB=98=E6=AC=BE=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E4=BD=9C=E5=BA=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FinPaymentApplyController.php | 16 ++++++++++++++++ app/common/model/FinPaymentApply.php | 4 +++- app/common/service/FinPaymentApplyService.php | 13 +++++++++++++ config/route.php | 2 +- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/app/common/controller/FinPaymentApplyController.php b/app/common/controller/FinPaymentApplyController.php index d58c1d6..98c49c2 100644 --- a/app/common/controller/FinPaymentApplyController.php +++ b/app/common/controller/FinPaymentApplyController.php @@ -162,4 +162,20 @@ class FinPaymentApplyController extends BaseController $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()); + } + } } \ No newline at end of file diff --git a/app/common/model/FinPaymentApply.php b/app/common/model/FinPaymentApply.php index 8dbe4f9..c81ac0a 100644 --- a/app/common/model/FinPaymentApply.php +++ b/app/common/model/FinPaymentApply.php @@ -2,10 +2,12 @@ namespace app\common\model; +use Illuminate\Database\Eloquent\SoftDeletes; use support\Model; class FinPaymentApply extends Model { + use SoftDeletes; /** * The connection name for the model. * @@ -40,7 +42,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','warn', 'created_at', 'updated_at', 'claimed_by',]; + 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', 'deleted_at', 'claimed_by', 'created_by',]; /** * 不允许自动填充模型字段 diff --git a/app/common/service/FinPaymentApplyService.php b/app/common/service/FinPaymentApplyService.php index e659a86..4567461 100644 --- a/app/common/service/FinPaymentApplyService.php +++ b/app/common/service/FinPaymentApplyService.php @@ -214,6 +214,12 @@ class FinPaymentApplyService $query->whereDoesntHave('receipt'); } + if($param['scene'] == 'delete'){ //查询作废数据 + $query->onlyTrashed(); + }elseif ($param['scene'] == 'all'){ //查询包含作废数据的全量数据 + $query->withTrashed(); + } + if ((isset($param['scene']) && $param['scene'] == 'list') || empty($param['receipt_id'])) { return $query->orderBy('id','desc')->paginate($limit, ['*'], 'page', $page); } @@ -271,4 +277,11 @@ class FinPaymentApplyService return $query->paginate($limit, ['*'], 'page', $page); } + public function delete($id) + { + $res = FinPaymentApply::where('id', $id)->delete(); + return $res; + } + + } \ No newline at end of file diff --git a/config/route.php b/config/route.php index ec7d821..c390d7a 100644 --- a/config/route.php +++ b/config/route.php @@ -378,7 +378,7 @@ Route::group('/admin', function () { Route::any('/show', [app\common\controller\FinPaymentApplyController::class, 'show']); Route::any('/store', [app\common\controller\FinPaymentApplyController::class, 'store']); Route::any('/update', [app\common\controller\FinPaymentApplyController::class, 'update']); - Route::any('/destroy', [app\common\controller\FinPaymentApplyController::class, 'destroy']); + Route::any('/delete', [app\common\controller\FinPaymentApplyController::class, 'delete']); }); // 系统配置 From 4dbd72acce839f711b70f8a8dad60cff0014dcb4 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Sat, 1 Nov 2025 14:02:15 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E5=BE=85=E5=85=A5=E8=B4=A6=E4=B8=8E?= =?UTF-8?q?=E5=85=A5=E8=B4=A6=E5=AE=9E=E9=99=85=E6=B1=87=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/service/FinPaymentApplyService.php | 7 ++++++- app/common/service/FinReceiptService.php | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/common/service/FinPaymentApplyService.php b/app/common/service/FinPaymentApplyService.php index 4567461..be467e5 100644 --- a/app/common/service/FinPaymentApplyService.php +++ b/app/common/service/FinPaymentApplyService.php @@ -214,13 +214,18 @@ class FinPaymentApplyService $query->whereDoesntHave('receipt'); } + if(isset($param['scene']) && $param['scene'] == 'pending'){ //待入账列表 + $query->where('receipt_id', '>' ,'0'); + $query->where('submit_files','!=',''); + } + if($param['scene'] == 'delete'){ //查询作废数据 $query->onlyTrashed(); }elseif ($param['scene'] == 'all'){ //查询包含作废数据的全量数据 $query->withTrashed(); } - if ((isset($param['scene']) && $param['scene'] == 'list') || empty($param['receipt_id'])) { + if ((isset($param['scene']) && ($param['scene'] == 'list' || $param['scene'] == 'pending'))|| empty($param['receipt_id']) ) { return $query->orderBy('id','desc')->paginate($limit, ['*'], 'page', $page); } diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php index 6dd69a7..37b9c94 100644 --- a/app/common/service/FinReceiptService.php +++ b/app/common/service/FinReceiptService.php @@ -303,6 +303,11 @@ class FinReceiptService public function serviceUpdatePayment(Request $request, array $data = [], string $scene = 'payment') { $payment_apply_id = $request->input('payment_apply_id'); + $exchange_rate = $request->input('exchange_rate'); + if(empty($exchange_rate) || !is_numeric($exchange_rate)){ + throw new BusinessException('请输入汇率'); + } + $id = $request->input('id'); $data = $this->preProcess(ucfirst($scene), $data, $request); $config = $this->buildQueryConfig($request, $scene); @@ -314,6 +319,8 @@ class FinReceiptService $receipt = FinReceipt::find($id); $data['discount_amount'] = $payment->amount - $receipt->amount ?? 0; $data['submit_files'] = $payment->submit_files ?? ''; + $data['exchange_rate'] = $exchange_rate; + $data['total_amount_cny'] = round($data['amount']*$exchange_rate,2); $updated = $this->logicUpdateBy($config, $data); return $this->postProcess(ucfirst($scene), $data); From f1d5fae122bdeb66a7ed3db0439c91ac0eccab8b Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Sat, 1 Nov 2025 14:13:55 +0800 Subject: [PATCH 11/13] =?UTF-8?q?=E5=85=A5=E8=B4=A6=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=B1=87=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/FinReceiptController.php | 6 +++++- app/common/logic/FinReceiptLogic.php | 4 ++-- app/common/service/FinReceiptService.php | 16 ++++++++-------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/common/controller/FinReceiptController.php b/app/common/controller/FinReceiptController.php index cade259..f0e0626 100644 --- a/app/common/controller/FinReceiptController.php +++ b/app/common/controller/FinReceiptController.php @@ -34,7 +34,11 @@ class FinReceiptController extends BaseController { try { $id = $request->input('id'); - $raw = $this->service->credit($id); + $exchange_rate = $request->input('exchange_rate'); + if(empty($exchange_rate) || !is_numeric($exchange_rate)){ + return $this->error('请输入汇率'); + } + $raw = $this->service->credit($id,$exchange_rate); return $this->success($raw); } catch (\Throwable $e) { return $this->error($e->getMessage()); diff --git a/app/common/logic/FinReceiptLogic.php b/app/common/logic/FinReceiptLogic.php index 62db50f..622663b 100644 --- a/app/common/logic/FinReceiptLogic.php +++ b/app/common/logic/FinReceiptLogic.php @@ -14,8 +14,8 @@ class FinReceiptLogic */ protected string $modelClass = FinReceipt::class; - public function credit($id) + public function credit($id, $data) { - return FinReceipt::where('id', $id)->update(['received_at' => time()]); + return FinReceipt::where('id', $id)->update($data); } } \ No newline at end of file diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php index 37b9c94..0070585 100644 --- a/app/common/service/FinReceiptService.php +++ b/app/common/service/FinReceiptService.php @@ -282,13 +282,19 @@ class FinReceiptService return $query->paginate($limit, ['*'], 'page', $page); } - public function credit($id) + public function credit($id, $exchange_rate) { $finReceipt = FinReceipt::find($id); if(!empty($finReceipt->received_at)){ throw new BusinessException('该记录已将确认入账'); } - $res = $this->logic->credit($id); + + $data = [ + 'received_at' => time(), + 'exchange_rate' => $exchange_rate, + 'total_amount_cny' => round($finReceipt['amount']*$exchange_rate,2), + ]; + $res = $this->logic->credit($id,$data); $this->afterServiceUpdate(['id'=>$id]); return $res; } @@ -303,10 +309,6 @@ class FinReceiptService public function serviceUpdatePayment(Request $request, array $data = [], string $scene = 'payment') { $payment_apply_id = $request->input('payment_apply_id'); - $exchange_rate = $request->input('exchange_rate'); - if(empty($exchange_rate) || !is_numeric($exchange_rate)){ - throw new BusinessException('请输入汇率'); - } $id = $request->input('id'); $data = $this->preProcess(ucfirst($scene), $data, $request); @@ -319,8 +321,6 @@ class FinReceiptService $receipt = FinReceipt::find($id); $data['discount_amount'] = $payment->amount - $receipt->amount ?? 0; $data['submit_files'] = $payment->submit_files ?? ''; - $data['exchange_rate'] = $exchange_rate; - $data['total_amount_cny'] = round($data['amount']*$exchange_rate,2); $updated = $this->logicUpdateBy($config, $data); return $this->postProcess(ucfirst($scene), $data); From 56ad5517075843898a748a113d75cb64620e2cc7 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Sat, 1 Nov 2025 14:44:47 +0800 Subject: [PATCH 12/13] =?UTF-8?q?=E6=94=B6=E6=B1=87=E5=87=AD=E8=AF=81?= =?UTF-8?q?=E5=80=92=E8=AE=A1=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/FinReceiptController.php | 9 ++++++++- app/common/model/FinPaymentApply.php | 2 +- app/common/service/FinPaymentApplyService.php | 1 + app/common/service/FinReceiptService.php | 6 ++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/common/controller/FinReceiptController.php b/app/common/controller/FinReceiptController.php index f0e0626..4c73b7a 100644 --- a/app/common/controller/FinReceiptController.php +++ b/app/common/controller/FinReceiptController.php @@ -12,6 +12,7 @@ use app\common\model\User; use app\common\service\OssService; use app\common\traits\crud\CrudControllerTrait; use app\common\service\FinReceiptService; +use support\Redis; use support\Request; class FinReceiptController extends BaseController @@ -85,14 +86,20 @@ class FinReceiptController extends BaseController { if (isset($data['created_at'])){ $data['claim_timeout'] = (($data['created_at'] < (time()-86400)) && empty($data['payment_apply_id'])) ?1:0; + $data['claim_timeout_time'] = date('Y-m-d H:i:s', $data['created_at']+86400); $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['arrived_at'])) $data['arrived_at'] = date('Y-m-d H:i:s', $data['arrived_at']); - if (isset($data['received_at'])) + if (isset($data['received_at'])){ $data['received_at'] = date('Y-m-d H:i:s', $data['received_at']); + $voucher_no_timeout_hour = redis::get('voucher_no_timeout_hour'); + if(!empty($voucher_no_timeout_hour)){ + $data['voucher_no_timeout_time'] = date('Y-m-d H:i:s', time()+(60*60*$voucher_no_timeout_hour)); + } + } 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')??''; diff --git a/app/common/model/FinPaymentApply.php b/app/common/model/FinPaymentApply.php index c81ac0a..af52c85 100644 --- a/app/common/model/FinPaymentApply.php +++ b/app/common/model/FinPaymentApply.php @@ -42,7 +42,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','warn', 'created_at', 'updated_at', 'deleted_at', 'claimed_by', 'created_by',]; + 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', 'received_at', 'created_at', 'updated_at', 'deleted_at', 'claimed_by', 'created_by',]; /** * 不允许自动填充模型字段 diff --git a/app/common/service/FinPaymentApplyService.php b/app/common/service/FinPaymentApplyService.php index be467e5..ed9267a 100644 --- a/app/common/service/FinPaymentApplyService.php +++ b/app/common/service/FinPaymentApplyService.php @@ -217,6 +217,7 @@ class FinPaymentApplyService if(isset($param['scene']) && $param['scene'] == 'pending'){ //待入账列表 $query->where('receipt_id', '>' ,'0'); $query->where('submit_files','!=',''); + $query->whereNotNull('received_at'); } if($param['scene'] == 'delete'){ //查询作废数据 diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php index 0070585..5f6b480 100644 --- a/app/common/service/FinReceiptService.php +++ b/app/common/service/FinReceiptService.php @@ -10,6 +10,7 @@ use app\common\validate\FinReceiptValidate; use app\common\traits\crud\CrudServiceTrait; use app\common\model\FinReceipt; use support\exception\BusinessException; +use support\Redis; use support\Request; class FinReceiptService @@ -194,6 +195,10 @@ class FinReceiptService $page = (int)$request->get('current', 1); $param = $request->all(); + if(isset($param['voucher_no_timeout_hour'])){ + redis::set('voucher_no_timeout_hour', $param['voucher_no_timeout_hour'], 'EX', 30); + } + $where = []; // 汇款国家 @@ -295,6 +300,7 @@ class FinReceiptService 'total_amount_cny' => round($finReceipt['amount']*$exchange_rate,2), ]; $res = $this->logic->credit($id,$data); + FinPaymentApply::where('id', $finReceipt->payment_apply_id)->update(['received_at' => $data['received_at']]); $this->afterServiceUpdate(['id'=>$id]); return $res; } From 5b77b8ed834f2f98d192a79763fd11cb42cf1a0d Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Sat, 1 Nov 2025 14:59:41 +0800 Subject: [PATCH 13/13] =?UTF-8?q?=E5=BE=85=E5=85=A5=E8=B4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/service/FinPaymentApplyService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/common/service/FinPaymentApplyService.php b/app/common/service/FinPaymentApplyService.php index ed9267a..42cae9a 100644 --- a/app/common/service/FinPaymentApplyService.php +++ b/app/common/service/FinPaymentApplyService.php @@ -217,7 +217,7 @@ class FinPaymentApplyService if(isset($param['scene']) && $param['scene'] == 'pending'){ //待入账列表 $query->where('receipt_id', '>' ,'0'); $query->where('submit_files','!=',''); - $query->whereNotNull('received_at'); + $query->whereNull('received_at'); } if($param['scene'] == 'delete'){ //查询作废数据