mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
916 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2f98dc976a | |||
| 20237d69fb | |||
| 22f1548eac | |||
| 4e4475ad12 | |||
| a287a1193a | |||
| a80b3013c3 | |||
| f5cf2ac2df | |||
| 2767d94a16 | |||
| f68ef5c5e2 | |||
| 639ccd3927 | |||
| 5651ed7010 | |||
| fd89233e49 | |||
| be70afd9bf | |||
| efac46264e | |||
| a0817dbb6e | |||
| dfa7013f04 | |||
| 28a57887b6 | |||
| 8a96941127 | |||
| 3a5423a308 | |||
| ddd1b7b29e | |||
| 5433c202a7 | |||
| b967e4f9ab | |||
| e9b7de47fa | |||
| 3c942af883 | |||
| baa9f79272 | |||
| 10c66dc2dc | |||
| 05d4b7fe36 | |||
| 7fc4568fbf | |||
| f55a57c222 | |||
| 301d7b5520 | |||
| 9f965109c7 | |||
| 108a952ee3 | |||
| 1426d804e5 | |||
| 88b3dc8b84 | |||
| 4b3274f6d5 | |||
| da1b6b1b6d | |||
| ac0a90c168 | |||
| a5e47324b2 | |||
| 40d22de809 | |||
| 7154b5a943 | |||
| 863c2874dd | |||
| 862398b0d5 | |||
| 9e20b717a6 | |||
| 129f3ecf10 | |||
| f71f1fecd4 | |||
| 6f5f854827 | |||
| f4275f20a3 | |||
| 35d9a1f8d8 | |||
| de1afc26dc | |||
| 904fb3d9e5 | |||
| 304337d5e2 | |||
| aa312c8f6e | |||
| 05d079f261 | |||
| a1cb511125 | |||
| 8d29a25793 | |||
| a7593e4ab2 | |||
| 8ecb306e92 | |||
| 918fd0d17d | |||
| 4f888da29a | |||
| 559de29acf | |||
| 87116d29c9 | |||
| d9eeaf4bef | |||
| 5dabc88fa9 | |||
| 8c29fcda1f | |||
| edd6b0d6ff | |||
| 6940290570 | |||
| 327bd75cc9 | |||
| 9f760d8694 | |||
| 4a1905abde | |||
| 5d1ff709eb | |||
| a50b475525 | |||
| 97ec65e292 | |||
| 5df226c153 | |||
| 3e87f320bf | |||
| 408a3a1211 | |||
| bed78c053a | |||
| c53ebf76b3 | |||
| 4085ac4829 | |||
| 778729b81d | |||
| 54c212e905 | |||
| 5b370a299c | |||
| e57dc231e6 | |||
| 5727801918 | |||
| bf325ff028 | |||
| 229e757663 | |||
| 10d62dd8d1 | |||
| 0fa0d8daab | |||
| bb59a444cf | |||
| 45c878a2ed | |||
| e871f4b287 | |||
| 6eaa810b67 | |||
| 68d961a681 | |||
| 2c29e5939e | |||
| 6910dce35f | |||
| a19db06b6b | |||
| 4e53e1b48a | |||
| aef9b82918 | |||
| f96fef94fe | |||
| ab141ae160 | |||
| bf4830ba7a | |||
| 5baf04c835 | |||
| 4917c54868 | |||
| 9c7d07f603 | |||
| 6f9320f3a4 | |||
| c69c043576 | |||
| 745655dbfa | |||
| b764ee0769 | |||
| ab1d92af86 | |||
| 2ff9a38114 | |||
| 0abdbd525e | |||
| f44aace3c5 | |||
| 0af84a9b7d | |||
| 1aff95b41c | |||
| 745f476f89 | |||
| e1d751b859 | |||
| 6077b1fbbb | |||
| 5fe8a7a59e | |||
| 8b38bcac8a | |||
| 5561442932 | |||
| f33efd373c | |||
| 53c325b36d | |||
| cd141bf988 | |||
| 908f3fc11b | |||
| 8e9f12b17e | |||
| 782bcc69f1 | |||
| 144464621e | |||
| b290f95426 | |||
| b7e6269aa9 | |||
| 7180f802b3 | |||
| 7159c1c11d | |||
| cce0cae57c | |||
| bebce6fbaa | |||
| 531ab699ba | |||
| 9f9c17977d | |||
| 24f5de8c2c | |||
| 3b8079785a | |||
| 627fb3aa96 | |||
| 2b4d3f1992 | |||
| 65daceb59c | |||
| d7457e7174 | |||
| 9753eb3a18 | |||
| e7df49a0d1 | |||
| cd4e7aab10 | |||
| 29350dbb86 | |||
| 7338ebc78a | |||
| 4eded7a742 | |||
| dc562f6554 | |||
| d96a35a49f | |||
| 8024fef2e8 | |||
| 2d965009ec | |||
| 7d84ddee95 | |||
| 92b31a9342 | |||
| 012dbfde09 | |||
| 0b651953ea | |||
| b34f50ae9d | |||
| 8f0d1e6fdf | |||
| e8990d96f7 | |||
| 69ee0eea2c | |||
| adcdf5909e | |||
| b9523fb567 | |||
| 79678d7b93 | |||
| 2bdfd2772a | |||
| 55513f5175 | |||
| 709534ce04 | |||
| 74d85eee60 | |||
| 63badc08f0 | |||
| 73010ed32b | |||
| 7a2a90545b | |||
| c0ee3a8e57 | |||
| 0c7e4d5785 | |||
| c3cd8ae3a0 | |||
| 0e7469f1cd | |||
| 32476afdd4 | |||
| 8b6db1fb68 | |||
| 43f3fbff07 | |||
| caf8624d4c | |||
| eb417cf389 | |||
| 276a87ff0d | |||
| 6d2f179025 | |||
| 8609c926f9 | |||
| 368a055bb4 | |||
| d617001412 | |||
| c932cb00cc | |||
| 1be62a5f77 | |||
| 445bcb3864 | |||
| d489775924 | |||
| fff428882d | |||
| 42205ddbc3 | |||
| 722e502b3b | |||
| 4f93569b4c | |||
| e1abebc66c | |||
| 2424882cfe | |||
| 23f50faa84 | |||
| edc510681e | |||
| db03836ef5 | |||
| 3a5f404294 | |||
| 9b79f16faa | |||
| 4ff4418f7f | |||
| 19c8f1e658 | |||
| e1c4d674b6 | |||
| 3326de9c4f | |||
| 54dd6d407d | |||
| 9ee81d9385 | |||
| aa1ba03415 | |||
| fb6b2173b5 | |||
| f18e4a882f | |||
| 8edc91bb61 | |||
| 6122c288df | |||
| 9650877819 | |||
| c65d875a3d | |||
| c1bc610549 | |||
| 82d406abfc | |||
| 701610978d | |||
| f7e1665a02 | |||
| d389b87609 | |||
| 987fdcfba2 | |||
| 6214a2b723 | |||
| fe00b1fab7 | |||
| 41df3e6ae7 | |||
| cf7d9ccca5 | |||
| 384d234b50 | |||
| 3fbfa44a04 | |||
| cbc294054e | |||
| 324556985a | |||
| 1b8c6ca317 | |||
| bbd09d300c | |||
| 47c97d6151 | |||
| 435e3a8f7a | |||
| 151032bb66 | |||
| f32335d57b | |||
| 2deddc4e03 | |||
| 32e665e4f7 | |||
| a987419040 | |||
| b0a65f870c | |||
| 33a75eca7d | |||
| deb68dc723 | |||
| 519408c2b5 | |||
| 53907e2463 | |||
| 10e6f6045e | |||
| c06cec5b41 | |||
| cfe611d05d | |||
| b9b79ca65a | |||
| 9a1562386f | |||
| 22700893a2 | |||
| 550c9480a4 | |||
| 48bab9998c | |||
| 3ff81d4f00 | |||
| cc7edfc784 | |||
| 72448d656c | |||
| c941f679b6 | |||
| 78f6c70cad | |||
| 1575d62e0f | |||
| 43f4bc533a | |||
| 9ae36dc400 | |||
| 02c55d97b7 | |||
| baeaa0f31a | |||
| dadc786f1f | |||
| bd9dab0029 | |||
| e2b795c872 | |||
| 9a79c6dd1d | |||
| d8e1c38429 | |||
| aa28afb9f0 | |||
| 7ec109eb3e | |||
| 7151616b04 | |||
| f2007b25e4 | |||
| 6389fc6600 | |||
| eb6b2943af | |||
| 5fb7ddb0ec | |||
| 91feb5b8fa | |||
| 9c98693071 | |||
| 56fb250e6f | |||
| eabfeb6724 | |||
| 8902a09337 | |||
| 0a69faeb3b | |||
| bea9507dae | |||
| a1a9ab76bb | |||
| 5d9e621920 | |||
| 5b1f4eff0d | |||
| ac41229f8b | |||
| 2fb12d3a7c | |||
| 28088f7d9a | |||
| ced07a293e | |||
| 59ee063186 | |||
| 8cd63e93c3 | |||
| d3bf6b0dee | |||
| 093ea075f0 | |||
| 62066a5be5 | |||
| 88c0ba31d7 | |||
| 36236144ce | |||
| 69e4f83919 | |||
| 6338fdf771 | |||
| 83091caa46 | |||
| 99f5dcf8ab | |||
| eb6f313c77 | |||
| 3b60a90435 | |||
| 3a9fe2b6af | |||
| 603b807225 | |||
| 0ae05f05b6 | |||
| 290e531d12 | |||
| a44ad3df3a | |||
| de56c21734 | |||
| 89aa52e9c2 | |||
| 072e65c00c | |||
| 8701620dcf | |||
| e9f86f0603 | |||
| 6d77fe171a | |||
| 073250ce43 | |||
| 07d3b4b7a3 | |||
| 3b86a50bed | |||
| 35cf8a20c3 | |||
| a17534ae6d | |||
| ab12494ba5 | |||
| b6834ac6f5 | |||
| 200a954730 | |||
| 499837b135 | |||
| 537dbd4564 | |||
| a4365e5c33 | |||
| 98424eacf4 | |||
| eb905e7176 | |||
| 7998f6e43f | |||
| eb41d7c2ef | |||
| fd8f8d6cb4 | |||
| fafd145bca | |||
| d9a3f42e87 | |||
| 686ef83f31 | |||
| 5fab8224c6 | |||
| 9e95da84c4 | |||
| a54aefcf9f | |||
| d217cf0ef2 | |||
| 1978cf017b | |||
| ea381e0bf5 | |||
| de26957532 | |||
| 715d26c9d2 | |||
| f1432388d8 | |||
| 5ca53c2124 | |||
| 48dbe00744 | |||
| e2df3af9cd | |||
| df0b67d9b9 | |||
| a28a5a0c29 | |||
| 1560bdfcf8 | |||
| 585e4705a4 | |||
| 2e41499fd1 | |||
| f3688385eb | |||
| fdfae861c6 | |||
| b16eddf13a | |||
| dd78be57fe | |||
| 49042f5507 | |||
| a97faa0024 | |||
| 99d7aeac5f | |||
| fe340b1246 | |||
| e79206a681 | |||
| 1838e46d1b | |||
| 6bfbac6494 | |||
| 266fd7302b | |||
| f7b081eb94 | |||
| 388a1024b4 | |||
| 899f84aed0 | |||
| 4a497dd61b | |||
| 02f3686768 | |||
| 826840f992 | |||
| bd5d9fe520 | |||
| 34d4aeed1c | |||
| 6d5b6a206f | |||
| c9678b5be3 | |||
| f4c252546a | |||
| 24c8f5acbc | |||
| 5f2d5c36a1 | |||
| eed71a4696 | |||
| d947caa1e0 | |||
| d3b6e56f76 | |||
| 5b692fa7a5 | |||
| 1413b619f6 | |||
| 46e49b7e5b | |||
| 5201874111 | |||
| 7426d6dff2 | |||
| ede4231676 | |||
| bc1a7c04db | |||
| 5356098cc4 | |||
| e83206ceab | |||
| 251d44912f | |||
| 7e4b5d8528 | |||
| 9ab0133e00 | |||
| 87d7a7572f | |||
| 56c71e1500 | |||
| d37dfa2aa8 | |||
| 2fad8a5994 | |||
| f3c7422e6c | |||
| 22da7b5efd | |||
| 5b7d6b0a2f | |||
| 788b632285 | |||
| 35d0d9e97b | |||
| 0ef2c9bf6d | |||
| 34532d0f68 | |||
| 50a545595f | |||
| 3462430474 | |||
| 60a263c508 | |||
| 5829d9c0a1 | |||
| 9a061d2f37 | |||
| 564bac38b9 | |||
| ad2be90c3b | |||
| 47624ed8f2 | |||
| 528cc2f68d | |||
| 69ede16fe9 | |||
| 6060c7966a | |||
| f8f470078c | |||
| e5f4068bc0 | |||
| e0504c8d79 | |||
| 3a8f64719d | |||
| 1d86949d54 | |||
| 74b363fb12 | |||
| 1212372515 | |||
| e17c4cb014 | |||
| e4c32b5ad2 | |||
| 6a86738f61 | |||
| 79d8acb50b | |||
| 388973de4c | |||
| 7292ce37e4 | |||
| f2ad76a7ae | |||
| 7d273b5ce6 | |||
| 15be2c14ab | |||
| a735885bbb | |||
| 1ed5a3e4a0 | |||
| 816a40d647 | |||
| 0316b7c651 | |||
| 91415bd11d | |||
| f037352a28 | |||
| 0f508aed3a | |||
| 7d352a90e5 | |||
| 95c37f1e1f | |||
| a84e826c31 | |||
| c882450dce | |||
| 6fd8956892 | |||
| adb9a18651 | |||
| c932f2b86f | |||
| 1dc23b088e | |||
| 47704001dd | |||
| d02f395e72 | |||
| bdfccca2c8 | |||
| 97c900447f | |||
| 5db4b715e2 | |||
| 745cfef185 | |||
| 05aa23a645 | |||
| c7330fd051 | |||
| a4bb600a3c | |||
| 2631edc326 | |||
| c1faa710b4 | |||
| ab37914145 | |||
| c49ebe2836 | |||
| 85f67db797 | |||
| 284b21ec51 | |||
| 7146600376 | |||
| b5b2ba59af | |||
| fa29de775c | |||
| 0496851286 | |||
| 584fbccb93 | |||
| 994d7ab4d9 | |||
| 529cec7864 | |||
| 6f30884a8c | |||
| f8a985035e | |||
| ca3ecb0fda | |||
| f5a67f7e97 | |||
| 288cced125 | |||
| a76ce39830 | |||
| 64467ea4be | |||
| 09e0565988 | |||
| 22ce6b8156 | |||
| f810168dbb | |||
| fc0809d9d2 | |||
| 29d1fb893d | |||
| f01640d9f2 | |||
| 753951a1d2 | |||
| 552b6f0e1e | |||
| 314575e2b6 | |||
| 2deea66f0a | |||
| aab739737c | |||
| 595df401c2 | |||
| b03601cec5 | |||
| c040dfe2c3 | |||
| 0abf617a0d | |||
| ffe39f40ff | |||
| 6f547b0a2f | |||
| 06785efe9b | |||
| 556c9352c8 | |||
| d97357f33a | |||
| 2691d7df33 | |||
| 9df9e5bd7c | |||
| 05b1aedda5 | |||
| 7ece556475 | |||
| 919a48eb9a | |||
| 495574e60d | |||
| c17c29ad06 | |||
| 4c8d363e25 | |||
| f5df10297e | |||
| 9245793ebe | |||
| 5547e80993 | |||
| 658a669a4d | |||
| d6faaecb35 | |||
| fdc6a4adc1 | |||
| 3dbcf81cc3 | |||
| b3bf814d25 | |||
| d489c0091f | |||
| 46699784da | |||
| 1538994cc5 | |||
| a5cb002b4e | |||
| 7d23f86c0d | |||
| 999d2f535d | |||
| fcdf4e32d7 | |||
| 96dd0ec72a | |||
| 1b333e1061 | |||
| 18a2ac1fd7 | |||
| 52377d6ecb | |||
| 2b956f4cfe | |||
| e84995bcc7 | |||
| 97bda44d61 | |||
| fc2fe2c712 | |||
| 983d7a5092 | |||
| df1112f86f | |||
| 1bfc44c1e0 | |||
| f75d2235a2 | |||
| 31ce575f5f | |||
| cd6d86fb4b | |||
| 7f7101cce5 | |||
| a892656725 | |||
| 86cc7faf30 | |||
| c2ed6ce35e | |||
| 579bcbb17f | |||
| 4d4d9165ce | |||
| bfcc3e1aae | |||
| 199a18e8dd | |||
| 33277d080a | |||
| 5c86e7fda0 | |||
| efdc235502 | |||
| c89510dda7 | |||
| a6ef50d350 | |||
| e7164e903d | |||
| 3eaeccc8d3 | |||
| 8e4a6b3911 | |||
| f9b657ab43 | |||
| ada8117bd1 | |||
| 402556d51b | |||
| a60ab688da | |||
| 5d9a08ea0b | |||
| e4ef885553 | |||
| bdece13293 | |||
| e3cfb002a5 | |||
| f5bace1c3b | |||
| 642e1b2d5a | |||
| d2321a3347 | |||
| 5cf7511c31 | |||
| 0a8109ae9e | |||
| 36289a3694 | |||
| 46b079462a | |||
| 3c83f91a27 | |||
| 0a51074064 | |||
| bd5e89e832 | |||
| 763cc2d38c | |||
| a36adc7ca5 | |||
| 950b3d168a | |||
| a35cf282f6 | |||
| 39408e08ca | |||
| e472260db1 | |||
| 2428fac309 | |||
| aa681ecd93 | |||
| 611adf96e7 | |||
| d4f1184779 | |||
| 45acd797da | |||
| 4b411ddaf4 | |||
| c13d2ce219 | |||
| 412f4cc4b6 | |||
| 04650debbb | |||
| 3436ed37a1 | |||
| 980dd22c4b | |||
| 7cc43bcdd9 | |||
| 8487c6adf3 | |||
| ca5879cab0 | |||
| 2bb8adf175 | |||
| d0a873e065 | |||
| e6eb05739c | |||
| 5c4fbe2c52 | |||
| 1854ca24de | |||
| d93e6ea25e | |||
| 5c780ae0f9 | |||
| 5c374e2e19 | |||
| b6ed451b54 | |||
| 74ede9e3dd | |||
| 438f7fdff5 | |||
| d6647b488f | |||
| 3fb7bc93d7 | |||
| f97fc04a2b | |||
| 77690cb607 | |||
| f876c59a0d | |||
| c5d5195d2d | |||
| 7ba48b07d1 | |||
| 96131c5b33 | |||
| 3ae4b019ce | |||
| 2558e8f4f2 | |||
| fdec05ca45 | |||
| 9fe86c52bd | |||
| ea34c74f6d | |||
| 3a69ce6972 | |||
| 83fc73acec | |||
| e8613bd6d9 | |||
| 3e4f627cbe | |||
| a870d259f9 | |||
| ed0db2e372 | |||
| 80359cc23b | |||
| 67867220ed | |||
| 35206ca249 | |||
| 394eadf6a2 | |||
| 440271bc27 | |||
| 7769a27a73 | |||
| a28ad55508 | |||
| 845873354f | |||
| b065881715 | |||
| fb5c5ad890 | |||
| 1e37de379d | |||
| be2b9d8759 | |||
| aaf68b6368 | |||
| c0577128ae | |||
| 6a91da7b69 | |||
| d6eda8a11d | |||
| 5dec999cbf | |||
| 99060ffa51 | |||
| 73fdc2c0f4 | |||
| 52038cb365 | |||
| bb2f75d837 | |||
| b94b87c1b7 | |||
| 0aa1979611 | |||
| 9e872dfb35 | |||
| ff035c1f70 | |||
| 8408add279 | |||
| 47d6849dfa | |||
| 56559d3daa | |||
| bae61caae1 | |||
| af07299bcf | |||
| 3e26c7e8ef | |||
| bac81b57f4 | |||
| 1d64dc9984 | |||
| bbadaa53ba | |||
| e4f5210e83 | |||
| 078e83477e | |||
| ce6e6be2bf | |||
| f608bb54f0 | |||
| bb210f8583 | |||
| d4016e869b | |||
| e0d743b5a0 | |||
| 8052ae3a11 | |||
| 6a381446bc | |||
| 1dbade82a7 | |||
| e70d804c32 | |||
| 39391990af | |||
| b96dad37f5 | |||
| 012904c522 | |||
| 90420cebe7 | |||
| 04bd67573c | |||
| f69c99b070 | |||
| fdf4f21155 | |||
| 95ab15df21 | |||
| 2d885776dd | |||
| 1f02b7247d | |||
| ef3460f796 | |||
| 8825e49b68 | |||
| 7c17edc5fd | |||
| 6423aa6345 | |||
| d22e3884fa | |||
| 263e122dea | |||
| 6ecee81112 | |||
| cee6ca4eee | |||
| e2766c66a1 | |||
| 6c94e39da8 | |||
| c7b6622a62 | |||
| efe3a97f3e | |||
| 2d167ef47e | |||
| e504b31b15 | |||
| 0469a725ed | |||
| 68075186d4 | |||
| 3897821cb7 | |||
| 07d70af213 | |||
| 6b491cc2e5 | |||
| 53809af105 | |||
| 1efbca15ec | |||
| a331c659a8 | |||
| 4a1d021b85 | |||
| 87e155334b | |||
| 4d594bb084 | |||
| 5fdae14e01 | |||
| 7b3793e6d7 | |||
| d281017c24 | |||
| d08ded395a | |||
| 40c5692276 | |||
| 18554e9924 | |||
| 8a8fb3e03e | |||
| 396f9370ae | |||
| 919cbc463b | |||
| 78e223844f | |||
| dcfbbd63a7 | |||
| 1fc9330d98 | |||
| 9ff98196f0 | |||
| d2fe2bfef4 | |||
| ff0713f005 | |||
| 7bd24b6547 | |||
| 33086eb1a6 | |||
| 82517e3cb3 | |||
| 41d9769d04 | |||
| 906623bad3 | |||
| 898205ec9d | |||
| 7b791abf80 | |||
| 27f2367e88 | |||
| 6874d09ced | |||
| eeaba20fb0 | |||
| 5599c1ba71 | |||
| 0220f876c4 | |||
| 1f0f5e8afd | |||
| 1426d6f13c | |||
| 187411237d | |||
| dac4470f72 | |||
| 65b49d4d61 | |||
| bfbe07dc8e | |||
| 4ef90f7cf2 | |||
| c07aa6c1f1 | |||
| 28ad88900e | |||
| b707717418 | |||
| 6b4d2736c5 | |||
| 9ebacae701 | |||
| e18f49b5b7 | |||
| 81a7d79e0c | |||
| c698466b3d | |||
| 8e3be2747f | |||
| 8dafa7d678 | |||
| f36bb9d090 | |||
| 87c60dc488 | |||
| e11e0307af | |||
| 78fcb6c111 | |||
| f0bc306ebd | |||
| 0671e24916 | |||
| a328be683e | |||
| 4854e9b095 | |||
| 64a4e4b45f | |||
| 9774f4b823 | |||
| 2365ad10cf | |||
| 47eb9262ad | |||
| 9f6d0fbc79 | |||
| 22a2d7d7a1 | |||
| 5339799312 | |||
| 565fd5eae3 | |||
| 1156f437df | |||
| c5ffe372cc | |||
| 12a51722b3 | |||
| 82f45007d1 | |||
| 048cd52fc8 | |||
| 4a7c4f51a5 | |||
| 3f9874a0bd | |||
| c972bc87a3 | |||
| b057cd91c3 | |||
| d29ead2144 | |||
| 71eb8db3f3 | |||
| 7b1df81649 | |||
| ce1a2556b7 | |||
| bec9f121ab | |||
| 1d479f6f79 | |||
| 550f6c6b77 | |||
| 5caac091aa | |||
| 1d3ab4ab2a | |||
| 5e11b8ebdf | |||
| 4a158b8dac | |||
| 280f5f4974 | |||
| 926cb61ca3 | |||
| 3aec23525c | |||
| 992e5b0008 | |||
| 0f0e99af35 | |||
| da1c653570 | |||
| f86f129949 | |||
| ec24033209 | |||
| e3dd8440df | |||
| 7647dc0e23 | |||
| 3bfb67b55a | |||
| a26368b728 | |||
| a1a9ffa0aa | |||
| c3050445e1 | |||
| 3620e4c4b5 | |||
| 3dafe41c33 | |||
| e28cc43b18 | |||
| 80873a14e2 | |||
| 799936fd8b | |||
| c6d4a6ffae | |||
| bc5a8bce47 | |||
| 2c03e68242 | |||
| 857004a6a5 | |||
| 35b2d526ed | |||
| 7e7290acc5 | |||
| 5256d5b2f9 | |||
| e8c33e46c4 | |||
| 5afd37652c | |||
| aeb0dfb025 | |||
| 1a591c0404 | |||
| 22c07b19ad | |||
| 9d2dceab2e | |||
| d00be021bc | |||
| 3d89a25f5c | |||
| 13c4b173d3 | |||
| 3a74fa5e12 | |||
| 098297188d | |||
| 4440f229d9 | |||
| 32465e2170 | |||
| 5d9782d1c9 | |||
| 036f389308 | |||
| 3de95f7019 | |||
| 0dc1a3c289 | |||
| 4302b42ad8 | |||
| 95daebb8f1 | |||
| 2cc0465165 | |||
| d626c0bb51 | |||
| 4601d5191b | |||
| 13fa349605 | |||
| bb2e6f0c67 | |||
| c681e89d34 | |||
| fd686d9ca5 | |||
| 327c2958c4 | |||
| 92c086a5bc | |||
| cc5b39e457 | |||
| 42883b3723 | |||
| 634d4b8b7d | |||
| 6255936cd1 | |||
| b31c8d508c | |||
| 90c1c037ca | |||
| 20289c7f1e | |||
| ac1fc3103b | |||
| cf6bebcde2 | |||
| a6fc5dd1a5 | |||
| fa88ffca49 | |||
| 2b6a2810e5 | |||
| c67ee25654 | |||
| f1cde19261 | |||
| b7e5475014 | |||
| a75c05fdae | |||
| 3327b8a4f5 | |||
| 604413d978 | |||
| a25feacf53 | |||
| 1090de9060 | |||
| 1c721f7f10 | |||
| 4813c54e6d | |||
| b79ecdc6a9 | |||
| 7fa70becde | |||
| 57a0ea535a | |||
| f84415ce89 | |||
| 0b79ff5521 | |||
| d0f209b006 | |||
| 8cec7b436f | |||
| d2468769df | |||
| 884f4b33d1 | |||
| c15f67e304 | |||
| f5ea06e3fe | |||
| 6fcf952967 | |||
| b0a2ab08c9 | |||
| e0a78cc126 | |||
| 5e7cfd4da0 | |||
| feec49318b | |||
| 9977d516e1 | |||
| c9131b3c3d | |||
| 2675fd8704 | |||
| 02c6825c4a | |||
| 908e0a49f9 | |||
| 9252134cc4 | |||
| 6444f471e8 | |||
| cf03a032e5 | |||
| 2cb8f9f407 | |||
| a846028919 | |||
| 274cd83c81 | |||
| ef1759379e | |||
| ad9b983325 | |||
| fc36a193e9 | |||
| 86d26edb72 | |||
| 052218b621 | |||
| da52ddd3ac | |||
| 6cfed45ffe | |||
| a048a79ca8 | |||
| 487d024039 | |||
| 25c36d085f | |||
| ba0dbf80a1 | |||
| afba2d6880 | |||
| 39771a42b6 | |||
| 624df67ca5 | |||
| 3f73848c18 | |||
| 63aae14b28 | |||
| ea6711f06b | |||
| 8c23d178e8 | |||
| aae9f160e6 | |||
| ba61f7f3ab | |||
| 04117754db | |||
| 821a39e5ff | |||
| 05cb3dd35e | |||
| 5b5bf1bb06 | |||
| 3d7090758d | |||
| e546825520 | |||
| f6af7c5f4f | |||
| 6ea51d56c1 | |||
| b36313e24c | |||
| f2422ea45c | |||
| d26c90136b | |||
| c10e78ad51 | |||
| e4c8c021ec | |||
| 46891669f1 | |||
| c281beb87a | |||
| 0d53a61f18 | |||
| 6d0e7dd51d | |||
| 592e8c489b | |||
| ee77fd236a | |||
| ee87443ca4 | |||
| 31105cfcef | |||
| 5d34201579 | |||
| 61a75a4ee1 | |||
| f385407804 | |||
| 0554cc895f | |||
| afcb1277f1 | |||
| 2d49f4aabf | |||
| 2095c18871 |
@@ -51,3 +51,7 @@ MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
UNITY_APP_URL="https://unity.izyim.com"
|
||||
EXCHANGE_URL=https://dev.exchange.cief-malaysia.com/
|
||||
MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||
|
||||
YD_API_CODE=''
|
||||
|
||||
@@ -63,7 +63,7 @@ abstract class AbstractControllerLogic
|
||||
|
||||
} catch (ErrorException|GeneralExceptions|TypeError $exception){
|
||||
return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(),
|
||||
$exception->getCode() ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
|
||||
!in_array($exception->getCode(), [0, 42000]) ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ClaimantId implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('claimant_id', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class Delivered implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereHas('packingList', function($packingList){
|
||||
return $packingList->where('type', PackingListType::SHIPPING_PACKING_LIST)->where('status', ApprovalStatus::APPROVED);
|
||||
})->whereHas('container',
|
||||
function($container) {
|
||||
return $container->where('containers.status', ApprovalStatus::COMPLETED);
|
||||
}
|
||||
)->whereHas('deliverySchedules',
|
||||
function($schedule) {
|
||||
return $schedule->where('eta', '<', Carbon::now())->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class HasPendingDelivery implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $value ? $builder->whereHas('packingLists', function (Builder $query) use($value) {
|
||||
$query->whereDoesntHave('transports');
|
||||
}) : $builder->whereDoesntHave('packingLists', function (Builder $query) use($value) {
|
||||
$query->whereDoesntHave('transports');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class InDestinationWarehouse implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereHas('packingList', function($packingList){
|
||||
return $packingList->where('type', PackingListType::SHIPPING_PACKING_LIST)->where('status', ApprovalStatus::APPROVED);
|
||||
})->whereHas('container',
|
||||
function($container) {
|
||||
return $container->where('containers.status', ApprovalStatus::COMPLETED);
|
||||
}
|
||||
)->whereDoesntHave('deliverySchedules',
|
||||
function($schedule) {
|
||||
return $schedule->where('etd', '<', Carbon::now())->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class InOriginWarehouse implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereHas('packingList', function($packingList){
|
||||
return $packingList->where('type', PackingListType::SHIPPING_PACKING_LIST)->where('status', ApprovalStatus::APPROVED);
|
||||
})->whereDoesntHave('shippingSchedules',
|
||||
function($schedule) {
|
||||
return $schedule->where('etd', '<', Carbon::now())
|
||||
->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class InTransit implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereHas('packingList', function($packingList){
|
||||
return $packingList->where('type', PackingListType::SHIPPING_PACKING_LIST)->where('status', ApprovalStatus::APPROVED);
|
||||
})->whereHas('container',
|
||||
function($container) {
|
||||
return $container->where('containers.status', ApprovalStatus::PENDING_VERIFICATION);
|
||||
}
|
||||
)->whereHas('shippingSchedules',
|
||||
function($schedule) {
|
||||
return $schedule->where('etd', '<', Carbon::now())
|
||||
->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class OwnerId implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('owner_id', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class PackingListDeliveryStatus implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $value == 1 ? $builder->whereHas('containers', function ($query){
|
||||
$query->where('containers.status', ApprovalStatus::COMPLETED);
|
||||
})->whereDoesntHave('transports') : ($value == 2 ? $builder->whereHas('transports', function (Builder $query) use ($value) {
|
||||
$query->whereDoesntHave('schedules', function (Builder $query) use ($value) {
|
||||
$query->where('status', '!=', ApprovalStatus::EXPIRED)->where('eta', '<=', Carbon::now());
|
||||
});
|
||||
}) : $builder->whereHas('transports', function (Builder $query) use ($value) {
|
||||
$query->whereHas('schedules', function (Builder $query) use ($value) {
|
||||
$query->where('status', '!=', ApprovalStatus::EXPIRED)->where('eta', '<=', Carbon::now());
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class PackingListStatus implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('packing_lists.status', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class PackingListType implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('packing_lists.type', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class TypeIn implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereIn('type', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class WarehouseParcels implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereHas('packingList', function ($query){
|
||||
return $query->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->where('status', ApprovalStatus::APPROVED);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class WithArrivalDate implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->leftJoin('transport_arrangements', function ($join) {
|
||||
$join->on('packing_lists.id', '=', 'transport_arrangements.owner_id')->where('transport_arrangements.owner_type', 'App\Models\PackingList');
|
||||
})->addSelect(['packing_lists.*', DB::raw('transport_arrangements.drop_date as arrival_date')]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Interfaces;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
interface Notifiable
|
||||
{
|
||||
public function subject(): MorphTo;
|
||||
|
||||
public function target(): MorphTo;
|
||||
|
||||
public function causer(): MorphTo;
|
||||
}
|
||||
@@ -7,7 +7,6 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface Packable
|
||||
{
|
||||
|
||||
public function packingLists(): morphMany;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Interfaces;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface Transactionable
|
||||
{
|
||||
|
||||
public function transactions(): morphMany;
|
||||
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class CurlContainerListJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
private $page;
|
||||
|
||||
public function __construct($page = 1)
|
||||
{
|
||||
$this->page = $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$cookies = $this->getCookie();
|
||||
|
||||
$headers = [
|
||||
'Content-Type' => 'application/json',
|
||||
'Cookie' => $cookies,
|
||||
];
|
||||
|
||||
$last_two_month = Carbon::now()->subMonth(2)->format('Y-m-d');
|
||||
|
||||
$client = new \GuzzleHttp\Client(['headers' => $headers]);
|
||||
$res = $client->post('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', [\GuzzleHttp\RequestOptions::JSON => json_decode('{"controller":"VCustomercontainer","view":"grid1","request":{"PageIndex":' . $this->page . ',"PageSize":10,"PageOffset":0,"SortExpression":"CreatedOn DESC","GroupExpression":"","Filter":["LoadedTime:<=%js%\"' . $last_two_month . 'T00:00:00.000\"\u0000"],"ContextKey":"view1","FilterIsExternal":false,"LookupContextFieldName":null,"LookupContextController":null,"LookupContextView":null,"LookupContext":null,"Inserting":false,"LastCommandName":null,"ExternalFilter":[],"DoesNotRequireData":false,"LastView":"grid1","Tag":null,"RequiresFirstLetters":false,"ViewType":"Grid","SupportsCaching":true,"SystemFilter":null,"RequiresRowCount":true,"QuickFindHint":null,"RequiresPivot":false,"PivotDefinitions":null,"RequiresMetaData":true}}')]);
|
||||
|
||||
$data = json_decode($res->getBody()->getContents());
|
||||
|
||||
if (!empty($data->d->Rows)) {
|
||||
// insert data here
|
||||
|
||||
// next page
|
||||
$this->page = $this->page > 0 ? $this->page + 1 : 1;
|
||||
CurlContainerListJob::dispatch($this->page + 1)
|
||||
->delay(Carbon::now()->addSeconds(10));
|
||||
}
|
||||
}
|
||||
|
||||
public function getCookie()
|
||||
{
|
||||
// get latest cookies
|
||||
$client = new \GuzzleHttp\Client(['cookies' => true]);
|
||||
$r = $client->request('GET', 'http://portal.vtnation.com.my');
|
||||
$call_cookie = $client->getConfig('cookies');
|
||||
$call_cookie = $call_cookie->toArray();
|
||||
$latest_cookie = [];
|
||||
|
||||
foreach ($call_cookie as $key => $row) {
|
||||
$latest_cookie[] = $row['Name'] . '=' . $row['Value'];
|
||||
}
|
||||
$latest_cookie = implode(';', $latest_cookie);
|
||||
|
||||
// get access token
|
||||
$headers = [
|
||||
'Content-Type' => 'application/json',
|
||||
'Cookie' => $latest_cookie,
|
||||
];
|
||||
$client = new \GuzzleHttp\Client(['headers' => $headers]);
|
||||
$res = $client->post('http://portal.vtnation.com.my/Services/DataControllerService.asmx/Login', [\GuzzleHttp\RequestOptions::JSON => [
|
||||
"username" => "CIEF",
|
||||
"password" => "0122120880",
|
||||
"createPersistentCookie" => true,
|
||||
]]);
|
||||
|
||||
$token = json_decode($res->getBody()->getContents());
|
||||
$token = $token->d->AccessToken;
|
||||
|
||||
$latest_cookie = $latest_cookie . ';AppVTCC=' . $token;
|
||||
return $latest_cookie;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchOrderListsFromYdPortalProcessor;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class FetchOrdersFromYDPortalJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
||||
public $timeout = 900;
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
(App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,6 +15,7 @@ use App\Classes\Modules\Companies\Processors\CreateCompanyModuleProcessor;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
||||
use App\Classes\Modules\Companies\Services\ApprovesCompanyConnection;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompanyConnection;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\Modules\Documents\Processors\UploadIdentityDocumentProcessor;
|
||||
@@ -76,6 +77,9 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
/** @var GenerateEmailVerificationAttemptProcessor */
|
||||
private $generateEmailVerificationAttemptProcessor;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/**
|
||||
* CreateCustomerLogic constructor.
|
||||
* @param CreateUserProcessor $createUserProcessor
|
||||
@@ -88,8 +92,9 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
* @param UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor
|
||||
* @param AuthenticationProcessor $authenticationProcessor
|
||||
* @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
*/
|
||||
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, AssignEmployeeProcessor $assignEmployeeProcessor, UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor)
|
||||
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, AssignEmployeeProcessor $assignEmployeeProcessor, UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor, FetchesCompanyModule $fetchesCompanyModule)
|
||||
{
|
||||
$this->createUserProcessor = $createUserProcessor;
|
||||
$this->createCompanyProcessor = $createCompanyProcessor;
|
||||
@@ -101,6 +106,7 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
$this->uploadIdentityDocumentProcessor = $uploadIdentityDocumentProcessor;
|
||||
$this->authenticationProcessor = $authenticationProcessor;
|
||||
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,7 +132,9 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
/** @var CompanyModule $companyModule */
|
||||
$companyModule = $this->createCompanyModuleProcessor->execute($company, BusinessType::IMPORTER);
|
||||
|
||||
$connectionObject = new CompanyConnectionObject($companyModule, 'CIEF', mt_rand(1000, 9999).(new GeneratesInitials())->name($company->name)->length(3)->generate());
|
||||
$inviter = $this->fetchesCompanyModule->execute(['reference'=>'CIEF']);
|
||||
|
||||
$connectionObject = new CompanyConnectionObject($companyModule, $inviter, mt_rand(1000, 9999).(new GeneratesInitials())->name($company->name)->length(3)->generate(), 'CIEF');
|
||||
|
||||
$connection = $this->createsCompanyConnection->execute($connectionObject);
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\ControllersLogic;
|
||||
|
||||
use App\Classes\Modules\Accounts\Processors\CrossAuthenticationProcessor;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CrossAuthenticateUserLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Cross Authentication',
|
||||
'message' => 'You have successfully logged in to your account'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CrossAuthenticationProcessor */
|
||||
private $crossAuthenticationProcessor;
|
||||
|
||||
|
||||
/**
|
||||
* CrossAuthenticateUserLogic constructor.
|
||||
* @param CrossAuthenticationProcessor $authenticationProcessor
|
||||
*/
|
||||
public function __construct(CrossAuthenticationProcessor $crossAuthenticationProcessor)
|
||||
{
|
||||
$this->crossAuthenticationProcessor = $crossAuthenticationProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\AccessUnauthorisedException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function logic(Request $request): JsonResponse {
|
||||
return $this->response($this->crossAuthenticationProcessor->execute($request));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\ValueObjects\Constants\Notifications;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class GeneratePasswordResetLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
@@ -27,7 +27,6 @@ class LogoutUserLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function __construct(InvalidatesAuthenticationToken $invalidatesAuthenticationToken)
|
||||
{
|
||||
logger("logout user logic");
|
||||
$this->invalidatesAuthenticationToken = $invalidatesAuthenticationToken;
|
||||
}
|
||||
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\DataTransferObjects;
|
||||
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class CrossAuthenticationCredentialsObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
private $access_token;
|
||||
|
||||
/** @var string */
|
||||
private $platform;
|
||||
|
||||
/**
|
||||
* CrossAuthenticationCredentialsObject constructor.
|
||||
* @param string $access_token
|
||||
* @param string $platform
|
||||
*/
|
||||
public function __construct(string $access_token, int $platform)
|
||||
{
|
||||
$this->access_token = $access_token;
|
||||
$this->platform = $platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAccessToken(): string
|
||||
{
|
||||
return $this->access_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPlatform(): int
|
||||
{
|
||||
return $this->platform;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Models\User;
|
||||
|
||||
class UserSocialAccountObject implements DataTransferObject
|
||||
{
|
||||
/** @var String */
|
||||
private $app_id;
|
||||
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/** @var integer */
|
||||
private $platform;
|
||||
|
||||
/**
|
||||
* UserSocialAccountObject constructor.
|
||||
* @param String $token
|
||||
* @param String $app_id
|
||||
*/
|
||||
public function __construct(String $app_id, User $user, int $platform)
|
||||
{
|
||||
$this->app_id = $app_id;
|
||||
$this->user = $user;
|
||||
$this->platform = $platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAppId(): String
|
||||
{
|
||||
return $this->app_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function getUser(): User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPlatform(): int
|
||||
{
|
||||
return $this->platform;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Processors;
|
||||
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\CrossAuthenticationCredentialsObject;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyConnectionObject;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\UserSocialAccountObject;
|
||||
|
||||
use App\Classes\Modules\Accounts\Services\CrossAuthenticatesUser;
|
||||
use App\Classes\Modules\Accounts\Services\AuthenticationRedirect;
|
||||
use App\Classes\Modules\Accounts\Services\FetchesUser;
|
||||
use App\Classes\Modules\Accounts\Services\GeneratesAuthenticationToken;
|
||||
use App\Classes\Modules\Accounts\Standards\Rules\CanCrossAuthenticateUser;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
|
||||
use App\Classes\Modules\Accounts\Processors\CreateUserProcessor;
|
||||
use App\Classes\Modules\Companies\Processors\CreateCompanyProcessor;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\Modules\Companies\Processors\CreateCompanyModuleProcessor;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompanyConnection;
|
||||
use App\Classes\General\Services\GeneratesInitials;
|
||||
use App\Classes\Modules\Companies\Services\ApprovesCompanyConnection;
|
||||
use App\Classes\Modules\Companies\Processors\AssignEmployeeProcessor;
|
||||
use App\Classes\Modules\Documents\Processors\UploadIdentityDocumentProcessor;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesUserSocialAccount;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use App\Classes\ValueObjects\Constants\CompanyType;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\UserSocialAccount;
|
||||
|
||||
class CrossAuthenticationProcessor
|
||||
{
|
||||
|
||||
/** @var CanCrossAuthenticateUser */
|
||||
private $canCrossAuthenticateUser;
|
||||
|
||||
/** @var CrossAuthenticatesUser */
|
||||
private $authenticatesUser;
|
||||
|
||||
/** @var GeneratesAuthenticationToken */
|
||||
private $generatesAuthenticationToken;
|
||||
|
||||
/** @var FetchesUser */
|
||||
private $fetchesUser;
|
||||
|
||||
/** @var AuthenticationRedirect */
|
||||
private $authenticationRedirect;
|
||||
|
||||
/** @var CreateUserProcessor */
|
||||
private $createUserProcessor;
|
||||
|
||||
/** @var CreateCompanyProcessor */
|
||||
private $createCompanyProcessor;
|
||||
|
||||
/** @var CreateContactProcessor */
|
||||
private $createContactProcessor;
|
||||
|
||||
/** @var CreateCompanyModuleProcessor */
|
||||
private $createCompanyModuleProcessor;
|
||||
|
||||
/** @var CreatesCompanyConnection */
|
||||
private $createsCompanyConnection;
|
||||
|
||||
/** @var ApprovesCompanyConnection */
|
||||
private $approvesCompanyConnection;
|
||||
|
||||
/** @var AssignEmployeeProcessor */
|
||||
private $assignEmployeeProcessor;
|
||||
|
||||
/** @var UploadIdentityDocumentProcessor */
|
||||
private $uploadIdentityDocumentProcessor;
|
||||
|
||||
/** @var CreatesUserSocialAccount */
|
||||
private $createsUserSocialAccount;
|
||||
|
||||
/**
|
||||
* CrossAuthenticationProcessor constructor.
|
||||
* @param CanCrossAuthenticateUser $canCrossAuthenticateUser
|
||||
* @param CrossAuthenticatesUser $crossAuthenticatesUser
|
||||
* @param GeneratesAuthenticationToken $generatesAuthenticationToken
|
||||
* @param FetchesUser $fetchesUser
|
||||
* @param AuthenticationRedirect $authenticationRedirect
|
||||
* @param CreateUserProcessor $createUserProcessor
|
||||
* @param CreateCompanyProcessor $createCompanyProcessor
|
||||
* @param CreateContactProcessor $createContactProcessor
|
||||
* @param CreateCompanyModuleProcessor $createCompanyModuleProcessor
|
||||
* @param CreatesCompanyConnection $createsCompanyConnection
|
||||
* @param ApprovesCompanyConnection $approvesCompanyConnection
|
||||
* @param AssignEmployeeProcessor $assignEmployeeProcessor
|
||||
* @param UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor
|
||||
* @param CreatesUserSocialAccount $createsUserSocialAccount
|
||||
*/
|
||||
public function __construct(
|
||||
CanCrossAuthenticateUser $canCrossAuthenticateUser,
|
||||
CrossAuthenticatesUser $crossAuthenticatesUser,
|
||||
GeneratesAuthenticationToken $generatesAuthenticationToken,
|
||||
FetchesUser $fetchesUser,
|
||||
AuthenticationRedirect $authenticationRedirect,
|
||||
CreateUserProcessor $createUserProcessor,
|
||||
CreateCompanyProcessor $createCompanyProcessor,
|
||||
CreateContactProcessor $createContactProcessor,
|
||||
CreateCompanyModuleProcessor $createCompanyModuleProcessor,
|
||||
CreatesCompanyConnection $createsCompanyConnection,
|
||||
ApprovesCompanyConnection $approvesCompanyConnection,
|
||||
AssignEmployeeProcessor $assignEmployeeProcessor,
|
||||
UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor,
|
||||
CreatesUserSocialAccount $createsUserSocialAccount
|
||||
)
|
||||
{
|
||||
$this->canCrossAuthenticateUser = $canCrossAuthenticateUser;
|
||||
$this->crossAuthenticatesUser = $crossAuthenticatesUser;
|
||||
$this->generatesAuthenticationToken = $generatesAuthenticationToken;
|
||||
$this->fetchesUser = $fetchesUser;
|
||||
$this->authenticationRedirect = $authenticationRedirect;
|
||||
$this->createUserProcessor = $createUserProcessor;
|
||||
$this->createCompanyProcessor = $createCompanyProcessor;
|
||||
$this->createContactProcessor = $createContactProcessor;
|
||||
$this->createCompanyModuleProcessor = $createCompanyModuleProcessor;
|
||||
$this->createsCompanyConnection = $createsCompanyConnection;
|
||||
$this->createsCompanyConnection = $createsCompanyConnection;
|
||||
$this->approvesCompanyConnection = $approvesCompanyConnection;
|
||||
$this->assignEmployeeProcessor = $assignEmployeeProcessor;
|
||||
$this->uploadIdentityDocumentProcessor = $uploadIdentityDocumentProcessor;
|
||||
$this->createsUserSocialAccount = $createsUserSocialAccount;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return array
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\AccessUnauthorisedException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request): array {
|
||||
|
||||
$object = new CrossAuthenticationCredentialsObject($request->input('access_token'), $request->input('platform'));
|
||||
|
||||
$this->canCrossAuthenticateUser->passes($object);
|
||||
|
||||
$cross = $this->crossAuthenticatesUser->execute($object);
|
||||
|
||||
$user_social_account = UserSocialAccount::where('app_id', $cross->token->user->id)->first();
|
||||
if (!$user_social_account) {
|
||||
|
||||
$request->request->add([
|
||||
'name' => $cross->token->user->name,
|
||||
'email' => $cross->token->user->email,
|
||||
'password' => 'pass123',
|
||||
'password_confirmation' => 'pass123',
|
||||
]);
|
||||
|
||||
$user = $this->createUserProcessor->execute(
|
||||
$request,
|
||||
RoleTypes::USER,
|
||||
env('APP_ENV') != 'production' ? ApprovalStatus::APPROVED : ApprovalStatus::PENDING_VERIFICATION
|
||||
);
|
||||
|
||||
$company = $this->createCompanyProcessor->execute(
|
||||
$cross->payload->data->name,
|
||||
CompanyType::COMPANY_BUSINESS,
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
|
||||
$contactObject = new ContactObject(
|
||||
$cross->payload->data->contact->reference,
|
||||
$cross->payload->data->contact->phone,
|
||||
$cross->payload->data->contact->email,
|
||||
$cross->payload->data->contact->wechat_id
|
||||
);
|
||||
$contact = $this->createContactProcessor->execute($contactObject, $company);
|
||||
|
||||
$companyModule = $this->createCompanyModuleProcessor->execute($company, BusinessType::IMPORTER);
|
||||
|
||||
$connectionObject = new CompanyConnectionObject(
|
||||
$companyModule, 'CIEF',
|
||||
mt_rand(1000, 9999).(new GeneratesInitials())->name($company->name)->length(3)->generate()
|
||||
);
|
||||
$connection = $this->createsCompanyConnection->execute($connectionObject);
|
||||
|
||||
$this->approvesCompanyConnection->execute($connection);
|
||||
|
||||
$object = new EmploymentObject($companyModule, $user);
|
||||
$this->assignEmployeeProcessor->execute($object);
|
||||
|
||||
$request->request->add([
|
||||
'files' => [$cross->document->src],
|
||||
'identification_no' => $cross->payload->data->identification->reference,
|
||||
]);
|
||||
|
||||
$this->uploadIdentityDocumentProcessor->execute($request, $company);
|
||||
|
||||
$object = new UserSocialAccountObject(
|
||||
$cross->token->user->id,
|
||||
$user,
|
||||
$request->input('platform')
|
||||
);
|
||||
$this->createsUserSocialAccount->execute($object);
|
||||
}
|
||||
else {
|
||||
$user = $user_social_account->user()->first();
|
||||
}
|
||||
|
||||
return ['access_token' => $this->generatesAuthenticationToken->execute($user), 'redirect_url' => $this->authenticationRedirect->url($user)];
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -56,4 +56,4 @@ class GenerateEmailVerificationAttemptProcessor
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use App\Models\User;
|
||||
|
||||
@@ -11,6 +12,11 @@ class AuthenticationRedirect
|
||||
public function url(User $user){
|
||||
|
||||
if($user->type === RoleTypes::USER){
|
||||
|
||||
if (in_array($user->companyModule()->first()->type, [BusinessType::ONLINE_SELLER, BusinessType::LAST_MILE_DELIVERY_AGENT])) {
|
||||
return route('last_mile_delivery.dashboard');
|
||||
}
|
||||
|
||||
return route('dashboard');
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\UserSocialAccountObject;
|
||||
use App\Models\UserSocialAccount;
|
||||
|
||||
class CreatesUserSocialAccount extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param UserSocialAccountObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(UserSocialAccountObject $object) {
|
||||
$model = new UserSocialAccount();
|
||||
$model->user_id = $object->getUser()->id;
|
||||
$model->app_id = $object->getAppId();
|
||||
$model->platform = $object->getPlatform();
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\AccessUnauthorisedException;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\CrossAuthenticationCredentialsObject;
|
||||
use App\Classes\ValueObjects\Constants\PlatformType;
|
||||
|
||||
class CrossAuthenticatesUser
|
||||
{
|
||||
|
||||
/**
|
||||
* @param CrossAuthenticationCredentialsObject $object
|
||||
* @return false|string
|
||||
* @throws AccessUnauthorisedException
|
||||
*/
|
||||
|
||||
public function execute(CrossAuthenticationCredentialsObject $object){
|
||||
|
||||
if ($object->getPlatform() == PlatformType::EXCHANGE) {
|
||||
|
||||
$token = $object->getAccessToken();
|
||||
|
||||
$tokenParts = explode(".", $token);
|
||||
$tokenPayload = base64_decode($tokenParts[1]);
|
||||
$jwtPayload = json_decode($tokenPayload);
|
||||
|
||||
$response = Http::withToken($object->getAccessToken())->get(env('EXCHANGE_URL') . 'api/v1/company/' . $jwtPayload->user->company_id . '/show')->object();
|
||||
|
||||
$response_document = Http::withToken($object->getAccessToken())->get(env('EXCHANGE_URL') . 'api/v1/storage/' . $response->payload->data->identification->files[0]->file->file_info[0]->original->file . '/fetch')->object();
|
||||
$response->token = $jwtPayload;
|
||||
$response->document = $response_document->payload;
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\UserSocialAccount;
|
||||
|
||||
class FetchesUserSocialAccount extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var UserSocialAccount */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* FetchesUser constructor.
|
||||
* @param UserSocialAccount $repository
|
||||
*/
|
||||
public function __construct(UserSocialAccount $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,11 @@ class GeneratesAuthenticationToken {
|
||||
$companyModule = $user->companyModule()->first();
|
||||
|
||||
$claims = array_merge($claims, [
|
||||
'company_id' => $companyModule->company_id
|
||||
'company_id' => $companyModule->company_id,
|
||||
'company_module_id' => $companyModule->id,
|
||||
'company_module_type' => $companyModule->type,
|
||||
'company_name' => $companyModule->name,
|
||||
'company_marking' => $companyModule->type !== 8 ? $companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference : 'HWT',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\AuthenticationCredentialsObject;
|
||||
use App\Classes\Modules\Accounts\Standards\Validators\UserCrossAuthenticationValidation;
|
||||
|
||||
class CanCrossAuthenticateUser extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var UserCrossAuthenticationValidation */
|
||||
private $userCrossAuthenticationValidation;
|
||||
|
||||
/**
|
||||
* CanCrossAuthenticateUser constructor.
|
||||
* @param UserCrossAuthenticationValidation $userCrossAuthenticationValidation
|
||||
*/
|
||||
public function __construct(UserCrossAuthenticationValidation $userCrossAuthenticationValidation)
|
||||
{
|
||||
$this->userCrossAuthenticationValidation = $userCrossAuthenticationValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param AuthenticationCredentialsObject $object
|
||||
* @return bool
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->userCrossAuthenticationValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AuthenticationCredentialsObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\CrossAuthenticationCredentialsObject;
|
||||
|
||||
class UserCrossAuthenticationValidation extends AbstractValidation
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param CrossAuthenticationCredentialsObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array {
|
||||
return [
|
||||
'access_token' => $object->getAccesstoken(),
|
||||
'platform' => $object->getPlatform()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array {
|
||||
return [
|
||||
'access_token' => 'required',
|
||||
'platform' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -4,12 +4,19 @@ namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\General\Interfaces\Contactable;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesDistrict;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -39,19 +46,29 @@ class CreateAddressLogic extends AbstractControllerLogic
|
||||
/** @var CreatesAddress */
|
||||
private $createsAddress;
|
||||
|
||||
/** @var CreateContactProcessor */
|
||||
private $createContactProcessor;
|
||||
|
||||
/** @var CreateRemarkProcessor */
|
||||
private $createRemarkProcessor;
|
||||
|
||||
/**
|
||||
* CreateAddressLogic constructor.
|
||||
* @param CanCreateAddress $canCreateAddress
|
||||
* @param FetchesDistrict $fetchesDistrict
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param CreatesAddress $createsAddress
|
||||
* @param CreateContactProcessor $createContactProcessor
|
||||
* @param CreateRemarkProcessor $createRemarkProcessor
|
||||
*/
|
||||
public function __construct(CanCreateAddress $canCreateAddress, FetchesDistrict $fetchesDistrict, FetchesCompanyModule $fetchesCompanyModule, CreatesAddress $createsAddress)
|
||||
public function __construct(CanCreateAddress $canCreateAddress, FetchesDistrict $fetchesDistrict, FetchesCompanyModule $fetchesCompanyModule, CreatesAddress $createsAddress, CreateContactProcessor $createContactProcessor, CreateRemarkProcessor $createRemarkProcessor)
|
||||
{
|
||||
$this->canCreateAddress = $canCreateAddress;
|
||||
$this->fetchesDistrict = $fetchesDistrict;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createsAddress = $createsAddress;
|
||||
$this->createContactProcessor = $createContactProcessor;
|
||||
$this->createRemarkProcessor = $createRemarkProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,12 +83,23 @@ class CreateAddressLogic extends AbstractControllerLogic
|
||||
|
||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||
|
||||
$object = new AddressObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code'), $request->input('reference'));
|
||||
$object = new AddressObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code'), $request->input('type'), ApprovalStatus::APPROVED, $request->input('reference'));
|
||||
|
||||
$this->canCreateAddress->passes($object);
|
||||
|
||||
/** @var Address $address */
|
||||
$address = $this->createsAddress->execute($this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]), $object);
|
||||
|
||||
if($request->input('phone')){
|
||||
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
||||
$this->createContactProcessor->execute($contactObject, $address);
|
||||
}
|
||||
|
||||
if($request->input('remark')){
|
||||
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||
use App\Classes\Modules\Addresses\Services\ListsStates;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Http\Resources\StateResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListStatesLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Addresses',
|
||||
'message' => 'You have successfully retrieved a list of Addresses'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ListsStates */
|
||||
private $listStates;
|
||||
|
||||
/**
|
||||
* ListStatesLogic constructor.
|
||||
* @param ListsStates $listStates
|
||||
*/
|
||||
public function __construct(ListsStates $listStates)
|
||||
{
|
||||
$this->listStates = $listStates;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$query = $this->listStates->execute($this->listStates->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(StateResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,14 @@ use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesDistrict;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanUpdateAddress;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use App\Classes\ValueObjects\Constants\AddressType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -38,22 +45,31 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
||||
/** @var FetchesDistrict */
|
||||
private $fetchesDistrict;
|
||||
|
||||
/** @var CreateContactProcessor */
|
||||
private $createContactProcessor;
|
||||
|
||||
/** @var CreateRemarkProcessor */
|
||||
private $createRemarkProcessor;
|
||||
|
||||
/**
|
||||
* UpdateAddressLogic constructor.
|
||||
* @param CanUpdateAddress $canUpdateAddress
|
||||
* @param UpdatesAddress $updatesAddress
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
* @param FetchesDistrict $fetchesDistrict
|
||||
* @param CreateContactProcessor $createContactProcessor
|
||||
* @param CreateRemarkProcessor $createRemarkProcessor
|
||||
*/
|
||||
public function __construct(CanUpdateAddress $canUpdateAddress, UpdatesAddress $updatesAddress, FetchesAddress $fetchesAddress, FetchesDistrict $fetchesDistrict)
|
||||
public function __construct(CanUpdateAddress $canUpdateAddress, UpdatesAddress $updatesAddress, FetchesAddress $fetchesAddress, FetchesDistrict $fetchesDistrict, CreateContactProcessor $createContactProcessor, CreateRemarkProcessor $createRemarkProcessor)
|
||||
{
|
||||
$this->canUpdateAddress = $canUpdateAddress;
|
||||
$this->updatesAddress = $updatesAddress;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
$this->fetchesDistrict = $fetchesDistrict;
|
||||
$this->createContactProcessor = $createContactProcessor;
|
||||
$this->createRemarkProcessor = $createRemarkProcessor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
@@ -65,14 +81,27 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
||||
{
|
||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||
|
||||
$object = new AddressObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code'), $request->input('reference'));
|
||||
$object = new AddressObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code'), AddressType::DELIVERY, ApprovalStatus::APPROVED, $request->input('reference'));
|
||||
|
||||
$this->canUpdateAddress->passes($object);
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->route('id')]);
|
||||
|
||||
/** @var Address $address */
|
||||
$address = $this->updatesAddress->execute($address, $object);
|
||||
|
||||
$address->contacts()->delete(); $address->remarks()->delete();
|
||||
|
||||
if($request->input('phone')){
|
||||
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
||||
$this->createContactProcessor->execute($contactObject, $address);
|
||||
}
|
||||
|
||||
if($request->input('remark')){
|
||||
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,12 @@ class AddressObject implements DataTransferObject
|
||||
/** @var int */
|
||||
private $postCode;
|
||||
|
||||
/** @var int */
|
||||
private $type;
|
||||
|
||||
/** @var int */
|
||||
private $status;
|
||||
|
||||
/** @var string|null */
|
||||
private $reference;
|
||||
|
||||
@@ -37,9 +43,11 @@ class AddressObject implements DataTransferObject
|
||||
* @param int $stateId
|
||||
* @param int $districtId
|
||||
* @param int $postCode
|
||||
* @param int $type
|
||||
* @param int $status
|
||||
* @param null|string $reference
|
||||
*/
|
||||
public function __construct(string $streetOne, ?string $streetTwo, int $countryId, int $stateId, int $districtId, int $postCode, ?string $reference = null, ?int $status = ApprovalStatus::APPROVED)
|
||||
public function __construct(string $streetOne, ?string $streetTwo, int $countryId, int $stateId, int $districtId, int $postCode, int $type, int $status, ?string $reference = null)
|
||||
{
|
||||
$this->streetOne = $streetOne;
|
||||
$this->streetTwo = $streetTwo;
|
||||
@@ -47,8 +55,9 @@ class AddressObject implements DataTransferObject
|
||||
$this->stateId = $stateId;
|
||||
$this->districtId = $districtId;
|
||||
$this->postCode = $postCode;
|
||||
$this->reference = $reference;
|
||||
$this->type = $type;
|
||||
$this->status = $status;
|
||||
$this->reference = $reference;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,11 +109,11 @@ class AddressObject implements DataTransferObject
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
* @return int
|
||||
*/
|
||||
public function getReference(): ?string
|
||||
public function getType(): int
|
||||
{
|
||||
return $this->reference;
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,5 +124,13 @@ class AddressObject implements DataTransferObject
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
public function getReference(): ?string
|
||||
{
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -10,6 +10,8 @@ namespace App\Classes\Modules\Addresses\Services;
|
||||
|
||||
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Classes\ValueObjects\Constants\AddressType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\District;
|
||||
use App\Models\OldAddress;
|
||||
|
||||
@@ -31,7 +33,7 @@ class CleansOldAddress
|
||||
return null;
|
||||
}
|
||||
|
||||
return new AddressObject($this->cleanAddress($address->street_one, $district, $address->post_code), $this->cleanAddress($address->street_two, $district, $address->post_code), $district->country_id, $district->state_id, $district->id, $address->post_code, 'Delivery Address');
|
||||
return new AddressObject($this->cleanAddress($address->street_one, $district, $address->post_code), $this->cleanAddress($address->street_two, $district, $address->post_code), $district->country_id, $district->state_id, $district->id, $address->post_code, AddressType::DELIVERY, ApprovalStatus::APPROVED, 'Delivery Address');
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ class CreatesAddress extends AbstractUpdateRelationshipRecord
|
||||
$model->district_id = $object->getDistrictId();
|
||||
$model->postcode = $object->getPostCode();
|
||||
$model->status = $object->getStatus();
|
||||
$model->type = $object->getType();
|
||||
|
||||
return $this->handler($addressable->addresses(), $model);
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Addresses\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use App\Models\State;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ListsStates extends AbstractListRecord
|
||||
{
|
||||
|
||||
/** @var State */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsStates constructor.
|
||||
* @param State $repository
|
||||
*/
|
||||
public function __construct(State $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Classes\Modules\Announcements\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class AnnouncementObject implements DataTransferObject
|
||||
{
|
||||
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Billplzs\ControllersLogic;
|
||||
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
|
||||
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
use App\Http\Resources\TransactionResource;
|
||||
use App\Models\Booking;
|
||||
use App\Models\User;
|
||||
use App\Models\Wallet;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Billplzs\Services\GetBillplzBill;
|
||||
use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CallbackBillplzLogic
|
||||
{
|
||||
/** @var GetBillplzBill */
|
||||
private $getBillplzBill;
|
||||
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var UpdatesWalletBalance */
|
||||
private $updatesWalletBalance;
|
||||
|
||||
/**
|
||||
* CallbackBillplzLogic constructor.
|
||||
* @param GetBillplzBill $getBillplzBill
|
||||
* @param FetchesTransaction $fetchesTransaction
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param UpdatesWalletBalance $updatesWalletBalance
|
||||
*/
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus)
|
||||
{
|
||||
$this->getBillplzBill = $getBillplzBill;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return bool|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @throws MalformedRequestException
|
||||
* @throws ResourceNotFoundException
|
||||
*/
|
||||
public function execute(Request $request)
|
||||
{
|
||||
$billplzXSignatureObject = new BillplzXSignatureObject($request);
|
||||
|
||||
if(!$billplzXSignatureObject->isValidSignature()){
|
||||
throw new MalformedRequestException('Billplz Payment validation failed.');
|
||||
}
|
||||
|
||||
$billPlz = $this->getBillplzBill->execute($billplzXSignatureObject->getBillPlzId());
|
||||
|
||||
if(!$billPlz) throw new ResourceNotFoundException('Billplz bill not found.');
|
||||
|
||||
$transaction = $this->fetchesTransaction->execute(['payment_reference' => $billplzXSignatureObject->getBillPlzId()]);
|
||||
|
||||
if($billPlz->state === 'paid') {
|
||||
$status = ApprovalStatus::APPROVED;
|
||||
}
|
||||
|
||||
if($billPlz->state === 'due') {
|
||||
$status = $billplzXSignatureObject->getStatus() === 'failed' ? ApprovalStatus::REJECTED : ApprovalStatus::PENDING_VERIFICATION;
|
||||
}
|
||||
|
||||
$token = Auth::fromUser(User::find(1));
|
||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
||||
|
||||
$marking = $transaction->owner()->first()->owner()->first();
|
||||
|
||||
return $request->method() === 'POST' ? true : view('pages.payments_redirect', ['marking' => $marking->reference, 'transaction' => $transaction, 'status' => $status]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Billplzs\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
|
||||
|
||||
use ErrorException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateBillplzBillLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Billplz Bill',
|
||||
'message' => 'You have successfully created a new Bill'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CreatesBillplzBill */
|
||||
private $createsBillplzBill;
|
||||
|
||||
/**
|
||||
* CreateBookingLogic constructor.
|
||||
* @param CreatesBillplzBill $createsBillplzBill
|
||||
*/
|
||||
public function __construct(CreatesBillplzBill $createsBillplzBill)
|
||||
{
|
||||
$this->createsBillplzBill = $createsBillplzBill;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$billPlz = $this->createsBillplzBill->execute($request->user()->name, $request->user()->email, $request->input('description'), 200, $request->input('bankName'));
|
||||
|
||||
if(!$billPlz) throw new MalformedRequestException('Unable to get correct response from billplz server.');
|
||||
|
||||
return $this->response(['data' => $billPlz]);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Billplzs\DataTransferObjects;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use function PHPSTORM_META\map;
|
||||
|
||||
class BillplzXSignatureObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
private $billPlzId;
|
||||
|
||||
/** @var string */
|
||||
private $status;
|
||||
|
||||
/** @var array */
|
||||
private $billPlzConstructArray;
|
||||
|
||||
/** @var string */
|
||||
private $billPlzConstructString;
|
||||
|
||||
/** @var string */
|
||||
private $billPlzComputedXSignature;
|
||||
|
||||
/** @var string */
|
||||
private $type;
|
||||
|
||||
/** @var Request */
|
||||
private $request;
|
||||
|
||||
/** @var string */
|
||||
private $requestXSignature;
|
||||
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
|
||||
$this->type = $request->exists('billplz') ? 'redirect' : 'callback';
|
||||
|
||||
$this->request = $this->type === 'redirect' ? $request->input('billplz') : $request;
|
||||
|
||||
$this->billPlzId = $this->request['id'];
|
||||
|
||||
$this->status = $this->request['transaction_status'];
|
||||
|
||||
$this->requestXSignature = $this->request['x_signature'];
|
||||
|
||||
$this->_constructBillplzArray()->_natSortBillplzArray()->_constructBillplzString()->_computeBillplzXSignature();
|
||||
}
|
||||
|
||||
private function _constructBillplzArray(){
|
||||
|
||||
$this->billPlzConstructArray = collect($this->request)->forget('x_signature')->map(function($item, $key){
|
||||
return $this->type === 'redirect' ? 'billplz'.$key.$item : $key.$item;
|
||||
})->toArray();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function _natCaseSortBillplzArray(){
|
||||
natcasesort($this->billPlzConstructArray);
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function _natSortBillplzArray(){
|
||||
natsort($this->billPlzConstructArray);
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function _constructBillplzString(){
|
||||
$this->billPlzConstructString = implode('|', $this->billPlzConstructArray);
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function _computeBillplzXSignature(){
|
||||
$this->billPlzComputedXSignature = hash_hmac('sha256', $this->billPlzConstructString, config('billplz.x_signature_key'));
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBillPlzId(): string
|
||||
{
|
||||
return $this->billPlzId;
|
||||
}
|
||||
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getBillPlzConstructArray(): array
|
||||
{
|
||||
return $this->billPlzConstructArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBillPlzConstructString(): string
|
||||
{
|
||||
return $this->billPlzConstructString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBillPlzComputedXSignature(): string
|
||||
{
|
||||
return $this->billPlzComputedXSignature;
|
||||
}
|
||||
|
||||
public function isValidSignature(): bool
|
||||
{
|
||||
return $this->billPlzComputedXSignature === $this->requestXSignature ? true : false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Billplzs\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
|
||||
class CreatesBillplzBill
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $email
|
||||
* @param string $description
|
||||
* @param float $amount
|
||||
* @param string $billNumber
|
||||
* @param null|string $bankCode
|
||||
* @param null|Boolean $wallet
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $name, string $email, string $description, float $amount, string $billNumber, ?string $bankCode = null, ?bool $wallet = null) {
|
||||
try{
|
||||
// config('billplz.maybank')
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [
|
||||
'collection_id' => $wallet ? config('billplz.wallet_collection_id') : config('billplz.collection_id'),
|
||||
'name' => $name,
|
||||
'email' => $email,
|
||||
'description' => $description,
|
||||
'amount' => $this->finalizeAmount($amount),
|
||||
'redirect_url' => route('online_payment.redirect'),
|
||||
'callback_url' => route('api.online_payment.callback'),
|
||||
'reference_1_label' => 'Bank Code',
|
||||
'reference_1' => $bankCode ? $bankCode : '',
|
||||
'reference_2_label' => 'Bill Number',
|
||||
'reference_2' => $billNumber
|
||||
]);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
|
||||
$data['url'] = $data['url'].'?auto_submit=true';
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from billplz server' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected function finalizeAmount($amount){
|
||||
$number = round($amount, 2) * 100;
|
||||
return (string) $number;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Billplzs\Services;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class GetBillplzBill
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $billPlzId
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $billPlzId) {
|
||||
try{
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$billPlzId);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
|
||||
return (object) $data;
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from billplz server');
|
||||
}
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Processors\AssignConnectionSegmentProcessor;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyConnection;
|
||||
use App\Http\Resources\CompanyResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AssignCompanyConnectionToConnectionSegmentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Assign Company Connection To Connection Segment',
|
||||
'message' => 'You have successfully assigned Company Connection to Connection segment'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var FetchesCompanyConnection */
|
||||
private $fetchesCompanyConnection;
|
||||
|
||||
/** @var AssignConnectionSegmentProcessor */
|
||||
private $assignCompanyConnectionToConnectionSegmentProcessor;
|
||||
|
||||
/**
|
||||
* AssignCompanyToSegmentLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param FetchesCompanyConnection $fetchesCompanyConnection
|
||||
* @param AssignConnectionSegmentProcessor $assignCompanyConnectionToConnectionSegmentProcessor
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesCompanyConnection $fetchesCompanyConnection, AssignConnectionSegmentProcessor $assignCompanyConnectionToConnectionSegmentProcessor)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->fetchesCompanyConnection = $fetchesCompanyConnection;
|
||||
$this->assignCompanyConnectionToConnectionSegmentProcessor = $assignCompanyConnectionToConnectionSegmentProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
|
||||
$companyConnection = $this->fetchesCompanyConnection->execute(['id' => $request->route('company_connection_id')]);
|
||||
|
||||
$this->assignCompanyConnectionToConnectionSegmentProcessor->execute($companyConnection, $request->input('segment_id'));
|
||||
|
||||
return $this->resourceResponse(new CompanyResource($company));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\ListsCompanyModules;
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanListCompanies;
|
||||
use App\Http\Resources\CompanyModuleResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListCompanyModulesLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Company Moduels',
|
||||
'message' => 'You have successfully retrieved a list of Companies'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanListCompanies */
|
||||
private $canListCompanies;
|
||||
|
||||
/** @var ListsCompanyModules */
|
||||
private $listsCompanyModules;
|
||||
|
||||
/**
|
||||
* ListCompaniesControllersLogic constructor.
|
||||
* @param CanListCompanies $canListCompanies
|
||||
* @param ListsCompanyModules $listsCompanyModules
|
||||
*/
|
||||
public function __construct(CanListCompanies $canListCompanies, ListsCompanyModules $listsCompanyModules)
|
||||
{
|
||||
$this->canListCompanies = $canListCompanies;
|
||||
$this->listsCompanyModules = $listsCompanyModules;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canListCompanies->passes();
|
||||
|
||||
$query = $this->listsCompanyModules->execute($this->listsCompanyModules->deserializeFilters($request->input('filters')));
|
||||
return $this->collectionResponse(CompanyModuleResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyConnection;
|
||||
use App\Classes\Modules\Companies\Services\RemovesCompanyConnectionFromConnectionSegment;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Http\Resources\CompanyResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RemoveCompanyConnectionFromConnectionSegmentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Detach Company Connection From Connection Segment',
|
||||
'message' => 'You have successfully detached Company Connection from Connection segment'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var FetchesCompanyConnection */
|
||||
private $fetchesCompanyConnection;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/** @var RemovesCompanyConnectionFromConnectionSegment */
|
||||
private $removesCompanyConnectionFromConnectionSegment;
|
||||
|
||||
/**
|
||||
* RemoveCompanyFromSegmentLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param FetchesCompanyConnection $fetchesCompanyConnection
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
* @param RemovesCompanyConnectionFromConnectionSegment $removesCompanyConnectionFromConnectionSegment
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesCompanyConnection $fetchesCompanyConnection, FetchesSegment $fetchesSegment, RemovesCompanyConnectionFromConnectionSegment $removesCompanyConnectionFromConnectionSegment)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->fetchesCompanyConnection = $fetchesCompanyConnection;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
$this->removesCompanyConnectionFromConnectionSegment = $removesCompanyConnectionFromConnectionSegment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
|
||||
$companyConnection = $this->fetchesCompanyConnection->execute(['id' => $request->route('company_connection_id')]);
|
||||
|
||||
$segment = $this->fetchesSegment->execute(['id' => $request->route('segment_id')]);
|
||||
|
||||
$this->removesCompanyConnectionFromConnectionSegment->execute($companyConnection, $segment);
|
||||
|
||||
return $this->resourceResponse(new CompanyResource($company));
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompany;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyModuleName;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanUpdateCompany;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
@@ -35,17 +36,22 @@ class UpdateCompanyLogic extends AbstractControllerLogic
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var UpdatesCompanyModuleName */
|
||||
private $updatesCompanyModuleName;
|
||||
|
||||
/**
|
||||
* UpdateCompanyControllersLogic constructor.
|
||||
* @param CanUpdateCompany $canUpdateCompany
|
||||
* @param UpdatesCompany $updatesCompany
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param UpdatesCompanyModuleName $updatesCompanyModuleName
|
||||
*/
|
||||
public function __construct(CanUpdateCompany $canUpdateCompany, UpdatesCompany $updatesCompany, FetchesCompany $fetchesCompany)
|
||||
public function __construct(CanUpdateCompany $canUpdateCompany, UpdatesCompany $updatesCompany, FetchesCompany $fetchesCompany, UpdatesCompanyModuleName $updatesCompanyModuleName)
|
||||
{
|
||||
$this->canUpdateCompany = $canUpdateCompany;
|
||||
$this->updatesCompany = $updatesCompany;
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->updatesCompanyModuleName = $updatesCompanyModuleName;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,23 +62,17 @@ class UpdateCompanyLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
$object = new CompanyObject($request->input('name'), $request->input('reference'), $request->input('type'));
|
||||
|
||||
$object = new CompanyObject($request->input('reference_no'), $request->input('name'), $request->input('type'));
|
||||
$this->canUpdateCompany->passes($object);
|
||||
|
||||
$this->canUpdateCompany->passes($object);
|
||||
$query = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
|
||||
$query = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
$query = $this->updatesCompany->execute($query, $object);
|
||||
|
||||
$query = $this->updatesCompany->execute($query, $object);
|
||||
|
||||
return $this->resourceResponse(new CompanyResource($query));
|
||||
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
$this->updatesCompanyModuleName->execute($query->companyModules()->first(), $object->getName());
|
||||
|
||||
return $this->resourceResponse(new CompanyResource($query));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,9 @@ class CompanyConnectionObject implements DataTransferObject
|
||||
|
||||
/** @var CompanyModule */
|
||||
private $invitee;
|
||||
|
||||
/** @var CompanyModule */
|
||||
private $inviter;
|
||||
|
||||
/** @var string */
|
||||
private $inviterReference;
|
||||
@@ -20,12 +23,14 @@ class CompanyConnectionObject implements DataTransferObject
|
||||
/**
|
||||
* CompanyConnectionObject constructor.
|
||||
* @param CompanyModule $invitee
|
||||
* @param CompanyModule $inviter
|
||||
* @param string $inviterReference
|
||||
* @param string $inviteeReference
|
||||
*/
|
||||
public function __construct(CompanyModule $invitee, string $inviterReference, string $inviteeReference)
|
||||
public function __construct(CompanyModule $invitee, CompanyModule $inviter, string $inviteeReference, string $inviterReference)
|
||||
{
|
||||
$this->invitee = $invitee;
|
||||
$this->inviter = $inviter;
|
||||
$this->inviterReference = $inviterReference;
|
||||
$this->inviteeReference = $inviteeReference;
|
||||
}
|
||||
@@ -38,6 +43,14 @@ class CompanyConnectionObject implements DataTransferObject
|
||||
return $this->invitee;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CompanyModule
|
||||
*/
|
||||
public function getInviter(): CompanyModule
|
||||
{
|
||||
return $this->inviter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Processors;
|
||||
|
||||
use App\Classes\Modules\Companies\Services\AssignsCompanyConnectionToConnectionSegment;
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanAssignSegment;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Models\CompanyConnection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AssignConnectionSegmentProcessor
|
||||
{
|
||||
|
||||
/** @var CanAssignSegment */
|
||||
private $canAssignSegment;
|
||||
|
||||
/** @var AssignsCompanyConnectionToConnectionSegment */
|
||||
private $assignsCompanyConnectionToConnectionSegment;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/**
|
||||
* AssignCompanyToSegmentProcessor constructor.
|
||||
* @param CanAssignSegment $canAssignSegment
|
||||
* @param AssignsCompanyConnectionToConnectionSegment $assignsCompanyConnectionToConnectionSegment
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
*/
|
||||
public function __construct(CanAssignSegment $canAssignSegment, AssignsCompanyConnectionToConnectionSegment $assignsCompanyConnectionToConnectionSegment, FetchesSegment $fetchesSegment)
|
||||
{
|
||||
$this->canAssignSegment = $canAssignSegment;
|
||||
$this->assignsCompanyConnectionToConnectionSegment = $assignsCompanyConnectionToConnectionSegment;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param CompanyConnection $companyConnection
|
||||
* @param int|null $segmentId
|
||||
* @return Model
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(CompanyConnection $companyConnection, ?int $segmentId = SegmentConstants::STANDARD_SEGMENT): Model {
|
||||
|
||||
$segment = $this->fetchesSegment->execute(['id' => $segmentId]);
|
||||
|
||||
$this->canAssignSegment->passes();
|
||||
|
||||
return $this->assignsCompanyConnectionToConnectionSegment->execute($companyConnection, $segment);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\CompanyConnection;
|
||||
use App\Models\Segment;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
class AssignsCompanyConnectionToConnectionSegment extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param CompanyConnection $companyConnection
|
||||
* @param Segment $segment
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(CompanyConnection $companyConnection, Segment $segment)
|
||||
{
|
||||
try {
|
||||
|
||||
$companyConnection->segments()->attach($segment);
|
||||
|
||||
return $companyConnection;
|
||||
|
||||
} catch (QueryException $exception){
|
||||
throw new MalformedRequestException($exception);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -30,10 +30,8 @@ class CreatesCompanyConnection extends AbstractUpdateRecord
|
||||
public function execute(CompanyConnectionObject $object)
|
||||
{
|
||||
|
||||
$companyModule = $this->fetchesCompany->execute(['id', 1])->companyModules()->first();
|
||||
|
||||
$connection = new CompanyConnection();
|
||||
$connection->inviter_id = $companyModule->id;
|
||||
$connection->inviter_id = $object->getInviter()->id;
|
||||
$connection->invitee_id = $object->getInvitee()->id;
|
||||
$connection->inviter_reference = $object->getInviterReference();
|
||||
$connection->invitee_reference = $object->getInviteeReference();
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\CompanyConnection;
|
||||
|
||||
class FetchesCompanyConnection extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var CompanyConnection */
|
||||
private $repository;
|
||||
|
||||
|
||||
/**
|
||||
* FetchesCompanyConnection constructor.
|
||||
* @param CompanyConnection $repository
|
||||
*/
|
||||
public function __construct(CompanyConnection $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\CompanyModule;
|
||||
|
||||
class ListsCompanyModules extends AbstractListRecord
|
||||
{
|
||||
|
||||
/** @var CompanyModule */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsCompanyModules constructor.
|
||||
* @param CompanyModule $repository
|
||||
*/
|
||||
public function __construct(CompanyModule $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\CompanyConnection;
|
||||
use App\Models\Segment;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
class RemovesCompanyConnectionFromConnectionSegment extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param CompanyConnection $companyConnection
|
||||
* @param Segment $segment
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(CompanyConnection $companyConnection, Segment $segment)
|
||||
{
|
||||
try {
|
||||
|
||||
$companyConnection->segments()->detach($segment);
|
||||
|
||||
return $companyConnection;
|
||||
|
||||
} catch (QueryException $exception){
|
||||
throw new MalformedRequestException($exception);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
use App\Models\Company;
|
||||
|
||||
class UpdatesCompany extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Company $model
|
||||
* @param CompanyObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Company $model, CompanyObject $object)
|
||||
{
|
||||
$model->name = $object->getName();
|
||||
$model->reference = $object->getReference();
|
||||
$model->type = $object->getType();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyModuleObject;
|
||||
use App\Models\CompanyModule;
|
||||
|
||||
class UpdatesCompanyModuleName extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param CompanyModule $model
|
||||
* @param CompanyModuleObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(CompanyModule $model, string $name)
|
||||
{
|
||||
$model->name = $name;
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
use App\Classes\Modules\Companies\Standards\Validators\CompanyValidation;
|
||||
|
||||
class CanUpdateCompany extends AbstractRule
|
||||
{
|
||||
/** @var CompanyValidation */
|
||||
private $companyValidation;
|
||||
|
||||
|
||||
/**
|
||||
* CanUpdateCompany constructor.
|
||||
* @param CompanyValidation $companyValidation
|
||||
*/
|
||||
public function __construct(CompanyValidation $companyValidation)
|
||||
{
|
||||
$this->companyValidation = $companyValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CompanyObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->companyValidation->validate($object, 'PUT');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CompanyObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,8 @@ class CompanyValidation extends AbstractValidation
|
||||
{
|
||||
return [
|
||||
'company_name' => $object->getName(),
|
||||
'company_reference' => $object->getReference()
|
||||
'company_reference' => $object->getReference(),
|
||||
'type' => $object->getType()
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
|
||||
namespace App\Classes\Modules\Contacts\Processors;
|
||||
|
||||
use App\Classes\General\Interfaces\Contactable;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Contacts\Services\CreatesContact;
|
||||
use App\Classes\Modules\Contacts\Standards\Rules\CanCreateContact;
|
||||
use App\Models\Company;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CreateContactProcessor
|
||||
@@ -15,6 +14,9 @@ class CreateContactProcessor
|
||||
/** @var CanCreateContact */
|
||||
private $canCreateContact;
|
||||
|
||||
/** @var CreatesContact */
|
||||
private $createsContact;
|
||||
|
||||
/**
|
||||
* CreateContactProcessor constructor.
|
||||
* @param CanCreateContact $canCreateContact
|
||||
@@ -28,17 +30,17 @@ class CreateContactProcessor
|
||||
|
||||
/**
|
||||
* @param ContactObject $object
|
||||
* @param Company $company
|
||||
* @param Contactable $contactable
|
||||
* @return Model
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(ContactObject $object, Company $company): Model
|
||||
public function execute(ContactObject $object, Contactable $contactable): Model
|
||||
{
|
||||
|
||||
$this->canCreateContact->passes($object);
|
||||
|
||||
return $this->createsContact->execute($company,$object);
|
||||
return $this->createsContact->execute($contactable,$object);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Delivery\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Services\CancelsOrder;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Http\Resources\DeliveryOrderResource;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CancelDeliveryOrderLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Cancelled Order',
|
||||
'message' => 'You have successfully cancelled an order'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CancelsOrder */
|
||||
private $cancelsOrder;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/**
|
||||
* CancelDeliveryOrderLogic constructor.
|
||||
* @param CancelsOrder $cancelsOrder
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
*/
|
||||
public function __construct(CancelsOrder $cancelsOrder, FetchesOrder $fetchesOrder)
|
||||
{
|
||||
$this->cancelsOrder = $cancelsOrder;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
/** @var Order $order */
|
||||
$order = $this->fetchesOrder->execute(['id' => $request->route('id')]);
|
||||
|
||||
return $this->resourceResponse(new DeliveryOrderResource($this->cancelsOrder->execute($order)));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Delivery\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\General\Services\GeneratesInitials;
|
||||
use App\Classes\Modules\Accounts\Processors\AuthenticationProcessor;
|
||||
use App\Classes\Modules\Accounts\Processors\CreateUserProcessor;
|
||||
use App\Classes\Modules\Accounts\Processors\GenerateEmailVerificationAttemptProcessor;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyConnectionObject;
|
||||
use App\Classes\Modules\Companies\Processors\AssignEmployeeProcessor;
|
||||
use App\Classes\Modules\Companies\Processors\CreateCompanyProcessor;
|
||||
use App\Classes\Modules\Companies\Processors\CreateCompanyModuleProcessor;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
||||
use App\Classes\Modules\Companies\Services\ApprovesCompanyConnection;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompanyConnection;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\Modules\Documents\Processors\UploadIdentityDocumentProcessor;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use App\Classes\ValueObjects\Constants\CompanyType;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\User;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreateDeliveryCustomerLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created User',
|
||||
'message' => 'You have successfully created a new User'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CreateUserProcessor */
|
||||
private $createUserProcessor;
|
||||
|
||||
/** @var CreateCompanyProcessor */
|
||||
private $createCompanyProcessor;
|
||||
|
||||
/** @var CreateCompanyModuleProcessor */
|
||||
private $createCompanyModuleProcessor;
|
||||
|
||||
/** @var CreateContactProcessor */
|
||||
private $createContactProcessor;
|
||||
|
||||
/** @var CreatesCompanyConnection */
|
||||
private $createsCompanyConnection;
|
||||
|
||||
/** @var ApprovesCompanyConnection */
|
||||
private $approvesCompanyConnection;
|
||||
|
||||
/** @var AssignEmployeeProcessor */
|
||||
private $assignEmployeeProcessor;
|
||||
|
||||
/** @var UploadIdentityDocumentProcessor */
|
||||
private $uploadIdentityDocumentProcessor;
|
||||
|
||||
/** @var AuthenticationProcessor */
|
||||
private $authenticationProcessor;
|
||||
|
||||
/** @var GenerateEmailVerificationAttemptProcessor */
|
||||
private $generateEmailVerificationAttemptProcessor;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/**
|
||||
* CreateDeliveryCustomerLogic constructor.
|
||||
* @param CreateUserProcessor $createUserProcessor
|
||||
* @param CreateCompanyProcessor $createCompanyProcessor
|
||||
* @param CreateCompanyModuleProcessor $createCompanyModuleProcessor
|
||||
* @param CreateContactProcessor $createContactProcessor
|
||||
* @param CreatesCompanyConnection $createsCompanyConnection
|
||||
* @param ApprovesCompanyConnection $approvesCompanyConnection
|
||||
* @param AssignEmployeeProcessor $assignEmployeeProcessor
|
||||
* @param UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor
|
||||
* @param AuthenticationProcessor $authenticationProcessor
|
||||
* @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
*/
|
||||
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, AssignEmployeeProcessor $assignEmployeeProcessor, UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor, FetchesCompanyModule $fetchesCompanyModule)
|
||||
{
|
||||
$this->createUserProcessor = $createUserProcessor;
|
||||
$this->createCompanyProcessor = $createCompanyProcessor;
|
||||
$this->createCompanyModuleProcessor = $createCompanyModuleProcessor;
|
||||
$this->createContactProcessor = $createContactProcessor;
|
||||
$this->createsCompanyConnection = $createsCompanyConnection;
|
||||
$this->approvesCompanyConnection = $approvesCompanyConnection;
|
||||
$this->assignEmployeeProcessor = $assignEmployeeProcessor;
|
||||
$this->uploadIdentityDocumentProcessor = $uploadIdentityDocumentProcessor;
|
||||
$this->authenticationProcessor = $authenticationProcessor;
|
||||
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\AccessUnauthorisedException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = $this->createUserProcessor->execute($request, RoleTypes::USER, !App::environment(['production']) ? ApprovalStatus::APPROVED : ApprovalStatus::PENDING_VERIFICATION);
|
||||
|
||||
/** @var Company $company */
|
||||
$company = $this->createCompanyProcessor->execute($request->input('name'), CompanyType::PERSONAL_BUSINESS, ApprovalStatus::PENDING_SUBMISSION);
|
||||
|
||||
$contactObject = new ContactObject($request->input('name'), $request->input('phone'), $request->input('contact_email'), $request->input('wechat_id'));
|
||||
|
||||
$this->createContactProcessor->execute($contactObject, $company);
|
||||
|
||||
/** @var CompanyModule $companyModule */
|
||||
$companyModule = $this->createCompanyModuleProcessor->execute($company, BusinessType::ONLINE_SELLER);
|
||||
|
||||
$inviter = $this->fetchesCompanyModule->execute(['reference'=>'HWT']);
|
||||
|
||||
$connectionObject = new CompanyConnectionObject($companyModule, $inviter, mt_rand(1000, 9999).(new GeneratesInitials())->name($company->name)->length(3)->generate(), 'HWT');
|
||||
|
||||
$connection = $this->createsCompanyConnection->execute($connectionObject);
|
||||
|
||||
$this->approvesCompanyConnection->execute($connection);
|
||||
|
||||
$Object = new EmploymentObject($companyModule, $user);
|
||||
|
||||
$this->assignEmployeeProcessor->execute($Object);
|
||||
|
||||
return $this->response($this->authenticationProcessor->execute($request));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Delivery\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\Modules\Orders\DataTransferObjects\OrderObject;
|
||||
use App\Classes\Modules\Orders\Services\CreatesOrder;
|
||||
use App\Classes\Modules\Orders\Services\GeneratesOrderNumber;
|
||||
use App\Classes\Modules\Orders\Standards\Rules\CanCreateOrder;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\PackingLists\Services\CreatesPackingList;
|
||||
use App\Classes\Modules\PackingLists\Services\Packages\CreatesPackage;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use App\Classes\ValueObjects\Constants\OrderType;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Http\Resources\DeliveryOrderResource;
|
||||
use App\Models\Address;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateDeliveryOrderLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created Order',
|
||||
'message' => 'You have successfully created a new Order'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var fetchesAddress */
|
||||
private $fetchesAddress;
|
||||
|
||||
/** @var CanCreateOrder */
|
||||
private $canCreateOrder;
|
||||
|
||||
/** @var CreatesOrder */
|
||||
private $createsOrder;
|
||||
|
||||
/** @var CreatesAddress */
|
||||
private $createAddress;
|
||||
|
||||
/** @var CreateContactProcessor */
|
||||
private $createContactProcessor;
|
||||
|
||||
/** @var CreateRemarkProcessor */
|
||||
private $createRemarkProcessor;
|
||||
|
||||
/** @var GeneratesOrderNumber */
|
||||
private $generatesOrderNumber;
|
||||
|
||||
/** @var CreatesPackingList */
|
||||
private $createsPackingList;
|
||||
|
||||
/** @var CreatesPackage */
|
||||
private $createsPackage;
|
||||
|
||||
|
||||
/**
|
||||
* CreateDeliveryOrderLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
* @param CanCreateOrder $canCreateOrder
|
||||
* @param CreatesOrder $createsOrder
|
||||
* @param CreatesAddress $createAddress
|
||||
* @param CreateContactProcessor $createContactProcessor
|
||||
* @param CreateRemarkProcessor $createRemarkProcessor
|
||||
* @param GeneratesOrderNumber $generatesOrderNumber
|
||||
* @param CreatesPackingList $createsPackingList
|
||||
* @param CreatesPackage $createPackage
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CanCreateOrder $canCreateOrder, CreatesOrder $createsOrder, CreatesAddress $createAddress, CreateContactProcessor $createContactProcessor, CreateRemarkProcessor $createRemarkProcessor, GeneratesOrderNumber $generatesOrderNumber, CreatesPackingList $createsPackingList, CreatesPackage $createsPackage)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
$this->canCreateOrder = $canCreateOrder;
|
||||
$this->createsOrder = $createsOrder;
|
||||
$this->createAddress = $createAddress;
|
||||
$this->createContactProcessor = $createContactProcessor;
|
||||
$this->createRemarkProcessor = $createRemarkProcessor;
|
||||
$this->generatesOrderNumber = $generatesOrderNumber;
|
||||
$this->createsPackingList = $createsPackingList;
|
||||
$this->createsPackage = $createsPackage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
|
||||
$senderAddress = $this->fetchesAddress->execute(['id' => $request->input('sender_address_id')]);
|
||||
$deliveryAddress = $this->fetchesAddress->execute(['id' => $request->input('delivery_address_id')]);
|
||||
|
||||
/** @var CompanyModule $companyModule */
|
||||
$companyModule = $company->companyModules()->where('type', BusinessType::ONLINE_SELLER)->first();
|
||||
|
||||
$orderObject = new OrderObject($this->generatesOrderNumber->execute('168M', 7), OrderType::LAST_MILE_DELIVERY, ApprovalStatus::APPROVED);
|
||||
|
||||
$this->canCreateOrder->passes($orderObject);
|
||||
|
||||
/** @var Order $order */
|
||||
$order = $this->createsOrder->execute($companyModule, $orderObject);
|
||||
|
||||
$senderAddressObject = new AddressObject($senderAddress->street_one, $senderAddress->street_two, $senderAddress->country_id, $senderAddress->state_id, $senderAddress->district_id, $senderAddress->postcode, $senderAddress->type, ApprovalStatus::APPROVED, $senderAddress->reference);
|
||||
$deliveryAddressObject = new AddressObject($deliveryAddress->street_one, $deliveryAddress->street_two, $deliveryAddress->country_id, $deliveryAddress->state_id, $deliveryAddress->district_id, $deliveryAddress->postcode, $deliveryAddress->type, ApprovalStatus::APPROVED, $deliveryAddress->reference);
|
||||
|
||||
/** @var Address $orderSenderAddress */
|
||||
$orderSenderAddress = $this->createAddress->execute($order, $senderAddressObject);
|
||||
/** @var Address $orderDeliveryAddress */
|
||||
$orderDeliveryAddress = $this->createAddress->execute($order, $deliveryAddressObject);
|
||||
|
||||
$senderContact = $senderAddress->contacts()->first();
|
||||
$deliveryContact = $deliveryAddress->contacts()->first();
|
||||
|
||||
$contactObject = new ContactObject($senderContact->reference, $senderContact->phone, '','');
|
||||
$this->createContactProcessor->execute($contactObject, $orderSenderAddress);
|
||||
|
||||
$contactObject = new ContactObject($deliveryContact->reference, $deliveryContact->phone, '','');
|
||||
$this->createContactProcessor->execute($contactObject, $orderDeliveryAddress);
|
||||
|
||||
$senderRemark = $senderAddress->remarks()->first();
|
||||
$deliveryRemark = $deliveryAddress->remarks()->first();
|
||||
|
||||
if ($senderRemark){
|
||||
$remarkObject = new RemarkObject($senderRemark->content, Auth()->user()->id);
|
||||
|
||||
if($remarkObject->getContent()){
|
||||
$this->createRemarkProcessor->execute($orderSenderAddress, $remarkObject);
|
||||
}
|
||||
}
|
||||
|
||||
if ($deliveryRemark){
|
||||
$remarkObject = new RemarkObject($deliveryRemark->content, Auth()->user()->id);
|
||||
|
||||
if($remarkObject->getContent()){
|
||||
$this->createRemarkProcessor->execute($orderDeliveryAddress, $remarkObject);
|
||||
}
|
||||
}
|
||||
|
||||
$packingListObject = new PackingListObject($order->reference, $companyModule->id, PackingListType::DELIVERY_PACKING_LIST, ApprovalStatus::PENDING_VERIFICATION);
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
$packingList = $this->createsPackingList->execute($packingListObject, $order);
|
||||
|
||||
$packageObject = new PackageObject($request->input('packing_list.type'), $request->input('packing_list.description'), (float) 1, (float) 1, (float) 1, $request->input('packing_list.weight'), (float) $request->input('packing_list.quantity'), ApprovalStatus::APPROVED);
|
||||
$this->createsPackage->execute($packageObject, $packingList);
|
||||
|
||||
return $this->resourceResponse(new DeliveryOrderResource($order));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Delivery\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Services\ListsOrders;
|
||||
use App\Classes\Modules\Orders\Standards\Rules\CanListOrders;
|
||||
use App\Classes\ValueObjects\Constants\OrderType;
|
||||
use App\Http\Resources\DeliveryOrderResource;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListOrdersLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Orders',
|
||||
'message' => 'You have successfully retrieved a list of Orders'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanListOrders */
|
||||
private $canListOrders;
|
||||
|
||||
/** @var ListsOrders */
|
||||
private $listsOrders;
|
||||
|
||||
/**
|
||||
* ListOrdersLogic constructor.
|
||||
* @param CanListOrders $canListOrders
|
||||
* @param ListsOrders $listsOrders
|
||||
*/
|
||||
public function __construct(CanListOrders $canListOrders, ListsOrders $listsOrders)
|
||||
{
|
||||
$this->canListOrders = $canListOrders;
|
||||
$this->listsOrders = $listsOrders;
|
||||
}
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canListOrders->passes();
|
||||
|
||||
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true, 'type_in' => [OrderType::LAST_MILE_DELIVERY]]));
|
||||
|
||||
return $this->collectionResponse(DeliveryOrderResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -54,7 +54,7 @@ class ListDocumentLogic extends AbstractControllerLogic
|
||||
|
||||
$this->canListDocuments->passes();
|
||||
|
||||
$query = $this->listsDocuments->execute($this->listsDocuments->deserializeFilters($request->input('filters')));
|
||||
$query = $this->listsDocuments->execute(array_merge($this->listsDocuments->deserializeFilters($request->input('filters')), ['with_owner' => true]));
|
||||
|
||||
return $this->collectionResponse(DocumentResource::collection($query));
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\ControllersLogic;
|
||||
|
||||
use App\Classes\Modules\Documents\Standards\Rules\CanUpdateDocumentReference;
|
||||
use App\Http\Resources\DocumentResource;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Documents\Services\FetchesDocument;
|
||||
use App\Classes\Modules\Documents\Services\UpdatesDocumentReference;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateDocumentReferenceLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Update Document Reference',
|
||||
'message' => 'You have successfully updated the Document Reference'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateDocumentReference*/
|
||||
private $canUpdateDocumentReference;
|
||||
|
||||
/** @var UpdatesDocumentReference */
|
||||
private $updatesDocumentReference;
|
||||
|
||||
/** @var FetchesDocument */
|
||||
private $fetchesDocument;
|
||||
|
||||
|
||||
/**
|
||||
* RejectDocumentLogic constructor.
|
||||
* @param CanApproveDocument $canApproveDocument
|
||||
* @param ApprovesDocument $approvesDocument
|
||||
* @param FetchesDocument $fetchesDocument
|
||||
*/
|
||||
public function __construct(CanUpdateDocumentReference $canUpdateDocumentReference, UpdatesDocumentReference $updatesDocumentReference, FetchesDocument $fetchesDocument)
|
||||
{
|
||||
$this->canUpdateDocumentReference = $canUpdateDocumentReference;
|
||||
$this->updatesDocumentReference = $updatesDocumentReference;
|
||||
$this->fetchesDocument = $fetchesDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$document = $this->fetchesDocument->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->canUpdateDocumentReference->passes();
|
||||
|
||||
$document_query = $this->updatesDocumentReference->execute($document, $request->input('identification_number'));
|
||||
|
||||
return $this->resourceResponse(new DocumentResource($document_query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\Document;
|
||||
|
||||
class UpdatesDocumentReference extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Document $model
|
||||
* @return mixed
|
||||
*/
|
||||
public function execute(Document $model, string $reference) {
|
||||
$model->reference = $reference;
|
||||
return $this->handler($model);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
|
||||
class CanUpdateDocumentReference extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DocumentObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DocumentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\PackingList;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Carbon\Carbon;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
|
||||
class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, FromCollection
|
||||
{
|
||||
|
||||
use Exportable;
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'ORDER NUMBER',
|
||||
'Marking',
|
||||
'Warehouse',
|
||||
'Cbm',
|
||||
'Description',
|
||||
'quantity',
|
||||
'Received Date',
|
||||
'Remarks'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$returnArray = collect();
|
||||
|
||||
$packingLists = PackingList::where('type', '=', 1)->where('status', '=', 2)->get();
|
||||
$exceptionUsers = in_array(Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]);
|
||||
|
||||
foreach($packingLists as $packingList){
|
||||
$packages = !$packingList->packingLists()->exists() || $exceptionUsers ? $packingList->packages : $packingList->packingLists->first()->packages;
|
||||
foreach ($packages as $package) {
|
||||
$returnArray->push($package);
|
||||
}
|
||||
}
|
||||
|
||||
return $returnArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ReturnArray $returnArray
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function map($package): array
|
||||
{
|
||||
$packingList = $package->packingList;
|
||||
$order = $packingList->owner;
|
||||
|
||||
$connection = $order->companyModule()->first()->inviters()->withPivot('invitee_reference')->first();
|
||||
$marking = $connection ? $connection->pivot->invitee_reference:'';
|
||||
|
||||
$warehouse = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee;
|
||||
|
||||
$cbm = (($package->width / 100) * ($package->height / 100) * ($package->length / 100)) * $package->quantity;
|
||||
|
||||
$arrival_date = $packingList->transports()->first()->drop_date->format('d-m-Y');
|
||||
|
||||
return [
|
||||
$packingList->owner->reference,
|
||||
$marking,
|
||||
$warehouse->reference,
|
||||
$cbm,
|
||||
$package->description,
|
||||
$package->quantity,
|
||||
$arrival_date,
|
||||
''
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Container;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ExportsContainerPackingList implements FromQuery, WithHeadingRow, WithMapping
|
||||
{
|
||||
use Exportable;
|
||||
|
||||
protected $id;
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Marking',
|
||||
'Refrence',
|
||||
'Quantity',
|
||||
'CBM',
|
||||
'Status',
|
||||
'Delivery Phone',
|
||||
'Delivery Refrence',
|
||||
'Delivery Address',
|
||||
'Remark',
|
||||
'Delivery Date'
|
||||
];
|
||||
}
|
||||
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
return Container::find($this->id)->packingLists();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Company $container
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function map($packing_list): array
|
||||
{
|
||||
$order = $packing_list->owner()->first();
|
||||
$address = $order->addresses()->first();
|
||||
$company = $order->companyModule()->first();
|
||||
$connection = $company->inviters()->withPivot('invitee_reference')->first();
|
||||
$marking = $connection ? $connection->pivot->invitee_reference:'';
|
||||
|
||||
$quantity = 0;
|
||||
$cbm = 0;
|
||||
foreach ($packing_list->packages()->get() as $key => $row) {
|
||||
$quantity += $row->quantity;
|
||||
$cbm += (($row->width / 100) * ($row->height / 100) * ($row->length / 100)) * $row->quantity;
|
||||
}
|
||||
|
||||
$status = '';
|
||||
if ($packing_list->transports()->count() > 0) {
|
||||
$status = 'Delivery';
|
||||
}
|
||||
elseif ($packing_list->status == ApprovalStatus::SUSPENDED) {
|
||||
$status = 'On Hold';
|
||||
}
|
||||
elseif ($packing_list->status != ApprovalStatus::SUSPENDED) {
|
||||
$status = 'Release';
|
||||
}
|
||||
|
||||
return [
|
||||
$marking,
|
||||
$order->reference,
|
||||
$quantity,
|
||||
$cbm,
|
||||
$status,
|
||||
$address->contacts()->first() ? $address->contacts()->first()->phone : 'n/a',
|
||||
$address->contacts()->first() ? $address->contacts()->first()->reference : 'n/a',
|
||||
$address->street_one . ' ' . $address->street_two . ' ' . $address->district->name . ' ' . $address->post_code . ' ' . $address->state->name . ' ' . $address->country->name,
|
||||
$address->remarks()->first() ? $address->remarks()->first()->content : 'n/a',
|
||||
$packing_list->transports()->first() ? $packing_list->transports()->current_schedule->eta : 'n/a'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\CompanyModule;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
|
||||
class ExportsCustomersOrderLatestDate implements FromQuery, WithHeadingRow, WithMapping
|
||||
{
|
||||
|
||||
use Exportable;
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Marking',
|
||||
'Name',
|
||||
'Email',
|
||||
'Latest Order'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
return CompanyModule::where('type', '=', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Company $company
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function map($company): array
|
||||
{
|
||||
$connection = $company->inviters()->withPivot('invitee_reference')->first();
|
||||
$marking = $connection ? $connection->pivot->invitee_reference:'';
|
||||
|
||||
$employees = $company->employees()->first();
|
||||
|
||||
$order = $company->orders()
|
||||
->join('packing_lists', 'packing_lists.owner_id', '=', 'orders.id')
|
||||
->join('transport_arrangements', 'transport_arrangements.owner_id', '=', 'packing_lists.id')
|
||||
->orderBy('drop_date', 'desc')
|
||||
->first();
|
||||
|
||||
return [
|
||||
$marking,
|
||||
$employees ? $employees->name : '',
|
||||
$employees ? $employees->email : '',
|
||||
$order ? $order->drop_date : ''
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\AddressType;
|
||||
use App\Classes\ValueObjects\Constants\OrderType;
|
||||
use App\Classes\ValueObjects\Constants\PackageType;
|
||||
use App\Models\Order;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
|
||||
class ExportsDeliveryOrders implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, WithTitle
|
||||
{
|
||||
use Exportable;
|
||||
|
||||
private $request;
|
||||
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Types_Of_Services',
|
||||
'Service_Type',
|
||||
'Sender_Name',
|
||||
'Sender_Company_Name',
|
||||
'Sender_Building_Unit',
|
||||
'Sender_Address',
|
||||
'Sender_Address_2',
|
||||
'Sender_Postal_Code',
|
||||
'Sender_Phone_Number',
|
||||
'Delivery_Name',
|
||||
'Delivery Company Name',
|
||||
'Delivery_Building_Unit',
|
||||
'Delivery_Address',
|
||||
'Delivery_Address_2',
|
||||
'Delivery_Postal_Code',
|
||||
'Delivery_Phone_Number',
|
||||
'Shipment_Type',
|
||||
'Mode',
|
||||
'Pickup_Address_Type',
|
||||
'Reference_Number',
|
||||
'Quantity',
|
||||
'Weight',
|
||||
'Length',
|
||||
'Width',
|
||||
'Height',
|
||||
'COD_Amount',
|
||||
'DO_Numbers'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
$selectedIds = array_map(function($value){
|
||||
return ['id' => $value];
|
||||
}, json_decode($this->request->input('ids')));
|
||||
|
||||
return Order::where('type', OrderType::LAST_MILE_DELIVERY)->whereIn('id', $selectedIds);
|
||||
}
|
||||
|
||||
public function title(): string
|
||||
{
|
||||
return 'bulk-shipment';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function map($order): array
|
||||
{
|
||||
$senderAddress = $order->addresses()->where('type', AddressType::PICK_UP)->first();
|
||||
$deliveryAddress = $order->addresses()->where('type', AddressType::DELIVERY)->first();
|
||||
$package = $order->packingLists()->first()->packages()->first();
|
||||
|
||||
return [
|
||||
'Domestic Shipment',
|
||||
'ST00000020',
|
||||
$senderAddress->contacts()->first()->reference,
|
||||
$senderAddress->reference ? $senderAddress->reference : $order->companyModule->name,
|
||||
$senderAddress->street_one,
|
||||
$senderAddress->street_two.' '.$senderAddress->district->name.' '.$senderAddress->postcode.' '.$senderAddress->state->name.' '.$senderAddress->country->name,
|
||||
'',
|
||||
$senderAddress->postcode,
|
||||
$senderAddress->contacts()->first()->phone,
|
||||
$deliveryAddress->contacts()->first()->reference,
|
||||
$deliveryAddress->reference,
|
||||
$deliveryAddress->street_one,
|
||||
$deliveryAddress->street_two.' '.$deliveryAddress->district->name.' '.$deliveryAddress->postcode.' '.$deliveryAddress->state->name.' '.$deliveryAddress->country->name,
|
||||
'',
|
||||
$deliveryAddress->postcode,
|
||||
$deliveryAddress->contacts()->first()->phone,
|
||||
$package->type === PackageType::CARTON ? 'Package' : ($package->type === PackageType::PALLET ? 'Pallet' : 'Documents'),
|
||||
'Pick Up',
|
||||
'Default',
|
||||
$order->reference,
|
||||
$package->quantity,
|
||||
$package->weight * $package->quantity,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
'',
|
||||
''
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
||||
|
||||
class ExportsDeliveryValidValues implements WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, WithTitle, FromCollection
|
||||
{
|
||||
use Exportable;
|
||||
|
||||
private $request;
|
||||
|
||||
/**
|
||||
* ExportsDeliveryValidValues constructor.
|
||||
* @param Request $request
|
||||
*/
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Types_Of_Services',
|
||||
'Service_Type',
|
||||
'Mode',
|
||||
'Flag',
|
||||
'Pickup Address'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$returnArray = collect();
|
||||
|
||||
$returnArray->push(['Domestic Shipment', 'Package', 'Pick Up', 'Yes', 'Default']);
|
||||
$returnArray->push(['', 'Documents', 'Lodge In / Walk In', 'No', 'Sender']);
|
||||
$returnArray->push(['', 'Pallet', '', '', '']);
|
||||
|
||||
return $returnArray;
|
||||
}
|
||||
|
||||
public function title(): string
|
||||
{
|
||||
return 'valid-values';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ReturnArray $returnArray
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function map($returnArray): array
|
||||
{
|
||||
return [
|
||||
$returnArray[0],
|
||||
$returnArray[1],
|
||||
$returnArray[2],
|
||||
$returnArray[3],
|
||||
$returnArray[4],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\Modules\Exports\Services\ExportsDeliveryOrders;
|
||||
use App\Classes\Modules\Exports\Services\ExportsDeliveryValidValues;
|
||||
use App\Models\Order;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
|
||||
class ExportsMultipleDeliveryOrders implements WithMultipleSheets
|
||||
{
|
||||
use Exportable;
|
||||
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* ExportsMultipleDeliveryOrders constructor.
|
||||
* @param Request $request
|
||||
*/
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function sheets(): array
|
||||
{
|
||||
$sheets = [];
|
||||
$sheets[] = new ExportsDeliveryOrders($this->request);
|
||||
$sheets[] = new ExportsDeliveryValidValues($this->request);
|
||||
|
||||
return $sheets;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\PackingList;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ExportsOnHoldPackingList implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
||||
{
|
||||
|
||||
use Exportable;
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Container Ref.',
|
||||
'ETA',
|
||||
'Unstuffing',
|
||||
'Marking',
|
||||
'Order Number'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
return PackingList::where('type', '=', 2)->whereIn('status', [4, 5])->whereHas('containers');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PackingList $packingList
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function map($packingList): array
|
||||
{
|
||||
$container = $packingList->containers()->first();
|
||||
$ContainerTransport = $container->transports()->first();
|
||||
$order = $packingList->owner;
|
||||
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||
|
||||
return [
|
||||
$container->reference,
|
||||
$ContainerTransport ? $ContainerTransport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->eta : 'n/a',
|
||||
$ContainerTransport ? $ContainerTransport->drop_date : 'n/a',
|
||||
$marking,
|
||||
$order->reference,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\PackingList;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ExportsPendingArrangementDeliveryList implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
||||
{
|
||||
|
||||
use Exportable;
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Container Ref.',
|
||||
'ETA',
|
||||
'Unstuffing',
|
||||
'Marking',
|
||||
'Order Number',
|
||||
'status',
|
||||
'Delay Days / delivery date',
|
||||
'Quantity',
|
||||
'State',
|
||||
'Postcode',
|
||||
'Address',
|
||||
'PIC',
|
||||
'Phone',
|
||||
'Remark'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
return PackingList::where('type', '=', 2)->whereHas('containers', function ($query){
|
||||
$query->where('containers.status', ApprovalStatus::COMPLETED);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PackingList $packingList
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function map($packingList): array
|
||||
{
|
||||
$container = $packingList->containers()->first();
|
||||
$ContainerTransport = $container->transports()->first();
|
||||
$order = $packingList->owner;
|
||||
$marking = $order->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||
$address = $order->addresses()->where('status', ApprovalStatus::APPROVED)->first();
|
||||
$contacts = $address->contacts->first() ? $address->contacts->first(): '';
|
||||
$originalPackingList = $packingList->owner instanceof PackingList ? $packingList->owner : $packingList;
|
||||
$transport = $originalPackingList->containers()->first()->transports()->first();
|
||||
$deliveryTransport = $originalPackingList->transports()->first();
|
||||
|
||||
return [
|
||||
$container->reference,
|
||||
$ContainerTransport->schedules()->where('status', '=', ApprovalStatus::APPROVED)->first()->eta,
|
||||
$ContainerTransport->drop_date,
|
||||
$marking,
|
||||
$order->reference,
|
||||
$deliveryTransport ? (Carbon::parse($deliveryTransport->schedules()->first()->eta) < Carbon::now() ? 'Delivered' : 'Pending Delivery') : 'Pending Arrangement',
|
||||
$deliveryTransport ? $deliveryTransport->schedules()->first()->eta : ($transport ? Carbon::now()->diffInDays($transport->drop_date, false) . ' Days' : ''),
|
||||
$packingList->packages()->sum('quantity'),
|
||||
$address->state->name,
|
||||
$address->postcode,
|
||||
$address->street_one.', '.$address->street_two.' '.$address->district->name.' '.$address->postcode.' '.$address->state->name.' '.$address->country->name,
|
||||
$address->remarks->first() ? $address->remarks->first()->content: '',
|
||||
$contacts ? $contacts ->reference : '',
|
||||
$contacts ? $contacts ->phone : '',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Notifications\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\Notifiable;
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
class NotificationObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private $title;
|
||||
|
||||
/** @var string */
|
||||
private $description;
|
||||
|
||||
/** @var Notifiable */
|
||||
private $subject;
|
||||
|
||||
/** @var Notifiable */
|
||||
private $target;
|
||||
|
||||
/** @var Notifiable */
|
||||
private $causer;
|
||||
|
||||
/** @var int|null */
|
||||
private $status;
|
||||
|
||||
/**
|
||||
* OrderObject constructor.
|
||||
* @param string $reference
|
||||
* @param int $type
|
||||
* @param int|null $status
|
||||
*/
|
||||
public function __construct(
|
||||
string $title,
|
||||
string $description,
|
||||
Notifiable $subject,
|
||||
Notifiable $target,
|
||||
Notifiable $causer,
|
||||
?int $status = ApprovalStatus::PENDING_VERIFICATION
|
||||
)
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->description = $description;
|
||||
$this->subject = $subject;
|
||||
$this->target = $target;
|
||||
$this->causer = $causer;
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Notifiable
|
||||
*/
|
||||
public function getSubject(): Notifiable
|
||||
{
|
||||
return $this->subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Notifiable
|
||||
*/
|
||||
public function getTarget(): Notifiable
|
||||
{
|
||||
return $this->target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Notifiable
|
||||
*/
|
||||
public function getCauser(): Notifiable
|
||||
{
|
||||
return $this->causer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStatus(): int
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Notifications\Processors;
|
||||
|
||||
use App\Classes\Modules\Notifications\DataTransferObjects\NotificationObject;
|
||||
use App\Classes\Modules\Notifications\Services\CreatesNotification;
|
||||
|
||||
class CreateNotificationProcessor
|
||||
{
|
||||
/** @var CreatesNotification */
|
||||
private $createsNotification;
|
||||
|
||||
/**
|
||||
* CreateNotificationProcessor constructor.
|
||||
* @param CreatesNotification $createsNotification
|
||||
*/
|
||||
public function __construct(CreatesNotification $createsNotification)
|
||||
{
|
||||
$this->createsNotification = $createsNotification;
|
||||
}
|
||||
|
||||
public function execute(NotificationObject $object)
|
||||
{
|
||||
$notification = $this->createsNotification->execute($object);
|
||||
return $notification;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Notifications\Services;
|
||||
|
||||
use App\Classes\Modules\Notifications\DataTransferObjects\NotificationObject;
|
||||
use App\Models\Notification;
|
||||
|
||||
class CreatesNotification
|
||||
{
|
||||
/**
|
||||
* @param NotificationObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(NotificationObject $object) {
|
||||
$model = new Notification();
|
||||
$model->title = $object->getTitle();
|
||||
$model->description = $object->getDescription();
|
||||
$model->status = $object->getStatus();
|
||||
$model->subject_type = get_class($object->getSubject());
|
||||
$model->subject_id = $object->getSubject()->id;
|
||||
$model->target_type = get_class($object->getTarget());
|
||||
$model->target_id = $object->getTarget()->id;
|
||||
$model->causer_type = get_class($object->getCauser());
|
||||
$model->causer_id = $object->getCauser()->id;
|
||||
$model->save();
|
||||
|
||||
return $model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Services\CreatesOrderRemark;
|
||||
use App\Classes\Modules\Remarks\Standards\Rules\CanCreateRemark;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Http\Resources\RemarkResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AssignOrderRemarkLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Order Remark',
|
||||
'message' => 'You have successfully created a new Order Remark'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateRemark */
|
||||
private $canCreateRemark;
|
||||
|
||||
/** @var CreatesOrderRemark */
|
||||
private $createsOrderRemark;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/**
|
||||
* CreateRemarkLogic constructor.
|
||||
* @param CanCreateRemark $canCreateRemark
|
||||
* @param CreatesOrderRemark $createsOrderRemark
|
||||
*/
|
||||
public function __construct(CanCreateRemark $canCreateRemark, CreatesOrderRemark $createsOrderRemark, FetchesOrder $fetchesOrder)
|
||||
{
|
||||
$this->canCreateRemark = $canCreateRemark;
|
||||
$this->createsOrderRemark = $createsOrderRemark;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new RemarkObject(
|
||||
$request->input('content'),
|
||||
$request->route('id')
|
||||
);
|
||||
|
||||
$this->canCreateRemark->passes($object);
|
||||
$query = $this->createsOrderRemark->execute($this->fetchesOrder->execute(['id' => $request->route('id')]), $object);
|
||||
return $this->resourceResponse( new RemarkResource($query));
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,14 @@
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Orders\Processors\CreateOrderProcessor;
|
||||
use App\Classes\Modules\Orders\Services\GeneratesOrderNumber;
|
||||
use App\Classes\ValueObjects\Constants\WarehouseReferences;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -57,12 +59,21 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
|
||||
public function logic(Request $request) : JsonResponse {
|
||||
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->input('address_id')]);
|
||||
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $request->input('warehouse_id')]);
|
||||
|
||||
if(!in_array($company->companyModules()->importers()->first()->id, WarehouseReferences::YD_EXEMPT_LIST)){
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['reference' => $originWarehouse->reference === WarehouseReferences::VT_GUANG_ZHOU ? WarehouseReferences::YD_GUANG_ZHOU_2 : WarehouseReferences::YD_YIWU]);
|
||||
}
|
||||
|
||||
if($originWarehouse->reference === WarehouseReferences::YD_YIWU && in_array($address->state_id, [5, 13, 14])) {
|
||||
throw new RequestValidationException('Our Yiwu warehouse is unable to ship goods to Sabah & Sarawak at the moment. you can select our Guangzhou warehouse as an alternative.');
|
||||
}
|
||||
|
||||
$order = $this->createOrderProcessor->execute($company, $originWarehouse, $address, $this->generatesOrderNumber->execute());
|
||||
|
||||
return $this->resourceResponse(new OrderResource($order));
|
||||
|
||||
@@ -19,6 +19,7 @@ use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use App\Models\PackingList;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
@@ -80,6 +81,9 @@ class CreateShippingPackingListLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
@@ -93,6 +97,8 @@ class CreateShippingPackingListLogic extends AbstractControllerLogic
|
||||
PackingListType::SHIPPING_PACKING_LIST,
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
|
||||
$packages = $request->input('packages');
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Services\ListsOrders;
|
||||
use App\Classes\Modules\Orders\Standards\Rules\CanListOrders;
|
||||
use App\Classes\ValueObjects\Constants\OrderType;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -44,7 +45,7 @@ class ListOrdersLogic extends AbstractControllerLogic
|
||||
{
|
||||
$this->canListOrders->passes();
|
||||
|
||||
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true]));
|
||||
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true, 'type_in' => [OrderType::SHARED_CONTAINER, OrderType::DEDICATED_CONTAINER]]));
|
||||
|
||||
return $this->collectionResponse(OrderResource::collection($query));
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Services\CalculatesCBM;
|
||||
use App\Classes\Modules\Orders\Services\CalculatesBaseRate;
|
||||
use App\Classes\Modules\Orders\Services\CalculatesSegmentRate;
|
||||
use App\Classes\Modules\Orders\Services\CalculatesStateRate;
|
||||
use App\Classes\Modules\Orders\Services\CalculatesWarehouseRate;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Classes\Modules\Transactions\Processors\CreateShippingCostTransactionProcessor;
|
||||
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ShippingCostLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Order Shipping Cost',
|
||||
'message' => 'Order shipping cost calculation done'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CalculateCBM */
|
||||
private $calculateCBM;
|
||||
|
||||
/** @var CalculatesBaseRate */
|
||||
private $calculateBaseRate;
|
||||
|
||||
/** @var CalculatesSegmentRate */
|
||||
private $calculateSegmentRate;
|
||||
|
||||
/** @var CalculatesStateRate */
|
||||
private $calculateStateRate;
|
||||
|
||||
/** @var CalculatesWarehouse */
|
||||
private $calculateWarehouseRate;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/** @var ShippingCostTransactionProcessor */
|
||||
private $shippingCostTransactionProcessor;
|
||||
|
||||
/**
|
||||
* ShippingCostLogic constructor.
|
||||
* @param CalculateCBM $calculateCBM
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
*/
|
||||
public function __construct(FetchesOrder $fetchesOrder, CalculatesCBM $calculateCBM, CalculatesBaseRate $calculateBaseRate, CalculatesSegmentRate $calculateSegmentRate, CalculatesStateRate $calculateStateRate, CalculatesWarehouseRate $calculateWarehouseRate, CreateShippingCostTransactionProcessor $shippingCostTransactionProcessor)
|
||||
{
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
$this->calculateCBM = $calculateCBM;
|
||||
$this->calculatesBaseRate = $calculateBaseRate;
|
||||
$this->calculatesSegmentRate = $calculateSegmentRate;
|
||||
$this->calculatesStateRate = $calculateStateRate;
|
||||
$this->calculateWarehouseRate = $calculateWarehouseRate;
|
||||
$this->shippingCostTransactionProcessor = $shippingCostTransactionProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$order = $this->fetchesOrder->getRepository()->where(['id' => $request->route('id')])->first();
|
||||
|
||||
$baseRate = $this->calculatesBaseRate->execute($order);
|
||||
$segmentRate = $this->calculatesSegmentRate->execute($order, SegmentConstants::STANDARD_SEGMENT) + $this->calculatesSegmentRate->execute($order, SegmentConstants::CUSTOM_SEGMENT);
|
||||
$stateRate = $this->calculatesStateRate->execute($order, false) + $this->calculatesStateRate->execute($order, true);
|
||||
$warehouseRate = $this->calculateWarehouseRate->execute($order);
|
||||
|
||||
$totalShippingCost = 0;
|
||||
$totalCBM = 0;
|
||||
$quantity = 0;
|
||||
foreach($order->parcels as $parcel){
|
||||
$cbm = $this->calculateCBM->execute($order, $parcel);
|
||||
|
||||
if($cbm > 0){
|
||||
$totalCBM += $cbm;
|
||||
$quantity ++;
|
||||
$totalShippingCost += (($segmentRate + $stateRate + $warehouseRate) * $cbm);
|
||||
}
|
||||
}
|
||||
|
||||
$this->shippingCostTransactionProcessor->execute($order, $quantity, round($totalCBM,2), round($totalShippingCost,2));
|
||||
return $this->resourceResponse(new OrderResource($order));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\ErrorException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\Orders\Services\UpdateOrderReference;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use App\Models\Company;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateOrderLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Update Order',
|
||||
'message' => 'You have successfully update the order'
|
||||
];
|
||||
}
|
||||
|
||||
private $updateOrderReference;
|
||||
private $fetchesOrder;
|
||||
|
||||
public function __construct(UpdateOrderReference $updateOrderReference, FetchesOrder $fetchesOrder)
|
||||
{
|
||||
$this->updateOrderReference = $updateOrderReference;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
}
|
||||
|
||||
protected function logic(Request $request): JsonResponse
|
||||
{
|
||||
$reference_id = $request->input('reference_id');
|
||||
|
||||
$order = $this->fetchesOrder->execute(['id' => $request->route('id')]);
|
||||
|
||||
$order = $this->updateOrderReference->execute($order, $reference_id);
|
||||
|
||||
return $this->resourceResponse(new OrderResource($order));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
class OrderObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var int */
|
||||
/** @var string */
|
||||
private $reference;
|
||||
|
||||
/** @var int */
|
||||
@@ -20,11 +20,11 @@ class OrderObject implements DataTransferObject
|
||||
|
||||
/**
|
||||
* OrderObject constructor.
|
||||
* @param int $reference
|
||||
* @param string $reference
|
||||
* @param int $type
|
||||
* @param int|null $status
|
||||
*/
|
||||
public function __construct(int $reference, int $type, ?int $status = ApprovalStatus::PENDING_VERIFICATION)
|
||||
public function __construct(string $reference, int $type, ?int $status)
|
||||
{
|
||||
$this->reference = $reference;
|
||||
$this->type = $type;
|
||||
@@ -32,9 +32,9 @@ class OrderObject implements DataTransferObject
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* @return string
|
||||
*/
|
||||
public function getReference(): int
|
||||
public function getReference(): string
|
||||
{
|
||||
return $this->reference;
|
||||
}
|
||||
@@ -48,12 +48,13 @@ class OrderObject implements DataTransferObject
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* @return int|null
|
||||
*/
|
||||
public function getStatus(): int
|
||||
public function getStatus(): ?int
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Orders\Standards\Rules\CanApproveChangeOrderAddress;
|
||||
use App\Classes\Modules\Orders\Services\UpdatesOrdersAddress;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ApproveChangeOrderAddressProcessor
|
||||
@@ -20,17 +21,27 @@ class ApproveChangeOrderAddressProcessor
|
||||
/** @var UpdatesOrdersAddress */
|
||||
private $updatesOrdersAddress;
|
||||
|
||||
/** @var UpdateDoFromVTPortalProcessor */
|
||||
private $updateDoFromVTPortalProcessor;
|
||||
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor ;
|
||||
|
||||
/**
|
||||
* ApproveChangeOrderAddressProcessor constructor.
|
||||
* @param CanApproveChangeOrderAddress $canApproveChangeOrderAddress
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
* @param UpdatesOrdersAddress $updatesOrdersAddress
|
||||
* @param \App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
*/
|
||||
public function __construct(CanApproveChangeOrderAddress $canApproveChangeOrderAddress, FetchesAddress $fetchesAddress, UpdatesOrdersAddress $updatesOrdersAddress)
|
||||
public function __construct(CanApproveChangeOrderAddress $canApproveChangeOrderAddress, FetchesAddress $fetchesAddress, UpdatesOrdersAddress $updatesOrdersAddress, \App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor)
|
||||
{
|
||||
$this->canApproveChangeOrderAddress = $canApproveChangeOrderAddress;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
$this->updatesOrdersAddress = $updatesOrdersAddress;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,12 +49,13 @@ class ApproveChangeOrderAddressProcessor
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\InternalServerErrorException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function execute(Request $request)
|
||||
{
|
||||
|
||||
$status = (int) $request->route('status');
|
||||
|
||||
$this->canApproveChangeOrderAddress->passes();
|
||||
@@ -52,9 +64,17 @@ class ApproveChangeOrderAddressProcessor
|
||||
|
||||
if($status === ApprovalStatus::APPROVED){
|
||||
$address->owner->addresses()->update(['status' => ApprovalStatus::EXPIRED]);
|
||||
|
||||
$appointee = $address->owner->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_FREIGHT_FORWARDER)->first()->appointee->id;
|
||||
if($appointee === 2) {
|
||||
foreach($address->owner->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST) as $packingList){
|
||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->updatesOrdersAddress->execute($address, $status);
|
||||
$address = $this->updatesOrdersAddress->execute($address, $status);
|
||||
|
||||
return $address;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,11 @@ use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Orders\DataTransferObjects\OrderObject;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
|
||||
use App\Classes\Modules\Orders\Services\CreatesOrder;
|
||||
use App\Classes\Modules\Orders\Services\GeneratesOrderNumber;
|
||||
use App\Classes\Modules\Orders\Standards\Rules\CanCreateOrder;
|
||||
@@ -33,6 +38,12 @@ class CreateOrderProcessor
|
||||
/** @var CreateOrderRolesProcessor */
|
||||
private $createOrderRolesProcessor;
|
||||
|
||||
/** @var CreateContactProcessor */
|
||||
private $createContactProcessor;
|
||||
|
||||
/** @var CreateRemarkProcessor */
|
||||
private $createRemarkProcessor;
|
||||
|
||||
/**
|
||||
* CreateOrderProcessor constructor.
|
||||
* @param CanCreateOrder $canCreateOrder
|
||||
@@ -40,12 +51,14 @@ class CreateOrderProcessor
|
||||
* @param CreatesAddress $createAddress
|
||||
* @param CreateOrderRolesProcessor $createOrderRolesProcessor
|
||||
*/
|
||||
public function __construct(CanCreateOrder $canCreateOrder, CreatesOrder $createsOrder, CreatesAddress $createAddress, CreateOrderRolesProcessor $createOrderRolesProcessor)
|
||||
public function __construct(CanCreateOrder $canCreateOrder, CreatesOrder $createsOrder, CreatesAddress $createAddress, CreateOrderRolesProcessor $createOrderRolesProcessor, CreateContactProcessor $createContactProcessor, CreateRemarkProcessor $createRemarkProcessor)
|
||||
{
|
||||
$this->canCreateOrder = $canCreateOrder;
|
||||
$this->createsOrder = $createsOrder;
|
||||
$this->createAddress = $createAddress;
|
||||
$this->createOrderRolesProcessor = $createOrderRolesProcessor;
|
||||
$this->createContactProcessor = $createContactProcessor;
|
||||
$this->createRemarkProcessor = $createRemarkProcessor;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,9 +84,39 @@ class CreateOrderProcessor
|
||||
/** @var Order $order */
|
||||
$order = $this->createsOrder->execute($importer, $orderObject);
|
||||
|
||||
$addressObject = new AddressObject($address->street_one, $address->street_two, $address->country_id, $address->state_id, $address->district_id, $address->postcode,$address->reference);
|
||||
$addressObject = new AddressObject($address->street_one, $address->street_two, $address->country_id, $address->state_id, $address->district_id, $address->postcode, $address->type, ApprovalStatus::APPROVED, $address->reference);
|
||||
|
||||
/** @var Address $order_address */
|
||||
$order_address = $this->createAddress->execute($order, $addressObject);
|
||||
|
||||
$contact = $address->contacts()->first();
|
||||
|
||||
if ($contact) {
|
||||
$contactObject = new ContactObject(
|
||||
$contact->reference,
|
||||
$contact->phone,
|
||||
'',
|
||||
''
|
||||
);
|
||||
|
||||
if($contactObject->getPhone()){
|
||||
$order_remark = $this->createContactProcessor->execute($contactObject, $order_address);
|
||||
}
|
||||
}
|
||||
|
||||
$remark = $address->remarks()->first();
|
||||
|
||||
if ($remark){
|
||||
$remarkObject = new RemarkObject(
|
||||
$remark->content,
|
||||
Auth()->user()->id
|
||||
);
|
||||
|
||||
if($remarkObject->getContent()){
|
||||
$this->createRemarkProcessor->execute($order_address, $remarkObject);
|
||||
}
|
||||
}
|
||||
|
||||
$this->createAddress->execute($order, $addressObject);
|
||||
|
||||
$this->createOrderRolesProcessor->execute($originWarehouse, $order);
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class CreateOrderRolesProcessor
|
||||
$importer = $order->companyModule;
|
||||
|
||||
/** @var CompanyModule $destinationWarehouse */
|
||||
$destinationWarehouse = $this->fetchesCompanyModule->execute(['reference' => WarehouseReferences::DESTINATION_WAREHOUSE[$address->state_id ]]);
|
||||
$destinationWarehouse = $this->fetchesCompanyModule->execute(['reference' => $originWarehouse->reference === WarehouseReferences::YD_GUANG_ZHOU || $originWarehouse->reference === WarehouseReferences::YD_YIWU ? WarehouseReferences::YD_DESTINATION_WAREHOUSE : WarehouseReferences::VT_DESTINATION_WAREHOUSE[$address->state_id]]);
|
||||
|
||||
/** @var CompanyModule $freightForwarder */
|
||||
$freightForwarder = $originWarehouse->company->companyModules()->freightForwarders()->first();
|
||||
@@ -79,33 +79,9 @@ class CreateOrderRolesProcessor
|
||||
$roleObject = new OrderRoleObject($order, $destinationWarehouse, OrderRoleTypes::DESTINATION_WAREHOUSE);
|
||||
$this->createsOrderRole->execute($roleObject);
|
||||
|
||||
|
||||
$roleObject = new OrderRoleObject($order, $freightForwarder, OrderRoleTypes::LAST_MILE_DELIVERY_DRIVER);
|
||||
$this->createsOrderRole->execute($roleObject);
|
||||
|
||||
return true;
|
||||
|
||||
$companies = $this->fetchesCompany->getRepository()->whereIn('id',[1, $request->get('warehouse_id')])->get();
|
||||
|
||||
$cief_company = $companies[0]->id == 1 ? $companies[0] : $companies[1];
|
||||
$warehouse_company = $companies[0]->id != 1 ? $companies[0] : $companies[1];
|
||||
|
||||
$cief_company_module = $cief_company->companyModule()->first();
|
||||
$contractEntities[] = $this->unityCreateContractEntity->execute( $contract_reference_no, [$cief_company_module->unity_hash_id]);
|
||||
$contractEntities[0]->{"company_module_id"} = $cief_company_module->id;
|
||||
|
||||
$warehouse_company_module = $warehouse_company->companyModule()->first();
|
||||
$contractEntities[] = $this->unityCreateContractEntity->execute( $contract_reference_no, [$warehouse_company_module->unity_hash_id]);
|
||||
$contractEntities[1]->{"company_module_id"} = $warehouse_company_module->id;
|
||||
|
||||
foreach($contractEntities as $entity){
|
||||
$order_role_object = new OrderRoleObject($orderId, $entity->company_module_id, $entity->hash_id, $entity->entity_signature_hash_id);
|
||||
|
||||
$this->canCreateOrderRole->passes($order_role_object);
|
||||
|
||||
$this->createsOrderRole->execute($order_role_object);
|
||||
}
|
||||
|
||||
return $contractEntities;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,12 @@ use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\DeletesAddress;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Classes\ValueObjects\Constants\AddressType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -29,6 +34,12 @@ class RequestChangeOrderAddressProcessor
|
||||
/** @var DeletesAddress */
|
||||
private $deletesAddress;
|
||||
|
||||
/** @var CreateContactProcessor */
|
||||
private $createContactProcessor;
|
||||
|
||||
/** @var CreateRemarkProcessor */
|
||||
private $createRemarkProcessor;
|
||||
|
||||
/**
|
||||
* ChangeOrderAddressProcessor constructor.
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
@@ -36,7 +47,7 @@ class RequestChangeOrderAddressProcessor
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
* @param DeletesAddress $deletesAddress
|
||||
*/
|
||||
public function __construct(CanChangeOrderAddress $canChangeOrderAddress, FetchesOrder $fetchesOrder, CreatesAddress $createsAddress, FetchesAddress $fetchesAddress, DeletesAddress $deletesAddress)
|
||||
public function __construct(CanChangeOrderAddress $canChangeOrderAddress, FetchesOrder $fetchesOrder, CreatesAddress $createsAddress, FetchesAddress $fetchesAddress, DeletesAddress $deletesAddress, CreateContactProcessor $createContactProcessor, CreateRemarkProcessor $createRemarkProcessor)
|
||||
{
|
||||
|
||||
$this->canChangeOrderAddress = $canChangeOrderAddress;
|
||||
@@ -44,12 +55,20 @@ class RequestChangeOrderAddressProcessor
|
||||
$this->createsAddress = $createsAddress;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
$this->deletesAddress = $deletesAddress;
|
||||
$this->createContactProcessor = $createContactProcessor;
|
||||
$this->createRemarkProcessor = $createRemarkProcessor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request)
|
||||
{
|
||||
|
||||
$this->canChangeOrderAddress->passes();
|
||||
|
||||
$order = $this->fetchesOrder->execute(['id' => $request->get('order_id')]);
|
||||
@@ -58,8 +77,33 @@ class RequestChangeOrderAddressProcessor
|
||||
}
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->get('address_id')]);
|
||||
$addressObject = new AddressObject($address->street_one, $address->street_two, $address->country_id, $address->state_id, $address->district_id, $address->postcode, $address->reference, ApprovalStatus::PENDING_VERIFICATION);
|
||||
$this->createsAddress->execute($order, $addressObject);
|
||||
$addressObject = new AddressObject($address->street_one, $address->street_two, $address->country_id, $address->state_id, $address->district_id, $address->postcode, AddressType::DELIVERY, ApprovalStatus::PENDING_VERIFICATION, $address->reference);
|
||||
$order_address = $this->createsAddress->execute($order, $addressObject);
|
||||
|
||||
$contact = $address->contacts()->first();
|
||||
if($contact){
|
||||
$contactObject = new ContactObject(
|
||||
$contact->reference,
|
||||
$contact->phone,
|
||||
'',
|
||||
''
|
||||
);
|
||||
|
||||
$this->createContactProcessor->execute($contactObject, $order_address);
|
||||
|
||||
}
|
||||
|
||||
$remark = $address->remarks()->first();
|
||||
|
||||
if($remark){
|
||||
$remarkObject = new RemarkObject(
|
||||
$remark->content,
|
||||
Auth()->user()->id
|
||||
);
|
||||
|
||||
$this->createRemarkProcessor->execute($order_address, $remarkObject);
|
||||
}
|
||||
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Processors;
|
||||
|
||||
use App\Classes\Exceptions\InternalServerErrorException;
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromVTPortal;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\PackingList;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
class UpdateDoFromVTPortalProcessor
|
||||
{
|
||||
/** @var FetchesDataFromVTPortal */
|
||||
private $fetchesDataFRomVTPortal;
|
||||
|
||||
/** @var FetchesAddress */
|
||||
private $fetchesAddress;
|
||||
|
||||
/**
|
||||
* FetchDeliveryListFromVTPortalProcessor constructor.
|
||||
* @param FetchesDataFromVTPortal $fetchesDataFRomVTPortal
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
*/
|
||||
public function __construct(FetchesDataFromVTPortal $fetchesDataFRomVTPortal, FetchesAddress $fetchesAddress)
|
||||
{
|
||||
$this->fetchesDataFRomVTPortal = $fetchesDataFRomVTPortal;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PackingList $packing_list
|
||||
* @return array
|
||||
* @throws GuzzleException
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
public function execute(PackingList $packing_list) {
|
||||
|
||||
if(!app()->environment(['production'])){
|
||||
return [];
|
||||
}
|
||||
|
||||
try {
|
||||
$address= $packing_list->owner->addresses()->where('status', ApprovalStatus::APPROVED)->first();
|
||||
$order = $packing_list->owner;
|
||||
|
||||
if ($packing_list) {
|
||||
$contact = $address->contacts()->first();
|
||||
$remark = $address->remarks()->first();
|
||||
|
||||
$remark = $remark ? $remark->content : 'URGENT!!! PLEASE CALL BEFORE ONE DAY DELIVERY.';
|
||||
$phone = $contact ? $contact->phone : null;
|
||||
$reference = $contact ? $contact->reference : null;
|
||||
|
||||
$status = 'On Hold';
|
||||
|
||||
if (in_array($packing_list->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) {
|
||||
$status = 'Release';
|
||||
}
|
||||
|
||||
$vt_do = $this->fetchesDataFRomVTPortal->clientRequest('http://portal.vtnation.com.my/Services/DataControllerService.asmx/GetPage', 'POST', json_decode('{"controller":"Do","view":"grid1","request":{"PageIndex":-1,"PageSize":10000,"Filter": ["FullMarking:$contains$%js%\"' . $order->reference . '\"\u0000"]}}'), '');
|
||||
|
||||
$vt_do = $this->fetchesDataFRomVTPortal->getResponseBody($vt_do);
|
||||
|
||||
if ($vt_do) {
|
||||
foreach ($vt_do->Rows as $key => $row) {
|
||||
if($row[4] !== $packing_list->containers()->first()->reference) continue;
|
||||
$vt_do_update = $this->fetchesDataFRomVTPortal->clientRequest(
|
||||
'http://portal.vtnation.com.my/Services/DataControllerService.asmx/Execute',
|
||||
'POST',
|
||||
json_decode('{
|
||||
"controller": "Do",
|
||||
"view": "editForm1",
|
||||
"args": {
|
||||
"CommandName": "Update",
|
||||
"CommandArgument": "Save",
|
||||
"Path": "ag2/a4",
|
||||
"LastCommandName": "Edit",
|
||||
"Values": [
|
||||
{
|
||||
"Name": "ShippingAddress",
|
||||
"NewValue": "' . $address->street_one . ' ' . $address->street_two . ' '. $address->district->name.' '. $address->postcode.' '.$address->state->name.' '.$address->country->name.'",
|
||||
"Modified": true,
|
||||
"ReadOnly": false,
|
||||
"Error": null
|
||||
},
|
||||
{
|
||||
"Name": "Attn",
|
||||
"NewValue": "'.$reference.'",
|
||||
"Modified": true,
|
||||
"ReadOnly": false,
|
||||
"Error": null
|
||||
},
|
||||
{
|
||||
"Name": "Tel",
|
||||
"NewValue": "'.$phone.'",
|
||||
"Modified": true,
|
||||
"ReadOnly": false,
|
||||
"Error": null
|
||||
},
|
||||
{
|
||||
"Name": "Status",
|
||||
"NewValue": "' . $status . '",
|
||||
"Modified": true,
|
||||
"ReadOnly": false,
|
||||
"Error": null
|
||||
},
|
||||
{
|
||||
"Name": "Doremarks",
|
||||
"NewValue": "'. $remark .'",
|
||||
"Modified": true,
|
||||
"ReadOnly": false,
|
||||
"Error": null
|
||||
},
|
||||
{
|
||||
"Name": "DoID",
|
||||
"OldValue": '.$row[0].',
|
||||
"NewValue": '.$row[0].',
|
||||
"Modified": false,
|
||||
"ReadOnly": true,
|
||||
"Error": null
|
||||
}
|
||||
],
|
||||
"Controller": "Do"
|
||||
}
|
||||
}'), '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new InternalServerErrorException('failed to approve address due to an error related to VT portal: '.$exception->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Processors;
|
||||
|
||||
use App\Classes\Exceptions\InternalServerErrorException;
|
||||
use App\Classes\Modules\Orders\Services\FetchesDataFromYDPortal;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\PackingList;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpdateDoFromYDPortalProcessor
|
||||
{
|
||||
/** @var FetchesDataFromYDPortal */
|
||||
private $fetchesDataFRomYDPortal;
|
||||
|
||||
/** @var FetchesAddress */
|
||||
private $fetchesAddress;
|
||||
|
||||
/**
|
||||
* FetchDeliveryListFromVTPortalProcessor constructor.
|
||||
* @param FetchesDataFromYDPortal $fetchesDataFRomYDPortal
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
*/
|
||||
public function __construct(FetchesDataFromYDPortal $fetchesDataFRomYDPortal, FetchesAddress $fetchesAddress)
|
||||
{
|
||||
$this->fetchesDataFRomYDPortal = $fetchesDataFRomYDPortal;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PackingList $packingList
|
||||
* @return void
|
||||
* @throws InternalServerErrorException
|
||||
*/
|
||||
public function execute(PackingList $packingList) {
|
||||
if(!app()->environment(['production'])){
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$address = $packingList->owner->addresses()->where('status', ApprovalStatus::APPROVED)->first();
|
||||
|
||||
if (!in_array($packingList->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$contact = $address->contacts()->first();
|
||||
$remark = $address->remarks()->first();
|
||||
|
||||
$phone = $contact ? $contact->phone : null;
|
||||
$reference = $contact ? $contact->reference : null;
|
||||
$remark = $remark ? $remark->content : 'URGENT!!! PLEASE CALL BEFORE ONE DAY DELIVERY.';
|
||||
|
||||
$this->fetchesDataFRomYDPortal->clientRequest(
|
||||
'http://www.yd-wl.com/api/UpdateOrderAddress.ashx',
|
||||
'POST',
|
||||
[
|
||||
'expressno' => $packingList->reference,
|
||||
'customers_name' => $reference,
|
||||
'cellphone' => $phone,
|
||||
'postcode' => $address->postcode,
|
||||
'streetAddress' => $address->street_one . ' ' . $address->street_two . ' '. $address->district->name.' '. $address->post_code.' '.$address->state->name.' '.$address->country->name.' '.$address->postcode.' || '.$remark
|
||||
|
||||
]);
|
||||
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new InternalServerErrorException('failed to approve address due to an error related to YD portal');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Order;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CalculatesBaseRate
|
||||
{
|
||||
|
||||
public function execute(Order $order){
|
||||
return 300;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Order;
|
||||
use App\Models\Package;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CalculatesCBM
|
||||
{
|
||||
|
||||
public function execute(Order $order, Package $parcel){
|
||||
return $parcel->length * $parcel->width * $parcel->height;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Models\Order;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CalculatesSegmentRate
|
||||
{
|
||||
|
||||
public function execute(Order $order, int $segmentRates){
|
||||
return ($segmentRates == SegmentConstants::STANDARD_SEGMENT) ? 300 : (
|
||||
(($segmentRates == SegmentConstants::CUSTOM_SEGMENT) ? -20 : 0)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Order;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CalculatesStateRate
|
||||
{
|
||||
|
||||
public function execute(Order $order, $isOutskirt=false){
|
||||
return ($isOutskirt) ? 20 : 40;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user