post(); $mobile = $this->request->post('mobile'); if ($mobile) { $exists = \app\common\model\Invitation::where('mobile', $mobile)->find(); if ($exists) { //$this->error(); $this->success(__('Username already invited')); } else{ $dine = $params['dine']; $attendees = $params['attendees']; //echo print_r($dine)."
==". print_r($attendees); die;
                
                $feeData = array(
                        'username'=>$this->request->post('username'),
                        'company'=>$this->request->post('company'),
                        'position'=>$this->request->post('position'),
                        'mobile'=>$this->request->post('mobile'),
                        'hometown'=>$this->request->post('hometown'),
                        'gender'=>$this->request->post('gender'),
                        'is_member'=>$this->request->post('is_member'),
                        //'pay_member'=>$params['pay_member'],
                        'dine'=>json_encode($dine, JSON_UNESCAPED_UNICODE),
                        'attendees'=>json_encode($attendees, JSON_UNESCAPED_UNICODE)
                    );
                
                $invitation = new Invitation;
        
                try {
                    $result  = $invitation->allowField(true)->save($feeData);
        
                    if ($result !== false) {
                        $this->success();
                    } else {
                        $this->error($row->getError());
                    }
                } catch (\think\exception\PDOException $e) {
                    $this->error($e->getMessage());
                } catch (\think\Exception $e) {
                     $this->error($e->getMessage());
                }                
            }
        }  
    }
    
    public function test()
    {
        $this->success('返回成功', $this->request->param());
    }

    /**
     * 无需登录的接口
     *
     */
    public function test1()
    {
        $this->success('返回成功', ['action' => 'test1']);
    }

    /**
     * 需要登录的接口
     *
     */
    public function test2()
    {
        $this->success('返回成功', ['action' => 'test2']);
    }

    /**
     * 需要登录且需要验证有相应组的权限
     *
     */
    public function test3()
    {
        $this->success('返回成功', ['action' => 'test3']);
    }
    
    
    public function invitation()
    {

        $params = request()->post();

       /* $username = $this->request->post('username');
        $company = $this->request->post('company');
        $position = $this->request->post('position');
        $hometown = $this->request->post('hometown');
        $gender = $this->request->post('gender');
        $is_member = $this->request->post('is_member');
        $attendees = $this->request->post('attendees');
        
        
        if (!$username) {
            $this->error(__('Invalid parameters'));
        }
        
        if ($mobile && !Validate::regex($mobile, "^1\d{10}$")) {
            $this->error(__('Mobile is incorrect'));
        }*/
        $mobile = $this->request->post('mobile');
        $mobile = '13246777081';
            
         if ($mobile) {
            $exists = \app\common\model\Invitation::where('mobile', $mobile)->find();
            if ($exists) {
                //$this->error();
                $this->success(__('Username already invited'));
            }
            else{
                            
               $dine = $this->request->post('dine');
               $attendees = $this->request->post('attendees');
                
                
                $feeData = array(
                        'username'=>$this->request->post('username'),
                        'company'=>$this->request->post('company'),
                        'position'=>$this->request->post('position'),
                        'mobile'=>$this->request->post('mobile'),
                        'hometown'=>$this->request->post('hometown'),
                        'gender'=>$this->request->post('gender'),
                        'is_member'=>$this->request->post('is_member'),
                        //'pay_member'=>$params['pay_member'],
                        'dine'=>json_encode($dine, JSON_UNESCAPED_UNICODE),
                        'attendees'=>json_encode($attendees, JSON_UNESCAPED_UNICODE)
                    );
                
                $invitation = new Invitation;
        
                try {
                    $result  = $invitation->allowField(true)->save($feeData);
        
                    if ($result !== false) {
                        $this->success();
                    } else {
                        $this->error($row->getError());
                    }
                } catch (\think\exception\PDOException $e) {
                    $this->error($e->getMessage());
                } catch (\think\Exception $e) {
                     $this->error($e->getMessage());
                }                
            }
        }      

    }
    

}