CashierActionLog.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * CashierActionLog.php
  4. * todo 文件描述
  5. * Created on 2024/12/11 上午9:47
  6. * @author: hankaige
  7. */
  8. namespace app\models;
  9. class CashierActionLog extends \yii\db\ActiveRecord
  10. {
  11. const SEND_COUPON = 1;
  12. const EDIT_USER = 2;
  13. const ADD_USER = 3;
  14. const RECHARGE_MONEY = 4;
  15. const RECHARGE_INTEGRAL = 5;
  16. const HANGINF_ORDER = 6;
  17. const DEL_HANGINF_ORDER = 7;
  18. const CREATE_ORDER = 8;
  19. const REFUND_ORDER = 9;
  20. const TEXT = [
  21. self::SEND_COUPON => '优惠券发放',
  22. self::EDIT_USER => '编辑用户信息',
  23. self::ADD_USER => '创建会员',
  24. self::RECHARGE_MONEY => '余额充值',
  25. self::RECHARGE_INTEGRAL => '积分充值',
  26. self::HANGINF_ORDER => '挂单操作',
  27. self::DEL_HANGINF_ORDER => '删除挂单',
  28. self::CREATE_ORDER => '订单下单',
  29. self::REFUND_ORDER => '订单退款'
  30. ];
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public static function tableName()
  35. {
  36. return '{{%cashier_action_log}}';
  37. }
  38. public function rules()
  39. {
  40. return [
  41. [['store_id','user_id'],'required'],
  42. [['store_id','user_id','action'],'integer'],
  43. [['desc'],'string']
  44. ];
  45. }
  46. public function attributeLabels()
  47. {
  48. return [
  49. 'store_id' => '商城ID',
  50. 'user_id' => '操作人ID',
  51. 'action' => '操作类型',
  52. 'desc' => '操作内容'
  53. ];
  54. }
  55. public static function setLog($storeId,$userId,$action,$desc, $md_id = 0){
  56. $model = new self();
  57. $model->store_id = $storeId;
  58. $model->md_id = $md_id;
  59. $model->user_id = $userId;
  60. $model->action = $action;
  61. $model->desc = $desc;
  62. $model->created_at = time();
  63. $model->save();
  64. }
  65. public function getUser(){
  66. return $this->hasOne(User::className(),['id' => 'user_id'])->select('id,nickname');
  67. }
  68. }