Info.php 19 KB

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