orderstats.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. class orderstatsControl extends SystemControl
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. }
  8. public function indexOp()
  9. {
  10. $type = $_GET['type'] ? $_GET['type'] : 'system';
  11. $page = "{$type}.order.stats";
  12. $model_refill_order = Model('refill_order');
  13. $condition['type'] = $type;
  14. if (!empty($_GET['cid'])) {
  15. $condition['cid'] = $_GET['cid'];
  16. }
  17. $start_unixtime = intval(strtotime($_GET['query_start_time']));
  18. $end_unixtime = intval(strtotime($_GET['query_end_time']));
  19. if ($start_unixtime > 0 && $end_unixtime > $start_unixtime) {
  20. $condition['time_stamp'] = [['egt', $start_unixtime], ['lt', $end_unixtime], 'and'];
  21. } elseif ($start_unixtime > 0) {
  22. $condition['time_stamp'] = ['egt', $start_unixtime];
  23. } elseif ($end_unixtime > 0) {
  24. $condition['time_stamp'] = ['lt', $end_unixtime];
  25. }
  26. $stats_list = $model_refill_order->getOrderStatsList($condition);
  27. if ($type == 'provider') {
  28. $provider_list = Model('')->table('refill_provider,store')->field('refill_provider.store_id,store.store_name')->join('inner')
  29. ->on('store.store_id=refill_provider.store_id')->limit(1000)->select();
  30. Tpl::output('provider_list', $provider_list);
  31. } elseif ($type == 'merchant') {
  32. $merchant_list = Model('')->table('merchant')->limit(1000)->select();
  33. Tpl::output('merchant_list', $merchant_list);
  34. }
  35. $success_count_total = $success_refill_amounts_total = $success_mch_amounts_toatl = $success_channel_amounts_total = $profit_amounts_total = 0;
  36. foreach ($stats_list as $stats) {
  37. $success_count_total += $stats['success_count'];
  38. $success_refill_amounts_total += $stats['success_refill_amounts'];
  39. $success_mch_amounts_toatl += $stats['success_mch_amounts'];
  40. $success_channel_amounts_total += $stats['success_channel_amounts'];
  41. $profit_amounts_total += $stats['profit_amounts'];
  42. }
  43. $total_stats = [
  44. 'success_count_total' => $success_count_total,
  45. 'success_refill_amounts_total' => $success_refill_amounts_total,
  46. 'success_mch_amounts_toatl' => $success_mch_amounts_toatl,
  47. 'success_channel_amounts_total' => $success_channel_amounts_total,
  48. 'profit_amounts_total' => $profit_amounts_total
  49. ];
  50. $check_text = ['未编辑', '匹配', '不匹配'];
  51. Tpl::output('total_stats', $total_stats);
  52. Tpl::output('stats_list', $stats_list);
  53. Tpl::output('check_text', $check_text);
  54. Tpl::output('show_page', $model_refill_order->showpage());
  55. Tpl::showpage($page);
  56. }
  57. public function ExportDataOp()
  58. {
  59. $type = $_GET['type'] ? $_GET['type'] : 'system';
  60. $model_refill_order = Model('refill_order');
  61. $condition['type'] = $type;
  62. if (!empty($_GET['cid'])) {
  63. $condition['cid'] = $_GET['cid'];
  64. }
  65. $start_unixtime = intval($_GET['query_start_time']);
  66. $end_unixtime = intval($_GET['query_end_time']);
  67. if ($start_unixtime > 0 && $end_unixtime > $start_unixtime) {
  68. $condition['time_stamp'] = [['egt', $start_unixtime], ['lt', $end_unixtime], 'and'];
  69. } elseif ($start_unixtime > 0) {
  70. $condition['time_stamp'] = ['egt', $start_unixtime];
  71. } elseif ($end_unixtime > 0) {
  72. $condition['time_stamp'] = ['lt', $end_unixtime];
  73. }
  74. $stats_list = $model_refill_order->getOrderStatsList($condition);
  75. $success_count_total = $success_refill_amounts_total = $success_mch_amounts_toatl = $success_channel_amounts_total = $profit_amounts_total = 0;
  76. foreach ($stats_list as $stats) {
  77. $success_count_total += $stats['success_count'];
  78. $success_refill_amounts_total += $stats['success_refill_amounts'];
  79. $success_mch_amounts_toatl += $stats['success_mch_amounts'];
  80. $success_channel_amounts_total += $stats['success_channel_amounts'];
  81. $profit_amounts_total += $stats['profit_amounts'];
  82. }
  83. $total_stats = [
  84. 'success_count_total' => ncPriceFormat($success_count_total),
  85. 'success_refill_amounts_total' => ncPriceFormat($success_refill_amounts_total),
  86. 'success_mch_amounts_toatl' => ncPriceFormat($success_mch_amounts_toatl),
  87. 'success_channel_amounts_total' => ncPriceFormat($success_channel_amounts_total),
  88. 'profit_amounts_total' => ncPriceFormat($profit_amounts_total)
  89. ];
  90. $result['data'] = $stats_list;
  91. $result['total_stats'] = $total_stats;
  92. echo(json_encode($result));
  93. exit;
  94. }
  95. }