This commit is contained in:
knowpia
2022-09-14 09:31:30 +08:00
parent 7cdf9fef70
commit c133d6c830
2 changed files with 31 additions and 3 deletions

View File

@@ -2,6 +2,7 @@
namespace app\controller;
use app\model\Student;
use think\response\Json;
class Order
@@ -16,10 +17,22 @@ class Order
public function create(): Json
{
$userid = $GLOBALS['data']['userid'];
$amount = $GLOBALS['data']['amount'] ?? 15;
$amount = env("PAY_AMOUNT") ?? 15;
if(env("APP_DEBUG")){
$amount = 0.01;
}
if(empty($GLOBALS['data']['data']['student_id'])){
return show("请正确上传用户信息!", ERROR_CODE,[]);
}
$student_id = $GLOBALS['data']['data']['student_id'];
if(!Student::findOrEmpty($student_id)){
return show("用户信息不存在!", ERROR_CODE,[]);
}
if(\app\model\Order::where(["userid"=>$userid,"student_id"=>$student_id,"status"=>1])->find()){
return show("已经为该孩子助力过了!", ERROR_CODE,[]);
}
$order = \app\model\Order::create([
'student_id' => 14,
'student_id' => $student_id,
'user_id' => $userid,
'amount' => $amount,
'status' => 0,