PackageOrder.php
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace app\mobile\model;
use think\Model;
use think\Db;
class PackageOrder extends Model
{
// 表名
protected $name = 'mobile_package_order';
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
// 课程信息
public function course(){
return $this->belongsTo('Course');
}
/**
* 新增订单
*/
public function add($user, $order, $pay_type)
{
// 记录订单信息
$this->save([
'user_id' => $user['id'],
'company_id' => Company::where('user_id',$user['id'])->value('id'),
'package_id' => $order['package_info']['id'],
'order_sn' => get_order_sn(),
'pay_price' => $order['pay_price'],
'pay_type' => $pay_type,
'package_price' => $order['package_price'],
'people_num' => $order['spec_info']['people_num'],
'course_spec_id' => $order['spec_info']['id'],
'is_top' => $order['spec_info']['is_top']
]);
return true;
}
}