StoreSeckillTime.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace app\admin\model\ump;
  3. use crmeb\basic\BaseModel;
  4. use crmeb\traits\ModelTrait;
  5. class StoreSeckillTime extends BaseModel
  6. {
  7. /**
  8. * 模型名称
  9. * @var string
  10. */
  11. protected $name = 'store_seckill_time';
  12. use ModelTrait;
  13. /**
  14. * 秒杀添加时间段ID
  15. * @param $id
  16. * @param $time
  17. * @throws \Exception
  18. */
  19. public static function saveSeckillTime($id, $time)
  20. {
  21. self::where('seckill_id', $id)->delete();
  22. $data = [];
  23. foreach ($time as $k => $v) {
  24. $data[$k]['seckill_id'] = $id;
  25. $data[$k]['time_id'] = $v;
  26. }
  27. self::insertAll($data);
  28. }
  29. /**
  30. * 修改秒杀获取时间ID数组
  31. * @param $id
  32. * @return array
  33. */
  34. public static function getSeckillTime($id)
  35. {
  36. return self::where('seckill_id', $id)->column('time_id');
  37. }
  38. /**
  39. * 获取时间段内秒杀活动ID数组
  40. * @param $time_id
  41. * @return array
  42. */
  43. public static function getSeckillId($time_id)
  44. {
  45. return self::where('time_id', $time_id)->column('seckill_id');
  46. }
  47. }