<?php
    namespace app\money\model;
    use think\helper\Hash;
    use app\money\model\Role as RoleModel;
    use think\model;
    use think\Db;
    
    class EsopPlan extends Model
    {
        
        // 设置当前模型对应的完整数据表名称
        protected $table = '__ESOP__PLAN__';


        public static function  getAll($map=[], $order='')
        {
            $data_list = self::view('esop_plan p', true)
                        ->view('member', 'mobile, name, id_card', 'member.id=p.mid', 'left')
                        ->view('stock_list', 'title', 'stock_list.id=p.stock_id', 'left')
                        ->where($map)
                        ->order($order)
                        ->paginate()
                        ->each( function($item, $key){
                            $item->account = money_convert($item->account);
                            $item->plan_account = money_convert($item->plan_account);
                            $item->remain_account = money_convert($item->remain_account);
                            $item->release_account = money_convert($item->release_account);
                        });
       
            return $data_list;

        }

        /*
         * 释放时自动更新期权计划信息
         *
         */
        public static function plan_up($id,$mmoney){
            return self::where(["id"=>$id])->update($mmoney);
        }

    }
?>
