Pbargainquota.php 2.9 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. * ============================================================================
  15. * 数据层模型
  16. */
  17. class Pbargainquota extends BaseModel
  18. {
  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. {
  32. if ($pagesize) {
  33. $res = Db::name('pbargainquota')->field($field)->where($condition)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  34. $this->page_info = $res;
  35. $result = $res->items();
  36. } else {
  37. $result = Db::name('pbargainquota')->field($field)->where($condition)->order($order)->select()->toArray();
  38. }
  39. return $result;
  40. }
  41. /**
  42. * 读取单条记录
  43. * @access public
  44. * @author csdeshang
  45. * @param type $condition 条件
  46. * @return type
  47. */
  48. public function getBargainquotaInfo($condition)
  49. {
  50. $result = Db::name('pbargainquota')->where($condition)->find();
  51. return $result;
  52. }
  53. /**
  54. * 获取当前可用套餐
  55. * @access public
  56. * @author csdeshang
  57. * @param type $store_id 店铺ID
  58. * @return type
  59. */
  60. public function getBargainquotaCurrent($store_id)
  61. {
  62. $condition = array();
  63. $condition[] = array('store_id', '=', $store_id);
  64. $condition[] = array('bargainquota_endtime', '>', TIMESTAMP);
  65. return $this->getBargainquotaInfo($condition);
  66. }
  67. /**
  68. * 增加
  69. * @access public
  70. * @author csdeshang
  71. * @param type $data 数据
  72. * @return type
  73. */
  74. public function addBargainquota($data)
  75. {
  76. return Db::name('pbargainquota')->insertGetId($data);
  77. }
  78. /**
  79. * 更新
  80. * @access public
  81. * @author csdeshang
  82. * @param type $update 更新数据
  83. * @param type $condition 条件
  84. * @return type
  85. */
  86. public function editBargainquota($update, $condition)
  87. {
  88. return Db::name('pbargainquota')->where($condition)->update($update);
  89. }
  90. /**
  91. * 删除
  92. * @access public
  93. * @author csdeshang
  94. * @param type $condition 条件
  95. * @return type
  96. */
  97. public function delBargainquota($condition)
  98. {
  99. return Db::name('pbargainquota')->where($condition)->delete();
  100. }
  101. }