BlankerController.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Helpers\Utils;
  4. use Illuminate\Http\Request;
  5. use App\Services\CallApiService;
  6. use Themes\blanker\pro\app\Services\BlankerService;
  7. class BlankerController
  8. {
  9. /**
  10. * @var CallApiService
  11. */
  12. private $callApiService;
  13. private $blankerService;
  14. public function __construct(CallApiService $callApiService, BlankerService $blankerService)
  15. {
  16. $this->callApiService = $callApiService;
  17. $this->blankerService = $blankerService;
  18. }
  19. public function currPrice()
  20. {
  21. $printingJson = json_decode(base64_decode(request('PrintingJson')), true);
  22. $result = response()->json($this->blankerService->colrow(
  23. $printingJson['p'],
  24. $printingJson['p3'],
  25. $printingJson['e_size_type'],
  26. $printingJson['abcd_value'],
  27. $printingJson['pri_r'],
  28. $printingJson['opsens5'],
  29. $printingJson['ii2'],
  30. $printingJson['ii3'],
  31. request('OuterWidth'),
  32. request('OuterHeight'),
  33. request('OuterWidth'),
  34. request('OuterHeight'),
  35. ))->getData(true);
  36. $this->callApiService->setGateToken();
  37. $gateToken = session()->get('GateToken');
  38. $response = $this->callApiService->callApi([
  39. 'url' => 'item-pick',
  40. 'data' => [
  41. 'Page' => [
  42. [
  43. 'Id' => (int)request('ItemId'),
  44. ]
  45. ]
  46. ],
  47. 'headers' => ['GateToken' => $gateToken['main']]
  48. ]);
  49. if ($this->callApiService->verifyApiError($response)) {
  50. return response()->json($response['body'], 401);
  51. }
  52. $item = $response['Page'][0];
  53. return response()->json([
  54. 'ItemName' => $item['ItemName'],
  55. 'CurrPrice' => (float)$result['total_op'],
  56. ]);
  57. }
  58. }