$userId])->value('id'); } /** * 保存资料 * @param $where 条件 * @param $data 数据 * @return int|string */ public static function saveData($where, $data){ $data['updated_at'] = date('Y-m-d H:i:s'); return UserProfile::where($where)->update($data); } /** * 完善资料奖励 * @param $userId * @return bool|int|string */ public static function profileAward($userId){ // 验证资料是否已完善 $profile = UserProfile::checkUserProfile($userId); $isAward = isset($profile['profile_award_status'])? intval($profile['profile_award_status']) : 0; PRedis::set('member:profileAward:'.$userId, $profile, 600); if(empty($profile) || $isAward || (empty($profile['photolist']) || empty($profile['introduce']) || empty($profile['family']) || empty($profile['hobby']) || empty($profile['purpose']) || empty($profile['cause']) || empty($profile['expect']))){ // 设置为隐身模式 Member::saveData(['id'=> $userId], ['is_heart'=> 0]); return false; } // 加入怦然心动,关闭隐身 Member::saveData(['id'=> $userId], ['is_heart'=> 1]); // 完善资料分销奖励 $inviteInfo = Member::getInviteInfo($userId); $inviteId = isset($inviteInfo['invite_id'])? $inviteInfo['invite_id'] : 0; if($inviteInfo && $inviteId>0){ if(!UserBalanceLog::checkHasMarket($inviteId, $userId, 4)){ Award::marketAward($inviteId, $userId, 4); } } // 不在送爱心 return false; /*Db::startTrans(); $siteInfo = cmf_get_site_info(); $awardNum = isset($siteInfo['profile_award_redheart'])? intval($siteInfo['profile_award_redheart']) : 0; $field = 'id,openid,user_nickname,real_name,redheart'; $memberInfo = Member::getInfo(['id'=> $userId], $field); if($awardNum){ $redheart = isset($memberInfo['redheart'])? intval($memberInfo['redheart']) : 0; if(!Member::saveData(['id'=> $userId], ['redheart'=> intval($redheart + $awardNum)])){ Db::rollback(); return 2125; } // 账户明细 $remark = "完善资料奖励{$awardNum}个爱心"; $accountData = [ 'type' => 4, 'account_type' => 1, 'change_type' => 1, 'user_id' => $userId, 'money' => $awardNum, 'balance' => $redheart, 'created_at' => date('Y-m-d H:i:s'), 'remark' => $remark, ]; AccountLog::insertGetId($accountData); } // 加入怦然心动 if(!Member::saveData(['id'=> $userId], ['is_heart'=> 1])){ Db::rollback(); return false; } // 奖励爱心 $res = UserProfile::saveData(['userid'=> $userId], ['profile_award_status'=> 1]); if(!$res){ Db::rollback(); return false; } Db::commit(); return $res;*/ } /** * 验证用户信息是否完善 * @param $userId * @return array|bool|false|\PDOStatement|string|Model */ public static function checkUserProfile($userId){ $field = 'photolist,introduce,family,hobby,purpose,cause,expect,profile_award_status'; $profile = UserProfile::getInfo(['userid'=> $userId], $field); if(empty($profile) || (empty($profile['photolist']) || empty($profile['introduce']) || empty($profile['family']) || empty($profile['hobby']) || empty($profile['purpose']) || empty($profile['cause']) || empty($profile['expect']))){ return false; } return $profile; } /** * 获取会员信息 * @param $where 条件 * @param string $field 字段 * @return array|false|\PDOStatement|string|Model */ public static function getInfo($where, $field = "") { $field = $field? $field : 'id,userid,idcard,wechat_code,qq'; $info = UserProfile::where($where)->field($field)->find(); return $info ? $info->toArray() : []; } }