From 36d1d333b1f9ef6ca192f8ad7a033e4999b0ba7e Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 23 Sep 2025 15:13:56 +0800 Subject: [PATCH 01/39] =?UTF-8?q?=E4=BB=98=E6=AC=BE=E4=B8=8E=E6=94=B6?= =?UTF-8?q?=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FinPaymentApplyController.php | 33 +++++ .../controller/FinReceiptController.php | 56 ++++++++ app/common/logic/FinPaymentApplyLogic.php | 17 +++ app/common/logic/FinReceiptLogic.php | 17 +++ app/common/model/FinPaymentApply.php | 65 +++++++++ app/common/model/FinPaymentStock.php | 67 +++++++++ app/common/model/FinReceipt.php | 65 +++++++++ app/common/model/StockOrders.php | 8 ++ app/common/service/FinPaymentApplyService.php | 107 +++++++++++++++ app/common/service/FinReceiptService.php | 127 ++++++++++++++++++ .../validate/FinPaymentApplyValidate.php | 29 ++++ app/common/validate/FinReceiptValidate.php | 56 ++++++++ app/controller/IndexController.php | 38 +++--- config/route.php | 18 +++ 14 files changed, 684 insertions(+), 19 deletions(-) create mode 100644 app/common/controller/FinPaymentApplyController.php create mode 100644 app/common/controller/FinReceiptController.php create mode 100644 app/common/logic/FinPaymentApplyLogic.php create mode 100644 app/common/logic/FinReceiptLogic.php create mode 100644 app/common/model/FinPaymentApply.php create mode 100644 app/common/model/FinPaymentStock.php create mode 100644 app/common/model/FinReceipt.php create mode 100644 app/common/service/FinPaymentApplyService.php create mode 100644 app/common/service/FinReceiptService.php create mode 100644 app/common/validate/FinPaymentApplyValidate.php create mode 100644 app/common/validate/FinReceiptValidate.php diff --git a/app/common/controller/FinPaymentApplyController.php b/app/common/controller/FinPaymentApplyController.php new file mode 100644 index 0000000..2d0f22e --- /dev/null +++ b/app/common/controller/FinPaymentApplyController.php @@ -0,0 +1,33 @@ +service = new FinPaymentApplyService(); + } + + /** + * 列表页数据格式化 + * + * @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; + // } +} \ No newline at end of file diff --git a/app/common/controller/FinReceiptController.php b/app/common/controller/FinReceiptController.php new file mode 100644 index 0000000..4acf899 --- /dev/null +++ b/app/common/controller/FinReceiptController.php @@ -0,0 +1,56 @@ +service = new FinReceiptService(); + } + + /** + * 列表页数据格式化 + * + * @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']); + if (isset($data['arrived_at'])) + $data['arrived_at'] = date('Y-m-d H:i:s', $data['arrived_at']); + if (isset($data['received_at'])) + $data['received_at'] = date('Y-m-d H:i:s', $data['received_at']); + return $data; + } + + /** + * 数据格式化 + * + * @param array $data + * @return array + */ + protected function showFormat($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']); + if (isset($data['arrived_at'])) + $data['arrived_at'] = date('Y-m-d H:i:s', $data['arrived_at']); + if (isset($data['received_at'])) + $data['received_at'] = date('Y-m-d H:i:s', $data['received_at']); + return $data; + } +} \ No newline at end of file diff --git a/app/common/logic/FinPaymentApplyLogic.php b/app/common/logic/FinPaymentApplyLogic.php new file mode 100644 index 0000000..09b93e1 --- /dev/null +++ b/app/common/logic/FinPaymentApplyLogic.php @@ -0,0 +1,17 @@ +hasOne(FinReceipt::class, 'payment_apply_id', 'id'); + } + + /** + * 备货单 + */ + public function stock() + { + return $this->belongsToMany(StockOrders::class, 'fin_payment_stock', 'payment_apply_id', 'stock_id'); + } +} \ No newline at end of file diff --git a/app/common/model/FinPaymentStock.php b/app/common/model/FinPaymentStock.php new file mode 100644 index 0000000..6f4a3ba --- /dev/null +++ b/app/common/model/FinPaymentStock.php @@ -0,0 +1,67 @@ +belongsTo(FinPaymentApply::class, 'payment_apply_id', 'id'); + } + + // 收款记录 + public function receipt() + { + return $this->belongsTo(FinReceipt::class, 'receipt_id', 'id'); + } + + // 付款申请 + public function stock() + { + return $this->belongsTo(StockOrders::class, 'stock_id', 'id'); + } +} \ No newline at end of file diff --git a/app/common/model/FinReceipt.php b/app/common/model/FinReceipt.php new file mode 100644 index 0000000..a98914f --- /dev/null +++ b/app/common/model/FinReceipt.php @@ -0,0 +1,65 @@ +hasOne(FinPaymentApply::class, 'id', 'payment_apply_id'); + } + + /** + * 备货单 + */ + public function stock() + { + return $this->belongsToMany(StockOrders::class, 'fin_payment_stock', 'receipt_id', 'stock_id'); + } +} \ No newline at end of file diff --git a/app/common/model/StockOrders.php b/app/common/model/StockOrders.php index 0b97fe4..0802afe 100644 --- a/app/common/model/StockOrders.php +++ b/app/common/model/StockOrders.php @@ -95,4 +95,12 @@ class StockOrders extends Model { return $this->hasOne(User::class, 'id', 'salesperson_id'); } + + /** + * 客户的标签 + */ + public function payment() + { + return $this->belongsToMany(FinPaymentApply::class, 'fin_payment_stock', 'stock_id', 'payment_apply_id'); + } } \ No newline at end of file diff --git a/app/common/service/FinPaymentApplyService.php b/app/common/service/FinPaymentApplyService.php new file mode 100644 index 0000000..00ad976 --- /dev/null +++ b/app/common/service/FinPaymentApplyService.php @@ -0,0 +1,107 @@ +validator; + } + + /** + * 构建查询条件 + */ + protected function buildQueryConfig(Request $request, string $scene = 'index'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'index': + // ====== ====== 排序 ====== ====== + $config['order']['id'] = 'desc'; + break; + case 'show': + $config['where']['id'] = $p['id']; + break; + case 'update': + case 'destroy': + $config['where']['id'] = $p['id']; + break; + case 'store': + break; + } + + return $config; + } + + public function beforeServiceStore($data, Request $request) + { + $data['apply_no'] = $this->generateUniqueApplyNo(); + $data['submit_files'] = json_encode($data['submit_files']); + return $data; + } + + public function beforeServiceUpdate($data, Request $request) + { + $data['submit_files'] = json_encode($data['submit_files']); + return $data; + } + + + /** + * 生成唯一的付款申请编码 + * 格式:PA + 日期 + 6位字母数字组合 + * + * @return string 唯一编码 + */ + public function generateUniqueApplyNo() + { + $chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $maxAttempts = 10; // 防止无限循环 + $secondChar = 'PA' . date('Ymd'); + + for ($attempt = 0; $attempt < $maxAttempts; $attempt++) { + // 生成后6位随机字符 + $suffix = ''; + for ($i = 0; $i < 6; $i++) { + $suffix .= $chars[rand(0, strlen($chars) - 1)]; + } + + $applyNo = $secondChar . $suffix; + + // 检查是否已存在 + $existing = FinPaymentApply::where('apply_no', $applyNo)->first(); + if (!$existing) { + return $applyNo; + } + } + + // 如果1000次尝试后仍然重复,使用时间戳确保唯一性 + $timestamp = substr(time(), -6); + return $secondChar . $timestamp; + } +} \ No newline at end of file diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php new file mode 100644 index 0000000..2cc781c --- /dev/null +++ b/app/common/service/FinReceiptService.php @@ -0,0 +1,127 @@ +validator; + } + + + /** + * 构建查询条件 + */ + protected function buildQueryConfig(Request $request, string $scene = 'index'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'index': + // ====== ====== 排序 ====== ====== + $config['order']['id'] = 'desc'; + + // ====== ====== 筛选 ====== ====== + // 汇款国家 + if (isset($p['country_id']) && !empty($p['country_id'])) { + $config['where']['country_id'] = $p['country_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'] . '%'; + $config['orWhere'][] = ['remitter', 'like', $k]; + } + break; + case 'show': + $config['where']['id'] = $p['id']; + break; + case 'update': + case 'destroy': + $config['where']['id'] = $p['id']; + break; + case 'store': + break; + } + + return $config; + } + + public function beforeServiceStore($data, Request $request) + { + if(isset($data['payment_apply_id']) && empty($data['payment_apply_id'])){ + unset($data['payment_apply_id']); + } + $data['receipt_no'] = $this->generateUniqueReceipt(); + $data['arrived_at'] = strtotime( $data['arrived_at']); + return $data; + } + + public function beforeServiceUpdate($data, Request $request) + { + $data['arrived_at'] = strtotime( $data['arrived_at']); + $data['received_at'] = strtotime( $data['received_at']); + return $data; + } + + + /** + * 生成唯一的付款申请编码 + * 格式:PA + 日期 + 6位字母数字组合 + * + * @return string 唯一编码 + */ + public function generateUniqueReceipt() + { + $chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $maxAttempts = 10; // 防止无限循环 + $secondChar = 'RE' . date('Ymd'); + + for ($attempt = 0; $attempt < $maxAttempts; $attempt++) { + // 生成后6位随机字符 + $suffix = ''; + for ($i = 0; $i < 6; $i++) { + $suffix .= $chars[rand(0, strlen($chars) - 1)]; + } + + $ReceiptNo = $secondChar . $suffix; + + // 检查是否已存在 + $existing = FinReceipt::where('receipt_no', $ReceiptNo)->first(); + if (!$existing) { + return $ReceiptNo; + } + } + + // 如果1000次尝试后仍然重复,使用时间戳确保唯一性 + $timestamp = substr(time(), -6); + return $secondChar . $timestamp; + } +} \ No newline at end of file diff --git a/app/common/validate/FinPaymentApplyValidate.php b/app/common/validate/FinPaymentApplyValidate.php new file mode 100644 index 0000000..58145e3 --- /dev/null +++ b/app/common/validate/FinPaymentApplyValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/common/validate/FinReceiptValidate.php b/app/common/validate/FinReceiptValidate.php new file mode 100644 index 0000000..c006dee --- /dev/null +++ b/app/common/validate/FinReceiptValidate.php @@ -0,0 +1,56 @@ + 'integer|gt:0', + 'country_id' => 'require|integer|gt:0', + 'remitter' => 'require', + 'account_id' => 'require|integer|gt:0', + 'currency_id' => 'require|integer|gt:0', + 'amount' => 'require|gt:0', + 'exchange_rate' => 'require|gt:0', + 'arrived_at' => 'require', + 'is_domestic_return' => 'require|integer', + ]; + + // 提示 + protected $message = [ + 'payment_apply_id.integer' => '付款申请ID必须是整数', + 'payment_apply_id.gt' => '付款申请ID必须大于0', + 'country_id.require' => '付款来源国家ID不能为空', + 'country_id.integer' => '付款来源国家ID必须是整数', + 'country_id.gt' => '付款来源国家ID必须大于0', + 'remitter.require' => '汇款人不能为空', + 'account_id.require' => '收款账号ID不能为空', + 'account_id.integer' => '收款账号ID必须是整数', + 'account_id.gt' => '收款账号ID必须大于0', + 'currency_id.require' => '收款币种ID不能为空', + 'currency_id.integer' => '收款币种ID必须是整数', + 'currency_id.gt' => '收款币种ID必须大于0', + 'amount.require' => '收款金额不能为空', + 'amount.gt' => '收款金额必须大于0', + 'exchange_rate.require' => '实际汇率不能为空', + 'exchange_rate.gt' => '实际汇率必须大于0', + 'arrived_at.require' => '到账时间不能为空', + 'arrived_at.gt' => '到账时间必须大于0', + 'is_domestic_return.require' => '是否回转内地不能为空', + 'is_domestic_return.integer' => '是否回转内地必须是整数', + ]; + + // 场景 + protected $scene = [ + 'store' => [ + 'payment_apply_id', 'country_id', 'remitter', 'account_id', 'currency_id', 'amount', 'exchange_rate', 'arrived_at' + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/controller/IndexController.php b/app/controller/IndexController.php index b25b5a4..cf30328 100644 --- a/app/controller/IndexController.php +++ b/app/controller/IndexController.php @@ -70,27 +70,27 @@ class IndexController public function createResource() { $options = [ - 'controller' => [ - 'module' => 'crm', - 'name' => 'approval_flows' - ], +// 'controller' => [ +// 'module' => 'common', +// 'name' => 'fin_payment_apply' +// ], 'model' => [ - 'module' => 'crm', - 'name' => 'approval_flows' + 'module' => 'common', + 'name' => 'fin_payment_stock' ], - 'service' => [ - 'module' => 'crm', - 'name' => 'approval_flows' - ], - 'logic' => [ - 'module' => 'crm', - 'name' => 'approval_flows' - ], - 'validate' => [ - 'module' => 'crm', - 'name' => 'approval_flows' - ], - 'table' => 'approval_flows' +// 'service' => [ +// 'module' => 'common', +// 'name' => 'fin_payment_apply' +// ], +// 'logic' => [ +// 'module' => 'common', +// 'name' => 'fin_payment_apply' +// ], +// 'validate' => [ +// 'module' => 'common', +// 'name' => 'fin_payment_apply' +// ], + 'table' => 'fin_payment_stock' ]; $result = (new Generate($options))->doGenerate(); diff --git a/config/route.php b/config/route.php index 887c683..087fcf8 100644 --- a/config/route.php +++ b/config/route.php @@ -351,6 +351,24 @@ Route::group('/admin', function () { Route::any('/user/achieved', [app\admin\targets\controller\StatisticsController::class, 'userAchieved']); }); }); + + // 收款记录 + Route::group('/receipt', function () { + Route::any('/list', [app\common\controller\FinReceiptController::class, 'index']); + Route::any('/show', [app\common\controller\FinReceiptController::class, 'show']); + Route::any('/store', [app\common\controller\FinReceiptController::class, 'store']); + Route::any('/update', [app\common\controller\FinReceiptController::class, 'update']); + 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']); + 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']); + }); }); From 4717bb01ca52dfb3c8ebebf4c617b34155dc71ef Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 23 Sep 2025 15:14:08 +0800 Subject: [PATCH 02/39] =?UTF-8?q?=E4=BB=98=E6=AC=BE=E4=B8=8E=E6=94=B6?= =?UTF-8?q?=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/model/FinPaymentApply.php | 8 +++ app/common/model/FinPaymentStock.php | 4 +- app/common/model/FinReceipt.php | 14 ++++-- app/common/model/FinReceiptHis.php | 49 +++++++++++++++++++ app/common/model/StockOrders.php | 8 +++ app/common/service/FinPaymentApplyService.php | 19 +++++++ app/common/service/FinReceiptService.php | 4 +- app/controller/IndexController.php | 4 +- 8 files changed, 102 insertions(+), 8 deletions(-) create mode 100644 app/common/model/FinReceiptHis.php diff --git a/app/common/model/FinPaymentApply.php b/app/common/model/FinPaymentApply.php index 2fb04a7..0556210 100644 --- a/app/common/model/FinPaymentApply.php +++ b/app/common/model/FinPaymentApply.php @@ -62,4 +62,12 @@ class FinPaymentApply extends Model { return $this->belongsToMany(StockOrders::class, 'fin_payment_stock', 'payment_apply_id', 'stock_id'); } + + /** + * 关联的备货单(通过中间表) + */ + public function stocks() + { + return $this->belongsToMany(StockOrders::class, 'fin_payment_stock', 'payment_apply_id', 'stock_id'); + } } \ No newline at end of file diff --git a/app/common/model/FinPaymentStock.php b/app/common/model/FinPaymentStock.php index 6f4a3ba..d5b3d10 100644 --- a/app/common/model/FinPaymentStock.php +++ b/app/common/model/FinPaymentStock.php @@ -40,7 +40,7 @@ class FinPaymentStock extends Model /** * 允许自动填充模型字段 */ - protected $fillable = ['id', 'payment_apply_id', 'receipt_id', 'stock_id', 'allocated_amount', 'allocated_amount_cny']; + protected $fillable = ['id', 'pi_no', 'payment_apply_id', 'receipt_id', 'stock_id', 'allocated_amount', 'allocated_amount_cny', 'updated_at', 'created_at']; /** * 不允许自动填充模型字段 @@ -59,7 +59,7 @@ class FinPaymentStock extends Model return $this->belongsTo(FinReceipt::class, 'receipt_id', 'id'); } - // 付款申请 + // 备货单 public function stock() { return $this->belongsTo(StockOrders::class, 'stock_id', 'id'); diff --git a/app/common/model/FinReceipt.php b/app/common/model/FinReceipt.php index a98914f..c87ab12 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', 'is_domestic_return', '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', 'is_domestic_return', 'created_by', 'updated_by', 'created_at', 'updated_at']; /** * 不允许自动填充模型字段 @@ -48,11 +48,11 @@ class FinReceipt extends Model protected $guarded = []; /** - * 获取付款申请 + * 对应的付款申请(1-1,可为空) */ public function payment() { - return $this->hasOne(FinPaymentApply::class, 'id', 'payment_apply_id'); + return $this->belongsTo(FinPaymentApply::class, 'payment_apply_id', 'id'); } /** @@ -62,4 +62,12 @@ class FinReceipt extends Model { return $this->belongsToMany(StockOrders::class, 'fin_payment_stock', 'receipt_id', 'stock_id'); } + + /** + * 关联的备货单(通过中间表) + */ + public function stocks() + { + return $this->belongsToMany(StockOrders::class, 'fin_payment_stock', 'receipt_id', 'stock_id'); + } } \ No newline at end of file diff --git a/app/common/model/FinReceiptHis.php b/app/common/model/FinReceiptHis.php new file mode 100644 index 0000000..814b87f --- /dev/null +++ b/app/common/model/FinReceiptHis.php @@ -0,0 +1,49 @@ +belongsToMany(FinPaymentApply::class, 'fin_payment_stock', 'stock_id', 'payment_apply_id'); } + + /** + * 关联收款记录(多对多,经由中间表) + */ + public function receipts() + { + return $this->belongsToMany(FinReceipt::class, 'fin_payment_stock', 'stock_id', 'receipt_id'); + } } \ No newline at end of file diff --git a/app/common/service/FinPaymentApplyService.php b/app/common/service/FinPaymentApplyService.php index 00ad976..d7912e1 100644 --- a/app/common/service/FinPaymentApplyService.php +++ b/app/common/service/FinPaymentApplyService.php @@ -2,9 +2,11 @@ namespace app\common\service; +use app\common\model\FinPaymentStock; use app\common\validate\FinPaymentApplyValidate; use app\common\traits\crud\CrudServiceTrait; use app\common\model\FinPaymentApply; +use support\Redis; use support\Request; class FinPaymentApplyService @@ -61,10 +63,27 @@ class FinPaymentApplyService public function beforeServiceStore($data, Request $request) { $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'))); return $data; } + + public function afterServiceStore($res) + { + $data = [ + 'payment_apply_id' => $res['id'], + ]; + $stock = json_decode(redis::get('stock'.$res['doc_user_id']), true); + redis::del('stock'); + foreach ($stock as $k => $v) { + $data['stock_id'] = $v['stock_id']; + $data['pi_no'] = $v['pi_on']; + FinPaymentStock::create($data); + } + } + public function beforeServiceUpdate($data, Request $request) { $data['submit_files'] = json_encode($data['submit_files']); diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php index 2cc781c..3a7832d 100644 --- a/app/common/service/FinReceiptService.php +++ b/app/common/service/FinReceiptService.php @@ -80,12 +80,14 @@ class FinReceiptService unset($data['payment_apply_id']); } $data['receipt_no'] = $this->generateUniqueReceipt(); - $data['arrived_at'] = strtotime( $data['arrived_at']); + $data['arrived_at'] = $request->user->uid; + $data['updated_by'] = $request->user->uid; return $data; } public function beforeServiceUpdate($data, Request $request) { + $data['updated_by'] = $request->user->uid; $data['arrived_at'] = strtotime( $data['arrived_at']); $data['received_at'] = strtotime( $data['received_at']); return $data; diff --git a/app/controller/IndexController.php b/app/controller/IndexController.php index cf30328..e92751b 100644 --- a/app/controller/IndexController.php +++ b/app/controller/IndexController.php @@ -76,7 +76,7 @@ class IndexController // ], 'model' => [ 'module' => 'common', - 'name' => 'fin_payment_stock' + 'name' => 'fin_receipt_his' ], // 'service' => [ // 'module' => 'common', @@ -90,7 +90,7 @@ class IndexController // 'module' => 'common', // 'name' => 'fin_payment_apply' // ], - 'table' => 'fin_payment_stock' + 'table' => 'fin_receipt_his' ]; $result = (new Generate($options))->doGenerate(); From e6d3cc3f047e365c0f76fc0ba0e6eb60c6ae8892 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 23 Sep 2025 16:45:06 +0800 Subject: [PATCH 03/39] =?UTF-8?q?=E4=BB=98=E6=AC=BE=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E7=9B=B8=E5=85=B3=E5=AD=97=E6=AE=B5=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FinPaymentApplyController.php | 65 ++++++++++++++++--- app/common/service/FinPaymentApplyService.php | 6 +- app/common/service/FinReceiptService.php | 28 ++++++++ config/route.php | 2 +- 4 files changed, 89 insertions(+), 12 deletions(-) diff --git a/app/common/controller/FinPaymentApplyController.php b/app/common/controller/FinPaymentApplyController.php index 2d0f22e..76e51bf 100644 --- a/app/common/controller/FinPaymentApplyController.php +++ b/app/common/controller/FinPaymentApplyController.php @@ -1,7 +1,13 @@ 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; + } } \ No newline at end of file diff --git a/app/common/service/FinPaymentApplyService.php b/app/common/service/FinPaymentApplyService.php index d7912e1..535d621 100644 --- a/app/common/service/FinPaymentApplyService.php +++ b/app/common/service/FinPaymentApplyService.php @@ -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']; diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php index 3a7832d..53d61ff 100644 --- a/app/common/service/FinReceiptService.php +++ b/app/common/service/FinReceiptService.php @@ -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); + } /** diff --git a/config/route.php b/config/route.php index 087fcf8..f2c9cb7 100644 --- a/config/route.php +++ b/config/route.php @@ -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']); From 1d6caad7b08f15c56d69db3482f888675338e723 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 23 Sep 2025 17:33:09 +0800 Subject: [PATCH 04/39] =?UTF-8?q?=E4=BB=98=E6=AC=BE=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E7=BB=93=E6=9E=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/FinReceiptController.php | 15 +++++++++++++++ app/common/service/FinPaymentApplyService.php | 14 ++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/app/common/controller/FinReceiptController.php b/app/common/controller/FinReceiptController.php index 4acf899..c80dc3a 100644 --- a/app/common/controller/FinReceiptController.php +++ b/app/common/controller/FinReceiptController.php @@ -2,6 +2,9 @@ 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\traits\crud\CrudControllerTrait; use app\common\service\FinReceiptService; @@ -32,6 +35,12 @@ class FinReceiptController extends BaseController $data['arrived_at'] = date('Y-m-d H:i:s', $data['arrived_at']); if (isset($data['received_at'])) $data['received_at'] = date('Y-m-d H:i:s', $data['received_at']); + 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; return $data; } @@ -51,6 +60,12 @@ class FinReceiptController extends BaseController $data['arrived_at'] = date('Y-m-d H:i:s', $data['arrived_at']); if (isset($data['received_at'])) $data['received_at'] = date('Y-m-d H:i:s', $data['received_at']); + 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; return $data; } } \ No newline at end of file diff --git a/app/common/service/FinPaymentApplyService.php b/app/common/service/FinPaymentApplyService.php index 535d621..14b9d64 100644 --- a/app/common/service/FinPaymentApplyService.php +++ b/app/common/service/FinPaymentApplyService.php @@ -66,6 +66,7 @@ class FinPaymentApplyService $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')), 'EX', 30); + unset($data['stock']); return $data; } @@ -75,12 +76,14 @@ class FinPaymentApplyService $data = [ 'payment_apply_id' => $res['id'], ]; - $stock = json_decode(redis::get('stock_' . $res['doc_user_id']), true); + $piStock = 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']; - FinPaymentStock::create($data); + foreach ($piStock as $stock) { + foreach ($stock['stock_id'] as $v) { + $data['stock_id'] = $v; + $data['pi_no'] = $stock['pi_on']; + FinPaymentStock::create($data); + } } } @@ -90,7 +93,6 @@ class FinPaymentApplyService return $data; } - /** * 生成唯一的付款申请编码 * 格式:PA + 日期 + 6位字母数字组合 From 870bca5e578a5d697491cd8b3f425c71962b6099 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 23 Sep 2025 18:26:17 +0800 Subject: [PATCH 05/39] =?UTF-8?q?=E4=BB=98=E6=AC=BE=E8=AF=A6=E6=83=85-?= =?UTF-8?q?=E5=A4=87=E8=B4=A7=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/FinPaymentApplyController.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/common/controller/FinPaymentApplyController.php b/app/common/controller/FinPaymentApplyController.php index 76e51bf..3d82e92 100644 --- a/app/common/controller/FinPaymentApplyController.php +++ b/app/common/controller/FinPaymentApplyController.php @@ -4,6 +4,7 @@ namespace app\common\controller; use app\common\controller\BaseController; use app\common\model\Country; +use app\common\model\FinPaymentStock; use app\common\model\SysAccount; use app\common\model\SysCurrency; use app\common\model\SysDictItem; @@ -39,7 +40,7 @@ class FinPaymentApplyController extends BaseController 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; + $data['country_name'] = Country::where('id', $data['country_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'])) @@ -68,7 +69,7 @@ class FinPaymentApplyController extends BaseController 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; + $data['country_name'] = Country::where('id', $data['country_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'])) @@ -77,6 +78,14 @@ class FinPaymentApplyController extends BaseController $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']); + + $finPaymentStock = FinPaymentStock::where('payment_apply_id', $data['id'])->get(); + $stock = []; + foreach ($finPaymentStock as $v) { + $stock[$v['pi_no']] = ['pi_no' => $v['pi_no']]; + $stock[$v['pi_no']]['stock_id'] = [$v['stock_id']]; + } + $data['stock'] = $stock; return $data; } } \ No newline at end of file From db10ece6b702b15188a2b74800018be5439a54a8 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 23 Sep 2025 18:30:13 +0800 Subject: [PATCH 06/39] =?UTF-8?q?=E4=BB=98=E6=AC=BE=E8=AF=A6=E6=83=85-?= =?UTF-8?q?=E5=A4=87=E8=B4=A7=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/FinPaymentApplyController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/common/controller/FinPaymentApplyController.php b/app/common/controller/FinPaymentApplyController.php index 3d82e92..abf31a8 100644 --- a/app/common/controller/FinPaymentApplyController.php +++ b/app/common/controller/FinPaymentApplyController.php @@ -85,7 +85,7 @@ class FinPaymentApplyController extends BaseController $stock[$v['pi_no']] = ['pi_no' => $v['pi_no']]; $stock[$v['pi_no']]['stock_id'] = [$v['stock_id']]; } - $data['stock'] = $stock; + $data['stock'] = array_values($stock); return $data; } } \ No newline at end of file From 54f83679ea79c08b3fd3366bc2f8a6b9f3537b37 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 23 Sep 2025 18:38:02 +0800 Subject: [PATCH 07/39] =?UTF-8?q?=E6=94=B6=E6=AC=BE=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/service/FinReceiptService.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php index 53d61ff..e50bc7d 100644 --- a/app/common/service/FinReceiptService.php +++ b/app/common/service/FinReceiptService.php @@ -93,7 +93,8 @@ class FinReceiptService unset($data['payment_apply_id']); } $data['receipt_no'] = $this->generateUniqueReceipt(); - $data['arrived_at'] = $request->user->uid; + $data['arrived_at'] = strtotime( $data['arrived_at']); + $data['created_by'] = $request->user->uid; $data['updated_by'] = $request->user->uid; return $data; } @@ -109,8 +110,10 @@ class FinReceiptService public function beforeServiceUpdate($data, Request $request) { $data['updated_by'] = $request->user->uid; - $data['arrived_at'] = strtotime( $data['arrived_at']); - $data['received_at'] = strtotime( $data['received_at']); + $data['arrived_at'] = strtotime($data['arrived_at']); + if(isset($data['received_at'])) + $data['received_at'] = strtotime($data['received_at']); + return $data; } public function afterServiceUpdate($res) From abc1142e88e1707d4e1aeaf0070ff691fb8c3897 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Wed, 24 Sep 2025 10:16:34 +0800 Subject: [PATCH 08/39] =?UTF-8?q?=E7=BB=91=E5=AE=9A=E4=BB=98=E6=AC=BE?= =?UTF-8?q?=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/service/FinReceiptService.php | 9 ++-- app/common/validate/FinReceiptValidate.php | 62 +++++++++++----------- config/route.php | 1 + 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php index e50bc7d..bf83f38 100644 --- a/app/common/service/FinReceiptService.php +++ b/app/common/service/FinReceiptService.php @@ -54,6 +54,8 @@ class FinReceiptService // 没有付款记录的收款记录 if (isset($p['payment_apply']) && $p['payment_apply'] == 'not') { + $config['where']['payment_apply_id'] = ['null']; + } elseif (isset($p['payment_apply']) && $p['payment_apply'] == 'already') { $config['where']['payment_apply_id'] = ['not null']; } @@ -110,7 +112,8 @@ class FinReceiptService public function beforeServiceUpdate($data, Request $request) { $data['updated_by'] = $request->user->uid; - $data['arrived_at'] = strtotime($data['arrived_at']); + if(isset($data['arrived_at'])) + $data['arrived_at'] = strtotime($data['arrived_at']); if(isset($data['received_at'])) $data['received_at'] = strtotime($data['received_at']); @@ -118,8 +121,8 @@ class FinReceiptService } public function afterServiceUpdate($res) { - $receipt = FinReceipt::where('id',$res->id)->first()->toArray(); - $receipt = array_merge($receipt,['receipt_id' => $res->id]); + $receipt = FinReceipt::where('id',$res['id'])->first()->toArray(); + $receipt = array_merge($receipt,['receipt_id' => $res['id']]); unset($receipt['id']); FinReceiptHis::create($receipt); } diff --git a/app/common/validate/FinReceiptValidate.php b/app/common/validate/FinReceiptValidate.php index c006dee..237b03e 100644 --- a/app/common/validate/FinReceiptValidate.php +++ b/app/common/validate/FinReceiptValidate.php @@ -8,49 +8,49 @@ class FinReceiptValidate extends Validate { // 规则 protected $rule = [ - 'payment_apply_id' => 'integer|gt:0', - 'country_id' => 'require|integer|gt:0', - 'remitter' => 'require', - 'account_id' => 'require|integer|gt:0', - 'currency_id' => 'require|integer|gt:0', - 'amount' => 'require|gt:0', - 'exchange_rate' => 'require|gt:0', - 'arrived_at' => 'require', - 'is_domestic_return' => 'require|integer', +// 'payment_apply_id' => 'integer|gt:0', +// 'country_id' => 'require|integer|gt:0', +// 'remitter' => 'require', +// 'account_id' => 'require|integer|gt:0', +// 'currency_id' => 'require|integer|gt:0', +// 'amount' => 'require|gt:0', +// 'exchange_rate' => 'require|gt:0', +// 'arrived_at' => 'require', +// 'is_domestic_return' => 'require|integer', ]; // 提示 protected $message = [ - 'payment_apply_id.integer' => '付款申请ID必须是整数', - 'payment_apply_id.gt' => '付款申请ID必须大于0', - 'country_id.require' => '付款来源国家ID不能为空', - 'country_id.integer' => '付款来源国家ID必须是整数', - 'country_id.gt' => '付款来源国家ID必须大于0', - 'remitter.require' => '汇款人不能为空', - 'account_id.require' => '收款账号ID不能为空', - 'account_id.integer' => '收款账号ID必须是整数', - 'account_id.gt' => '收款账号ID必须大于0', - 'currency_id.require' => '收款币种ID不能为空', - 'currency_id.integer' => '收款币种ID必须是整数', - 'currency_id.gt' => '收款币种ID必须大于0', - 'amount.require' => '收款金额不能为空', - 'amount.gt' => '收款金额必须大于0', - 'exchange_rate.require' => '实际汇率不能为空', - 'exchange_rate.gt' => '实际汇率必须大于0', - 'arrived_at.require' => '到账时间不能为空', - 'arrived_at.gt' => '到账时间必须大于0', - 'is_domestic_return.require' => '是否回转内地不能为空', - 'is_domestic_return.integer' => '是否回转内地必须是整数', +// 'payment_apply_id.integer' => '付款申请ID必须是整数', +// 'payment_apply_id.gt' => '付款申请ID必须大于0', +// 'country_id.require' => '付款来源国家ID不能为空', +// 'country_id.integer' => '付款来源国家ID必须是整数', +// 'country_id.gt' => '付款来源国家ID必须大于0', +// 'remitter.require' => '汇款人不能为空', +// 'account_id.require' => '收款账号ID不能为空', +// 'account_id.integer' => '收款账号ID必须是整数', +// 'account_id.gt' => '收款账号ID必须大于0', +// 'currency_id.require' => '收款币种ID不能为空', +// 'currency_id.integer' => '收款币种ID必须是整数', +// 'currency_id.gt' => '收款币种ID必须大于0', +// 'amount.require' => '收款金额不能为空', +// 'amount.gt' => '收款金额必须大于0', +// 'exchange_rate.require' => '实际汇率不能为空', +// 'exchange_rate.gt' => '实际汇率必须大于0', +// 'arrived_at.require' => '到账时间不能为空', +// 'arrived_at.gt' => '到账时间必须大于0', +// 'is_domestic_return.require' => '是否回转内地不能为空', +// 'is_domestic_return.integer' => '是否回转内地必须是整数', ]; // 场景 protected $scene = [ 'store' => [ - 'payment_apply_id', 'country_id', 'remitter', 'account_id', 'currency_id', 'amount', 'exchange_rate', 'arrived_at' +// 'payment_apply_id', 'country_id', 'remitter', 'account_id', 'currency_id', 'amount', 'exchange_rate', 'arrived_at' ], 'update' => [ - +// 'payment_apply_id' ] ]; } \ No newline at end of file diff --git a/config/route.php b/config/route.php index f2c9cb7..be37a5b 100644 --- a/config/route.php +++ b/config/route.php @@ -358,6 +358,7 @@ Route::group('/admin', function () { Route::any('/show', [app\common\controller\FinReceiptController::class, 'show']); 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, 'update']); Route::any('/destroy', [app\common\controller\FinReceiptController::class, 'destroy']); }); From 435d3ce67737213c36f5faaa5a307182b08f7dd7 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Wed, 24 Sep 2025 15:23:47 +0800 Subject: [PATCH 09/39] =?UTF-8?q?=E4=BB=98=E6=AC=BE=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FinPaymentApplyController.php | 14 ++- app/common/model/FinPaymentApply.php | 10 +- app/common/service/FinPaymentApplyService.php | 106 ++++++++++++++++++ 3 files changed, 120 insertions(+), 10 deletions(-) diff --git a/app/common/controller/FinPaymentApplyController.php b/app/common/controller/FinPaymentApplyController.php index abf31a8..3d35f09 100644 --- a/app/common/controller/FinPaymentApplyController.php +++ b/app/common/controller/FinPaymentApplyController.php @@ -9,6 +9,7 @@ use app\common\model\SysAccount; use app\common\model\SysCurrency; use app\common\model\SysDictItem; use app\common\model\User; +use app\common\service\OssService; use app\common\traits\crud\CrudControllerTrait; use app\common\service\FinPaymentApplyService; @@ -43,8 +44,19 @@ class FinPaymentApplyController extends BaseController $data['country_name'] = Country::where('id', $data['country_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'])) + $OssService = new OssService(); + if (isset($data['submit_files'])){ $data['submit_files'] = json_decode($data['submit_files'], true); + foreach ($data['submit_files'] as $key => $value) { + $data['submit_files'][$key] = [ + 'file_src' => $value['file_src'], + 'file_full' => $OssService->generatePrivateUrl($value['file_src']), + 'file_name' => $value['file_name'], + ]; + } + } + if (isset($data['voucher_file'])) + $data['voucher_file_full'] = $OssService->generatePrivateUrl($data['voucher_file']); if (isset($data['created_at'])) $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); if (isset($data['updated_at'])) diff --git a/app/common/model/FinPaymentApply.php b/app/common/model/FinPaymentApply.php index 0556210..f02f137 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', 'currency_id', 'amount', 'swift', 'remit_bank', 'country_id', 'remitter', 'exchange_rate', 'total_amount_cny', 'voucher_file', 'submit_files', 'created_at', 'updated_at']; + protected $fillable = ['id', 'apply_no', 'doc_user_id', 'sales_user_id', 'corp_id', 'account_id', 'currency_id', 'amount', 'swift', 'remit_bank', 'country_id', 'remitter', 'exchange_rate', 'total_amount_cny', 'voucher_file', 'voucher_name', 'submit_files', 'created_at', 'updated_at']; /** * 不允许自动填充模型字段 @@ -55,14 +55,6 @@ class FinPaymentApply extends Model return $this->hasOne(FinReceipt::class, 'payment_apply_id', 'id'); } - /** - * 备货单 - */ - public function stock() - { - return $this->belongsToMany(StockOrders::class, 'fin_payment_stock', 'payment_apply_id', 'stock_id'); - } - /** * 关联的备货单(通过中间表) */ diff --git a/app/common/service/FinPaymentApplyService.php b/app/common/service/FinPaymentApplyService.php index 14b9d64..294bc01 100644 --- a/app/common/service/FinPaymentApplyService.php +++ b/app/common/service/FinPaymentApplyService.php @@ -45,6 +45,23 @@ class FinPaymentApplyService case 'index': // ====== ====== 排序 ====== ====== $config['order']['id'] = 'desc'; + + // ====== ====== 筛选 ====== ====== + // 汇款国家 + if (isset($p['country_id']) && !empty($p['country_id'])) { + $config['where']['country_id'] = $p['country_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'] . '%'; + $config['orWhere'][] = ['remitter', 'like', $k]; + } break; case 'show': $config['where']['id'] = $p['id']; @@ -125,4 +142,93 @@ class FinPaymentApplyService $timestamp = substr(time(), -6); return $secondChar . $timestamp; } + + /** + * 根据相似度排序付款记录 + * @param Request $request + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator|\Illuminate\Pagination\LengthAwarePaginator + */ + public function complexQueryIndex(Request $request) + { + $limit = (int)$request->get('size', 15); + $page = (int)$request->get('current', 1); + $param = $request->all(); + + $where = []; + + // 汇款国家 + if (isset($param['country_id']) && !empty($param['country_id'])) { + $where[] = ['country_id', $param['country_id']]; + } + // 收款账户筛选 + if (isset($param['account_id']) && !empty($param['account_id'])) { + $where[] = ['account_id', $param['account_id']]; + } + + // 关键字 + if (isset($param['keyword']) && $param['keyword']) { + $k = '%' . $param['keyword'] . '%'; + $where[] = ['remitter', 'like', $k]; + } + + // 构建查询 + $query = $this->modelClass::where($where); + + // 应用是否有关联收款记录的筛选 + $correlation = $param['correlation']??''; + if ($correlation === 'receipt') { + $query->whereHas('receipt'); + } elseif ($correlation === 'unbind') { + $query->whereDoesntHave('receipt'); + } + + if (isset($param['scene']) && $param['scene'] == 'list') { + return $query->paginate($limit, ['*'], 'page', $page); + } + + // 计算七天前的时间戳 + $sevenDaysAgo = time() - (10 * 24 * 60 * 60); + + // 构建相似度排序逻辑 + $similarityOrder = []; + + // 如果有传入参数,计算相似度 + if (isset($param['account_id']) && !empty($param['account_id'])) { + $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['keyword']) && $param['keyword']) { + $keyword = addslashes($param['keyword']); + $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)) { + $orderByClause = "CASE + WHEN created_at >= {$sevenDaysAgo} THEN + (" . implode(' + ', $similarityOrder) . ") + ELSE 999999 + END ASC, "; + } + + $orderByClause .= "CASE + WHEN created_at < {$sevenDaysAgo} THEN id + ELSE 0 + END DESC"; + + $query->orderByRaw($orderByClause); + + return $query->paginate($limit, ['*'], 'page', $page); + } + } \ No newline at end of file From 82e4435a2cca7569342524a33d270f5018484385 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Wed, 24 Sep 2025 17:49:14 +0800 Subject: [PATCH 10/39] =?UTF-8?q?=E6=94=B6=E6=B1=87=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/FinReceiptController.php | 5 +++++ app/common/model/FinReceipt.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/common/controller/FinReceiptController.php b/app/common/controller/FinReceiptController.php index c80dc3a..a443537 100644 --- a/app/common/controller/FinReceiptController.php +++ b/app/common/controller/FinReceiptController.php @@ -5,6 +5,7 @@ use app\common\controller\BaseController; use app\common\model\Country; use app\common\model\SysAccount; use app\common\model\SysCurrency; +use app\common\service\OssService; use app\common\traits\crud\CrudControllerTrait; use app\common\service\FinReceiptService; @@ -41,6 +42,8 @@ class FinReceiptController extends BaseController $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['fx_receipt_file'])) + $data['fx_receipt_file_full'] = (new OssService)->generatePrivateUrl($data['fx_receipt_file']); return $data; } @@ -66,6 +69,8 @@ class FinReceiptController extends BaseController $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['fx_receipt_file'])) + $data['fx_receipt_file_full'] = (new OssService)->generatePrivateUrl($data['fx_receipt_file']); return $data; } } \ No newline at end of file diff --git a/app/common/model/FinReceipt.php b/app/common/model/FinReceipt.php index c87ab12..dbefafa 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', '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', 'created_by', 'updated_by', 'created_at', 'updated_at']; /** * 不允许自动填充模型字段 From e0b11718a744fc3d1dd51ee53d6379ba1ecd4018 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Wed, 24 Sep 2025 17:55:16 +0800 Subject: [PATCH 11/39] =?UTF-8?q?=E6=94=B6=E6=AC=BE=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=85=B3=E8=81=94=E5=A4=87=E8=B4=A7=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/model/FinReceipt.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/common/model/FinReceipt.php b/app/common/model/FinReceipt.php index dbefafa..7347be0 100644 --- a/app/common/model/FinReceipt.php +++ b/app/common/model/FinReceipt.php @@ -55,14 +55,6 @@ class FinReceipt extends Model return $this->belongsTo(FinPaymentApply::class, 'payment_apply_id', 'id'); } - /** - * 备货单 - */ - public function stock() - { - return $this->belongsToMany(StockOrders::class, 'fin_payment_stock', 'receipt_id', 'stock_id'); - } - /** * 关联的备货单(通过中间表) */ From ec2502cd586a2060a0862ffa8b37b6fa1045dd47 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Thu, 25 Sep 2025 17:48:31 +0800 Subject: [PATCH 12/39] =?UTF-8?q?=E6=94=B6=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/service/FinReceiptService.php | 95 +++++++++++++++++++++++- 1 file changed, 93 insertions(+), 2 deletions(-) diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php index bf83f38..2f77af5 100644 --- a/app/common/service/FinReceiptService.php +++ b/app/common/service/FinReceiptService.php @@ -59,7 +59,7 @@ class FinReceiptService $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']; } @@ -70,7 +70,7 @@ class FinReceiptService } // 关键字 - if (isset($p['keyword']) && $p['keyword']) { + if (isset($p['$query']) && $p['keyword']) { $k = '%' . $p['keyword'] . '%'; $config['orWhere'][] = ['remitter', 'like', $k]; } @@ -160,4 +160,95 @@ class FinReceiptService $timestamp = substr(time(), -6); return $secondChar . $timestamp; } + + /** + * 根据相似度排序付款记录 + * @param Request $request + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator|\Illuminate\Pagination\LengthAwarePaginator + */ + public function complexQueryIndex(Request $request) + { + $limit = (int)$request->get('size', 15); + $page = (int)$request->get('current', 1); + $param = $request->all(); + + $where = []; + + // 汇款国家 + if (isset($param['country_id']) && !empty($param['country_id'])) { + $where[] = ['country_id', $param['country_id']]; + } + // 收款账户筛选 + if (isset($param['account_id']) && !empty($param['account_id'])) { + $where[] = ['account_id', $param['account_id']]; + } + // 收款申请筛选 + if (isset($param['payment_apply_id']) && !empty($param['payment_apply_id'])) { + $where[]['payment_apply_id'] = $param['payment_apply_id']; + } + + // 关键字 + if (isset($param['keyword']) && $param['keyword']) { + $k = '%' . $param['keyword'] . '%'; + $where[] = ['remitter', 'like', $k]; + } + + // 构建查询 + $query = $this->modelClass::where($where); + + // 没有付款记录的收款记录 + if (isset($param['payment_apply']) && $param['payment_apply'] == 'not') { + $query->whereNull('payment_apply_id'); + } elseif (isset($param['payment_apply']) && $param['payment_apply'] == 'already') { + $query->whereNotNull('payment_apply_id'); + } + + if (isset($param['scene']) && $param['scene'] == 'list') { + return $query->paginate($limit, ['*'], 'page', $page); + } + + // 计算七天前的时间戳 + $sevenDaysAgo = time() - (10 * 24 * 60 * 60); + + // 构建相似度排序逻辑 + $similarityOrder = []; + + // 如果有传入参数,计算相似度 + if (isset($param['account_id']) && !empty($param['account_id'])) { + $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['keyword']) && $param['keyword']) { + $keyword = addslashes($param['keyword']); + $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)) { + $orderByClause = "CASE + WHEN created_at >= {$sevenDaysAgo} THEN + (" . implode(' + ', $similarityOrder) . ") + ELSE 999999 + END ASC, "; + } + + $orderByClause .= "CASE + WHEN created_at < {$sevenDaysAgo} THEN id + ELSE 0 + END DESC"; + + $query->orderByRaw($orderByClause); + + return $query->paginate($limit, ['*'], 'page', $page); + } } \ No newline at end of file From ae6cd4ec78739fee47a584d4b5c55b70c3ea157d Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Fri, 26 Sep 2025 16:43:09 +0800 Subject: [PATCH 13/39] =?UTF-8?q?=E5=8F=98=E6=9B=B4=E5=8E=86=E5=8F=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FinReceiptHisController.php | 77 +++++++++++++++++++ app/common/logic/FinReceiptHisLogic.php | 17 ++++ app/common/service/FinReceiptHisService.php | 62 +++++++++++++++ app/common/validate/FinReceiptHisValidate.php | 29 +++++++ config/route.php | 5 ++ 5 files changed, 190 insertions(+) create mode 100644 app/common/controller/FinReceiptHisController.php create mode 100644 app/common/logic/FinReceiptHisLogic.php create mode 100644 app/common/service/FinReceiptHisService.php create mode 100644 app/common/validate/FinReceiptHisValidate.php diff --git a/app/common/controller/FinReceiptHisController.php b/app/common/controller/FinReceiptHisController.php new file mode 100644 index 0000000..eb57d99 --- /dev/null +++ b/app/common/controller/FinReceiptHisController.php @@ -0,0 +1,77 @@ +service = new FinReceiptHisService(); + } + + /** + * 列表页数据格式化 + * + * @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']); + if (isset($data['arrived_at'])) + $data['arrived_at'] = date('Y-m-d H:i:s', $data['arrived_at']); + if (isset($data['received_at'])) + $data['received_at'] = date('Y-m-d H:i:s', $data['received_at']); + 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['fx_receipt_file'])) + $data['fx_receipt_file_full'] = (new OssService)->generatePrivateUrl($data['fx_receipt_file']); + return $data; + } + + /** + * 数据格式化 + * + * @param array $data + * @return array + */ + protected function showFormat($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']); + if (isset($data['arrived_at'])) + $data['arrived_at'] = date('Y-m-d H:i:s', $data['arrived_at']); + if (isset($data['received_at'])) + $data['received_at'] = date('Y-m-d H:i:s', $data['received_at']); + 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['fx_receipt_file'])) + $data['fx_receipt_file_full'] = (new OssService)->generatePrivateUrl($data['fx_receipt_file']); + return $data; + } +} \ No newline at end of file diff --git a/app/common/logic/FinReceiptHisLogic.php b/app/common/logic/FinReceiptHisLogic.php new file mode 100644 index 0000000..3e90dac --- /dev/null +++ b/app/common/logic/FinReceiptHisLogic.php @@ -0,0 +1,17 @@ +validator; + } + + /** + * 构建查询条件 + */ + protected function buildQueryConfig(Request $request, string $scene = 'index'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'index': + if(empty($p['receipt_id'])){ + throw new BusinessException('receipt_id不能为空'); + } + // ====== ====== 排序 ====== ====== + $config['order']['id'] = 'desc'; + + // ====== ====== 筛选 ====== ====== + $config['where']['receipt_id'] = $p['receipt_id']; + + break; + case 'show': + $config['where']['id'] = $p['id']; + break; + } + + return $config; + } +} \ No newline at end of file diff --git a/app/common/validate/FinReceiptHisValidate.php b/app/common/validate/FinReceiptHisValidate.php new file mode 100644 index 0000000..7a1f7c4 --- /dev/null +++ b/app/common/validate/FinReceiptHisValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/config/route.php b/config/route.php index be37a5b..3f7477f 100644 --- a/config/route.php +++ b/config/route.php @@ -361,6 +361,11 @@ Route::group('/admin', function () { Route::any('/payment', [app\common\controller\FinReceiptController::class, 'update']); Route::any('/destroy', [app\common\controller\FinReceiptController::class, 'destroy']); }); + // 收款记录历史 + Route::group('/receipt/his', function () { + Route::any('/list', [app\common\controller\FinReceiptHisController::class, 'index']); + Route::any('/show', [app\common\controller\FinReceiptHisController::class, 'show']); + }); // 付款申请 Route::group('/payment', function () { From 40dfd99f4e59d88952b30168e706af70b14c63b6 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Sun, 28 Sep 2025 09:47:09 +0800 Subject: [PATCH 14/39] =?UTF-8?q?=E5=85=B3=E8=81=94=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FinPaymentApplyController.php | 33 +++++++++++++------ .../controller/FinReceiptController.php | 15 +++++---- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/app/common/controller/FinPaymentApplyController.php b/app/common/controller/FinPaymentApplyController.php index 3d35f09..d8158fa 100644 --- a/app/common/controller/FinPaymentApplyController.php +++ b/app/common/controller/FinPaymentApplyController.php @@ -37,13 +37,13 @@ class FinPaymentApplyController extends BaseController 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; + $data['corp_name'] = SysDictItem::where('id', $data['corp_id'])->value('item_label')??''; if (isset($data['account_id'])) //收款账号 - $data['account_name'] = SysAccount::where('id', $data['account_id'])->first()->account_name; + $data['account_name'] = SysAccount::where('id', $data['account_id'])->value('account_name')??''; if (isset($data['country_id'])) //付款来源国家 - $data['country_name'] = Country::where('id', $data['country_id'])->first()->cn_addr; + $data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr')??''; if (isset($data['currency_id'])) //付款币种 - $data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->first()->currency_name; + $data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name')??''; $OssService = new OssService(); if (isset($data['submit_files'])){ $data['submit_files'] = json_decode($data['submit_files'], true); @@ -55,7 +55,8 @@ class FinPaymentApplyController extends BaseController ]; } } - if (isset($data['voucher_file'])) + $data['voucher_file_full'] = ''; + if (!empty($data['voucher_file'])) $data['voucher_file_full'] = $OssService->generatePrivateUrl($data['voucher_file']); if (isset($data['created_at'])) $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); @@ -77,15 +78,27 @@ class FinPaymentApplyController extends BaseController 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; + $data['corp_name'] = SysDictItem::where('id', $data['corp_id'])->value('item_label')??''; if (isset($data['account_id'])) //收款账号 - $data['account_name'] = SysAccount::where('id', $data['account_id'])->first()->account_name; + $data['account_name'] = SysAccount::where('id', $data['account_id'])->value('account_name')??''; if (isset($data['country_id'])) //付款来源国家 - $data['country_name'] = Country::where('id', $data['country_id'])->first()->cn_addr; + $data['country_name'] = Country::where('id', $data['country_id'])->value('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['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name')??''; + $OssService = new OssService(); + if (isset($data['submit_files'])){ $data['submit_files'] = json_decode($data['submit_files'], true); + foreach ($data['submit_files'] as $key => $value) { + $data['submit_files'][$key] = [ + 'file_src' => $value['file_src'], + 'file_full' => $OssService->generatePrivateUrl($value['file_src']), + 'file_name' => $value['file_name'], + ]; + } + } + $data['voucher_file_full'] = ''; + if (!empty($data['voucher_file'])) + $data['voucher_file_full'] = $OssService->generatePrivateUrl($data['voucher_file']); if (isset($data['created_at'])) $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); if (isset($data['updated_at'])) diff --git a/app/common/controller/FinReceiptController.php b/app/common/controller/FinReceiptController.php index a443537..3dcdf72 100644 --- a/app/common/controller/FinReceiptController.php +++ b/app/common/controller/FinReceiptController.php @@ -37,12 +37,13 @@ class FinReceiptController extends BaseController if (isset($data['received_at'])) $data['received_at'] = date('Y-m-d H:i:s', $data['received_at']); if (isset($data['account_id'])) //收款账号 - $data['account_name'] = SysAccount::where('id', $data['account_id'])->first()->account_name; + $data['account_name'] = SysAccount::where('id', $data['account_id'])->value('account_name')??''; if (isset($data['country_id'])) //付款来源国家 - $data['country_name'] = Country::where('id', $data['currency_id'])->first()->cn_addr; + $data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr')??''; if (isset($data['currency_id'])) //付款币种 - $data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->first()->currency_name; - if (isset($data['fx_receipt_file'])) + $data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name')??''; + $data['fx_receipt_file_full'] = ''; + if (!empty($data['fx_receipt_file'])) $data['fx_receipt_file_full'] = (new OssService)->generatePrivateUrl($data['fx_receipt_file']); return $data; } @@ -64,11 +65,11 @@ class FinReceiptController extends BaseController if (isset($data['received_at'])) $data['received_at'] = date('Y-m-d H:i:s', $data['received_at']); if (isset($data['account_id'])) //收款账号 - $data['account_name'] = SysAccount::where('id', $data['account_id'])->first()->account_name; + $data['account_name'] = SysAccount::where('id', $data['account_id'])->value('account_name')??''; if (isset($data['country_id'])) //付款来源国家 - $data['country_name'] = Country::where('id', $data['currency_id'])->first()->cn_addr; + $data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr')??''; if (isset($data['currency_id'])) //付款币种 - $data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->first()->currency_name; + $data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name')??''; if (isset($data['fx_receipt_file'])) $data['fx_receipt_file_full'] = (new OssService)->generatePrivateUrl($data['fx_receipt_file']); return $data; From a3a6cfefc062b2c2d0a3c96da36054dfae973b91 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Sun, 28 Sep 2025 09:56:01 +0800 Subject: [PATCH 15/39] =?UTF-8?q?=E6=94=B6=E6=AC=BE=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/FinPaymentApplyController.php | 12 ++++++++---- app/common/controller/FinReceiptController.php | 11 ++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/common/controller/FinPaymentApplyController.php b/app/common/controller/FinPaymentApplyController.php index d8158fa..8739043 100644 --- a/app/common/controller/FinPaymentApplyController.php +++ b/app/common/controller/FinPaymentApplyController.php @@ -55,9 +55,11 @@ class FinPaymentApplyController extends BaseController ]; } } - $data['voucher_file_full'] = ''; - if (!empty($data['voucher_file'])) + if (!empty($data['voucher_file'])) { $data['voucher_file_full'] = $OssService->generatePrivateUrl($data['voucher_file']); + } elseif (isset($data['voucher_file'])) { + $data['voucher_file_full'] = ''; + } if (isset($data['created_at'])) $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); if (isset($data['updated_at'])) @@ -96,9 +98,11 @@ class FinPaymentApplyController extends BaseController ]; } } - $data['voucher_file_full'] = ''; - if (!empty($data['voucher_file'])) + if (!empty($data['voucher_file'])) { $data['voucher_file_full'] = $OssService->generatePrivateUrl($data['voucher_file']); + } elseif (isset($data['voucher_file'])) { + $data['voucher_file_full'] = ''; + } if (isset($data['created_at'])) $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); if (isset($data['updated_at'])) diff --git a/app/common/controller/FinReceiptController.php b/app/common/controller/FinReceiptController.php index 3dcdf72..76b1ed8 100644 --- a/app/common/controller/FinReceiptController.php +++ b/app/common/controller/FinReceiptController.php @@ -42,9 +42,11 @@ class FinReceiptController extends BaseController $data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr')??''; if (isset($data['currency_id'])) //付款币种 $data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name')??''; - $data['fx_receipt_file_full'] = ''; - if (!empty($data['fx_receipt_file'])) + if (!empty($data['fx_receipt_file'])){ $data['fx_receipt_file_full'] = (new OssService)->generatePrivateUrl($data['fx_receipt_file']); + }elseif (isset($data['fx_receipt_file'])){ + $data['fx_receipt_file_full'] = ''; + } return $data; } @@ -70,8 +72,11 @@ class FinReceiptController extends BaseController $data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr')??''; if (isset($data['currency_id'])) //付款币种 $data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name')??''; - if (isset($data['fx_receipt_file'])) + if (!empty($data['fx_receipt_file'])) { $data['fx_receipt_file_full'] = (new OssService)->generatePrivateUrl($data['fx_receipt_file']); + } elseif (isset($data['fx_receipt_file'])) { + $data['fx_receipt_file_full'] = ''; + } return $data; } } \ No newline at end of file From 90cce108b0b3e27d15351b70b420308fc5187a82 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Sun, 28 Sep 2025 10:10:15 +0800 Subject: [PATCH 16/39] =?UTF-8?q?=E6=94=B6=E6=AC=BE=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E4=B8=8E=E4=BF=AE=E6=94=B9=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/FinPaymentApplyController.php | 8 ++++---- app/common/controller/FinReceiptHisController.php | 11 +++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/common/controller/FinPaymentApplyController.php b/app/common/controller/FinPaymentApplyController.php index 8739043..7dead81 100644 --- a/app/common/controller/FinPaymentApplyController.php +++ b/app/common/controller/FinPaymentApplyController.php @@ -33,9 +33,9 @@ class FinPaymentApplyController extends BaseController protected function indexFormat($data) { if (isset($data['doc_user_id'])) //内勤 - $data['doc_user_name'] = User::where('id', $data['doc_user_id'])->first()->name; + $data['doc_user_name'] = User::where('id', $data['doc_user_id'])->value('name')??''; if (isset($data['sales_user_id'])) //业务员 - $data['sales_user_name'] = User::where('id', $data['doc_user_id'])->first()->name; + $data['sales_user_name'] = User::where('id', $data['doc_user_id'])->value('name')??''; if (isset($data['corp_id'])) //公司(渠道) $data['corp_name'] = SysDictItem::where('id', $data['corp_id'])->value('item_label')??''; if (isset($data['account_id'])) //收款账号 @@ -76,9 +76,9 @@ class FinPaymentApplyController extends BaseController protected function showFormat($data) { if (isset($data['doc_user_id'])) //内勤 - $data['doc_user_name'] = User::where('id', $data['doc_user_id'])->first()->name; + $data['doc_user_name'] = User::where('id', $data['doc_user_id'])->value('name')??''; if (isset($data['sales_user_id'])) //业务员 - $data['sales_user_name'] = User::where('id', $data['doc_user_id'])->first()->name; + $data['sales_user_name'] = User::where('id', $data['doc_user_id'])->value('name')??''; if (isset($data['corp_id'])) //公司(渠道) $data['corp_name'] = SysDictItem::where('id', $data['corp_id'])->value('item_label')??''; if (isset($data['account_id'])) //收款账号 diff --git a/app/common/controller/FinReceiptHisController.php b/app/common/controller/FinReceiptHisController.php index eb57d99..e10d859 100644 --- a/app/common/controller/FinReceiptHisController.php +++ b/app/common/controller/FinReceiptHisController.php @@ -5,6 +5,7 @@ use app\common\controller\BaseController; use app\common\model\Country; use app\common\model\SysAccount; use app\common\model\SysCurrency; +use app\common\model\User; use app\common\service\OssService; use app\common\traits\crud\CrudControllerTrait; use app\common\service\FinReceiptHisService; @@ -45,6 +46,11 @@ class FinReceiptHisController extends BaseController $data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->first()->currency_name; if (isset($data['fx_receipt_file'])) $data['fx_receipt_file_full'] = (new OssService)->generatePrivateUrl($data['fx_receipt_file']); + + if (isset($data['created_by'])) + $data['created_by'] = User::where('id', $data['created_by'])->value('name')??''; + if (isset($data['updated_by'])) + $data['updated_by'] = User::where('id', $data['updated_by'])->value('name')??''; return $data; } @@ -72,6 +78,11 @@ class FinReceiptHisController extends BaseController $data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->first()->currency_name; if (isset($data['fx_receipt_file'])) $data['fx_receipt_file_full'] = (new OssService)->generatePrivateUrl($data['fx_receipt_file']); + + if (isset($data['created_by'])) + $data['created_by'] = User::where('id', $data['created_by'])->value('name')??''; + if (isset($data['updated_by'])) + $data['updated_by'] = User::where('id', $data['updated_by'])->value('name')??''; return $data; } } \ No newline at end of file From d05106f9dfc7cfc323ecc3f686c0d442a8f9de43 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Thu, 9 Oct 2025 10:16:21 +0800 Subject: [PATCH 17/39] =?UTF-8?q?=E6=94=B6=E6=AC=BE=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FinPaymentApplyController.php | 8 +++++--- app/common/controller/FinReceiptController.php | 4 +++- app/common/controller/FinReceiptHisController.php | 15 ++++++++++----- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/common/controller/FinPaymentApplyController.php b/app/common/controller/FinPaymentApplyController.php index 7dead81..9129390 100644 --- a/app/common/controller/FinPaymentApplyController.php +++ b/app/common/controller/FinPaymentApplyController.php @@ -81,8 +81,10 @@ class FinPaymentApplyController extends BaseController $data['sales_user_name'] = User::where('id', $data['doc_user_id'])->value('name')??''; if (isset($data['corp_id'])) //公司(渠道) $data['corp_name'] = SysDictItem::where('id', $data['corp_id'])->value('item_label')??''; - if (isset($data['account_id'])) //收款账号 + 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')??''; + } if (isset($data['country_id'])) //付款来源国家 $data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr')??''; if (isset($data['currency_id'])) //付款币种 @@ -111,8 +113,8 @@ class FinPaymentApplyController extends BaseController $finPaymentStock = FinPaymentStock::where('payment_apply_id', $data['id'])->get(); $stock = []; foreach ($finPaymentStock as $v) { - $stock[$v['pi_no']] = ['pi_no' => $v['pi_no']]; - $stock[$v['pi_no']]['stock_id'] = [$v['stock_id']]; + $stock[$v['pi_no']]['pi_no'] = $v['pi_no']; + $stock[$v['pi_no']]['stock_id'][] = [$v['stock_id']]; } $data['stock'] = array_values($stock); return $data; diff --git a/app/common/controller/FinReceiptController.php b/app/common/controller/FinReceiptController.php index 76b1ed8..74052f7 100644 --- a/app/common/controller/FinReceiptController.php +++ b/app/common/controller/FinReceiptController.php @@ -36,8 +36,10 @@ class FinReceiptController extends BaseController $data['arrived_at'] = date('Y-m-d H:i:s', $data['arrived_at']); if (isset($data['received_at'])) $data['received_at'] = date('Y-m-d H:i:s', $data['received_at']); - if (isset($data['account_id'])) //收款账号 + 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')??''; + } if (isset($data['country_id'])) //付款来源国家 $data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr')??''; if (isset($data['currency_id'])) //付款币种 diff --git a/app/common/controller/FinReceiptHisController.php b/app/common/controller/FinReceiptHisController.php index e10d859..16e4b3c 100644 --- a/app/common/controller/FinReceiptHisController.php +++ b/app/common/controller/FinReceiptHisController.php @@ -70,14 +70,19 @@ class FinReceiptHisController extends BaseController $data['arrived_at'] = date('Y-m-d H:i:s', $data['arrived_at']); if (isset($data['received_at'])) $data['received_at'] = date('Y-m-d H:i:s', $data['received_at']); - if (isset($data['account_id'])) //收款账号 - $data['account_name'] = SysAccount::where('id', $data['account_id'])->first()->account_name; + 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')??''; + } if (isset($data['country_id'])) //付款来源国家 - $data['country_name'] = Country::where('id', $data['currency_id'])->first()->cn_addr; + $data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr')??''; if (isset($data['currency_id'])) //付款币种 - $data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->first()->currency_name; - if (isset($data['fx_receipt_file'])) + $data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name')??''; + if (!empty($data['fx_receipt_file'])){ $data['fx_receipt_file_full'] = (new OssService)->generatePrivateUrl($data['fx_receipt_file']); + }elseif (isset($data['fx_receipt_file'])){ + $data['fx_receipt_file_full'] = ''; + } if (isset($data['created_by'])) $data['created_by'] = User::where('id', $data['created_by'])->value('name')??''; From 73ed4a413c84a81c76b2cacaf8a257f14b90feb6 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Thu, 9 Oct 2025 10:24:13 +0800 Subject: [PATCH 18/39] =?UTF-8?q?=E4=BB=98=E6=AC=BE=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FinPaymentApplyController.php | 4 +++- app/common/controller/FinReceiptController.php | 4 +++- .../controller/FinReceiptHisController.php | 17 +++++++++++------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/common/controller/FinPaymentApplyController.php b/app/common/controller/FinPaymentApplyController.php index 9129390..e916df4 100644 --- a/app/common/controller/FinPaymentApplyController.php +++ b/app/common/controller/FinPaymentApplyController.php @@ -38,8 +38,10 @@ class FinPaymentApplyController extends BaseController $data['sales_user_name'] = User::where('id', $data['doc_user_id'])->value('name')??''; if (isset($data['corp_id'])) //公司(渠道) $data['corp_name'] = SysDictItem::where('id', $data['corp_id'])->value('item_label')??''; - if (isset($data['account_id'])) //收款账号 + 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')??''; + } if (isset($data['country_id'])) //付款来源国家 $data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr')??''; if (isset($data['currency_id'])) //付款币种 diff --git a/app/common/controller/FinReceiptController.php b/app/common/controller/FinReceiptController.php index 74052f7..ddddfac 100644 --- a/app/common/controller/FinReceiptController.php +++ b/app/common/controller/FinReceiptController.php @@ -68,8 +68,10 @@ class FinReceiptController extends BaseController $data['arrived_at'] = date('Y-m-d H:i:s', $data['arrived_at']); if (isset($data['received_at'])) $data['received_at'] = date('Y-m-d H:i:s', $data['received_at']); - if (isset($data['account_id'])) //收款账号 + 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')??''; + } if (isset($data['country_id'])) //付款来源国家 $data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr')??''; if (isset($data['currency_id'])) //付款币种 diff --git a/app/common/controller/FinReceiptHisController.php b/app/common/controller/FinReceiptHisController.php index 16e4b3c..7adcf0d 100644 --- a/app/common/controller/FinReceiptHisController.php +++ b/app/common/controller/FinReceiptHisController.php @@ -38,15 +38,20 @@ class FinReceiptHisController extends BaseController $data['arrived_at'] = date('Y-m-d H:i:s', $data['arrived_at']); if (isset($data['received_at'])) $data['received_at'] = date('Y-m-d H:i:s', $data['received_at']); - if (isset($data['account_id'])) //收款账号 - $data['account_name'] = SysAccount::where('id', $data['account_id'])->first()->account_name; + 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')??''; + } if (isset($data['country_id'])) //付款来源国家 - $data['country_name'] = Country::where('id', $data['currency_id'])->first()->cn_addr; + $data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr')??''; if (isset($data['currency_id'])) //付款币种 - $data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->first()->currency_name; - if (isset($data['fx_receipt_file'])) + $data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name')??''; + if (!empty($data['fx_receipt_file'])){ $data['fx_receipt_file_full'] = (new OssService)->generatePrivateUrl($data['fx_receipt_file']); - + }elseif (isset($data['fx_receipt_file'])){ + $data['fx_receipt_file_full'] = ''; + } + if (isset($data['created_by'])) $data['created_by'] = User::where('id', $data['created_by'])->value('name')??''; if (isset($data['updated_by'])) From 6644cc1c58e01c3f8fb60cd4fe5eeb8832b7c4a6 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Thu, 23 Oct 2025 11:27:24 +0800 Subject: [PATCH 19/39] =?UTF-8?q?=E6=94=B6=E6=AC=BE=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/FinPaymentApplyController.php | 2 +- app/common/controller/FinReceiptController.php | 10 ++++++++++ app/common/service/FinReceiptService.php | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/common/controller/FinPaymentApplyController.php b/app/common/controller/FinPaymentApplyController.php index e916df4..57c4b75 100644 --- a/app/common/controller/FinPaymentApplyController.php +++ b/app/common/controller/FinPaymentApplyController.php @@ -75,7 +75,7 @@ class FinPaymentApplyController extends BaseController * @param array $data * @return array */ - protected function showFormat($data) + public function showFormat($data) { if (isset($data['doc_user_id'])) //内勤 $data['doc_user_name'] = User::where('id', $data['doc_user_id'])->value('name')??''; diff --git a/app/common/controller/FinReceiptController.php b/app/common/controller/FinReceiptController.php index ddddfac..c558d44 100644 --- a/app/common/controller/FinReceiptController.php +++ b/app/common/controller/FinReceiptController.php @@ -3,8 +3,12 @@ namespace app\common\controller; use app\common\controller\BaseController; use app\common\model\Country; +use app\common\model\FinPaymentApply; +use app\common\model\FinPaymentStock; use app\common\model\SysAccount; use app\common\model\SysCurrency; +use app\common\model\SysDictItem; +use app\common\model\User; use app\common\service\OssService; use app\common\traits\crud\CrudControllerTrait; use app\common\service\FinReceiptService; @@ -81,6 +85,12 @@ class FinReceiptController extends BaseController } elseif (isset($data['fx_receipt_file'])) { $data['fx_receipt_file_full'] = ''; } + + if (!empty($data['payment_apply_id'])) { + $paymentApply = FinPaymentApply::where('id', $data['payment_apply_id'])->first()->toArray(); + $paymentApply = (new FinPaymentApplyController())->showFormat($paymentApply); + $data['payment_apply'] = $paymentApply; + } return $data; } } \ No newline at end of file diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php index 2f77af5..155aecd 100644 --- a/app/common/service/FinReceiptService.php +++ b/app/common/service/FinReceiptService.php @@ -70,7 +70,7 @@ class FinReceiptService } // 关键字 - if (isset($p['$query']) && $p['keyword']) { + if (isset($p['keyword']) && $p['keyword']) { $k = '%' . $p['keyword'] . '%'; $config['orWhere'][] = ['remitter', 'like', $k]; } From 0f505d5c567d1a70ec0a73126be73044e3921b3d Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Thu, 23 Oct 2025 16:25:02 +0800 Subject: [PATCH 20/39] =?UTF-8?q?=E6=94=B6=E6=AC=BE=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E8=81=94=E6=9F=A5=E4=BB=98=E6=AC=BE=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/FinReceiptController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/common/controller/FinReceiptController.php b/app/common/controller/FinReceiptController.php index c558d44..ebfd956 100644 --- a/app/common/controller/FinReceiptController.php +++ b/app/common/controller/FinReceiptController.php @@ -87,7 +87,10 @@ class FinReceiptController extends BaseController } if (!empty($data['payment_apply_id'])) { - $paymentApply = FinPaymentApply::where('id', $data['payment_apply_id'])->first()->toArray(); + $paymentApply = FinPaymentApply::where('id', $data['payment_apply_id'])->first(); + if(!$paymentApply) + return $data; + $paymentApply = $paymentApply->toArray(); $paymentApply = (new FinPaymentApplyController())->showFormat($paymentApply); $data['payment_apply'] = $paymentApply; } From 7036e3b849803d8d2100836a77b5f3f6f55bfa9c Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Thu, 23 Oct 2025 17:09:40 +0800 Subject: [PATCH 21/39] =?UTF-8?q?=E6=8E=92=E5=BA=8F=E8=A7=84=E5=88=99?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/FinReceiptController.php | 16 +++++++++++++++- app/common/service/FinPaymentApplyService.php | 6 ++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/common/controller/FinReceiptController.php b/app/common/controller/FinReceiptController.php index ebfd956..56d7bfb 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\Request; class FinReceiptController extends BaseController { @@ -23,7 +24,18 @@ class FinReceiptController extends BaseController { $this->service = new FinReceiptService(); } - + public function show(Request $request) + { + try { + $raw = $this->service->serviceShow($request); + $data = $this->transformData($raw, method_exists($this, 'showFormat') + ? [$this, 'showFormat'] + : null); + return $this->success($data); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } /** * 列表页数据格式化 * @@ -91,6 +103,8 @@ class FinReceiptController extends BaseController if(!$paymentApply) return $data; $paymentApply = $paymentApply->toArray(); + $paymentApply['created_at'] = strtotime($paymentApply['created_at']); + $paymentApply['updated_at'] = strtotime($paymentApply['updated_at']); $paymentApply = (new FinPaymentApplyController())->showFormat($paymentApply); $data['payment_apply'] = $paymentApply; } diff --git a/app/common/service/FinPaymentApplyService.php b/app/common/service/FinPaymentApplyService.php index 294bc01..f451ce4 100644 --- a/app/common/service/FinPaymentApplyService.php +++ b/app/common/service/FinPaymentApplyService.php @@ -217,14 +217,16 @@ class FinPaymentApplyService $orderByClause = "CASE WHEN created_at >= {$sevenDaysAgo} THEN (" . implode(' + ', $similarityOrder) . ") - ELSE 999999 + ELSE 0 END ASC, "; } $orderByClause .= "CASE WHEN created_at < {$sevenDaysAgo} THEN id - ELSE 0 + ELSE 999999 END DESC"; + + $orderByClause .= ", id DESC"; $query->orderByRaw($orderByClause); From b47d23cd678c01b7591cdb295feded7d7410e38a Mon Sep 17 00:00:00 2001 From: mzl Date: Fri, 24 Oct 2025 11:15:09 +0800 Subject: [PATCH 22/39] Merge branch 'develop' --- app/common/logic/PurchaseOrdersLogic.php | 3 +- app/common/service/StockOrdersService.php | 57 ++++------------------- 2 files changed, 10 insertions(+), 50 deletions(-) diff --git a/app/common/logic/PurchaseOrdersLogic.php b/app/common/logic/PurchaseOrdersLogic.php index 500379d..0914f43 100644 --- a/app/common/logic/PurchaseOrdersLogic.php +++ b/app/common/logic/PurchaseOrdersLogic.php @@ -24,7 +24,7 @@ class PurchaseOrdersLogic public function getPiList() { return (new StockOrders())->where('pi_no', '!=', '') - ->select('pi_no') + ->select('pi_no', 'salesperson_snapshot') ->distinct() ->get(); } @@ -35,6 +35,7 @@ class PurchaseOrdersLogic public function getOrderNoListByPiNo($piNo) { return (new StockOrders())->where('pi_no', $piNo) + ->where('approval_status', 2) ->select('order_no', 'biz_date', 'salesperson_snapshot', 'id as stock_orders_id', 'salesperson_id') ->get(); } diff --git a/app/common/service/StockOrdersService.php b/app/common/service/StockOrdersService.php index f243654..76d2ab5 100644 --- a/app/common/service/StockOrdersService.php +++ b/app/common/service/StockOrdersService.php @@ -330,33 +330,25 @@ class StockOrdersService $data = $this->preProcess('Store', $data, $request); $dl = $this->getDataLimitFromRequest($request); $created = $this->logicCreate($data, $dl); - // 添加金额 $created->addMoney('cif_total', $data['cif_total']['currency'], $data['cif_total']['amount'], $data['cif_total']['rate'], '合计到岸价'); - // 处理车辆和账户信息 $this->processOrderItems($created, $data); - // 处理文件附件 $this->processOrderFiles($created, $data); - return $this->postProcess('Store', $created); }); } protected function onlyFillableData(Model|string $model, array $data, array $extraWhitelist = []): array { - // 兼容传类名或实例 $m = \is_string($model) ? new $model : $model; - // 1) 优先使用 fillable $keys = $m->getFillable(); - // 2) 若没配置 fillable(常见:用 guarded),回退到完整表字段,避免误伤 if (empty($keys)) { $keys = $m->getConnection() ->getSchemaBuilder() ->getColumnListing($m->getTable()); } - // 3) 允许额外白名单(如虚拟字段、JSON映射字段) if ($extraWhitelist) { $keys = array_merge($keys, $extraWhitelist); } @@ -413,11 +405,13 @@ class StockOrdersService // 过滤掉非库字段 $dbData = $this->onlyFillableData($config['model'], $data); // 更新主表 - $updated = $this->logicUpdateBy($config, $dbData); + $this->logicUpdateBy($config, $dbData); // 获取更新后的数据 $order = $this->logicShow($config); // 处理车辆和账户信息 $this->processOrderItems($order, $data, true); + // 添加金额 + $order->addMoney('cif_total', $data['cif_total']['currency'], $data['cif_total']['amount'], $data['cif_total']['rate'], '合计到岸价'); // 处理文件附件 $this->processOrderFiles($order, $data, true); return $this->postProcess('Update', $order); @@ -436,10 +430,8 @@ class StockOrdersService if ($isUpdate) { $this->clearExistingOrderItems($order->id); } - // 处理车辆项 $this->processVehicleItems($order, $data['veh_list'] ?? []); - // 处理账户项 $this->processAccountItems($order, $data['account_list'] ?? []); } @@ -552,7 +544,6 @@ class StockOrdersService $this->processVehiclePrices($item, $veh); // 累计到岸价 - // $cifTotalAmount += $veh['total_price']['amount'] ?? 0; $profitCurrency === '' ? $profitCurrency = $veh['profit']['currency'] ?? '' : ''; $profitRate === 0 ? $profitRate = $veh['profit']['rate'] ?? 0 : ''; $profitTotalAmount += $veh['profit']['amount'] ?? 0; @@ -572,7 +563,6 @@ class StockOrdersService $keysToRemove = ['vin', 'remark', 'modify_list', 'order_id']; $array = array_diff_key($veh, array_flip($keysToRemove)); $uniqueIdStr = json_encode($array); - return md5($uniqueIdStr); } @@ -600,6 +590,7 @@ class StockOrdersService // retention_price 留款/挂账 // car_price 车价 // accessory_price 配件费 + // increase_price 加价 // 基础费用 $priceFields = [ @@ -617,7 +608,8 @@ class StockOrdersService 'profit' => '利润', 'retention_price' => '挂账', 'car_price' => '车价', - 'accessory_price' => '配件费' + 'accessory_price' => '配件费', + 'increase_price' => '加价' ]; foreach ($priceFields as $field => $description) { @@ -771,12 +763,10 @@ class StockOrdersService { $vehList = []; $index = 0; - $currencyInfo = $this->getCurrencyInfo($item->settlement_currency); - foreach ($item->items as $v) { // 如果已存在相同车辆,增加数量 if (isset($vehList[$v->unique_id])) { - $this->incrementVehicleCount($vehList[$v->unique_id], $currencyInfo); + $this->incrementVehicleCount($vehList[$v->unique_id]); // 拼接 remark 值 if (!empty($v->remark)) { if (!empty($vehList[$v->unique_id]['remark'])) { @@ -787,17 +777,9 @@ class StockOrdersService } continue; } - $index++; // 处理金额信息 $moneyValues = $this->processItemMoneyValues($v); - - // 处理改装信息 - // $modificationText = $this->getModificationText($v->options); - - // 利润 - // $itemProfit = empty($moneyValues['profit']['amount']) ? 0 : $moneyValues['profit']['amount']; - // 构建车辆信息 $vehList[$v->unique_id] = [ 'index' => $index, @@ -805,19 +787,10 @@ class StockOrdersService 'color_interior_snapshot' => $v->color_interior_snapshot, 'color_exterior_snapshot' => $v->color_exterior_snapshot, 'num' => 1, - // 'modify' => $modificationText, 'mileage' => $v->mileage, 'remark' => $v->remark, ] + $moneyValues; - // var_dump($vehList[$v->unique_id]); - // 添加利润信息 - // $vehList[$v->unique_id]['profit'] = [ - // 'currency' => $item->settlement_currency, - // 'amount' => $itemProfit, - // 'currency_info' => $currencyInfo['currency_symbol'] . number_format($itemProfit, 2, '.', ',') - // ]; } - return ['list' => $vehList]; } @@ -853,23 +826,9 @@ class StockOrdersService /** * 增加车辆数量并更新相关金额显示 */ - private function incrementVehicleCount(array &$vehicleData, array $currencyInfo): void + private function incrementVehicleCount(array &$vehicleData): void { $vehicleData['num'] += 1; - - // // 更新总价显示 - // if (isset($vehicleData['total_price']['amount'])) { - // $totalAmount = $vehicleData['total_price']['amount'] * $vehicleData['num']; - // $vehicleData['total_price']['currency_info'] = $currencyInfo['currency_symbol'] . number_format($totalAmount, 2, '.', ','); - // } - - // // 更新利润显示 - // if (isset($vehicleData['profit']['amount'])) { - // $profitAmount = $vehicleData['profit']['amount'] * $vehicleData['num']; - // $vehicleData['profit']['currency_info'] = $currencyInfo['currency_symbol'] . number_format($profitAmount, 2, '.', ','); - // } - - // var_dump($vehicleData); $fieldList = [ 'fob_transport_fee', From cb4a3a3cd3aec8772ab07955111f43120b630af1 Mon Sep 17 00:00:00 2001 From: mzl Date: Fri, 24 Oct 2025 15:47:46 +0800 Subject: [PATCH 23/39] Merge branch 'develop' --- app/common/service/ApprovalRecordsService.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/common/service/ApprovalRecordsService.php b/app/common/service/ApprovalRecordsService.php index 3b37365..61c026e 100644 --- a/app/common/service/ApprovalRecordsService.php +++ b/app/common/service/ApprovalRecordsService.php @@ -56,9 +56,9 @@ class ApprovalRecordsService case 'todo': if ($p['scene'] === 'todo') { - // if (!in_array(1, $request->user->role_ids)) { - // $config['where']['approver_id'] = $request->user->uid; - // } + if (!in_array(1, $request->user->role_ids)) { + $config['where']['approver_id'] = $request->user->uid; + } $config['where']['status'] = 'pending'; $config['where']['instance.status'] = 'processing'; } From cd6c4b425d14b6b713137c13fc405edf5f4ec0d4 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Fri, 24 Oct 2025 16:32:23 +0800 Subject: [PATCH 24/39] =?UTF-8?q?=E5=85=A5=E5=8F=82=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/service/SysOpLogService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/common/service/SysOpLogService.php b/app/common/service/SysOpLogService.php index 3291093..ee19817 100644 --- a/app/common/service/SysOpLogService.php +++ b/app/common/service/SysOpLogService.php @@ -61,7 +61,7 @@ class SysOpLogService // 关键字 if (isset($p['keyword']) && $p['keyword']) { $k = '%' . $p['keyword'] . '%'; - foreach (['user_name', 'route'] as $col) { + foreach (['user_name', 'route', 'params_brief'] as $col) { $config['orWhere'][] = [$col, 'like', $k]; } } From 83d76b16b4a154ae11ca388e904ea1c548ca6ede Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Mon, 27 Oct 2025 10:57:47 +0800 Subject: [PATCH 25/39] =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E5=85=A5=E8=B4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FinReceiptController.php | 17 +++++++++++++++++ app/common/logic/FinReceiptLogic.php | 4 ++++ app/common/service/FinReceiptService.php | 19 +++++++++++++++++++ config/route.php | 1 + 4 files changed, 41 insertions(+) diff --git a/app/common/controller/FinReceiptController.php b/app/common/controller/FinReceiptController.php index 56d7bfb..486bfde 100644 --- a/app/common/controller/FinReceiptController.php +++ b/app/common/controller/FinReceiptController.php @@ -24,6 +24,23 @@ class FinReceiptController extends BaseController { $this->service = new FinReceiptService(); } + + /** + * 确认入账 + * @param Request $request + * @return \support\Response + */ + public function credit(Request $request) + { + try { + $id = $request->input('id'); + $raw = $this->service->credit($id); + return $this->success($raw); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } + public function show(Request $request) { try { diff --git a/app/common/logic/FinReceiptLogic.php b/app/common/logic/FinReceiptLogic.php index 5d8f5f3..62db50f 100644 --- a/app/common/logic/FinReceiptLogic.php +++ b/app/common/logic/FinReceiptLogic.php @@ -14,4 +14,8 @@ class FinReceiptLogic */ protected string $modelClass = FinReceipt::class; + public function credit($id) + { + return FinReceipt::where('id', $id)->update(['received_at' => time()]); + } } \ No newline at end of file diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php index 155aecd..e2611d7 100644 --- a/app/common/service/FinReceiptService.php +++ b/app/common/service/FinReceiptService.php @@ -2,10 +2,12 @@ namespace app\common\service; +use app\common\logic\FinReceiptLogic; use app\common\model\FinReceiptHis; use app\common\validate\FinReceiptValidate; use app\common\traits\crud\CrudServiceTrait; use app\common\model\FinReceipt; +use support\exception\BusinessException; use support\Request; class FinReceiptService @@ -23,6 +25,14 @@ class FinReceiptService */ protected $validator = FinReceiptValidate::class; + + protected $logic; + + public function __construct() + { + $this->logic = (new FinReceiptLogic()); + } + /** * 获取验证器 */ @@ -251,4 +261,13 @@ class FinReceiptService return $query->paginate($limit, ['*'], 'page', $page); } + + public function credit($id) + { + $finReceipt = FinReceipt::find($id); + if(!empty($finReceipt->received_at)){ + throw new BusinessException('该记录已将确认入账'); + } + return $this->logic->credit($id); + } } \ No newline at end of file diff --git a/config/route.php b/config/route.php index 3f7477f..ba10155 100644 --- a/config/route.php +++ b/config/route.php @@ -360,6 +360,7 @@ Route::group('/admin', function () { Route::any('/update', [app\common\controller\FinReceiptController::class, 'update']); Route::any('/payment', [app\common\controller\FinReceiptController::class, 'update']); Route::any('/destroy', [app\common\controller\FinReceiptController::class, 'destroy']); + Route::any('/credit', [app\common\controller\FinReceiptController::class, 'credit']); }); // 收款记录历史 Route::group('/receipt/his', function () { From 19cb169abdbd6365ae93382f19f5e600123df312 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Mon, 27 Oct 2025 11:57:00 +0800 Subject: [PATCH 26/39] =?UTF-8?q?=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/service/FinReceiptService.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php index e2611d7..7154bfa 100644 --- a/app/common/service/FinReceiptService.php +++ b/app/common/service/FinReceiptService.php @@ -268,6 +268,7 @@ class FinReceiptService if(!empty($finReceipt->received_at)){ throw new BusinessException('该记录已将确认入账'); } + $this->afterServiceUpdate(['id'=>$id]); return $this->logic->credit($id); } } \ No newline at end of file From 1bd2eee8db7922ef3a8e40437a9e55a63043ff2c Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Mon, 27 Oct 2025 14:52:04 +0800 Subject: [PATCH 27/39] =?UTF-8?q?=E5=85=A5=E8=B4=A6=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/service/FinReceiptService.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php index 7154bfa..bc9ff6a 100644 --- a/app/common/service/FinReceiptService.php +++ b/app/common/service/FinReceiptService.php @@ -268,7 +268,8 @@ class FinReceiptService if(!empty($finReceipt->received_at)){ throw new BusinessException('该记录已将确认入账'); } + $res = $this->logic->credit($id); $this->afterServiceUpdate(['id'=>$id]); - return $this->logic->credit($id); + return $res; } } \ No newline at end of file From 21274732909ba0b3f7a5981309db574d9d9eb3b3 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 28 Oct 2025 16:59:51 +0800 Subject: [PATCH 28/39] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/SysConfigController.php | 48 +++++++++++++ app/admin/logic/SysConfigLogic.php | 17 +++++ app/admin/service/SysConfigService.php | 76 ++++++++++++++++++++ app/admin/validate/SysConfigValidate.php | 29 ++++++++ app/common/logic/SysConfigLogic.php | 22 ++++++ app/common/model/SysConfig.php | 49 +++++++++++++ app/common/service/SysConfigService.php | 37 ++++++++++ 7 files changed, 278 insertions(+) create mode 100644 app/admin/controller/SysConfigController.php create mode 100644 app/admin/logic/SysConfigLogic.php create mode 100644 app/admin/service/SysConfigService.php create mode 100644 app/admin/validate/SysConfigValidate.php create mode 100644 app/common/logic/SysConfigLogic.php create mode 100644 app/common/model/SysConfig.php create mode 100644 app/common/service/SysConfigService.php diff --git a/app/admin/controller/SysConfigController.php b/app/admin/controller/SysConfigController.php new file mode 100644 index 0000000..3534079 --- /dev/null +++ b/app/admin/controller/SysConfigController.php @@ -0,0 +1,48 @@ +service = new SysConfigService(); + } + + /** + * 列表页数据格式化 + * + * @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; + } + + /** + * 数据格式化 + * + * @param array $data + * @return array + */ + protected function showFormat($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; + } +} \ No newline at end of file diff --git a/app/admin/logic/SysConfigLogic.php b/app/admin/logic/SysConfigLogic.php new file mode 100644 index 0000000..60be4a8 --- /dev/null +++ b/app/admin/logic/SysConfigLogic.php @@ -0,0 +1,17 @@ +validator; + } + + /** + * 构建查询条件 + */ + protected function buildQueryConfig(Request $request, string $scene = 'default'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'index': + // ====== ====== 排序 ====== ====== + $config['order']['id'] = 'desc'; + + // ====== ====== 筛选 ====== ====== + // 状态 + if (isset($p['status']) && in_array($p['status'], [0,1])) { + $config['where']['status'] = $p['status']; + } + // 关键字 + if (isset($p['keyword']) && $p['keyword']) { + $k = '%' . $p['keyword'] . '%'; + foreach (['config_key','config_value','description'] as $col) { + $config['orWhere'][] = [$col, 'like', $k]; + } + } + break; + case 'show': + $config['where']['id'] = $p['id']; + //$config['where']['status'] = 1; + break; + case 'store': + break; + case 'update': + $config['where']['id'] = $p['id']; + break; + case 'destroy': + $config['where']['id'] = $p['id']; + break; + } + + return $config; + } +} \ No newline at end of file diff --git a/app/admin/validate/SysConfigValidate.php b/app/admin/validate/SysConfigValidate.php new file mode 100644 index 0000000..2bb978a --- /dev/null +++ b/app/admin/validate/SysConfigValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/common/logic/SysConfigLogic.php b/app/common/logic/SysConfigLogic.php new file mode 100644 index 0000000..633d177 --- /dev/null +++ b/app/common/logic/SysConfigLogic.php @@ -0,0 +1,22 @@ +where('config_key', $key)->get(['id', 'config_key', 'config_value']); + } +} \ No newline at end of file diff --git a/app/common/model/SysConfig.php b/app/common/model/SysConfig.php new file mode 100644 index 0000000..29b4577 --- /dev/null +++ b/app/common/model/SysConfig.php @@ -0,0 +1,49 @@ +logic = (new SysConfigLogic()); + } + + /** + * 获取系统list + */ + public static function getConfig(string $config_key) + { + $value = Redis::get($config_key); + if (empty($value)) { + $config = (new SysConfigLogic())->findByKey($config_key); + if (empty($config)) { + return null; + } + $value = $config->config_value; + Redis::set($config->config_key, $value, 'EX', 7200); + } + + return $value; + } +} \ No newline at end of file From 8a1b2f236936b8e943798db3b0742c7ad2648527 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 28 Oct 2025 17:05:23 +0800 Subject: [PATCH 29/39] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/service/SysConfigService.php | 7 +++++++ config/route.php | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/app/admin/service/SysConfigService.php b/app/admin/service/SysConfigService.php index cedca5b..62e4812 100644 --- a/app/admin/service/SysConfigService.php +++ b/app/admin/service/SysConfigService.php @@ -5,6 +5,7 @@ namespace app\admin\service; use app\admin\validate\SysConfigValidate; use app\common\traits\crud\CrudServiceTrait; use app\common\model\SysConfig; +use support\Redis; use support\Request; class SysConfigService @@ -73,4 +74,10 @@ class SysConfigService return $config; } + + + public function beforeServiceUpdate($data, Request $request) + { + Redis::del($data['config_key']); + } } \ No newline at end of file diff --git a/config/route.php b/config/route.php index ba10155..29c4e6e 100644 --- a/config/route.php +++ b/config/route.php @@ -376,6 +376,15 @@ Route::group('/admin', function () { Route::any('/update', [app\common\controller\FinPaymentApplyController::class, 'update']); Route::any('/destroy', [app\common\controller\FinPaymentApplyController::class, 'destroy']); }); + + // 系统配置 + Route::group('/config', function () { + Route::any('/list', [app\admin\controller\SysConfigController::class, 'index']); + Route::any('/show', [app\admin\controller\SysConfigController::class, 'show']); + Route::any('/store', [app\admin\controller\SysConfigController::class, 'store']); + Route::any('/update', [app\admin\controller\SysConfigController::class, 'update']); + Route::any('/destroy', [app\admin\controller\SysConfigController::class, 'destroy']); + }); }); From e62becd30b6d394e9c991c03f03819086161ad15 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Wed, 29 Oct 2025 11:46:08 +0800 Subject: [PATCH 30/39] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/UploadController.php | 7 +++-- app/common/service/OssService.php | 34 ++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/app/common/controller/UploadController.php b/app/common/controller/UploadController.php index d90c84a..a025666 100644 --- a/app/common/controller/UploadController.php +++ b/app/common/controller/UploadController.php @@ -87,12 +87,15 @@ class UploadController } $originalName = $file->getUploadName(); + $ossservice = new OssService(); + $mimes = $ossservice->getMimeTypes(['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'zip', 'rar']); + $result = Storage::adapter('oss') ->path('x_server/' . $sceneUrl . date('Ymd')) ->size(1024*1024*5) + ->extYes($mimes) ->upload($file); - - $ossservice = new OssService(); + $data = [ 'original_name' => $originalName, diff --git a/app/common/service/OssService.php b/app/common/service/OssService.php index 72a956e..1aacc1c 100644 --- a/app/common/service/OssService.php +++ b/app/common/service/OssService.php @@ -76,4 +76,38 @@ class OssService throw new BusinessException('Delete Error: ' . $th->getMessage()); } } + + /** + * 获取对应的 MIME 类型 + */ + public function getMimeTypes($extensions) + { + $mimeMap = [ + 'jpg' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'png' => 'image/png', + 'gif' => 'image/gif', + 'bmp' => 'image/bmp', + 'webp' => 'image/webp', + 'pdf' => 'application/pdf', + 'doc' => 'application/msword', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'xls' => 'application/vnd.ms-excel', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'ppt' => 'application/vnd.ms-powerpoint', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'txt' => 'text/plain', + 'zip' => 'application/zip', + 'rar' => 'application/x-rar-compressed' + ]; + + $mimes = []; + foreach ($extensions as $ext) { + if (isset($mimeMap[$ext])) { + $mimes[] = $mimeMap[$ext]; + } + } + + return array_unique($mimes); + } } \ No newline at end of file From 07c0b2a2f3ab249a6e48451b57e4cacd21ceed0a Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Wed, 29 Oct 2025 14:14:40 +0800 Subject: [PATCH 31/39] =?UTF-8?q?=E6=94=B6=E4=BB=98=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FinPaymentApplyController.php | 2 ++ .../controller/FinReceiptController.php | 22 +++++++++++++++- app/common/model/FinPaymentApply.php | 2 +- app/common/service/FinReceiptService.php | 26 +++++++++++++++++++ config/route.php | 2 +- 5 files changed, 51 insertions(+), 3 deletions(-) diff --git a/app/common/controller/FinPaymentApplyController.php b/app/common/controller/FinPaymentApplyController.php index 57c4b75..37fc4d7 100644 --- a/app/common/controller/FinPaymentApplyController.php +++ b/app/common/controller/FinPaymentApplyController.php @@ -66,6 +66,8 @@ class FinPaymentApplyController extends BaseController $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['claimed_at'])) + $data['claimed_at'] = date('Y-m-d H:i:s', $data['claimed_at']); return $data; } diff --git a/app/common/controller/FinReceiptController.php b/app/common/controller/FinReceiptController.php index 486bfde..d8ef9c2 100644 --- a/app/common/controller/FinReceiptController.php +++ b/app/common/controller/FinReceiptController.php @@ -53,6 +53,24 @@ class FinReceiptController extends BaseController return $this->error($e->getMessage()); } } + + /** + * 更新 + * + * @param Request $request 请求对象 + * @return mixed 返回更新成功的数据或信息 + */ + public function payment(Request $request) + { + try { + $data = $this->validate($this->service->getValidator(), $request->post(), 'update'); + $res = $this->service->serviceUpdatePayment($request, $data); + return $this->success([], '更新成功'); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } + /** * 列表页数据格式化 * @@ -61,8 +79,10 @@ class FinReceiptController extends BaseController */ protected function indexFormat($data) { - if (isset($data['created_at'])) + if (isset($data['created_at'])){ + $data['claim_timeout'] = (($data['created_at'] < (time()-86400)) && empty($data['payment_apply_id'])) ?1:0; $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'])) diff --git a/app/common/model/FinPaymentApply.php b/app/common/model/FinPaymentApply.php index f02f137..82f81cb 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', 'currency_id', 'amount', 'swift', 'remit_bank', 'country_id', 'remitter', 'exchange_rate', 'total_amount_cny', 'voucher_file', 'voucher_name', 'submit_files', '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', 'created_at', 'updated_at']; /** * 不允许自动填充模型字段 diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php index bc9ff6a..6e7b7e3 100644 --- a/app/common/service/FinReceiptService.php +++ b/app/common/service/FinReceiptService.php @@ -3,6 +3,7 @@ namespace app\common\service; use app\common\logic\FinReceiptLogic; +use app\common\model\FinPaymentApply; use app\common\model\FinReceiptHis; use app\common\validate\FinReceiptValidate; use app\common\traits\crud\CrudServiceTrait; @@ -89,6 +90,7 @@ class FinReceiptService $config['where']['id'] = $p['id']; break; case 'update': + case 'payment': case 'destroy': $config['where']['id'] = $p['id']; break; @@ -272,4 +274,28 @@ class FinReceiptService $this->afterServiceUpdate(['id'=>$id]); return $res; } + + /** + * 更新计算折让金额 + * @param Request $request + * @param array $data + * @param string $scene + * @return mixed + */ + public function serviceUpdatePayment(Request $request, array $data = [], string $scene = 'payment') + { + $payment_apply_id = $request->input('payment_apply_id'); + $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()]); + + //折让金额 + $payment = FinPaymentApply::where('id', $payment_apply_id)->first(); + $receipt = FinReceipt::find($id); + $data['discount_amount'] = $payment->amount - $payment->amount ?? 0; + + $updated = $this->logicUpdateBy($config, $data); + return $this->postProcess(ucfirst($scene), $data); + } } \ No newline at end of file diff --git a/config/route.php b/config/route.php index 29c4e6e..b962ee9 100644 --- a/config/route.php +++ b/config/route.php @@ -358,7 +358,7 @@ Route::group('/admin', function () { Route::any('/show', [app\common\controller\FinReceiptController::class, 'show']); 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, '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']); }); From b440c032410ad41e76b05dfd2a139be8c954fbc3 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Wed, 29 Oct 2025 15:47:51 +0800 Subject: [PATCH 32/39] =?UTF-8?q?=E8=B6=85=E6=97=B6=E6=9C=AA=E8=AE=A4?= =?UTF-8?q?=E9=A2=86=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/service/FinReceiptService.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php index 6e7b7e3..48f9832 100644 --- a/app/common/service/FinReceiptService.php +++ b/app/common/service/FinReceiptService.php @@ -64,10 +64,13 @@ class FinReceiptService } // 没有付款记录的收款记录 - if (isset($p['payment_apply']) && $p['payment_apply'] == 'not') { + if (isset($p['payment_apply']) && $p['payment_apply'] == 'not') { //未认领 $config['where']['payment_apply_id'] = ['null']; - } elseif (isset($p['payment_apply']) && $p['payment_apply'] == 'already') { + } elseif (isset($p['payment_apply']) && $p['payment_apply'] == 'already') { //已认领 $config['where']['payment_apply_id'] = ['not null']; + } elseif (isset($p['payment_apply']) && $p['payment_apply'] == 'timeout') { //超时未认领 + $config['where']['payment_apply_id'] = ['not null']; + $config['where']['created_at'] = ['<' ,time() - 24*60*60]; } // 收款申请筛选 From cf45acbf0f7ae47a3bfa124dbb323dc4401eb024 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Wed, 29 Oct 2025 15:58:23 +0800 Subject: [PATCH 33/39] =?UTF-8?q?=E5=85=A5=E8=B4=A6=E8=B5=84=E6=96=99?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/FinPaymentApplyController.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/common/controller/FinPaymentApplyController.php b/app/common/controller/FinPaymentApplyController.php index 37fc4d7..3bf4b15 100644 --- a/app/common/controller/FinPaymentApplyController.php +++ b/app/common/controller/FinPaymentApplyController.php @@ -66,8 +66,10 @@ class FinPaymentApplyController extends BaseController $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['claimed_at'])) - $data['claimed_at'] = date('Y-m-d H:i:s', $data['claimed_at']); + if (isset($data['claimed_at'])){ + $data['enter_file_last'] = date('Y-m-d H:i:s', ($data['claimed_at']+86400)); //入账资料最后提交时间 + $data['claimed_at'] = date('Y-m-d H:i:s', $data['claimed_at']); //认领时间 + } return $data; } From 346d67c084c1dc6063d7680869c2f78b291213d4 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Wed, 29 Oct 2025 18:05:23 +0800 Subject: [PATCH 34/39] =?UTF-8?q?=E8=B6=85=E8=BF=8724=E5=B0=8F=E6=97=B6?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E9=80=9A=E7=9F=A5=E6=8F=90=E4=BA=A4=E5=85=A5?= =?UTF-8?q?=E8=B4=A6=E8=B5=84=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/model/FinPaymentApply.php | 2 +- app/common/service/FinReceiptService.php | 2 +- .../scaffold/templates/paymentFiles.stub | 103 ++++++++++++++++++ app/functions.php | 3 +- app/process/Task.php | 44 +++++++- 5 files changed, 149 insertions(+), 5 deletions(-) create mode 100644 app/common/utils/scaffold/templates/paymentFiles.stub 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/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 @@ + + + + + + 邮箱提醒 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/functions.php b/app/functions.php index 7ae0d0a..075dfbf 100644 --- a/app/functions.php +++ b/app/functions.php @@ -179,7 +179,8 @@ if (!function_exists('tplUrl')) { { $urlArray = [ 'email' => 'common/utils/scaffold/templates/Email.stub', - 'work_order' => 'common/utils/scaffold/templates/workOrder.stub' + 'work_order' => 'common/utils/scaffold/templates/workOrder.stub', + 'payment_files' => 'common/utils/scaffold/templates/paymentFiles.stub', ]; return $urlArray[$tplKey]; } diff --git a/app/process/Task.php b/app/process/Task.php index 910b5ad..47dbb93 100644 --- a/app/process/Task.php +++ b/app/process/Task.php @@ -2,6 +2,8 @@ namespace app\process; +use app\common\model\FinPaymentApply; +use app\common\model\User; use app\crm\model\Customer; use support\Log; use Workerman\Crontab\Crontab; @@ -11,7 +13,7 @@ class Task public function onWorkerStart() { - // 每半小时执行一次 + // 每半小时执行一次,通知待跟进客户 new Crontab('0 */30 * * * *', function(){ echo date('Y-m-d H:i:s') . "\n"; Log::info('send follow start',[time()]); @@ -34,7 +36,45 @@ class Task $item->save(); } - Log::info('send follow start',[time()]); + Log::info('send follow end',[time()]); + }); + + // 检查入账资料是否提交 + new Crontab('* */70 * * * *', function () { + $G = date('G'); + if ($G > 22 || $G < 8) { + return; + } + Log::info('fin_payment_apply submit_files start', [time()]); + $orWhere = [ + ['submit_files', '=', '[]'], + ['submit_files', '=', ''], + ]; + $where = [ + ['warn', '<', 2], + ['created_at', '>', time() - 60 * 60 * 48], + ['created_at', '<', time() - 60 * 60 * 24], + ]; + $payment = FinPaymentApply::where($where)->orWhere($orWhere)->orderBy('id', 'desc')->get(); + foreach ($payment as $item) { + Log::info('fin_payment_apply submit_files ', [$item->toArray()]); + $notice = [ + 'code' => $item->apply_no, + 'payment_entity' => $item->payment_entity ?? $item->remitter, + 'content' => '认领收款单后请在24小时内提交入账资料', + 'reply' => '', + ]; + $email = []; + $email[] = User::where('id', $item->claimed_by)->value('email'); + $email[] = User::where('id', $item->doc_user_id)->value('email'); + $email = array_unique($email); + \app\common\utils\email\MailSend::send($email, '【XYH】付款记录', replaceTpl($notice, 'payment_files')); + + $item->warn = ++$item->warn; + $item->save(); + } + + Log::info('fin_payment_apply submit_files end', [time()]); }); } From f3b1c9bae43074430c2a97972261f63ace668280 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Wed, 29 Oct 2025 18:38:37 +0800 Subject: [PATCH 35/39] =?UTF-8?q?=E4=BB=98=E6=AC=BE=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/service/FinPaymentApplyService.php | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) 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)) { From 9f944ae92cc86093b7b8e8bb750c4e088c8155f2 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Thu, 30 Oct 2025 09:52:20 +0800 Subject: [PATCH 36/39] =?UTF-8?q?=E5=8C=B9=E9=85=8D=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/service/FinPaymentApplyService.php | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/app/common/service/FinPaymentApplyService.php b/app/common/service/FinPaymentApplyService.php index 19a2f3f..e5091fd 100644 --- a/app/common/service/FinPaymentApplyService.php +++ b/app/common/service/FinPaymentApplyService.php @@ -3,6 +3,7 @@ namespace app\common\service; use app\common\model\FinPaymentStock; +use app\common\model\FinReceipt; use app\common\validate\FinPaymentApplyValidate; use app\common\traits\crud\CrudServiceTrait; use app\common\model\FinPaymentApply; @@ -182,10 +183,16 @@ class FinPaymentApplyService $query->whereDoesntHave('receipt'); } - if (isset($param['scene']) && $param['scene'] == 'list') { - return $query->paginate($limit, ['*'], 'page', $page); + if ((isset($param['scene']) && $param['scene'] == 'list') || empty($param['receipt_id'])) { + return $query->orderBy('id','desc')->paginate($limit, ['*'], 'page', $page); } + $receipt = FinReceipt::where('id', $param['receipt_id'])->first(); + $account_id = $receipt->account_id; + $currency_id = $receipt->currency_id; + $remitter = $receipt->remitter; + $amount = $receipt->amount; + // 计算十天前的时间戳 $sevenDaysAgo = time() - (10 * 24 * 60 * 60); @@ -193,29 +200,24 @@ class FinPaymentApplyService $similarityOrder = []; // 如果有传入参数,计算相似度 - if (isset($param['account_id']) && !empty($param['account_id'])) { - $similarityOrder[] = "CASE WHEN account_id = {$param['account_id']} THEN 0 ELSE 1 END"; + if (!empty($account_id)) { + $similarityOrder[] = "CASE WHEN account_id = {$account_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 (!empty($currency_id)) { + $similarityOrder[] = "CASE WHEN currency_id = {$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 (!empty($remitter)) { + $similarityOrder[] = "CASE WHEN remitter = {$remitter} THEN 0 ELSE 1 END"; } - if (isset($param['amount']) && !empty($param['amount'])) { - $amount = (float)$param['amount']; + if (!empty($amount)) { + $amount = (float)$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']) { - $keyword = addslashes($param['keyword']); - $similarityOrder[] = "CASE WHEN remitter LIKE '%{$keyword}%' THEN 0 ELSE 1 END"; - } - // 构建排序SQL $orderByClause = ""; if (!empty($similarityOrder)) { @@ -227,11 +229,11 @@ class FinPaymentApplyService } $orderByClause .= "CASE - WHEN created_at < {$sevenDaysAgo} THEN id + WHEN created_at > {$sevenDaysAgo} THEN id ELSE 999999 - END DESC"; + END DESC, "; - $orderByClause .= ", id DESC"; + $orderByClause .= "id DESC"; $query->orderByRaw($orderByClause); From 672258e594d1f2634f81f890458ffcc0e4966a5a Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Thu, 30 Oct 2025 13:35:53 +0800 Subject: [PATCH 37/39] =?UTF-8?q?=E6=94=B6=E6=AC=BE=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard/FinStatisticsController.php | 44 +++++++++++++++++++ .../controller/FinReceiptController.php | 15 +++++++ app/common/service/FinReceiptService.php | 19 +++++++- config/route.php | 4 ++ 4 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 app/admin/controller/dashboard/FinStatisticsController.php diff --git a/app/admin/controller/dashboard/FinStatisticsController.php b/app/admin/controller/dashboard/FinStatisticsController.php new file mode 100644 index 0000000..a3d3f9b --- /dev/null +++ b/app/admin/controller/dashboard/FinStatisticsController.php @@ -0,0 +1,44 @@ +',0); + + $result = []; + //已认领数量 + $result['claimed_num'] = $query->count(); + //已认领金额 + $result['claimed_amount'] = $query->sum('amount'); + + + $query = FinReceipt::whereNull('payment_apply_id'); + + //未认领数量 + $result['unclaimed_num'] = $query->count(); + //未认领金额 + $result['unclaimed_amount'] = $query->sum('amount'); + + //已超时未认领数量 + $result['timeout'] = $query->where('created_at','<',time()-24*3600)->count(); + + return $this->success($result); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } + +} \ No newline at end of file diff --git a/app/common/controller/FinReceiptController.php b/app/common/controller/FinReceiptController.php index d8ef9c2..4e9c574 100644 --- a/app/common/controller/FinReceiptController.php +++ b/app/common/controller/FinReceiptController.php @@ -147,4 +147,19 @@ class FinReceiptController extends BaseController } return $data; } + + /** + * 收款记录统计 + * @param Request $request + * @return \support\Response + */ + public function statistics(Request $request) + { + try { + $raw = $this->service->statistics(); + return $this->success($raw); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } } \ No newline at end of file diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php index 91db094..1f1c731 100644 --- a/app/common/service/FinReceiptService.php +++ b/app/common/service/FinReceiptService.php @@ -279,7 +279,7 @@ class FinReceiptService } /** - * 更新计算折让金额 + * 更新:绑定收款记录,计算折让金额 * @param Request $request * @param array $data * @param string $scene @@ -296,9 +296,24 @@ class FinReceiptService //折让金额 $payment = FinPaymentApply::where('id', $payment_apply_id)->first(); $receipt = FinReceipt::find($id); - $data['discount_amount'] = $payment->amount - $payment->amount ?? 0; + $data['discount_amount'] = $payment->amount - $receipt->amount ?? 0; $updated = $this->logicUpdateBy($config, $data); return $this->postProcess(ucfirst($scene), $data); } + + /** + * 收款记录统计 + * @return bool|int + */ + public function statistics() + { + $finReceipt = FinReceipt::find($id); + if(!empty($finReceipt->received_at)){ + throw new BusinessException('该记录已将确认入账'); + } + $res = $this->logic->credit($id); + $this->afterServiceUpdate(['id'=>$id]); + return $res; + } } \ No newline at end of file diff --git a/config/route.php b/config/route.php index b962ee9..ec7d821 100644 --- a/config/route.php +++ b/config/route.php @@ -368,6 +368,10 @@ Route::group('/admin', function () { Route::any('/show', [app\common\controller\FinReceiptHisController::class, 'show']); }); + Route::group('/fin', function () { + Route::any('/statistics', [app\admin\controller\dashboard\FinStatisticsController::class, 'statistics']); + }); + // 付款申请 Route::group('/payment', function () { Route::any('/list', [app\common\controller\FinPaymentApplyController::class, 'index']); From ea3d511c4d486e56b133a7e0c9b84074a480c97d Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Thu, 30 Oct 2025 14:26:59 +0800 Subject: [PATCH 38/39] =?UTF-8?q?=E6=9C=AA=E5=85=A5=E8=B4=A6=E9=87=91?= =?UTF-8?q?=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/dashboard/FinStatisticsController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/admin/controller/dashboard/FinStatisticsController.php b/app/admin/controller/dashboard/FinStatisticsController.php index a3d3f9b..95cf09d 100644 --- a/app/admin/controller/dashboard/FinStatisticsController.php +++ b/app/admin/controller/dashboard/FinStatisticsController.php @@ -24,6 +24,10 @@ class FinStatisticsController extends BaseController //已认领金额 $result['claimed_amount'] = $query->sum('amount'); + //未入账数量 + $result['unreceived_num'] = FinReceipt::whereNull('received_at')->count(); + //未入账金额 + $result['unreceived_amount'] = FinReceipt::whereNull('received_at')->sum('amount'); $query = FinReceipt::whereNull('payment_apply_id'); From 077edc5fd6bf914e31c22f1909c2e1187a1be706 Mon Sep 17 00:00:00 2001 From: mzl Date: Thu, 30 Oct 2025 14:40:24 +0800 Subject: [PATCH 39/39] Merge branch 'feature/mzl_dev' into develop # Conflicts: # config/route.php --- .../dashboard/OfficeClerkController.php | 164 ++++++++++++++++++ config/route.php | 11 ++ 2 files changed, 175 insertions(+) create mode 100644 app/admin/controller/dashboard/OfficeClerkController.php diff --git a/app/admin/controller/dashboard/OfficeClerkController.php b/app/admin/controller/dashboard/OfficeClerkController.php new file mode 100644 index 0000000..2bd2bcc --- /dev/null +++ b/app/admin/controller/dashboard/OfficeClerkController.php @@ -0,0 +1,164 @@ +where('approver_id', $request->user->uid) + ->where('status', 'approved') + ->count('id'); + + $pending = Db::table('approval_records') + ->where('approver_id', $request->user->uid) + ->where('status', 'pending') + ->count('id'); + + $unclaimed = Db::table('fin_payment_apply') + ->where('doc_user_id', $request->user->uid) + ->where('receipt_id', 0) + ->count('id'); + + $claimed = Db::table('fin_payment_apply') + ->where('doc_user_id', $request->user->uid) + ->where('receipt_id', '>', 0) + ->count('id'); + + $twentyFourHoursAgo = time() - (24 * 3600); + $timeout = Db::table('fin_payment_apply') + ->where('doc_user_id', $request->user->uid) + ->whereNotNull('submit_files') + ->whereJsonLength('submit_files', '>', 0) + ->where('receipt_id', '>', 0) + ->where('claimed_at', '<', $twentyFourHoursAgo) + ->count('id'); + + return $this->success([ + 'approved' => $approved, + 'pending' => $pending, + 'unclaimed' => $unclaimed, + 'claimed' => $claimed, + 'timeout' => $timeout + ]); + } + + // 曲线 + public function curve() + { + $groupIds = Db::table('user_group') + ->where('scenario_code', 'stock_orders') + ->pluck('id'); + $userIds = Db::table('user_group_members') + ->whereIn('group_id', $groupIds) + ->pluck('user_id'); + $list = Db::table('stock_orders') + ->join('user', 'stock_orders.salesperson_id', '=', 'user.id') + ->whereIn('stock_orders.salesperson_id', $userIds) + ->whereIn('stock_orders.approval_status', [0, 1, 2]) + ->whereNull('stock_orders.deleted_at') + ->groupBy('stock_orders.salesperson_id', 'user.name') + ->selectRaw('user.name, count(*) as count') + ->pluck('count', 'name') + ->toArray(); + $optionType = []; + $counts = []; + foreach ($list as $key=>$val) { + $optionType[] = $key; + $counts[] = $val; + } + $arr = [ + "optionType" => $optionType, + "counts" => $counts + ]; + return $this->success($arr); + } + + // 审批 + public function approval(Request $request) + { + $list = Db::table('approval_records as ar') + ->join('approval_instances as ai', 'ar.instance_id', '=', 'ai.id') + ->join('stock_orders as so', 'ai.biz_id', '=', 'so.id') + ->where('ar.approver_id', $request->user->uid) + ->where('ar.status', 'pending') + ->where('ai.flow_type', 'stock_orders') + ->where('ai.biz_type', 'stock_orders') + ->where('ai.status', 'processing') + ->whereNull('so.deleted_at') + ->select( + 'so.order_no', + 'ai.created_at as approval_created_at', + 'so.salesperson_snapshot as salesperson_name' + ) + ->get() + ->map(function($item) { + return [ + 'order_no' => $item->order_no, + 'approval_created_at' => date('Y-m-d H:i:s', strtotime($item->approval_created_at)), // 格式化时间 + 'salesperson_name' => $item->salesperson_name + ]; + }) + ->toArray(); + return $this->success($list); + } + + // 认领 + public function claim(Request $request) + { + $type = $request->get('type'); + if ($type == 'unclaimed') { + $list = Db::table('fin_payment_apply') + ->where('doc_user_id', $request->user->uid) + ->where('receipt_id', 0) + ->select( + 'apply_no', + 'amount', + 'created_at' + ) + ->get() + ->map(function($item) { + return [ + 'apply_no' => $item->apply_no, + 'amount' => $item->amount, + 'created_at' => date('Y-m-d H:i:s', $item->created_at) + ]; + }) + ->toArray(); + } else { + $twentyFourHoursAgo = time() - (24 * 3600); + $list = Db::table('fin_payment_apply') + ->where('doc_user_id', $request->user->uid) + ->whereNotNull('submit_files') + ->whereJsonLength('submit_files', '>', 0) + ->where('receipt_id', '>', 0) + ->where('claimed_at', '<', $twentyFourHoursAgo) + ->select( + 'apply_no', + 'amount', + 'created_at' + ) + ->get() + ->map(function($item) { + return [ + 'apply_no' => $item->apply_no, + 'amount' => $item->amount, + 'created_at' => date('Y-m-d H:i:s', $item->created_at) + ]; + }) + ->toArray(); + } + return $this->success($list); + } +} \ No newline at end of file diff --git a/config/route.php b/config/route.php index d6536c4..22b0862 100644 --- a/config/route.php +++ b/config/route.php @@ -459,6 +459,17 @@ Route::group('/admin', function () { Route::any('/update', [app\admin\controller\SysConfigController::class, 'update']); Route::any('/destroy', [app\admin\controller\SysConfigController::class, 'destroy']); }); + + // 仪表盘 + Route::group('/dashboard', function () { + // 内勤 + Route::group('/officeclerk', function () { + Route::any('/card', [app\admin\controller\dashboard\OfficeClerkController::class, 'card']); + Route::any('/curve', [app\admin\controller\dashboard\OfficeClerkController::class, 'curve']); + Route::any('/approval', [app\admin\controller\dashboard\OfficeClerkController::class, 'approval']); + Route::any('/claim', [app\admin\controller\dashboard\OfficeClerkController::class, 'claim']); + }); + }); });