AdminbackController.class.php 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610
  1. <?php
  2. namespace Admin\Controller;
  3. use Think\Controller;
  4. class AdminbackController extends Controller
  5. {
  6. /**
  7. * 后台收入统计 水友
  8. *
  9. * @param $templateid []
  10. * @return $type 消息类型
  11. */
  12. public function shouye_gailan()
  13. {
  14. ini_set('memory_limit', '256M');
  15. header('Content-Type:text/json;charset=utf-8');
  16. header('Access-Control-Allow-Origin:*');
  17. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  18. header('Access-Control-Allow-Methods:POST');
  19. header('Access-Control-Expose-Headers:*');
  20. $fk_liaotian_biao = M("user_info");
  21. $jinri_start_time = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
  22. $jinri_end_time = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')) - 1;
  23. $zuo_start_time = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'));
  24. $zuo_end_time = mktime(0, 0, 0, date('m'), date('d'), date('Y')) - 1;
  25. $san_start_time = strtotime(date("Y-m-d", strtotime("-3 day")) . "00:00:00");
  26. $san_end_time = time();
  27. $zhou_start_time = strtotime(date("Y-m-d", strtotime("-1 week")) . "00:00:00");
  28. $zhou_end_time = time();
  29. $yue_start_time = strtotime(date("Y-m-d", strtotime("-1 month")) . "00:00:00");
  30. $yue_end_time = time();
  31. $jl_start_time = '0';
  32. $jl_end_time = '9999999999999999999999';
  33. //注册
  34. $zc_jilei = 0;
  35. $zc_jinri = 0;
  36. $zc_zuori = 0;
  37. $zc_sanri = 0;
  38. $zc_yizhou = 0;
  39. $zc_yiyue = 0;
  40. //付费人数
  41. $ffp_jilei = 0;
  42. $ffp_jinri = 0;
  43. $ffp_zuori = 0;
  44. $ffp_sanri = 0;
  45. $ffp_yizhou = 0;
  46. $ffp_yiyue = 0;
  47. //付费金额
  48. $ffm_jilei = 0;
  49. $ffm_jinri = 0;
  50. $ffm_zuori = 0;
  51. $ffm_sanri = 0;
  52. $ffm_yizhou = 0;
  53. $ffm_yiyue = 0;
  54. $zhuce_list = M("user_info")->field("add_time")->select();
  55. foreach ($zhuce_list as $key => $value) {
  56. # code...
  57. $user_zhuce_time = $value['add_time'];
  58. if ($jinri_end_time > $user_zhuce_time and $user_zhuce_time > $jinri_start_time) {
  59. $zc_jilei++;
  60. $zc_jinri++;
  61. $zc_sanri++;
  62. $zc_yizhou++;
  63. $zc_yiyue++;
  64. } elseif ($zuo_end_time > $user_zhuce_time and $user_zhuce_time > $zuo_start_time) {
  65. $zc_jilei++;
  66. $zc_zuori++;
  67. $zc_yiyue++;
  68. } elseif ($san_end_time > $user_zhuce_time and $user_zhuce_time > $san_start_time) {
  69. $zc_jilei++;
  70. $zc_sanri++;
  71. $zc_yiyue++;
  72. } elseif ($zhou_end_time > $user_zhuce_time and $user_zhuce_time > $zhou_start_time) {
  73. $zc_jilei++;
  74. $zc_yizhou++;
  75. $zc_yiyue++;
  76. } elseif ($yue_end_time > $user_zhuce_time and $user_zhuce_time > $yue_start_time) {
  77. $zc_jilei++;
  78. $zc_yiyue++;
  79. } elseif ($user_zhuce_time < $yue_start_time) {
  80. $zc_jilei++;
  81. }
  82. }
  83. //付费人数 和钱数
  84. $user_list = M("pay_test")->field("uid,pay_time,amount")->where("order_type='已支付'")->select();
  85. foreach ($user_list as $key1 => $value1) {
  86. $user_ff_time = $value1['pay_time'];
  87. $fufei_jine = $value1['amount'];
  88. if ($jinri_end_time > $user_ff_time and $user_ff_time > $jinri_start_time) {
  89. $ffm_jilei += $fufei_jine;
  90. $ffm_jinri += $fufei_jine;
  91. $ffm_sanri += $fufei_jine;
  92. $ffm_yizhou += $fufei_jine;
  93. $ffm_yiyue += $fufei_jine;
  94. } elseif ($zuo_end_time > $user_ff_time and $user_ff_time > $zuo_start_time) {
  95. $ffm_yiyue += $fufei_jine;
  96. $ffm_jilei += $fufei_jine;
  97. $ffm_zuori += $fufei_jine;
  98. $ffm_yizhou += $fufei_jine;
  99. } elseif ($san_end_time > $user_ff_time and $user_ff_time > $san_start_time) {
  100. $ffm_yiyue += $fufei_jine;
  101. $ffm_jilei += $fufei_jine;
  102. $ffm_sanri += $fufei_jine;
  103. $ffm_yizhou += $fufei_jine;
  104. } elseif ($zhou_end_time > $user_ff_time and $user_ff_time > $zhou_start_time) {
  105. $ffm_yiyue += $fufei_jine;
  106. $ffm_jilei += $fufei_jine;
  107. $ffm_yizhou += $fufei_jine;
  108. } elseif ($yue_end_time > $user_ff_time and $user_ff_time > $yue_start_time) {
  109. $ffm_jilei += $fufei_jine;
  110. $ffm_yiyue += $fufei_jine;
  111. } else {
  112. //} else ($user_zhuce_time < $yue_start_time) {
  113. $ffm_jilei += $fufei_jine;
  114. }
  115. }
  116. //今日
  117. $todaytime = strtotime(date("Y-m-d", time()) . "00:00:00");
  118. //三日
  119. $threedaytime = strtotime(date("Y-m-d", strtotime("-3 day")) . "00:00:00");
  120. //周
  121. $weekdaytime = strtotime(date("Y-m-d", strtotime("-1 week")) . "00:00:00");
  122. //14日
  123. $fourteendaytime = strtotime(date("Y-m-d", strtotime("-14 day")) . "00:00:00");
  124. $yueday_time = strtotime(date("Y-m-d", strtotime("-30 day")) . "00:00:00");
  125. $renshu_jin = M("pay_test")->where("pay_time>='$todaytime'")->field("uid")->group("uid")->select();
  126. $renshu_zuo = M("pay_test")->where("pay_time>='$zuo_start_time' and pay_time<='$zuo_end_time'")->field("uid")->group("uid")->select();
  127. $renshu_san = M("pay_test")->where("pay_time>='$threedaytime'")->field("uid")->group("uid")->select();;
  128. $renshu_zhou = M("pay_test")->where("pay_time>='$weekdaytime'")->field("uid")->group("uid")->select();
  129. $renshu_yue = M("pay_test")->where("pay_time>='$yueday_time'")->field("uid")->group("uid")->select();
  130. $renshu_jilei = M("pay_test")->field("uid")->group("uid")->select();
  131. $huoyue_jin = M("huoyue_list")->where("time>='$jinri_start_time' and time<='$jinri_end_time'")->field("uid")->group("uid")->select();
  132. $huoyue_zuo = M("huoyue_list")->where("time>='$zuo_start_time' and time<='$zuo_end_time'")->field("uid")->group("uid")->select();
  133. $huoyue_san = M("huoyue_list")->where("time>='$san_start_time' and time<='$san_end_time' ")->field("uid")->group("uid")->select();;
  134. $huoyue_zhou = M("huoyue_list")->where("time>='$zhou_start_time' and time<='$zhou_end_time'")->field("uid")->group("uid")->select();
  135. $huoyue_yue = M("huoyue_list")->where("time>='$yue_start_time' and time<='$yue_end_time'")->field("uid")->group("uid")->select();
  136. $huoyue_jilei = M("huoyue_list")->field("uid")->group("uid")->select();
  137. $yizhoulist['jinri'] = $zc_jinri;
  138. $yizhoulist['zuori'] = $zc_zuori;
  139. $yizhoulist['sanri'] = $zc_sanri;
  140. $yizhoulist['zhou'] = $zc_yizhou;
  141. $yizhoulist['yue'] = $zc_yiyue;
  142. $yizhoulist['jilei'] = $zc_jilei;
  143. $fufei_num['jinri_num'] = count($renshu_jin);
  144. $fufei_num['zuori_num'] = count($renshu_zuo);
  145. $fufei_num['sanri_num'] = count($renshu_san);
  146. $fufei_num['zhou_num'] = count($renshu_zhou);
  147. $fufei_num['yue_num'] = count($renshu_yue);
  148. $fufei_num['jilei_num'] = count($renshu_jilei);
  149. $fufei_number['jinri_people'] = $ffm_jinri;
  150. $fufei_number['zuori_people'] = $ffm_zuori;
  151. $fufei_number['sanri_people'] = $ffm_sanri;
  152. $fufei_number['zhou_people'] = $ffm_yizhou;
  153. $fufei_number['yue_people'] = $ffm_yiyue;
  154. $fufei_number['jilei_people'] = $ffm_jilei;
  155. $huoyue_num['jinriAAA_num'] = count($huoyue_jin);
  156. $huoyue_num['zuoriAAA_num'] = count($huoyue_zuo);
  157. $huoyue_num['sanriAAA_num'] = count($huoyue_san);
  158. $huoyue_num['zhouAAA_num'] = count($huoyue_zhou);
  159. $huoyue_num['yueAAA_num'] = count($huoyue_yue);
  160. $huoyue_num['jileiAAA_num'] = count($huoyue_jilei);
  161. $shuzu_list = array($yizhoulist, $fufei_number, $fufei_num, $huoyue_num);
  162. $data['code'] = '200';
  163. $data['status'] = '1';
  164. $data['message'] = '';
  165. $data['data'] = $shuzu_list;
  166. echo json_encode($data);
  167. }
  168. public function slUserStatistics()
  169. {
  170. // 指定允许其他域名访问
  171. // header('Access-Control-Allow-Origin:*');
  172. // 响应类型
  173. header('Access-Control-Allow-Methods:POST');
  174. // 响应头设置
  175. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  176. if (!empty($_POST)) {
  177. $token = $_POST['token']; //b8e3bb6ef8747d7
  178. if ($token != 'b8e3bb6ef8747d7') {
  179. $data['code'] = '203';
  180. $data['msg'] = 'token错误';
  181. echo json_encode($data);
  182. die;
  183. }
  184. //今日
  185. $todaytime = strtotime(date("Y-m-d", time()) . "00:00:00");
  186. //三日
  187. $threedaytime = strtotime(date("Y-m-d", strtotime("-3 day")) . "00:00:00");
  188. //周
  189. $weekdaytime = strtotime(date("Y-m-d", strtotime("-1 week")) . "00:00:00");
  190. //14日
  191. $fourteendaytime = strtotime(date("Y-m-d", strtotime("-14 day")) . "00:00:00");
  192. /**
  193. * 注册人数统计
  194. */
  195. //累计新增注册
  196. $arr['totaluser'] = M("slgj_user")->count();
  197. //今日新增注册
  198. $arr['todayuser'] = M("slgj_user")->where("registertime>='$todaytime'")->count();
  199. //3日新增注册
  200. $arr['threedayuser'] = M("slgj_user")->where("registertime>='$threedaytime'")->count();
  201. //周新增注册
  202. $arr['weekuser'] = M("slgj_user")->where("registertime>='$weekdaytime'")->count();
  203. //14日新增注册
  204. $arr['fourteenuser'] = M("slgj_user")->where("registertime>='$fourteendaytime'")->count();
  205. /**
  206. * 登录人数统计
  207. */
  208. //今日登录人数
  209. $arr['todayloginuser'] = count(M("slgj_user_sessid")->where("time>='$todaytime' and uid!=0")->group("uid")->getField("uid", true));
  210. //3日登录人数
  211. $arr['threedayloginuser'] = count(M("slgj_user_sessid")->where("time>='$threedaytime' and uid!=0")->group("uid")->getField("uid", true));
  212. //周登录人数
  213. $arr['weekloginuser'] = count(M("slgj_user_sessid")->where("time>='$weekdaytime' and uid!=0")->group("uid")->getField("uid", true));
  214. //14日登录人数
  215. $arr['fourteenloginuser'] = count(M("slgj_user_sessid")->where("time>='$fourteendaytime' and uid!=0")->group("uid")->getField("uid", true));
  216. /**
  217. * 留存人数统计
  218. */
  219. //3日留存
  220. $arr['threedaykeep'] = "0";
  221. //7日留存
  222. $arr['weekdaykeep'] = "0";
  223. //14日留存
  224. $arr['fourteenkeep'] = "0";
  225. $data['code'] = '200';
  226. $data['msg'] = '请求成功';
  227. $data['data'] = $arr;
  228. echo json_encode($data);
  229. } else {
  230. $data['code'] = '202';
  231. $data['msg'] = '参数不正确';
  232. echo json_encode($data);
  233. die;
  234. }
  235. }
  236. //sl后台用户统计
  237. public function slUserInfo()
  238. {
  239. // 指定允许其他域名访问
  240. // header('Access-Control-Allow-Origin:*');
  241. // 响应类型
  242. header('Access-Control-Allow-Methods:POST');
  243. // 响应头设置
  244. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  245. if (!empty($_POST)) {
  246. $token = $_POST['token']; //b8e3bb6ef8747d7
  247. if ($token != 'b8e3bb6ef8747d7') {
  248. $data['code'] = '203';
  249. $data['msg'] = 'token错误';
  250. echo json_encode($data);
  251. die;
  252. }
  253. $page = $_POST['page'];
  254. $size = $_POST['size'];
  255. $arr = M("slgj_user")->field("id,account,registertime,lastlogintime")->page($page, $size)->order("id desc")->select();
  256. if ($arr) {
  257. $total = M("slgj_user")->count();
  258. foreach ($arr as $k => $v) {
  259. $arr[$k]['registertime'] = date("m.d H:i", $v['registertime']);
  260. $lastlogintime = M("slgj_user_sessid")->where(array("uid" => $v['id']))->order("id desc")->find();
  261. if ($lastlogintime) {
  262. $arr[$k]['lastlogintime'] = date("m.d H:i", $lastlogintime['time']);
  263. } else {
  264. $arr[$k]['lastlogintime'] = date("m.d H:i", $v['lastlogintime']);
  265. }
  266. }
  267. $data['code'] = '200';
  268. $data['msg'] = '请求成功';
  269. $data['data'] = $arr;
  270. $data['total'] = $total;
  271. echo json_encode($data);
  272. } else {
  273. $data['code'] = '201';
  274. $data['msg'] = '暂无数据';
  275. $data['data'] = array();
  276. $data['total'] = "0";
  277. echo json_encode($data);
  278. }
  279. } else {
  280. $data['code'] = '202';
  281. $data['msg'] = '参数不正确';
  282. echo json_encode($data);
  283. die;
  284. }
  285. }
  286. //sl后台用户信息
  287. public function slUserFeedback()
  288. {
  289. // 指定允许其他域名访问
  290. // header('Access-Control-Allow-Origin:*');
  291. // 响应类型
  292. header('Access-Control-Allow-Methods:POST');
  293. // 响应头设置
  294. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  295. if (!empty($_POST)) {
  296. $token = $_POST['token']; //b8e3bb6ef8747d7
  297. if ($token != 'b8e3bb6ef8747d7') {
  298. $data['code'] = '203';
  299. $data['msg'] = 'token错误';
  300. echo json_encode($data);
  301. die;
  302. }
  303. $page = $_POST['page'];
  304. $size = $_POST['size'];
  305. $arr = M("slgj_user_feedback")->page($page, $size)->order("id desc")->select();
  306. if ($arr) {
  307. $total = M("slgj_user_feedback")->count();
  308. foreach ($arr as $k => $v) {
  309. $arr[$k]['account'] = M("slgj_user")->where(array("uid" => $v['uid']))->find()['account'];
  310. $arr[$k]['time'] = date("m.d H:i", $v['time']);
  311. if ($v['reply_time'] == "") {
  312. $arr[$k]['is_reply'] = "回复";
  313. } else {
  314. $arr[$k]['is_reply'] = "已回复";
  315. }
  316. }
  317. $data['code'] = '200';
  318. $data['msg'] = '请求成功';
  319. $data['data'] = $arr;
  320. $data['total'] = $total;
  321. echo json_encode($data);
  322. } else {
  323. $data['code'] = '201';
  324. $data['msg'] = '暂无数据';
  325. $data['data'] = array();
  326. $data['total'] = "0";
  327. echo json_encode($data);
  328. }
  329. } else {
  330. $data['code'] = '202';
  331. $data['msg'] = '参数不正确';
  332. echo json_encode($data);
  333. die;
  334. }
  335. }
  336. //sl后台用意见反馈
  337. public function slUserReply()
  338. {
  339. // 指定允许其他域名访问
  340. // header('Access-Control-Allow-Origin:*');
  341. // 响应类型
  342. header('Access-Control-Allow-Methods:POST');
  343. // 响应头设置
  344. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  345. if (!empty($_POST)) {
  346. $token = $_POST['token']; //b8e3bb6ef8747d7
  347. if ($token != 'b8e3bb6ef8747d7') {
  348. $data['code'] = '203';
  349. $data['msg'] = 'token错误';
  350. echo json_encode($data);
  351. die;
  352. }
  353. $id = $_POST['id']; //数据id
  354. $arr['reply_content'] = $_POST['reply_content'];
  355. $arr['reply_time'] = time();
  356. $ret = M("slgj_user_feedback")->where("id='$id'")->save($arr);
  357. if ($ret) {
  358. $data['code'] = '200';
  359. $data['msg'] = '请求成功';
  360. echo json_encode($data);
  361. } else {
  362. $data['code'] = '201';
  363. $data['msg'] = '请求失败';
  364. echo json_encode($data);
  365. }
  366. } else {
  367. $data['code'] = '202';
  368. $data['msg'] = '参数不正确';
  369. echo json_encode($data);
  370. die;
  371. }
  372. }
  373. //sl后台回复
  374. public function advertShowList()
  375. {
  376. // 指定允许其他域名访问
  377. header('Access-Control-Allow-Origin:*');
  378. // 响应类型
  379. header('Access-Control-Allow-Methods:POST');
  380. // 响应头设置
  381. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  382. if (!empty($_POST)) {
  383. $token = $_POST['token']; //b8e3bb6ef8747d7
  384. if ($token != 'b8e3bb6ef8747d7') {
  385. $data['code'] = '203';
  386. $data['msg'] = 'token错误';
  387. echo json_encode($data);
  388. die;
  389. }
  390. $page = $_POST['page'];
  391. $size = $_POST['size'];
  392. $arr = M("slgj_advert_list")->page($page, $size)->where("type='视频列表广告'")->select();
  393. if ($arr) {
  394. $total = M("slgj_advert_list")->where("type='视频列表广告'")->count();
  395. $data['code'] = '200';
  396. $data['msg'] = '请求成功';
  397. $data['data'] = $arr;
  398. $data['total'] = $total;
  399. echo json_encode($data);
  400. } else {
  401. $data['code'] = '201';
  402. $data['msg'] = '暂无数据';
  403. $data['data'] = array();
  404. $data['total'] = "0";
  405. echo json_encode($data);
  406. }
  407. } else {
  408. $data['code'] = '202';
  409. $data['msg'] = '参数不正确';
  410. echo json_encode($data);
  411. die;
  412. }
  413. }
  414. //视频列表和视频详情广告展示
  415. public function advertShowStart()
  416. {
  417. // 指定允许其他域名访问
  418. header('Access-Control-Allow-Origin:*');
  419. // 响应类型
  420. header('Access-Control-Allow-Methods:POST');
  421. // 响应头设置
  422. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  423. if (!empty($_POST)) {
  424. $token = $_POST['token']; //b8e3bb6ef8747d7
  425. if ($token != 'b8e3bb6ef8747d7') {
  426. $data['code'] = '203';
  427. $data['msg'] = 'token错误';
  428. echo json_encode($data);
  429. die;
  430. }
  431. $page = $_POST['page'];
  432. $size = $_POST['size'];
  433. $arr = M("slgj_advert_list")->page($page, $size)->where("type='片头广告'")->select();
  434. if ($arr) {
  435. $total = M("slgj_advert_list")->where("type='片头广告'")->count();
  436. $data['code'] = '200';
  437. $data['msg'] = '请求成功';
  438. $data['data'] = $arr;
  439. $data['total'] = $total;
  440. echo json_encode($data);
  441. } else {
  442. $data['code'] = '201';
  443. $data['msg'] = '暂无数据';
  444. $data['data'] = array();
  445. $data['total'] = "0";
  446. echo json_encode($data);
  447. }
  448. } else {
  449. $data['code'] = '202';
  450. $data['msg'] = '参数不正确';
  451. echo json_encode($data);
  452. die;
  453. }
  454. }
  455. //视频开头广告展示
  456. public function videoAdvertAdd()
  457. {
  458. // 指定允许其他域名访问
  459. // header('Access-Control-Allow-Origin:*');
  460. // 响应类型
  461. header('Access-Control-Allow-Methods:POST');
  462. // 响应头设置
  463. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  464. // echo PHP_EOL.'22';
  465. if (!empty($_POST)) {
  466. $token = $_POST['token']; //b8e3bb6ef8747d7
  467. if ($token != 'b8e3bb6ef8747d7') {
  468. $data['code'] = '203';
  469. $data['msg'] = 'token错误';
  470. echo json_encode($data);
  471. die;
  472. }
  473. $arr['type'] = $type = $_POST['type']; //广告类型 视频列表和视频详情/视频开头
  474. $count = M("slgj_advert_list")->where("type='$type'")->count();
  475. if ($count == "0") {
  476. $arr['number'] = "00" . ($count + 1);
  477. } else {
  478. $numbers = M("slgj_advert_list")->where("type='$type'")->order("number desc")->find()['number'];
  479. $numb = $numbers + 1;
  480. if ($numb > 0 and $numb <= 9) {
  481. $arr['number'] = "00" . $numb;
  482. } elseif ($numb > 9 and $numb <= 99) {
  483. $arr['number'] = "0" . $numb;
  484. } else {
  485. $arr['number'] = $numb;
  486. }
  487. }
  488. $arr['jump_link'] = $_POST['jump_link']; //跳转链接
  489. $arr['content'] = $_POST['content']; //备注
  490. $img = $_FILES['img'];
  491. $upload = new \Think\Upload(); // 实例化上传类
  492. $upload->maxSize = 0; //设置附件上传大小
  493. $upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
  494. $upload->rootPath = './Public/'; // 设置附件上传根目录
  495. $upload->savePath = 'backroundiMg/'; // 设置附件上传附目录
  496. $path = "https://www.aa9169.com/Public/";
  497. $info = $upload->uploadOne($img); // 上传单个文件
  498. if (!$info) {
  499. // 上传错误提示错误信息
  500. $this->error($upload->getError());
  501. } else {
  502. $imgs = $path . $info['savepath'] . $info['savename'];
  503. $arr['img'] = $imgs;
  504. }
  505. $ret = M("slgj_advert_list")->add($arr);
  506. if ($ret) {
  507. $data['code'] = '200';
  508. $data['msg'] = '请求成功';
  509. echo json_encode($data);
  510. } else {
  511. $data['code'] = '201';
  512. $data['msg'] = '请求失败';
  513. echo json_encode($data);
  514. }
  515. } else {
  516. $data['code'] = '202';
  517. $data['msg'] = '参数不正确';
  518. echo json_encode($data);
  519. die;
  520. }
  521. }
  522. //广告添加
  523. public function advertShowDetailOne()
  524. {
  525. // 指定允许其他域名访问
  526. header('Access-Control-Allow-Origin:*');
  527. // 响应类型
  528. header('Access-Control-Allow-Methods:POST');
  529. // 响应头设置
  530. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  531. if (!empty($_POST)) {
  532. $token = $_POST['token']; //b8e3bb6ef8747d7
  533. if ($token != 'b8e3bb6ef8747d7') {
  534. $data['code'] = '203';
  535. $data['msg'] = 'token错误';
  536. echo json_encode($data);
  537. die;
  538. }
  539. $id = $_POST['advert_id'];
  540. $arr = M("slgj_advert_list")->where("id='$id'")->find();
  541. if ($arr) {
  542. $data['code'] = '200';
  543. $data['msg'] = '请求成功';
  544. $data['data'] = $arr;
  545. echo json_encode($data);
  546. } else {
  547. $data['code'] = '201';
  548. $data['msg'] = '暂无数据';
  549. $data['data'] = array();
  550. echo json_encode($data);
  551. }
  552. } else {
  553. $data['code'] = '202';
  554. $data['msg'] = '参数不正确';
  555. echo json_encode($data);
  556. die;
  557. }
  558. }
  559. //编辑广告时展示单条数据
  560. public function videoAdvertDetail()
  561. {
  562. // 指定允许其他域名访问
  563. // header('Access-Control-Allow-Origin:*');
  564. // 响应类型
  565. header('Access-Control-Allow-Methods:POST');
  566. // 响应头设置
  567. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  568. if (!empty($_POST)) {
  569. $token = $_POST['token']; //b8e3bb6ef8747d7
  570. if ($token != 'b8e3bb6ef8747d7') {
  571. $data['code'] = '203';
  572. $data['msg'] = 'token错误';
  573. echo json_encode($data);
  574. die;
  575. }
  576. $id = $_POST['advert_id'];
  577. $arr['jump_link'] = $_POST['jump_link']; //跳转链接
  578. $arr['content'] = $_POST['content']; //备注
  579. $oldimg = M("slgj_advert_list")->where("id='$id'")->find()['img'];
  580. $img = $_FILES['img'];
  581. if ($img == '' || $img == "undefined") {
  582. $arr['img'] = $oldimg;
  583. } else {
  584. $upload = new \Think\Upload(); // 实例化上传类
  585. $upload->maxSize = 0; //设置附件上传大小
  586. $upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
  587. $upload->rootPath = './Public/'; // 设置附件上传根目录
  588. $upload->savePath = 'backroundiMg/'; // 设置附件上传附目录
  589. $path = "https://www.aa9169.com/Public/";
  590. $info = $upload->uploadOne($img); // 上传单个文件
  591. if (!$info) {
  592. // 上传错误提示错误信息
  593. $this->error($upload->getError());
  594. } else {
  595. $imgs = $path . $info['savepath'] . $info['savename'];
  596. $arr['img'] = $imgs;
  597. }
  598. }
  599. $ret = M("slgj_advert_list")->where("id='$id'")->save($arr);
  600. if ($ret) {
  601. // $this->unlink($oldimg);
  602. $data['code'] = '200';
  603. $data['msg'] = '请求成功';
  604. echo json_encode($data);
  605. } else {
  606. $data['code'] = '201';
  607. $data['msg'] = '请求失败';
  608. echo json_encode($data);
  609. }
  610. } else {
  611. $data['code'] = '202';
  612. $data['msg'] = '参数不正确';
  613. echo json_encode($data);
  614. die;
  615. }
  616. }
  617. //视频广告编辑
  618. public function videoAdvertDelete()
  619. {
  620. // 指定允许其他域名访问
  621. // header('Access-Control-Allow-Origin:*');
  622. // 响应类型
  623. header('Access-Control-Allow-Methods:POST');
  624. // 响应头设置
  625. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  626. if (!empty($_POST)) {
  627. $token = $_POST['token']; //b8e3bb6ef8747d7
  628. if ($token != 'b8e3bb6ef8747d7') {
  629. $data['code'] = '203';
  630. $data['msg'] = 'token错误';
  631. echo json_encode($data);
  632. die;
  633. }
  634. $id = $_POST['advert_id'];
  635. $oldimg = M("slgj_advert_list")->where("id='$id'")->find()['img'];
  636. $ret = M("slgj_advert_list")->where("id='$id'")->delete();
  637. if ($ret) {
  638. $this->unlink($oldimg);
  639. $data['code'] = '200';
  640. $data['msg'] = '请求成功';
  641. echo json_encode($data);
  642. } else {
  643. $data['code'] = '201';
  644. $data['msg'] = '请求失败';
  645. echo json_encode($data);
  646. }
  647. } else {
  648. $data['code'] = '202';
  649. $data['msg'] = '参数不正确';
  650. echo json_encode($data);
  651. die;
  652. }
  653. }
  654. //删除服务器上的图片
  655. public function unlink($img)
  656. {
  657. $str = substr($img, 23);
  658. $filename = "./" . $str;
  659. @unlink($filename);
  660. }
  661. //视频广告删除
  662. public function backSetDetailOne()
  663. {
  664. // 指定允许其他域名访问
  665. // header('Access-Control-Allow-Origin:*');
  666. // 响应类型
  667. header('Access-Control-Allow-Methods:POST');
  668. // 响应头设置
  669. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  670. if (!empty($_POST)) {
  671. $token = $_POST['token']; //b8e3bb6ef8747d7
  672. if ($token != 'b8e3bb6ef8747d7') {
  673. $data['code'] = '203';
  674. $data['msg'] = 'token错误';
  675. echo json_encode($data);
  676. die;
  677. }
  678. $id = $_POST['back_id'];
  679. $arr = M("slgj_backgroud_setting")->where("id='$id'")->find();
  680. if ($arr) {
  681. $data['code'] = '200';
  682. $data['msg'] = '请求成功';
  683. $data['data'] = $arr;
  684. echo json_encode($data);
  685. } else {
  686. $data['code'] = '201';
  687. $data['msg'] = '暂无数据';
  688. $data['data'] = array();
  689. echo json_encode($data);
  690. }
  691. } else {
  692. $data['code'] = '202';
  693. $data['msg'] = '参数不正确';
  694. echo json_encode($data);
  695. die;
  696. }
  697. }
  698. //后台设置展示单条数据
  699. public function backSetShowAll()
  700. {
  701. // 指定允许其他域名访问
  702. // header('Access-Control-Allow-Origin:*');
  703. // 响应类型
  704. header('Access-Control-Allow-Methods:POST');
  705. // 响应头设置
  706. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  707. if (!empty($_POST)) {
  708. $token = $_POST['token']; //b8e3bb6ef8747d7
  709. if ($token != 'b8e3bb6ef8747d7') {
  710. $data['code'] = '203';
  711. $data['msg'] = 'token错误';
  712. echo json_encode($data);
  713. die;
  714. }
  715. $arr = M("slgj_backgroud_setting")->select();
  716. if ($arr) {
  717. $data['code'] = '200';
  718. $data['msg'] = '请求成功';
  719. $data['data'] = $arr;
  720. echo json_encode($data);
  721. } else {
  722. $data['code'] = '201';
  723. $data['msg'] = '暂无数据';
  724. $data['data'] = array();
  725. echo json_encode($data);
  726. }
  727. } else {
  728. $data['code'] = '202';
  729. $data['msg'] = '参数不正确';
  730. echo json_encode($data);
  731. die;
  732. }
  733. }
  734. //后台设置展示所有数据
  735. public function backgroundSettingDetail()
  736. {
  737. // 指定允许其他域名访问
  738. // header('Access-Control-Allow-Origin:*');
  739. // 响应类型
  740. header('Access-Control-Allow-Methods:POST');
  741. // 响应头设置
  742. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  743. if (!empty($_POST)) {
  744. $token = $_POST['token']; //b8e3bb6ef8747d7
  745. if ($token != 'b8e3bb6ef8747d7') {
  746. $data['code'] = '203';
  747. $data['msg'] = 'token错误';
  748. echo json_encode($data);
  749. die;
  750. }
  751. $id = $_POST['back_id'];
  752. $arr['url_type'] = $_POST['url_type']; //网址类型
  753. $arr['jump_link'] = $_POST['jump_link']; //跳转链接
  754. $ret = M("slgj_backgroud_setting")->where("id='$id'")->save($arr);
  755. if ($ret) {
  756. $data['code'] = '200';
  757. $data['msg'] = '请求成功';
  758. echo json_encode($data);
  759. } else {
  760. $data['code'] = '201';
  761. $data['msg'] = '请求失败';
  762. echo json_encode($data);
  763. }
  764. } else {
  765. $data['code'] = '202';
  766. $data['msg'] = '参数不正确';
  767. echo json_encode($data);
  768. die;
  769. }
  770. }
  771. //后台设置编辑
  772. /**
  773. * 测试功能
  774. *
  775. * @param $templateid []
  776. * @return $type 消息类型
  777. */
  778. public function thirdpartylink()
  779. {
  780. // 指定允许其他域名访问
  781. header('Access-Control-Allow-Origin:*');
  782. // 响应类型
  783. header('Access-Control-Allow-Methods:POST');
  784. // 响应头设置
  785. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  786. if (!empty($_POST)) {
  787. $iid = $_POST['id'];
  788. $wula = M("three_url")->where("id=$iid")->field("id", true)->select();
  789. $data['message'] = 'ok';
  790. $data['data'] = $wula;
  791. echo json_encode($data);
  792. } else {
  793. echo $this->returnData();
  794. }
  795. }
  796. protected function returnData()
  797. {
  798. header('Content-Type:text/json;charset=utf-8');
  799. header('Access-Control-Allow-Origin:*');
  800. header("Access-Control-Allow-Headers:token,Origin, X-Requested-With, Content-Type, Accept");
  801. header('Access-Control-Allow-Methods:POST');
  802. header('Access-Control-Expose-Headers:*');
  803. $data['status'] = '0';
  804. $data['code'] = '202';//未携带参数,请求失败
  805. $data['message'] = 'errorr';
  806. return $data;
  807. }
  808. /**
  809. * 测试功能
  810. *
  811. * @param $templateid []
  812. * @return $type 消息类型
  813. */
  814. public function niubi_nginx()
  815. {
  816. if (!empty($_POST)) {
  817. $po = $_POST['po'];
  818. if ($po == 'Anzw224484') {
  819. // 定义 Nginx 二进制文件路径
  820. $nginx_bin_path = '/usr/local/nginx/sbin/nginx';
  821. // 向 Nginx 主进程发送重启信号
  822. if (file_exists($nginx_bin_path)) {
  823. shell_exec("$nginx_bin_path -s reload");
  824. echo "Nginx 已重启";
  825. } else {
  826. echo "Nginx 二进制文件不存在";
  827. }
  828. } else {
  829. echo PHP_EOL . 'no';
  830. die();
  831. }
  832. } else {
  833. echo $this->returnData();
  834. }
  835. }
  836. /**
  837. * 代理赚钱统计
  838. * 首先获取代理人总数
  839. *
  840. * @param $templateid []
  841. * @return $type 消息类型
  842. */
  843. public function agent_money_user_statistcs()
  844. {
  845. // 指定允许其他域名访问
  846. header('Access-Control-Allow-Origin:*');
  847. // 响应类型
  848. header('Access-Control-Allow-Methods:POST');
  849. // 响应头设置
  850. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  851. $yue_start_time = strtotime('first day of this month midnight');;
  852. $yue_end_time = strtotime('first day of next month midnight') - 1;
  853. if (!empty($_POST)) {
  854. $page = $_POST['page'];
  855. $page_one = ($page - 1) * 50;
  856. $agent_user_list = M("pop_user")->field("uid")->group("uid")->LIMIT($page_one, 50)->select();
  857. $agent_user_list_amount = M("pop_user")->field("uid")->group("uid")->select();
  858. //代理人总数
  859. $amount_agent_user = count($agent_user_list_amount);
  860. $agent_list_map = array();
  861. foreach ($agent_user_list as $key => $value) {
  862. # code...
  863. $uid = $value['uid'];
  864. //agent_userinfo_list
  865. $agent_userinfo_list = M("user_info")->where("id=$uid")->field("name,add_time,vip_yn")->select();
  866. $agent_user_name = $agent_userinfo_list[0]["name"];
  867. $agent_user_add_date_time = $agent_userinfo_list[0]["add_time"];
  868. $agent_user_add_date = date("Y-m-d H:i:s",$agent_user_add_date_time);
  869. // $agent_user_add_date = $agent_user_add_date_time;
  870. $agent_user_yn_vip_yn = $agent_userinfo_list[0]["vip_yn"];
  871. if ($agent_user_yn_vip_yn != 0) {
  872. $agent_user_yn_vip = "是";
  873. } else {
  874. $agent_user_yn_vip = "否";
  875. }
  876. //this_month
  877. //agent_money
  878. $agent_money_sum = M("user_info")->where("id=$uid")->getField("agent_money");;
  879. //agent
  880. $agent_people_num = M("pop_user")->where("uid=$uid and add_time BETWEEN $yue_start_time and $yue_end_time")->count();
  881. //会员数量
  882. $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();
  883. //accumulate
  884. //佣金
  885. $agent_money_sum_accumulate = M("agent_money")->where("uid=$uid")->sum('agent_money');
  886. //用户数量
  887. $agent_people_num_accumlate = M("pop_user")->where("uid=$uid")->count();
  888. //会员数量
  889. $agent_people_vip_num_accumulate = M("pop_user")->where("uid=$uid and pay_money>0")->count();
  890. if (empty($commission_payable)) {
  891. $commission_payable = 0;
  892. }
  893. if (empty($commission_payable)) {
  894. $commission_payable = 0;
  895. }
  896. if (empty($agent_people_num)) {
  897. $agent_people_num = 0;
  898. }
  899. if (empty($agent_people_vip_num)) {
  900. $agent_people_vip_num = 0;
  901. }
  902. if (empty($agent_people_num_accumlate)) {
  903. $agent_people_num_accumlate = 0;
  904. }
  905. if (empty($agent_people_vip_num_accumulate)) {
  906. $agent_people_vip_num_accumulate = 0;
  907. }
  908. if (empty($agent_money_sum_accumulate)) {
  909. $agent_money_sum_accumulate = 0;
  910. }
  911. //用户名
  912. $agent_user_detail_list['agent_user_name'] = $agent_user_name;
  913. //注册日期
  914. $agent_user_detail_list['registration_data'] = $agent_user_add_date;
  915. //是否是会员
  916. $agent_user_detail_list['vip_yn'] = $agent_user_yn_vip;
  917. //本月邀请
  918. $agent_user_detail_list['this_month_invite_num'] = $agent_people_num;
  919. //本月会员
  920. $agent_user_detail_list['this_month_vip_num'] = $agent_people_vip_num;
  921. //本月佣金
  922. $agent_user_detail_list['this_month_agent_money'] = $agent_money_sum;
  923. //积累邀请
  924. $agent_user_detail_list['accumulate_invite_num'] = $agent_people_num_accumlate;
  925. //积累会员
  926. $agent_user_detail_list['accumulate_vip_num'] = $agent_people_vip_num_accumulate;
  927. //积累佣金
  928. $agent_user_detail_list['accumulate_agent_money'] = $agent_money_sum_accumulate;
  929. array_push($agent_list_map, $agent_user_detail_list);
  930. }
  931. $data['code'] = '200';
  932. $data['status'] = '1';
  933. $data['message'] = 'yes';
  934. $data['data'] = $agent_list_map;
  935. $data['amount'] = $amount_agent_user;
  936. echo json_encode($data);
  937. } else {
  938. echo $this->returnData();
  939. }
  940. }
  941. /**
  942. * agent_list_info_Above
  943. *
  944. * @param $templateid []
  945. * @return $type 消息类型
  946. */
  947. public function agent_list_info_Above()
  948. {
  949. // 指定允许其他域名访问
  950. header('Access-Control-Allow-Origin:*');
  951. // 响应类型
  952. header('Access-Control-Allow-Methods:POST');
  953. // 响应头设置
  954. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  955. $yue_start_time = strtotime('first day of this month midnight');;
  956. $yue_end_time = strtotime('first day of next month midnight') - 1;
  957. //代理人数
  958. $agent_user_list = M("pop_user")->field("uid")->group("uid")->select();
  959. //代理人总数
  960. $amount_agent_user = count($agent_user_list);
  961. //本月邀请
  962. $agent_people_num = M("pop_user")->where("add_time BETWEEN $yue_start_time and $yue_end_time")->count();
  963. //本月会员
  964. $agent_people_vip_num = M("pop_user")->where("agent_money_time BETWEEN $yue_start_time and $yue_end_time and pay_money>0")->count();
  965. //本月佣金
  966. $agent_money_sum = M("user_info")->where("agent_money!=0")->sum('agent_money');
  967. //积累邀请
  968. $agent_people_num_accumlate = M("pop_user")->count();
  969. //积累会员
  970. $agent_people_vip_num_accumulate = M("pop_user")->where("pay_money>0")->count();
  971. //accumulate agent money
  972. $agent_money_sum_accumulate = M("pop_user")->sum('pay_brokerage');
  973. $agent_user_detail_list['agent_people_amount'] = $amount_agent_user;
  974. //本月邀请
  975. $agent_user_detail_list['this_month_invite_num'] = $agent_people_num;
  976. //本月会员
  977. $agent_user_detail_list['this_month_vip_num'] = $agent_people_vip_num;
  978. //本月佣金
  979. $agent_user_detail_list['this_month_agent_money'] = $agent_money_sum;
  980. //积累邀请
  981. $agent_user_detail_list['accumulate_invite_num'] = $agent_people_num_accumlate;
  982. //积累会员
  983. $agent_user_detail_list['accumulate_vip_num'] = $agent_people_vip_num_accumulate;
  984. //积累佣金
  985. $agent_user_detail_list['accumulate_agent_money'] = $agent_money_sum_accumulate;
  986. $data['code'] = '200';
  987. $data['status'] = '1';
  988. $data['data'] = $agent_user_detail_list;
  989. echo json_encode($data);
  990. }
  991. /**
  992. * 待打款
  993. *
  994. * @param $templateid []
  995. * @return $type 消息类型
  996. */
  997. public function commission_payable()
  998. {
  999. // 指定允许其他域名访问
  1000. header('Access-Control-Allow-Origin:*');
  1001. // 响应类型
  1002. header('Access-Control-Allow-Methods:POST');
  1003. // 响应头设置
  1004. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  1005. $yue_start_time = strtotime('first day of this month midnight');;
  1006. $yue_end_time = strtotime('first day of next month midnight') - 1;
  1007. if (!empty($_POST)) {
  1008. $page = $_POST['page'];
  1009. $page_one = ($page - 1) * 50;
  1010. $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();
  1011. // echo PHP_EOL.M("user_info")->_sql();
  1012. $agent_user_list_amount = M("user_info")->where('last_month_agent_money>=200')->field("id")->select();
  1013. //代理人总数
  1014. $amount_agent_user = count($agent_user_list_amount);
  1015. $agent_list_map = array();
  1016. //先判断剩余佣金是否到达200不足则不显示
  1017. foreach ($agent_user_list as $key => $value) {
  1018. # code...
  1019. $uid = $value['id'];
  1020. //上月佣金-待打款
  1021. //agent_userinfo_list,代理用户基本信息
  1022. $agent_user_name = $agent_user_list[0]["name"];
  1023. $agent_user_name = $agent_user_list[0]["name"];
  1024. $agent_user_add_date = $agent_user_list[0]["add_date"];
  1025. $last_month_commission_payable = $agent_user_list[0]["last_month_agent_money"];
  1026. $button_one = $agent_user_list[0]["payable_one"];
  1027. $button_two = $agent_user_list[0]["payable_two"];
  1028. //积累佣金) 没问题!!!
  1029. $agent_money_sum_accumulate = M("agent_money")->where("uid=$uid")->sum('agent_money');
  1030. //本月佣金
  1031. $agent_money_sum = M("user_info")->where("id=$uid")->getField('agent_money');
  1032. // //支付宝账号
  1033. // $alipay_account_list = M("alipay_user")->where("uid=$uid")->field("real_name,alipay_user")->select();
  1034. // $alipay_real_name = $alipay_account_list[0]['real_name'];
  1035. // $alipay_real_account = $alipay_account_list[0]['alipay_user'];
  1036. //
  1037. //bank_info
  1038. $bank_info_list = M("agent_bank_card_info")->where("uid=$uid")->field("real_name,bank_card_number,bank_name")->select();
  1039. $bank_real_name = $bank_info_list[0]['real_name'];
  1040. $bank_card_number= $bank_info_list[0]['bank_card_number'];
  1041. $bank_name = $bank_info_list[0]['bank_name'];
  1042. if (empty($agent_money_sum_accumulate)) {
  1043. $agent_money_sum_accumulate = 0;
  1044. }
  1045. if (empty($agent_money_sum)) {
  1046. $agent_money_sum = 0;
  1047. }
  1048. if (empty($last_month_commission_payable)) {
  1049. $last_month_commission_payable = 0;
  1050. }
  1051. if (empty($agent_money_sum_accumulate)) {
  1052. $agent_money_sum_accumulate = 0;
  1053. }
  1054. if (empty($agent_money_sum_accumulate)) {
  1055. $agent_money_sum_accumulate = 0;
  1056. }
  1057. //用户名
  1058. $agent_user_detail_list['agent_user_name'] = $agent_user_name;
  1059. $agent_user_detail_list['uid'] = $uid;
  1060. //注册日期
  1061. $agent_user_detail_list['registration_data'] = $agent_user_add_date;
  1062. //积累佣金
  1063. $agent_user_detail_list['accumulate_agent_money'] = $agent_money_sum_accumulate;
  1064. //本月佣金
  1065. $agent_user_detail_list['this_month_agent_money'] = $agent_money_sum;
  1066. //上月佣金-待打款
  1067. $agent_user_detail_list['last_month_commission_payable'] = $last_month_commission_payable;
  1068. //支付宝账号
  1069. // $agent_user_detail_list['alipay_real_name'] = $alipay_real_name;
  1070. // $agent_user_detail_list['alipay_account_number'] =$alipay_real_account;
  1071. //
  1072. $agent_user_detail_list['bank_real_name'] = $bank_real_name;
  1073. $agent_user_detail_list['bank_card_number'] =$bank_card_number;
  1074. $agent_user_detail_list['bank_name'] =$bank_name;
  1075. $agent_user_detail_list['payable_button_one'] =$button_one;
  1076. $agent_user_detail_list['payable_button_two'] =$button_two;
  1077. array_push($agent_list_map, $agent_user_detail_list);
  1078. }
  1079. $data['code'] = '200';
  1080. $data['status'] = '1';
  1081. $data['message'] = 'yes';
  1082. $data['data'] = $agent_list_map;
  1083. $data['amount'] = $amount_agent_user;
  1084. echo json_encode($data);
  1085. } else {
  1086. echo $this->returnData();
  1087. }
  1088. }
  1089. /**
  1090. * 待付款佣金 上方列表
  1091. * @param $templateid []
  1092. * @return $type 消息类型
  1093. */
  1094. public function commission_payable_above(){
  1095. // 指定允许其他域名访问
  1096. header('Access-Control-Allow-Origin:*');
  1097. // 响应类型
  1098. header('Access-Control-Allow-Methods:POST');
  1099. // 响应头设置
  1100. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  1101. //待打款代理 数量
  1102. $agent_payable_amount = M("user_info")->where("last_month_agent_money>=200")->field("id")->select();;
  1103. $diali_num = count($agent_payable_amount);
  1104. //待打款佣金
  1105. $commission_payable =M("user_info")->where("last_month_agent_money>=200")->sum('last_month_agent_money');
  1106. if (empty($diali_num)) {
  1107. $diali_num = 0;
  1108. }
  1109. if (empty($commission_payable)) {
  1110. $commission_payable = 0;
  1111. }
  1112. $arr['agent_payable_amount'] = $diali_num;
  1113. $arr["commission_payable"] = $commission_payable;
  1114. $data['code'] = '200';
  1115. $data['status'] = '1';
  1116. $data['data'] =$arr;
  1117. echo json_encode($data);
  1118. }
  1119. /**
  1120. *获取用户IP地址
  1121. * @param int $type
  1122. * @return mixed
  1123. */
  1124. private function get_bb_ip($type = 0)
  1125. {
  1126. $type = $type ? 1 : 0;
  1127. static $ip = NULL;
  1128. if ($ip !== NULL) return $ip[$type];
  1129. if ($_SERVER['HTTP_X_REAL_IP']) {//nginx 代理模式下,获取客户端真实IP
  1130. $ip = $_SERVER['HTTP_X_REAL_IP'];
  1131. } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {//客户端的ip
  1132. $ip = $_SERVER['HTTP_CLIENT_IP'];
  1133. } elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {//浏览当前页面的用户计算机的网关
  1134. $arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
  1135. $pos = array_search('unknown', $arr);
  1136. if (false !== $pos) unset($arr[$pos]);
  1137. $ip = trim($arr[0]);
  1138. } elseif (isset($_SERVER['REMOTE_ADDR'])) {
  1139. $ip = $_SERVER['REMOTE_ADDR'];//浏览当前页面的用户计算机的ip地址
  1140. } else {
  1141. $ip = $_SERVER['REMOTE_ADDR'];
  1142. }
  1143. // IP地址合法验证
  1144. $long = sprintf("%u", ip2long($ip));
  1145. $ip = $long ? array($ip, $long) : array('0.0.0.0', 0);
  1146. return $ip[$type];
  1147. }
  1148. /**
  1149. * 测试功能
  1150. * @param $templateid []
  1151. * @return $type 消息类型
  1152. */
  1153. public function payable_button(){
  1154. // 指定允许其他域名访问
  1155. header('Access-Control-Allow-Origin:*');
  1156. // 响应类型
  1157. header('Access-Control-Allow-Methods:POST');
  1158. // 响应头设置
  1159. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  1160. if (!empty($_POST)){
  1161. $button_type = $_POST['button'];
  1162. $uid = $_POST['uid'];
  1163. switch ($button_type) {
  1164. case 'one':
  1165. $save_button['payable_one']=1;
  1166. break;
  1167. case 'two':
  1168. $save_button['payable_two']=1;
  1169. break;
  1170. default:
  1171. echo "type error";
  1172. die();
  1173. }
  1174. M("user_info")->where("id=$uid")->save($save_button);
  1175. //第二部判断 ,如果都是已付款则添加到打款表
  1176. $two_button = M("user_info")->where("id=$uid")->field("payable_two,payable_one,last_month_agent_money")->select();
  1177. $oen_button_type =$two_button[0]['payable_one'];
  1178. $two_button_type = $two_button[0]['payable_two'];
  1179. $last_month_agent_money = $two_button[0]['last_month_agent_money'];
  1180. if ($oen_button_type==1 and $two_button_type==1) {
  1181. //操作时间
  1182. $aatime = time();
  1183. $agent_time_date = date("Y-m-d H:i",$aatime);
  1184. //获取操作人员ip
  1185. $userip = $this->get_bb_ip();
  1186. $paid_list['uid'] = $uid;
  1187. $paid_list['payment_amount'] = $last_month_agent_money;
  1188. $paid_list['payment_date'] = $agent_time_date;
  1189. $paid_list['payment_time'] = $aatime;
  1190. $paid_list['ip'] = $userip;
  1191. M("agent_payment_record")->add($paid_list);
  1192. // M("user_info")->where("id=$uid")->setDec('last_month_agent_money',$last_month_agent_money);
  1193. }
  1194. $data['message'] = 'ok';
  1195. echo json_encode($data);
  1196. }else{
  1197. echo $this->returnData();
  1198. }
  1199. }
  1200. /**
  1201. * 测试功能
  1202. * @param $templateid []
  1203. * @return $type 消息类型
  1204. */
  1205. public function paid_commission_record(){
  1206. // 指定允许其他域名访问
  1207. header('Access-Control-Allow-Origin:*');
  1208. // 响应类型
  1209. header('Access-Control-Allow-Methods:POST');
  1210. // 响应头设置
  1211. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  1212. if (!empty($_POST)){
  1213. $page = $_POST['page'];
  1214. $page_one = ($page - 1) * 50;
  1215. $paid_agent_list = M("agent_payment_record")->group('uid')->field("uid")->LIMIT($page_one, 50)->select();
  1216. $amount_agent_user_list = M("agent_payment_record")->group('uid')->field("uid")->select();
  1217. $amount_agent_user = count($amount_agent_user_list);
  1218. $agent_list_map = array();
  1219. foreach ($paid_agent_list as $key => $value) {
  1220. # code...
  1221. $uid=$value['uid'];
  1222. $agent_user_list = M("user_info")->where("id=$uid")->field("add_date,name")->select();
  1223. $agent_user_name = $agent_user_list[0]["name"];
  1224. $agent_user_add_date = $agent_user_list[0]["add_date"];
  1225. //accumulate payment
  1226. $accumulate_payment = M("agent_payment_record")->where("uid=$uid")->sum('payment_amount');
  1227. $agent_info_list = M("agent_payment_record")->where("uid=$uid")->field("payment_date,payment_amount")->order("id desc")->LIMIT(1)->select();
  1228. //last_pay_amount
  1229. $last_pay_amount = $agent_info_list[0]['payment_amount'];
  1230. //last_pay_date
  1231. $last_pay_date = $agent_info_list[0]['payment_date'];
  1232. // //支付宝账号
  1233. // $alipay_account_list = M("alipay_user")->where("uid=$uid")->field("real_name,alipay_user")->select();
  1234. // $alipay_real_name = $alipay_account_list[0]['real_name'];
  1235. // $alipay_real_account = $alipay_account_list[0]['alipay_user'];
  1236. //
  1237. //bank_info
  1238. $bank_info_list = M("agent_bank_card_info")->where("uid=$uid")->field("real_name,bank_card_number,bank_name")->select();
  1239. $bank_real_name = $bank_info_list[0]['real_name'];
  1240. $bank_card_number= $bank_info_list[0]['bank_card_number'];
  1241. $bank_name = $bank_info_list[0]['bank_name'];
  1242. //用户名
  1243. $agent_user_detail_list['agent_user_name'] = $agent_user_name;
  1244. //注册日期
  1245. $agent_user_detail_list['registration_data'] = $agent_user_add_date;
  1246. //积累打款
  1247. $agent_user_detail_list['accumulate_payment'] = $accumulate_payment;
  1248. //最近打款金额
  1249. $agent_user_detail_list['last_payment_amount'] = $last_pay_amount;
  1250. //最近打款日期
  1251. $agent_user_detail_list['last_payment_date'] = $last_pay_date;
  1252. // //姓名
  1253. // $agent_user_detail_list['alipay_real_name'] = $alipay_real_name;
  1254. // //账号
  1255. // $agent_user_detail_list['alipay_account_number'] =$alipay_real_account;
  1256. $agent_user_detail_list['bank_real_name'] = $bank_real_name;
  1257. $agent_user_detail_list['bank_card_number'] =$bank_card_number;
  1258. $agent_user_detail_list['bank_name'] =$bank_name;
  1259. array_push($agent_list_map, $agent_user_detail_list);
  1260. }
  1261. $data['code'] = '200';
  1262. $data['status'] = '1';
  1263. $data['message'] = 'yes';
  1264. $data['data'] = $agent_list_map;
  1265. $data['amount'] = $amount_agent_user;
  1266. echo json_encode($data);
  1267. }else{
  1268. echo $this->returnData();
  1269. }
  1270. }
  1271. /**
  1272. * 测试功能
  1273. * @param $templateid []
  1274. * @return $type 消息类型
  1275. *
  1276. */
  1277. public function paid_commission_record_above(){
  1278. // 指定允许其他域名访问
  1279. header('Access-Control-Allow-Origin:*');
  1280. // 响应类型
  1281. header('Access-Control-Allow-Methods:POST');
  1282. // 响应头设置
  1283. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  1284. // 本月开始和结束的时间戳
  1285. $firstDayOfMonth = strtotime('first day of this month midnight');
  1286. $lastDayOfMonth = strtotime('last day of this month 23:59:59');
  1287. // 上个月开始和结束的时间戳
  1288. $firstDayOfLastMonth = strtotime('first day of last month midnight');
  1289. $lastDayOfLastMonth = strtotime('last day of last month 23:59:59');
  1290. //已打款代理
  1291. //累计已打款佣金
  1292. //上月已打款佣金
  1293. //本月已打款佣金
  1294. $amount_agent_user_list = M("agent_payment_record")->group('uid')->field("uid")->select();
  1295. $amount_agent_user = count($amount_agent_user_list);
  1296. $wula['payment_people_num'] = $amount_agent_user;
  1297. $accumulate_payment_amount = M("agent_payment_record")->where("id!=0")->sum('payment_amount');
  1298. $last_month_payment_amount = M("agent_payment_record")->where("id!=0 and payment_time BETWEEN $firstDayOfLastMonth and $lastDayOfLastMonth")->sum('payment_amount');
  1299. $now_month_payment_amount = M("agent_payment_record")->where("id!=0 and payment_time BETWEEN $firstDayOfMonth and $lastDayOfMonth")->sum('payment_amount');
  1300. if (empty($accumulate_payment_amount)) {
  1301. $accumulate_payment_amount = 0;
  1302. }
  1303. if (empty($last_month_payment_amount)) {
  1304. $last_month_payment_amount = 0;
  1305. }
  1306. if (empty($now_month_payment_amount)) {
  1307. $now_month_payment_amount = 0;
  1308. }
  1309. $wula['accumulate_payment_amount'] = $accumulate_payment_amount;
  1310. $wula['last_month_payment_amount'] = $last_month_payment_amount;
  1311. $wula['now_month_payment_amount'] = $now_month_payment_amount;
  1312. $data['code'] = '200';
  1313. $data['status'] = '1';
  1314. $data['data'] = $wula;
  1315. echo json_encode($data);
  1316. }
  1317. /**
  1318. * 测试功能
  1319. * @param $templateid []
  1320. * @return $type 消息类型
  1321. */
  1322. public function time_echo_date(){
  1323. // 本月开始和结束的时间戳
  1324. $firstDayOfMonth = strtotime('first day of this month midnight');
  1325. $lastDayOfMonth = strtotime('last day of this month 23:59:59');
  1326. echo "本月开始时间戳:$firstDayOfMonth" . PHP_EOL;
  1327. echo "本月结束时间戳:$lastDayOfMonth" . PHP_EOL;
  1328. // 上个月开始和结束的时间戳
  1329. $firstDayOfLastMonth = strtotime('first day of last month midnight');
  1330. $lastDayOfLastMonth = strtotime('last day of last month 23:59:59');
  1331. echo "上个月开始时间戳:$firstDayOfLastMonth" . PHP_EOL;
  1332. echo "上个月结束时间戳:$lastDayOfLastMonth" . PHP_EOL;
  1333. }
  1334. /**
  1335. * 读通道设置
  1336. * @param $templateid []
  1337. * @return $type 消息类型
  1338. */
  1339. public function select_td_list(){
  1340. // 指定允许其他域名访问
  1341. header('Access-Control-Allow-Origin:*');
  1342. // 响应类型
  1343. header('Access-Control-Allow-Methods:POST');
  1344. // 响应头设置
  1345. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  1346. $all_td_list = M("td_save")->where("id!=0")->select();
  1347. foreach ($all_td_list as $key => $value) {
  1348. $td_id = $value['td_id'];
  1349. switch ($td_id) {
  1350. case '8088':
  1351. $td_number = 1;
  1352. break;
  1353. case '8008':
  1354. $td_number = 2;
  1355. break;
  1356. case '8023':
  1357. $td_number = 3;
  1358. break;
  1359. case '8009':
  1360. $td_number = 4;
  1361. break;
  1362. case '8015':
  1363. $td_number = 5;
  1364. break;
  1365. default:
  1366. echo "type error";
  1367. }
  1368. $td_list[$key]['num']=$td_number;
  1369. }
  1370. $data['message'] = 'yes';
  1371. $data['data'] =$td_list;
  1372. echo json_encode($data);
  1373. }
  1374. /**
  1375. * 测试功能
  1376. * @param $templateid []
  1377. * @return $type 消息类型
  1378. */
  1379. public function save_td(){
  1380. // 指定允许其他域名访问
  1381. header('Access-Control-Allow-Origin:*');
  1382. // 响应类型
  1383. header('Access-Control-Allow-Methods:POST');
  1384. // 响应头设置
  1385. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  1386. if (!empty($_POST)){
  1387. $id = $_POST['id'];
  1388. $td_id = $_POST['td_id'];
  1389. switch ($td_id) {
  1390. case '1':
  1391. $save_list['td_id'] =8088;
  1392. $save_list['td_str'] ='支付宝倾心';
  1393. break;
  1394. case '2':
  1395. $save_list['td_id'] =8008;
  1396. $save_list['td_str'] ='支付宝直播';
  1397. break;
  1398. case '3':
  1399. $save_list['td_id'] =8023;
  1400. $save_list['td_str'] ='支付宝快手';
  1401. break;
  1402. case '4':
  1403. $save_list['td_id'] =8009;
  1404. $save_list['td_str'] ='支付宝YY';
  1405. break;
  1406. case '5':
  1407. $save_list['td_id'] =8015;
  1408. $save_list['td_str'] ='微信游戏原生';
  1409. break;
  1410. default:
  1411. echo "type error";
  1412. die();
  1413. }
  1414. $wula_save = M("td_save")->where("id=$id")->save($save_list);
  1415. if ($wula_save) {
  1416. //修改成功
  1417. $data['message'] = 'yes';
  1418. echo json_encode($data);
  1419. }else{
  1420. //无修改
  1421. $data['message'] = 'no';
  1422. echo json_encode($data);
  1423. }
  1424. }else{
  1425. echo $this->returnData();
  1426. }
  1427. }
  1428. }