Compare commits
616 Commits
dependabot
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c94239da7 | |||
| 7e6c8224a5 | |||
| 8bc1289206 | |||
| 75390f10cd | |||
| 7468e63299 | |||
| 4c88de77a7 | |||
| c7502b853c | |||
| 249ab13004 | |||
| fce67286fd | |||
| f841639ec3 | |||
| c270017111 | |||
| 0ee317b0fc | |||
| f606b9cdd5 | |||
| 412b4d6794 | |||
| c045cabcf7 | |||
| f5adc203f3 | |||
| f3362bab00 | |||
| 268e2fdbee | |||
| 6d38e6fc8c | |||
| 99ff081b05 | |||
| 5b88887f53 | |||
| 669f716112 | |||
| addd34cb82 | |||
| c77a6e7af6 | |||
| 28ca917d5d | |||
| 1196abb0a0 | |||
| 68560e4e35 | |||
| a4eb7b9ad3 | |||
| 35591ab04c | |||
| 339b1063c6 | |||
| 83592117d1 | |||
| ff1e396fbc | |||
| 5471ccfa17 | |||
| c0aa379d37 | |||
| 3da0cec4a1 | |||
| bca5179cc3 | |||
| c075112810 | |||
| 57d01028cf | |||
| bef633434c | |||
| 6afba02675 | |||
| 4ac1ef0e73 | |||
| 0b0faf26d2 | |||
| d49695e7e8 | |||
| 0e96905213 | |||
| 57d9d4b99b | |||
| f77e6874d0 | |||
| daa72ff60c | |||
| 8bd44c10b8 | |||
| f4c77eee00 | |||
| 5b11c5b629 | |||
| 2e1f28c8c5 | |||
| 7bc2b82837 | |||
| f6f73cbb94 | |||
| 411b005dee | |||
| aacf2fc830 | |||
| e498a2b202 | |||
| 3853a81fba | |||
| 7b26a021e1 | |||
| b310799bf0 | |||
| 1a44be502a | |||
| 103a41c0ff | |||
| 9e5e3720b5 | |||
| baf7c2130e | |||
| c889960805 | |||
| 9462aea45f | |||
| f26ba1d75c | |||
| 2d575dd86b | |||
| 5db70758cb | |||
| 8f2036eecc | |||
| 083422047c | |||
| dda65951b3 | |||
| dbd30021f9 | |||
| c69416ee88 | |||
| 03b0c71708 | |||
| d4214ee4bf | |||
| c70999100b | |||
| eceac30f4b | |||
| 736eb6feba | |||
| cd0710c428 | |||
| bd03a983a2 | |||
| 4c3896cbee | |||
| c362de7589 | |||
| c17af03ef3 | |||
| 2fbf72df61 | |||
| 55b0002688 | |||
| 2a3a86f185 | |||
| 82072f18dc | |||
| 7bfc30e50d | |||
| 109d70363d | |||
| 0ef8dca814 | |||
| 9685d7ee8a | |||
| 1dd6b73632 | |||
| 1a591b202c | |||
| ddda064033 | |||
| 48b5955e16 | |||
| a877e28da9 | |||
| f0ec279ea5 | |||
| 254931998c | |||
| 9ad22c03a8 | |||
| 1210c71484 | |||
| bd4b5e8a83 | |||
| 3b02745302 | |||
| 2349f1031c | |||
| 8ea29296bd | |||
| 68ce69ec70 | |||
| 814db0307a | |||
| 0aaddbe9ad | |||
| 5fcca05d2b | |||
| 8f6be2c87e | |||
| 8749ce8848 | |||
| ac0ca03845 | |||
| 568928c98f | |||
| 8fb4b979c3 | |||
| 23739baa7c | |||
| c7ce7a9351 | |||
| 74f4c21244 | |||
| 996ff6e6aa | |||
| 918d9129f4 | |||
| 27f782f659 | |||
| 17b1db88c1 | |||
| 27e05fdfde | |||
| a07151f507 | |||
| 94c4cf760a | |||
| 20cc7f22dc | |||
| 49257e4cf4 | |||
| bc0b3336c5 | |||
| fadf93b425 | |||
| 0815b43797 | |||
| 55185bae5b | |||
| 4030166118 | |||
| f179cbedd7 | |||
| 20bb89f388 | |||
| e4ccf5190b | |||
| 38b0b8f63f | |||
| dedbcc6c84 | |||
| cef0f7632d | |||
| 7af4457c6a | |||
| 9e851e1a10 | |||
| b322f9a8a6 | |||
| 02722c3146 | |||
| 8405913e84 | |||
| 5d5b23b25b | |||
| e3e10952a6 | |||
| 58e2dcdcc9 | |||
| 936fca0667 | |||
| e777d7e816 | |||
| 5472c99b15 | |||
| 2848102b79 | |||
| d3fae0711f | |||
| 0f05abc0ae | |||
| e52071f1f8 | |||
| f65b7380dc | |||
| 96f84d69e2 | |||
| 8f23d0a1b0 | |||
| 1058cf4a9a | |||
| dae26c74ee | |||
| 5a35b3f6a5 | |||
| 79936f7030 | |||
| 734b16d8a6 | |||
| e0940ac9bc | |||
| 843e3806fb | |||
| 13e99bd4a9 | |||
| bce8363a53 | |||
| e536c55439 | |||
| d474c71c88 | |||
| 0df5bc06fe | |||
| d221f9a49f | |||
| 371e4af00f | |||
| 27508e468c | |||
| 20af2287c4 | |||
| 5433bee74d | |||
| 291d7bfeaa | |||
| 1803ea1343 | |||
| 014cdbcf75 | |||
| d91622b6d3 | |||
| 2d96396687 | |||
| 27b16d7595 | |||
| 265923aa84 | |||
| e8bbcfcfad | |||
| 9e963d581e | |||
| 6843f99a1f | |||
| 1c0f4392b2 | |||
| 8d3c122d93 | |||
| e57ab1a0fb | |||
| a0e6fc6157 | |||
| d842e7bc02 | |||
| a3dfb2bbe6 | |||
| 932911a746 | |||
| 3f3c169555 | |||
| 6b8123d650 | |||
| ac885c5e3f | |||
| 8c44bdac05 | |||
| bb65968afe | |||
| 44d3ea2468 | |||
| 3f76dd78cb | |||
| 9c1d94cdc0 | |||
| e322ceb622 | |||
| 1a24d95d31 | |||
| 2e159063b5 | |||
| 1be8be97aa | |||
| 565693d911 | |||
| 87cfcf3dd2 | |||
| 45b1be2b9f | |||
| bb85db9c3b | |||
| f506f9275d | |||
| 973a8a7ebb | |||
| 86534dea29 | |||
| 353d8c5183 | |||
| 3b02dfb1c7 | |||
| f78b9eddb9 | |||
| 30ea561714 | |||
| db557162af | |||
| 76b19c6ff5 | |||
| df5f29566d | |||
| 82d815adbb | |||
| d54b735986 | |||
| fbfb43040c | |||
| b332ac8acf | |||
| 61a6836a67 | |||
| 5a6a1a19c4 | |||
| 120bb5edc9 | |||
| d14bbc1d22 | |||
| 10c5a8c75c | |||
| 51da1dbbc3 | |||
| 89e4110ab0 | |||
| c06beae86f | |||
| bc59b580b0 | |||
| e1ea9fe4f4 | |||
| 5acb0aa92c | |||
| 7c2952899b | |||
| e925c6bed9 | |||
| a715a7c022 | |||
| b94c39923f | |||
| ce5bd50939 | |||
| ecbd6e1c6d | |||
| debe3f8025 | |||
| b1e4edad3b | |||
| 3ad6ed8bfa | |||
| 41b78a0599 | |||
| f3dc18b8ac | |||
| 427fc40edb | |||
| 90218eafe0 | |||
| 751a412185 | |||
| c3becc324b | |||
| 43ad853b60 | |||
| 955a5581a3 | |||
| f1be291c1c | |||
| aeee78a888 | |||
| 98db7a3ec2 | |||
| c0d65d55d1 | |||
| 7c14c15841 | |||
| 1c46ef4161 | |||
| 39f7fbbb99 | |||
| da95ee481d | |||
| 8153235f1f | |||
| 00f814152d | |||
| f28fa7d0e2 | |||
| 2361f5dc1c | |||
| e75fd81e27 | |||
| 265336ef3d | |||
| 7c9b0caded | |||
| a59d9bf6a9 | |||
| 657b96dadf | |||
| c8ee950fd0 | |||
| da7f69adae | |||
| da4457eba6 | |||
| b149a1f492 | |||
| ee7e149c35 | |||
| adee63564d | |||
| b00a1eb082 | |||
| 56e2c3fa9c | |||
| 6ea56238a8 | |||
| 678f066a97 | |||
| 20d1c5f027 | |||
| 9a797a159d | |||
| 63a06e78e1 | |||
| 96d068307f | |||
| 1f18d21069 | |||
| cb9fdaeb63 | |||
| b82fbd3ce3 | |||
| a3c07b2a84 | |||
| 772f149e81 | |||
| 75a72826fd | |||
| ec50817657 | |||
| d9d447bf54 | |||
| 9293564235 | |||
| 211d463288 | |||
| c3a8393c84 | |||
| 50e69755eb | |||
| 2cf1f7ff72 | |||
| af7c7344b4 | |||
| 58258a070e | |||
| 75a91c93e8 | |||
| 7a46e8684f | |||
| 1052c6241e | |||
| 0107f24de8 | |||
| fbcd7dd957 | |||
| 3e8bd39737 | |||
| e61aed425c | |||
| 0847e03b27 | |||
| 05626aac35 | |||
| 77818e9431 | |||
| abde239ff7 | |||
| 872afe444f | |||
| 4bd57ccd0b | |||
| 2191dadf47 | |||
| b48b118032 | |||
| 8d5ba9c42e | |||
| 565f51e81c | |||
| 0872d2f61a | |||
| 63a54c78e2 | |||
| 7d31892c57 | |||
| 33df24e1af | |||
| fe9547f78d | |||
| e24f431893 | |||
| 11ac571abb | |||
| 9c9575396b | |||
| 817ae1a452 | |||
| 32716cc81c | |||
| e949b1d717 | |||
| c089beae10 | |||
| 3332d6a36c | |||
| 4f1ae7fad8 | |||
| 12970c3830 | |||
| 6b5f51eed7 | |||
| 88f46d8dec | |||
| 5abbe10cf9 | |||
| ba92152daa | |||
| e248cd036c | |||
| f5531ac121 | |||
| 13c4f5ea3a | |||
| cd96aa8377 | |||
| 13f3e8e8f9 | |||
| 8c580827b4 | |||
| 0093b8d841 | |||
| 2071021cdd | |||
| 34cf203c01 | |||
| 9aa8c53b23 | |||
| 5973a5deda | |||
| 3237e80fb4 | |||
| da97d9b85c | |||
| 562093f22c | |||
| 65314bad77 | |||
| 31fbeee1cf | |||
| 5085ef140b | |||
| 1c4406a6eb | |||
| d815c15176 | |||
| a3a3cc1b7c | |||
| f266d781ac | |||
| f0962b0779 | |||
| d9cbd4ef93 | |||
| 6c90f9f642 | |||
| c341d21bbe | |||
| 91ebc9972c | |||
| 3fe6be6a57 | |||
| de0071734b | |||
| a0c0186337 | |||
| f3c317b505 | |||
| 09d0d57630 | |||
| b44ebfc0b6 | |||
| 3d054535db | |||
| c5b8c50923 | |||
| de60682f40 | |||
| 3d5b224e20 | |||
| d447f6f34d | |||
| 44e969d24b | |||
| ec933737cf | |||
| 97109cfd08 | |||
| 96507b7d7e | |||
| 9c5f9e3844 | |||
| cee7f07d76 | |||
| 87951b5ca6 | |||
| 6a3c69393e | |||
| b75d554cd7 | |||
| fb029dd813 | |||
| bb5df086de | |||
| a83131ba5e | |||
| 655b1a3a94 | |||
| 976e220859 | |||
| ae4436d3f1 | |||
| fdbc7ddf1b | |||
| 266aa3387c | |||
| adbf3297c4 | |||
| 9aae7e44ec | |||
| d3d27cf251 | |||
| 229aa84426 | |||
| 19447c6a11 | |||
| bd86e1ab05 | |||
| 6f97f0927c | |||
| 21d1a566f3 | |||
| ec73828eea | |||
| d62b4b3790 | |||
| c77b7e3821 | |||
| 9cce52b8ba | |||
| 5f2ba4133d | |||
| 4539056ec5 | |||
| 19b837a993 | |||
| 87891ac059 | |||
| e92c9d304d | |||
| 26c484d30c | |||
| e21fcd784c | |||
| 75544ef6bb | |||
| a084072f98 | |||
| 70fea18829 | |||
| 0b65005f9d | |||
| 54b25480e2 | |||
| 86783a0b56 | |||
| 8a2efb21a0 | |||
| cab5a4b2ed | |||
| 9bd0f3a296 | |||
| febe377eec | |||
| a497a8bb16 | |||
| b667348f5d | |||
| e67e90c96c | |||
| aff5831350 | |||
| dcf214b324 | |||
| 701b449517 | |||
| c1782cacfe | |||
| b0aa5e3fec | |||
| f06675dd2b | |||
| bd8872a785 | |||
| fbf48ef906 | |||
| 51f7d3990f | |||
| cd99acb61b | |||
| 1884ada219 | |||
| 3991ce3e9a | |||
| eb8c84b0c5 | |||
| c8f85b0ccd | |||
| a1e1ae261a | |||
| f9b4e9a898 | |||
| 2fd7a805eb | |||
| 1a443a4ab8 | |||
| c5b8957253 | |||
| 4b554f97ae | |||
| 38176274ff | |||
| 3c1278db82 | |||
| 0e4f9b91e5 | |||
| 7a658b7bfa | |||
| 4667b31dd8 | |||
| 39b0a8c372 | |||
| 40ed5dd5a5 | |||
| e6022ded9c | |||
| 6ad975e199 | |||
| 59cda8d129 | |||
| 311aec7847 | |||
| 2d7e1ec7bf | |||
| ecd7b08b27 | |||
| e2b94eea77 | |||
| 04e7a78575 | |||
| e232e03ef7 | |||
| 7f718555ac | |||
| b74c513271 | |||
| 794f358353 | |||
| 49aab1b97a | |||
| 374181c82c | |||
| 6b0f805adc | |||
| 4730bea74c | |||
| 49b9093f1b | |||
| 906fabe23f | |||
| d65adb904d | |||
| 5f91bcb221 | |||
| b37767f30d | |||
| 6613c985cd | |||
| 60d511d3c1 | |||
| f12e298298 | |||
| 0772488a50 | |||
| 2ff1897f60 | |||
| bd0170e094 | |||
| 8609b55797 | |||
| 31d4267d9f | |||
| c176c32668 | |||
| d3a9f33769 | |||
| 89ffa516c5 | |||
| 82aa1f88b4 | |||
| c51b1a72a9 | |||
| fa7889d7d5 | |||
| 3271200312 | |||
| 33719f8456 | |||
| 92ea143a92 | |||
| 8178af420a | |||
| c964fd1485 | |||
| 039fa1d44e | |||
| 78c05aadd3 | |||
| 6fd6db2d1d | |||
| b7600757a0 | |||
| 1527201bdb | |||
| cf7848b966 | |||
| ea855611e3 | |||
| 9b1140b8f9 | |||
| 4298a1f53e | |||
| 3623fd636b | |||
| 482b65e026 | |||
| ff6fed66ef | |||
| 40de3073f6 | |||
| 69892f4a6e | |||
| 5a68c84430 | |||
| 24a76fb092 | |||
| 2cd41593a5 | |||
| a2a9b31a25 | |||
| 45b2269920 | |||
| 4c99703290 | |||
| e39bcab748 | |||
| c2d06472e3 | |||
| 12cd0c7d74 | |||
| 0a22ba67c5 | |||
| 223a457f93 | |||
| 9c773bc635 | |||
| d0529330e5 | |||
| c7bc18c9aa | |||
| 0694940507 | |||
| c6b5f01c55 | |||
| 0a0d6bc998 | |||
| c3df293ddf | |||
| 71071d61ce | |||
| 356cee060a | |||
| f662bb7cb2 | |||
| 431ef40793 | |||
| 690203d818 | |||
| 6372a89d30 | |||
| ddae475a6c | |||
| ac617e8795 | |||
| fc1efa8d61 | |||
| c7fbb2ae0e | |||
| abc34b315a | |||
| e2289f1727 | |||
| 1a61f7939b | |||
| aa7e170aaf | |||
| da619f261e | |||
| ded58ea79a | |||
| 2da297facd | |||
| a253bb1aaf | |||
| dcfbfe4801 | |||
| cf6c601bcf | |||
| 3e24f71987 | |||
| b68bcfec03 | |||
| dd64010236 | |||
| d7d98b5195 | |||
| 9798f8296b | |||
| 68aafab377 | |||
| e4115b64ff | |||
| 3be42738d7 | |||
| da08630a1f | |||
| 001ff9e4e3 | |||
| a69e09efeb | |||
| 0a4090650d | |||
| 671da7e617 | |||
| 3f8bcfd588 | |||
| f036aa61f7 | |||
| d926a0fd98 | |||
| 21c73270fe | |||
| 97e4eb46eb | |||
| ad36ee9441 | |||
| c6557bab38 | |||
| 30cd115050 | |||
| 3dc10f41c8 | |||
| 466a1750bd | |||
| 7aee591a2c | |||
| 8ee98c06c2 | |||
| b91925a3f6 | |||
| c27a9c3f85 | |||
| ec9a2a2ce0 | |||
| 42ba7f3036 | |||
| db11b6255b | |||
| ce99ad9cf9 | |||
| 36ae8f27bb | |||
| 3fcceb0649 | |||
| d607f403ec | |||
| 4005b0f90c | |||
| 87bbc1a8e4 | |||
| 79c3e3382a | |||
| 2e178c8b16 | |||
| 62e159c1f2 | |||
| 2e57663f7c | |||
| 403cbfb6bb | |||
| 466751c13f | |||
| 2d6e6e4537 | |||
| 7231d54fa2 | |||
| 61224e5611 | |||
| 85d39b867b | |||
| 8f30c3a42d | |||
| 011e53054d | |||
| 2972b9a301 | |||
| e9c78c7e77 | |||
| 341117dfe9 | |||
| 3efa2138c5 | |||
| a5c6ad343b | |||
| f282ade0b3 | |||
| 252deff4c2 | |||
| f7312a97b0 | |||
| ade9da5be7 | |||
| 0c5b9aeb19 | |||
| f306ee161c | |||
| 0ee3699b44 | |||
| 4c281934ff | |||
| 507f4f8a73 | |||
| a158bad0bf | |||
| a3e9bf9aab | |||
| b23d7195c5 | |||
| 0af6824866 | |||
| d66fa052fb | |||
| adadd7994e | |||
| aae582344e | |||
| 4db6dac439 | |||
| 91bde37441 | |||
| 044450e448 | |||
| 56ebd398ab | |||
| 6d5eb98614 | |||
| 434179ba18 | |||
| 9e4b8deb78 | |||
| 4688af0cb4 | |||
| d44edffa1b | |||
| ceb7ed4949 | |||
| 4b94ed2a51 | |||
| 9feba2916a | |||
| 4f15afb3ce | |||
| eb54b7ba0a |
24
.env
24
.env
@@ -2,7 +2,7 @@ APP_NAME='W4RP Services'
|
|||||||
APP_ENV=local
|
APP_ENV=local
|
||||||
APP_KEY=base64:PBOxrGFJAtwj9SDF4F0DZ1J+6MjrJmRiPZJQwRdy3XQ=
|
APP_KEY=base64:PBOxrGFJAtwj9SDF4F0DZ1J+6MjrJmRiPZJQwRdy3XQ=
|
||||||
APP_DEBUG=true
|
APP_DEBUG=true
|
||||||
APP_URL=http://localhost
|
APP_URL=https://services.w4rp.space
|
||||||
|
|
||||||
LOG_CHANNEL=daily
|
LOG_CHANNEL=daily
|
||||||
|
|
||||||
@@ -10,14 +10,16 @@ DB_CONNECTION=mysql
|
|||||||
DB_HOST=127.0.0.1
|
DB_HOST=127.0.0.1
|
||||||
DB_PORT=3306
|
DB_PORT=3306
|
||||||
DB_DATABASE=w4rpservices2
|
DB_DATABASE=w4rpservices2
|
||||||
DB_USERNAME=
|
DB_USERNAME=minerva
|
||||||
DB_PASSWORD=
|
DB_PASSWORD=FuckingShit12
|
||||||
|
|
||||||
BROADCAST_DRIVER=log
|
BROADCAST_DRIVER=log
|
||||||
CACHE_DRIVER=file
|
CACHE_DRIVER=redis
|
||||||
|
CACHE_PREFIX=w4rpservices_cache
|
||||||
|
|
||||||
QUEUE_DRIVER=redis
|
QUEUE_DRIVER=redis
|
||||||
QUEUE_CONNECTION=sync
|
QUEUE_CONNECTION=redis
|
||||||
|
QUEUE_PREFIX=w4rpservices_queue
|
||||||
|
|
||||||
SESSION_DRIVER=file
|
SESSION_DRIVER=file
|
||||||
SESSION_LIFETIME=120
|
SESSION_LIFETIME=120
|
||||||
@@ -25,6 +27,8 @@ SESSION_LIFETIME=120
|
|||||||
REDIS_HOST=127.0.0.1
|
REDIS_HOST=127.0.0.1
|
||||||
REDIS_PASSWORD=null
|
REDIS_PASSWORD=null
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
|
REDIS_DATABASE=0
|
||||||
|
REDIS_CACHE_DB=1
|
||||||
|
|
||||||
MAIL_DRIVER=smtp
|
MAIL_DRIVER=smtp
|
||||||
MAIL_HOST=smtp.mailtrap.io
|
MAIL_HOST=smtp.mailtrap.io
|
||||||
@@ -33,9 +37,11 @@ MAIL_USERNAME=null
|
|||||||
MAIL_PASSWORD=null
|
MAIL_PASSWORD=null
|
||||||
MAIL_ENCRYPTION=null
|
MAIL_ENCRYPTION=null
|
||||||
|
|
||||||
ESI_CLIENT_ID=
|
ESI_CLIENT_ID=91a051aea72742068b51801042397c38
|
||||||
ESI_SECRET_KEY=
|
ESI_SECRET_KEY=1co6qRMoXyx1dG2iBbAZ1z6NUOoaJWyQnqEnsqoj
|
||||||
ESI_USERAGENT=
|
ESI_USERAGENT='W4RP Services'
|
||||||
ESI_CALLBACK_URI=
|
ESI_CALLBACK_URI=https://services.w4rp.space/callback/
|
||||||
ESI_PRIMARY_CHAR=93738489
|
ESI_PRIMARY_CHAR=93738489
|
||||||
ESI_ALLIANCE=99004116
|
ESI_ALLIANCE=99004116
|
||||||
|
|
||||||
|
HORIZON_PREFIX=w4rpservices_horizon
|
||||||
|
|||||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -5,5 +5,7 @@
|
|||||||
/public/logs/*
|
/public/logs/*
|
||||||
worker.log
|
worker.log
|
||||||
/public/cache/*
|
/public/cache/*
|
||||||
/.env
|
.env
|
||||||
.vscode
|
.vscode
|
||||||
|
/storage/logs
|
||||||
|
worker.log
|
||||||
@@ -7,9 +7,6 @@ use Illuminate\Console\Command;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
//Library
|
|
||||||
use Commands\Library\CommandHelper;
|
|
||||||
|
|
||||||
//Models
|
//Models
|
||||||
use App\Models\Lookups\AllianceLookup;
|
use App\Models\Lookups\AllianceLookup;
|
||||||
use App\Models\Lookups\CharacterLookup;
|
use App\Models\Lookups\CharacterLookup;
|
||||||
@@ -57,9 +54,6 @@ class CleanStaleDataCommand extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$command = new CommandHelper;
|
|
||||||
$command->CleanJobStatusTable();
|
|
||||||
|
|
||||||
//Empty the item lookup table
|
//Empty the item lookup table
|
||||||
ItemLookup::truncate();
|
ItemLookup::truncate();
|
||||||
|
|
||||||
|
|||||||
@@ -5,16 +5,13 @@ namespace App\Console\Commands\Data;
|
|||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Log;
|
use Log;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
//Models
|
use Illuminate\Support\Str;
|
||||||
use App\Models\ScheduledTask\ScheduleJob;
|
use App\Library\Helpers\LookupHelper;
|
||||||
|
|
||||||
//Library
|
|
||||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
|
||||||
use App\Library\Esi\Esi;
|
use App\Library\Esi\Esi;
|
||||||
use Seat\Eseye\Cache\NullCache;
|
use App\Library\Moons\MoonCalc;
|
||||||
use Seat\Eseye\Configuration;
|
use App\Models\MoonRental\AllianceMoon;
|
||||||
use App\Library\Helpers\FinanceHelper;
|
use App\Models\MoonRental\AllianceMoonOre;
|
||||||
|
|
||||||
class Test extends Command
|
class Test extends Command
|
||||||
{
|
{
|
||||||
@@ -49,11 +46,25 @@ class Test extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$helper = new FinanceHelper;
|
//Declare variables
|
||||||
$config = config('esi');
|
$lookup = new LookupHelper;
|
||||||
$startTime = time();
|
$mHelper = new MoonCalc;
|
||||||
$receipt = $helper->GetApiWalletJournal(1, $config['primary']);
|
$months = 3;
|
||||||
$endTime = time();
|
$rentalTax = 0.25;
|
||||||
var_dump($endTime - $startTime);
|
$worth1;
|
||||||
|
$worth2;
|
||||||
|
|
||||||
|
$moons = AllianceMoon::all();
|
||||||
|
|
||||||
|
foreach($moons as $moon) {
|
||||||
|
//Declare the arrays needed
|
||||||
|
$ores = array();
|
||||||
|
|
||||||
|
$ores = AllianceMoonOre::where([
|
||||||
|
'moon_id' => $moon->moon_id,
|
||||||
|
])->get(['ore_type_id', 'quantity'])->toArray();
|
||||||
|
|
||||||
|
dd($ores);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ use Illuminate\Console\Command;
|
|||||||
|
|
||||||
//Library
|
//Library
|
||||||
use App\Library\Moons\MoonCalc;
|
use App\Library\Moons\MoonCalc;
|
||||||
use Comamnds\Library\CommandHelper;
|
|
||||||
|
|
||||||
//Job
|
//Job
|
||||||
use App\Jobs\Commands\Eve\ItemPricesUpdateJob;
|
use App\Jobs\Commands\Eve\ItemPricesUpdateJob;
|
||||||
@@ -46,17 +45,10 @@ class ItemPricesUpdateCommand extends Command
|
|||||||
{
|
{
|
||||||
//Declare variables
|
//Declare variables
|
||||||
$moonHelper = new MoonCalc;
|
$moonHelper = new MoonCalc;
|
||||||
$task = new CommandHelper('ItemPricesUpdateCommand');
|
|
||||||
|
|
||||||
//Set the task as started
|
|
||||||
$task->SetStartStatus();
|
|
||||||
|
|
||||||
//Fetch new prices from fuzzwork.co.uk for the item pricing schemes
|
//Fetch new prices from fuzzwork.co.uk for the item pricing schemes
|
||||||
$moonHelper->FetchNewPrices();
|
$moonHelper->FetchNewPrices();
|
||||||
|
|
||||||
//Set the task as completed
|
|
||||||
$task->SetStopStatus();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
152
app/Console/Commands/Files/ImportAllianceMoons.php
Normal file
152
app/Console/Commands/Files/ImportAllianceMoons.php
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
//Namespace
|
||||||
|
namespace App\Console\Commands\Files;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Http\File;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Log;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use DB;
|
||||||
|
|
||||||
|
//Application Library
|
||||||
|
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
use App\Library\Helpers\LookupHelper;
|
||||||
|
use App\Library\Moons\MoonCalc;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\MoonRental\AllianceMoonOre;
|
||||||
|
use App\Models\MoonRental\AllianceMoon;
|
||||||
|
|
||||||
|
class ImportAllianceMoons extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'files:import:moons';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Import moons from tab-delimited text.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
///universe/moons/{moon_id}/
|
||||||
|
//Declare variables
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$mHelper = new MoonCalc;
|
||||||
|
//Create the collection of lines for the input file.
|
||||||
|
$moons = new Collection;
|
||||||
|
|
||||||
|
//Create the file handler
|
||||||
|
$data = Storage::get('public/alliance_moons.txt');
|
||||||
|
//Split the string into separate arrays based on the line
|
||||||
|
$lines = preg_split("/\n/", $data);
|
||||||
|
//Take each line and split it again by tabs
|
||||||
|
foreach($lines as $temp) {
|
||||||
|
//Split the lines into separate arrays by tabs
|
||||||
|
$separated = preg_split("/\t/", $temp);
|
||||||
|
//Push the tabbed array into the collection
|
||||||
|
$moons->push($separated);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The first pass through the collection of data is to get all of the ore data
|
||||||
|
* and store it in the database. From the database moon ore, we will create a list
|
||||||
|
* of moons and store those in the database. After the list of moons are created in the
|
||||||
|
* database, the function will then update the value of all the moons.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//Start working our way through all of the moons
|
||||||
|
//and saving the data to the database
|
||||||
|
foreach($moons as $moon) {
|
||||||
|
//If the first array is null then we are dealing with an ore
|
||||||
|
if($moon[0] == null) {
|
||||||
|
$moonInfo = $lookup->GetMoonInfo($moon[6]);
|
||||||
|
$solarName = $lookup->SystemIdToName($moonInfo->system_id);
|
||||||
|
|
||||||
|
$moonType = $mHelper->IsRMoonGoo($moon[1]);
|
||||||
|
|
||||||
|
if(AllianceMoon::where(['moon_id' => $moonInfo->moon_id])->count() == 0) {
|
||||||
|
//Save the moon into the database
|
||||||
|
$newMoon = new AllianceMoon;
|
||||||
|
$newMoon->moon_id = $moonInfo->moon_id;
|
||||||
|
$newMoon->name = $moonInfo->name;
|
||||||
|
$newMoon->system_id = $moonInfo->system_id;
|
||||||
|
$newMoon->system_name = $solarName;
|
||||||
|
$newMoon->moon_type = $moonType;
|
||||||
|
$newMoon->worth_amount = 0.00;
|
||||||
|
$newMoon->rented = 'No';
|
||||||
|
$newMoon->rental_amount = 0.00;
|
||||||
|
$newMoon->save();
|
||||||
|
} else {
|
||||||
|
$current = AllianceMoon::where([
|
||||||
|
'moon_id' => $moonInfo->moon_id,
|
||||||
|
])->first();
|
||||||
|
|
||||||
|
if($current->moon_type == 'R4' && ($moonType == 'R8' || $moonType == 'R16' || $moonType == 'R32' || $moonType == 'R64')) {
|
||||||
|
AllianceMoon::where([
|
||||||
|
'moon_id' => $moonInfo->moon_id,
|
||||||
|
])->update([
|
||||||
|
'moon_type' => $moonType,
|
||||||
|
]);
|
||||||
|
} else if($current->moon_type == 'R8' && ($moonType == 'R16' || $moonType == 'R32' || $moonType == 'R64')) {
|
||||||
|
AllianceMoon::where([
|
||||||
|
'moon_id' => $moonInfo->moon_id,
|
||||||
|
])->update([
|
||||||
|
'moon_type' => $moonType,
|
||||||
|
]);
|
||||||
|
} else if($current->moon_type == 'R16' && ($moonType == 'R32' || $moonType == 'R64')) {
|
||||||
|
AllianceMoon::where([
|
||||||
|
'moon_id' => $moonInfo->moon_id,
|
||||||
|
])->update([
|
||||||
|
'moon_type' => $moonType,
|
||||||
|
]);
|
||||||
|
} else if($current->moon_type == 'R32' && $moonType == 'R64') {
|
||||||
|
AllianceMoon::where([
|
||||||
|
'moon_id' => $moonInfo->moon_id,
|
||||||
|
])->update([
|
||||||
|
'moon_type' => $moonType,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Save a new entry into the database
|
||||||
|
$ore = new AllianceMoonOre;
|
||||||
|
$ore->moon_id = $moon[6];
|
||||||
|
$ore->moon_name = $moonInfo->name;
|
||||||
|
$ore->ore_type_id = $moon[3];
|
||||||
|
$ore->ore_name = $moon[1];
|
||||||
|
$ore->quantity = $moon[2];
|
||||||
|
$ore->solar_system_id = $moon[4];
|
||||||
|
$ore->planet_id = $moon[5];
|
||||||
|
$ore->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,9 @@ use Carbon\Carbon;
|
|||||||
|
|
||||||
//Application Library
|
//Application Library
|
||||||
use App\Library\Helpers\FinanceHelper;
|
use App\Library\Helpers\FinanceHelper;
|
||||||
use Commands\Library\CommandHelper;
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\Commands\Finances\UpdateAllianceWalletJournalJob;
|
||||||
|
|
||||||
//Models
|
//Models
|
||||||
use App\Models\Finances\AllianceWalletJournal;
|
use App\Models\Finances\AllianceWalletJournal;
|
||||||
@@ -47,18 +49,6 @@ class UpdateAllianceWalletJournal extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
//Declare variables
|
UpdateAllianceWalletJournalJob::dispatch()->onQueue('finances');
|
||||||
$fHelper = new FinanceHelper;
|
|
||||||
$config = config('esi');
|
|
||||||
$task = new CommandHelper('UpdateAllianceWalletJournal');
|
|
||||||
//Set the task as started
|
|
||||||
$task->SetStartStatus();
|
|
||||||
|
|
||||||
$fHelper->GetApiWalletJournal(1, $config['primary']);
|
|
||||||
|
|
||||||
//Set the task as stopped
|
|
||||||
$task->SetStopStatus();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Commands\Library;
|
|
||||||
|
|
||||||
//Internal Libraries
|
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
//Models
|
|
||||||
use App\Models\ScheduledTask\ScheduleJob;
|
|
||||||
|
|
||||||
class CommandHelper {
|
|
||||||
|
|
||||||
private $job_name;
|
|
||||||
private $job_state;
|
|
||||||
private $system_time;
|
|
||||||
|
|
||||||
public function __construct($name) {
|
|
||||||
$this->job_name = $name;
|
|
||||||
$this->job_state = 'Starting';
|
|
||||||
$this->system_time = Carbon::now();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function SetStartStatus() {
|
|
||||||
//Add an entry into the jobs table
|
|
||||||
$job = new ScheduleJob;
|
|
||||||
$job->job_name = $this->job_name;
|
|
||||||
$job->job_state = $this->job_state;
|
|
||||||
$job->system_time = $this->system_time;
|
|
||||||
$job->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function SetStopStatus() {
|
|
||||||
//Mark the job as finished
|
|
||||||
ScheduleJob::where([
|
|
||||||
'system_time' => $this->system_time,
|
|
||||||
'job_name' => $this->job_name,
|
|
||||||
])->update([
|
|
||||||
'job_state' => 'Finished',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function CleanJobStatusTable() {
|
|
||||||
//Delete old jobs
|
|
||||||
ScheduleJob::where(['system_time', '<', Carbon::now()->subMonths(3)])->delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands\MiningTaxes;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
use App\Jobs\Commands\MiningTaxes\PreFetchMiningTaxesLedgers as PreFetch;
|
||||||
|
|
||||||
|
class ExecuteMiningTaxesLedgersCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'mt:ledgers';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Execute mining taxes ledgers jobs.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
PreFetch::dispatch();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands\MiningTaxes;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
use App\Jobs\Commands\MiningTaxes\FetchMiningTaxesObservers as FetchObservers;
|
||||||
|
|
||||||
|
class ExecuteMiningTaxesObserversCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'mt:observer';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Dispatch a mining tax observer job.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
FetchObservers::dispatch();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands\MiningTaxes;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
use App\Jobs\Commands\MiningTaxes\ProcessMiningTaxesPayments as PMTP;
|
||||||
|
|
||||||
|
class ExecuteProcesssMiningTaxesPaymentsCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'mt:payments';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Process Mining Taxes payments from the console.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
PMTP::dispatch();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands\MiningTaxes;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
use App\Jobs\Commands\MiningTaxes\MiningTaxesWeeklyInvoicing as SendInvoice;
|
||||||
|
|
||||||
|
class ExecuteSendMiningTaxesInvoiceCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'mt:send';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Execute send mining tax invoices.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
SendInvoice::dispatch();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,155 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands\MiningTaxes;
|
|
||||||
|
|
||||||
//Internal Library
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Log;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
//Application Library
|
|
||||||
use Commands\Library\CommandHelper;
|
|
||||||
use App\Library\Helpers\LookupHelper;
|
|
||||||
|
|
||||||
//Models
|
|
||||||
use App\Models\MiningTax\Invoice;
|
|
||||||
use App\Models\MiningTax\Ledger;
|
|
||||||
|
|
||||||
//Jobs
|
|
||||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
|
||||||
|
|
||||||
class MiningTaxesInvoices extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'MiningTax:Invoice';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Mining Taxes Invoice Command';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
//Declare variables
|
|
||||||
$lookup = new LookupHelper;
|
|
||||||
$config = config('esi');
|
|
||||||
$body = null;
|
|
||||||
$task = new CommandHelper('MiningTaxesInvoices');
|
|
||||||
//Set the task as started
|
|
||||||
$task->SetStartStatus();
|
|
||||||
|
|
||||||
//Get the characters for each non-invoiced ledger entry
|
|
||||||
$charIds = Ledger::distinct('character_id')->pluck('character_id');
|
|
||||||
|
|
||||||
//Foreach character tally up the mining ledger.
|
|
||||||
foreach($charIds as $charId) {
|
|
||||||
//Declare some variables we need for each iteration of the loop
|
|
||||||
$invoice = array();
|
|
||||||
$ores = array();
|
|
||||||
$totalPrice = 0.00;
|
|
||||||
|
|
||||||
//Get the rows from the database for each character and the requirement of not been invoiced yet
|
|
||||||
$rows = Ledger::where([
|
|
||||||
'character_id' => $charId,
|
|
||||||
'invoiced' => 'No',
|
|
||||||
])->get()->toArray();
|
|
||||||
|
|
||||||
var_dump($rows);
|
|
||||||
|
|
||||||
//Taly up the item composition from each row and multiply by the quantity
|
|
||||||
foreach($rows as $row) {
|
|
||||||
if(!isset($ores[$row['type_id']])) {
|
|
||||||
$ores[$row['type_id']] = 0;
|
|
||||||
}
|
|
||||||
$ores[$row['type_id']] = $ores[$row['type_id']] + $row['quantity'];
|
|
||||||
|
|
||||||
//Add up the total price from the ledger rows for the report later
|
|
||||||
$totalPrice = $totalPrice + $row['amount'];
|
|
||||||
}
|
|
||||||
|
|
||||||
//Reduce the total price by the take percentage
|
|
||||||
$invoiceAmount = $totalPrice * 0.10;
|
|
||||||
$invoiceAmount = round($invoiceAmount, 2);
|
|
||||||
|
|
||||||
//Get the character name from the character id
|
|
||||||
$charName = $lookup->CharacterIdToName($charId);
|
|
||||||
|
|
||||||
//Generate a unique invoice id
|
|
||||||
$invoiceId = uniqid();
|
|
||||||
|
|
||||||
//Save the invoice model
|
|
||||||
$invoice = new Invoice;
|
|
||||||
$invoice->character_id = $charId;
|
|
||||||
$invoice->character_name = $charName;
|
|
||||||
$invoice->invoice_id = $invoiceId;
|
|
||||||
$invoice->invoice_amount = $invoiceAmount;
|
|
||||||
$invoice->date_issued = Carbon::now();
|
|
||||||
$invoice->date_due = Carbon::now()->addDays(7);
|
|
||||||
$invoice->status = 'Pending';
|
|
||||||
$invoice->save();
|
|
||||||
|
|
||||||
//Update the ledger entries
|
|
||||||
Ledger::where([
|
|
||||||
'character_id' => $charId,
|
|
||||||
'invoiced' => 'No',
|
|
||||||
])->update([
|
|
||||||
'invoiced' => 'Yes',
|
|
||||||
'invoice_id' => $invoiceId,
|
|
||||||
]);
|
|
||||||
|
|
||||||
//Create the mail body
|
|
||||||
$body .= "Dear Miner,<br><br>";
|
|
||||||
$body .= "Mining Taxes are due for the following ores mined from alliance moons: <br>";
|
|
||||||
foreach($ores as $ore => $quantity) {
|
|
||||||
$oreName = $lookup->ItemIdToName($ore);
|
|
||||||
$body .= $oreName . ": " . number_format(round($quantity * $config['mining_tax']), 0, ".", ",") . "<br>";
|
|
||||||
}
|
|
||||||
$body .= "Please remit " . number_format($totalPrice, 2, ".", ",") . " ISK to Spatial Forces by " . $invoice->date_due . "<br>";
|
|
||||||
$body .= "Set the reason for transfer as MMT: " . $invoice->invoice_id . "<br>";
|
|
||||||
$body .= "<br><br>";
|
|
||||||
$body .= "You can also send a contract with the following ores in the contract with the reason set as MMT: " . $invoice->invoice_id . "<br>";
|
|
||||||
foreach($ores as $ore => $quantity) {
|
|
||||||
$oreName = $lookup->ItemIdToName($ore);
|
|
||||||
$body .= $oreName . ": " . number_format(round($quantity * $config['mining_tax']), ".", ",") . "<br>";
|
|
||||||
}
|
|
||||||
$body .= "<br>";
|
|
||||||
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
|
|
||||||
|
|
||||||
//Mail the invoice to the character if the character is in
|
|
||||||
//Warped Intentions or Legacy
|
|
||||||
$subject = 'Warped Intentions Mining Taxes';
|
|
||||||
$sender = $config['primary'];
|
|
||||||
$recipientType = 'character';
|
|
||||||
$recipient = $charId;
|
|
||||||
|
|
||||||
//Send the Eve Mail Job to the queue to be dispatched
|
|
||||||
ProcessSendEveMailJob::dispatch($body, $recipient, $recipientType, $subject, $sender)->onQueue('mail');
|
|
||||||
}
|
|
||||||
|
|
||||||
//Set the task as stopped
|
|
||||||
$task->SetStopStatus();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands\MiningTaxes;
|
|
||||||
|
|
||||||
//Internal Library
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Log;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
//Application Library
|
|
||||||
use Commands\Library\CommandHelper;
|
|
||||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
|
||||||
use App\Library\Esi\Esi;
|
|
||||||
use App\Library\Helpers\LookupHelper;
|
|
||||||
use App\Library\Moons\MoonCalc;
|
|
||||||
|
|
||||||
//Models
|
|
||||||
use App\Models\MiningTax\Observer;
|
|
||||||
use App\Models\MiningTax\Ledger;
|
|
||||||
use App\Models\Moon\MineralPrice;
|
|
||||||
use App\Models\Moon\ItemComposition;
|
|
||||||
use App\Models\Esi\EsiToken;
|
|
||||||
use App\Models\Esi\EsiScope;
|
|
||||||
|
|
||||||
//Jobs
|
|
||||||
//use App\Jobs\Commands\MiningTaxes\FetchMiningTaxesLedgersJob;
|
|
||||||
|
|
||||||
class MiningTaxesLedgers extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'MiningTax:Ledgers';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Start getting the mining ledgers.';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
//Create the command helper container
|
|
||||||
$task = new CommandHelper('MiningTaxesLedger');
|
|
||||||
//Set the task as started
|
|
||||||
$task->SetStartStatus();
|
|
||||||
|
|
||||||
//Get the site configuration which holds some data we need
|
|
||||||
$config = config('esi');
|
|
||||||
//Get the observers from the database
|
|
||||||
$observers = Observer::all();
|
|
||||||
//Job Variables to be moved later
|
|
||||||
$esiHelper = new Esi;
|
|
||||||
$lookup = new LookupHelper;
|
|
||||||
$mHelper = new MoonCalc;
|
|
||||||
$esiHelper = new Esi;
|
|
||||||
/*
|
|
||||||
//For each of the observers, send a job to fetch the mining ledger
|
|
||||||
foreach($observers as $obs) {
|
|
||||||
//Dispatch the mining taxes ledger jobs
|
|
||||||
FetchMiningTaxesLedgersJob::dispatch($config['primary'], $config['corporation'], $obs->observer_id)->onQueue('miningtaxes');
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
|
||||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
|
||||||
|
|
||||||
foreach($observers as $obs) {
|
|
||||||
try {
|
|
||||||
$response = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/{observer_id}/', [
|
|
||||||
'corporation_id' => $config['corporation'],
|
|
||||||
'observer_id' => $obs->observer_id,
|
|
||||||
]);
|
|
||||||
} catch(RequestFailedException $e) {
|
|
||||||
Log::warning('Failed to get the mining ledger in FetchMiningTaxesLedgersCommand for observer id: ' . $this->observerId);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$ledgers = json_decode($response->raw);
|
|
||||||
|
|
||||||
foreach($ledgers as $ledger) {
|
|
||||||
//Get some basic information we need to work with
|
|
||||||
$charName = $lookup->CharacterIdToName($ledger->character_id);
|
|
||||||
//Get the type name from the ledger ore stuff
|
|
||||||
$typeName = $lookup->ItemIdToName($ledger->type_id);
|
|
||||||
//Get the price from the helper function
|
|
||||||
$price = $mHelper->CalculateOrePrice($ledger->type_id);
|
|
||||||
//Calculate the total price based on the amount
|
|
||||||
$amount = $price * $ledger->quantity;
|
|
||||||
|
|
||||||
//Insert or update the entry in the database
|
|
||||||
$item = Ledger::updateOrCreate([
|
|
||||||
'character_id' => $ledger->character_id,
|
|
||||||
'character_name' => $charName,
|
|
||||||
'observer_id' => $obs->observer_id,
|
|
||||||
'last_updated' => $ledger->last_updated,
|
|
||||||
'type_id' => $ledger->type_id,
|
|
||||||
'ore_name' => $typeName,
|
|
||||||
'quantity' => $ledger->quantity,
|
|
||||||
'amount' => $amount,
|
|
||||||
], [
|
|
||||||
'character_id' => $ledger->character_id,
|
|
||||||
'character_name' => $charName,
|
|
||||||
'observer_id' => $obs->observer_id,
|
|
||||||
'last_updated' => $ledger->last_updated,
|
|
||||||
'type_id' => $ledger->type_id,
|
|
||||||
'ore_name' => $typeName,
|
|
||||||
'quantity' => $ledger->quantity,
|
|
||||||
'amount' => $amount,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Clean up old data
|
|
||||||
//Ledger::where(['updated_at', '<', Carbon::now()->subDays(120)])->delete();
|
|
||||||
|
|
||||||
//Return 0
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands\MiningTaxes;
|
|
||||||
|
|
||||||
//Internal Library
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Log;
|
|
||||||
use Commands\Library\CommandHelper;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
//Application Library
|
|
||||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
|
||||||
use App\Library\Esi\Esi;
|
|
||||||
use App\Library\Helpers\LookupHelper;
|
|
||||||
|
|
||||||
//App Models
|
|
||||||
use App\Models\MiningTax\Observer;
|
|
||||||
|
|
||||||
//Jobs
|
|
||||||
use App\Jobs\Commands\MiningTaxes\FetchMiningTaxesObserversJob;
|
|
||||||
|
|
||||||
class MiningTaxesObservers extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'MiningTax:Observer';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Get mining tax observers.';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
//Create the command helper container
|
|
||||||
$task = new CommandHelper('MiningTaxesObservers');
|
|
||||||
//Set the task as started
|
|
||||||
$task->SetStartStatus();
|
|
||||||
$startTime = time();
|
|
||||||
|
|
||||||
//Declare variables
|
|
||||||
$config = config('esi');
|
|
||||||
$lookup = new LookupHelper;
|
|
||||||
$esiHelper = new Esi;
|
|
||||||
|
|
||||||
//Check for the esi scope
|
|
||||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1')) {
|
|
||||||
Log::critical('Esi scopes were not found for FetchMiningTaxesObserversJob.');
|
|
||||||
print("Esi scopes not found.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$char = $lookup->GetCharacterInfo($config['primary']);
|
|
||||||
|
|
||||||
//Get the refresh token for the character
|
|
||||||
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
|
||||||
//Get the esi variable
|
|
||||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$response = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/', [
|
|
||||||
'corporation_id' => $char->corporation_id,
|
|
||||||
]);
|
|
||||||
} catch(RequestFailedException $e) {
|
|
||||||
Log::critical("Failed to get moon observers in FetchMiningTaxesObservers");
|
|
||||||
Log::critical($e);
|
|
||||||
dd($e);
|
|
||||||
}
|
|
||||||
|
|
||||||
$resp = json_decode($response->raw, false);
|
|
||||||
|
|
||||||
//Run through the mining observers, and add them to the database
|
|
||||||
foreach($resp as $observer) {
|
|
||||||
|
|
||||||
Observer::updateOrInsert([
|
|
||||||
'observer_id' => $observer->observer_id,
|
|
||||||
], [
|
|
||||||
'observer_id' => $observer->observer_id,
|
|
||||||
'observer_type' => $observer->observer_type,
|
|
||||||
'last_updated' => $observer->last_updated,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cleanup stale data that hasn't been updated in at least 1 week.
|
|
||||||
*/
|
|
||||||
$date = Carbon::now()->subDays(60);
|
|
||||||
Observer::where('last_updated', '<', $date)->delete();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$task->SetStopStatus();
|
|
||||||
$endTime = time();
|
|
||||||
printf("Time to complete: " . ($endTime - $startTime) . "\n\r");
|
|
||||||
|
|
||||||
//Return 0 saying everything is fine
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,152 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands\MiningTaxes;
|
|
||||||
|
|
||||||
//Internal Library
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Log;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
//Application Library
|
|
||||||
use Commands\Library\CommandHelper;
|
|
||||||
use App\Library\Lookup\LookupHelper;
|
|
||||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
|
||||||
use App\Library\Esi\Esi;
|
|
||||||
|
|
||||||
//Models
|
|
||||||
use App\Models\MiningTaxes\Invoice;
|
|
||||||
use App\Models\MiningTaxes\Payment;
|
|
||||||
use App\Models\Finances\PlayerDonationJournal;
|
|
||||||
|
|
||||||
//Jobs
|
|
||||||
use App\Jobs\Commands\MiningTaxes\ProcessMiningTaxesPaymentsJob;
|
|
||||||
|
|
||||||
class MiningTaxesPayments extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'MiningTax:Payments';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Process mining tax payments';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
//Create the command helper container
|
|
||||||
$task = new CommandHelper('MiningTaxesPayments');
|
|
||||||
//Set the task as started
|
|
||||||
$task->SetStartStatus();
|
|
||||||
|
|
||||||
//Declare variables for the function
|
|
||||||
$lookup = new LookupHelper;
|
|
||||||
$currentTime = Carbon::now();
|
|
||||||
$config = config('esi');
|
|
||||||
$esiHelper = new Esi;
|
|
||||||
|
|
||||||
//Check for the esi scope
|
|
||||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-contracts.read_corporation_contracts.v1')) {
|
|
||||||
Log::critical('Esi scopes were not found for MiningTaxesPayments');
|
|
||||||
print("Esi scope not found.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Get the refresh token
|
|
||||||
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
|
||||||
//Get the esi variable
|
|
||||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
|
||||||
|
|
||||||
//Get all of the contracts from esi
|
|
||||||
try {
|
|
||||||
$response = $esi->invoke('get', '/corporations/{corporation_id}/contracts/', [
|
|
||||||
'corporation_id' => $config['corporation'],
|
|
||||||
]);
|
|
||||||
} catch(RequestFailedException $e) {
|
|
||||||
Log::critical("Failed to get contrcts in MiningTaxesPayments command.");
|
|
||||||
Log::critical($e);
|
|
||||||
dd($e);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Decode the contracts from the json response
|
|
||||||
$contracts = json_decode($response->raw, false);
|
|
||||||
|
|
||||||
//Get the outstanding invoices
|
|
||||||
$outstanding = Invoice::where([
|
|
||||||
'status' => 'Pending',
|
|
||||||
])->get();
|
|
||||||
|
|
||||||
//Use the player donation and the journal in order to check over the pending contracts to attempt
|
|
||||||
//to pay the contract
|
|
||||||
foreach($outstanding as $invoice) {
|
|
||||||
//See if we have a reason with the correct uniqid from the player donation journal
|
|
||||||
$found = PlayerDonationJournal::where([
|
|
||||||
'reason' => "MMT: " . $invoice->invoice_id,
|
|
||||||
])->count();
|
|
||||||
|
|
||||||
if($found == 1) {
|
|
||||||
//If the bill is paid on time, then update the invoice as such
|
|
||||||
if($currentTime->lessThanOrEqualTo($invoice->due_date)) {
|
|
||||||
Invoice::where([
|
|
||||||
'invoice_id' => $invoice->invoice_id,
|
|
||||||
])->update([
|
|
||||||
'status' => 'Paid',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//If the bill is paid late, then update the invoice as such
|
|
||||||
if($currentTime->greaterThan($invoice->due_date)) {
|
|
||||||
Invoice::where([
|
|
||||||
'invoice_id' => $invoice->invoice_id,
|
|
||||||
])->update([
|
|
||||||
'status' => 'Paid Late',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//If we didn't found a journal entry, then we shall check the contracts for a correct entry
|
|
||||||
foreach($contracts as $contract) {
|
|
||||||
if(($contract->title == ("MMT: " . $invoice->invoice_id)) && ($currentTime->lessThanOrEqualTo($invoice->due_date))) {
|
|
||||||
Invoice::where([
|
|
||||||
'invoice_i' => $invoice->invoice_id,
|
|
||||||
])->update([
|
|
||||||
'stauts' => 'Paid'
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(($contract->title == ("MMT: " . $invoice_id)) && ($currentTime->greaterThan($invoice->due_date))) {
|
|
||||||
Invoice::where([
|
|
||||||
'invoice_id' => $invoice->invoice_id,
|
|
||||||
])->update([
|
|
||||||
'status' => 'Paid Late',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Set the task as stopped
|
|
||||||
$task->SetStopStatus();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class ExecuteSendMoonRentalInvoices extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'mr:invoice';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Execute command to send moon rental invoices job';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands\MoonRental;
|
||||||
|
|
||||||
|
//Application Library
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Log;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use App\Library\Moons\MoonCalc;
|
||||||
|
use App\Library\Helpers\LookupHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\MoonRental\AllianceMoon;
|
||||||
|
use App\Models\MoonRental\AllianceMoonOre;
|
||||||
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\Commands\MoonRental\UpdateAllianceMoonRentalWorth;
|
||||||
|
|
||||||
|
class ExecuteUpdateAllianceMoonRentalWorth extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'mr:worth';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Update alliance moon rental worth.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
UpdateAllianceMoonRentalWorth::dispatch();
|
||||||
|
|
||||||
|
/*
|
||||||
|
//Declare variables
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$mHelper = new MoonCalc;
|
||||||
|
$months = 3;
|
||||||
|
$rentalTax = 0.25;
|
||||||
|
|
||||||
|
$moons = AllianceMoon::all();
|
||||||
|
|
||||||
|
foreach($moons as $moon) {
|
||||||
|
//Declare the arrays needed
|
||||||
|
$ores = array();
|
||||||
|
$worth = 0.00;
|
||||||
|
|
||||||
|
$ores = AllianceMoonOre::where([
|
||||||
|
'moon_id' => $moon->moon_id,
|
||||||
|
])->get(['ore_name', 'quantity'])->toArray();
|
||||||
|
|
||||||
|
if(sizeof($ores) == 1) {
|
||||||
|
$ores[1]["ore_name"] = null;
|
||||||
|
$ores[1]["quantity"] = 0.00;
|
||||||
|
$ores[2]["ore_name"] = null;
|
||||||
|
$ores[2]["quantity"] = 0.00;
|
||||||
|
$ores[3]["ore_name"] = null;
|
||||||
|
$ores[3]["quantity"] = 0.00;
|
||||||
|
} else if(sizeof($ores) == 2) {
|
||||||
|
$ores[2]["ore_name"] = null;
|
||||||
|
$ores[2]["quantity"] = 0.00;
|
||||||
|
$ores[3]["ore_name"] = null;
|
||||||
|
$ores[3]["quantity"] = 0.00;
|
||||||
|
} else if(sizeof($ores) == 3) {
|
||||||
|
$ores[3]["ore_name"] = null;
|
||||||
|
$ores[3]["quantity"] = 0.00;
|
||||||
|
}
|
||||||
|
|
||||||
|
//one of these two ways will work
|
||||||
|
$worth = $mHelper->MoonTotalWorth($ores[0]["ore_name"], $ores[0]["quantity"],
|
||||||
|
$ores[1]["ore_name"], $ores[1]["quantity"],
|
||||||
|
$ores[2]["ore_name"], $ores[2]["quantity"],
|
||||||
|
$ores[3]["ore_name"], $ores[3]["quantity"]);
|
||||||
|
|
||||||
|
$rentalAmount = $worth * $rentalTax * $months;
|
||||||
|
|
||||||
|
AllianceMoon::where([
|
||||||
|
'moon_id' => $moon->moon_id,
|
||||||
|
])->update([
|
||||||
|
'worth_amount' => $worth,
|
||||||
|
'rental_amount' => $rentalAmount,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands\Structures;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
use App\Jobs\Commands\Assets\FetchAllianceAssets as FAA;
|
||||||
|
|
||||||
|
class ExecuteFetchAllianceAssetsCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'structure:assets';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Execute fetch alliance command.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
FAA::dispatch();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,24 +4,23 @@ namespace App\Console\Commands\Structures;
|
|||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
//Job
|
use App\Jobs\Commands\Structures\FetchAllianceStructures as FAS;
|
||||||
use App\Jobs\Commands\Structures\ProcessStructureJob;
|
|
||||||
|
|
||||||
class GetStructuresCommand extends Command
|
class ExecuteFetchAllianceStructuresCommand extends Command
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The name and signature of the console command.
|
* The name and signature of the console command.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'services:GetStructures';
|
protected $signature = 'structure:structure';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $description = 'Get the list of structures ';
|
protected $description = 'Fetch alliance structures command.';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new command instance.
|
* Create a new command instance.
|
||||||
@@ -36,18 +35,12 @@ class GetStructuresCommand extends Command
|
|||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
//Get the esi config
|
FAS::dispatch();
|
||||||
$config = config('esi');
|
|
||||||
|
|
||||||
//Declare some variables
|
return 0;
|
||||||
$charId = $config['primary'];
|
|
||||||
$corpId = 98287666;
|
|
||||||
|
|
||||||
//Dispatch the job to be done when the application has time
|
|
||||||
ProcessStructureJob::dispatch($charId, $corpId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
42
app/Console/Commands/TestCommand.php
Normal file
42
app/Console/Commands/TestCommand.php
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class TestCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'command:name';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Command description';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,8 +6,21 @@ namespace App\Console;
|
|||||||
use Illuminate\Console\Scheduling\Schedule;
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||||
|
|
||||||
//Library
|
//Jobs
|
||||||
use Commands\Library\CommandHelper;
|
use App\Jobs\Commands\MiningTaxes\PreFetchMiningTaxesLedgers;
|
||||||
|
use App\Jobs\Commands\MiningTaxes\FetchMiningTaxesObservers;
|
||||||
|
use App\Jobs\Commands\MiningTaxes\ProcessMiningTaxesPayments;
|
||||||
|
use App\Jobs\Commands\MiningTaxes\Invoices\UpdateMiningTaxesLateInvoices1st;
|
||||||
|
use App\Jobs\Commands\MiningTaxes\Invoices\UpdateMiningTaxesLateInvoices15th;
|
||||||
|
use App\Jobs\Commands\MiningTaxes\MiningTaxesWeeklyInvoicing;
|
||||||
|
use App\Jobs\Commands\Finances\UpdateAllianceWalletJournalJob;
|
||||||
|
use App\Jobs\Commands\Finances\UpdateItemPrices as UpdateItemPricesJob;
|
||||||
|
use App\Jobs\Commands\Data\PurgeUsers as PurgeUsersJob;
|
||||||
|
use App\Jobs\Commands\Structures\FetchAllianceStructures;
|
||||||
|
use App\Jobs\Commands\Structures\PurgeAllianceStructures;
|
||||||
|
use App\Jobs\Commands\Assets\FetchAllianceAssets;
|
||||||
|
use App\Jobs\Commands\Assets\PurgeAllianceAssets;
|
||||||
|
use App\Jobs\Commands\MoonRental\UpdateAllianceMoonRentalWorth as UpdateAMRW;
|
||||||
|
|
||||||
class Kernel extends ConsoleKernel
|
class Kernel extends ConsoleKernel
|
||||||
{
|
{
|
||||||
@@ -17,28 +30,18 @@ class Kernel extends ConsoleKernel
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $commands = [
|
protected $commands = [
|
||||||
/**
|
|
||||||
* Data Commands
|
|
||||||
*/
|
|
||||||
Commands\Data\PurgeUsers::class,
|
Commands\Data\PurgeUsers::class,
|
||||||
Commands\Data\EmptyJumpBridges::class,
|
|
||||||
Commands\Data\CleanStaleDataCommand::class,
|
|
||||||
Commands\Data\Test::class,
|
Commands\Data\Test::class,
|
||||||
/**
|
|
||||||
* Eve Commands
|
|
||||||
*/
|
|
||||||
Commands\Eve\ItemPricesUpdateCommand::class,
|
Commands\Eve\ItemPricesUpdateCommand::class,
|
||||||
/**
|
|
||||||
* Finance Commands
|
|
||||||
*/
|
|
||||||
Commands\Finances\UpdateAllianceWalletJournal::class,
|
Commands\Finances\UpdateAllianceWalletJournal::class,
|
||||||
/**
|
Commands\MiningTaxes\ExecuteMiningTaxesObserversCommand::class,
|
||||||
* Mining Tax Commands
|
Commands\MiningTaxes\ExecuteMiningTaxesLedgersCommand::class,
|
||||||
*/
|
Commands\MiningTaxes\ExecuteSendMiningTaxesInvoiceCommand::class,
|
||||||
Commands\MiningTaxes\MiningTaxesInvoices::class,
|
Commands\MiningTaxes\ExecuteProcesssMiningTaxesPaymentsCommand::class,
|
||||||
Commands\MiningTaxes\MiningTaxesLedgers::class,
|
Commands\Structures\ExecuteFetchAllianceStructuresCommand::class,
|
||||||
Commands\MiningTaxes\MiningTaxesObservers::class,
|
Commands\Structures\ExecuteFetchAllianceAssetsCommand::class,
|
||||||
Commands\MiningTaxes\MiningTaxesPayments::class,
|
Commands\Files\ImportAllianceMoons::class,
|
||||||
|
Commands\MoonRental\ExecuteUpdateAllianceMoonRentalWorth::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,50 +52,74 @@ class Kernel extends ConsoleKernel
|
|||||||
*/
|
*/
|
||||||
protected function schedule(Schedule $schedule)
|
protected function schedule(Schedule $schedule)
|
||||||
{
|
{
|
||||||
|
//Schedule Monitor Jobs
|
||||||
|
$schedule->command('schedule-monitor:sync')->dailyAt('04:56');
|
||||||
|
$schedule->command('schedule-monitor:clean')->daily();
|
||||||
|
|
||||||
//Horizon Graph Schedule
|
//Horizon Graph Schedule
|
||||||
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purge Data Schedule
|
* Purge Data Schedule
|
||||||
*/
|
*/
|
||||||
$schedule->command('data:CleanData')
|
$schedule->job(new PurgeUsersJob)
|
||||||
->weekly(7, '11:00');
|
->weekly();
|
||||||
$schedule->command('data:PurgeCorpLedgers')
|
|
||||||
->monthly();
|
|
||||||
$schedule->command('data:PurgeUsers')
|
|
||||||
->dailyAt('23:00');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finances Update Schedule
|
* Finances Update Schedule
|
||||||
*/
|
*/
|
||||||
$schedule->command('finances:UpdateJournals')
|
$schedule->job(new UpdateAllianceWalletJournalJob)
|
||||||
->hourlyAt('45')
|
->hourlyAt('45')
|
||||||
->withoutOverlapping();
|
->withoutOverlapping();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Item Update Schedule
|
* Item Update Schedule
|
||||||
*/
|
*/
|
||||||
$schedule->command('services:ItemPriceUpdate')
|
$schedule->job(new UpdateItemPricesJob)
|
||||||
->hourlyAt('30')
|
->hourlyAT('30')
|
||||||
->withoutOverlapping();
|
->withoutOverlapping();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mining Tax Schedule
|
* Mining Tax Schedule
|
||||||
*/
|
*/
|
||||||
$schedule->command('MiningTaxes:Observers')
|
$schedule->job(new FetchMiningTaxesObservers)
|
||||||
->dailyAt('22:00')
|
|
||||||
->withoutOverlapping();
|
|
||||||
$schedule->command('MiningTaxes:Ledgers')
|
|
||||||
->dailyAt('20:00')
|
->dailyAt('20:00')
|
||||||
->withoutOverlapping();
|
->withoutOverlapping();
|
||||||
/*
|
$schedule->job(new PreFetchMiningTaxesLedgers)
|
||||||
$schedule->command('MiningTaxes:Invoices')
|
->dailyAt('22:00')
|
||||||
->weeklyOn(1, '8:00')
|
|
||||||
->withoutOverlapping();
|
->withoutOverlapping();
|
||||||
$schedule->command('MiningTaxes:Payments')
|
$schedule->job(new MiningTaxesWeeklyInvoicing)
|
||||||
|
->weeklyOn(1, '06:00')
|
||||||
|
->withoutOverlapping();
|
||||||
|
$schedule->job(new ProcessMiningTaxesPayments)
|
||||||
->hourlyAt('15')
|
->hourlyAt('15')
|
||||||
->withoutOverlapping();
|
->withoutOverlapping();
|
||||||
*/
|
$schedule->job(new UpdateMiningTaxesLateInvoices1st)
|
||||||
|
->monthlyOn(1, '16:00')
|
||||||
|
->withoutOverlapping();
|
||||||
|
$schedule->job(new UpdateMiningTaxesLateInvoices15th)
|
||||||
|
->monthlyOn(15, '16:00')
|
||||||
|
->withoutOverlapping();
|
||||||
|
$schedule->job(new UpdateAMRW)
|
||||||
|
->dailyAt('13:00')
|
||||||
|
->withoutOverlapping();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alliance Structure and Assets Schedule
|
||||||
|
*/
|
||||||
|
$schedule->job(new FetchAllianceStructures)
|
||||||
|
->dailyAt('21:00')
|
||||||
|
->withoutOverlapping();
|
||||||
|
$schedule->job(new FetchAllianceAssets)
|
||||||
|
->hourlyAt('15')
|
||||||
|
->withoutOverlapping();
|
||||||
|
$schedule->job(new PurgeAllianceStructures)
|
||||||
|
->monthlyOn(2, '14:00')
|
||||||
|
->withoutOverlapping();
|
||||||
|
$schedule->job(new PurgeAllianceAssets)
|
||||||
|
->monthlyOn(2, '15:00')
|
||||||
|
->withoutOverlapping();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -106,4 +133,14 @@ class Kernel extends ConsoleKernel
|
|||||||
|
|
||||||
require base_path('routes/console.php');
|
require base_path('routes/console.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the timezone that should be used by default for scheduled events.
|
||||||
|
*
|
||||||
|
* @return \DateTimeZone|string|null
|
||||||
|
*/
|
||||||
|
protected function scheduleTimezone()
|
||||||
|
{
|
||||||
|
return 'UTC';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ namespace App\Http\Controllers\AfterActionReports;
|
|||||||
//Internal Library
|
//Internal Library
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
//Models
|
//Models
|
||||||
use App\Models\AfterActionReports\Report;
|
use App\Models\AfterActionReports\AfterActionReport;
|
||||||
use App\Models\AfterActionReports\Comment;
|
use App\Models\AfterActionReports\AfterActionReportComment;
|
||||||
|
|
||||||
class AfterActionReportsController extends Controller
|
class AfterActionReportsController extends Controller
|
||||||
{
|
{
|
||||||
@@ -18,18 +19,69 @@ class AfterActionReportsController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function DisplayReportForm() {
|
public function DisplayReportForm() {
|
||||||
//
|
return view('reports.user.form.report');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function StoreReport() {
|
public function StoreReport(Request $request) {
|
||||||
|
$this->validate($request, [
|
||||||
|
'location' => 'required',
|
||||||
|
'time' => 'required',
|
||||||
|
'comms' => 'required',
|
||||||
|
'doctrine' => 'required',
|
||||||
|
'objective' => 'required',
|
||||||
|
'result' => 'required',
|
||||||
|
'summary' => 'required',
|
||||||
|
'improvements' => 'required',
|
||||||
|
'well' => 'required',
|
||||||
|
'comments' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$report = new AfterActionReport;
|
||||||
|
$report->fc_id = auth()->user()->getId();
|
||||||
|
$report->fc_name = auth()->user()->getName();
|
||||||
|
$report->formup_time = $request->time;
|
||||||
|
$report->formup_location = $request->location;
|
||||||
|
$report->comms = $request->comms;
|
||||||
|
$report->doctrine = $request->doctrine;
|
||||||
|
$report->objective = $request->objective;
|
||||||
|
$report->objective_result = $request->result;
|
||||||
|
$report->summary = $request->summary;
|
||||||
|
$report->improvements = $request->improvements;
|
||||||
|
$report->worked_well = $request->well;
|
||||||
|
$report->additonal_comments = $request->comments;
|
||||||
|
$report->save();
|
||||||
|
|
||||||
|
return redirect('/reports/display/all')->with('success', 'Added report to the database.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function StoreComment() {
|
public function DisplayCommentForm($id) {
|
||||||
|
return view('reports.user.form.comment')->with('id', $id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function StoreComment(Request $request) {
|
||||||
|
$this->validate($request, [
|
||||||
|
'reportId' => 'required',
|
||||||
|
'comments' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$comment = new AfterActionReportComment;
|
||||||
|
$comment->report_id = $request->reportId;
|
||||||
|
$comment->character_id = auth()->user()->getId();
|
||||||
|
$comment->character_name = auth()->user()->getName();
|
||||||
|
$comment->comments = $required->comments;
|
||||||
|
$comment->save();
|
||||||
|
|
||||||
|
return redirect('/reports/display/all')->with('success', 'Added comemnt to the report.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function DisplayAllReports() {
|
public function DisplayAllReports() {
|
||||||
|
//Grab all the reports
|
||||||
|
$reports = AfterActionReport::where('created_at', '>=', Carbon::now()->subDays(30));
|
||||||
|
$comments = AfterActionReportComment::where('created_at', '>=', Carbon::now()->subDays(30));
|
||||||
|
$reportCount = AfterActionReport::where('created_at', '>=', Carbon::now()->subDays(30))->count();
|
||||||
|
|
||||||
|
return view('reports.user.displayreports')->with('reports', $reports)
|
||||||
|
->with('comments', $comments)
|
||||||
|
->with('reportCount', $reportCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,8 @@ class LoginController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function redirectToProvider($profile = null, Socialite $social) {
|
public function redirectToProvider($profile = null, Socialite $social) {
|
||||||
//The default scope is public data for everyone due to OAuth2 Tokens
|
//The default scope is public data for everyone due to OAuth2 Tokens
|
||||||
$scopes = ['publicData'];
|
//We also add the send mail scope in order to be able to send mails more efficiently through jobs when other scopes are required.
|
||||||
|
$scopes = ['publicData', 'esi-mail.send_mail.v1'];
|
||||||
|
|
||||||
//Collect any other scopes we need if we are logged in.
|
//Collect any other scopes we need if we are logged in.
|
||||||
//If we are logged in we are linking another character to this one.
|
//If we are logged in we are linking another character to this one.
|
||||||
@@ -159,9 +160,14 @@ class LoginController extends Controller
|
|||||||
* @param \Laravel\Socialite\Two\User $user
|
* @param \Laravel\Socialite\Two\User $user
|
||||||
*/
|
*/
|
||||||
private function createAlt($user, $orgCharacter) {
|
private function createAlt($user, $orgCharacter) {
|
||||||
|
//Check to see if the alt is already in the database
|
||||||
|
$altCount = UserAlt::where(['character_id' => $user->id])->count();
|
||||||
|
|
||||||
$altCount = UserAlt::where('character_id', $user->id)->count();
|
//Check to see if the new character being added is already a main character
|
||||||
if($altCount == 0) {
|
$mainCount = User::where(['character_id' => $user->id])->count();
|
||||||
|
|
||||||
|
//If not already in the database, then add the new character
|
||||||
|
if($altCount == 0 && $mainCount == 0) {
|
||||||
//Create the new alt in the table
|
//Create the new alt in the table
|
||||||
$newAlt = new UserAlt;
|
$newAlt = new UserAlt;
|
||||||
$newAlt->name = $user->getName();
|
$newAlt->name = $user->getName();
|
||||||
@@ -174,7 +180,6 @@ class LoginController extends Controller
|
|||||||
$newAlt->expires_in = $user->expiresIn;
|
$newAlt->expires_in = $user->expiresIn;
|
||||||
$newAlt->save();
|
$newAlt->save();
|
||||||
|
|
||||||
//Create the entry into the EsiToken table
|
|
||||||
//Create the entry into the EsiToken table
|
//Create the entry into the EsiToken table
|
||||||
if(EsiToken::where(['character_id' => $user->id])->count() == 0) {
|
if(EsiToken::where(['character_id' => $user->id])->count() == 0) {
|
||||||
$this->SaveEsiToken($user);
|
$this->SaveEsiToken($user);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use App\Models\Contracts\SupplyChainBid;
|
|||||||
use App\Models\Contracts\SupplyChainContract;
|
use App\Models\Contracts\SupplyChainContract;
|
||||||
|
|
||||||
//Jobs
|
//Jobs
|
||||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
use App\Jobs\Commands\Eve\SendEveMail;
|
||||||
|
|
||||||
class SupplyChainController extends Controller
|
class SupplyChainController extends Controller
|
||||||
{
|
{
|
||||||
@@ -25,7 +25,7 @@ class SupplyChainController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->middleware('auth');
|
$this->middleware('auth');
|
||||||
$this->middleware('role:Renter');
|
$this->middleware('role:User');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,7 +454,7 @@ class SupplyChainController extends Controller
|
|||||||
$body .= "Notes: " . $contract->body . "<br>";
|
$body .= "Notes: " . $contract->body . "<br>";
|
||||||
$body .= "Delivery Date: " . $contract->delivery_date . "<br>";
|
$body .= "Delivery Date: " . $contract->delivery_date . "<br>";
|
||||||
$body .= "<br>Sincerely on behalf of,<br>" . $contract->issuer_name . "<br>";
|
$body .= "<br>Sincerely on behalf of,<br>" . $contract->issuer_name . "<br>";
|
||||||
ProcessSendEveMailJob::dispatch($body, 145223267, 'mailing_list', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(30));
|
SendEveMail::dispatch($body, 145223267, 'mailing_list', $subject, $config['primary'])->delay(Carbon::now()->addSeconds(30));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -469,7 +469,7 @@ class SupplyChainController extends Controller
|
|||||||
$body .= "Contract: " . $contract->title . "<br>";
|
$body .= "Contract: " . $contract->title . "<br>";
|
||||||
$body .= "Notes: " . $contract->note . "<br>";
|
$body .= "Notes: " . $contract->note . "<br>";
|
||||||
$body .= "<br>Sincerely on behalf of,<br>" . $contract->issuer_name;
|
$body .= "<br>Sincerely on behalf of,<br>" . $contract->issuer_name;
|
||||||
ProcessSendEveMailJob::dispatch($body, 145223267, 'mailing_list', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(30));
|
SendEveMail::dispatch($body, 145223267, 'mailing_list', $subject, $config['primary'])->delay(Carbon::now()->addSeconds(30));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,335 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Dashboard;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use DB;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
//Libraries
|
|
||||||
use App\Library\Helpers\TaxesHelper;
|
|
||||||
use App\Library\Helpers\LookupHelper;
|
|
||||||
use App\Library\Helpers\SRPHelper;
|
|
||||||
|
|
||||||
//Models
|
|
||||||
use App\Models\User\User;
|
|
||||||
use App\Models\User\UserRole;
|
|
||||||
use App\Models\User\UserPermission;
|
|
||||||
use App\Models\User\AvailableUserPermission;
|
|
||||||
use App\Models\User\AvailableUserRole;
|
|
||||||
use App\Models\Admin\AllowedLogin;
|
|
||||||
|
|
||||||
class AdminController extends Controller
|
|
||||||
{
|
|
||||||
public function __construct() {
|
|
||||||
$this->middleware('auth');
|
|
||||||
$this->middleware('role:Admin');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function displayTestAdminDashboard() {
|
|
||||||
return view('admin.dashboards.testdashboard');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function showJournalEntries() {
|
|
||||||
$dateInit = Carbon::now();
|
|
||||||
$date = $dateInit->subDays(30);
|
|
||||||
|
|
||||||
$journal = DB::select('SELECT amount,reason,description,date FROM `player_donation_journal` WHERE corporation_id=98287666 AND date >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 2 MONTH) ORDER BY date DESC');
|
|
||||||
|
|
||||||
return view('admin.dashboards.walletjournal')->with('journal', $journal);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function displayUsersPaginated() {
|
|
||||||
//Declare array variables
|
|
||||||
$user = array();
|
|
||||||
$permission = array();
|
|
||||||
$userArr = array();
|
|
||||||
$permString = null;
|
|
||||||
|
|
||||||
$usersArr = User::orderBy('name', 'asc')->paginate(50);
|
|
||||||
|
|
||||||
foreach($usersArr as $user) {
|
|
||||||
$user->role = $user->getRole();
|
|
||||||
|
|
||||||
$permCount = UserPermission::where([
|
|
||||||
'character_id' => $user->character_id,
|
|
||||||
])->count();
|
|
||||||
|
|
||||||
if($permCount > 0) {
|
|
||||||
$perms = UserPermission::where([
|
|
||||||
'character_id' => $user->character_id,
|
|
||||||
])->get('permission')->toArray();
|
|
||||||
|
|
||||||
foreach($perms as $perm) {
|
|
||||||
$permString .= $perm['permission'] . ', ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$user->permission = $permString;
|
|
||||||
} else {
|
|
||||||
$user->permission = 'No Permissions';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return view('admin.dashboards.userspaged')->with('usersArr', $usersArr);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function searchUsers(Request $request) {
|
|
||||||
//Declare array variables
|
|
||||||
$user = array();
|
|
||||||
$permission = array();
|
|
||||||
$userArr = array();
|
|
||||||
$permString = null;
|
|
||||||
|
|
||||||
//Validate the input from the form
|
|
||||||
$this->validate($request, [
|
|
||||||
'parameter' => 'required',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$usersArr = User::where('name', 'like', $request->parameter . "%")->paginate(50);
|
|
||||||
|
|
||||||
foreach($usersArr as $user) {
|
|
||||||
$user->role = $user->getRole();
|
|
||||||
|
|
||||||
$permCount = UserPermission::where([
|
|
||||||
'character_id' => $user->character_id,
|
|
||||||
])->count();
|
|
||||||
|
|
||||||
if($permCount > 0) {
|
|
||||||
$perms = UserPermission::where([
|
|
||||||
'character_id' => $user->character_id,
|
|
||||||
])->get('permission')->toArray();
|
|
||||||
|
|
||||||
foreach($perms as $perm) {
|
|
||||||
$permString .= $perm['permission'] . ', ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$user->permission = $permString;
|
|
||||||
} else {
|
|
||||||
$user->permission = 'No Permissions';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return view('admin.dashboards.users.searched')->with('usersArr', $usersArr);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function displayAllowedLogins() {
|
|
||||||
//Declare array variables
|
|
||||||
$entities = array();
|
|
||||||
|
|
||||||
/** Entities for allowed logins */
|
|
||||||
$legacys = AllowedLogin::where(['login_type' => 'Legacy'])->pluck('entity_name')->toArray();
|
|
||||||
$renters = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_name')->toArray();
|
|
||||||
//Compile a list of entities by their entity_id
|
|
||||||
foreach($legacys as $legacy) {
|
|
||||||
$entities[] = $legacy;
|
|
||||||
}
|
|
||||||
foreach($renters as $renter) {
|
|
||||||
$entities[] = $renter;
|
|
||||||
}
|
|
||||||
|
|
||||||
return view('admin.dashboards.allowed_logins')->with('entities', $entities);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function displayTaxes() {
|
|
||||||
//Declare variables needed for displaying items on the page
|
|
||||||
$months = 3;
|
|
||||||
$pi = array();
|
|
||||||
$industry = array();
|
|
||||||
$reprocessing = array();
|
|
||||||
$office = array();
|
|
||||||
$corpId = 98287666;
|
|
||||||
$srpActual = array();
|
|
||||||
$srpLoss = array();
|
|
||||||
|
|
||||||
/** Taxes Pane */
|
|
||||||
//Declare classes needed for displaying items on the page
|
|
||||||
$tHelper = new TaxesHelper();
|
|
||||||
$srpHelper = new SRPHelper();
|
|
||||||
//Get the dates for the tab panes
|
|
||||||
$dates = $tHelper->GetTimeFrameInMonths($months);
|
|
||||||
//Get the data for the Taxes Pane
|
|
||||||
foreach($dates as $date) {
|
|
||||||
//Get the srp actual pay out for the date range
|
|
||||||
$srpActual[] = [
|
|
||||||
'date' => $date['start']->toFormattedDateString(),
|
|
||||||
'gross' => number_format($srpHelper->GetAllianceSRPActual($date['start'], $date['end']), 2, ".", ","),
|
|
||||||
];
|
|
||||||
|
|
||||||
//Get the srp loss value for the date range
|
|
||||||
$srpLoss[] = [
|
|
||||||
'date' => $date['start']->toFormattedDateString(),
|
|
||||||
'gross' => number_format($srpHelper->GetAllianceSRPLoss($date['start'], $date['end']), 2, ".", ","),
|
|
||||||
];
|
|
||||||
|
|
||||||
//Get the pi taxes for the date range
|
|
||||||
$pis[] = [
|
|
||||||
'date' => $date['start']->toFormattedDateString(),
|
|
||||||
'gross' => number_format($tHelper->GetPIGross($date['start'], $date['end']), 2, ".", ","),
|
|
||||||
];
|
|
||||||
//Get the industry taxes for the date range
|
|
||||||
$industrys[] = [
|
|
||||||
'date' => $date['start']->toFormattedDateString(),
|
|
||||||
'gross' => number_format($tHelper->GetIndustryGross($date['start'], $date['end']), 2, ".", ","),
|
|
||||||
];
|
|
||||||
//Get the reprocessing taxes for the date range
|
|
||||||
$reprocessings[] = [
|
|
||||||
'date' => $date['start']->toFormattedDateString(),
|
|
||||||
'gross' => number_format($tHelper->GetReprocessingGross($date['start'], $date['end']), 2, ".", ","),
|
|
||||||
];
|
|
||||||
//Get the office taxes for the date range
|
|
||||||
$offices[] = [
|
|
||||||
'date' => $date['start']->toFormattedDateString(),
|
|
||||||
'gross' => number_format($tHelper->GetOfficeGross($date['start'], $date['end']), 2, ".", ","),
|
|
||||||
];
|
|
||||||
//Get the market taxes for the date range
|
|
||||||
$markets[] = [
|
|
||||||
'date' => $date['start']->toFormattedDateString(),
|
|
||||||
'gross' => number_format($tHelper->GetAllianceMarketGross($date['start'], $date['end']), 2, ".", ","),
|
|
||||||
];
|
|
||||||
//Get the jump gate taxes for the date range
|
|
||||||
$jumpgates[] = [
|
|
||||||
'date' => $date['start']->toFormattedDateString(),
|
|
||||||
'gross' => number_format($tHelper->GetJumpGateGross($date['start'], $date['end']), 2, ".", ","),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return view('admin.dashboards.taxes')->with('pis', $pis)
|
|
||||||
->with('industrys', $industrys)
|
|
||||||
->with('offices', $offices)
|
|
||||||
->with('markets', $markets)
|
|
||||||
->with('jumpgates', $jumpgates)
|
|
||||||
->with('reprocessings', $reprocessings)
|
|
||||||
->with('srpActual', $srpActual)
|
|
||||||
->with('srpLoss', $srpLoss);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function displayModifyUser(Request $request) {
|
|
||||||
$permissions = array();
|
|
||||||
|
|
||||||
$name = $request->user;
|
|
||||||
|
|
||||||
//Get the user information from the name
|
|
||||||
$user = User::where(['name' => $name])->first();
|
|
||||||
|
|
||||||
$perms = AvailableUserPermission::all();
|
|
||||||
foreach($perms as $p) {
|
|
||||||
$permissions[$p->permission] = $p->permission;
|
|
||||||
}
|
|
||||||
|
|
||||||
$roles = AvailableUserRole::all();
|
|
||||||
|
|
||||||
$role = $user->getRole();
|
|
||||||
|
|
||||||
//Pass the user information to the page for hidden text entries
|
|
||||||
return view('admin.user.modify')->with('user', $user)
|
|
||||||
->with('permissions', $permissions)
|
|
||||||
->with('role', $role)
|
|
||||||
->with('roles', $roles);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function modifyRole(Request $request) {
|
|
||||||
$this->validate($request, [
|
|
||||||
'user' => 'required',
|
|
||||||
'role' => 'required|role!=None',
|
|
||||||
]);
|
|
||||||
|
|
||||||
UserRole::where(['character_id' => $user])->update([
|
|
||||||
'role' => $request->role,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return redirect('/admin/dashboard/users')->with('success', "User: " . $user . " has been modified to a new role: " . $request->role . ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addPermission(Request $request) {
|
|
||||||
//Get the user and permission from the form
|
|
||||||
$character = $request->user;
|
|
||||||
$permission = $request->permission;
|
|
||||||
|
|
||||||
//Check to see if the character already has the permission
|
|
||||||
$check = UserPermission::where(['character_id' => $character, 'permission' => $permission])->get(['permission']);
|
|
||||||
|
|
||||||
if(!isset($check[0]->permission)) {
|
|
||||||
$perm = new UserPermission;
|
|
||||||
$perm->character_id = $character;
|
|
||||||
$perm->permission = $permission;
|
|
||||||
$perm->save();
|
|
||||||
|
|
||||||
return redirect('/admin/dashboard/users')->with('success', 'User udpated!');
|
|
||||||
} else {
|
|
||||||
return redirect('/admin/dashboard/users')->with('error', 'User not updated or already has the permission.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeUser(Request $request) {
|
|
||||||
//Get the user from the form to delete
|
|
||||||
$user = $request->user;
|
|
||||||
|
|
||||||
//Get the user data from the table
|
|
||||||
$data = User::where(['name' => $user])->get();
|
|
||||||
|
|
||||||
//Delete the user's ESI Scopes
|
|
||||||
DB::table('EsiScopes')->where(['character_id' => $data[0]->character_id])->delete();
|
|
||||||
|
|
||||||
//Delete the user's ESI Token
|
|
||||||
DB::table('EsiTokens')->where(['character_id' => $data[0]->character_id])->delete();
|
|
||||||
|
|
||||||
//Delete the user's role from the roles table
|
|
||||||
DB::table('user_roles')->where(['character_id' => $data[0]->character_id])->delete();
|
|
||||||
|
|
||||||
//Delete the user from the user table
|
|
||||||
DB::table('users')->where(['character_id' => $data[0]->character_id])->delete();
|
|
||||||
|
|
||||||
return redirect('/admin/dashboard/users')->with('success', 'User deleted from the site.');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addAllowedLogin(Request $request) {
|
|
||||||
//Set the parameters to validate the form
|
|
||||||
$this->validate($request, [
|
|
||||||
'allowedEntityId' => 'required',
|
|
||||||
'allowedEntityType' => 'required',
|
|
||||||
'allowedEntityName' => 'required',
|
|
||||||
'allowedLoginType' => 'required',
|
|
||||||
]);
|
|
||||||
|
|
||||||
//Check to see if the entity exists in the database already
|
|
||||||
$found = AllowedLogin::where([
|
|
||||||
'entity_type' => $request->allowedentityType,
|
|
||||||
'entity_name' => $request->allowedEntityName,
|
|
||||||
])->count();
|
|
||||||
if($found != 0) {
|
|
||||||
AllowedLogin::where([
|
|
||||||
'entity_type' => $request->allowedEntityType,
|
|
||||||
'entity_name' => $request->allowedEntityName,
|
|
||||||
])->update([
|
|
||||||
'entity_id' => $request->allowedEntityId,
|
|
||||||
'entity_type' => $request->allowedEntityType,
|
|
||||||
'entity_name' => $request->allowedEntityName,
|
|
||||||
'login_type' => $request->allowedLoginType,
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
$login = new AllowedLogin;
|
|
||||||
$login->entity_id = $request->allowedEntityId;
|
|
||||||
$login->entity_name = $request->allowedEntityName;
|
|
||||||
$login->entity_type = $request->allowedEntityType;
|
|
||||||
$login->login_type = $request->allowedLoginType;
|
|
||||||
$login->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
return redirect('/admin/dashboard')->with('success', 'Entity added to allowed login list.');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeAllowedLogin(Request $request) {
|
|
||||||
//Set the parameters to validate the form
|
|
||||||
$this->validate($request, [
|
|
||||||
'removeAllowedLogin' => 'required',
|
|
||||||
]);
|
|
||||||
|
|
||||||
AllowedLogin::where([
|
|
||||||
'entity_name' => $request->removeAllowedLogin,
|
|
||||||
])->delete();
|
|
||||||
|
|
||||||
return redirect('/admin/dashboard')->with('success', 'Entity removed from allowed login list.');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -15,7 +15,13 @@ use App\Library\Helpers\LookupHelper;
|
|||||||
use App\Library\Helpers\SRPHelper;
|
use App\Library\Helpers\SRPHelper;
|
||||||
|
|
||||||
//Models
|
//Models
|
||||||
|
use App\Models\User\User;
|
||||||
|
use App\Models\User\UserRole;
|
||||||
|
use App\Models\User\UserPermission;
|
||||||
|
use App\Models\User\AvailableUserPermission;
|
||||||
|
use App\Models\User\AvailableUserRole;
|
||||||
|
use App\Models\Admin\AllowedLogin;
|
||||||
|
use App\Models\Finances\AllianceWalletJournal;
|
||||||
|
|
||||||
class AdminDashboardController extends Controller
|
class AdminDashboardController extends Controller
|
||||||
{
|
{
|
||||||
@@ -34,7 +40,10 @@ class AdminDashboardController extends Controller
|
|||||||
* Show the administration dashboard.
|
* Show the administration dashboard.
|
||||||
*/
|
*/
|
||||||
public function displayAdminDashboard() {
|
public function displayAdminDashboard() {
|
||||||
if(auth()->user()->hasRole('Admin') || auth()->user()->hasPermission('moon.admin') || auth()->user()->hasPermission('srp.admin') || auth()->user()->hasPermission('contract.admin')) {
|
if(auth()->user()->hasRole('Admin') ||
|
||||||
|
auth()->user()->hasPermission('srp.admin') ||
|
||||||
|
auth()->user()->hasPermission('contract.admin' ||
|
||||||
|
auth()->user()->hasPermission('mining.officer'))) {
|
||||||
//Do nothing and continue on
|
//Do nothing and continue on
|
||||||
} else {
|
} else {
|
||||||
redirect('/dashboard');
|
redirect('/dashboard');
|
||||||
@@ -43,4 +52,389 @@ class AdminDashboardController extends Controller
|
|||||||
|
|
||||||
return view('admin.dashboards.dashboard');
|
return view('admin.dashboards.dashboard');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display users in a paginated format
|
||||||
|
*/
|
||||||
|
public function displayUsersPaginated() {
|
||||||
|
$this->middleware('role:Admin');
|
||||||
|
|
||||||
|
//Declare array variables
|
||||||
|
$user = array();
|
||||||
|
$permission = array();
|
||||||
|
$userArr = array();
|
||||||
|
$permString = null;
|
||||||
|
|
||||||
|
$usersArr = User::orderBy('name', 'asc')->paginate(50);
|
||||||
|
|
||||||
|
foreach($usersArr as $user) {
|
||||||
|
$user->role = $user->getRole();
|
||||||
|
|
||||||
|
$permCount = UserPermission::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->count();
|
||||||
|
|
||||||
|
if($permCount > 0) {
|
||||||
|
$perms = UserPermission::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->get('permission')->toArray();
|
||||||
|
|
||||||
|
foreach($perms as $perm) {
|
||||||
|
$permString .= $perm['permission'] . ', ';
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->permission = $permString;
|
||||||
|
} else {
|
||||||
|
$user->permission = 'No Permissions';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.dashboards.userspaged')->with('usersArr', $usersArr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search users for a specific user
|
||||||
|
*/
|
||||||
|
public function searchUsers(Request $request) {
|
||||||
|
$this->middleware('role:Admin');
|
||||||
|
|
||||||
|
//Declare array variables
|
||||||
|
$user = array();
|
||||||
|
$permission = array();
|
||||||
|
$userArr = array();
|
||||||
|
$permString = null;
|
||||||
|
|
||||||
|
//Validate the input from the form
|
||||||
|
$this->validate($request, [
|
||||||
|
'parameter' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$usersArr = User::where('name', 'like', $request->parameter . "%")->paginate(50);
|
||||||
|
|
||||||
|
foreach($usersArr as $user) {
|
||||||
|
$user->role = $user->getRole();
|
||||||
|
|
||||||
|
$permCount = UserPermission::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->count();
|
||||||
|
|
||||||
|
if($permCount > 0) {
|
||||||
|
$perms = UserPermission::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->get('permission')->toArray();
|
||||||
|
|
||||||
|
foreach($perms as $perm) {
|
||||||
|
$permString .= $perm['permission'] . ', ';
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->permission = $permString;
|
||||||
|
} else {
|
||||||
|
$user->permission = 'No Permissions';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.dashboards.users.searched')->with('usersArr', $usersArr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the allowed logins
|
||||||
|
*/
|
||||||
|
public function displayAllowedLogins() {
|
||||||
|
$this->middleware('role:Admin');
|
||||||
|
|
||||||
|
//Declare array variables
|
||||||
|
$entities = array();
|
||||||
|
|
||||||
|
/** Entities for allowed logins */
|
||||||
|
$legacys = AllowedLogin::where(['login_type' => 'Legacy'])->pluck('entity_name')->toArray();
|
||||||
|
$renters = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_name')->toArray();
|
||||||
|
//Compile a list of entities by their entity_id
|
||||||
|
foreach($legacys as $legacy) {
|
||||||
|
$entities[] = $legacy;
|
||||||
|
}
|
||||||
|
foreach($renters as $renter) {
|
||||||
|
$entities[] = $renter;
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.dashboards.allowed_logins')->with('entities', $entities);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the taxes for the alliance
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function displayTaxes() {
|
||||||
|
$this->middleware('role:Admin');
|
||||||
|
|
||||||
|
//Declare variables needed for displaying items on the page
|
||||||
|
$months = 6;
|
||||||
|
$pi = array();
|
||||||
|
$industry = array();
|
||||||
|
$reprocessing = array();
|
||||||
|
$office = array();
|
||||||
|
$corpId = 98287666;
|
||||||
|
$srpActual = array();
|
||||||
|
$srpLoss = array();
|
||||||
|
$miningTaxes = array();
|
||||||
|
$miningTaxesLate = array();
|
||||||
|
|
||||||
|
/** Taxes Pane */
|
||||||
|
//Declare classes needed for displaying items on the page
|
||||||
|
$tHelper = new TaxesHelper();
|
||||||
|
$srpHelper = new SRPHelper();
|
||||||
|
//Get the dates for the tab panes
|
||||||
|
$dates = $tHelper->GetTimeFrameInMonths($months);
|
||||||
|
|
||||||
|
//Get the data for the Taxes Pane
|
||||||
|
foreach($dates as $date) {
|
||||||
|
//Get the srp actual pay out for the date range
|
||||||
|
$srpActual[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($srpHelper->GetAllianceSRPActual($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
|
||||||
|
//Get the srp loss value for the date range
|
||||||
|
$srpLoss[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($srpHelper->GetAllianceSRPLoss($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
|
||||||
|
//Get the pi taxes for the date range
|
||||||
|
$pis[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetPIGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
//Get the industry taxes for the date range
|
||||||
|
$industrys[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetIndustryGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
//Get the reprocessing taxes for the date range
|
||||||
|
$reprocessings[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetReprocessingGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
//Get the office taxes for the date range
|
||||||
|
$offices[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetOfficeGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
//Get the market taxes for the date range
|
||||||
|
$markets[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetAllianceMarketGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
//Get the jump gate taxes for the date range
|
||||||
|
$jumpgates[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetJumpGateGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
|
||||||
|
$miningTaxes[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetMoonMiningTaxesGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
|
||||||
|
$miningTaxesLate[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetMoonMiningTaxesLateGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
|
||||||
|
$moonRentalTaxes[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetMoonRentalTaxesGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.dashboards.taxes')->with('pis', $pis)
|
||||||
|
->with('industrys', $industrys)
|
||||||
|
->with('offices', $offices)
|
||||||
|
->with('markets', $markets)
|
||||||
|
->with('jumpgates', $jumpgates)
|
||||||
|
->with('reprocessings', $reprocessings)
|
||||||
|
->with('srpActual', $srpActual)
|
||||||
|
->with('srpLoss', $srpLoss)
|
||||||
|
->with('miningTaxes', $miningTaxes)
|
||||||
|
->with('miningTaxesLate', $miningTaxesLate)
|
||||||
|
->with('moonRentalTaxes', $moonRentalTaxes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the modify user form
|
||||||
|
*/
|
||||||
|
public function displayModifyUser(Request $request) {
|
||||||
|
$this->middleware('role:Admin');
|
||||||
|
|
||||||
|
$permissions = array();
|
||||||
|
$roles = array();
|
||||||
|
|
||||||
|
$name = $request->user;
|
||||||
|
|
||||||
|
//Get the user information from the name
|
||||||
|
$user = User::where(['name' => $name])->first();
|
||||||
|
|
||||||
|
$perms = AvailableUserPermission::all();
|
||||||
|
foreach($perms as $p) {
|
||||||
|
$permissions[$p->permission] = $p->permission;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tempRoles = AvailableUserRole::all();
|
||||||
|
|
||||||
|
foreach($tempRoles as $tempRole) {
|
||||||
|
array_push($roles, [
|
||||||
|
$tempRole['role'] => $tempRole['role']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$role = $user->getRole();
|
||||||
|
|
||||||
|
//Pass the user information to the page for hidden text entries
|
||||||
|
return view('admin.user.modify')->with('user', $user)
|
||||||
|
->with('permissions', $permissions)
|
||||||
|
->with('role', $role)
|
||||||
|
->with('roles', $roles);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modify a user's role
|
||||||
|
*/
|
||||||
|
public function modifyRole(Request $request) {
|
||||||
|
$this->middleware('role:Admin');
|
||||||
|
|
||||||
|
$this->validate($request, [
|
||||||
|
'user' => 'required',
|
||||||
|
'role' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
UserRole::where(['character_id' => $request->user])->update([
|
||||||
|
'role' => $request->role,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect('/admin/dashboard/users')->with('success', "User: " . $request->user . " has been modified to a new role: " . $request->role . ".");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addPermission(Request $request) {
|
||||||
|
$this->middleware('role:Admin');
|
||||||
|
|
||||||
|
//Get the user and permission from the form
|
||||||
|
$character = $request->user;
|
||||||
|
$permission = $request->permission;
|
||||||
|
|
||||||
|
//Check to see if the character already has the permission
|
||||||
|
$check = UserPermission::where(['character_id' => $character, 'permission' => $permission])->get(['permission']);
|
||||||
|
|
||||||
|
if(!isset($check[0]->permission)) {
|
||||||
|
$perm = new UserPermission;
|
||||||
|
$perm->character_id = $character;
|
||||||
|
$perm->permission = $permission;
|
||||||
|
$perm->save();
|
||||||
|
|
||||||
|
return redirect('/admin/dashboard/users')->with('success', 'User udpated!');
|
||||||
|
} else {
|
||||||
|
return redirect('/admin/dashboard/users')->with('error', 'User not updated or already has the permission.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a user to reset their permissions
|
||||||
|
*/
|
||||||
|
public function removeUser(Request $request) {
|
||||||
|
$this->middleware('role:Admin');
|
||||||
|
|
||||||
|
//Get the user from the form to delete
|
||||||
|
$user = $request->user;
|
||||||
|
|
||||||
|
//Get the user data from the table
|
||||||
|
$data = User::where(['name' => $user])->get();
|
||||||
|
|
||||||
|
//Delete the user's ESI Scopes
|
||||||
|
DB::table('EsiScopes')->where(['character_id' => $data[0]->character_id])->delete();
|
||||||
|
|
||||||
|
//Delete the user's ESI Token
|
||||||
|
DB::table('EsiTokens')->where(['character_id' => $data[0]->character_id])->delete();
|
||||||
|
|
||||||
|
//Delete the user's role from the roles table
|
||||||
|
DB::table('user_roles')->where(['character_id' => $data[0]->character_id])->delete();
|
||||||
|
|
||||||
|
//Delete the user from the user table
|
||||||
|
DB::table('users')->where(['character_id' => $data[0]->character_id])->delete();
|
||||||
|
|
||||||
|
return redirect('/admin/dashboard/users')->with('success', 'User deleted from the site.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an entity to the allowed login table
|
||||||
|
*/
|
||||||
|
public function addAllowedLogin(Request $request) {
|
||||||
|
$this->middleware('role:Admin');
|
||||||
|
|
||||||
|
//Set the parameters to validate the form
|
||||||
|
$this->validate($request, [
|
||||||
|
'allowedEntityId' => 'required',
|
||||||
|
'allowedEntityType' => 'required',
|
||||||
|
'allowedEntityName' => 'required',
|
||||||
|
'allowedLoginType' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Check to see if the entity exists in the database already
|
||||||
|
$found = AllowedLogin::where([
|
||||||
|
'entity_type' => $request->allowedentityType,
|
||||||
|
'entity_name' => $request->allowedEntityName,
|
||||||
|
])->count();
|
||||||
|
if($found != 0) {
|
||||||
|
AllowedLogin::where([
|
||||||
|
'entity_type' => $request->allowedEntityType,
|
||||||
|
'entity_name' => $request->allowedEntityName,
|
||||||
|
])->update([
|
||||||
|
'entity_id' => $request->allowedEntityId,
|
||||||
|
'entity_type' => $request->allowedEntityType,
|
||||||
|
'entity_name' => $request->allowedEntityName,
|
||||||
|
'login_type' => $request->allowedLoginType,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$login = new AllowedLogin;
|
||||||
|
$login->entity_id = $request->allowedEntityId;
|
||||||
|
$login->entity_name = $request->allowedEntityName;
|
||||||
|
$login->entity_type = $request->allowedEntityType;
|
||||||
|
$login->login_type = $request->allowedLoginType;
|
||||||
|
$login->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect('/admin/dashboard')->with('success', 'Entity added to allowed login list.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove an entity from the allowed login table
|
||||||
|
*/
|
||||||
|
public function removeAllowedLogin(Request $request) {
|
||||||
|
$this->middleware('role:Admin');
|
||||||
|
|
||||||
|
//Set the parameters to validate the form
|
||||||
|
$this->validate($request, [
|
||||||
|
'removeAllowedLogin' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
AllowedLogin::where([
|
||||||
|
'entity_name' => $request->removeAllowedLogin,
|
||||||
|
])->delete();
|
||||||
|
|
||||||
|
return redirect('/admin/dashboard')->with('success', 'Entity removed from allowed login list.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show journal entries in a table for admins from alliance wallets
|
||||||
|
*/
|
||||||
|
public function displayJournalEntries() {
|
||||||
|
$this->middleware('role:Admin');
|
||||||
|
|
||||||
|
$date = Carbon::now()->subDays(60);
|
||||||
|
|
||||||
|
$journal = AllianceWalletJournal::where('date', '>=', $date)
|
||||||
|
->where([
|
||||||
|
'corporation_id' => 98287666,
|
||||||
|
'ref_type' => 'player_donation',
|
||||||
|
])->orderByDesc('date',)->get(['amount', 'reason', 'description', 'date']);
|
||||||
|
|
||||||
|
return view('admin.dashboards.walletjournal')->with('journal', $journal);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class DashboardController extends Controller
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->middleware('auth');
|
$this->middleware('auth');
|
||||||
$this->middleware('role:Guest');
|
$this->middleware('role:User');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
322
app/Http/Controllers/Finances/FinanceController.php
Normal file
322
app/Http/Controllers/Finances/FinanceController.php
Normal file
@@ -0,0 +1,322 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Finances;
|
||||||
|
|
||||||
|
//Internal Libraries
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Log;
|
||||||
|
use Khill\Lavacharts\Lavacharts;
|
||||||
|
|
||||||
|
//Application Library
|
||||||
|
use App\Library\Helpers\TaxesHelper;
|
||||||
|
use App\Library\Helpers\LookupHelper;
|
||||||
|
use App\Library\Helpers\SRPHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\User\User;
|
||||||
|
|
||||||
|
class FinanceController extends Controller
|
||||||
|
{
|
||||||
|
//Construct
|
||||||
|
public function __construct() {
|
||||||
|
$this->middleware('auth');
|
||||||
|
$this->middleware('role:User');
|
||||||
|
$this->middleware('permission:ceo');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the finances of the alliance with cards like the admin dashboard
|
||||||
|
*/
|
||||||
|
public function displayCards() {
|
||||||
|
$months = 3;
|
||||||
|
|
||||||
|
$pi = array();
|
||||||
|
$industry = array();
|
||||||
|
$reprocessing = array();
|
||||||
|
$office = array();
|
||||||
|
$corpId = 98287666;
|
||||||
|
$srpActual = array();
|
||||||
|
$srpLoss = array();
|
||||||
|
$miningTaxes = array();
|
||||||
|
$miningTaxesLate = array();
|
||||||
|
|
||||||
|
/** Taxes Pane */
|
||||||
|
//Declare classes needed for displaying items on the page
|
||||||
|
$tHelper = new TaxesHelper();
|
||||||
|
$srpHelper = new SRPHelper();
|
||||||
|
//Get the dates for the tab panes
|
||||||
|
$dates = $tHelper->GetTimeFrameInMonths($months);
|
||||||
|
|
||||||
|
//Get the data for the Taxes Pane
|
||||||
|
foreach($dates as $date) {
|
||||||
|
//Get the srp actual pay out for the date range
|
||||||
|
$srpActual[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($srpHelper->GetAllianceSRPActual($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
|
||||||
|
//Get the srp loss value for the date range
|
||||||
|
$srpLoss[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($srpHelper->GetAllianceSRPLoss($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
|
||||||
|
//Get the pi taxes for the date range
|
||||||
|
$pis[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetPIGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
//Get the industry taxes for the date range
|
||||||
|
$industrys[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetIndustryGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
//Get the reprocessing taxes for the date range
|
||||||
|
$reprocessings[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetReprocessingGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
//Get the office taxes for the date range
|
||||||
|
$offices[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetOfficeGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
//Get the market taxes for the date range
|
||||||
|
$markets[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetAllianceMarketGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
//Get the jump gate taxes for the date range
|
||||||
|
$jumpgates[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetJumpGateGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
|
||||||
|
$miningTaxes[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetMoonMiningTaxesGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
|
||||||
|
$miningTaxesLate[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetMoonMiningTaxesLateGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
|
||||||
|
$moonRentalTaxes[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetMoonRentalTaxesGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('finances.display.card')->with('pis', $pis)
|
||||||
|
->with('industrys', $industrys)
|
||||||
|
->with('offices', $offices)
|
||||||
|
->with('markets', $markets)
|
||||||
|
->with('jumpgates', $jumpgates)
|
||||||
|
->with('reprocessings', $reprocessings)
|
||||||
|
->with('srpActual', $srpActual)
|
||||||
|
->with('srpLoss', $srpLoss)
|
||||||
|
->with('miningTaxes', $miningTaxes)
|
||||||
|
->with('miningTaxesLate', $miningTaxesLate)
|
||||||
|
->with('moonRentalTaxes', $moonRentalTaxes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a graph of the financial outlook of the alliance
|
||||||
|
*/
|
||||||
|
public function displayOutlook() {
|
||||||
|
$months = 12;
|
||||||
|
$income = array();
|
||||||
|
$expenses = array();
|
||||||
|
$totalPi = 0.00;
|
||||||
|
$totalIndustry = 0.00;
|
||||||
|
$totalReprocessing = 0.00;
|
||||||
|
$totalOffices = 0.00;
|
||||||
|
$totalMarket = 0.00;
|
||||||
|
$totalJumpGate = 0.00;
|
||||||
|
$totalMiningTaxes = 0.00;
|
||||||
|
$totalMoonRentals = 0.00;
|
||||||
|
$totalSrp = 0.00;
|
||||||
|
$totalCapEx = 0.00;
|
||||||
|
$totalSovExpenses = 0.00;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Declare classes needed for displaying items on the page
|
||||||
|
*/
|
||||||
|
$tHelper = new TaxesHelper();
|
||||||
|
$srpHelper = new SRPHelper();
|
||||||
|
//Get the dates to process
|
||||||
|
$dates = $tHelper->GetTimeFrameInMonths($months);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup the chart variables
|
||||||
|
*/
|
||||||
|
$lava = new Lavacharts;
|
||||||
|
$finances = $lava->DataTable();
|
||||||
|
$incomeStreams = $lava->DataTable();
|
||||||
|
$expenseStreams = $lava->DataTable();
|
||||||
|
|
||||||
|
$finances->addDateColumn('Month')
|
||||||
|
->addNumberColumn('Income')
|
||||||
|
->addNumberColumn('Expenses')
|
||||||
|
->addNumberColumn('Difference')
|
||||||
|
->setDateTimeFormat('Y');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the income and expenses data for date range
|
||||||
|
*/
|
||||||
|
foreach($dates as $date) {
|
||||||
|
/**
|
||||||
|
* Get the individual expenses.
|
||||||
|
* Will totalize later in the foreach loop
|
||||||
|
*/
|
||||||
|
$srpActual = $srpHelper->GetAllianceSRPActual($date['start'], $date['end']);
|
||||||
|
$capEx = 0.00;
|
||||||
|
$sovExpenses = 3000000000.00;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the individual incomes.
|
||||||
|
* Will totalize later in the foreach loop
|
||||||
|
*/
|
||||||
|
$pi = $tHelper->GetPIGross($date['start'], $date['end']);
|
||||||
|
$industry = $tHelper->GetIndustryGross($date['start'], $date['end']);
|
||||||
|
$reprocessing = $tHelper->GetReprocessingGross($date['start'], $date['end']);
|
||||||
|
$offices = $tHelper->GetOfficeGross($date['start'], $date['end']);
|
||||||
|
$market = $tHelper->GetAllianceMarketGross($date['start'], $date['end']);
|
||||||
|
$jumpgate = $tHelper->GetJumpGateGross($date['start'], $date['end']);
|
||||||
|
$miningTaxes = $tHelper->GetMoonMiningTaxesGross($date['start'], $date['end']) + $tHelper->GetMoonMiningTaxesLateGross($date['start'], $date['end']);
|
||||||
|
$moonRentals = $tHelper->GetMoonRentalTaxesGross($date['start'], $date['end']);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Totalize the expenses
|
||||||
|
*/
|
||||||
|
$expenses = (($srpActual + $capEx + $sovExpenses) / 1000000.00);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Totalize the incomes
|
||||||
|
*/
|
||||||
|
$incomes = (($pi +
|
||||||
|
$industry +
|
||||||
|
$reprocessing +
|
||||||
|
$offices +
|
||||||
|
$market +
|
||||||
|
$jumpgate +
|
||||||
|
$miningTaxes +
|
||||||
|
$moonRentals) / 1000000.00);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the difference between income and expenses
|
||||||
|
*/
|
||||||
|
$difference = $incomes - $expenses;
|
||||||
|
|
||||||
|
//Add the rows for the combo column chart
|
||||||
|
$finances->addRow([$date['start'], $incomes, $expenses, $difference]);
|
||||||
|
|
||||||
|
//Add up each of the income streams, then the expenses
|
||||||
|
$totalPi += $pi;
|
||||||
|
$totalIndustry += $industry;
|
||||||
|
$totalReprocessing += $reprocessing;
|
||||||
|
$totalOffices += $offices;
|
||||||
|
$totalMarket += $market;
|
||||||
|
$totalJumpGate += $jumpgate;
|
||||||
|
$totalMiningTaxes += $miningTaxes;
|
||||||
|
$totalMoonRentals += $moonRentals;
|
||||||
|
$totalSrp += $srpActual;
|
||||||
|
$totalCapEx = $capEx;
|
||||||
|
$totalSovExpenses += $sovExpenses;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finish setting up the lava chart before passing it to the blade template
|
||||||
|
*/
|
||||||
|
$lava->ComboChart('Finances', $finances, [
|
||||||
|
'title' => 'Alliance Finances',
|
||||||
|
'titleTextStyle' => [
|
||||||
|
'color' => 'rgb(123, 65, 80)',
|
||||||
|
'fontSize' => 16,
|
||||||
|
],
|
||||||
|
'legend' => [
|
||||||
|
'position' => 'in',
|
||||||
|
],
|
||||||
|
'seriesType' => 'bars',
|
||||||
|
'series' => [
|
||||||
|
2 => [
|
||||||
|
'type' => 'line',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'height' => 360,
|
||||||
|
]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup the 3d pie chart for income streams
|
||||||
|
*/
|
||||||
|
$incomeStreams->addStringColumn('Incomes')
|
||||||
|
->addNumberColumn('ISK')
|
||||||
|
->addRow(['PI', $totalPi])
|
||||||
|
->addRow(['Industry', $totalIndustry])
|
||||||
|
->addRow(['Reprocessing', $totalReprocessing])
|
||||||
|
->addRow(['Offices', $totalOffices])
|
||||||
|
->addRow(['Market', $totalMarket])
|
||||||
|
->addRow(['Jump Gate', $totalJumpGate])
|
||||||
|
->addRow(['Mining Taxes', $totalMiningTaxes])
|
||||||
|
->addRow(['Moon Rentals', $totalMoonRentals]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup the 3d pie chart for expense streams
|
||||||
|
*/
|
||||||
|
$expenseStreams->addStringColumn('Expenses')
|
||||||
|
->addNumberColumn('ISK')
|
||||||
|
->addRow(['SRP', $totalSrp])
|
||||||
|
->addRow(['Cap Ex', $totalCapEx])
|
||||||
|
->addRow(['Sov Expenses', $totalSovExpenses]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup the pie chart data for income streams
|
||||||
|
*/
|
||||||
|
$lava->PieChart('Incomes', $incomeStreams, [
|
||||||
|
'title' => 'Alliance Income Streams',
|
||||||
|
'is3D' => true,
|
||||||
|
'height' => 360,
|
||||||
|
]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup the pie chart data for expenses
|
||||||
|
*/
|
||||||
|
$lava->PieChart('Expenses', $expenseStreams, [
|
||||||
|
'title' => 'Alliance Expenses',
|
||||||
|
'is3D' => true,
|
||||||
|
'height' => 360,
|
||||||
|
'slices' => [
|
||||||
|
['offset' => 0.15],
|
||||||
|
['offset' => 0.25],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
return view('finances.display.outlook')->with('lava', $lava);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request an amount of ISK to fund a capital project
|
||||||
|
*/
|
||||||
|
public function requestFundingDisplay() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store the request for the capital project
|
||||||
|
*/
|
||||||
|
public function storeFundingRequest() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a request for the capital project
|
||||||
|
*/
|
||||||
|
public function deleteFundingRequest() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -83,6 +83,6 @@ class FuelController extends Controller
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
return view('logistics.fuel')->with('jumpGates', $jumpGates)
|
return view('logistics.fuel')->with('jumpGates', $jumpGates)
|
||||||
->with('lava', $lava);
|
->with('lava', $lava);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ use Log;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Khill\Lavacharts\Lavacharts;
|
use Khill\Lavacharts\Lavacharts;
|
||||||
use Auth;
|
use Auth;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
//Application Library
|
//Application Library
|
||||||
use App\Library\Helpers\LookupHelper;
|
use App\Library\Helpers\LookupHelper;
|
||||||
@@ -25,12 +27,188 @@ use App\Models\Moon\ItemComposition;
|
|||||||
use App\Models\Moon\MineralPrice;
|
use App\Models\Moon\MineralPrice;
|
||||||
use App\Models\Esi\EsiToken;
|
use App\Models\Esi\EsiToken;
|
||||||
use App\Models\Esi\EsiScope;
|
use App\Models\Esi\EsiScope;
|
||||||
|
use App\Models\Structure\Structure;
|
||||||
|
use App\Models\MiningTax\MiningOperation;
|
||||||
|
|
||||||
class MiningTaxesAdminController extends Controller
|
class MiningTaxesAdminController extends Controller
|
||||||
{
|
{
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->middleware('auth');
|
$this->middleware('auth');
|
||||||
$this->middleware('role:Admin');
|
$this->middleware('role:User');
|
||||||
|
$this->middleware('permission:mining.officer');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the form for mining operations held by the alliance
|
||||||
|
*/
|
||||||
|
public function displayMiningOperationForm() {
|
||||||
|
//Declare variables
|
||||||
|
$config = config('esi');
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$sHelper = new StructureHelper($config['primary'], $config['corporation']);
|
||||||
|
$coll = new Collection;
|
||||||
|
$structures = new Collection;
|
||||||
|
|
||||||
|
//Get all of the structures
|
||||||
|
$athanors = $sHelper->GetStructuresByType('Athanor');
|
||||||
|
$tataras = $sHelper->GetStructuresByType('Tatara');
|
||||||
|
|
||||||
|
//Cycle through each athanor and add it to the stack
|
||||||
|
foreach($athanors as $athanor) {
|
||||||
|
$structures->push([
|
||||||
|
$athanor->structure_id => $athanor->structure_name,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
//Cycle through each tatara and add it to the stack
|
||||||
|
foreach($tataras as $tatara) {
|
||||||
|
$structures->push([
|
||||||
|
$tatara->structure_id => $tatara->structure_name,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
//Sort all of the structures
|
||||||
|
$structures->sort();
|
||||||
|
|
||||||
|
//Get the current mining operations.
|
||||||
|
$operations = MiningOperation::where([
|
||||||
|
'processed' => 'No',
|
||||||
|
])->get();
|
||||||
|
|
||||||
|
return view('miningtax.admin.display.miningops.form')->with('structures', $structures)
|
||||||
|
->with('operations', $operations);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store the results from the mining operations form
|
||||||
|
*/
|
||||||
|
public function storeMiningOperationForm(Request $request) {
|
||||||
|
//Validate the data
|
||||||
|
$this->validate($request, [
|
||||||
|
'name' => 'required',
|
||||||
|
'date' => 'required',
|
||||||
|
'structure' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$config = config('esi');
|
||||||
|
$sHelper = new StructureHelper($config['primary'], $config['corporation']);
|
||||||
|
|
||||||
|
//Get the name of the structure from the database
|
||||||
|
$m = $sHelper->GetStructureInfo($request->structure);
|
||||||
|
|
||||||
|
//Save the mining operation into the database
|
||||||
|
$operation = new MiningOperation;
|
||||||
|
$operation->structure_id = $request->structure;
|
||||||
|
$operation->structure_name = $m->structure_name;
|
||||||
|
$operation->authorized_by_id = auth()->user()->getId();
|
||||||
|
$operation->authorized_by_name = auth()->user()->getName();
|
||||||
|
$operation->operation_name = $request->name;
|
||||||
|
$operation->operation_date = $request->date;
|
||||||
|
$operation->processed = 'No';
|
||||||
|
$operation->processed_on = null;
|
||||||
|
$operation->save();
|
||||||
|
|
||||||
|
return redirect('/admin/dashboard')->with('success', 'Operation added successfully.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the page to approve corporation moon rentals
|
||||||
|
*/
|
||||||
|
public function DisplayMoonRentalRequests() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Approve a moon rental from the form
|
||||||
|
*/
|
||||||
|
public function storeApproveMoonRentalRequest() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the page to setup the form for corporations to rent a moon
|
||||||
|
*/
|
||||||
|
public function DisplayMoonRentalForm() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store the details for the form for corporations renting a specific moon
|
||||||
|
*/
|
||||||
|
public function StoreMoonRentalForm() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a moon from being rented from a specific corporation
|
||||||
|
*/
|
||||||
|
public function DeleteMoonRental(Request $request) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display an invoice based on it's id
|
||||||
|
*
|
||||||
|
* @var $invoiceId
|
||||||
|
*/
|
||||||
|
public function displayInvoice($invoiceId) {
|
||||||
|
$ores = array();
|
||||||
|
$moons = array();
|
||||||
|
$totalPrice = 0.00;
|
||||||
|
$config = config('esi');
|
||||||
|
$structure = new StructureHelper($config['primary'], $config['corporation']);
|
||||||
|
|
||||||
|
//Get the invoice from the database
|
||||||
|
$invoice = Invoice::where([
|
||||||
|
'invoice_id' => $invoiceId,
|
||||||
|
])->first();
|
||||||
|
|
||||||
|
//Get the line items for the ledger for the invoice
|
||||||
|
$items = Ledger::where([
|
||||||
|
'invoice_id' => $invoiceId,
|
||||||
|
])->get();
|
||||||
|
|
||||||
|
//Build the total ores table for the display page
|
||||||
|
foreach($items as $item) {
|
||||||
|
if(!isset($ores[$item['ore_name']])) {
|
||||||
|
$ores[$item['ore_name']] = 0;
|
||||||
|
}
|
||||||
|
$ores[$item['ore_name']] = $ores[$item['ore_name']] + $item['quantity'];
|
||||||
|
|
||||||
|
$totalPrice += $item['amount'];
|
||||||
|
}
|
||||||
|
|
||||||
|
//Print out the lines of the ledger line by line for another table
|
||||||
|
foreach($items as $item) {
|
||||||
|
//Get the structure info from the database or esi
|
||||||
|
$tempObserverInfo = $structure->GetStructureInfo($item['observer_id']);
|
||||||
|
|
||||||
|
if(isset($tempObserverInfo->name)) {
|
||||||
|
array_push($moons, [
|
||||||
|
'character_name' => $item['character_name'],
|
||||||
|
'observer_name' => $tempObserverInfo->name,
|
||||||
|
'type_id' => $item['type_id'],
|
||||||
|
'ore_name' => $item['ore_name'],
|
||||||
|
'quantity' => $item['quantity'],
|
||||||
|
'amount' => $item['amount'],
|
||||||
|
'tax_amount' => $item['amount'] * $config['public_mining_tax'],
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
array_push($moons, [
|
||||||
|
'character_name' => $item['character_name'],
|
||||||
|
'observer_name' => $tempObserverInfo->structure_name,
|
||||||
|
'type_id' => $item['type_id'],
|
||||||
|
'ore_name' => $item['ore_name'],
|
||||||
|
'quantity' => $item['quantity'],
|
||||||
|
'amount' => $item['amount'],
|
||||||
|
'tax_amount' => $item['amount'] * $config['public_mining_tax'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('miningtax.admin.display.details.invoice')->with('ores', $ores)
|
||||||
|
->with('moons', $moons)
|
||||||
|
->with('invoice', $invoice)
|
||||||
|
->with('totalPrice', $totalPrice);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,11 +221,51 @@ class MiningTaxesAdminController extends Controller
|
|||||||
'status' => 'Late',
|
'status' => 'Late',
|
||||||
])->orWhere([
|
])->orWhere([
|
||||||
'status' => 'Deferred',
|
'status' => 'Deferred',
|
||||||
])->paginate(50);
|
])->orderByDesc('invoice_id')->paginate(50);
|
||||||
|
|
||||||
|
$totalAmount = Invoice::where([
|
||||||
|
'status' => 'Pending',
|
||||||
|
])->orWhere([
|
||||||
|
'status' => 'Late',
|
||||||
|
])->orWhere([
|
||||||
|
'status' => 'Deferred',
|
||||||
|
])->sum('invoice_amount');
|
||||||
|
|
||||||
return view('miningtax.admin.display.unpaid')->with('invoices', $invoices);
|
return view('miningtax.admin.display.unpaid')->with('invoices', $invoices);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search unpaid invoices
|
||||||
|
*/
|
||||||
|
public function SearchUnpaidInvoice(Request $request) {
|
||||||
|
$invoices = Invoice::where('invoice_id', 'LIKE', '%' . $request->q . '%')
|
||||||
|
->where(['status' => 'Pending'])
|
||||||
|
->orWhere(['status' => 'Late'])
|
||||||
|
->orWhere(['status' => 'Deferred'])
|
||||||
|
->orderByDesc('invoice_id')
|
||||||
|
->paginate(25);
|
||||||
|
|
||||||
|
if(count($invoices) > 0) {
|
||||||
|
return view('miningtax.admin.display.unpaid')->with('invoices', $invoices);
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('miningtax.admin.display.unpaid')->with('error', 'No invoices found');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display page to modify an unpaid invoice
|
||||||
|
*/
|
||||||
|
public function DisplayModifyInvoice() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modify an unpaid invoice
|
||||||
|
*/
|
||||||
|
public function ProcessModifyInvoice() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark an invoice paid
|
* Mark an invoice paid
|
||||||
*/
|
*/
|
||||||
@@ -61,6 +279,8 @@ class MiningTaxesAdminController extends Controller
|
|||||||
'invoice_id' => $request->invoiceId,
|
'invoice_id' => $request->invoiceId,
|
||||||
])->update([
|
])->update([
|
||||||
'status' => $request->status,
|
'status' => $request->status,
|
||||||
|
'modified_by_id' => auth()->user()->getId(),
|
||||||
|
'modified_by_name' => auth()->user()->getName(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return redirect('/miningtax/admin/display/unpaid')->with('success', 'Invoice successfully updated.');
|
return redirect('/miningtax/admin/display/unpaid')->with('success', 'Invoice successfully updated.');
|
||||||
@@ -76,6 +296,13 @@ class MiningTaxesAdminController extends Controller
|
|||||||
'status' => 'Paid Late',
|
'status' => 'Paid Late',
|
||||||
])->paginate(50);
|
])->paginate(50);
|
||||||
|
|
||||||
return view('miningtax.admin.display.paidinvoices')->with('invoices', $invoices);
|
$totalAmount = Invoice::where([
|
||||||
|
'status' => 'Paid',
|
||||||
|
])->orWhere([
|
||||||
|
'status' => 'Paid Late',
|
||||||
|
])->sum('invoice_amount');
|
||||||
|
|
||||||
|
return view('miningtax.admin.display.paidinvoices')->with('invoices', $invoices)
|
||||||
|
->with('totalAmount', $totalAmount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ namespace App\Http\Controllers\MiningTaxes;
|
|||||||
//Internal Library
|
//Internal Library
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use DB;
|
||||||
use Log;
|
use Log;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Khill\Lavacharts\Lavacharts;
|
use Khill\Lavacharts\Lavacharts;
|
||||||
use Auth;
|
use Auth;
|
||||||
//Collection Stuff
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
@@ -18,6 +18,7 @@ use App\Library\Helpers\LookupHelper;
|
|||||||
use App\Library\Helpers\StructureHelper;
|
use App\Library\Helpers\StructureHelper;
|
||||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||||
use App\Library\Esi\Esi;
|
use App\Library\Esi\Esi;
|
||||||
|
use App\Library\Moons\MoonCalc;
|
||||||
|
|
||||||
//Models
|
//Models
|
||||||
use App\Models\Moon\ItemComposition;
|
use App\Models\Moon\ItemComposition;
|
||||||
@@ -28,6 +29,9 @@ use App\Models\MiningTax\Invoice;
|
|||||||
use App\Models\Esi\EsiToken;
|
use App\Models\Esi\EsiToken;
|
||||||
use App\Models\Esi\EsiScope;
|
use App\Models\Esi\EsiScope;
|
||||||
use App\Models\User\User;
|
use App\Models\User\User;
|
||||||
|
use App\Models\MoonRental\AllianceMoon;
|
||||||
|
use App\Models\MoonRental\AllianceMoonOre;
|
||||||
|
use App\Models\MoonRental\AllianceMoonRental;
|
||||||
|
|
||||||
class MiningTaxesController extends Controller
|
class MiningTaxesController extends Controller
|
||||||
{
|
{
|
||||||
@@ -39,6 +43,359 @@ class MiningTaxesController extends Controller
|
|||||||
$this->middleware('role:User');
|
$this->middleware('role:User');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the moons either the person is renting, or their corp are renting
|
||||||
|
*/
|
||||||
|
public function DisplayRentedMoons() {
|
||||||
|
$moons = array();
|
||||||
|
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
|
||||||
|
$userId = auth()->user()->getId();
|
||||||
|
$charInfo = $lookup->GetCharacterInfo(auth()->user()->getId());
|
||||||
|
$corpId = $charInfo->corporation_id;
|
||||||
|
|
||||||
|
|
||||||
|
$tempMoons = AllianceMoonRental::where([
|
||||||
|
'entity_id' => $userId,
|
||||||
|
])->orWhere([
|
||||||
|
'entity_id' => $corpId,
|
||||||
|
])->get();
|
||||||
|
|
||||||
|
//Foreach of the moons we got let's build the moon info and the ore data
|
||||||
|
foreach($tempMoons as $tempMoon) {
|
||||||
|
//Get the ores for the moon
|
||||||
|
$ores = AllianceMoonOre::where([
|
||||||
|
'moon_id' => $tempMoon->moon_id,
|
||||||
|
])->get()->toArray();
|
||||||
|
|
||||||
|
$moons->push([
|
||||||
|
'moon_id' => $tempMoon->moon_id,
|
||||||
|
'system' => $tempMoon->system_name,
|
||||||
|
'moon_name' => $tempMoon->name,
|
||||||
|
'ores' => $ores,
|
||||||
|
'worth_amount' => $tempMoon->worth_amount,
|
||||||
|
'rental_amount' => $tempMoon->rental_amount,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('miningtax.user.display.rentedmoons')->with('moons', $moons)
|
||||||
|
->with('ores', $ores);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the page with the moon rental form
|
||||||
|
*/
|
||||||
|
public function DisplayMoonRentalForm(Request $request) {
|
||||||
|
$this->validate($request, [
|
||||||
|
'moon_id' => 'required',
|
||||||
|
'moon_name' => 'required',
|
||||||
|
'worth_amount' => 'required',
|
||||||
|
'rental_amount' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$moon = AllianceMoon::where([
|
||||||
|
'moon_id' => $request->moon_id,
|
||||||
|
])->first();
|
||||||
|
|
||||||
|
$ores = AllianceMoonOre::where([
|
||||||
|
'moon_id' => $request->moon_id,
|
||||||
|
])->get();
|
||||||
|
|
||||||
|
return view('miningtax.user.display.moonrentals.form')->with('moon', $moon)
|
||||||
|
->with('ores', $ores);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store the information from the moon rental form
|
||||||
|
*/
|
||||||
|
public function storeMoonRentalForm(Request $request) {
|
||||||
|
$this->validate($request, [
|
||||||
|
'moon_id' => 'required',
|
||||||
|
'rental_start' => 'required',
|
||||||
|
'rental_end' => 'required',
|
||||||
|
'entity_name' => 'required',
|
||||||
|
'entity_type' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$entityId = null;
|
||||||
|
|
||||||
|
//From the name and type of the entity get the entity id.
|
||||||
|
if($request->entity_type == 'Character') {
|
||||||
|
$entityId = $lookup->CharacterNameToId($request->entity_name);
|
||||||
|
} else if($request->entity_type == 'Corporation') {
|
||||||
|
$entityId = $lookup->CorporationNameToId($request->entity_name);
|
||||||
|
} else if($request->entity_type == 'Alliance') {
|
||||||
|
$entityId = $lookup->AllianceNameToId($request->entity_name);
|
||||||
|
} else {
|
||||||
|
return redirect('/dashboard')->with('error', 'Moon Rental error. Please contact the site admin.');
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create the next billing date from a Carbon date 3 months from the rental start
|
||||||
|
$nextBillingDate = Carbon::create($request->rental_start)->addMonths(3);
|
||||||
|
|
||||||
|
//Create the uniqid for the billing cycle.
|
||||||
|
$invoiceId = "MR" . uniqid();
|
||||||
|
|
||||||
|
//Get the moon's information from the database so we know how much to make the bill for
|
||||||
|
$moon = AllianceMoon::where([
|
||||||
|
'moon_id' => $request->moon_id,
|
||||||
|
])->first();
|
||||||
|
|
||||||
|
//Update the data on the Alliance Moon
|
||||||
|
AllianceMoon::where([
|
||||||
|
'moon_id' => $request->moon_id,
|
||||||
|
])->update([
|
||||||
|
'rented' => 'Yes',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Insert a new moon rental into the database
|
||||||
|
AllianceMoonRental::insert([
|
||||||
|
'moon_id' => $moon->moon_id,
|
||||||
|
'moon_name' => $moon->name,
|
||||||
|
'rental_amount' => $moon->rental_amount,
|
||||||
|
'rental_start' => $request->rental_start,
|
||||||
|
'rental_end' => $request->rental_end,
|
||||||
|
'next_billing_date' => $nextBillingDate,
|
||||||
|
'entity_id' => $entityId,
|
||||||
|
'entity_name' => $request->entity_name,
|
||||||
|
'entity_type' => $request->entity_type,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect('/dashboard')->with('success', 'Before placing a structure please send the ISK to the holding corp with the description of ' . $invoiceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function displayAvailableMoons() {
|
||||||
|
//Declare variables
|
||||||
|
$moons = new Collection;
|
||||||
|
$mHelper = new MoonCalc;
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$system = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Declare our different flavors of moon goo for the blade
|
||||||
|
*/
|
||||||
|
$r4Goo = [
|
||||||
|
'Zeolites',
|
||||||
|
'Sylvite',
|
||||||
|
'Bitumens',
|
||||||
|
'Coesite',
|
||||||
|
];
|
||||||
|
|
||||||
|
$r8Goo = [
|
||||||
|
'Cobaltite',
|
||||||
|
'Euxenite',
|
||||||
|
'Titanite',
|
||||||
|
'Scheelite',
|
||||||
|
];
|
||||||
|
|
||||||
|
$r16Goo = [
|
||||||
|
'Otavite',
|
||||||
|
'Sperrylite',
|
||||||
|
'Vanadinite',
|
||||||
|
'Chromite',
|
||||||
|
];
|
||||||
|
|
||||||
|
$r32Goo = [
|
||||||
|
'Carnotite',
|
||||||
|
'Zircon',
|
||||||
|
'Pollucite',
|
||||||
|
'Cinnabar',
|
||||||
|
];
|
||||||
|
|
||||||
|
$r64Goo = [
|
||||||
|
'Xenotime',
|
||||||
|
'Monazite',
|
||||||
|
'Loparite',
|
||||||
|
'Ytterbite',
|
||||||
|
];
|
||||||
|
|
||||||
|
//Get all of the system names from the database by plucking all the non-rented moon system names
|
||||||
|
$systems = AllianceMoon::where([
|
||||||
|
'rented' => 'No',
|
||||||
|
])->pluck('system_name')->unique()->toArray();
|
||||||
|
|
||||||
|
//Get all of the moons which are not rented
|
||||||
|
$allyMoons = AllianceMoon::where([
|
||||||
|
'rented' => 'No',
|
||||||
|
])->get();
|
||||||
|
|
||||||
|
//Cycle through all of the moons to create arrays of data
|
||||||
|
foreach($allyMoons as $moon) {
|
||||||
|
$ores = AllianceMoonOre::where([
|
||||||
|
'moon_id' => $moon->moon_id,
|
||||||
|
])->get(['ore_name', 'quantity'])->toArray();
|
||||||
|
|
||||||
|
if($moon->moon_type != 'R32' && $moon->moon_type != 'R64') {
|
||||||
|
$moons->push([
|
||||||
|
'system' => $moon->system_name,
|
||||||
|
'moon_name' => $moon->name,
|
||||||
|
'ores' => $ores,
|
||||||
|
'worth_amount' => $moon->worth_amount,
|
||||||
|
'rental_amount' => $moon->rental_amount,
|
||||||
|
'moon_id' => $moon->moon_id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('miningtax.user.display.moons.availablemoons')->with('moons', $moons)
|
||||||
|
->with('systems', $systems)
|
||||||
|
->with('r4Goo', $r4Goo)
|
||||||
|
->with('r8Goo', $r8Goo)
|
||||||
|
->with('r16Goo', $r16Goo)
|
||||||
|
->with('r32Goo', $r32Goo)
|
||||||
|
->with('r64Goo', $r64Goo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display all the moons in Warped Intentions Sovreignty
|
||||||
|
*/
|
||||||
|
public function displayAllMoons() {
|
||||||
|
//Declare variables
|
||||||
|
$moons = new Collection;
|
||||||
|
$mHelper = new MoonCalc;
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$system = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Declare our different flavors of moon goo for the blade
|
||||||
|
*/
|
||||||
|
$r4Goo = [
|
||||||
|
'Zeolites',
|
||||||
|
'Sylvite',
|
||||||
|
'Bitumens',
|
||||||
|
'Coesite',
|
||||||
|
];
|
||||||
|
|
||||||
|
$r8Goo = [
|
||||||
|
'Cobaltite',
|
||||||
|
'Euxenite',
|
||||||
|
'Titanite',
|
||||||
|
'Scheelite',
|
||||||
|
];
|
||||||
|
|
||||||
|
$r16Goo = [
|
||||||
|
'Otavite',
|
||||||
|
'Sperrylite',
|
||||||
|
'Vanadinite',
|
||||||
|
'Chromite',
|
||||||
|
];
|
||||||
|
|
||||||
|
$r32Goo = [
|
||||||
|
'Carnotite',
|
||||||
|
'Zircon',
|
||||||
|
'Pollucite',
|
||||||
|
'Cinnabar',
|
||||||
|
];
|
||||||
|
|
||||||
|
$r64Goo = [
|
||||||
|
'Xenotime',
|
||||||
|
'Monazite',
|
||||||
|
'Loparite',
|
||||||
|
'Ytterbite',
|
||||||
|
];
|
||||||
|
|
||||||
|
$systems = [
|
||||||
|
'0-NTIS',
|
||||||
|
'1-NJLK',
|
||||||
|
'35-JWD',
|
||||||
|
'8KR9-5',
|
||||||
|
'EIMJ-M',
|
||||||
|
'F-M1FU',
|
||||||
|
'G-C8QO',
|
||||||
|
'I6M-9U',
|
||||||
|
'L5D-ZL',
|
||||||
|
'L-YMYU',
|
||||||
|
'VQE-CN',
|
||||||
|
'VR-YIQ',
|
||||||
|
'XZ-SKZ',
|
||||||
|
'Y-CWQY',
|
||||||
|
];
|
||||||
|
|
||||||
|
//Get all of the moons which are not rented
|
||||||
|
$allyMoons = AllianceMoon::all();
|
||||||
|
|
||||||
|
foreach($allyMoons as $moon) {
|
||||||
|
$ores = AllianceMoonOre::where([
|
||||||
|
'moon_id' => $moon->moon_id,
|
||||||
|
])->get(['ore_name', 'quantity'])->toArray();
|
||||||
|
|
||||||
|
$moons->push([
|
||||||
|
'system' => $moon->system_name,
|
||||||
|
'moon_name' => $moon->name,
|
||||||
|
'ores' => $ores,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('miningtax.user.display.moons.allmoons')->with('moons', $moons)
|
||||||
|
->with('systems', $systems)
|
||||||
|
->with('r4Goo', $r4Goo)
|
||||||
|
->with('r8Goo', $r8Goo)
|
||||||
|
->with('r16Goo', $r16Goo)
|
||||||
|
->with('r32Goo', $r32Goo)
|
||||||
|
->with('r64Goo', $r64Goo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display an invoice based on it's id
|
||||||
|
*
|
||||||
|
* @var $invoiceId
|
||||||
|
*/
|
||||||
|
public function displayInvoice($invoiceId) {
|
||||||
|
$ores = array();
|
||||||
|
$moons = array();
|
||||||
|
$totalPrice = 0.00;
|
||||||
|
$config = config('esi');
|
||||||
|
$structure = new StructureHelper($config['primary'], $config['corporation']);
|
||||||
|
|
||||||
|
$systems = AllianceMoon::where([
|
||||||
|
'rented' => 'No',
|
||||||
|
])->pluck('system_name')->unique()->toArray();
|
||||||
|
|
||||||
|
//Get the invoice from the database
|
||||||
|
$invoice = Invoice::where([
|
||||||
|
'invoice_id' => $invoiceId,
|
||||||
|
])->first();
|
||||||
|
|
||||||
|
//Get the line items for the ledger for the invoice
|
||||||
|
$items = Ledger::where([
|
||||||
|
'invoice_id' => $invoiceId,
|
||||||
|
])->get();
|
||||||
|
|
||||||
|
//Build the total ores table for the display page
|
||||||
|
foreach($items as $item) {
|
||||||
|
if(!isset($ores[$item['ore_name']])) {
|
||||||
|
$ores[$item['ore_name']] = 0;
|
||||||
|
}
|
||||||
|
$ores[$item['ore_name']] = $ores[$item['ore_name']] + $item['quantity'];
|
||||||
|
|
||||||
|
$totalPrice += $item['amount'];
|
||||||
|
}
|
||||||
|
|
||||||
|
//Print out the lines of the ledger line by line for another table
|
||||||
|
foreach($items as $item) {
|
||||||
|
//Get the structure info from the database or esi
|
||||||
|
$tempObserverInfo = $structure->GetStructureInfo($item['observer_id']);
|
||||||
|
|
||||||
|
//Create the array for the line by line
|
||||||
|
array_push($moons, [
|
||||||
|
'character_name' => $item['character_name'],
|
||||||
|
'observer_name' => $tempObserverInfo->structure_name,
|
||||||
|
'type_id' => $item['type_id'],
|
||||||
|
'ore_name' => $item['ore_name'],
|
||||||
|
'quantity' => $item['quantity'],
|
||||||
|
'amount' => $item['amount'],
|
||||||
|
'tax_amount' => $item['amount'] * $config['public_mining_tax'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('miningtax.user.display.details.invoice')->with('ores', $ores)
|
||||||
|
->with('moons', $moons)
|
||||||
|
->with('invoice', $invoice)
|
||||||
|
->with('totalPrice', $totalPrice);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the users invoices
|
* Display the users invoices
|
||||||
*/
|
*/
|
||||||
@@ -73,20 +430,20 @@ class MiningTaxesController extends Controller
|
|||||||
|
|
||||||
//Total up the unpaid invoices
|
//Total up the unpaid invoices
|
||||||
foreach($unpaid as $un) {
|
foreach($unpaid as $un) {
|
||||||
$unpaidAmount += $un->amount;
|
$unpaidAmount += $un->invoice_amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Total up the paid invoices
|
//Total up the paid invoices
|
||||||
foreach($paid as $p) {
|
foreach($paid as $p) {
|
||||||
$paidAmount += $p;
|
$paidAmount += $p->invoice_amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('miningtax.user.display.invoices')->with('unpaid', $unpaid)
|
return view('miningtax.user.display.invoices.invoices')->with('unpaid', $unpaid)
|
||||||
->with('late', $late)
|
->with('late', $late)
|
||||||
->with('deferred', $deferred)
|
->with('deferred', $deferred)
|
||||||
->with('paid', $paid)
|
->with('paid', $paid)
|
||||||
->with('unpaidAmount', $unpaidAmount)
|
->with('unpaidAmount', $unpaidAmount)
|
||||||
->with('paidAmount', $paidAmount);
|
->with('paidAmount', $paidAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -123,8 +480,9 @@ class MiningTaxesController extends Controller
|
|||||||
//Basically get the structure info and attach it to the variable set
|
//Basically get the structure info and attach it to the variable set
|
||||||
foreach($extractions as $ex) {
|
foreach($extractions as $ex) {
|
||||||
$sName = $sHelper->GetStructureInfo($ex->structure_id);
|
$sName = $sHelper->GetStructureInfo($ex->structure_id);
|
||||||
|
//Add the information into the structures array to go to the page to be displayed
|
||||||
array_push($structures, [
|
array_push($structures, [
|
||||||
'structure_name' => $sName->name,
|
'structure_name' => $sName->structure_name,
|
||||||
'start_time' => $esiHelper->DecodeDate($ex->extraction_start_time),
|
'start_time' => $esiHelper->DecodeDate($ex->extraction_start_time),
|
||||||
'arrival_time' => $esiHelper->DecodeDate($ex->chunk_arrival_time),
|
'arrival_time' => $esiHelper->DecodeDate($ex->chunk_arrival_time),
|
||||||
'decay_time' => $esiHelper->DecodeDate($ex->natural_decay_time),
|
'decay_time' => $esiHelper->DecodeDate($ex->natural_decay_time),
|
||||||
@@ -195,7 +553,7 @@ class MiningTaxesController extends Controller
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
//Return the view with the extractions variable for html processing
|
//Return the view with the extractions variable for html processing
|
||||||
return view('miningtax.user.display.upcoming')->with('structures', $structures)
|
return view('miningtax.user.display.pulls.upcoming')->with('structures', $structures)
|
||||||
->with('lava', $lava)
|
->with('lava', $lava)
|
||||||
->with('calendar', $calendar);
|
->with('calendar', $calendar);
|
||||||
}
|
}
|
||||||
@@ -212,7 +570,6 @@ class MiningTaxesController extends Controller
|
|||||||
$esiHelper = new Esi;
|
$esiHelper = new Esi;
|
||||||
$lookup = new LookupHelper;
|
$lookup = new LookupHelper;
|
||||||
$config = config('esi');
|
$config = config('esi');
|
||||||
$sHelper = new StructureHelper($config['primary'], $config['corporation']);
|
|
||||||
|
|
||||||
//Check for the esi scope
|
//Check for the esi scope
|
||||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1')) {
|
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1')) {
|
||||||
@@ -228,51 +585,51 @@ class MiningTaxesController extends Controller
|
|||||||
|
|
||||||
//Setup the esi container
|
//Setup the esi container
|
||||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||||
|
//Declare the structure helper after the esi container has been created
|
||||||
|
$sHelper = new StructureHelper($config['primary'], $config['corporation'], $esi);
|
||||||
|
|
||||||
//Get the character data from the lookup table if possible or esi
|
//Get the character data from the lookup table if possible or esi
|
||||||
$character = $lookup->GetCharacterInfo($config['primary']);
|
$character = $lookup->GetCharacterInfo($config['primary']);
|
||||||
|
|
||||||
|
//Get the corporation information from the character id
|
||||||
|
$corpInfo = $lookup->GetCorporationInfo($character->corporation_id);
|
||||||
|
|
||||||
//Get the observers from the database
|
//Get the observers from the database
|
||||||
$observers = Observer::all();
|
$observers = Observer::all();
|
||||||
|
|
||||||
$corpInfo = $lookup->GetCorporationInfo(auth()->user()->getId());
|
|
||||||
|
|
||||||
//Get the ledgers for each structure one at a time
|
//Get the ledgers for each structure one at a time
|
||||||
foreach($observers as $obs) {
|
foreach($observers as $obs) {
|
||||||
|
//Get the structure information
|
||||||
|
$structureInfo = $sHelper->GetStructureInfo($obs->observer_id);
|
||||||
|
|
||||||
|
//Add the name to the structures array
|
||||||
|
array_push($structures, $structureInfo->name);
|
||||||
/**
|
/**
|
||||||
* Get the ledger from each observer.
|
* Get the ledger from each observer.
|
||||||
* We don't care about observer type as it can only be an Athanor or Tatara
|
* We don't care about observer type as it can only be an Athanor or Tatara
|
||||||
*/
|
*/
|
||||||
$ledgers = Ledger::where([
|
$ledgers = Ledger::where([
|
||||||
'observer_id' => $obs->structure_id,
|
'observer_id' => $obs->observer_id,
|
||||||
'character_id' => auth()->user()->getId(),
|
'character_id' => auth()->user()->getId(),
|
||||||
])->where('last_updated', '>=', Carbon::now()->subDays(30))->get();
|
])->where('last_updated', '>=', Carbon::now()->subDays(30))->get();
|
||||||
|
|
||||||
if($ledgers != null) {
|
if($ledgers->count() > 0) {
|
||||||
foreach($ledgers as $ledger) {
|
foreach($ledgers as $ledger) {
|
||||||
//Get the structure name from the database
|
//Foreach ledger add it to the array
|
||||||
$structure = $sHelper->GetStructureInfo($obs->observer_id);
|
|
||||||
|
|
||||||
array_push($miningLedgers, [
|
array_push($miningLedgers, [
|
||||||
'structure' => $structure->name,
|
'structure' => $structureInfo->name,
|
||||||
'character' => auth()->user()->getName(),
|
'character' => auth()->user()->getName(),
|
||||||
'corpTicker' => $corpInfo->ticker,
|
'corpTicker' => $corpInfo->ticker,
|
||||||
'ore' => $ore,
|
'ore' => $ledger->ore_name,
|
||||||
'quantity' => $ledger->quantity,
|
'quantity' => $ledger->quantity,
|
||||||
'updated' => $ledger->last_updated,
|
'updated' => $ledger->last_updated,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
array_push($structures, [
|
|
||||||
'name' => $structure->name,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
redirect('/dashboard')->with('error', 'No available data for the mining ledger to be displayed.');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Return the view
|
//Return the view
|
||||||
return view('miningtax.user.display.ledger')->with('miningLedgers', $miningLedgers)
|
return view('miningtax.user.display.details.ledger')->with('miningLedgers', $miningLedgers)
|
||||||
->with('structures', $structures);
|
->with('structures', $structures);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,27 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Test;
|
namespace App\Http\Controllers\Test;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use Log;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
//Application Library
|
||||||
use App\Library\Helpers\LookupHelper;
|
use App\Library\Helpers\LookupHelper;
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
use App\Library\Moons\MoonCalc;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\MoonRental\AllianceMoon;
|
||||||
|
use App\Models\MoonRental\AllianceMoonOre;
|
||||||
|
use App\Models\MiningTax\Invoice;
|
||||||
|
use App\Models\MiningTax\Ledger;
|
||||||
|
use App\Models\MiningTax\Observer;
|
||||||
|
use App\Models\User\UserAlt;
|
||||||
|
use App\Models\User\User;
|
||||||
|
|
||||||
class TestController extends Controller
|
class TestController extends Controller
|
||||||
{
|
{
|
||||||
@@ -19,7 +36,331 @@ class TestController extends Controller
|
|||||||
return view('test.char.display')->with('char', $char);
|
return view('test.char.display')->with('char', $char);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function CharacterLookupTest(Request $request) {
|
public function DebugMiningTaxesInvoices() {
|
||||||
|
//Declare variables
|
||||||
|
$mailDelay = 15;
|
||||||
|
$mains = new Collection;
|
||||||
|
$perms = null;
|
||||||
|
$config = config('esi');
|
||||||
|
$bodies = new Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This section will determine if users are mains or alts of a main.
|
||||||
|
* If they are mains, we keep the key. If they are alts of a main, then we delete
|
||||||
|
* the key from the collection.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//Pluck all the users from the database of ledgers to determine if they are mains or alts.
|
||||||
|
$tempMains = Ledger::where([
|
||||||
|
'invoiced' => 'Yes',
|
||||||
|
])->where('last_updated', '>', Carbon::now()->subDays(7))->pluck('character_id');
|
||||||
|
|
||||||
|
//Get the unique character ids from the ledgers in the previous statement
|
||||||
|
$tempMains = $tempMains->unique()->values()->all();
|
||||||
|
|
||||||
|
//Cycle through the array of mains, and remove any characters which are in the User Alt table,
|
||||||
|
//as those characters will be grouped with their correct main later.
|
||||||
|
for($i = 0; $i < sizeof($tempMains); $i++) {
|
||||||
|
if(UserAlt::where(['character_id' => $tempMains[$i]])->count() == 0) {
|
||||||
|
$mains->push($tempMains[$i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For each of the users, let's determine if there are any ledgers,
|
||||||
|
* then determine if there are any alts and ledgers associated with the alts.
|
||||||
|
*/
|
||||||
|
foreach($mains as $main) {
|
||||||
|
//Declare some variables for each run through the for loop
|
||||||
|
$ledgers = new Collection;
|
||||||
|
|
||||||
|
//Count the ledgers for the main
|
||||||
|
$mainLedgerCount = Ledger::where([
|
||||||
|
'character_id' => $main,
|
||||||
|
'invoiced' => 'Yes',
|
||||||
|
])->where('last_updated', '>', Carbon::now()->subDays(7))->count();
|
||||||
|
|
||||||
|
//If there are ledgers for the main, then let's grab them
|
||||||
|
if($mainLedgerCount > 0) {
|
||||||
|
$mainLedgers = Ledger::where([
|
||||||
|
'character_id' => $main,
|
||||||
|
'invoiced' => 'Yes',
|
||||||
|
])->where('last_updated', '>', Carbon::now()->subDays(7))->get();
|
||||||
|
|
||||||
|
//Cycle through the entries, and add them to the ledger to send with the invoice
|
||||||
|
foreach($mainLedgers as $row) {
|
||||||
|
$ledgers->push([
|
||||||
|
'character_id' => $row->character_id,
|
||||||
|
'character_name' => $row->character_name,
|
||||||
|
'observer_id' => $row->observer_id,
|
||||||
|
'type_id' => $row->type_id,
|
||||||
|
'ore_name' => $row->ore_name,
|
||||||
|
'quantity' => (int)$row->quantity,
|
||||||
|
'amount' => (float)$row->amount,
|
||||||
|
'last_updated' => $row->last_updated,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the alt count for the main character
|
||||||
|
$altCount = UserAlt::where(['main_id' => $main])->count();
|
||||||
|
//If more than 0 alts, grab all the alts.
|
||||||
|
if($altCount > 0) {
|
||||||
|
$alts = UserAlt::where([
|
||||||
|
'main_id' => $main,
|
||||||
|
])->get();
|
||||||
|
|
||||||
|
//Cycle through the alts, and get the ledgers, and push onto the stack
|
||||||
|
foreach($alts as $alt) {
|
||||||
|
$altLedgerCount = Ledger::where([
|
||||||
|
'character_id' => $alt->character_id,
|
||||||
|
'invoiced' => 'Yes',
|
||||||
|
])->where('last_updated', '>', Carbon::now()->subDays(7))->count();
|
||||||
|
|
||||||
|
if($altLedgerCount > 0) {
|
||||||
|
$altLedgers = Ledger::where([
|
||||||
|
'character_id' => $alt->character_id,
|
||||||
|
'invoiced' => 'Yes',
|
||||||
|
])->where('last_updated', '>', Carbon::now()->subDays(7))->get();
|
||||||
|
|
||||||
|
foreach($altLedgers as $row) {
|
||||||
|
$ledgers->push([
|
||||||
|
'character_id' => $row->character_id,
|
||||||
|
'character_name' => $row->character_name,
|
||||||
|
'observer_id' => $row->observer_id,
|
||||||
|
'type_id' => $row->type_id,
|
||||||
|
'ore_name' => $row->ore_name,
|
||||||
|
'quantity' => (int)$row->quantity,
|
||||||
|
'amount' => (float)$row->amount,
|
||||||
|
'last_updated' => $row->last_updated,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the collected information over to the function to send the actual mail
|
||||||
|
*/
|
||||||
|
if($ledgers->count() > 0) {
|
||||||
|
$body = $this->CreateInvoice($main, $ledgers, $mailDelay);
|
||||||
|
$bodies->push($body);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('test.miningtax.invoice')->with('bodies', $bodies);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the invoice to the mail out
|
||||||
|
*
|
||||||
|
* @var charId
|
||||||
|
* @var ledgers
|
||||||
|
* @var mailDelay
|
||||||
|
*/
|
||||||
|
private function CreateInvoice($charId, Collection $ledgers, int &$mailDelay) {
|
||||||
|
$ores = array();
|
||||||
|
$characters = array();
|
||||||
|
$characterIds = array();
|
||||||
|
$totalPrice = 0.00;
|
||||||
|
$body = null;
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$config = config('esi');
|
||||||
|
|
||||||
|
//Create an invoice id
|
||||||
|
$invoiceId = "M" . uniqid();
|
||||||
|
|
||||||
|
//Collect the total price of all of the ledgers
|
||||||
|
$totalPrice = round((float)$ledgers->sum('amount'), 2);
|
||||||
|
|
||||||
|
//Get the sum of all the ledgers
|
||||||
|
$invoiceAmount = round(((float)$ledgers->sum('amount') * (float)$config['mining_tax']), 2);
|
||||||
|
|
||||||
|
//Get the character name from the lookup table
|
||||||
|
$charName = $lookup->CharacterIdToName($charId);
|
||||||
|
|
||||||
|
//Create the date due and the invoice date
|
||||||
|
$dateDue = Carbon::now()->addDays(7);
|
||||||
|
$invoiceDate = Carbon::now();
|
||||||
|
|
||||||
|
//Set the mining tax from the config file
|
||||||
|
$numberMiningTax = number_format(((float)$config['mining_tax'] * (float)100.00), 2, ".", ",");
|
||||||
|
|
||||||
|
//Create the list of ores to put in the mail
|
||||||
|
$temp = $ledgers->toArray();
|
||||||
|
foreach($temp as $t) {
|
||||||
|
//If the key isn't set, set it to the default of 0
|
||||||
|
if(!isset($ores[$t['type_id']])) {
|
||||||
|
$ores[$t['type_id']] = (int)0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add the quantity into the ores array
|
||||||
|
$ores[$t['type_id']] += (int)$t['quantity'];
|
||||||
|
|
||||||
|
//Create a list of character names
|
||||||
|
if(!isset($characters[$t['character_name']])) {
|
||||||
|
$characters[$t['character_name']] = $t['character_name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create a list of character ids
|
||||||
|
if(!isset($characterIds[$t['character_id']])) {
|
||||||
|
$characterIds[$t['character_id']] = $t['character_id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the mail body to send to the main character
|
||||||
|
*/
|
||||||
|
$body .= "Dear " . $charName . ",<br><br>";
|
||||||
|
$body .= "Mining Taxes are due for the following ores mined from alliance moons: <br>";
|
||||||
|
foreach($ores as $ore => $quantity) {
|
||||||
|
$oreName = $lookup->ItemIdToName($ore);
|
||||||
|
$body .= $oreName . ": " . number_format($quantity, 0, ".", ",") . "<br>";
|
||||||
|
}
|
||||||
|
$body .= "Total Value of Ore Mined: " . number_format($totalPrice, 2, ".", ",") . " ISK.";
|
||||||
|
$body .= "<br><br>";
|
||||||
|
$body .= "Please remit " . number_format($invoiceAmount, 2, ".", ",") . " ISK to Spatial Forces by " . $dateDue . "<br>";
|
||||||
|
$body .= "Set the reason for transfer as " . $invoiceId . "<br>";
|
||||||
|
$body .= "The mining taxes are currently set to " . $numberMiningTax . "%.<br>";
|
||||||
|
$body .= "<br><br>";
|
||||||
|
$body .= "You can also send a contract with the following ores in the contract with the reason set as: " . $invoiceId . "<br>";
|
||||||
|
foreach($ores as $ore => $quantity) {
|
||||||
|
$oreName = $lookup->ItemIdToName($ore);
|
||||||
|
$body .= $oreName . ": " . number_format(round($quantity * $config['mining_tax']), 0, ".", ",") . "<br>";
|
||||||
|
}
|
||||||
|
$body .= "<br>";
|
||||||
|
$body .= "Characters Processed: <br>";
|
||||||
|
foreach($characters as $character) {
|
||||||
|
$body .= $character . "<br>";
|
||||||
|
}
|
||||||
|
$body .= "<br>";
|
||||||
|
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
|
||||||
|
|
||||||
|
//Check if the mail body is greater than 2000 characters. If greater than 2,000 characters, then
|
||||||
|
if(strlen($body) > 2000) {
|
||||||
|
$body = "Dear " . $charName . "<br><br>";
|
||||||
|
$body .= "Total Value of Ore Mined: " . number_format($totalPrice, 2, ".", ",") . " ISK.";
|
||||||
|
$body .= "<br><br>";
|
||||||
|
$body .= "Please remit " . number_format($invoiceAmount, 2, ".", ",") . " ISK to Spatial Forces by " . $dateDue . "<br>";
|
||||||
|
$body .= "Set the reason for transfer as: " . $invoiceId . "<br>";
|
||||||
|
$body .= "The mining taxes are currently set to " . $numberMiningTax . "%.<br>";
|
||||||
|
$body .= "<br>";
|
||||||
|
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Increment the mail delay for the next cycle
|
||||||
|
*/
|
||||||
|
$mailDelay += 20;
|
||||||
|
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function DebugMiningObservers() {
|
||||||
|
//Declare variables
|
||||||
|
$mailDelay = 15;
|
||||||
|
$config = config('esi');
|
||||||
|
$mains = new Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This section will determine if users are mains or alts of a main.
|
||||||
|
* If they are mains, we keep the key. If they are alts of a main, then we delete
|
||||||
|
* the key from the collection.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//Pluck all the users from the database of ledgers to determine if they are mains or alts.
|
||||||
|
$tempMains = Ledger::where([
|
||||||
|
'invoiced' => 'Yes',
|
||||||
|
])->where('last_updated', '>', Carbon::now()->subMonths(3))->pluck('character_id');
|
||||||
|
|
||||||
|
//Get the unique character ids from the ledgers in the previous statement
|
||||||
|
$tempMains = $tempMains->unique()->values()->all();
|
||||||
|
|
||||||
|
for($i = 0; $i < sizeof($tempMains); $i++) {
|
||||||
|
if(UserAlt::where(['character_id' => $tempMains[$i]])->count() == 0) {
|
||||||
|
$mains->push($tempMains[$i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For each of the users, let's determine if there are any ledgers,
|
||||||
|
* then determine if there are any alts and ledgers associated with the alts.
|
||||||
|
*/
|
||||||
|
foreach($mains as $main) {
|
||||||
|
//Declare some variables for each run through the for loop
|
||||||
|
$mainLedgerCount = 0;
|
||||||
|
$ledgers = new Collection;
|
||||||
|
|
||||||
|
//Count the ledgers for the main
|
||||||
|
$mainLedgerCount = Ledger::where([
|
||||||
|
'character_id' => $main,
|
||||||
|
'invoiced' => 'Yes',
|
||||||
|
])->where('last_updated', '>', Carbon::now()->subMonths(3))->count();
|
||||||
|
|
||||||
|
//If there are ledgers for the main, then let's grab them
|
||||||
|
if($mainLedgerCount > 0) {
|
||||||
|
$mainLedgers = Ledger::where([
|
||||||
|
'character_id' => $main,
|
||||||
|
'invoiced' => 'Yes',
|
||||||
|
])->where('last_updated', '>', Carbon::now()->subMonths(3))->get();
|
||||||
|
|
||||||
|
//Cycle through the entries, and add them to the ledger to send with the invoice
|
||||||
|
foreach($mainLedgers as $row) {
|
||||||
|
$ledgers->push([
|
||||||
|
'character_id' => $row->character_id,
|
||||||
|
'character_name' => $row->character_name,
|
||||||
|
'observer_id' => $row->observer_id,
|
||||||
|
'type_id' => $row->type_id,
|
||||||
|
'ore_name' => $row->ore_name,
|
||||||
|
'quantity' => $row->quantity,
|
||||||
|
'amount' => (float)$row->amount,
|
||||||
|
'last_updated' => $row->last_updated,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the alt count for the main character
|
||||||
|
$altCount = UserAlt::where(['main_id' => $main])->count();
|
||||||
|
//If more than 0 alts, grab all the alts.
|
||||||
|
if($altCount > 0) {
|
||||||
|
$alts = UserAlt::where([
|
||||||
|
'main_id' => $main,
|
||||||
|
])->get();
|
||||||
|
|
||||||
|
//Cycle through the alts, and get the ledgers, and push onto the stack
|
||||||
|
foreach($alts as $alt) {
|
||||||
|
$altLedgerCount = Ledger::where([
|
||||||
|
'character_id' => $alt->character_id,
|
||||||
|
'invoiced' => 'Yes',
|
||||||
|
])->where('last_updated', '>', Carbon::now()->subMonths(3))->count();
|
||||||
|
|
||||||
|
if($altLedgerCount > 0) {
|
||||||
|
$altLedgers = Ledger::where([
|
||||||
|
'character_id' => $alt->character_id,
|
||||||
|
'invoiced' => 'Yes',
|
||||||
|
])->where('last_updated', '>', Carbon::now()->subMonths(3))->get();
|
||||||
|
|
||||||
|
foreach($altLedgers as $row) {
|
||||||
|
$ledgers->push([
|
||||||
|
'character_id' => $row->character_id,
|
||||||
|
'character_name' => $row->character_name,
|
||||||
|
'observer_id' => $row->observer_id,
|
||||||
|
'type_id' => $row->type_id,
|
||||||
|
'ore_name' => $row->ore_name,
|
||||||
|
'quantity' => $row->quantity,
|
||||||
|
'amount' => (float)$row->amount,
|
||||||
|
'last_updated' => $row->last_updated,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($ledgers->count() > 0) {
|
||||||
|
var_dump($ledgers);
|
||||||
|
var_dump(round(((float)$ledgers->sum('amount') * (float)$config['mining_tax']), 2));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class Authenticate extends Middleware
|
|||||||
protected function redirectTo($request)
|
protected function redirectTo($request)
|
||||||
{
|
{
|
||||||
if(!$this->auth->check()){
|
if(!$this->auth->check()){
|
||||||
return route('/');
|
return '/';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use Closure;
|
|||||||
use DB;
|
use DB;
|
||||||
|
|
||||||
use App\Models\User\UserPermission;
|
use App\Models\User\UserPermission;
|
||||||
|
use App\Models\User\UserRole;
|
||||||
|
|
||||||
class RequirePermission
|
class RequirePermission
|
||||||
{
|
{
|
||||||
@@ -18,9 +19,15 @@ class RequirePermission
|
|||||||
*/
|
*/
|
||||||
public function handle($request, Closure $next, $permission)
|
public function handle($request, Closure $next, $permission)
|
||||||
{
|
{
|
||||||
$perms = UserPermission::where(['character_id' => auth()->user()->character_id, 'permission'=> $permission])->get(['permission']);
|
$role = UserRole::where([
|
||||||
|
'character_id' => auth()->user()->character_id,
|
||||||
|
])->get(['role']);
|
||||||
|
|
||||||
abort_unless(auth()->check() && isset($perms[0]->permission), 403, "You don't have the correct permission to be in this area.");
|
if($role[0]->role != "Admin") {
|
||||||
|
$perms = UserPermission::where(['character_id' => auth()->user()->character_id, 'permission'=> $permission])->get(['permission']);
|
||||||
|
|
||||||
|
abort_unless(auth()->check() && isset($perms[0]->permission), 403, "You don't have the correct permission to be in this area.");
|
||||||
|
}
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|||||||
10
app/Http/Requests/Request.php
Normal file
10
app/Http/Requests/Request.php
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
abstract class Request extends FormRequest
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
176
app/Jobs/Commands/Assets/FetchAllianceAssets.php
Normal file
176
app/Jobs/Commands/Assets/FetchAllianceAssets.php
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\Assets;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
//Application Library
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
use App\Library\Helpers\LookupHelper;
|
||||||
|
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Structure\Asset;
|
||||||
|
|
||||||
|
class FetchAllianceAssets implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of job retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $tries = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//Set the connection for the job
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('assets');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Declare variables
|
||||||
|
$config = config('esi');
|
||||||
|
$corpId = 98287666;
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
|
//Get the refresh token from the database
|
||||||
|
$token = $esiHelper->GetRefreshToken($config['primary']);
|
||||||
|
//Create the esi authentication container
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||||
|
|
||||||
|
//Check the esi scope
|
||||||
|
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-assets.read_corporation_assets.v1')) {
|
||||||
|
Log::critical("Scope check failed in FetchAllianceAssets for esi-assets.read_corporation_assets.v1");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Set the current page
|
||||||
|
$currentPage = 1;
|
||||||
|
//Set our default pages
|
||||||
|
$totalPages = 1;
|
||||||
|
|
||||||
|
do {
|
||||||
|
if($esiHelper->TokenExpired($token)) {
|
||||||
|
$token = $esiHelper->GetRefreshToken($config['primary']);
|
||||||
|
$esi = $esiHelper->SetupAuthenticationToken($token);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Attempt to get the assets
|
||||||
|
$assets = $esi->page($currentPage)
|
||||||
|
->invoke('get', '/corporations/{corporation_id}/assets/', [
|
||||||
|
'corporation_id' => $corpId,
|
||||||
|
]);
|
||||||
|
|
||||||
|
//If on the first page, then update the total number of pages
|
||||||
|
if($currentPage == 1) {
|
||||||
|
$totalPages = $assets->pages;
|
||||||
|
}
|
||||||
|
|
||||||
|
//For each asset retrieved, let's process it.
|
||||||
|
foreach($assets as $a) {
|
||||||
|
ProcessAllianceAssets::dispatch($a);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Increment the current page
|
||||||
|
$currentPage++;
|
||||||
|
} while($currentPage <= $totalPages);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The job failed to process
|
||||||
|
* @param Exception $exception
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function failed($exception) {
|
||||||
|
if(!exception instanceof RequestFailedException) {
|
||||||
|
//If not a failure due to ESI, then log it. Otherwise,
|
||||||
|
//deduce why the exception occurred.
|
||||||
|
Log::critical($exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((is_object($exception->getEsiResponse()) && (stristr($exception->getEsiResponse()->error, 'Too many errors') || stristr($exception->getEsiResponse()->error, 'This software has exceeded the error limit for ESI'))) ||
|
||||||
|
(is_string($exception->getEsiResponse()) && (stristr($exception->getEsiResponse(), 'Too many errors') || stristr($exception->getEsiResponse(), 'This software has exceeded the error limit for ESI')))) {
|
||||||
|
|
||||||
|
//We have hit the error rate limiter, wait 120 seconds before releasing the job back into the queue.
|
||||||
|
Log::info('FetchAllianceAssets has hit the error rate limiter. Releasing the job back into the wild in 2 minutes.');
|
||||||
|
$this->release(120);
|
||||||
|
} else {
|
||||||
|
$errorCode = $exception->getEsiResponse()->getErrorCode();
|
||||||
|
|
||||||
|
switch($errorCode) {
|
||||||
|
case 400: //Bad Request
|
||||||
|
Log::critical("Bad request has occurred in FetchAllianceAssets. Job has been discarded");
|
||||||
|
break;
|
||||||
|
case 401: //Unauthorized Request
|
||||||
|
Log::critical("Unauthorized request has occurred in FetchAllianceAssets at " . Carbon::now()->toDateTimeString() . ".\r\nCancelling the job.");
|
||||||
|
$this->delete();
|
||||||
|
break;
|
||||||
|
case 403: //Forbidden
|
||||||
|
Log::critical("FetchAllianceAssets has incurred a forbidden error. Cancelling the job.");
|
||||||
|
$this->delete();
|
||||||
|
break;
|
||||||
|
case 420: //Error Limited
|
||||||
|
Log::warning("Error rate limit occurred in FetchAllianceAssets. Restarting job in 120 seconds.");
|
||||||
|
$this->release(120);
|
||||||
|
break;
|
||||||
|
case 500: //Internal Server Error
|
||||||
|
Log::critical("Internal Server Error for ESI in FetchAllianceAssets. Attempting a restart in 120 seconds.");
|
||||||
|
$this->release(120);
|
||||||
|
break;
|
||||||
|
case 503: //Service Unavailable
|
||||||
|
Log::critical("Service Unavailabe for ESI in FetchAllianceAssets. Releasing the job back to the queue in 30 seconds.");
|
||||||
|
$this->release(30);
|
||||||
|
break;
|
||||||
|
case 504: //Gateway Timeout
|
||||||
|
Log::critical("Gateway timeout in FetchAllianceAssets. Releasing the job back to the queue in 30 seconds.");
|
||||||
|
$this->release(30);
|
||||||
|
break;
|
||||||
|
case 201:
|
||||||
|
//Good response code
|
||||||
|
$this->delete();
|
||||||
|
break;
|
||||||
|
//If no code is given, then log and break out of switch.
|
||||||
|
default:
|
||||||
|
Log::warning("No response code received from esi call in FetchAllianceAssets.\r\n");
|
||||||
|
$this->delete();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tags for jobs
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public function tags() {
|
||||||
|
return ['FetchAllianceAssets', 'AllianceStructures', 'Assets'];
|
||||||
|
}
|
||||||
|
}
|
||||||
109
app/Jobs/Commands/Assets/ProcessAllianceAssets.php
Normal file
109
app/Jobs/Commands/Assets/ProcessAllianceAssets.php
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\Assets;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Structure\Asset;
|
||||||
|
|
||||||
|
class ProcessAllianceAssets implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of job retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $tries = 3;
|
||||||
|
|
||||||
|
//Private variable
|
||||||
|
private $asset;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct($a)
|
||||||
|
{
|
||||||
|
//Set the connection for the job
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('assets');
|
||||||
|
|
||||||
|
$this->asset = $a;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* If the asset is not in the database, then let's save it to the database,
|
||||||
|
* otherwise, we just update the old asset
|
||||||
|
*/
|
||||||
|
$count = Asset::where([
|
||||||
|
'item_id' => $this->asset->item_id,
|
||||||
|
])->count();
|
||||||
|
|
||||||
|
if($count == 0) {
|
||||||
|
$as = new Asset;
|
||||||
|
if(isset($this->asset->is_blueprint_copy)) {
|
||||||
|
$as->is_blueprint_copy = $this->asset->is_blueprint_copy;
|
||||||
|
}
|
||||||
|
$as->is_singleton = $this->asset->is_singleton;
|
||||||
|
$as->item_id = $this->asset->item_id;
|
||||||
|
$as->location_flag = $this->asset->location_flag;
|
||||||
|
$as->location_id = $this->asset->location_id;
|
||||||
|
$as->location_type = $this->asset->location_type;
|
||||||
|
$as->quantity = $this->asset->quantity;
|
||||||
|
$as->type_id = $this->asset->type_id;
|
||||||
|
$as->save();
|
||||||
|
} else {
|
||||||
|
//Update the previously found asset
|
||||||
|
Asset::where([
|
||||||
|
'item_id' => $this->asset->item_id,
|
||||||
|
])->update([
|
||||||
|
'is_singleton' => $this->asset->is_singleton,
|
||||||
|
'location_flag' => $this->asset->location_flag,
|
||||||
|
'location_id' => $this->asset->location_id,
|
||||||
|
'location_type' => $this->asset->location_type,
|
||||||
|
'quantity' => $this->asset->quantity,
|
||||||
|
'type_id' => $this->asset->type_id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if(isset($this->asset->is_blueprint_copy)) {
|
||||||
|
Asset::where([
|
||||||
|
'item_id' => $this->asset->item_id,
|
||||||
|
])->update([
|
||||||
|
'is_blueprint_copy' => $this->asset->is_blueprint_copy,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tags for jobs
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public function tags() {
|
||||||
|
return ['FetchAllianceAssets', 'AllianceStructures', 'Assets'];
|
||||||
|
}
|
||||||
|
}
|
||||||
59
app/Jobs/Commands/Assets/PurgeAllianceAssets.php
Normal file
59
app/Jobs/Commands/Assets/PurgeAllianceAssets.php
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\Assets;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\Commands\Assets\FetchAllianceAssets;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Structure\Asset;
|
||||||
|
|
||||||
|
class PurgeAllianceAssets implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of job retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $tries = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//Set the connection for the job
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('assets');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
Asset::truncate();
|
||||||
|
|
||||||
|
FetchAllianceAssets::dispatch()->delay(Carbon::now()->addSeconds(30));
|
||||||
|
}
|
||||||
|
}
|
||||||
205
app/Jobs/Commands/Data/PurgeUsers.php
Normal file
205
app/Jobs/Commands/Data/PurgeUsers.php
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\Data;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Log;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//Libraries
|
||||||
|
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\User\User;
|
||||||
|
use App\Models\User\UserAlt;
|
||||||
|
use App\Models\Esi\EsiScope;
|
||||||
|
use App\Models\Esi\EsiToken;
|
||||||
|
use App\Models\User\UserPermission;
|
||||||
|
use App\Models\User\UserRole;
|
||||||
|
use App\Models\Admin\AllowedLogin;
|
||||||
|
|
||||||
|
class PurgeUsers implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $retries = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('default');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Declare some variables
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
|
//Setup the esi variable
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication();
|
||||||
|
|
||||||
|
//Get all of the users from the database
|
||||||
|
$users = User::all();
|
||||||
|
|
||||||
|
//Get the allowed logins
|
||||||
|
$legacy = AllowedLogin::where(['login_type' => 'Legacy'])->pluck('entity_id')->toArray();
|
||||||
|
$renter = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_id')->toArray();
|
||||||
|
|
||||||
|
//Cycle through all of the users, and either update their role, or delete them.
|
||||||
|
foreach($users as $user) {
|
||||||
|
//Set the fail bit to false for the next user to check
|
||||||
|
$failed = false;
|
||||||
|
|
||||||
|
//Note a screen entry for when doing cli stuff
|
||||||
|
printf("Processing character with id of " . $user->character_id . "\r\n");
|
||||||
|
|
||||||
|
//Get the character information
|
||||||
|
try {
|
||||||
|
$character_info = $esi->invoke('get', '/characters/{character_id}/', [
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$corp_info = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||||
|
'corporation_id' => $character_info->corporation_id,
|
||||||
|
]);
|
||||||
|
} catch(RequestFailedException $e) {
|
||||||
|
Log::warning('Failed to get character information in purge user command for user ' . $user->character_id);
|
||||||
|
$failed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//If the fail bit is still false, then continue
|
||||||
|
if($failed === false) {
|
||||||
|
//Get the user's role
|
||||||
|
$role = UserRole::where(['character_id' => $user->character_id])->first();
|
||||||
|
|
||||||
|
//We don't want to modify Admin and SuperUsers. Admins and SuperUsers are removed via a different process.
|
||||||
|
if($role->role != 'Admin') {
|
||||||
|
//Check if the user is allowed to login
|
||||||
|
if(isset($corp_info->alliance_id)) {
|
||||||
|
//Warped Intentions is allowed to login
|
||||||
|
if($corp_info->alliance_id == '99004116') {
|
||||||
|
//If the alliance is Warped Intentions, then modify the role if we need to
|
||||||
|
if($role->role != 'User') {
|
||||||
|
//Upate the role of the user
|
||||||
|
UserRole::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->update([
|
||||||
|
'role' => 'User',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Update the user type
|
||||||
|
User::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->update([
|
||||||
|
'user_type' => 'W4RP',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} else if(in_array($corp_info->alliance_id, $legacy)) { //Legacy Users
|
||||||
|
if($role->role != 'User') {
|
||||||
|
//Update the role of the user
|
||||||
|
UserRole::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->update([
|
||||||
|
'role' => 'User',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Update the user type
|
||||||
|
User::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->update([
|
||||||
|
'user_type' => 'Legacy',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} else if(in_array($corp_info->alliance_id, $renter)) { //Renter Users
|
||||||
|
if($role->role != 'Renter') {
|
||||||
|
//Update the role of the user
|
||||||
|
UserRole::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->update([
|
||||||
|
'role' => 'Renter',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Update the user type
|
||||||
|
User::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->update([
|
||||||
|
'user_type' => 'Renter',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//If the user is part of no valid login group, then delete the user.
|
||||||
|
//Delete all of the permissions first
|
||||||
|
UserPermission::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->delete();
|
||||||
|
|
||||||
|
//Delete the user's role
|
||||||
|
UserRole::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->delete();
|
||||||
|
|
||||||
|
//Delete any alts the user might have registered.
|
||||||
|
$altCount = UserAlt::where(['main_id' => $user->character_id])->count();
|
||||||
|
if($altCount > 0) {
|
||||||
|
UserAlt::where([
|
||||||
|
'main_id' => $user->character_id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Delete the user's esi scopes
|
||||||
|
EsiScope::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->delete();
|
||||||
|
|
||||||
|
//Delete the user's esi token
|
||||||
|
EsiToken::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->delete();
|
||||||
|
|
||||||
|
//Delete the user from the user table
|
||||||
|
User::where([
|
||||||
|
'character_id' => $user->character_id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the tags for Horzion
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public function tags() {
|
||||||
|
return ['Data', 'PurgeUsers'];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,10 +12,24 @@ use Log;
|
|||||||
//Library
|
//Library
|
||||||
use App\Library\Moons\MoonCalc;
|
use App\Library\Moons\MoonCalc;
|
||||||
|
|
||||||
class ItemPricesUpdateJob implements ShouldQueue
|
class ItemPricesUpdate implements ShouldQueue
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of job retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $tries = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*
|
*
|
||||||
@@ -23,7 +37,8 @@ class ItemPricesUpdateJob implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
//
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('default');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,4 +52,13 @@ class ItemPricesUpdateJob implements ShouldQueue
|
|||||||
|
|
||||||
$moonHelper->FetchNewPrices();
|
$moonHelper->FetchNewPrices();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the tags for Horzion
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public function tags() {
|
||||||
|
return ['Eve', 'ItemPricesUpdate'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,157 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Jobs\Commands\Eve;
|
|
||||||
|
|
||||||
//Internal Library
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Spatie\RateLimitedMiddleware\RateLimited;
|
|
||||||
use Log;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
//Library
|
|
||||||
use App\Library\Esi\Esi;
|
|
||||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
|
||||||
use Seat\Eseye\Cache\NullCache;
|
|
||||||
use Seat\Eseye\Configuration;
|
|
||||||
|
|
||||||
//Models
|
|
||||||
use App\Models\Esi\EsiScope;
|
|
||||||
use App\Models\Esi\EsiToken;
|
|
||||||
use App\Models\Jobs\JobStatus;
|
|
||||||
use App\Models\Mail\SentMail;
|
|
||||||
|
|
||||||
class ProcessSendEveMailJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Timeout in seconds
|
|
||||||
* With new rate limiting, we shouldn't use this timeout
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
//public $timeout = 3600;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retries
|
|
||||||
* With new rate limiting, we shouldn't use this timeout
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
//public $retries = 3;
|
|
||||||
|
|
||||||
private $sender;
|
|
||||||
private $body;
|
|
||||||
private $recipient;
|
|
||||||
private $recipient_type;
|
|
||||||
private $subject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new job instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct($body, $recipient, $recipient_type, $subject, $sender) {
|
|
||||||
$this->body = $body;
|
|
||||||
$this->recipient = $recipient;
|
|
||||||
$this->recipient_type = $recipient_type;
|
|
||||||
$this->subject = $subject;
|
|
||||||
$this->sender = $sender;
|
|
||||||
|
|
||||||
$this->connection = 'redis';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the job.
|
|
||||||
* Utilized by using ProcessSendEveMailJob::dispatch($mail);
|
|
||||||
* The model is passed into the dispatch function, then added to the queue
|
|
||||||
* for processing.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
//Declare some variables
|
|
||||||
$esiHelper = new Esi;
|
|
||||||
|
|
||||||
//Get the esi configuration
|
|
||||||
$config = config('esi');
|
|
||||||
|
|
||||||
//Retrieve the token for main character to send mails from
|
|
||||||
$token = $esiHelper->GetRefreshToken($config['primary']);
|
|
||||||
|
|
||||||
//Create the ESI authentication container
|
|
||||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
|
||||||
|
|
||||||
//Attemp to send the mail
|
|
||||||
try {
|
|
||||||
$esi->setBody([
|
|
||||||
'approved_cost' => 100,
|
|
||||||
'body' => $this->body,
|
|
||||||
'recipients' => [[
|
|
||||||
'recipient_id' => $this->recipient,
|
|
||||||
'recipient_type' => $this->recipient_type,
|
|
||||||
]],
|
|
||||||
'subject' => $this->subject,
|
|
||||||
])->invoke('post', '/characters/{character_id}/mail/', [
|
|
||||||
'character_id'=> $this->sender,
|
|
||||||
]);
|
|
||||||
} catch(RequestFailedException $e) {
|
|
||||||
Log::warning($e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->SaveSentRecord($this->sender, $this->subject, $this->body, $this->recipient, $this->recipient_type);
|
|
||||||
|
|
||||||
$this->delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Middleware to only allow 4 jobs to be run per minute
|
|
||||||
* After a failed job, the job is released back into the queue for at least 1 minute x the number of times attempted
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function middleware() {
|
|
||||||
|
|
||||||
//Allow 4 jobs per minute, and implement a rate limited backoff on failed jobs
|
|
||||||
$rateLimitedMiddleware = (new RateLimited())
|
|
||||||
->allow(4)
|
|
||||||
->everySeconds(60)
|
|
||||||
->releaseAfterOneMinute()
|
|
||||||
->releaseAfterBackoff($this->attempts());
|
|
||||||
|
|
||||||
return [new RateLimited()];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Determine the time at which the job should timeout.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function retryUntil() : \DateTime
|
|
||||||
{
|
|
||||||
return Carbon::now()->addDay();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The job failed to process.
|
|
||||||
*
|
|
||||||
* @param Exception $exception
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function failed($exception)
|
|
||||||
{
|
|
||||||
Log::critical($exception);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function SaveSentRecord($sender, $subject, $body, $recipient, $recipientType) {
|
|
||||||
$sentmail = new SentMail;
|
|
||||||
$sentmail->sender = $sender;
|
|
||||||
$sentmail->subject = $subject;
|
|
||||||
$sentmail->body = $body;
|
|
||||||
$sentmail->recipient = $recipient;
|
|
||||||
$sentmail->recipient_type = $recipientType;
|
|
||||||
$sentmail->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
216
app/Jobs/Commands/Eve/SendEveMail.php
Normal file
216
app/Jobs/Commands/Eve/SendEveMail.php
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\Eve;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Spatie\RateLimitedMiddleware\RateLimited;
|
||||||
|
use Log;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//Library
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||||
|
use Seat\Eseye\Cache\NullCache;
|
||||||
|
use Seat\Eseye\Configuration;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Esi\EsiScope;
|
||||||
|
use App\Models\Esi\EsiToken;
|
||||||
|
use App\Models\Jobs\JobStatus;
|
||||||
|
use App\Models\Mail\SentMail;
|
||||||
|
use Seat\Eseye\Containers\EsiResponse;
|
||||||
|
|
||||||
|
class SendEveMail implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retries
|
||||||
|
* With new rate limiting, we need a retry basis versus timeout basis
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $retries = 1;
|
||||||
|
|
||||||
|
private $sender;
|
||||||
|
private $body;
|
||||||
|
private $recipient;
|
||||||
|
private $recipient_type;
|
||||||
|
private $subject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct($body, $recipient, $recipient_type, $subject, $sender) {
|
||||||
|
//Set the connection
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('mail');
|
||||||
|
|
||||||
|
//Set the middleware for the job
|
||||||
|
$this->middleware = $this->middleware();
|
||||||
|
|
||||||
|
//Private variables
|
||||||
|
$this->body = $body;
|
||||||
|
$this->recipient = $recipient;
|
||||||
|
$this->recipient_type = $recipient_type;
|
||||||
|
$this->subject = $subject;
|
||||||
|
$this->sender = $sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
* Utilized by using SendEveMail::dispatch($mail);
|
||||||
|
* The model is passed into the dispatch function, then added to the queue
|
||||||
|
* for processing.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Declare some variables
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
$errorCode = null;
|
||||||
|
|
||||||
|
//Get the esi configuration
|
||||||
|
$config = config('esi');
|
||||||
|
|
||||||
|
//Retrieve the token for main character to send mails from
|
||||||
|
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
||||||
|
//Create the ESI authentication container
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||||
|
|
||||||
|
//Check to see if the token is valid or not
|
||||||
|
if($esiHelper->TokenExpired($refreshToken)) {
|
||||||
|
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$esi->setBody([
|
||||||
|
'approved_cost' => 10000,
|
||||||
|
'body' => $this->body,
|
||||||
|
'recipients' => [[
|
||||||
|
'recipient_id' => $this->recipient,
|
||||||
|
'recipient_type' => $this->recipient_type,
|
||||||
|
]],
|
||||||
|
'subject' => $this->subject,
|
||||||
|
])->invoke('post', '/characters/{character_id}/mail/', [
|
||||||
|
'character_id'=> $this->sender,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Middleware to only allow 4 jobs to be run per minute
|
||||||
|
* After a failed job, the job is released back into the queue for at least 1 minute x the number of times attempted
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function middleware() {
|
||||||
|
|
||||||
|
//Allow 4 jobs per minute, and implement a rate limited backoff on failed jobs
|
||||||
|
$rateLimitedMiddleware = (new RateLimited())
|
||||||
|
->enabled()
|
||||||
|
->key('psemj')
|
||||||
|
->connectionName('default')
|
||||||
|
->allow(4)
|
||||||
|
->everySeconds(60)
|
||||||
|
->releaseAfterOneMinute()
|
||||||
|
->releaseAfterBackoff($this->attempts());
|
||||||
|
|
||||||
|
return [$rateLimitedMiddleware];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Determine the time at which the job should timeout.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function retryUntil() : \DateTime
|
||||||
|
{
|
||||||
|
return Carbon::now()->addDay();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The job failed to process.
|
||||||
|
*
|
||||||
|
* @param Exception $exception
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function failed($exception)
|
||||||
|
{
|
||||||
|
if(!exception instanceof RequestFailedException) {
|
||||||
|
//If not a failure due to ESI, then log it. Otherwise,
|
||||||
|
//deduce why the exception occurred.
|
||||||
|
Log::critical($exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((is_object($exception->getEsiResponse()) && (stristr($exception->getEsiResponse()->error, 'Too many errors') || stristr($exception->getEsiResponse()->error, 'This software has exceeded the error limit for ESI'))) ||
|
||||||
|
(is_string($exception->getEsiResponse()) && (stristr($exception->getEsiResponse(), 'Too many errors') || stristr($exception->getEsiResponse(), 'This software has exceeded the error limit for ESI')))) {
|
||||||
|
|
||||||
|
//We have hit the error rate limiter, wait 120 seconds before releasing the job back into the queue.
|
||||||
|
Log::info('SendEveMail has hit the error rate limiter. Releasing the job back into the wild in 2 minutes.');
|
||||||
|
$this->release(120);
|
||||||
|
} else {
|
||||||
|
$errorCode = $exception->getEsiResponse()->getErrorCode();
|
||||||
|
|
||||||
|
switch($errorCode) {
|
||||||
|
case 400: //Bad Request
|
||||||
|
Log::critical("Bad request has occurred in SendEveMail. Job has been discarded");
|
||||||
|
break;
|
||||||
|
case 401: //Unauthorized Request
|
||||||
|
Log::critical("Unauthorized request has occurred in SendEveMail at " . Carbon::now()->toDateTimeString() . ".\r\nCancelling the job.");
|
||||||
|
break;
|
||||||
|
case 403: //Forbidden
|
||||||
|
Log::critical("SendEveMail has incurred a forbidden error. Cancelling the job.");
|
||||||
|
break;
|
||||||
|
case 420: //Error Limited
|
||||||
|
Log::warning("Error rate limit occurred in SendEveMail. Restarting job in 120 seconds.");
|
||||||
|
$this->release(120);
|
||||||
|
break;
|
||||||
|
case 500: //Internal Server Error
|
||||||
|
Log::critical("Internal Server Error for ESI in SendEveMail. Attempting a restart in 120 seconds.");
|
||||||
|
$this->release(120);
|
||||||
|
break;
|
||||||
|
case 503: //Service Unavailable
|
||||||
|
Log::critical("Service Unavailabe for ESI in SendEveMail. Releasing the job back to the queue in 30 seconds.");
|
||||||
|
$this->release(30);
|
||||||
|
break;
|
||||||
|
case 504: //Gateway Timeout
|
||||||
|
Log::critical("Gateway timeout in SendEveMail. Releasing the job back to the queue in 30 seconds.");
|
||||||
|
$this->release(30);
|
||||||
|
break;
|
||||||
|
case 520: //Internal Error -- Mostly comes when rate limited hit
|
||||||
|
Log::warning("Rate limit hit for SendEveMail. Releasing the job back to the queue in 30 seconds.");
|
||||||
|
$this->release(30);
|
||||||
|
break;
|
||||||
|
case 201: //Good response code
|
||||||
|
$this->SaveSentRecord($this->sender, $this->subject, $this->body, $this->recipient, $this->recipient_type);
|
||||||
|
$this->delete();
|
||||||
|
break;
|
||||||
|
//If no code is given, then log and break out of switch.
|
||||||
|
default:
|
||||||
|
Log::warning("No response code received from esi call in SendEveMail.\r\n");
|
||||||
|
$this->delete();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tags() {
|
||||||
|
return ['ProcessEveMails'];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function SaveSentRecord($sender, $subject, $body, $recipient, $recipientType) {
|
||||||
|
$sentmail = new SentMail;
|
||||||
|
$sentmail->sender = $sender;
|
||||||
|
$sentmail->subject = $subject;
|
||||||
|
$sentmail->body = $body;
|
||||||
|
$sentmail->recipient = $recipient;
|
||||||
|
$sentmail->recipient_type = $recipientType;
|
||||||
|
$sentmail->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\Finances;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Log;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//Application Library
|
||||||
|
use App\Library\Helpers\FinanceHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Finances\AllianceWalletJournal;
|
||||||
|
|
||||||
|
class UpdateAllianceWalletJournalJob implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 1800;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $retries = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('finances');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Declare variables
|
||||||
|
$fHelper = new FinanceHelper;
|
||||||
|
$config = config('esi');
|
||||||
|
|
||||||
|
$pages = $fHelper->GetAllianceWalletJournalPages(1, $config['primary']);
|
||||||
|
|
||||||
|
//If the number of pages received is zero there is an error in the job.
|
||||||
|
if($pages == 0) {
|
||||||
|
Log::critical('Failed to get the number of pages in the job.');
|
||||||
|
$this->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
for($i = 1; $i <= $pages; $i++) {
|
||||||
|
UpdateAllianceWalletJournalPage::dispatch(1, $config['primary'], $i)->onQueue('journal');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the tags for Horzion
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public function tags() {
|
||||||
|
return ['UpdateAllianceWalletJournal', 'Finances'];
|
||||||
|
}
|
||||||
|
}
|
||||||
226
app/Jobs/Commands/Finances/UpdateAllianceWalletJournalPage.php
Normal file
226
app/Jobs/Commands/Finances/UpdateAllianceWalletJournalPage.php
Normal file
@@ -0,0 +1,226 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\Finances;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
|
||||||
|
//Application Library
|
||||||
|
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||||
|
use Seat\Eseye\Cache\NullCache;
|
||||||
|
use Seat\Eseye\Configuration;
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
use App\Library\Helpers\LookupHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Finances\AllianceWalletJournal;
|
||||||
|
|
||||||
|
class UpdateAllianceWalletJournalPage implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of job retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $tries = 3;
|
||||||
|
|
||||||
|
private $division;
|
||||||
|
private $charId;
|
||||||
|
private $page;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct($division, $charId, $page)
|
||||||
|
{
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('finances');
|
||||||
|
|
||||||
|
$this->division = $division;
|
||||||
|
$this->charId = $charId;
|
||||||
|
$this->page = $page;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Declare variables in the handler
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
|
//Setup the esi container.
|
||||||
|
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||||
|
|
||||||
|
//Check the scope
|
||||||
|
if(!$esiHelper->HaveEsiScope($this->charId, 'esi-wallet.read_corporation_wallets.v1')) {
|
||||||
|
Log::critical('Scope check failed for esi-wallet.read_corporation_wallets.v1 for character id: ' . $charId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($esiHelper->TokenExpired($token)) {
|
||||||
|
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Reference the character id to the corporation id
|
||||||
|
$char = $lookup->GetCharacterInfo($this->charId);
|
||||||
|
$corpId = $char->corporation_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to get the data from the esi api. If it fails, we skip the page, and go onto the next page, unless
|
||||||
|
* the failed page is the first page.
|
||||||
|
*/
|
||||||
|
$journals = $esi->page($this->page)
|
||||||
|
->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
|
||||||
|
'corporation_id' => $corpId,
|
||||||
|
'division' => $this->division,
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Decode the json data, and return it as an array
|
||||||
|
$wallet = json_decode($journals->raw, true);
|
||||||
|
|
||||||
|
//Foreach journal entry, add the journal entry to the table
|
||||||
|
foreach($wallet as $entry) {
|
||||||
|
//See if we find the entry id in the database already
|
||||||
|
$found = AllianceWalletJournal::where([
|
||||||
|
'id' => $entry['id'],
|
||||||
|
])->count();
|
||||||
|
|
||||||
|
if($found == 0) {
|
||||||
|
$awj = new AllianceWalletJournal;
|
||||||
|
$awj->id = $entry['id'];
|
||||||
|
$awj->corporation_id = $corpId;
|
||||||
|
$awj->division = $this->division;
|
||||||
|
if(isset($entry['amount'])) {
|
||||||
|
$awj->amount = $entry['amount'];
|
||||||
|
}
|
||||||
|
if(isset($entry['balance'])) {
|
||||||
|
$awj->balance = $entry['balance'];
|
||||||
|
}
|
||||||
|
if(isset($entry['context_id'])) {
|
||||||
|
$awj->context_id = $entry['context_id'];
|
||||||
|
}
|
||||||
|
if(isset($entry['date'])) {
|
||||||
|
$awj->date = $esiHelper->DecodeDate($entry['date']);
|
||||||
|
}
|
||||||
|
if(isset($entry['description'])) {
|
||||||
|
$awj->description = $entry['description'];
|
||||||
|
}
|
||||||
|
if(isset($entry['first_party_id'])) {
|
||||||
|
$awj->first_party_id = $entry['first_party_id'];
|
||||||
|
}
|
||||||
|
if(isset($entry['reason'])) {
|
||||||
|
$awj->reason = $entry['reason'];
|
||||||
|
}
|
||||||
|
if(isset($entry['ref_type'])) {
|
||||||
|
$awj->ref_type = $entry['ref_type'];
|
||||||
|
}
|
||||||
|
if(isset($entry['tax'])) {
|
||||||
|
$awj->tax = $entry['tax'];
|
||||||
|
}
|
||||||
|
if(isset($entry['tax_receiver_id'])) {
|
||||||
|
$awj->tax_receiver_id = $entry['tax_receiver_id'];
|
||||||
|
}
|
||||||
|
$awj->save();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Return as completed
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The job failed to process
|
||||||
|
* @param Exception $exception
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function failed($exception) {
|
||||||
|
if(!exception instanceof RequestFailedException) {
|
||||||
|
//If not a failure due to ESI, then log it. Otherwise,
|
||||||
|
//deduce why the exception occurred.
|
||||||
|
Log::critical($exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((is_object($exception->getEsiResponse()) && (stristr($exception->getEsiResponse()->error, 'Too many errors') || stristr($exception->getEsiResponse()->error, 'This software has exceeded the error limit for ESI'))) ||
|
||||||
|
(is_string($exception->getEsiResponse()) && (stristr($exception->getEsiResponse(), 'Too many errors') || stristr($exception->getEsiResponse(), 'This software has exceeded the error limit for ESI')))) {
|
||||||
|
|
||||||
|
//We have hit the error rate limiter, wait 120 seconds before releasing the job back into the queue.
|
||||||
|
Log::info('UpdateAllianceWalletJournalPage has hit the error rate limiter. Releasing the job back into the wild in 2 minutes.');
|
||||||
|
$this->release(120);
|
||||||
|
} else {
|
||||||
|
$errorCode = $exception->getEsiResponse()->getErrorCode();
|
||||||
|
|
||||||
|
switch($errorCode) {
|
||||||
|
case 400: //Bad Request
|
||||||
|
Log::critical("Bad request has occurred in UpdateAllianceWalletJournalPage. Job has been discarded");
|
||||||
|
break;
|
||||||
|
case 401: //Unauthorized Request
|
||||||
|
Log::critical("Unauthorized request has occurred in UpdateAllianceWalletJournalPage at " . Carbon::now()->toDateTimeString() . ".\r\nCancelling the job.");
|
||||||
|
$this->delete();
|
||||||
|
break;
|
||||||
|
case 403: //Forbidden
|
||||||
|
Log::critical("UpdateAllianceWalletJournalPage has incurred a forbidden error. Cancelling the job.");
|
||||||
|
$this->delete();
|
||||||
|
break;
|
||||||
|
case 420: //Error Limited
|
||||||
|
Log::warning("Error rate limit occurred in UpdateAllianceWalletJournalPage. Restarting job in 120 seconds.");
|
||||||
|
$this->release(120);
|
||||||
|
break;
|
||||||
|
case 500: //Internal Server Error
|
||||||
|
Log::critical("Internal Server Error for ESI in UpdateAllianceWalletJournalPage. Attempting a restart in 120 seconds.");
|
||||||
|
$this->release(120);
|
||||||
|
break;
|
||||||
|
case 503: //Service Unavailable
|
||||||
|
Log::critical("Service Unavailabe for ESI in UpdateAllianceWalletJournalPage. Releasing the job back to the queue in 30 seconds.");
|
||||||
|
$this->release(30);
|
||||||
|
break;
|
||||||
|
case 504: //Gateway Timeout
|
||||||
|
Log::critical("Gateway timeout in UpdateAllianceWalletJournalPage. Releasing the job back to the queue in 30 seconds.");
|
||||||
|
$this->release(30);
|
||||||
|
break;
|
||||||
|
case 201:
|
||||||
|
//Good response code
|
||||||
|
$this->delete();
|
||||||
|
break;
|
||||||
|
//If no code is given, then log and break out of switch.
|
||||||
|
default:
|
||||||
|
Log::warning("No response code received from esi call in UpdateAllianceWalletJournalPage.\r\n");
|
||||||
|
$this->delete();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the tags for Horzion
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public function tags() {
|
||||||
|
return ['UpdateAllianceWalletJournalPage', 'Finances'];
|
||||||
|
}
|
||||||
|
}
|
||||||
66
app/Jobs/Commands/Finances/UpdateItemPrices.php
Normal file
66
app/Jobs/Commands/Finances/UpdateItemPrices.php
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\Finances;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Log;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//Library Functions
|
||||||
|
use App\Library\Moons\MoonCalc;
|
||||||
|
|
||||||
|
class UpdateItemPrices implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 1800;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $retries = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('default');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Declare variables
|
||||||
|
$moonHelper = new MoonCalc;
|
||||||
|
//Fetch new prices from fuzzwork.co.uk for the item pricing schemes
|
||||||
|
$moonHelper->FetchNewPrices();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the tags for Horzion
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public function tags() {
|
||||||
|
return ['UpdateItemPrices', 'Finances'];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Jobs\Commands\MiningTaxes;
|
|
||||||
|
|
||||||
//Internal Library
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
//App Library
|
|
||||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
|
||||||
use App\Library\Esi\Esi;
|
|
||||||
use App\Library\Helpers\LookupHelper;
|
|
||||||
use App\Library\Moons\MoonCalc;
|
|
||||||
|
|
||||||
//App Models
|
|
||||||
use App\Models\MiningTax\Observer;
|
|
||||||
use App\Models\MiningTax\Ledger;
|
|
||||||
use App\Models\Moon\MineralPrice;
|
|
||||||
use App\Models\Moon\ItemComposition;
|
|
||||||
use App\Models\Esi\EsiToken;
|
|
||||||
use App\Models\Esi\EsiScope;
|
|
||||||
|
|
||||||
class FetchMiningTaxesLedgersJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Timeout in seconds
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $timeout = 3600;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Number of job retries
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $tries = 3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Job Variables
|
|
||||||
*/
|
|
||||||
private $charId;
|
|
||||||
private $corpId;
|
|
||||||
private $observerId;
|
|
||||||
private $esi;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new job instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct($charId, $corpId, $observerId)
|
|
||||||
{
|
|
||||||
//Set the connection for the job
|
|
||||||
$this->connection = 'redis';
|
|
||||||
|
|
||||||
//Import the variables from the calling function
|
|
||||||
$this->charId = $charId;
|
|
||||||
$this->corpId = $corpId;
|
|
||||||
$this->observerId = $observerId;
|
|
||||||
|
|
||||||
//Setup the ESI stuff
|
|
||||||
$esiHelper = new Esi;
|
|
||||||
|
|
||||||
//Setup the private esi variables
|
|
||||||
if(!$esiHelper->haveEsiScope($this->charId, 'esi-industry.read_corporation_mining.v1')) {
|
|
||||||
Log::critical('Character: ' . $this->charId . ' did not have the correct esi scope in FetchMiningTaxesLedgersJob.');
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$refreshToken = $esiHelper->GetRefreshToken($this->charId);
|
|
||||||
$this->esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the job.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
//Declare variables
|
|
||||||
$lookup = new LookupHelper;
|
|
||||||
$mHelper = new MoonCalc;
|
|
||||||
$esiHelper = new Esi;
|
|
||||||
|
|
||||||
//Get the ledger from ESI
|
|
||||||
try {
|
|
||||||
$response = $this->esi->invoke('get', '/corporation/{corporation_id}/mining/observers/{observer_id}/', [
|
|
||||||
'corporation_id' => $this->corpId,
|
|
||||||
'observer_id' => $this->observerId,
|
|
||||||
]);
|
|
||||||
} catch(RequestFailedException $e) {
|
|
||||||
Log::warning('Failed to get the mining ledger in FetchMiningTaxesLedgersJob for observer id: ' . $this->observerId);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$ledgers = json_decode($response);
|
|
||||||
|
|
||||||
//Sort through the array, and create the variables needed for database entries
|
|
||||||
foreach($ledgers as $ledger) {
|
|
||||||
//Get some basic information we need to work with
|
|
||||||
$charName = $lookup->CharacterIdToName($ledger->character_id);
|
|
||||||
//Get the type name from the ledger ore stuff
|
|
||||||
$typeName = $lookup->ItemIdToName($ledger->type_id);
|
|
||||||
//Decode the date and store it.
|
|
||||||
//$updated = $esiHelper->DecodeDate($ledger->last_updated);
|
|
||||||
|
|
||||||
$price = $mHelper->CalculateOrePrice($ledger->type_id);
|
|
||||||
$amount = $price * $ledger->quantity;
|
|
||||||
|
|
||||||
//Insert or update the entry in the database
|
|
||||||
$item = Ledger::updateOrCreate([
|
|
||||||
'character_id' => $ledger->character_id,
|
|
||||||
'character_name' => $charName,
|
|
||||||
'observer_id' => $this->observerId,
|
|
||||||
'last_updated' => $ledger->last_updated,
|
|
||||||
'type_id' => $ledger->type_id,
|
|
||||||
'ore_name' => $typeName,
|
|
||||||
'quantity' => $ledger->quantity,
|
|
||||||
'price' => $amount,
|
|
||||||
], [
|
|
||||||
'character_id' => $ledger->character_id,
|
|
||||||
'character_name' => $charName,
|
|
||||||
'observer_id' => $this->observerId,
|
|
||||||
'last_updated' => $ledger->last_updated,
|
|
||||||
'type_id' => $ledger->type_id,
|
|
||||||
'ore_name' => $typeName,
|
|
||||||
'quantity' => $ledger->quantity,
|
|
||||||
'price' => $amount,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Clean up old data
|
|
||||||
Ledger::where(['updated_at', '<', Carbon::now()->subDays(120)])->delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
200
app/Jobs/Commands/MiningTaxes/FetchMiningTaxesObservers.php
Normal file
200
app/Jobs/Commands/MiningTaxes/FetchMiningTaxesObservers.php
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\MiningTaxes;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Log;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//Application Library
|
||||||
|
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
use App\Library\Helpers\LookupHelper;
|
||||||
|
use App\Library\Helpers\StructureHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\MiningTax\Observer;
|
||||||
|
|
||||||
|
class FetchMiningTaxesObservers implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of job retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $tries = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('miningtaxes');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Declare variables
|
||||||
|
$config = config('esi');
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$sHelper = new StructureHelper($config['primary'], $config['corporation']);
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
|
//Check for the ESI scope needed.
|
||||||
|
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1')) {
|
||||||
|
Log::critical('Esi scopes were not found for FetchMiningTaxesObserversJob.');
|
||||||
|
print("Esi scopes not found.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//Check for the other ESI scope needed.
|
||||||
|
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-universe.read_structures.v1')) {
|
||||||
|
Log::critical('Esi scope esi-universe.read_structures.v1 was not found for FetchMiningTaxesObserversJob.');
|
||||||
|
print("Esi scopes not found 2");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the refresh token for the character
|
||||||
|
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
||||||
|
//Get the esi variable
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||||
|
|
||||||
|
//Invoke the call to ESI API.
|
||||||
|
$response = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/', [
|
||||||
|
'corporation_id' => $config['corporation'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Decode the json response, but leave it as objects rather than an array
|
||||||
|
$resp = json_decode($response->raw, false);
|
||||||
|
|
||||||
|
//Run through the mining observers, and add them to the database
|
||||||
|
foreach($resp as $observer) {
|
||||||
|
//See if the observer is found in the database
|
||||||
|
$found = Observer::where([
|
||||||
|
'observer_id' => $observer->observer_id,
|
||||||
|
])->count();
|
||||||
|
|
||||||
|
//Get the observer name from esi
|
||||||
|
$structureInfo = $sHelper->GetStructureInfo($observer->observer_id);
|
||||||
|
|
||||||
|
//If found, then update the structure
|
||||||
|
if($found > 0) {
|
||||||
|
//Update the existing structure in the database
|
||||||
|
Observer::where([
|
||||||
|
'observer_id' => $observer->observer_id,
|
||||||
|
])->update([
|
||||||
|
'observer_id' => $observer->observer_id,
|
||||||
|
'observer_name' => $structureInfo->name,
|
||||||
|
'last_updated' => $observer->last_updated,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
//Add a new observer into the observer table
|
||||||
|
$newObs = new Observer;
|
||||||
|
$newObs->observer_id = $observer->observer_id;
|
||||||
|
$newObs->observer_type = $observer->observer_type;
|
||||||
|
$newObs->observer_name = $structureInfo->name;
|
||||||
|
$newObs->last_updated = $observer->last_updated;
|
||||||
|
$newObs->solar_system_id = $structureInfo->solar_system_id;
|
||||||
|
$newObs->solar_system_name = $lookup->SystemIdToName($structureInfo->solar_system_id);
|
||||||
|
$newObs->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleanup stale data that hasn't been updated in at least 1 week.
|
||||||
|
*/
|
||||||
|
$date = Carbon::now()->subDays(7);
|
||||||
|
Observer::where('last_updated', '<', $date)->delete();
|
||||||
|
|
||||||
|
//Return 0 saying everything is fine
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The job failed to process
|
||||||
|
* @param Exception $exception
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function failed($exception) {
|
||||||
|
if(!exception instanceof RequestFailedException) {
|
||||||
|
//If not a failure due to ESI, then log it. Otherwise,
|
||||||
|
//deduce why the exception occurred.
|
||||||
|
Log::critical($exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((is_object($exception->getEsiResponse()) && (stristr($exception->getEsiResponse()->error, 'Too many errors') || stristr($exception->getEsiResponse()->error, 'This software has exceeded the error limit for ESI'))) ||
|
||||||
|
(is_string($exception->getEsiResponse()) && (stristr($exception->getEsiResponse(), 'Too many errors') || stristr($exception->getEsiResponse(), 'This software has exceeded the error limit for ESI')))) {
|
||||||
|
|
||||||
|
//We have hit the error rate limiter, wait 120 seconds before releasing the job back into the queue.
|
||||||
|
Log::info('FetchMiningTaxesObservers has hit the error rate limiter. Releasing the job back into the wild in 2 minutes.');
|
||||||
|
$this->release(120);
|
||||||
|
} else {
|
||||||
|
$errorCode = $exception->getEsiResponse()->getErrorCode();
|
||||||
|
|
||||||
|
switch($errorCode) {
|
||||||
|
case 400: //Bad Request
|
||||||
|
Log::critical("Bad request has occurred in FetchMiningTaxesObservers. Job has been discarded");
|
||||||
|
break;
|
||||||
|
case 401: //Unauthorized Request
|
||||||
|
Log::critical("Unauthorized request has occurred in FetchMiningTaxesObservers at " . Carbon::now()->toDateTimeString() . ".\r\nCancelling the job.");
|
||||||
|
break;
|
||||||
|
case 403: //Forbidden
|
||||||
|
Log::critical("FetchMiningTaxesObservers has incurred a forbidden error. Cancelling the job.");
|
||||||
|
break;
|
||||||
|
case 420: //Error Limited
|
||||||
|
Log::warning("Error rate limit occurred in FetchMiningTaxesObservers. Restarting job in 120 seconds.");
|
||||||
|
$this->release(120);
|
||||||
|
break;
|
||||||
|
case 500: //Internal Server Error
|
||||||
|
Log::critical("Internal Server Error for ESI in FetchMiningTaxesObservers. Attempting a restart in 120 seconds.");
|
||||||
|
$this->release(120);
|
||||||
|
break;
|
||||||
|
case 503: //Service Unavailable
|
||||||
|
Log::critical("Service Unavailabe for ESI in FetchMiningTaxesObservers. Releasing the job back to the queue in 30 seconds.");
|
||||||
|
$this->release(30);
|
||||||
|
break;
|
||||||
|
case 504: //Gateway Timeout
|
||||||
|
Log::critical("Gateway timeout in FetchMiningTaxesObservers. Releasing the job back to the queue in 30 seconds.");
|
||||||
|
$this->release(30);
|
||||||
|
break;
|
||||||
|
case 201: //Good response code
|
||||||
|
$this->delete();
|
||||||
|
break;
|
||||||
|
//If no code is given, then log and break out of switch.
|
||||||
|
default:
|
||||||
|
Log::warning("No response code received from esi call in FetchMiningTaxesObservers.\r\n");
|
||||||
|
$this->delete();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the tags for Horizon
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public function tags() {
|
||||||
|
return ['FetchMiningObservers', 'MiningTaxes'];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\MiningTaxes\Invoices;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Support\Facades\Bus;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\MiningTax\MiningOperation;
|
||||||
|
use App\Models\MiningTax\Ledger;
|
||||||
|
|
||||||
|
class ProcessAllianceMiningOperations implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of job retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $tries = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//Set job parameters
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('miningtaxes');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$count = MiningOperation::where([
|
||||||
|
'processed' => 'No',
|
||||||
|
])->where('operation_date', '<=', Carbon::now())
|
||||||
|
->count();
|
||||||
|
|
||||||
|
if($count > 0) {
|
||||||
|
$operations = MiningOperation::where([
|
||||||
|
'processed' => 'No',
|
||||||
|
])->where('operation_date', '<=', Carbon::now())
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach($operations as $operation) {
|
||||||
|
$ledgers = Ledger::where([
|
||||||
|
'observer_id' => $operation->structure_id,
|
||||||
|
'invoiced' => 'No',
|
||||||
|
'last_updated' => $operation->operation_date,
|
||||||
|
])->get();
|
||||||
|
|
||||||
|
foreach($ledgers as $ledger) {
|
||||||
|
Ledger::where([
|
||||||
|
'observer_id' => $operation->structure_id,
|
||||||
|
'invoiced' => 'No',
|
||||||
|
'last_updated' => $operation->operation_date,
|
||||||
|
])->update([
|
||||||
|
'invoiced' => 'Yes',
|
||||||
|
'invoice_id' => 'MiningOp' . $operation->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
MiningOperation::where([
|
||||||
|
'id' => $operation->id,
|
||||||
|
])->update([
|
||||||
|
'processed' => 'Yes',
|
||||||
|
'processed_on' => Carbon::now(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the tags for Horzion
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public function tags() {
|
||||||
|
return ['ProcessAllianceMiningOperations', 'MiningTaxes', 'MiningOperations'];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,320 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\MiningTaxes\Invoices;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Log;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
//Application Library
|
||||||
|
use App\Library\Helpers\LookupHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\MiningTax\Invoice;
|
||||||
|
use App\Models\MiningTax\Ledger;
|
||||||
|
use App\Models\User\UserAlt;
|
||||||
|
use App\Models\User\User;
|
||||||
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\Commands\Eve\SendEveMail;
|
||||||
|
|
||||||
|
class SendMiningTaxesInvoices implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of job retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $tries = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('miningtaxes');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Declare variables
|
||||||
|
$mailDelay = 15;
|
||||||
|
$mains = new Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This section will determine if users are mains or alts of a main.
|
||||||
|
* If they are mains, we keep the key. If they are alts of a main, then we delete
|
||||||
|
* the key from the collection.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//Pluck all the users from the database of ledgers to determine if they are mains or alts.
|
||||||
|
$tempMains = Ledger::where([
|
||||||
|
'invoiced' => 'No',
|
||||||
|
])->where('last_updated', '>', Carbon::now()->subDays(7))->pluck('character_id');
|
||||||
|
|
||||||
|
//Get the unique character ids from the ledgers in the previous statement
|
||||||
|
$tempMains = $tempMains->unique()->values()->all();
|
||||||
|
|
||||||
|
//Cycle through the array of mains, and remove any characters which are in the User Alt table,
|
||||||
|
//as those characters will be grouped with their correct main later.
|
||||||
|
for($i = 0; $i < sizeof($tempMains); $i++) {
|
||||||
|
if(UserAlt::where(['character_id' => $tempMains[$i]])->count() == 0) {
|
||||||
|
$mains->push($tempMains[$i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For each of the users, let's determine if there are any ledgers,
|
||||||
|
* then determine if there are any alts and ledgers associated with the alts.
|
||||||
|
*/
|
||||||
|
foreach($mains as $main) {
|
||||||
|
//Declare some variables for each run through the for loop
|
||||||
|
$ledgers = new Collection;
|
||||||
|
|
||||||
|
//Count the ledgers for the main
|
||||||
|
$mainLedgerCount = Ledger::where([
|
||||||
|
'character_id' => $main,
|
||||||
|
'invoiced' => 'No',
|
||||||
|
])->where('last_updated', '>', Carbon::now()->subDays(7))->count();
|
||||||
|
|
||||||
|
//If there are ledgers for the main, then let's grab them
|
||||||
|
if($mainLedgerCount > 0) {
|
||||||
|
$mainLedgers = Ledger::where([
|
||||||
|
'character_id' => $main,
|
||||||
|
'invoiced' => 'No',
|
||||||
|
])->where('last_updated', '>', Carbon::now()->subDays(7))->get();
|
||||||
|
|
||||||
|
//Cycle through the entries, and add them to the ledger to send with the invoice
|
||||||
|
foreach($mainLedgers as $row) {
|
||||||
|
$ledgers->push([
|
||||||
|
'character_id' => $row->character_id,
|
||||||
|
'character_name' => $row->character_name,
|
||||||
|
'observer_id' => $row->observer_id,
|
||||||
|
'type_id' => $row->type_id,
|
||||||
|
'ore_name' => $row->ore_name,
|
||||||
|
'quantity' => (int)$row->quantity,
|
||||||
|
'amount' => (float)$row->amount,
|
||||||
|
'last_updated' => $row->last_updated,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the alt count for the main character
|
||||||
|
$altCount = UserAlt::where(['main_id' => $main])->count();
|
||||||
|
//If more than 0 alts, grab all the alts.
|
||||||
|
if($altCount > 0) {
|
||||||
|
$alts = UserAlt::where([
|
||||||
|
'main_id' => $main,
|
||||||
|
])->get();
|
||||||
|
|
||||||
|
//Cycle through the alts, and get the ledgers, and push onto the stack
|
||||||
|
foreach($alts as $alt) {
|
||||||
|
$altLedgerCount = Ledger::where([
|
||||||
|
'character_id' => $alt->character_id,
|
||||||
|
'invoiced' => 'No',
|
||||||
|
])->where('last_updated', '>', Carbon::now()->subDays(7))->count();
|
||||||
|
|
||||||
|
if($altLedgerCount > 0) {
|
||||||
|
$altLedgers = Ledger::where([
|
||||||
|
'character_id' => $alt->character_id,
|
||||||
|
'invoiced' => 'No',
|
||||||
|
])->where('last_updated', '>', Carbon::now()->subDays(7))->get();
|
||||||
|
|
||||||
|
foreach($altLedgers as $row) {
|
||||||
|
$ledgers->push([
|
||||||
|
'character_id' => $row->character_id,
|
||||||
|
'character_name' => $row->character_name,
|
||||||
|
'observer_id' => $row->observer_id,
|
||||||
|
'type_id' => $row->type_id,
|
||||||
|
'ore_name' => $row->ore_name,
|
||||||
|
'quantity' => (int)$row->quantity,
|
||||||
|
'amount' => (float)$row->amount,
|
||||||
|
'last_updated' => $row->last_updated,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the collected information over to the function to send the actual mail
|
||||||
|
*/
|
||||||
|
if($ledgers->count() > 0) {
|
||||||
|
$this->CreateInvoice($main, $ledgers, $mailDelay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the invoice to the mail out
|
||||||
|
*
|
||||||
|
* @var charId
|
||||||
|
* @var ledgers
|
||||||
|
* @var mailDelay
|
||||||
|
*/
|
||||||
|
private function CreateInvoice($charId, Collection $ledgers, int &$mailDelay) {
|
||||||
|
$ores = array();
|
||||||
|
$characters = array();
|
||||||
|
$characterIds = array();
|
||||||
|
$totalPrice = 0.00;
|
||||||
|
$body = null;
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$config = config('esi');
|
||||||
|
|
||||||
|
//Create an invoice id
|
||||||
|
$invoiceId = "M" . uniqid();
|
||||||
|
|
||||||
|
//Collect the total price of all of the ledgers
|
||||||
|
$totalPrice = round((float)$ledgers->sum('amount'), 2);
|
||||||
|
|
||||||
|
//Get the sum of all the ledgers
|
||||||
|
$invoiceAmount = round(((float)$ledgers->sum('amount') * (float)$config['mining_tax']), 2);
|
||||||
|
|
||||||
|
//Get the character name from the lookup table
|
||||||
|
$charName = $lookup->CharacterIdToName($charId);
|
||||||
|
|
||||||
|
//Create the date due and the invoice date
|
||||||
|
$dateDue = Carbon::now()->addDays(7);
|
||||||
|
$invoiceDate = Carbon::now();
|
||||||
|
|
||||||
|
//Set the mining tax from the config file
|
||||||
|
$numberMiningTax = number_format(((float)$config['mining_tax'] * (float)100.00), 2, ".", ",");
|
||||||
|
|
||||||
|
//Create the list of ores to put in the mail
|
||||||
|
$temp = $ledgers->toArray();
|
||||||
|
foreach($temp as $t) {
|
||||||
|
//If the key isn't set, set it to the default of 0
|
||||||
|
if(!isset($ores[$t['type_id']])) {
|
||||||
|
$ores[$t['type_id']] = (int)0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add the quantity into the ores array
|
||||||
|
$ores[$t['type_id']] += (int)$t['quantity'];
|
||||||
|
|
||||||
|
//Create a list of character names
|
||||||
|
if(!isset($characters[$t['character_name']])) {
|
||||||
|
$characters[$t['character_name']] = $t['character_name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create a list of character ids
|
||||||
|
if(!isset($characterIds[$t['character_id']])) {
|
||||||
|
$characterIds[$t['character_id']] = $t['character_id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the mail body to send to the main character
|
||||||
|
*/
|
||||||
|
$body .= "Dear " . $charName . ",<br><br>";
|
||||||
|
$body .= "Mining Taxes are due for the following ores mined from alliance moons: <br>";
|
||||||
|
foreach($ores as $ore => $quantity) {
|
||||||
|
$oreName = $lookup->ItemIdToName($ore);
|
||||||
|
$body .= $oreName . ": " . number_format($quantity, 0, ".", ",") . "<br>";
|
||||||
|
}
|
||||||
|
$body .= "Total Value of Ore Mined: " . number_format($totalPrice, 2, ".", ",") . " ISK.";
|
||||||
|
$body .= "<br><br>";
|
||||||
|
$body .= "Please remit " . number_format($invoiceAmount, 2, ".", ",") . " ISK to Spatial Forces or contract Spatial Forces the following ores:<br>";
|
||||||
|
foreach($ores as $ore => $quantity) {
|
||||||
|
$oreName = $lookup->ItemIdToName($ore);
|
||||||
|
$body .= $oreName . ": " . number_format(round($quantity * $config['mining_tax']), 0, ".", ",") . "<br>";
|
||||||
|
}
|
||||||
|
$body .= "<br>";
|
||||||
|
$body .= "The due date is " . $dateDue . "<br>";
|
||||||
|
$body .= "Set the reason for transfer as " . $invoiceId . "<br>";
|
||||||
|
$body .= "The mining taxes are currently set to " . $numberMiningTax . "%.<br>";
|
||||||
|
$body .= "<br>";
|
||||||
|
$body .= "Characters Processed: <br>";
|
||||||
|
foreach($characters as $character) {
|
||||||
|
$body .= $character . "<br>";
|
||||||
|
}
|
||||||
|
$body .= "<br>";
|
||||||
|
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
|
||||||
|
|
||||||
|
//Check if the mail body is greater than 2000 characters. If greater than 2,000 characters, then
|
||||||
|
if(strlen($body) > 2000) {
|
||||||
|
$body = "Dear " . $charName . "<br><br>";
|
||||||
|
$body .= "Total Value of Ore Mined: " . number_format($totalPrice, 2, ".", ",") . " ISK.";
|
||||||
|
$body .= "<br><br>";
|
||||||
|
$body .= "Please remit " . number_format($invoiceAmount, 2, ".", ",") . " ISK to Spatial Forces or contract 15% of the ores mined to Spatial Forces.<br>";
|
||||||
|
$body .= "The due date is " . $dateDue . "<br>";
|
||||||
|
$body .= "Set the reason for transfer as: " . $invoiceId . "<br>";
|
||||||
|
$body .= "The mining taxes are currently set to " . $numberMiningTax . "%.<br>";
|
||||||
|
$body .= "<br>";
|
||||||
|
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
|
||||||
|
}
|
||||||
|
|
||||||
|
//Mail the invoice to the character if the character is in
|
||||||
|
//Warped Intentions or Legacy
|
||||||
|
$subject = 'Warped Intentions Mining Taxes';
|
||||||
|
$sender = $config['primary'];
|
||||||
|
$recipientType = 'character';
|
||||||
|
$recipient = $charId;
|
||||||
|
|
||||||
|
//Send the Eve Mail Job to the queue to be dispatched
|
||||||
|
SendEveMail::dispatch($body, $recipient, $recipientType, $subject, $sender)->delay(Carbon::now()->addSeconds($mailDelay));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new invoice model, and save it to the database
|
||||||
|
*/
|
||||||
|
$invoice = new Invoice;
|
||||||
|
$invoice->character_id = $charId;
|
||||||
|
$invoice->character_name = $charName;
|
||||||
|
$invoice->invoice_id = $invoiceId;
|
||||||
|
$invoice->invoice_amount = $invoiceAmount;
|
||||||
|
$invoice->date_issued = $invoiceDate;
|
||||||
|
$invoice->date_due = $dateDue;
|
||||||
|
$invoice->status = 'Pending';
|
||||||
|
$invoice->mail_body = $body;
|
||||||
|
$invoice->save();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark the invoices as paid
|
||||||
|
*/
|
||||||
|
foreach($characterIds as $char) {
|
||||||
|
Ledger::where([
|
||||||
|
'character_id' => $char,
|
||||||
|
'invoiced' => 'No',
|
||||||
|
])->update([
|
||||||
|
'invoice_id' => $invoiceId,
|
||||||
|
'invoiced' => 'Yes',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Increment the mail delay for the next cycle
|
||||||
|
*/
|
||||||
|
$mailDelay += 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the tags for Horizon
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public function tags() {
|
||||||
|
return ['MiningTaxes', 'SendMiningTaxesInvoics', 'Invoices'];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\MiningTaxes\Invoices;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Log;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//Application Library
|
||||||
|
use App\Library\Helpers\LookupHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\MiningTax\Invoice;
|
||||||
|
use App\Models\User\User;
|
||||||
|
use App\Models\User\UserAlt;
|
||||||
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\Commands\Eve\SendEveMail;
|
||||||
|
|
||||||
|
class UpdateMiningTaxesLateInvoices15th implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of job retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $tries = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('miningtaxes');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Declare variables
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$config = config('esi');
|
||||||
|
$mailDelay = 15;
|
||||||
|
$today = Carbon::now();
|
||||||
|
|
||||||
|
//Get all of the invoices that are still pending.
|
||||||
|
$invoices = Invoice::where([
|
||||||
|
'status' => 'Pending',
|
||||||
|
])->get();
|
||||||
|
|
||||||
|
//Cycle through the invoices, and see if they are late or not.
|
||||||
|
foreach($invoices as $invoice) {
|
||||||
|
$dueDate = Carbon::create($invoice->date_due);
|
||||||
|
|
||||||
|
if($dueDate->greaterThan($today->subDays(7))) {
|
||||||
|
//Update the invoice in the database
|
||||||
|
Invoice::where([
|
||||||
|
'invoice_id' => $invoice->invoice_id,
|
||||||
|
])->update([
|
||||||
|
'status' => 'Late',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Build the mail
|
||||||
|
$subject = 'Warped Intentions Mining Taxes - Invoice Late';
|
||||||
|
$sender = $config['primary'];
|
||||||
|
$recipientType = 'character';
|
||||||
|
$recipient = $invoice->character_id;
|
||||||
|
|
||||||
|
$body = "Dear " . $invoice->character_name . ",<br><br>";
|
||||||
|
$body .= "The Mining Invoice: " . $invoice->invoice_id . " is late.<br>";
|
||||||
|
$body .= "Please remite " . number_format($invoice->invoice_amount, 2, ".", ",") . "to Spatial Forces.<br>";
|
||||||
|
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
|
||||||
|
|
||||||
|
//Send a reminder to the user through eve mail about the late invoice
|
||||||
|
SendEveMail::dispatch($body, $recipient, $recipientType, $subject, $sender)->delay(Carbon::now()->addSeconds($mailDelay));
|
||||||
|
|
||||||
|
$mailDelay += 20;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the tags for Horzion
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public function tags() {
|
||||||
|
return ['UpdateMiningTaxesLateInvoices', 'MiningTaxes', 'Invoices'];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\MiningTaxes\Invoices;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Log;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//Application Library
|
||||||
|
use App\Library\Helpers\LookupHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\MiningTax\Invoice;
|
||||||
|
use App\Models\User\User;
|
||||||
|
use App\Models\User\UserAlt;
|
||||||
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\Commands\Eve\SendEveMail;
|
||||||
|
|
||||||
|
class UpdateMiningTaxesLateInvoices1st implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of job retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $tries = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('miningtaxes');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Declare variables
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$config = config('esi');
|
||||||
|
$mailDelay = 15;
|
||||||
|
$today = Carbon::now();
|
||||||
|
|
||||||
|
//Get all of the invoices that are still pending.
|
||||||
|
$invoices = Invoice::where([
|
||||||
|
'status' => 'Pending',
|
||||||
|
])->get();
|
||||||
|
|
||||||
|
//Cycle through the invoices, and see if they are late or not.
|
||||||
|
foreach($invoices as $invoice) {
|
||||||
|
$dueDate = Carbon::create($invoice->date_due);
|
||||||
|
|
||||||
|
if($dueDate->greaterThan($today->subDays(7))) {
|
||||||
|
//Update the invoice in the database
|
||||||
|
Invoice::where([
|
||||||
|
'invoice_id' => $invoice->invoice_id,
|
||||||
|
])->update([
|
||||||
|
'status' => 'Late',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Build the mail
|
||||||
|
$subject = 'Warped Intentions Mining Taxes - Invoice Late';
|
||||||
|
$sender = $config['primary'];
|
||||||
|
$recipientType = 'character';
|
||||||
|
$recipient = $invoice->character_id;
|
||||||
|
|
||||||
|
$body = "Dear " . $invoice->character_name . ",<br><br>";
|
||||||
|
$body .= "The Mining Invoice: " . $invoice->invoice_id . " is late.<br>";
|
||||||
|
$body .= "Please remite " . number_format($invoice->invoice_amount, 2, ".", ",") . "to Spatial Forces.<br>";
|
||||||
|
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
|
||||||
|
|
||||||
|
//Send a reminder to the user through eve mail about the late invoice
|
||||||
|
SendEveMail::dispatch($body, $recipient, $recipientType, $subject, $sender)->delay(Carbon::now()->addSeconds($mailDelay));
|
||||||
|
|
||||||
|
$mailDelay += 20;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the tags for Horzion
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public function tags() {
|
||||||
|
return ['UpdateMiningTaxesLateInvoices', 'MiningTaxes', 'Invoices'];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,164 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\MiningTaxes\Ledgers;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//App Library
|
||||||
|
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
use App\Library\Helpers\LookupHelper;
|
||||||
|
use App\Library\Moons\MoonCalc;
|
||||||
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\Commands\MiningTaxes\Ledgers\ProcessMiningTaxesLedgers;
|
||||||
|
|
||||||
|
//App Models
|
||||||
|
use App\Models\MiningTax\Observer;
|
||||||
|
use App\Models\MiningTax\Ledger;
|
||||||
|
use App\Models\Moon\MineralPrice;
|
||||||
|
use App\Models\Moon\ItemComposition;
|
||||||
|
use App\Models\Esi\EsiToken;
|
||||||
|
use App\Models\Esi\EsiScope;
|
||||||
|
|
||||||
|
class FetchMiningTaxesLedgers implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of job retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $tries = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Job Variables
|
||||||
|
*/
|
||||||
|
private $charId;
|
||||||
|
private $corpId;
|
||||||
|
private $observerId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct($charId, $corpId, $observerId)
|
||||||
|
{
|
||||||
|
//Set the connection for the job
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('miningtaxes');
|
||||||
|
|
||||||
|
//Import the variables from the calling function
|
||||||
|
$this->charId = $charId;
|
||||||
|
$this->corpId = $corpId;
|
||||||
|
$this->observerId = $observerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Declare variables
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$mHelper = new MoonCalc;
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
$pageFailed = false;
|
||||||
|
$config = config('esi');
|
||||||
|
|
||||||
|
//Check for the correct scope
|
||||||
|
if(!$esiHelper->haveEsiScope($this->charId, 'esi-industry.read_corporation_mining.v1')) {
|
||||||
|
Log::critical('Character: ' . $this->charId . ' did not have the correct esi scope in FetchMiningTaxesLedgersJob.');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the esi token in order to pull data from esi
|
||||||
|
$refreshToken = $esiHelper->GetRefreshToken($this->charId);
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||||
|
|
||||||
|
//Set the current page
|
||||||
|
$currentPage = 1;
|
||||||
|
$totalPages = 1;
|
||||||
|
|
||||||
|
//Setup a do-while loop to sort through the ledgers by pages
|
||||||
|
do {
|
||||||
|
/**
|
||||||
|
* During the course of the operation, we want to ensure our token stays valid.
|
||||||
|
* If the token, expires, then we want to refresh the token through the esi helper
|
||||||
|
* library functionality.
|
||||||
|
*/
|
||||||
|
if($esiHelper->TokenExpired($refreshToken)) {
|
||||||
|
$refreshToken = $esiHelper->GetRefreshToken($this->charId);
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to get the data from the esi api. If it fails, we skip the page
|
||||||
|
*/
|
||||||
|
try {
|
||||||
|
$response = $esi->page($currentPage)
|
||||||
|
->invoke('get', '/corporation/{corporation_id}/mining/observers/{observer_id}/', [
|
||||||
|
'corporation_id' => $config['corporation'],
|
||||||
|
'observer_id' => $this->observerId,
|
||||||
|
]);
|
||||||
|
} catch(RequestFailedException $e) {
|
||||||
|
Log::warning('Failed to get the mining ledger in FetchMiningTaxesLedgersCommand for observer id: ' . $this->observerId);
|
||||||
|
$pageFailed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the current page is the first one and the page didn't fail, then update the total pages.
|
||||||
|
* If the first page failed, just return as we aren't going to be able to get the total amount of data needed.
|
||||||
|
*/
|
||||||
|
if($currentPage == 1 && $pageFailed == false) {
|
||||||
|
$totalPages = $response->pages;
|
||||||
|
} else if($currentPage == 1 && $pageFailed == true) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($pageFailed == true) {
|
||||||
|
//If the page failed, then reset the variable, and skip the current iteration
|
||||||
|
//of creating the jobs.
|
||||||
|
$pageFailed = false;
|
||||||
|
} else {
|
||||||
|
//Decode the json response from the ledgers
|
||||||
|
$ledgers = json_decode($response->raw);
|
||||||
|
|
||||||
|
//Dispatch jobs to process each of the mining ledger entries
|
||||||
|
foreach($ledgers as $ledger) {
|
||||||
|
ProcessMiningTaxesLedgers::dispatch($ledger, $this->observerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Increment the current pages
|
||||||
|
$currentPage++;
|
||||||
|
|
||||||
|
} while($currentPage <= $totalPages);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the tags for Horzion
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public function tags() {
|
||||||
|
return ['FetchMiningTaxesLedgers', 'MiningTaxes', 'MiningTaxesLedgers'];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\MiningTaxes\Ledgers;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
//App Library
|
||||||
|
use App\Library\Helpers\LookupHelper;
|
||||||
|
use App\Library\Moons\MoonCalc;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\MiningTax\Ledger;
|
||||||
|
use App\Models\Moon\MineralPrice;
|
||||||
|
use App\Models\Moon\ItemComposition;
|
||||||
|
|
||||||
|
class ProcessMiningTaxesLedgers implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of job retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $tries = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Job Variables
|
||||||
|
*/
|
||||||
|
private $ledger;
|
||||||
|
private $observerId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct($ledger, $observerId)
|
||||||
|
{
|
||||||
|
//Set the connection for the job
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('miningtaxes');
|
||||||
|
|
||||||
|
//Import variables from the calling function
|
||||||
|
$this->ledger = $ledger;
|
||||||
|
$this->observerId = $observerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$mHelper = new MoonCalc;
|
||||||
|
$config = config('esi');
|
||||||
|
|
||||||
|
//Create a starting date for the ledger
|
||||||
|
$ledgerDate = Carbon::createFromFormat('Y-m-d', $this->ledger->last_updated);
|
||||||
|
|
||||||
|
//If the ledger is more than one day old, then process it, otherwise, we don't process it
|
||||||
|
//or add it to the database as it may still be updating.
|
||||||
|
if($ledgerDate->lessThan(Carbon::now()->subDay())) {
|
||||||
|
//Get some of the basic information we need to work with
|
||||||
|
$charName = $lookup->CharacterIdToName($this->ledger->character_id);
|
||||||
|
//Get the type name from the ledger ore
|
||||||
|
$typeName = $lookup->ItemIdToName($this->ledger->type_id);
|
||||||
|
//Get the price from the helper function
|
||||||
|
$price = $mHelper->CalculateOrePrice($this->ledger->type_id);
|
||||||
|
//Calculate the total price based on the amount
|
||||||
|
$amount = (($price * $this->ledger->quantity) * $config['refine_rate']);
|
||||||
|
|
||||||
|
$found = Ledger::where([
|
||||||
|
'character_id' => $this->ledger->character_id,
|
||||||
|
'observer_id' => $this->observerId,
|
||||||
|
'type_id' => $this->ledger->type_id,
|
||||||
|
'last_updated' => $this->ledger->last_updated,
|
||||||
|
])->count();
|
||||||
|
|
||||||
|
if($found == 0) {
|
||||||
|
$ledg = new Ledger;
|
||||||
|
$ledg->character_id = $this->ledger->character_id;
|
||||||
|
$ledg->character_name = $charName;
|
||||||
|
$ledg->observer_id = $this->observerId;
|
||||||
|
$ledg->last_updated = $this->ledger->last_updated;
|
||||||
|
$ledg->type_id = $this->ledger->type_id;
|
||||||
|
$ledg->ore_name = $typeName;
|
||||||
|
$ledg->quantity = $this->ledger->quantity;
|
||||||
|
$ledg->amount = $amount;
|
||||||
|
$ledg->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the tags for Horzion
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public function tags() {
|
||||||
|
return ['ProcessMiningTaxesLedgers', 'MiningTaxes', 'MiningTaxesLedgers'];
|
||||||
|
}
|
||||||
|
}
|
||||||
58
app/Jobs/Commands/MiningTaxes/MiningTaxesWeeklyInvoicing.php
Normal file
58
app/Jobs/Commands/MiningTaxes/MiningTaxesWeeklyInvoicing.php
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\MiningTaxes;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Support\Facades\Bus;
|
||||||
|
|
||||||
|
use App\Jobs\Commands\MiningTaxes\Invoices\SendMiningTaxesInvoices;
|
||||||
|
use App\Jobs\Commands\MiningTaxes\Invoices\ProcessAllianceMiningOperations;
|
||||||
|
|
||||||
|
class MiningTaxesWeeklyInvoicing implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of job retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $tries = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//Set job parameters
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('miningtaxes');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
Bus::chain([
|
||||||
|
new ProcessAllianceMiningOperations,
|
||||||
|
new SendMiningTaxesInvoices,
|
||||||
|
])->dispatch();
|
||||||
|
}
|
||||||
|
}
|
||||||
75
app/Jobs/Commands/MiningTaxes/PreFetchMiningTaxesLedgers.php
Normal file
75
app/Jobs/Commands/MiningTaxes/PreFetchMiningTaxesLedgers.php
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\MiningTaxes;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Log;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\MiningTax\Observer;
|
||||||
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\Commands\MiningTaxes\Ledgers\FetchMiningTaxesLedgers;
|
||||||
|
|
||||||
|
class PreFetchMiningTaxesLedgers implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of job retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $tries = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('miningtaxes');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Get the site configuration which holds some data we need
|
||||||
|
$config = config('esi');
|
||||||
|
//Get the observers from the database
|
||||||
|
$observers = Observer::all();
|
||||||
|
|
||||||
|
//For each of the observers, send a job to fetch the mining ledger
|
||||||
|
foreach($observers as $obs) {
|
||||||
|
//Dispatch the mining taxes ledger jobs
|
||||||
|
FetchMiningTaxesLedgers::dispatch($config['primary'], $config['corporation'], $obs->observer_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the tags for Horzion
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public function tags() {
|
||||||
|
return ['PreFetchMiningTaxesLedgers', 'MiningTaxes', 'MiningTaxesLedgers'];
|
||||||
|
}
|
||||||
|
}
|
||||||
143
app/Jobs/Commands/MiningTaxes/ProcessMiningTaxesPayments.php
Normal file
143
app/Jobs/Commands/MiningTaxes/ProcessMiningTaxesPayments.php
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\MiningTaxes;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
//Library
|
||||||
|
use App\Library\Helpers\LookupHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\MiningTax\Invoice;
|
||||||
|
use App\Models\MiningTax\Payment;
|
||||||
|
use App\Models\Finances\AllianceWalletJournal;
|
||||||
|
|
||||||
|
class ProcessMiningTaxesPayments implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of job retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $tries = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('miningtaxes');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Declare the variables we will need
|
||||||
|
$looup = new LookupHelper;
|
||||||
|
$currentTime = Carbon::now();
|
||||||
|
|
||||||
|
//Get the outstanding invoices
|
||||||
|
$outstanding = Invoice::where([
|
||||||
|
'status' => 'Pending',
|
||||||
|
])->get();
|
||||||
|
|
||||||
|
//Use the player donation journal from finances to see if the invoice_id is present
|
||||||
|
//as a reason
|
||||||
|
foreach($outstanding as $invoice) {
|
||||||
|
//See if we have a reason with the correct uniqid from the player donation journal
|
||||||
|
$found = AllianceWalletJournal::where([
|
||||||
|
'reason' => $invoice->invoice_id,
|
||||||
|
])->count();
|
||||||
|
|
||||||
|
//If we have received the invoice, then mark the invoice as paid
|
||||||
|
if($found > 0) {
|
||||||
|
//If we have the count, then grab the journal entry in order to do some things with it
|
||||||
|
$journal = AllianceWalletJournal::where([
|
||||||
|
'reason' => $invoice->invoice_id,
|
||||||
|
])->first();
|
||||||
|
|
||||||
|
//If the bill is paid on time, then update the invoice as such
|
||||||
|
if($currentTime->lessThanOrEqualTo($journal->inserted_at)) {
|
||||||
|
Invoice::where([
|
||||||
|
'invoice_id' => $invoice->invoice_id,
|
||||||
|
])->update([
|
||||||
|
'status' => 'Paid',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($currentTime->greaterThan($journal->inserted_at)) {
|
||||||
|
Invoice::where([
|
||||||
|
'invoice_id' => $invoice->invoice_id,
|
||||||
|
])->update([
|
||||||
|
'status' => 'Paid Late',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$count = AllianceWalletJournal::where([
|
||||||
|
'reason' => $invoice->invoice_id,
|
||||||
|
])->count();
|
||||||
|
|
||||||
|
if($count > 0) {
|
||||||
|
//If we have the count, then grab the journal entry in order to do some things with it
|
||||||
|
$journal = AllianceWalletJournal::where([
|
||||||
|
'reason' => $invoice->invoice_id,
|
||||||
|
])->first();
|
||||||
|
|
||||||
|
//If the bill is paid on time, then update the invoice as such
|
||||||
|
if($currentTime->lessThanOrEqualTo($journal->inserted_at)) {
|
||||||
|
Invoice::where([
|
||||||
|
'invoice_id' => $invoice->invoice_id,
|
||||||
|
])->update([
|
||||||
|
'status' => 'Paid',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($currentTime->greaterThan($journal->inserted_at)) {
|
||||||
|
Invoice::where([
|
||||||
|
'invoice_id' => $invoice->invoice_id,
|
||||||
|
])->update([
|
||||||
|
'status' => 'Paid Late',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Use the contract descriptions from the esi to see if the invoice_id is present.
|
||||||
|
//If the invoice is present, then mark it off as sent in correctly
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the tags for Horzion
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public function tags() {
|
||||||
|
return ['ProcessMiningTaxesPayments', 'MiningTaxes', 'Payments'];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Jobs\Commands\MiningTaxes;
|
|
||||||
|
|
||||||
//Internal Library
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Log;
|
|
||||||
|
|
||||||
//Library
|
|
||||||
use App\Library\Lookups\LookupHelper;
|
|
||||||
|
|
||||||
//Models
|
|
||||||
use App\Models\MiningTaxes\Invoice;
|
|
||||||
use App\Models\MiningTaxes\Payment;
|
|
||||||
use App\Models\Finances\PlayerDonationJournal;
|
|
||||||
|
|
||||||
class ProcessMiningTaxesPaymentsJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new job instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->connection = 'redis';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the job.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
//Declare the variables we will need
|
|
||||||
$looup = new LookupHelper;
|
|
||||||
$currentTime = Carbon::now();
|
|
||||||
|
|
||||||
//Get the outstanding invoices
|
|
||||||
$outstanding = Invoice::where([
|
|
||||||
'status' => 'Pending',
|
|
||||||
])->get();
|
|
||||||
|
|
||||||
//Use the player donation journal from finances to see if the invoice_id is present
|
|
||||||
//as a reason
|
|
||||||
foreach($outstanding as $invoice) {
|
|
||||||
//See if we have a reason with the correct uniqid from the player donation journal
|
|
||||||
$found = PlayerDonationJournal::where([
|
|
||||||
'reason' => "MMT: " . $invoice->invoice_id,
|
|
||||||
])->count();
|
|
||||||
|
|
||||||
//If we have received the invoice, then mark the invoice as paid
|
|
||||||
if($count > 0) {
|
|
||||||
//If we have the count, then grab the journal entry in order to do some things with it
|
|
||||||
$journal = PlayerDonationJournal::where([
|
|
||||||
'reason' => "MMT: " . $invoice->invoice_id,
|
|
||||||
])->first();
|
|
||||||
|
|
||||||
//If the bill is paid on time, then update the invoice as such
|
|
||||||
if($currentTime->lessThanOrEqualTo($journal->inserted_at)) {
|
|
||||||
Invoice::where([
|
|
||||||
'invoice_id' => $invoice->invoice_id,
|
|
||||||
])->update([
|
|
||||||
'status' => 'Paid',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($currentTime->greaterThan($journal->inserted_at)) {
|
|
||||||
Invoice::where([
|
|
||||||
'invoice_id' => $invoice->invoice_id,
|
|
||||||
])->update([
|
|
||||||
'status' => 'Paid Late',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
316
app/Jobs/Commands/MiningTaxes/SendMiningTaxesInvoicesOld.php
Normal file
316
app/Jobs/Commands/MiningTaxes/SendMiningTaxesInvoicesOld.php
Normal file
@@ -0,0 +1,316 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\MiningTaxes;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Log;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
//Application Library
|
||||||
|
use App\Library\Helpers\LookupHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\MiningTax\Invoice;
|
||||||
|
use App\Models\MiningTax\Ledger;
|
||||||
|
use App\Models\User\UserAlt;
|
||||||
|
use App\Models\User\User;
|
||||||
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\Commands\Eve\SendEveMail;
|
||||||
|
|
||||||
|
class SendMiningTaxesInvoicesOld implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of job retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $tries = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('miningtaxes');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Declare variables
|
||||||
|
$mailDelay = 15;
|
||||||
|
$mains = new Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This section will determine if users are mains or alts of a main.
|
||||||
|
* If they are mains, we keep the key. If they are alts of a main, then we delete
|
||||||
|
* the key from the collection.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//Pluck all the users from the database of ledgers to determine if they are mains or alts.
|
||||||
|
$tempMains = Ledger::where([
|
||||||
|
'invoiced' => 'No',
|
||||||
|
])->where('last_updated', '>', Carbon::now()->subDays(7))->pluck('character_id');
|
||||||
|
|
||||||
|
//Get the unique character ids from the ledgers in the previous statement
|
||||||
|
$tempMains = $tempMains->unique()->values()->all();
|
||||||
|
|
||||||
|
//Cycle through the array of mains, and remove any characters which are in the User Alt table,
|
||||||
|
//as those characters will be grouped with their correct main later.
|
||||||
|
for($i = 0; $i < sizeof($tempMains); $i++) {
|
||||||
|
if(UserAlt::where(['character_id' => $tempMains[$i]])->count() == 0) {
|
||||||
|
$mains->push($tempMains[$i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For each of the users, let's determine if there are any ledgers,
|
||||||
|
* then determine if there are any alts and ledgers associated with the alts.
|
||||||
|
*/
|
||||||
|
foreach($mains as $main) {
|
||||||
|
//Declare some variables for each run through the for loop
|
||||||
|
$ledgers = new Collection;
|
||||||
|
|
||||||
|
//Count the ledgers for the main
|
||||||
|
$mainLedgerCount = Ledger::where([
|
||||||
|
'character_id' => $main,
|
||||||
|
'invoiced' => 'No',
|
||||||
|
])->where('last_updated', '>', Carbon::now()->subDays(7))->count();
|
||||||
|
|
||||||
|
//If there are ledgers for the main, then let's grab them
|
||||||
|
if($mainLedgerCount > 0) {
|
||||||
|
$mainLedgers = Ledger::where([
|
||||||
|
'character_id' => $main,
|
||||||
|
'invoiced' => 'No',
|
||||||
|
])->where('last_updated', '>', Carbon::now()->subDays(7))->get();
|
||||||
|
|
||||||
|
//Cycle through the entries, and add them to the ledger to send with the invoice
|
||||||
|
foreach($mainLedgers as $row) {
|
||||||
|
$ledgers->push([
|
||||||
|
'character_id' => $row->character_id,
|
||||||
|
'character_name' => $row->character_name,
|
||||||
|
'observer_id' => $row->observer_id,
|
||||||
|
'type_id' => $row->type_id,
|
||||||
|
'ore_name' => $row->ore_name,
|
||||||
|
'quantity' => (int)$row->quantity,
|
||||||
|
'amount' => (float)$row->amount,
|
||||||
|
'last_updated' => $row->last_updated,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the alt count for the main character
|
||||||
|
$altCount = UserAlt::where(['main_id' => $main])->count();
|
||||||
|
//If more than 0 alts, grab all the alts.
|
||||||
|
if($altCount > 0) {
|
||||||
|
$alts = UserAlt::where([
|
||||||
|
'main_id' => $main,
|
||||||
|
])->get();
|
||||||
|
|
||||||
|
//Cycle through the alts, and get the ledgers, and push onto the stack
|
||||||
|
foreach($alts as $alt) {
|
||||||
|
$altLedgerCount = Ledger::where([
|
||||||
|
'character_id' => $alt->character_id,
|
||||||
|
'invoiced' => 'No',
|
||||||
|
])->where('last_updated', '>', Carbon::now()->subDays(7))->count();
|
||||||
|
|
||||||
|
if($altLedgerCount > 0) {
|
||||||
|
$altLedgers = Ledger::where([
|
||||||
|
'character_id' => $alt->character_id,
|
||||||
|
'invoiced' => 'No',
|
||||||
|
])->where('last_updated', '>', Carbon::now()->subDays(7))->get();
|
||||||
|
|
||||||
|
foreach($altLedgers as $row) {
|
||||||
|
$ledgers->push([
|
||||||
|
'character_id' => $row->character_id,
|
||||||
|
'character_name' => $row->character_name,
|
||||||
|
'observer_id' => $row->observer_id,
|
||||||
|
'type_id' => $row->type_id,
|
||||||
|
'ore_name' => $row->ore_name,
|
||||||
|
'quantity' => (int)$row->quantity,
|
||||||
|
'amount' => (float)$row->amount,
|
||||||
|
'last_updated' => $row->last_updated,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the collected information over to the function to send the actual mail
|
||||||
|
*/
|
||||||
|
if($ledgers->count() > 0) {
|
||||||
|
$this->CreateInvoice($main, $ledgers, $mailDelay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the invoice to the mail out
|
||||||
|
*
|
||||||
|
* @var charId
|
||||||
|
* @var ledgers
|
||||||
|
* @var mailDelay
|
||||||
|
*/
|
||||||
|
private function CreateInvoice($charId, Collection $ledgers, int &$mailDelay) {
|
||||||
|
$ores = array();
|
||||||
|
$characters = array();
|
||||||
|
$characterIds = array();
|
||||||
|
$totalPrice = 0.00;
|
||||||
|
$body = null;
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$config = config('esi');
|
||||||
|
|
||||||
|
//Create an invoice id
|
||||||
|
$invoiceId = "M" . uniqid();
|
||||||
|
|
||||||
|
//Get the sum of all the ledgers
|
||||||
|
$invoiceAmount = round(((float)$ledgers->sum('amount') * (float)$config['mining_tax']), 2);
|
||||||
|
|
||||||
|
//Get the character name from the lookup table
|
||||||
|
$charName = $lookup->CharacterIdToName($charId);
|
||||||
|
|
||||||
|
//Create the date due and the invoice date
|
||||||
|
$dateDue = Carbon::now()->addDays(7);
|
||||||
|
$invoiceDate = Carbon::now();
|
||||||
|
|
||||||
|
//Set the mining tax from the config file
|
||||||
|
$numberMiningTax = number_format(((float)$config['mining_tax'] * (float)100.00), 2, ".", ",");
|
||||||
|
|
||||||
|
//Create the list of ores to put in the mail
|
||||||
|
$temp = $ledgers->toArray();
|
||||||
|
foreach($temp as $t) {
|
||||||
|
//If the key isn't set, set it to the default of 0
|
||||||
|
if(!isset($ores[$t['type_id']])) {
|
||||||
|
$ores[$t['type_id']] = (int)0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add the quantity into the ores array
|
||||||
|
$ores[$t['type_id']] += (int)$t['quantity'];
|
||||||
|
|
||||||
|
//Create a list of character names
|
||||||
|
if(!isset($characters[$t['character_name']])) {
|
||||||
|
$characters[$t['character_name']] = $t['character_name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create a list of character ids
|
||||||
|
if(!isset($characterIds[$t['character_id']])) {
|
||||||
|
$characterIds[$t['character_id']] = $t['character_id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the mail body to send to the main character
|
||||||
|
*/
|
||||||
|
$body .= "Dear " . $charName . ",<br><br>";
|
||||||
|
$body .= "Mining Taxes are due for the following ores mined from alliance moons: <br>";
|
||||||
|
foreach($ores as $ore => $quantity) {
|
||||||
|
$oreName = $lookup->ItemIdToName($ore);
|
||||||
|
$body .= $oreName . ": " . number_format($quantity, 0, ".", ",") . "<br>";
|
||||||
|
}
|
||||||
|
$body .= "Total Value of Ore Mined: " . number_format($totalPrice, 2, ".", ",") . " ISK.";
|
||||||
|
$body .= "<br><br>";
|
||||||
|
$body .= "Please remit " . number_format($invoiceAmount, 2, ".", ",") . " ISK to Spatial Forces by " . $dateDue . "<br>";
|
||||||
|
$body .= "Set the reason for transfer as " . $invoiceId . "<br>";
|
||||||
|
$body .= "The mining taxes are currently set to " . $numberMiningTax . "%.<br>";
|
||||||
|
$body .= "<br><br>";
|
||||||
|
$body .= "You can also send a contract with the following ores in the contract with the reason set as: " . $invoiceId . "<br>";
|
||||||
|
foreach($ores as $ore => $quantity) {
|
||||||
|
$oreName = $lookup->ItemIdToName($ore);
|
||||||
|
$body .= $oreName . ": " . number_format(round($quantity * $config['mining_tax']), 0, ".", ",") . "<br>";
|
||||||
|
}
|
||||||
|
$body .= "<br>";
|
||||||
|
$body .= "Characters Processed: <br>";
|
||||||
|
foreach($characters as $character) {
|
||||||
|
$body .= $character . "<br>";
|
||||||
|
}
|
||||||
|
$body .= "<br>";
|
||||||
|
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
|
||||||
|
|
||||||
|
//Check if the mail body is greater than 2000 characters. If greater than 2,000 characters, then
|
||||||
|
if(strlen($body) > 2000) {
|
||||||
|
$body = "Dear " . $charName . "<br><br>";
|
||||||
|
$body .= "Total Value of Ore Mined: " . number_format($totalPrice, 2, ".", ",") . " ISK.";
|
||||||
|
$body .= "<br><br>";
|
||||||
|
$body .= "Please remit " . number_format($invoiceAmount, 2, ".", ",") . " ISK to Spatial Forces by " . $dateDue . "<br>";
|
||||||
|
$body .= "Set the reason for transfer as: " . $invoiceId . "<br>";
|
||||||
|
$body .= "The mining taxes are currently set to " . $numberMiningTax . "%.<br>";
|
||||||
|
$body .= "<br>";
|
||||||
|
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
|
||||||
|
}
|
||||||
|
|
||||||
|
//Mail the invoice to the character if the character is in
|
||||||
|
//Warped Intentions or Legacy
|
||||||
|
$subject = 'Warped Intentions Mining Taxes';
|
||||||
|
$sender = $config['primary'];
|
||||||
|
$recipientType = 'character';
|
||||||
|
$recipient = $charId;
|
||||||
|
|
||||||
|
//Send the Eve Mail Job to the queue to be dispatched
|
||||||
|
SendEveMail::dispatch($body, $recipient, $recipientType, $subject, $sender)->delay(Carbon::now()->addSeconds($mailDelay));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new invoice model, and save it to the database
|
||||||
|
*/
|
||||||
|
$invoice = new Invoice;
|
||||||
|
$invoice->character_id = $charId;
|
||||||
|
$invoice->character_name = $charName;
|
||||||
|
$invoice->invoice_id = $invoiceId;
|
||||||
|
$invoice->invoice_amount = $invoiceAmount;
|
||||||
|
$invoice->date_issued = $invoiceDate;
|
||||||
|
$invoice->date_due = $dateDue;
|
||||||
|
$invoice->status = 'Pending';
|
||||||
|
$invoice->mail_body = $body;
|
||||||
|
$invoice->save();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark the invoices as paid
|
||||||
|
*/
|
||||||
|
foreach($characterIds as $char) {
|
||||||
|
Ledger::where([
|
||||||
|
'character_id' => $char,
|
||||||
|
'invoiced' => 'No',
|
||||||
|
])->update([
|
||||||
|
'invoice' => $invoiceId,
|
||||||
|
'invoiced' => 'Yes',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Increment the mail delay for the next cycle
|
||||||
|
*/
|
||||||
|
$mailDelay += 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the tags for Horizon
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public function tags() {
|
||||||
|
return ['MiningTaxes', 'SendMiningTaxesInvoics', 'Invoices'];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\MoonRental\Invoices;
|
||||||
|
|
||||||
|
//Application Library
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Log;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use App\Library\Helpers\LookupHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\MoonRental\AllianceMoon;
|
||||||
|
use App\Models\MoonRental\AllianceMoonOre;
|
||||||
|
use App\Models\MoonRental\AllianceMoonRental;
|
||||||
|
|
||||||
|
class SendMoonRentalInvoices implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('miningtaxes');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Declare variables
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$months = 3;
|
||||||
|
$today = Carbon::now();
|
||||||
|
$future = Carbon::now()->addMonths(3);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\MoonRental;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Log;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use App\Library\Moons\MoonCalc;
|
||||||
|
use App\Library\Helpers\LookupHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\MoonRental\AllianceMoon;
|
||||||
|
use App\Models\MoonRental\AllianceMoonOre;
|
||||||
|
|
||||||
|
class UpdateAllianceMoonRentalWorth implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('default');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Declare variables
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$mHelper = new MoonCalc;
|
||||||
|
$months = 3;
|
||||||
|
$rentalTax = 0.25;
|
||||||
|
|
||||||
|
$moons = AllianceMoon::all();
|
||||||
|
|
||||||
|
foreach($moons as $moon) {
|
||||||
|
//Declare the arrays needed
|
||||||
|
$ores = array();
|
||||||
|
$worth = 0.00;
|
||||||
|
|
||||||
|
$ores = AllianceMoonOre::where([
|
||||||
|
'moon_id' => $moon->moon_id,
|
||||||
|
])->get(['ore_name', 'quantity'])->toArray();
|
||||||
|
|
||||||
|
if(sizeof($ores) == 1) {
|
||||||
|
$ores[1]["ore_name"] = null;
|
||||||
|
$ores[1]["quantity"] = 0.00;
|
||||||
|
$ores[2]["ore_name"] = null;
|
||||||
|
$ores[2]["quantity"] = 0.00;
|
||||||
|
$ores[3]["ore_name"] = null;
|
||||||
|
$ores[3]["quantity"] = 0.00;
|
||||||
|
} else if(sizeof($ores) == 2) {
|
||||||
|
$ores[2]["ore_name"] = null;
|
||||||
|
$ores[2]["quantity"] = 0.00;
|
||||||
|
$ores[3]["ore_name"] = null;
|
||||||
|
$ores[3]["quantity"] = 0.00;
|
||||||
|
} else if(sizeof($ores) == 3) {
|
||||||
|
$ores[3]["ore_name"] = null;
|
||||||
|
$ores[3]["quantity"] = 0.00;
|
||||||
|
}
|
||||||
|
|
||||||
|
//one of these two ways will work
|
||||||
|
$worth = $mHelper->MoonTotalWorth($ores[0]["ore_name"], $ores[0]["quantity"],
|
||||||
|
$ores[1]["ore_name"], $ores[1]["quantity"],
|
||||||
|
$ores[2]["ore_name"], $ores[2]["quantity"],
|
||||||
|
$ores[3]["ore_name"], $ores[3]["quantity"]);
|
||||||
|
|
||||||
|
$rentalAmount = $worth * $rentalTax * $months;
|
||||||
|
|
||||||
|
AllianceMoon::where([
|
||||||
|
'moon_id' => $moon->moon_id,
|
||||||
|
])->update([
|
||||||
|
'worth_amount' => $worth,
|
||||||
|
'rental_amount' => $rentalAmount,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
174
app/Jobs/Commands/Structures/FetchAllianceStructures.php
Normal file
174
app/Jobs/Commands/Structures/FetchAllianceStructures.php
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\Structures;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
//Application Library
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
use Seat\Eseye\Exception\RequestFailedException;
|
||||||
|
use App\Library\Structures\StructureHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Structure\Structure;
|
||||||
|
use App\Models\Structure\Service;
|
||||||
|
|
||||||
|
class FetchAllianceStructures implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of job retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $tries = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//Set the connection for the job
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('structures');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//Declare variables
|
||||||
|
$config = config('esi');
|
||||||
|
$corpId = 98287666;
|
||||||
|
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
$structureScope = $esiHelper->HaveEsiScope($config['primary'], 'esi-universe.read_structures.v1');
|
||||||
|
$corpStructureScope = $esiHelper->HaveEsiScope($config['primary'], 'esi-corporations.read_structures.v1');
|
||||||
|
|
||||||
|
//Check scopes
|
||||||
|
if($structureScope == false || $corpStructureScope == false) {
|
||||||
|
if($structureScope == false) {
|
||||||
|
Log::critical("Scope check for esi-universe.read_structures.v1 has failed.");
|
||||||
|
}
|
||||||
|
if($corpStructureScope == false) {
|
||||||
|
Log::critical("Scope check for esi-corporations.read_structures.v1 has failed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the refresh token from the database
|
||||||
|
$token = $esiHelper->GetRefreshToken($config['primary']);
|
||||||
|
//Create the esi authentication container
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||||
|
|
||||||
|
//Set the current page
|
||||||
|
$currentPage = 1;
|
||||||
|
//Set our default pages
|
||||||
|
$totalPages = 1;
|
||||||
|
|
||||||
|
do {
|
||||||
|
//Attempt to get the entire page worth of structures
|
||||||
|
$structures = $esi->page($currentPage)
|
||||||
|
->invoke('get', '/corporations/{corporation_id}/structures/', [
|
||||||
|
'corporation_id' => $corpId,
|
||||||
|
]);
|
||||||
|
|
||||||
|
//If on the first page, then update the total number of pages
|
||||||
|
if($currentPage == 1) {
|
||||||
|
$totalPages = $structures->pages;
|
||||||
|
}
|
||||||
|
|
||||||
|
//For each asset retrieved, let's process it.
|
||||||
|
foreach($structures as $s) {
|
||||||
|
ProcessAllianceStructures::dispatch($s)->onQueue('structures');
|
||||||
|
}
|
||||||
|
|
||||||
|
//Increment the current page
|
||||||
|
$currentPage++;
|
||||||
|
} while($currentPage <= $totalPages);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The job failed to process
|
||||||
|
* @param Exception $exception
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function failed($exception) {
|
||||||
|
if(!exception instanceof RequestFailedException) {
|
||||||
|
//If not a failure due to ESI, then log it. Otherwise,
|
||||||
|
//deduce why the exception occurred.
|
||||||
|
Log::critical($exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((is_object($exception->getEsiResponse()) && (stristr($exception->getEsiResponse()->error, 'Too many errors') || stristr($exception->getEsiResponse()->error, 'This software has exceeded the error limit for ESI'))) ||
|
||||||
|
(is_string($exception->getEsiResponse()) && (stristr($exception->getEsiResponse(), 'Too many errors') || stristr($exception->getEsiResponse(), 'This software has exceeded the error limit for ESI')))) {
|
||||||
|
|
||||||
|
//We have hit the error rate limiter, wait 120 seconds before releasing the job back into the queue.
|
||||||
|
Log::info('FetchAllianceStructures has hit the error rate limiter. Releasing the job back into the wild in 2 minutes.');
|
||||||
|
$this->release(120);
|
||||||
|
} else {
|
||||||
|
$errorCode = $exception->getEsiResponse()->getErrorCode();
|
||||||
|
|
||||||
|
switch($errorCode) {
|
||||||
|
case 400: //Bad Request
|
||||||
|
Log::critical("Bad request has occurred in FetchAllianceStructures. Job has been discarded");
|
||||||
|
break;
|
||||||
|
case 401: //Unauthorized Request
|
||||||
|
Log::critical("Unauthorized request has occurred in FetchAllianceStructures at " . Carbon::now()->toDateTimeString() . ".\r\nCancelling the job.");
|
||||||
|
break;
|
||||||
|
case 403: //Forbidden
|
||||||
|
Log::critical("FetchAllianceStructures has incurred a forbidden error. Cancelling the job.");
|
||||||
|
break;
|
||||||
|
case 420: //Error Limited
|
||||||
|
Log::warning("Error rate limit occurred in FetchAllianceStructures. Restarting job in 120 seconds.");
|
||||||
|
$this->release(120);
|
||||||
|
break;
|
||||||
|
case 500: //Internal Server Error
|
||||||
|
Log::critical("Internal Server Error for ESI in FetchAllianceStructures. Attempting a restart in 120 seconds.");
|
||||||
|
$this->release(120);
|
||||||
|
break;
|
||||||
|
case 503: //Service Unavailable
|
||||||
|
Log::critical("Service Unavailabe for ESI in FetchAllianceStructures. Releasing the job back to the queue in 30 seconds.");
|
||||||
|
$this->release(30);
|
||||||
|
break;
|
||||||
|
case 504: //Gateway Timeout
|
||||||
|
Log::critical("Gateway timeout in FetchAllianceStructures. Releasing the job back to the queue in 30 seconds.");
|
||||||
|
$this->release(30);
|
||||||
|
break;
|
||||||
|
case 201: //Good response code
|
||||||
|
$this->delete();
|
||||||
|
break;
|
||||||
|
//If no code is given, then log and break out of switch.
|
||||||
|
default:
|
||||||
|
Log::warning("No response code received from esi call in FetchAllianceStructures.\r\n");
|
||||||
|
$this->delete();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tags() {
|
||||||
|
return ['FetchAllianceStructures', 'AllianceStructures', 'Structures'];
|
||||||
|
}
|
||||||
|
}
|
||||||
216
app/Jobs/Commands/Structures/ProcessAllianceStructures.php
Normal file
216
app/Jobs/Commands/Structures/ProcessAllianceStructures.php
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\Structures;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
//Application Library
|
||||||
|
use App\Library\Helpers\LookupHelper;
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Structure\Structure;
|
||||||
|
use App\Models\Structure\Service;
|
||||||
|
|
||||||
|
class ProcessAllianceStructures implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of job retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $tries = 3;
|
||||||
|
|
||||||
|
private $structure;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct($s)
|
||||||
|
{
|
||||||
|
//Set the connection for the job
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('structures');
|
||||||
|
|
||||||
|
//Set variables
|
||||||
|
$this->structure = $s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Update the structure if it already exists, or add the structure if it doesn't exist in the database
|
||||||
|
*/
|
||||||
|
if(Structure::where(['structure_id' => $this->structure->structure_id])->count() > 0) {
|
||||||
|
$this->UpdateStructure($this->structure);
|
||||||
|
} else {
|
||||||
|
$this->SaveNewStructure($this->structure);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the tags for the job
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public function tags() {
|
||||||
|
return ['ProcessAllianceStructures', 'AllianceStructures', 'Structures'];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function SaveNewStructure($structure) {
|
||||||
|
//Declare variables
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
|
//Get the solar system name
|
||||||
|
$solarName = $lookup->SystemIdToName($structure->system_id);
|
||||||
|
|
||||||
|
$s = new Structure;
|
||||||
|
$s->structure_id = $structure->structure_id;
|
||||||
|
$s->structure_name = $structure->name;
|
||||||
|
$s->solar_system_id = $structure->system_id;
|
||||||
|
$s->solar_system_name = $solarName;
|
||||||
|
$s->type_id = $structure->type_id;
|
||||||
|
$s->type_name = $lookup->StructureTypeIdToName($structure->type_id);
|
||||||
|
$s->corporation_id = $structure->corporation_id;
|
||||||
|
if(isset($structure->services)) {
|
||||||
|
$s->services = true;
|
||||||
|
foreach($structure->services as $service) {
|
||||||
|
$serv = new Service;
|
||||||
|
$serv->structure_id = $structure->structure_id;
|
||||||
|
$serv->name = $service->name;
|
||||||
|
$serv->state = $service->state;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$s->services = false;
|
||||||
|
}
|
||||||
|
$s->state = $structure->state;
|
||||||
|
if(isset($structre->state_timer_start)) {
|
||||||
|
$s->state_timer_start = $esiHelper->DecodeDate($structure->state_timer_start);
|
||||||
|
}
|
||||||
|
if(isset($structure->state_timer_end)) {
|
||||||
|
$s->state_timer_end = $esiHelper->DecodeDate($structure->state_timer_end);
|
||||||
|
}
|
||||||
|
if(isset($structure->fuel_expires)) {
|
||||||
|
$s->fuel_expires = $esiHelper->DecodeDate($structure->fuel_expires);
|
||||||
|
}
|
||||||
|
$s->profile_id = $structure->profile_id;
|
||||||
|
if(isset($structure->next_reinforce_apply)) {
|
||||||
|
$s->next_reinforce_apply = $structure->next_reinforce_apply;
|
||||||
|
}
|
||||||
|
if(isset($structure->next_reinforce_hour)) {
|
||||||
|
$s->next_reinforce_hour = $structure->next_reinforce_hour;
|
||||||
|
}
|
||||||
|
$s->reinforce_hour = $structure->reinforce_hour;
|
||||||
|
if(isset($structure->unanchors_at)) {
|
||||||
|
$s->unanchors_at = $esiHelper->DecodeDate($s->unanchors_at);
|
||||||
|
}
|
||||||
|
$s->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function UpdateStructure($structure) {
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
|
if(isset($structure->corporation_id)) {
|
||||||
|
Structure::where([
|
||||||
|
'structure_id' => $structure->structure_id,
|
||||||
|
])->update([
|
||||||
|
'corporation_id' => $structure->corporation_id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if(isset($structure->state)) {
|
||||||
|
Structure::where([
|
||||||
|
'structure_id' => $structure->structure_id,
|
||||||
|
])->update([
|
||||||
|
'state' => $structure->state,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if(isset($structure->state_timer_start)) {
|
||||||
|
Structure::where([
|
||||||
|
'structure_id' => $structure->structure_id,
|
||||||
|
])->update([
|
||||||
|
'state_timer_start' => $esiHelper->DecodeDate($structure->state_timer_start),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if(isset($structure->state_timer_end)) {
|
||||||
|
Structure::where([
|
||||||
|
'structure_id' => $structure->structure_id,
|
||||||
|
])->update([
|
||||||
|
'state_timer_end' => $esiHelper->DecodeDate($structure->state_timer_end),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if(isset($structure->fuel_expires)) {
|
||||||
|
Structure::where([
|
||||||
|
'structure_id' => $structure->structure_id,
|
||||||
|
])->update([
|
||||||
|
'fuel_expires' => $esiHelper->DecodeDate($structure->fuel_expires),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if(isset($structure->profile_id)) {
|
||||||
|
Structure::where([
|
||||||
|
'structure_id' => $structure->structure_id,
|
||||||
|
])->update([
|
||||||
|
'profile_id' => $structure->profile_id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if(isset($structure->next_reinforce_apply)) {
|
||||||
|
Structure::where([
|
||||||
|
'structure_id' => $structure->structure_id,
|
||||||
|
])->update([
|
||||||
|
'next_reinforce_apply' => $structure->next_reinforce_apply,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if(isset($structure->next_reinforce_hour)) {
|
||||||
|
Structure::where([
|
||||||
|
'structure_id' => $structure->structure_id,
|
||||||
|
])->update([
|
||||||
|
'next_reinforce_hour' => $structure->next_reinforce_hour,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if(isset($structure->reinforce_hour)) {
|
||||||
|
Structure::where([
|
||||||
|
'structure_id' => $structure->structure_id,
|
||||||
|
])->update([
|
||||||
|
'reinforce_hour' => $structure->reinforce_hour,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if(isset($structure->unanchors_at)) {
|
||||||
|
Structure::where([
|
||||||
|
'structure_id' => $structure->structure_id,
|
||||||
|
])->update([
|
||||||
|
'unanchors_at' => $esiHelper->DecodeDate($structure->unanchors_at),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Service::where(['structure_id' => $structure->structure_id])->count() > 0) {
|
||||||
|
foreach($structure->services as $service) {
|
||||||
|
Service::where([
|
||||||
|
'structure_id' => $structure->structure_id,
|
||||||
|
])->update([
|
||||||
|
'state' => $service->state,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
70
app/Jobs/Commands/Structures/PurgeAllianceStructures.php
Normal file
70
app/Jobs/Commands/Structures/PurgeAllianceStructures.php
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Commands\Structures;
|
||||||
|
|
||||||
|
//Internal Library
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\Commands\Structures\FetchAllianceStructures;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\Structure\Structure;
|
||||||
|
use App\Models\Structure\Service;
|
||||||
|
|
||||||
|
class PurgeAllianceStructures implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $timeout = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of job retries
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $tries = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//Set the connection for the job
|
||||||
|
$this->connection = 'redis';
|
||||||
|
$this->onQueue('structures');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
Structure::truncate();
|
||||||
|
Service::truncate();
|
||||||
|
|
||||||
|
FetchAllianceStructures::dispatch()->delay(Carbon::now()->addSeconds(30));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the tags for the job
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public function tags() {
|
||||||
|
return ['PurgeAllianceStructures', 'AllianceStructures', 'Structures'];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,7 +18,7 @@ use App\Models\Contracts\SupplyChainBid;
|
|||||||
use App\Models\Contracts\SupplyChainContract;
|
use App\Models\Contracts\SupplyChainContract;
|
||||||
|
|
||||||
//Jobs
|
//Jobs
|
||||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
use App\Jobs\Commands\Eve\SendEveMail;
|
||||||
|
|
||||||
class EndSupplyChainContractJob implements ShouldQueue
|
class EndSupplyChainContractJob implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
|||||||
169
app/Jobs/Middleware/EveMailLimiter.php
Normal file
169
app/Jobs/Middleware/EveMailLimiter.php
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Support\Facades\Redis;
|
||||||
|
|
||||||
|
class EveMailLimiter {
|
||||||
|
/** @var bool|\Closure */
|
||||||
|
protected $enabled = true;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $connectionName = 'redis';
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $key;
|
||||||
|
|
||||||
|
/** @var int */
|
||||||
|
protected $timeSpanInSeconds = 1;
|
||||||
|
|
||||||
|
/** @var int */
|
||||||
|
protected $allowedNumberOfJobsInTimeSpan = 4;
|
||||||
|
|
||||||
|
/** @var int */
|
||||||
|
protected $releaseInSeconds = 60;
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
protected $releaseRandomSeconds = null;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$calledByClass = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]['class'];
|
||||||
|
|
||||||
|
$this->key($calledByClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool|\Closure $enabled
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function enabled($enabled = true)
|
||||||
|
{
|
||||||
|
$this->enabled = $enabled;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function connectionName(string $connectionName = 'redis')
|
||||||
|
{
|
||||||
|
$this->connectionName = $connectionName;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function key(string $key)
|
||||||
|
{
|
||||||
|
$this->key = $key;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function timespanInSeconds(int $timespanInSeconds)
|
||||||
|
{
|
||||||
|
$this->timeSpanInSeconds = $timespanInSeconds;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function allow(int $allowedNumberOfJobsInTimeSpan = 4)
|
||||||
|
{
|
||||||
|
$this->allowedNumberOfJobsInTimeSpan = $allowedNumberOfJobsInTimeSpan;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function everySecond(int $timespanInSeconds = 1)
|
||||||
|
{
|
||||||
|
$this->timeSpanInSeconds = $timespanInSeconds;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function everySeconds(int $timespanInSeconds = 60)
|
||||||
|
{
|
||||||
|
return $this->everySecond($timespanInSeconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function everyMinute(int $timespanInMinutes = 1)
|
||||||
|
{
|
||||||
|
return $this->everySecond($timespanInMinutes * 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function everyMinutes(int $timespanInMinutes)
|
||||||
|
{
|
||||||
|
return $this->everySecond($timespanInMinutes * 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function releaseAfterOneSecond()
|
||||||
|
{
|
||||||
|
return $this->releaseAfterSeconds(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function releaseAfterSeconds(int $releaseInSeconds)
|
||||||
|
{
|
||||||
|
$this->releaseInSeconds = $releaseInSeconds;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function releaseAfterOneMinute()
|
||||||
|
{
|
||||||
|
return $this->releaseAfterMinutes(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function releaseAfterMinutes(int $releaseInMinutes)
|
||||||
|
{
|
||||||
|
return $this->releaseAfterSeconds($releaseInMinutes * 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function releaseAfterRandomSeconds(int $min = 1, int $max = 10)
|
||||||
|
{
|
||||||
|
$this->releaseRandomSeconds = [$min, $max];
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function releaseAfterBackoff(int $attemptedCount, int $backoffRate = 2)
|
||||||
|
{
|
||||||
|
$releaseAfterSeconds = 0;
|
||||||
|
$interval = $this->releaseInSeconds;
|
||||||
|
for ($attempt = 0; $attempt <= $attemptedCount; $attempt++) {
|
||||||
|
$releaseAfterSeconds += $interval * pow($backoffRate, $attempt);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->releaseAfterSeconds($releaseAfterSeconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function releaseDuration(): int
|
||||||
|
{
|
||||||
|
if (! is_null($this->releaseRandomSeconds)) {
|
||||||
|
return random_int(...$this->releaseRandomSeconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->releaseInSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle($job, $next)
|
||||||
|
{
|
||||||
|
if ($this->enabled instanceof Closure) {
|
||||||
|
$this->enabled = (bool) $this->enabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $this->enabled) {
|
||||||
|
return $next($job);
|
||||||
|
}
|
||||||
|
|
||||||
|
Redis::connection($this->connectionName)
|
||||||
|
->throttle($this->key)
|
||||||
|
->block(0)
|
||||||
|
->allow($this->allowedNumberOfJobsInTimeSpan)
|
||||||
|
->every($this->timeSpanInSeconds)
|
||||||
|
->then(function () use ($job, $next) {
|
||||||
|
$next($job);
|
||||||
|
}, function () use ($job) {
|
||||||
|
$job->release($this->releaseDuration());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@ use App\Models\Esi\EsiToken;
|
|||||||
use App\Models\Esi\EsiScope;
|
use App\Models\Esi\EsiScope;
|
||||||
|
|
||||||
//Jobs
|
//Jobs
|
||||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
use App\Jobs\Commands\Eve\SendEveMail;
|
||||||
|
|
||||||
//Seat Stuff
|
//Seat Stuff
|
||||||
use Seat\Eseye\Cache\NullCache;
|
use Seat\Eseye\Cache\NullCache;
|
||||||
@@ -46,7 +46,7 @@ class Esi {
|
|||||||
$subject = 'W4RP Services - Incorrect ESI Scope';
|
$subject = 'W4RP Services - Incorrect ESI Scope';
|
||||||
$body = "Please register on https://services.w4rp.space with the scope: " . $scope;
|
$body = "Please register on https://services.w4rp.space with the scope: " . $scope;
|
||||||
|
|
||||||
ProcessSendEveMailJob::dispatch($body, (int)$charId, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(5));
|
SendEveMail::dispatch($body, (int)$charId, 'character', $subject, $config['primary'])->delay(Carbon::now()->addSeconds(5));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ class FinanceHelper {
|
|||||||
public function GetApiWalletJournal($division, $charId) {
|
public function GetApiWalletJournal($division, $charId) {
|
||||||
//Declare class variables
|
//Declare class variables
|
||||||
$lookup = new LookupHelper;
|
$lookup = new LookupHelper;
|
||||||
$finance = new FinanceHelper;
|
|
||||||
$esiHelper = new Esi;
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
//Setup the esi container.
|
//Setup the esi container.
|
||||||
@@ -159,6 +158,47 @@ class FinanceHelper {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the pages for the alliance wallet journal
|
||||||
|
*/
|
||||||
|
public function GetAllianceWalletJournalPages($division, $charId) {
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
|
//Setup the esi container.
|
||||||
|
$token = $esiHelper->GetRefreshToken($charId);
|
||||||
|
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||||
|
|
||||||
|
//Check the scope
|
||||||
|
if(!$esiHelper->HaveEsiScope($charId, 'esi-wallet.read_corporation_wallets.v1')) {
|
||||||
|
Log::critical('Scope check failed for esi-wallet.read_corporation_wallets.v1 for character id: ' . $charId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Reference the character id to the corporation id
|
||||||
|
$char = $lookup->GetCharacterInfo($charId);
|
||||||
|
$corpId = $char->corporation_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to get the data from the esi api. If it fails, we skip the page, and go onto the next page, unless
|
||||||
|
* the failed page is the first page.
|
||||||
|
*/
|
||||||
|
try {
|
||||||
|
$journals = $esi->page(1)
|
||||||
|
->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
|
||||||
|
'corporation_id' => $corpId,
|
||||||
|
'division' => $division,
|
||||||
|
]);
|
||||||
|
} catch(RequestFailedException $e) {
|
||||||
|
Log::warning('Failed to get wallet journal pages for character id: ' . $charId);
|
||||||
|
Log::warning($e);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Return the total pages
|
||||||
|
return $journals->pages;
|
||||||
|
}
|
||||||
|
|
||||||
private function GetPIMaterialsArray() {
|
private function GetPIMaterialsArray() {
|
||||||
//Setup array for PI items
|
//Setup array for PI items
|
||||||
$pi_items = [
|
$pi_items = [
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ use App\Models\Lookups\CorporationLookup;
|
|||||||
use App\Models\Lookups\AllianceLookup;
|
use App\Models\Lookups\AllianceLookup;
|
||||||
use App\Models\Lookups\SolarSystem;
|
use App\Models\Lookups\SolarSystem;
|
||||||
use App\Models\Lookups\ItemLookup;
|
use App\Models\Lookups\ItemLookup;
|
||||||
|
use App\Models\Lookups\MoonLookup;
|
||||||
|
|
||||||
class LookupHelper {
|
class LookupHelper {
|
||||||
|
|
||||||
@@ -29,10 +30,45 @@ class LookupHelper {
|
|||||||
public function __construct() {
|
public function __construct() {
|
||||||
//Declare a variable for use by the construct
|
//Declare a variable for use by the construct
|
||||||
$esiHelper = new Esi;
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
$this->esi = $esiHelper->SetupEsiAuthentication();
|
$this->esi = $esiHelper->SetupEsiAuthentication();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function StructureTypeIdToName($typeId) {
|
||||||
|
$structureTypes = [
|
||||||
|
35841 => 'Ansiblex Jump Gate',
|
||||||
|
35840 => 'Pharolux Cyno Beacon',
|
||||||
|
37534 => 'Tenebrex Cyno Jammer',
|
||||||
|
35834 => 'Keepstar',
|
||||||
|
35833 => 'Fortizar',
|
||||||
|
35832 => 'Astrahus',
|
||||||
|
35836 => 'Tatara',
|
||||||
|
35835 => 'Athanor',
|
||||||
|
35827 => 'Sotiyo',
|
||||||
|
35826 => 'Azbel',
|
||||||
|
35825 => 'Raitaru',
|
||||||
|
];
|
||||||
|
|
||||||
|
return $structureTypes[$typeId];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function StructureNameToTypeId($name) {
|
||||||
|
$structureTypes = [
|
||||||
|
'Ansiblex Jump Gate' => 35841,
|
||||||
|
'Pharolux Cyno Beacon' => 35840,
|
||||||
|
'Tenebrex Cyno Jammer' => 37534,
|
||||||
|
'Keepstar' => 35834,
|
||||||
|
'Fortizar' => 35833,
|
||||||
|
'Astrahus' => 35832,
|
||||||
|
'Tatara' => 35836,
|
||||||
|
'Athanor' => 35835,
|
||||||
|
'Sotiyo' => 35827,
|
||||||
|
'Azbel' => 35826,
|
||||||
|
'Raitaru' => 35825,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $structureTypes[$name];
|
||||||
|
}
|
||||||
|
|
||||||
public function ItemNameToId($itemName) {
|
public function ItemNameToId($itemName) {
|
||||||
$item = ItemLookup::where([
|
$item = ItemLookup::where([
|
||||||
'name' => $itemName,
|
'name' => $itemName,
|
||||||
@@ -217,6 +253,58 @@ class LookupHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get moon information from the database, or store it in the database if it's not found
|
||||||
|
*/
|
||||||
|
public function GetMoonInfo($moonId) {
|
||||||
|
//Check our own database first
|
||||||
|
$moon = $this->LookupMoonInfo($moonId);
|
||||||
|
|
||||||
|
//If no data was found in the database, then save the data, and return what is found through esi
|
||||||
|
if( $moon == null) {
|
||||||
|
try {
|
||||||
|
$response = $this->esi->invoke('get', '/universe/moons/{moon_id}/', [
|
||||||
|
'moon_id' => $moonId,
|
||||||
|
]);
|
||||||
|
} catch(RequestFailedException $e) {
|
||||||
|
Log::critical("Failed to get moon information in LookupHelper.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->SaveMoonInfo($response);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
} else {
|
||||||
|
//Return the moon info
|
||||||
|
return $moon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lookup moon info from the database
|
||||||
|
*/
|
||||||
|
private function LookupMoonInfo($moonId) {
|
||||||
|
$moon = MoonLookup::where([
|
||||||
|
'moon_id' => $moonId,
|
||||||
|
])->first();
|
||||||
|
|
||||||
|
return $moon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save moon info into the lookup database
|
||||||
|
*/
|
||||||
|
private function SaveMoonInfo($moon) {
|
||||||
|
$newMoon = new MoonLookup;
|
||||||
|
$newMoon->moon_id = $moon->moon_id;
|
||||||
|
$newMoon->name = $moon->name;
|
||||||
|
$newMoon->position_x = $moon->position->x;
|
||||||
|
$newMoon->position_y = $moon->position->y;
|
||||||
|
$newMoon->position_z = $moon->position->z;
|
||||||
|
$newMoon->system_id = $moon->system_id;
|
||||||
|
$newMoon->save();
|
||||||
|
}
|
||||||
|
|
||||||
public function GetCharacterInfo($charId) {
|
public function GetCharacterInfo($charId) {
|
||||||
//Check our own database first
|
//Check our own database first
|
||||||
$char = $this->LookupCharacter($charId, null);
|
$char = $this->LookupCharacter($charId, null);
|
||||||
@@ -247,7 +335,7 @@ class LookupHelper {
|
|||||||
public function GetCorporationInfo($corpId) {
|
public function GetCorporationInfo($corpId) {
|
||||||
//Check our own database first
|
//Check our own database first
|
||||||
$corp = $this->LookupCorporation($corpId, null);
|
$corp = $this->LookupCorporation($corpId, null);
|
||||||
|
|
||||||
//If the corporation was not found in the database, then get the information and store it in our database for later
|
//If the corporation was not found in the database, then get the information and store it in our database for later
|
||||||
if($corp == null) {
|
if($corp == null) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
72
app/Library/Helpers/MiningTaxHelper.php
Normal file
72
app/Library/Helpers/MiningTaxHelper.php
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Library\Helpers;
|
||||||
|
|
||||||
|
//Internal Libraries
|
||||||
|
use Log;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
//Application Library
|
||||||
|
use App\Library\Helpers\LookupHelper;
|
||||||
|
|
||||||
|
//Models
|
||||||
|
use App\Models\MiningTax\Invoice;
|
||||||
|
use App\Models\MiningTax\Ledger;
|
||||||
|
|
||||||
|
//Jobs
|
||||||
|
use App\Jobs\Commands\Eve\SendEveMail;
|
||||||
|
|
||||||
|
class MiningTaxHelper {
|
||||||
|
/**
|
||||||
|
* Private variables
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the ledgers for a certain character and send back as a collection
|
||||||
|
*
|
||||||
|
* @var $charId
|
||||||
|
* @return collection $ledgers
|
||||||
|
*/
|
||||||
|
public function GetLedgers(int $charId) {
|
||||||
|
$ledgers = new Collection;
|
||||||
|
|
||||||
|
$rowCount = Ledger::where([
|
||||||
|
'character_id' => $charId,
|
||||||
|
'invoiced' => 'No',
|
||||||
|
])->count();
|
||||||
|
|
||||||
|
if($rowCount > 0) {
|
||||||
|
$rows = Ledger::where([
|
||||||
|
'character_id' => $charId,
|
||||||
|
'invoiced' => 'No',
|
||||||
|
])->get()->toArray();
|
||||||
|
|
||||||
|
foreach($rows as $row) {
|
||||||
|
$ledgers->push($row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ledgers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the invoice and mail it
|
||||||
|
*
|
||||||
|
* @var int $charId
|
||||||
|
* @var collection $ledgers
|
||||||
|
* @var int $mailDelay
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function MailMiningInvoice(int $charId, collection $ledgers, int &$mailDelay) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@ use Log;
|
|||||||
use App\Jobs\Library\JobHelper;
|
use App\Jobs\Library\JobHelper;
|
||||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||||
use App\Library\Esi\Esi;
|
use App\Library\Esi\Esi;
|
||||||
use App\Library\Lookups\LookupHelper;
|
use App\Library\Helpers\LookupHelper;
|
||||||
|
|
||||||
//App Models
|
//App Models
|
||||||
use App\Models\Jobs\JobStatus;
|
use App\Models\Jobs\JobStatus;
|
||||||
@@ -73,24 +73,7 @@ class StructureHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function GetSolarSystemName($systemId) {
|
public function GetStructureName($structureId) {
|
||||||
//Declare some variables
|
|
||||||
$esiHelper = new Esi;
|
|
||||||
$lookup = new LookupHelper;
|
|
||||||
|
|
||||||
$solar = $lookup->SystemIdToName($systemId);
|
|
||||||
|
|
||||||
if($solar != null) {
|
|
||||||
return $solar;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GetStructureInfo($structureId) {
|
|
||||||
//Declare some variables
|
|
||||||
$esiHelper = new Esi;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$info = $this->esi->invoke('get', '/universe/structures/{structure_id}/', [
|
$info = $this->esi->invoke('get', '/universe/structures/{structure_id}/', [
|
||||||
'structure_id' => $structureId,
|
'structure_id' => $structureId,
|
||||||
@@ -103,10 +86,45 @@ class StructureHelper {
|
|||||||
$info = null;
|
$info = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $info;
|
$structure = json_decode($info->raw, true);
|
||||||
|
|
||||||
|
if(!isset($structure['name'])) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return (string)$structure['name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for a structure in our own database, otherwise pull it from esi.
|
||||||
|
*/
|
||||||
|
public function GetStructureInfo($structureId) {
|
||||||
|
$info = Structure::where([
|
||||||
|
'structure_id' => $structureId,
|
||||||
|
])->first();
|
||||||
|
|
||||||
|
if($info != null) {
|
||||||
|
return $info;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
$info = $this->esi->invoke('get', '/universe/structures/{structure_id}/', [
|
||||||
|
'structure_id' => $structureId,
|
||||||
|
]);
|
||||||
|
} catch(RequestFailedException $e) {
|
||||||
|
Log::warning("Failed to get structure information for structure with id " . $structureId);
|
||||||
|
Log::warning($e->getCode());
|
||||||
|
Log::warning($e->getMessage());
|
||||||
|
Log::warning($e->getEsiResponse());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $info;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function UpdateExistingStructure($structure, $info) {
|
private function UpdateExistingStructure($structure, $info) {
|
||||||
|
$esi = new Esi;
|
||||||
|
|
||||||
//Update the structure id and name
|
//Update the structure id and name
|
||||||
Structure::where(['structure_id' => $structure->structure_id])->update([
|
Structure::where(['structure_id' => $structure->structure_id])->update([
|
||||||
'structure_id' => $structure->structure_id,
|
'structure_id' => $structure->structure_id,
|
||||||
@@ -140,21 +158,21 @@ class StructureHelper {
|
|||||||
//Update the state timer start
|
//Update the state timer start
|
||||||
if(isset($structure->state_timer_start)) {
|
if(isset($structure->state_timer_start)) {
|
||||||
Structure::where(['structure_id' => $structure->structure_id])->update([
|
Structure::where(['structure_id' => $structure->structure_id])->update([
|
||||||
'state_timer_start' => $this->DecodeDate($structure->state_timer_start),
|
'state_timer_start' => $esi->DecodeDate($structure->state_timer_start),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update the state timer end
|
//Update the state timer end
|
||||||
if(isset($structure->state_timer_end)) {
|
if(isset($structure->state_timer_end)) {
|
||||||
Structure::where(['structure_id' => $structure->structure_id])->update([
|
Structure::where(['structure_id' => $structure->structure_id])->update([
|
||||||
'state_timer_end' => $this->DecodeDate($structure->state_timer_end),
|
'state_timer_end' => $esi->DecodeDate($structure->state_timer_end),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update the fuel expires
|
//Update the fuel expires
|
||||||
if(isset($structure->fuel_expires)) {
|
if(isset($structure->fuel_expires)) {
|
||||||
Structure::where(['structure_id' => $structure->structure_id])->update([
|
Structure::where(['structure_id' => $structure->structure_id])->update([
|
||||||
'fuel_expires' => $this->DecodeDate($structure->fuel_expires),
|
'fuel_expires' => $esi->DecodeDate($structure->fuel_expires),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +187,7 @@ class StructureHelper {
|
|||||||
//Update the next reinforce apply
|
//Update the next reinforce apply
|
||||||
if(isset($structure->next_reinforce_apply)) {
|
if(isset($structure->next_reinforce_apply)) {
|
||||||
Structure::where(['structure_id' => $structure->structure_id])->update([
|
Structure::where(['structure_id' => $structure->structure_id])->update([
|
||||||
'next_reinforce_apply' => $this->DecodeDate($structure->next_reinforce_apply),
|
'next_reinforce_apply' => $esi->DecodeDate($structure->next_reinforce_apply),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +222,7 @@ class StructureHelper {
|
|||||||
//Update the unanchors at field
|
//Update the unanchors at field
|
||||||
if(isset($structure->unanchors_at)) {
|
if(isset($structure->unanchors_at)) {
|
||||||
//Decode the date / time
|
//Decode the date / time
|
||||||
$daTi = $this->DecodeDate($structure->unanchors_at);
|
$daTi = $esi->DecodeDate($structure->unanchors_at);
|
||||||
|
|
||||||
Structure::where(['structure_id' => $structure->structure_id])->update([
|
Structure::where(['structure_id' => $structure->structure_id])->update([
|
||||||
'unanchors_at' => $daTi,
|
'unanchors_at' => $daTi,
|
||||||
@@ -230,12 +248,14 @@ class StructureHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function SaveNewStructure($structure, $info) {
|
private function SaveNewStructure($structure, $info) {
|
||||||
|
//Declare helper variable needed
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
$esi = new Esi;
|
||||||
|
|
||||||
if(isset($info->solar_system_id)) {
|
if(isset($info->solar_system_id)) {
|
||||||
$solarName = $this->GetSolarSystemName($info->solar_system_id);
|
$solarName = $lookup->SolarSystemIdToName($info->solar_system_id);
|
||||||
} else {
|
} else {
|
||||||
Log::critical("Couldn't get solar system name for structure " . $structure->structure_id);
|
Log::critical("Couldn't get solar system name for structure " . $structure->structure_id . " in SaveNewStructure in StructureHelper.php");
|
||||||
Log::critical("Check access lists.");
|
|
||||||
$solarName = null;
|
$solarName = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,20 +280,20 @@ class StructureHelper {
|
|||||||
$st->state = 'None';
|
$st->state = 'None';
|
||||||
}
|
}
|
||||||
if(isset($structure->state_timer_start)) {
|
if(isset($structure->state_timer_start)) {
|
||||||
$st->state_timer_start = $this->DecodeDate($structure->state_timer_start);
|
$st->state_timer_start = $esi->DecodeDate($structure->state_timer_start);
|
||||||
}
|
}
|
||||||
if(isset($structure->state_timer_end)) {
|
if(isset($structure->state_timer_end)) {
|
||||||
$st->state_timer_end = $this->DecodeDate($structure->state_timer_end);
|
$st->state_timer_end = $esi->DecodeDate($structure->state_timer_end);
|
||||||
}
|
}
|
||||||
if(isset($structure->fuel_expires)) {
|
if(isset($structure->fuel_expires)) {
|
||||||
$st->fuel_expires = $this->DecodeDate($structure->fuel_expires);
|
$st->fuel_expires = $esi->DecodeDate($structure->fuel_expires);
|
||||||
}
|
}
|
||||||
$st->profile_id = $structure->profile_id;
|
$st->profile_id = $structure->profile_id;
|
||||||
$st->position_x = $info->position->x;
|
$st->position_x = $info->position->x;
|
||||||
$st->position_y = $info->position->y;
|
$st->position_y = $info->position->y;
|
||||||
$st->position_z = $info->position->z;
|
$st->position_z = $info->position->z;
|
||||||
if(isset($structure->next_reinforce_apply)) {
|
if(isset($structure->next_reinforce_apply)) {
|
||||||
$st->next_reinforce_apply = $this->DecodeDate($structure->next_reinforce_apply);
|
$st->next_reinforce_apply = $esi->DecodeDate($structure->next_reinforce_apply);
|
||||||
}
|
}
|
||||||
if(isset($structure->next_reinforce_hour)) {
|
if(isset($structure->next_reinforce_hour)) {
|
||||||
$st->next_reinforce_hour = $structure->next_reinforce_hour;
|
$st->next_reinforce_hour = $structure->next_reinforce_hour;
|
||||||
@@ -286,7 +306,7 @@ class StructureHelper {
|
|||||||
$st->reinforce_weekday = $structure->reinforce_weekday;
|
$st->reinforce_weekday = $structure->reinforce_weekday;
|
||||||
}
|
}
|
||||||
if(isset($structure->unanchors_at)) {
|
if(isset($structure->unanchors_at)) {
|
||||||
$daTi = $this->DecodeDate($structure->unanchors_at);
|
$daTi = $esi->DecodeDate($structure->unanchors_at);
|
||||||
$st->unanchors_at = $daTi;
|
$st->unanchors_at = $daTi;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,7 +324,10 @@ class StructureHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function GetStructuresByType($type) {
|
public function GetStructuresByType($type) {
|
||||||
$sType = $this->StructureTypeToId($type);
|
//Declare variable
|
||||||
|
$lookup = new LookupHelper;
|
||||||
|
|
||||||
|
$sType = $lookup->StructureNameToTypeId($type);
|
||||||
|
|
||||||
$structures = Structure::where([
|
$structures = Structure::where([
|
||||||
'type_id' => $sType,
|
'type_id' => $sType,
|
||||||
@@ -312,32 +335,6 @@ class StructureHelper {
|
|||||||
|
|
||||||
return $structures;
|
return $structures;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function StructureTypeToId($name) {
|
|
||||||
$structureTypes = [
|
|
||||||
'Ansiblex Jump Gate' => 35841,
|
|
||||||
'Pharolux Cyno Beacon' => 35840,
|
|
||||||
'Tenebrex Cyno Jammer' => 37534,
|
|
||||||
'Keepstar' => 35834,
|
|
||||||
'Fortizar' => 35833,
|
|
||||||
'Astrahus' => 35832,
|
|
||||||
'Tatara' => 35836,
|
|
||||||
'Athanor' => 35835,
|
|
||||||
'Sotiyo' => 35827,
|
|
||||||
'Azbel' => 35826,
|
|
||||||
'Raitaru' => 35825,
|
|
||||||
];
|
|
||||||
|
|
||||||
return $structureTypes[$name];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function DecodeDate($date) {
|
|
||||||
$esiHelper = new Esi;
|
|
||||||
|
|
||||||
$dateTime = $esiHelper->DecodeDate($date);
|
|
||||||
|
|
||||||
return $dateTime;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -9,15 +9,9 @@ use Carbon\Carbon;
|
|||||||
use App\Models\User\User;
|
use App\Models\User\User;
|
||||||
use App\Models\User\UserRole;
|
use App\Models\User\UserRole;
|
||||||
use App\Models\User\UserPermission;
|
use App\Models\User\UserPermission;
|
||||||
|
use App\Models\Finances\AllianceWalletJournal;
|
||||||
use App\Models\Finances\ReprocessingTaxJournal;
|
use App\Models\MiningTax\Invoice;
|
||||||
use App\Models\Finances\StructureIndustryTaxJournal;
|
use App\Models\MoonRental\AllianceMoonRental;
|
||||||
use App\Models\Finances\PlanetProductionTaxJournal;
|
|
||||||
use App\Models\Finances\OfficeFeesJournal;
|
|
||||||
use App\Models\Finances\JumpBridgeJournal;
|
|
||||||
use App\Models\Finances\PISaleJournal;
|
|
||||||
use App\Models\Finances\AllianceMarketJournal;
|
|
||||||
use App\Models\SRP\SRPShip;
|
|
||||||
|
|
||||||
class TaxesHelper {
|
class TaxesHelper {
|
||||||
|
|
||||||
@@ -33,11 +27,40 @@ class TaxesHelper {
|
|||||||
$this->end = $en;
|
$this->end = $en;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function GetMoonRentalTaxesGross($start, $end) {
|
||||||
|
$revenue = 0.00;
|
||||||
|
|
||||||
|
$revenue = AllianceMoonRental::whereBetween('rental_start', [$start, $end])
|
||||||
|
->sum('rental_amount');
|
||||||
|
|
||||||
|
return $revenue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function GetMoonMiningTaxesGross($start, $end) {
|
||||||
|
$revenue = 0.00;
|
||||||
|
|
||||||
|
$revenue = Invoice::where([
|
||||||
|
'status' => 'Paid',
|
||||||
|
])->whereBetween('date_issued', [$start, $end])
|
||||||
|
->sum('invoice_amount');
|
||||||
|
|
||||||
|
return $revenue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function GetMoonMiningTaxesLateGross($start, $end) {
|
||||||
|
$revenue = 0.00;
|
||||||
|
|
||||||
|
$revenue = Invoice::where([
|
||||||
|
'status' => 'Paid Late',
|
||||||
|
])->whereBetween('date_issued', [$start, $end])->sum('invoice_amount');
|
||||||
|
|
||||||
|
return $revenue;
|
||||||
|
}
|
||||||
|
|
||||||
public function GetAllianceMarketGross($start, $end) {
|
public function GetAllianceMarketGross($start, $end) {
|
||||||
$revenue = 0.00;
|
$revenue = 0.00;
|
||||||
|
|
||||||
$revenue = AllianceMarketJournal::where([
|
$revenue = AllianceWalletJournal::where([
|
||||||
'second_party_id' => '98287666',
|
|
||||||
'ref_type' => 'brokers_fee',
|
'ref_type' => 'brokers_fee',
|
||||||
])->whereBetween('date', [$start, $end])
|
])->whereBetween('date', [$start, $end])
|
||||||
->sum('amount');
|
->sum('amount');
|
||||||
@@ -48,9 +71,8 @@ class TaxesHelper {
|
|||||||
public function GetJumpGateGross($start, $end) {
|
public function GetJumpGateGross($start, $end) {
|
||||||
$revenue = 0.00;
|
$revenue = 0.00;
|
||||||
|
|
||||||
$revenue = JumpBridgeJournal::where([
|
$revenue = AllianceWalletJournal::where([
|
||||||
'ref_type' => 'structure_gate_jump',
|
'ref_type' => 'structure_gate_jump',
|
||||||
'second_party_id' => '98287666',
|
|
||||||
])->whereBetween('date', [$start, $end])
|
])->whereBetween('date', [$start, $end])
|
||||||
->sum('amount');
|
->sum('amount');
|
||||||
|
|
||||||
@@ -60,9 +82,8 @@ class TaxesHelper {
|
|||||||
public function GetIndustryGross($start, $end) {
|
public function GetIndustryGross($start, $end) {
|
||||||
$revenue = 0.00;
|
$revenue = 0.00;
|
||||||
|
|
||||||
$revenue = StructureIndustryTaxJournal::where([
|
$revenue = AllianceWalletJournal::where([
|
||||||
'ref_type' => 'industry_job_tax',
|
'ref_type' => 'industry_job_tax',
|
||||||
'second_party_id' => '98287666',
|
|
||||||
])->whereBetween('date', [$start, $end])
|
])->whereBetween('date', [$start, $end])
|
||||||
->sum('amount');
|
->sum('amount');
|
||||||
|
|
||||||
@@ -72,9 +93,8 @@ class TaxesHelper {
|
|||||||
public function GetReprocessingGross($start, $end) {
|
public function GetReprocessingGross($start, $end) {
|
||||||
$revenue = 0.00;
|
$revenue = 0.00;
|
||||||
|
|
||||||
$revenue = ReprocessingTaxJournal::where([
|
$revenue = AllianceWalletJournal::where([
|
||||||
'ref_type' => 'reprocessing_tax',
|
'ref_type' => 'reprocessing_tax',
|
||||||
'second_party_id' => '98287666',
|
|
||||||
])->whereBetween('date', [$start, $end])
|
])->whereBetween('date', [$start, $end])
|
||||||
->sum('amount');
|
->sum('amount');
|
||||||
|
|
||||||
@@ -86,16 +106,14 @@ class TaxesHelper {
|
|||||||
$revenueExport = 0.00;
|
$revenueExport = 0.00;
|
||||||
|
|
||||||
//Get the import revenue from the database
|
//Get the import revenue from the database
|
||||||
$revenueImport = PlanetProductionTaxJournal::where([
|
$revenueImport = AllianceWalletJournal::where([
|
||||||
'ref_type' => 'planetary_import_tax',
|
'ref_type' => 'planetary_import_tax',
|
||||||
'second_party_id' => '98287666',
|
|
||||||
])->whereBetween('date', [$start, $end])
|
])->whereBetween('date', [$start, $end])
|
||||||
->sum('amount');
|
->sum('amount');
|
||||||
|
|
||||||
//Get the export revenue from the database
|
//Get the export revenue from the database
|
||||||
$revenueExport = PlanetProductionTaxJournal::where([
|
$revenueExport = AllianceWalletJournal::where([
|
||||||
'ref_type' => 'planetary_export_tax',
|
'ref_type' => 'planetary_export_tax',
|
||||||
'second_party_id' => '98287666',
|
|
||||||
])->whereBetween('date', [$start, $end])
|
])->whereBetween('date', [$start, $end])
|
||||||
->sum('amount');
|
->sum('amount');
|
||||||
|
|
||||||
@@ -109,27 +127,14 @@ class TaxesHelper {
|
|||||||
public function GetOfficeGross($start, $end) {
|
public function GetOfficeGross($start, $end) {
|
||||||
$revenue = 0.00;
|
$revenue = 0.00;
|
||||||
|
|
||||||
$revenue = OfficeFeesJournal::where([
|
$revenue = AllianceWalletJournal::where([
|
||||||
'ref_type' => 'office_rental_fee',
|
'ref_type' => 'office_rental_fee',
|
||||||
'second_party_id' => '98287666',
|
|
||||||
])->whereBetween('date', [$start, $end])
|
])->whereBetween('date', [$start, $end])
|
||||||
->sum('amount');
|
->sum('amount');
|
||||||
|
|
||||||
return $revenue;
|
return $revenue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetPiSalesGross($start, $end) {
|
|
||||||
$revenue = 0.00;
|
|
||||||
|
|
||||||
$grosses = PISaleJournal::whereBetween('date', [$start, $end])->get()->toArray();
|
|
||||||
|
|
||||||
foreach($grosses as $gross) {
|
|
||||||
$revenue += ($gross['quantity'] * $gross['unit_price']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $revenue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a set of dates from now until the amount of months has passed
|
* Returns a set of dates from now until the amount of months has passed
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -43,67 +43,29 @@ class MoonCalc {
|
|||||||
/**
|
/**
|
||||||
* Calculate the total worth of a moon
|
* Calculate the total worth of a moon
|
||||||
*/
|
*/
|
||||||
public function SpatialMoonsTotalWorth($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
|
public function MoonTotalWorth($firstOre = null, $firstQuan = 0.00, $secondOre = null, $secondQuan = 0.00, $thirdOre = null, $thirdQuan = 0.00, $fourthOre = null, $fourthQuan = 0.00) {
|
||||||
//Declare variables
|
//Declare variables
|
||||||
$totalPriceMined = 0.00;
|
$total = 0.00;
|
||||||
|
|
||||||
//Get the configuration for pricing calculations
|
|
||||||
$config = DB::table('Config')->get();
|
|
||||||
|
|
||||||
//Convert the quantities into numbers we want to utilize
|
//Convert the quantities into numbers we want to utilize
|
||||||
$this->ConvertPercentages($firstPerc, $firstQuan, $secondPerc, $secondQuan, $thirdPerc, $thirdQuan, $fourthPerc, $fourthQuan);
|
$this->ConvertPercentages($firstQuan, $secondQuan, $thirdQuan, $fourthQuan);
|
||||||
|
|
||||||
//Calculate the prices from the ores
|
//Calculate the prices from the ores
|
||||||
if($firstOre != 'None') {
|
if($firstOre != null) {
|
||||||
$totalPriceMined += $this->CalcMoonPrice($firstOre, $firstPerc);
|
$total += $this->CalcMoonPrice($firstOre, $firstQuan);
|
||||||
}
|
}
|
||||||
if($secondOre != 'None') {
|
if($secondOre != null) {
|
||||||
$totalPriceMined += $this->CalcMoonPrice($secondOre, $secondPerc);
|
$total += $this->CalcMoonPrice($secondOre, $secondQuan);
|
||||||
}
|
}
|
||||||
if($thirdOre != 'None') {
|
if($thirdOre != null) {
|
||||||
$totalPriceMined += $this->CalcMoonPrice($thirdOre, $thirdPerc);
|
$total += $this->CalcMoonPrice($thirdOre, $thirdQuan);
|
||||||
}
|
}
|
||||||
if($fourthOre != 'None') {
|
if($fourthOre != null) {
|
||||||
$totalPriceMined += $this->CalcMoonPrice($fourthOre, $fourthPerc);
|
$total += $this->CalcMoonPrice($fourthOre, $fourthQuan);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Return the rental price to the caller
|
//Return the rental price to the caller
|
||||||
return $totalPriceMined;
|
return $total;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculate the rental price
|
|
||||||
*/
|
|
||||||
public function SpatialMoons($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
|
|
||||||
//Declare variables
|
|
||||||
$totalPrice = 0.00;
|
|
||||||
|
|
||||||
//Get the configuration for pricing calculations
|
|
||||||
$config = DB::table('Config')->get();
|
|
||||||
|
|
||||||
//Convert the quantities into numbers we want to utilize
|
|
||||||
$this->ConvertPercentages($firstPerc, $firstQuan, $secondPerc, $secondQuan, $thirdPerc, $thirdQuan, $fourthPerc, $fourthQuan);
|
|
||||||
|
|
||||||
//Calculate the prices from the ores
|
|
||||||
if($firstOre != 'None') {
|
|
||||||
$totalPrice += $this->CalcRentalPrice($firstOre, $firstPerc);
|
|
||||||
}
|
|
||||||
if($secondOre != 'None') {
|
|
||||||
$totalPrice += $this->CalcRentalPrice($secondOre, $secondPerc);
|
|
||||||
}
|
|
||||||
if($thirdOre != 'None') {
|
|
||||||
$totalPrice += $this->CalcRentalPrice($thirdOre, $thirdPerc);
|
|
||||||
}
|
|
||||||
if($fourthOre != 'None') {
|
|
||||||
$totalPrice += $this->CalcRentalPrice($fourthOre, $fourthPerc);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Calculate the rental price. Refined rate is already included in the price from rental composition
|
|
||||||
$rentalPrice['alliance'] = $totalPrice * ($config[0]->RentalTax / 100.00);
|
|
||||||
$rentalPrice['outofalliance'] = $totalPrice * ($config[0]->AllyRentalTax / 100.00);
|
|
||||||
|
|
||||||
//Return the rental price to the caller
|
|
||||||
return $rentalPrice;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -480,7 +442,7 @@ class MoonCalc {
|
|||||||
/**
|
/**
|
||||||
* Calculate the moon's total price
|
* Calculate the moon's total price
|
||||||
*/
|
*/
|
||||||
private function CalcMoonPrice($ore, $percentage) {
|
public function CalcMoonPrice($ore, $percentage) {
|
||||||
//Specify the total pull amount
|
//Specify the total pull amount
|
||||||
$totalPull = $this->CalculateTotalMoonPull();
|
$totalPull = $this->CalculateTotalMoonPull();
|
||||||
|
|
||||||
@@ -537,12 +499,12 @@ class MoonCalc {
|
|||||||
/**
|
/**
|
||||||
* Return the type of ore a particular moon ore is.
|
* Return the type of ore a particular moon ore is.
|
||||||
*/
|
*/
|
||||||
private function IsRMoonGoo($ore) {
|
public function IsRMoonGoo($ore) {
|
||||||
$ores = [
|
$ores = [
|
||||||
'Zeolites' => 'Gas',
|
'Zeolites' => 'R4',
|
||||||
'Sylvite' => 'Gas',
|
'Sylvite' => 'R4',
|
||||||
'Bitumens' => 'Gas',
|
'Bitumens' => 'R4',
|
||||||
'Coesite' => 'Gas',
|
'Coesite' => 'R4',
|
||||||
'Cobaltite' => 'R8',
|
'Cobaltite' => 'R8',
|
||||||
'Euxenite' => 'R8',
|
'Euxenite' => 'R8',
|
||||||
'Titanite' => 'R8',
|
'Titanite' => 'R8',
|
||||||
@@ -575,12 +537,12 @@ class MoonCalc {
|
|||||||
* Return true if a moon ore is a moon ore, and false
|
* Return true if a moon ore is a moon ore, and false
|
||||||
* if the ore is not a moon ore.
|
* if the ore is not a moon ore.
|
||||||
*/
|
*/
|
||||||
private function IsRMoonOre($ore) {
|
public function IsRMoonOre($ore) {
|
||||||
$ores = [
|
$ores = [
|
||||||
'Zeolites' => 'Gas',
|
'Zeolites' => 'R4',
|
||||||
'Sylvite' => 'Gas',
|
'Sylvite' => 'R4',
|
||||||
'Bitumens' => 'Gas',
|
'Bitumens' => 'R4',
|
||||||
'Coesite' => 'Gas',
|
'Coesite' => 'R4',
|
||||||
'Cobaltite' => 'R8',
|
'Cobaltite' => 'R8',
|
||||||
'Euxenite' => 'R8',
|
'Euxenite' => 'R8',
|
||||||
'Titanite' => 'R8',
|
'Titanite' => 'R8',
|
||||||
@@ -612,34 +574,24 @@ class MoonCalc {
|
|||||||
/**
|
/**
|
||||||
* Convert percentages from quantities into a normalized percentage
|
* Convert percentages from quantities into a normalized percentage
|
||||||
*/
|
*/
|
||||||
private function ConvertPercentages(&$firstPerc, $firstQuan, &$secondPerc, $secondQuan, &$thirdPerc, $thirdQuan, &$fourthPerc, $fourthQuan) {
|
public function ConvertPercentages(&$firstPerc, &$secondPerc, &$thirdPerc, &$fourthPerc) {
|
||||||
//Set the base percentages for the if statements
|
|
||||||
$firstPerc = 0.00;
|
|
||||||
$secondPerc = 0.00;
|
|
||||||
$thirdPerc = 0.00;
|
|
||||||
$fourthPerc = 0.00;
|
|
||||||
|
|
||||||
//Convert the quantities into numbers we want to utilize
|
//Convert the quantities into numbers we want to utilize
|
||||||
if($firstQuan >= 1.00) {
|
if($firstPerc >= 1.00) {
|
||||||
$firstPerc = $this->ConvertToPercentage($firstQuan);
|
$firstPerc = $this->ConvertToPercentage($firstPerc);
|
||||||
} else {
|
}
|
||||||
$firstPerc = $firstQuan;
|
|
||||||
}
|
if($secondPerc >= 1.00) {
|
||||||
if($secondQuan >= 1.00) {
|
$secondPerc = $this->ConvertToPercentage($secondPerc);
|
||||||
$secondPerc = $this->ConvertToPercentage($secondQuan);
|
}
|
||||||
} else {
|
|
||||||
$secondPerc = $secondQuan;
|
if($thirdPerc >= 1.00) {
|
||||||
}
|
$thirdPerc = $this->ConvertToPercentage($thirdPerc);
|
||||||
if($thirdQuan >= 1.00) {
|
}
|
||||||
$thirdPerc = $this->ConvertToPercentage($thirdQuan);
|
|
||||||
} else {
|
if($fourthPerc >= 1.00) {
|
||||||
$thirdPerc = $thirdQuan;
|
$fourthPerc = $this->ConvertToPercentage($fourthPerc);
|
||||||
}
|
}
|
||||||
if($fourthQuan >= 1.00) {
|
|
||||||
$fourthPerc = $this->ConvertToPercentage($fourthQuan);
|
|
||||||
} else {
|
|
||||||
$fourthPerc = $fourthQuan;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Add up all the percentages
|
//Add up all the percentages
|
||||||
$totalPerc = $firstPerc + $secondPerc + $thirdPerc + $fourthPerc;
|
$totalPerc = $firstPerc + $secondPerc + $thirdPerc + $fourthPerc;
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ class AllowedLogin extends Model
|
|||||||
//Table Name
|
//Table Name
|
||||||
public $table = 'allowed_logins';
|
public $table = 'allowed_logins';
|
||||||
|
|
||||||
|
//Primary Key
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
//Timestamps
|
//Timestamps
|
||||||
public $timestamps = true;
|
public $timestamps = true;
|
||||||
|
|
||||||
|
|||||||
41
app/Models/AfterActionReports/AfterActionReport.php
Normal file
41
app/Models/AfterActionReports/AfterActionReport.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\AfterActionReports;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class AfterActionReport extends Model
|
||||||
|
{
|
||||||
|
//Table Name
|
||||||
|
public $table = 'fc_after_action_reports';
|
||||||
|
|
||||||
|
//Primary Key
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
|
//Timestamps
|
||||||
|
public $timestamps = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'fc_id',
|
||||||
|
'fc_name',
|
||||||
|
'formup_time',
|
||||||
|
'formup_location',
|
||||||
|
'comms',
|
||||||
|
'doctrine',
|
||||||
|
'objective',
|
||||||
|
'objective_result',
|
||||||
|
'summary',
|
||||||
|
'improvements',
|
||||||
|
'worked_well',
|
||||||
|
'additional_comments',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function comments() {
|
||||||
|
return $this->hasMany(App\Models\AfterActionReports\AfterActionReportComment::class, 'report_id', 'id');
|
||||||
|
}
|
||||||
|
}
|
||||||
33
app/Models/AfterActionReports/AfterActionReportComment.php
Normal file
33
app/Models/AfterActionReports/AfterActionReportComment.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\AfterActionReports;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class AfterActionReportComment extends Model
|
||||||
|
{
|
||||||
|
//Table Name
|
||||||
|
public $table = 'fc_aar_comments';
|
||||||
|
|
||||||
|
//Primary Key
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
|
//Timestamps
|
||||||
|
public $timestamps = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'report_id',
|
||||||
|
'character_id',
|
||||||
|
'character_name',
|
||||||
|
'comments',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function report() {
|
||||||
|
$this->belongsTo(App\Models\AfterActionReports\AfterActionReport::class, 'id', 'report_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,9 @@ class BlacklistEntity extends Model
|
|||||||
//Table Name
|
//Table Name
|
||||||
public $table = 'alliance_blacklist';
|
public $table = 'alliance_blacklist';
|
||||||
|
|
||||||
|
//Primary Key
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
//Timestamps
|
//Timestamps
|
||||||
public $timestamps = true;
|
public $timestamps = true;
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ class SupplyChainBid extends Model
|
|||||||
//Table Name
|
//Table Name
|
||||||
public $table = 'supply_chain_bids';
|
public $table = 'supply_chain_bids';
|
||||||
|
|
||||||
|
//Primary Key
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
// Timestamps
|
// Timestamps
|
||||||
public $timestamps = true;
|
public $timestamps = true;
|
||||||
|
|
||||||
@@ -29,11 +32,11 @@ class SupplyChainBid extends Model
|
|||||||
|
|
||||||
//Relationships
|
//Relationships
|
||||||
public function ContractId() {
|
public function ContractId() {
|
||||||
return $this->hasOne('App\Models\Contracts\SupplyChainContract', 'contract_id', 'contract_id');
|
return $this->belongsTo(App\Models\Contracts\SupplyChainContract::class, 'contract_id', 'contract_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Contract() {
|
public function Contract() {
|
||||||
return $this->belongsTo(SupplyChainContract::class);
|
return $this->belongsTo(App\Models\Contracts\SupplyChainContract::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Model functions
|
//Model functions
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ class SupplyChainContract extends Model
|
|||||||
//Table Name
|
//Table Name
|
||||||
public $table = 'supply_chain_contracts';
|
public $table = 'supply_chain_contracts';
|
||||||
|
|
||||||
|
//Primary Key
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
//Timestamps
|
//Timestamps
|
||||||
public $timestamps = true;
|
public $timestamps = true;
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ class EsiScope extends Model
|
|||||||
// Table Name
|
// Table Name
|
||||||
protected $table = 'EsiScopes';
|
protected $table = 'EsiScopes';
|
||||||
|
|
||||||
|
//Primary Key
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
// Timestamps
|
// Timestamps
|
||||||
public $timestamps = true;
|
public $timestamps = true;
|
||||||
|
|
||||||
@@ -23,6 +26,6 @@ class EsiScope extends Model
|
|||||||
];
|
];
|
||||||
|
|
||||||
public function user() {
|
public function user() {
|
||||||
return $this->belongsTo('App\Models\User\User', 'character_id', 'character_id');
|
return $this->belongsTo(App\Models\User\User::class, 'character_id', 'character_id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,11 @@ class EsiToken extends Model
|
|||||||
'expires_in',
|
'expires_in',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function user() {
|
||||||
|
return $this->belongsTo(App\Models\User\User::class, 'character_id', 'character_id');
|
||||||
|
}
|
||||||
|
|
||||||
public function esiscopes() {
|
public function esiscopes() {
|
||||||
return $this->hasMany('App\Models\EsiScope', 'character_id', 'character_id');
|
return $this->hasMany(App\Models\EsiScope::class, 'character_id', 'character_id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ class AllianceWalletJournal extends Model
|
|||||||
*/
|
*/
|
||||||
protected $table = 'alliance_wallet_journal';
|
protected $table = 'alliance_wallet_journal';
|
||||||
|
|
||||||
|
//Primary Key
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Timestamps
|
* Timestamps
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ class JobStatus extends Model
|
|||||||
//Table Name
|
//Table Name
|
||||||
public $table = 'job_statuses';
|
public $table = 'job_statuses';
|
||||||
|
|
||||||
|
//Primary Key
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
//Timestamps
|
//Timestamps
|
||||||
public $timestaps = true;
|
public $timestaps = true;
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ class AllianceLookup extends Model
|
|||||||
//Table Name
|
//Table Name
|
||||||
public $table = 'alliance_lookup';
|
public $table = 'alliance_lookup';
|
||||||
|
|
||||||
|
//Primary Key
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
//Timestamps
|
//Timestamps
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ class CharacterLookup extends Model
|
|||||||
//Table Name
|
//Table Name
|
||||||
public $table = 'character_lookup';
|
public $table = 'character_lookup';
|
||||||
|
|
||||||
|
//Primary Key
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
//Timestamps
|
//Timestamps
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ class CorporationLookup extends Model
|
|||||||
//Table Name
|
//Table Name
|
||||||
public $table = 'corporation_lookup';
|
public $table = 'corporation_lookup';
|
||||||
|
|
||||||
|
//Primary Key
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
//Timestamps
|
//Timestamps
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ class ItemLookup extends Model
|
|||||||
*/
|
*/
|
||||||
public $table = 'item_lookup';
|
public $table = 'item_lookup';
|
||||||
|
|
||||||
|
//Primary Key
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Timestamps
|
* Timestamps
|
||||||
*/
|
*/
|
||||||
|
|||||||
37
app/Models/Lookups/MoonLookup.php
Normal file
37
app/Models/Lookups/MoonLookup.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Lookups;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class MoonLookup extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Table Name
|
||||||
|
*/
|
||||||
|
public $table = 'moon_lookup';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary Key
|
||||||
|
*/
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timestamps
|
||||||
|
*/
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'moon_id',
|
||||||
|
'name',
|
||||||
|
'position_x',
|
||||||
|
'position_y',
|
||||||
|
'position_z',
|
||||||
|
'system_id',
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -9,6 +9,9 @@ class SolarSystem extends Model
|
|||||||
//Table Name
|
//Table Name
|
||||||
public $table = 'solar_systems';
|
public $table = 'solar_systems';
|
||||||
|
|
||||||
|
//Primary Key
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
//Timestamps
|
//Timestamps
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ class SentMail extends Model
|
|||||||
//Table Name
|
//Table Name
|
||||||
protected $table = 'sent_mails';
|
protected $table = 'sent_mails';
|
||||||
|
|
||||||
|
//Primary Key
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
//Timestamps
|
//Timestamps
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ class Invoice extends Model
|
|||||||
//Table Name
|
//Table Name
|
||||||
protected $table = 'alliance_mining_tax_invoices';
|
protected $table = 'alliance_mining_tax_invoices';
|
||||||
|
|
||||||
|
//Primary Key
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
//Timestamps
|
//Timestamps
|
||||||
public $timestamps = true;
|
public $timestamps = true;
|
||||||
|
|
||||||
@@ -25,10 +28,11 @@ class Invoice extends Model
|
|||||||
'date_issued',
|
'date_issued',
|
||||||
'date_due',
|
'date_due',
|
||||||
'status',
|
'status',
|
||||||
|
'mail_body',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getPayment() {
|
public function getPayment() {
|
||||||
return $this->hasMany('App\Models\MiningTax\Payment', 'invoice_id', 'invoice_id');
|
return $this->hasOne(App\Models\MiningTax\Payment::class, 'invoice_id', 'invoice_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCharacterId() {
|
public function getCharacterId() {
|
||||||
@@ -44,7 +48,7 @@ class Invoice extends Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getLedgers() {
|
public function getLedgers() {
|
||||||
return $this->hasMany('App\Models\MiningTax\Ledger', 'invoice_id', 'invoice_id');
|
return $this->hasMany(App\Models\MiningTax\Ledger::class, 'invoice_id', 'invoice_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvoiceAmount() {
|
public function getInvoiceAmount() {
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ class Ledger extends Model
|
|||||||
//Table Name
|
//Table Name
|
||||||
protected $table = 'alliance_mining_tax_ledgers';
|
protected $table = 'alliance_mining_tax_ledgers';
|
||||||
|
|
||||||
|
//Primary Key
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
//Timestamps
|
//Timestamps
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
@@ -31,7 +34,7 @@ class Ledger extends Model
|
|||||||
];
|
];
|
||||||
|
|
||||||
public function getInvoice() {
|
public function getInvoice() {
|
||||||
return $this->belongsTo('App\Models\MiningTax\Invoice', 'invoice_id', 'invoice_id');
|
return $this->belongsTo(App\Models\MiningTax\Invoice::class, 'invoice_id', 'invoice_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
34
app/Models/MiningTax/MiningOperation.php
Normal file
34
app/Models/MiningTax/MiningOperation.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\MiningTax;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class MiningOperation extends Model
|
||||||
|
{
|
||||||
|
//Table Name
|
||||||
|
protected $table = 'alliance_mining_tax_operations';
|
||||||
|
|
||||||
|
//Primary Key
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
|
//Timestamps
|
||||||
|
public $timestamps = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The array of variables which are mass assignable
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'structure_id',
|
||||||
|
'structure_name',
|
||||||
|
'authorized_by_id',
|
||||||
|
'authorized_by_name',
|
||||||
|
'operation_date',
|
||||||
|
'operation_name',
|
||||||
|
'processed',
|
||||||
|
'processed_on',
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -9,6 +9,9 @@ class Observer extends Model
|
|||||||
//Table Name
|
//Table Name
|
||||||
protected $table = 'alliance_mining_tax_observers';
|
protected $table = 'alliance_mining_tax_observers';
|
||||||
|
|
||||||
|
//Primary Key
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
//Timestamps
|
//Timestamps
|
||||||
public $timestamps = true;
|
public $timestamps = true;
|
||||||
|
|
||||||
@@ -21,11 +24,8 @@ class Observer extends Model
|
|||||||
'last_updated',
|
'last_updated',
|
||||||
'observer_id',
|
'observer_id',
|
||||||
'observer_type',
|
'observer_type',
|
||||||
];
|
'observer_name',
|
||||||
|
'solar_system_name',
|
||||||
public function getLedgers() {
|
'solar_system_id',
|
||||||
return $this->hasMany('App\Models\MiningTax\Ledger', 'observer_id', 'observer_id');
|
];
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ class Payment extends Model
|
|||||||
//Table Name
|
//Table Name
|
||||||
protected $table = 'alliance_mining_tax_payments';
|
protected $table = 'alliance_mining_tax_payments';
|
||||||
|
|
||||||
|
//Primary Key
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
//Timestamps
|
//Timestamps
|
||||||
public $timestamps = true;
|
public $timestamps = true;
|
||||||
|
|
||||||
@@ -28,6 +31,6 @@ class Payment extends Model
|
|||||||
];
|
];
|
||||||
|
|
||||||
public function getInvoice() {
|
public function getInvoice() {
|
||||||
return $this->belongsTo('App\Models\MiningTax\Invoice', 'invoice_id', 'invoice_id');
|
return $this->belongsTo(App\Models\MiningTax\Invoice::class, 'invoice_id', 'invoice_id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ class Config extends Model
|
|||||||
// Table Name
|
// Table Name
|
||||||
protected $table = 'Config';
|
protected $table = 'Config';
|
||||||
|
|
||||||
|
//Primary Key
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
// Timestamps
|
// Timestamps
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ class ItemComposition extends Model
|
|||||||
// Table Name
|
// Table Name
|
||||||
protected $table = 'ItemComposition';
|
protected $table = 'ItemComposition';
|
||||||
|
|
||||||
|
//Primary Key
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
// Timestamps
|
// Timestamps
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
}
|
}
|
||||||
|
|||||||
39
app/Models/MoonRental/AllianceMoon.php
Normal file
39
app/Models/MoonRental/AllianceMoon.php
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\MoonRental;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class AllianceMoon extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Table Name
|
||||||
|
*/
|
||||||
|
public $table = 'alliance_moons';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary Key
|
||||||
|
*/
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timestamps
|
||||||
|
*/
|
||||||
|
public $timestamps = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'moon_id',
|
||||||
|
'name',
|
||||||
|
'system_id',
|
||||||
|
'system_name',
|
||||||
|
'moon_type',
|
||||||
|
'worth_amount',
|
||||||
|
'rented',
|
||||||
|
'rental_amount',
|
||||||
|
];
|
||||||
|
}
|
||||||
38
app/Models/MoonRental/AllianceMoonOre.php
Normal file
38
app/Models/MoonRental/AllianceMoonOre.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\MoonRental;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class AllianceMoonOre extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Table Name
|
||||||
|
*/
|
||||||
|
public $table = 'alliance_moon_ores';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary Key
|
||||||
|
*/
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timestamps
|
||||||
|
*/
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'moon_id',
|
||||||
|
'moon_name',
|
||||||
|
'ore_type_id',
|
||||||
|
'ore_name',
|
||||||
|
'quantity',
|
||||||
|
'solar_system_id',
|
||||||
|
'planet_id',
|
||||||
|
];
|
||||||
|
}
|
||||||
40
app/Models/MoonRental/AllianceMoonRental.php
Normal file
40
app/Models/MoonRental/AllianceMoonRental.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\MoonRental;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class AllianceMoonRental extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Table Name
|
||||||
|
*/
|
||||||
|
public $table = 'alliance_moon_rentals';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary Key
|
||||||
|
*/
|
||||||
|
public $primaryKey = 'id';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timestamps
|
||||||
|
*/
|
||||||
|
public $timestamps = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'moon_id',
|
||||||
|
'moon_name',
|
||||||
|
'rental_amount',
|
||||||
|
'rental_start',
|
||||||
|
'rental_end',
|
||||||
|
'next_billing_date',
|
||||||
|
'entity_id',
|
||||||
|
'entity_name',
|
||||||
|
'entity_type',
|
||||||
|
];
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user