SaleLog.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2018/11/1
  6. * Time: 10:51
  7. */
  8. namespace app\common\services\operation;
  9. class SaleLog extends OperationBase
  10. {
  11. public $modules = 'goods';
  12. public $type = 'update';
  13. protected function modifyDefault()
  14. {
  15. $this->setLog('mark', $this->model->getOriginal('goods_id'));
  16. }
  17. /**
  18. * 获取模型需要记录的字段
  19. * @return mixed
  20. */
  21. protected function recordField()
  22. {
  23. return [
  24. 'ed_num' => '单品满件包邮',
  25. 'ed_money' => '单品满额包邮',
  26. 'ed_full_reduction' => '单品满额立减',
  27. 'award_balance' => '赠送余额',
  28. 'pay_reward_balance' => '赠送门店余额',
  29. 'point' => '赠送积分',
  30. 'max_point_deduct' => '积分最高抵扣',
  31. 'min_point_deduct' => '积分最低抵扣',
  32. ];
  33. }
  34. /**
  35. * 获取模型修改了哪些字段
  36. * @param object array
  37. * @return array
  38. */
  39. protected function modifyField()
  40. {
  41. $model = $this->model;
  42. foreach ($this->recordField() as $key => $item) {
  43. if ($model->isDirty('ed_full') || $model->isDirty('ed_reduction')) {
  44. $this->modify_fields['ed_full_reduction']['old_content'] = '满'.$model->getOriginal('ed_full').'元立减'.$model->getOriginal('ed_reduction').'元';
  45. $this->modify_fields['ed_full_reduction']['new_content'] = '满'.$model->ed_full.'元立减'.$model->ed_reduction.'元';
  46. }
  47. if ($model->isDirty($key)) {
  48. $this->modify_fields[$key]['old_content'] = $model->getOriginal($key);
  49. $this->modify_fields[$key]['new_content'] = $model->{$key};
  50. }
  51. }
  52. return $this->modify_fields;
  53. }
  54. }