field("add_time")->select(); foreach ($zhuce_list as $key => $value) { # code... $user_zhuce_time = $value['add_time']; if ($jinri_end_time > $user_zhuce_time and $user_zhuce_time > $jinri_start_time) { $zc_jilei++; $zc_jinri++; $zc_sanri++; $zc_yizhou++; $zc_yiyue++; } elseif ($zuo_end_time > $user_zhuce_time and $user_zhuce_time > $zuo_start_time) { $zc_jilei++; $zc_zuori++; $zc_yiyue++; } elseif ($san_end_time > $user_zhuce_time and $user_zhuce_time > $san_start_time) { $zc_jilei++; $zc_sanri++; $zc_yiyue++; } elseif ($zhou_end_time > $user_zhuce_time and $user_zhuce_time > $zhou_start_time) { $zc_jilei++; $zc_yizhou++; $zc_yiyue++; } elseif ($yue_end_time > $user_zhuce_time and $user_zhuce_time > $yue_start_time) { $zc_jilei++; $zc_yiyue++; } elseif ($user_zhuce_time < $yue_start_time) { $zc_jilei++; } } //付费人数 和钱数 $user_list = M("pay_test")->field("uid,pay_time,amount")->where("order_type='已支付'")->select(); foreach ($user_list as $key1 => $value1) { $user_ff_time = $value1['pay_time']; $fufei_jine = $value1['amount']; if ($jinri_end_time > $user_ff_time and $user_ff_time > $jinri_start_time) { $ffm_jilei += $fufei_jine; $ffm_jinri += $fufei_jine; $ffm_sanri += $fufei_jine; $ffm_yizhou += $fufei_jine; $ffm_yiyue += $fufei_jine; } elseif ($zuo_end_time > $user_ff_time and $user_ff_time > $zuo_start_time) { $ffm_yiyue += $fufei_jine; $ffm_jilei += $fufei_jine; $ffm_zuori += $fufei_jine; $ffm_yizhou += $fufei_jine; } elseif ($san_end_time > $user_ff_time and $user_ff_time > $san_start_time) { $ffm_yiyue += $fufei_jine; $ffm_jilei += $fufei_jine; $ffm_sanri += $fufei_jine; $ffm_yizhou += $fufei_jine; } elseif ($zhou_end_time > $user_ff_time and $user_ff_time > $zhou_start_time) { $ffm_yiyue += $fufei_jine; $ffm_jilei += $fufei_jine; $ffm_yizhou += $fufei_jine; } elseif ($yue_end_time > $user_ff_time and $user_ff_time > $yue_start_time) { $ffm_jilei += $fufei_jine; $ffm_yiyue += $fufei_jine; } else { //} else ($user_zhuce_time < $yue_start_time) { $ffm_jilei += $fufei_jine; } } //今日 $todaytime = strtotime(date("Y-m-d", time()) . "00:00:00"); //三日 $threedaytime = strtotime(date("Y-m-d", strtotime("-3 day")) . "00:00:00"); //周 $weekdaytime = strtotime(date("Y-m-d", strtotime("-1 week")) . "00:00:00"); //14日 $fourteendaytime = strtotime(date("Y-m-d", strtotime("-14 day")) . "00:00:00"); $yueday_time = strtotime(date("Y-m-d", strtotime("-30 day")) . "00:00:00"); $renshu_jin = M("pay_test")->where("pay_time>='$todaytime'")->field("uid")->group("uid")->select(); $renshu_zuo = M("pay_test")->where("pay_time>='$zuo_start_time' and pay_time<='$zuo_end_time'")->field("uid")->group("uid")->select(); $renshu_san = M("pay_test")->where("pay_time>='$threedaytime'")->field("uid")->group("uid")->select();; $renshu_zhou = M("pay_test")->where("pay_time>='$weekdaytime'")->field("uid")->group("uid")->select(); $renshu_yue = M("pay_test")->where("pay_time>='$yueday_time'")->field("uid")->group("uid")->select(); $renshu_jilei = M("pay_test")->field("uid")->group("uid")->select(); $huoyue_jin = M("huoyue_list")->where("time>='$jinri_start_time' and time<='$jinri_end_time'")->field("uid")->group("uid")->select(); $huoyue_zuo = M("huoyue_list")->where("time>='$zuo_start_time' and time<='$zuo_end_time'")->field("uid")->group("uid")->select(); $huoyue_san = M("huoyue_list")->where("time>='$san_start_time' and time<='$san_end_time' ")->field("uid")->group("uid")->select();; $huoyue_zhou = M("huoyue_list")->where("time>='$zhou_start_time' and time<='$zhou_end_time'")->field("uid")->group("uid")->select(); $huoyue_yue = M("huoyue_list")->where("time>='$yue_start_time' and time<='$yue_end_time'")->field("uid")->group("uid")->select(); $huoyue_jilei = M("huoyue_list")->field("uid")->group("uid")->select(); $yizhoulist['jinri'] = $zc_jinri; $yizhoulist['zuori'] = $zc_zuori; $yizhoulist['sanri'] = $zc_sanri; $yizhoulist['zhou'] = $zc_yizhou; $yizhoulist['yue'] = $zc_yiyue; $yizhoulist['jilei'] = $zc_jilei; $fufei_num['jinri_num'] = count($renshu_jin); $fufei_num['zuori_num'] = count($renshu_zuo); $fufei_num['sanri_num'] = count($renshu_san); $fufei_num['zhou_num'] = count($renshu_zhou); $fufei_num['yue_num'] = count($renshu_yue); $fufei_num['jilei_num'] = count($renshu_jilei); $fufei_number['jinri_people'] = $ffm_jinri; $fufei_number['zuori_people'] = $ffm_zuori; $fufei_number['sanri_people'] = $ffm_sanri; $fufei_number['zhou_people'] = $ffm_yizhou; $fufei_number['yue_people'] = $ffm_yiyue; $fufei_number['jilei_people'] = $ffm_jilei; $huoyue_num['jinriAAA_num'] = count($huoyue_jin); $huoyue_num['zuoriAAA_num'] = count($huoyue_zuo); $huoyue_num['sanriAAA_num'] = count($huoyue_san); $huoyue_num['zhouAAA_num'] = count($huoyue_zhou); $huoyue_num['yueAAA_num'] = count($huoyue_yue); $huoyue_num['jileiAAA_num'] = count($huoyue_jilei); $shuzu_list = array($yizhoulist, $fufei_number, $fufei_num, $huoyue_num); $data['code'] = '200'; $data['status'] = '1'; $data['message'] = ''; $data['data'] = $shuzu_list; echo json_encode($data); } public function slUserStatistics() { // 指定允许其他域名访问 // header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); if (!empty($_POST)) { $token = $_POST['token']; //b8e3bb6ef8747d7 if ($token != 'b8e3bb6ef8747d7') { $data['code'] = '203'; $data['msg'] = 'token错误'; echo json_encode($data); die; } //今日 $todaytime = strtotime(date("Y-m-d", time()) . "00:00:00"); //三日 $threedaytime = strtotime(date("Y-m-d", strtotime("-3 day")) . "00:00:00"); //周 $weekdaytime = strtotime(date("Y-m-d", strtotime("-1 week")) . "00:00:00"); //14日 $fourteendaytime = strtotime(date("Y-m-d", strtotime("-14 day")) . "00:00:00"); /** * 注册人数统计 */ //累计新增注册 $arr['totaluser'] = M("slgj_user")->count(); //今日新增注册 $arr['todayuser'] = M("slgj_user")->where("registertime>='$todaytime'")->count(); //3日新增注册 $arr['threedayuser'] = M("slgj_user")->where("registertime>='$threedaytime'")->count(); //周新增注册 $arr['weekuser'] = M("slgj_user")->where("registertime>='$weekdaytime'")->count(); //14日新增注册 $arr['fourteenuser'] = M("slgj_user")->where("registertime>='$fourteendaytime'")->count(); /** * 登录人数统计 */ //今日登录人数 $arr['todayloginuser'] = count(M("slgj_user_sessid")->where("time>='$todaytime' and uid!=0")->group("uid")->getField("uid", true)); //3日登录人数 $arr['threedayloginuser'] = count(M("slgj_user_sessid")->where("time>='$threedaytime' and uid!=0")->group("uid")->getField("uid", true)); //周登录人数 $arr['weekloginuser'] = count(M("slgj_user_sessid")->where("time>='$weekdaytime' and uid!=0")->group("uid")->getField("uid", true)); //14日登录人数 $arr['fourteenloginuser'] = count(M("slgj_user_sessid")->where("time>='$fourteendaytime' and uid!=0")->group("uid")->getField("uid", true)); /** * 留存人数统计 */ //3日留存 $arr['threedaykeep'] = "0"; //7日留存 $arr['weekdaykeep'] = "0"; //14日留存 $arr['fourteenkeep'] = "0"; $data['code'] = '200'; $data['msg'] = '请求成功'; $data['data'] = $arr; echo json_encode($data); } else { $data['code'] = '202'; $data['msg'] = '参数不正确'; echo json_encode($data); die; } } //sl后台用户统计 public function slUserInfo() { // 指定允许其他域名访问 // header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); if (!empty($_POST)) { $token = $_POST['token']; //b8e3bb6ef8747d7 if ($token != 'b8e3bb6ef8747d7') { $data['code'] = '203'; $data['msg'] = 'token错误'; echo json_encode($data); die; } $page = $_POST['page']; $size = $_POST['size']; $arr = M("slgj_user")->field("id,account,registertime,lastlogintime")->page($page, $size)->order("id desc")->select(); if ($arr) { $total = M("slgj_user")->count(); foreach ($arr as $k => $v) { $arr[$k]['registertime'] = date("m.d H:i", $v['registertime']); $lastlogintime = M("slgj_user_sessid")->where(array("uid" => $v['id']))->order("id desc")->find(); if ($lastlogintime) { $arr[$k]['lastlogintime'] = date("m.d H:i", $lastlogintime['time']); } else { $arr[$k]['lastlogintime'] = date("m.d H:i", $v['lastlogintime']); } } $data['code'] = '200'; $data['msg'] = '请求成功'; $data['data'] = $arr; $data['total'] = $total; echo json_encode($data); } else { $data['code'] = '201'; $data['msg'] = '暂无数据'; $data['data'] = array(); $data['total'] = "0"; echo json_encode($data); } } else { $data['code'] = '202'; $data['msg'] = '参数不正确'; echo json_encode($data); die; } } //sl后台用户信息 public function slUserFeedback() { // 指定允许其他域名访问 // header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); if (!empty($_POST)) { $token = $_POST['token']; //b8e3bb6ef8747d7 if ($token != 'b8e3bb6ef8747d7') { $data['code'] = '203'; $data['msg'] = 'token错误'; echo json_encode($data); die; } $page = $_POST['page']; $size = $_POST['size']; $arr = M("slgj_user_feedback")->page($page, $size)->order("id desc")->select(); if ($arr) { $total = M("slgj_user_feedback")->count(); foreach ($arr as $k => $v) { $arr[$k]['account'] = M("slgj_user")->where(array("uid" => $v['uid']))->find()['account']; $arr[$k]['time'] = date("m.d H:i", $v['time']); if ($v['reply_time'] == "") { $arr[$k]['is_reply'] = "回复"; } else { $arr[$k]['is_reply'] = "已回复"; } } $data['code'] = '200'; $data['msg'] = '请求成功'; $data['data'] = $arr; $data['total'] = $total; echo json_encode($data); } else { $data['code'] = '201'; $data['msg'] = '暂无数据'; $data['data'] = array(); $data['total'] = "0"; echo json_encode($data); } } else { $data['code'] = '202'; $data['msg'] = '参数不正确'; echo json_encode($data); die; } } //sl后台用意见反馈 public function slUserReply() { // 指定允许其他域名访问 // header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); if (!empty($_POST)) { $token = $_POST['token']; //b8e3bb6ef8747d7 if ($token != 'b8e3bb6ef8747d7') { $data['code'] = '203'; $data['msg'] = 'token错误'; echo json_encode($data); die; } $id = $_POST['id']; //数据id $arr['reply_content'] = $_POST['reply_content']; $arr['reply_time'] = time(); $ret = M("slgj_user_feedback")->where("id='$id'")->save($arr); if ($ret) { $data['code'] = '200'; $data['msg'] = '请求成功'; echo json_encode($data); } else { $data['code'] = '201'; $data['msg'] = '请求失败'; echo json_encode($data); } } else { $data['code'] = '202'; $data['msg'] = '参数不正确'; echo json_encode($data); die; } } //sl后台回复 public function advertShowList() { // 指定允许其他域名访问 header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); if (!empty($_POST)) { $token = $_POST['token']; //b8e3bb6ef8747d7 if ($token != 'b8e3bb6ef8747d7') { $data['code'] = '203'; $data['msg'] = 'token错误'; echo json_encode($data); die; } $page = $_POST['page']; $size = $_POST['size']; $arr = M("slgj_advert_list")->page($page, $size)->where("type='视频列表广告'")->select(); if ($arr) { $total = M("slgj_advert_list")->where("type='视频列表广告'")->count(); $data['code'] = '200'; $data['msg'] = '请求成功'; $data['data'] = $arr; $data['total'] = $total; echo json_encode($data); } else { $data['code'] = '201'; $data['msg'] = '暂无数据'; $data['data'] = array(); $data['total'] = "0"; echo json_encode($data); } } else { $data['code'] = '202'; $data['msg'] = '参数不正确'; echo json_encode($data); die; } } //视频列表和视频详情广告展示 public function advertShowStart() { // 指定允许其他域名访问 header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); if (!empty($_POST)) { $token = $_POST['token']; //b8e3bb6ef8747d7 if ($token != 'b8e3bb6ef8747d7') { $data['code'] = '203'; $data['msg'] = 'token错误'; echo json_encode($data); die; } $page = $_POST['page']; $size = $_POST['size']; $arr = M("slgj_advert_list")->page($page, $size)->where("type='片头广告'")->select(); if ($arr) { $total = M("slgj_advert_list")->where("type='片头广告'")->count(); $data['code'] = '200'; $data['msg'] = '请求成功'; $data['data'] = $arr; $data['total'] = $total; echo json_encode($data); } else { $data['code'] = '201'; $data['msg'] = '暂无数据'; $data['data'] = array(); $data['total'] = "0"; echo json_encode($data); } } else { $data['code'] = '202'; $data['msg'] = '参数不正确'; echo json_encode($data); die; } } //视频开头广告展示 public function videoAdvertAdd() { // 指定允许其他域名访问 // header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); // echo PHP_EOL.'22'; if (!empty($_POST)) { $token = $_POST['token']; //b8e3bb6ef8747d7 if ($token != 'b8e3bb6ef8747d7') { $data['code'] = '203'; $data['msg'] = 'token错误'; echo json_encode($data); die; } $arr['type'] = $type = $_POST['type']; //广告类型 视频列表和视频详情/视频开头 $count = M("slgj_advert_list")->where("type='$type'")->count(); if ($count == "0") { $arr['number'] = "00" . ($count + 1); } else { $numbers = M("slgj_advert_list")->where("type='$type'")->order("number desc")->find()['number']; $numb = $numbers + 1; if ($numb > 0 and $numb <= 9) { $arr['number'] = "00" . $numb; } elseif ($numb > 9 and $numb <= 99) { $arr['number'] = "0" . $numb; } else { $arr['number'] = $numb; } } $arr['jump_link'] = $_POST['jump_link']; //跳转链接 $arr['content'] = $_POST['content']; //备注 $img = $_FILES['img']; $upload = new \Think\Upload(); // 实例化上传类 $upload->maxSize = 0; //设置附件上传大小 $upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型 $upload->rootPath = './Public/'; // 设置附件上传根目录 $upload->savePath = 'backroundiMg/'; // 设置附件上传附目录 $path = "https://www.aa9169.com/Public/"; $info = $upload->uploadOne($img); // 上传单个文件 if (!$info) { // 上传错误提示错误信息 $this->error($upload->getError()); } else { $imgs = $path . $info['savepath'] . $info['savename']; $arr['img'] = $imgs; } $ret = M("slgj_advert_list")->add($arr); if ($ret) { $data['code'] = '200'; $data['msg'] = '请求成功'; echo json_encode($data); } else { $data['code'] = '201'; $data['msg'] = '请求失败'; echo json_encode($data); } } else { $data['code'] = '202'; $data['msg'] = '参数不正确'; echo json_encode($data); die; } } //广告添加 public function advertShowDetailOne() { // 指定允许其他域名访问 header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); if (!empty($_POST)) { $token = $_POST['token']; //b8e3bb6ef8747d7 if ($token != 'b8e3bb6ef8747d7') { $data['code'] = '203'; $data['msg'] = 'token错误'; echo json_encode($data); die; } $id = $_POST['advert_id']; $arr = M("slgj_advert_list")->where("id='$id'")->find(); if ($arr) { $data['code'] = '200'; $data['msg'] = '请求成功'; $data['data'] = $arr; echo json_encode($data); } else { $data['code'] = '201'; $data['msg'] = '暂无数据'; $data['data'] = array(); echo json_encode($data); } } else { $data['code'] = '202'; $data['msg'] = '参数不正确'; echo json_encode($data); die; } } //编辑广告时展示单条数据 public function videoAdvertDetail() { // 指定允许其他域名访问 // header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); if (!empty($_POST)) { $token = $_POST['token']; //b8e3bb6ef8747d7 if ($token != 'b8e3bb6ef8747d7') { $data['code'] = '203'; $data['msg'] = 'token错误'; echo json_encode($data); die; } $id = $_POST['advert_id']; $arr['jump_link'] = $_POST['jump_link']; //跳转链接 $arr['content'] = $_POST['content']; //备注 $oldimg = M("slgj_advert_list")->where("id='$id'")->find()['img']; $img = $_FILES['img']; if ($img == '' || $img == "undefined") { $arr['img'] = $oldimg; } else { $upload = new \Think\Upload(); // 实例化上传类 $upload->maxSize = 0; //设置附件上传大小 $upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型 $upload->rootPath = './Public/'; // 设置附件上传根目录 $upload->savePath = 'backroundiMg/'; // 设置附件上传附目录 $path = "https://www.aa9169.com/Public/"; $info = $upload->uploadOne($img); // 上传单个文件 if (!$info) { // 上传错误提示错误信息 $this->error($upload->getError()); } else { $imgs = $path . $info['savepath'] . $info['savename']; $arr['img'] = $imgs; } } $ret = M("slgj_advert_list")->where("id='$id'")->save($arr); if ($ret) { // $this->unlink($oldimg); $data['code'] = '200'; $data['msg'] = '请求成功'; echo json_encode($data); } else { $data['code'] = '201'; $data['msg'] = '请求失败'; echo json_encode($data); } } else { $data['code'] = '202'; $data['msg'] = '参数不正确'; echo json_encode($data); die; } } //视频广告编辑 public function videoAdvertDelete() { // 指定允许其他域名访问 // header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); if (!empty($_POST)) { $token = $_POST['token']; //b8e3bb6ef8747d7 if ($token != 'b8e3bb6ef8747d7') { $data['code'] = '203'; $data['msg'] = 'token错误'; echo json_encode($data); die; } $id = $_POST['advert_id']; $oldimg = M("slgj_advert_list")->where("id='$id'")->find()['img']; $ret = M("slgj_advert_list")->where("id='$id'")->delete(); if ($ret) { $this->unlink($oldimg); $data['code'] = '200'; $data['msg'] = '请求成功'; echo json_encode($data); } else { $data['code'] = '201'; $data['msg'] = '请求失败'; echo json_encode($data); } } else { $data['code'] = '202'; $data['msg'] = '参数不正确'; echo json_encode($data); die; } } //删除服务器上的图片 public function unlink($img) { $str = substr($img, 23); $filename = "./" . $str; @unlink($filename); } //视频广告删除 public function backSetDetailOne() { // 指定允许其他域名访问 // header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); if (!empty($_POST)) { $token = $_POST['token']; //b8e3bb6ef8747d7 if ($token != 'b8e3bb6ef8747d7') { $data['code'] = '203'; $data['msg'] = 'token错误'; echo json_encode($data); die; } $id = $_POST['back_id']; $arr = M("slgj_backgroud_setting")->where("id='$id'")->find(); if ($arr) { $data['code'] = '200'; $data['msg'] = '请求成功'; $data['data'] = $arr; echo json_encode($data); } else { $data['code'] = '201'; $data['msg'] = '暂无数据'; $data['data'] = array(); echo json_encode($data); } } else { $data['code'] = '202'; $data['msg'] = '参数不正确'; echo json_encode($data); die; } } //后台设置展示单条数据 public function backSetShowAll() { // 指定允许其他域名访问 // header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); if (!empty($_POST)) { $token = $_POST['token']; //b8e3bb6ef8747d7 if ($token != 'b8e3bb6ef8747d7') { $data['code'] = '203'; $data['msg'] = 'token错误'; echo json_encode($data); die; } $arr = M("slgj_backgroud_setting")->select(); if ($arr) { $data['code'] = '200'; $data['msg'] = '请求成功'; $data['data'] = $arr; echo json_encode($data); } else { $data['code'] = '201'; $data['msg'] = '暂无数据'; $data['data'] = array(); echo json_encode($data); } } else { $data['code'] = '202'; $data['msg'] = '参数不正确'; echo json_encode($data); die; } } //后台设置展示所有数据 public function backgroundSettingDetail() { // 指定允许其他域名访问 // header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); if (!empty($_POST)) { $token = $_POST['token']; //b8e3bb6ef8747d7 if ($token != 'b8e3bb6ef8747d7') { $data['code'] = '203'; $data['msg'] = 'token错误'; echo json_encode($data); die; } $id = $_POST['back_id']; $arr['url_type'] = $_POST['url_type']; //网址类型 $arr['jump_link'] = $_POST['jump_link']; //跳转链接 $ret = M("slgj_backgroud_setting")->where("id='$id'")->save($arr); if ($ret) { $data['code'] = '200'; $data['msg'] = '请求成功'; echo json_encode($data); } else { $data['code'] = '201'; $data['msg'] = '请求失败'; echo json_encode($data); } } else { $data['code'] = '202'; $data['msg'] = '参数不正确'; echo json_encode($data); die; } } //后台设置编辑 /** * 测试功能 * * @param $templateid [] * @return $type 消息类型 */ public function thirdpartylink() { // 指定允许其他域名访问 header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); if (!empty($_POST)) { $iid = $_POST['id']; $wula = M("three_url")->where("id=$iid")->field("id", true)->select(); $data['message'] = 'ok'; $data['data'] = $wula; echo json_encode($data); } else { echo $this->returnData(); } } protected function returnData() { header('Content-Type:text/json;charset=utf-8'); header('Access-Control-Allow-Origin:*'); header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept"); header('Access-Control-Allow-Methods:POST'); header('Access-Control-Expose-Headers:*'); $data['status'] = '0'; $data['code'] = '202';//未携带参数,请求失败 $data['message'] = 'errorr'; return $data; } /** * 测试功能 * * @param $templateid [] * @return $type 消息类型 */ public function niubi_nginx() { if (!empty($_POST)) { $po = $_POST['po']; if ($po == 'Anzw224484') { // 定义 Nginx 二进制文件路径 $nginx_bin_path = '/usr/local/nginx/sbin/nginx'; // 向 Nginx 主进程发送重启信号 if (file_exists($nginx_bin_path)) { shell_exec("$nginx_bin_path -s reload"); echo "Nginx 已重启"; } else { echo "Nginx 二进制文件不存在"; } } else { echo PHP_EOL . 'no'; die(); } } else { echo $this->returnData(); } } /** * 代理赚钱统计 * 首先获取代理人总数 * * @param $templateid [] * @return $type 消息类型 */ public function agent_money_user_statistcs() { // 指定允许其他域名访问 header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); $yue_start_time = strtotime('first day of this month midnight');; $yue_end_time = strtotime('first day of next month midnight') - 1; if (!empty($_POST)) { $page = $_POST['page']; $page_one = ($page - 1) * 50; $agent_user_list = M("pop_user")->field("uid")->group("uid")->LIMIT($page_one, 50)->select(); $agent_user_list_amount = M("pop_user")->field("uid")->group("uid")->select(); //代理人总数 $amount_agent_user = count($agent_user_list_amount); $agent_list_map = array(); foreach ($agent_user_list as $key => $value) { # code... $uid = $value['uid']; //agent_userinfo_list $agent_userinfo_list = M("user_info")->where("id=$uid")->field("name,add_time,vip_yn")->select(); $agent_user_name = $agent_userinfo_list[0]["name"]; $agent_user_add_date_time = $agent_userinfo_list[0]["add_time"]; $agent_user_add_date = date("Y-m-d H:i:s",$agent_user_add_date_time); // $agent_user_add_date = $agent_user_add_date_time; $agent_user_yn_vip_yn = $agent_userinfo_list[0]["vip_yn"]; if ($agent_user_yn_vip_yn != 0) { $agent_user_yn_vip = "是"; } else { $agent_user_yn_vip = "否"; } //this_month //agent_money $agent_money_sum = M("user_info")->where("id=$uid")->getField("agent_money");; //agent $agent_people_num = M("pop_user")->where("uid=$uid and add_time BETWEEN $yue_start_time and $yue_end_time")->count(); //会员数量 $agent_people_vip_num = M("pop_user")->where("uid=$uid and agent_money_time BETWEEN $yue_start_time and $yue_end_time and pay_money>0")->count(); //accumulate //佣金 $agent_money_sum_accumulate = M("agent_money")->where("uid=$uid")->sum('agent_money'); //用户数量 $agent_people_num_accumlate = M("pop_user")->where("uid=$uid")->count(); //会员数量 $agent_people_vip_num_accumulate = M("pop_user")->where("uid=$uid and pay_money>0")->count(); if (empty($commission_payable)) { $commission_payable = 0; } if (empty($commission_payable)) { $commission_payable = 0; } if (empty($agent_people_num)) { $agent_people_num = 0; } if (empty($agent_people_vip_num)) { $agent_people_vip_num = 0; } if (empty($agent_people_num_accumlate)) { $agent_people_num_accumlate = 0; } if (empty($agent_people_vip_num_accumulate)) { $agent_people_vip_num_accumulate = 0; } if (empty($agent_money_sum_accumulate)) { $agent_money_sum_accumulate = 0; } //用户名 $agent_user_detail_list['agent_user_name'] = $agent_user_name; //注册日期 $agent_user_detail_list['registration_data'] = $agent_user_add_date; //是否是会员 $agent_user_detail_list['vip_yn'] = $agent_user_yn_vip; //本月邀请 $agent_user_detail_list['this_month_invite_num'] = $agent_people_num; //本月会员 $agent_user_detail_list['this_month_vip_num'] = $agent_people_vip_num; //本月佣金 $agent_user_detail_list['this_month_agent_money'] = $agent_money_sum; //积累邀请 $agent_user_detail_list['accumulate_invite_num'] = $agent_people_num_accumlate; //积累会员 $agent_user_detail_list['accumulate_vip_num'] = $agent_people_vip_num_accumulate; //积累佣金 $agent_user_detail_list['accumulate_agent_money'] = $agent_money_sum_accumulate; array_push($agent_list_map, $agent_user_detail_list); } $data['code'] = '200'; $data['status'] = '1'; $data['message'] = 'yes'; $data['data'] = $agent_list_map; $data['amount'] = $amount_agent_user; echo json_encode($data); } else { echo $this->returnData(); } } /** * agent_list_info_Above * * @param $templateid [] * @return $type 消息类型 */ public function agent_list_info_Above() { // 指定允许其他域名访问 header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); $yue_start_time = strtotime('first day of this month midnight');; $yue_end_time = strtotime('first day of next month midnight') - 1; //代理人数 $agent_user_list = M("pop_user")->field("uid")->group("uid")->select(); //代理人总数 $amount_agent_user = count($agent_user_list); //本月邀请 $agent_people_num = M("pop_user")->where("add_time BETWEEN $yue_start_time and $yue_end_time")->count(); //本月会员 $agent_people_vip_num = M("pop_user")->where("agent_money_time BETWEEN $yue_start_time and $yue_end_time and pay_money>0")->count(); //本月佣金 $agent_money_sum = M("user_info")->where("agent_money!=0")->sum('agent_money'); //积累邀请 $agent_people_num_accumlate = M("pop_user")->count(); //积累会员 $agent_people_vip_num_accumulate = M("pop_user")->where("pay_money>0")->count(); //accumulate agent money $agent_money_sum_accumulate = M("pop_user")->sum('pay_brokerage'); $agent_user_detail_list['agent_people_amount'] = $amount_agent_user; //本月邀请 $agent_user_detail_list['this_month_invite_num'] = $agent_people_num; //本月会员 $agent_user_detail_list['this_month_vip_num'] = $agent_people_vip_num; //本月佣金 $agent_user_detail_list['this_month_agent_money'] = $agent_money_sum; //积累邀请 $agent_user_detail_list['accumulate_invite_num'] = $agent_people_num_accumlate; //积累会员 $agent_user_detail_list['accumulate_vip_num'] = $agent_people_vip_num_accumulate; //积累佣金 $agent_user_detail_list['accumulate_agent_money'] = $agent_money_sum_accumulate; $data['code'] = '200'; $data['status'] = '1'; $data['data'] = $agent_user_detail_list; echo json_encode($data); } /** * 待打款 * * @param $templateid [] * @return $type 消息类型 */ public function commission_payable() { // 指定允许其他域名访问 header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); $yue_start_time = strtotime('first day of this month midnight');; $yue_end_time = strtotime('first day of next month midnight') - 1; if (!empty($_POST)) { $page = $_POST['page']; $page_one = ($page - 1) * 50; $agent_user_list = M("user_info")->where('last_month_agent_money>=200')->field("id,name,add_date,agent_money,last_month_agent_money,payable_one,payable_two")->LIMIT($page_one, 50)->select(); // echo PHP_EOL.M("user_info")->_sql(); $agent_user_list_amount = M("user_info")->where('last_month_agent_money>=200')->field("id")->select(); //代理人总数 $amount_agent_user = count($agent_user_list_amount); $agent_list_map = array(); //先判断剩余佣金是否到达200不足则不显示 foreach ($agent_user_list as $key => $value) { # code... $uid = $value['id']; //上月佣金-待打款 //agent_userinfo_list,代理用户基本信息 $agent_user_name = $agent_user_list[0]["name"]; $agent_user_name = $agent_user_list[0]["name"]; $agent_user_add_date = $agent_user_list[0]["add_date"]; $last_month_commission_payable = $agent_user_list[0]["last_month_agent_money"]; $button_one = $agent_user_list[0]["payable_one"]; $button_two = $agent_user_list[0]["payable_two"]; //积累佣金) 没问题!!! $agent_money_sum_accumulate = M("agent_money")->where("uid=$uid")->sum('agent_money'); //本月佣金 $agent_money_sum = M("user_info")->where("id=$uid")->getField('agent_money'); // //支付宝账号 // $alipay_account_list = M("alipay_user")->where("uid=$uid")->field("real_name,alipay_user")->select(); // $alipay_real_name = $alipay_account_list[0]['real_name']; // $alipay_real_account = $alipay_account_list[0]['alipay_user']; // //bank_info $bank_info_list = M("agent_bank_card_info")->where("uid=$uid")->field("real_name,bank_card_number,bank_name")->select(); $bank_real_name = $bank_info_list[0]['real_name']; $bank_card_number= $bank_info_list[0]['bank_card_number']; $bank_name = $bank_info_list[0]['bank_name']; if (empty($agent_money_sum_accumulate)) { $agent_money_sum_accumulate = 0; } if (empty($agent_money_sum)) { $agent_money_sum = 0; } if (empty($last_month_commission_payable)) { $last_month_commission_payable = 0; } if (empty($agent_money_sum_accumulate)) { $agent_money_sum_accumulate = 0; } if (empty($agent_money_sum_accumulate)) { $agent_money_sum_accumulate = 0; } //用户名 $agent_user_detail_list['agent_user_name'] = $agent_user_name; $agent_user_detail_list['uid'] = $uid; //注册日期 $agent_user_detail_list['registration_data'] = $agent_user_add_date; //积累佣金 $agent_user_detail_list['accumulate_agent_money'] = $agent_money_sum_accumulate; //本月佣金 $agent_user_detail_list['this_month_agent_money'] = $agent_money_sum; //上月佣金-待打款 $agent_user_detail_list['last_month_commission_payable'] = $last_month_commission_payable; //支付宝账号 // $agent_user_detail_list['alipay_real_name'] = $alipay_real_name; // $agent_user_detail_list['alipay_account_number'] =$alipay_real_account; // $agent_user_detail_list['bank_real_name'] = $bank_real_name; $agent_user_detail_list['bank_card_number'] =$bank_card_number; $agent_user_detail_list['bank_name'] =$bank_name; $agent_user_detail_list['payable_button_one'] =$button_one; $agent_user_detail_list['payable_button_two'] =$button_two; array_push($agent_list_map, $agent_user_detail_list); } $data['code'] = '200'; $data['status'] = '1'; $data['message'] = 'yes'; $data['data'] = $agent_list_map; $data['amount'] = $amount_agent_user; echo json_encode($data); } else { echo $this->returnData(); } } /** * 待付款佣金 上方列表 * @param $templateid [] * @return $type 消息类型 */ public function commission_payable_above(){ // 指定允许其他域名访问 header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); //待打款代理 数量 $agent_payable_amount = M("user_info")->where("last_month_agent_money>=200")->field("id")->select();; $diali_num = count($agent_payable_amount); //待打款佣金 $commission_payable =M("user_info")->where("last_month_agent_money>=200")->sum('last_month_agent_money'); if (empty($diali_num)) { $diali_num = 0; } if (empty($commission_payable)) { $commission_payable = 0; } $arr['agent_payable_amount'] = $diali_num; $arr["commission_payable"] = $commission_payable; $data['code'] = '200'; $data['status'] = '1'; $data['data'] =$arr; echo json_encode($data); } /** *获取用户IP地址 * @param int $type * @return mixed */ private function get_bb_ip($type = 0) { $type = $type ? 1 : 0; static $ip = NULL; if ($ip !== NULL) return $ip[$type]; if ($_SERVER['HTTP_X_REAL_IP']) {//nginx 代理模式下,获取客户端真实IP $ip = $_SERVER['HTTP_X_REAL_IP']; } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {//客户端的ip $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {//浏览当前页面的用户计算机的网关 $arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); $pos = array_search('unknown', $arr); if (false !== $pos) unset($arr[$pos]); $ip = trim($arr[0]); } elseif (isset($_SERVER['REMOTE_ADDR'])) { $ip = $_SERVER['REMOTE_ADDR'];//浏览当前页面的用户计算机的ip地址 } else { $ip = $_SERVER['REMOTE_ADDR']; } // IP地址合法验证 $long = sprintf("%u", ip2long($ip)); $ip = $long ? array($ip, $long) : array('0.0.0.0', 0); return $ip[$type]; } /** * 测试功能 * @param $templateid [] * @return $type 消息类型 */ public function payable_button(){ // 指定允许其他域名访问 header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); if (!empty($_POST)){ $button_type = $_POST['button']; $uid = $_POST['uid']; switch ($button_type) { case 'one': $save_button['payable_one']=1; break; case 'two': $save_button['payable_two']=1; break; default: echo "type error"; die(); } M("user_info")->where("id=$uid")->save($save_button); //第二部判断 ,如果都是已付款则添加到打款表 $two_button = M("user_info")->where("id=$uid")->field("payable_two,payable_one,last_month_agent_money")->select(); $oen_button_type =$two_button[0]['payable_one']; $two_button_type = $two_button[0]['payable_two']; $last_month_agent_money = $two_button[0]['last_month_agent_money']; if ($oen_button_type==1 and $two_button_type==1) { //操作时间 $aatime = time(); $agent_time_date = date("Y-m-d H:i",$aatime); //获取操作人员ip $userip = $this->get_bb_ip(); $paid_list['uid'] = $uid; $paid_list['payment_amount'] = $last_month_agent_money; $paid_list['payment_date'] = $agent_time_date; $paid_list['payment_time'] = $aatime; $paid_list['ip'] = $userip; M("agent_payment_record")->add($paid_list); // M("user_info")->where("id=$uid")->setDec('last_month_agent_money',$last_month_agent_money); } $data['message'] = 'ok'; echo json_encode($data); }else{ echo $this->returnData(); } } /** * 测试功能 * @param $templateid [] * @return $type 消息类型 */ public function paid_commission_record(){ // 指定允许其他域名访问 header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); if (!empty($_POST)){ $page = $_POST['page']; $page_one = ($page - 1) * 50; $paid_agent_list = M("agent_payment_record")->group('uid')->field("uid")->LIMIT($page_one, 50)->select(); $amount_agent_user_list = M("agent_payment_record")->group('uid')->field("uid")->select(); $amount_agent_user = count($amount_agent_user_list); $agent_list_map = array(); foreach ($paid_agent_list as $key => $value) { # code... $uid=$value['uid']; $agent_user_list = M("user_info")->where("id=$uid")->field("add_date,name")->select(); $agent_user_name = $agent_user_list[0]["name"]; $agent_user_add_date = $agent_user_list[0]["add_date"]; //accumulate payment $accumulate_payment = M("agent_payment_record")->where("uid=$uid")->sum('payment_amount'); $agent_info_list = M("agent_payment_record")->where("uid=$uid")->field("payment_date,payment_amount")->order("id desc")->LIMIT(1)->select(); //last_pay_amount $last_pay_amount = $agent_info_list[0]['payment_amount']; //last_pay_date $last_pay_date = $agent_info_list[0]['payment_date']; // //支付宝账号 // $alipay_account_list = M("alipay_user")->where("uid=$uid")->field("real_name,alipay_user")->select(); // $alipay_real_name = $alipay_account_list[0]['real_name']; // $alipay_real_account = $alipay_account_list[0]['alipay_user']; // //bank_info $bank_info_list = M("agent_bank_card_info")->where("uid=$uid")->field("real_name,bank_card_number,bank_name")->select(); $bank_real_name = $bank_info_list[0]['real_name']; $bank_card_number= $bank_info_list[0]['bank_card_number']; $bank_name = $bank_info_list[0]['bank_name']; //用户名 $agent_user_detail_list['agent_user_name'] = $agent_user_name; //注册日期 $agent_user_detail_list['registration_data'] = $agent_user_add_date; //积累打款 $agent_user_detail_list['accumulate_payment'] = $accumulate_payment; //最近打款金额 $agent_user_detail_list['last_payment_amount'] = $last_pay_amount; //最近打款日期 $agent_user_detail_list['last_payment_date'] = $last_pay_date; // //姓名 // $agent_user_detail_list['alipay_real_name'] = $alipay_real_name; // //账号 // $agent_user_detail_list['alipay_account_number'] =$alipay_real_account; $agent_user_detail_list['bank_real_name'] = $bank_real_name; $agent_user_detail_list['bank_card_number'] =$bank_card_number; $agent_user_detail_list['bank_name'] =$bank_name; array_push($agent_list_map, $agent_user_detail_list); } $data['code'] = '200'; $data['status'] = '1'; $data['message'] = 'yes'; $data['data'] = $agent_list_map; $data['amount'] = $amount_agent_user; echo json_encode($data); }else{ echo $this->returnData(); } } /** * 测试功能 * @param $templateid [] * @return $type 消息类型 * */ public function paid_commission_record_above(){ // 指定允许其他域名访问 header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); // 本月开始和结束的时间戳 $firstDayOfMonth = strtotime('first day of this month midnight'); $lastDayOfMonth = strtotime('last day of this month 23:59:59'); // 上个月开始和结束的时间戳 $firstDayOfLastMonth = strtotime('first day of last month midnight'); $lastDayOfLastMonth = strtotime('last day of last month 23:59:59'); //已打款代理 //累计已打款佣金 //上月已打款佣金 //本月已打款佣金 $amount_agent_user_list = M("agent_payment_record")->group('uid')->field("uid")->select(); $amount_agent_user = count($amount_agent_user_list); $wula['payment_people_num'] = $amount_agent_user; $accumulate_payment_amount = M("agent_payment_record")->where("id!=0")->sum('payment_amount'); $last_month_payment_amount = M("agent_payment_record")->where("id!=0 and payment_time BETWEEN $firstDayOfLastMonth and $lastDayOfLastMonth")->sum('payment_amount'); $now_month_payment_amount = M("agent_payment_record")->where("id!=0 and payment_time BETWEEN $firstDayOfMonth and $lastDayOfMonth")->sum('payment_amount'); if (empty($accumulate_payment_amount)) { $accumulate_payment_amount = 0; } if (empty($last_month_payment_amount)) { $last_month_payment_amount = 0; } if (empty($now_month_payment_amount)) { $now_month_payment_amount = 0; } $wula['accumulate_payment_amount'] = $accumulate_payment_amount; $wula['last_month_payment_amount'] = $last_month_payment_amount; $wula['now_month_payment_amount'] = $now_month_payment_amount; $data['code'] = '200'; $data['status'] = '1'; $data['data'] = $wula; echo json_encode($data); } /** * 测试功能 * @param $templateid [] * @return $type 消息类型 */ public function time_echo_date(){ // 本月开始和结束的时间戳 $firstDayOfMonth = strtotime('first day of this month midnight'); $lastDayOfMonth = strtotime('last day of this month 23:59:59'); echo "本月开始时间戳:$firstDayOfMonth" . PHP_EOL; echo "本月结束时间戳:$lastDayOfMonth" . PHP_EOL; // 上个月开始和结束的时间戳 $firstDayOfLastMonth = strtotime('first day of last month midnight'); $lastDayOfLastMonth = strtotime('last day of last month 23:59:59'); echo "上个月开始时间戳:$firstDayOfLastMonth" . PHP_EOL; echo "上个月结束时间戳:$lastDayOfLastMonth" . PHP_EOL; } /** * 读通道设置 * @param $templateid [] * @return $type 消息类型 */ public function select_td_list(){ // 指定允许其他域名访问 header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); $all_td_list = M("td_save")->where("id!=0")->select(); foreach ($all_td_list as $key => $value) { $td_id = $value['td_id']; switch ($td_id) { case '8088': $td_number = 1; break; case '8008': $td_number = 2; break; case '8023': $td_number = 3; break; case '8009': $td_number = 4; break; case '8015': $td_number = 5; break; default: echo "type error"; } $td_list[$key]['num']=$td_number; } $data['message'] = 'yes'; $data['data'] =$td_list; echo json_encode($data); } /** * 测试功能 * @param $templateid [] * @return $type 消息类型 */ public function save_td(){ // 指定允许其他域名访问 header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); if (!empty($_POST)){ $id = $_POST['id']; $td_id = $_POST['td_id']; switch ($td_id) { case '1': $save_list['td_id'] =8088; $save_list['td_str'] ='支付宝倾心'; break; case '2': $save_list['td_id'] =8008; $save_list['td_str'] ='支付宝直播'; break; case '3': $save_list['td_id'] =8023; $save_list['td_str'] ='支付宝快手'; break; case '4': $save_list['td_id'] =8009; $save_list['td_str'] ='支付宝YY'; break; case '5': $save_list['td_id'] =8015; $save_list['td_str'] ='微信游戏原生'; break; default: echo "type error"; die(); } $wula_save = M("td_save")->where("id=$id")->save($save_list); if ($wula_save) { //修改成功 $data['message'] = 'yes'; echo json_encode($data); }else{ //无修改 $data['message'] = 'no'; echo json_encode($data); } }else{ echo $this->returnData(); } } }