Promotion.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /*
  3. * 前台促销列表
  4. */
  5. namespace app\home\controller;
  6. use think\facade\View;
  7. use think\facade\Lang;
  8. /**
  9. * ============================================================================
  10. * DSMall多用户商城
  11. * ============================================================================
  12. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  13. * 网站地址: http://www.csdeshang.com
  14. * ----------------------------------------------------------------------------
  15. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  16. * 不允许对程序代码以任何形式任何目的的再发布。
  17. * ============================================================================
  18. * 控制器
  19. */
  20. class Promotion extends BaseMall {
  21. const PAGESIZE = 16;
  22. public function initialize() {
  23. parent::initialize();
  24. Lang::load(base_path() . 'home/lang/'.config('lang.default_lang').'/promotion.lang.php');
  25. }
  26. public function index() {
  27. $xianshigoods_model = model('pxianshigoods');
  28. $goods_model = model('goods');
  29. $condition = array();
  30. $condition[]=array('xianshigoods_state','=',1);
  31. $condition[]=array('xianshigoods_starttime','<=', TIMESTAMP);
  32. $condition[]=array('xianshigoods_end_time','>', TIMESTAMP);
  33. $gc_id = intval(input('param.gc_id'));
  34. if ($gc_id) {
  35. $condition[]=array('gc_id_1','=',intval($gc_id));
  36. }
  37. $goods_list = $xianshigoods_model->getXianshigoodsExtendList($condition, self::PAGESIZE, 'xianshigoods_id desc');
  38. $xs_goods_list = array();
  39. foreach ($goods_list as $k => $goods_info) {
  40. $xs_goods_list[$goods_info['goods_id']] = $goods_info;
  41. $xs_goods_list[$goods_info['goods_id']]['image_url_240'] = goods_cthumb($goods_info['goods_image'], 240, $goods_info['store_id']);
  42. $xs_goods_list[$goods_info['goods_id']]['down_price'] = $goods_info['goods_price'] - $goods_info['xianshigoods_price'];
  43. }
  44. $condition = array(array('goods_id','in', array_keys($xs_goods_list)));
  45. $goods_list = $goods_model->getGoodsOnlineList($condition, 'goods_id,gc_id_1,evaluation_good_star,store_id,store_name', 0, '', self::PAGESIZE, null, false);
  46. $last_goods_list = array();
  47. foreach ($goods_list as $k => $goods_info) {
  48. $last_goods_list[$goods_info['goods_id']] = $xs_goods_list[$goods_info['goods_id']];
  49. $last_goods_list[$goods_info['goods_id']]['evaluation_good_star'] = $goods_info['evaluation_good_star'];
  50. $last_goods_list[$goods_info['goods_id']]['store_name'] = $goods_info['store_name'];
  51. if ($last_goods_list[$goods_info['goods_id']]['gc_id_1'] != $goods_info['gc_id_1']) {
  52. //兼容以前版本,如果秒杀商品表没有保存一级分类ID,则马上保存
  53. $xianshigoods_model->editXianshigoods(array('gc_id_1' => $goods_info['gc_id_1']), array('xianshigoods_id' => $last_goods_list[$goods_info['goods_id']]['xianshigoods_id']));
  54. }
  55. }
  56. //查询商品评分信息
  57. $goodsevallist = model('evaluategoods')->getEvaluategoodsList(array(array('geval_goodsid','in', array_keys($last_goods_list))));
  58. $eval_list = array();
  59. if (!empty($goodsevallist)) {
  60. foreach ($goodsevallist as $v) {
  61. if ($v['geval_content'] == '' || (isset($eval_list[$v['geval_goodsid']]) && count($eval_list[$v['geval_goodsid']]) >= 2))
  62. continue;
  63. $eval_list[$v['geval_goodsid']][] = $v;
  64. }
  65. }
  66. View::assign('goodsevallist', $eval_list);
  67. View::assign('goods_list', $last_goods_list);
  68. if (!empty(input('get.curpage'))) {
  69. return View::fetch($this->template_dir . 'item');
  70. } else {
  71. //导航
  72. $nav_link = array(
  73. 0 => array(
  74. 'title' => lang('homepage'),
  75. 'link' => HOME_SITE_URL,
  76. ),
  77. 1 => array(
  78. 'title' => lang('limited_time_discount')
  79. )
  80. );
  81. View::assign('nav_link_list', $nav_link);
  82. //查询商品分类
  83. $goods_class = model('goodsclass')->getGoodsclassListByParentId(0);
  84. View::assign('goods_class', $goods_class);
  85. View::assign('total_page', $xianshigoods_model->page_info->render());
  86. return View::fetch($this->template_dir . 'index');
  87. }
  88. }
  89. }
  90. ?>