Presellquota.php 2.8 KB

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