RechargeLogic.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace App\Http\logic\api;
  3. use App\dao\Pay\Recharge;
  4. use App\Facade\TableName;
  5. use Illuminate\Support\Facades\DB;
  6. class RechargeLogic
  7. {
  8. public function guidePayment($JumpOut)
  9. {
  10. $guidePayment = DB::table('agent.dbo.recharge_gear')->where('status', 1)->where('first_pay', 2)->first();
  11. if (!$guidePayment) {
  12. return [];
  13. }
  14. $names = (new Recharge())->poll();
  15. $list = DB::table('agent.dbo.recharge_gear')
  16. ->where('status', 1)
  17. ->where('first_pay', 2)
  18. ->orderBy('money', 'asc')->where('status', 1)->get();
  19. foreach ($list as $val) {
  20. $data = [];
  21. $gear = \GuzzleHttp\json_decode($val->gear, true);
  22. foreach ($names as $k => $va) {
  23. foreach ($gear as $key => &$value) {
  24. if ($value['id'] == $va['id']) {
  25. if ($value['status'] != -1) {
  26. // type = 1 sdk跳转 type=2 外跳链接 type=0 默认
  27. $type = $va['new_pay_type'] == 1 ? 3 : 2;
  28. if($va['new_pay_type'] == 4){
  29. $type = 0;
  30. }
  31. if (in_array($value['id'], $JumpOut)) {
  32. $data[] = ['id' => $value['id'], 'name' => $va, 'status' => 1, 'type' => $type];
  33. } else {
  34. $data[] = ['id' => $value['id'], 'name' => $va, 'status' => 1, 'type' => $type];
  35. }
  36. }
  37. }
  38. }
  39. }
  40. $gear = array_values($data);
  41. $val->gear = \GuzzleHttp\json_encode($gear);
  42. }
  43. return $list;
  44. }
  45. }