WithdrawDetailController.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /****************************************************************
  3. * Author: libaojia
  4. * Date: 2017/11/14 上午10:54
  5. * Email: livsyitian@163.com
  6. * QQ: 995265288
  7. * User: 芸众商城 www.yunzshop.com
  8. ****************************************************************/
  9. namespace app\backend\modules\finance\controllers;
  10. use app\backend\modules\finance\models\Withdraw;
  11. use app\common\components\BaseController;
  12. use app\common\exceptions\AppException;
  13. use app\common\exceptions\ShopException;
  14. use app\common\facades\Setting;
  15. class WithdrawDetailController extends BaseController
  16. {
  17. //提现记录 model 实例
  18. protected $withdrawModel;
  19. /**
  20. * @throws ShopException
  21. */
  22. public function preAction()
  23. {
  24. parent::preAction(); // TODO: Change the autogenerated stub
  25. $this->setWithdrawModel();
  26. }
  27. /**
  28. * 提现记录详情 接口
  29. * @return string
  30. * @throws \Throwable
  31. */
  32. public function index()
  33. {
  34. return view('finance.withdraw.withdraw-info', [
  35. 'item' => $this->withdrawModel,
  36. 'set' => Setting::get('plugin.commission'),
  37. ])->render();
  38. }
  39. /**
  40. * 附值 withdrawModel
  41. * @throws ShopException
  42. */
  43. protected function setWithdrawModel()
  44. {
  45. $this->withdrawModel = Withdraw::find($this->getPostWithdrawId());
  46. if (!$this->withdrawModel) {
  47. throw new ShopException('数据不存在或已被删除!');
  48. }
  49. }
  50. /**
  51. * 获取 POST 提交的ID主键
  52. * @return string
  53. * @throws ShopException
  54. */
  55. protected function getPostWithdrawId()
  56. {
  57. $withdraw_id = trim(\YunShop::request()->id);
  58. if (empty($withdraw_id)) {
  59. throw new ShopException('数据错误,请重试!');
  60. }
  61. return $withdraw_id;
  62. }
  63. }