UserClass.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. <?php
  2. namespace biz\user\classes;
  3. use biz\merchant\classes\MerchantAssetClass;
  4. use biz\merchant\classes\MerchantClass;
  5. use biz\merchant\services\MerchantService;
  6. use biz\message\classes\ChatClass;
  7. use biz\user\services\UserIntegralService;
  8. use common\components\business;
  9. use common\components\configDict;
  10. use common\components\util;
  11. use common\components\wxUtil;
  12. use common\services\ImageService;
  13. use common\services\xhMerchantExtendService;
  14. use common\services\xhUserCapitalService;
  15. use common\services\xhUserIntegralService;
  16. use common\services\xhUserMergeService;
  17. use Yii;
  18. use biz\base\classes\BaseClass;
  19. class UserClass extends BaseClass
  20. {
  21. public static $baseFile = '\biz\user\models\User';
  22. //用户和收入的来源
  23. public static $sourceType = [
  24. 2 => '朋友圈',
  25. 1 => '门店',
  26. 0 => '公众号',
  27. 3 => '淘宝',
  28. ];
  29. //用户来源分类
  30. public static $userSource = [
  31. 0 => ['name' => 'official', 'title' => '公众号'],
  32. 1 => ['name' => 'alipay', 'title' => '支付宝'],
  33. 2 => ['name' => 'mini', 'title' => '小程序'],
  34. ];
  35. //用户来源分类ID
  36. public static $userSourceId = [
  37. 'official' => ['id' => 0, 'name' => 'official'],
  38. 'alipay' => ['id' => 1, 'name' => 'alipay'],
  39. 'mini' => ['id' => 2, 'name' => 'mini'],
  40. ];
  41. //组合客户基本和资产信息
  42. public static function groupUserBaseInfo($list)
  43. {
  44. //取客户资产
  45. $ids = array_column($list, 'id');
  46. $ids = array_unique($ids);
  47. $asset = UserAssetClass::getByUserIds($ids, 'userId');
  48. $merchantIdList = array_column($list, 'merchantId');
  49. $merchantIdList = array_filter(array_unique($merchantIdList));
  50. $merchantList = MerchantService::getByIds($merchantIdList, null, 'id');
  51. foreach ($list as $key => $val) {
  52. $userId = $val['id'];
  53. //访问时间
  54. $visitTime = date("m-d H:i", $val['visitTime']);
  55. if (date("m-d") == date("m-d", $val['visitTime'])) {
  56. $visitTime = '今天 ' . date("H:i", $val['visitTime']);
  57. }
  58. $list[$key]['visitTimeFormat'] = $visitTime;
  59. $list[$key]['userAsset'] = isset($asset[$userId]) ? $asset[$userId] : [];
  60. //客户发来新消息数
  61. $list[$key]['unReadNum'] = ChatClass::getUnreadNum($userId);
  62. $list[$key] = business::formatUserAvatar($list[$key]);
  63. $merchantId = $val['merchantId'];
  64. $list[$key]['merchantName'] = isset($merchantList[$merchantId]['merchantName']) ? $merchantList[$merchantId]['merchantName'] : '';
  65. }
  66. return $list;
  67. }
  68. //获取客户基本和资产信息 shish 2019.11.30
  69. public static function getUserInfo($id)
  70. {
  71. $list = self::getByIds([$id]);
  72. $data = self::groupUserBaseInfo($list);
  73. return current($data);
  74. }
  75. //根据手机号查询客户 shish 2019.12.1
  76. public static function getByMobile($mobile, $merchantId)
  77. {
  78. return self::getByCondition(['merchantId' => $merchantId, 'mobile' => $mobile]);
  79. }
  80. public static function generateUser($getUserInfo, $merchantId)
  81. {
  82. //替换掉微信不支持的图片
  83. $date = date("Y-m-d H:i:s");
  84. $time = time();
  85. $getUserInfo['userName'] = isset($getUserInfo['userName']) ? preg_replace('/[\x{10000}-\x{10FFFF}]/u', '', $getUserInfo['userName']) : '';
  86. $getUserInfo['realName'] = isset($getUserInfo['realName']) && !empty($getUserInfo['realName']) ? $getUserInfo['realName'] : '';
  87. $getUserInfo['sex'] = isset($getUserInfo['sex']) ? $getUserInfo['sex'] : 0;//未知
  88. $getUserInfo['identity'] = 0;
  89. $subscribe = isset($getUserInfo['subscribe']) ? $getUserInfo['subscribe'] : 0;
  90. $getUserInfo['subscribe'] = $subscribe;
  91. $getUserInfo['merchantId'] = $merchantId;
  92. $getUserInfo['status'] = 0;
  93. //默认没有完整用户信息
  94. $isFull = isset($getUserInfo['headImgUrl']) && !empty($getUserInfo['headImgUrl']) ? 1 : 0;
  95. $getUserInfo['isFull'] = $isFull;
  96. $getUserInfo['createTime'] = $date;
  97. $getUserInfo['avatar'] = '';
  98. $getUserInfo['password'] = '';
  99. $getUserInfo['payPassword'] = '';
  100. $getUserInfo['mobile'] = isset($getUserInfo['mobile']) ? $getUserInfo['mobile'] : 0;
  101. $getUserInfo['addTime'] = $time;
  102. $getUserInfo['visitTime'] = $time;
  103. $getUserInfo['source'] = isset($getUserInfo['source']) ? $getUserInfo['source'] : 0;
  104. $getUserInfo['hasSubscribe'] = 0;
  105. //生成用户基础信息
  106. $user = self::add($getUserInfo);
  107. $userId = $user['id'];
  108. if (empty($user['userName'])) {
  109. self::updateById($userId, ['userName' => $userId]);
  110. }
  111. $assetData = ['userId' => $userId, 'merchantId' => $merchantId, 'createTime' => $date];
  112. //生成用户资产信息
  113. UserAssetClass::add($assetData);
  114. //保存头像
  115. if (isset($getUserInfo['headImgUrl']) && !empty($getUserInfo['headImgUrl'])) {
  116. if (empty($preUser) || (isset($preUser['avatar']) && empty($preUser['avatar']))) {
  117. $imgUrl = $getUserInfo['headImgUrl'];
  118. $currentImg = ImageService::generateAvatar($merchantId, $imgUrl);
  119. if (!empty($currentImg)) {
  120. self::updateById($userId, ['avatar' => $currentImg]);
  121. }
  122. }
  123. }
  124. //商家客户粉丝 +1
  125. $type = $subscribe == 1 ? 3 : 1;
  126. MerchantAssetClass::addUserNum($merchantId, $type);
  127. return $user;
  128. }
  129. public static function updateUser($originalUser, $getUserInfo, $merchantId)
  130. {
  131. $data = [];
  132. $assetData = [];
  133. $userId = $originalUser['id'];
  134. //替换掉微信不支持的图片
  135. $userName = isset($getUserInfo['userName']) ? preg_replace('/[\x{10000}-\x{10FFFF}]/u', '', $getUserInfo['userName']) : '';
  136. if (!empty($userName)) {
  137. $data['userName'] = $userName;
  138. }
  139. if (isset($getUserInfo['openId']) && !empty($getUserInfo['openId'])) {
  140. $openId = $getUserInfo['openId'];
  141. $data['openId'] = $openId;
  142. }
  143. if (isset($getUserInfo['miniOpenId']) && !empty($getUserInfo['miniOpenId'])) {
  144. $data['miniOpenId'] = $getUserInfo['miniOpenId'];
  145. }
  146. if (isset($getUserInfo['unionId']) && !empty($getUserInfo['unionId'])) {
  147. $data['unionId'] = $getUserInfo['unionId'];
  148. }
  149. if (isset($getUserInfo['sex'])) {
  150. $data['sex'] = $getUserInfo['sex'];
  151. }
  152. if (isset($getUserInfo['subscribe'])) {
  153. $data['subscribe'] = $getUserInfo['subscribe'];
  154. }
  155. if (isset($getUserInfo['subscribeTime'])) {
  156. $data['subscribeTime'] = $getUserInfo['subscribeTime'];
  157. }
  158. $data['merchantId'] = $merchantId;
  159. if (isset($getUserInfo['alipayId']) && !empty($getUserInfo['alipayId'])) {
  160. $data['alipayId'] = $getUserInfo['alipayId'];
  161. }
  162. if (isset($getUserInfo['isFull'])) {
  163. $data['isFull'] = $getUserInfo['isFull'];
  164. }
  165. if (isset($getUserInfo['headImgUrl']) && !empty($getUserInfo['headImgUrl'])) {
  166. $data['isFull'] = 1;
  167. }
  168. /**更新头像**/
  169. if (isset($originalUser['avatar']) == false || empty($originalUser['avatar'])) {
  170. if (isset($getUserInfo['headImgUrl']) && !empty($getUserInfo['headImgUrl'])) {
  171. $imgUrl = $getUserInfo['headImgUrl'];
  172. $name = ImageService::generateAvatar($merchantId, $imgUrl);
  173. if(!empty($name)){
  174. $data['avatar'] = $name;
  175. }
  176. }
  177. }
  178. /**商家增加粉丝**/
  179. if (isset($originalUser['subscribe']) && $originalUser['subscribe'] == 0 && isset($getUserInfo['subscribe']) && $getUserInfo['subscribe'] == 1) {
  180. MerchantAssetClass::addUserNum($merchantId, 2);
  181. }
  182. //更新访问时间
  183. self::updateById($userId, $data);
  184. if (!empty($assetData)) {
  185. UserAssetClass::updateByUserId($userId, $assetData);
  186. }
  187. $user = self::getById($userId);
  188. return $user;
  189. }
  190. public static function getByMiniOpenId($miniOpenId, $merchantId)
  191. {
  192. return self::getByCondition(['merchantId' => $merchantId, 'miniOpenId' => $miniOpenId]);
  193. }
  194. public static function getByAlipayId($alipayId, $merchantId)
  195. {
  196. return self::getByCondition(['merchantId' => $merchantId, 'alipayId' => $alipayId]);
  197. }
  198. public static function getByOpenId($openId, $merchantId)
  199. {
  200. return self::getByCondition(['merchantId' => $merchantId, 'openId' => $openId]);
  201. }
  202. public static function getByUnionId($unionId, $merchantId)
  203. {
  204. return self::getByCondition(['merchantId' => $merchantId, 'unionId' => $unionId]);
  205. }
  206. /**
  207. * 合并用户
  208. */
  209. public static function mergeUser($delUser, $retainUser)
  210. {
  211. $connection = Yii::$app->db;//事务处理
  212. $transaction = $connection->beginTransaction();
  213. try {
  214. $delUserId = $delUser['id'];
  215. $retainUserId = $retainUser['id'];
  216. $userName = $retainUser['userName'];
  217. $merchantId = $retainUser['merchantId'];
  218. //合并记录
  219. $return = UserMergeClass::add(['delUserId' => $delUserId, 'merchantId' => $merchantId, 'retainUserId' => $retainUserId, 'addTime' => time(), 'createTime' => date("Y-m-d H:i:s")]);
  220. $targetId = $return['id'];
  221. $typeList = configDict::getConfig('capitalType');
  222. $capitalType = $typeList['xhMergeUser']['id'];
  223. $now = time();
  224. $date = date("Y-m-d H:i:s");
  225. //数据迁移
  226. $updateData = [];
  227. $updateKey = [
  228. 'mobile',
  229. 'password',
  230. 'payPassword',
  231. 'subscribe',
  232. 'hasSubscribe',
  233. 'subscribeTime',
  234. 'alipayId',
  235. 'openId',
  236. 'miniOpenId',
  237. 'unionId',
  238. ];
  239. foreach ($updateKey as $key) {
  240. if (isset($delUser[$key]) && !empty($delUser[$key])) {
  241. $updateData[$key] = $delUser[$key];
  242. }
  243. }
  244. if (!empty($updateData)) {
  245. $updateData['visitTime'] = time();
  246. self::updateById($retainUserId, $updateData);
  247. }
  248. //资产累加
  249. $addData = [];
  250. $delUserAsset = UserAssetClass::getByUserId($delUserId);
  251. $retainUserAsset = UserAssetClass::getByUserId($retainUserId);
  252. if (!empty($delUserAsset)) {
  253. //累计消费
  254. $delTotalExpend = isset($delUserAsset['totalExpend']) ? $delUserAsset['totalExpend'] : 0;
  255. if (!empty($delTotalExpend)) {
  256. $addData['totalExpend'] = $retainUserAsset['totalExpend'] + $delTotalExpend;
  257. //变化记录要增加
  258. }
  259. //累计收入
  260. $delTotalIncome = isset($delUserAsset['totalIncome']) ? $delUserAsset['totalIncome'] : 0;
  261. if (!empty($delTotalIncome)) {
  262. $addData['totalIncome'] = $retainUserAsset['totalIncome'] + $delTotalIncome;
  263. //变化记录要增加
  264. }
  265. //累计充值
  266. $delTotalRecharge = isset($delUserAsset['totalRecharge']) ? $delUserAsset['totalRecharge'] : 0;
  267. if (!empty($delTotalRecharge)) {
  268. $addData['totalRecharge'] = $retainUserAsset['totalRecharge'] + $delTotalRecharge;
  269. //变化记录要增加
  270. }
  271. //累计购买数量
  272. $delTotalBuyNum = isset($delUserAsset['totalBuyNum']) ? $delUserAsset['totalBuyNum'] : 0;
  273. if (!empty($delTotalBuyNum)) {
  274. $addData['totalBuyNum'] = $retainUserAsset['totalBuyNum'] + $delTotalBuyNum;
  275. //变化记录要增加
  276. }
  277. //余额
  278. $delBalance = isset($delUserAsset['balance']) ? $delUserAsset['balance'] : 0;
  279. if (!empty($delBalance)) {
  280. $addData['balance'] = $retainUserAsset['balance'] + $delBalance;
  281. //变化记录要增加
  282. $userCapitalData = [
  283. 'relateId' => $targetId,
  284. 'balance' => $addData['balance'],
  285. 'totalIncome' => $retainUserAsset['totalIncome'] + $delBalance,
  286. 'totalExpend' => $retainUserAsset['totalExpend'],
  287. 'amount' => $delBalance,
  288. 'io' => 1,
  289. 'payWay' => 0,
  290. 'event' => '帐号合并',
  291. 'merchantId' => $merchantId,
  292. 'userId' => $retainUserId,
  293. 'alipayId' => '',
  294. 'userName' => $userName,
  295. 'operateId' => 0,
  296. 'createTime' => $date,
  297. 'addTime' => $now,
  298. 'capitalType' => $capitalType,
  299. ];
  300. xhUserCapitalService::add($userCapitalData);//用户资金流水增加
  301. }
  302. //成长值
  303. $delGrowth = isset($delUserAsset['growth']) ? $delUserAsset['growth'] : 0;
  304. if (!empty($delGrowth)) {
  305. $addData['growth'] = $retainUserAsset['growth'] + $delGrowth;
  306. //注意会员等级要进行重新计算!!!!!还有积分变化记录要增加
  307. $growthData = [
  308. 'userId' => $retainUserId,
  309. 'userName' => $userName,
  310. 'merchantId' => $merchantId,
  311. 'relateId' => $targetId,
  312. 'integral' => $addData['growth'],
  313. 'num' => $delGrowth,
  314. 'io' => 1,
  315. 'payWay' => 0,
  316. 'alipayId' => '',
  317. 'event' => '帐号合并',
  318. 'operatorId' => 0,
  319. 'createTime' => $date,
  320. 'capitalType' => $capitalType,
  321. 'addTime' => $now,
  322. ];
  323. UserGrowthClass::add($growthData);
  324. //成长值增加升级
  325. $preLevel = $retainUserAsset['member'];
  326. $preGrowth = $retainUserAsset['growth'];
  327. $merchantExtend = xhMerchantExtendService::getByMerchantId($merchantId);
  328. UserIntegralService::increaseToUpgrade($preGrowth, $addData['growth'], $preLevel, $retainUserId, $merchantId, $merchantExtend);
  329. }
  330. if (!empty($addData)) {
  331. UserAssetClass::updateByUserId($retainUserId, $addData);
  332. }
  333. }
  334. //删除用户
  335. $clearData = ['openId' => '', 'miniOpenId' => '', 'unionId' => '', 'alipayId' => '', 'merchantId' => 0];
  336. self::updateById($delUserId, $clearData);
  337. UserAssetClass::updateByUserId($delUserId, ['merchantId' => 0]);
  338. //清除支付宝用户
  339. $clearAlipayData = ['alipayId' => '', 'alipayAccount' => '', 'merchantId' => 0];
  340. UserAlipayClass::updateByUserId($delUserId, $clearAlipayData);
  341. $transaction->commit();
  342. return self::getById($retainUserId);
  343. } catch (Exception $e) {
  344. $transaction->rollBack();
  345. Yii::info("合并userid $delUserId $retainUserId 时事务回滚,原因:" . $e->getMessage());
  346. return [];
  347. }
  348. }
  349. //找出相同unionId的用户
  350. public static function getSameUnionId($merchantId, $unionId)
  351. {
  352. return self::getAllByCondition(['merchantId' => $merchantId, 'unionId' => $unionId], 'addTime desc', '*');
  353. }
  354. public static function valid($info, $merchantId)
  355. {
  356. if (empty($info)) {
  357. util::fail('找不到客户');
  358. }
  359. if ($info['merchantId'] != $merchantId) {
  360. util::fail('这个客户您没有权限操作');
  361. }
  362. }
  363. //根据消费次数和有没领优惠券来判断是不是新人
  364. public static function newUser($userInfo)
  365. {
  366. $asset = isset($userInfo['userAsset']) ? $userInfo['userAsset'] : [];
  367. $totalBuyNum = isset($asset['totalBuyNum']) ? $asset['totalBuyNum'] : 0;
  368. if ($totalBuyNum > 0) {
  369. return false;
  370. }
  371. $getCouponNum = isset($asset['getCouponNum']) ? $asset['getCouponNum'] : 0;
  372. if ($getCouponNum) {
  373. return false;
  374. }
  375. return true;
  376. }
  377. public static function getUserByIds($ids)
  378. {
  379. $info = self::getByIds($ids, null, 'id');
  380. if (empty($info)) {
  381. return [];
  382. }
  383. $data = self::groupUserBaseInfo($info);
  384. return $data;
  385. }
  386. //将微信和小程序获取的用户信息转成可以保存的用户信息
  387. public static function switchUserInfo($info, $source)
  388. {
  389. $openId = '';
  390. if (isset($info['openid']) && !empty($info['openid'])) {
  391. $openId = $info['openid'];
  392. unset($info['openId']);
  393. }
  394. if (isset($info['openId']) && !empty($info['openId'])) {
  395. $openId = $info['openId'];
  396. unset($info['openId']);
  397. }
  398. if (!empty($openId)) {
  399. $userSource = self::$userSourceId;
  400. switch ($source) {
  401. case $userSource['mini']['name']:
  402. $info['miniOpenId'] = $openId;
  403. break;
  404. case $userSource['official']['name']:
  405. $info['openId'] = $openId;
  406. break;
  407. default:
  408. }
  409. }
  410. if (isset($info['nickname'])) {
  411. $info['userName'] = $info['nickname'];
  412. }
  413. if (isset($info['nickName'])) {
  414. $info['userName'] = $info['nickName'];
  415. }
  416. if (isset($info['unionid'])) {
  417. $info['unionId'] = $info['unionid'];
  418. }
  419. if (isset($info['unionId'])) {
  420. $info['unionId'] = $info['unionId'];
  421. }
  422. if (isset($info['headimgurl'])) {
  423. $info['headImgUrl'] = $info['headimgurl'];
  424. }
  425. if (isset($info['avatarUrl'])) {
  426. $info['headImgUrl'] = $info['avatarUrl'];
  427. }
  428. if (isset($info['subscribe_time'])) {
  429. $info['subscribeTime'] = $info['subscribe_time'];
  430. }
  431. if (isset($info['subscribe'])) {
  432. $info['subscribe'] = $info['subscribe'];
  433. }
  434. return $info;
  435. }
  436. //创建以及更新用户 shish 2020.2.7
  437. public static function replaceUser($userInfo, $source, $merchantId)
  438. {
  439. $userInfo = self::switchUserInfo($userInfo, $source);
  440. $userSource = self::$userSourceId;
  441. switch ($source) {
  442. case $userSource['mini']['name']:
  443. $sourceId = $userSource['mini']['id'];
  444. $miniOpenId = $userInfo['miniOpenId'];
  445. $user = self::getByMiniOpenId($miniOpenId, $merchantId);
  446. break;
  447. case $userSource['alipay']['name']:
  448. $sourceId = $userSource['alipay']['id'];
  449. $alipayId = $userInfo['alipayId'];
  450. $user = self::getByAlipayId($alipayId, $merchantId);
  451. break;
  452. case $userSource['official']['name']:
  453. $sourceId = $userSource['official']['id'];
  454. //老客添加没有openId
  455. $openId = isset($userInfo['openId']) ? $userInfo['openId'] : '';
  456. $user = [];
  457. if (!empty($openId)) {
  458. $user = self::getByOpenId($openId, $merchantId);
  459. }
  460. break;
  461. default:
  462. throw new \Exception('未知来源的用户');
  463. }
  464. if (empty($user)) {
  465. $userInfo['source'] = $sourceId;
  466. $userInfo['merchantId'] = $merchantId;
  467. $user = self::generateUser($userInfo, $merchantId);
  468. } else {
  469. //支付宝付款时不需要每次更新用户信息
  470. if ($source != $userSource['alipay']['name']) {
  471. $user = self::updateUser($user, $userInfo, $merchantId);
  472. }
  473. }
  474. //存在相同unionid则进行合并
  475. $unionId = isset($userInfo['unionId']) ? $userInfo['unionId'] : '';
  476. if (!empty($unionId)) {
  477. $same = self::getSameUnionId($merchantId, $unionId);
  478. if (count($same) == 2) {
  479. $delUser = $same[0];
  480. $retainUser = $same[1];
  481. $user = self::mergeUser($delUser, $retainUser);
  482. }
  483. }
  484. return $user;
  485. }
  486. //拉取粉丝 shish 2020.2.7
  487. public static function syncWxUser($merchantId, $nextOpenId = '')
  488. {
  489. $merchant = MerchantClass::getMerchantById($merchantId);
  490. //一次拉取调用最多拉取10000个关注者的OpenID
  491. $result = wxUtil::getSubscribeUserList($merchant, $nextOpenId);
  492. $total = isset($result['total']) ? $result['total'] : 0;
  493. $next_openid = isset($result['next_openid']) ? $result['next_openid'] : '';
  494. $count = isset($result['count']) ? $result['count'] : 0;
  495. $openIdList = isset($result['data']['openid']) ? $result['data']['openid'] : [];
  496. $currentTotal = count($openIdList);
  497. if ($count == 0 || $currentTotal == 0) {
  498. return ['total' => $total, 'count' => $count, 'nextOpenId' => $next_openid];
  499. }
  500. $currentTotalPage = $currentTotal > 100 ? ceil($currentTotal / 100) : 1;
  501. $userSource = Yii::$app->dict->getValue('userSourceGetId', 'official');
  502. $source = $userSource['name'];
  503. for ($m = 1; $m <= $currentTotalPage; $m++) {
  504. $offset = ($m - 1) * 100;
  505. $subIdList = array_slice($openIdList, $offset, 100);
  506. $info = wxUtil::batchGetUserInfo($merchant, $subIdList);
  507. if (empty($info) || isset($info['user_info_list']) == false || empty($info['user_info_list'])) {
  508. continue;
  509. }
  510. $user_info_list = $info['user_info_list'];
  511. foreach ($user_info_list as $val) {
  512. $val['isFull'] = 1;
  513. $val['unionId'] = $val['unionid'];
  514. $val['headImgUrl'] = $val['headimgurl'];
  515. $val['openId'] = $val['openid'];
  516. $val['nickName'] = $val['nickname'];
  517. $val['merchantId'] = $merchantId;
  518. self::replaceUser($val, $source, $merchantId);
  519. }
  520. }
  521. return ['total' => $total, 'count' => $count, 'nextOpenId' => $next_openid];
  522. }
  523. }