master
cody 6 months ago
parent 02d9499b88
commit 71a16f0627

@ -190,6 +190,7 @@ class CourseController extends BaseController
* @OA\Parameter(name="total", in="query", @OA\Schema(type="integer"), description="开课人数"), * @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="class", in="query", @OA\Schema(type="string"), description="所在班级"),
* @OA\Parameter(name="price", 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_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="is_fee", in="query", @OA\Schema(type="integer"), description="是否缴费-0否1是"),
* @OA\Parameter(name="status", in="query", @OA\Schema(type="integer"), description="课程状态0待发布, 1已发布"), * @OA\Parameter(name="status", in="query", @OA\Schema(type="integer"), description="课程状态0待发布, 1已发布"),

@ -309,6 +309,10 @@ class CourseController extends CommonController
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]); return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
} }
$signModel = CourseSign::find($all['id']); $signModel = CourseSign::find($all['id']);
// 如果已缴费或者已上传凭证,不允许修改
if ($signModel->fee_status == 1 || !empty($signModel->fee_file_ids)) {
return $this->fail([ResponseCode::ERROR_BUSINESS, '已缴费或已上传凭证,不允许修改']);
}
$original = $signModel->getOriginal(); $original = $signModel->getOriginal();
$signModel->fill($all); $signModel->fill($all);
$signModel->save(); $signModel->save();
@ -523,7 +527,7 @@ class CourseController extends CommonController
* path="/api/mobile/course/pay", * path="/api/mobile/course/pay",
* tags={"小程序-课程"}, * tags={"小程序-课程"},
* summary="获取支付参数", * 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\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
* @OA\Response( * @OA\Response(
* response="200", * response="200",
@ -535,21 +539,30 @@ class CourseController extends CommonController
{ {
$all = \request()->all(); $all = \request()->all();
$messages = [ $messages = [
'no.required' => 'no必填', 'payment_no.required' => '支付订单号必填',
]; ];
$validator = Validator::make($all, [ $validator = Validator::make($all, [
'no' => 'required', 'payment_no' => 'required',
], $messages); ], $messages);
if ($validator->fails()) { if ($validator->fails()) {
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]); 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) { if (!$courseSign) {
return $this->fail([ResponseCode::ERROR_PARAMETER, '订单不存在']); 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); $course = Course::find($courseSign->course_id);
if ($course->fee_type != 2) { if ($course->supply_wechat_pay != 1) {
return $this->fail([ResponseCode::ERROR_PARAMETER, '支付类型错误']); return $this->fail([ResponseCode::ERROR_PARAMETER, '不支持微信支付']);
}
if (empty($course->is_fee)) {
return $this->fail([ResponseCode::ERROR_PARAMETER, '课程未设置收费']);
} }
// 下单 // 下单
$config = [ $config = [
@ -560,9 +573,9 @@ class CourseController extends CommonController
$app = Factory::payment($config); $app = Factory::payment($config);
$result = $app->order->unify([ $result = $app->order->unify([
'trade_type' => 'NATIVE', 'trade_type' => 'NATIVE',
'product_id' => $courseSign->no, 'product_id' => $courseSign->payment_no,
'body' => $courseSign->title, 'body' => $courseSign->title,
'out_trade_no' => $courseSign->no, 'out_trade_no' => $courseSign->payment_no,
'total_fee' => $courseSign->money * 100, 'total_fee' => $courseSign->money * 100,
'notify_url' => getDomain() . '/api/mobile/course/pay_callback', 'notify_url' => getDomain() . '/api/mobile/course/pay_callback',
]); ]);

@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
return new class extends Migration return new class extends Migration {
{
/** /**
* Run the migrations. * Run the migrations.
* *
@ -15,7 +14,7 @@ return new class extends Migration
{ {
Schema::table('course_signs', function (Blueprint $table) { 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('订单金额'); $table->decimal('money', 10, 2)->nullable()->comment('订单金额');
// 标题 // 标题

@ -14,7 +14,7 @@ return new class extends Migration {
{ {
Schema::table('courses', function (Blueprint $table) { Schema::table('courses', function (Blueprint $table) {
$table->decimal('price', 10, 2)->nullable()->default(0)->comment('价格'); $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是');
}); });
} }

Loading…
Cancel
Save