Ppintuanquota.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. /**
  3. * 秒杀套餐模型
  4. */
  5. namespace app\common\model;
  6. use think\facade\Db;
  7. /**
  8. *
  9. *
  10. * ----------------------------------------------------------------------------
  11. *
  12. * 数据层模型
  13. */
  14. class Ppintuanquota extends BaseModel
  15. {
  16. public $page_info;
  17. /**
  18. * 获取拼团套餐列表
  19. * @access public
  20. * @author csdeshang
  21. * @param type $condition 条件
  22. * @param type $pagesize 分页
  23. * @param type $order 排序
  24. * @param type $field 字段
  25. * @return type
  26. */
  27. public function getPintuanquotaList($condition, $pagesize = null, $order = '', $field = '*')
  28. {
  29. if ($pagesize) {
  30. $res = Db::name('ppintuanquota')->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('ppintuanquota')->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 getPintuanquotaInfo($condition)
  46. {
  47. $result = Db::name('ppintuanquota')->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 getPintuanquotaCurrent($store_id)
  58. {
  59. $condition = array();
  60. $condition[] = array('store_id', '=', $store_id);
  61. $condition[] = array('pintuanquota_endtime', '>', TIMESTAMP);
  62. return $this->getPintuanquotaInfo($condition);
  63. }
  64. /**
  65. * 增加
  66. * @access public
  67. * @author csdeshang
  68. * @param type $data 数据
  69. * @return type
  70. */
  71. public function addPintuanquota($data)
  72. {
  73. return Db::name('ppintuanquota')->insertGetId($data);
  74. }
  75. /**
  76. * 更新
  77. * @access public
  78. * @author csdeshang
  79. * @param type $update 更新数据
  80. * @param type $condition 条件
  81. * @return type
  82. */
  83. public function editPintuanquota($update, $condition)
  84. {
  85. return Db::name('ppintuanquota')->where($condition)->update($update);
  86. }
  87. /**
  88. * 删除
  89. * @access public
  90. * @author csdeshang
  91. * @param type $condition 条件
  92. * @return type
  93. */
  94. public function delPintuanquota($condition)
  95. {
  96. return Db::name('ppintuanquota')->where($condition)->delete();
  97. }
  98. }