PayController.php 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace App\dao\Pay;
  3. use App\Facade\TableName;
  4. use App\Http\logic\api\BaseApiLogic;
  5. use App\Services\FirstRechargeGifts;
  6. use App\Services\OrderServices;
  7. use App\Services\StoredProcedure;
  8. use Illuminate\Support\Facades\DB;
  9. class PayController extends BaseApiLogic
  10. {
  11. public function verify($userId, $GiftsID, $pay_amount)
  12. {
  13. if (!empty($GiftsID) && false) {
  14. if ($GiftsID < 100) { // 礼包--首冲
  15. $pay_amount = (int)DB::connection('write')->table('QPAccountsDB.dbo.FirstRechargeGifts')->where('GiftsID', $GiftsID)->first()->Price ?? 0;
  16. // 购买礼包
  17. $giftService = new FirstRechargeGifts();
  18. $bool = $giftService->buyGifts($GiftsID, $userId);
  19. if ($bool === false) {
  20. $this->error = $giftService->getError();
  21. return false;
  22. }
  23. } elseif ($GiftsID > 100 && $GiftsID < 200) { // 周卡
  24. $CardID = $GiftsID - 100;
  25. $WeeklyCard = DB::connection('write')->table('QPPlatformDB.dbo.MonthCard')->where([
  26. 'CardID' => $CardID,
  27. 'CardState' => 1,
  28. ])->first();
  29. $Price = $WeeklyCard->Price ?? '';
  30. if (!$WeeklyCard || $Price != $pay_amount) {
  31. $this->error = 'A função está em manutenção, temporariamente indisponível para compra';
  32. return false;
  33. }
  34. } elseif ($GiftsID == 200 || $GiftsID == 201||$GiftsID == 211 || $GiftsID == 212) { // 首充30元【修改逻辑,充值过首充礼包才不可以首充,不是只要充值过就不能首充】
  35. // $result = StoredProcedure::FirstCharge($userId)[0]->Ret ?? 0;
  36. // if ($result != 0) {
  37. // $this->error = 'First charge condition not met';
  38. // return false;
  39. // }
  40. $firstPayExists = DB::table(TableName::QPAccountsDB().'UserRechargeActive')->where('UserID',$userId)->first();
  41. if ($firstPayExists) {
  42. $this->error = ['firstPay.already_got','First charge condition not met'];
  43. return false;
  44. }
  45. // $pay_amount = (new OrderServices())->FirstCharge;
  46. $result = DB::table(TableName::agent() . 'recharge_gear')
  47. ->where('gift_id', $GiftsID)
  48. ->first();
  49. $pay_amount = $result->money ?? 0;
  50. // } elseif ($GiftsID == 211 || $GiftsID == 212) { // 引导付费 [只要充值过,就不能买引导付费]
  51. // // 判断礼包有没有充值过
  52. // // $guide_payment_exists = DB::table(TableName::agent() . 'guide_payment')->where('UserID',$userId)->first();
  53. // // 查看用户有没有充值过
  54. // $user_recharge = DB::table(TableName::QPAccountsDB() . 'YN_VIPAccount')
  55. // ->where('UserID', $userId)
  56. // ->value('Recharge') ?: 0;
  57. //
  58. // if ($user_recharge > 0) { // 引导付费礼包重复充值
  59. // $this->error = 'Desculpe, você já recarregou e não pode comprar este pacote de desconto'; // 对不起,你已经充值过了,无法购买该优惠礼包
  60. // return false;
  61. // }
  62. // $result = DB::table(TableName::agent() . 'recharge_gear')
  63. // ->where('gift_id', $GiftsID)
  64. // ->first();
  65. // $pay_amount = $result->money ?? 0;
  66. }
  67. }
  68. return $pay_amount;
  69. }
  70. }