Plan.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace app\shop\controller\user;
  3. use app\shop\controller\Controller;
  4. use app\shop\model\user\BalancePlan as PlanModel;
  5. use app\shop\model\user\BalanceOrder as BalanceOrderModel;
  6. /**
  7. * 充值控制器
  8. */
  9. class Plan extends Controller
  10. {
  11. /**
  12. * 列表
  13. */
  14. public function index()
  15. {
  16. $model = new PlanModel();
  17. $list = $model->getList($this->postData());
  18. return $this->renderSuccess('', compact('list'));
  19. }
  20. /**
  21. * 添加
  22. */
  23. public function add()
  24. {
  25. $model = new PlanModel();
  26. // 新增记录
  27. if ($model->add($this->postData())) {
  28. return $this->renderSuccess('添加成功');
  29. }
  30. return $this->renderError('添加失败');
  31. }
  32. /**
  33. * 更新
  34. */
  35. public function edit($plan_id)
  36. {
  37. $detail = PlanModel::detail($plan_id);
  38. if($this->request->isGet()){
  39. return $this->renderSuccess('', compact('detail'));
  40. }
  41. if ($detail->edit($this->postData())) {
  42. return $this->renderSuccess('更新成功');
  43. }
  44. return $this->renderError('更新失败');
  45. }
  46. /**
  47. * 删除
  48. */
  49. public function delete($plan_id)
  50. {
  51. // 详情
  52. $model = new PlanModel;
  53. // 更新记录
  54. if ($model->setDelete(['plan_id' => $plan_id])) {
  55. return $this->renderSuccess('删除成功');
  56. }
  57. return $this->renderError('删除失败');
  58. }
  59. /**
  60. * 充值记录
  61. */
  62. public function log()
  63. {
  64. $model = new BalanceOrderModel();
  65. $list = $model->getList($this->postData());
  66. return $this->renderSuccess('', compact('list'));
  67. }
  68. }