Info.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: leo
  5. * Date: 2018/11/2
  6. * Time: 上午9:16
  7. */
  8. namespace common\helpers\user;
  9. use common\components\ActiveQuery;
  10. use common\components\ActiveRecord;
  11. use common\helpers\Cache;
  12. use common\helpers\Tool;
  13. use common\models\Config;
  14. use common\models\PerfMonth;
  15. use common\models\PerfPeriod;
  16. use common\models\Period;
  17. use common\models\DeclarationLevel;
  18. use common\models\DecRole;
  19. use common\models\EmployLevel;
  20. use common\models\OpenBank;
  21. use common\models\Region;
  22. use common\models\User;
  23. use common\models\UserBonus;
  24. use common\models\UserInfo;
  25. use common\models\UserNetwork;
  26. use common\models\UserRelation;
  27. use common\models\UserSystem;
  28. use common\models\UserWallet;
  29. use yii\base\Exception;
  30. class Info {
  31. /**
  32. * 获取用户ID
  33. * @param $userName
  34. * @return mixed
  35. */
  36. public static function getUserIdByUserName($userName) {
  37. $user = UserInfo::findOneAsArray('USER_NAME=:USER_NAME AND DELETED=0', [':USER_NAME' => $userName], 'USER_ID');
  38. return $user ? $user['USER_ID'] : null;
  39. }
  40. /**
  41. * 获取会员名通过ID
  42. * @param $userId
  43. * @return mixed|null
  44. */
  45. public static function getUserNameByUserId($userId) {
  46. $user = UserInfo::findOneAsArray('USER_ID=:USER_ID AND DELETED=0', [':USER_ID' => $userId], 'USER_NAME');
  47. return $user ? $user['USER_NAME'] : null;
  48. }
  49. /**
  50. * 获取会员姓名通过ID
  51. * @param $userId
  52. * @return null
  53. */
  54. public static function getUserRealNameByUserId($userId) {
  55. $user = User::findOneAsArray('ID=:ID AND DELETED=0', [':ID' => $userId], 'REAL_NAME');
  56. return $user ? $user['REAL_NAME'] : null;
  57. }
  58. /**
  59. * 获取手机号通过ID
  60. * @param $userId
  61. * @return null
  62. */
  63. public static function getUserMobileByUserId($userId) {
  64. $user = User::findOneAsArray('ID=:ID AND DELETED=0', [':ID' => $userId], 'MOBILE');
  65. return $user ? $user['MOBILE'] : null;
  66. }
  67. /**
  68. * 通过用户ID获取用户的编号和名称
  69. * @param $userId
  70. * @return array|null
  71. */
  72. public static function getBaseUserById($userId) {
  73. return User::findOneAsArray('ID=:ID', [':ID' => $userId], 'ID,USER_NAME,REAL_NAME');
  74. }
  75. /**
  76. * 通过用户ID获取用户的编号和名称
  77. * @param $username
  78. * @return array|null
  79. */
  80. public static function getBaseUserByUserName($username) {
  81. return User::findOneAsArray('USER_NAME=:USER_NAME', [':USER_NAME' => $username]);
  82. }
  83. /**
  84. * 当前期数的会员信息
  85. * @param $userId
  86. * @return array|\yii\db\ActiveRecord|null
  87. * @throws Exception
  88. */
  89. public static function baseInfoNowPeriod($userId) {
  90. $data = User::find()->where('ID=:ID', [':ID' => $userId])->asArray()->one();
  91. if (!$data) throw new Exception('会员不存在'.$userId);
  92. $infoData = UserInfo::find()->where('USER_ID=:USER_ID', [':USER_ID' => $userId])->select('ZC_PV,CON_UID,REC_UID,CON_NUM,REC_NUM,NETWORK_DEEP,RELATION_DEEP,SYSTEM_ID,REG_TYPE,REG_NAME,CREDIT_CODE,PREMISES,LEGAL_PERSON,CLOSE_LOGIN,IS_BIND_MAIN,HIGHEST_EMP_LV,HIGHEST_EMP_LV_PERIOD,SHOULD_REG_TYPE,IS_SYSTEM_LEADER,ALLOW_TRANSFER,TRANSFER_PROP,IS_GROUP_LEADER,GROUP_LEADER_AT,SHOW_EMP_LV')->asArray()->one();
  93. if ($infoData) {
  94. $data = array_merge($data, $infoData);
  95. }
  96. if (!$data['DEC_LV']) $data['DEC_LV'] = DeclarationLevel::getDefaultLevelId();
  97. if (!$data['LAST_DEC_LV']) $data['LAST_DEC_LV'] = DeclarationLevel::getDefaultLevelId();
  98. if (!$data['EMP_LV']) $data['EMP_LV'] = EmployLevel::getDefaultLevelId();
  99. return $data;
  100. }
  101. /**
  102. * 基本信息
  103. * @param $userId
  104. * @param $periodNum
  105. * @return array|\yii\db\ActiveRecord|null
  106. * @throws Exception
  107. */
  108. public static function baseInfo($userId, $periodNum = null) {
  109. if($periodNum == null){
  110. return self::baseInfoNowPeriod($userId);
  111. } else {
  112. // 获取当前期数
  113. $tableName = '{{%USER_ALL_'.$periodNum.'}}';
  114. if(ActiveRecord::isExistsTable($tableName, 'dbNetPoint')){
  115. if($data = \Yii::$app->dbNetPoint->createCommand("SELECT * FROM $tableName WHERE ID=:ID")->bindValues([':ID'=>$userId])->queryOne()) {
  116. if (!$data['DEC_LV']) $data['DEC_LV'] = DeclarationLevel::getDefaultLevelId();
  117. if (!$data['LAST_DEC_LV']) $data['LAST_DEC_LV'] = DeclarationLevel::getDefaultLevelId();
  118. if (!$data['EMP_LV']) $data['EMP_LV'] = EmployLevel::getDefaultLevelId();
  119. if (!$data['HIGHEST_EMP_LV']) $data['HIGHEST_EMP_LV'] = EmployLevel::getDefaultLevelId();
  120. return $data;
  121. }else{
  122. return self::baseInfoNowPeriod($userId);
  123. }
  124. } else {
  125. return self::baseInfoNowPeriod($userId);
  126. }
  127. }
  128. }
  129. /**
  130. * 基本信息含中文地区和中文子公司
  131. * @param $userId
  132. * @param $periodNum
  133. * @return array|\yii\db\ActiveRecord|null
  134. * @throws Exception
  135. */
  136. public static function baseInfoZh($userId, $periodNum = null) {
  137. $baseInfo = self::baseInfo($userId, $periodNum);
  138. // 状态处理
  139. $baseInfo['STATUS_NAME'] = \Yii::$app->params['userStatus'][$baseInfo['STATUS']]['label'];
  140. //登录状态
  141. $baseInfo['LOGIN_STATUS_NAME'] = $baseInfo['ALLOW_LOGIN'] == 0 ? '禁止登录' : '允许登录';
  142. // 子公司
  143. $baseInfo['SUB_COM_NAME'] = '';
  144. $baseInfo['PROVINCE_NAME'] = $baseInfo['PROVINCE'] ? Region::getCnName($baseInfo['PROVINCE']) : '';
  145. $baseInfo['CITY_NAME'] = $baseInfo['CITY'] ? Region::getCnName($baseInfo['CITY']) : '';
  146. $baseInfo['COUNTY_NAME'] = $baseInfo['COUNTY'] ? Region::getCnName($baseInfo['COUNTY']) : '';
  147. $baseInfo['BANK_PROVINCE_NAME'] = $baseInfo['BANK_PROVINCE'] ? Region::getCnName($baseInfo['BANK_PROVINCE']) : '';
  148. $baseInfo['BANK_CITY_NAME'] = $baseInfo['BANK_CITY'] ? Region::getCnName($baseInfo['BANK_CITY']) : '';
  149. $baseInfo['BANK_COUNTY_NAME'] = $baseInfo['BANK_COUNTY'] ? Region::getCnName($baseInfo['BANK_COUNTY']) : '';
  150. $baseInfo['OPEN_BANK_NAME'] = $baseInfo['OPEN_BANK'] ? OpenBank::getCnName($baseInfo['OPEN_BANK']) : '';
  151. // 获取会员体系
  152. $baseInfo['SYSTEM_NAME'] = '';
  153. // 获取会员级别名称
  154. $baseInfo['DEC_LV_NAME'] = Cache::getDecLevelConfig()[$baseInfo['DEC_LV']]['LEVEL_NAME'];
  155. $baseInfo['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$baseInfo['LAST_DEC_LV']]['LEVEL_NAME'];
  156. $baseInfo['EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$baseInfo['EMP_LV']]['LEVEL_NAME'];
  157. $baseInfo['HIGHEST_EMP_LV_NAME'] = '';
  158. // 获取会员报单级别
  159. $baseInfo['DEC_ROLE_NAME'] = '无';
  160. //民族
  161. $baseInfo['NATION_NAME'] = \Yii::$app->params['nation'][$baseInfo['NATION']]['name']??'';
  162. return $baseInfo;
  163. }
  164. /**
  165. * 基本信息及余额
  166. * @param $userId
  167. * @param $periodNum
  168. * @return array
  169. */
  170. public static function baseInfoWithBalance($userId, $periodNum = null) {
  171. $baseInfo = self::baseInfoZh($userId, $periodNum);
  172. if ($baseInfo) {
  173. $userBonus = self::BalanceInfo($userId);
  174. }
  175. return array_merge($baseInfo, $userBonus);
  176. }
  177. /**
  178. * 获取余额信息
  179. * @param $userId
  180. * @return array|int[]|null
  181. */
  182. public static function BalanceInfo($userId) {
  183. $userBonus = [
  184. 'BONUS' => 0,
  185. 'BONUS_FREEZE' => 0,
  186. 'CF' => 0,
  187. 'LX' => 0,
  188. 'QY_TOTAL' => 0,
  189. 'YC_TOTAL' => 0,
  190. 'FX_TOTAL' => 0,
  191. 'LS_TOTAL' => 0,
  192. 'CF_TOTAL' => 0,
  193. 'LX_TOTAL' => 0,
  194. 'FL_TOTAL' => 0,
  195. 'BT_TOTAL' => 0,
  196. 'FW_TOTAL' => 0,
  197. 'CASH' => 0,
  198. ];
  199. if ($userBonusResult = UserBonus::findOneAsArray(['USER_ID' => $userId])) {
  200. $userBonus = $userBonusResult;
  201. }
  202. if ($userCashResult = UserWallet::findOneAsArray(['USER_ID' => $userId])) {
  203. $userBonus['CASH'] = $userCashResult['CASH'];
  204. }
  205. return $userBonus;
  206. }
  207. /**
  208. * 基本信息带着网络和节点信息
  209. * @param $userId
  210. * @param $periodNum
  211. * @return array|null|\yii\db\ActiveRecord
  212. */
  213. public static function baseInfoWithNet($userId, $periodNum = null) {
  214. $baseInfo = self::baseInfoZh($userId, $periodNum);
  215. $baseInfo['CON_USER_NAME'] = '';
  216. $baseInfo['CON_REAL_NAME'] = '';
  217. $baseInfo['LOCATION'] = '';
  218. $baseInfo['REC_USER_NAME'] = '';
  219. $baseInfo['REC_REAL_NAME'] = '';
  220. $baseInfo['DEC_USER_NAME'] = '';
  221. $baseInfo['DEC_REAL_NAME'] = '';
  222. $baseInfo['DEC_DEC_LV'] = '';
  223. $baseInfo['DEC_DEC_LV_NAME'] = '';
  224. if ($baseInfo) {
  225. if (isset($baseInfo['CON_UID']) && $baseInfo['CON_UID']) {
  226. // 安置网上级
  227. //$netParentUserInfo = UserNetwork::getFirstParentUserInfo($userId);
  228. $netParentBaseInfo = self::baseInfo($baseInfo['CON_UID']);
  229. $networkParent = UserNetwork::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $userId]);
  230. //$baseInfo['CON_UID'] = $baseInfo['CON_UID'];
  231. $baseInfo['CON_USER_NAME'] = $netParentBaseInfo['USER_NAME'];
  232. $baseInfo['CON_REAL_NAME'] = $netParentBaseInfo['REAL_NAME'];
  233. $baseInfo['LOCATION'] = $networkParent['RELATIVE_LOCATION'];
  234. }
  235. if (isset($baseInfo['REC_UID']) && $baseInfo['REC_UID']) {
  236. // 推荐网上级
  237. //$relationParentUserInfo = UserRelation::getFirstParentUserInfo($userId);
  238. $relationParentBaseInfo = self::baseInfo($baseInfo['REC_UID']);
  239. //$baseInfo['REC_UID'] = $relationParentUserInfo['USER_ID'];
  240. $baseInfo['REC_USER_NAME'] = $relationParentBaseInfo['USER_NAME'];
  241. $baseInfo['REC_REAL_NAME'] = $relationParentBaseInfo['REAL_NAME'];
  242. }
  243. if (isset($baseInfo['DEC_ID']) && $baseInfo['DEC_ID']) {
  244. $decBaseInfo = self::baseInfoZh($baseInfo['DEC_ID']);
  245. $baseInfo['DEC_USER_NAME'] = $decBaseInfo['USER_NAME'];
  246. $baseInfo['DEC_REAL_NAME'] = $decBaseInfo['REAL_NAME'];
  247. $baseInfo['DEC_DEC_LV'] = $decBaseInfo['DEC_LV'];
  248. $baseInfo['DEC_DEC_LV_NAME'] = $decBaseInfo['DEC_LV_NAME'];
  249. $baseInfo['DEC_DEC_ROLE_NAME'] = $decBaseInfo['DEC_ROLE_NAME'];
  250. $baseInfo['DEC_DEC_ROLE_ID'] = $decBaseInfo['DEC_ROLE_ID'];
  251. }
  252. }
  253. return $baseInfo;
  254. }
  255. /**
  256. * 基本信息含网络和余额
  257. * @param $userId
  258. * @param $periodNum
  259. * @return array
  260. */
  261. public static function baseInfoWithNetAndBalance($userId, $periodNum = null) {
  262. return array_merge(self::baseInfoWithNet($userId), self::BalanceInfo($userId));
  263. }
  264. /**
  265. * 通过用户名获取用户信息从INFO表
  266. * @param $userName
  267. * @return array|null|\yii\db\ActiveRecord
  268. */
  269. public static function getUserByUserNameFromUserInfoTable($userName) {
  270. return UserInfo::findOneAsArray(['USER_NAME' => $userName]);
  271. }
  272. /**
  273. * 获取报单级别
  274. * @param $userId
  275. * @param null $periodNum
  276. * @return mixed
  277. * @throws \yii\db\Exception
  278. */
  279. public static function getDecLv($userId, $periodNum = null) {
  280. if ($periodNum === null) {
  281. $data = User::findOneAsArray('ID=:ID', [':ID' => $userId], 'DEC_LV');
  282. $decLv = $data['DEC_LV'];
  283. } else {
  284. $period = Period::instance();
  285. $yearMonth = $period->getYearMonth($periodNum);
  286. $data = PerfPeriod::find()->yearMonth($yearMonth)->select('LAST_DEC_LV')->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM', [':USER_ID' => $userId, ':PERIOD_NUM' => $periodNum])->asArray()->one();
  287. $decLv = $data ? $data['LAST_DEC_LV'] : DeclarationLevel::getDefaultLevelId();
  288. }
  289. return $decLv;
  290. }
  291. /**
  292. * 获取聘级
  293. * @param $userId
  294. * @param null $periodNum
  295. * @return mixed
  296. * @throws \yii\db\Exception
  297. */
  298. public static function getEmpLv($userId, $periodNum = null) {
  299. if ($periodNum === null) {
  300. $data = User::findOneAsArray('ID=:ID', [':ID' => $userId], 'EMP_LV');
  301. $empLv = $data['EMP_LV'];
  302. } else {
  303. $period = Period::instance();
  304. $yearMonth = $period->getYearMonth($periodNum);
  305. $data = PerfMonth::find()->yearMonth($yearMonth)->select('LAST_EMP_LV')->where('USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH', [':USER_ID' => $userId, ':CALC_MONTH' => $yearMonth])->asArray()->one();
  306. $empLv = $data ? $data['LAST_EMP_LV'] : EmployLevel::getDefaultLevelId();
  307. }
  308. return $empLv;
  309. }
  310. /**
  311. * 获取最高聘级
  312. * @param $userId
  313. * @return mixed
  314. */
  315. public static function getHighEmpLv($userId){
  316. $data = UserInfo::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $userId], 'HIGHEST_EMP_LV');
  317. $empLv = $data ? $data['HIGHEST_EMP_LV'] : EmployLevel::getDefaultLevelId();
  318. return $empLv;
  319. }
  320. /**
  321. * 获取报单级别名称
  322. * @param $userId
  323. * @param null $periodNum
  324. * @return mixed
  325. * @throws \yii\db\Exception
  326. */
  327. public static function getDecLvName($userId, $periodNum = null) {
  328. if (!$decLv = self::getDecLv($userId, $periodNum)) {
  329. $decLv = DeclarationLevel::getDefaultLevelId();
  330. }
  331. return Cache::getDecLevelConfig()[$decLv]['LEVEL_NAME'];
  332. }
  333. /**
  334. * 获取聘级名称
  335. * @param $userId
  336. * @param null $periodNum
  337. * @return mixed
  338. * @throws \yii\db\Exception
  339. */
  340. public static function getEmpLvName($userId, $periodNum = null) {
  341. if (!$empLv = self::getEmpLv($userId, $periodNum)) {
  342. $empLv = EmployLevel::getDefaultLevelId();
  343. }
  344. return Cache::getEmpLevelConfig()[$empLv]['LEVEL_NAME'];
  345. }
  346. /**
  347. * 获取民族对应的代码
  348. * @param $str
  349. * @return int|string
  350. */
  351. public static function getNationCode($str) {
  352. $str = preg_replace('/族$/', '', $str);
  353. $allNation = \Yii::$app->params['nation'];
  354. foreach ($allNation as $key => $nation) {
  355. if ($str . '族' == $nation['name']) {
  356. return $key;
  357. }
  358. }
  359. return 0;
  360. }
  361. /**
  362. * 生成用户名
  363. * @param string $prefix
  364. * @param int $length
  365. * @return string
  366. */
  367. public static function generateUserName(string $prefix = 'HZ', int $length = 10) {
  368. $result = Tool::randomString($length, $prefix).array_rand([0,1,2,3,5,6,7,8,9],1);
  369. if (User::find()->where('USER_NAME=:USER_NAME', [':USER_NAME' => $result])->exists()) {
  370. return self::generateUserName($prefix, $length);
  371. }
  372. return $result;
  373. }
  374. /**
  375. * 新增加的 生成前端姓名里用户名
  376. * @param string $prefix
  377. * @param int $length
  378. * @return string
  379. */
  380. public static function generateWebUserName(string $prefix = 'HZ', int $length = 10) {
  381. $result = Tool::randomString($length, $prefix).array_rand([0,1,2,3,5,6,7,8,9],1);
  382. if (substr($result ,-1) == '4'){
  383. return self::generateWebUserName($prefix, $length);
  384. }
  385. if (User::find()->where('USER_NAME=:USER_NAME', [':USER_NAME' => $result])->exists()) {
  386. return self::generateWebUserName($prefix, $length);
  387. }
  388. return $result;
  389. }
  390. /**
  391. * 定位会员的子公司
  392. * @param $userArea
  393. * @return array|bool
  394. */
  395. public static function location($userArea){
  396. if(!is_array($userArea)){
  397. $userArea = json_decode($userArea, true);
  398. }
  399. if(!$userArea || !isset($userArea[0])){
  400. return false;
  401. }
  402. //获取会员的所在省份
  403. $userProvince = $userArea[0];
  404. $list = [];
  405. if(!$list){
  406. return false;
  407. }
  408. $matched = [];
  409. $userCity = isset($userArea[1]) ? intval($userArea[1]) : 0;
  410. $userCounty = isset($userArea[2]) ? intval($userArea[2]) : 0;
  411. foreach($list as $row){
  412. $manageRange = json_decode($row['MANAGE_RANGE'], true);
  413. foreach($manageRange as $manage){
  414. // $manage = ["370000","371000","371082"] or ["210000",""];
  415. $pro = isset($manage[0]) ? intval($manage[0]) : 0;
  416. $city = isset($manage[1]) ? intval($manage[1]) : 0;
  417. $county = isset($manage[2]) ? intval($manage[2]) : 0;
  418. if($userProvince == $pro && $userCity == $city && $userCounty == $county){
  419. $matched = $row;
  420. break;
  421. }
  422. if($userProvince == $pro && $userCity == $city && $county == 0){
  423. $matched = $row;
  424. break;
  425. }
  426. if($userProvince == $pro && $city == 0 && $county == 0){
  427. $matched = $row;
  428. break;
  429. }
  430. }
  431. }
  432. unset($userCounty, $userCity, $userArea, $userProvince, $list);
  433. return $matched;
  434. }
  435. /**
  436. * 通过id获取身份证号
  437. * @param $userId
  438. * @return null
  439. */
  440. public static function getIdCardByUserId($userId) {
  441. $user = User::findOneAsArray('ID=:ID', [':ID' => $userId], 'ID_CARD');
  442. return $user ? $user['ID_CARD'] : null;
  443. }
  444. /**
  445. * 通过id获取状态
  446. * @param $userId
  447. * @return null
  448. */
  449. public static function getStatusByUserId($userId){
  450. $user = User::findOneAsArray('ID=:ID', [':ID' => $userId], 'STATUS');
  451. return $user ? $user['STATUS'] : null;
  452. }
  453. /**
  454. * 通过id获取期数
  455. * @param $userId
  456. * @return null
  457. */
  458. public static function getPeriodNumByUserId($userId) {
  459. $user = User::findOneAsArray('ID=:ID', [':ID' => $userId], 'PERIOD_AT');
  460. return $user ? $user['PERIOD_AT'] : null;
  461. }
  462. /**
  463. * 是否实名认证
  464. * @param $userId
  465. * @return bool
  466. */
  467. public static function isVerified($userId) {
  468. $user = User::findOneAsArray('ID=:ID', [':ID' => $userId], 'VERIFIED');
  469. if ($user && $user['VERIFIED'] == 1) return true;
  470. return false;
  471. }
  472. /**
  473. * 根据商城设置获取密码
  474. * @param $idCard
  475. * @param $userName
  476. * @param bool $payPwd
  477. * @return bool|string
  478. */
  479. public static function passwordGenerator($idCard,$userName,$payPwd=false) {
  480. $systemConfig = Cache::getSystemConfig();
  481. if($payPwd){
  482. $config = $systemConfig['payPasswordRule'];
  483. }else{
  484. $config = $systemConfig['passwordRule'];
  485. }
  486. $rule = $config['VALUE']; //id_s_6 , id_p_8, user_name 后台设置,分别为身份证的后6位,前8位或者用户名
  487. switch ($rule) {
  488. case 'id_s_6':
  489. $password = substr($idCard, -6);
  490. break;
  491. case 'id_p_8':
  492. $password = substr($idCard, 0, 8);
  493. break;
  494. case 'user_name':
  495. $password = $userName;
  496. break;
  497. default:
  498. $password = '123456';
  499. }
  500. return $password;
  501. }
  502. /**
  503. * 当时会员级别状态等
  504. * @param $userId
  505. * @return array|null
  506. */
  507. public static function getLastInfo($userId){
  508. $data = User::findOneAsArray('ID=:ID', [':ID' => $userId], 'LAST_DEC_LV AS DEC_LV,EMP_LV,STATUS');
  509. return $data;
  510. }
  511. /**
  512. * 是否合作会员
  513. * @param $userId
  514. * @return bool
  515. */
  516. public static function isUnion($userId){
  517. $data = User::findOneAsArray('ID=:ID', [':ID' => $userId], 'IS_UNION');
  518. if ($data && $data['IS_UNION'] == 1) return true;
  519. return false;
  520. }
  521. }