ConfirmPayController.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. *
  5. * User: king/QQ:995265288
  6. * Date: 2018/7/27 下午4:02
  7. * Email: livsyitian@163.com
  8. */
  9. namespace app\backend\modules\withdraw\controllers;
  10. use app\backend\models\Withdraw;
  11. use app\common\exceptions\ShopException;
  12. use app\common\facades\Setting;
  13. use app\common\services\Session;
  14. use app\common\services\withdraw\PayedService;
  15. class ConfirmPayController extends PreController
  16. {
  17. /**
  18. * 提现记录确认打款接口
  19. */
  20. public function index()
  21. {
  22. \Log::debug('提现记录确认打款接口+++++++++++++++++++++');
  23. if (!$this->checkVerify()) {
  24. $this->message('提现验证失败或验证已过期', yzWebUrl("withdraw.records", ['id' => $resultData['id']]), 'error');
  25. }
  26. $result = (new PayedService($this->withdrawModel))->confirmPay();
  27. if ($result == true) {
  28. $this->withdrawModel->update(['pay_way'=>Withdraw::WITHDRAW_WITH_MANUAL]); //线下手动打款后更改提现记录途径
  29. return $this->successJson('确认打款成功');
  30. }
  31. return $this->errorJson('确认打款失败,请刷新重试');
  32. }
  33. public function validatorWithdrawModel($withdrawModel)
  34. {
  35. if ($withdrawModel->status != Withdraw::STATUS_AUDIT && $withdrawModel->status != Withdraw::STATUS_PAYING) {
  36. throw new ShopException('状态错误,不符合打款规则!');
  37. }
  38. }
  39. /**
  40. * 打款验证
  41. * @return bool
  42. */
  43. private function checkVerify()
  44. {
  45. $set = Setting::getByGroup('pay_password')['withdraw_verify'] ?: [];
  46. if (empty($set) || empty($set['is_phone_verify'])) {
  47. return true;
  48. }
  49. $verify = Session::get('withdraw_verify'); //没获取到
  50. if ($verify && $verify >= time()) {
  51. return true;
  52. }
  53. return false;
  54. }
  55. }