stat_anotice.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. defined('InShopNC') or exit('Access Invalid!');
  3. class stat_anoticeControl extends SystemControl
  4. {
  5. public function __construct() {
  6. parent::__construct();
  7. }
  8. public function indexOp()
  9. {
  10. $goods_name = trim($_REQUEST['goods_name']);
  11. $sort = trim($_REQUEST['sort']);
  12. $cond = [];
  13. if(!empty($goods_name)) {
  14. $cond['goods_name'] = array('like',"%{$goods_name}%");
  15. }
  16. if($sort == 'descending') {
  17. $order = 'nc_count desc';
  18. }
  19. elseif($sort == 'ascending') {
  20. $order = 'nc_count asc';
  21. }
  22. else {
  23. $order = '';
  24. }
  25. $mod_notice = Model('arrival_notice');
  26. $result = $mod_notice->where($cond)->field('count(*) as nc_count,goods_id,goods_name')->group('goods_id')->order($order)->select();
  27. Tpl::output('list', $result);
  28. Tpl::showpage('stat.anotice.list');
  29. }
  30. public function favoritesOp()
  31. {
  32. $goods_name = trim($_REQUEST['goods_name']);
  33. $sort = trim($_REQUEST['sort']);
  34. $cond = [];
  35. if(!empty($goods_name)) {
  36. $cond['goods_name'] = array('like',"%{$goods_name}%");
  37. }
  38. if($sort == 'descending') {
  39. $order = 'nc_count desc';
  40. }
  41. elseif($sort == 'ascending') {
  42. $order = 'nc_count asc';
  43. }
  44. else {
  45. $order = '';
  46. }
  47. $cond = array('fv_type=goods');
  48. $on = 'goods.goods_id=favorites.fav_id';
  49. $mod = Model();
  50. $result = $mod->table('goods,favorites')->join('inner')->on($on)->where($cond)->field('goods_name,goods_id,count(*) as nc_count')->group('fav_id')->order($order)->select();
  51. Tpl::output('list', $result);
  52. Tpl::showpage('stat.anotice.favorite.list');
  53. }
  54. public function fcodeOp()
  55. {
  56. $mod_goods = Model('goods');
  57. $mod_fcode = Model('goods_fcode');
  58. $items = $mod_fcode->field('goods_commonid,batch_code,count(*) as nc_count')->group('goods_commonid,batch_code')->select();
  59. $result = [];
  60. foreach ($items as $item)
  61. {
  62. $val = [];
  63. $val['goods_commonid'] = $item['goods_commonid'];
  64. $val['batch_code'] = $item['batch_code'];
  65. $val['count'] = $item['nc_count'];
  66. $unused = $mod_fcode->where(array('goods_commonid' => $item['goods_commonid'],'batch_code' => $item['batch_code'],'fc_state' => 0))->count();
  67. $binded = $mod_fcode->where(array('goods_commonid' => $item['goods_commonid'],'batch_code' => $item['batch_code'],'grab_state' => 2))->count();
  68. $val['used'] = $item['nc_count'] - $unused;
  69. $val['binded'] = $binded;
  70. $url = "https://passport.lrlz.com/mobile/index.php?act=fcode&op=index&common_id={$item['goods_commonid']}&batch_code={$item['batch_code']}";
  71. $val['fc_link'] = $url;
  72. $goods = $mod_goods->where(array('goods_commonid' => $item['goods_commonid']))->limit(1)->select();
  73. if(empty($goods)) {
  74. $val['goods_name'] = "不存在了!";
  75. } else {
  76. $val['goods_name'] = $goods[0]['goods_name'];
  77. }
  78. $result[] = $val;
  79. }
  80. Tpl::output('list', $result);
  81. Tpl::showpage('stat.anotice.fcode.list');
  82. }
  83. }