Pmansongquota.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /**
  3. * 满即送套餐模型
  4. *
  5. */
  6. namespace app\common\model;
  7. use think\facade\Db;
  8. /**
  9. * ============================================================================
  10. * DSMall多用户商城
  11. * ============================================================================
  12. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  13. * 网站地址: http://www.csdeshang.com
  14. * ----------------------------------------------------------------------------
  15. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  16. * 不允许对程序代码以任何形式任何目的的再发布。
  17. * ============================================================================
  18. * 数据层模型
  19. */
  20. class Pmansongquota extends BaseModel
  21. {
  22. public $page_info;
  23. /**
  24. * 读取满即送套餐列表
  25. * @access public
  26. * @author csdeshang
  27. * @param array $condition 查询条件
  28. * @param int $pagesize 分页数
  29. * @param string $order 排序
  30. * @param string $field 所需字段
  31. * @return array 满即送套餐列表
  32. *
  33. */
  34. public function getMansongquotaList($condition, $pagesize = null, $order = '', $field = '*')
  35. {
  36. if($pagesize){
  37. $res = Db::name('pmansongquota')->field($field)->where($condition)->order($order)->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false);
  38. $this->page_info = $res;
  39. $result = $res->items();
  40. }else{
  41. $result = Db::name('pmansongquota')->field($field)->where($condition)->order($order)->select()->toArray();
  42. }
  43. return $result;
  44. }
  45. /**
  46. * 读取单条记录
  47. * @access public
  48. * @author csdeshang
  49. * @param type $condition 条件
  50. * @return type
  51. */
  52. public function getMansongquotaInfo($condition)
  53. {
  54. $result = Db::name('pmansongquota')->where($condition)->find();
  55. return $result;
  56. }
  57. /**
  58. * 获取当前可用套餐
  59. * @access public
  60. * @author csdeshang
  61. * @param int $store_id 店铺id
  62. * @return array
  63. */
  64. public function getMansongquotaCurrent($store_id)
  65. {
  66. $condition = array();
  67. $condition[] = array('store_id', '=', $store_id);
  68. $condition[] = array('mansongquota_endtime', '>', TIMESTAMP);
  69. return $this->getMansongquotaInfo($condition);
  70. }
  71. /**
  72. * 增加
  73. * @access public
  74. * @author csdeshang
  75. * @param array $data 数据
  76. * @return bool
  77. */
  78. public function addMansongquota($data)
  79. {
  80. return Db::name('pmansongquota')->insertGetId($data);
  81. }
  82. /**
  83. * 更新
  84. * @access public
  85. * @author csdeshang
  86. * @param array $update 更新数据
  87. * @param array $condition 条件
  88. * @return bool
  89. */
  90. public function editMansongquota($update, $condition)
  91. {
  92. return Db::name('pmansongquota')->where($condition)->update($update);
  93. }
  94. /**
  95. * 删除
  96. * @access public
  97. * @author csdeshang
  98. * @param array $condition 条件
  99. * @return bool
  100. */
  101. public function delMansongquota($condition)
  102. {
  103. return Db::name('pmansongquota')->where($condition)->delete();
  104. }
  105. }