param = $param; $this->info = $this->getinfo($this->param); $this->option = json_decode($this->info['option'], true); $info = $this->getapplyinfo(); if (!$info) { return backarr(0, "无数据"); } $msg = "分享进入"; $returndata = [ 'uaarid' => 0, 'addscore' => 0, ]; if (1 == $info['isnewuser']) { $msg .= "-新用户"; $maxnewuser = $this->option['maxnewuser']; $shareresult = $this->getshareloginfo($info['shareuid']); if (!$shareresult['status']) { return $shareresult; } $shareinfo = $shareresult['data']; $userid = $shareinfo['userid']; $isaddscore = false; if ($maxnewuser > 0) { $count = $this->countnewuser($userid); if ($count < $maxnewuser) { $isaddscore = true; } } else { $isaddscore = true; } if ($isaddscore) { $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); } /** * 获取新用户数量 * 20220104 * wj */ /*private function countnewuser() { $arr = $this->param; $m_ual = new userapplylogmodel(); if (!isset($arr['shareuid']) || empty($arr['shareuid']) || !is_numeric($arr['shareuid'])) { return backarr(0, "请求错误"); } $where = [ 'isnewuser' => 1, 'shareuid' => $arr['shareuid'], 'sharetime' => ['like', '%' . date('Y-m-d') . '%'], ]; $count = $m_ual->getList($where, 'count'); return $count; }*/ public function countnewuser($userid) { $where = [ 'usl.userid' => $userid, 'ual.sharetime' => ['like', '%' . date('Y-m-d') . '%'], 'ual.isnewuser' => 1, ]; $m_usl = new usersharelogmodel(); $count = $m_usl->getListjoinapply($where, 'count'); $count = empty($count) ? 0 : $count; return $count; } /** * 获取详细 * 20220104 * wj */ private function getapplyinfo() { $arr = $this->param; $where = []; if (isset($arr['shareuid'])) { $where['shareuid'] = $arr['shareuid']; } if (isset($arr['userid'])) { $where['userid'] = $arr['userid']; } if (isset($arr['openid'])) { $where['shareopenid'] = $arr['openid']; } if (isset($arr['applyid'])) { $where['id'] = $arr['applyid']; } $m_ual = new userapplylogmodel(); $info = $m_ual->getInfo($where); if (empty($info)) { return false; } return $info; } /** * 获取分享详情 * 20220104 * wj */ private function getshareloginfo($shareuid) { //$arr = $this->param; $m_usl = new usersharelogmodel(); $where = [ 'shareuid' => $shareuid, ]; $info = $m_usl->getInfo($where); if (empty($info)) { return backarr(0, "无分享信息"); } if (empty($info['userid'])) { return backarr(0, "无用户id"); } return backarr(1, "查询成功", $info); } }