p_xianshi_quota.model.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * 限时折扣套餐模型
  4. *
  5. *
  6. *
  7. *
  8. */
  9. defined('InShopNC') or exit('Access Invalid!');
  10. class p_xianshi_quotaModel extends Model{
  11. public function __construct(){
  12. parent::__construct('p_xianshi_quota');
  13. }
  14. /**
  15. * 读取限时折扣套餐列表
  16. * @param array $condition 查询条件
  17. * @param int $page 分页数
  18. * @param string $order 排序
  19. * @param string $field 所需字段
  20. * @return array 限时折扣套餐列表
  21. *
  22. */
  23. public function getXianshiQuotaList($condition, $page=null, $order='', $field='*') {
  24. $result = $this->field($field)->where($condition)->page($page)->order($order)->select();
  25. return $result;
  26. }
  27. /**
  28. * 读取单条记录
  29. * @param array $condition
  30. *
  31. */
  32. public function getXianshiQuotaInfo($condition) {
  33. $result = $this->where($condition)->find();
  34. return $result;
  35. }
  36. /**
  37. * 获取当前可用套餐
  38. * @param int $store_id
  39. * @return array
  40. *
  41. */
  42. public function getXianshiQuotaCurrent($store_id) {
  43. $condition = array();
  44. $condition['store_id'] = $store_id;
  45. $condition['end_time'] = array('gt', time());
  46. return $this->getXianshiQuotaInfo($condition);
  47. }
  48. /*
  49. * 增加
  50. * @param array $param
  51. * @return bool
  52. *
  53. */
  54. public function addXianshiQuota($param){
  55. return $this->insert($param);
  56. }
  57. /*
  58. * 更新
  59. * @param array $update
  60. * @param array $condition
  61. * @return bool
  62. *
  63. */
  64. public function editXianshiQuota($update, $condition){
  65. return $this->where($condition)->update($update);
  66. }
  67. /*
  68. * 删除
  69. * @param array $condition
  70. * @return bool
  71. *
  72. */
  73. public function delXianshiQuota($condition){
  74. return $this->where($condition)->delete();
  75. }
  76. }