Pmgdiscountquota.php 3.3 KB

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