Presellquota.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. * DSMall多用户商城
  7. * ============================================================================
  8. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  9. * 网站地址: http://www.csdeshang.com
  10. * ----------------------------------------------------------------------------
  11. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  12. * 不允许对程序代码以任何形式任何目的的再发布。
  13. * ============================================================================
  14. * 数据层模型
  15. */
  16. class Presellquota extends BaseModel
  17. {
  18. public $page_info;
  19. /**
  20. * 读取预售套餐列表
  21. * @access public
  22. * @author csdeshang
  23. * @param array $condition 查询条件
  24. * @param int $pagesize 分页数
  25. * @param string $order 排序
  26. * @param string $field 所需字段
  27. * @return array 预售套餐列表
  28. *
  29. */
  30. public function getPresellquotaList($condition, $pagesize = null, $order = '', $field = '*')
  31. {
  32. if($pagesize){
  33. $result = Db::name('presellquota')->field($field)->where($condition)->order($order)->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false);
  34. $this->page_info=$result;
  35. $result=$result->items();
  36. }else{
  37. $result=Db::name('presellquota')->field($field)->where($condition)->order($order)->select()->toArray();
  38. }
  39. return $result;
  40. }
  41. /**
  42. * 读取单条记录
  43. * @access public
  44. * @author csdeshang
  45. * @param array $condition 查询条件
  46. * @return array
  47. */
  48. public function getPresellquotaInfo($condition)
  49. {
  50. $result = Db::name('presellquota')->where($condition)->find();
  51. return $result;
  52. }
  53. /**
  54. * 获取当前可用套餐
  55. * @access public
  56. * @author csdeshang
  57. * @param int $store_id 店铺id
  58. * @return array
  59. */
  60. public function getPresellquotaCurrent($store_id)
  61. {
  62. $condition = array();
  63. $condition[] = array('store_id','=',$store_id);
  64. $condition[] = array('presellquota_endtime','>',TIMESTAMP);
  65. return $this->getPresellquotaInfo($condition);
  66. }
  67. /**
  68. * 增加
  69. * @access public
  70. * @author csdeshang
  71. * @param array $data 参数内容
  72. * @return bool
  73. */
  74. public function addPresellquota($data)
  75. {
  76. return Db::name('presellquota')->insertGetId($data);
  77. }
  78. /**
  79. * 编辑更新预售套餐
  80. * @access public
  81. * @author csdeshang
  82. * @param type $update 更新数据
  83. * @param type $condition 检索条件
  84. * @return bool
  85. */
  86. public function editPresellquota($update, $condition)
  87. {
  88. return Db::name('presellquota')->where($condition)->update($update);
  89. }
  90. /*
  91. * 删除
  92. * @access public
  93. * @author csdeshang
  94. * @param array $condition 检索条件
  95. * @return bool
  96. */
  97. public function delPresellquota($condition)
  98. {
  99. return Db::name('presellquota')->where($condition)->delete();
  100. }
  101. }