<?php

namespace app\api\controller\ContactUs;

use app\BaseController;
use app\common\model\ContactUs\JoinApply as ModelJoinApply;
use app\Request;
use think\Validate;
use think\exception\ValidateException;
use think\facade\Filesystem;
use app\common\arw\adjfut\src\Excel;
use app\common\arw\adjfut\src\UploadFile;
use think\facade\Db;
use app\common\exception\Tool;
use think\facade\Env;


class JoinApply extends BaseController
{
    /**
     * 初始化
     *
     * @date 2022-03-15
     * @example
     * @author admin
     * @since 1.0.0
     */
    protected function initialize(): void
    {
        $this->middleware[SessionInit::class] = [
            'only' => ['accountLogin', 'getCaptcha']
        ];
    }

    /**
     * 添加加盟申请
     */
    public function addJoinApply(Request $request): array
    {
        $params = $request->param();
        $this->validate($params, [
            'join_apply_user_name|名字' => 'require',
            'join_apply_user_phone|电话' => 'require',
            'join_apply_user_position|职位' => 'require',
            'join_apply_user_area|所在地区' => 'require',
            'join_apply_user_org|所属机构名称' => 'require',
            'captcha|验证码' => 'require|captcha',
        ]);
        $model = ModelJoinApply::create($params, [
            'join_apply_guid',
            'join_apply_create_user_guid',
            'join_apply_update_user_guid',
            'join_apply_user_name',
            'join_apply_user_phone',
            'join_apply_user_position',
            'join_apply_user_area',
            'join_apply_user_org',
            'join_apply_status'
        ]);
        return msg('申请成功!');
    }
}
