Presellquota.php 3.0 KB

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