This commit is contained in:
2022-09-09 16:35:41 +08:00
parent af2304dece
commit 66fbd56613
3 changed files with 31 additions and 7 deletions

View File

@@ -2,17 +2,26 @@
namespace app\controller; namespace app\controller;
use think\response\Json;
class Order class Order
{ {
/**
public function create() * Notes : 捐助订单
*
* @Date : 2022/9/9 16:30
* @Author : <Jason.C>
* @return Json
*/
public function create(): Json
{ {
$userid = $GLOBALS['data']['userid']; $userid = $GLOBALS['data']['userid'];
$order = \app\model\Order::create([ $amount = $GLOBALS['data']['amount'] ?? 15;
'student_id' => 1,
$order = \app\model\Order::create([
'student_id' => 14,
'user_id' => $userid, 'user_id' => $userid,
'amount' => 15, 'amount' => $amount,
'type' => 1,
'status' => 0, 'status' => 0,
]); ]);

View File

@@ -6,5 +6,5 @@ use think\Model;
class Order extends Model class Order extends Model
{ {
protected $autoWriteTimestamp = true;
} }

15
app/model/Student.php Normal file
View File

@@ -0,0 +1,15 @@
<?php
namespace app\model;
use think\Model;
use think\model\relation\HasMany;
class Student extends Model
{
public function orders(): HasMany
{
return $this->hasMany(Order::class);
}
}