OrderAction.php
1.5 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
43
44
45
46
<?php
namespace addons\shopro\model;
use think\Model;
use addons\shopro\exception\Exception;
use think\Db;
/**
* 订单操作日志
*/
class OrderAction extends Model
{
// 表名,不含前缀
protected $name = 'shopro_order_action';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = 'deletetime';
protected $hidden = ['createtime', 'updatetime', 'deletetime'];
// //列表动态隐藏字段
// protected static $list_hidden = ['content', 'params', 'images', 'service_ids'];
public static function operAdd($order = null, $item = null, $user = null, $type = 'user', $remark = '')
{
$oper_id = empty($user) ? 0 : (is_array($user) ? $user['id'] : $user->id);
$self = new self();
$self->order_id = $order['id'];
$self->order_item_id = is_null($item) ? 0 : $item['id'];
$self->oper_type = $type;
$self->oper_id = $oper_id;
$self->order_status = is_null($order) ? 0 : $order['status'];
$self->dispatch_status = is_null($item) ? 0 : $item['dispatch_status'];
$self->comment_status = is_null($item) ? 0 : $item['comment_status'];
$self->aftersale_status = is_null($item) ? 0 : $item['aftersale_status'];
$self->refund_status = is_null($item) ? 0 : $item['refund_status'];
$self->remark = $remark;
$self->save();
return $self;
}
}