| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- /**
- * CashierActionLog.php
- * todo 文件描述
- * Created on 2024/12/11 上午9:47
- * @author: hankaige
- */
- namespace app\models;
- class CashierActionLog extends \yii\db\ActiveRecord
- {
- const SEND_COUPON = 1;
- const EDIT_USER = 2;
- const ADD_USER = 3;
- const RECHARGE_MONEY = 4;
- const RECHARGE_INTEGRAL = 5;
- const HANGINF_ORDER = 6;
- const DEL_HANGINF_ORDER = 7;
- const CREATE_ORDER = 8;
- const REFUND_ORDER = 9;
- const TEXT = [
- self::SEND_COUPON => '优惠券发放',
- self::EDIT_USER => '编辑用户信息',
- self::ADD_USER => '创建会员',
- self::RECHARGE_MONEY => '余额充值',
- self::RECHARGE_INTEGRAL => '积分充值',
- self::HANGINF_ORDER => '挂单操作',
- self::DEL_HANGINF_ORDER => '删除挂单',
- self::CREATE_ORDER => '订单下单',
- self::REFUND_ORDER => '订单退款'
- ];
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%cashier_action_log}}';
- }
- public function rules()
- {
- return [
- [['store_id','user_id'],'required'],
- [['store_id','user_id','action'],'integer'],
- [['desc'],'string']
- ];
- }
- public function attributeLabels()
- {
- return [
- 'store_id' => '商城ID',
- 'user_id' => '操作人ID',
- 'action' => '操作类型',
- 'desc' => '操作内容'
- ];
- }
- public static function setLog($storeId,$userId,$action,$desc, $md_id = 0){
- $model = new self();
- $model->store_id = $storeId;
- $model->md_id = $md_id;
- $model->user_id = $userId;
- $model->action = $action;
- $model->desc = $desc;
- $model->created_at = time();
- $model->save();
- }
- public function getUser(){
- return $this->hasOne(User::className(),['id' => 'user_id'])->select('id,nickname');
- }
- }
|