From 71a16f06277e0ab78d99e30e5632916b90968806 Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Mon, 23 Jun 2025 14:47:08 +0800 Subject: [PATCH] update --- .../Controllers/Admin/CourseController.php | 1 + .../Controllers/Mobile/CourseController.php | 29 ++++++++++++++----- ..._06_23_114618_alert_course_signs_table.php | 5 ++-- .../2025_06_23_133423_alert_courses_table.php | 2 +- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/Admin/CourseController.php b/app/Http/Controllers/Admin/CourseController.php index 6b044ba..ed0281f 100755 --- a/app/Http/Controllers/Admin/CourseController.php +++ b/app/Http/Controllers/Admin/CourseController.php @@ -190,6 +190,7 @@ class CourseController extends BaseController * @OA\Parameter(name="total", in="query", @OA\Schema(type="integer"), description="开课人数"), * @OA\Parameter(name="class", in="query", @OA\Schema(type="string"), description="所在班级"), * @OA\Parameter(name="price", in="query", @OA\Schema(type="string"), description="价格"), + * @OA\Parameter(name="supply_wechat_pay", in="query", @OA\Schema(type="string"), description="是否支持微信支付0否1是"), * @OA\Parameter(name="is_arrange", in="query", @OA\Schema(type="integer"), description="是否排课-0否1是"), * @OA\Parameter(name="is_fee", in="query", @OA\Schema(type="integer"), description="是否缴费-0否1是"), * @OA\Parameter(name="status", in="query", @OA\Schema(type="integer"), description="课程状态:0待发布, 1已发布"), diff --git a/app/Http/Controllers/Mobile/CourseController.php b/app/Http/Controllers/Mobile/CourseController.php index 1bc832f..551571f 100755 --- a/app/Http/Controllers/Mobile/CourseController.php +++ b/app/Http/Controllers/Mobile/CourseController.php @@ -309,6 +309,10 @@ class CourseController extends CommonController return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]); } $signModel = CourseSign::find($all['id']); + // 如果已缴费或者已上传凭证,不允许修改 + if ($signModel->fee_status == 1 || !empty($signModel->fee_file_ids)) { + return $this->fail([ResponseCode::ERROR_BUSINESS, '已缴费或已上传凭证,不允许修改']); + } $original = $signModel->getOriginal(); $signModel->fill($all); $signModel->save(); @@ -523,7 +527,7 @@ class CourseController extends CommonController * path="/api/mobile/course/pay", * tags={"小程序-课程"}, * summary="获取支付参数", - * @OA\Parameter(name="no", in="query", @OA\Schema(type="string"), required=false, description="no"), + * @OA\Parameter(name="payment_no", in="query", @OA\Schema(type="string"), required=false, description="payment_no"), * @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"), * @OA\Response( * response="200", @@ -535,21 +539,30 @@ class CourseController extends CommonController { $all = \request()->all(); $messages = [ - 'no.required' => 'no必填', + 'payment_no.required' => '支付订单号必填', ]; $validator = Validator::make($all, [ - 'no' => 'required', + 'payment_no' => 'required', ], $messages); if ($validator->fails()) { return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]); } - $courseSign = CourseSign::where('no', $all['no'])->first(); + $courseSign = CourseSign::where('payment_no', $all['payment_no'])->first(); if (!$courseSign) { return $this->fail([ResponseCode::ERROR_PARAMETER, '订单不存在']); } + if ($courseSign->status != 1) { + return $this->fail([ResponseCode::ERROR_PARAMETER, '审核状态异常']); + } + if ($courseSign->fee_status == 1) { + return $this->fail([ResponseCode::ERROR_PARAMETER, '请勿重复缴费']); + } $course = Course::find($courseSign->course_id); - if ($course->fee_type != 2) { - return $this->fail([ResponseCode::ERROR_PARAMETER, '支付类型错误']); + if ($course->supply_wechat_pay != 1) { + return $this->fail([ResponseCode::ERROR_PARAMETER, '不支持微信支付']); + } + if (empty($course->is_fee)) { + return $this->fail([ResponseCode::ERROR_PARAMETER, '课程未设置收费']); } // 下单 $config = [ @@ -560,9 +573,9 @@ class CourseController extends CommonController $app = Factory::payment($config); $result = $app->order->unify([ 'trade_type' => 'NATIVE', - 'product_id' => $courseSign->no, + 'product_id' => $courseSign->payment_no, 'body' => $courseSign->title, - 'out_trade_no' => $courseSign->no, + 'out_trade_no' => $courseSign->payment_no, 'total_fee' => $courseSign->money * 100, 'notify_url' => getDomain() . '/api/mobile/course/pay_callback', ]); diff --git a/database/migrations/2025_06_23_114618_alert_course_signs_table.php b/database/migrations/2025_06_23_114618_alert_course_signs_table.php index b4c5c2e..5b7a55b 100644 --- a/database/migrations/2025_06_23_114618_alert_course_signs_table.php +++ b/database/migrations/2025_06_23_114618_alert_course_signs_table.php @@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class extends Migration -{ +return new class extends Migration { /** * Run the migrations. * @@ -15,7 +14,7 @@ return new class extends Migration { Schema::table('course_signs', function (Blueprint $table) { // 订单号 - $table->string('no')->nullable()->comment('订单号'); + $table->string('payment_no')->nullable()->comment('订单号'); // 订单金额 $table->decimal('money', 10, 2)->nullable()->comment('订单金额'); // 标题 diff --git a/database/migrations/2025_06_23_133423_alert_courses_table.php b/database/migrations/2025_06_23_133423_alert_courses_table.php index 19a98d1..7bf8839 100644 --- a/database/migrations/2025_06_23_133423_alert_courses_table.php +++ b/database/migrations/2025_06_23_133423_alert_courses_table.php @@ -14,7 +14,7 @@ return new class extends Migration { { Schema::table('courses', function (Blueprint $table) { $table->decimal('price', 10, 2)->nullable()->default(0)->comment('价格'); - $table->boolean('fee_type')->default(1)->nullable()->comment('缴费类型1上传缴费凭证2在线支付'); + $table->boolean('supply_wechat_pay')->default(0)->nullable()->comment('是否支持微信支付0否1是'); }); }