dingd
This commit is contained in:
@@ -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'];
|
||||||
|
$amount = $GLOBALS['data']['amount'] ?? 15;
|
||||||
|
|
||||||
$order = \app\model\Order::create([
|
$order = \app\model\Order::create([
|
||||||
'student_id' => 1,
|
'student_id' => 14,
|
||||||
'user_id' => $userid,
|
'user_id' => $userid,
|
||||||
'amount' => 15,
|
'amount' => $amount,
|
||||||
'type' => 1,
|
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -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
15
app/model/Student.php
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user