Plan.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace app\store\model\recharge;
  3. use app\common\model\recharge\Plan as PlanModel;
  4. /**
  5. * 用户充值订单模型
  6. * Class Plan
  7. * @package app\store\model\recharge
  8. */
  9. class Plan extends PlanModel
  10. {
  11. /**
  12. * 获取优惠券列表
  13. * @return \think\Paginator
  14. * @throws \think\exception\DbException
  15. */
  16. public function getList()
  17. {
  18. return $this->where('is_delete', '=', 0)
  19. ->order(['sort' => 'asc', 'create_time' => 'desc'])
  20. ->paginate(15, false, [
  21. 'query' => request()->request()
  22. ]);
  23. }
  24. /**
  25. * 添加新记录
  26. * @param $data
  27. * @return false|int
  28. */
  29. public function add($data)
  30. {
  31. $data['wxapp_id'] = self::$wxapp_id;
  32. return $this->allowField(true)->save($data);
  33. }
  34. /**
  35. * 更新记录
  36. * @param $data
  37. * @return bool|int
  38. */
  39. public function edit($data)
  40. {
  41. return $this->allowField(true)->save($data) !== false;
  42. }
  43. /**
  44. * 删除记录 (软删除)
  45. * @return bool|int
  46. */
  47. public function setDelete()
  48. {
  49. return $this->save(['is_delete' => 1]) !== false;
  50. }
  51. }