OrderLog.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2018/11/3
  6. * Time: 11:20
  7. */
  8. namespace app\common\services\operation;
  9. class OrderLog extends OperationBase
  10. {
  11. public $modules = 'order';
  12. public $type = 'operating';
  13. protected function modifyDefault()
  14. {
  15. $this->setLog('mark', $this->model->getOriginal('id'));
  16. }
  17. protected function special()
  18. {
  19. $this->setLog('mark', $this->model->getOriginal('order_id'));
  20. $this->setLog('field_name', '修改订单备注');
  21. $this->setLog('field', 'remark');
  22. $this->setLog('old_content',$this->model->getOriginal('remark'));
  23. $this->setLog('new_content', $this->model->remark);
  24. }
  25. /**
  26. * 获取模型需要记录的字段
  27. * @return mixed
  28. */
  29. protected function recordField()
  30. {
  31. return [
  32. 'status' => ['field_name'=>'订单操作' , -1=> '关闭订单', 0=>'待付款', 1=>'待发货', 2=>'待收货', 3=>'订单完成'],
  33. //'status' => ['field_name'=>'订单操作' , -1=> '关闭订单', 0=>'订单确认付款', 1=>'订单确认发货', 2=>'订单确认收货', 3=>'订单完成'],
  34. 'refund_id' => '订单退款处理',
  35. 'price' => '订单改价',
  36. ];
  37. }
  38. /**
  39. * 获取模型修改了哪些字段
  40. * @param object array
  41. * @return array
  42. */
  43. protected function modifyField()
  44. {
  45. $model = $this->model;
  46. if (is_null($model->getOriginal())) {
  47. return [];
  48. }
  49. foreach ($this->recordField() as $key => $item) {
  50. if ($model->isDirty($key)) {
  51. $this->modify_fields[$key]['old_content'] = $model->getOriginal($key);
  52. $this->modify_fields[$key]['new_content'] = $model->{$key};
  53. }
  54. }
  55. return $this->modify_fields;
  56. }
  57. }