Commit 9c804c83 authored by wangzhengwen's avatar wangzhengwen

免费证书相关修改

parent 69d2c5d3
......@@ -5,6 +5,7 @@ namespace app\api\controller;
use app\api\middleware\Auth;
use app\api\service\AlipayTradeService;
use app\BaseController;
use app\model\Payment;
use think\facade\Log;
use think\facade\View;
use veitool\make\Controller;
......@@ -23,19 +24,7 @@ class PayController
*/
public function create($params)
{
// $params = request()->only([
// 'order_id',
// 'order_type',
// 'pay_method',
// 'amount',
// 'user_id'
// ]);
//
// // 验证参数
// $validate = validate('Pay');
// if (!$validate->scene('create')->check($params)) {
// return json(['code' => 400, 'msg' => $validate->getError()]);
// }
// 在调用 PayService::createPayment() 之前先检查是否存在有效支付记录
$existingPayment = Db::name('payment')
->where([
......
......@@ -254,10 +254,10 @@ class User extends BaseController
if (!$course) {
return $this->returnMsg('证书不存在');
}
if ($course['price']<=0)
{
return $this->returnMsg('免费证书无需购买');
}
// if ($course['price']<=0)
// {
// return $this->returnMsg('免费证书无需购买');
// }
$courseOrder = CertOrder::where(['status'=>0,'user_id'=>$userId,'cert_id'=>$course['id']])->count();
if (!$courseOrder)
......
......@@ -76,6 +76,13 @@ class PayService
'updatetime' => time(),
'expire_time' => time() + self::ORDER_TIMEOUT // 2小时过期
];
//如果是免费证书
if ($orderType == self::ORDER_TYPE_CERT and $amount <=0) {
$paymentData['pay_status'] = self::PAY_STATUS_SUCCESS;
self::handleBusinessAfterPayment($paymentData);
}
// 写入数据库
$paymentId = Db::name('payment')->insertGetId($paymentData);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment