Pmansongquota.php 3.1 KB

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