PlatformmobileController.class.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Home\Controller;
  15. use Home\Model\OrderModel;
  16. class PlatformmobileController extends CommonController {
  17. public $member_id;
  18. protected function _initialize(){
  19. parent::_initialize();
  20. $isopen_admin_managefront = D('Home/Front')->get_config_by_name('isopen_admin_managefront');
  21. $isopen_admin_managefront = isset($isopen_admin_managefront) ? $isopen_admin_managefront : 0;
  22. if( $isopen_admin_managefront == 0 )
  23. {
  24. echo json_encode( array('code' => 3, 'message' => '未开启平台手机端功能') );
  25. die();
  26. }
  27. $token = I('request.token');
  28. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  29. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  30. {
  31. echo json_encode( array('code' => 1,'message' => '请先登录') );
  32. die();
  33. }
  34. $this->member_id = $weprogram_token['member_id'];
  35. //检测是否平台管理员
  36. $platform_admin_member = D('Home/Front')->get_config_by_name('platform_admin_member');
  37. if( empty($platform_admin_member) )
  38. {
  39. echo json_encode( array('code' => 3, 'message' => '您不是平台管理员') );
  40. die();
  41. }
  42. $platform_admin_member_arr = explode(',', $platform_admin_member );
  43. if( !in_array( $this->member_id , $platform_admin_member_arr ) )
  44. {
  45. echo json_encode( array('code' => 3, 'message' => '您不是平台管理员') );
  46. die();
  47. }
  48. }
  49. /**
  50. * @author yj
  51. * @desc 获取平台手机端数据所需要的内容
  52. */
  53. public function getIndexData()
  54. {
  55. $begin_time = 0;
  56. $end_time = time() +1;
  57. $sales_data = D('Home/OrderV3')->analySalesByTime( $begin_time , $end_time );//销售统计
  58. $todayOrderData = D('Home/OrderV3')->getTodayOrderData();//今日平台数据
  59. $user_data = D('Home/OrderV3')->getPlatformUserData();
  60. $goods_data = D('Home/OrderV3')->getPlatformGoodsData();
  61. $business_data = D('Home/OrderV3')->getBusinessData();
  62. $need_data = [];
  63. $need_data['sales_data'] = $sales_data;
  64. $need_data['todayOrderData'] = $todayOrderData;
  65. $need_data['user_data'] = $user_data;
  66. $need_data['goods_data'] = $goods_data;
  67. $need_data['business_data'] = $business_data;
  68. $need_data['code'] = 0;
  69. echo json_encode( $need_data );
  70. die();
  71. }
  72. public function searchAnalySalesByTime()
  73. {
  74. $type = I('request.type', 0);
  75. $begin_time = I('request.begin_time','','strtotime');
  76. $end_time = I('request.end_time', '', 'strtotime');
  77. switch( $type )
  78. {
  79. case 0:
  80. $begin_time = 0;
  81. $end_time = time() +1;
  82. break;
  83. case 1:
  84. //今日
  85. $begin_time = strtotime( date('Y-m-d').' 00:00:00' );
  86. $end_time = $begin_time + 86400;
  87. break;
  88. case 2:
  89. //昨日
  90. $begin_time = strtotime( date('Y-m-d').' 00:00:00' ) - 86400;
  91. $end_time = $begin_time + 86400;
  92. break;
  93. case 3:
  94. //7日
  95. $begin_time = strtotime( date('Y-m-d').' 00:00:00' );
  96. $end_time = $begin_time + 86400;
  97. $begin_time = $begin_time - 6*86400;
  98. break;
  99. }
  100. $sales_data = D('Home/OrderV3')->analySalesByTime( $begin_time , $end_time );//销售统计
  101. $need_data = [];
  102. $need_data['code'] = 1;
  103. $need_data['sales_data'] = $sales_data;
  104. echo json_encode( $need_data );
  105. die();
  106. }
  107. }