ShopPayLog.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2018/11/1
  6. * Time: 18:58
  7. */
  8. namespace app\common\services\operation;
  9. class ShopPayLog extends OperationBase
  10. {
  11. public $modules = 'shop';
  12. public $type = 'pay';
  13. protected function modifyDefault()
  14. {
  15. $this->setLog('mark', 'shop.pay');
  16. }
  17. /**
  18. * 获取模型需要记录的字段
  19. * @return mixed
  20. */
  21. protected function recordField()
  22. {
  23. return [
  24. 'weixin' => ['field_name' => '微信支付',0=> '关闭', 1=>'开启'],
  25. 'weixin_pay' => ['field_name' => '标准微信支付',0=> '关闭', 1=>'开启'],
  26. 'weixin_appid' => '微信支付身份标识(appId)',
  27. 'weixin_secret'=> '微信身份密钥(appSecret)',
  28. 'weixin_mchid' => '微信支付商户号(mchId)',
  29. 'weixin_apisecret' => '微信支付密钥(apiSecret)',
  30. 'alipay' => ['field_name' => '支付宝支付',0=> '关闭', 1=>'开启'],
  31. 'alipay_withdrawals' => ['field_name' => '支付宝提现',0=> '关闭', 1=>'开启'],
  32. 'credit' => ['field_name' => '余额支付',0=> '关闭', 1=>'开启'],
  33. 'remittance' => ['field_name' => '银行转账',0=> '关闭', 1=>'开启'],
  34. 'remittance_bank' => '银行转账开户行',
  35. 'remittance_sub_bank' => '银行转账开户支行',
  36. 'remittance_bank_account_name' => '银行转账开户名',
  37. 'remittance_bank_account' => '银行转账开户账号',
  38. ];
  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. }