|
|
|
|
@ -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',
|
|
|
|
|
]);
|
|
|
|
|
|