stat.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. {template 'common/header'}
  2. <style>
  3. .account-stat-num > div{width:25%; float:left; font-size:16px; text-align:center;}
  4. .account-stat-num > div span{display:block; font-size:30px; font-weight:bold;}
  5. </style>
  6. <ul class="nav nav-tabs">
  7. <li {if $do == 'chart' && $type == 'credit2'}class="active"{/if}><a href="{php echo url('mc/stat/chart', array('type' => 'credit2'))}">余额统计</a></li>
  8. <li {if $do == 'chart' && $type == 'credit1'}class="active"{/if}><a href="{php echo url('mc/stat/chart', array('type' => 'credit1'))}">积分统计</a></li>
  9. <li {if $do == 'chart' && $type == 'cash'}class="active"{/if}><a href="{php echo url('mc/stat/chart', array('type' => 'cash'))}">现金统计</a></li>
  10. <li {if $do == 'list' && $type == 'credit2'}class="active"{/if}><a href="{php echo url('mc/stat/list', array('type' => 'credit2'))}">余额明细</a></li>
  11. <li {if $do == 'list' && $type == 'credit1'}class="active"{/if}><a href="{php echo url('mc/stat/list', array('type' => 'credit1'))}">积分明细</a></li>
  12. <li {if $do == 'list' && $type == 'cash'}class="active"{/if}><a href="{php echo url('mc/stat/list', array('type' => 'cash'))}">现金明细</a></li>
  13. </ul>
  14. {if $do == 'chart'}
  15. <div class="panel panel-default">
  16. <div class="panel-heading">
  17. {$names[$type]}统计
  18. </div>
  19. {if $type != 'cash'}
  20. <div class="panel-body">
  21. <div class="account-stat-num row">
  22. <div>今日充值总额<span>{$today_recharge}</span></div>
  23. <div>今日消费总额<span>{php echo abs($today_consume);}</span></div>
  24. <div>{php echo date('Y-m-d', $starttime);}~{php echo date('Y-m-d', $endtime);}<br>充值总额<span>{$total_recharge}</span></div>
  25. <div>{php echo date('Y-m-d', $starttime);}~{php echo date('Y-m-d', $endtime);}<br>消费总额<span>{php echo abs($total_consume)}</span></div>
  26. </div>
  27. </div>
  28. {else}
  29. <div class="panel-body">
  30. <div class="account-stat-num row">
  31. <div style="width:50%">今日消费总额<span>{php echo abs($today_consume);}</span></div>
  32. <div style="width:50%">{php echo date('Y-m-d', $starttime);}~{php echo date('Y-m-d', $endtime);}<br>消费总额<span>{php echo abs($total_consume)}</span></div>
  33. </div>
  34. </div>
  35. {/if}
  36. </div>
  37. <div class="panel panel-default">
  38. <div class="panel-heading">
  39. {$names[$do]}统计
  40. </div>
  41. <div class="panel-body" id="scroll">
  42. <div class="pull-left">
  43. <form action="" id="form1">
  44. <input name="c" value="mc" type="hidden" />
  45. <input name="a" value="stat" type="hidden" />
  46. <input name="do" value="{$do}" type="hidden" />
  47. <input name="type" value="{$type}" type="hidden" />
  48. {php echo tpl_form_field_daterange('time', array('start' => date('Y-m-d', $starttime),'end' => date('Y-m-d', $endtime)), '')}
  49. <input type="hidden" value="" name="scroll">
  50. </form>
  51. </div>
  52. <div class="pull-right">
  53. <div class="checkbox">
  54. {if $type != 'cash'}
  55. <label style="color:rgba(149,192,0,1);;"><input checked type="checkbox"> 充值统计</label>&nbsp;
  56. {/if}
  57. <label style="color:rgba(203,48,48,1)"><input checked type="checkbox"> 消费统计</label>&nbsp;
  58. </div>
  59. </div>
  60. <div style="margin-top:20px">
  61. <canvas id="myChart" width="1200" height="300"></canvas>
  62. </div>
  63. </div>
  64. </div>
  65. <script>
  66. require(['chart', 'daterangepicker'], function(c) {
  67. $('.daterange').on('apply.daterangepicker', function(ev, picker) {
  68. $('#form1')[0].submit();
  69. });
  70. var chart = null;
  71. var chartDatasets = null;
  72. var templates = {
  73. consume: {
  74. label: '消费',
  75. fillColor : "rgba(203,48,48,0.1)",
  76. strokeColor : "rgba(203,48,48,1)",
  77. pointColor : "rgba(203,48,48,1)",
  78. pointStrokeColor : "#fff",
  79. pointHighlightFill : "#fff",
  80. pointHighlightStroke : "rgba(203,48,48,1)"
  81. },
  82. recharge: {
  83. label: '充值',
  84. fillColor : "rgba(149,192,0,0.1)",
  85. strokeColor : "rgba(149,192,0,1)",
  86. pointColor : "rgba(149,192,0,1)",
  87. pointStrokeColor : "#fff",
  88. pointHighlightFill : "#fff",
  89. pointHighlightStroke : "rgba(149,192,0,1)"
  90. }
  91. };
  92. function refreshData() {
  93. if(!chart || !chartDatasets) {
  94. return;
  95. }
  96. var visables = [];
  97. var i = 0;
  98. $('.checkbox input[type="checkbox"]').each(function(){
  99. if($(this).attr('checked')) {
  100. visables.push(i);
  101. }
  102. i++;
  103. });
  104. var ds = [];
  105. $.each(visables, function(){
  106. var o = chartDatasets[this];
  107. ds.push(o);
  108. });
  109. chart.datasets = ds;
  110. chart.update();
  111. }
  112. var url = location.href + '&#aaaa';
  113. $.post(url, function(data){
  114. var data = $.parseJSON(data)
  115. var datasets = data.datasets;
  116. if(!chart) {
  117. var label = data.label;
  118. var ds = $.extend(true, {}, templates);
  119. ds.consume.data = datasets.consume;
  120. ds.recharge.data = datasets.recharge;
  121. var lineChartData = {
  122. labels : label,
  123. datasets : [ds.consume, ds.recharge]
  124. };
  125. var ctx = document.getElementById("myChart").getContext("2d");
  126. chart = new Chart(ctx).Line(lineChartData, {
  127. responsive: true
  128. });
  129. chartDatasets = $.extend(true, {}, chart.datasets);
  130. }
  131. refreshData();
  132. });
  133. $('.checkbox input[type="checkbox"]').on('click', function(){
  134. $(this).attr('checked', !$(this).attr('checked'))
  135. refreshData();
  136. });
  137. });
  138. </script>
  139. {else}
  140. <div class="panel panel-info">
  141. <div class="panel-heading">筛选</div>
  142. <div class="panel-body">
  143. <form action="./index.php" method="get" class="form-horizontal" role="form">
  144. <input type="hidden" name="c" value="mc">
  145. <input type="hidden" name="a" value="stat">
  146. <input type="hidden" name="do" value="list">
  147. <input type="hidden" name="type" value="{$type}">
  148. {if $type != 'cash'}
  149. <input type="hidden" name="num" value="{$num}">
  150. <div class="form-group">
  151. <label class="col-xs-12 col-sm-3 col-md-2 control-label">类型</label>
  152. <div class="col-sm-8 col-lg-9 col-xs-12">
  153. <div class="btn-group">
  154. <a href="{php echo filter_url('num:0');}" class="btn {if $_GPC['num'] == ''}btn-primary{else}btn-default{/if}">不限</a>
  155. <a href="{php echo filter_url('num:1');}" class="btn {if $_GPC['num'] == 1}btn-primary{else}btn-default{/if}">充值</a>
  156. <a href="{php echo filter_url('num:2');}" class="btn {if $_GPC['num'] == 2}btn-primary{else}btn-default{/if}">消费</a>
  157. </div>
  158. </div>
  159. </div>
  160. {/if}
  161. <div class="form-group">
  162. <label class="col-xs-12 col-sm-3 col-md-2 control-label">消费时间</label>
  163. <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
  164. {php echo tpl_form_field_daterange('time', array('starttime' => date('Y-m-d', $starttime), 'endtime' => date('Y-m-d', $endtime),));}
  165. </div>
  166. </div>
  167. <div class="form-group">
  168. <label class="col-xs-12 col-sm-3 col-md-2 control-label">姓名/手机号码/UID</label>
  169. <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
  170. <input type="text" class="form-control" name="user" value="{$_GPC['user']}" />
  171. </div>
  172. </div>
  173. <div class="form-group">
  174. <label class="col-xs-12 col-sm-3 col-md-2 control-label">积分/金额/实收</label>
  175. <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
  176. <div class="input-group">
  177. <input type="text" class="form-control" name="min" value="{$_GPC['min']}" />
  178. <span class="input-group-addon">至</span>
  179. <input type="text" class="form-control" name="max" value="{$_GPC['max']}" />
  180. </div>
  181. </div>
  182. </div>
  183. <div class="form-group">
  184. <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
  185. <div class="col-xs-12 col-sm-3 col-md-2 col-lg-2">
  186. <button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
  187. <input type="hidden" name="token" value="{$_W['token']}"/>
  188. </div>
  189. </div>
  190. </form>
  191. </div>
  192. </div>
  193. {if $type != 'cash'}
  194. <form method="post" class="form-horizontal" id="form1">
  195. <div class="panel panel-default ">
  196. <div class="table-responsive panel-body">
  197. <table class="table table-hover">
  198. <thead>
  199. <tr>
  200. <th style="width:80px;">会员编号</th>
  201. <th>姓名</th>
  202. <th>手机</th>
  203. <th>类型</th>
  204. <th>金额</th>
  205. <th width="200">消费门店</th>
  206. <th>操作人</th>
  207. <th>操作时间</th>
  208. <th width="400">备注</th>
  209. </tr>
  210. </thead>
  211. <tbody>
  212. {loop $data $row}
  213. <tr>
  214. <td>{$row['uid']}</td>
  215. <td>{$users[$row['uid']]['realname']}</td>
  216. <td>{$users[$row['uid']]['mobile']}</td>
  217. <td>
  218. {if $row['num'] > 0}
  219. <span class="label label-success">充值</span>
  220. {else}
  221. <span class="label label-danger">消费</span>
  222. {/if}
  223. </td>
  224. <td>{php echo abs($row['num']);}</td>
  225. <td>
  226. {if $row['store_id'] > 0}
  227. {$stores[$row['store_id']]['business_name']}-{$stores[$row['store_id']]['branch_name']}
  228. {else}
  229. 未知
  230. {/if}
  231. </td>
  232. <td>
  233. {if $row['clerk_id'] > 0}
  234. {$clerks[$row['clerk_id']]['name']}
  235. {else}
  236. 未知
  237. {/if}
  238. </td>
  239. <td>{php echo date('Y-m-d H:i', $row['createtime'])}</td>
  240. <td style="cursor: pointer"><span data-toggle="popover" data-placement="top" data-trigger="hover" data-content="{$row['remark']}">{php echo cutstr($row['remark'], 30, '...');}</span></td>
  241. </tr>
  242. {/loop}
  243. </tbody>
  244. </table>
  245. </div>
  246. </div>
  247. {$pager}
  248. </form>
  249. {else}
  250. <form method="post" class="form-horizontal" id="form1">
  251. <div class="panel panel-default ">
  252. <div class="table-responsive panel-body">
  253. <table class="table table-hover">
  254. <thead>
  255. <tr>
  256. <th style="width:80px;">会员编号</th>
  257. <th>姓名</th>
  258. <th>手机</th>
  259. <th>消费金额</th>
  260. <th>实收金额</th>
  261. <th>余额支付</th>
  262. <th>积分抵消</th>
  263. <th>实收现金</th>
  264. <th>消费门店</th>
  265. <th>操作人</th>
  266. <th width="150">操作时间</th>
  267. <th width="400">备注</th>
  268. </tr>
  269. </thead>
  270. <tbody>
  271. {loop $data $row}
  272. <tr>
  273. <td>{$row['uid']}</td>
  274. <td>{$users[$row['uid']]['realname']}</td>
  275. <td>{$users[$row['uid']]['mobile']}</td>
  276. <td>{$row['fee']}</td>
  277. <td>{$row['final_fee']}</td>
  278. <td>{$row['credit2']}</td>
  279. <td>{$row['credit1_fee']}</td>
  280. <td>{$row['final_cash']}</td>
  281. <td>
  282. {if $row['store_id'] > 0}
  283. {$stores[$row['store_id']]['business_name']}-{$stores[$row['store_id']]['branch_name']}
  284. {else}
  285. 未知
  286. {/if}
  287. </td>
  288. <td>
  289. {if $row['clerk_id'] > 0}
  290. {$clerks[$row['clerk_id']]['name']}
  291. {else}
  292. 未知
  293. {/if}
  294. </td>
  295. <td>{php echo date('Y-m-d H:i', $row['createtime'])}</td>
  296. <td style="cursor: pointer"><span data-toggle="popover" data-placement="top" data-trigger="hover" data-content="{$row['remark']}">{php echo cutstr($row['remark'], 30, '...');}</span></td>
  297. </tr>
  298. {/loop}
  299. </tbody>
  300. </table>
  301. </div>
  302. </div>
  303. {$pager}
  304. </form>
  305. {/if}
  306. <script>
  307. require(['bootstrap'],function($){
  308. $('[data-toggle="popover"]').popover()
  309. });
  310. </script>
  311. {/if}
  312. {template 'common/footer'}