Dashboard.php 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\View;
  4. use think\facade\Db;
  5. use think\facade\Lang;
  6. /**
  7. *
  8. *
  9. * ----------------------------------------------------------------------------
  10. *
  11. * 控制器
  12. */
  13. class Dashboard extends AdminControl
  14. {
  15. public function initialize()
  16. {
  17. parent::initialize(); // TODO: Change the autogenerated stub
  18. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/dashboard.lang.php');
  19. include_once root_path() . 'extend/mall/statistics.php';
  20. include_once root_path() . 'extend/mall/datehelper.php';
  21. }
  22. function index()
  23. {
  24. $this->welcome();
  25. }
  26. /*
  27. * 检查是否为最新版本
  28. */
  29. function version()
  30. {
  31. //当前版本
  32. $curent_version = file_get_contents(base_path() . 'version.php');
  33. //获取最新版本信息
  34. $vaules = array(
  35. 'domain' => $_SERVER['HTTP_HOST'],
  36. 'version' => $curent_version,
  37. );
  38. $service_url = "http://service.csdeshang.com/index.php/home/Version/checkDsmall.html?" . http_build_query($vaules);
  39. //设置超时时间
  40. $opts = array(
  41. 'http' =>
  42. array(
  43. 'timeout' => 3
  44. )
  45. );
  46. $context = stream_context_create($opts);
  47. $service_info = @file_get_contents($service_url, FALSE, $context);
  48. $version_message = json_decode($service_info);
  49. View::assign('version_message', $version_message);
  50. }
  51. function welcome()
  52. {
  53. $this->version();
  54. /**
  55. * 管理员信息
  56. */
  57. $admin_model = model('admin');
  58. $tmp = $this->getAdminInfo();
  59. $condition = array();
  60. $condition[] = array('admin_id', '=', $tmp['admin_id']);
  61. $admin_info = $admin_model->infoAdmin($condition);
  62. $admin_info['admin_login_time'] = date('Y-m-d H:i:s', ($admin_info['admin_login_time'] == '' ? TIMESTAMP : $admin_info['admin_login_time']));
  63. /**
  64. * 系统信息
  65. */
  66. $setup_date = config('ds_config.setup_date');
  67. $statistics['tp_version'] = \think\App::VERSION;
  68. $statistics['os'] = PHP_OS;
  69. $statistics['web_server'] = $_SERVER['SERVER_SOFTWARE'];
  70. $statistics['php_version'] = PHP_VERSION;
  71. $statistics['sql_version'] = $this->_mysql_version();
  72. //$statistics['shop_version'] = $version;
  73. $statistics['setup_date'] = substr($setup_date, 0, 10);
  74. $statistics['domain'] = $_SERVER['HTTP_HOST'];
  75. $statistics['ip'] = GetHostByName($_SERVER['SERVER_NAME']);
  76. $statistics['zlib'] = function_exists('gzclose') ? 'YES' : 'NO'; //zlib
  77. $statistics['safe_mode'] = (bool) ini_get('safe_mode') ? 'YES' : 'NO'; //safe_mode = Off
  78. $statistics['timezone'] = function_exists("date_default_timezone_get") ? date_default_timezone_get() : "no_timezone";
  79. $statistics['curl'] = function_exists('curl_init') ? 'YES' : 'NO';
  80. $statistics['fileupload'] = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : 'unknown';
  81. $statistics['max_ex_time'] = @ini_get("max_execution_time") . 's'; //脚本最大执行时间
  82. $statistics['set_time_limit'] = function_exists("set_time_limit") ? true : false;
  83. $statistics['memory_limit'] = ini_get('memory_limit');
  84. $statistics['version'] = file_get_contents(base_path() . 'version.php');
  85. if (function_exists("gd_info")) {
  86. $gd = gd_info();
  87. $statistics['gdinfo'] = $gd['GD Version'];
  88. } else {
  89. $statistics['gdinfo'] = lang('ds_unknown');
  90. }
  91. View::assign('statistics', $statistics);
  92. View::assign('admin_info', $admin_info);
  93. $this->_stat_json();
  94. $this->setAdminCurItem('welcome');
  95. echo View::fetch('welcome');
  96. exit;
  97. }
  98. private function _stat_json()
  99. {
  100. $this->_get_week_member();
  101. $this->_get_week_goods();
  102. $this->_get_week_store();
  103. $this->_get_week_order();
  104. }
  105. /**
  106. * 获取本周新增订单数量
  107. */
  108. private function _get_week_order()
  109. {
  110. $field = ' COUNT(*) as allnum ';
  111. $current_weekarr = getWeek_SdateAndEdate(TIMESTAMP);
  112. $stime = strtotime($current_weekarr['sdate']) - 86400 * 7;
  113. $etime = strtotime($current_weekarr['edate']) + 86400 - 1;
  114. //总计的查询时间
  115. $count_arr['seartime'] = ($stime + 86400 * 7) . '|' . $etime;
  116. $up_week = @date('W', $stime); //上周
  117. $curr_week = @date('W', $etime); //本周
  118. //构造横轴数据
  119. for ($i = 1; $i <= 7; $i++) {
  120. //统计图数据
  121. $up_arr[$i] = 0;
  122. $curr_arr[$i] = 0;
  123. $tmp_weekarr = getSystemWeekArr();
  124. //统计表数据
  125. $currlist_arr[$i]['timetext'] = $tmp_weekarr[$i];
  126. //方便搜索会员列表,计算开始时间和结束时间
  127. $currlist_arr[$i]['stime'] = strtotime($current_weekarr['sdate']) + ($i - 1) * 86400;
  128. $currlist_arr[$i]['etime'] = $currlist_arr[$i]['stime'] + 86400 - 1;
  129. $uplist_arr[$i]['val'] = 0;
  130. $currlist_arr[$i]['val'] = 0;
  131. //横轴
  132. $stat_arr['xAxis']['categories'][] = $tmp_weekarr[$i];
  133. unset($tmp_weekarr);
  134. }
  135. $where = array();
  136. $where[] = array('add_time', 'between', array($stime, $etime));
  137. $field .= ',WEEKOFYEAR(FROM_UNIXTIME(add_time)) as weekval,WEEKDAY(FROM_UNIXTIME(add_time))+1 as dayofweekval ';
  138. $orderlist = Db::name('order')->field($field)->where($where)->group('weekval,dayofweekval')->select()->toArray();
  139. if ($orderlist) {
  140. foreach ($orderlist as $k => $v) {
  141. if ($up_week == intval($v['weekval'])) {
  142. $up_arr[$v['dayofweekval']] = intval($v['allnum']);
  143. $uplist_arr[$v['dayofweekval']]['val'] = intval($v['allnum']);
  144. if (isset($count_arr['up'])) {
  145. $count_arr['up'] += intval($v['allnum']);
  146. } else {
  147. $count_arr['up'] = 0;
  148. }
  149. }
  150. if ($curr_week == $v['weekval']) {
  151. $curr_arr[$v['dayofweekval']] = intval($v['allnum']);
  152. $currlist_arr[$v['dayofweekval']]['val'] = intval($v['allnum']);
  153. if (isset($count_arr['curr'])) {
  154. $count_arr['curr'] += intval($v['allnum']);
  155. } else {
  156. $count_arr['curr'] = 0;
  157. }
  158. }
  159. }
  160. }
  161. $stat_arr['series'][0]['name'] = lang('last_week');
  162. $stat_arr['series'][0]['data'] = array_values($up_arr);
  163. $stat_arr['series'][1]['name'] = lang('this_week');
  164. $stat_arr['series'][1]['data'] = array_values($curr_arr);
  165. //得到统计图数据
  166. $stat_arr['title'] = lang('new_order_statistics');
  167. $stat_arr['yAxis'] = lang('new_order_count');
  168. $stat_json = getStatData_LineLabels($stat_arr);
  169. View::assign('stat_json_week_order', $stat_json);
  170. }
  171. /**
  172. * 获取本周新增店铺数量
  173. */
  174. private function _get_week_store()
  175. {
  176. $field = ' COUNT(*) as allnum ';
  177. $current_weekarr = getWeek_SdateAndEdate(TIMESTAMP);
  178. $stime = strtotime($current_weekarr['sdate']) - 86400 * 7;
  179. $etime = strtotime($current_weekarr['edate']) + 86400 - 1;
  180. //总计的查询时间
  181. $count_arr['seartime'] = ($stime + 86400 * 7) . '|' . $etime;
  182. $up_week = @date('W', $stime); //上周
  183. $curr_week = @date('W', $etime); //本周
  184. //构造横轴数据
  185. for ($i = 1; $i <= 7; $i++) {
  186. //统计图数据
  187. $up_arr[$i] = 0;
  188. $curr_arr[$i] = 0;
  189. $tmp_weekarr = getSystemWeekArr();
  190. //统计表数据
  191. $currlist_arr[$i]['timetext'] = $tmp_weekarr[$i];
  192. //方便搜索会员列表,计算开始时间和结束时间
  193. $currlist_arr[$i]['stime'] = strtotime($current_weekarr['sdate']) + ($i - 1) * 86400;
  194. $currlist_arr[$i]['etime'] = $currlist_arr[$i]['stime'] + 86400 - 1;
  195. $uplist_arr[$i]['val'] = 0;
  196. $currlist_arr[$i]['val'] = 0;
  197. //横轴
  198. $stat_arr['xAxis']['categories'][] = $tmp_weekarr[$i];
  199. unset($tmp_weekarr);
  200. }
  201. $where = array();
  202. $where[] = array('store_addtime', 'between', array($stime, $etime));
  203. $field .= ',WEEKOFYEAR(FROM_UNIXTIME(store_addtime)) as weekval,WEEKDAY(FROM_UNIXTIME(store_addtime))+1 as dayofweekval ';
  204. $storelist = Db::name('store')->field($field)->where($where)->group('weekval,dayofweekval')->select()->toArray();
  205. if ($storelist) {
  206. foreach ($storelist as $k => $v) {
  207. if ($up_week == intval($v['weekval'])) {
  208. $up_arr[$v['dayofweekval']] = intval($v['allnum']);
  209. $uplist_arr[$v['dayofweekval']]['val'] = intval($v['allnum']);
  210. if (isset($count_arr['up'])) {
  211. $count_arr['up'] += intval($v['allnum']);
  212. } else {
  213. $count_arr['up'] = 0;
  214. }
  215. }
  216. if ($curr_week == $v['weekval']) {
  217. $curr_arr[$v['dayofweekval']] = intval($v['allnum']);
  218. $currlist_arr[$v['dayofweekval']]['val'] = intval($v['allnum']);
  219. if (isset($count_arr['curr'])) {
  220. $count_arr['curr'] += intval($v['allnum']);
  221. } else {
  222. $count_arr['curr'] = 0;
  223. }
  224. }
  225. }
  226. }
  227. $stat_arr['series'][0]['name'] = lang('last_week');
  228. $stat_arr['series'][0]['data'] = array_values($up_arr);
  229. $stat_arr['series'][1]['name'] = lang('this_week');
  230. $stat_arr['series'][1]['data'] = array_values($curr_arr);
  231. //得到统计图数据
  232. $stat_arr['title'] = lang('new_store_statistics');
  233. $stat_arr['yAxis'] = lang('new_store_count');
  234. $stat_json = getStatData_LineLabels($stat_arr);
  235. View::assign('stat_json_week_store', $stat_json);
  236. }
  237. /**
  238. * 获取本周新增商品数量
  239. */
  240. private function _get_week_goods()
  241. {
  242. $field = ' COUNT(*) as allnum ';
  243. $current_weekarr = getWeek_SdateAndEdate(TIMESTAMP);
  244. $stime = strtotime($current_weekarr['sdate']) - 86400 * 7;
  245. $etime = strtotime($current_weekarr['edate']) + 86400 - 1;
  246. //总计的查询时间
  247. $count_arr['seartime'] = ($stime + 86400 * 7) . '|' . $etime;
  248. $up_week = @date('W', $stime); //上周
  249. $curr_week = @date('W', $etime); //本周
  250. //构造横轴数据
  251. for ($i = 1; $i <= 7; $i++) {
  252. //统计图数据
  253. $up_arr[$i] = 0;
  254. $curr_arr[$i] = 0;
  255. $tmp_weekarr = getSystemWeekArr();
  256. //统计表数据
  257. $currlist_arr[$i]['timetext'] = $tmp_weekarr[$i];
  258. //方便搜索会员列表,计算开始时间和结束时间
  259. $currlist_arr[$i]['stime'] = strtotime($current_weekarr['sdate']) + ($i - 1) * 86400;
  260. $currlist_arr[$i]['etime'] = $currlist_arr[$i]['stime'] + 86400 - 1;
  261. $uplist_arr[$i]['val'] = 0;
  262. $currlist_arr[$i]['val'] = 0;
  263. //横轴
  264. $stat_arr['xAxis']['categories'][] = $tmp_weekarr[$i];
  265. unset($tmp_weekarr);
  266. }
  267. $where = array();
  268. $where[] = array('goods_addtime', 'between', array($stime, $etime));
  269. $field .= ',WEEKOFYEAR(FROM_UNIXTIME(goods_addtime)) as weekval,WEEKDAY(FROM_UNIXTIME(goods_addtime))+1 as dayofweekval ';
  270. $goodslist = Db::name('goodscommon')->field($field)->where($where)->group('weekval,dayofweekval')->select()->toArray();
  271. if ($goodslist) {
  272. foreach ($goodslist as $k => $v) {
  273. if ($up_week == intval($v['weekval'])) {
  274. $up_arr[$v['dayofweekval']] = intval($v['allnum']);
  275. $uplist_arr[$v['dayofweekval']]['val'] = intval($v['allnum']);
  276. if (isset($count_arr['up'])) {
  277. $count_arr['up'] += intval($v['allnum']);
  278. } else {
  279. $count_arr['up'] = 0;
  280. }
  281. }
  282. if ($curr_week == $v['weekval']) {
  283. $curr_arr[$v['dayofweekval']] = intval($v['allnum']);
  284. $currlist_arr[$v['dayofweekval']]['val'] = intval($v['allnum']);
  285. if (isset($count_arr['curr'])) {
  286. $count_arr['curr'] += intval($v['allnum']);
  287. } else {
  288. $count_arr['curr'] = 0;
  289. }
  290. }
  291. }
  292. }
  293. $stat_arr['series'][0]['name'] = lang('last_week');
  294. $stat_arr['series'][0]['data'] = array_values($up_arr);
  295. $stat_arr['series'][1]['name'] = lang('this_week');
  296. $stat_arr['series'][1]['data'] = array_values($curr_arr);
  297. //得到统计图数据
  298. $stat_arr['title'] = lang('new_goods_statistics');
  299. $stat_arr['yAxis'] = lang('new_goods_count');
  300. $stat_json = getStatData_LineLabels($stat_arr);
  301. View::assign('stat_json_week_goods', $stat_json);
  302. }
  303. /**
  304. * 获取本周新增会员数量
  305. */
  306. private function _get_week_member()
  307. {
  308. $field = ' COUNT(*) as allnum ';
  309. $current_weekarr = getWeek_SdateAndEdate(TIMESTAMP);
  310. $stime = strtotime($current_weekarr['sdate']) - 86400 * 7;
  311. $etime = strtotime($current_weekarr['edate']) + 86400 - 1;
  312. //总计的查询时间
  313. $count_arr['seartime'] = ($stime + 86400 * 7) . '|' . $etime;
  314. $up_week = @date('W', $stime); //上周
  315. $curr_week = @date('W', $etime); //本周
  316. //构造横轴数据
  317. for ($i = 1; $i <= 7; $i++) {
  318. //统计图数据
  319. $up_arr[$i] = 0;
  320. $curr_arr[$i] = 0;
  321. $tmp_weekarr = getSystemWeekArr();
  322. //统计表数据
  323. $currlist_arr[$i]['timetext'] = $tmp_weekarr[$i];
  324. //方便搜索会员列表,计算开始时间和结束时间
  325. $currlist_arr[$i]['stime'] = strtotime($current_weekarr['sdate']) + ($i - 1) * 86400;
  326. $currlist_arr[$i]['etime'] = $currlist_arr[$i]['stime'] + 86400 - 1;
  327. $uplist_arr[$i]['val'] = 0;
  328. $currlist_arr[$i]['val'] = 0;
  329. //横轴
  330. $stat_arr['xAxis']['categories'][] = $tmp_weekarr[$i];
  331. unset($tmp_weekarr);
  332. }
  333. $where = array();
  334. $where[] = array('member_addtime', 'between', array($stime, $etime));
  335. $field .= ',WEEKOFYEAR(FROM_UNIXTIME(member_addtime)) as weekval,WEEKDAY(FROM_UNIXTIME(member_addtime))+1 as dayofweekval ';
  336. $memberlist = Db::name('member')->field($field)->where($where)->group('weekval,dayofweekval')->select()->toArray();
  337. if ($memberlist) {
  338. foreach ($memberlist as $k => $v) {
  339. if ($up_week == intval($v['weekval'])) {
  340. $up_arr[$v['dayofweekval']] = intval($v['allnum']);
  341. $uplist_arr[$v['dayofweekval']]['val'] = intval($v['allnum']);
  342. if (isset($count_arr['up'])) {
  343. $count_arr['up'] += intval($v['allnum']);
  344. } else {
  345. $count_arr['up'] = 0;
  346. }
  347. }
  348. if ($curr_week == $v['weekval']) {
  349. $curr_arr[$v['dayofweekval']] = intval($v['allnum']);
  350. $currlist_arr[$v['dayofweekval']]['val'] = intval($v['allnum']);
  351. if (isset($count_arr['curr'])) {
  352. $count_arr['curr'] += intval($v['allnum']);
  353. } else {
  354. $count_arr['curr'] = 0;
  355. }
  356. }
  357. }
  358. }
  359. $stat_arr['series'][0]['name'] = lang('last_week');
  360. $stat_arr['series'][0]['data'] = array_values($up_arr);
  361. $stat_arr['series'][1]['name'] = lang('this_week');
  362. $stat_arr['series'][1]['data'] = array_values($curr_arr);
  363. //得到统计图数据
  364. $stat_arr['title'] = lang('new_member_statistics');
  365. $stat_arr['yAxis'] = lang('new_member_count');
  366. $stat_json = getStatData_LineLabels($stat_arr);
  367. View::assign('stat_json_week_member', $stat_json);
  368. }
  369. /**
  370. * 获取当前数据库版本
  371. */
  372. private function _mysql_version()
  373. {
  374. $version = Db::query("select version() as ver");
  375. return $version[0]['ver'];
  376. }
  377. function aboutus()
  378. {
  379. $this->setAdminCurItem('aboutus');
  380. return View::fetch();
  381. }
  382. /**
  383. * 统计
  384. */
  385. public function statistics()
  386. {
  387. $statistics = array();
  388. // 本周开始时间点
  389. $tmp_time = mktime(0, 0, 0, date('m'), date('d'), date('Y')) - (date('w') == 0 ? 7 : date('w') - 1) * 24 * 60 * 60;
  390. /**
  391. * 会员
  392. */
  393. $member_model = model('member');
  394. // 会员总数
  395. $statistics['member'] = $member_model->getMemberCount(array());
  396. // 新增会员数
  397. $statistics['week_add_member'] = $member_model->getMemberCount(array(array('member_addtime', '>=', $tmp_time)));
  398. // 预存款提现
  399. $statistics['cashlist'] = model('predeposit')->getPdcashCount(array('pdc_payment_state' => 0));
  400. // 会员认证
  401. $statistics['member_auth'] = $member_model->getMemberCount(array(array('member_auth_state', '=', 1)));
  402. /**
  403. * 店铺
  404. */
  405. $store_model = model('store');
  406. // 店铺总数
  407. $statistics['store'] = model('store')->getStoreCount(array());
  408. // 店铺申请数
  409. $statistics['store_joinin'] = model('storejoinin')->getStorejoininCount(array(array('joinin_state', 'in', array(10, 11))));
  410. //经营类目申请
  411. $statistics['store_bind_class_applay'] = model('storebindclass')->getStorebindclassCount(array('storebindclass_state' => 0));
  412. //店铺续签申请
  413. $statistics['store_reopen_applay'] = model('storereopen')->getStorereopenCount(array('storereopen_state' => 1));
  414. // 即将到期
  415. $statistics['store_expire'] = $store_model->getStoreCount(array(array('store_state', '=', 1), array('store_endtime', 'between', array(TIMESTAMP, TIMESTAMP + 864000))));
  416. // 已经到期
  417. $statistics['store_expired'] = $store_model->getStoreCount(array(array('store_state', '=', 1), array('store_endtime', 'between', array(1, TIMESTAMP))));
  418. /**
  419. * 商品
  420. */
  421. $goods_model = model('goods');
  422. // 商品总数
  423. $statistics['goods'] = $goods_model->getGoodsCommonCount(array());
  424. // 新增商品数
  425. $statistics['week_add_product'] = $goods_model->getGoodsCommonCount(array(array('goods_addtime', '>=', $tmp_time)));
  426. // 等待审核
  427. $statistics['product_verify'] = $goods_model->getGoodsCommonWaitVerifyCount(array());
  428. // 举报
  429. $statistics['inform_list'] = model('inform')->getInformCount(array('inform_state' => 1));
  430. // 品牌申请
  431. $statistics['brand_apply'] = model('brand')->getBrandCount(array('brand_apply' => '0'));
  432. /**
  433. * 交易
  434. */
  435. $order_model = model('order');
  436. $refundreturn_model = model('refundreturn');
  437. $vrrefund_model = model('vrrefund');
  438. $complain_model = model('complain');
  439. // 订单总数
  440. $statistics['order'] = $order_model->getOrderCount(array());
  441. // 退款
  442. $statistics['refund'] = $refundreturn_model->getRefundreturnCount(array('refund_type' => 1, 'refund_state' => 2));
  443. // 退货
  444. $statistics['return'] = $refundreturn_model->getRefundreturnCount(array('refund_type' => 2, 'refund_state' => 2));
  445. // 虚拟订单退款
  446. $statistics['vr_refund'] = $vrrefund_model->getVrrefundCount(array('admin_state' => 1));
  447. // 投诉
  448. $statistics['complain_new_list'] = $complain_model->getComplainCount(array('complain_state' => 10));
  449. // 待仲裁
  450. $statistics['complain_handle_list'] = $complain_model->getComplainCount(array('complain_state' => 40));
  451. /**
  452. * 运营
  453. */
  454. // 抢购数量
  455. $statistics['groupbuy_verify_list'] = model('groupbuy')->getGroupbuyCount(array('groupbuy_state' => 10));
  456. // 积分订单
  457. $pointsorder_model = model('pointorder');
  458. $condition = array();
  459. $condition = array(array('point_orderstate', 'in', array(11, 20)));
  460. $statistics['points_order'] = $pointsorder_model->getPointorderCount($condition);
  461. //待审核账单
  462. $bill_model = model('bill');
  463. $statistics['check_billno'] = $bill_model->getOrderbillCount(array('ob_state' => BILL_STATE_STORE_COFIRM));
  464. //待支付账单
  465. $statistics['pay_billno'] = $bill_model->getOrderbillCount(array('ob_state' => BILL_STATE_STORE_COFIRM));
  466. // 平台客服
  467. $statistics['mall_consult'] = model('mallconsult')->getMallconsultCount(array('mallconsult_isreply' => 0));
  468. // 服务站
  469. $statistics['chain'] = model('chain')->getChainWaitVerifyCount(array());
  470. echo json_encode($statistics);
  471. exit;
  472. }
  473. /**
  474. * h5链接
  475. */
  476. public function h5_link()
  477. {
  478. return View::fetch();
  479. }
  480. public function h5_activity()
  481. {
  482. $activity_model = model('activity');
  483. $keyword = input('param.keyword');
  484. $condition = array();
  485. $condition[] = array('activity_type', '=', 1); //只显示商品活动
  486. $condition[] = array('activity_state', '=', 1);
  487. if ($keyword) {
  488. $condition[] = array('activity_title', 'like', '%' . $keyword . '%');
  489. }
  490. $activity_list = $activity_model->getActivityList($condition, 10, 'activity_sort asc');
  491. View::assign('show_page', $activity_model->page_info->render());
  492. View::assign('activity_list', $activity_list);
  493. return View::fetch();
  494. }
  495. public function h5_live()
  496. {
  497. $condition = array();
  498. $store_model = model('store');
  499. $keyword = input('param.keyword');
  500. if (config('ds_config.live_type') == 1) {
  501. $minipro_live_model = model('minipro_live');
  502. if ($keyword) {
  503. $condition[] = array('minipro_live_name', 'like', '%' . $keyword . '%');
  504. }
  505. $minipro_live_list = $minipro_live_model->getMiniproLiveList($condition);
  506. $store_list = array();
  507. foreach ($minipro_live_list as $key => $val) {
  508. if (!isset($store_list[$val['store_id']])) {
  509. $store_list[$val['store_id']] = $store_model->getStoreInfo(array('store_id' => $val['store_id']));
  510. }
  511. $minipro_live_list[$key]['store_name'] = $store_list[$val['store_id']]['store_name'] ? $store_list[$val['store_id']]['store_name'] : '';
  512. }
  513. View::assign('minipro_live_list', $minipro_live_list);
  514. View::assign('show_page', $minipro_live_model->page_info->render());
  515. } else {
  516. $live_apply_model = model('live_apply');
  517. $condition[] = array('live_apply_state', '=', 1);
  518. if ($keyword) {
  519. $condition[] = array('live_apply_name', 'like', '%' . $keyword . '%');
  520. }
  521. $live_apply_list = $live_apply_model->getLiveApplyList($condition, '*', 10, 'live_apply_state asc,live_apply_id desc');
  522. $store_list = array();
  523. foreach ($live_apply_list as $key => $val) {
  524. $live_apply_list[$key]['live_apply_user_name'] = '';
  525. switch ($val['live_apply_user_type']) {
  526. case 2:
  527. if (!isset($store_list[$val['live_apply_user_id']])) {
  528. $store_list[$val['live_apply_user_id']] = $store_model->getStoreInfo(array('store_id' => $val['live_apply_user_id']));
  529. }
  530. $live_apply_list[$key]['live_apply_user_name'] = $store_list[$val['live_apply_user_id']]['store_name'] ? $store_list[$val['live_apply_user_id']]['store_name'] : '';
  531. break;
  532. }
  533. }
  534. View::assign('live_apply_list', $live_apply_list);
  535. View::assign('show_page', $live_apply_model->page_info->render());
  536. }
  537. return View::fetch();
  538. }
  539. public function h5_market()
  540. {
  541. $condition = array();
  542. $keyword = input('param.keyword');
  543. $marketmanage_type = intval(input('param.type'));
  544. $condition[] = array('marketmanage_type', '=', $marketmanage_type);
  545. if ($keyword) {
  546. $condition[] = array('marketmanage_name', 'like', '%' . $keyword . '%');
  547. }
  548. $marketmanage_model = model('marketmanage');
  549. $marketmanage_list = $marketmanage_model->getMarketmanageList($condition, 10);
  550. View::assign('marketmanage_list', $marketmanage_list);
  551. View::assign('show_page', $marketmanage_model->page_info->render());
  552. return View::fetch();
  553. }
  554. public function h5_bonus()
  555. {
  556. $keyword = input('param.keyword');
  557. $condition = array();
  558. $condition[] = array('bonus_state', '=', 1);
  559. $condition[] = array('bonus_type', '=', 1);
  560. if ($keyword) {
  561. $condition[] = array('bonus_name', 'like', '%' . $keyword . '%');
  562. }
  563. $bonus_model = model('bonus');
  564. $bonus_list = $bonus_model->getBonusList($condition, 10);
  565. View::assign('bonus_list', $bonus_list);
  566. View::assign('show_page', $bonus_model->page_info->render());
  567. return View::fetch();
  568. }
  569. public function h5_special()
  570. {
  571. $keyword = input('param.keyword');
  572. $editable_page_model = model('editable_page');
  573. $store_id = intval(input('param.store_id'));
  574. $condition = array();
  575. $condition[] = array('store_id', '=', $store_id);
  576. $condition[] = array('editable_page_client', '=', 'h5');
  577. if ($keyword) {
  578. $condition[] = array('editable_page_name', 'like', '%' . $keyword . '%');
  579. }
  580. $editable_page_list = $editable_page_model->getEditablePageList($condition, 10);
  581. View::assign('show_page', $editable_page_model->page_info->render());
  582. View::assign('editable_page_list', $editable_page_list);
  583. return View::fetch();
  584. }
  585. public function h5_point_prod()
  586. {
  587. $keyword = input('param.keyword');
  588. $pointprod_model = model('pointprod');
  589. $condition = array();
  590. $condition[] = array('pgoods_show', '=', 1);
  591. if ($keyword) {
  592. $condition[] = array('pgoods_name', 'like', '%' . $keyword . '%');
  593. }
  594. $prod_list = $pointprod_model->getPointProdList($condition, '*', 'pgoods_sort asc,pgoods_id desc', 0, 10);
  595. //信息输出
  596. View::assign('prod_list', $prod_list);
  597. View::assign('show_page', $pointprod_model->page_info->render());
  598. return View::fetch();
  599. }
  600. public function h5_article_class()
  601. {
  602. if (input('param.ajax') == 1) {
  603. $articleclass_model = model('articleclass');
  604. $parent_id = intval(input('param.parent_id'));
  605. $condition = array();
  606. $condition[] = array('ac_parent_id', '=', $parent_id);
  607. $data = $articleclass_model->getArticleclassList($condition);
  608. ds_json_encode(10000, '', $data);
  609. } else {
  610. return View::fetch();
  611. }
  612. }
  613. public function h5_article()
  614. {
  615. $keyword = input('param.keyword');
  616. $article_model = model('article');
  617. $condition = array();
  618. $condition[] = array('article_show', '=', 1);
  619. if ($keyword) {
  620. $condition[] = array('article_title', 'like', '%' . $keyword . '%');
  621. }
  622. $article_list = $article_model->getArticleList($condition, 10);
  623. return View::fetch();
  624. }
  625. public function h5_document()
  626. {
  627. $condition = array();
  628. $keyword = input('param.keyword');
  629. $document_model = model('document');
  630. if ($keyword) {
  631. $condition[] = array('document_title', 'like', '%' . $keyword . '%');
  632. }
  633. $doc_list = $document_model->getDocumentList($condition);
  634. View::assign('doc_list', $doc_list);
  635. return View::fetch();
  636. }
  637. public function h5_store_class()
  638. {
  639. $storeclass_model = model('storeclass');
  640. $keyword = input('param.keyword');
  641. $store_class_list = $storeclass_model->getStoreclassList(array(), 10);
  642. View::assign('class_list', $store_class_list);
  643. View::assign('show_page', $storeclass_model->page_info->render());
  644. return View::fetch();
  645. }
  646. public function h5_store()
  647. {
  648. $keyword = input('param.keyword');
  649. $store_model = model('store');
  650. $condition = array();
  651. $condition[] = array('store_state', '=', 1);
  652. if ($keyword) {
  653. $condition[] = array('store_name', 'like', '%' . $keyword . '%');
  654. }
  655. $store_list = $store_model->getStoreList($condition, 10, 'store_id desc');
  656. View::assign('store_list', $store_list);
  657. View::assign('show_page', $store_model->page_info->render());
  658. return View::fetch();
  659. }
  660. public function h5_goods_class()
  661. {
  662. if (input('param.ajax') == 1) {
  663. $goodsclass_model = model('goodsclass');
  664. $parent_id = intval(input('param.parent_id'));
  665. $data = $goodsclass_model->getGoodsclassListByParentId($parent_id);
  666. ds_json_encode(10000, '', $data);
  667. } else {
  668. return View::fetch();
  669. }
  670. }
  671. public function h5_goods()
  672. {
  673. $keyword = input('param.keyword');
  674. $goods_model = model('goods');
  675. $condition = array();
  676. $condition[] = array('goods_state', '=', 1);
  677. $condition[] = array('goods_verify', '=', 1);
  678. if ($keyword) {
  679. $condition[] = array('goods_name', 'like', '%' . $keyword . '%');
  680. }
  681. $goods_list = $goods_model->getGoodsList($condition, '*', '', '', 0, 10);
  682. View::assign('goods_list', $goods_list);
  683. View::assign('show_page', $goods_model->page_info->render());
  684. return View::fetch();
  685. }
  686. }