BalanceSetLog.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2018/11/3
  6. * Time: 11:54
  7. */
  8. namespace app\common\services\operation;
  9. class BalanceSetLog extends OperationBase
  10. {
  11. public $modules = 'finance';
  12. public $type = 'balance';
  13. private $default = false;
  14. protected function modifyDefault()
  15. {
  16. if (isset($this->model['type'])) {
  17. $this->default = true;
  18. $this->setLog('mark', $this->model['type']);
  19. $this->setLog('type', 'withdraw_balance');
  20. } else {
  21. $this->setLog('mark', 'finance.balance');
  22. }
  23. }
  24. protected function special()
  25. {
  26. }
  27. /**
  28. * 获取模型需要记录的字段
  29. * @return mixed
  30. */
  31. protected function recordField()
  32. {
  33. $balance = [
  34. 'recharge' => ['field_name'=>'账户充值', 0=>'关闭账户充值', 1=>'开启账户充值' ],
  35. 'recharge_activity' => ['field_name'=>'充值活动', 0=>'关闭充值活动', 1=>'开启充值活动', 2=>'重置充值活动' ],
  36. 'proportion_status' => ['field_name'=>'充值满额送', 0=>'赠送固定金额', 1=>'赠送充值比例'],
  37. ];
  38. $withdraw_balance = [
  39. 'status' => ['field_name'=>'开启余额提现', 0=>'关闭', 1=>'开启'],
  40. 'wechat' => ['field_name'=>'余额提现到微信', 0=>'关闭', 1=>'开启'],
  41. 'alipay' => ['field_name'=>'余额提现到支付宝', 0=>'关闭', 1=>'开启'],
  42. 'balance_manual' => ['field_name'=>'余额手动提现', 0=>'关闭', 1=>'开启'],
  43. 'poundage_type' => ['field_name'=>'余额提现手续费',0=>'手续费比例', 1=>'固定金额'],
  44. 'withdrawmoney' => '余额提现限制(最小金额值)',
  45. ];
  46. if ($this->default) {
  47. return $withdraw_balance;
  48. }
  49. return $balance;
  50. }
  51. /**
  52. * 获取模型修改了哪些字段
  53. * @param object array
  54. * @return array
  55. */
  56. protected function modifyField()
  57. {
  58. $model = $this->model;
  59. $keys = array_keys($this->recordField());
  60. $old = array_only($model['old'], $keys);
  61. $new = array_only($model['new'], $keys);
  62. if (empty($old) || empty($new)) {
  63. return [];
  64. }
  65. foreach ($this->recordField() as $key => $item) {
  66. if ($old[$key] != $new[$key]) {
  67. $this->modify_fields[$key]['old_content'] = $old[$key];
  68. $this->modify_fields[$key]['new_content'] = $new[$key];
  69. }
  70. }
  71. return $this->modify_fields;
  72. }
  73. }