Wholesalequota.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. /**
  3. * 批发套餐模型
  4. */
  5. namespace app\common\model;
  6. use think\facade\Db;
  7. /**
  8. * ============================================================================
  9. *
  10. * ============================================================================
  11. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  12. * 网站地址: https://www.valimart.net/
  13. * ----------------------------------------------------------------------------
  14. *
  15. * ============================================================================
  16. * 数据层模型
  17. */
  18. class Wholesalequota 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. public function getWholesalequotaList($condition, $pagesize = null, $order = '', $field = '*')
  32. {
  33. if($pagesize){
  34. $res = Db::name('wholesalequota')->field($field)->where($condition)->order($order)->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false);
  35. $this->page_info = $res;
  36. $result = $res->items();
  37. }else{
  38. $result = Db::name('wholesalequota')->field($field)->where($condition)->order($order)->select()->toArray();
  39. }
  40. return $result;
  41. }
  42. /**
  43. * 读取单条记录
  44. * @access public
  45. * @author csdeshang
  46. * @param type $condition 条件
  47. * @return type
  48. */
  49. public function getWholesalequotaInfo($condition)
  50. {
  51. $result = Db::name('wholesalequota')->where($condition)->find();
  52. return $result;
  53. }
  54. /**
  55. * 获取当前可用套餐
  56. * @access public
  57. * @author csdeshang
  58. * @param type $store_id 店铺ID
  59. * @return type
  60. */
  61. public function getWholesalequotaCurrent($store_id)
  62. {
  63. $condition = array();
  64. $condition[] = array('store_id', '=', $store_id);
  65. $condition[] = array('wholesalequota_endtime', '>', TIMESTAMP);
  66. return $this->getWholesalequotaInfo($condition);
  67. }
  68. /**
  69. * 增加
  70. * @access public
  71. * @author csdeshang
  72. * @param type $data 数据
  73. * @return bool
  74. */
  75. public function addWholesalequota($data)
  76. {
  77. return Db::name('wholesalequota')->insertGetId($data);
  78. }
  79. /**
  80. * 更新
  81. * @access public
  82. * @author csdeshang
  83. * @param type $update 更新数据
  84. * @param type $condition 检索条件
  85. * @return bool
  86. */
  87. public function editWholesalequota($update, $condition)
  88. {
  89. return Db::name('wholesalequota')->where($condition)->update($update);
  90. }
  91. /**
  92. * 删除
  93. * @access public
  94. * @author csdeshang
  95. * @param type $condition 条件
  96. * @return bool
  97. */
  98. public function delWholesalequota($condition)
  99. {
  100. return Db::name('wholesalequota')->where($condition)->delete();
  101. }
  102. }