You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.8 KiB

  1. <?php
  2. namespace App\Controller\v3;
  3. use App\Constants\v3\ErrorCode;
  4. use App\Constants\v3\UserType;
  5. use App\Controller\BaseController;
  6. use App\Exception\ErrorCodeException;
  7. use App\Model\v3\FinancialRecord;
  8. use App\Model\v3\Store;
  9. use App\Model\v3\UserBalance;
  10. use App\Service\v3\Interfaces\FinancialRecordServiceInterface;
  11. use Hyperf\Di\Annotation\Inject;
  12. use Hyperf\Validation\ValidationException;
  13. class WithdrawController extends BaseController
  14. {
  15. /**
  16. * @Inject
  17. * @var FinancialRecordServiceInterface
  18. */
  19. protected $financialService;
  20. /**
  21. * 商户提现页数据
  22. * 1、可提现金额
  23. * 2、获得的奖励金额(历史总奖励金额)
  24. * 3、用户须知
  25. * 4、提现须知
  26. */
  27. public function pageByStore()
  28. {
  29. $validator = $this->validationFactory->make(
  30. $this->request->all(),
  31. [
  32. 'user_id' => 'required|nonempty|integer',
  33. 'store_id' => 'required|nonempty|integer',
  34. ],
  35. ['*.*' => ':attribute 参数不正确']
  36. );
  37. if ($validator->fails()) {
  38. throw new ValidationException($validator);
  39. }
  40. $userId = $this->request->input('user_id', 0);
  41. $storeId = $this->request->input('store_id', 0);
  42. $store = Store::query()->where(['user_id' => $userId, 'id' => $storeId])->first();
  43. if (empty($store)) {
  44. throw new ErrorCodeException(ErrorCode::STORE_NOT_AVAILABLE);
  45. }
  46. $data['balance'] = UserBalance::query()
  47. ->where(['source_id' => $store->user_id, 'user_type' => UserType::STORE])
  48. ->value('balance');
  49. $data['award'] = $this->financialService->sumAmount(
  50. $store->user_id,
  51. UserType::STORE,
  52. [FinancialRecord::MONEY_TYPE_STORE_PLAT_NEW_USER, FinancialRecord::MONEY_TYPE_STORE_FIRST_ORDER]
  53. );
  54. $data['notice'] = [
  55. [
  56. 'title' => '用户须知',
  57. 'content' => '<p>请仔细填写相关信息,如果由于您填写的信息有误导致资金流失,平台概不负责。</p><p>注意:因微信限制当前用户账户余额满<span style="color:red;">1</span>元后才可提现</p>'
  58. ],
  59. [
  60. 'title' => '提现须知',
  61. 'content' => '<p>一次提现金额最低为<span style="color:red;">1</span>元</p>'
  62. .'<p>一次提现金额最高为<span style="color:red;">5000</span>元</p>'
  63. .'<p>每天可提现<span style="color:red;">10</span>次</p>'
  64. ],
  65. ];
  66. return $this->success($data);
  67. }
  68. public function applyByStore()
  69. {
  70. $validator = $this->validationFactory->make(
  71. $this->request->all(),
  72. [
  73. 'user_id' => 'required|nonempty'
  74. ]
  75. );
  76. }
  77. }