publish_statistics.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <?php
  2. // by 请勿倒卖,已申请软著,否则追究法律责任
  3. namespace app\index;
  4. class publish_statistics extends BaseUser
  5. {
  6. function index()
  7. {
  8. $id = bees_decrypt(SafeRequest("id", "get"));
  9. $row = db('appid')->where('in_uid', $this->userid)->where('in_id', $id)->find();
  10. $row || exit(include_once dirname(__FILE__) . '/../pack/error/404.php');
  11. $sid = bees_encrypt($row['in_id']);
  12. $start_date = SafeRequest("start_date", "get");
  13. $end_date = SafeRequest("end_date", "get");
  14. $starttime = $start_date . ' 00:00:00';
  15. $endtime = $end_date . ' 23:59:59';
  16. $specified = '';
  17. if (!empty($start_date) && !empty($end_date)) {
  18. $specified = "addtime>'" . $starttime . "' and addtime<'" . $endtime . "' ";
  19. }
  20. $total = db('downhistory')->where($specified)->where('appid', $id)->where('uid', $this->userid)->count();
  21. $num = 10;
  22. $cpage = isset($_GET['page']) ? $_GET['page'] : 1;
  23. $pagenum = ceil($total / $num);
  24. $offset = ($cpage - 1) * $num;
  25. $result = db('downhistory')->where($specified)->where('appid', $id)->where('uid', $this->userid)->order('addtime desc')->limit($offset, $num)->select();
  26. $start = $offset + 1;
  27. $end = $cpage == $pagenum ? $total : $cpage * $num;
  28. $next = $cpage == $pagenum ? 0 : $cpage + 1;
  29. $prev = $cpage == 1 ? 0 : $cpage - 1;
  30. ?>
  31. <!DOCTYPE html>
  32. <html lang="">
  33. <head>
  34. <meta charset="utf-8">
  35. <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0" />
  36. <meta name="keywords" content="<?php echo IN_KEYWORDS;?>" />
  37. <meta name="description" content="<?php echo IN_DESCRIPTION;?>" />
  38. <title>
  39. <?php echo $row['in_name'];?>应用详情 -
  40. <?php echo IN_NAME;?>
  41. </title>
  42. <?php
  43. $this->static_();
  44. ?>
  45. </head>
  46. <body>
  47. <?php
  48. $this->header();
  49. ?>
  50. <link rel="stylesheet" href="/static/pack/font-awesome-4.7.0/css/font-awesome.css" />
  51. <link rel="stylesheet" type="text/css" href="/static/index/css/jquery.datetimepicker.css?20190530" />
  52. <script src="/static/index/js/jquery.datetimepicker.js?20190530"></script>
  53. <script src="/static/index/js/bootstrap-paginator.js"></script>
  54. <div class="release-app-wrap">
  55. <div class="container">
  56. <div class="release-app2">
  57. <div class="crumbs">
  58. <a href="/index/apps/apps">我的应用</a>
  59. <span>/</span>
  60. <a href="/index/apps/apps">应用列表</a>
  61. <span>/</span>
  62. <?php echo $row['in_name'];?>
  63. </div>
  64. <div class="row clearfix">
  65. <?php
  66. $this->publish_app_list();
  67. ?>
  68. <div class="col-sm-10">
  69. <div class="aside-right">
  70. <div class="app-details app-details2">
  71. <?php
  72. $this->publish_top($row);
  73. ?>
  74. <hr>
  75. <div class="download-details">
  76. <div class="d-top clearfix">
  77. <div class="date date1">
  78. <input class="form-control" type="text" id="datetimepicker1" value="<?php
  79. if (empty($start_date)) {
  80. ?><?php echo date(" Y/m/d", strtotime(date("Y/m/d") . '-1 week' ));?>
  81. <?php
  82. } else {
  83. ?>
  84. <?php echo $start_date;?>
  85. <?php
  86. }
  87. ?>">
  88. <span class="iconfont icon-date"></span>
  89. </div>
  90. <div class="fl line">
  91. _
  92. </div>
  93. <div class="date date2">
  94. <input class="form-control" type="text" id="datetimepicker2" value="<?php
  95. if (empty($end_date)) {
  96. ?><?php echo date(" Y/m/d");?>
  97. <?php
  98. } else {
  99. ?>
  100. <?php echo $end_date;?>
  101. <?php
  102. }
  103. ?>">
  104. <span class="iconfont icon-date"></span>
  105. </div>
  106. <button type="button" class="ms-btn ms-btn-secondary fl query">查询</button>
  107. <span class="fl num">累计总下载 <i>
  108. <?php echo $row['in_downloads'];?>
  109. </i> 次</span>
  110. <button type="button" class="ms-btn ms-btn-secondary fr cleanUp"
  111. data-app-id="<?php echo bees_encrypt($row['in_id']);?>">清空统计数据
  112. </button>
  113. </div>
  114. <div class="table-responsive">
  115. <table class="table">
  116. <tr>
  117. <th>时间</th>
  118. <th>应用名称</th>
  119. <th>版本</th>
  120. <th>大小</th>
  121. <th>浏览次数</th>
  122. <th>下载次数</th>
  123. </tr>
  124. <?php
  125. foreach ($result as $key => $value) {
  126. ?>
  127. <tr>
  128. <td><?php echo $value['addtime'];?></td>
  129. <td><?php echo $value['appname'];?></td>
  130. <td><?php echo $value['appversion'];?></td>
  131. <td><?php echo formatsize($value['appsize']);?></td>
  132. <td><?php echo $value['liulan'];?></td>
  133. <td><?php echo $value['down'];?></td>
  134. </tr>
  135. <?php
  136. }
  137. ?>
  138. </table>
  139. <?php
  140. if ($total == 0) {
  141. ?>
  142. <div class="text-center no-content">
  143. <img src="/static/index/image/invoice-1.png" alt="">
  144. <p class="color-333 mt10">
  145. 暂无任何数据
  146. </p>
  147. </div>
  148. <?php
  149. }
  150. ?>
  151. </div>
  152. <?php
  153. if ($pagenum != 1) {
  154. ?>
  155. <?php
  156. if ($total !== 0) {
  157. ?>
  158. <?php
  159. if (empty($start_date)) {
  160. ?>
  161. <div style="text-align: center">
  162. <ul id="pager" class="pagination">
  163. <li><a>共<b>
  164. <?php echo $total;?>
  165. </b>条记录</b>
  166. <?php echo $cpage;?>/
  167. <?php echo $pagenum;?>
  168. </a></li>
  169. <?php
  170. if ($cpage == 1) {
  171. ?>
  172. <li class='active'><a>首页</a></li>
  173. <?php
  174. } else {
  175. ?>
  176. <li><a href='?page=1&id=<?php echo $sid;?>'>首页</a></li>
  177. <?php
  178. }
  179. if ($prev) {
  180. ?>
  181. <li><a href='?page=<?php echo $prev;?>&id=<?php echo $sid;?>'>上一页</a></li>
  182. <?php
  183. } else {
  184. }
  185. if ($next) {
  186. ?>
  187. <li><a href='?page=<?php echo $next;?>&id=<?php echo $sid;?>'>下一页</a></li>
  188. <?php
  189. } else {
  190. }
  191. if ($cpage == $pagenum) {
  192. ?>
  193. <li class='active'><a>尾页</a></li>
  194. <?php
  195. } else {
  196. ?>
  197. <li><a href='?page=<?php echo $pagenum;?>&id=<?php echo $sid;?>'>尾页</a></li>
  198. <?php
  199. }
  200. ?>
  201. </ul>
  202. </div>
  203. <?php
  204. } else {
  205. ?>
  206. <div style="text-align: center">
  207. <ul id="pager" class="pagination">
  208. <li><a>共<b>
  209. <?php echo $total;?>
  210. </b>条记录</b>
  211. <?php echo $cpage;?>/
  212. <?php echo $pagenum;?>
  213. </a></li>
  214. <?php
  215. if ($cpage == 1) {
  216. ?>
  217. <li class='active'><a>首页</a></li>
  218. <?php
  219. } else {
  220. ?>
  221. <li><a
  222. href='?page=1&id=<?php echo $sid;?>&start_date=<?php echo $start_date;?>&end_date=<?php echo $end_date;?>'>首页</a>
  223. </li>
  224. <?php
  225. }
  226. if ($prev) {
  227. ?>
  228. <li><a
  229. href='?page=<?php echo $prev;?>&id=<?php echo $sid;?>&start_date=<?php echo $start_date;?>&end_date=<?php echo $end_date;?>'>上一页</a>
  230. </li>
  231. <?php
  232. } else {
  233. }
  234. if ($next) {
  235. ?>
  236. <li><a
  237. href='?page=<?php echo $next;?>&id=<?php echo $sid;?>&start_date=<?php echo $start_date;?>&end_date=<?php echo $end_date;?>'>下一页</a>
  238. </li>
  239. <?php
  240. } else {
  241. }
  242. if ($cpage == $pagenum) {
  243. ?>
  244. <li class='active'><a>尾页</a></li>
  245. <?php
  246. } else {
  247. ?>
  248. <li><a
  249. href='?page=<?php echo $pagenum;?>&id=<?php echo $sid;?>&start_date=<?php echo $start_date;?>&end_date=<?php echo $end_date;?>'>尾页</a>
  250. </li>
  251. <?php
  252. }
  253. ?>
  254. </ul>
  255. </div>
  256. <?php
  257. }
  258. ?>
  259. <?php
  260. }
  261. ?>
  262. <?php
  263. }
  264. ?>
  265. </div>
  266. </div>
  267. </div>
  268. </div>
  269. </div>
  270. </div>
  271. </div>
  272. </div>
  273. <?php
  274. $this->inc_merge();
  275. ?>
  276. <script>
  277. $(function () {
  278. $(".download-details div:first").on('click', '.query', function () {
  279. var start_date = $(this).parent().find("input:first").val();
  280. var end_date = $(this).parent().find("input:last").val();
  281. window.location.href = "/index/publish_statistics?id=<?php echo bees_encrypt($row['in_id']);?>&start_date=" + start_date + "&end_date=" + end_date + "&page=1";
  282. });
  283. $(".download-details div:first").on('click', '.cleanUp', function () {
  284. var appId = $(this).data('app-id');
  285. alert('确认清空统计数据吗?', function () {
  286. $.post('/index/ajax_profile/cleanStatistics', { appId: appId }, function (data) {
  287. if (data.code == 200) {
  288. window.location.reload();
  289. } else {
  290. alert(data.msg);
  291. }
  292. }, 'json')
  293. }, function () {
  294. }, 'center', '确定', '取消');
  295. });
  296. })
  297. </script>
  298. <?php
  299. $this->footer();
  300. ?>
  301. </body>
  302. </html>
  303. <?php
  304. }
  305. }