PayPublic.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Services;
  3. use App\Http\helper\Helper;
  4. use App\Http\logic\api\BaseApiLogic;
  5. use Illuminate\Support\Facades\DB;
  6. class PayPublic extends BaseApiLogic
  7. {
  8. public function PayVerify($userId, $userName, $userEmail, $GiftsID,$pay_amount)
  9. {
  10. // 获取用户填写信息,填写过用最新填写的,没填写过 模拟
  11. $userPayInfo = Helper::userPayInfo($userId, $userName, $userEmail);
  12. $email = $userPayInfo['email'];
  13. $user_name = $userPayInfo['userName'];
  14. $userInfo = DB::connection('write')->table('QPAccountsDB.dbo.AccountsInfo')->where('UserID', $userId)->select('NickName')->first();
  15. if (!$userInfo) {
  16. $this->error = 'Payment error_6';
  17. return false;
  18. }
  19. // 购买礼包
  20. $giftService = new FirstRechargeGifts();
  21. $bool = $giftService->buyGifts($GiftsID, $userId);
  22. if ($bool === false) {
  23. $this->error = $giftService->getError();
  24. return false;
  25. }
  26. if (!empty($GiftsID)) {
  27. $pay_amount = (int)DB::connection('write')->table('QPAccountsDB.dbo.FirstRechargeGifts')->where('GiftsID', $GiftsID)->first()->Price ?? 0;
  28. }
  29. if ($pay_amount < 0) {
  30. $this->error = 'Payment error_4';
  31. return false;
  32. }
  33. return compact('user_name', 'email', 'pay_amount');
  34. }
  35. }