Pxianshiquota.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. /**
  3. * 秒杀套餐模型
  4. */
  5. namespace app\common\model;
  6. use think\facade\Db;
  7. /**
  8. *
  9. *
  10. * ----------------------------------------------------------------------------
  11. *
  12. * 数据层模型
  13. */
  14. class Pxianshiquota extends BaseModel
  15. {
  16. public $page_info;
  17. /**
  18. * 读取秒杀套餐列表
  19. * @access public
  20. * @author csdeshang
  21. * @param array $condition 条件
  22. * @param int $pagesize 分页
  23. * @param string $order 排序
  24. * @param string $field 字段
  25. * @return array 秒杀套餐列表
  26. */
  27. public function getXianshiquotaList($condition, $pagesize = null, $order = '', $field = '*')
  28. {
  29. if ($pagesize) {
  30. $res = Db::name('pxianshiquota')->field($field)->where($condition)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  31. $this->page_info = $res;
  32. $result = $res->items();
  33. } else {
  34. $result = Db::name('pxianshiquota')->field($field)->where($condition)->order($order)->select()->toArray();
  35. }
  36. return $result;
  37. }
  38. /**
  39. * 读取单条记录
  40. * @access public
  41. * @author csdeshang
  42. * @param type $condition 条件
  43. * @return type
  44. */
  45. public function getXianshiquotaInfo($condition)
  46. {
  47. $result = Db::name('pxianshiquota')->where($condition)->find();
  48. return $result;
  49. }
  50. /**
  51. * 获取当前可用套餐
  52. * @access public
  53. * @author csdeshang
  54. * @param type $store_id 店铺ID
  55. * @return type
  56. */
  57. public function getXianshiquotaCurrent($store_id)
  58. {
  59. $condition = array();
  60. $condition[] = array('store_id', '=', $store_id);
  61. $condition[] = array('xianshiquota_endtime', '>', TIMESTAMP);
  62. return $this->getXianshiquotaInfo($condition);
  63. }
  64. /**
  65. * 增加
  66. * @access public
  67. * @author csdeshang
  68. * @param type $data 数据
  69. * @return bool
  70. */
  71. public function addXianshiquota($data)
  72. {
  73. return Db::name('pxianshiquota')->insertGetId($data);
  74. }
  75. /**
  76. * 更新
  77. * @access public
  78. * @author csdeshang
  79. * @param type $update 更新数据
  80. * @param type $condition 检索条件
  81. * @return bool
  82. */
  83. public function editXianshiquota($update, $condition)
  84. {
  85. return Db::name('pxianshiquota')->where($condition)->update($update);
  86. }
  87. /**
  88. * 删除
  89. * @access public
  90. * @author csdeshang
  91. * @param type $condition 条件
  92. * @return bool
  93. */
  94. public function delXianshiquota($condition)
  95. {
  96. return Db::name('pxianshiquota')->where($condition)->delete();
  97. }
  98. }