12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610 |
- <?php
-
- namespace Admin\Controller;
-
- use Think\Controller;
-
- class AdminbackController extends Controller
- {
-
- /**
- * 后台收入统计 水友
- *
- * @param $templateid []
- * @return $type 消息类型
- */
- public function shouye_gailan()
- {
- ini_set('memory_limit', '256M');
- 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:*');
- $fk_liaotian_biao = M("user_info");
-
- $jinri_start_time = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
- $jinri_end_time = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')) - 1;
-
- $zuo_start_time = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'));
- $zuo_end_time = mktime(0, 0, 0, date('m'), date('d'), date('Y')) - 1;
-
- $san_start_time = strtotime(date("Y-m-d", strtotime("-3 day")) . "00:00:00");
- $san_end_time = time();
-
- $zhou_start_time = strtotime(date("Y-m-d", strtotime("-1 week")) . "00:00:00");
- $zhou_end_time = time();
-
- $yue_start_time = strtotime(date("Y-m-d", strtotime("-1 month")) . "00:00:00");
- $yue_end_time = time();
-
- $jl_start_time = '0';
- $jl_end_time = '9999999999999999999999';
-
- //注册
- $zc_jilei = 0;
- $zc_jinri = 0;
- $zc_zuori = 0;
- $zc_sanri = 0;
- $zc_yizhou = 0;
- $zc_yiyue = 0;
- //付费人数
- $ffp_jilei = 0;
- $ffp_jinri = 0;
- $ffp_zuori = 0;
- $ffp_sanri = 0;
- $ffp_yizhou = 0;
- $ffp_yiyue = 0;
- //付费金额
- $ffm_jilei = 0;
- $ffm_jinri = 0;
- $ffm_zuori = 0;
- $ffm_sanri = 0;
- $ffm_yizhou = 0;
- $ffm_yiyue = 0;
-
-
- $zhuce_list = M("user_info")->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();
- }
- }
-
-
-
-
-
- }
|