Pmansongquota.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /**
  3. * 满即送套餐模型
  4. *
  5. */
  6. namespace app\common\model;
  7. use think\facade\Db;
  8. /**
  9. *
  10. *
  11. * ----------------------------------------------------------------------------
  12. *
  13. * 数据层模型
  14. */
  15. class Pmansongquota 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 getMansongquotaList($condition, $pagesize = null, $order = '', $field = '*')
  30. {
  31. if ($pagesize) {
  32. $res = Db::name('pmansongquota')->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('pmansongquota')->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 getMansongquotaInfo($condition)
  48. {
  49. $result = Db::name('pmansongquota')->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 getMansongquotaCurrent($store_id)
  60. {
  61. $condition = array();
  62. $condition[] = array('store_id', '=', $store_id);
  63. $condition[] = array('mansongquota_endtime', '>', TIMESTAMP);
  64. return $this->getMansongquotaInfo($condition);
  65. }
  66. /**
  67. * 增加
  68. * @access public
  69. * @author csdeshang
  70. * @param array $data 数据
  71. * @return bool
  72. */
  73. public function addMansongquota($data)
  74. {
  75. return Db::name('pmansongquota')->insertGetId($data);
  76. }
  77. /**
  78. * 更新
  79. * @access public
  80. * @author csdeshang
  81. * @param array $update 更新数据
  82. * @param array $condition 条件
  83. * @return bool
  84. */
  85. public function editMansongquota($update, $condition)
  86. {
  87. return Db::name('pmansongquota')->where($condition)->update($update);
  88. }
  89. /**
  90. * 删除
  91. * @access public
  92. * @author csdeshang
  93. * @param array $condition 条件
  94. * @return bool
  95. */
  96. public function delMansongquota($condition)
  97. {
  98. return Db::name('pmansongquota')->where($condition)->delete();
  99. }
  100. }