IncomeSetLog.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2018/11/3
  6. * Time: 15:17
  7. */
  8. namespace app\common\services\operation;
  9. class IncomeSetLog extends OperationBase
  10. {
  11. public $modules = 'finance';
  12. public $type = 'income';
  13. protected function modifyDefault()
  14. {
  15. if (is_array($this->model)) {
  16. $this->setLog('mark', 'finance.income');
  17. } else {
  18. $this->setLog('mark', $this->model->getOriginal('id'));
  19. }
  20. }
  21. protected function special()
  22. {
  23. }
  24. /**
  25. * 获取模型需要记录的字段
  26. * @return mixed
  27. */
  28. protected function recordField()
  29. {
  30. $income = [
  31. 'balance' => ['field_name'=>'提现到余额', 0=>'关闭', 1=>'开启'],
  32. 'wechat' => ['field_name'=>'收入提现到微信', 0=>'关闭', 1=>'开启'],
  33. 'alipay' => ['field_name'=>'收入提现到支付宝', 0=>'关闭', 1=>'开启'],
  34. 'manual' => ['field_name'=>'收入手动提现', 0=>'关闭', 1=>'开启'],
  35. 'free_audit' => ['field_name'=>'收入提现免审核',0=>'关闭', 1=>'开启'],
  36. 'servicetax_rate' => '劳务税比例(%)',
  37. ];
  38. return $income;
  39. }
  40. /**
  41. * 获取模型修改了哪些字段
  42. * @param object array
  43. * @return array
  44. */
  45. protected function modifyField()
  46. {
  47. $model = $this->model;
  48. $keys = array_keys($this->recordField());
  49. $old = array_only($model['old'], $keys);
  50. $new = array_only($model['new'], $keys);
  51. if (empty($old) || empty($new)) {
  52. return [];
  53. }
  54. foreach ($this->recordField() as $key => $item) {
  55. if ($old[$key] != $new[$key]) {
  56. $this->modify_fields[$key]['old_content'] = $old[$key];
  57. $this->modify_fields[$key]['new_content'] = $new[$key];
  58. }
  59. }
  60. return $this->modify_fields;
  61. }
  62. }