param = $param; $this->info = $this->getinfo($this->param); //$this->option = json_decode($this->info['option'], true); //$isaddscore = false; $msg = "签到"; $uinfo = $this->getuserinfo(); $userid = $uinfo['id']; $issign = $this->issign(); if ($issign) { return backarr(0, "已签到"); } $adddata = [ 'sourcedemo' => $msg, 'userid' => $userid, 'scoretype' => $this->info['scoretype'], 'addscore' => $this->info['score'], 'sourcetype' => 2, ]; $result = $this->adduserscore($adddata); if (empty($result['status'])) { return $result; } $data = $result['data']; $uaarid = $data['uaarid']; $recorddata = [ 'sbid' => $this->info['id'], 'code' => $this->info['code'], 'refid' => $uaarid, 'type' => 1, //积分增加 ]; $id = $this->newrecord($recorddata); if (!$id) { log::error($msg . " 创建关系失败"); } $returndata = [ 'uaarid' => $uaarid, 'addscore' => $adddata['addscore'], ]; return backarr(1, $msg, $returndata); } /** * 是否签到 * 20220105 * wj */ private function issign() { $arr = $this->param; $m_s = new signinmodel(); $where = [ 'userid' => $arr['userid'], 'signdate' => date('Y-m-d'), ]; $count = $m_s->getList($where, 'count'); return 1 < $count ? true : false; } /** * 获取分享详情 * 20220104 * wj */ private function getuserinfo() { $arr = $this->param; $checkuserinfo = isset($arr['checkuserinfo']) && $arr['checkuserinfo'] ? true : false; $where = []; if (isset($arr['userid'])) { $where['id'] = $arr['userid']; } if (isset($arr['openid'])) { $where['openid'] = $arr['openid']; } if (empty($where)) { throw new Exception("请求数据错误"); } if ($checkuserinfo) { $m_u = new userinfomodel(); $info = $m_u->getInfo($where); if (empty($info)) { throw new Exception("无用户信息"); } } else { $info = $where; } return $info; } }