<?php

namespace plugin\admin\app\model;
/**
 * @property integer $id 主键(主键)
 * @property string $title 标题
 * @property string $icon 图标
 * @property string $key 标识
 * @property integer $pid 上级菜单
 * @property string $created_at 创建时间
 * @property string $updated_at 更新时间
 * @property string $href url
 * @property integer $type 类型
 * @property integer $weight 排序
 */
class Withdrawl extends \app\model\Withdrawl
{
    public static function onAfterUpdate($row)
    {
        $changedData = $row->getChangedData();
        if(isset($changedData['status'])){
            if ( $changedData['status']==\app\enum\WithdrawlStatus::TRANSFERRING->value) {
                Hook('withdrawl.transfering',$row);
            }else if ( $changedData['status']==\app\enum\WithdrawlStatus::COMPLETE->value) {
                Hook('withdrawl.success',$row);
            }else if ( $changedData['status']==\app\enum\WithdrawlStatus::REJECT->value) {
                \app\model\User::money($row->user_id,$row->deduction_amount,\app\enum\BalanceType::WITHDRAWAL_REJECT,$row->id);
                Hook('withdrawl.reject',$row);
            }
        }
    }
}
