Groupbuyquota.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  9. * 网站地址: https://www.valimart.net/
  10. * ----------------------------------------------------------------------------
  11. *
  12. * ============================================================================
  13. * 数据层模型
  14. */
  15. class Groupbuyquota extends BaseModel
  16. {
  17. public $page_info;
  18. /**
  19. * 读取抢购套餐列表
  20. * @access public
  21. * @author csdeshang
  22. * @param array $condition 查询条件
  23. * @param int $pagesize 分页数
  24. * @param string $order 排序
  25. * @param string $field 所需字段
  26. * @return array 抢购套餐列表
  27. *
  28. */
  29. public function getGroupbuyquotaList($condition, $pagesize = null, $order = '', $field = '*')
  30. {
  31. if($pagesize){
  32. $result = Db::name('groupbuyquota')->field($field)->where($condition)->order($order)->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false);
  33. $this->page_info=$result;
  34. $result=$result->items();
  35. }else{
  36. $result=Db::name('groupbuyquota')->field($field)->where($condition)->order($order)->select()->toArray();
  37. }
  38. return $result;
  39. }
  40. /**
  41. * 读取单条记录
  42. * @access public
  43. * @author csdeshang
  44. * @param array $condition 查询条件
  45. * @return array
  46. */
  47. public function getGroupbuyquotaInfo($condition)
  48. {
  49. $result = Db::name('groupbuyquota')->where($condition)->find();
  50. return $result;
  51. }
  52. /**
  53. * 获取当前可用套餐
  54. * @access public
  55. * @author csdeshang
  56. * @param int $store_id 店铺id
  57. * @return array
  58. */
  59. public function getGroupbuyquotaCurrent($store_id)
  60. {
  61. $condition = array();
  62. $condition[] = array('store_id','=',$store_id);
  63. $condition[] = array('groupbuyquota_endtime','>',TIMESTAMP);
  64. return $this->getGroupbuyquotaInfo($condition);
  65. }
  66. /**
  67. * 增加
  68. * @access public
  69. * @author csdeshang
  70. * @param array $data 参数内容
  71. * @return bool
  72. */
  73. public function addGroupbuyquota($data)
  74. {
  75. return Db::name('groupbuyquota')->insertGetId($data);
  76. }
  77. /**
  78. * 编辑更新抢购套餐
  79. * @access public
  80. * @author csdeshang
  81. * @param type $update 更新数据
  82. * @param type $condition 检索条件
  83. * @return bool
  84. */
  85. public function editGroupbuyquota($update, $condition)
  86. {
  87. return Db::name('groupbuyquota')->where($condition)->update($update);
  88. }
  89. /*
  90. * 删除
  91. * @access public
  92. * @author csdeshang
  93. * @param array $condition 检索条件
  94. * @return bool
  95. */
  96. public function delGroupbuyquota($condition)
  97. {
  98. return Db::name('groupbuyquota')->where($condition)->delete();
  99. }
  100. }