| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace app\weixin\model;
- use think\Model;
- class HeartMatch extends Model
- {
- protected $table = 'sg_user_heart_match';
- /**
- * 获取我互选的用户ID
- * @param $aid 活动ID
- * @param $userId 当前用户ID
- * @return array|mixed
- */
- public static function getHeartUids($aid, $userId){
- $uids = HeartMatch::where(['aid'=> $aid,'uid'=> $userId])->where('status','in',[1,2,3])->value('heart_uids');
- $uids = $uids? explode(',', $uids) : [];
- return $uids;
- }
- /**
- * 获取匹配结果
- * @param $aid
- * @param $userId
- * @return array
- */
- public static function getMatchResult($aid, $userId){
- $info = [];
- $siteInfo = $siteInfo = cmf_get_site_info();
- $contactType = isset($siteInfo['contact_type']) ? $siteInfo['contact_type'] : 1;
- // 是否已匹配
- $matchStatus = Activity::where(['id'=> $aid])->value('is_match');
- if($matchStatus != 1 && $contactType != 3){
- return 1;
- }
- $matchData = HeartMatch::where(['aid'=> $aid, 'uid'=> $userId])->field('match_uid,status')->find();
- $matchUid = isset($matchData['match_uid'])? trim($matchData['match_uid']) : '';
- $matchStatus = isset($matchData['status'])? intval($matchData['status']) : 0;
- if($matchStatus == 1){
- return 1;
- }
- $matchUids = explode(',', $matchUid);
- if(empty($matchUids) || $matchStatus != 2){
- return [];
- }
- return Member::getMatchList($matchUid);
- }
- }
|