Pbargainquota.php 3.0 KB

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