VideoDemandCourseGoods.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * Create date 2018/1/3 14:24
  4. * Author: 芸众商城 www.yunzshop.com
  5. */
  6. namespace app\common\services\goods;
  7. use app\common\components\BaseController;
  8. use Setting;
  9. class VideoDemandCourseGoods extends BaseController
  10. {
  11. //视频点播插件设置
  12. protected $videoDemand;
  13. public function __construct()
  14. {
  15. parent::__construct();
  16. $this->videoDemand = Setting::get('plugin.video_demand');
  17. }
  18. /**
  19. * 是否启用视频点播
  20. */
  21. public function whetherEnabled()
  22. {
  23. if (app('plugins')->isEnabled('video-demand')) {
  24. if ($this->videoDemand['is_video_demand']) {
  25. return true;
  26. }
  27. }
  28. return false;
  29. }
  30. /**
  31. * 是课程商品的id集合
  32. * @return [array] [$courseGoods_ids]
  33. */
  34. public function courseGoodsIds()
  35. {
  36. //是否启用视频点播
  37. $courseGoods_ids = [];
  38. if ($this->whetherEnabled()) {
  39. $courseGoods = \Yunshop\VideoDemand\models\CourseGoodsModel::getCourseGoodsIdsData()->toArray();
  40. foreach ($courseGoods as $value) {
  41. $courseGoods_ids[] = $value['goods_id'];
  42. }
  43. }
  44. return $courseGoods_ids;
  45. }
  46. /**
  47. * 商品是否是课程
  48. * @param [int] $goods_id [商品id]
  49. * @return int $data 0 不是|1 是
  50. */
  51. public function isCourse($goods_id)
  52. {
  53. if ($this->whetherEnabled()) {
  54. $data = \Yunshop\VideoDemand\models\CourseGoodsModel::uniacid()
  55. ->select('is_course')
  56. ->where('goods_id', $goods_id)
  57. ->value('is_course');
  58. }
  59. $data = $data === null ? 0 : $data;
  60. return $data;
  61. }
  62. }