GoodsCategoryLog.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2018/10/31
  6. * Time: 16:10
  7. */
  8. namespace app\common\services\operation;
  9. class GoodsCategoryLog extends OperationBase
  10. {
  11. public $modules = 'goods';
  12. public $type = 'update';
  13. protected function modifyDefault()
  14. {
  15. $this->setLog('mark', $this->model->goods_id);
  16. }
  17. /**
  18. * 获取模型需要记录的字段
  19. * @return mixed
  20. */
  21. protected function recordField()
  22. {
  23. return [
  24. 'category_id' => '商品分类',
  25. ];
  26. }
  27. /**
  28. * 获取模型修改了哪些字段
  29. * @param object array
  30. * @return array
  31. */
  32. protected function modifyField()
  33. {
  34. $model = $this->model;
  35. foreach ($this->recordField() as $key => $item) {
  36. if ( $model->isDirty($key)) {
  37. $this->modify_fields[$key]['old_content'] = '商品ID:'.$model->goods_id;
  38. $this->modify_fields[$key]['new_content'] = '分类ID:'.$model->{$key};
  39. }
  40. }
  41. return $this->modify_fields;
  42. }
  43. }