GoodsListPromotion.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\bargain\event;
  11. use addon\bargain\model\Bargain;
  12. /**
  13. * 商品营销活动信息
  14. */
  15. class GoodsListPromotion
  16. {
  17. public function handle($param)
  18. {
  19. if (empty($param[ 'promotion' ]) || $param[ 'promotion' ] != 'bargain') return [];
  20. $condition = [
  21. [ 'pb.site_id', '=', $param[ 'site_id' ] ],
  22. [ 'pb.status', '=', 1 ],
  23. [ 'g.goods_state', '=', 1 ],
  24. [ 'g.is_delete', '=', 0 ]
  25. ];
  26. if (!empty($param[ 'goods_name' ])) {
  27. $condition[] = [ 'g.goods_name', 'like', '%' . $param[ 'goods_name' ] . '%' ];
  28. }
  29. if (!empty($param[ 'select_type' ]) && $param[ 'select_type' ] == 'selected' && isset($param[ 'goods_ids' ])) {
  30. $condition[] = [ 'g.goods_id', 'in', $param[ 'goods_ids' ] ];
  31. }
  32. if (!empty($param[ 'category_id' ])) {
  33. $condition[] = [ 'g.category_id', 'like', '%,' . $param[ 'category_id' ] . ',%' ];
  34. }
  35. if (!empty($param[ 'label_id' ])) {
  36. $condition[] = [ 'g.label_id', '=', $param[ 'label_id' ] ];
  37. }
  38. if (!empty($param[ 'goods_class' ])) {
  39. $condition[] = [ 'g.goods_class', '=', $param[ 'goods_class' ] ];
  40. }
  41. $field = 'pb.*,g.goods_name,g.goods_image,g.price,g.recommend_way,sku.sku_id,sku.price,sku.sku_name,sku.sku_image,sku.stock as goods_stock,g.label_name,g.goods_class_name';
  42. $model = new Bargain();
  43. $list = $model->getBargainPageList($condition, $param[ 'page' ], $param[ 'page_size' ], 'g.create_time desc', $field);
  44. return $list;
  45. }
  46. }