stat_favorites.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: james
  5. * Date: 2017/4/6
  6. * Time: 上午10:43
  7. */
  8. defined('InShopNC') or exit('Access Invalid!');
  9. class stat_favoritesControl extends SystemControl
  10. {
  11. public function __construct()
  12. {
  13. parent::__construct();
  14. }
  15. public function indexOp()
  16. {
  17. $goods_name = trim($_REQUEST['goods_name']);
  18. $brand_name = trim($_REQUEST['brand_name']);
  19. $sort = trim($_REQUEST['sort']);
  20. $cond = [];
  21. if(!empty($goods_name)) {
  22. $cond['goods_name'] = array('like',"%{$goods_name}%");
  23. }
  24. else if (!empty($brand_name))
  25. {
  26. $cond['brand_name'] = array('like',"%{$brand_name}%");
  27. }
  28. if($sort == 'descending') {
  29. $order = 'nc_count desc';
  30. }
  31. elseif($sort == 'ascending') {
  32. $order = 'nc_count asc';
  33. }
  34. else {
  35. $order = '';
  36. }
  37. $mod_favorites = Model('favorites');
  38. $cond = array('fv_type=goods');
  39. $on = 'goods.goods_id=favorites.fav_id';
  40. $mod_goods = Model();
  41. $result = $mod_goods->table('goods,favorites')->join('inner')->on($on)->field('goods_name,goods_id,count(*) as nc_count')->group('fav_id')->where($cond)->select();
  42. Tpl::showpage('stat.collection.list');
  43. }
  44. }