UserClass.php 19 KB

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