OrderAction.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace addons\shopro\model;
  3. use think\Model;
  4. use addons\shopro\exception\Exception;
  5. use think\Db;
  6. /**
  7. * 订单操作日志
  8. */
  9. class OrderAction extends Model
  10. {
  11. // 表名,不含前缀
  12. protected $name = 'shopro_order_action';
  13. // 自动写入时间戳字段
  14. protected $autoWriteTimestamp = 'int';
  15. // 定义时间戳字段名
  16. protected $createTime = 'createtime';
  17. protected $updateTime = 'updatetime';
  18. protected $deleteTime = 'deletetime';
  19. protected $hidden = ['createtime', 'updatetime', 'deletetime'];
  20. // //列表动态隐藏字段
  21. // protected static $list_hidden = ['content', 'params', 'images', 'service_ids'];
  22. public static function operAdd($order = null, $item = null, $oper = null, $type = 'user', $remark = '')
  23. {
  24. $oper_id = empty($oper) ? 0 : (is_array($oper) ? $oper['id'] : $oper->id);
  25. $self = new self();
  26. $self->order_id = $order['id'];
  27. $self->order_item_id = is_null($item) ? 0 : $item['id'];
  28. $self->oper_type = $type;
  29. $self->oper_id = $oper_id;
  30. $self->order_status = is_null($order) ? 0 : $order['status'];
  31. $self->dispatch_status = is_null($item) ? 0 : $item['dispatch_status'];
  32. $self->comment_status = is_null($item) ? 0 : $item['comment_status'];
  33. $self->aftersale_status = is_null($item) ? 0 : $item['aftersale_status'];
  34. $self->refund_status = is_null($item) ? 0 : $item['refund_status'];
  35. $self->remark = $remark;
  36. $self->save();
  37. return $self;
  38. }
  39. }