/** * 后台对提交过来的申请进行审核 * * @access public * @param id:申请id,多个用逗号分隔 * * @return array */ public function audit() { $id = $this->input['id']; if (!$id) { $this->errorOutput(NOID); } $status = intval($this->input['status']); if (!$status) { $this->errorOutput(NO_STATUS); } $data = array('suggestion' => $this->input['suggestion'], 'status' => $status); $ret = $this->mode->update($id, $data); if ($ret) { //申请创建成功后更改该用户的推送状态 $company = new CompanyApi(); //已审核,用户的推送状态是待开通 if ($status == 2) { $company->modifyUserPushStatus($ret['dingdone_user_id'], 3); } else { if ($status == 3) { $company->modifyUserPushStatus($ret['dingdone_user_id'], 4); } } $this->addItem($ret); $this->output(); } }
public function audit() { $id = $this->input['id']; if (!$id) { $this->errorOutput(NOID); } $status = intval($this->input['dev_status']); if (!$status) { $this->errorOutput(NO_STATUS); } $refuse_develop_reason = trim($this->input['refuse_develop_reason']); $data = array('dev_status' => $status, 'refuse_develop_reason' => $refuse_develop_reason); $ret = $this->mode->update($id, $data); if ($ret) { //申请创建成功后更改该用户的角色 $company = new CompanyApi(); //已审核,用户变成开发者角色 if ($status == 2) { $_ret = $company->setUserInfo(array('a' => 'setUserRoleId', 'user_id' => $ret['dingdone_user_id'], 'dingdone_role_id' => 2)); } else { if ($status == 3) { $_ret = $company->setUserInfo(array('a' => 'setUserRoleId', 'user_id' => $ret['dingdone_user_id'], 'dingdone_role_id' => 1)); } } if ($_ret && is_array($_ret) && !isset($_ret['ErrorCode'])) { $this->addItem($ret); $this->output(); } else { $this->errorOutput(FAILED); } } }
/** * 申请leancloud的appkey master_key * @param $user_id * @param $user_name */ public function apply_leancloud_key($user_id, $user_name) { //申请创建成功后更改该用户的推送状态 $company = new CompanyApi(); //$company->modifyUserPushStatus($user_id,3); //先查看此用户是已经有app_key与app_id信息了 如果有,不需要一下操作 $push_info = $company->getPushApiConfig($user_id); //已存在则不需要继续获取 if (!$push_info || !$push_info['app_id'] && !$push_info['app_key']) { //先要通过leancloud开放平台创建用户,并且创建应用,拿到app_id app_key $this->lean = new leanCloud(); //根据用户id拿到用户信息 $user_info = $this->company->getUserInfoByUserId($user_id); $app_info = $this->api->getAppInfoByUserId($user_id); $email = $user_info['email']; $result = $this->lean->createUser($email, $user_name); if ($result['code'] == 1) { //用户在leancloud第一次创建应用失败 $result = $this->leancloud_user->detail(array('user_id' => $user_id)); if (!$result) { $this->errorOutput(CREATE_LEANCLOUD_USER_FAIL); } } $accsss_token = $result['access_token']; $uid = $result['uid']; //将信息存入liv_leancloud_user中 $data = $result; $data['user_id'] = $user_id; $data['user_name'] = $user_name; $data['email'] = $email; $data['create_time'] = TIMENOW; $this->leancloud_user->create($data); //创建应用 $name = $app_info['name']; $description = $app_info['brief']; $ret = $this->lean->createApp($accsss_token, $uid, $name, $description); //将应用信息存入liv_leancloud_app中 if ($ret['code'] == 1) { //已经存在 则取出key和id $key_info = $this->lean->getAppInfoBy($uid, $accsss_token, $name); $app_key = $key_info['app_key']; $app_id = $key_info['app_id']; $isRet = array('user_id' => $user_id, 'user_name' => $user_name, 'app_name' => $name, 'app_key' => $app_key, 'app_id' => $app_id, 'client_id' => $key_info['client_id'], 'created_at' => $key_info['created_at']); $this->leancloud_app->create($isRet); } else { //将应用信息存入liv_leancloud_app中 $ret['user_id'] = $user_id; $ret['user_name'] = $user_name; $ret['created_at'] = $ret['created']; unset($ret['created']); $this->leancloud_app->create($ret); $app_key = $ret['app_key']; $app_id = $ret['app_id']; } //保存配置到 push_api_config $res = $this->company->saveLeancloudParam($name, $user_id, $app_id, $app_key); $company->modifyUserPushStatus($user_id, 5); } }
public function create() { $user_id = $this->user['user_id']; if (!$user_id) { $this->errorOutput(NO_LOGIN); } //检测该用户有没有已经提交了,如果提交了就更新数据 $applyInfo = $this->mode->detail(array('dingdone_user_id' => $user_id)); $name = $this->input['name']; //姓名 $dingdone_name = $this->user['user_name']; //叮当账号名 $dev_type = $this->input['dev_type']; //证件类型 $identity_num = $this->input['identity_num']; //证件号 $address = $this->input['address']; //地址 $province = $this->input['province']; //省份地区码 $city = $this->input['city']; //城市地区码 $district = $this->input['district']; //区/县地区码 $telephone = $this->input['telephone']; //电话 $email = $this->input['email']; //邮箱 $link_man = $this->input['link_man']; //联系人 $link_phone = $this->input['link_phone']; //联系人手机号 $link_email = $this->input['link_email']; //联系人邮箱 $company_brief = $this->input['company_brief']; // $company_fax = $this->input['company_fax']; // $company_site = $this->input['company_site']; // $postalcode = $this->input['postalcode']; // $tech = $this->input['tech']; // $is_has_market = $this->input['is_has_market']; $reason = $this->input['reason']; $fixed_line = $this->input['fixed_line']; $app_name = $this->input['app_name']; if (!$name) { $this->errorOutput(NO_NAME); } if (!$dev_type) { $this->errorOutput(NO_TYPE); } if (!$identity_num) { $this->errorOutput(NO_IDENTITY_NUM); } if (!email) { $this->errorOutput(NO_EMAIL); } $data = array('name' => $name, 'dingdone_name' => $dingdone_name, 'dingdone_user_id' => $user_id, 'dev_type' => $dev_type, 'identity_num' => $identity_num, 'address' => $address, 'province' => $province, 'city' => $city, 'district' => $district, 'telephone' => $telephone, 'email' => $email, 'link_man' => $link_man, 'link_phone' => $link_phone, 'link_email' => $link_email, 'company_brief' => $company_brief, 'company_fax' => $company_fax, 'company_site' => $company_site, 'fixed_line' => $fixed_line, 'postalcode' => $postalcode, 'tech' => $tech, 'is_has_market' => $is_has_market, 'reason' => $reason, 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'is_developer' => 1, 'app_name' => $app_name); if (isset($_FILES['identity_photo']) && !$_FILES['identity_photo']['error']) { $img = $this->_upYunOp->uploadToBucket($_FILES['identity_photo'], '', $this->user['user_id']); if ($img) { $img_info = array('host' => $img['host'], 'dir' => $img['dir'], 'filepath' => $img['filepath'], 'filename' => $img['filename'], 'imgwidth' => $img['imgwidth'], 'imgheight' => $img['imgheight']); $data['identity_photo'] = addslashes(serialize($img_info)); } } if ($applyInfo) { $data['dev_status'] = 1; $ret = $this->mode->update($applyInfo['id'], $data); } else { //申请创建成功后更改该用户的推送状态 $company = new CompanyApi(); $company->modifyUserPushStatus($user_id, 4); $ret = $this->mode->create($data); } if ($ret) { $this->addItem(array('return' => 1)); $this->output(); } else { $this->errorOutput(FAILED); } }
/** * 更新申请,重新提交 * * @access public * @param name:姓名 * type:申请类型 * identity_type:证件类型 * identity_num:证件号 * address:地址 * province:省份地区码 * city:城市地区码 * telephone:电话 * link_man:联系人 * product_brief:产品描述 * @return array */ public function update() { $id = $this->input['id']; if (!$id) { $this->errorOutput(NOID); } $name = $this->input['name']; //姓名 $type = $this->input['type']; //申请类型 $identity_type = $this->input['identity_type']; //证件类型 $identity_num = $this->input['identity_num']; //证件号 $address = $this->input['address']; //地址 $province = $this->input['province']; //省份地区码 $city = $this->input['city']; //城市地区码 $district = $this->input['district']; //区/县地区码 $telephone = $this->input['telephone']; //电话 $email = $this->input['email']; //邮箱 $link_man = $this->input['link_man']; //联系人 $product_brief = $this->input['product_brief']; //产品描述 if (!$name) { $this->errorOutput(NO_NAME); } if (!$type) { $this->errorOutput(NO_TYPE); } if (!$identity_type) { $this->errorOutput(NO_IDENTITY_TYPE); } if (!$identity_num) { $this->errorOutput(NO_IDENTITY_NUM); } if (!$address) { $this->errorOutput(NO_ADDRESS); } if (!email) { $this->errorOutput(NO_EMAIL); } $data = array('name' => $name, 'type' => $type, 'identity_type' => $identity_type, 'identity_num' => $identity_num, 'address' => $address, 'province' => $province, 'city' => $city, 'district' => $district, 'telephone' => $telephone, 'email' => $email, 'link_man' => $link_man, 'product_brief' => $product_brief, 'update_time' => TIMENOW, 'status' => 1, 'is_push' => 1); //如果传递了证件图 if (isset($_FILES['credentials']) && !$_FILES['credentials']['error']) { /* $_FILES['Filedata'] = $_FILES['credentials']; unset($_FILES['credentials']); $material_pic = new material(); $img = $material_pic->addMaterial($_FILES); */ $img = $this->_upYunOp->uploadToBucket($_FILES['credentials'], '', $this->user['user_id']); if ($img) { $img_info = array('host' => $img['host'], 'dir' => $img['dir'], 'filepath' => $img['filepath'], 'filename' => $img['filename'], 'imgwidth' => $img['imgwidth'], 'imgheight' => $img['imgheight']); $data['identity_photo'] = addslashes(serialize($img_info)); } } $ret = $this->mode->update($id, $data); if ($ret) { //申请创建成功后更改该用户的推送状态 $company = new CompanyApi(); $company->modifyUserPushStatus($ret['dingdone_user_id'], 2); $this->addItem(array('return' => 1)); } else { $this->addItem(array('return' => 0)); } $this->output(); }
/** * 后台对提交过来的申请进行审核 * * @access public * @param id:申请id,多个用逗号分隔 * * @return array */ public function audit() { $id = $this->input['id']; if (!$id) { $this->errorOutput(NOID); } $status = intval($this->input['status']); if (!$status) { $this->errorOutput(NO_STATUS); } $data = array('suggestion' => $this->input['suggestion'], 'status' => $status); $ret = $this->mode->update($id, $data); if ($ret) { //申请创建成功后更改该用户的推送状态 $company = new CompanyApi(); //已审核,用户的推送状态是待审核 if ($status == 1) { $company->modifyUserPushStatus($ret['dingdone_user_id'], 2); } elseif ($status == 2) { //$company->modifyUserPushStatus($ret['dingdone_user_id'],3); $user_id = $ret['dingdone_user_id']; $company->modifyUserPushStatus($ret['dingdone_user_id'], 5); //先查看此用户是已经有app_key与app_id信息了 如果有,不需要一下操作 $push_info = $company->getPushApiConfig($user_id); //已存在则不需要继续获取 if (!$push_info || !$push_info['app_id'] && !$push_info['app_key']) { //先要通过leancloud开放平台创建用户,并且创建应用,拿到app_id app_key $this->lean = new leanCloud(); //根据用户id拿到用户信息 $user_info = $this->company->getUserInfoByUserId($user_id); $app_info = $this->api->getAppInfoByUserId($user_id); $user_name = $ret['dingdone_name']; $email = $ret['email']; $result = $this->lean->createUser($email, $user_name); $accsss_token = $result['access_token']; $uid = $result['uid']; //将信息存入liv_leancloud_user中 $data = $result; $data['user_id'] = $user_id; $data['user_name'] = $user_name; $data['email'] = $email; $data['create_time'] = TIMENOW; $this->leancloud_user->create($data); //创建应用 $name = $app_info['name']; $description = $app_info['brief']; $ret = $this->lean->createApp($accsss_token, $uid, $name, $description); //将应用信息存入liv_leancloud_app中 if ($ret['code'] == 1) { //已经存在 则取出key和id $key_info = $this->lean->getAppInfoBy($uid, $accsss_token, $name); $app_key = $key_info['app_key']; $app_id = $key_info['app_id']; $isRet = array('user_id' => $user_id, 'user_name' => $user_name, 'app_name' => $name, 'app_key' => $app_key, 'app_id' => $app_id, 'client_id' => $key_info['client_id'], 'created_at' => $key_info['created_at']); $this->leancloud_app->create($isRet); } else { //将应用信息存入liv_leancloud_app中 $ret['user_id'] = $user_id; $ret['user_name'] = $user_name; $this->leancloud_app->create($ret); $app_key = $ret['app_key']; $app_id = $ret['app_id']; } $this->company->saveLeancloudParam($name, $user_id, $app_id, $app_key); } } else { if ($status == 3) { $company->modifyUserPushStatus($ret['dingdone_user_id'], 4); } } $this->addItem($ret); $this->output(); } }