CheckoutOkController.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace Themes\Pro\modunawa\app\Http\Controllers\Shop;
  3. use App\Http\Controllers\Controller;
  4. use App\Services\CallApiService;
  5. use Carbon\Carbon;
  6. use Unirest\Request;
  7. class CheckoutOkController extends Controller
  8. {
  9. private $callApiService;
  10. public function __construct(CallApiService $callApiService)
  11. {
  12. $this->callApiService = $callApiService;
  13. }
  14. public function index()
  15. {
  16. $id = session('sorder_id');
  17. if (empty($id)) {
  18. notify()->error('잘 못 된 접근 입니다', 'Error', 'bottomRight');
  19. return redirect()->to('/');
  20. }
  21. $listType1Book = $this->callApiService->callApi([
  22. 'url' => 'list-type1-book',
  23. 'data' => [
  24. 'Book' => [
  25. [
  26. 'QueryVars' => [
  27. 'QueryName' => 'pro:shop/sorder',
  28. 'IsntPagination' => true,
  29. 'SimpleFilter' => "mx.id = $id"
  30. ],
  31. 'PageVars' => [
  32. 'Limit' => 100000
  33. ]
  34. ],
  35. [
  36. 'QueryVars' => [
  37. 'QueryName' => 'pro:shop/sorder-bd',
  38. 'IsntPagination' => true,
  39. 'SimpleFilter' => "mb.sorder_id = $id",
  40. 'SubSimpleFilter' => "image_type = 'thumb'",
  41. ],
  42. 'PageVars' => [
  43. 'Limit' => 100000
  44. ]
  45. ],
  46. ]
  47. ]
  48. ]);
  49. if ($this->callApiService->verifyApiError($listType1Book)) {
  50. notify()->error($listType1Book['body'], 'Error', 'bottomRight');
  51. return redirect()->back();
  52. }
  53. $sorderCharge['sub_total'] = collect($listType1Book['Book'][1]['Page'])->sum('C8');
  54. $checkoutCharge['charge_amt'] = (int)$listType1Book['Book'][0]['Page'][0]['D7'];
  55. $sorderCharge['total'] = $sorderCharge['sub_total'] + $checkoutCharge['charge_amt'];
  56. $sorderCharge['count'] = collect($listType1Book['Book'][1]['Page'])->count();
  57. // dump($listType1Book['Book']);
  58. return view('views.shop.checkout-ok', compact('listType1Book', 'sorderCharge'))->with('codeTitle', [
  59. "paymethod('sorder')",
  60. ]);
  61. }
  62. public function store()
  63. {
  64. }
  65. }