Pmansongquota.php 3.0 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. * ============================================================================
  16. * 数据层模型
  17. */
  18. class Pmansongquota extends BaseModel
  19. {
  20. public $page_info;
  21. /**
  22. * 读取满即送套餐列表
  23. * @access public
  24. * @author csdeshang
  25. * @param array $condition 查询条件
  26. * @param int $pagesize 分页数
  27. * @param string $order 排序
  28. * @param string $field 所需字段
  29. * @return array 满即送套餐列表
  30. *
  31. */
  32. public function getMansongquotaList($condition, $pagesize = null, $order = '', $field = '*')
  33. {
  34. if ($pagesize) {
  35. $res = Db::name('pmansongquota')->field($field)->where($condition)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  36. $this->page_info = $res;
  37. $result = $res->items();
  38. } else {
  39. $result = Db::name('pmansongquota')->field($field)->where($condition)->order($order)->select()->toArray();
  40. }
  41. return $result;
  42. }
  43. /**
  44. * 读取单条记录
  45. * @access public
  46. * @author csdeshang
  47. * @param type $condition 条件
  48. * @return type
  49. */
  50. public function getMansongquotaInfo($condition)
  51. {
  52. $result = Db::name('pmansongquota')->where($condition)->find();
  53. return $result;
  54. }
  55. /**
  56. * 获取当前可用套餐
  57. * @access public
  58. * @author csdeshang
  59. * @param int $store_id 店铺id
  60. * @return array
  61. */
  62. public function getMansongquotaCurrent($store_id)
  63. {
  64. $condition = array();
  65. $condition[] = array('store_id', '=', $store_id);
  66. $condition[] = array('mansongquota_endtime', '>', TIMESTAMP);
  67. return $this->getMansongquotaInfo($condition);
  68. }
  69. /**
  70. * 增加
  71. * @access public
  72. * @author csdeshang
  73. * @param array $data 数据
  74. * @return bool
  75. */
  76. public function addMansongquota($data)
  77. {
  78. return Db::name('pmansongquota')->insertGetId($data);
  79. }
  80. /**
  81. * 更新
  82. * @access public
  83. * @author csdeshang
  84. * @param array $update 更新数据
  85. * @param array $condition 条件
  86. * @return bool
  87. */
  88. public function editMansongquota($update, $condition)
  89. {
  90. return Db::name('pmansongquota')->where($condition)->update($update);
  91. }
  92. /**
  93. * 删除
  94. * @access public
  95. * @author csdeshang
  96. * @param array $condition 条件
  97. * @return bool
  98. */
  99. public function delMansongquota($condition)
  100. {
  101. return Db::name('pmansongquota')->where($condition)->delete();
  102. }
  103. }