HeartMatch.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\weixin\model;
  3. use think\Model;
  4. class HeartMatch extends Model
  5. {
  6. protected $table = 'sg_user_heart_match';
  7. /**
  8. * 获取我互选的用户ID
  9. * @param $aid 活动ID
  10. * @param $userId 当前用户ID
  11. * @return array|mixed
  12. */
  13. public static function getHeartUids($aid, $userId){
  14. $uids = HeartMatch::where(['aid'=> $aid,'uid'=> $userId])->where('status','in',[1,2,3])->value('heart_uids');
  15. $uids = $uids? explode(',', $uids) : [];
  16. return $uids;
  17. }
  18. /**
  19. * 获取匹配结果
  20. * @param $aid
  21. * @param $userId
  22. * @return array
  23. */
  24. public static function getMatchResult($aid, $userId){
  25. $info = [];
  26. $siteInfo = $siteInfo = cmf_get_site_info();
  27. $contactType = isset($siteInfo['contact_type']) ? $siteInfo['contact_type'] : 1;
  28. // 是否已匹配
  29. $matchStatus = Activity::where(['id'=> $aid])->value('is_match');
  30. if($matchStatus != 1 && $contactType != 3){
  31. return 1;
  32. }
  33. $matchData = HeartMatch::where(['aid'=> $aid, 'uid'=> $userId])->field('match_uid,status')->find();
  34. $matchUid = isset($matchData['match_uid'])? trim($matchData['match_uid']) : '';
  35. $matchStatus = isset($matchData['status'])? intval($matchData['status']) : 0;
  36. if($matchStatus == 1){
  37. return 1;
  38. }
  39. $matchUids = explode(',', $matchUid);
  40. if(empty($matchUids) || $matchStatus != 2){
  41. return [];
  42. }
  43. return Member::getMatchList($matchUid);
  44. }
  45. }