| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- <?php
- namespace bizHd\ll\classes;
- use common\components\noticeUtil;
- use common\components\util;
- use Yii;
- use bizHd\base\classes\BaseClass;
- class LlUserClass extends BaseClass
- {
- public static $baseFile = '\bizHd\ll\models\LlUser';
- public static function addMobile($user, $mobile)
- {
- }
- public static function addWx($user, $wx)
- {
- }
- public static function addNo($user, $no)
- {
- }
- public static function getInfo($id, $sensitive = true)
- {
- $user = LlUserClass::getById($id, true);
- if (empty($user)) {
- util::fail('没有找到失信人员信息');
- }
- $name = $user->name ?? '';
- $firstDate = $user->firstDate ?? '';
- $lastDate = $user->lastDate ?? '';
- $breakNum = $user->breakNum ?? 0;
- $breakAmount = $user->breakAmount ?? 0;
- $mobileRes = LlMobileClass::getAllByCondition(['userId' => $id], null, '*');
- $mobileList = [];
- if (!empty($mobileRes)) {
- foreach ($mobileRes as $key => $val) {
- $mobile = $val['mobile'] ?? '';
- if (empty($mobile)) {
- continue;
- }
- if ($sensitive) {
- $mobile = substr_replace($mobile, '****', 3, 4);
- }
- $mobileList[] = $mobile;
- }
- }
- $wxRes = LlWxClass::getAllByCondition(['userId' => $id], null, '*');
- $wxList = [];
- if (!empty($wxRes)) {
- foreach ($wxRes as $key => $val) {
- $wx = $val['wx'] ?? '';
- if (empty($wx)) {
- continue;
- }
- if ($sensitive) {
- $wxNum = strlen($wx);
- $num = ceil($wxNum / 3);
- $str = '';
- for ($i = 1; $i <= $num; $i++) {
- $str .= '*';
- }
- $wx = substr_replace($wx, $str, -$num);
- }
- $wxList[] = $wx;
- }
- }
- $noRes = LlNoClass::getAllByCondition(['userId' => $id], null, '*');
- $noList = [];
- if (!empty($noRes)) {
- foreach ($noRes as $key => $val) {
- $no = $val['no'] ?? '';
- if (empty($no)) {
- continue;
- }
- if ($sensitive) {
- $no = substr_replace($no, '*********', 6, 9);
- }
- $noList[] = $no;
- }
- }
- $userInfo = [
- 'name' => $name,
- 'mobileList' => $mobileList,
- 'wxList' => $wxList,
- 'noList' => $noList,
- 'firstDate' => $firstDate,
- 'lastDate' => $lastDate,
- 'breakNum' => $breakNum,
- 'breakAmount' => $breakAmount,
- ];
- return $userInfo;
- }
- public static function getUserList($where, $sensitive = true)
- {
- $order = 'addTime DESC';
- $data = self::getList('*', $where, $order);
- $totalUserNum = self::getCount($where);
- $data['totalUserNum'] = $totalUserNum;
- if (isset($data['list']) && $data['list']) {
- foreach ($data['list'] as $key => $val) {
- if ($sensitive) {
- $mobile = $val['mobile'] ?? '';
- if (!empty($mobile)) {
- $mobile = substr_replace($mobile, '****', 3, 4);
- }
- $data['list'][$key]['mobile'] = $mobile;
- $wx = $val['wx'] ?? '';
- if (!empty($wx)) {
- $wxNum = strlen($wx);
- $num = ceil($wxNum / 3);
- $str = '';
- for ($i = 1; $i <= $num; $i++) {
- $str .= '*';
- }
- $wx = substr_replace($wx, $str, -$num);
- }
- $data['list'][$key]['wx'] = $wx;
- $no = $val['no'] ?? '';
- if (!empty($no)) {
- $no = substr_replace($no, '*********', 6, 9);
- }
- $data['list'][$key]['no'] = $no;
- }
- }
- }
- return $data;
- }
- public static function replaceUser($userInfo, $shop)
- {
- $shopId = $shop->id ?? '';
- $shopMobile = $shop->mobile ?? '';
- $shopFullName = $shop->merchantName . ' ' . $shop->shopName;
- $userId = 0;
- $baseId = 0;
- $thatDate = $userInfo['date'] ?? '';
- $name = $userInfo['name'] ?? '';
- $no = $userInfo['no'] ?? '';
- $noRes = LlNoClass::getByCondition(['no' => $no], true);
- if (!empty($noRes)) {
- $userId = $noRes->userId ?? 0;
- $baseId = $noRes->baseId ?? 0;
- }
- $mobile = $userInfo['mobile'] ?? '';
- $mobileRes = LlMobileClass::getByCondition(['mobile' => $mobile], true);
- if (!empty($mobileRes) && empty($userId)) {
- $userId = $mobileRes->userId ?? 0;
- $baseId = $mobileRes->baseId ?? 0;
- }
- $wx = $userInfo['wx'] ?? '';
- $wxRes = LlWxClass::getByCondition(['wx' => $wx], true);
- if (!empty($wxRes) && empty($userId)) {
- $userId = $wxRes->userId ?? 0;
- $baseId = $wxRes->baseId ?? 0;
- }
- if (!empty($userId)) {
- $user = self::getById($userId, true);
- } else {
- $userInfo['firstDate'] = $thatDate;
- $userInfo['lastDate'] = $thatDate;
- $user = self::add($userInfo, true);
- }
- if (!empty($baseId)) {
- $base = LlBaseClass::getById($baseId, true);
- if (empty($base)) {
- noticeUtil::push("用户提供的老赖信息,有baseId:{$baseId}但没base信息,提借者:{$shopId} {$shopMobile} {$shopFullName}", '15280215347');
- util::fail('用户信息有问题,请联系客服,baseId:' . $baseId);
- }
- if (!empty($no) && $no != $base->no) {
- noticeUtil::push("用户提供的老赖身份证号是{$no},但baseId:{$baseId}的身份证号是另个:{$base->no},提借者:{$shopId} {$shopMobile} {$shopFullName}", '15280215347');
- util::fail('请提身份证号有问题,请联系客服');
- }
- } else {
- $base = null;
- if (!empty($no)) {
- $base = LlBaseClass::getByCondition(['no' => $no], true);
- if (empty($base)) {
- $baseData = ['no' => $no, 'name' => $name, 'firstDate' => $thatDate, 'lastDate' => $thatDate];
- $base = LlBaseClass::add($baseData, true);
- }
- }
- }
- $userId = $user->id ?? 0;
- $baseId = $base->id ?? 0;
- if (!empty($wx)) {
- $wxRes = LlWxClass::getByCondition(['wx' => $wx], true);
- if (empty($wxRes)) {
- $wxRes = LlWxClass::add(['wx' => $wx], true);
- }
- $wxRes->baseId = $baseId;
- $wxRes->userId = $userId;
- $wxRes->save();
- }
- if (!empty($mobile)) {
- $mobileRes = LlMobileClass::getByCondition(['mobile' => $mobile], true);
- if (empty($mobileRes)) {
- $mobileRes = LlMobileClass::add(['mobile' => $mobile], true);
- }
- $mobileRes->baseId = $baseId;
- $mobileRes->userId = $userId;
- $mobileRes->save();
- }
- if (!empty($no)) {
- $noRes = LlNoClass::getByCondition(['no' => $no], true);
- if (empty($noRes)) {
- $noRes = LlNoClass::add(['no' => $no], true);
- }
- $noRes->baseId = $baseId;
- $noRes->userId = $userId;
- $noRes->save();
- }
- return $user;
- }
- }
|