<?php

namespace app\wechatapi\controller;

use app\BaseController;
use think\facade\Db;
use think\facade\Request;

class Message  extends BaseController {

    protected $middleware = ['app\middleware\CheckValidata::class'];

    public function submitMessage(){
        $data['province_id'] = Request::param('province_id',0);
        $data['city_id'] = Request::param('city_id',0);
        $data['area_id'] = Request::param('area_id',0);
        $data['area_name'] = Request::param('area_name','');
        $data['province_name'] = Request::param('province_name','');
        $data['city_name'] = Request::param('city_name','');
        $data['ip'] = Request::ip();
        $data['industry'] = Request::param('industry',''); //行业
        $data['from'] = Request::param('from',0);
        $data['content'] = Request::param('content','');
        $data['user_name'] = Request::param('user_name');
        $data['create_time'] = time();
        $data['phone'] = Request::param('phone');
        $data['business'] = Request::param('business','');
        $add = Db::name('message')->insert($data);
        if($add) {
            return $this->returnJson([],200);
        } else {
            return $this->returnJson([],'添加失败!','400');
        }
    }


    //获取业务类型
    public function getBusiness()
    {

        $data =Db::name('business')->select()->toArray();

        return $this->returnJson($data,200);

    }






}