Plan.php 1.3 KB

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