ProductController.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace App\Http\Controllers\Pay;
  3. use App\Cache\StatisticCache;
  4. use App\Facade\Site;
  5. use App\Libs\ApiResponse;
  6. use App\Services\Pay\ProductService;
  7. use Illuminate\Http\Request;
  8. use Illuminate\Routing\Controller as BaseController;
  9. /**
  10. * 充值商品
  11. *
  12. */
  13. class ProductController extends BaseController
  14. {
  15. use ApiResponse;
  16. protected $productService;
  17. public function __construct(
  18. ProductService $productService
  19. )
  20. {
  21. $this->productService = $productService;
  22. }
  23. public function charge_list(Request $request)
  24. {
  25. $template_id = 1;
  26. // 充值类型站点
  27. $channelType = Site::getChannelType();
  28. if ($channelType === 'RECHARGE') {
  29. $sendOrderId = Site::getSendOrderId();
  30. $channelPayId = Site::getChannelPayId();
  31. // 获取派单信息
  32. $sendOrder = $this->productService->getSendOrderById($sendOrderId);
  33. $template_id = getProp($sendOrder, 'pay_id', $channelPayId);
  34. }
  35. \Log::info('chargeList:template_id:' . $template_id);
  36. // 获取模板充值列表
  37. $charge_list = ProductService::getChargeProduct($template_id);
  38. \Log::info('$charge_list:' . json_encode($charge_list));
  39. if (!$charge_list) {
  40. return response()->error('WAP_SYS_ERROR');
  41. }
  42. $data = [];
  43. foreach ($charge_list as $v) {
  44. $temp = [
  45. 'price' => $v->price,
  46. 'price_desc' => $v->price_desc,
  47. 'name_desc' => $v->name_desc,
  48. 'given' => $v->given,
  49. 'is_default' => $v->is_default,
  50. 'angle_sign_text' => $v->angle_sign_text,
  51. 'type' => $v->type,
  52. 'product_id' => $v->id,
  53. ];
  54. $data[] = $temp;
  55. }
  56. // 统计(uv|pv)
  57. StatisticCache::setPV('charge_list');
  58. $uid = Site::getUid();
  59. if ($uid) StatisticCache::setUV('charge_list', $uid);
  60. return response()->success($data);
  61. }
  62. }