RelationLog.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2018/11/3
  6. * Time: 9:58
  7. */
  8. namespace app\common\services\operation;
  9. class RelationLog extends OperationBase
  10. {
  11. public $modules = 'member';
  12. public $type = 'relation';
  13. protected function modifyDefault()
  14. {
  15. $this->setLog('mark', $this->model->getOriginal('id'));
  16. }
  17. /**
  18. * 获取模型需要记录的字段
  19. * @return mixed
  20. */
  21. protected function recordField()
  22. {
  23. return [
  24. 'status' => ['field_name'=>'会员关系链' , 1=> '启用关系链', 0=>' 禁用关系链'],
  25. 'become_child' => ['field_name' => '会员成为下线条件',0=>'首次点击分享链接', 1=>'首次下单', 2=>'首次付款'],
  26. 'become' => '获得发展下线权利条件',
  27. ];
  28. }
  29. /**
  30. * 获取模型修改了哪些字段
  31. * @param object array
  32. * @return array
  33. */
  34. protected function modifyField()
  35. {
  36. $model = $this->model;
  37. if (is_null($model->getOriginal())) {
  38. return [];
  39. }
  40. foreach ($this->recordField() as $key => $item) {
  41. if ($model->isDirty($key)) {
  42. if ($key == 'become') {
  43. $this->modify_fields[$key]['old_content'] = $this->arrayValue($model,$model->getOriginal($key));
  44. $this->modify_fields[$key]['new_content'] = $this->arrayValue($model,$model->{$key});
  45. } else {
  46. $this->modify_fields[$key]['old_content'] = $model->getOriginal($key);
  47. $this->modify_fields[$key]['new_content'] = $model->{$key};
  48. }
  49. }
  50. }
  51. return $this->modify_fields;
  52. }
  53. private function arrayValue($model, $key)
  54. {
  55. $array = [
  56. 'key' => $key,
  57. 0 => '无条件',
  58. 1 => '申请',
  59. 2 => '消费达到('.$model->become_ordercount.')次',
  60. 3 => '消费达到('.$model->become_moneycount.')元',
  61. 4 => '购买指定商品ID:'.$model->become_goods_id,
  62. ];
  63. return $array;
  64. }
  65. }