コード例 #1
0
 /**
  * 活动列表
  * @param int $user_id 用户id
  * @param int $page 页数
  * @param int $district 地区id
  * @param int $industry 分类id
  *
  * @return json
  * */
 public function actionActivitylist()
 {
     $param = Yii::$app->getRequest()->get();
     if (isset($param['user_id'])) {
         $user_id = intval($param['user_id']);
         $page = isset($param['page']) ? intval($param['page']) : 1;
         $activityurl = Yii::$app->params['iheima_api'] . '/?app=rss&controller=community&action=activity&page=' . $page;
         if (isset($param['district'])) {
             $activityurl .= '&district=' . intval($param['district']);
         }
         if (isset($param['industry'])) {
             $activityurl .= '&industry=' . intval($param['industry']);
         }
         $activitylist = Yii::$app->util->do_request($activityurl, '', 'GET');
         if ($activitylist['errcode'] == 1000) {
             $model = new UserBaseInfo();
             $user = $model->getUserById($user_id);
             $cyj_id = $user['open_id'];
             foreach ($activitylist['data']['list'] as $key => $value) {
                 $userinfo = array('open_id' => $cyj_id, 'timeline' => time(), 'sign' => 'ts');
                 $strinfo = $this->encrypt(json_encode($userinfo), '0e8357fd');
                 $activitylist['data']['list'][$key]['url'] = $value['url'] . '&from=group&act=' . $strinfo;
             }
             $return = array('status' => '0', 'msg' => 'success', 'data' => $activitylist['data']);
         } else {
             $return = array('status' => '4101', 'msg' => 'iheima_return_error');
         }
     } else {
         $return = array('status' => '1101', 'msg' => 'param_userid_missing');
     }
     return $return;
 }
コード例 #2
0
ファイル: Member.php プロジェクト: songhongyu/datecenter
 public function ihm()
 {
     $now = time();
     $query = Member::find()->from(self::tableName() . ' member')->where(['and', 'regtime>1439879084', "regtime<{$now}"])->asArray()->select(['member.*', 'mdetail.sex', 'mdetail.company'])->leftJoin(MemberDetail::tableName() . ' mdetail', 'member.userid=mdetail.userid');
     // ->groupBy(['member.mobile']);
     // $query = $query->from(Member::tableName());
     $user = new UserBaseInfo();
     // $user_openid = new UserOpenid();
     $fileLogger = FileLogger::getInstance('iheima.log');
     foreach ($query->batch(1000, Yii::$app->iheima) as $rows) {
         $params = [];
         $openId = [];
         if (!arr_null($rows)) {
             foreach ($rows as $row) {
                 $openIds = openId('iHeiMa');
                 $params[] = ['username' => $row['username'], 'password' => $row['password'], 'password_salt' => $row['salt'], 'mobile' => $row['mobile'], 'email' => $row['email'], 'gender' => $row['sex'], 'reg_ip' => $row['regip'], 'last_login_time' => $row['lastlogintime'], 'last_login_ip' => $row['lastloginip'], 'create_time' => $row['regtime'], 'update_time' => time(), 'status' => $row['status'], 'open_id' => $openIds];
                 $openId[] = ['openid' => $openIds, 'userid' => $row['userid'], 'flag' => 'iheima'];
             }
             $result = $user->batchInsertUser($params);
             if (!$result) {
                 $fileLogger->writeOne('同步失败' . json_encode($row['email']), Logger::LEVEL_INFO, 'iHeiMa用户同步失败');
                 return false;
             }
             // $rt = $user_openid->batchInsert($openId);
             // if (!$rt) {
             //     return false;
             // }
             //$fileLogger->writeOne('同步成功' . json_encode($params), Logger::LEVEL_INFO, 'iHeiMa用户同步成功');
         }
     }
     $fileLogger->writeOne(json_encode($openId), Logger::LEVEL_INFO, 'iHeiMa用户openId与用户id对应关系数据');
     return $openId;
 }
コード例 #3
0
ファイル: UserService.php プロジェクト: songhongyu/datecenter
 /**
  * 获取个应用系统登录接口地址
  *
  * @param bool $is_register true 表示注册
  * @return array|null
  * @throws \yii\base\Exception
  */
 public function getCookieUrl($is_register = false)
 {
     $cookieUrl = null;
     $appId = null;
     $info = null;
     $userModel = new UserBaseInfo();
     $userInfo = $userModel->getUserInfoCache();
     $sso = SsoSettingInfo::findAll();
     if ($sso) {
         foreach ($sso as $k => $val) {
             if (isset($val['log_out']['sign_in']) && $val['log_out']['sign_in']) {
                 $cookieUrl[] = $val['log_out']['sign_in'];
                 $appId[] = $val['app_id'];
             }
         }
     }
     if (isset($userInfo['id']) && $userInfo['id'] && $cookieUrl) {
         $user = $userModel->getUserById($userInfo['id']);
         $info['openid'] = $user['open_id'];
         $info['mobile'] = $user['mobile'];
         $info['email'] = $user['email'];
         if ($is_register) {
             $info['is_register'] = $is_register;
             $info['salt'] = $user['password_salt'];
             $info['password'] = $user['password'];
         }
         $info = json_encode($info);
         foreach ($cookieUrl as $key => &$url) {
             $appDir = $appId[$key];
             $encrypt = AsymmetryCrypt::opensslPublicEncrypt($info, dirname(Yii::$app->getBasePath()) . '/common/rsa_key/' . $appDir . '/rsa_public_key.pem');
             // TODO:: 为解决 +/ 丢失 / bug,临时解决方案
             $encrypt = str_replace('+/', '+_', $encrypt);
             $encrypt = rawurlencode($encrypt);
             $bool = filter_var($url, FILTER_VALIDATE_URL);
             if ($bool === false) {
                 unset($cookieUrl[$key]);
                 continue;
             }
             $path = parse_url($url);
             if (!isset($path['query'])) {
                 $url .= '?c=' . $encrypt;
                 continue;
             }
             $query = queryToArray($path['query']);
             $query['c'] = $encrypt;
             $query_params = arrayToQuery($query);
             $url = $path['scheme'] . '://' . $path['host'] . '?' . $query_params;
         }
         shuffle($cookieUrl);
         return $cookieUrl;
     } else {
         return null;
     }
 }
コード例 #4
0
 /**
  * 获取融云token
  * @see <*****@*****.**>
  * http://jira.chuangyejia.com:8090/pages/viewpage.action?pageId=3412605
  * @param $uid int  用户ID
  *
  * @return json
  */
 public function actionGettoken()
 {
     $uid = Yii::$app->getRequest()->get('uid');
     $uid = intval($uid);
     if ($uid) {
         $userinfo = UserBaseInfo::findOne($uid);
         $userinfo->username = $userinfo->username ? $userinfo->username : $userinfo->id;
         $userinfo->avatar = $userinfo->avatar ? $userinfo->avatar : 'http://www.idaiyan.cnuploads/20151023/s70_2015102318482010000.jpg';
         if ($userinfo->id && $userinfo->username && $userinfo->avatar) {
             $result = Yii::$app->rongyun->getToken($userinfo->id, $userinfo->username, $userinfo->avatar);
             $res = json_decode($result, true);
             if ($res['code'] == '200') {
                 //$return = array('status' => '0', 'msg' => 'success', 'data' => ['token' => $res['token'], 'uid' => $userinfo->id ]);
                 $return = Yii::$app->util->responseArray('0', 'success', '成功', ['token' => $res['token'], 'uid' => $userinfo->id]);
             } else {
                 //$return = array('status' => '4101', 'msg' => 'rongyun_result_error');
                 $return = Yii::$app->util->responseArray('4101', 'rongyun_result_error', '失败');
             }
         } else {
             //$return = array('status' => '1102', 'msg' => 'userinfo_error');
             $return = Yii::$app->util->responseArray('1102', 'userinfo_error', '用户信息有误!');
         }
     } else {
         //$return = array('status' => '1101', 'msg' => 'params_uid_error');
         $return = Yii::$app->util->responseArray('1101', 'params_uid_error', '参数有误!');
     }
     return $return;
 }
コード例 #5
0
 /**
  * 获取有效的city信息(city不为0, repair_status为0)
  */
 public function getCitys()
 {
     $arr = null;
     $result = UserBaseInfo::find()->select('city')->where(['!=', 'city', 0])->andWhere(['repair_status' => 0])->asArray()->all();
     //获取数组中某一列的值
     $arr = ArrayHelper::getColumn($result, 'city');
     return $arr;
 }
コード例 #6
0
 /**
  * 获取创业家下所有应用系统设置COOKIE接口地址
  */
 public function actionAppCookie()
 {
     // 获取JS回调函数
     $callback = Yii::$app->getRequest()->get('callback');
     $is_register = Yii::$app->getRequest()->get('is_register') ?: 0;
     try {
         $info = null;
         $userModel = new UserBaseInfo();
         $userInfo = $userModel->getUserInfoCache();
         if (isset($userInfo['id']) && $userInfo['id']) {
             $user = $userModel->getUserById($userInfo['id']);
             $info['openid'] = $user['open_id'];
             $info['mobile'] = $user['mobile'];
             $info['email'] = $user['email'];
             $info['password_salt'] = $user['password_salt'];
             $info['password'] = $user['password'];
             $info['username'] = $user['username'];
             if ($is_register) {
                 $info['is_register'] = $is_register;
                 $info['salt'] = $user['password_salt'];
                 $info['password'] = $user['password'];
             }
             $json = json_encode($info);
             // 记录日志
             $logger = FileLogger::getInstance('sso_' . date('Ymd') . '.log');
             $encrypt = AsymmetryCrypt::opensslPublicEncrypt($json, dirname(Yii::$app->getBasePath()) . '/common/rsa_public_key.pem');
             // $logger->writeOne($json . '====' . $encrypt, Logger::LEVEL_INFO,'SSO-IHEIMA');
             // TODO:: +/ 替换成 +_
             $encrypt = str_replace('+/', '+_', $encrypt);
             $encrypt = rawurlencode($encrypt);
             $logger->writeOne($json . '====' . $encrypt, Logger::LEVEL_INFO, 'SSO-IHEIMA');
             $thinksns = AsymmetryCrypt::opensslPublicEncrypt($json, dirname(Yii::$app->getBasePath()) . '/common/rsa_key/100003/rsa_public_key.pem');
             $thinksns = rawurlencode($thinksns);
             // TODO:: 获取应用系统COOKIE接口地址
             $appCookie = ['code' => 0, 'sso' => [Url::toRoute(['sso/index'], true), 'http://app.iheima.net/?app=ihminterface&controller=index&action=ihmlogin&c=' . $encrypt, 'http://dev-group.chuangyejia.com/index.php?app=public&mod=Passport&act=grouplogin&c=' . $thinksns, 'http://test-group.chuangyejia.com/index.php?app=public&mod=Passport&act=grouplogin&c=' . $thinksns, 'http://group.chuangyejia.com/index.php?app=public&mod=Passport&act=grouplogin&c=' . $thinksns, 'http://cyj.zhiyicx.com/index.php?app=public&mod=Passport&act=grouplogin&c=' . $thinksns, 'http://group-t.chuangyejia.com/index.php?app=public&mod=Passport&act=grouplogin&c=' . $thinksns], 'msg' => []];
             echo $callback . '(' . json_encode($appCookie) . ')';
         } else {
             echo $callback . '(' . json_encode(['code' => 1, 'msg' => '用户未登录']) . ')';
         }
     } catch (Exception $ex) {
         // TODO:: 异常处理
         echo $callback . '(' . json_encode(['code' => 2, 'msg' => '系统繁忙,请稍后重试']) . ')';
     }
 }
コード例 #7
0
 public function beforeAction($action)
 {
     if ($action->actionMethod == 'actionWxNotify') {
         $action->controller->enableCsrfValidation = false;
     }
     $alipay = Yii::$app->alipay;
     $wxpay = Yii::$app->wxpay;
     $request = Yii::$app->getRequest();
     $get = $request->get();
     $appId = isset($get['app_id']) && $get['app_id'] ? $get['app_id'] : '100002';
     if (!$appId) {
         // app_id 为必须参数
         die('app_id required');
     }
     $sso = new SsoSettingInfo();
     $mch = $sso->getMchByAppid($appId);
     $mch = json_decode($mch['mch_info'], true);
     if (arr_null($mch)) {
         // TODO:: 应用sso配置中没有设置商户信息
         die('mch information required');
     }
     $wxpayi = $mch['wxpay'];
     $alipayi = $mch['alipay'];
     WxPayConfig::$appId = $wxpayi['app_id'];
     WxPayConfig::$appSecret = $wxpayi['app_secret'];
     WxPayConfig::$mchId = $wxpayi['mch_id'];
     WxPayConfig::$key = $wxpayi['key'];
     WxPayConfig::$sslcert_path = $wxpayi['sslcert_path'];
     WxPayConfig::$sslkey_path = $wxpayi['sslkey_path'];
     $alipay->sellerEmail = $alipayi['seller_email'];
     $alipay->partner = $alipayi['partner'];
     $alipay->key = $alipayi['key'];
     $login = UserBaseInfo::isLogin();
     if ($login) {
         return parent::beforeAction($action);
     }
     return $this->redirect(['user/login']);
 }
コード例 #8
0
 public function actionDelete()
 {
     $mUser = new UserBaseInfo();
     $params = Yii::$app->request->get();
     $params = array_map('trim', $params);
     if (isset($params['city'])) {
         $params['city'] = 0;
         $params['city_addr'] = null;
     } else {
         if (isset($params['hometown'])) {
             $params['hometown'] = 0;
             $params['hometown_addr'] = null;
         }
     }
     //修改用户基本资料
     $result = $mUser->updateUserById($params);
     if ($result) {
         return Util::setAlert('删除成功', 'user/profile');
     } else {
         return Util::setAlert('删除失败', 'user/profile');
     }
 }
コード例 #9
0
 /**
  * weixin/qq/weibo第三方登录绑定判断
  */
 public function actionThirdParty()
 {
     $params = Yii::$app->getRequest()->post();
     $params = array_map('htmlEntityString', $params);
     $openid = isset($params['open_id']) ? $params['open_id'] : '';
     $type = isset($params['type']) ? $params['type'] : '';
     if (!$openid) {
         return responseArray(1101, 'openid_params_missing', '缺失用户身份唯一标识openid参数');
     }
     if (!$type) {
         return responseArray(1102, 'type_params_missing', '缺失第三方登录类型参数');
     }
     try {
         $user = UserBaseInfo::find()->select(['id'])->where(['open_id' => $openid, 'status' => UserBaseInfo::USER_NORMAL_STATUS])->one();
         if (!$user) {
             return responseArray(2101, 'user_not_exists', '用户不存在或被禁用');
         }
         $thridParty = new UserThirdPartyLogin();
         $thridParty = $thridParty->getByUserId($user->id, UserThirdPartyLogin::BIND_API_CHANNEL, $type);
         if ($thridParty && $thridParty['status'] == UserThirdPartyLogin::STATUS_LOGIN_BIND) {
             return responseArray(0, 'user_bind_thirdparty', '用户已绑定该类型第三方登录', ['open_id' => $thridParty->open_id, 'type' => $thridParty->type, 'profile_info' => $thridParty->profile_info]);
         } else {
             return responseArray(1103, 'user_notbind_thirdparty', '用户未绑定该类型第三方登录');
         }
     } catch (Exception $ex) {
         return responseArray(1, 'network_anomaly', '网络异常,请稍后重试');
     }
 }
コード例 #10
0
 /**
  * 以数据中心用户为基础针对iHeima用户进行数据修复
  */
 public function actionRepire($startTime = false, $endTime = false)
 {
     list($startTime, $endTime) = $this->_getTime($startTime, $endTime);
     $mMember = new Member();
     $ihmMobiles = [];
     $ihmUsers = Member::getByTime($startTime, $endTime);
     $dcUsers = UserBaseInfo::getByTime($startTime, $endTime);
     if (!$dcUsers) {
         die(date('Y-m-d H:i:s', $startTime) . ' 至 ' . date('Y-m-d H:i:s', $endTime) . " 暂无用户注册\n");
     }
     $msgData = [];
     $storeMsg = [];
     $updateMsg = [];
     $insertData = [];
     $stat = ['sync_ok' => 0, 'sync_fail' => 0, 'openid_incon' => 0, 'multi_openid' => 0];
     $ihmUsers = $this->_transform($ihmUsers);
     echo "\n\n";
     foreach ($dcUsers as $user) {
         // $user['open_id'] = '';
         $mobile = $user['mobile'];
         $openid = $user['open_id'];
         if (isset($ihmUsers[$mobile])) {
             if (is_array($ihmUsers[$mobile])) {
                 $msgData[] = $mobile . '  (' . $openid . '): 存在多OPENID';
                 $stat['multi_openid']++;
             } else {
                 if ($ihmUsers[$mobile] == $user['open_id']) {
                     $msgData[] = $mobile . '  (' . $openid . '): 同步无误';
                     $stat['sync_ok']++;
                 } else {
                     $msgData[] = $mobile . '  (' . $openid . '): OPENID不匹配';
                     if ($mMember->updateOpenid($mobile, $openid)) {
                         $ihmOpenid = $ihmUsers[$mobile] ? $ihmUsers[$mobile] : '空';
                         $updateMsg[] = $mobile . ': OPENID同步成功(' . $ihmOpenid . '=>' . $openid . ')';
                     } else {
                         $updateMsg[] = $mobile . ': OPENID同步失败';
                     }
                     $stat['openid_incon']++;
                 }
             }
         } else {
             $msgData[] = $mobile . '  (' . $openid . '): 不存在';
             if ($userid = $this->_store($user)) {
                 $storeMsg[] = $mobile . ':  重新同步成功(' . $userid . ')';
             } else {
                 $storeMsg[] = $mobile . ': 重新同步失败';
             }
             $stat['sync_fail']++;
         }
     }
     $statMsg = [];
     foreach ($stat as $key => $val) {
         $statMsg[] = $key . ':' . $val;
     }
     echo implode("\n", $msgData) . "\n\n";
     echo implode("\t", $statMsg) . "\n\n";
     if ($storeMsg) {
         echo "用户信息重新同步结果如下:\n";
         echo implode("\n", $storeMsg) . "\n\n";
     }
     if ($updateMsg) {
         echo "用户OPENID重新同步结果如下:\n";
         echo implode("\n", $updateMsg) . "\n\n";
     }
 }
コード例 #11
0
 /**
  * Action Create-User
  */
 public function actionCreateUser()
 {
     // TODO: 内测痛过后增加请求的限制
     $config = Yii::$app->util->loadConfig('flow');
     $ca = 'user/register';
     $session = Yii::$app->session;
     $session->open();
     $curBusiName = $ca;
     $curBusiStep = 'step3';
     //$session[$ca];
     $mobile = '18601352377';
     //$session[$ca]['data']['mobile'];
     $password = '******';
     //$session[$ca]['data']['password'];
     $rePassword = '******';
     //$session[$ca]['data']['re_password'];
     if (empty($password) || empty($rePassword)) {
         Yii::$app->util->formatResData(1000, 'param_missing_password', '密码不能为空');
     }
     if (empty($rePassword)) {
         Yii::$app->util->formatResData(1001, 'param_missing_repassword', '密码确认不能为空');
     }
     if ($password !== $rePassword) {
         Yii::$app->util->formatResData(1100, 'error_password_nequal', '两次密码输入不符');
     }
     if (!isset($config[$curBusiName]) && !isset($config[$curBusiName][$curBusiStep])) {
         Yii::$app->util->formatResData(1002, 'missing_busi_param', '系统繁忙,请稍后重试');
     }
     $stepConfig = $config[$curBusiName][$curBusiStep];
     $relStep = isset($stepConfig['relStep']) ? $stepConfig['relStep'] : null;
     if (!$relStep || $curBusiStep !== $relStep) {
         Yii::$app->util->formatResData(1200, 'error_curstep_illegal', '系统繁忙,请稍后重试');
     }
     $result = false;
     $data = ['mobile' => $mobile, 'password' => $password];
     try {
         $mUser = new UserBaseInfo();
         $result = $mUser->register($data);
     } catch (\Exception $e) {
         // TODO: 增加日志记录
     }
     if ($result) {
         $user = ['id' => $result, 'mobile' => $mobile];
         $session['user'] = $user;
         unset($session[$curBusiName]);
         unset($session['captcha_' . $curBusiName]);
         Yii::$app->util->formatResData(0, 'success', ['url' => $stepConfig['url']]);
     } else {
         Yii::$app->util->formatResData(1300, 'error_register', '注册失败');
     }
 }
コード例 #12
0
 /**
  * 同步个人信息
  *
  * @param array $data 变更数据
  *  $data中必须包含为id的Key
  * @return boolean
  */
 protected function syncProfile($data)
 {
     $res = false;
     $mUser = new UserBaseInfo();
     $uid = isset($data['id']) && $data['id'] ? $data['id'] : false;
     if (!$uid) {
         return $uid;
     }
     unset($data['id']);
     $user = $mUser->getUserById($uid);
     if ($user) {
         $industry = Yii::$app->util->loadConfig('user-industry', '/platform_i/config/');
         $user = array_merge($user, $data);
         // 设置默认同步数据
         $data = ['open_id' => $user['open_id'], 'name' => $user['username'], 'password' => $user['password'], 'salt' => $user['password_salt'], 'birthday' => $user['birthday'], 'city' => $user['city'], 'industry' => $user['industry'], 'company' => $user['company'], 'position' => $user['position'], 'dc_avatar' => $user['avatar']];
         // $data = array_merge($defData, $data);
         $data['industry'] = !$industry || !$data['industry'] || !isset($industry[$data['industry']]) ? '' : $industry[$data['industry']];
         $data['user_trade'] = $data['industry'];
         $data['job'] = $data['position'];
         unset($data['industry']);
         unset($data['position']);
         $mDistrict = new District();
         $city = $mDistrict->getByCity($data['city']);
         $data['city'] = (!isset($city['parent']) ? '' : $city['parent']['name']) . ' ' . $city['name'];
         try {
             $sso = Yii::$app->sso;
             $res = $sso->sync('profile', $data);
             $sso->syncProfileLog($res, json_encode($data), 'profile');
         } catch (\Exception $e) {
         }
         // TODO: 针对同步结果进行相关操作
         if ($res) {
         } else {
         }
     }
     return $res;
 }
コード例 #13
0
 /**
  * 用户地址接口   
  */
 public function actionInfo($id)
 {
     $util = Yii::$app->util;
     $request = Yii::$app->getRequest();
     $params = Yii::$app->request->get();
     //判断用户是否登录
     if (!UserBaseInfo::isLogin()) {
         $util->formatResData(1202, 'please_login', ['msg' => '请你登录']);
     }
     $id = intval($id);
     //判断参数的是否为空
     if (!$id) {
         $util->formatResData(1101, 'address_param_missing', ['msg' => '地址信息参数缺失']);
     }
     //判断是否是Ajax请求
     if (!$request->getIsAjax($id)) {
         $util->formatResData(1301, 'illegal_request', ['msg' => '非法请求']);
     }
     $address = new Address();
     $data = $address->getByUserId($id);
     //通过地址ID获取对应的地址信息
     $data = $address->getById($id);
     if (!$data) {
         $util->formatResData(1102, 'id_not_exists', ['msg' => 'ID信息不存在']);
     }
     //从session或cookie中获取用户id
     $userId = UserBaseInfo::getUserId();
     if ($data['user_id'] != $userId) {
         $util->formatResData(1103, 'can_not_operate_other\'s_order_message', ['msg' => '不能操作其他人的订单信息']);
     }
     if (!$data['post_code']) {
         unset($data['post_code']);
     }
     //根据子区域id获取区域信息
     $region = District::getById($data['county'], true);
     if (!$region) {
         $util->formatResData(1104, 'region_message_not_exists', ['msg' => '该子区域ID对应的区域信息不存在']);
     }
     $result = ['city' => $region['upid'], 'province' => $region['parent']['upid']];
     $result = array_merge($data, $result);
     if ($result) {
         $util->formatResData(0, 'success', $result);
     } else {
         $util->formatResData(1201, 'get_address_fail', ['msg' => '获取地区信息失败']);
     }
 }
コード例 #14
0
 public function bindEmail($params = array())
 {
     if (isset($params['mobile']) && $params['mobile']) {
         // 注册邮箱的唯一性
         $tool = $params['mobile'];
         $user = new UserBaseInfo();
         $unique = $user->uniqueUser($tool);
         if ($unique) {
             Yii::$app->util->formatResData(1206, 'email_register_already', ['msg' => '该邮箱已经被注册']);
         }
     }
 }
コード例 #15
0
ファイル: user.php プロジェクト: songhongyu/datecenter
        <?php 
$this->beginBody();
?>
        <header>
            <div class="top">
                <a href="<?php 
echo Url::toRoute('ucenter/index');
?>
">
                    <img src="<?php 
echo Yii::$app->params['res'];
?>
/images/logo-chuangyejia.png" width="90" height="48">
                </a>
                <?php 
$result = UserBaseInfo::isLogin();
if ($result) {
    ?>
                  <a href="<?php 
    echo Url::toRoute('user/logout');
    ?>
" style ="margin-left:15px" class="log-out ajax-logout">退出</a>
                <?php 
} else {
    ?>
                 <a href="<?php 
    echo Url::toRoute('user/login');
    ?>
" style ="margin-left:15px" class="log-out">登录</a>
                 <a href="<?php 
    echo Url::toRoute('user/register');
コード例 #16
0
 public function actionReport($startTime = false, $endTime = false)
 {
     date_default_timezone_set('PRC');
     if (empty($startTime) && empty($endTime)) {
         $startTime = strtotime(date('Y-m-d 00:00:00', strtotime("-1 day")));
         $endTime = strtotime(date('Y-m-d 23:59:59', strtotime("-1 day")));
     } else {
         if (empty($startTime) || empty($endTime)) {
             $tmp = $startTime;
             $startTime = strtotime($tmp . ' 00:00:00');
             $endTime = strtotime($tmp . ' 23:59:59');
         } else {
             if ($startTime > $endTime) {
                 $tmp = $startTime;
                 $startTime = $endTime;
                 $endTime = $tmp;
             }
             $startTime = strtotime($startTime);
             $endTime = strtotime($endTime);
         }
     }
     //获取i黑马注册用户的信息
     $ihmUsers = Member::getByTime($startTime, $endTime);
     //获取数据中心注册用户的信息
     $dcUsers = UserBaseInfo::getByTime($startTime, $endTime);
     if (empty($dcUsers) && empty($ihmUsers)) {
         $errorMessage[] = date('Y-m-d H:i:s', $startTime) . '至' . date('Y-m-d H:i:s', $endTime) . ' 无用户注册。';
     } else {
         if (empty($dcUsers) && isset($ihmUsers)) {
             $errorMessage[] = date('Y-m-d H:i:s', $startTime) . '至' . date('Y-m-d H:i:s', $endTime) . ' 数据中心中无用户注册,而i黑马有用户注册。';
         } else {
             $ihmOpenIds = array();
             foreach ($ihmUsers as $key => $user) {
                 $mobile = $user['mobile'];
                 if (isset($ihmOpenIds[$mobile])) {
                     if (is_string($ihmOpenIds[$mobile])) {
                         $ihmOpenIds[$mobile] = [$ihmOpenIds[$mobile], $user['open_id']];
                     } else {
                         if (is_array($ihmOpenIds[$mobile])) {
                             $ihmOpenIds[$mobile][] = $user['open_id'];
                         }
                     }
                 } else {
                     $ihmOpenIds[$mobile] = $user['open_id'];
                 }
             }
             foreach ($dcUsers as $key => $user) {
                 $mobile = $ihmOpenIds[$user['mobile']];
                 if (!isset($mobile)) {
                     $errorMessage[] = $user['mobile'] . '(' . $user['open_id'] . ') : 同步失败';
                 } else {
                     if (is_array($mobile)) {
                         $mobile = implode(", ", $mobile);
                         $errorMessage[] = $user['mobile'] . '(' . $user['open_id'] . ') : 存在多OPENID (' . $mobile . ')';
                     } else {
                         if (is_string($mobile)) {
                             if ($mobile != $user['open_id']) {
                                 $errorMessage[] = $user['mobile'] . '(' . $user['open_id'] . ') : OPENID不匹配(' . $user['open_id'] . ',' . $mobile . ')';
                             }
                         }
                     }
                 }
             }
         }
     }
     $errorMessage = implode("<br/>", $errorMessage);
     //发送邮件操作
     $userID = UserBaseInfo::SYSTEM_USER;
     $email = Yii::$app->params['syncUserEmail'];
     $data = ['userID' => $userID, 'to' => $email, 'appID' => '100000', 'business' => S_SYNCUSER_CHECK, 'tplno' => 5, 'subject' => '检测同步用户报告', 'content' => $errorMessage];
     $sender = Yii::$app->mailer;
     $result = $sender->check($data, true);
     if (!$result[0]) {
         $result = $sender->exec($result[1]);
     } else {
         //邮箱发送失败记录到日志文件中
         FileLogger::getInstance(date('Ymd') . '_sync_user_report.log')->writeOne('邮箱发送失败', Logger::LEVEL_ERROR, 'report');
     }
 }
コード例 #17
0
 /**
  * 获取订单列表信息
  */
 public function actionList()
 {
     $this->layout = 'main';
     //判断用户是否登录
     if (!UserBaseInfo::isLogin()) {
         return $this->redirect(Url::toRoute('user/login'));
     }
     //从session或cookie中获取open_id
     $openId = UserBaseInfo::getOpenId();
     $data['open_id'] = $openId;
     $data['status'] = Order::ORDER_USABLE_STATUS;
     $params = Yii::$app->request->get();
     $startTime = false;
     $endTime = false;
     $time = Yii::$app->util->loadConfig('user-order-time', '/platform_i/config/');
     if ($params) {
         if (isset($params['startTime']) && isset($params['endTime'])) {
             $data['startTime'] = strtotime($params['startTime'] . ' 00:00:00');
             $data['endTime'] = strtotime($params['endTime'] . ' 23:59:59');
             $checkTime = $this->checkTime($params['startTime'], $params['endTime']);
             if ($checkTime['startTime'] && $checkTime['endTime']) {
                 $data['startTime'] = strtotime($checkTime['startTime'] . ' 00:00:00');
                 $data['endTime'] = strtotime($checkTime['endTime'] . '23:59:59');
                 $params['startTime'] = $checkTime['startTime'];
                 $params['endTime'] = $checkTime['endTime'];
             }
             if ($data['startTime'] > $data['endTime']) {
                 $tmpParam = $params['startTime'];
                 $params['startTime'] = $params['endTime'];
                 $params['endTime'] = $tmpParam;
                 $tmpData = $data['startTime'];
                 $data['startTime'] = $data['endTime'];
                 $data['endTime'] = $tmpData;
             }
             $timeInterval = $params['startTime'] . '_' . $params['endTime'];
             foreach ($time as $key => &$value) {
                 if ($timeInterval == $value['timeInterval']) {
                     $value['class'] = true;
                 }
             }
         } else {
             if (isset($params['timeRange'])) {
                 if (in_array($params['timeRange'], array_keys($time))) {
                     $time[$params['timeRange']]['class'] = true;
                 } else {
                     $time[1]['class'] = true;
                 }
             } else {
                 //默认为今天
                 $time[1]['class'] = true;
                 $params['timeRange'] = 1;
             }
             $data['endTime'] = strtotime(date('Y-m-d 23:59:59'));
             $data['startTime'] = $this->getTime($params['timeRange']);
         }
         if (isset($params['payStatus'])) {
             if ($params['payStatus'] != 0 && $params['payStatus'] != 1 && $params['payStatus'] != 5) {
                 unset($params['payStatus']);
             } else {
                 $data['pay_status'] = $params['payStatus'];
             }
         }
     } else {
         $params['timeRange'] = 1;
         $data['endTime'] = strtotime(date('Y-m-d 23:59:59'));
         $data['startTime'] = $this->getTime($params['timeRange']);
         $time[1]['class'] = true;
     }
     $result = Order::getData($data, $startTime, $endTime);
     $pages = new Pagination(['totalCount' => $result->count(), 'pageSize' => '10']);
     $result = $result->offset($pages->offset)->limit($pages->limit)->asArray()->all();
     //从缓存中取出应用配置信息
     $appConfig = AppConfig::getConfigUrl();
     if (is_array($appConfig)) {
         foreach ($result as $key => &$value) {
             $value['config_urls'] = $appConfig[$value['app_id']];
         }
     }
     return $this->render('list', ['result' => $result, 'pages' => $pages, 'time' => $time]);
 }
コード例 #18
0
ファイル: UserService.php プロジェクト: songhongyu/datecenter
 public function getUserBindInfo($username, $type, $openId)
 {
     $third = new UserThirdPartyLogin();
     $channel = UserThirdPartyLogin::BIND_API_CHANNEL;
     if (!$username) {
         return responseArray(1101, 'username_pwd_params_missing', '用户标识丢失');
     }
     if (!$type) {
         return responseArray(1201, 'third_type_not_found', '第三方类型不能为空');
     }
     if (!$openId) {
         return responseArray(1202, 'third_openId_not_found', '第三方账号关联open_id丢失');
     }
     $user = UserBaseInfo::find()->where(['mobile' => $username])->orWhere(['email' => $username])->one();
     $userOpenId['open_id'] = $user['open_id'];
     if ($user == null) {
         return responseArray(1102, 'user_not_exists', '用户不存在');
     }
     $info = $third->checkBindByUAT($user['id'], $channel, $type, true);
     $beenBind = $third->checkBeenBindUAT($user['id'], $channel, $type, true);
     if ($info && is_array($info) || $beenBind) {
         if ($beenBind['open_id'] == $openId) {
             return responseArray(0, 'success', '用户已绑定并与现操作绑定号一致', $beenBind['open_id']);
         }
         $beenBind['profile_info'] = json_decode($beenBind['profile_info']);
         $oldBind = [];
         if (isset($beenBind['profile_info'])) {
             foreach ($beenBind['profile_info'] as $key => $value) {
                 $oldBind[$key] = $value;
             }
         }
         $oldBind['open_id'] = $beenBind['open_id'];
         return responseArray(1401, 'has_been_bind', '用户已绑定但与现操作绑定号不一致', $oldBind);
     }
     if (!is_array($info)) {
         return responseArray(1301, 'user_not_bind', '用户未绑定', $user->attributes);
     }
 }
コード例 #19
0
ファイル: main.php プロジェクト: songhongyu/datecenter
                            </li>
                        <?php 
}
?>
                        </ul>
                    </li>
                    <!-- 这个别删啊,未登录嵌套这个li -->
                    <!-- <li class="prelogin">
                        <a href="">登录</a>
                    </li> -->
                    <li class="news" style='display:none'>
                        <span class="news-num">3</span>
                    </li>
                    <li class="portrait">
                    <?php 
if (UserBaseInfo::isLogin()) {
    ?>
                        <?php 
    if (empty($avatar)) {
        ?>
                            <img src="<?php 
        echo Yii::$app->params['res'];
        ?>
/images/avatar.png" alt="<?php 
        echo $name;
        ?>
">
                        <?php 
    } else {
        ?>
                            <img width='48px' height='48px' src="<?php 
コード例 #20
0
ファイル: Member.php プロジェクト: songhongyu/datecenter
 /**
  * 分页同步数据
  * select * from i_member where length(mobile)>11 手机长度超过11位
  * @param int $page 数据库分页当前页数
  * @param int $totalNum 数据库总记录
  */
 public function sync($page)
 {
     $params = null;
     $prefixAvatar = 'http://www.idaiyan.cn';
     $sexMap = [1 => 1, 2 => 2, 3 => 0, 0 => 0];
     $statusMap = [0 => 1, 1 => 0];
     if ($page <= 0) {
         $page = 1;
     }
     $page = ($page - 1) * self::$pageSize;
     $multiMobile = $this->multi();
     $multiMobile = implode(',', $multiMobile);
     $query = self::find()->where(['AND', "mobile not in ({$multiMobile})", "mobile<>''", "is_admin=0", "is_del<>2"])->orderBy('uid')->offset($page)->limit(self::$pageSize)->asArray();
     $fileLogger = FileLogger::getInstance('idaiyan.log');
     $fileLog = FileLogger::getInstance('idaiyan_dc.log');
     $user = new UserBaseInfo();
     foreach ($query->batch(self::$batchSize) as $members) {
         $now = time();
         foreach ($members as $member) {
             //                $exists = $user->uniqueUser($member['mobile']);
             //                if ($exists) {
             //                    $fileLog->writeOne($member['mobile'] , Logger::LEVEL_INFO, 'i代言语句数据中心用户同步手机重复检测');
             //                    continue;
             //                }
             if ($member['avatar']) {
                 $avatar = $prefixAvatar . $member['avatar'];
             } else {
                 $avatar = '';
             }
             $openId = openId('idaiyan');
             $params[] = ['username' => $member['nickname'], 'realname' => $member['truename'], 'password' => $member['password'], 'password_salt' => $member['random'], 'mobile' => $member['mobile'], 'email' => $member['email'], 'gender' => $sexMap[$member['sex']], 'avatar' => $avatar, 'birthday' => date('Y-m-d', $member['birthday']), 'reg_ip' => $member['create_ip'], 'reg_channel' => 'idaiyan', 'last_login_time' => $member['update_at'], 'last_login_ip' => '', 'create_time' => $now, 'update_time' => $member['update_at'], 'status' => $statusMap[$member['is_del']], 'open_id' => $openId];
         }
         $result = $user->batchInsertUser($params);
         if (!$result) {
             $mobiles = i_array_column($members, 'mobile');
             $fileLogger->writeOne('同步失败' . json_encode($mobiles), Logger::LEVEL_INFO, 'iDaiyan用户同步失败');
         }
         unset($params);
     }
 }