Compare commits
656 Commits
develop_te
...
38fb18899b
| Author | SHA1 | Date | |
|---|---|---|---|
| 38fb18899b | |||
| 9c1f2793c2 | |||
| 6a58f37a76 | |||
| b18517abf2 | |||
| 0f80219b71 | |||
| fed756efae | |||
| 54848b2864 | |||
| c839743f50 | |||
| 18c88570f0 | |||
| 14660c72be | |||
| 84dac71bd6 | |||
| f4a5b2ced8 | |||
| c7eece32d6 | |||
| d8f244caf0 | |||
| 8089ce8c6a | |||
| 612bb07bec | |||
| 8107d9961e | |||
| de2ec9ff87 | |||
| 742722544c | |||
| cbecd88a3a | |||
| f4fcfef729 | |||
| cee9802959 | |||
| 254aee03e8 | |||
| 1b0043743b | |||
| 46c07ac9e1 | |||
| 3d491faed5 | |||
| 51cb1ac2f4 | |||
| 4bcd069c85 | |||
| 66edc41718 | |||
| bf1b69b1cb | |||
| c2674ea33e | |||
| 15c8098b1f | |||
| 9ca9909e6f | |||
| fcca1cd794 | |||
| 4a5fc09ce4 | |||
| 1160d9f908 | |||
| 5f6c99538f | |||
| 8e4086b4ca | |||
| 765fafe218 | |||
| 14ea649634 | |||
| de6676895a | |||
| 2eeee057f8 | |||
| 466db48ac2 | |||
| e8894d95cf | |||
| aff3440e42 | |||
| fc368aeda4 | |||
| 841f19e551 | |||
| 8b12d46912 | |||
| a8725713aa | |||
| a6420812df | |||
| c26e96f3dd | |||
| 8b3d340456 | |||
| 9fbf23279b | |||
| 786295bc47 | |||
| 31181d74c7 | |||
| 7f82bb539e | |||
| 935ef9f998 | |||
| 5f5954da52 | |||
| d9eb6d01bf | |||
| 4a2fdadfdb | |||
| 7b990a5ecd | |||
| ac2c12c0c9 | |||
| f4da4ffae9 | |||
| 210a325688 | |||
| 3567e02642 | |||
| c7a70cb128 | |||
| 466d94fda4 | |||
| aedf9e1559 | |||
| fcff5c1da5 | |||
| 808a111853 | |||
| a38317a58c | |||
| 486f42bd5b | |||
| 02ce80b8ed | |||
| 1598df9824 | |||
| 2fc52ee53a | |||
| 67703d073f | |||
| ff65b56590 | |||
| f733aefd03 | |||
| 9dcec5fb27 | |||
| bda215d894 | |||
| f1570369bd | |||
| cf6ac7c0b1 | |||
| 853fb0b89e | |||
| fc60a58a9c | |||
| cbf3eaf788 | |||
| 7eeffdce65 | |||
| 07bf0d24f6 | |||
| b8b87401ce | |||
| a7964a0b43 | |||
| b4710619ff | |||
| 42e660d618 | |||
| 8b28b1c96e | |||
| 1212473b9e | |||
| 01cc7a87ed | |||
| f929f33867 | |||
| 232a447217 | |||
| eaddbdcd06 | |||
| 960eb2bb11 | |||
| 764cb6947b | |||
| 605cdb3197 | |||
| 8dda53e52e | |||
| b9bce3f2d6 | |||
| 7b11279d10 | |||
| 509a0cf78f | |||
| ec7f58b365 | |||
| 1325a5ad12 | |||
| 4974ea58b9 | |||
| 6af3558660 | |||
| 41f12df16c | |||
| f8fe14e11c | |||
| 5970783482 | |||
| f137d03073 | |||
| be987c25b5 | |||
| 68b0c3e102 | |||
| 5d05a35d89 | |||
| c15bd51d2a | |||
| 654f4b3281 | |||
| 83d2e9ff8d | |||
| 4c9393ed25 | |||
| e32a3fa46f | |||
| 71120548cb | |||
| 4d991bc6cd | |||
| 0b3159f22e | |||
| 67b2e8801a | |||
| 6252df348e | |||
| 41a2799e41 | |||
| d91252b4d0 | |||
| e2bce9f831 | |||
| 76bd5de916 | |||
| 10d86207ba | |||
| 62bd53e386 | |||
| 64db503c1f | |||
| d721c5290d | |||
| 4f6e40f4f6 | |||
| d2a7b6f4d8 | |||
| afbaafbb7c | |||
| b6297117a1 | |||
| b44227cebc | |||
| 84a2cdf67c | |||
| 0eb1d25bb3 | |||
| 743c4847ec | |||
| ebb8416d2a | |||
| fa0fd7c28b | |||
| 1b7ecc29d8 | |||
| d341107508 | |||
| 29db4c75e0 | |||
| c215815f28 | |||
| 580d204711 | |||
| fcb07c9a4a | |||
| c8f1496250 | |||
| 20c8a945bc | |||
| 222fbec635 | |||
| e2f25286c6 | |||
| 5bde9a9de4 | |||
| 3d9432e4f5 | |||
| dc4dc3001f | |||
| 5f0b1a0fcb | |||
| e41fa19f13 | |||
| 91ce0662df | |||
| 8f0f6110d0 | |||
| 7354fae9ac | |||
| 3af811cfcd | |||
| 29da1bad45 | |||
| 9d0daea74a | |||
| 344dc4f30a | |||
| 46f644aacf | |||
| d636d64fe7 | |||
| 10f7735af9 | |||
| 08df1b687a | |||
| 029c3b2fc2 | |||
| f304d233a6 | |||
| 44ae62e05b | |||
| d708741885 | |||
| 585451739f | |||
| 993298694b | |||
| 3597f8f864 | |||
| d4ce0399ad | |||
| 70be1e7603 | |||
| 23f452ab63 | |||
| cef5518fbf | |||
| d7d221bc83 | |||
| 6e1f401d46 | |||
| 339899ac61 | |||
| 5c065c0950 | |||
| 88a17988ae | |||
| 78635bae05 | |||
| 03728ff399 | |||
| f0519ac0f4 | |||
| 51e2bc876a | |||
| 7bed41e76a | |||
| 66790e84f7 | |||
| 0b9608d1d9 | |||
| 7e160790bc | |||
| 59c65a2aff | |||
| 41adc08f7f | |||
| 5ae27e5e79 | |||
| 1a066e41de | |||
| 4d904bc64d | |||
| 11e58e7430 | |||
| 70e6582bc4 | |||
| b0b22f2f57 | |||
| a1e676e6e3 | |||
| 53e83536e7 | |||
| 4b00b49b9c | |||
| 3928cad868 | |||
| feb2174855 | |||
| 95350e3f7d | |||
| 0866d9c4fd | |||
| c49cd9d9fd | |||
| 5c6ea83b47 | |||
| 3cfc391a5d | |||
| f37328f8bd | |||
| a3ebb5d3f2 | |||
| e6762b6b8b | |||
| 02f48dc0eb | |||
| ae697a540f | |||
| cb8b6798b9 | |||
| 973953aae6 | |||
| 6cf6d2a1ca | |||
| 9a7b6f56ac | |||
| 7d18d6102d | |||
| d95e799494 | |||
| e977d4b4f1 | |||
| 7ac9879702 | |||
| 252de5c9e2 | |||
| ac4c104490 | |||
| a888adae97 | |||
| 60a07ded50 | |||
| 8b2d081c7b | |||
| 1e78dc9718 | |||
| af921cc166 | |||
| d52db5ea5f | |||
| a9c9fdbd32 | |||
| 2d00d2992d | |||
| bb0aa72f8b | |||
| 3ee7f1cf7e | |||
| 8a2d171a28 | |||
| 4c58ff63b1 | |||
| 38f29ac7e9 | |||
| a75b3b173a | |||
| 07672be58b | |||
| 684771b746 | |||
| 57b89a7ed7 | |||
| 6527bf63a3 | |||
| d34b947a91 | |||
| 49e620d9aa | |||
| 556c42cc72 | |||
| b2d1106e0b | |||
| 540dff822d | |||
| 7a9b1ef9cf | |||
| f259bab4ed | |||
| 878f9f8ff7 | |||
| 8575a04639 | |||
| be9dee86dc | |||
| c93d05a1a3 | |||
| 75c4a27556 | |||
| d04e6d7303 | |||
| 8cc3cb3217 | |||
| 1276c4e8d5 | |||
| c5a622148f | |||
| 69e3570600 | |||
| a1010ff2c7 | |||
| e7b14d20f1 | |||
| 3a120b55cb | |||
| 761fc6e86f | |||
| f66f3a2247 | |||
| b570510602 | |||
| 373a8ecedd | |||
| 90b19f20b6 | |||
| 0e6afcaab9 | |||
| 30461d6986 | |||
| aaea1c429a | |||
| 7d327edd21 | |||
| b7ec1b1eda | |||
| 7e04e72070 | |||
| 43e69a2895 | |||
| 446076cc2e | |||
| 13cdbb56ee | |||
| d6ea318358 | |||
| 487f0277fd | |||
| 2046e61c1b | |||
| 34ea8ac762 | |||
| bad55084a1 | |||
| 405b632a8a | |||
| 59d646925f | |||
| 8922fa93f3 | |||
| e29f4bd4df | |||
| 08cd7af663 | |||
| 53964b5398 | |||
| 19bb1d742e | |||
| 29e35435a6 | |||
| b8b935c8b2 | |||
| 50a7226864 | |||
| 522c240771 | |||
| aa5ada0790 | |||
| 14107d60e4 | |||
| 48066e7b13 | |||
| fcad79edf1 | |||
| 91d19f413a | |||
| b0b6ef72a5 | |||
| 9bec4ef093 | |||
| 54abef6b56 | |||
| 7ad88c1e98 | |||
| c83216aa23 | |||
| 6f82b130c0 | |||
| f24de31a92 | |||
| b367d1a97d | |||
| 54bf441b6c | |||
| 2d392039ac | |||
| 4b379b7e53 | |||
| dd2c676ecc | |||
| 1d6b09e20e | |||
| abae40397c | |||
| 3a8ccf4c35 | |||
| 885d1a631a | |||
| 6b08d327ec | |||
| 097b719937 | |||
| 0ac1fc2b46 | |||
| 699d6d4245 | |||
| 767f51d1d6 | |||
| 06983dfe46 | |||
| 8bcee346ff | |||
| a588175a9e | |||
| 2d9edc4c78 | |||
| 2c45e0b38f | |||
| 824fc52717 | |||
| 5002913d70 | |||
| aa0615974b | |||
| 4765a738c0 | |||
| 1806a6a38a | |||
| 515955f65d | |||
| bea3dcd873 | |||
| 7eb9d49ede | |||
| 8f96b4cae3 | |||
| c083b0576f | |||
| 5822832ab3 | |||
| 1623277e26 | |||
| ffbf0c0f37 | |||
| 4d528e0e72 | |||
| a6ac190358 | |||
| 49728c6fcb | |||
| dc5eba281e | |||
| fd1a88cdf6 | |||
| c21d6ed238 | |||
| 401c3f8842 | |||
| 7f266b4b15 | |||
| 4eaa1efdbf | |||
| 2624aa6c56 | |||
| 74db686f47 | |||
| 6582f9ca96 | |||
| 4aa09e49a9 | |||
| 6c1cd57e6a | |||
| 094221ab2b | |||
| 8ef22d87a2 | |||
| a42ae7a94f | |||
| c2b49aad9f | |||
| 1903774cdf | |||
| ce2bf4c7ce | |||
| 8d995cb5b4 | |||
| 059703b1f4 | |||
| dc9d6671a4 | |||
| a4ee889127 | |||
| 9f8e25948a | |||
| 46821425a8 | |||
| 48625c4845 | |||
| 0447163694 | |||
| 323c800751 | |||
| f45b60c9d3 | |||
| aaa1837502 | |||
| 9a27bb7014 | |||
| 96ff53bbea | |||
| 29f7626fc8 | |||
| 0b687e6712 | |||
| b22c9af6a6 | |||
| bc0f052359 | |||
| 64d0812adb | |||
| a3109f6ab4 | |||
| 903496c893 | |||
| a198a31755 | |||
| 8b5a368b17 | |||
| 6c051fa8e7 | |||
| 98a94385a3 | |||
| a0b16e8f72 | |||
| ae1421c495 | |||
| 74759b5599 | |||
| d7838b772a | |||
| fa350cb505 | |||
| fe830e1a52 | |||
| 8b3c6e45ef | |||
| 36e8fec12f | |||
| 963df499b9 | |||
| 7d77ba7745 | |||
| f0bc7ec9ed | |||
| 377392b9dd | |||
| 1057fadb57 | |||
| 97e6c41725 | |||
| 90c4ec7346 | |||
| c22414b2fd | |||
| 9a95595dd8 | |||
| be15b70885 | |||
| 57a0c4f21d | |||
| 53e01f61ad | |||
| 5e37cddc82 | |||
| 446af258b9 | |||
| 35deebd0f8 | |||
| e753695146 | |||
| 4152f46504 | |||
| e293cacd44 | |||
| fbfc0975dd | |||
| d8a299e4a2 | |||
| 4d284c4328 | |||
| 413ff05221 | |||
| 334dca1b5d | |||
| 23bcf3f864 | |||
| a6bf88c22d | |||
| 737fb817d3 | |||
| 40879dd516 | |||
| 280d4be22b | |||
| dd3622adf0 | |||
| fc543ed9c1 | |||
| 26e4b4ac82 | |||
| 0660edfeeb | |||
| ffb073bf92 | |||
| 155a66d84c | |||
| c9b1d4c541 | |||
| 598dd3c471 | |||
| bd5cf6a0c5 | |||
| e4c73706bb | |||
| 8b9fd4d927 | |||
| 31c9d2a325 | |||
| 77c7e300f5 | |||
| 55e48b5e13 | |||
| 42785f219f | |||
| 5bc428b5f1 | |||
| 9c7dbe9b4d | |||
| 843b16f5cd | |||
| ce4e9ff0d7 | |||
| 46c4671920 | |||
| 8e59118d68 | |||
| 727132bef1 | |||
| 9066ea946f | |||
| d091589dac | |||
| bcafb4fae6 | |||
| c6ca1094bf | |||
| f509962c9b | |||
| ae8f35f54e | |||
| 7e6fdad0cf | |||
| e859b65659 | |||
| feb8dff689 | |||
| dae88e5ae6 | |||
| 3c8aa521ae | |||
| f7239cd9d4 | |||
| 9c9af7ce1f | |||
| 965718a18e | |||
| 716dcb810e | |||
| 8536183aad | |||
| 6e3b88c61c | |||
| bfbdcb8708 | |||
| b7f782db4a | |||
| d5c597db92 | |||
| f392b8c2ae | |||
| ae30b71aed | |||
| 9144f06859 | |||
| 74c496efbe | |||
| eddb1e2fc0 | |||
| 7e64fe73a9 | |||
| d81c2c977d | |||
| fcf5dcf94a | |||
| e1c45ea6cf | |||
| 5495e82905 | |||
| 805bbf9d00 | |||
| db01e57029 | |||
| f4c8c1ac9c | |||
| c04bcb7072 | |||
| 52893ee84f | |||
| a6a844ade0 | |||
| b3e63d74ac | |||
| 05aedf2231 | |||
| 971d11c27d | |||
| b79dc9236c | |||
| 24abbba56d | |||
| 89992325e5 | |||
| d4201cf3a6 | |||
| 94f6521907 | |||
| 16db1ccf1f | |||
| cd4e70b4d7 | |||
| ff52c3fee9 | |||
| d60e9cb0e0 | |||
| 3087e7aa6a | |||
| 92cf24a9dd | |||
| 7b428dc9ab | |||
| 14fc8ce0a3 | |||
| f8efd223ee | |||
| 227ad92a2f | |||
| 05915ae64a | |||
| b5834b4c33 | |||
| 136a819ccf | |||
| 2249223d31 | |||
| bf214611c3 | |||
| 174c9fd7b3 | |||
| 1291553ed9 | |||
| fff27c609b | |||
| c25ea4edc4 | |||
| fac55d0614 | |||
| 519ba46165 | |||
| 040f3312fa | |||
| 9612381897 | |||
| 2d2aaf3372 | |||
| 778e067540 | |||
| 13dfbd7e0c | |||
| 6f883cabdc | |||
| 9eebfd8268 | |||
| 1cedc4d547 | |||
| b7538b0340 | |||
| 5b467fca78 | |||
| 3cc5ee00b8 | |||
| da10e294ae | |||
| 1c17ec17ce | |||
| eeba316880 | |||
| 95768638ac | |||
| 99c95a92e1 | |||
| 40af6214b2 | |||
| 9095851f33 | |||
| ac4897f0ac | |||
| 38732a626a | |||
| 726d1c7c55 | |||
| f4edac6ef5 | |||
| fb9963d49f | |||
| 53d38e816c | |||
| f11fc0a099 | |||
| 12b6d1b866 | |||
| 8791579969 | |||
| d1f5dbf5e9 | |||
| d1d07197f1 | |||
| b46bef67df | |||
| 8ee7b255f3 | |||
| 38705cc76a | |||
| 5a76970fb4 | |||
| 33bc871529 | |||
| 71f24f26c8 | |||
| dd71e57903 | |||
| fef69f0640 | |||
| d96931c7e5 | |||
| 5ffe2fc3df | |||
| 132e9df303 | |||
| 581122b4d9 | |||
| 88682f65ce | |||
| de17f54160 | |||
| fcf19e80a4 | |||
| 41f10bc387 | |||
| 8221bfb85b | |||
| a701321417 | |||
| ff961f42ee | |||
| a3f6327739 | |||
| 0d758d8587 | |||
| 499f9407b6 | |||
| d1cdb23175 | |||
| cb6516bfea | |||
| ba78531cbe | |||
| b30efada95 | |||
| 203aeb3842 | |||
| c2765a0260 | |||
| c0a175092f | |||
| a6bc94af50 | |||
| 7373d66506 | |||
| 07ed282141 | |||
| 3972716675 | |||
| 0e80ab61a2 | |||
| 20071a4f40 | |||
| 3c5db83d4c | |||
| c1c79075d1 | |||
| 0aa351cd63 | |||
| 624a9478de | |||
| 2865e800e6 | |||
| 928f86011a | |||
| 4086c8282f | |||
| 005533fd27 | |||
| f5e8fad6bd | |||
| 5c6b6e028b | |||
| f1acf8db53 | |||
| 93b21b4ee0 | |||
| 891087cf7a | |||
| 618623432a | |||
| 165e0565b5 | |||
| 630e67693f | |||
| fce818807e | |||
| 4a254d9f28 | |||
| 52d41e9e36 | |||
| 34b74335c2 | |||
| 1119e366ee | |||
| 632527da5c | |||
| 78c06adaf8 | |||
| 8d6beb7884 | |||
| 68d1fe3cf6 | |||
| 93e7cb60e8 | |||
| 569bdbf4ce | |||
| f54a9b6728 | |||
| 686f24e090 | |||
| 09147525a0 | |||
| 149546ee8e | |||
| 1535a5cc33 | |||
| d5703bd99a | |||
| b1ff156a6c | |||
| df06595007 | |||
| 2a7179abe5 | |||
| 4be7ddc1c2 | |||
| c438fb049e | |||
| 70d5e2fc80 | |||
| 3824fae695 | |||
| 55161e242e | |||
| fbcc2a0483 | |||
| befc1bf41e | |||
| 55abd48d30 | |||
| 7a6695c7ed | |||
| 239815839a | |||
| a385776538 | |||
| 96822cf248 | |||
| 35a90fef3b | |||
| 67ae480665 | |||
| 5420a24800 | |||
| 002f20af78 | |||
| 30ad1e720d | |||
| 999a5603be | |||
| ffa9cc98ed | |||
| f81b84cf39 | |||
| c366cc34b0 | |||
| 98be6cc43e | |||
| 9dba7647c5 | |||
| 7f55f1997a | |||
| 88ebe674de | |||
| cedc621e95 | |||
| 4187931abd | |||
| a8b3d30ac6 | |||
| f439929e6d | |||
| b68db7b6c5 | |||
| ffd2769bad | |||
| 150aa8f5c7 | |||
| b3e52f9c3d | |||
| 07c71c04ba | |||
| 358dd0f2b7 | |||
| a1324cf390 | |||
| c0509263d4 | |||
| 33e9b3612a | |||
| 0fe00cf140 | |||
| 0d2bdb5f18 | |||
| 9e3ef5090a | |||
| 7a8a6ed462 | |||
| 3cd1ab90d6 | |||
| fd2809c1a8 | |||
| b47dc76429 | |||
| 0dcc0bfa80 | |||
| 4cdbc6a7cc | |||
| 7b827874e0 | |||
| 8538410fec | |||
| def606d3a0 | |||
| 2f5457107c |
@@ -60,7 +60,7 @@ class Auth extends \fast\Auth
|
||||
}
|
||||
$admin->loginfailure = 0;
|
||||
$admin->logintime = time();
|
||||
$admin->loginip = request()->ip();
|
||||
$admin->loginip = request()->server('HTTP_X_REAL_IP') ?: request()->server('HTTP_X_FORWARDED_FOR') ?: request()->ip();
|
||||
$admin->token = Random::uuid();
|
||||
$admin->save();
|
||||
Session::set("admin", $admin->toArray());
|
||||
@@ -229,6 +229,7 @@ class Auth extends \fast\Auth
|
||||
if ($this->logined) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$admin = Session::get('admin');
|
||||
if (!$admin) {
|
||||
$admin = Cache::get("admin_" . $token);
|
||||
@@ -239,6 +240,7 @@ class Auth extends \fast\Auth
|
||||
// Session::set("admin.safecode", $this->getEncryptSafecode($admin));
|
||||
}
|
||||
}
|
||||
|
||||
if (!$admin) {
|
||||
return false;
|
||||
}
|
||||
@@ -246,6 +248,7 @@ class Auth extends \fast\Auth
|
||||
if (!$my) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//校验安全码,可用于判断关键信息发生了变更需要重新登录
|
||||
// if (!isset($admin['safecode']) || $this->getEncryptSafecode($my) !== $admin['safecode']) {
|
||||
// $this->logout();
|
||||
@@ -259,12 +262,13 @@ class Auth extends \fast\Auth
|
||||
}
|
||||
}
|
||||
//判断管理员IP是否变动
|
||||
if (Config::get('fastadmin.loginip_check')) {
|
||||
if (!isset($admin['loginip']) || $admin['loginip'] != request()->ip()) {
|
||||
$this->logout();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// if (Config::get('fastadmin.loginip_check')) {
|
||||
// if (!isset($admin['loginip']) || $admin['loginip'] != request()->ip()) {
|
||||
// $this->logout();
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
$this->logined = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ class AdminLog extends Model
|
||||
}
|
||||
$title = implode(' / ', $title);
|
||||
}
|
||||
$login_ip = request()->server('HTTP_X_REAL_IP') ?: request()->server('HTTP_X_FORWARDED_FOR') ?: request()->ip();
|
||||
self::create([
|
||||
'title' => $title,
|
||||
'content' => !is_scalar($content) ? json_encode($content, JSON_UNESCAPED_UNICODE) : $content,
|
||||
@@ -84,7 +85,7 @@ class AdminLog extends Model
|
||||
'admin_id' => $admin_id,
|
||||
'username' => $username,
|
||||
'useragent' => substr(request()->server('HTTP_USER_AGENT'), 0, 255),
|
||||
'ip' => xss_clean(strip_tags(request()->ip()))
|
||||
'ip' => $login_ip//xss_clean(strip_tags(request()->ip()))
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -675,23 +675,45 @@ class Activities extends adminApi
|
||||
$page_limit = input('page_limit', 30);
|
||||
$user_id = input('user_id', '');
|
||||
$gift_bag_id = input('gift_bag_id', 1);
|
||||
$begin_time = input('begin_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$where = [];
|
||||
if($user_id){
|
||||
$where['user_id'] = $user_id;
|
||||
$where['a.user_id'] = $user_id;
|
||||
}
|
||||
if($gift_bag_id){
|
||||
$where['gift_bag_id'] = $gift_bag_id;
|
||||
$where['a.gift_bag_id'] = $gift_bag_id;
|
||||
}else{
|
||||
$where['a.gift_bag_id'] = ['in', [1,2]];
|
||||
}
|
||||
$count = db::name('vs_gift_bag_receive_log')->where($where)->count();
|
||||
$lists_data = db::name('vs_gift_bag_receive_log')->where($where)->page($page, $page_limit)->order("id desc")->select();
|
||||
if($begin_time){
|
||||
$where['a.createtime'] = ['>=', strtotime($begin_time)];
|
||||
}
|
||||
if($end_time){
|
||||
$where['a.createtime'] = ['<=', strtotime($end_time)];
|
||||
}
|
||||
if($begin_time && $end_time){
|
||||
$where['a.createtime'] = ['between', [strtotime($begin_time), strtotime($end_time)]];
|
||||
}
|
||||
$count = db::name('vs_gift_bag_receive_log')->alias('a')->where($where)->count();
|
||||
$lists_data = db::name('vs_gift_bag_receive_log')
|
||||
->alias('a')
|
||||
->join('vs_gift_bag_detail b', 'a.parent_id=b.id')
|
||||
->join('vs_gift c', 'a.gift_id=c.gid')
|
||||
->field('a.*,b.name,b.type,b.quantity,b.foreign_id,c.gift_price,b.name')
|
||||
->where($where)->page($page, $page_limit)->order("id desc")->select();
|
||||
$lists = [];
|
||||
foreach ($lists_data as $key => $value) {
|
||||
$gift_bag = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->find();
|
||||
$user = db::name('user')->where('id',$value['user_id'])->find();
|
||||
$lists[$key]['id'] = $value['id'];
|
||||
$lists[$key]['user_id'] = $value['user_id'];
|
||||
$lists[$key]['user_name'] = $value['user_id'].'-'.db::name('user')->where('id',$value['user_id'])->value('nickname');
|
||||
$lists[$key]['user_name'] = $user['user_code'].'-'.$user['nickname'];
|
||||
$lists[$key]['gift_bag_type'] = db::name('vs_gift_bag')->where('id',$value['gift_bag_id'])->value('name');
|
||||
$lists[$key]['money'] = $gift_bag['money'];
|
||||
//礼物
|
||||
$lists[$key]['gift'] = $value['name']."*".$value['quantity'];
|
||||
$lists[$key]['gift_price'] = $value['gift_price'] * $value['quantity'];
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
||||
}
|
||||
$return_data = [
|
||||
|
||||
@@ -372,6 +372,8 @@ class BlindBox extends adminApi
|
||||
}
|
||||
$gift_id = input('gift_id', '');
|
||||
$description = input('description', '');
|
||||
$status = input('status', 1);
|
||||
|
||||
$introd =$_POST['introd']??"";
|
||||
if(empty($gift_id)){
|
||||
return V(0,"请配置礼物");
|
||||
@@ -386,7 +388,10 @@ class BlindBox extends adminApi
|
||||
'introd' => $introd,
|
||||
];
|
||||
$ext = json_encode($ext);
|
||||
$res = db::name('vs_gift_bag')->where(['id'=>$gift_bag_id])->update(['ext'=>$ext]);
|
||||
$res = db::name('vs_gift_bag')->where(['id'=>$gift_bag_id])->update([
|
||||
'ext'=>$ext,
|
||||
'status' => $status,
|
||||
]);
|
||||
if($res){
|
||||
return V(1,"成功");
|
||||
}else{
|
||||
@@ -406,6 +411,7 @@ class BlindBox extends adminApi
|
||||
'gift_id' => $ext_data['gift_id'],
|
||||
'description' => $ext_data['description'],
|
||||
'introd' => stripcslashes($ext_data['introd']),
|
||||
'status' => $gift_bag['status'],
|
||||
];
|
||||
if($gift_bag){
|
||||
return V(1,"成功",$ext);
|
||||
@@ -531,7 +537,7 @@ class BlindBox extends adminApi
|
||||
if($activities_id == ""){
|
||||
$activities_id = 4;
|
||||
}
|
||||
$bag_list = db::name("vs_gift_bag")->field('id,name')->where(['activities_id'=>$activities_id,'status'=>1])->select();
|
||||
$bag_list = db::name("vs_gift_bag")->field('id,name')->where(['activities_id'=>$activities_id])->select();
|
||||
return V(1,"成功", $bag_list);
|
||||
}
|
||||
//--------------------------盲盒转盘与巡乐会-------------------------------------------------------
|
||||
@@ -732,11 +738,11 @@ class BlindBox extends adminApi
|
||||
$room_id = input('room_id', '');
|
||||
$gift_bag_id = input('gift_bag_id', '');
|
||||
$periods = input('periods', '');
|
||||
$stime = input('stime', '');
|
||||
$etime = input('etime', '');
|
||||
$stime = input('stime', date('Y-m-d'));
|
||||
$etime = input('etime', date('Y-m-d h:i:s', time()));
|
||||
$where = [];
|
||||
if($room_id){
|
||||
$where['room_id'] = $room_id;
|
||||
$where['room_number'] = $room_id;
|
||||
}
|
||||
if($gift_id){
|
||||
$where['gift_id'] = $gift_id;
|
||||
|
||||
@@ -62,7 +62,7 @@ class Decorate extends adminApi
|
||||
$return_list[$k]['admin_name'] = db::name('admin')->where(['id'=>$v['admin_id']])->value('nickname')??"--";
|
||||
$return_list[$k]['ext_value'] = $v['ext_value'] ?? 0;
|
||||
$return_list[$k]['price'] = $v['price'] ?? 0;
|
||||
|
||||
$return_list[$k]['special_num'] = $v['special_num'] ?? '';
|
||||
|
||||
}
|
||||
$return_data = [
|
||||
@@ -97,6 +97,11 @@ class Decorate extends adminApi
|
||||
if($type==""){
|
||||
return V(0,"参数错");
|
||||
}
|
||||
if(in_array($type, [6,7,8])){
|
||||
if($special_num==""){
|
||||
return V(0,"请填写靓号");
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'title' => $title,
|
||||
@@ -152,6 +157,11 @@ class Decorate extends adminApi
|
||||
$special_num = input('special_num', '');
|
||||
$ext_value = input('ext_value', '');
|
||||
$price = input('price', '');
|
||||
if(in_array($type, [6,7,8])){
|
||||
if($special_num==""){
|
||||
return V(0,"请填写靓号");
|
||||
}
|
||||
}
|
||||
$data = [];
|
||||
if($title!=""){
|
||||
$data['title'] = $title;
|
||||
@@ -276,7 +286,15 @@ class Decorate extends adminApi
|
||||
return V(0,"该价格已存在");
|
||||
}
|
||||
//计算折扣取整
|
||||
$discount = round($price/$original_price, 2)*10;
|
||||
if($price==0 || $original_price==0){
|
||||
$discount = 0;
|
||||
}else{
|
||||
$discount = round($price/$original_price, 2)*10;
|
||||
if($discount >= 10){
|
||||
$discount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'did' => $did,
|
||||
'day' => $day,
|
||||
@@ -365,6 +383,9 @@ class Decorate extends adminApi
|
||||
}else{
|
||||
$return_list[$k]['name'] = db::name('vs_decorate')->where(['did'=>$v['did']])->value('title');
|
||||
}
|
||||
if(in_array($v['type'],[12,13])){
|
||||
$return_list[$k]['name'] = $return_list[$k]['name'] ." * ".$v['num']." 张";
|
||||
}
|
||||
$return_list[$k]['base_image'] = db::name('vs_decorate')->where(['did'=>$v['did']])->value('base_image');
|
||||
$return_list[$k]['is_using'] = $v['is_using'];
|
||||
$return_list[$k]['is_using_str'] = $v['is_using']==1?"使用中":"未使用";
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
namespace app\adminapi\controller;
|
||||
ini_set('memory_limit', '512M'); // 临时增加到512MB
|
||||
use app\common\controller\adminApi;
|
||||
use app\common\library\GiftTableManager;
|
||||
use think\Db;
|
||||
use think\Log;
|
||||
|
||||
class GiveGift extends adminApi
|
||||
{
|
||||
@@ -27,10 +29,16 @@ class GiveGift extends adminApi
|
||||
$from_id = input('from_id', '');//礼物来源id
|
||||
$gift_id = input('gift_id', '');//礼物id
|
||||
$from = input('from', '');// 来源类型,1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏 5系统任务 6-cp房间送礼
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
|
||||
$where=[];
|
||||
//获取当前月份的开始时间和结束时间
|
||||
$firstDay = date('Y-m-01');
|
||||
$lastDay = date('Y-m-t 23:59:59');
|
||||
$start_time = input('start_time', $firstDay);
|
||||
$end_time = input('end_time', $lastDay);
|
||||
$start_time = empty($start_time) ? $firstDay : $start_time;
|
||||
$end_time = empty($end_time) ? $lastDay : $end_time;
|
||||
$search_time = [];
|
||||
$search_time = [strtotime($start_time), strtotime($end_time)];
|
||||
$where = [];
|
||||
$gwhere = [];
|
||||
if($send_user != ''){
|
||||
$user_id = db::name('user')->where('user_code', $send_user)->value('id');
|
||||
@@ -73,25 +81,40 @@ class GiveGift extends adminApi
|
||||
$gwhere['gg.createtime'] = ['<=', strtotime($end_time)];
|
||||
}
|
||||
}
|
||||
$page_array = [];
|
||||
$page_array = [
|
||||
'page' => !empty($page)?$page:1,
|
||||
'page_limit' => !empty($page_limit)?$page_limit:10,
|
||||
];
|
||||
$gift_list = model('Gift')->getGiftRecords($search_time,$where,$page_array);
|
||||
//礼物总数
|
||||
$gift_num = db::name('vs_give_gift')->where($where)->sum('number');
|
||||
$gift_num = $gift_list['number'];
|
||||
//总金额
|
||||
$total_price = db::name('vs_give_gift')->where($where)->sum('total_price');
|
||||
$total_price = $gift_list['total_price'];
|
||||
//平台收益
|
||||
$app_earning = 0;
|
||||
//接收人收益
|
||||
$receive_earning = 0;
|
||||
//房主收益
|
||||
$room_owner_earning = 0;
|
||||
|
||||
// 获取所有送礼记录
|
||||
$lists = db::name('vs_give_gift')->where($where)->order('id', 'desc')->page($page, $page_limit)->select();
|
||||
$count = db::name('vs_give_gift')->where($where)->count();
|
||||
$lists = $gift_list['lists'];
|
||||
$count = $gift_list['count'];
|
||||
// $lists = db::name('vs_give_gift')->where($where)->order('id', 'desc')->page($page, $page_limit)->select();
|
||||
// $count = db::name('vs_give_gift')->where($where)->count();
|
||||
$earning_list = [];
|
||||
if(!empty($where)){
|
||||
$tables = GiftTableManager::getTablesByTimeRange(
|
||||
strtotime($start_time),
|
||||
strtotime($end_time)
|
||||
);
|
||||
if(empty($tables)){
|
||||
$tables[0] = "fa_vs_give_gift";
|
||||
}
|
||||
$table_name = substr($tables[0], 3);//截取可查询的表名
|
||||
$earning_list = db::name('vs_give_gift_ratio_log')
|
||||
->alias('egl')
|
||||
->join('vs_give_gift gg', 'egl.give_gift_id = gg.id')
|
||||
->join($table_name.' gg', 'egl.give_gift_id = gg.id')
|
||||
->where($gwhere) // 替换为实际的筛选条件
|
||||
->field('egl.app_earning,egl.gift_user_earning,egl.room_owner_earning')
|
||||
->select();
|
||||
@@ -114,10 +137,11 @@ class GiveGift extends adminApi
|
||||
array_column($lists, 'user_id'),
|
||||
array_column($lists, 'gift_user')
|
||||
);
|
||||
$room_ids = array_filter(array_merge(
|
||||
array_column($lists, 'room_id'),
|
||||
array_column($lists, 'from_id')
|
||||
));
|
||||
// $room_ids = array_filter(array_merge(
|
||||
// array_column($lists, 'room_id'),
|
||||
// array_column($lists, 'from_id')
|
||||
// ));
|
||||
$room_ids = array_column($lists, 'from_id');
|
||||
$gift_ids_list = array_column($lists, 'gift_id');
|
||||
|
||||
// 批量获取用户信息
|
||||
@@ -149,7 +173,7 @@ class GiveGift extends adminApi
|
||||
if (!empty($gift_ids_list)) {
|
||||
$gift_list = db::name('vs_gift')
|
||||
->where('gid', 'in', array_unique($gift_ids_list))
|
||||
->field('gid,gift_name,gift_price')
|
||||
->field('gid,gift_name,gift_price,type,label')
|
||||
->select();
|
||||
foreach ($gift_list as $gift) {
|
||||
$gifts[$gift['gid']] = $gift;
|
||||
@@ -182,8 +206,11 @@ class GiveGift extends adminApi
|
||||
// 礼物信息
|
||||
$gift_info = isset($gifts[$value['gift_id']]) ? $gifts[$value['gift_id']] : null;
|
||||
$value['gift_name'] = $gift_info ? $gift_info['gift_name'].'-'.$value['gift_id'] : '';
|
||||
$value['gift_price'] = $gift_info ? $gift_info['gift_price'] : 0;
|
||||
|
||||
if($gift_info && $gift_info['label']==2){
|
||||
$value['gift_price'] ="未知(盲盒)";
|
||||
}else{
|
||||
$value['gift_price'] = $gift_info ? $gift_info['gift_price'] : 0;
|
||||
}
|
||||
// 房间信息处理
|
||||
if($value['from'] == 1){
|
||||
$value['room'] = '聊天送礼';
|
||||
@@ -231,4 +258,5 @@ class GiveGift extends adminApi
|
||||
$start = ($page - 1) * $limit;
|
||||
return array_slice($array, $start, $limit);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\common\controller\adminApi;
|
||||
use app\common\library\GiftTableManager;
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
use think\Session;
|
||||
@@ -89,6 +90,7 @@ class Guild extends adminApi
|
||||
$list[$k]['status_str'] = $v['status'] == 1 ? '正常' : '解散';
|
||||
$list[$k]['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
|
||||
$list[$k]['updatetime'] = date('Y-m-d H:i:s',$v['updatetime']);
|
||||
$list[$k]['delete_time'] = $v['delete_time'] ? date('Y-m-d H:i:s',$v['delete_time']) : "无";
|
||||
$list[$k]['user_id'] = $user['user_code']??"";
|
||||
$list[$k]['intro'] = $v['intro'];
|
||||
//幸运币流水
|
||||
@@ -446,9 +448,9 @@ class Guild extends adminApi
|
||||
$rum_lists[$k]['charm_level']=$user_info['charm_level']??0;
|
||||
$rum_lists[$k]['wealth_level']=$user_info['wealth_level']??0;
|
||||
//用户流水
|
||||
$consumption_sql = db::name('vs_user_money_log')
|
||||
$consumption_sql = db::name('user_coin_log')
|
||||
->whereIn('change_type',$coin_consumption_type_array)
|
||||
->where(['money_type'=>1,'user_id' => $v['user_id']]);
|
||||
->where(['user_id' => $v['user_id']]);
|
||||
if($v['quit_type'] == 3){
|
||||
$consumption_sql->where(['createtime'=>['<=',$v['delete_time']]]);
|
||||
$consumption_sql->where(['createtime'=>['>=',$v['createtime']]]);
|
||||
@@ -479,8 +481,16 @@ class Guild extends adminApi
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$guild_id = input('guild_id', 0);
|
||||
$search_stime_str = input('search_stime','');
|
||||
$search_etime_str = input('search_etime','');
|
||||
$firstDay = date('Y-m-01');
|
||||
$lastDay = date('Y-m-t 23:59:59');
|
||||
$search_stime_str = input('search_stime',$firstDay);
|
||||
$search_etime_str = input('search_etime',$lastDay);
|
||||
if(empty($search_stime_str)){
|
||||
$search_stime_str = $firstDay;
|
||||
}
|
||||
if(empty($search_etime_str)){
|
||||
$search_etime_str = $lastDay;
|
||||
}
|
||||
$room_id = input('room_id', 0);
|
||||
$where=['a.status'=>1];
|
||||
$where=['a.room_id'=>['>',0]];
|
||||
@@ -498,6 +508,7 @@ class Guild extends adminApi
|
||||
->join('vs_room b', 'a.room_id = b.id', 'left')
|
||||
->where(['a.guild_id'=>$guild_id])->where($where)->count();
|
||||
$list = db::name($this->table_guild_user)->alias('a')
|
||||
->field('a.*,b.room_name,b.room_number')
|
||||
->join('vs_room b', 'a.room_id = b.id', 'left')
|
||||
->where(['a.guild_id'=>$guild_id])->where($where)
|
||||
// ->page($page, $page_limit)
|
||||
@@ -507,6 +518,49 @@ class Guild extends adminApi
|
||||
}
|
||||
$rum_lists = [];
|
||||
//总流水
|
||||
$tables = GiftTableManager::getTablesByTimeRange(
|
||||
strtotime($search_stime_str),
|
||||
strtotime($search_etime_str)
|
||||
);
|
||||
|
||||
$room_consumption =[];
|
||||
if($tables){
|
||||
foreach ($list as $vs) {
|
||||
$search_stime = $search_stime_str;
|
||||
$search_etime = $search_etime_str;
|
||||
if($search_stime!=""){
|
||||
if($vs['apply_time'] && strtotime($search_stime) < $vs['apply_time']) {
|
||||
$search_stime = date('Y-m-d H:i:s',$vs['apply_time']);
|
||||
}
|
||||
}else{
|
||||
$search_stime = date('Y-m-d H:i:s',$vs['apply_time']);
|
||||
}
|
||||
if($search_etime!=""){
|
||||
if($vs['quit_time'] && (strtotime($search_etime) > $vs['quit_time'])){
|
||||
$search_etime = date('Y-m-d H:i:s',$vs['quit_time']);
|
||||
}
|
||||
}else{
|
||||
if($vs['quit_time']){
|
||||
$search_etime = date('Y-m-d H:i:s',$vs['quit_time']);
|
||||
}else{
|
||||
$search_etime = date('Y-m-d H:i:s',time());
|
||||
}
|
||||
}
|
||||
$all_total_price =0;
|
||||
$total_price = 0;
|
||||
foreach ($tables as $table_name) {
|
||||
//表前缀
|
||||
$table_prefix = config('database.prefix');
|
||||
$table_name = str_replace($table_prefix, '', $table_name);
|
||||
$total_price = db::name($table_name)
|
||||
->where(['from_id' => $vs['room_id'], 'from' => 2])
|
||||
->where(['createtime' => ['between',[strtotime($search_stime),strtotime($search_etime)]]])
|
||||
->sum('total_price');
|
||||
$all_total_price += $total_price;
|
||||
$room_consumption[$vs['id']] = $all_total_price;
|
||||
}
|
||||
}
|
||||
}
|
||||
$total_consumption = 0;
|
||||
foreach ($list as $k=>$v){
|
||||
$search_stime = $search_stime_str;
|
||||
@@ -539,8 +593,9 @@ class Guild extends adminApi
|
||||
$rum_lists[$k]['room_name']=$room_info['room_name']?? '';
|
||||
$rum_lists[$k]['room_cover']=$room_info['room_cover']?? '';
|
||||
//房间流水
|
||||
$rum_lists[$k]['consumption']= model('Room')->getRoomFlow($v['room_id'],$search_stime,$search_etime);
|
||||
$rum_lists[$k]['add_time'] = date('Y-m-d H:i:s',$v['createtime']);
|
||||
// $rum_lists[$k]['consumption']= model('Room')->getRoomFlow($v['room_id'],$search_stime,$search_etime);
|
||||
$rum_lists[$k]['consumption']= $room_consumption[$v['id']]??0;
|
||||
$rum_lists[$k]['add_time'] = date('Y-m-d H:i:s',$v['apply_time']);
|
||||
$total_consumption += $rum_lists[$k]['consumption'];
|
||||
//幸运币统计
|
||||
$where_lucky = [];
|
||||
@@ -606,45 +661,50 @@ class Guild extends adminApi
|
||||
$guild_id = input('guild_id', '');
|
||||
$merge_guild_id = input('merge_guild_id', '');
|
||||
//解散工会
|
||||
$guild = model('Guild')->getOne(['id'=>$guild_id]);
|
||||
$guild = model('Guild')->getOne(['guild_special_id'=>$guild_id]);
|
||||
$merge_guild=model('Guild')->getOne(['guild_special_id'=>$merge_guild_id]);
|
||||
if(empty($guild)){
|
||||
return V(0,"该工会不存在");
|
||||
}
|
||||
if($guild['status'] == 2){
|
||||
return V(0,"该工会已解散");
|
||||
}
|
||||
if(!$merge_guild_id){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
if(empty($merge_guild)){
|
||||
return V(0,"并入工会不存在");
|
||||
}
|
||||
$guild_id = $guild['id'];
|
||||
$merge_guild_id = $merge_guild['id'];
|
||||
db::startTrans();
|
||||
try{
|
||||
$res = model('Guild')->edit(['id'=>$guild_id],['status'=>2,'delete_time'=>time()]);
|
||||
//并入工会
|
||||
if(!$merge_guild_id){
|
||||
db::rollback();
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$merge_guild = model('Guild')->getOne(['id'=>$merge_guild_id]);
|
||||
if(empty($merge_guild)){
|
||||
db::rollback();
|
||||
return V(0,"并入工会不存在");
|
||||
}
|
||||
$merge_guild_user = db('vs_guild_user')->where(['guild_id'=>$merge_guild_id,'quit_type'=>0])->select();
|
||||
$merge_guild_user = db('vs_guild_user')->where(['guild_id'=>$guild_id,'quit_type'=>0,'status'=>1])->select();
|
||||
foreach ($merge_guild_user as $key=>$value){
|
||||
$res = db('vs_guild_user')->insert([
|
||||
'user_id'=>$value['user_id'],
|
||||
'guild_id'=>$merge_guild_id,
|
||||
'room_id'=>$value['room_id'],
|
||||
'coin'=>$value['coin'],
|
||||
'status'=>$value['status'],
|
||||
'is_deacon'=>$value['is_deacon'],
|
||||
'is_show_room'=>$value['is_show_room'],
|
||||
'remarks'=>$value['remarks'],
|
||||
'apply_time'=>$value['apply_time'],
|
||||
'remarks'=>"公会合并:从".$guild['guild_name']."合入".$merge_guild['guild_name'],
|
||||
'settlement_ratio' =>$value['settlement_ratio'],
|
||||
'apply_time'=>time(),
|
||||
'createtime'=>time(),
|
||||
]);
|
||||
if(!$res){
|
||||
db::rollback();
|
||||
return V(0,"失败");
|
||||
}
|
||||
//更新公会人数
|
||||
db('vs_guild')->where('id', $merge_guild_id)->setInc('num');
|
||||
//拉用户进入工会群聊
|
||||
if($merge_guild_id<=95){
|
||||
$merge_guild_id = "g".$merge_guild_id;
|
||||
}else{
|
||||
$merge_guild_id = $merge_guild_id;
|
||||
}
|
||||
$rid = 'g'.$merge_guild_id;
|
||||
$reslut = model('api/Tencent')->add_group_member($rid, $value['user_id']);
|
||||
}
|
||||
@@ -654,7 +714,12 @@ class Guild extends adminApi
|
||||
return V(0,"失败");
|
||||
}
|
||||
//解散群
|
||||
model('Tencent')->delete_group('g'.$guild_id);
|
||||
if($guild_id<=95){
|
||||
$guild_id = "g".$guild_id;
|
||||
}else{
|
||||
$guild_id = $guild_id;
|
||||
}
|
||||
model('api/Tencent')->delete_group('g'.$guild_id);
|
||||
db::commit();
|
||||
return V(1,"成功");
|
||||
} catch(\Exception $e) {
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use app\common\library\GiftTableManager;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
@@ -162,11 +163,19 @@ class Index extends adminApi
|
||||
$day_time_end = strtotime(date('Y-m-') . $i . ' 23:59:59');
|
||||
$gift_money[$i]['time'] = date('Y-m-') . $i;
|
||||
//总礼物打赏值
|
||||
$gift_money[$i]['gift_total_day'] = Db::name('vs_give_gift')->where('createtime', 'between', [$day_time, $day_time_end])->sum('total_price');
|
||||
$tables = GiftTableManager::getTablesByTimeRange(
|
||||
$day_time,
|
||||
$day_time_end
|
||||
);
|
||||
$table_name = $tables[0];
|
||||
//表前缀
|
||||
$table_prefix = config('database.prefix');
|
||||
$table_name = str_replace($table_prefix, '', $table_name);
|
||||
$gift_money[$i]['gift_total_day'] = Db::name($table_name)->where('createtime', 'between', [$day_time, $day_time_end])->sum('total_price');
|
||||
//购买礼物打赏价值
|
||||
$gift_money[$i]['gift_buy_day'] = Db::name('vs_give_gift')->where('type',1)->where('createtime', 'between', [$day_time, $day_time_end])->sum('total_price');
|
||||
$gift_money[$i]['gift_buy_day'] = Db::name($table_name)->where('type',1)->where('createtime', 'between', [$day_time, $day_time_end])->sum('total_price');
|
||||
//背包礼物打赏价值
|
||||
$gift_money[$i]['gift_backpack_day'] = Db::name('vs_give_gift')->where('type',2)->where('createtime', 'between', [$day_time, $day_time_end])->sum('total_price');
|
||||
$gift_money[$i]['gift_backpack_day'] = Db::name($table_name)->where('type',2)->where('createtime', 'between', [$day_time, $day_time_end])->sum('total_price');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Cache;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
@@ -16,18 +17,20 @@ use think\Validate;
|
||||
*/
|
||||
class Lottery extends adminApi
|
||||
{
|
||||
|
||||
// Redis实例
|
||||
private $redis;
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = [];
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
|
||||
}
|
||||
/*
|
||||
* 配置列表
|
||||
*/
|
||||
public function config_list(){
|
||||
$list = db::name("bb_lottery_config")->order('sort desc')->select();
|
||||
$list = db::name("bb_lottery_config")->where(['delete_time' => 0])->order('sort desc')->select();
|
||||
$list_data = [];
|
||||
foreach ($list as $k=>$v){
|
||||
$list_data[$k]['id'] = $v['id'];
|
||||
@@ -43,13 +46,114 @@ class Lottery extends adminApi
|
||||
* 配置设置
|
||||
*/
|
||||
public function config_set(){
|
||||
$bb_lottery_config = Db::name('bb_lottery_config')->column('value', 'key');
|
||||
$small_pool_trigger_times = $bb_lottery_config['small_pool_trigger_times'];//初级开奖的累计次数
|
||||
$lottery_rate = $bb_lottery_config['lottery_rate'];//初级最大爆币率
|
||||
$small_pool_trigger_times_5 = $bb_lottery_config['small_pool_trigger_times_5'];//中级开奖的累计次数
|
||||
$lottery_rate_5 = $bb_lottery_config['lottery_rate_5'];//中级最大爆币率
|
||||
$small_pool_trigger_times_10 = $bb_lottery_config['small_pool_trigger_times_10'];//高级最大爆币率
|
||||
$lottery_rate_10 = $bb_lottery_config['lottery_rate_10'];//高级最大爆币率
|
||||
$params = $this->request->post();
|
||||
$small_type = 0;
|
||||
$small_type_5 = 0;
|
||||
$small_type_10 = 0;
|
||||
|
||||
foreach ($params as $k=>$v){
|
||||
$data = [
|
||||
'value'=>$v,
|
||||
];
|
||||
db::name("bb_lottery_config")->where(['key'=>$k])->update($data);
|
||||
|
||||
if($k=='small_pool_trigger_times'){
|
||||
if($v != $small_pool_trigger_times){
|
||||
$small_type = 1;
|
||||
}
|
||||
}
|
||||
if($k=='lottery_rate'){
|
||||
if($v != $lottery_rate){
|
||||
$small_type = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if($k=='small_pool_trigger_times_5'){
|
||||
if($v != $small_pool_trigger_times_5){
|
||||
$small_type_5 = 1;
|
||||
}
|
||||
}
|
||||
if($k=='lottery_rate_5'){
|
||||
if($v != $lottery_rate_5){
|
||||
$small_type_5 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if($k=='small_pool_trigger_times_10'){
|
||||
if($v != $small_pool_trigger_times_10){
|
||||
$small_type_10 = 1;
|
||||
}
|
||||
}
|
||||
if($k=='lottery_rate_10'){
|
||||
if($v != $lottery_rate_10){
|
||||
$small_type_10 = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->redis = Cache::store('redis')->handler();
|
||||
if($small_type==1){
|
||||
$prize_amount = $this->redis->get('lottery:small_pool:total_gold');
|
||||
Db::name('bb_lottery_winner_record')->insert([
|
||||
'uid' => 0,
|
||||
'prize_type' => 1,
|
||||
'prize_amount' => $prize_amount,
|
||||
'pool_amount' => $prize_amount,
|
||||
'ratio' => 100,
|
||||
'release_amount' => $prize_amount,
|
||||
'create_time' => time(),
|
||||
'status' => 0 // 未发放
|
||||
]);
|
||||
//修改开启下一轮
|
||||
$dd =$this->redis->get('lottery:small_pool:round');
|
||||
$this->redis->set('lottery:small_pool:round', $dd+1);
|
||||
$this->redis->set('lottery:small_pool:total_times',0);
|
||||
$this->redis->set('lottery:small_pool:total_gold',0);
|
||||
}
|
||||
if($small_type_5==1){
|
||||
$prize_amount_5 = $this->redis->get('lottery:small_pool:total_gold_5');
|
||||
Db::name('bb_lottery_winner_record')->insert([
|
||||
'uid' => 0,
|
||||
'prize_type' => 3,
|
||||
'prize_amount' => $prize_amount_5,
|
||||
'pool_amount' => $prize_amount_5,
|
||||
'ratio' => 100,
|
||||
'release_amount' => $prize_amount_5,
|
||||
'create_time' => time(),
|
||||
'status' => 0 // 未发放
|
||||
]);
|
||||
//修改开启下一轮
|
||||
$dd5 =$this->redis->get('lottery:small_pool:round_5');
|
||||
$this->redis->set('lottery:small_pool:round_5', $dd5+1);
|
||||
$this->redis->set('lottery:small_pool:total_times_5',0);
|
||||
$this->redis->set('lottery:small_pool:total_gold_5',0);
|
||||
}
|
||||
if($small_type_10==1){
|
||||
$prize_amount_10 = $this->redis->get('lottery:small_pool:total_gold_10');
|
||||
Db::name('bb_lottery_winner_record')->insert([
|
||||
'uid' => 0,
|
||||
'prize_type' => 4,
|
||||
'prize_amount' => $prize_amount_10,
|
||||
'pool_amount' => $prize_amount_10,
|
||||
'ratio' => 100,
|
||||
'release_amount' => $prize_amount_10,
|
||||
'create_time' => time(),
|
||||
'status' => 0 // 未发放
|
||||
]);
|
||||
//修改开启下一轮
|
||||
$dd_10 =$this->redis->get('lottery:small_pool:round_10');
|
||||
$this->redis->set('lottery:small_pool:round_10', $dd_10+1);
|
||||
$this->redis->set('lottery:small_pool:total_times_10',0);
|
||||
$this->redis->set('lottery:small_pool:total_gold_10',0);
|
||||
}
|
||||
|
||||
|
||||
return V(1,"成功");
|
||||
}
|
||||
|
||||
@@ -61,7 +165,18 @@ class Lottery extends adminApi
|
||||
$page_limit = input('page_limit', 30);
|
||||
$stime = input('stime', '');
|
||||
$etime = input('etime', '');
|
||||
$pool_type = input('pool_type', '1');
|
||||
$user_code = input('user_code');
|
||||
if($user_code){
|
||||
$userId = db::name('user')->where(['user_code'=>$user_code])->value('id');
|
||||
if($userId){
|
||||
$where['uid'] = $userId;
|
||||
}else{
|
||||
$where['uid'] = '1';
|
||||
}
|
||||
}
|
||||
$where = [];
|
||||
$where['prize_type'] = $pool_type;
|
||||
if($stime!==""){
|
||||
$where['create_time'] = ['>=', strtotime($stime)];
|
||||
}
|
||||
@@ -72,16 +187,39 @@ class Lottery extends adminApi
|
||||
$where['create_time'] = ['between', [strtotime($stime), strtotime($etime)]];
|
||||
}
|
||||
$count = db::name('bb_lottery_winner_record')->where($where)->count();
|
||||
$lists_data = db::name('bb_lottery_winner_record')->field('id,uid as user_id,prize_type,prize_amount,pool_amount,ratio,release_amount,status,create_time as createtime')->where($where)->page($page, $page_limit)->order("id desc")->select();
|
||||
$lists_data = db::name('bb_lottery_winner_record')
|
||||
->field('id,uid as user_id,prize_type,prize_amount,pool_amount,ratio,release_amount,status,create_time as createtime')
|
||||
->where($where)->page($page, $page_limit)->order("id desc")->select();
|
||||
foreach ($lists_data as $k=>$v){
|
||||
$user_info = db::name('user')->where(['id'=>$v['user_id']])->find();
|
||||
$lists_data[$k]['user_code'] = $user_info['user_code'];
|
||||
$lists_data[$k]['nickname'] = $user_info['user_code']."-".$user_info['nickname'];
|
||||
if($v['user_id'] > 0){
|
||||
$user_info = db::name('user')->where(['id'=>$v['user_id']])->find();
|
||||
$lists_data[$k]['user_code'] = $user_info['user_code']??"";
|
||||
$lists_data[$k]['nickname'] = $user_info['user_code']."-".$user_info['nickname'];
|
||||
}else{
|
||||
$lists_data[$k]['user_code'] = "";
|
||||
$lists_data[$k]['nickname'] = "后台重置,全部释放";
|
||||
}
|
||||
|
||||
//奖项类型:1-小奖 2-大奖
|
||||
$lists_data[$k]['prize_type_str'] = $v['prize_type']==1?"小奖":"大奖";
|
||||
if($v['prize_type']==4){
|
||||
$lists_data[$k]['prize_type_str'] = "高级奖";
|
||||
$gift_price = 10;
|
||||
}elseif ($v['prize_type']==2){
|
||||
$gift_price = 1;
|
||||
$lists_data[$k]['prize_type_str'] = "大奖";
|
||||
}elseif ($v['prize_type']==3){
|
||||
$gift_price = 5;
|
||||
$lists_data[$k]['prize_type_str'] = "中级奖";
|
||||
}else{
|
||||
$gift_price = 1;
|
||||
$lists_data[$k]['prize_type_str'] = "小奖";
|
||||
}
|
||||
|
||||
//状态:1-已发放 0-未发放'
|
||||
$lists_data[$k]['status_str'] = $v['status']==1?"已发放":"未发放";
|
||||
$lists_data[$k]['createtime'] = date("Y-m-d H:i:s", $v['createtime']);
|
||||
$lists_data[$k]['prize_amount'] = floor($v['prize_amount']);
|
||||
$lists_data[$k]['beilv'] = floor($v['prize_amount'] / $gift_price);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
@@ -98,32 +236,127 @@ class Lottery extends adminApi
|
||||
* 实时统计
|
||||
*/
|
||||
public function realtime_statistics(){
|
||||
$pool_type = input('pool_type', '1');
|
||||
|
||||
$bb_config = db::name('bb_lottery_config')->field('key,value')->select();
|
||||
$bb_config = array_column($bb_config, null, 'key');
|
||||
// 循环奖池进度
|
||||
//最新轮次
|
||||
$latest_times = db::name('bb_lottery_pool_flow')->where(['pool_type'=>1])->max('times');
|
||||
$pool_progress = db::name('bb_lottery_pool_flow')->where(['pool_type'=>1,'times'=>$latest_times])->count();//当前进度
|
||||
$pool_total_amount = db::name('bb_lottery_pool_flow')->where(['pool_type'=>1,'times'=>$latest_times,'type'=>1])->sum('amount');
|
||||
//获取配置表中奖池配置
|
||||
$pool_progress_str = $pool_progress."/".$bb_config['small_pool_trigger_times']['value']."(".$pool_total_amount."金币)";
|
||||
if($pool_type == 4){
|
||||
$latest_times = db::name('bb_lottery_pool_flow_10')->where(['pool_type'=>1])->max('times');//最新轮次
|
||||
$pool_progress = db::name('bb_lottery_pool_flow_10')->where(['pool_type'=>1,'times'=>$latest_times])->count();//当前进度
|
||||
$pool_total_amount = db::name('bb_lottery_pool_flow_10')->where(['pool_type'=>1,'times'=>$latest_times,'type'=>1])->sum('amount');
|
||||
//获取配置表中奖池配置
|
||||
$pool_progress_str = $pool_progress."/".$bb_config['small_pool_trigger_times_10']['value']."(".$pool_total_amount."金币)";
|
||||
//最近中奖用户
|
||||
$last_winner_user_id = db::name('bb_lottery_winner_record')->where(['status'=>1,'prize_type'=>4])->order('id desc')->find();
|
||||
//平台累计收入
|
||||
$platform_total_income = db::name('bb_lottery_winner_record')->where(['prize_type'=>4])->sum('release_amount');
|
||||
}elseif($pool_type == 3){
|
||||
$latest_times = db::name('bb_lottery_pool_flow_5')->where(['pool_type'=>1])->max('times');//最新轮次
|
||||
$pool_progress = db::name('bb_lottery_pool_flow_5')->where(['pool_type'=>1,'times'=>$latest_times])->count();//当前进度
|
||||
$pool_total_amount = db::name('bb_lottery_pool_flow_5')->where(['pool_type'=>1,'times'=>$latest_times,'type'=>1])->sum('amount');
|
||||
//获取配置表中奖池配置
|
||||
$pool_progress_str = $pool_progress."/".$bb_config['small_pool_trigger_times_5']['value']."(".$pool_total_amount."金币)";
|
||||
//最近中奖用户
|
||||
$last_winner_user_id = db::name('bb_lottery_winner_record')->where(['status'=>1,'prize_type'=>3])->order('id desc')->find();
|
||||
//平台累计收入
|
||||
$platform_total_income = db::name('bb_lottery_winner_record')->where(['prize_type'=>3])->sum('release_amount');
|
||||
}else{
|
||||
$latest_times = db::name('bb_lottery_pool_flow')->where(['pool_type'=>1])->max('times');//最新轮次
|
||||
$pool_progress = db::name('bb_lottery_pool_flow')->where(['pool_type'=>1,'times'=>$latest_times])->count();//当前进度
|
||||
$pool_total_amount = db::name('bb_lottery_pool_flow')->where(['pool_type'=>1,'times'=>$latest_times,'type'=>1])->sum('amount');
|
||||
//获取配置表中奖池配置
|
||||
$pool_progress_str = $pool_progress."/".$bb_config['small_pool_trigger_times']['value']."(".$pool_total_amount."金币)";
|
||||
//最近中奖用户
|
||||
$last_winner_user_id = db::name('bb_lottery_winner_record')->where(['status'=>1,'prize_type'=>1])->order('id desc')->find();
|
||||
//平台累计收入
|
||||
$platform_total_income = db::name('bb_lottery_winner_record')->where(['prize_type'=>1])->sum('release_amount');
|
||||
}
|
||||
|
||||
|
||||
//蓄水池当前金额
|
||||
$big_round = db::name('bb_lottery_pool_flow')->where(['pool_type'=>2])->max('times');
|
||||
$bigAddGold = Db::name('bb_lottery_pool_flow')
|
||||
->where(['pool_type' => 2, 'type' => 3, 'times' => $big_round])
|
||||
->sum('amount') ?: 0;
|
||||
//最近中奖用户
|
||||
$last_winner_user_id = db::name('bb_lottery_winner_record')->where(['status'=>1])->order('id desc')->find();
|
||||
$last_winner_user_info = db::name('user')->where(['id'=>$last_winner_user_id['uid']])->find();
|
||||
// $big_round = db::name('bb_lottery_pool_flow')->where(['pool_type'=>2])->max('times');
|
||||
// $bigAddGold = Db::name('bb_lottery_pool_flow')->where(['pool_type' => 2, 'type' => 3, 'times' => $big_round])->sum('amount') ?: 0;
|
||||
$bigAddGold = 0;
|
||||
|
||||
if($last_winner_user_id){
|
||||
$last_winner_user_info = db::name('user')->where(['id'=>$last_winner_user_id['uid']])->find();
|
||||
$last_winner_user_text = "用户ID:".$last_winner_user_info['user_code']." 获得 ".$last_winner_user_id['prize_amount']." 金币 (".$last_winner_user_id['ratio']."%)";
|
||||
}else{
|
||||
$last_winner_user_text = "无";
|
||||
}
|
||||
|
||||
//平台累计收入
|
||||
$platform_total_income = db::name('bb_lottery_pool_flow')->where(['type'=>4])->sum('amount');
|
||||
// $platform_total_income = db::name('bb_lottery_pool_flow')->where(['type'=>4])->sum('amount');
|
||||
|
||||
$return_data=[
|
||||
'pool_progress' => $pool_progress_str,
|
||||
'pool_amount_now' => ($bigAddGold)."金币 (".(($bigAddGold)/$bb_config['big_pool_threshold']['value'])."%)",
|
||||
'last_winner_user' => "用户ID:".$last_winner_user_info['user_code']." 获得 ".$last_winner_user_id['prize_amount']." 金币 (".$last_winner_user_id['ratio']."%)",
|
||||
'last_winner_user' => $last_winner_user_text,
|
||||
'platform_total_income' => $platform_total_income." 金币",
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 抽奖记录
|
||||
*/
|
||||
public function pool_flow_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$stime = input('stime', '');
|
||||
$etime = input('etime', '');
|
||||
$pool_type = input('pool_type', '1');
|
||||
$user_code = input('user_code');
|
||||
if($user_code){
|
||||
$userId = db::name('user')->where(['user_code'=>$user_code])->value('id');
|
||||
if($userId){
|
||||
$where['uid'] = $userId;
|
||||
}else{
|
||||
$where['uid'] = '1';
|
||||
}
|
||||
}
|
||||
if($pool_type == 4){
|
||||
$table = 'bb_lottery_gift_record_10';
|
||||
}
|
||||
elseif($pool_type == 3){
|
||||
$table = 'bb_lottery_gift_record_5';
|
||||
}
|
||||
else{
|
||||
$table = 'bb_lottery_gift_record';
|
||||
}
|
||||
$where = [];
|
||||
if($stime!==""){
|
||||
$where['create_time'] = ['>=', strtotime($stime)];
|
||||
}
|
||||
if($etime!==""){
|
||||
$where['create_time'] = ['<=', strtotime($etime)];
|
||||
}
|
||||
if($stime!=="" && $etime!==""){
|
||||
$where['create_time'] = ['between', [strtotime($stime), strtotime($etime)]];
|
||||
}
|
||||
$count = db::name($table)->where($where)->count();
|
||||
$lists_data = db::name($table)
|
||||
->field('id,send_uid,recv_uid,gift_id,gift_gold,recv_gold,small_pool_add,remark,create_time as createtime')
|
||||
->where($where)
|
||||
->order("id desc")
|
||||
->page($page, $page_limit)->select();
|
||||
foreach ($lists_data as $k=>$v){
|
||||
$send_user_info = db::name('user')->field('nickname,user_code')->where(['id'=>$v['send_uid']])->find();
|
||||
$recv_user_info = db::name('user')->field('nickname,user_code')->where(['id'=>$v['recv_uid']])->find();
|
||||
$lists_data[$k]['send_nickname'] = $send_user_info['user_code']."-".$send_user_info['nickname'];
|
||||
$lists_data[$k]['recv_nickname'] = $recv_user_info['user_code']."-".$recv_user_info['nickname'];
|
||||
$lists_data[$k]['gift_name'] = db::name('vs_gift')->where(['gid'=>$v['gift_id']])->value('gift_name');
|
||||
$lists_data[$k]['createtime'] = date("Y-m-d H:i:s", $v['createtime']);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists_data,
|
||||
'total_data' => [
|
||||
]
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
|
||||
}
|
||||
}
|
||||
146
application/adminapi/controller/Monster.php
Normal file
146
application/adminapi/controller/Monster.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Cache;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
|
||||
class Monster extends adminApi
|
||||
{
|
||||
|
||||
|
||||
//获取列表
|
||||
public function get_monster_list()
|
||||
{
|
||||
$order = input('order', 'id');
|
||||
$sort = input('sort', 'desc');
|
||||
$page = input('page', 1);
|
||||
$limit = input('limit', 20);
|
||||
$reslut = model('Monster')->get_monster_list($order, $sort, $page, $limit);
|
||||
$data = [];
|
||||
$data['code'] = 0;
|
||||
$data['msg'] = '获取成功';
|
||||
$data['count'] = $reslut['data']['count'];
|
||||
$data['data'] = $reslut['data']['list'];
|
||||
return V(1,"成功", $data);
|
||||
}
|
||||
|
||||
//获取详情
|
||||
public function get_monster_info()
|
||||
{
|
||||
$id = input('id', 0);
|
||||
$reslut = model('Monster')->get_monster_info($id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//编辑
|
||||
public function edit_monster()
|
||||
{
|
||||
|
||||
$data['id'] = input('id', 0);
|
||||
$data['gid'] = input('gid', 0);
|
||||
$data['num'] = input('num', 0);
|
||||
$data['type_name'] = input('type_name', 0);
|
||||
$data['multiple'] = input('multiple', 0);
|
||||
|
||||
$reslut = model('Monster')->edit_monster($data);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//获取礼物列表
|
||||
public function get_gift_list()
|
||||
{
|
||||
$reslut = model('Monster')->get_gift_list();
|
||||
$data = [];
|
||||
$data['code'] = 0;
|
||||
$data['msg'] = '获取成功';
|
||||
$data['count'] = $reslut['data']['count'];
|
||||
$data['data'] = $reslut['data']['list'];
|
||||
return V(1,"成功", $data);
|
||||
}
|
||||
|
||||
|
||||
//获取列表
|
||||
public function get_monster_multiple_list()
|
||||
{
|
||||
$order = input('order', 'id');
|
||||
$sort = input('sort', 'desc');
|
||||
$page = input('page', 1);
|
||||
$limit = input('limit', 20);
|
||||
$reslut = model('Monster')->get_monster_multiple_list($order, $sort, $page, $limit);
|
||||
$data = [];
|
||||
$data['code'] = 0;
|
||||
$data['msg'] = '获取成功';
|
||||
$data['count'] = $reslut['data']['count'];
|
||||
$data['data'] = $reslut['data']['list'];
|
||||
return V(1,"成功", $data);
|
||||
}
|
||||
|
||||
//获取详情
|
||||
public function get_monster_multiple_info()
|
||||
{
|
||||
$id = input('id', 0);
|
||||
$reslut = model('Monster')->get_monster_multiple_info($id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//编辑
|
||||
public function edit_monster_multiple()
|
||||
{
|
||||
$data['id'] = input('id', 0);
|
||||
$data['multiple'] = input('multiple', 0);
|
||||
$reslut = model('Monster')->edit_monster_multiple($data);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//获取列表
|
||||
public function get_monster_log(){
|
||||
$order = input('order', 'id');
|
||||
$sort = input('sort', 'desc');
|
||||
$page = input('page', 1);
|
||||
$limit = input('limit', 20);
|
||||
$reslut = model('Monster')->get_monster_log($order, $sort, $page, $limit);
|
||||
$data = [];
|
||||
$data['code'] = 0;
|
||||
$data['msg'] = '获取成功';
|
||||
$data['count'] = $reslut['data']['count'];
|
||||
$data['data'] = $reslut['data']['list'];
|
||||
$data['totalRow'] = $reslut['data']['totalRow'];
|
||||
return V(1,"成功", $data);
|
||||
}
|
||||
|
||||
//获取列表
|
||||
public function get_user_monster_log(){
|
||||
$mid = input('mid', 0);
|
||||
$order = input('order', 'id');
|
||||
$sort = input('sort', 'desc');
|
||||
$page = input('page', 1);
|
||||
$limit = input('limit', 20);
|
||||
$reslut = model('Monster')->get_user_monster_log($mid, $order, $sort, $page, $limit);
|
||||
$data = [];
|
||||
$data['code'] = 0;
|
||||
$data['msg'] = '获取成功';
|
||||
$data['count'] = $reslut['data']['count'];
|
||||
$data['data'] = $reslut['data']['list'];
|
||||
return V(1,"成功", $data);
|
||||
}
|
||||
|
||||
//获取列表
|
||||
public function get_user_monster_win_log(){
|
||||
$mid = input('mid', 0);
|
||||
$order = input('order', 'id');
|
||||
$sort = input('sort', 'desc');
|
||||
$page = input('page', 1);
|
||||
$limit = input('limit', 20);
|
||||
$reslut = model('Monster')->get_user_monster_win_log($mid, $order, $sort, $page, $limit);
|
||||
$data = [];
|
||||
$data['code'] = 0;
|
||||
$data['msg'] = '获取成功';
|
||||
$data['count'] = $reslut['data']['count'];
|
||||
$data['data'] = $reslut['data']['list'];
|
||||
return V(1,"成功", $data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -414,4 +414,19 @@ class Nobility extends adminApi
|
||||
return V(0, "删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
//爵位赠送
|
||||
public function give_nobility(){
|
||||
$user_code = input('user_code', '');
|
||||
$lid = input('lid', '');
|
||||
$user_id = db::name('user')->where('delete_time', 0)->where('user_code', $user_code)->value('id');
|
||||
if (empty($user_id)) {
|
||||
return V(0, "请选择用户");
|
||||
}
|
||||
if (empty($lid)) {
|
||||
return V(0, "请选择爵位");
|
||||
}
|
||||
$reslut = model('api/Nobility')->buyNobility($user_id,$lid);
|
||||
return V($reslut['code'],$reslut['msg'], null);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use app\common\library\GiftTableManager;
|
||||
use think\Cache;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
@@ -220,6 +222,14 @@ class Room extends adminApi
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
}
|
||||
$lists[]=[
|
||||
'createtime' => '',
|
||||
'deletetime' => 0,
|
||||
'id' => -1,
|
||||
'type_name' => '练歌房',
|
||||
'status' => 1,
|
||||
'sort' => 99
|
||||
];
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
@@ -320,11 +330,15 @@ class Room extends adminApi
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search_name = input('search_name', '');
|
||||
$search_type = input('search_type', '');
|
||||
$where=[];
|
||||
//标签名称
|
||||
if($search_name!==''){
|
||||
$where['name'] = ['like', '%'.$search_name.'%'];
|
||||
}
|
||||
if($search_type!==''){
|
||||
$where['type'] = $search_type;
|
||||
}
|
||||
$where['delete_time'] = 0;
|
||||
$count = db::name($this->relation)->where($where)->count();
|
||||
$lists = db::name($this->relation)->where($where)->page($page, $page_limit)->select();
|
||||
@@ -474,7 +488,12 @@ class Room extends adminApi
|
||||
$where['room_status'] = $search_status;
|
||||
}
|
||||
if($type_id!==''){
|
||||
$where['type_id'] = $type_id;
|
||||
if($type_id == -1){
|
||||
$where['type_id'] = 1;
|
||||
$where['label_id'] = 2;
|
||||
}else{
|
||||
$where['type_id'] = $type_id;
|
||||
}
|
||||
}else{
|
||||
$where['type_id'] = ['<>',6];
|
||||
}
|
||||
@@ -509,8 +528,14 @@ class Room extends adminApi
|
||||
$lists[$key]['user_name'] = model('User')->where(['id'=>$value['user_id']])->value('nickname');
|
||||
$lists[$key]['room_name'] = $value['room_name'];
|
||||
$lists[$key]['room_cover'] = $value['room_cover'];
|
||||
$lists[$key]['room_type_str'] = db::name($this->table_room_type)->where(['id'=>$value['type_id']])->value('type_name');
|
||||
$lists[$key]['room_label_str'] = db::name($this->table_room_label)->where(['id'=>$value['label_id']])->value('label_name');
|
||||
if($value['type_id']==1 && $value['label_id']==2){
|
||||
$lists[$key]['room_type_str'] = "练歌房";
|
||||
$lists[$key]['room_label_str'] = "练歌房";
|
||||
$value['type_id']=-1;
|
||||
}else{
|
||||
$lists[$key]['room_type_str'] = db::name($this->table_room_type)->where(['id'=>$value['type_id']])->value('type_name');
|
||||
$lists[$key]['room_label_str'] = db::name($this->table_room_label)->where(['id'=>$value['label_id']])->value('label_name');
|
||||
}
|
||||
$lists[$key]['is_recommend'] = $value['is_recommend'] != 1 ? '是' : '否';
|
||||
$lists[$key]['is_top'] = $value['is_top'] != 1 ? '是' : '否';
|
||||
$lists[$key]['is_hot'] = $value['is_hot'] != 1 ? '是' : '否';
|
||||
@@ -641,6 +666,10 @@ class Room extends adminApi
|
||||
}
|
||||
$room_data['growth_week_subsidy'] = round($weekSubsidy, 2);
|
||||
|
||||
if($room_data['type_id']==1 && $room_data['label_id']==2){
|
||||
$room_data['type_id']=-1;
|
||||
}
|
||||
|
||||
return V(1,"成功", $room_data);
|
||||
}
|
||||
|
||||
@@ -651,19 +680,43 @@ class Room extends adminApi
|
||||
if($type == 2){
|
||||
$start_time = strtotime(date('Y-m-d'));
|
||||
$end_time = $start_time + 86400;
|
||||
$tables = GiftTableManager::getTablesByTimeRange(
|
||||
$start_time,
|
||||
$end_time
|
||||
);
|
||||
}elseif ($type == 3){
|
||||
$start_time = strtotime(date('Y-m-d',strtotime('-1 day')));
|
||||
$end_time = $start_time + 86400;
|
||||
$tables = GiftTableManager::getTablesByTimeRange(
|
||||
$start_time,
|
||||
$end_time
|
||||
);
|
||||
}elseif ($type == 4){
|
||||
$start_time = strtotime(date('Y-m-d',strtotime('-2 day')));
|
||||
$end_time = $start_time + 86400;
|
||||
$tables = GiftTableManager::getTablesByTimeRange(
|
||||
$start_time,
|
||||
$end_time
|
||||
);
|
||||
}elseif ($type == 1){
|
||||
$start_time = 1748676768;//2025-06-00 15:32:48
|
||||
$end_time = time();
|
||||
$tables = GiftTableManager::getTablesByTimeRange(
|
||||
$start_time,
|
||||
$end_time
|
||||
);
|
||||
}
|
||||
|
||||
$profit = db::name('vs_give_gift')->where('from_id', $room_id)->where('from',2)->where('createtime', 'between', [$start_time, $end_time])->sum('total_price');
|
||||
return $profit;
|
||||
$all_total_price =0;
|
||||
if($tables){
|
||||
foreach ($tables as $table_name){
|
||||
//表前缀
|
||||
$table_prefix = config('database.prefix');
|
||||
$table_name = str_replace($table_prefix, '', $table_name);
|
||||
$total_price = db::name($table_name)->where('from_id', $room_id)->where('from',2)->where('createtime', 'between', [$start_time, $end_time])->sum('total_price');
|
||||
$all_total_price += $total_price;
|
||||
}
|
||||
}
|
||||
return $all_total_price;
|
||||
}
|
||||
|
||||
|
||||
@@ -695,86 +748,69 @@ class Room extends adminApi
|
||||
$type = input('type', 1);//1:全部流水 2:日流水 3:周流水 4:月流水
|
||||
$stime = input('stime', '');
|
||||
$etime = input('etime', '');
|
||||
|
||||
$firstDay = date('Y-m-01');
|
||||
$lastDay = date('Y-m-t 23:59:59');
|
||||
$begin_time_table = empty($stime) ? $firstDay : $stime;
|
||||
$end_time_table = empty($etime) ? $lastDay : $etime;
|
||||
if($room_id == ''){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
if($type == 1){
|
||||
$begin_time = 1748676768;//2025-06-00 15:32:48
|
||||
$end_time = time();
|
||||
$where['a.createtime'] = ['between', [$begin_time, $end_time]];
|
||||
}elseif ($type == 2){
|
||||
//日流水
|
||||
$begin_time = strtotime(date('Y-m-d 00:00:00',time()));
|
||||
$end_time = time();
|
||||
$where['a.createtime'] = ['between', [$begin_time, $end_time]];
|
||||
}
|
||||
elseif ($type == 3){
|
||||
//周流水
|
||||
//本周一
|
||||
$begin_time = strtotime(date('Y-m-d 00:00:00', strtotime('this week')));
|
||||
$end_time = time();
|
||||
$where['a.createtime'] = ['between', [$begin_time, $end_time]];
|
||||
}
|
||||
elseif ($type == 4){
|
||||
$begin_time = strtotime(date('Y-m-01'));
|
||||
$end_time = time();
|
||||
$where['a.createtime'] = ['between', [$begin_time, $end_time]];
|
||||
}
|
||||
if($stime != '' && $etime != ''){
|
||||
$begin_time = strtotime($stime);
|
||||
$end_time = strtotime($etime);
|
||||
$where['a.createtime'] = ['between', [$begin_time, $end_time]];
|
||||
}elseif($stime != '' && $etime == ''){
|
||||
$begin_time = strtotime($stime);
|
||||
$end_time = time();
|
||||
$where['a.createtime'] = ['between', [$begin_time, $end_time]];
|
||||
}elseif($etime != '' && $stime == ''){
|
||||
$end_time = strtotime($etime);
|
||||
$where['a.createtime'] = ['<=', $etime];
|
||||
}
|
||||
|
||||
$count = db::name('vs_give_gift')->alias('a')
|
||||
->field('a.id')
|
||||
->join('user b', 'a.user_id = b.id', 'left')
|
||||
->join('user c', 'a.gift_user = c.id', 'left')
|
||||
->join('vs_gift d', 'a.gift_id = d.gid', 'left')
|
||||
->where('a.from',2)
|
||||
->where('a.from_id',$room_id)
|
||||
->where($where)
|
||||
->count();
|
||||
$list = db::name('vs_give_gift')->alias('a')
|
||||
->field('a.number,a.createtime,a.total_price,a.type,b.nickname,b.avatar,c.nickname as gift_nickname,c.avatar as gift_avatar,d.gift_name,a.from,a.from_id')
|
||||
->join('user b', 'a.user_id = b.id', 'left')
|
||||
->join('user c', 'a.gift_user = c.id', 'left')
|
||||
->join('vs_gift d', 'a.gift_id = d.gid', 'left')
|
||||
->where('a.from',2)
|
||||
->where('a.from_id',$room_id)
|
||||
->where($where)
|
||||
->order('a.id desc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
$params['from_id'] = $room_id;
|
||||
$ext_params['start_time'] = strtotime($begin_time_table);
|
||||
$ext_params['end_time'] = strtotime($end_time_table);
|
||||
$params['page'] = $page;
|
||||
$params['limit'] = $page_limit;
|
||||
$res = model('api/GiveGiftBases')->getGiftRecords($params,$ext_params);
|
||||
$list = $res['data'];
|
||||
$count = $res['total'];
|
||||
$list_data = [];
|
||||
foreach ($list as &$value) {
|
||||
$value['time'] = date('Y-m-d', $value['createtime']);
|
||||
$value['sender_nickname'] = db::name('user')->where('id', $value['user_id'])->value('nickname');
|
||||
$value['sender_avatar'] = db::name('user')->where('id', $value['user_id'])->value('avatar');
|
||||
$value['receive_nickname'] = db::name('user')->where('id', $value['gift_user'])->value('nickname');
|
||||
$value['receive_avatar'] = db::name('user')->where('id', $value['gift_user'])->value('avatar');
|
||||
$value['gift_name'] = db::name('vs_gift')->where('gid', $value['gift_id'])->value('gift_name');
|
||||
|
||||
}
|
||||
if($list){
|
||||
foreach ($list as &$v){
|
||||
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
|
||||
$v['content'] = $v['nickname'].' 给 '.$v['gift_nickname'].' 送了 '.$v['gift_name'].' x '.$v['number'];
|
||||
$v['content'] = $v['sender_nickname'].' 给 '.$v['receive_nickname'].' 送了 '.$v['gift_name'].' x '.$v['number'];
|
||||
// 来源:1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏
|
||||
$v['from_str'] = model('Gift')->GiveGiftFromStr[$v['from']];
|
||||
|
||||
$v['from_str'] = model('adminapi/Gift')->GiveGiftFromStr[$v['from']];
|
||||
}
|
||||
}
|
||||
$where =[];
|
||||
$where['createtime'] = ['between', [strtotime($begin_time_table), strtotime($end_time_table)]];
|
||||
$all_total_price = 0;
|
||||
$tables = GiftTableManager::getTablesByTimeRange(
|
||||
strtotime($begin_time_table),
|
||||
strtotime($end_time_table)
|
||||
);
|
||||
if($tables){
|
||||
foreach ($tables as $table_name){
|
||||
//表前缀
|
||||
$table_prefix = config('database.prefix');
|
||||
$table_name = str_replace($table_prefix, '', $table_name);
|
||||
$total_price = db::name($table_name)
|
||||
->where('from',2)
|
||||
->where('from_id',$room_id)
|
||||
->where($where)->sum('total_price');
|
||||
$all_total_price += $total_price;
|
||||
}
|
||||
}
|
||||
//幸运流水总计
|
||||
$total_lucky_coin = db::name('vs_room_luck_value')->alias('a')->where('room_id',$room_id)->where($where)->sum('luck_value');
|
||||
$total_lucky_coin = db::name('vs_room_luck_value')->where('room_id',$room_id)->where($where)->sum('luck_value');
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list,
|
||||
'total' =>[
|
||||
'total_price' => db::name('vs_give_gift')->alias('a')
|
||||
->join('user b', 'a.user_id = b.id', 'left')
|
||||
->where('a.from',2)
|
||||
->where('a.from_id',$room_id)
|
||||
->where($where)->sum('total_price'),
|
||||
'total_price' => $all_total_price,
|
||||
'total_lucky_coin' => $total_lucky_coin,
|
||||
]
|
||||
];
|
||||
@@ -950,8 +986,35 @@ class Room extends adminApi
|
||||
if($sort !== ""){
|
||||
$data['sort'] = $sort;
|
||||
}
|
||||
if($type_id==-1){
|
||||
model('api/RoomSong')->agree_song(1,$room_id,1);
|
||||
unset($data['type_id']);
|
||||
}
|
||||
if($type_id==1){
|
||||
$data['label_id'] = 1;
|
||||
//推送给前端
|
||||
$text = [
|
||||
'room_id' => $room_id,
|
||||
'type' => $type_id,
|
||||
'text' => '房间类型已修改type--'.$type_id
|
||||
];
|
||||
model('api/Chat')->sendMsg(1012,$room_id,$text);
|
||||
}
|
||||
if($type_id == 9){
|
||||
$data['label_id'] = 6;
|
||||
}
|
||||
$start_time = input('start_time', '');//营业开始时间
|
||||
if($start_time){
|
||||
$data['start_time'] = $start_time;
|
||||
}
|
||||
$end_time = input('end_time', '');//营业结束时间
|
||||
if($end_time){
|
||||
$data['end_time'] = $end_time;
|
||||
}
|
||||
$data['updatetime'] = time();
|
||||
$res = db::name('vs_room')->where('id',$room_id)->update($data);
|
||||
if($res){
|
||||
Cache::rm('room_info_'.$room_id);
|
||||
return V(1,"成功");
|
||||
}
|
||||
else{
|
||||
@@ -1963,4 +2026,70 @@ class Room extends adminApi
|
||||
return V(1, "成功", $return_data);
|
||||
}
|
||||
|
||||
// 房间主持人列表
|
||||
public function room_host_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 10);
|
||||
$room_id = input('room_id', '');
|
||||
if(empty($room_id)){
|
||||
return V(0, "房间ID不能为空");
|
||||
}
|
||||
$count = db::name("vs_room_host")->where(['room_id'=>$room_id])->count();
|
||||
$room_host_lists = db::name("vs_room_host")->where(['room_id'=>$room_id])->order('createtime desc')->page($page, $page_limit)->select();
|
||||
if($room_host_lists){
|
||||
foreach ($room_host_lists as $key => $value){
|
||||
$room_host_lists[$key]['type_str'] = $value['type'] == 1 ? '主持' : '管理'; //1主持 2管理
|
||||
$room_host_lists[$key]['nickname'] = db::name('user')->where(['id'=>$value['user_id']])->value('nickname');
|
||||
$room_host_lists[$key]['avatar'] = db::name('user')->where(['id'=>$value['user_id']])->value('avatar');
|
||||
$room_host_lists[$key]['user_code'] = db::name('user')->where(['id'=>$value['user_id']])->value('user_code');
|
||||
$room_host_lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
//主持是否在买上
|
||||
$roop_pit_9 = db::name('vs_room_pit')->where(['room_id'=>$room_id, 'user_id'=>$value['user_id'],'pit_number'=>9])->value('id');
|
||||
$room_host_lists[$key]['is_on_mic'] = $roop_pit_9 ? 1 : 0;
|
||||
}
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $room_host_lists
|
||||
];
|
||||
return V(1, "成功", $return_data);
|
||||
}
|
||||
|
||||
|
||||
//房间幸运值流水详情
|
||||
public function room_luck_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 10);
|
||||
$room_id = input('room_id', '');
|
||||
if(empty($room_id)){
|
||||
return V(0, "房间ID不能为空");
|
||||
}
|
||||
$count = db::name("vs_room_luck_value")->where(['room_id'=>$room_id])->count();
|
||||
$room_host_lists = db::name("vs_room_luck_value")
|
||||
->where(['room_id'=>$room_id])
|
||||
->order('createtime desc')
|
||||
->page($page, $page_limit)->select();
|
||||
if($room_host_lists){
|
||||
foreach ($room_host_lists as $key => $value){
|
||||
$room_host_lists[$key]['send_nickname'] = db::name('user')->where(['id'=>$value['send_uid']])->value('nickname');
|
||||
$room_host_lists[$key]['send_avatar'] = db::name('user')->where(['id'=>$value['send_uid']])->value('avatar');
|
||||
$room_host_lists[$key]['send_user_code'] = db::name('user')->where(['id'=>$value['send_uid']])->value('user_code');
|
||||
$room_host_lists[$key]['recv_nickname'] = db::name('user')->where(['id'=>$value['recv_uid']])->value('nickname');
|
||||
$room_host_lists[$key]['recv_avatar'] = db::name('user')->where(['id'=>$value['recv_uid']])->value('avatar');
|
||||
$room_host_lists[$key]['recv_user_code'] = db::name('user')->where(['id'=>$value['recv_uid']])->value('user_code');
|
||||
$room_host_lists[$key]['gift_name'] = db::name('vs_gift')->where(['gid'=>$value['gift_id']])->value('gift_name');
|
||||
$room_host_lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
}
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $room_host_lists
|
||||
];
|
||||
return V(1, "成功", $return_data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,7 +46,7 @@ class SingerSong extends adminApi
|
||||
->join('user u', 'ss.user_id=u.id', 'left')
|
||||
->field('ss.*,u.nickname,u.avatar,u.user_code,u.mobile,u.sex')
|
||||
->where($where)
|
||||
->order('ss.id desc')
|
||||
->order('ss.status asc ,ss.id desc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
if($list){
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\common\controller\adminApi;
|
||||
use app\common\library\GiftTableManager;
|
||||
use think\Db;
|
||||
use Yzh\YunPay;
|
||||
|
||||
@@ -11,6 +12,7 @@ class Statistical extends adminApi
|
||||
//初始化
|
||||
public function _initialize()
|
||||
{
|
||||
set_time_limit(0);
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
@@ -85,6 +87,12 @@ class Statistical extends adminApi
|
||||
$search_uid = input('search_uid', '');
|
||||
$begin_time = input('begin_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
|
||||
$firstDay = date('Y-m-01');
|
||||
$lastDay = date('Y-m-t 23:59:59');
|
||||
$begin_time = empty($begin_time) ? $firstDay : $begin_time;
|
||||
$end_time = empty($end_time) ? $lastDay : $end_time;
|
||||
|
||||
$where=[];
|
||||
$group = 'user_id';
|
||||
if($type == 2){
|
||||
@@ -117,11 +125,23 @@ class Statistical extends adminApi
|
||||
if(!empty($begin_time) && !empty($end_time)){
|
||||
$where['createtime'] = ['between',[strtotime($begin_time),strtotime($end_time)]];
|
||||
}
|
||||
$count = db::name('vs_give_gift')
|
||||
|
||||
$tables = GiftTableManager::getTablesByTimeRange(
|
||||
strtotime($begin_time),
|
||||
strtotime($end_time)
|
||||
);
|
||||
if(empty($tables)){
|
||||
$tables[0] = "fa_vs_give_gift";
|
||||
}
|
||||
$table_name = $tables[count($tables)-1];
|
||||
//表前缀
|
||||
$table_prefix = config('database.prefix');
|
||||
$table_name = str_replace($table_prefix, '', $table_name);//截取可查询的表名
|
||||
$count = db::name($table_name)
|
||||
->where($where)
|
||||
->group($group)
|
||||
->count();
|
||||
$lists = db::name('vs_give_gift')
|
||||
$lists = db::name($table_name)
|
||||
->field('id,createtime,user_id,gift_user,sum(total_price) as total_price,sum(number) as number')
|
||||
->where($where)
|
||||
->group($group)
|
||||
@@ -185,13 +205,13 @@ class Statistical extends adminApi
|
||||
// 1.系统调节 2.充值 3.提现 4.金币转增(送出) 5.每日任务奖励 6.充值返利 7.购买装扮
|
||||
// 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换
|
||||
// 15.首充 16.天降好礼充值 17.退出工会扣款 18.房主收益 19.主持人收益 20.抢头条 21.公会长收益
|
||||
$where['change_type'] = ['in', [4,7,10,17,20]];
|
||||
$count = db::name('vs_user_money_log')
|
||||
$where['change_type'] = ['in', [4,7,10,17,20,24,25,32,42,50,56,59]];
|
||||
$count = db::name('user_coin_log')
|
||||
->where($where)
|
||||
->group('user_id')
|
||||
->count();
|
||||
$lists = db::name('vs_user_money_log')
|
||||
->field('log_id,createtime,user_id,sum(change_value) as change_value')
|
||||
$lists = db::name('user_coin_log')
|
||||
->field('id,createtime,user_id,sum(coin) as change_value')
|
||||
->where($where)
|
||||
->group('user_id')
|
||||
->order('change_value desc')
|
||||
@@ -209,7 +229,7 @@ class Statistical extends adminApi
|
||||
'count' => $count,
|
||||
'lists' => $lists,
|
||||
'total' =>[
|
||||
'total_price' => db::name('vs_user_money_log')->where($where)->sum('change_value')
|
||||
'total_price' => db::name('user_coin_log')->where($where)->sum('coin')
|
||||
]
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
@@ -244,13 +264,24 @@ class Statistical extends adminApi
|
||||
if(!empty($begin_time) && !empty($end_time)){
|
||||
$where['createtime'] = ['between',[strtotime($begin_time),strtotime($end_time)]];
|
||||
}
|
||||
$tables = GiftTableManager::getTablesByTimeRange(
|
||||
strtotime($begin_time),
|
||||
strtotime($end_time)
|
||||
);
|
||||
if(empty($tables)){
|
||||
$tables[0] = "fa_vs_give_gift";
|
||||
}
|
||||
$table_name = $tables[count($tables)-1];
|
||||
//表前缀
|
||||
$table_prefix = config('database.prefix');
|
||||
$table_name = str_replace($table_prefix, '', $table_name);//截取可查询的表名
|
||||
//不为空
|
||||
$where['from'] = 2;
|
||||
$count = db::name('vs_give_gift')
|
||||
$count = db::name($table_name)
|
||||
->where($where)
|
||||
->group('from_id')
|
||||
->count();
|
||||
$lists = db::name('vs_give_gift')
|
||||
$lists = db::name($table_name)
|
||||
->field('id,createtime,user_id,gift_user,sum(total_price) as total_price,sum(number) as number,from_id')
|
||||
->where($where)
|
||||
->group('from_id')
|
||||
@@ -303,7 +334,7 @@ class Statistical extends adminApi
|
||||
'count' => $count,
|
||||
'lists' => $lists,
|
||||
'total' =>[
|
||||
'total_price' => db::name('vs_give_gift')->where($where)->sum('total_price'),
|
||||
'total_price' => db::name($table_name)->where($where)->sum('total_price'),
|
||||
'total_lucky_coin' => db::name('vs_room_luck_value')->where($where_lucky)->sum('luck_value'),
|
||||
]
|
||||
];
|
||||
@@ -521,28 +552,35 @@ class Statistical extends adminApi
|
||||
$search_user_id = 0;
|
||||
$search_gift_bag_id = 0;
|
||||
if($search_id){
|
||||
$search_user_id= db::name('user')->where('user_code', $search_id)->value('id');
|
||||
$where['b.user_code'] = $search_id;
|
||||
}
|
||||
if($search_name){
|
||||
$where['b.nickname'] = ['like', '%'.$search_name.'%'];
|
||||
$search_user_id= db::name('user')->where('nickname', $search_name)->value('id');
|
||||
}
|
||||
if($search_task_id){
|
||||
$where['a.task_id'] = $search_task_id;
|
||||
$search_gift_bag_id = db::name('vs_tasks')->where('id', $search_task_id)->value('tasks_bag_id');
|
||||
}
|
||||
if($search_task_name){
|
||||
$where['c.task_name'] = ['like', '%'.$search_task_name.'%'];
|
||||
$search_gift_bag_id = db::name('vs_tasks')->where('task_name', $search_task_name)->value('tasks_bag_id');
|
||||
}
|
||||
if($begin_time !== ''){
|
||||
$where['a.collection_time'] = ['>=', strtotime($begin_time)];
|
||||
if(!empty($begin_time) && !empty($end_time)){
|
||||
$where['a.collection_time'] = ['between', [strtotime($begin_time), strtotime($end_time)]];
|
||||
}else{
|
||||
if(!empty($begin_time)){
|
||||
$where['a.collection_time'] = ['>=', strtotime($begin_time)];
|
||||
}elseif(!empty($end_time)){
|
||||
$where['a.collection_time'] = ['<=', strtotime($end_time)];
|
||||
}
|
||||
}
|
||||
if($end_time !== ''){
|
||||
$where['a.collection_time'] = ['<=', strtotime($end_time)];
|
||||
if(!empty($begin_time) && !empty($end_time)){
|
||||
$where['a.createtime'] = ['between', [strtotime($begin_time), strtotime($end_time)]];
|
||||
}else{
|
||||
if(!empty($begin_time)){
|
||||
$where['a.createtime'] = ['>=', strtotime($begin_time)];
|
||||
}elseif(!empty($end_time)){
|
||||
$where['a.createtime'] = ['<=', strtotime($end_time)];
|
||||
}
|
||||
}
|
||||
|
||||
// 添加条件:只统计已领取的任务奖励
|
||||
// $where['a.is_claimed'] = 1;
|
||||
|
||||
@@ -632,28 +670,42 @@ class Statistical extends adminApi
|
||||
//奖品价值
|
||||
$data_list[$listkey]['reward_price'] = 0;
|
||||
|
||||
$data_list[$listkey]['completion_time'] = date('Y-m-d H:i:s', $list['completion_time']);
|
||||
$data_list[$listkey]['collection_time'] = date('Y-m-d H:i:s', $list['collection_time']);
|
||||
|
||||
// 计算奖励信息
|
||||
if (isset($bag_details[$list['tasks_bag_id']])) {
|
||||
$reward_info = $bag_details[$list['tasks_bag_id']];
|
||||
foreach ($reward_info as $value) {
|
||||
//价格
|
||||
$reward_price = 0;
|
||||
if($value['type'] == 1){
|
||||
$reward_name = $value['quantity'].$value['name'];
|
||||
$reward_price = $value['gold'] * $value['quantity'];
|
||||
}elseif($value['type'] == 2){
|
||||
$reward_name = $value['name'].'x'.$value['quantity'];
|
||||
$gift_price = isset($gift_prices[$value['foreign_id']]) ? $gift_prices[$value['foreign_id']] : 0;
|
||||
$reward_price = $gift_price * $value['quantity'];
|
||||
}elseif($value['type'] == 3){
|
||||
$reward_name = $value['name'].'x'.$value['days'].'天';
|
||||
//$reward_price = isset($decorate_prices[$value['foreign_id']]) ? $decorate_prices[$value['foreign_id']] : 0;
|
||||
}else{
|
||||
$reward_name = $value['quantity'].$value['name'];
|
||||
//$reward_price = $value['gold'] * $value['quantity'];
|
||||
if($list['task_id']==1){
|
||||
$sign_in_info = Db::name('vs_user_tasks_sign_in')->where(['user_id'=>$list['user_id'],'sign_in_date'=>date('Y-m-d', $list['createtime'])])->order('id desc')->find();
|
||||
if($sign_in_info){
|
||||
$data_list[$listkey]['reward_str'] = ($bag_details[$list['tasks_bag_id']][$sign_in_info['continuous']-1]['gold']
|
||||
* $bag_details[$list['tasks_bag_id']][$sign_in_info['continuous']-1]['quantity'])
|
||||
.$bag_details[$list['tasks_bag_id']][$sign_in_info['continuous']-1]['name'];
|
||||
$data_list[$listkey]['reward_price'] = $bag_details[$list['tasks_bag_id']][$sign_in_info['continuous']-1]['gold']
|
||||
* $bag_details[$list['tasks_bag_id']][$sign_in_info['continuous']-1]['quantity'];
|
||||
}
|
||||
}else{
|
||||
$reward_info = $bag_details[$list['tasks_bag_id']];
|
||||
foreach ($reward_info as $value) {
|
||||
//价格
|
||||
$reward_price = 0;
|
||||
if($value['type'] == 1){
|
||||
$reward_name = $value['quantity'].$value['name'];
|
||||
$reward_price = $value['gold'] * $value['quantity'];
|
||||
}elseif($value['type'] == 2){
|
||||
$reward_name = $value['name'].'x'.$value['quantity'];
|
||||
$gift_price = isset($gift_prices[$value['foreign_id']]) ? $gift_prices[$value['foreign_id']] : 0;
|
||||
$reward_price = $gift_price * $value['quantity'];
|
||||
}elseif($value['type'] == 3){
|
||||
$reward_name = $value['name'].'x'.$value['days'].'天';
|
||||
//$reward_price = isset($decorate_prices[$value['foreign_id']]) ? $decorate_prices[$value['foreign_id']] : 0;
|
||||
}else{
|
||||
$reward_name = $value['quantity'].$value['name'];
|
||||
//$reward_price = $value['gold'] * $value['quantity'];
|
||||
}
|
||||
$data_list[$listkey]['reward_str'] .= $reward_name." ";
|
||||
$data_list[$listkey]['reward_price'] += $reward_price;
|
||||
}
|
||||
$data_list[$listkey]['reward_str'] .= $reward_name." ";
|
||||
$data_list[$listkey]['reward_price'] += $reward_price;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -661,42 +713,125 @@ class Statistical extends adminApi
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'total_reward_price' => $this->get_claimed_reward_price($begin_time, $end_time,$search_user_id,$search_gift_bag_id),
|
||||
'total_reward_price' => 0,//$this->get_claimed_reward_price($begin_time, $end_time,$search_user_id,$search_gift_bag_id),
|
||||
'lists' => $data_list,
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
//每日任务领取金币统计
|
||||
public function get_claimed_reward_price_show(){
|
||||
$search_id = input('search_uid', '');
|
||||
$search_name = input('search_name', '');
|
||||
$search_task_id = input('search_task_id', '');
|
||||
$search_task_name = input('search_task_name', '');
|
||||
$begin_time = input('begin_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$search_user_id = 0;
|
||||
if($search_id){
|
||||
$search_user_id= db::name('user')->where('user_code', $search_id)->value('id');
|
||||
}
|
||||
if($search_name){
|
||||
$search_user_id= db::name('user')->where('nickname', $search_name)->value('id');
|
||||
}
|
||||
$search_gift_bag_id = 0;
|
||||
if($search_task_name){
|
||||
$search_gift_bag_id = db::name('vs_tasks')->where('task_name', $search_task_name)->value('tasks_bag_id');
|
||||
}
|
||||
if($search_task_id){
|
||||
$search_gift_bag_id = db::name('vs_tasks')->where('id', $search_task_id)->value('tasks_bag_id');
|
||||
}
|
||||
$total_reward_price = $this->get_claimed_reward_price($begin_time, $end_time,$search_user_id,$search_gift_bag_id);
|
||||
return V(1,"成功", ['total_reward_price' => $total_reward_price]);
|
||||
}
|
||||
//获取已领取任务奖励的总价值
|
||||
public function get_claimed_reward_price($stime="",$etime="",$search_user_id=0,$search_gift_bag_id=0){
|
||||
//获取所有已领取的任务奖励礼包
|
||||
$where = [];
|
||||
if(!empty($stime)){
|
||||
$where['a.createtime'] = ['>=', strtotime($stime)];
|
||||
}
|
||||
if(!empty($etime)){
|
||||
$where['a.createtime'] = ['<=', strtotime($etime)];
|
||||
}
|
||||
if($search_user_id > 0){
|
||||
$where['a.user_id'] = $search_user_id;
|
||||
}
|
||||
if($search_gift_bag_id > 0){
|
||||
$where['a.gift_bag_id'] = $search_gift_bag_id;
|
||||
}
|
||||
$tasks_bag_details = db::name('vs_gift_bag_receive_log')
|
||||
->alias('a')
|
||||
->join('vs_gift_bag_detail b', 'a.parent_id=b.id')
|
||||
->field('a.createtime,b.type,b.foreign_id,b.quantity,b.gold')
|
||||
->where(['b.type'=>['in', [1,2]]])
|
||||
->where('a.gift_bag_id','>=',18)
|
||||
->where('a.gift_bag_id','<=',51)
|
||||
->where($where)
|
||||
->select();
|
||||
if(!empty($etime) && strtotime($etime)<="1767114849"){//2025-12-31 01:14:09
|
||||
if(!empty($stime) && !empty($etime)){
|
||||
$where['a.createtime'] = ['between', [strtotime($stime), strtotime($etime)]];
|
||||
}else{
|
||||
if(!empty($stime)){
|
||||
$where['a.createtime'] = ['>=', strtotime($stime)];
|
||||
}elseif(!empty($etime)){
|
||||
$where['a.createtime'] = ['<=', strtotime($etime)];
|
||||
}
|
||||
}
|
||||
$tasks_bag_details = db::name('vs_gift_bag_receive_log')
|
||||
->alias('a')
|
||||
->join('vs_gift_bag_detail b', 'a.parent_id=b.id', 'INNER')
|
||||
->field('a.createtime,b.type,b.foreign_id,b.quantity,b.gold')
|
||||
->where(['b.type'=>['in', [1,2]]])
|
||||
->whereBetween('a.gift_bag_id', [18, 52])
|
||||
->where($where)
|
||||
->select();
|
||||
}else{
|
||||
if(!empty($stime) && strtotime($stime)<="1767114849" && strtotime($etime)>"1767114849"){
|
||||
$old_tasks_bag_details = db::name('vs_gift_bag_receive_log')
|
||||
->alias('a')
|
||||
->join('vs_gift_bag_detail b', 'a.parent_id=b.id', 'INNER')
|
||||
->field('a.createtime,b.type,b.foreign_id,b.quantity,b.gold')
|
||||
->where(['b.type'=>['in', [1,2]]])
|
||||
->whereBetween('a.gift_bag_id', [18, 52])
|
||||
->whereBetween('a.createtime', [strtotime($stime), 1767114849])
|
||||
->where($where)
|
||||
->select();
|
||||
$new_tasks_bag_details = db::name('vs_gift_bag_receive_tasks_log')
|
||||
->alias('a')
|
||||
->join('vs_gift_bag_detail b', 'a.parent_id=b.id', 'INNER')
|
||||
->field('a.createtime,b.type,b.foreign_id,b.quantity,b.gold')
|
||||
->where(['b.type'=>['in', [1,2]]])
|
||||
->whereBetween('a.gift_bag_id', [18, 52])
|
||||
->whereBetween('a.createtime', [1767114849, strtotime($etime)])
|
||||
->where($where)
|
||||
->select();
|
||||
$tasks_bag_details = array_merge($old_tasks_bag_details, $new_tasks_bag_details);
|
||||
}else{
|
||||
if(!empty($stime) && !empty($etime)){
|
||||
$where['a.createtime'] = ['between', [strtotime($stime), strtotime($etime)]];
|
||||
}else{
|
||||
if(!empty($stime)){
|
||||
$where['a.createtime'] = ['>=', strtotime($stime)];
|
||||
}elseif(!empty($etime)){
|
||||
$where['a.createtime'] = ['<=', strtotime($etime)];
|
||||
}
|
||||
}
|
||||
$tasks_bag_details = db::name('vs_gift_bag_receive_tasks_log')
|
||||
->alias('a')
|
||||
->join('vs_gift_bag_detail b', 'a.parent_id=b.id', 'INNER')
|
||||
->field('a.createtime,b.type,b.foreign_id,b.quantity,b.gold')
|
||||
->where(['b.type'=>['in', [1,2]]])
|
||||
->whereBetween('a.gift_bag_id', [18, 52])
|
||||
->where($where)
|
||||
->select();
|
||||
}
|
||||
}
|
||||
$total_reward_price = 0;
|
||||
// 批量获取礼物价格以减少数据库查询
|
||||
$gift_ids = [];
|
||||
foreach ($tasks_bag_details as $detail) {
|
||||
if($detail['type'] == 2) {
|
||||
$gift_ids[] = $detail['foreign_id'];
|
||||
}
|
||||
}
|
||||
|
||||
$gift_prices = [];
|
||||
if (!empty($gift_ids)) {
|
||||
$gifts = db::name('vs_gift')->where('gid', 'in', array_unique($gift_ids))->column('gift_price', 'gid');
|
||||
$gift_prices = $gifts ?: [];
|
||||
}
|
||||
|
||||
foreach ($tasks_bag_details as $detail){
|
||||
if($detail['type'] == 1){
|
||||
$total_reward_price += $detail['gold'] * $detail['quantity'];
|
||||
}else{
|
||||
$gift_price = db::name('vs_gift')->where('gid',$detail['foreign_id'])->value('gift_price');
|
||||
$gift_price = isset($gift_prices[$detail['foreign_id']]) ? $gift_prices[$detail['foreign_id']] : 0;
|
||||
$total_reward_price += $gift_price * $detail['quantity'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,16 +25,18 @@ class SysSet extends adminApi
|
||||
|
||||
public $configType = [
|
||||
'1' => '基础设置',
|
||||
'2' => '登录设置',
|
||||
// '2' => '登录设置',
|
||||
'3' => '支付配置',
|
||||
'4' => '提现设置',
|
||||
'5' => '推送及IM配置',
|
||||
// '5' => '推送及IM配置',
|
||||
// '6' => '每日任务设置',
|
||||
'7' => '云存储配置',
|
||||
'7' => '第三方配置',
|
||||
'8' => '房间配置',
|
||||
'9' => '弹窗内容设置',
|
||||
// '9' => '弹窗内容设置',
|
||||
'10' => '邀请奖励',
|
||||
'11' => '二级密码',
|
||||
'12' => '情侣任务设置',
|
||||
'13' => '趣味活动中去',
|
||||
];
|
||||
public $noAdminConfigType = [
|
||||
'1' => '基础设置',
|
||||
|
||||
@@ -78,7 +78,7 @@ class SystemMessage extends adminApi
|
||||
$data['title'] = $title;
|
||||
}
|
||||
|
||||
$content = input('content', '');
|
||||
$content = input('content', ''); //$_POST['content'] ?? '';
|
||||
if($content){
|
||||
$data['content'] = $content;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ class SystemMessage extends adminApi
|
||||
if($receiving_id){
|
||||
$data['receiving_id'] = $receiving_id;
|
||||
}else{
|
||||
$user_list = db::name('user')->field('id')->select();
|
||||
$user_list = db::name('user')->where('delete_time',0)->where(['sex'=>['<>',0]])->field('id')->select();
|
||||
$data['receiving_id'] = implode(',', array_column($user_list, 'id'));
|
||||
}
|
||||
if($id){
|
||||
|
||||
@@ -30,7 +30,7 @@ class Tasks extends adminApi
|
||||
public function task_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 10);
|
||||
$seach_task_type = input('seach_task_type', '');
|
||||
$seach_task_type = input('task_type', '');
|
||||
$where=[];
|
||||
if($seach_task_type != ''){
|
||||
$where['task_type'] = $seach_task_type;
|
||||
@@ -121,5 +121,12 @@ class Tasks extends adminApi
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 任务类型列表
|
||||
*/
|
||||
public function task_type_list(){
|
||||
$list = model('api/Tasks')->task_type;
|
||||
return V(1,"成功", $list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,6 +9,7 @@ use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
use app\common\library\Token as TokenLib;
|
||||
|
||||
/**
|
||||
* 后台首页
|
||||
@@ -95,7 +96,7 @@ class User extends adminApi
|
||||
a.login_device,
|
||||
a.loginip,
|
||||
c.coin,
|
||||
c.earnings,
|
||||
d.earnings,
|
||||
b.is_real,
|
||||
a.init_code,
|
||||
a.status
|
||||
@@ -109,18 +110,20 @@ class User extends adminApi
|
||||
if($order_type=='coin'){
|
||||
$order = "c.coin ".$order_type_val_str;
|
||||
}elseif($order_type=='earnings'){
|
||||
$order = "c.earnings ".$order_type_val_str;
|
||||
$order = "d.earnings ".$order_type_val_str;
|
||||
}
|
||||
$user_data = db::name('user')->alias('a')
|
||||
->join('(SELECT * FROM fa_user_auth WHERE id IN (SELECT MAX(id) FROM fa_user_auth GROUP BY mobile)) b', 'a.mobile = b.mobile', 'LEFT')
|
||||
->join('user_wallet c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_coin c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_earnings d', 'a.id = d.user_id','LEFT')
|
||||
->where($where)
|
||||
->field($field)
|
||||
->order($order);
|
||||
$lists = $user_data->page($page, $page_limit)->select();
|
||||
$count = db::name('user')->alias('a')
|
||||
->join('(SELECT * FROM fa_user_auth WHERE id IN (SELECT MAX(id) FROM fa_user_auth GROUP BY mobile)) b', 'a.mobile = b.mobile', 'LEFT')
|
||||
->join('user_wallet c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_coin c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_earnings d', 'a.id = d.user_id','LEFT')
|
||||
->where($where)
|
||||
->field($field)
|
||||
->count();
|
||||
@@ -143,6 +146,8 @@ class User extends adminApi
|
||||
$lists[$key]['user_block_time'] = '';
|
||||
$lists[$key]['mobile_block_time'] = '';
|
||||
$lists[$key]['ip_block_time'] = '';
|
||||
//禁用理由
|
||||
$lists[$key]['user_block_reason'] = '';
|
||||
if($is_block_user){
|
||||
$lists[$key]['is_block_user'] = 1;
|
||||
if($is_block_user['block_time']==0){
|
||||
@@ -150,6 +155,7 @@ class User extends adminApi
|
||||
}else{
|
||||
$lists[$key]['user_block_time'] = date('Y-m-d H:i:s',$is_block_user['block_time']);
|
||||
}
|
||||
$lists[$key]['user_block_reason'] = model('Block')->getBanReason()[$is_block_user['ban_eason']];
|
||||
}
|
||||
// if($is_block_mobile){
|
||||
// $lists[$key]['is_block_mobile'] = 1;
|
||||
@@ -170,18 +176,20 @@ class User extends adminApi
|
||||
}
|
||||
$total_coin = db::name('user')->alias('a')
|
||||
->join('(SELECT * FROM fa_user_auth WHERE id IN (SELECT MAX(id) FROM fa_user_auth GROUP BY mobile)) b', 'a.mobile = b.mobile', 'LEFT')
|
||||
->join('user_wallet c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_coin c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_earnings d', 'a.id = d.user_id','LEFT')
|
||||
->where(['a.delete_time'=>0])
|
||||
->where($where)
|
||||
->field($field)
|
||||
->sum('c.coin');
|
||||
$total_earnings = db::name('user')->alias('a')
|
||||
->join('(SELECT * FROM fa_user_auth WHERE id IN (SELECT MAX(id) FROM fa_user_auth GROUP BY mobile)) b', 'a.mobile = b.mobile', 'LEFT')
|
||||
->join('user_wallet c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_coin c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_earnings d', 'a.id = d.user_id','LEFT')
|
||||
->where(['a.delete_time'=>0])
|
||||
->where($where)
|
||||
->field($field)
|
||||
->sum('c.earnings');
|
||||
->sum('d.earnings');
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
@@ -219,6 +227,15 @@ class User extends adminApi
|
||||
$type = input('type', 0);
|
||||
$time = input('time', 0);
|
||||
$status = input('status', 1);
|
||||
$ban_eason = input('ban_eason', 0);
|
||||
$ban_day = input('ban_day', 0);
|
||||
if(empty($time)){
|
||||
if(!empty($ban_day)){
|
||||
$time = date('Y-m-d H:i:s', time() + $ban_day * 86400);
|
||||
}else{
|
||||
$time = "";
|
||||
}
|
||||
}
|
||||
$user_info = model('User')->where('id', $user_id)->find();
|
||||
if(!$user_info){
|
||||
return V(0, "用户不存在");
|
||||
@@ -250,10 +267,28 @@ class User extends adminApi
|
||||
'type_text' => $type_text,
|
||||
'block_time' => $block_time,
|
||||
'createtime' => time(),
|
||||
'ban_eason' => $ban_eason,
|
||||
'ban_day' => $ban_day,
|
||||
]);
|
||||
if (!$res) {
|
||||
return V(0, "添加失败");
|
||||
}
|
||||
//加推送单聊消息
|
||||
if($block_time){
|
||||
$content = "您的账号因 含有".model('Block')->getBanReason()[$ban_eason] . "内容 于".date('Y-m-d H:i:s',time())." 被封禁".model('Block')->getBanTime()[$ban_day]." ,".date('Y-m-d H:i:s',$block_time)."解封,如对处罚有异议请及时联系管理员申诉";
|
||||
}else{
|
||||
$content = "您的账号因 含有".model('Block')->getBanReason()[$ban_eason] . "内容 于".date('Y-m-d H:i:s',time())." 被永久封禁".model('Block')->getBanTime()[$ban_day]." ,请及时联系管理员申诉";
|
||||
}
|
||||
|
||||
$text = [
|
||||
'MsgType' => 404,
|
||||
'ToUserId' => $user_id,
|
||||
'Text' => [
|
||||
'text' => $content
|
||||
]
|
||||
];
|
||||
//谁发送给谁,什么消息,是否同步到发送者1是,2否,消息是否只下发给在线用户 1 是,0 否
|
||||
model('api/Tencent')->user_sendmsg("administrator",$user_id,json_encode($text),2,1);
|
||||
}else{
|
||||
if($type ==1) {
|
||||
$res = model('User')->where('id', $user_id)->update(['status' => 1]);
|
||||
@@ -272,8 +307,21 @@ class User extends adminApi
|
||||
Db::name('block')->where($map)->delete();
|
||||
Db::name('sms_error')->where(['mobile' => $user_info['mobile']])->delete();
|
||||
}
|
||||
$token = db::name('user_token')->where('user_id', $user_id)->value('token');
|
||||
// 删除这个Token,使其失效
|
||||
TokenLib::delete($token);
|
||||
return V(1,"成功", null);
|
||||
}
|
||||
//封禁理由
|
||||
public function getBanEason(){
|
||||
$list = model('Block')->getBanReason();
|
||||
return V(1,"成功", $list);
|
||||
}
|
||||
//封禁时长
|
||||
public function getBanDay(){
|
||||
$list = model('Block')->getBanTime();
|
||||
return V(1,"成功", $list);
|
||||
}
|
||||
|
||||
/*
|
||||
* 设为官方账号
|
||||
@@ -373,7 +421,7 @@ class User extends adminApi
|
||||
$user_data['user_info']['wealth_level_icon'] = $user['wealth_level_icon'];
|
||||
$user_data['user_info']['user_code'] = $user['user_code'];
|
||||
$user_data['user_info']['mobile'] = $user['mobile'];
|
||||
$user_data['user_info']['sex'] = $user['sex']==1 ? '男' : '女';
|
||||
$user_data['user_info']['sex'] = $user['sex'];
|
||||
$user_data['user_info']['birthday'] = $user['birthday'];
|
||||
$user_data['user_info']['system'] = $user['system'];
|
||||
$user_data['user_info']['age'] = $user['age'];
|
||||
@@ -587,7 +635,7 @@ class User extends adminApi
|
||||
a.user_code,
|
||||
a.login_device,
|
||||
c.coin,
|
||||
c.earnings,
|
||||
d.earnings,
|
||||
b.is_real,
|
||||
a.init_code,
|
||||
a.status,
|
||||
@@ -595,12 +643,14 @@ class User extends adminApi
|
||||
';
|
||||
$count = db::name('user')->alias('a')
|
||||
->join('fa_user_auth b', 'a.mobile = b.mobile','LEFT')
|
||||
->join('user_wallet c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_coin c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_earnings d', 'a.id = d.user_id','LEFT')
|
||||
->where($where)
|
||||
->count();
|
||||
$user_data = db::name('user')->alias('a')
|
||||
->join('fa_user_auth b', 'a.mobile = b.mobile','LEFT')
|
||||
->join('user_wallet c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_coin c', 'a.id = c.user_id','LEFT')
|
||||
->join('user_wallet_earnings d', 'a.id = d.user_id','LEFT')
|
||||
->where($where)
|
||||
->field($field)
|
||||
->order('a.id desc');
|
||||
@@ -810,6 +860,7 @@ class User extends adminApi
|
||||
$type = input('type', 1);
|
||||
$type_text = input('type_text', '');
|
||||
$block_time = input('block_time', 0);
|
||||
$ban_eason = input('ban_eason', 0);
|
||||
$admin_id = Session::get('admin_id');
|
||||
//插入fa_block 表
|
||||
$res = Db::name('block')->insert([
|
||||
@@ -818,10 +869,27 @@ class User extends adminApi
|
||||
'type_text' => $type_text,
|
||||
'block_time' => strtotime($block_time),
|
||||
'createtime' => time(),
|
||||
'ban_eason' => $ban_eason,
|
||||
]);
|
||||
if (!$res) {
|
||||
return V(0, "添加失败");
|
||||
}
|
||||
//1账号, 2设备, 3ip 4禁言
|
||||
if($type == 1){
|
||||
$user_id = db::name('user')->where('user_code', $type_text)->value('id');
|
||||
}
|
||||
if($type == 2){
|
||||
$user_id = db::name('user')->where('login_device', $type_text)->value('id');
|
||||
}
|
||||
if($type == 3){
|
||||
$user_id = db::name('user')->where('loginip', $type_text)->value('id');
|
||||
}
|
||||
if(isset($user_id)){
|
||||
$token = db::name('user_token')->where('user_id', $user_id)->value('token');
|
||||
// 删除这个Token,使其失效
|
||||
TokenLib::delete($token);
|
||||
}
|
||||
|
||||
return V(1,"添加成功", null);
|
||||
}
|
||||
/*
|
||||
@@ -897,20 +965,29 @@ class User extends adminApi
|
||||
]);
|
||||
}
|
||||
//查他的钱包
|
||||
$wallet = db::name('user_wallet')->where(['user_id'=>$user_id])->find();
|
||||
if($wallet){
|
||||
db::name('user_wallet')->where(['id'=>$wallet['id']])->update([
|
||||
//清空金币表
|
||||
$wallet_coin = db::name('user_wallet_coin')->where(['user_id'=>$user_id])->find();
|
||||
if($wallet_coin){
|
||||
db::name('user_wallet_coin')->where(['id'=>$wallet_coin['id']])->update([
|
||||
'coin' => 0,
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
}
|
||||
//清空钻石表
|
||||
$wallet_earnings = db::name('user_wallet_earnings')->where(['user_id'=>$user_id])->find();
|
||||
if($wallet_earnings){
|
||||
db::name('user_wallet_earnings')->where(['id'=>$wallet_earnings['id']])->update([
|
||||
'earnings' => 0,
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
}
|
||||
|
||||
//他的装扮
|
||||
$dress = db::name('vs_user_decorate')->where(['user_id'=>$user_id])->select();
|
||||
if($dress){
|
||||
foreach ($dress as $key => $value) {
|
||||
if($value['end_time'] > time()){
|
||||
db::name('vs_user_decorate')->where(['id'=>$value['id']])->update([
|
||||
db::name('vs_user_decorate')->where(['udid'=>$value['udid']])->update([
|
||||
'is_perpetual' => 2,
|
||||
'end_time' => time(),
|
||||
'updatetime' => time(),
|
||||
@@ -993,4 +1070,76 @@ class User extends adminApi
|
||||
|
||||
return V(1, "操作成功");
|
||||
}
|
||||
|
||||
//cp关系列表
|
||||
public function user_cp_list(){
|
||||
$user_id = input('user_id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
if (!$user_id){
|
||||
return V(0, "参数错误");
|
||||
}
|
||||
$count = db::name('user_cp_zone')
|
||||
->where(['user_id1'=>$user_id])
|
||||
->whereOr(['user_id2'=>$user_id])
|
||||
->count();
|
||||
$list = db::name('user_cp_zone')->where(['user_id1'=>$user_id])->whereOr(['user_id2'=>$user_id])->select();
|
||||
foreach ($list as $key => $value) {
|
||||
$user1 = db::name('user')->field('id,nickname,user_code')->where(['id'=>$value['user_id1']])->find();
|
||||
$user2 = db::name('user')->field('id,nickname,user_code')->where(['id'=>$value['user_id2']])->find();
|
||||
$list[$key]['user1_nickname'] = $user1['nickname'];
|
||||
$list[$key]['user1_user_code'] = $user1['user_code'];
|
||||
$list[$key]['user2_nickname'] = $user2['nickname'];
|
||||
$list[$key]['user3_user_code'] = $user2['user_code'];
|
||||
$list[$key]['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
||||
$list[$key]['status_str'] = $value['status'] == 1 ? '已建立' : '已取消';
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
//用户关系列表
|
||||
public function user_relation_list(){
|
||||
$user_id = input('user_id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
if (!$user_id){
|
||||
return V(0, "参数错误");
|
||||
}
|
||||
$room_auction1 = db::name('vs_room_auction_relation')->alias('a')
|
||||
->join('user b','a.user_id1 = b.id','left')
|
||||
->join('user c','a.user_id2 = c.id','left')
|
||||
->join('vs_relation d','a.relation_id = d.id','left')//关系
|
||||
->field('a.relation_id,a.cp_room_id,a.id,a.user_id1,a.user_id2,a.updatetime,a.time_day,a.end_time,b.sex as sex1,b.nickname as nickname1,b.avatar as avatar1,c.sex as sex2,c.nickname as nickname2,c.avatar as avatar2,d.name as relation_name,d.icon as image ,a.delete_time')
|
||||
->where(['a.user_id1' => $user_id,'a.end_time' =>['>',time()]])
|
||||
->order('a.updatetime desc')
|
||||
->select();
|
||||
$room_auction2 = db::name('vs_room_auction_relation')->alias('a')
|
||||
->join('user b','a.user_id1 = b.id','left')
|
||||
->join('user c','a.user_id2 = c.id','left')
|
||||
->join('vs_relation d','a.relation_id = d.id','left')//关系
|
||||
->field('a.relation_id,a.cp_room_id,a.id,a.user_id1,a.user_id2,a.updatetime,a.time_day,a.end_time,b.sex as sex1,b.nickname as nickname1,b.avatar as avatar1,c.sex as sex2,c.nickname as nickname2,c.avatar as avatar2,d.name as relation_name,d.icon as image,a.delete_time')
|
||||
->where(['a.user_id2' => $user_id,'a.end_time' =>['>',time()]])
|
||||
->order('a.updatetime desc')
|
||||
->select();
|
||||
|
||||
$room_auction = array_merge((array)$room_auction1, (array)$room_auction2);
|
||||
foreach ($room_auction as $key => $value) {
|
||||
//是否有效
|
||||
$room_auction[$key]['is_valid'] = $value['delete_time'] ==0 && $value['end_time'] > time() ? 1 : 0;
|
||||
$room_auction[$key]['end_time'] = date('Y-m-d H:i:s',$value['end_time']);
|
||||
$room_auction[$key]['add_time'] = date('Y-m-d H:i:s',$value['updatetime']);
|
||||
|
||||
}
|
||||
$return_data = [
|
||||
'lists' => $room_auction
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -18,6 +18,9 @@ class UserCp extends adminApi
|
||||
->where($where)
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
foreach ($list as &$v){
|
||||
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
|
||||
@@ -178,8 +178,46 @@ class UserZone extends adminApi
|
||||
public function del_comment(){
|
||||
$id = input('id', 0);
|
||||
$res = db::name('user_zone_comment')->where(['id'=>$id])->update(['is_delete'=> 2,'updatetime'=> time()]);
|
||||
if($res){
|
||||
$zone_id = db::name('user_zone_comment')->where(['id'=>$id])->value('zone_id');
|
||||
//删除评论下的回复
|
||||
$dd = db::name('user_zone_comment')->where('pid', $id)->find();
|
||||
if($dd){
|
||||
$reslut1 = db::name('user_zone_comment')->where('pid', $id)->update(['is_delete' => 2,'updatetime' => time()]);
|
||||
if (!$reslut1) {
|
||||
return ['code' => 0, 'msg' => '请重试!!', 'data' => null];
|
||||
}
|
||||
}
|
||||
//减少评论数量
|
||||
$num = db::name('user_zone_comment')->where('pid', $id)->count();
|
||||
if($num > 0){
|
||||
$num = $num + 1;
|
||||
}else{
|
||||
$num = 1;
|
||||
}
|
||||
$reslut2 = db::name('user_zone')->where('id', $zone_id)->setDec('comment_num', $num);
|
||||
if (!$reslut2) {
|
||||
return ['code' => 0, 'msg' => '请重试!!', 'data' => null];
|
||||
}
|
||||
}
|
||||
return V($res ? 1 : 0, $res ? '删除成功' : '删除失败');
|
||||
}
|
||||
|
||||
public function comment_zone()
|
||||
{
|
||||
$id = input('id', 0);
|
||||
$content = input('content', '');
|
||||
$comment_data = db::name('user_zone_comment')->where(['id'=>$id])->find();
|
||||
$zid = $comment_data['zone_id'];
|
||||
$pid = $id;
|
||||
$reply_to = input('reply_to', 0);
|
||||
if(!$reply_to){
|
||||
$reply_to = $comment_data['user_id'];
|
||||
}
|
||||
$reslut = model('api/UserZone')->comment_zone(21216, $zid, $content,$pid, $reply_to);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//动态置顶或显示操作操作
|
||||
public function zone_top_or_show(){
|
||||
$id = input('id', 0);
|
||||
|
||||
46
application/adminapi/model/Block.php
Normal file
46
application/adminapi/model/Block.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Session;
|
||||
use think\Db;
|
||||
class Block extends Model
|
||||
{
|
||||
// 开启自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'int';
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
|
||||
protected $name = 'block';
|
||||
|
||||
// 封禁理由 辱骂、低俗、引流、涉政、黑产、其它
|
||||
public static $ban_reason = [
|
||||
'1' => '辱骂',
|
||||
'2' => '低俗',
|
||||
'3' => '引流',
|
||||
'4' => '涉政',
|
||||
'5' => '黑产',
|
||||
'0' => '其它',
|
||||
];
|
||||
|
||||
//封禁时长 1天、3天、7天、一个月、永久
|
||||
public static $ban_time = [
|
||||
'1' => '1天',
|
||||
'3' => '3天',
|
||||
'7' => '7天',
|
||||
'30' => '一个月',
|
||||
'0' => '永久',
|
||||
];
|
||||
|
||||
//获取封禁理由
|
||||
public static function getBanReason(){
|
||||
return self::$ban_reason;
|
||||
}
|
||||
//获取封禁时长
|
||||
public static function getBanTime(){
|
||||
return self::$ban_time;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace app\adminapi\model;
|
||||
|
||||
use app\common\library\GiftTableManager;
|
||||
use think\Log;
|
||||
use think\Model;
|
||||
use think\Session;
|
||||
use think\Db;
|
||||
@@ -19,14 +21,19 @@ class Gift extends Model
|
||||
public $giftType = [
|
||||
1 => '普通礼物',
|
||||
2 => '盲盒礼物',
|
||||
3 => '礼包礼物'
|
||||
3 => '礼包礼物',
|
||||
6 => '酒吧房礼物'
|
||||
];
|
||||
//送礼流水来源:1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏
|
||||
public $GiveGiftFromStr = [
|
||||
1 => '聊天送礼',
|
||||
2 => '房间语聊送礼',
|
||||
3 => '直播送礼',
|
||||
4 => '动态打赏'
|
||||
4 => '动态打赏',
|
||||
5 => '房心愿礼物',
|
||||
6 => '酒吧房自定义礼物',
|
||||
7 => '酒吧房普通礼物',
|
||||
8 => '酒吧房小黑屋礼物'
|
||||
];
|
||||
|
||||
public function getList($where = [], $page = 1, $limit = 10)
|
||||
@@ -73,4 +80,104 @@ class Gift extends Model
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取送礼记录
|
||||
*/
|
||||
|
||||
public function getGiftRecords($search_time,$where,$page_array)
|
||||
{
|
||||
// 获取需要查询的表
|
||||
$tables = GiftTableManager::getTablesByTimeRange(
|
||||
$search_time[0],
|
||||
$search_time[1]
|
||||
);
|
||||
//数组排序fa_vs_give_gift_202601 表明数字大的排在前面
|
||||
arsort($tables);
|
||||
if(empty($tables)){
|
||||
$tables[0] = "fa_vs_give_gift";
|
||||
}
|
||||
$gift_count = 0;
|
||||
$gift_total_price = 0;
|
||||
$gift_number = 0;
|
||||
$all_lists = []; // 存储所有查询结果
|
||||
$remaining_page_offset = ($page_array['page'] - 1) * $page_array['page_limit']; // 需要跳过的记录数
|
||||
$collected_count = 0; // 已收集的记录数
|
||||
if($tables){
|
||||
foreach ($tables as $table) {
|
||||
$table_name = substr($table, 3);//截取可查询的表名
|
||||
|
||||
// 获取当前表的总记录数
|
||||
$count = db::name($table_name)->where($where)->count();
|
||||
|
||||
if($count > 0){
|
||||
// 如果还需要跳过记录
|
||||
if($remaining_page_offset > 0){
|
||||
// 如果当前表的记录数大于需要跳过的记录数
|
||||
if($count > $remaining_page_offset){
|
||||
// 从当前表中获取所需数据,跳过前面的记录
|
||||
$table_lists = db::name($table_name)
|
||||
->where($where)
|
||||
->order('createtime', 'desc')
|
||||
->limit($remaining_page_offset, $page_array['page_limit'])
|
||||
->select();
|
||||
|
||||
// 添加到结果中
|
||||
foreach($table_lists as $item){
|
||||
if($collected_count < $page_array['page_limit']){
|
||||
$all_lists[] = $item;
|
||||
$collected_count++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$remaining_page_offset = 0; // 已经跳过所需的记录
|
||||
} else {
|
||||
// 当前表的所有记录都需要跳过
|
||||
$remaining_page_offset -= $count;
|
||||
}
|
||||
} else if($collected_count < $page_array['page_limit']) {
|
||||
// 如果不需要跳过记录,且还没有收集足够的数据
|
||||
$remaining_needed = $page_array['page_limit'] - $collected_count;
|
||||
|
||||
// 从当前表获取剩余所需的数据
|
||||
$table_lists = db::name($table_name)
|
||||
->where($where)
|
||||
->order('createtime', 'desc')
|
||||
->limit($remaining_needed)
|
||||
->select();
|
||||
|
||||
// 添加到结果中
|
||||
foreach($table_lists as $item){
|
||||
if($collected_count < $page_array['page_limit']){
|
||||
$all_lists[] = $item;
|
||||
$collected_count++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$total_price = db::name($table_name)->where($where)->sum('total_price');
|
||||
$number = db::name($table_name)->where($where)->sum('number');
|
||||
$gift_count += $count;
|
||||
$gift_total_price += $total_price;
|
||||
$gift_number += $number;
|
||||
|
||||
// 如果已经收集到足够数据,跳出循环
|
||||
if($collected_count >= $page_array['page_limit']){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$result = [
|
||||
'lists' => $all_lists,
|
||||
'count' => $gift_count,
|
||||
'total_price' => $gift_total_price,
|
||||
'number' => $gift_number,
|
||||
];
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
252
application/adminapi/model/Monster.php
Normal file
252
application/adminapi/model/Monster.php
Normal file
@@ -0,0 +1,252 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class Monster extends Model
|
||||
{
|
||||
//列表
|
||||
public function get_monster_list($order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
|
||||
$list = db::name('Monster')->order($order, $sort)->page($page, $limit)->select();
|
||||
$total_num = db::name('Monster')->sum('num');
|
||||
foreach ($list as $k => &$v) {
|
||||
$gift_info = db::name('vs_gift')->where('gid', $v['gid'])->find();
|
||||
$v['gift_name'] = $gift_info['gift_name'];
|
||||
$v['base_image'] = localpath_to_netpath($gift_info['base_image']);
|
||||
$v['gift_price'] = $gift_info['gift_price'];
|
||||
$v['rate'] = round(($v['num']/$total_num), 6) * 100;
|
||||
$v['rate'] .= '%';
|
||||
$v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
|
||||
$v['updatetime'] = date('Y-m-d H:i:s', $v['updatetime']);
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('Monster')->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//获取礼物列表
|
||||
public function get_gift_list(){
|
||||
$map = [];
|
||||
// $map[] = ['gid', 'not in', [36,37,38]];
|
||||
$map['type'] = ['=', 1];
|
||||
$map['is_show'] = ['=',1];
|
||||
$map['delete_time'] = ['=', 0];
|
||||
$list = db::name('vs_gift')->where($map)->order('gift_price asc')->select();
|
||||
$data = [];
|
||||
$data['count'] = db::name('vs_gift')->where($map)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
|
||||
|
||||
|
||||
}
|
||||
|
||||
//编辑
|
||||
public function edit_monster($data)
|
||||
{
|
||||
if (empty($data)) {
|
||||
return ['code' => 0, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$monster_info = db::name('Monster')->find($data['id']);
|
||||
if (empty($monster_info)) {
|
||||
return ['code' => 0, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$map = [];
|
||||
$map['gid'] = ['=', $data['gid']];
|
||||
// $map['type'] = ['=', 1];
|
||||
$map['is_show'] = ['=',1];
|
||||
$map['delete_time'] = ['=', 0];
|
||||
$gift_info = db::name('vs_gift')->where($map)->find();
|
||||
if(!$gift_info){
|
||||
return ['code' => 0, 'msg' => '配置礼物不存在', 'data' => null];
|
||||
}
|
||||
|
||||
if($monster_info['multiple'] * 10 != $gift_info['gift_price']){
|
||||
return ['code' => 0, 'msg' => '配置礼物的价格必须为倍数的10倍', 'data' => null];
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
$update_data = [];
|
||||
$update_data['type_name'] = $data['type_name'];
|
||||
if($data['multiple']){
|
||||
$update_data['multiple'] = $data['multiple'];
|
||||
}
|
||||
$update_data['gid'] = $data['gid'];
|
||||
$update_data['num'] = $data['num'];
|
||||
$update_data['updatetime'] = time();
|
||||
$reslut = db::name('Monster')->where(['id' => $data['id']])->update($update_data);
|
||||
if (!$reslut) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return ['code' => 1, 'msg' => '修改成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
dump($e);
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//获取信息
|
||||
public function get_monster_info($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$monster_info = db::name('Monster')->where(['id' => $id])->find();
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $monster_info];
|
||||
}
|
||||
|
||||
|
||||
//列表
|
||||
public function get_monster_multiple_list($order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
|
||||
$list = db::name('monster_multiple')->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('monster_multiple')->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//编辑
|
||||
public function edit_monster_multiple($data)
|
||||
{
|
||||
if (empty($data)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
$monster_info = db::name('monster_multiple')->find($data['id']);
|
||||
if (empty($monster_info)) {
|
||||
return ['code' => 201, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
$update_data = [];
|
||||
$update_data['multiple'] = $data['multiple'];
|
||||
$update_data['updatetime'] = time();
|
||||
$reslut = db::name('monster_multiple')->where(['id' => $data['id']])->update($update_data);
|
||||
if (!$reslut) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return ['code' => 1, 'msg' => '修改成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
dump($e);
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//获取信息
|
||||
public function get_monster_multiple_info($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
return ['code' => 0, 'msg' => '参数异常', 'data' => null];
|
||||
}
|
||||
$monster_info = db::name('monster_multiple')->where(['id' => $id])->find();
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $monster_info];
|
||||
}
|
||||
|
||||
|
||||
//列表
|
||||
public function get_monster_log($order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
|
||||
$list = db::name('monster_log')->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['type_name'] = '暂未开奖';
|
||||
$v['gid'] = 0;
|
||||
$v['gift_name'] = '';
|
||||
$v['base_image'] = '';
|
||||
$v['gift_price'] = 0;
|
||||
if($v['is_delete'] == 2){
|
||||
$gift_info = db::name('Monster')->alias('a')->join('vs_gift b', 'a.gid = b.gid')->field('b.gid,b.gift_name,b.base_image,b.gift_price,a.type_name')->where('a.type', $v['win_type'])->find();
|
||||
$v['gid'] = $gift_info['gid'];
|
||||
$v['gift_name'] = $gift_info['gift_name'];
|
||||
$v['base_image'] = localpath_to_netpath($gift_info['base_image']);
|
||||
$v['gift_price'] = $gift_info['gift_price'];
|
||||
$v['type_name'] = $gift_info['type_name'];
|
||||
$v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
|
||||
$v['updatetime'] = date('Y-m-d H:i:s', $v['updatetime']);
|
||||
$v['end_time'] = date('Y-m-d H:i:s', $v['end_time']);
|
||||
}
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('monster_log')->count();
|
||||
$data['list'] = $list;
|
||||
$totalRowData = db::name('monster_log')->field('count(1) as count,SUM(out_amount) as out_amount,SUM(in_amount) as in_amount')->find();
|
||||
unset($totalRowData['count']);
|
||||
$data['totalRow'] = $totalRowData;
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//列表
|
||||
public function get_user_monster_log($mid, $order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
|
||||
$list = db::name('user_monster_log')->where('mid', $mid)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$user_info = db::name('user')->where('id', $v['uid'])->field('id,nickname,avatar')->find();
|
||||
$v['nickname'] = $user_info['nickname'];
|
||||
$v['avatar'] = localpath_to_netpath($user_info['avatar']);
|
||||
$v['type_name'] = db::name('Monster')->where('type', $v['type'])->value('type_name');
|
||||
$v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
|
||||
$v['updatetime'] = date('Y-m-d H:i:s', $v['updatetime']);
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_monster_log')->where('mid', $mid)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//列表
|
||||
public function get_user_monster_win_log($mid, $order, $sort, $page = 1, $limit = 20)
|
||||
{
|
||||
|
||||
$list = db::name('user_monster_win_log')->where('mid', $mid)->order($order, $sort)->page($page, $limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$user_info = db::name('user')->where('id', $v['uid'])->field('id,nickname,avatar')->find();
|
||||
$v['nickname'] = $user_info['nickname'];
|
||||
$v['avatar'] = localpath_to_netpath($user_info['avatar']);
|
||||
$v['type_name'] = db::name('Monster')->where('type', $v['win_type'])->value('type_name');
|
||||
$gift_info = db::name('vs_gift')->where('gid', $v['win_gid'])->field('gid,gift_name,base_image,gift_price')->find();
|
||||
$v['gift_name'] = $gift_info['gift_name'];
|
||||
$v['base_image'] = localpath_to_netpath($gift_info['base_image']);
|
||||
$v['gift_price'] = $gift_info['gift_price'];
|
||||
$v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
|
||||
$v['updatetime'] = date('Y-m-d H:i:s', $v['updatetime']);
|
||||
}
|
||||
$data = [];
|
||||
$data['count'] = db::name('user_monster_win_log')->where('mid', $mid)->count();
|
||||
$data['list'] = $list;
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace app\adminapi\model;
|
||||
|
||||
use app\common\library\GiftTableManager;
|
||||
use think\Model;
|
||||
use think\Session;
|
||||
use think\Db;
|
||||
@@ -15,7 +16,7 @@ class Room extends Model
|
||||
|
||||
protected $name = 'vs_room';
|
||||
|
||||
public $relation_type = [1=>'真爱拍',2=>'友情拍'];
|
||||
public $relation_type = [1=>'真爱拍',2=>'亲密拍',3=>'互娱房'];
|
||||
public $room_status = [1=>'正常',2=>'封禁',3=>'关闭'];
|
||||
|
||||
|
||||
@@ -70,9 +71,28 @@ class Room extends Model
|
||||
/*
|
||||
* 查询房间流水
|
||||
*/
|
||||
// public function getRoomFlow($room_id,$stime='',$etime=''){
|
||||
// $give_where = [];
|
||||
// $give_where['room_id'] = $room_id;
|
||||
//// $give_where['from'] = ["in",[2,3,6]];
|
||||
//// $give_where['from'] = 2;
|
||||
// if(!empty($stime)){
|
||||
// $give_where['createtime'] = ['>=',strtotime($stime)];
|
||||
// }
|
||||
// if(!empty($etime)){
|
||||
// $give_where['createtime'] = ['<',strtotime($etime)];
|
||||
// }
|
||||
// if(!empty($stime) && !empty($etime)){
|
||||
//// $give_where['createtime'] = ['between',[strtotime($stime),strtotime($etime)]];
|
||||
// $give_where['createtime'] = [['>=',strtotime($stime)],['<',strtotime($etime)]];
|
||||
// }
|
||||
// $total_price = db::name('vs_guild_flow')->where($give_where)
|
||||
// ->sum('flow_price');
|
||||
// return $total_price;
|
||||
// }
|
||||
public function getRoomFlow($room_id,$stime='',$etime=''){
|
||||
$give_where = [];
|
||||
$give_where['from_id'] = $room_id;
|
||||
$give_where['from'] = $room_id;
|
||||
// $give_where['from'] = ["in",[2,3,6]];
|
||||
$give_where['from'] = 2;
|
||||
if(!empty($stime)){
|
||||
@@ -85,8 +105,23 @@ class Room extends Model
|
||||
// $give_where['createtime'] = ['between',[strtotime($stime),strtotime($etime)]];
|
||||
$give_where['createtime'] = [['>=',strtotime($stime)],['<',strtotime($etime)]];
|
||||
}
|
||||
$total_price = db::name('vs_give_gift')->where($give_where)
|
||||
->sum('total_price');
|
||||
$tables = GiftTableManager::getTablesByTimeRange(
|
||||
strtotime($stime),
|
||||
strtotime($etime)
|
||||
);
|
||||
$all_total_price =0;
|
||||
if($tables){
|
||||
foreach ($tables as $table_name){
|
||||
//表前缀
|
||||
$table_prefix = config('database.prefix');
|
||||
$table_name = str_replace($table_prefix, '', $table_name);
|
||||
$total_price = db::name($table_name)
|
||||
->where($give_where)
|
||||
->sum('total_price');
|
||||
$all_total_price += $total_price;
|
||||
}
|
||||
}
|
||||
$total_price = $all_total_price;
|
||||
return $total_price;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,8 @@ class Activities extends BaseCom
|
||||
$uid = input('uid',$this->uid);
|
||||
$permission_status = 1;
|
||||
//查询是否首充
|
||||
$is_first_charge = db::name('vs_user_money_log')->where('user_id',$uid)->where('change_type',2)->where('money_type',1)->where(['createtime'=>['>=',"1760666400"]])->count();
|
||||
// $is_first_charge = db::name('vs_user_money_log')->where('user_id',$uid)->where('change_type',2)->where('money_type',1)->where(['createtime'=>['>=',"1760666400"]])->count();
|
||||
$is_first_charge = db::name('user_coin_log')->where('user_id',$uid)->where('change_type',2)->count();
|
||||
$permission = DB::name('vs_activities_receive')->where(['activities_id'=>$activities_id,'user_id'=>$uid])->where(['createtime'=>['>=',"1760666400"]])->find();
|
||||
$system = request()->header('system');
|
||||
$app_version = request()->header('App-Version');
|
||||
@@ -313,7 +314,7 @@ class Activities extends BaseCom
|
||||
$uid = input('uid',$this->uid);
|
||||
$first_charge_permission = 1;
|
||||
//查询是否首充
|
||||
$is_first_charge = db::name('vs_user_money_log')->where('user_id',$uid)->where('change_type',2)->where('money_type',1)->where(['createtime'=>['>=',"1760666400"]])->count();
|
||||
$is_first_charge = db::name('user_coin_log')->where('user_id',$uid)->where('change_type',2)->count();
|
||||
$permission = DB::name('vs_activities_receive')->where(['activities_id'=>$activities_id,'user_id'=>$uid])->where(['createtime'=>['>=',"1760666400"]])->find();
|
||||
if($is_first_charge > 0){
|
||||
$first_charge_permission = 0;
|
||||
|
||||
@@ -48,4 +48,16 @@ class Banner extends controller
|
||||
$reslut = model('Banner')->banner_list($show_type);
|
||||
return V(1,'操作成功', $reslut);
|
||||
}
|
||||
|
||||
//平台客服获取接口
|
||||
public function app_customer_service()
|
||||
{
|
||||
$platform_customer_service = get_system_config_value('platform_customer_service');
|
||||
$user_id = model('User')->where('user_code', $platform_customer_service)->value('id');
|
||||
$reslut = [
|
||||
'user_id' => $user_id,
|
||||
'user_name' => "客服",
|
||||
];
|
||||
return V(1, '成功', $reslut);
|
||||
}
|
||||
}
|
||||
|
||||
101
application/api/controller/BarRoom.php
Normal file
101
application/api/controller/BarRoom.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Cache;
|
||||
use think\Db;
|
||||
|
||||
class BarRoom extends BaseCom
|
||||
{
|
||||
|
||||
//麦位时长列表
|
||||
public function get_pit_time_list(){
|
||||
$reslut = model('BarRoom')->get_pit_duration_list();
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//房间麦位时长设置
|
||||
public function set_pit_time(){
|
||||
$room_id = input('room_id', 0);
|
||||
$time = input('time', 0);
|
||||
$user_id = $this->uid;
|
||||
if (!$room_id || !$time) {
|
||||
return V(0, '参数错误');
|
||||
}
|
||||
//判断用户是否是主持
|
||||
$user_is_on_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id])->value('pit_number');
|
||||
if($user_is_on_pit != 9){
|
||||
return V(0, '没有权限');
|
||||
}
|
||||
$reslut = model('BarRoom')->set_pit_duration($room_id, $time);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//约Ta礼物详情
|
||||
public function get_gift_info_ta(){
|
||||
$room_id = input('room_id', 0);
|
||||
$to_user_id =input('to_user_id', 0);
|
||||
$reslut = model('BarRoom')->get_gift_info_ta($room_id, $to_user_id, $this->uid);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//撩TA
|
||||
public function liao_ta(){
|
||||
$room_id = input('room_id', 0);
|
||||
$to_user_id =input('to_user_id', 0);
|
||||
$user_id = $this->uid;
|
||||
$type = input('type', 0);
|
||||
if($type == 1){
|
||||
if($user_id == $to_user_id){
|
||||
return V(0, '不能撩自己');
|
||||
}
|
||||
$reslut = model('BarRoom')->liao_ta($room_id,$user_id,$to_user_id);
|
||||
}else{
|
||||
$reslut = model('BarRoom')->one_key_liao_ta($room_id,$user_id);
|
||||
}
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//约TA
|
||||
public function meeting_ta(){
|
||||
$key_name = "api:meeting:ta:" . $this->uid;
|
||||
redis_lock_exits($key_name);
|
||||
$room_id = input('room_id', 0);
|
||||
$user_id =input('user_id', 0);
|
||||
$gift_id =input('gift_id', 0);
|
||||
if(!$room_id || !$user_id || !$gift_id){
|
||||
redis_unlocks($key_name);
|
||||
return V(0, '参数错误');
|
||||
}
|
||||
//获取缓存
|
||||
$meet_user_id = Cache::get('meeting_user_id_'.$user_id);
|
||||
if($meet_user_id == $user_id){
|
||||
redis_unlocks($key_name);
|
||||
return V(0, '佳人有约!');
|
||||
}
|
||||
//设置缓存
|
||||
Cache::set('meeting_user_id_'.$user_id, $user_id, 20);
|
||||
|
||||
$reslut = model('BarRoom')->meeting_ta($this->uid,$room_id,$user_id,$gift_id);
|
||||
if($reslut['code'] != 1){
|
||||
//删除缓存
|
||||
Cache::rm('meeting_user_id_'.$user_id);
|
||||
}
|
||||
redis_unlocks($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//小黑屋列表
|
||||
public function black_room_list(){
|
||||
$room_id = input('room_id', 0);
|
||||
$reslut = model('BarRoom')->black_room_list($room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
@@ -40,13 +40,15 @@ class BlindBoxTurntable extends BaseCom
|
||||
$num = input('num',1);
|
||||
$heart_id = input('heart_id',0);
|
||||
$auction_id = input('auction_id',0);
|
||||
if(!in_array($gift_bag_id,[10,11,12])){
|
||||
if(!in_array($gift_bag_id,[10,11,12,61])){
|
||||
return v(0,'非法活动ID', null);
|
||||
}
|
||||
//删除字符串里所有的空格
|
||||
$gift_user_ids = preg_replace('/\s+/', '', $gift_user_ids);
|
||||
if($gift_bag_id==10){
|
||||
$reslut = model('BlindBoxTurntableGiftDrawWorldNew')->draw_gift($gift_bag_id, $user_id, $gift_user_ids,$num,$room_id,$heart_id,$auction_id);
|
||||
$reslut = model('api/BlindBoxTurntableGiftDrawWorldNew')->draw_gift($gift_bag_id, $user_id, $gift_user_ids,$num,$room_id,$heart_id,$auction_id);
|
||||
}else{
|
||||
$reslut = model('BlindBoxTurntableGiftDrawWorldNew')->draw_gift_drop_bag($gift_bag_id, $user_id,$num,$room_id);
|
||||
$reslut = model('api/BlindBoxTurntableGiftDrawWorldNew')->draw_gift_drop_bag($gift_bag_id, $user_id,$num,$room_id);
|
||||
}
|
||||
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
@@ -78,13 +80,13 @@ class BlindBoxTurntable extends BaseCom
|
||||
/*
|
||||
* 获取全服抽奖记录
|
||||
*/
|
||||
public function get_all_record(){
|
||||
$gift_bag_id = input('gift_bag_id',0);
|
||||
$page = input('page',1);
|
||||
$page_size = input('page_size',12);
|
||||
$reslut = model('BlindBoxTurntableGift')->get_all_record($gift_bag_id,$page,$page_size);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
// public function get_all_record(){
|
||||
// $gift_bag_id = input('gift_bag_id',0);
|
||||
// $page = input('page',1);
|
||||
// $page_size = input('page_size',12);
|
||||
// $reslut = model('BlindBoxTurntableGift')->get_all_record($gift_bag_id,$page,$page_size);
|
||||
// return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
// }
|
||||
/*
|
||||
* 巡乐会
|
||||
*/
|
||||
@@ -142,7 +144,8 @@ class BlindBoxTurntable extends BaseCom
|
||||
* 1.开启 2.关闭
|
||||
*/
|
||||
public function blind_box_status(){
|
||||
$reslut = model('BlindBoxTurntableGift')->blind_box_status();
|
||||
$user_id = $this->uid;
|
||||
$reslut = model('BlindBoxTurntableGift')->blind_box_status($user_id);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
@@ -147,701 +147,6 @@ class Ceshi extends Controllers
|
||||
return V(1, '成功', $reslut);
|
||||
}
|
||||
|
||||
//清空数据 禁用 慎用 !!!!!!
|
||||
//清空数据 禁用 慎用 !!!!!!
|
||||
//清空数据 禁用 慎用 !!!!!!
|
||||
public function qing_chu_data()
|
||||
{
|
||||
//ip
|
||||
$ip = request()->ip();
|
||||
//白名单
|
||||
$white_list = $this -> allowIp;
|
||||
if (!in_array($ip, $white_list)) {
|
||||
return V(301, '非法访问!');
|
||||
}
|
||||
$i = 0;
|
||||
$res = [];
|
||||
//开启事务
|
||||
Db::startTrans();
|
||||
// $reslut = db::name('admin')->where('username','<>', 'admin')->delete();
|
||||
// if($reslut){
|
||||
// $i ++ ;
|
||||
// }else{
|
||||
// //数组末尾添加元素
|
||||
// array_push($res, '管理员删除失败!');
|
||||
// }
|
||||
$reslut1 = db::name('admin_log')->where('id','<>', 1)->delete();
|
||||
if($reslut1){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '管理员日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut3 = db::name('block')->where('id','>', 0)->delete();
|
||||
if($reslut3){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '封禁表删除失败!');
|
||||
}
|
||||
|
||||
$reslut6 = db::name('sms')->where('id','>', 0)->delete();
|
||||
if($reslut6){
|
||||
$i ++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '短信发送记录删除失败!');
|
||||
}
|
||||
|
||||
$reslut7 = db::name('system_message')->where('id','>', 0)->delete();
|
||||
if($reslut7){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '系统消息删除失败!');
|
||||
}
|
||||
// $reslut8 = db::name('topic')->where('id','>', 0)->delete();
|
||||
// if($reslut8){
|
||||
// $i++ ;
|
||||
// }else{
|
||||
// //数组末尾添加元素
|
||||
// array_push($res, '话题删除失败!');
|
||||
// }
|
||||
|
||||
|
||||
$user = db::name('user')->where('id','>', 0)->select();
|
||||
// if($user){
|
||||
// foreach ($user as &$v){
|
||||
// if($v['id']){
|
||||
// $j = 0;
|
||||
// $data[$j] = [
|
||||
// 'UserID' => 'u'.$v['id'],
|
||||
// ];
|
||||
// }
|
||||
// // model('Tencent')->account_deletes($data);
|
||||
// }
|
||||
// }
|
||||
|
||||
$reslut9 = db::name('user')->where('id','>', 0)->delete();
|
||||
if($reslut9){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户删除失败!');
|
||||
}
|
||||
|
||||
|
||||
$reslut10 = db::name('user_album')->where('id','>', 0)->delete();
|
||||
if($reslut10){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户相册删除失败!');
|
||||
}
|
||||
|
||||
$reslut11 = db::name('user_album_image')->where('id','>', 0)->delete();
|
||||
if($reslut11){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户相册图片删除失败!');
|
||||
}
|
||||
|
||||
$reslut12 = db::name('user_auth')->where('id','>', 0)->delete();
|
||||
if($reslut12){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户实名删除失败!');
|
||||
}
|
||||
|
||||
$reslut13 = db::name('user_avatar_log')->where('id','>', 0)->delete();
|
||||
if($reslut13){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户头像修改记录删除失败!');
|
||||
}
|
||||
|
||||
$reslut14 = db::name('user_black')->where('id','>', 0)->delete();
|
||||
if($reslut14){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户黑名单删除失败!');
|
||||
}
|
||||
|
||||
$reslut141 = db::name('user_coin_transfer')->where('id','>', 0)->delete();
|
||||
if($reslut141){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户金币转让删除失败!');
|
||||
}
|
||||
|
||||
$reslut15 = db::name('user_data')->where('id','>', 0)->delete();
|
||||
if($reslut15){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户数据删除失败!');
|
||||
}
|
||||
$reslut16 = db::name('user_exchange')->where('id','>', 0)->delete();
|
||||
if($reslut16){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户积分兑换记录删除失败!');
|
||||
}
|
||||
$reslut17 = db::name('user_follow')->where('id','>', 0)->delete();
|
||||
if($reslut17){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户关注删除失败!');
|
||||
}
|
||||
$reslut18 = db::name('user_message')->where('id','>', 0)->delete();
|
||||
if($reslut18){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户消息删除失败!');
|
||||
}
|
||||
// $reslut19 = db::name('user_money_log')->where('id','>', 0)->delete();
|
||||
// if($reslut19){
|
||||
// $i++ ;
|
||||
// }else{
|
||||
// //数组末尾添加元素
|
||||
// array_push($res, '用户余额记录删除失败!');
|
||||
// }
|
||||
$reslut20 = db::name('user_token')->where('id','>', 0)->delete();
|
||||
if($reslut20){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户token删除失败!');
|
||||
}
|
||||
$reslut21 = db::name('user_visit_log')->where('id','>', 0)->delete();
|
||||
if($reslut21){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户访问记录删除失败!');
|
||||
}
|
||||
$reslut22 = db::name('user_wallet')->where('id','>', 0)->delete();
|
||||
if($reslut22){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户钱包删除失败!');
|
||||
}
|
||||
$reslut23 = db::name('user_zone')->where('id','>', 0)->delete();
|
||||
if($reslut23){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户空间删除失败!');
|
||||
}
|
||||
$reslut24 = db::name('user_zone_comment')->where('id','>', 0)->delete();
|
||||
if($reslut24){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户空间评论删除失败!');
|
||||
}
|
||||
$reslut25 = db::name('user_zone_like')->where('id','>', 0)->delete();
|
||||
if($reslut25){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户空间点赞删除失败!');
|
||||
}
|
||||
$reslut26 = db::name('user_zone_rewards')->where('id','>', 0)->delete();
|
||||
if($reslut26){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户空间打赏列表删除失败!');
|
||||
}
|
||||
$reslut261 = db::name('user_zone_topic')->where('id','>', 0)->delete();
|
||||
if($reslut261){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '动态话题关联删除失败!');
|
||||
}
|
||||
|
||||
$reslut262 = db::name('vs_activities_receive')->where('id','>', 0)->delete();
|
||||
if($reslut262){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '活动参加删除失败!');
|
||||
}
|
||||
|
||||
$reslut263 = db::name('vs_admin_recharge_log')->where('arid','>', 0)->delete();
|
||||
if($reslut263){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '后台充值删除失败!');
|
||||
}
|
||||
|
||||
$reslut27 = db::name('vs_gift_bag_receive_log')->where('id','>', 0)->delete();
|
||||
if($reslut27){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户礼物发放删除失败!');
|
||||
}
|
||||
$reslut28 = db::name('vs_give_gift')->where('id','>', 0)->delete();
|
||||
if($reslut28){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户送礼记录删除失败!');
|
||||
}
|
||||
|
||||
$reslut29 = db::name('vs_give_gift_ratio_log')->where('id','>', 0)->delete();
|
||||
if($reslut29){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户送礼当前利率记录删除失败!');
|
||||
}
|
||||
|
||||
//解散群
|
||||
$group = db::name('vs_guild')->select();
|
||||
foreach ($group as &$value){
|
||||
model('Tencent')->delete_group('g'.$value['id']);
|
||||
}
|
||||
$reslut30 = db::name('vs_guild')->where('id','>', 0)->delete();
|
||||
if($reslut30){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户工会删除失败!');
|
||||
}
|
||||
|
||||
$reslut31 = db::name('vs_guild_subsidy')->where('id','>', 0)->delete();
|
||||
if($reslut31){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户工会补贴删除失败!');
|
||||
}
|
||||
|
||||
$reslut32 = db::name('vs_guild_user')->where('id','>', 0)->delete();
|
||||
if($reslut32){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户工会用户删除失败!');
|
||||
}
|
||||
|
||||
$reslut33 = db::name('vs_guild_user_quit_log')->where('id','>', 0)->delete();
|
||||
if($reslut33){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户退出工会记录删除失败!');
|
||||
}
|
||||
|
||||
$reslut34 = db::name('vs_headline')->where('id','>', 0)->delete();
|
||||
if($reslut34){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '头条记录删除失败!');
|
||||
}
|
||||
|
||||
//删除腾讯房间
|
||||
$room = db::name('vs_room')->select();
|
||||
// foreach ($room as &$value){
|
||||
// // model('Tencent')->delete_group('room'.$value['id']);
|
||||
// }
|
||||
$reslut35 = db::name('vs_room')->where('id','>', 0)->delete();
|
||||
if($reslut35){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间删除失败!');
|
||||
}
|
||||
|
||||
$reslut36 = db::name('vs_room_auction')->where('auction_id','>', 0)->delete();
|
||||
if($reslut36){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间竞拍删除失败!');
|
||||
}
|
||||
|
||||
$reslut37 = db::name('vs_room_auction_bid_log')->where('id','>', 0)->delete();
|
||||
if($reslut37){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间竞拍记录删除失败!');
|
||||
}
|
||||
|
||||
$reslut371 = db::name('vs_room_auction_relation')->where('id','>', 0)->delete();
|
||||
if($reslut371){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户拍得关系删除失败!');
|
||||
}
|
||||
|
||||
$reslut372 = db::name('vs_room_auction_relation_top')->where('id','>', 0)->delete();
|
||||
if($reslut372){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '关系卡、位 置顶表删除失败!');
|
||||
}
|
||||
|
||||
$reslut373 = db::name('vs_room_background')->where('id','>', 2)->delete();
|
||||
if($reslut373){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间背景图片表删除失败!');
|
||||
}
|
||||
|
||||
$reslut38 = db::name('vs_room_black')->where('id','>', 0)->delete();
|
||||
if($reslut38){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间黑名单删除失败!');
|
||||
}
|
||||
|
||||
$reslut39 = db::name('vs_room_cp_movie')->where('cp_id','>', 0)->delete();
|
||||
if($reslut39){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, 'cp房间删除失败!');
|
||||
}
|
||||
|
||||
$reslut40 = db::name('vs_room_host')->where('id','>', 0)->delete();
|
||||
if($reslut40){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间主持删除失败!');
|
||||
}
|
||||
|
||||
$reslut41 = db::name('vs_room_operation_log')->where('id','>', 0)->delete();
|
||||
if($reslut41){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut42 = db::name('vs_room_pit')->where('id','>', 0)->delete();
|
||||
if($reslut42){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间坑位删除失败!');
|
||||
}
|
||||
|
||||
$reslut43 = db::name('vs_room_pit_apply')->where('id','>', 0)->delete();
|
||||
if($reslut43){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间坑位申请删除失败!');
|
||||
}
|
||||
|
||||
$reslut44 = db::name('vs_room_pit_apply_help')->where('id','>', 0)->delete();
|
||||
if($reslut44){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间坑位申请帮助删除失败!');
|
||||
}
|
||||
|
||||
$reslut45 = db::name('vs_room_pit_apply_help_gift')->where('id','>', 0)->delete();
|
||||
if($reslut45){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间坑位申请帮助礼物删除失败!');
|
||||
}
|
||||
|
||||
$reslut46 = db::name('vs_room_pit_simulate')->where('id','>', 0)->delete();
|
||||
if($reslut46){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间坑位模拟删除失败!');
|
||||
}
|
||||
|
||||
$reslut47 = db::name('vs_room_pk')->where('pk_id','>', 0)->delete();
|
||||
if($reslut47){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间pk删除失败!');
|
||||
}
|
||||
|
||||
$reslut48 = db::name('vs_room_song')->where('did','>', 0)->delete();
|
||||
if($reslut48){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间歌曲删除失败!');
|
||||
}
|
||||
|
||||
$reslut49 = db::name('vs_room_subsidy')->where('id','>', 0)->delete();
|
||||
if($reslut49){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间补贴删除失败!');
|
||||
}
|
||||
|
||||
$reslut50 = db::name('vs_room_user_charm')->where('id','>', 0)->delete();
|
||||
if($reslut50){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间用户魅力删除失败!');
|
||||
}
|
||||
|
||||
$reslut51 = db::name('vs_room_user_muted')->where('id','>', 0)->delete();
|
||||
if($reslut51){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间用户禁言删除失败!');
|
||||
}
|
||||
|
||||
$reslut52 = db::name('vs_room_visitor')->where('id','>', 0)->delete();
|
||||
if($reslut52){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间访客删除失败!');
|
||||
}
|
||||
|
||||
$reslut53 = db::name('vs_suggest')->where('id','>', 0)->delete();
|
||||
if($reslut53){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '建议删除失败!');
|
||||
}
|
||||
|
||||
$reslut54 = db::name('vs_user_daily_tasks')->where('id','>', 0)->delete();
|
||||
if($reslut54){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户日常任务删除失败!');
|
||||
}
|
||||
|
||||
$reslut55 = db::name('vs_user_decorate')->where('udid','>', 0)->delete();
|
||||
if($reslut55){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户装扮表删除失败!');
|
||||
}
|
||||
|
||||
$reslut56 = db::name('vs_user_decorate_log')->where('udid','>', 0)->delete();
|
||||
if($reslut56){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户装扮日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut57 = db::name('vs_user_exp_day')->where('id','>', 0)->delete();
|
||||
if($reslut57){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户每日经验删除失败!');
|
||||
}
|
||||
|
||||
$reslut58 = db::name('vs_user_gift_pack')->where('pid','>', 0)->delete();
|
||||
if($reslut58){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户礼物背包删除失败!');
|
||||
}
|
||||
|
||||
$reslut59 = db::name('vs_user_gift_pack_log')->where('id','>', 0)->delete();
|
||||
if($reslut59){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户礼物背包日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut60 = db::name('vs_user_inform')->where('id','>', 0)->delete();
|
||||
if($reslut60){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户举报删除失败!');
|
||||
}
|
||||
|
||||
$reslut61 = db::name('vs_user_invited')->where('id','>', 0)->delete();
|
||||
if($reslut61){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户邀请删除失败!');
|
||||
}
|
||||
|
||||
$reslut62 = db::name('vs_user_invited_income_log')->where('id','>', 0)->delete();
|
||||
if($reslut62){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户邀请收入日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut63 = db::name('vs_user_live_remind')->where('id','>', 0)->delete();
|
||||
if($reslut63){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户直播提醒删除失败!');
|
||||
}
|
||||
|
||||
$reslut64 = db::name('vs_user_money_log')->where('log_id','>', 0)->delete();
|
||||
if($reslut64){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户钱包日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut641 = db::name('vs_user_pk_close')->where('id','>', 0)->delete();
|
||||
if($reslut641){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户钱包日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut65 = db::name('vs_user_recharge')->where('rid','>', 0)->delete();
|
||||
if($reslut65){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户充值删除失败!');
|
||||
}
|
||||
|
||||
$reslut66 = db::name('vs_user_tasks_sign_in')->where('id','>', 0)->delete();
|
||||
if($reslut66){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户任务签到删除失败!');
|
||||
}
|
||||
|
||||
$reslut661 = db::name('vs_user_withdrawal')->where('wid','>', 0)->delete();
|
||||
if($reslut661){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户提现表删除失败!');
|
||||
}
|
||||
|
||||
$reslut662 = db::name('vs_user_zone_manjiujiang')->where('id','>', 0)->delete();
|
||||
if($reslut662){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户发动态满九张图表删除失败!');
|
||||
}
|
||||
|
||||
$reslut67 = db::name('vs_wealth_level_log')->where('id','>', 0)->delete();
|
||||
if($reslut67){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '财富等级日志删除失败!');
|
||||
}
|
||||
$reslut68 = db::name('vs_user_friending')->where('id','>', 0)->delete();
|
||||
if($reslut68){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户好友删除失败!');
|
||||
}
|
||||
$reslut69 = db::name('vs_user_friending_heart')->where('id','>', 0)->delete();
|
||||
if($reslut69){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '用户好友心跳删除失败!');
|
||||
}
|
||||
$reslut70 = db::name('vs_room_hot_value_log')->where('id','>', 0)->delete();
|
||||
if($reslut70){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间热度值日志删除失败!');
|
||||
}
|
||||
|
||||
$reslut71 = db::name('vs_blind_box_turntable_results_log')->where('id','>', 0)->delete();
|
||||
if($reslut71){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '盲盒转盘结果日志删除失败!');
|
||||
}
|
||||
$reslut72 = db::name('vs_blind_box_turntable_log')->where('id','>', 0)->delete();
|
||||
if($reslut72){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '盲盒转盘日志删除失败!');
|
||||
}
|
||||
$reslut73 = db::name('vs_room_pan_xlh')->where('id','>', 0)->delete();
|
||||
if($reslut73){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间寻乐会删除失败!');
|
||||
}
|
||||
$reslut74 = db::name('vs_room_pan_xlh_log')->where('id','>', 0)->delete();
|
||||
if($reslut74){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间寻乐会日志删除失败!');
|
||||
}
|
||||
$reslut75 = db::name('vs_room_pan')->where('id','>', 0)->delete();
|
||||
if($reslut75){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '房间盘删除失败!');
|
||||
}
|
||||
$reslut76 = db::name('vs_gift_bag_receive_pan_log')->where('id','>', 0)->delete();
|
||||
if($reslut76){
|
||||
$i++ ;
|
||||
}else{
|
||||
//数组末尾添加元素
|
||||
array_push($res, '礼物背包领取盘日志删除失败!');
|
||||
}
|
||||
|
||||
//数据提交
|
||||
db::commit();
|
||||
return V(1, '成功'.$i.'条数据!', $res);
|
||||
}
|
||||
|
||||
|
||||
//测试富文本消息
|
||||
public function test_rich_text(){
|
||||
|
||||
@@ -15,6 +15,7 @@ class Cron
|
||||
* 提现云账号订单状态查询
|
||||
* 签约房时间结束处理
|
||||
* 签约到期处理
|
||||
* 酒吧房间麦位时间结束处理
|
||||
*/
|
||||
public function PerformPerSecond()
|
||||
{
|
||||
@@ -36,8 +37,6 @@ class Cron
|
||||
|
||||
|
||||
|
||||
|
||||
//经业务调整 暂时不要了
|
||||
//每10秒执行
|
||||
public function TenSeconds()
|
||||
{
|
||||
@@ -95,6 +94,15 @@ class Cron
|
||||
$cron = new \app\cron\controller\RoomHourRanking();
|
||||
$cron->index();
|
||||
}
|
||||
//每日执行(每天23点59分执行)
|
||||
/*
|
||||
* 每日任务开始
|
||||
*
|
||||
*/
|
||||
public function DayTask(){
|
||||
$cron = new \app\cron\controller\AppTodayStatistical();
|
||||
$cron->index();
|
||||
}
|
||||
|
||||
//临时
|
||||
public function teset(){
|
||||
|
||||
@@ -22,7 +22,8 @@ class Decorate extends BaseCom
|
||||
public function get_type_list()
|
||||
{
|
||||
$have_hot = input('have_hot',0);
|
||||
$reslut = model('Decorate')->get_type_list($have_hot);
|
||||
$from = input('from',1);//来源:1 道具商城 2 个性装扮
|
||||
$reslut = model('Decorate')->get_type_list($have_hot,$from);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//获取装饰列表
|
||||
@@ -43,7 +44,7 @@ class Decorate extends BaseCom
|
||||
$data = [];
|
||||
$reslut = model('Decorate')->get_decorate_detail($did);
|
||||
//当前用户金币
|
||||
$user_coin = db::name('user_wallet')->where(['user_id' => $this->uid])->value('coin');
|
||||
$user_coin = db::name('user_wallet_coin')->where(['user_id' => $this->uid])->value('coin');
|
||||
$data['user_info']['user_id'] = $this->uid;
|
||||
$data['user_info']['user_coin'] = intval($user_coin);
|
||||
$data['decorate'] = $reslut['data'];
|
||||
@@ -55,7 +56,7 @@ class Decorate extends BaseCom
|
||||
$did = input('did', 0);
|
||||
$day = input('day', 1);
|
||||
$user_id = input('user_id', 0);
|
||||
$num = input('num', 0);
|
||||
$num = input('num', 1);
|
||||
$keyname = "api:Decorate:pay_decorate:uid:".$uid;
|
||||
redis_lock_exit($keyname);
|
||||
if($user_id){//购买装扮 赠送好友
|
||||
@@ -80,7 +81,9 @@ class Decorate extends BaseCom
|
||||
public function set_user_decorate(){
|
||||
$uid = $this->uid;
|
||||
$udid = input('udid', 0);
|
||||
$reslut = model('Decorate')->set_user_decorate($uid,$udid);
|
||||
$room_id = input('room_id', 0);
|
||||
$num = input('num', 1);
|
||||
$reslut = model('Decorate')->set_user_decorate($uid,$udid,$room_id,$num);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//取消装扮
|
||||
@@ -91,4 +94,14 @@ class Decorate extends BaseCom
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//房间热度卡使用
|
||||
public function room_hot_card(){
|
||||
$uid = $this->uid;
|
||||
$udid = input('udid', 0);
|
||||
$room_id = input('room_id', 0);
|
||||
$num = input('num', 1);
|
||||
$reslut = model('Decorate')->room_hot_card($uid,$udid,$room_id,$num);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,10 @@ class Gift extends BaseCom
|
||||
//获取礼物标签列表
|
||||
public function get_gift_label()
|
||||
{
|
||||
$reslut = model('Gift')->get_gift_label();
|
||||
$no_label = input('no_label','');
|
||||
$no_label = explode(',',$no_label);
|
||||
$type = input('type',1);
|
||||
$reslut = model('Gift')->get_gift_label($type,$no_label);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
48
application/api/controller/GiftNew.php
Normal file
48
application/api/controller/GiftNew.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
|
||||
class GiftNew extends BaseCom
|
||||
{
|
||||
|
||||
/*
|
||||
* 获取礼物列表
|
||||
* @param int $label 礼物标签
|
||||
* @param int $type 类型:1-房间送礼礼物,2-排麦设置插麦礼物,3-拍卖位选择拍卖礼物,4-歌手添加歌单礼物,5-动态打赏礼物
|
||||
* @return array
|
||||
*/
|
||||
public function get_gift_list()
|
||||
{
|
||||
$key_name = "api:gift_new:get_gift_list:" . $this->uid;
|
||||
redis_lock_exits($key_name);
|
||||
$label = input('label', 0);
|
||||
$type = input('type');
|
||||
if (empty($type)) {
|
||||
return V(0, 'type参数错误');
|
||||
}
|
||||
$reslut = model('GiftNew')->get_gift_list($this->uid, $type, $label);
|
||||
redis_unlocks($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
/*
|
||||
* 酒吧房-自定义礼物设置
|
||||
*/
|
||||
public function set_custom_gift(){
|
||||
$gift_id = input('gift_id', 0);
|
||||
$room_id = input('room_id', 0);
|
||||
$gift_remark_name = input('gift_remark_name', '');
|
||||
$reslut = model('GiftNew')->set_custom_gift($this->uid, $gift_id, $room_id, $gift_remark_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
/*
|
||||
* 获取自定义礼物列表
|
||||
*/
|
||||
public function get_custom_gift_list(){
|
||||
$user_id = input('user_id', 0); //收礼人用户Id
|
||||
$reslut = model('GiftNew')->get_custom_gift_list($user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
@@ -192,7 +192,8 @@ class Guild extends BaseCom
|
||||
$guild_id = input('guild_id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 20);
|
||||
$reslut = model('Guild')->get_guild_user_list($guild_id,$uid,$page,$page_limit);
|
||||
$seach = input('search', '');
|
||||
$reslut = model('Guild')->get_guild_user_list($guild_id,$uid,$page,$page_limit,$seach);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
|
||||
}
|
||||
|
||||
@@ -33,11 +33,11 @@ class Login extends Controller
|
||||
{
|
||||
$user_name = input('user_login', '');
|
||||
$password = input('password', '');
|
||||
$system = input('system','');
|
||||
$system = input('system');
|
||||
if(empty($system)){
|
||||
$system = request()->header('system');
|
||||
}
|
||||
$login_device = input('deviceId','');
|
||||
$login_device = input('deviceId');
|
||||
if(empty($login_device)){
|
||||
$login_device = request()->header('deviceId');
|
||||
}
|
||||
@@ -56,11 +56,11 @@ class Login extends Controller
|
||||
*/
|
||||
public function phone_code(){
|
||||
|
||||
$system = input('system','');
|
||||
$system = input('system');
|
||||
if(empty($system)){
|
||||
$system = request()->header('system');
|
||||
}
|
||||
$login_device = input('deviceId','');
|
||||
$login_device = input('deviceId');
|
||||
if(empty($login_device)){
|
||||
$login_device = request()->header('deviceId');
|
||||
}
|
||||
@@ -95,11 +95,11 @@ class Login extends Controller
|
||||
public function one_click_login()
|
||||
{
|
||||
$loginToken = input('login_token', '');
|
||||
$system = input('system','');
|
||||
$system = input('system');
|
||||
if(empty($system)){
|
||||
$system = request()->header('system');
|
||||
}
|
||||
$login_device = input('deviceId','');
|
||||
$login_device = input('deviceId');
|
||||
if(empty($login_device)){
|
||||
$login_device = request()->header('deviceId');
|
||||
}
|
||||
@@ -116,10 +116,17 @@ class Login extends Controller
|
||||
}
|
||||
//检测是否注销过
|
||||
$config_time = get_system_config_value('cancel_no_login');
|
||||
$is_del = db::name('user')->where(['mobile' => $mobile,'delete_time' => ['<>', 0]])->find();
|
||||
if ($is_del) {
|
||||
if (time() - $is_del['delete_time'] < $config_time * 24 * 3600) {//30天内注销过
|
||||
return V(0, '注销30天内,不可操作。');
|
||||
$is_del = db::name('user')->where(['mobile' => $mobile,'delete_time' => ['<>', 0]])->order('delete_time', 'desc')->find();
|
||||
|
||||
//获取手机号绑定的账号数
|
||||
$count = db::name('user')->where(['mobile' => $mobile])->count();
|
||||
//获取注销的账号数
|
||||
$count_del = db::name('user')->where(['mobile' => $mobile,'delete_time' => ['<>', 0]])->count();
|
||||
if ($count == $count_del) {
|
||||
if ($is_del) {
|
||||
if (time() - $is_del['delete_time'] < $config_time * 24 * 3600) {//30天内注销过
|
||||
return V(0, '注销30天内,不可操作。');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,8 +142,8 @@ class Login extends Controller
|
||||
public function multi_account_login()
|
||||
{
|
||||
$user_name = input('user_login');
|
||||
$system = input('system','');
|
||||
$login_device = input('deviceId','');
|
||||
$system = input('system');
|
||||
$login_device = input('deviceId');
|
||||
if(empty($login_device)){
|
||||
$login_device = request()->header('deviceId');
|
||||
}
|
||||
@@ -154,11 +161,11 @@ class Login extends Controller
|
||||
public function wechatLogin()
|
||||
{
|
||||
$code = input('code');
|
||||
$system = input('system','');
|
||||
$system = input('system');
|
||||
if(empty($system)){
|
||||
$system = request()->header('system');
|
||||
}
|
||||
$login_device = input('deviceId','');
|
||||
$login_device = input('deviceId');
|
||||
if(empty($login_device)){
|
||||
$login_device = request()->header('deviceId');
|
||||
}
|
||||
@@ -254,11 +261,11 @@ class Login extends Controller
|
||||
public function aliLogin()
|
||||
{
|
||||
$authCode = input('auth_code');
|
||||
$system = input('system','');
|
||||
$system = input('system');
|
||||
if(empty($system)){
|
||||
$system = request()->header('system');
|
||||
}
|
||||
$login_device = input('deviceId','');
|
||||
$login_device = input('deviceId');
|
||||
if(empty($login_device)){
|
||||
$login_device = request()->header('deviceId');
|
||||
}
|
||||
@@ -306,11 +313,11 @@ class Login extends Controller
|
||||
*/
|
||||
public function iosLogin()
|
||||
{
|
||||
$system = input('system','');
|
||||
$system = input('system');
|
||||
if(empty($system)){
|
||||
$system = request()->header('system');
|
||||
}
|
||||
$login_device = input('deviceId','');
|
||||
$login_device = input('deviceId');
|
||||
if(empty($login_device)){
|
||||
$login_device = request()->header('deviceId');
|
||||
}
|
||||
@@ -373,11 +380,11 @@ class Login extends Controller
|
||||
//注销
|
||||
public function cancel()
|
||||
{
|
||||
$system = input('system','');
|
||||
$system = input('system');
|
||||
if(empty($system)){
|
||||
$system = request()->header('system');
|
||||
}
|
||||
$login_device = input('deviceId','');
|
||||
$login_device = input('deviceId');
|
||||
if(empty($login_device)){
|
||||
$login_device = request()->header('deviceId');
|
||||
}
|
||||
|
||||
109
application/api/controller/Monster.php
Normal file
109
application/api/controller/Monster.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 活动:
|
||||
* 1.首充好礼
|
||||
*
|
||||
*/
|
||||
class Monster extends BaseCom
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
//允许跨域
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
}
|
||||
|
||||
|
||||
//选择金币列表
|
||||
public function choice_gold_list(){
|
||||
$reslut = model('Monster')->choice_gold_list();
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
|
||||
}
|
||||
//游戏详情
|
||||
public function get_monster_info(){
|
||||
$uid = $this->uid;
|
||||
$reslut = model('Monster')->get_monster_info($uid);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//生成/结算喂养怪兽
|
||||
public function create_monster_log(){
|
||||
$uid = $this->uid;
|
||||
$key_name = "api:Monster:create_monster_log";
|
||||
redis_lock_exit($key_name);
|
||||
$reslut = model('Monster')->create_monster_log();
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//喂养怪兽
|
||||
public function open_beat_monster(){
|
||||
$uid = $this->uid;
|
||||
$rid = input('rid', 0);
|
||||
$type = input('type', 0);
|
||||
$num = input('num', 0);
|
||||
$key_name = "api:Monster:open_beat_monster:uid:".$uid;
|
||||
redis_lock_exit($key_name);
|
||||
$reslut = model('Monster')->open_beat_monster($uid, $rid, $type, $num);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
|
||||
}
|
||||
|
||||
//规则
|
||||
public function get_monster_note(){
|
||||
$reslut = model('Monster')->get_monster_note();
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//奖池
|
||||
public function get_monster_box_list(){
|
||||
$reslut = model('Monster')->get_monster_box_list();
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
|
||||
}
|
||||
|
||||
//开奖记录
|
||||
public function get_monster_log(){
|
||||
$uid = $this->uid;
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 20);
|
||||
$reslut = model('Monster')->get_monster_log($uid, $page, $page_limit);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//我的记录
|
||||
public function get_user_monster_log(){
|
||||
$uid = $this->uid;
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 20);
|
||||
$reslut = model('Monster')->get_user_monster_log($uid, $page, $page_limit);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//中奖次数榜单
|
||||
public function get_monster_winner_num_list(){
|
||||
$uid = $this->uid;
|
||||
$time = input('time', 1);
|
||||
$reslut = model('Monster')->get_monster_winner_num_list($uid, $time);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
|
||||
}
|
||||
|
||||
//设置房间期数开关
|
||||
public function operate_room_monster_show_status(){
|
||||
$uid = $this->uid;
|
||||
$rid = input('rid', 0);
|
||||
$is_show_monster_push = input('is_show_monster_push', 1);
|
||||
$reslut = model('Monster')->operate_room_monster_show_status($uid, $rid, $is_show_monster_push);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ class Nobility extends BaseCom
|
||||
public function buy_nobility(){
|
||||
$lid = input('lid', 0);
|
||||
$uid = input('uid', $this->uid);
|
||||
$reslut = model('Nobility')->buyNobility($uid,$lid);
|
||||
$reslut = model('Nobility')->buyNobility($uid,$lid,$is_send);
|
||||
return V($reslut['code'],$reslut['msg'], null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class Payment extends Controller
|
||||
* APP支付
|
||||
*/
|
||||
public function app_pay() {
|
||||
$type = input('type', 0); //1-微信 2-支付宝 4-通联支付宝 5-通联微信 6-苹果支付
|
||||
$type = input('type', 0); //1-微信 2-支付宝 4-通联支付宝 5-通联微信 6-苹果支付 7-JSAPI支付
|
||||
$user_id = input('user_id', 0);
|
||||
$money = input('money', 0);
|
||||
$coin = input('coin', 0);
|
||||
@@ -430,4 +430,60 @@ class Payment extends Controller
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//微信JSAPI支付
|
||||
public function pay_jsapi(){
|
||||
$user_code = input('user_code');
|
||||
$money = input('money', 0);
|
||||
$coin = $money * get_system_config_value('rmb_coin_ratio');
|
||||
|
||||
if (!$user_code) {
|
||||
return V(0, '请选择充值用户', null);
|
||||
}
|
||||
if (!is_numeric($money) || floor($money) != $money || $money <= 0 || $money > 5000) {
|
||||
return V(0, '请选择正确的充值金额', null);
|
||||
}
|
||||
|
||||
$user_id = db::name('user')->where(["user_code" => $user_code])->value('id');
|
||||
|
||||
//获取用户的手机号
|
||||
$user_phone = db::name('user')->where(["id" => $user_id])->value('mobile');
|
||||
if(!$user_phone){
|
||||
return V(0, '请先绑定手机号!', null);
|
||||
}
|
||||
//获取用户的实名信息
|
||||
$real_name = db::name('user_auth')->where(["mobile" => $user_phone,'is_real' => 1])->find();
|
||||
if(!$real_name){
|
||||
return V(0, '请先实名认证', null);
|
||||
}
|
||||
//获取用户的年龄
|
||||
if(!getAgeId($real_name['card_id'])){
|
||||
return V(0, '未成年不可充值!', null);
|
||||
}
|
||||
|
||||
$title = '充值到app用户'. $user_code ."余额!";
|
||||
|
||||
$order_number = $this->createOrderSn();
|
||||
$data['order_sn'] = $order_number;
|
||||
$data['money'] = $money;
|
||||
$data['user_id'] = $user_id;
|
||||
$data['pay_type'] = 7; //JSAPI支付
|
||||
$data['coin'] = $coin;
|
||||
$data['createtime'] = time();
|
||||
$data['remarke'] = $title;
|
||||
|
||||
$re = db::name('vs_user_recharge')->insert($data);
|
||||
if (!$re) {
|
||||
return V(0, '充值失败', null);
|
||||
}
|
||||
|
||||
//引用微信sdk
|
||||
Loader::import('WxPay.WxPay', EXTEND_PATH, '.php');
|
||||
$wx = new \WxPay();
|
||||
$result = $wx->WxPayJsapi($data);
|
||||
return V(1, 'app支付', $result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -40,14 +40,14 @@ class Ranking extends BaseCom
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//公会榜
|
||||
//公会榜【废弃】
|
||||
public function guild_ranking()
|
||||
{
|
||||
$reslut = $this->model->guild_ranking();
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//真爱榜
|
||||
//真爱榜【心动榜】
|
||||
public function love_ranking()
|
||||
{
|
||||
$reslut = $this->model->love_rankings();
|
||||
|
||||
@@ -116,4 +116,12 @@ class Redpacket extends BaseCom
|
||||
}
|
||||
return V(1, '获取成功', $result);
|
||||
}
|
||||
|
||||
//红包配置信息
|
||||
public function appConfig(){
|
||||
|
||||
$result['red_packet_min_amount'] = get_system_config_value('red_packet_min_amount') ?? 0;
|
||||
$result['red_packet_fee'] = get_system_config_value('red_packet_fee') ?? 0;
|
||||
return V(1, '获取成功', $result);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ class Room extends BaseCom
|
||||
$room_name = input('room_name', '');
|
||||
$room_cover = input('room_cover', '');
|
||||
$room_intro = input('room_intro', '');
|
||||
$password = input('room_password');
|
||||
|
||||
$signCount = db::name('vs_user_sign')->where(['parent_user_id' => $this->uid ,'end_time' => ['>', time()]] )->count();
|
||||
$num = get_system_config_value('sign_num_per_room');
|
||||
@@ -25,7 +26,7 @@ class Room extends BaseCom
|
||||
|
||||
$key_name = "api:room:user_create_room:" . $this->uid;
|
||||
redis_lock_exits($key_name);
|
||||
$reslut = model('Room')->user_create_room($this->uid, $room_name, $room_cover, $room_intro,0,0);
|
||||
$reslut = model('Room')->user_create_room($this->uid, $room_name, $room_cover, $room_intro,0,0,$password);
|
||||
redis_unlock($key_name);
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
@@ -39,8 +40,12 @@ class Room extends BaseCom
|
||||
$room_cover = input('room_cover', '');
|
||||
$room_intro = input('room_intro', '');
|
||||
$room_background_id = input('room_background', '');
|
||||
$password = input('room_password');
|
||||
if($room_id <= 0){
|
||||
return ['code' => 0, 'msg' => '房间不存在', 'data' => null];
|
||||
}
|
||||
|
||||
$reslut = model('Room')->user_edit_room($this->uid, $room_id, $room_name, $room_cover, $room_intro,$room_background_id);
|
||||
$reslut = model('Room')->user_edit_room($this->uid, $room_id, $room_name, $room_cover, $room_intro,$room_background_id,$password);
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -113,7 +118,7 @@ class Room extends BaseCom
|
||||
$end_time = input('end_time', '');
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 15);
|
||||
$reslut = model('Room')->room_turnover_detail($room_id, $start_time, $end_time, $page, $page_limit);
|
||||
$reslut = model('Room')->room_turnover_detail($this->uid, $room_id, $start_time, $end_time, $page, $page_limit);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
@@ -122,6 +127,9 @@ class Room extends BaseCom
|
||||
public function before_join_room_check()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间不存在');
|
||||
}
|
||||
$reslut = model('Room')->before_join_room_check($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -133,24 +141,32 @@ class Room extends BaseCom
|
||||
public function join_room()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$password = input('password', '');
|
||||
if($room_id == 0){
|
||||
return V(0, '房间不存在');
|
||||
}
|
||||
$password = input('room_password');
|
||||
|
||||
//检测系统是否维护中
|
||||
$is_maintenance = get_system_config_value('is_maintenance');
|
||||
//获取内侧账号
|
||||
$inside_uid = get_system_config_value('inside_uid');
|
||||
//先转为数组
|
||||
$inside_uid = explode(',',$inside_uid);
|
||||
if($inside_uid && $is_maintenance == 3){
|
||||
//排除小房间
|
||||
$room_type = db::name('vs_room')->where('id',$room_id)->value('type_id');
|
||||
if($room_type != 6){
|
||||
//先转为数组 不是内侧账号 返回301
|
||||
$inside_uid = explode(',',$inside_uid);
|
||||
//room id = 9 是武松打鼠的房间 暂定为内侧房间
|
||||
if(in_array($this->uid,$inside_uid) && $room_id != 9 && $room_id != 37){
|
||||
return V(0, '不可访问');
|
||||
}
|
||||
}
|
||||
}
|
||||
//内侧账号 才可进入
|
||||
//暂定为内侧房间
|
||||
if(!in_array($this->uid,$inside_uid) && ($room_id == 9 || $room_id == 37 || $room_id == 8)){
|
||||
return V(0, '内侧房间,不可访问');
|
||||
}
|
||||
|
||||
$reslut = model('Room')->join_room($this->uid, $room_id, $password);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
@@ -160,6 +176,9 @@ class Room extends BaseCom
|
||||
public function quit_room()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if(!$room_id){
|
||||
return V(0, '房间不存在');
|
||||
}
|
||||
$user_id = input('user_id', 0);
|
||||
$reslut = model('Room')->quit_room($this->uid, $room_id,$user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
@@ -175,29 +194,6 @@ class Room extends BaseCom
|
||||
}
|
||||
|
||||
|
||||
//直播间送礼
|
||||
public function room_give_gift()
|
||||
{
|
||||
$key_name = "api:room:gift:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$room_id = input('room_id', 0);
|
||||
$gift_id = input('gift_id', 0);
|
||||
$gift_num = input('gift_num', 1);
|
||||
$to_uid = input('to_uid', 0);//收礼人ID,逗号隔开的字符串
|
||||
$type = input('type', 1);//1金币购买 2送背包礼物
|
||||
$pit_number = input('pit_number', 0);
|
||||
$heart_id = input('heart_id', 0);
|
||||
|
||||
$pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
|
||||
if($gift_id == $pool_gift_id){
|
||||
$reslut = model('Lottery')->gift($this->uid, $to_uid, $gift_id, $room_id,$gift_num);
|
||||
}else{
|
||||
$reslut = model('Room')->room_gift($this->uid, $to_uid, $gift_id, $gift_num, $type, $room_id, $pit_number,$heart_id);
|
||||
}
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//房间送礼 背包一键全清
|
||||
public function room_gift_all_clear()
|
||||
{
|
||||
@@ -225,6 +221,9 @@ class Room extends BaseCom
|
||||
public function room_online_list()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if(!$room_id){
|
||||
return V(0, '房间不存在');
|
||||
}
|
||||
$page = input('page', 1);
|
||||
$limit = input('limit', 15);
|
||||
$reslut = model('Room')->room_online_list($room_id, $page, $limit);
|
||||
@@ -235,6 +234,9 @@ class Room extends BaseCom
|
||||
public function room_user_home()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if(!$room_id){
|
||||
return V(0, '房间不存在');
|
||||
}
|
||||
$user_id = input('user_id', 0);
|
||||
$reslut = model('Room')->room_user_home($this->uid,$room_id, $user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
@@ -255,6 +257,8 @@ class Room extends BaseCom
|
||||
$reslut = model('HeadLine')->current_headline();
|
||||
return V(1, '成功', $reslut);
|
||||
}
|
||||
|
||||
|
||||
//发(抢)头条
|
||||
public function send_headline()
|
||||
{
|
||||
@@ -305,11 +309,77 @@ class Room extends BaseCom
|
||||
}
|
||||
|
||||
|
||||
//房间类型列表
|
||||
public function room_type_list()
|
||||
{
|
||||
$http = get_system_config_value("web_site");
|
||||
//1-交友,2-拍卖,7-互娱,8-交友(不要了),9-点唱,10-签约,11-酒吧房
|
||||
$reslut = [
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => '交友',
|
||||
'icon' => $http.'/data/avatar/head_pic.png',
|
||||
'sort' => 1,
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => '拍卖',
|
||||
'icon' => $http.'/data/avatar/head_pic.png',
|
||||
'sort' => 2,
|
||||
],
|
||||
[
|
||||
'id' => 7,
|
||||
'name' => '互娱',
|
||||
'icon' => $http.'/data/avatar/head_pic.png',
|
||||
'sort' => 3,
|
||||
],
|
||||
[
|
||||
'id' => 9,
|
||||
'name' => '点唱',
|
||||
'icon' => $http.'/data/avatar/head_pic.png',
|
||||
'sort' => 4,
|
||||
],
|
||||
[
|
||||
'id' => 10,
|
||||
'name' => '签约',
|
||||
'icon' => $http.'/data/avatar/head_pic.png',
|
||||
'sort' => 5,
|
||||
],
|
||||
[
|
||||
'id' => 11,
|
||||
'name' => '酒吧',
|
||||
'icon' => $http.'/data/avatar/head_pic.png',
|
||||
'sort' => 6,
|
||||
],
|
||||
[
|
||||
'id' => 99,
|
||||
'name' => '练歌',
|
||||
'icon' => $http.'/data/avatar/head_pic.png',
|
||||
'sort' => 7,
|
||||
],
|
||||
];
|
||||
//根据sort 排序
|
||||
usort($reslut, function ($a, $b) {
|
||||
return $a['sort'] - $b['sort'];
|
||||
});
|
||||
return V(1, '成功', $reslut);
|
||||
}
|
||||
|
||||
|
||||
//修改房间类型
|
||||
public function change_room_type()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$type = input('type', 1);//1-交友,2-拍卖,7-互娱,8-交友(不要了),9-点唱,10-签约
|
||||
$type = input('type', 1);//1-交友,2-拍卖,7-互娱,9-点唱,10-签约,11-酒吧房,99-练歌
|
||||
|
||||
if(!$room_id || !$type){
|
||||
return V(0, '参数错误');
|
||||
}
|
||||
$owner = db::name('vs_room')->where(['id' => $room_id, 'user_id' => $this->uid])->field('id')->find();
|
||||
$host = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $this->uid,'delete_time' => null])->find();
|
||||
if(!$owner && !$host){
|
||||
return V(0, '没有权限操作');
|
||||
}
|
||||
$reslut = model('Room')->change_room_type($this->uid, $room_id, $type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -335,6 +405,9 @@ class Room extends BaseCom
|
||||
public function room_info()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if(!$room_id){
|
||||
return V(0, '房间不存在');
|
||||
}
|
||||
$reslut = model('Room')->room_info($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -447,22 +520,7 @@ class Room extends BaseCom
|
||||
|
||||
|
||||
//用户重连
|
||||
public function user_reconnect()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$reslut = model('Room')->user_reconnect($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//用户在房间内切后台保留机制
|
||||
public function user_in_room_background()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$type = input('type', 1);//1-切后台,2-切前台
|
||||
$reslut = model('Room')->user_in_room_background($this->uid, $room_id,$type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//给用户发送房间内消息
|
||||
public function send_room_message()
|
||||
@@ -481,4 +539,32 @@ class Room extends BaseCom
|
||||
$reslut = model('Room')->task_jump_room_recommend($task_id);
|
||||
return V(1, '成功', $reslut);
|
||||
}
|
||||
|
||||
//设置房间的营业时间
|
||||
public function set_room_business_time()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$start_time = input('start_time', '00:00:00');
|
||||
$end_time = input('end_time', '00:00:00');
|
||||
|
||||
if(!$room_id){
|
||||
return V(0, '参数错误');
|
||||
}
|
||||
$reslut = model('Room')->set_room_business_time($this->uid, $room_id, $start_time, $end_time);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//设置房间密码【改到编辑房间】暂时不用了
|
||||
public function set_room_password()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$password = input('password', '');
|
||||
if(!$room_id){
|
||||
return V(0, '参数错误');
|
||||
}
|
||||
|
||||
$reslut = model('Room')->set_room_password($this->uid, $room_id, $password);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ class RoomAuction extends BaseCom
|
||||
//房间关系列表
|
||||
public function room_relation_list()
|
||||
{
|
||||
$type_id = input('type');//1真爱拍 2 亲密拍
|
||||
$type_id = input('type');//1真爱拍 2 亲密拍 3互娱
|
||||
$reslut = model('RoomAuction')->room_relation_list($type_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -68,11 +68,12 @@ class RoomAuction extends BaseCom
|
||||
$gift_id = input('gift_id');
|
||||
$num = input('num');
|
||||
$type = input('type',1);//1金币购买 2送背包礼物
|
||||
$gift_bag_id = input('gift_bag_id',0);
|
||||
$pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
|
||||
if($gift_id == $pool_gift_id){
|
||||
return V(0, '此礼物不能进行此操作');
|
||||
}
|
||||
$reslut = model('RoomAuction')->room_auction_join($auction_id,$user_id,$gift_id,$num,$type);
|
||||
$reslut = model('RoomAuction')->room_auction_join($auction_id,$user_id,$gift_id,$num,$type,$gift_bag_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,33 +7,46 @@ use think\Db;
|
||||
|
||||
class RoomPit extends BaseCom
|
||||
{
|
||||
|
||||
//申请上麦
|
||||
public function apply_pit()
|
||||
{
|
||||
$key_name = "api:room:apply_pit:" . $this->uid;
|
||||
|
||||
$room_id = input('room_id', 0);
|
||||
$pit_number = input('pit_number', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$res = model('Room')->get_room_label($room_id);
|
||||
if($res['code'] != 1){
|
||||
$pit_number = input('pit_number', 0);
|
||||
|
||||
$key_name = "api:room:apply_pit:" . $this->uid;
|
||||
redis_lock_exits($key_name);
|
||||
|
||||
$room_type = model('Room')->get_room_type($room_id);
|
||||
if($room_type == 0){
|
||||
return V(0, '房间不存在', null);
|
||||
}
|
||||
|
||||
$room_label = $res['data']['label_id'];
|
||||
$room_type = $res['data']['type_id'];
|
||||
redis_lock_exits($key_name);
|
||||
if(($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8))|| $room_type == 2 || $room_type == 7 || $room_type == 9 || $room_type == 10){
|
||||
$reslut = model('RoomPit')->apply_pit($this->uid, $room_id,$pit_number);
|
||||
}elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8)){
|
||||
$gift_id = input('gift_id', 0);//酒吧房上其他麦需要带礼物
|
||||
if($room_type == 2){
|
||||
$reslut = model('RoomSong')->apply_kpit($this->uid, $room_id,$pit_number);
|
||||
}elseif($room_type == 11){
|
||||
//9麦位,10麦位 不做$gift_id校验
|
||||
if($pit_number != 9 && $pit_number != 10){
|
||||
//有麦位就是换麦
|
||||
$pit_infos = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $this->uid])->value('pit_number')??0;
|
||||
if($pit_infos == 10){
|
||||
return V(0, '此房间不允许嘉宾直接换麦', null);
|
||||
}
|
||||
if($gift_id == 0 && $pit_infos == 0){
|
||||
return V(0, '请选择礼物', null);
|
||||
}
|
||||
}
|
||||
$type = input('type', 0);//2-抱麦后的上麦
|
||||
$reslut = model('RoomPit')->apply_pit($this->uid, $room_id, $pit_number,$gift_id,$type);
|
||||
}else{
|
||||
redis_unlocks($key_name);
|
||||
return V(0, '房间不存在', null);
|
||||
$reslut = model('RoomPit')->apply_pit($this->uid, $room_id, $pit_number);
|
||||
}
|
||||
redis_unlocks($key_name);
|
||||
|
||||
//用户操作记录
|
||||
//1-禁麦位,2-清空消息,3-清空魅力值,4-加入黑名单,5-踢出房间,6-关闭麦克风,7-申请上麦,8-同意上麦,9-拒绝上麦,10-点歌,11-开启PK',
|
||||
model('Room')->room_operation_record($this->uid,$room_id,7,0,$pit_number);
|
||||
|
||||
@@ -44,6 +57,9 @@ class RoomPit extends BaseCom
|
||||
public function apply_pit_list()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$reslut = model('RoomPit')->apply_pit_list($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -52,7 +68,13 @@ class RoomPit extends BaseCom
|
||||
public function help_apply_pit()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$user_id = input('user_id', 0);
|
||||
if($user_id == 0){
|
||||
return V(0, '请选择助力用户', null);
|
||||
}
|
||||
$reslut = model('RoomPit')->help_apply_pit($this->uid, $room_id, $user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -61,7 +83,13 @@ class RoomPit extends BaseCom
|
||||
public function agree_pit()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$user_id = input('user_id', 0);//逗号分割
|
||||
if($user_id == 0){
|
||||
return V(0, '请选择同意用户', null);
|
||||
}
|
||||
$reslut = model('RoomPit')->agree_pit($this->uid, $room_id, $user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -70,6 +98,9 @@ class RoomPit extends BaseCom
|
||||
public function refuse_pit()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$user_id = input('user_id', 0);//逗号分割
|
||||
$reslut = model('RoomPit')->clear_apply_pit_list($this->uid, $room_id, $user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
@@ -79,6 +110,9 @@ class RoomPit extends BaseCom
|
||||
public function clear_apply_pit_list()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$reslut = model('RoomPit')->clear_apply_pit_list($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -87,7 +121,13 @@ class RoomPit extends BaseCom
|
||||
public function set_room_pit_apply_help_gift()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$gift_id = input('gift_id', 0);
|
||||
if($gift_id == 0){
|
||||
return V(0, '请选择礼物', null);
|
||||
}
|
||||
$gift_price = input('gift_price', 0);
|
||||
$pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
|
||||
if($gift_id == $pool_gift_id){
|
||||
@@ -101,26 +141,27 @@ class RoomPit extends BaseCom
|
||||
public function down_pit()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$pit_number = input('pit_number', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$res = model('Room')->get_room_label($room_id);
|
||||
if($res['code'] != 1){
|
||||
$pit_number = input('pit_number', 0);
|
||||
|
||||
$room_type = model('Room')->get_room_type($room_id);
|
||||
if($room_type == 0){
|
||||
return V(0, '房间不存在', null);
|
||||
}
|
||||
$room_label = $res['data']['label_id'];
|
||||
$room_type = $res['data']['type_id'];
|
||||
|
||||
if($room_type == 10){
|
||||
$upit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $this->uid])->value('pit_number');
|
||||
if($upit == 2){
|
||||
return V(0, '师父麦,不能操作', null);
|
||||
}
|
||||
}
|
||||
if(($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8)) || $room_type == 2 || $room_type == 7 || $room_type == 9 || $room_type == 10){
|
||||
$reslut = model('RoomPit')->DownPit($this->uid, $room_id,$pit_number);
|
||||
}elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8)){
|
||||
|
||||
if($room_type == 2){
|
||||
$reslut = model('RoomSong')->down_kpit($this->uid, $room_id);
|
||||
}else{
|
||||
$reslut = model('RoomPit')->DownPit($this->uid, $room_id,$pit_number);
|
||||
}
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
@@ -132,7 +173,10 @@ class RoomPit extends BaseCom
|
||||
$key_name = "api:room:change_room_up_pit_type:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$room_id = input('room_id', 0);
|
||||
// $user_id = input('user_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
|
||||
$reslut = model('RoomPit')->change_room_up_pit_type($this->uid, $room_id);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
@@ -142,8 +186,14 @@ class RoomPit extends BaseCom
|
||||
public function host_user_pit()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$pit_number = input('pit_number', 0);
|
||||
$user_id = input('user_id', 0);//
|
||||
$user_id = input('user_id', 0);
|
||||
if($user_id == 0){
|
||||
return V(0, '请选择用户', null);
|
||||
}
|
||||
$type = input('type', 0);//1-抱麦 2-踢下去
|
||||
$reslut = model('RoomPit')->host_user_pit($this->uid, $room_id,$pit_number,$user_id,$type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
@@ -154,6 +204,9 @@ class RoomPit extends BaseCom
|
||||
public function refuse_sign_room_host_invite()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$reslut = model('RoomPit')->refuse_sign_room_host_invite($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
@@ -67,4 +67,15 @@ class RoomPk extends BaseCom
|
||||
$reslut = model('RoomPk')->refuse_pk($is_pk,$room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//PK闭麦
|
||||
public function close_pk_mic()
|
||||
{
|
||||
$pk_id = input('pk_id', 0);
|
||||
$type = input('type', 1);//1、关闭,2、开启
|
||||
$user_id = input('user_id', 0);
|
||||
$reslut = model('RoomPk')->close_pk_mic($pk_id,$type,$user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ class RoomSong extends BaseCom
|
||||
|
||||
//同意、拒绝点歌
|
||||
public function agree_song(){
|
||||
return V(0, '暂不支持此类型的操作');
|
||||
$room_id = input('room_id');
|
||||
$type = input('type',1);//1同意 2拒绝
|
||||
$res = model('RoomSong')->agree_song($this->uid,$room_id,$type);
|
||||
@@ -48,6 +49,23 @@ class RoomSong extends BaseCom
|
||||
return V($res['code'], $res['msg'], $res['data']);
|
||||
}
|
||||
|
||||
//删除歌曲
|
||||
public function del_song(){
|
||||
$room_song_id = input('did');
|
||||
$room_id = input('room_id');
|
||||
$res = model('RoomSong')->del_song($this->uid,$room_song_id,$room_id);
|
||||
return V($res['code'], $res['msg'], $res['data']);
|
||||
}
|
||||
|
||||
|
||||
//已点列表搜索
|
||||
public function search_song(){
|
||||
$room_id = input('room_id');
|
||||
$search_user = input('search_user');
|
||||
$res = model('RoomSong')->search_song($room_id,$search_user);
|
||||
return V($res['code'], $res['msg'], $res['data']);
|
||||
}
|
||||
|
||||
|
||||
//上移歌 $type 1上移 2置顶
|
||||
public function up_song(){
|
||||
|
||||
69
application/api/controller/SendGift.php
Normal file
69
application/api/controller/SendGift.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Db;
|
||||
|
||||
class SendGift extends BaseCom
|
||||
{
|
||||
|
||||
/*
|
||||
* 送礼
|
||||
* @param int $gift_id
|
||||
*/
|
||||
public function send_gift()
|
||||
{
|
||||
$key_name = "api:send:gift:" . $this->uid;
|
||||
redis_lock_exits($key_name);
|
||||
|
||||
$room_id = input('room_id/d', 0);//房间ID
|
||||
$gift_id = input('gift_id/d', 0);//礼物ID
|
||||
$gift_num = (int)input('gift_num/d', 1);//礼物数量
|
||||
$to_uid = input('to_uid', 0);//收礼人ID,逗号隔开的字符串
|
||||
$type = input('type/d', 1);//1金币购买 2送背包礼物
|
||||
$heart_id = input('heart_id/d', 0);//助力时的 ID
|
||||
$gift_bag_id = input('gift_bag_id/d', 0);//盲盒类型ID 7-初级,8-中级,9-高级
|
||||
|
||||
if($room_id <= 0 || $gift_id <= 0 || $to_uid <= 0 || $type <= 0){
|
||||
redis_unlocks($key_name);
|
||||
return V(0, '参数错误');
|
||||
}
|
||||
|
||||
//获取幸运币
|
||||
$pool_gift_ids = Db::name('bb_lottery_config')->column('value', 'key');
|
||||
//转成数组
|
||||
$pool_gift_id_arr = [$pool_gift_ids['pool_gift_id']??0,$pool_gift_ids['pool_gift_id_5']??0,$pool_gift_ids['pool_gift_id_10']??0];
|
||||
|
||||
if(in_array($gift_id, $pool_gift_id_arr)){//送的是幸运币
|
||||
$reslut = model('Lottery')->gift($this->uid, $to_uid, $gift_id, $room_id,$gift_num,$pool_gift_ids);
|
||||
redis_unlocks($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}else{
|
||||
//获取房间类型 1:交友/pk(二卡八),2:练歌房(声网点歌),3:亲密拍,4:真爱拍,6:私密房,7:互娱房,9:点唱/歌手房,10:签约房,11:酒吧房
|
||||
$room_type = model('Room')->get_room_type($room_id);
|
||||
|
||||
//送礼 (送礼用户,收礼用户组,礼物ID,数量,礼物类型,房间ID )
|
||||
$reslut = model('SendGift')->send_gift($this->uid, $to_uid, $gift_id, $gift_num, $type, $room_id, $gift_bag_id, $heart_id);
|
||||
|
||||
if($room_type == 2){//2:练歌房(声网点歌)
|
||||
if($reslut['code'] == 1){
|
||||
$room_pits = model('RoomSong')->get_charm_rank($room_id);
|
||||
if($room_pits['code'] == 1){
|
||||
$room_pit = $room_pits['data'];
|
||||
//推送给前端
|
||||
$text = [
|
||||
'userCharmList' => $room_pit,
|
||||
];
|
||||
model('Chat')->sendMsg(1019,$room_id,$text);//K歌房送礼后魅力变化 排序变化
|
||||
}
|
||||
}
|
||||
redis_unlocks($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
redis_unlocks($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,17 +11,21 @@ class Sign extends BaseCom
|
||||
public function sign_coin_list()
|
||||
{
|
||||
$sign_id = input('sign_id', 0);//场次id
|
||||
$room_sign = db::name('vs_room_sign')->where('id', $sign_id)->field('sign_user_id,room_id')->find();
|
||||
$room_sign = db::name('vs_room_sign')->where('id', $sign_id)->field('sign_user_id,room_id,market_value')->find();
|
||||
if (!$room_sign) {
|
||||
return v(0, '参数错误');
|
||||
}
|
||||
//获取出价最高用户
|
||||
$sign_user = db::name('vs_user_sign_auction')->where(['room_id' => $room_sign['room_id'],'sign_time' => $sign_id,'type' => 0])->order('sign_value desc')->field('id,user_id,sign_value')->find();
|
||||
$sign_user = db::name('vs_user_sign_auction')
|
||||
->field('id,user_id,sign_value')
|
||||
->where(['room_id' => $room_sign['room_id'],'sign_time' => $sign_id,'type' => 0])
|
||||
->order('sign_value desc')
|
||||
->find();
|
||||
if($sign_user){
|
||||
$market_value = $sign_user['sign_value'];
|
||||
}else{
|
||||
//获取当前用户的身价
|
||||
$market_value = db::name('user')->where('id', $room_sign['sign_user_id'])->value('market_value');
|
||||
$market_value = $room_sign['market_value'];
|
||||
}
|
||||
|
||||
$sign_market_value = get_system_config_value('sign_market_value');
|
||||
@@ -86,6 +90,7 @@ class Sign extends BaseCom
|
||||
return V(0, '参数错误');
|
||||
}
|
||||
$sign = db::name('vs_room_sign')->where('id', $sign_id)->field('room_id,sign_user_id')->find();
|
||||
|
||||
$user_id = $sign['sign_user_id'];
|
||||
$room_id = $sign['room_id'];
|
||||
|
||||
|
||||
@@ -34,9 +34,16 @@ class Sms extends Api
|
||||
//检测是否注销过
|
||||
$config_time = get_system_config_value('cancel_no_login');
|
||||
$is_del = db::name('user')->where(['mobile' => $mobile,'delete_time' => ['<>', 0]])->find();
|
||||
if ($is_del) {
|
||||
if (time() - $is_del['delete_time'] < $config_time * 24 * 3600) {//30天内注销过
|
||||
return V(0, '注销30天内,不可操作。');
|
||||
|
||||
//获取手机号绑定的账号数
|
||||
$count = db::name('user')->where(['mobile' => $mobile])->count();
|
||||
//获取注销的账号数
|
||||
$count_del = db::name('user')->where(['mobile' => $mobile,'delete_time' => ['<>', 0]])->count();
|
||||
if ($count == $count_del) {
|
||||
if ($is_del) {
|
||||
if (time() - $is_del['delete_time'] < $config_time * 24 * 3600) {//30天内注销过
|
||||
return V(0, '注销30天内,不可操作。');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,22 @@ class Theme extends controller
|
||||
$reslut['theme_name'] = $theme['theme_name'];
|
||||
$reslut['is_open'] = 1;
|
||||
}
|
||||
return V(1,'操作成功', $reslut);
|
||||
|
||||
//版本号
|
||||
$app_version = request()->header('App-Version');
|
||||
$system = request()->header('system');
|
||||
$api_version = 0;
|
||||
if ($system == 'iOS') {
|
||||
$api_versions = db::name('version')->where(['type' => 2, 'status' => 1])->order('id', 'desc')->find();
|
||||
//app的版本和用户使用的当前版本比对
|
||||
//$api_versions['newversion'] 是数据库当前的版本 也是用户使用的版本
|
||||
//$app_version 有可能是appstore里面的审核版本 审核版本比用户的版本高
|
||||
//审核版本给前端返回1
|
||||
$result = version_compare($api_versions['newversion'],$app_version);
|
||||
if ($result < 0) {//-1:前面版本小于后面版本,0:相等,1:前面版本大于后面版本
|
||||
$api_version = 1;
|
||||
}
|
||||
}
|
||||
return V(1,'操作成功', $reslut,$api_version);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,16 @@ class User extends BaseCom
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//礼物墙礼物用户列表
|
||||
public function gift_wall_user_list()
|
||||
{
|
||||
$uid = input('user_id', 0);
|
||||
$gift_id = input('gift_id', 0);
|
||||
$reslut = model('User')->gift_wall_user_list($uid,$gift_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//相册列表
|
||||
public function get_album_list()
|
||||
{
|
||||
|
||||
@@ -13,12 +13,8 @@ class UserCp extends BaseCom
|
||||
$user_id = input('user_id', 0);
|
||||
$gift_id = input('gift_id', 0);
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id){
|
||||
$from_type = 2;
|
||||
}else{
|
||||
$from_type = 1;
|
||||
}
|
||||
$reslut = model('GiveGift')->give_gift($this->uid, $user_id, $gift_id, 1,$from_type,1,$room_id);
|
||||
|
||||
$reslut = model('SendGift')->send_gift($this->uid, $user_id, $gift_id, 1,1,$room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
@@ -193,7 +193,8 @@ class UserData extends BaseCom
|
||||
redis_lock_exit($key_name);
|
||||
$real_name = input('real_name');
|
||||
$card_number = input('card_number');
|
||||
|
||||
//去掉前后空格
|
||||
$card_number = trim($card_number);
|
||||
$reslut = model('UserData')->real_name($this->uid,$real_name, $card_number);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
|
||||
@@ -14,43 +14,19 @@ class UserWallet extends BaseCom
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
// //给前端的类型组装一个
|
||||
// public function gift_type()
|
||||
// {
|
||||
// // 1.系统调节 2.充值 3.提现 4.金币转增(送出) 5.每日任务奖励 6.充值返利 7.购买装扮
|
||||
// // 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换
|
||||
// $data = [
|
||||
//// ['id' => 1, 'name' => '系统调节'],
|
||||
// ['id' => 2, 'name' => '充值'],
|
||||
// ['id' => 3, 'name' => '提现'],
|
||||
// ['id' => 4, 'name' => '金币转增'],
|
||||
// ['id' => 5, 'name' => '每日任务奖励'],
|
||||
// ['id' => 6, 'name' => '充值返利'],
|
||||
// ['id' => 7, 'name' => '购买装扮'],
|
||||
// ['id' => 8, 'name' => '礼盒奖励'],
|
||||
// ['id' => 9, 'name' => '房间补贴'],
|
||||
// ['id' => 10, 'name' => '购买礼物'],
|
||||
// ['id' => 11, 'name' => '收礼增加收益'],
|
||||
// ['id' => 12, 'name' => '工会补贴'],
|
||||
// ['id' => 13, 'name' => '金币转增'],
|
||||
// ['id' => 14, 'name' => '收益兑换'],
|
||||
// ['id' => 15, 'name' => '送礼'],
|
||||
// ];
|
||||
// return V(1, '获取成功', $data);
|
||||
// }
|
||||
|
||||
//金币(钻石)明细
|
||||
public function log_list()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
// 1. 接收参数(前端传递:last_id=上一页最后一条的id,page_limit=每页条数)
|
||||
$last_id = input('last_id', 0); // 第一页 last_id=0
|
||||
$page_limit = input('page_limit', 30);
|
||||
$in_out_type = input('in_out_type', 1);//1收入2支出
|
||||
$gift_type = input('gift_type', 1);//1金币,2收益(钻石)
|
||||
//开始时间
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$start_time = input('start_time', '');//开始时间
|
||||
$end_time = input('end_time', '');//结束时间
|
||||
|
||||
$reslut = model('UserWallet')->log_list($this->uid, $page, $page_limit,$in_out_type,$start_time,$end_time,$gift_type);
|
||||
$reslut = model('UserWallet')->log_list($this->uid, $last_id, $page_limit,$in_out_type,$start_time,$end_time,$gift_type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ class UserZone extends BaseCom
|
||||
$api_version = 0;
|
||||
if ($system == 'iOS') {
|
||||
$api_versions = db::name('version')->where(['type' => 2, 'status' => 1])->order('id', 'desc')->find();
|
||||
$result = version_compare($api_versions['apiversion'],$app_version);
|
||||
$result = version_compare($api_versions['newversion'],$app_version);
|
||||
if ($result < 0) {
|
||||
$api_version = 1;
|
||||
}
|
||||
|
||||
103
application/api/controller/Wechat.php
Normal file
103
application/api/controller/Wechat.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
use think\Log;
|
||||
|
||||
class Wechat extends Controller
|
||||
{
|
||||
|
||||
private string $appId = 'wx0f0c0c0c0c0c0c0c';
|
||||
private string $appSecret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
|
||||
|
||||
/*
|
||||
* 核心:用code换取openid的方法
|
||||
* @param string $code 微信回调带来的code
|
||||
* @return string|bool 成功返回openid,失败返回false
|
||||
*/
|
||||
|
||||
public function exchangeOpenId()
|
||||
{
|
||||
$code = input('code', 0);
|
||||
|
||||
// 构建请求URL
|
||||
$url = "https://api.weixin.qq.com/sns/oauth2/access_token?" .
|
||||
"appid={$this->appId}&" .
|
||||
"secret={$this->appSecret}&" .
|
||||
"code={$code}&" .
|
||||
"grant_type=authorization_code";
|
||||
|
||||
Log::info('[微信授权] 请求微信接口URL:' . $url);
|
||||
|
||||
// 发送请求
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
||||
if (curl_errno($ch)) {
|
||||
Log::error('[微信授权] 请求失败:' . curl_error($ch));
|
||||
curl_close($ch);
|
||||
return V(0, '[微信授权] 请求失败:' . curl_error($ch));
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
Log::info('[微信授权] 微信返回原始数据:' . $response);
|
||||
|
||||
// 解析返回的JSON
|
||||
$data = json_decode($response, true);
|
||||
|
||||
if (empty($data) || isset($data['errcode'])) {
|
||||
Log::error('[微信授权] 解析失败或返回错误'.json_encode($data));
|
||||
return V(0, '[微信授权] 解析失败或返回错误');
|
||||
}
|
||||
|
||||
// 成功获取到openid
|
||||
return V(1, '获取成功', $data['openid']);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 获取用户信息
|
||||
* @param string $user_code 用户的user_code
|
||||
* @return array|bool 成功返回用户信息,失败返回false
|
||||
*/
|
||||
public function getUserInfo()
|
||||
{
|
||||
$user_code = input('user_code', 0);
|
||||
$user_info = db::name('user')
|
||||
->field('id user_id,nickname,avatar,mobile,user_code')
|
||||
->where(['user_code' => $user_code,'status' => ['<>',0]])->find();
|
||||
if(!$user_info){
|
||||
return ['code' => 0, 'msg' => '用户不存在或已注销', 'data' => null];
|
||||
}
|
||||
|
||||
return V(1, '获取成功', $user_info);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 可充值的金额
|
||||
* @param string $user_code 用户的user_code
|
||||
* @return array|bool 充值金额,失败返回false
|
||||
*/
|
||||
public function getRechargeMoney()
|
||||
{
|
||||
$money_coin = [
|
||||
['coin' => '1', 'money' => '0.10'],
|
||||
['coin' => '60', 'money' => '6.00'],
|
||||
['coin' => '1000', 'money' => '100.00'],
|
||||
];
|
||||
|
||||
return V(1, '获取成功', $money_coin);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,12 +30,16 @@ class Xintiao extends BaseCom
|
||||
'updatetime' => time()
|
||||
]);
|
||||
}
|
||||
//任务:18-每日在线时长 5 分钟
|
||||
model('Tasks')->tasks_complete($user_id,18);
|
||||
//任务:19-每日在线时长 10 分钟
|
||||
model('Tasks')->tasks_complete($user_id,19);
|
||||
//任务:20-每日在线时长 15 分钟
|
||||
model('Tasks')->tasks_complete($user_id,20);
|
||||
//查询房间是否热门房间
|
||||
$is_hot_room = db::name('vs_room')->where(['id' => $room_id,'is_hot' => 2])->find();
|
||||
if($is_hot_room){
|
||||
//任务:18-每日在线时长 5 分钟
|
||||
model('Tasks')->tasks_complete($user_id,18);
|
||||
//任务:19-每日在线时长 10 分钟
|
||||
model('Tasks')->tasks_complete($user_id,19);
|
||||
//任务:20-每日在线时长 15 分钟
|
||||
model('Tasks')->tasks_complete($user_id,20);
|
||||
}
|
||||
|
||||
//获取房间的类型
|
||||
$room_type = db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
|
||||
@@ -8,7 +8,7 @@ use think\Log;
|
||||
|
||||
use app\common\controller\Push;
|
||||
|
||||
class Xxiaoshi extends Controller
|
||||
class Xxiaoshi extends Controllers
|
||||
{
|
||||
|
||||
public function test()
|
||||
@@ -49,4 +49,363 @@ class Xxiaoshi extends Controller
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function queryUserRecharge()
|
||||
{
|
||||
// 1. 构建键值对数组(左侧为键,右侧为对应的值列表)
|
||||
// $userTimeData = [
|
||||
// [21238, 1768437495],
|
||||
// [21238, 1768438042],
|
||||
// [21238, 1768537071],
|
||||
// [21238, 1768537086],
|
||||
// [21238, 1768537102],
|
||||
// [21238, 1768537116],
|
||||
// [21238, 1768537130],
|
||||
// [21263, 1768538654],
|
||||
// [21283, 1768538494],
|
||||
// [21283, 1768538505],
|
||||
// [21346, 1768620290],
|
||||
// [21355, 1768562702],
|
||||
// [21521, 1768480294],
|
||||
// [21521, 1768535126],
|
||||
// [21521, 1768559545],
|
||||
// [21521, 1768559583],
|
||||
// [21521, 1768561603],
|
||||
// [21521, 1768561942],
|
||||
// [21549, 1768472710],
|
||||
// [21549, 1768473170],
|
||||
// [22109, 1768576512],
|
||||
// [22215, 1768448033],
|
||||
// [22230, 1768453987],
|
||||
// [22230, 1768494691],
|
||||
// [22230, 1768606319],
|
||||
// [22247, 1768568982],
|
||||
// [22349, 1768463236],
|
||||
// [22349, 1768463510],
|
||||
// [22349, 1768498328],
|
||||
// [22349, 1768534547],
|
||||
// [22349, 1768575347],
|
||||
// [22349, 1768575906],
|
||||
// [22349, 1768576001],
|
||||
// [22349, 1768576134],
|
||||
// [22349, 1768576484],
|
||||
// [22353, 1768493303],
|
||||
// [22353, 1768493644],
|
||||
// [22367, 1768450215],
|
||||
// [22367, 1768450295],
|
||||
// [22367, 1768450411],
|
||||
// [22367, 1768556122],
|
||||
// [22367, 1768557842],
|
||||
// [22367, 1768560574],
|
||||
// [22397, 1768489651],
|
||||
// [22397, 1768489678],
|
||||
// [22403, 1768615100],
|
||||
// [22403, 1768615185],
|
||||
// [22474, 1768610625],
|
||||
// [22489, 1768539082],
|
||||
// [22513, 1768469607],
|
||||
// [22513, 1768622078], // 新增的时间戳
|
||||
// [22546, 1768467110],
|
||||
// [22546, 1768480214],
|
||||
// [22546, 1768480289],
|
||||
// [22546, 1768617480],
|
||||
// [22546, 1768619884],
|
||||
// [22765, 1768555869],
|
||||
// [22765, 1768613623],
|
||||
// [22960, 1768478779],
|
||||
// [22960, 1768562093],
|
||||
// [22960, 1768562790],
|
||||
// [23160, 1768495390],
|
||||
// [23273, 1768546462],
|
||||
// [23317, 1768445313],
|
||||
// [23317, 1768499667],
|
||||
// [23317, 1768500101],
|
||||
// [23317, 1768500124],
|
||||
// [23317, 1768500550],
|
||||
// [23317, 1768502888],
|
||||
// [23317, 1768580934],
|
||||
// [23317, 1768580952],
|
||||
// [23317, 1768582152],
|
||||
// [23381, 1768484820],
|
||||
// [23381, 1768558830],
|
||||
// [23381, 1768562317],
|
||||
// [23418, 1768546419],
|
||||
// [23418, 1768556020],
|
||||
// [23428, 1768615120],
|
||||
// [23620, 1768438590],
|
||||
// [23620, 1768446478],
|
||||
// [23620, 1768446636],
|
||||
// [23620, 1768446926],
|
||||
// [23620, 1768446971],
|
||||
// [23620, 1768446983],
|
||||
// [23620, 1768446994],
|
||||
// [23768, 1768500957],
|
||||
// [23934, 1768487148],
|
||||
// [23979, 1768483941],
|
||||
// [23979, 1768484887],
|
||||
// [23979, 1768485349],
|
||||
// [23979, 1768488207],
|
||||
// [23979, 1768606496],
|
||||
// [23996, 1768537785],
|
||||
// [23996, 1768583372],
|
||||
// [24049, 1768480652],
|
||||
// [24049, 1768574886],
|
||||
// [24049, 1768575149],
|
||||
// [24049, 1768575263],
|
||||
// [24049, 1768575306],
|
||||
// [24049, 1768576026],
|
||||
// [24049, 1768576057],
|
||||
// [24049, 1768576122],
|
||||
// [24049, 1768576324],
|
||||
// [24049, 1768576359],
|
||||
// [24049, 1768576411],
|
||||
// [24049, 1768576450],
|
||||
// [24049, 1768576547],
|
||||
// [24049, 1768576572],
|
||||
// [24049, 1768576752],
|
||||
// [24049, 1768576788],
|
||||
// [24049, 1768610848],
|
||||
// [24049, 1768610956],
|
||||
// [24123, 1768476419],
|
||||
// [24123, 1768563117],
|
||||
// [24208, 1768480841],
|
||||
// [24221, 1768621532], // 新增的user_id和时间戳
|
||||
// [24224, 1768434963],
|
||||
// [24239, 1768575140],
|
||||
// [24262, 1768474400],
|
||||
// [24268, 1768562981],
|
||||
// [24268, 1768563148],
|
||||
// [24376, 1768495419],
|
||||
// [24402, 1768573575],
|
||||
// [24402, 1768573664],
|
||||
// [24497, 1768611030],
|
||||
// [24497, 1768611043],
|
||||
// [24559, 1768573337],
|
||||
// [24619, 1768444049],
|
||||
// [24724, 1768436254],
|
||||
// [24724, 1768436335],
|
||||
// [24724, 1768436370],
|
||||
// [24724, 1768436566],
|
||||
// [24724, 1768463485],
|
||||
// [24724, 1768463533],
|
||||
// [24724, 1768485920],
|
||||
// [24724, 1768486241],
|
||||
// [24724, 1768559795],
|
||||
// [24724, 1768575533],
|
||||
// [24724, 1768575836],
|
||||
// [24724, 1768575846],
|
||||
// [24724, 1768576947],
|
||||
// [24724, 1768577192],
|
||||
// [24724, 1768584426],
|
||||
// [24724, 1768591790],
|
||||
// [24724, 1768592625],
|
||||
// [24809, 1768574941],
|
||||
// [24914, 1768469768],
|
||||
// [24914, 1768478779],
|
||||
// [24914, 1768529233],
|
||||
// [24914, 1768547882],
|
||||
// [24949, 1768446759],
|
||||
// [24949, 1768468114],
|
||||
// [24949, 1768471318],
|
||||
// [24949, 1768489660],
|
||||
// [24949, 1768489679],
|
||||
// [24949, 1768489694],
|
||||
// [24949, 1768489908],
|
||||
// [24949, 1768489995],
|
||||
// [24949, 1768491042],
|
||||
// [24949, 1768491189],
|
||||
// [24949, 1768495030],
|
||||
// [24949, 1768495287],
|
||||
// [24949, 1768528803],
|
||||
// [24949, 1768621300], // 新增的时间戳
|
||||
// [25102, 1768486444],
|
||||
// [25102, 1768492650],
|
||||
// [25264, 1768469925],
|
||||
// [25297, 1768482093],
|
||||
// [25297, 1768523171],
|
||||
// [25297, 1768524115],
|
||||
// [25356, 1768453712],
|
||||
// [25356, 1768564162],
|
||||
// [25436, 1768567177],
|
||||
// [25504, 1768445533],
|
||||
// [25504, 1768474538],
|
||||
// [25504, 1768474550],
|
||||
// [25504, 1768549836],
|
||||
// [25504, 1768550533],
|
||||
// [25504, 1768551277],
|
||||
// [25504, 1768611155],
|
||||
// [25614, 1768463575],
|
||||
// [25614, 1768493369],
|
||||
// [25668, 1768550315],
|
||||
// [25668, 1768550900],
|
||||
// [25668, 1768551157],
|
||||
// [25689, 1768534840],
|
||||
// [25689, 1768534859],
|
||||
// [25689, 1768535523],
|
||||
// [25689, 1768606149],
|
||||
// [25689, 1768606164],
|
||||
// [25782, 1768440770],
|
||||
// [25868, 1768441940],
|
||||
// [25884, 1768446752],
|
||||
// [25884, 1768453213],
|
||||
// [25884, 1768478849],
|
||||
// [25909, 1768451888],
|
||||
// [25909, 1768452147],
|
||||
// [25909, 1768452512],
|
||||
// [25909, 1768452685],
|
||||
// [25909, 1768453007],
|
||||
// [25977, 1768465353],
|
||||
// [25977, 1768466422],
|
||||
// [25977, 1768466948],
|
||||
// [25977, 1768495780],
|
||||
// [26002, 1768474369],
|
||||
// [26010, 1768563140],
|
||||
// [26260, 1768595503],
|
||||
// [26333, 1768480346],
|
||||
// [26471, 1768463341],
|
||||
// [26471, 1768535162],
|
||||
// [26685, 1768544823],
|
||||
// [26846, 1768467107],
|
||||
// [26865, 1768526248],
|
||||
// [26910, 1768495212],
|
||||
// [26910, 1768495674],
|
||||
// [26932, 1768451859],
|
||||
// [26932, 1768452304],
|
||||
// [26932, 1768467016],
|
||||
// [26932, 1768467086],
|
||||
// [26961, 1768551610],
|
||||
// [26961, 1768551630],
|
||||
// [26961, 1768551741],
|
||||
// [26961, 1768617367],
|
||||
// [27063, 1768595933],
|
||||
// [27152, 1768544596],
|
||||
// [27172, 1768453726],
|
||||
// [27306, 1768467885],
|
||||
// [27306, 1768480720],
|
||||
// [27619, 1768480089],
|
||||
// [27619, 1768547882],
|
||||
// [27619, 1768547902],
|
||||
// [27619, 1768564945],
|
||||
// [27848, 1768445845],
|
||||
// [27848, 1768446640],
|
||||
// [27980, 1768485183],
|
||||
// [28015, 1768463456],
|
||||
// [28015, 1768464122],
|
||||
// [28226, 1768539447],
|
||||
// [28226, 1768539558],
|
||||
// [28226, 1768539674],
|
||||
// [28226, 1768539800],
|
||||
// [28226, 1768539899],
|
||||
// [28226, 1768539972],
|
||||
// [28226, 1768540093],
|
||||
// [28226, 1768540167],
|
||||
// [28226, 1768540273],
|
||||
// [28304, 1768454349],
|
||||
// [28357, 1768441100],
|
||||
// [28443, 1768471092],
|
||||
// [28443, 1768538447],
|
||||
// [28443, 1768540270],
|
||||
// [28443, 1768547826],
|
||||
// [28443, 1768556907],
|
||||
// [28443, 1768557771],
|
||||
// [28443, 1768564068],
|
||||
// [28443, 1768564085],
|
||||
// [28551, 1768481077],
|
||||
// [28551, 1768481222],
|
||||
// [28551, 1768548678],
|
||||
// [28551, 1768580500],
|
||||
// [28551, 1768580517],
|
||||
// [28561, 1768449441],
|
||||
// [28769, 1768553650],
|
||||
// [28769, 1768553902],
|
||||
// [28855, 1768568390],
|
||||
// [28924, 1768472667],
|
||||
// [28924, 1768490582],
|
||||
// [28924, 1768490656],
|
||||
// [28924, 1768490721],
|
||||
// [28924, 1768490844],
|
||||
// [28924, 1768490949],
|
||||
// [28924, 1768491079],
|
||||
// [28924, 1768491176],
|
||||
// [28924, 1768491285],
|
||||
// [28924, 1768569855],
|
||||
// [28924, 1768570809],
|
||||
// [28993, 1768444688],
|
||||
// [29420, 1768491595],
|
||||
// [30113, 1768544251],
|
||||
// [30190, 1768457671],
|
||||
// [30190, 1768457788],
|
||||
// [30190, 1768457926],
|
||||
// [30190, 1768458180],
|
||||
// [30190, 1768458568],
|
||||
// [30190, 1768458786],
|
||||
// [30190, 1768458886],
|
||||
// [30190, 1768459131],
|
||||
// [30190, 1768459373],
|
||||
// [30442, 1768529725],
|
||||
// [30551, 1768580619]
|
||||
// ];
|
||||
|
||||
if(isset($userTimeData)){
|
||||
$userTimeData = [];
|
||||
}
|
||||
$dtae = [];
|
||||
// 2. 循环数组,遍历每个键对应的所有值
|
||||
foreach ($userTimeData as $item) {
|
||||
$userId = $item[0]; // 获取用户ID
|
||||
$timestamp = $item[1]; // 获取时间戳
|
||||
// 批量查询(推荐,减少数据库连接次数)
|
||||
$rechargeData = Db::name('vs_user_recharge')
|
||||
->field('updatetime, pay_status, user_id, money')
|
||||
->where(['updatetime' => $timestamp,'pay_status' => 2 ])
|
||||
->select(); // 转为普通数组方便处理
|
||||
|
||||
if($rechargeData){
|
||||
foreach ($rechargeData as $recharge){
|
||||
$dtae[] = [
|
||||
'p_user' => $userId,
|
||||
'user_id' => $recharge['user_id'],
|
||||
'createtime' => $recharge['updatetime'],
|
||||
'money' => $recharge['money'],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// var_dump($dtae);
|
||||
echo "\n";
|
||||
echo "=========";
|
||||
var_dump(count($dtae));
|
||||
echo "\n";
|
||||
$invite = [];
|
||||
$invited_draw_conf = get_system_config_value('invited_draw');//分成比例
|
||||
if($dtae){
|
||||
foreach ($dtae as $item){
|
||||
$invit = db::name('vs_user_invited')->where(['user_id' => $item['p_user'],'sub_user_id' => $item['user_id']])->find();
|
||||
if($invit){
|
||||
$invited_draw = $invited_draw_conf / 100;
|
||||
$invited_draw_money = $item['money'] * $invited_draw;
|
||||
//增加余额并记录日志
|
||||
// $wallet_update = model('api/UserWallet')->change_user_earnings_log($item['p_user'],$invited_draw_money,0,6,'邀请用户充值返利'.$item['createtime']);
|
||||
// if(!$wallet_update){
|
||||
// Log::record("邀请用户充值返利(补发)失败:".$item['p_user'],"info");
|
||||
// echo "邀请用户充值返利失败".$item['p_user'];
|
||||
// }
|
||||
sleep(1);
|
||||
$invite[] = [
|
||||
'p_user' => $item['p_user'],
|
||||
'user_id' => $item['user_id'],
|
||||
'createtime' => $item['createtime'],
|
||||
'money' => $item['money'],
|
||||
'invited_draw_money' => $invited_draw_money,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "=========";
|
||||
echo "\n";
|
||||
// var_dump($invite);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,9 +12,10 @@ class Banner extends Model
|
||||
1 => '引导页',
|
||||
2 => '启动页',
|
||||
3 => '首页轮播图',
|
||||
4 => '房间首页',
|
||||
4 => '房间首页轮播图',
|
||||
5 => '工会列表页广告位',
|
||||
6 => '我的页面'
|
||||
6 => '我的主页广告位',
|
||||
7 => '道具商城广告位'
|
||||
];
|
||||
//1纯展示 2文章 3房间 4个人主页 5外站'
|
||||
public $Type = [
|
||||
|
||||
240
application/api/model/BarRoom.php
Normal file
240
application/api/model/BarRoom.php
Normal file
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Cache;
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
|
||||
/*
|
||||
* 酒吧房
|
||||
*/
|
||||
class BarRoom extends Model
|
||||
{
|
||||
// 开启自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = true;
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
// 麦位时长配置
|
||||
protected $pitDuration = [
|
||||
'1' => 5,
|
||||
'2' => 10,
|
||||
'3' => 15,
|
||||
'4' => 20,
|
||||
'5' => 25,
|
||||
'6' => 30,
|
||||
];
|
||||
|
||||
//麦位时长列表
|
||||
public function get_pit_duration_list(){
|
||||
foreach ($this->pitDuration as $key => $value) {
|
||||
$list[] = [
|
||||
'time' => $value,
|
||||
'time_str' => $value.'分钟',
|
||||
];
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//设置房间麦位时长
|
||||
public function set_pit_duration($room_id,$time){
|
||||
$room = db::name('vs_room')->where(['id' => $room_id, 'delete_time' => 0, 'room_status' => 1])->find();
|
||||
if(!$room){
|
||||
return ['code' => 0, 'msg' => '房间不存在', 'data' => null];
|
||||
}
|
||||
$room_data = db::name('vs_room_bar')->where('id',$room['id'])->find();
|
||||
if($room_data){
|
||||
if($room_data['pit_time'] != $time){
|
||||
db::name('vs_room_bar')->where('id',$room_id)->update(['pit_time' => $time]);
|
||||
}
|
||||
}else{
|
||||
db::name('vs_room_bar')->insert([
|
||||
'id' => $room_id,
|
||||
'pit_time' => $time,
|
||||
]);
|
||||
}
|
||||
//推送麦位时长
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//上麦选择礼物
|
||||
public function join_pit_choose_gift($user_id,$room_id,$gift_id){
|
||||
$pit_gift = db::name('vs_room_bar_pit_gift')->where(['room_id' => $room_id,'user_id' => $user_id])->find();
|
||||
$pit_time = db::name('vs_room_bar')->where('id',$room_id)->value('pit_time')??5;
|
||||
$end_time = time() + ($pit_time * 60);
|
||||
if($pit_gift){
|
||||
// 使用WHERE条件和影响行数验证确保并发安全
|
||||
$result = db::name('vs_room_bar_pit_gift')
|
||||
->where(['id' => $pit_gift['id']])
|
||||
->update([
|
||||
'gift_id' => $gift_id,
|
||||
'end_time' => $end_time,
|
||||
'updatetime' => time(),
|
||||
'delete_time' => 0,
|
||||
]);
|
||||
} else{
|
||||
// 执行插入操作
|
||||
$result = db::name('vs_room_bar_pit_gift')->insert([
|
||||
'room_id' => $room_id,
|
||||
'user_id' => $user_id,
|
||||
'gift_id' => $gift_id,
|
||||
'end_time' => $end_time,
|
||||
'createtime' => time(),
|
||||
]);
|
||||
}
|
||||
if(!$result){
|
||||
return ['code' => 0, 'msg' => '失败', 'data' => null];
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//约Ta礼物详情
|
||||
public function get_gift_info_ta($room_id,$to_user_id,$user_id){
|
||||
$return_data = [];
|
||||
$pit_gift = db::name('vs_room_bar_pit_gift')->where(['room_id' => $room_id,'user_id' => $to_user_id, 'delete_time' => 0])->find();
|
||||
if($pit_gift){
|
||||
$gift = db::name('vs_gift')->where(['gid' => $pit_gift['gift_id'], 'delete_time' => 0])->find();
|
||||
if(empty($gift)){
|
||||
return ['code' => 0, 'msg' => '礼物不存在', 'data' => null];
|
||||
}
|
||||
//当前用户钱包余额(金币)
|
||||
$wallet_coin = db::name('user_wallet_coin')->where(['user_id' => $user_id])->value('coin') ?? 0;
|
||||
$return_data = [
|
||||
'gift_id' => $pit_gift['gift_id'],
|
||||
'gift_name' => $gift['gift_name'],
|
||||
'base_image' => $gift['base_image'],
|
||||
'gift_price' => $gift['gift_price'],
|
||||
'user_wallet_coin' => $wallet_coin,
|
||||
];
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => $return_data];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//撩TA
|
||||
public function liao_ta($room_id,$user_id,$to_user_id){
|
||||
//查询撩TA礼物
|
||||
$liao_ta_gif = $this->get_liao_ta_gift();
|
||||
$liao_ta_gif_id = $liao_ta_gif['gid']??0;
|
||||
//调用送礼接口
|
||||
$re = model("api/SendGift")->send_gift($user_id,$to_user_id,$liao_ta_gif_id,1,1,$room_id);
|
||||
if($re['code'] != 1){
|
||||
return ['code' => 0, 'msg' => $re['msg'], 'data' => null];
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//一键全撩
|
||||
public function one_key_liao_ta($room_id,$user_id){
|
||||
//查询撩TA礼物
|
||||
$liao_ta_gif = $this->get_liao_ta_gift();
|
||||
$liao_ta_gif_id = $liao_ta_gif['gid']??0;
|
||||
//查询麦上用户
|
||||
$room_pit_Users = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',7],'user_id'=>['>',0],'status' => 1])->column('user_id');
|
||||
if(empty($room_pit_Users)){
|
||||
return ['code' => 0, 'msg' => '没有麦上用户', 'data' => null];
|
||||
}
|
||||
$to_user_ids = [];
|
||||
|
||||
foreach ($room_pit_Users as $key => $value) {
|
||||
if($user_id == $value){//自己
|
||||
continue;
|
||||
}
|
||||
//调用送礼接口
|
||||
$to_user_ids[] = $value;
|
||||
}
|
||||
|
||||
$to_user_ids = implode(',',$to_user_ids);
|
||||
$re = model("api/SendGift")->send_gift($user_id,$to_user_ids,$liao_ta_gif_id,1,1,$room_id);
|
||||
if($re['code'] != 1){
|
||||
return ['code' => 0, 'msg' => $re['msg'], 'data' => null];
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
//获取撩TA礼物
|
||||
public function get_liao_ta_gift(){
|
||||
$cache_key = 'gift_list_17';
|
||||
//2,缓存获取
|
||||
$gift_data = json_decode(Cache::get($cache_key), true);
|
||||
//获取到就返回
|
||||
if($gift_data){
|
||||
return $gift_data;
|
||||
}
|
||||
//查询撩TA礼物
|
||||
$where = [];
|
||||
$where['type'] = 6;
|
||||
$where['label'] = 17;
|
||||
$where['is_show'] = 1;
|
||||
$where['is_can_buy'] = 1;
|
||||
$where['delete_time'] = 0;
|
||||
$gift_data = db::name('vs_gift')->where($where)->order('gid desc')->find();
|
||||
//设置缓存
|
||||
Cache::set($cache_key, json_encode($gift_data), 3600*24);
|
||||
return $gift_data;
|
||||
}
|
||||
|
||||
|
||||
//约TA
|
||||
public function meeting_ta($user_id,$room_id,$meet_user_id,$gift_id){
|
||||
//走送礼流程
|
||||
$res = model("api/SendGift")->send_gift($user_id,$meet_user_id,$gift_id,1,1,$room_id);
|
||||
if($res['code'] != 1){
|
||||
return ['code' => 0, 'msg' => $res['msg'], 'data' => null];
|
||||
}
|
||||
|
||||
//预测版块 上线前注释掉 ======👇======
|
||||
//获取 房间ID
|
||||
// $room_last_id = db::name('vs_room')->order('id desc')->value('id');
|
||||
// if($room_last_id >= 19998){
|
||||
// return ['code' => 0, 'msg' =>'房间已满,暂时不能创建房间,请联系运营或管理', 'data' => null];
|
||||
// }
|
||||
//预测版块 上线前注释掉======👆======
|
||||
|
||||
|
||||
//创建私密房间 并告知前端拉谁进入
|
||||
$room_ids = model('api/Room')->user_create_room($user_id,'酒吧私密房',get_system_config_value('web_site').'/data/avatar/head_pic.png','酒吧房产生的一次性房间',11);
|
||||
if($room_ids['code'] != 1){
|
||||
return ['code' => 0, 'msg' => $room_ids['msg'], 'data' => null];
|
||||
}else{
|
||||
//记录小房间
|
||||
$datda = [
|
||||
'room_id' => $room_ids['data'],
|
||||
'p_room_id' => $room_id,
|
||||
'user_id' => $user_id,
|
||||
'meet_user_id' => $meet_user_id,
|
||||
'end_time' => time() + get_system_config_value('bar_room_timea') * 60,
|
||||
'createtime' => time(),
|
||||
'status' => 1 //1-正常,2-结束
|
||||
];
|
||||
db::name('vs_room_bar_movie')->insert($datda);
|
||||
|
||||
$text['text'] = '约TA并创建房间';
|
||||
$text['room_id'] = $room_ids['data'];//前端用来让用户跳转的房间id
|
||||
$text['user_id'] = $user_id;
|
||||
$text['meet_user_id'] = $meet_user_id;
|
||||
model('api/Chat')->sendMsg(1201,$room_id,$text);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//小黑屋列表
|
||||
public function black_room_list($room_id){
|
||||
$list = db::name('vs_room_bar_movie')->where(['p_room_id' => $room_id,'status' => 1,'end_time' => ['>',time()]])->select();
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => $list];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -182,11 +182,10 @@ class BlindBoxTurntableGift extends Model
|
||||
$roomtype = Db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
if($roomtype == 6){
|
||||
//推送消息
|
||||
$hot_value = db::name('vs_give_gift')->where('from_id', $room_id)->where('from',6)
|
||||
->sum('total_price');
|
||||
$hot_value = db::name('vs_room')->where('id', $room_id)->value('hot_value');
|
||||
$text1 = [
|
||||
'room_id' => $room_id,
|
||||
'hot_value' => $hot_value * 10,
|
||||
'hot_value' => $hot_value,
|
||||
'text' => '房间心动值变化'
|
||||
];
|
||||
//聊天室推送系统消息
|
||||
@@ -465,10 +464,23 @@ class BlindBoxTurntableGift extends Model
|
||||
}
|
||||
|
||||
//盲盒转盘开启状态
|
||||
public function blind_box_status(){
|
||||
$gift_bag_ids = [11,12];
|
||||
public function blind_box_status($user_id=0){
|
||||
$gift_bag_ids = [11,12,60,61];
|
||||
$gift_bag = db::name('vs_gift_bag')->where(['id'=>['in',$gift_bag_ids]])->select();
|
||||
$open_monster_status = get_system_config_value('open_monster_status');
|
||||
$fun_activities_recharge_restrictions = get_system_config_value('fun_activities_recharge_restrictions');
|
||||
if($fun_activities_recharge_restrictions ==0){
|
||||
return ['code' => 0, 'msg' => '趣味活动关闭', 'data' => null];
|
||||
}
|
||||
//用户充值金额
|
||||
$user_recharge_money = db::name('vs_user_recharge')->where(['user_id'=>$user_id,'pay_status'=>2])->sum('money');
|
||||
if($user_recharge_money < $fun_activities_recharge_restrictions){
|
||||
return ['code' => 0, 'msg' => '充值金额不足', 'data' => null];
|
||||
}
|
||||
foreach ($gift_bag as $bag){
|
||||
if($bag['id']==60 && $open_monster_status ==0){
|
||||
$bag['status'] = 0;
|
||||
}
|
||||
if($bag['status'] == 1){
|
||||
$result_data[] = [
|
||||
'gift_bag_id' => $bag['id'],
|
||||
|
||||
@@ -24,7 +24,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
// 连接到Redis服务器
|
||||
$this->redis->connect(config('redis.host'), config('redis.port')); // 根据实际配置调整主机和端口
|
||||
// 选择数据库1
|
||||
$this->redis->select(1);
|
||||
$this->redis->select(10);
|
||||
$this->cache_time = 60*60; //缓存一小时
|
||||
} catch (\Exception $e) {
|
||||
Log::record('Redis连接失败: ' . $e->getMessage(), 'error');
|
||||
@@ -35,9 +35,13 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
/**
|
||||
* 重构后的抽奖方法 - 优化响应速度
|
||||
*/
|
||||
public function draw_gift($gift_bag_id, $user_id, $gift_user_ids, $num = 1, $room_id = 0, $heart_id = 0,$auction_id = 0)
|
||||
public function draw_gift(int $gift_bag_id, int $user_id, string $gift_user_ids, $num = 1, $room_id = 0, $heart_id = 0, $auction_id = 0)
|
||||
{
|
||||
try {
|
||||
$bag_data = db::name("vs_gift_bag")->field('id,status')->where('id', $gift_bag_id)->find();
|
||||
if($bag_data['status']==0){ //其他转盘游戏
|
||||
return ['code' => 0, 'msg' => '游戏已关闭', 'data' => null];
|
||||
}
|
||||
// 收礼人
|
||||
$gift_user_ids = explode(',', $gift_user_ids);
|
||||
$total_num = $num * count($gift_user_ids); //总数量
|
||||
@@ -50,7 +54,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
return $validationResult;
|
||||
}
|
||||
//2.预计算抽奖结果
|
||||
$precomputeResult = $this->precomputeDrawResults($gift_bag_id, $total_num, $gift_user_ids,$periods );
|
||||
$precomputeResult = $this->precomputeDrawResults($gift_bag_id, $total_num, $gift_user_ids,$periods,$user_id );
|
||||
$precomputedResults = $precomputeResult['precomputedResults']; //预计算结果集
|
||||
$availableGiftss = $precomputeResult['precomputedResultss']; //可用礼物/需更新的礼物/需更新
|
||||
|
||||
@@ -69,7 +73,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
'precomputedResults' => $precomputedResults,
|
||||
];
|
||||
$this->redis->setex($key, 86400 * 7, "超出数量".json_encode($errorData));
|
||||
return ['code' => 0, 'msg' => '网络加载失败,请重试!', 'data' => null];
|
||||
return ['code' => 0, 'msg' => '活动火爆,请稍后重试!', 'data' => null];
|
||||
}
|
||||
$giftCounts = $this->countGifts($precomputedResults);
|
||||
foreach ($giftCounts as $giftId => $count) {
|
||||
@@ -85,7 +89,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
'giftUserCountsJianCha' => $count,
|
||||
];
|
||||
$this->redis->setex($key, 86400 * 7, "礼物数量超出限制 ".json_encode($errorData));
|
||||
return ['code' => 0, 'msg' => '网络加载失败,请重试!', 'data' => null];
|
||||
return ['code' => 0, 'msg' => '活动火爆,请稍后重试!', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,23 +134,28 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
if ($this->redis) {
|
||||
$this->redis->setex($key, 86400 * 7, $e->getMessage() . ' ' . json_encode($errorData));
|
||||
}
|
||||
return ['code' => 0, 'msg' => "网络加载失败,请重试!", 'data' => null];
|
||||
return ['code' => 0, 'msg' => "活动火爆,请稍后重试!", 'data' => null];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 预计算抽奖结果
|
||||
*/
|
||||
private function precomputeDrawResults($gift_bag_id, $total_num, $gift_user_ids,$periods)
|
||||
private function precomputeDrawResults($gift_bag_id, $total_num, $gift_user_ids,$periods,$user_id)
|
||||
{
|
||||
//查询需要关禁闭的用户user_code
|
||||
$pan_xian_userids = get_system_config_value('pan_xian_userids');
|
||||
$pan_xian_userids_id = db::name('user')->where(['user_code'=>['in',$pan_xian_userids]])->column('id');//用户user_code转Id
|
||||
|
||||
$pan_total_draw_times = $this->getCachedPanDrawTimes($gift_bag_id); //总抽奖次数
|
||||
$pan_total_remaining = $this->getCachedPanTotalRemaining($gift_bag_id); //剩余数量
|
||||
//获取可用礼物
|
||||
$availableGifts = $this->getAvailableGifts($gift_bag_id,$pan_total_draw_times+$total_num);
|
||||
$availableGifts = $this->getAvailableGifts($gift_bag_id,$pan_total_draw_times+$total_num,$user_id);
|
||||
$giftInfoMap = $this->getCachedPanGiftInfoMap($gift_bag_id);//预加载礼物信息
|
||||
$remaining_available_gifts = [];
|
||||
if (empty($availableGifts) ||$pan_total_remaining ==0) {
|
||||
//重置奖池
|
||||
$availableGifts = $this->resetPoolAndReload($gift_bag_id);
|
||||
$periods = $this->getCachedGiftBag($gift_bag_id)['periods']??$periods; // 获取新期数
|
||||
if (empty($availableGifts)) {
|
||||
throw new \Exception('重置奖池后仍无可用礼物');
|
||||
}
|
||||
@@ -209,6 +218,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
}
|
||||
}
|
||||
$pan_total_draw_times = $this->getCachedPanDrawTimes($gift_bag_id,"clear");//总抽奖次数重置
|
||||
$periods = $this->getCachedGiftBag($gift_bag_id)['periods']??$periods; // 获取新期数
|
||||
}
|
||||
// 再从新奖池中分配剩余所需礼物
|
||||
if ($newGiftsNeeded > 0 && !empty($availableGifts)) {
|
||||
@@ -227,6 +237,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
if(!$selectedGift){
|
||||
//重置奖池
|
||||
$availableGifts = $this->resetPoolAndReload($gift_bag_id);
|
||||
$periods = $this->getCachedGiftBag($gift_bag_id)['periods']??$periods; // 获取新期数
|
||||
if (empty($availableGifts)) {
|
||||
throw new \Exception('重置奖池后仍无可用礼物');
|
||||
}
|
||||
@@ -241,6 +252,32 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
$selectedGift = $this->selectGiftWithAliasMethod($aliasTableForNew);
|
||||
}
|
||||
$gift = $giftInfoMap[$selectedGift['foreign_id']]??[];
|
||||
|
||||
//关禁闭
|
||||
if(in_array($user_id,$pan_xian_userids_id)){
|
||||
$gift_bag_detail_duo = db::name("vs_gift_bag_detail")->where([ 'gift_bag_id' => $gift_bag_id,'remaining_number' => ['>',0]])->order('remaining_number', 'desc')->find();
|
||||
if($gift_bag_detail_duo){
|
||||
$selectedGift = $gift_bag_detail_duo;
|
||||
$gift = $giftInfoMap[$gift_bag_detail_duo['foreign_id']]??[];
|
||||
}
|
||||
}
|
||||
|
||||
//防止过高爆率,检查本期用户概率
|
||||
//当前用户在本期的(补偿 防止漏洞 超过预期 把盘拉平)
|
||||
//总抽奖金额(支出)
|
||||
// $total_money = db::name('vs_gift_bag_receive_log')->where(['gift_bag_id' => $gift_bag_id,'user_id' => $user_id,'periods'=>$periods])->sum('bag_price');
|
||||
// //总礼物价值(收入)
|
||||
// $total_gift_money = db::name('vs_gift_bag_receive_log')->where(['gift_bag_id' => $gift_bag_id,'user_id' => $user_id,'periods'=>$periods])->sum('gift_price');
|
||||
// if($total_money>0 && $total_gift_money>0){
|
||||
// $ratio =round(($total_gift_money / $total_money),3) ?? 0;
|
||||
// if($ratio > 1.03){
|
||||
// $gift_bag_detail_duo = db::name("vs_gift_bag_detail")->where([ 'gift_bag_id' => $gift_bag_id,'remaining_number' => ['>',0]])->order('remaining_number', 'desc')->find();
|
||||
// if($gift_bag_detail_duo){
|
||||
// $gift = $giftInfoMap[$gift_bag_detail_duo['foreign_id']]??[];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
$precomputedResults[] = [
|
||||
'gift_user_id' => $giftUserId,
|
||||
'gift_bag_detail' => $selectedGift,
|
||||
@@ -304,6 +341,17 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
if (in_array($user_id, $gift_user_ids)) {
|
||||
return ['code' => 0, 'msg' => "收礼人不能包含自己", 'data' => null];
|
||||
}
|
||||
foreach ($gift_user_ids as $gift_user_id){
|
||||
//查询是否实名认证
|
||||
$is_real = model('UserData')->real_name_info($gift_user_id);
|
||||
if($is_real['code']==0){
|
||||
return ['code' => 0, 'msg' => '收礼用户中有未实名,暂不支持收礼', 'data' => null];
|
||||
}else{
|
||||
if($is_real['data']['is_real'] !=1){
|
||||
return ['code' => 0, 'msg' => '收礼用户中有未实名,暂不支持收礼', 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
// 验证用户ID
|
||||
if (empty($user_id)) {
|
||||
return ['code' => 0, 'msg' => '用户ID不能为空', 'data' => null];
|
||||
@@ -313,7 +361,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
return ['code' => 0, 'msg' => '盲盒ID不能为空', 'data' => null];
|
||||
}
|
||||
// 检查用户金币
|
||||
$user_waller = db::name('user_wallet')
|
||||
$user_waller = db::name('user_wallet_coin')
|
||||
->where(['user_id' => $user_id])
|
||||
->find();
|
||||
if (!$user_waller) {
|
||||
@@ -374,7 +422,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
* @param $gift_bag_id
|
||||
* @param $total_draw_times 总抽奖次数
|
||||
*/
|
||||
private function getAvailableGifts($gift_bag_id, $pan_total_draw_times = 0)
|
||||
private function getAvailableGifts($gift_bag_id, $pan_total_draw_times = 0,$user_id=0)
|
||||
{
|
||||
$gift_bag_detail_data = $this->getCachedGiftBagDetail($gift_bag_id);
|
||||
$gift_detail_data = [];
|
||||
@@ -383,6 +431,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
$gift_detail_data[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
return $gift_detail_data;
|
||||
}
|
||||
|
||||
@@ -407,7 +456,14 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
Cache::rm("pan_gift_bag_detail".$gift_bag_id);
|
||||
|
||||
// 重新获取可用礼物
|
||||
return $this->getAvailableGifts($gift_bag_id);
|
||||
$getAvailableGifts = $this->getAvailableGifts($gift_bag_id);
|
||||
if(array_sum(array_column($getAvailableGifts, 'remaining_number')) < array_sum(array_column($getAvailableGifts, 'quantity'))){
|
||||
// 清除缓存
|
||||
Cache::rm("pan_gift_bag".$gift_bag_id);
|
||||
Cache::rm("pan_gift_bag_detail".$gift_bag_id);
|
||||
throw new \Exception('系统繁忙,请稍后再试!');
|
||||
}
|
||||
return $getAvailableGifts;
|
||||
} finally {
|
||||
// 释放锁
|
||||
$this->redis->del($lockKey);
|
||||
@@ -630,6 +686,13 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
if($type=="set"){
|
||||
$xlh_periods_num = $periods;
|
||||
Cache::set($cacheKey, $xlh_periods_num, 0);
|
||||
}else{
|
||||
if(empty($xlh_periods_num)){
|
||||
$xlh_periods_num = Db::name("vs_room_pan_xlh")
|
||||
->order('id desc')
|
||||
->value('periods');
|
||||
Cache::set($cacheKey, $xlh_periods_num, 0);
|
||||
}
|
||||
}
|
||||
return $xlh_periods_num;
|
||||
}
|
||||
@@ -689,7 +752,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
$this->batchInsertGiftBagReceiveLog($bag_data,$user_id, $boxTurntableLog,$room_id, $precomputedResults);
|
||||
|
||||
// 5. 发送礼物
|
||||
$result = $this->sendGiftsToRecipients($precomputedResults, $room_id,$user_id,$heart_id,$auction_id);
|
||||
$result = $this->sendGiftsToRecipients($bag_data,$precomputedResults, $room_id,$user_id,$heart_id,$auction_id);
|
||||
if (isset($result['code']) && $result['code'] !== 1) {
|
||||
throw new \Exception($result['msg']);
|
||||
}
|
||||
@@ -718,20 +781,13 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
private function deductUserCoins($user_id, $bagGiftPrice, $room_id , $bag_data=[])
|
||||
{
|
||||
// 使用悲观锁查询用户钱包
|
||||
$userWallet = db::name('user_wallet')
|
||||
$userWallet = db::name('user_wallet_coin')
|
||||
->where(['user_id' => $user_id])
|
||||
->find();
|
||||
if (!$userWallet || $userWallet['coin'] < $bagGiftPrice) {
|
||||
throw new \Exception('用户金币不足');
|
||||
}
|
||||
$walletUpdate = model('GiveGift')->change_user_cion_or_earnings_log(
|
||||
$user_id,
|
||||
$bagGiftPrice,
|
||||
$room_id,
|
||||
1,
|
||||
10,
|
||||
$bag_data['gift_bag_name'] .'抽奖消耗'
|
||||
);
|
||||
$walletUpdate = model('api/UserWallet')->change_user_cion_log($user_id, $bagGiftPrice, $room_id, 10, $bag_data['gift_bag_name'] .'抽奖消耗');
|
||||
if (!$walletUpdate) {
|
||||
throw new \Exception('扣除用户金币失败');
|
||||
}
|
||||
@@ -815,7 +871,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
/**
|
||||
* 发送礼物给接收者
|
||||
*/
|
||||
private function sendGiftsToRecipients($precomputedResults, $room_id,$user_id,$heart_id,$auction_id)
|
||||
private function sendGiftsToRecipients($bag_data,$precomputedResults, $room_id,$user_id,$heart_id,$auction_id)
|
||||
{
|
||||
// 统计每个用户每个礼物的数量
|
||||
$giftUserCounts = [];
|
||||
@@ -837,28 +893,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
if($userGift['count'] > 9){ //防止礼物超发,礼物超10个则不发送
|
||||
continue;
|
||||
}
|
||||
$giveGiftExt = [
|
||||
'gift_id' => $userGift['gift_id'],
|
||||
'count' => $userGift['count'],
|
||||
'gift_price' => $userGift['gift_price'],
|
||||
'all_gift_price' => $userGift['gift_price'] * $userGift['count'],
|
||||
'is_draw_gift' => 1
|
||||
];
|
||||
if(!empty($auction_id)){ //竞拍
|
||||
model('RoomAuction')->room_auction_join($auction_id,$user_id,$userGift['gift_id'],$userGift['count'],2,$giveGiftExt);
|
||||
}else{
|
||||
$res = model('Room')->room_gift(
|
||||
$user_id,
|
||||
$userGift['gift_user_id'],
|
||||
$userGift['gift_id'],
|
||||
$userGift['count'],
|
||||
1,
|
||||
$room_id,
|
||||
0,
|
||||
$heart_id,
|
||||
$giveGiftExt
|
||||
);
|
||||
}
|
||||
$res = model("api/SendGift")->single_send_gift_pan($user_id,$userGift['gift_user_id'],$userGift['gift_id'],$userGift['count'],1,$room_id,$bag_data['gift_bag_id'], $heart_id,$auction_id);
|
||||
if (isset($res) && $res['code'] != 1) {
|
||||
Log::record('发送礼物失败: ' . $res['msg'] . $userGift['gift_user_id'], "info");
|
||||
return ['code' => 0, 'msg' => $res['msg'], 'data' => null];
|
||||
@@ -869,13 +904,19 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
/**
|
||||
* 统计礼物数量
|
||||
*/
|
||||
private function countGifts($precomputedResults)
|
||||
private function countGifts($precomputedResults,$key_type = 1)
|
||||
{
|
||||
$giftCounts = [];
|
||||
foreach ($precomputedResults as $result) {
|
||||
$giftId = $result['gift_bag_detail']['foreign_id'];
|
||||
if (!isset($giftCounts[$giftId])) {
|
||||
$giftCounts[$giftId] = [
|
||||
$gift_user_id = $result['gift_user_id'];
|
||||
if($key_type ==1){
|
||||
$key = $giftId;
|
||||
}else{
|
||||
$key = $giftId.'_'.$gift_user_id;
|
||||
}
|
||||
if (!isset($giftCounts[$key])) {
|
||||
$giftCounts[$key] = [
|
||||
'gift_user_id' => $result['gift_user_id'],
|
||||
'gift_id' => $giftId,
|
||||
'count' => 0,
|
||||
@@ -883,7 +924,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
'quantity' => $result['gift_bag_detail']['quantity']
|
||||
];
|
||||
}
|
||||
$giftCounts[$giftId]['count']++;
|
||||
$giftCounts[$key]['count']++;
|
||||
}
|
||||
return $giftCounts;
|
||||
}
|
||||
@@ -911,7 +952,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
private function batchInsertBlindBoxResults($precomputedResults, $boxTurntableLog)
|
||||
{
|
||||
// 统计每个用户每个礼物的数量
|
||||
$giftUserCounts = $this->countGifts($precomputedResults);
|
||||
$giftUserCounts = $this->countGifts($precomputedResults,2);
|
||||
// 批量插入
|
||||
$batchInsertData = [];
|
||||
foreach ($giftUserCounts as $userGift) {
|
||||
@@ -1037,9 +1078,13 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
{
|
||||
$resultList = [];
|
||||
foreach ($giftCounts as $gift) {
|
||||
$gift_data = Db::name('vs_gift')->where(['gid'=>$gift['gift_id']])->find();
|
||||
$resultList[] = [
|
||||
'gift_id' => $gift['gift_id'],
|
||||
'count' => $gift['count']
|
||||
'count' => $gift['count'],
|
||||
'gift_price' => $gift_data['gift_price'],
|
||||
'gift_name' => $gift_data['gift_name'],
|
||||
'base_image' => $gift_data['base_image'],
|
||||
];
|
||||
}
|
||||
return [
|
||||
@@ -1068,6 +1113,10 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
return ['code' => 0, 'msg' => '用户不在房间,无法获取房主信息', 'data' => null];
|
||||
}
|
||||
$gift_bag_id = 13;
|
||||
$bag_data = db::name("vs_gift_bag")->field('id,status')->where('id', $gift_bag_id)->find();
|
||||
if($bag_data['status']==0){ //其他转盘游戏
|
||||
return ['code' => 0, 'msg' => '游戏已关闭', 'data' => null];
|
||||
}
|
||||
// 1. 获取并缓存盲盒配置
|
||||
$ext = $this->getCachedGiftBag($gift_bag_id); //获取转盘信息
|
||||
$bag_gift_price = $ext['xlh_box_price'] * $num;
|
||||
@@ -1099,18 +1148,11 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
$current_batch = min($batch_size, $num - $total_processed); // 当前批次处理数量
|
||||
// 批量扣除金币(只在第一次事务中处理)
|
||||
if ($total_processed == 0) {
|
||||
$user_waller = db::name('user_wallet')->where(['user_id' => $user_id])->find();
|
||||
$user_waller = db::name('user_wallet_coin')->where(['user_id' => $user_id])->find();
|
||||
if (!$user_waller || $user_waller['coin'] < $bag_gift_price) {
|
||||
return ['code' => 0, 'msg' => '用户金币不足', 'data' => null];
|
||||
}
|
||||
$wallet_update = model('GiveGift')->change_user_cion_or_earnings_log(
|
||||
$user_id,
|
||||
$bag_gift_price,
|
||||
$room_id,
|
||||
1,
|
||||
10,
|
||||
$ext['gift_bag_name'].'抽奖消耗'
|
||||
);
|
||||
$wallet_update = model('api/UserWallet')->change_user_cion_log($user_id, $bag_gift_price, $room_id, 10, $ext['gift_bag_name'].'抽奖消耗');
|
||||
if (!$wallet_update) {
|
||||
throw new \Exception('扣除用户金币失败');
|
||||
}
|
||||
@@ -1126,11 +1168,15 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
}
|
||||
}
|
||||
|
||||
//查询需要关禁闭的用户user_code
|
||||
$pan_xian_userids = get_system_config_value('pan_xian_userids');
|
||||
$pan_xian_userids_id = db::name('user')->where(['user_code'=>['in',$pan_xian_userids]])->column('id');//用户user_code转Id
|
||||
|
||||
// 处理当前批次的抽奖
|
||||
$inventory_updates = []; // 用于记录库存变化
|
||||
for ($i = 0; $i < $current_batch; $i++) {
|
||||
$total_draw_times = $this->getCachedPanDrawTimes($gift_bag_id) ?? 0; //已抽奖次数
|
||||
$availableGifts = $this->getAvailableGifts($gift_bag_id,$total_draw_times); //获取可用礼物
|
||||
$availableGifts = $this->getAvailableGifts($gift_bag_id,$total_draw_times,$user_id); //获取可用礼物
|
||||
if (empty($availableGifts)) {
|
||||
$availableGifts = $this->resetPoolAndReload($gift_bag_id);
|
||||
if (empty($availableGifts)) {
|
||||
@@ -1150,6 +1196,16 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
$inventory_updates[$selected_gift['id']] = ($inventory_updates[$selected_gift['id']] ?? 0) + 1;
|
||||
// 记录抽中结果
|
||||
$gift_id = $selected_gift['foreign_id'];
|
||||
|
||||
//关禁闭
|
||||
if(in_array($user_id,$pan_xian_userids_id)){
|
||||
$gift_bag_detail_duo = db::name("vs_gift_bag_detail")->where([ 'gift_bag_id' => $gift_bag_id,'remaining_number' => ['>',0]])->order('remaining_number', 'desc')->find();
|
||||
if($gift_bag_detail_duo){
|
||||
$gift_id = $gift_bag_detail_duo['foreign_id'];
|
||||
}
|
||||
}
|
||||
//关禁闭-end
|
||||
|
||||
$drawn_gifts[$gift_id] = ($drawn_gifts[$gift_id] ?? 0) + 1;
|
||||
// 处理主奖品
|
||||
if ($gift_id == $ext['locking_condition']['selected_gift_id']) {
|
||||
@@ -1158,6 +1214,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
$pan_xlh_num = $pan_xlh['num'] ?? 0;
|
||||
}
|
||||
$pan_xlh_num++;
|
||||
$pan_xlh_num_bf = $pan_xlh_num;
|
||||
cache::set('pan_xlh_num_'.$gift_bag_id.'_'.$pan_xlh['id'], $pan_xlh_num,$this->cache_time);
|
||||
$main_prize_updates[] = [
|
||||
'num' => $pan_xlh_num,
|
||||
@@ -1301,7 +1358,11 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
}
|
||||
// 8. 处理推送消息
|
||||
if ($is_zhong_jiang == 1) {
|
||||
$pan_xlh_num = cache::get('pan_xlh_num_'.$gift_bag_id.'_'.$pan_xlh['id']);
|
||||
if(cache::get('pan_xlh_num_'.$gift_bag_id.'_'.$pan_xlh['id'])){
|
||||
$pan_xlh_num = cache::get('pan_xlh_num_'.$gift_bag_id.'_'.$pan_xlh['id']);
|
||||
}else{
|
||||
$pan_xlh_num = $pan_xlh_num_bf;
|
||||
}
|
||||
$this->handlePrizeNotification($user_id, $room_id, $pan_xlh_num, $pan_xlh['id'],$ext['locking_condition']['locking_gift_id']);
|
||||
}
|
||||
//删除缓存
|
||||
@@ -1365,8 +1426,8 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
//测试数据
|
||||
// 20060 => [$selected_gift_id => 2],
|
||||
// 在这里可以添加更多规则 【正式规则】
|
||||
21222 => [$selected_gift_id => 6],//10012
|
||||
21259 => [$selected_gift_id => 6],//10049
|
||||
// 21222 => [$selected_gift_id => 6],//10012
|
||||
// 21259 => [$selected_gift_id => 6],//10049
|
||||
];
|
||||
// 如果没有指定用户或该用户没有特殊概率调整,则直接返回原数组
|
||||
if ($user_id <= 0 || !isset($probability_adjustments[$user_id])) {
|
||||
@@ -1413,8 +1474,8 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
}
|
||||
|
||||
if ($add_end_time <= 30) {
|
||||
Cache::set($cache_key, 30, 30);
|
||||
return 30;
|
||||
Cache::set($cache_key, 10, 10);
|
||||
return 10;
|
||||
}
|
||||
|
||||
return $add_end_time;
|
||||
@@ -1487,6 +1548,18 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
public function draw_gift_drop_bag($gift_bag_id, $user_id, $num = 1, $room_id = 0)
|
||||
{
|
||||
try {
|
||||
$open_monster_status = get_system_config_value('open_monster_status');
|
||||
$fun_activities_recharge_restrictions = get_system_config_value('fun_activities_recharge_restrictions');
|
||||
if($fun_activities_recharge_restrictions == 0){
|
||||
return ['code' => 0, 'msg' => '趣味活动关闭', 'data' => null];
|
||||
}
|
||||
if($gift_bag_id ==60 && $open_monster_status ==0){ //恋仙传说
|
||||
return ['code' => 0, 'msg' => '游戏已关闭', 'data' => null];
|
||||
}
|
||||
$bag_data = db::name("vs_gift_bag")->field('id,status')->where('id', $gift_bag_id)->find();
|
||||
if(in_array($gift_bag_id,[11,12,61]) && $bag_data['status']==0){ //其他转盘游戏
|
||||
return ['code' => 0, 'msg' => '游戏已关闭', 'data' => null];
|
||||
}
|
||||
// 参数验证
|
||||
$validation_result = $this->validateDrawParams($gift_bag_id, $user_id, $num);
|
||||
if ($validation_result['code'] !== 1) {
|
||||
@@ -1495,7 +1568,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
|
||||
// 获取转盘信息和用户钱包
|
||||
$bag_data = $this->getCachedGiftBag($gift_bag_id);
|
||||
$user_wallet = Db::name('user_wallet')->where(['user_id' => $user_id])->find();
|
||||
$user_wallet = Db::name('user_wallet_coin')->where(['user_id' => $user_id])->find();
|
||||
|
||||
if (!$user_wallet) {
|
||||
return ['code' => 0, 'msg' => '用户钱包不存在', 'data' => null];
|
||||
@@ -1507,7 +1580,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
}
|
||||
|
||||
// 检查奖池状态并准备礼物
|
||||
$pool_status = $this->prepareGiftPool($gift_bag_id, $num);
|
||||
$pool_status = $this->prepareGiftPool($gift_bag_id, $num,$user_id);
|
||||
if ($pool_status['code'] !== 1) {
|
||||
throw new \Exception($pool_status['msg']);
|
||||
}
|
||||
@@ -1528,7 +1601,8 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
$available_gifts,
|
||||
$remaining_available_gifts,
|
||||
$num,
|
||||
$periods
|
||||
$periods,
|
||||
$user_id
|
||||
);
|
||||
|
||||
if ($draw_result['code'] !== 1) {
|
||||
@@ -1586,7 +1660,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
$this->redis->setex($key, 86400 * 7, $e->getMessage() . ' ' . json_encode($error_data));
|
||||
}
|
||||
|
||||
return ['code' => 0, 'msg' => "网络加载失败,请重试!", 'data' => null];
|
||||
return ['code' => 0, 'msg' => "活动火爆,请稍后重试!", 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1613,11 +1687,11 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
/**
|
||||
* 准备奖池
|
||||
*/
|
||||
private function prepareGiftPool($gift_bag_id, $num)
|
||||
private function prepareGiftPool($gift_bag_id, $num,$user_id)
|
||||
{
|
||||
$pan_total_draw_times = $this->getCachedPanDrawTimes($gift_bag_id);
|
||||
$pan_total_remaining = $this->getCachedPanTotalRemaining($gift_bag_id);
|
||||
$available_gifts = $this->getAvailableGifts($gift_bag_id, $pan_total_draw_times + $num);
|
||||
$available_gifts = $this->getAvailableGifts($gift_bag_id, $pan_total_draw_times + $num,$user_id);
|
||||
|
||||
$remaining_gifts = [];
|
||||
|
||||
@@ -1631,6 +1705,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
$this->getCachedPanDrawTimes($gift_bag_id, "clear");
|
||||
} else if ($pan_total_remaining < $num) {
|
||||
// 如果剩余数量不足,保存当前剩余礼物作为上期剩余
|
||||
// 但只分配实际剩余数量的礼物,避免超额分配
|
||||
$remaining_gifts = $available_gifts;
|
||||
$available_gifts = $this->resetPoolAndReload($gift_bag_id);
|
||||
|
||||
@@ -1639,6 +1714,9 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
}
|
||||
|
||||
$this->getCachedPanDrawTimes($gift_bag_id, "clear");
|
||||
} else {
|
||||
// 剩余数量足够,直接使用当前奖池
|
||||
// 不需要特殊处理,正常流程即可
|
||||
}
|
||||
|
||||
return [
|
||||
@@ -1654,32 +1732,114 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
/**
|
||||
* 执行礼物抽取
|
||||
*/
|
||||
private function performGiftDrawing($gift_bag_id, $available_gifts, $remaining_gifts, $num, $periods)
|
||||
private function performGiftDrawing($gift_bag_id, $available_gifts, $remaining_gifts, $num, $periods,$user_id=0)
|
||||
{
|
||||
//查询需要关禁闭的用户user_code
|
||||
$pan_xian_userids = get_system_config_value('pan_xian_userids');
|
||||
$pan_xian_userids_id = db::name('user')->where(['user_code'=>['in',$pan_xian_userids]])->column('id');//用户user_code转Id
|
||||
|
||||
$drawn_gifts = [];
|
||||
$precomputed_results = [];
|
||||
$available_giftss = [];
|
||||
$inventory_updates = [];
|
||||
$old_gift_num = 0;
|
||||
|
||||
// 先处理上期剩余的礼物
|
||||
// 先处理上期剩余的礼物,但要严格控制数量,避免超额分配
|
||||
if (!empty($remaining_gifts)) {
|
||||
foreach ($remaining_gifts as $remaining_gift) {
|
||||
$gift_id = $remaining_gift['foreign_id'];
|
||||
$drawn_gifts[$gift_id] = ($drawn_gifts[$gift_id] ?? 0) + 1;
|
||||
// 获取上期实际剩余数量
|
||||
$remaining_total = array_sum(array_column($remaining_gifts, 'remaining_number'));
|
||||
// 计算实际可从剩余礼物中分配的数量
|
||||
$actual_old_gift_num = min($num, $remaining_total);
|
||||
|
||||
$gift_queue = []; // 初始化礼物队列
|
||||
foreach ($remaining_gifts as $remaining_gift) {
|
||||
$gift_id = $remaining_gift['foreign_id'];//礼物ID
|
||||
|
||||
//关禁闭
|
||||
if(in_array($user_id,$pan_xian_userids_id)){
|
||||
$gift_bag_detail_duo = db::name("vs_gift_bag_detail")->where([ 'gift_bag_id' => $gift_bag_id,'remaining_number' => ['>',0]])->order('remaining_number', 'desc')->find();
|
||||
if($gift_bag_detail_duo){
|
||||
$gift_id = $gift_bag_detail_duo['foreign_id'];
|
||||
$remaining_gift = $gift_bag_detail_duo;
|
||||
}
|
||||
}
|
||||
//关禁闭-end
|
||||
|
||||
//查询上期这个礼物抽取数量----------------
|
||||
$count_num = Db::name('vs_gift_bag_receive_pan_log')->where(['gift_bag_id' => $gift_bag_id,'gift_id' => $gift_id,'periods'=>$periods-1])->count();
|
||||
$error_gifts[$gift_id] =[
|
||||
//上期抽中数量
|
||||
'count_num'=>$count_num,
|
||||
'quantity'=>$remaining_gift['quantity'],
|
||||
'remaining_number'=>$remaining_gift['remaining_number'] // 添加实际剩余数量
|
||||
];
|
||||
|
||||
//上期这个礼物抽走数量与礼物上限数量相同剔除这个礼物
|
||||
if ($count_num >= $remaining_gift['quantity']){
|
||||
//错误日志记录--------
|
||||
$key = 'blind_box_draw_shengyu1_errors_' . date('Y-m-d-H-i-s');
|
||||
$errorData=[
|
||||
'gift_bag_id' => $gift_bag_id,
|
||||
'available_gifts' => $available_gifts,
|
||||
'remaining_gifts' => $remaining_gifts,
|
||||
'num' => $num,
|
||||
'gift_id' => $gift_id,
|
||||
'periods' => $periods,
|
||||
];
|
||||
$this->redis->setex($key, 86400 * 7, "礼物数量超出限制 ".json_encode($errorData));
|
||||
//错误日志记录--------end
|
||||
//剔除该礼物
|
||||
continue;
|
||||
}
|
||||
|
||||
// 将礼物按剩余数量添加到队列中
|
||||
for ($i = 0; $i < $remaining_gift['remaining_number']; $i++) {
|
||||
$gift_queue[] = $remaining_gift;
|
||||
}
|
||||
}
|
||||
// 从礼物队列中分配礼物,直到达到实际需要的数量
|
||||
for ($i = 0; $i < $actual_old_gift_num && $i < count($gift_queue); $i++) {
|
||||
$selected_gift = $gift_queue[$i];
|
||||
$gift_id = $selected_gift['foreign_id'];
|
||||
|
||||
//查询上把这个礼物抽取数量------防止并发多出容错----------
|
||||
$drawn_gifts[$gift_id] = ($drawn_gifts[$gift_id] ?? 0) + 1;
|
||||
$precomputed_results[] = [
|
||||
'gift_id' => $gift_id,
|
||||
'gift_detail_id' => $remaining_gift['id'],
|
||||
'gift_bag_detail' => $remaining_gift,
|
||||
'gift_detail_id' => $selected_gift['id'],
|
||||
'gift_bag_detail' => $selected_gift,
|
||||
'gift' => Db::name('vs_gift')->where(['gid' => $gift_id])->find(),
|
||||
'gift_user_id' => 0,
|
||||
'periods' => $periods,
|
||||
];
|
||||
$old_gift_num++;
|
||||
}
|
||||
//防止上把数据错误
|
||||
foreach ($drawn_gifts as $gift_id => $count){
|
||||
//正常数量
|
||||
$normal_num = $error_gifts[$gift_id]['quantity'] - $error_gifts[$gift_id]['count_num'];
|
||||
if($count > $normal_num){
|
||||
//错误日志记录--------
|
||||
$key = 'blind_box_draw_shengyu2_errors_' . date('Y-m-d-H-i-s');
|
||||
$errorData=[
|
||||
'gift_bag_id' => $gift_bag_id,
|
||||
'available_gifts' => $available_gifts,
|
||||
'remaining_gifts' => $remaining_gifts,
|
||||
'num' => $num,
|
||||
'gift_id' => $gift_id,
|
||||
'periods' => $periods,
|
||||
'error_gifts'=>$error_gifts,
|
||||
'normal_num'=>$normal_num
|
||||
];
|
||||
$this->redis->setex($key, 86400 * 7, "礼物数量超出限制 ".json_encode($errorData));
|
||||
//错误日志记录--------end
|
||||
$drawn_gifts[$gift_id] = $normal_num;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 计算还需要抽取的数量
|
||||
$remaining_count = $num - count($remaining_gifts);
|
||||
$remaining_count = max(0, $num - $old_gift_num);
|
||||
|
||||
// 抽取新礼物
|
||||
for ($i = 0; $i < $remaining_count; $i++) {
|
||||
@@ -1687,6 +1847,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
|
||||
if (!$selected_gift) {
|
||||
$gift_bag_detail = $this->resetPoolAndReload($gift_bag_id);
|
||||
$periods = $this->getCachedGiftBag($gift_bag_id)['periods']??$periods; // 获取新期数
|
||||
$selected_gift = $this->selectGiftFromAvailable($gift_bag_detail);
|
||||
|
||||
if (!$selected_gift) {
|
||||
@@ -1710,7 +1871,6 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
'gift_user_id' => 0,
|
||||
'periods' => $periods,
|
||||
];
|
||||
|
||||
$available_giftss[] = $result_entry;
|
||||
$precomputed_results[] = $result_entry;
|
||||
|
||||
|
||||
@@ -151,6 +151,15 @@ class Chat extends Model
|
||||
//爆币房推送信息
|
||||
// BlindCoinRoom = 1100,
|
||||
|
||||
//酒吧房撩TA推送
|
||||
// BarRoomLiaoTa = 1200,
|
||||
//酒吧房开私密房
|
||||
// BarRoomOpenPrivateRoom = 1201,
|
||||
//酒吧房抱麦
|
||||
// BarRoomUpSeat = 1202,
|
||||
//酒吧房上麦后设置自定义礼物设置
|
||||
// BarRoomSetCustomGift = 1203,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Cache;
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
@@ -17,8 +18,10 @@ class Decorate extends Model
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
// 定义字段类型 1头像框 2坐骑 3麦圈 6个人靓号 7房间靓号 8公会靓号
|
||||
public $TypeArray = [1=>'头像框',12=>'降身卡',2=>'坐骑',9=>'聊天气泡',6=>'个人靓号',7=>'房间靓号',8=>'公会靓号',3=>'麦圈',10=>'CP特效',11=>'CP装扮'];
|
||||
public $TypeArray = [1=>'头像框',12=>'降身卡',2=>'坐骑',9=>'聊天气泡',6=>'个人靓号',7=>'房间靓号',8=>'公会靓号',3=>'麦圈',10=>'CP特效',11=>'CP装扮',13=>"房间热度卡"];
|
||||
protected $FromType = [1=>'购买',2=>'后台赠送',3=>'礼盒开奖',4=>'好友赠送',5=>'首充赠送',6=>'天降好礼获得',7=>'财富等级特权赠送',8=>'新人充值好礼',9=>'爵位购买赠送',10=>'任务奖励',11=>"每日签到"];
|
||||
//特殊装扮(卡片类型 可直接购买 不用配置天数价格)
|
||||
public $SpecialType = [12=>'降身卡',13=>'房间热度卡'];
|
||||
public function __construct($data = [])
|
||||
{
|
||||
parent::__construct($data);
|
||||
@@ -26,7 +29,7 @@ class Decorate extends Model
|
||||
}
|
||||
|
||||
//获取装扮类型
|
||||
public function get_type_list($have_hot = 0)
|
||||
public function get_type_list($have_hot = 0,$from=1)
|
||||
{
|
||||
$no_show_ids = [7,8,3,10,11];
|
||||
$label = $this->TypeArray;
|
||||
@@ -39,6 +42,11 @@ class Decorate extends Model
|
||||
if (in_array($k, $no_show_ids)) {
|
||||
continue;
|
||||
}
|
||||
if($from==2){
|
||||
if($k==13){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$data[$i]['id'] = $k;
|
||||
$data[$i]['name'] = $v;
|
||||
++$i;
|
||||
@@ -76,9 +84,9 @@ class Decorate extends Model
|
||||
'a.type' => $type,
|
||||
];
|
||||
}
|
||||
if($type == 12){
|
||||
if(in_array($type, array_keys($this->SpecialType))){
|
||||
$map = [
|
||||
'type' => 12,
|
||||
'type' => $type,
|
||||
'delete_time' => 0,
|
||||
'show_status' => 1,
|
||||
'is_buy' => 1
|
||||
@@ -87,12 +95,22 @@ class Decorate extends Model
|
||||
->order('price asc')
|
||||
->select();
|
||||
}else{
|
||||
$list = DB::name($this->table)->alias('a')->join('fa_vs_decorate_price b', 'a.did = b.did')->field('a.did,a.title,a.type,a.base_image,a.play_image,min(b.price) as price,special_num')->where($map)->group('b.did')->order('price asc')->select();
|
||||
$list = DB::name($this->table)
|
||||
->alias('a')->join('fa_vs_decorate_price b', 'a.did = b.did')
|
||||
->field('a.did,a.title,a.type,a.base_image,a.play_image,min(b.price) as price,special_num,b.original_price,b.discount')->where($map)->group('b.did')->order('price asc')->select();
|
||||
}
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['base_image'] = localpath_to_netpath($v['base_image']);
|
||||
$v['play_image'] = localpath_to_netpath($v['play_image']);
|
||||
$v['price'] = (int)$v['price'];
|
||||
if(isset($v['discount'])){
|
||||
if($v['discount']<=0 || $v['discount']>=10){
|
||||
$v['discount'] = 0;
|
||||
$v['discount_str'] = "无折扣";
|
||||
}else{
|
||||
$v['discount_str'] = $v['discount']."折";
|
||||
}
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
|
||||
}
|
||||
@@ -103,7 +121,7 @@ class Decorate extends Model
|
||||
if (!$decorate) {
|
||||
return ['code' => 0, 'msg' => '参数错误'];
|
||||
}
|
||||
if($decorate['type'] == 12){
|
||||
if(in_array($decorate['type'], array_keys($this->SpecialType))){
|
||||
$result['title'] = $decorate['title'];
|
||||
$result['price'] = (int)$decorate['price'];
|
||||
$result['base_image'] = localpath_to_netpath($decorate['base_image']);
|
||||
@@ -115,6 +133,7 @@ class Decorate extends Model
|
||||
$result['title'] = $decorate['title'];
|
||||
foreach ($decorate_price as $k => $v) {
|
||||
$result['price_list'][$k]['price'] = (int)$v['price'];
|
||||
$result['price_list'][$k]['original_price'] = $v['original_price'];
|
||||
$result['price_list'][$k]['discount'] = $v['discount'];
|
||||
$result['price_list'][$k]['day'] = $v['day'];
|
||||
//月
|
||||
@@ -137,6 +156,11 @@ class Decorate extends Model
|
||||
*
|
||||
*/
|
||||
public function pay_decorate($uid, $did, $day=0,$from_type=1,$give_uid=0,$log_remark="",$num=1){
|
||||
if(empty($day) && in_array($from_type,array_keys($this->SpecialType))){
|
||||
$day = 0;
|
||||
}else{
|
||||
$day = db::name('vs_decorate_price')->where(['did'=>$did])->order('day asc')->value('day');
|
||||
}
|
||||
if(empty($log_remark)){
|
||||
$log_remark = $this->FromType[$from_type];
|
||||
}
|
||||
@@ -154,7 +178,7 @@ class Decorate extends Model
|
||||
if(!$decorate_info){
|
||||
return ['code' => 0, 'msg' => '该装扮不存在'.$did, 'data' => null];
|
||||
}
|
||||
if($decorate_info['type'] != 12){
|
||||
if(!in_array($decorate_info['type'],array_keys($this->SpecialType))){
|
||||
//该天数是否存在
|
||||
$map = [];
|
||||
$map = [
|
||||
@@ -177,7 +201,7 @@ class Decorate extends Model
|
||||
}
|
||||
}else{
|
||||
$decorate_price_info = [
|
||||
'price' => $decorate_info['price'],
|
||||
'price' => $decorate_info['price'] * $num,
|
||||
'day' => 0
|
||||
];
|
||||
}
|
||||
@@ -234,7 +258,7 @@ class Decorate extends Model
|
||||
$data['num'] = 1;
|
||||
$result = db::name('vs_user_decorate')->insert($data);
|
||||
}else{
|
||||
if($decorate_info['type'] == 12){
|
||||
if(in_array($decorate_info['type'],array_keys($this->SpecialType))){
|
||||
$result = db::name('vs_user_decorate')->where('udid', $user_decorate_data['udid'])->update([
|
||||
'is_using' => 2,
|
||||
'num' => $user_decorate_data['num'] + $num,
|
||||
@@ -273,7 +297,7 @@ class Decorate extends Model
|
||||
if($decorate_price_info['day'] ==0){
|
||||
$insert_data['end_time'] = 0; //永久礼物
|
||||
}
|
||||
$insert_data['day_num'] = $day;
|
||||
$insert_data['day_num'] = $day??0;
|
||||
$insert_data['pay_price'] = $pay_price ;
|
||||
$insert_data['special_num'] = $decorate_info['special_num'];
|
||||
$insert_data['give_uid'] = $give_uid;
|
||||
@@ -292,16 +316,16 @@ class Decorate extends Model
|
||||
}catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => "请重试", 'data' => null];
|
||||
return ['code' => 0, 'msg' => "请重试".$e->getMessage(), 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//用户装扮列表
|
||||
public function user_decorate($uid, $type,$page=1, $limit=10){
|
||||
if($type == 12){
|
||||
if(in_array($type, array_keys($this->SpecialType))){
|
||||
$reslut = db::name('vs_user_decorate')
|
||||
->alias('ud')->join('vs_decorate d', 'ud.did = d.did')
|
||||
->field('ud.udid,ud.user_id,ud.is_using,ud.end_time,ud.is_perpetual,ud.special_num,d.title,d.base_image,d.play_image,d.type,ud.num,d.ext_value')
|
||||
->field('ud.udid,ud.user_id,ud.is_using,ud.end_time,ud.is_perpetual,ud.special_num,d.title,d.base_image,d.play_image,d.type,ud.num,d.ext_value,d.price')
|
||||
->where('ud.user_id', $uid)
|
||||
->where('ud.type', $type)
|
||||
->where(['ud.num'=>[">",0]])
|
||||
@@ -310,7 +334,7 @@ class Decorate extends Model
|
||||
}else{
|
||||
$reslut = db::name('vs_user_decorate')
|
||||
->alias('ud')->join('vs_decorate d', 'ud.did = d.did')
|
||||
->field('ud.udid,ud.user_id,ud.is_using,ud.end_time,ud.is_perpetual,ud.special_num,d.title,d.base_image,d.play_image,d.type')
|
||||
->field('ud.udid,ud.user_id,ud.is_using,ud.end_time,ud.is_perpetual,ud.special_num,d.title,d.base_image,d.play_image,d.type,d.price')
|
||||
->where('ud.user_id', $uid)
|
||||
->where('ud.type', $type)
|
||||
->where(['ud.end_time'=>[">=",time()]])
|
||||
@@ -330,7 +354,7 @@ class Decorate extends Model
|
||||
}
|
||||
|
||||
// 设置用户装修
|
||||
public function set_user_decorate($uid,$udid)
|
||||
public function set_user_decorate($uid,$udid,$room_id,$num=1)
|
||||
{
|
||||
$map = [];
|
||||
$map = [
|
||||
@@ -341,7 +365,7 @@ class Decorate extends Model
|
||||
if (empty($info)) {
|
||||
return ['code' => 0, 'msg' => '装扮不存在', 'data' => null];
|
||||
}
|
||||
if($info['type'] == 12){
|
||||
if(in_array($info['type'],array_keys($this->SpecialType))){
|
||||
if ($info['num']-1 < 0) {
|
||||
return ['code' => 0, 'msg' => '无可用装扮', 'data' => null];
|
||||
}
|
||||
@@ -374,8 +398,8 @@ class Decorate extends Model
|
||||
$data = [];
|
||||
$data['is_using'] = 1;
|
||||
$data['updatetime'] = time();
|
||||
if($info['type'] == 12){
|
||||
$data['num'] = $info['num'] - 1;
|
||||
if(in_array($info['type'],array_keys($this->SpecialType))){
|
||||
$data['num'] = $info['num'] - $num;
|
||||
}
|
||||
$reslut = Db::name('vs_user_decorate')->where($map)->update($data);
|
||||
if (!$reslut) {
|
||||
@@ -409,7 +433,37 @@ class Decorate extends Model
|
||||
'createtime'=> time()
|
||||
]);
|
||||
}
|
||||
}else{
|
||||
}elseif($info['type'] == 13){//房间热度卡 增加房间热度
|
||||
if (empty($room_id)) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
$room_info = db::name('vs_room')->where(['id' => $room_id])->find();
|
||||
if (empty($room_info)) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '房间不存在', 'data' => null];
|
||||
}
|
||||
$increase_hot_value_all = 0;
|
||||
for ($i = 0; $i < $num; $i++) {
|
||||
$increase_hot_value = db::name('vs_decorate')->where(['did' => $info['did']])->value('ext_value') ?? 0;
|
||||
if ($room_info['today_hot_value'] <= $increase_hot_value) {
|
||||
db::name('vs_room')->where(['id' => $room_id])->update(['today_hot_value' => 0]);
|
||||
} else {
|
||||
db::name('vs_room')->where(['id' => $room_id])->setInc('today_hot_value', $increase_hot_value);
|
||||
}
|
||||
$increase_hot_value_all += $increase_hot_value;
|
||||
}
|
||||
//记录日志
|
||||
db::name('vs_room_hot_up_log')->insert([
|
||||
'did' => $udid,
|
||||
'user_id' => $uid,
|
||||
'room_id' => $room_id,
|
||||
'hot_value' => $increase_hot_value_all,
|
||||
'before_hot_value' => $room_info['today_hot_value'],
|
||||
'end_time' => date('Y-m-d H:00:00', time()),
|
||||
'createtime' => time()
|
||||
]);
|
||||
} else{
|
||||
//推送信息去所在房间
|
||||
//查询当前所在房间
|
||||
$room_id = db::name('vs_room_visitor')->where(['user_id' => $uid])->order('id' , 'desc')->value('room_id');
|
||||
@@ -528,4 +582,123 @@ class Decorate extends Model
|
||||
}
|
||||
return $reslut;
|
||||
}
|
||||
|
||||
//房间热度卡使用
|
||||
public function room_hot_card($uid,$udid,$room_id,$num=1)
|
||||
{
|
||||
$map = [];
|
||||
if($udid){
|
||||
$map = [
|
||||
'user_id' => $uid,
|
||||
'udid' => $udid
|
||||
];
|
||||
$info = db::name('vs_user_decorate')->where($map)->find();
|
||||
if (empty($info)) {
|
||||
return ['code' => 0, 'msg' => '房间热度卡不存在', 'data' => null];
|
||||
}
|
||||
if ($info['num']-$num < 0) {
|
||||
return ['code' => 0, 'msg' => '无可用房间热度卡', 'data' => null];
|
||||
}
|
||||
}else{
|
||||
$map = [
|
||||
'user_id' => $uid,
|
||||
'type' => 13,
|
||||
'num' => ['>',0]
|
||||
];
|
||||
$info = db::name('vs_user_decorate')->where($map)->select();
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
if($udid){
|
||||
$map = [
|
||||
'user_id' => $uid,
|
||||
'udid' => $udid
|
||||
];
|
||||
$data = [];
|
||||
$data['is_using'] = 1;
|
||||
$data['updatetime'] = time();
|
||||
$data['num'] = $info['num'] - $num;
|
||||
$reslut = Db::name('vs_user_decorate')->where($map)->update($data);
|
||||
if (!$reslut) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => "使用失败", 'data' => null];
|
||||
}
|
||||
|
||||
if (empty($room_id)) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
$room_info = db::name('vs_room')->where(['id' => $room_id])->find();
|
||||
if (empty($room_info)) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '房间不存在', 'data' => null];
|
||||
}
|
||||
$increase_hot_value = db::name('vs_decorate')->where(['did' => $info['did']])->value('ext_value') ?? 0;
|
||||
$increase_hot_value = $increase_hot_value * $num;
|
||||
db::name('vs_room')->where(['id' => $room_id])->setInc('today_hot_value', $increase_hot_value);
|
||||
//记录日志
|
||||
db::name('vs_room_hot_up_log')->insert([
|
||||
'did' => $info['did'],
|
||||
'user_id' => $uid,
|
||||
'room_id' => $room_id,
|
||||
'hot_value' => $increase_hot_value,
|
||||
'before_hot_value' => $room_info['today_hot_value'],
|
||||
'end_time' => date('Y-m-d H:00:00', time()),
|
||||
'createtime' => time()
|
||||
]);
|
||||
}else{
|
||||
$map = [
|
||||
'user_id' => $uid,
|
||||
'type' => 13,
|
||||
'num' => ['>',0]
|
||||
];
|
||||
$data = [];
|
||||
$data['is_using'] = 1;
|
||||
$data['updatetime'] = time();
|
||||
$data['num'] = 0;
|
||||
$result = Db::name('vs_user_decorate')->where($map)->update($data);
|
||||
if (!$result) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => "使用失败", 'data' => null];
|
||||
}
|
||||
if (empty($room_id)) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
$room_info = db::name('vs_room')->where(['id' => $room_id])->find();
|
||||
if (empty($room_info)) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '房间不存在', 'data' => null];
|
||||
}
|
||||
$increase_hot_value_all = 0;
|
||||
foreach ($info as $key => $value) {
|
||||
$increase_hot_value = db::name('vs_decorate')->where(['did' => $value['did']])->value('ext_value') ?? 0;
|
||||
$increase_hot_value = $increase_hot_value * $value['num'];
|
||||
$increase_hot_value_all += $increase_hot_value;
|
||||
}
|
||||
db::name('vs_room')->where(['id' => $room_id])->setInc('today_hot_value', $increase_hot_value_all);
|
||||
//记录日志
|
||||
db::name('vs_room_hot_up_log')->insert([
|
||||
'did' => 0,
|
||||
'user_id' => $uid,
|
||||
'room_id' => $room_id,
|
||||
'hot_value' => $increase_hot_value_all,
|
||||
'before_hot_value' => $room_info['today_hot_value'],
|
||||
'end_time' => date('Y-m-d H:00:00', time()),
|
||||
'createtime' => time()
|
||||
]);
|
||||
}
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
//更新装备缓存
|
||||
$cache_key = 'user_base_info_'.$uid;
|
||||
Cache::rm($cache_key);
|
||||
return ['code' => 1, 'msg' => "设置成功", 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => "设置失败", 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,22 +121,22 @@ class Family extends Model
|
||||
// 优化今日收益计算逻辑
|
||||
$todayStart = strtotime(date('Y-m-d'));
|
||||
if($v['createtime'] < $todayStart){
|
||||
$lists[$k]['today_earnings'] = round(db::name('vs_user_money_log')
|
||||
->where(['user_id' => $v['user_id'],'money_type' => 2,'change_type' =>11,'createtime' => ['between',[$todayStart,time()]]])
|
||||
->sum('change_value'), 4);//今日收益
|
||||
$lists[$k]['today_earnings'] = round(db::name('user_earnings_log')
|
||||
->where(['user_id' => $v['user_id'],'change_type' =>11,'createtime' => ['between',[$todayStart,time()]]])
|
||||
->sum('earnings'), 4);//今日收益
|
||||
}else{
|
||||
$lists[$k]['today_earnings'] = round(db::name('vs_user_money_log')
|
||||
->where(['user_id' => $v['user_id'],'money_type' => 2,'change_type' =>11,'createtime' => ['between',[$v['createtime'],time()]]])
|
||||
->sum('change_value'), 4);//今日收益
|
||||
$lists[$k]['today_earnings'] = round(db::name('user_earnings_log')
|
||||
->where(['user_id' => $v['user_id'],'change_type' =>11,'createtime' => ['between',[$v['createtime'],time()]]])
|
||||
->sum('earnings'), 4);//今日收益
|
||||
}
|
||||
|
||||
// 昨日收益计算逻辑优化
|
||||
$yesterdayStart = strtotime(date('Y-m-d', strtotime('-1 day')));
|
||||
$yesterdayEnd = strtotime(date('Y-m-d'));
|
||||
if($v['createtime'] <= $todayStart) {
|
||||
$lists[$k]['yesterday_earnings'] = round(db::name('vs_user_money_log')
|
||||
->where(['user_id' => $v['user_id'], 'money_type' => 2, 'change_type' => 11, 'createtime' => ['between', [$yesterdayStart, $yesterdayEnd]]])
|
||||
->sum('change_value'), 4);
|
||||
$lists[$k]['yesterday_earnings'] = round(db::name('user_earnings_log')
|
||||
->where(['user_id' => $v['user_id'], 'change_type' => 11, 'createtime' => ['between', [$yesterdayStart, $yesterdayEnd]]])
|
||||
->sum('earnings'), 4);
|
||||
}else{
|
||||
$lists[$k]['yesterday_earnings'] = 0;
|
||||
}
|
||||
|
||||
@@ -113,15 +113,17 @@ class Friend extends Model
|
||||
$return['user2_nickname'] = db::name('user')->where(['id'=>$originalPairs['user2_id']])->value('nickname');
|
||||
$return['heart_value'] = $originalPairs['heart_value'];
|
||||
$return['heart_id'] = $originalPairs['id'];
|
||||
$room_updatatime = db::name('vs_room')->where(['id' => $room_id,'step' => $step])->value('updatetime');
|
||||
if($room_updatatime){ //60秒内没操作 则创建关系无
|
||||
if(time() - $room_updatatime > 60){
|
||||
// $room_updatatime = db::name('vs_room')->where(['id' => $room_id,'step' => $step])->value('updatetime');
|
||||
$room_updatatime = db::name('vs_user_friending')->where(['id' => $id])->value('update_time');
|
||||
if($room_updatatime){ //180秒内没操作 则创建关系无(元旦 泽喜 说的)
|
||||
if(time() - $room_updatatime > 180){
|
||||
$this->createRelation(0,$room_id,$id,$return['user1_id'],$return['user2_id'],0);
|
||||
return ['code' => 1, 'msg' => '操作成功!', 'data' => $return];
|
||||
}
|
||||
}else{
|
||||
// 修改当前交友阶段
|
||||
db::name('vs_room')->where(['id' => $room_id])->update(['step' => $step,'updatetime' => time()]);
|
||||
db::name('vs_user_friending')->where(['id' => $id])->update(['update_time' => time()]);
|
||||
}
|
||||
}else{
|
||||
$step = 1;//结束下一轮
|
||||
@@ -131,7 +133,7 @@ class Friend extends Model
|
||||
$on_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',7],'user_id' => ['<>',0]])->select();
|
||||
if($on_pit){
|
||||
foreach ($on_pit as $pit){
|
||||
model('RoomPit')->DownPit($pit['user_id'], $room_id,$pit['pit_number']);
|
||||
model('api/RoomPit')->DownPit($pit['user_id'], $room_id,$pit['pit_number']);
|
||||
}
|
||||
}
|
||||
$return = null;
|
||||
@@ -139,7 +141,7 @@ class Friend extends Model
|
||||
|
||||
//结束交友游戏
|
||||
if($step == 1){
|
||||
db::name('vs_user_friending')->where(['id' => $id])->update(['status' => 2]);
|
||||
db::name('vs_user_friending')->where(['id' => $id])->update(['status' => 2,'update_time' => time()]);
|
||||
}
|
||||
//推送给前端消息
|
||||
$text['text'] = $step == 1 ? '交友结束' : '牵手良缘';
|
||||
@@ -147,7 +149,7 @@ class Friend extends Model
|
||||
$text['friend_user'] = $return;
|
||||
$text['friend_id'] = $id;
|
||||
model('api/Chat')->sendMsg(1049,$room_id,$text);
|
||||
model('Room')->clear_user_charm(db::name('vs_room')->where(['id' => $room_id])->value('user_id'), $room_id);
|
||||
model('api/Room')->clear_user_charm(db::name('vs_room')->where(['id' => $room_id])->value('user_id'), $room_id);
|
||||
return ['code' => 1, 'msg' => '操作成功!', 'data' => $return];
|
||||
}
|
||||
|
||||
@@ -166,11 +168,16 @@ class Friend extends Model
|
||||
$originalPairs = db::name('vs_user_friending_heart')
|
||||
->where(['id'=>$friending_heart['id']])
|
||||
->update(['status' => 3,'friend_config_id' =>$friending_config_id]);
|
||||
|
||||
$msg = '';
|
||||
// 修改当前交友阶段
|
||||
$res = db::name('vs_room')->where(['id' => $room_id])->update(['step' => 1]);
|
||||
$res2 = db::name('vs_user_friending')->where(['id' => $friend_id])->update(['status' => 2]);
|
||||
if ($originalPairs && $res && $res2) {
|
||||
|
||||
if ($originalPairs) {
|
||||
// 修改当前交友阶段
|
||||
$res = db::name('vs_room')->where(['id' => $room_id])->update(['step' => 1]);
|
||||
if($res){
|
||||
$res2 = db::name('vs_user_friending')->where(['id' => $friend_id])->update(['status' => 2,'update_time' => time()]);
|
||||
}
|
||||
|
||||
//所有人下麦
|
||||
$on_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',7],'user_id' => ['<>',0]])->select();
|
||||
if($on_pit){
|
||||
@@ -256,10 +263,14 @@ class Friend extends Model
|
||||
|
||||
return ['code' => 1, 'msg' => '创建关系成功!'.$msg, 'data' => null];
|
||||
} else {
|
||||
$ress = db::name('vs_user_friending')->where(['id' => $friend_id])->update(['status' => 2]);
|
||||
$re2s = db::name('vs_room')->where(['id' => $room_id])->update(['step' => 1]);
|
||||
$ress = 0;
|
||||
if($re2s){
|
||||
$ress = db::name('vs_user_friending')->where(['id' => $friend_id])->update(['status' => 2,'update_time' => time()]);
|
||||
}
|
||||
|
||||
//推送给前端消息
|
||||
$text['status1'] = $ress.'<=>'.$re2s.'<=>'.$res.'<=>'.$res2.'<=>'.$originalPairs;
|
||||
$text['status1'] = $ress.'<=>'.$re2s.'<=>'.$originalPairs;
|
||||
$text['text'] = '交友结束';
|
||||
$text['step'] = 1;//1 等待邂逅 2 心动连线 3 牵手良缘
|
||||
model('api/Chat')->sendMsg(1049,$room_id,$text);
|
||||
@@ -270,27 +281,20 @@ class Friend extends Model
|
||||
|
||||
|
||||
//退出私密房间
|
||||
public function outRoom($user_id,$room_id){
|
||||
public function outRoom($type,$room_id){
|
||||
//推送给前端消息
|
||||
$text['text'] = '退出私密小屋';
|
||||
model('api/Chat')->sendMsg(1055,$room_id,$text);
|
||||
|
||||
|
||||
// //查询在房间的用户
|
||||
// $users = db::name('vs_room_visitor')->where(['room_id'=>$room_id])->select();
|
||||
// if($users){
|
||||
// //退出房间
|
||||
// foreach ($users as $v){
|
||||
// //退出房间
|
||||
// model('Room')->quit_room($v['user_id'], $room_id,$v['user_id']);
|
||||
// }
|
||||
// }else{
|
||||
// model('Room')->quit_room($user_id, $room_id,$user_id);
|
||||
// }
|
||||
|
||||
//注销房间
|
||||
db::name('vs_room')->where(['id'=>$room_id])->update(['room_status'=>3]);
|
||||
db::name('vs_room_cp_movie')->where(['room_id'=>$room_id])->update(['status'=>4]);
|
||||
if($type){//交友、拍卖
|
||||
db::name('vs_room_cp_movie')->where(['room_id'=>$room_id])->update(['status'=>4]);
|
||||
}else{//酒吧房私密
|
||||
db::name('vs_room_bar_movie')->where(['room_id'=>$room_id])->update(['status'=>2]);
|
||||
}
|
||||
//删除腾讯群组
|
||||
model('api/Tencent')->delete_group('room'.$room_id);
|
||||
|
||||
return ['code' => 1, 'msg' => '退出成功!', 'data' => null];
|
||||
@@ -310,16 +314,12 @@ class Friend extends Model
|
||||
* @param $room_id 房间id
|
||||
* @param $pit_number 坑位
|
||||
*/
|
||||
public function room_give_gift($uid, $to_uid, $gift_id, $gift_num, $from_type, $type, $room_id, $pit_number, $heart_id,$give_gift_ext)
|
||||
public function room_give_gift($uid, $to_uid,$room_id,$res,$heart_id = 0)
|
||||
{
|
||||
$res = model('GiveGift')->give_gift($uid, $to_uid, $gift_id, $gift_num, $from_type, $type, $room_id, $pit_number,0,$give_gift_ext);
|
||||
if($res['code'] != 1){
|
||||
return $res;
|
||||
}
|
||||
|
||||
//送礼成功后续操作
|
||||
//查看当前时间是否在交友表的创建时间和结束时间段内 用来区分是否要拉取心动值高的用户上麦
|
||||
$friend = db::name('vs_user_friending')->where(['room_id' => $room_id,'status' => 1])->order('id desc')->find();
|
||||
|
||||
//查看当前时间是否在交友表的创建时间和结束时间段内 用来区分是否要拉取心动值高的用户上麦
|
||||
if($friend && time() >= $friend['create_time'] && time() <= $friend['end_time']){
|
||||
$heart_exp = get_system_config_value('coin_charm_exp');//金币与魅力值转换比
|
||||
$sumPrice = $res['data']['gift_total'] * $heart_exp;
|
||||
@@ -327,7 +327,7 @@ class Friend extends Model
|
||||
|
||||
if($heart_id){//有这个值就是助力 不参加抢麦操作
|
||||
db::name('vs_user_friending_heart')->where(['id' => $heart_id])->setInc('heart_value', $sumPrice);
|
||||
$this->pullHeartChange($room_id,$friend['id']);//聊天室心动值变化通知
|
||||
// $this->pullHeartChange($room_id,$friend['id']);//聊天室心动值变化通知 注释掉是因为下面那个函数会处理
|
||||
//生成新排名 判断抱上麦 还是换麦
|
||||
$this->pullUserPit($room_id,$friend['id']);
|
||||
}else{
|
||||
@@ -335,7 +335,7 @@ class Friend extends Model
|
||||
$host = $this->is_host($uid,$to_uid,$room_id);
|
||||
$user_idd = explode(",", $user_idd); // 将字符串转换为数组
|
||||
//判断是否是主持
|
||||
if($host['is_preside'] == 1){
|
||||
if($host && $host['is_preside'] == 1){
|
||||
if(!in_array($uid,$host['is_preside_user'])){//主持不是当前送礼人,那就是在收礼人中
|
||||
//从数组中剔除主持人 && $is_preside_user!= UID
|
||||
$user_idd = array_diff($user_idd, $host['is_preside_user']); // 从数组中移除
|
||||
@@ -371,13 +371,13 @@ class Friend extends Model
|
||||
foreach ($user_ids as $value) {
|
||||
//判断收礼人是否是主持
|
||||
if (in_array($value, $host)) {
|
||||
$is_preside = 1;
|
||||
$is_preside = 1;//是主持
|
||||
$is_preside_user[] = $value;
|
||||
}
|
||||
}
|
||||
//送礼人是主持或嘉宾
|
||||
if (in_array($uid, $host)) {
|
||||
$is_preside = 1;
|
||||
$is_preside = 1;//是嘉宾
|
||||
$is_preside_user[] = $uid;
|
||||
}
|
||||
return ['is_preside' =>$is_preside,'is_preside_user' => $is_preside_user];
|
||||
@@ -750,7 +750,7 @@ class Friend extends Model
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//获取此阶段的1-6麦位 全部返给前端 前端比对 里面没有自己 则闭麦……
|
||||
$getRoomNullPit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',7]])->select();
|
||||
$data_users = [];
|
||||
foreach($getRoomNullPit as $key_data => $value_data){
|
||||
|
||||
@@ -18,20 +18,67 @@ class Gift extends Model
|
||||
protected $table = 'fa_vs_gift';
|
||||
|
||||
//获取礼物类型
|
||||
public function get_gift_label()
|
||||
public function get_gift_label($type,$no_label = [])
|
||||
{
|
||||
if($type == 2) {//打赏 不需要热度卡
|
||||
$no_label = [1013,2];
|
||||
}
|
||||
$giftType = [];
|
||||
$giftTypeData = db::name('vs_gift_label')->where('delete_time',0)->where('tid',1)->order("sort asc,id desc")->select();
|
||||
//礼物
|
||||
$giftTypeData = db::name('vs_gift_label')
|
||||
->where('delete_time',0)
|
||||
->where('tid',1)
|
||||
->whereNotIn('id',$no_label)
|
||||
->order("sort asc,id desc")
|
||||
->select();
|
||||
foreach ($giftTypeData as $key => $value) {
|
||||
$giftType[$key]['id'] = $value['id'];
|
||||
$giftType[$key]['name'] = $value['name'];
|
||||
$giftType[$key]['sort'] = $value['sort'];
|
||||
}
|
||||
|
||||
//增加房间热度卡
|
||||
if (!in_array(1013, $no_label)) {
|
||||
$giftType[] = ['id' => 1013, 'name' => '房间热度卡', 'sort' => 0];
|
||||
}
|
||||
|
||||
//排序 1013排到最前面去
|
||||
usort($giftType, function($a, $b) {
|
||||
return $a['sort'] <=> $b['sort'];
|
||||
});
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $giftType];
|
||||
}
|
||||
|
||||
//拉取礼物列表
|
||||
public function get_gift_list($label = 0,$room_id = 0,$user_id = 0)
|
||||
{
|
||||
if($label == 1013){//房间热度卡
|
||||
$list = db::name('vs_user_decorate')
|
||||
->field('a.udid,a.num,b.title,b.base_image,b.price,b.ext_value')
|
||||
->alias('a')
|
||||
->join('vs_decorate b','a.did=b.did')
|
||||
->where([
|
||||
'a.user_id'=>$user_id,
|
||||
'a.type'=>13,
|
||||
'a.num' => ['>',0]
|
||||
])
|
||||
->order('a.num desc')
|
||||
->select();
|
||||
$return_data = [];
|
||||
if($list){
|
||||
foreach ($list as $k=>$v) {
|
||||
$return_data[$k]['gift_id'] = $v['udid'];
|
||||
$return_data[$k]['gift_name'] = $v['title'];
|
||||
$return_data[$k]['base_image'] = $v['base_image'];
|
||||
$return_data[$k]['gift_price'] = $v['price'];
|
||||
$return_data[$k]['num'] = $v['num'];
|
||||
$return_data[$k]['label'] = 1013;
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $return_data];
|
||||
}
|
||||
//其他礼物类型
|
||||
|
||||
$is_lock = 0;
|
||||
if ($label == 13) { // 专属礼物
|
||||
$Nobility = model('api/Nobility')->getUserNobilityInfo($user_id);
|
||||
@@ -55,20 +102,22 @@ class Gift extends Model
|
||||
|
||||
$map['delete_time'] = 0;
|
||||
$where['is_show'] = 1;
|
||||
if ($label && $label != 99) {
|
||||
$map['label'] = $label;
|
||||
}
|
||||
if ($label == 99) {
|
||||
if ($label == 99) { // 拍卖卡关系选择的礼物
|
||||
$gift_price = get_system_config_value('room_love_auction_cion');
|
||||
$where['gift_price'] = ['>',$gift_price];
|
||||
$where['label'] = ['<>',2];
|
||||
$where['label'] = ['in',[1,5]];
|
||||
}elseif ($label == 100) {// 哥单礼物
|
||||
$gift_price = get_system_config_value('singer_lowest_cion');//歌单最低价格
|
||||
$where['gift_price'] = ['>',$gift_price];
|
||||
$where['label'] = ['in',[1,5]];
|
||||
}elseif($label == 0){// 其他普通礼物
|
||||
$where['label'] = ['in',[1,5]];
|
||||
}else{
|
||||
$map['label'] = $label;
|
||||
}
|
||||
|
||||
$is_open_blind_box_turntable = 1;
|
||||
// if($room_id){
|
||||
// $is_open_blind_box_turntable = Db::name('vs_room')->where(['id'=>$room_id])->value('is_open_blind_box_turntable');
|
||||
// }
|
||||
$list = $this->field('gid as gift_id,gift_name,base_image,gift_price,icon')->where($map)->where($where)->order('sort asc, gift_price asc')->select();
|
||||
$list = $this->field('gid as gift_id,gift_name,base_image,gift_price,icon')->where($map)->where($where)->order('sort desc, gift_price asc')->select();
|
||||
if($label==2){
|
||||
$list_data = [];
|
||||
foreach ($list as &$v) {
|
||||
@@ -104,9 +153,9 @@ class Gift extends Model
|
||||
}
|
||||
}
|
||||
}
|
||||
usort($list_data, function($a, $b) {
|
||||
return $a['gift_id'] <=> $b['gift_id'];
|
||||
});
|
||||
// usort($list_data, function($a, $b) {
|
||||
// return $a['gift_id'] <=> $b['gift_id'];
|
||||
// });
|
||||
$list = $list_data;
|
||||
}
|
||||
|
||||
|
||||
193
application/api/model/GiftNew.php
Normal file
193
application/api/model/GiftNew.php
Normal file
@@ -0,0 +1,193 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Cache;
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
|
||||
class GiftNew extends Model
|
||||
{
|
||||
/*
|
||||
* 获取礼物列表
|
||||
* @param int $label 礼物标签
|
||||
* @param int $type 类型:1-房间送礼礼物,2-排麦设置插麦礼物,3-拍卖位选择拍卖礼物,4-歌手添加歌单礼物,5-动态打赏礼物, 6-酒吧房
|
||||
*/
|
||||
public function get_gift_list($user_id, $type, $label)
|
||||
{
|
||||
$is_lock = 0;
|
||||
if ($label == 13) { // 专属礼物
|
||||
$Nobility = model('api/Nobility')->getUserNobilityInfo($user_id);
|
||||
$power_list_ids = array_column($Nobility['power_list'],'id');
|
||||
if(!in_array(5,$power_list_ids)){
|
||||
$is_lock = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//1,先从缓存获取
|
||||
if($is_lock){//根据这个判断是不是爵位礼物 创建不同的key
|
||||
$cache_key = 'gift_list_'.$label.'_'.$is_lock;
|
||||
}else{
|
||||
$cache_key = 'gift_list_'.$label;
|
||||
}
|
||||
//2,缓存获取
|
||||
$list = json_decode(Cache::get($cache_key), true);
|
||||
//获取到就返回
|
||||
if($list){
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
|
||||
}
|
||||
|
||||
//================================从这里开始写逻辑==================================
|
||||
//根据type的值分析拉起礼物的场合 加$label的条件 给出对应的列表
|
||||
|
||||
//根据类型组装查询条件
|
||||
$where['is_show'] = 1;
|
||||
$where['delete_time'] = 0;
|
||||
if ($label == 99) {
|
||||
$gift_price = get_system_config_value('room_love_auction_cion');
|
||||
$where['gift_price'] = ['>',$gift_price];
|
||||
$where['label'] = ['<>',2];
|
||||
}
|
||||
switch ($type) {
|
||||
case 1:
|
||||
$where['label'] = $label;
|
||||
break;
|
||||
case 2:
|
||||
$where['label'] = 5;
|
||||
break;
|
||||
case 3:
|
||||
$where['type'] = 1;
|
||||
//爆币id
|
||||
$bb_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
|
||||
$where['gid'] = ['<>',$bb_gift_id];//拍卖位选礼物 不能是爆币这个礼物
|
||||
break;
|
||||
case 4:
|
||||
$where['type'] = 1;
|
||||
$where['gift_price'] = ['>',128];//歌单礼物价格要大于128 老板26年1月2号提的要求
|
||||
break;
|
||||
case 5:
|
||||
$where['type'] = 1;
|
||||
break;
|
||||
case 6:
|
||||
$where['type'] = 6;
|
||||
$where['label'] = $label;
|
||||
break;
|
||||
}
|
||||
$list = db::name('vs_gift')
|
||||
->field('gid as gift_id,gift_name,base_image,gift_price,icon')
|
||||
->where($where)->order('sort desc, gift_price asc')->select();
|
||||
|
||||
if($label==2){
|
||||
foreach ($list as &$v) {
|
||||
//获取盲盒列表
|
||||
$box_list = Db::name('vs_gift_bag')->where(['status'=>1])->where(['activities_id'=>["in",[4,5]]])->select();
|
||||
foreach ($box_list as $key =>$box) {
|
||||
$ext = json_decode($box['ext'],true);
|
||||
if ($ext['gift_id'] == $v['gift_id']) {
|
||||
$v['gift_bag_name'] = $box['name'];
|
||||
$v['rule'] = $ext['description'];
|
||||
$v['rule_url'] = get_system_config_value('web_site')."/api/Page/get_gift_box_rule?box_id=".$box["id"];
|
||||
$v['activities_id'] = $box['activities_id'];
|
||||
$v['gift_bag'] = $box['id'];
|
||||
$v['sort'] = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//爆币
|
||||
$pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
|
||||
if($pool_gift_id == $v['gift_id']){
|
||||
$v['gift_bag_name'] = "幸运币活动";
|
||||
$v['rule'] = "幸运羽币";
|
||||
$v['rule_url'] = get_system_config_value('web_site')."/api/Page/page_show?id=35";
|
||||
$v['activities_id'] = 88;
|
||||
$v['gift_bag'] = 0;
|
||||
$v['sort'] = 1;
|
||||
}
|
||||
}
|
||||
//排序
|
||||
usort($list, function($a, $b) {
|
||||
if ($a['sort'] == $b['sort']) {
|
||||
return 0;
|
||||
}
|
||||
return ($a['sort'] < $b['sort']) ? -1 : 1;
|
||||
});
|
||||
}else{
|
||||
foreach ($list as $key =>&$v) {
|
||||
$v['is_lock'] = $is_lock;
|
||||
if($label==14){ //酒吧房自定义礼物 自定义
|
||||
$gift_remark_name =db::name('vs_user_custom_gift')->where(['user_id' => $user_id,'gift_id'=>$v['gift_id'],'delete_time'=>0])->value('gift_remark_name');
|
||||
$v['gift_remark_name'] = $gift_remark_name ?? '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//================================到这里结束逻辑==================================
|
||||
if($label!=14) {//非自定义礼物走缓存
|
||||
//设置缓存
|
||||
Cache::set($cache_key, json_encode($list), 3600);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
|
||||
}
|
||||
|
||||
|
||||
//自定义礼物设置
|
||||
public function set_custom_gift($user_id, $gift_id, $room_id, $gift_remark_name){
|
||||
$gift_info = db::name('vs_gift')->where(['gid' => $gift_id, 'delete_time' => 0, 'is_show' => 1])->find();
|
||||
if(!$gift_info){
|
||||
return ['code' => 0, 'msg' => '礼物不存在','data' =>null];
|
||||
}
|
||||
|
||||
$user_custom_gift = db::name('vs_user_custom_gift')->where(['user_id' => $user_id,'gift_id'=>$gift_id])->find();
|
||||
if($user_custom_gift){
|
||||
db::name('vs_user_custom_gift')->where(['id' => $user_custom_gift['id']])->update(['gift_remark_name'=>$gift_remark_name,'updatetime'=>time()]);
|
||||
}else{
|
||||
$res = db::name('vs_user_custom_gift')->insert([
|
||||
'user_id' => $user_id,
|
||||
'gift_id'=>$gift_id,
|
||||
'gift_remark_name'=>$gift_remark_name,
|
||||
'createtime'=>time()
|
||||
]);
|
||||
if(!$res){
|
||||
return ['code' => 0, 'msg' => '设置失败','data' =>null];
|
||||
}
|
||||
}
|
||||
|
||||
$user_custom_gift_count = db::name('vs_user_custom_gift')->where(['user_id' => $user_id,'gift_remark_name' => ['<>', '']])->count();
|
||||
|
||||
if($user_custom_gift_count == 0){
|
||||
$type = 0;//删除
|
||||
}else{
|
||||
$type = 1;
|
||||
}
|
||||
|
||||
if(!$room_id){
|
||||
$room_id = db::name('vs_room_visitor')->where(['user_id' => $user_id])->order('id desc')->value('room_id');
|
||||
}
|
||||
|
||||
$user_on_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id])->value('pit_number');
|
||||
if($user_on_pit){
|
||||
$text['text'] = '设置自定义礼物';
|
||||
$text['type'] = $type;
|
||||
$text['user_id'] = $user_id;
|
||||
$text['pit_number'] = $user_on_pit;
|
||||
//聊天室推送系统消息
|
||||
model('api/Chat')->sendMsg(1203,$room_id,$text);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '设置成功','data' =>null];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//自定义礼物列表
|
||||
public function get_custom_gift_list($user_id){
|
||||
$list = db::name('vs_user_custom_gift')
|
||||
->alias('a')
|
||||
->join('vs_gift b','a.gift_id = b.gid')
|
||||
->field('a.id,b.gid as gift_id,a.gift_remark_name,b.gift_name,b.base_image,b.gift_price,b.icon')
|
||||
->where(['a.user_id' => $user_id,'a.delete_time'=>0,'a.gift_remark_name'=>['<>','']])
|
||||
->order('a.sort desc ,a.updatetime desc')
|
||||
->select();
|
||||
return ['code' => 1, 'msg' => '获取成功','data' =>$list];
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
501
application/api/model/GiveGiftBases.php
Normal file
501
application/api/model/GiveGiftBases.php
Normal file
@@ -0,0 +1,501 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use app\common\model\GiveGiftBase;
|
||||
use think\Cache;
|
||||
use think\Log;
|
||||
use think\Model;
|
||||
|
||||
class GiveGiftBases extends Model
|
||||
{
|
||||
|
||||
protected $giftModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->giftModel = new GiveGiftBase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取送礼记录
|
||||
*/
|
||||
|
||||
public function getGiftRecords($params,$ext_params=[])
|
||||
{
|
||||
// $params = $this->request->param();
|
||||
|
||||
$where = [];
|
||||
$options = [];
|
||||
|
||||
// 构建查询条件
|
||||
if (!empty($params['from_id'])) {
|
||||
$where['from_id'] = $params['from_id'];
|
||||
}
|
||||
if (!empty($params['user_id'])) {
|
||||
$where['user_id'] = $params['user_id'];
|
||||
}
|
||||
if (!empty($params['gift_user'])) {
|
||||
$where['gift_user'] = $params['gift_user'];
|
||||
}
|
||||
if (!empty($params['gift_id'])) {
|
||||
$where['gift_id'] = $params['gift_id'];
|
||||
}
|
||||
if (!empty($params['type'])) {
|
||||
$where['type'] = $params['type'];
|
||||
}
|
||||
if (!empty($params['from'])) {
|
||||
$where['from'] = $params['from'];
|
||||
}
|
||||
if (!empty($params['gift_type'])) {
|
||||
$where['gift_type'] = $params['gift_type'];
|
||||
}
|
||||
|
||||
// 时间范围
|
||||
if (!empty($ext_params)) {
|
||||
if (!empty($ext_params['start_time'])) {
|
||||
$options['start_time'] = $ext_params['start_time'];
|
||||
}
|
||||
if (!empty($ext_params['end_time'])) {
|
||||
$options['end_time'] = $ext_params['end_time'];
|
||||
}
|
||||
}else{
|
||||
if (!empty($params['start_time'])) {
|
||||
$options['start_time'] = strtotime($params['start_time']);
|
||||
}
|
||||
if (!empty($params['end_time'])) {
|
||||
$options['end_time'] = strtotime($params['end_time'] . ' 23:59:59');
|
||||
}
|
||||
}
|
||||
|
||||
// 分页参数
|
||||
$options['page'] = $params['page'] ?? 1;
|
||||
$options['limit'] = min($params['limit'] ?? 20, 100); // 限制最大100条
|
||||
|
||||
// 排序
|
||||
if (!empty($params['order'])) {
|
||||
$options['order'] = $params['order'];
|
||||
}
|
||||
|
||||
// 查询数据
|
||||
$result = $this->giftModel->getGiftRecords($where, $options);
|
||||
|
||||
Log::info("查询送礼记录,条件: " . json_encode($where) . ", 结果数: " . count($result['data']));
|
||||
|
||||
// $this->success('获取成功', $result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 房间送礼统计
|
||||
*/
|
||||
public function getRoomStatistics($params)
|
||||
{
|
||||
$fromId = $this->request->param('from_id/d', 0);
|
||||
$startTime = $this->request->param('start_time/d', strtotime('-7 days'));
|
||||
$endTime = $this->request->param('end_time/d', time());
|
||||
|
||||
if (!$fromId) {
|
||||
$this->error('房间ID不能为空');
|
||||
}
|
||||
|
||||
// 尝试从缓存获取
|
||||
$cacheKey = "gift:room:stats:{$fromId}:" . date('Ymd', $startTime) . '-' . date('Ymd', $endTime);
|
||||
$cachedData = Cache::get($cacheKey);
|
||||
|
||||
if ($cachedData !== false) {
|
||||
Log::info("从缓存获取房间统计: {$cacheKey}");
|
||||
$this->success('获取成功', $cachedData);
|
||||
}
|
||||
|
||||
$where = ['from_id' => $fromId];
|
||||
$options = [
|
||||
'start_time' => $startTime,
|
||||
'end_time' => $endTime,
|
||||
];
|
||||
|
||||
// 统计房间总数据
|
||||
$totalStats = $this->giftModel->getGiftStatistics($where, $options);
|
||||
|
||||
// 按送礼人分组统计
|
||||
$userStats = $this->giftModel->getGiftStatistics($where, array_merge($options, [
|
||||
'group_by' => 'user_id'
|
||||
]));
|
||||
|
||||
// 按收礼人分组统计
|
||||
$receiverStats = $this->giftModel->getGiftStatistics($where, array_merge($options, [
|
||||
'group_by' => 'gift_user'
|
||||
]));
|
||||
|
||||
$result = [
|
||||
'room_id' => $fromId,
|
||||
'time_range' => [
|
||||
'start_time' => $startTime,
|
||||
'end_time' => $endTime,
|
||||
'start_date' => date('Y-m-d H:i:s', $startTime),
|
||||
'end_date' => date('Y-m-d H:i:s', $endTime),
|
||||
],
|
||||
'total_stats' => $totalStats,
|
||||
'user_stats' => $userStats,
|
||||
'receiver_stats' => $receiverStats,
|
||||
];
|
||||
|
||||
// 缓存5分钟
|
||||
Cache::set($cacheKey, $result, 300);
|
||||
|
||||
Log::info("房间统计计算完成: {$fromId}, 送礼人数: " . count($userStats) . ", 收礼人数: " . count($receiverStats));
|
||||
|
||||
$this->success('获取成功', $result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 房间送礼统计总数
|
||||
*/
|
||||
public function getRoomStatistics_total($fromId, $startTime, $endTime)
|
||||
{
|
||||
if (!$fromId) {
|
||||
$this->error('房间ID不能为空');
|
||||
}
|
||||
|
||||
$where = ['from_id' => $fromId];
|
||||
$options = [
|
||||
'start_time' => $startTime,
|
||||
'end_time' => $endTime,
|
||||
];
|
||||
|
||||
// 统计房间总数据
|
||||
$totalStats = $this->giftModel->getGiftStatistics($where, $options);
|
||||
|
||||
$result = [
|
||||
'room_id' => $fromId,
|
||||
'time_range' => [
|
||||
'start_time' => $startTime,
|
||||
'end_time' => $endTime,
|
||||
'start_date' => date('Y-m-d H:i:s', $startTime),
|
||||
'end_date' => date('Y-m-d H:i:s', $endTime),
|
||||
],
|
||||
'total_stats' => $totalStats,
|
||||
];
|
||||
|
||||
// $this->success('获取成功', $result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户送礼统计
|
||||
*/
|
||||
public function getUserStatistics($params,$type)
|
||||
{
|
||||
if($type==1){
|
||||
$userId = $params['user_id'];
|
||||
}else{
|
||||
$userId = $params['gift_user'];
|
||||
}
|
||||
|
||||
$startTime = $params['start_time'];
|
||||
$endTime = $params['end_time'];
|
||||
|
||||
if (!$userId) {
|
||||
return ['code'=>0,'msg'=>'用户ID不能为空','data'=>null];
|
||||
}
|
||||
|
||||
if($type==1){
|
||||
$where = ['user_id' => $userId];
|
||||
}else{
|
||||
$where = ['gift_user' => $userId];
|
||||
}
|
||||
|
||||
$options = [
|
||||
'start_time' => $startTime,
|
||||
'end_time' => $endTime,
|
||||
];
|
||||
|
||||
// 用户总送礼统计
|
||||
$totalStats = $this->giftModel->getGiftStatistics($where, $options);
|
||||
|
||||
// 按房间分组统计
|
||||
$roomStats = $this->giftModel->getGiftStatistics($where, array_merge($options, [
|
||||
'group_by' => 'from_id'
|
||||
]));
|
||||
|
||||
// 按收礼人分组统计
|
||||
$receiverStats = $this->giftModel->getGiftStatistics($where, array_merge($options, [
|
||||
'group_by' => 'gift_user'
|
||||
]));
|
||||
|
||||
$result = [
|
||||
'user_id' => $userId,
|
||||
'time_range' => [
|
||||
'start_time' => $startTime,
|
||||
'end_time' => $endTime,
|
||||
'start_date' => date('Y-m-d H:i:s', $startTime),
|
||||
'end_date' => date('Y-m-d H:i:s', $endTime),
|
||||
],
|
||||
'total_stats' => $totalStats,
|
||||
'room_stats' => $roomStats,
|
||||
'receiver_stats' => $receiverStats,
|
||||
];
|
||||
|
||||
// 缓存5分钟
|
||||
// Cache::set($cacheKey, $result, 300);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 收礼统计
|
||||
*/
|
||||
public function getReceiveStatistics()
|
||||
{
|
||||
$giftUser = $this->request->param('gift_user/d', 0);
|
||||
$startTime = $this->request->param('start_time/d', strtotime('-30 days'));
|
||||
$endTime = $this->request->param('end_time/d', time());
|
||||
|
||||
if (!$giftUser) {
|
||||
$this->error('用户ID不能为空');
|
||||
}
|
||||
|
||||
$cacheKey = "gift:receive:stats:{$giftUser}:" . date('Ymd', $startTime) . '-' . date('Ymd', $endTime);
|
||||
$cachedData = Cache::get($cacheKey);
|
||||
|
||||
if ($cachedData !== false) {
|
||||
Log::info("从缓存获取收礼统计: {$cacheKey}");
|
||||
$this->success('获取成功', $cachedData);
|
||||
}
|
||||
|
||||
$where = ['gift_user' => $giftUser];
|
||||
$options = [
|
||||
'start_time' => $startTime,
|
||||
'end_time' => $endTime,
|
||||
];
|
||||
|
||||
// 总收礼统计
|
||||
$totalStats = $this->giftModel->getGiftStatistics($where, $options);
|
||||
|
||||
// 按房间分组统计
|
||||
$roomStats = $this->giftModel->getGiftStatistics($where, array_merge($options, [
|
||||
'group_by' => 'from_id'
|
||||
]));
|
||||
|
||||
// 按送礼人分组统计
|
||||
$giverStats = $this->giftModel->getGiftStatistics($where, array_merge($options, [
|
||||
'group_by' => 'user_id'
|
||||
]));
|
||||
|
||||
$result = [
|
||||
'gift_user' => $giftUser,
|
||||
'time_range' => [
|
||||
'start_time' => $startTime,
|
||||
'end_time' => $endTime,
|
||||
'start_date' => date('Y-m-d H:i:s', $startTime),
|
||||
'end_date' => date('Y-m-d H:i:s', $endTime),
|
||||
],
|
||||
'total_stats' => $totalStats,
|
||||
'room_stats' => $roomStats,
|
||||
'giver_stats' => $giverStats,
|
||||
];
|
||||
|
||||
// 缓存5分钟
|
||||
Cache::set($cacheKey, $result, 300);
|
||||
|
||||
Log::info("收礼统计计算完成: {$giftUser}, 房间数: " . count($roomStats) . ", 送礼人数: " . count($giverStats));
|
||||
|
||||
$this->success('获取成功', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取送礼趋势
|
||||
*/
|
||||
public function getGiftTrend()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
|
||||
$startTime = $params['start_time'] ?? strtotime('-7 days');
|
||||
$endTime = $params['end_time'] ?? time();
|
||||
$interval = $params['interval'] ?? 'day';
|
||||
|
||||
if (!in_array($interval, ['day', 'week', 'month'])) {
|
||||
$interval = 'day';
|
||||
}
|
||||
|
||||
$cacheKey = "gift:trend:" . date('Ymd', $startTime) . '-' . date('Ymd', $endTime) . ":{$interval}";
|
||||
$cachedData = Cache::get($cacheKey);
|
||||
|
||||
if ($cachedData !== false) {
|
||||
$this->success('获取成功', $cachedData);
|
||||
}
|
||||
|
||||
$trendData = $this->giftModel->getTrendStatistics($startTime, $endTime, $interval);
|
||||
|
||||
// 缓存10分钟
|
||||
Cache::set($cacheKey, $trendData, 600);
|
||||
|
||||
$this->success('获取成功', [
|
||||
'trend_data' => $trendData,
|
||||
'interval' => $interval,
|
||||
'time_range' => [
|
||||
'start_time' => $startTime,
|
||||
'end_time' => $endTime
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function getGiftList()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
|
||||
$where = [];
|
||||
$options = [];
|
||||
|
||||
// 构建查询条件
|
||||
$searchFields = ['from_id', 'user_id', 'gift_user', 'gift_id', 'type', 'from', 'gift_type'];
|
||||
foreach ($searchFields as $field) {
|
||||
if (!empty($params[$field])) {
|
||||
$where[$field] = $params[$field];
|
||||
}
|
||||
}
|
||||
|
||||
// 时间范围
|
||||
if (!empty($params['start_time'])) {
|
||||
$options['start_time'] = strtotime($params['start_time']);
|
||||
}
|
||||
if (!empty($params['end_time'])) {
|
||||
$options['end_time'] = strtotime($params['end_time']);
|
||||
}
|
||||
|
||||
// 搜索关键词
|
||||
if (!empty($params['search'])) {
|
||||
// 可以扩展搜索逻辑
|
||||
}
|
||||
|
||||
// 分页参数
|
||||
$options['page'] = $params['page'] ?? 1;
|
||||
$options['limit'] = $params['limit'] ?? $this->pageSize;
|
||||
|
||||
// 查询数据
|
||||
$result = $this->giftModel->getGiftRecords($where, $options);
|
||||
|
||||
// 转换时间格式
|
||||
foreach ($result['data'] as &$item) {
|
||||
$item['createtime_text'] = $item['createtime'] ? date('Y-m-d H:i:s', $item['createtime']) : '';
|
||||
$item['updatetime_text'] = $item['updatetime'] ? date('Y-m-d H:i:s', $item['updatetime']) : '';
|
||||
}
|
||||
|
||||
$total = $result['total'];
|
||||
$data = $result['data'];
|
||||
$result = array("total" => $total, "rows" => $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取送礼排行
|
||||
*/
|
||||
|
||||
public function getGiftRanking($params,$type)
|
||||
{
|
||||
$where = [];
|
||||
$options = [];
|
||||
|
||||
// 时间范围
|
||||
if (!empty($params['start_time'])) {
|
||||
$options['start_time'] = $params['start_time'];
|
||||
}
|
||||
if (!empty($params['end_time'])) {
|
||||
$options['end_time'] = $params['end_time'];
|
||||
}
|
||||
|
||||
// 分页参数
|
||||
$options['page'] = $params['page'] ?? 1;
|
||||
$options['limit'] = min($params['limit'] ?? 20, 100); // 限制最大100条
|
||||
|
||||
if($type == 1){
|
||||
$options['group_by'] = 'user_id';
|
||||
}else{
|
||||
$options['group_by'] = 'gift_user';
|
||||
}
|
||||
|
||||
|
||||
// 查询数据
|
||||
$result = $this->giftModel->getGiftStatisticsRanking($where, $options);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计收礼用户 的送礼用户的分组和
|
||||
*/
|
||||
|
||||
public function getToUserStatistics($params)
|
||||
{
|
||||
$where = [];
|
||||
$options = [];
|
||||
|
||||
// 时间范围
|
||||
if (!empty($params['start_time'])) {
|
||||
$options['start_time'] = $params['start_time'];
|
||||
}
|
||||
if (!empty($params['end_time'])) {
|
||||
$options['end_time'] = $params['end_time'];
|
||||
}
|
||||
if (!empty($params['from_id'])) {
|
||||
$where['from_id'] = $params['from_id'];
|
||||
}
|
||||
if (!empty($params['gift_user'])) {
|
||||
$where['gift_user'] = $params['gift_user'];
|
||||
}
|
||||
|
||||
// 分页参数
|
||||
$options['page'] = $params['page'] ?? 1;
|
||||
$options['limit'] = min($params['limit'] ?? 20, 100); // 限制最大100条
|
||||
|
||||
$options['group_by'] = 'user_id';
|
||||
|
||||
// 查询数据
|
||||
$result = $this->giftModel->getToUserStatistics($where, $options);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取房间内送礼排行
|
||||
*/
|
||||
|
||||
public function getRoomGiftRanking($params,$type)
|
||||
{
|
||||
$where = [];
|
||||
$options = [];
|
||||
|
||||
// 时间范围
|
||||
if (!empty($params['start_time'])) {
|
||||
$options['start_time'] = $params['start_time'];
|
||||
}
|
||||
if (!empty($params['end_time'])) {
|
||||
$options['end_time'] = $params['end_time'];
|
||||
}
|
||||
// 构建查询条件
|
||||
if (!empty($params['from_id'])) {
|
||||
$where['from_id'] = $params['from_id'];
|
||||
}
|
||||
|
||||
// 分页参数
|
||||
$options['page'] = $params['page'] ?? 1;
|
||||
$options['limit'] = min($params['limit'] ?? 20, 100); // 限制最大100条
|
||||
|
||||
if($type == 1){
|
||||
$options['group_by'] = 'user_id';
|
||||
}else{
|
||||
$options['group_by'] = 'gift_user';
|
||||
}
|
||||
|
||||
|
||||
// 查询数据
|
||||
$result = $this->giftModel->getGiftStatisticsRanking($where, $options);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -117,12 +117,14 @@ class Guild extends Model
|
||||
*/
|
||||
public function join_guild_apply($guild_id,$user_id=0)
|
||||
{
|
||||
$user_info = model('User')->get_user_info($user_id);
|
||||
if(!$user_info){
|
||||
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||
}
|
||||
if($user_info['is_real']!=1 || empty($user_info['card_id'])){
|
||||
return ['code' => 0, 'msg' => '请先实名认证', 'data' => null];
|
||||
//查询是否实名认证
|
||||
$is_real = model('api/UserData')->real_name_info($user_id);
|
||||
if($is_real['code']==0){
|
||||
return ['code' => 0, 'msg' => '请先实名认证','data' => null];
|
||||
}else{
|
||||
if($is_real['data']['is_real'] !=1){
|
||||
return ['code' => 0, 'msg' => '请先实名认证','data' => null];
|
||||
}
|
||||
}
|
||||
//公会是否存在
|
||||
$guild_info = db::name('vs_guild')->where(['id'=>$guild_id,'delete_time'=>0])->find();
|
||||
@@ -166,7 +168,7 @@ class Guild extends Model
|
||||
}
|
||||
//是否有房间
|
||||
$rid = 0;
|
||||
$room_info = db::name('vs_room')->where('user_id', $user_id)->find();
|
||||
$room_info = db::name('vs_room')->where(['user_id'=>$user_id,'delete_time'=>0,'type_id'=>['<>',6]])->find();
|
||||
if($room_info){
|
||||
$rid = $room_info['id'];
|
||||
}
|
||||
@@ -184,8 +186,8 @@ class Guild extends Model
|
||||
//增加公会人数
|
||||
db::name('vs_guild')->where('id', $guild_info['id'])->setInc('num', 1);
|
||||
//拉用户进入工会群聊
|
||||
// model('Tencent')->add_group_member('g'.$guild_id, $user_id);
|
||||
// model('Tencent')->send_group_system_notification('g'.$guild_id,"欢迎".$user_info['nickname'].'加入公会');
|
||||
// model('api/Tencent')->add_group_member('g'.$guild_id, $user_id);
|
||||
// model('api/Tencent')->send_group_system_notification('g'.$guild_id,"欢迎".$user_info['nickname'].'加入公会');
|
||||
|
||||
return ['code' => 1, 'msg' => '提交成功', 'data' => null];
|
||||
}else{
|
||||
@@ -273,6 +275,10 @@ class Guild extends Model
|
||||
$update_data['is_show_room'] = 1;
|
||||
$update_data['apply_time'] = time();
|
||||
$update_data['remarks'] = $remarks;
|
||||
$room_info = db::name('vs_room')->where(['user_id'=>$is_operate['user_id'],'delete_time'=>0,'type_id'=>['<>',6]])->find();
|
||||
if($room_info){
|
||||
$update_data['room_id'] = $room_info['id'];
|
||||
}
|
||||
//结算比例
|
||||
$configs = get_system_config();
|
||||
//未加入工会的收益
|
||||
@@ -291,8 +297,13 @@ class Guild extends Model
|
||||
db::name('vs_guild')->where('id', $guild_info['id'])->setInc('num', 1);
|
||||
//拉用户进入工会群聊
|
||||
$user_nickname = db::name('user')->where('id', $is_operate['user_id'])->value('nickname');
|
||||
model('api/Tencent')->add_group_member('g'.$is_operate['guild_id'], $is_operate['user_id']);
|
||||
model('api/Tencent')->send_group_system_notification('g'.$is_operate['guild_id'],"欢迎".$user_nickname.'加入公会');
|
||||
if($is_operate['guild_id']<=95){ //事故处理-114以前的群被删了
|
||||
$guild_id = "g".$is_operate['guild_id'];
|
||||
}else{
|
||||
$guild_id = $is_operate['guild_id'];
|
||||
}
|
||||
model('api/Tencent')->add_group_member('g'.$guild_id, $is_operate['user_id']);
|
||||
model('api/Tencent')->send_group_system_notification('g'.$guild_id,"欢迎".$user_nickname.'加入公会');
|
||||
//发系统信息
|
||||
$content = "恭喜加入{$guild_info['guild_name']}工会,您的个人收益增加{$ratiog}%,目前总收益{$ratio}%";
|
||||
model('api/UserMessage')->send_system_message($is_operate['user_id'], "加入公会成功通知", $content, 1);
|
||||
@@ -357,7 +368,12 @@ class Guild extends Model
|
||||
if($reslut){
|
||||
//减少公会人数
|
||||
db::name('vs_guild')->where('id', $guild_info['id'])->setDec('num');
|
||||
model('Tencent')->delete_group_member('g'.$guild_id, $user_id);
|
||||
if($guild_id<=95){ //事故处理-114以前的群被删了
|
||||
$guild_id = "g".$guild_id;
|
||||
}else{
|
||||
$guild_id = $guild_id;
|
||||
}
|
||||
model('api/Tencent')->delete_group_member('g'.$guild_id, $user_id);
|
||||
return ['code' => 1, 'msg' => '踢出成功','data' => null];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => '踢出失败','data' => null];
|
||||
@@ -366,6 +382,9 @@ class Guild extends Model
|
||||
|
||||
//退出公会
|
||||
public function quit_guild($uid, $guild_id,$type){
|
||||
//去除字符里的g
|
||||
$guild_id = str_replace('g', '', $guild_id);
|
||||
$guild_id = intval($guild_id);
|
||||
$config = get_system_config();
|
||||
$user_info = db::name('user')->find($uid);
|
||||
if(!$user_info){
|
||||
@@ -429,7 +448,16 @@ class Guild extends Model
|
||||
}
|
||||
//减少公会人数
|
||||
db::name('vs_guild')->where('id', $guild_info['id'])->setDec('num');
|
||||
model('Tencent')->delete_group_member('g'.$guild_id, $uid);
|
||||
if($guild_info['id']<=95){
|
||||
$guild_id = "g".$guild_info['id'];
|
||||
}else{
|
||||
$guild_id = $guild_info['id'];
|
||||
}
|
||||
model('api/Tencent')->delete_group_member('g'.$guild_id, $uid);
|
||||
|
||||
//付费退出费用给公会长
|
||||
$res = model('common/UserWallet')->change_user_money($guild_info['user_id'], $quit_guild_gold, model('common/UserWallet')::MONEYTYPECOIN, model('common/UserWallet')::GUILD_EXIT_DEACON_INCOME,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::GUILD_EXIT_DEACON_INCOME));
|
||||
|
||||
Db::commit();
|
||||
return ['code' => 1, 'msg' => '退出成功', 'data' => null];
|
||||
}else{
|
||||
@@ -536,8 +564,13 @@ class Guild extends Model
|
||||
return ['code' => 0, 'msg' => '审核失败', 'data' => null];
|
||||
}
|
||||
//减少公会人数
|
||||
db::name('vs_guild')->where('id', $apply_id)->setDec('num');
|
||||
model('Tencent')->delete_group_member('g'.$apply_id, $apply_info['user_id']);
|
||||
db::name('vs_guild')->where('id', $apply_info['guild_id'])->setDec('num');
|
||||
if($apply_info['guild_id']['id']<=95){
|
||||
$guild_id = "g".$apply_info['guild_id']['id'];
|
||||
}else{
|
||||
$guild_id = $apply_info['guild_id']['id'];
|
||||
}
|
||||
model('api/Tencent')->delete_group_member('g'.$guild_id, $apply_info['user_id']);
|
||||
} else {
|
||||
$update_data = [];
|
||||
$update_data['status'] = 2;
|
||||
@@ -570,7 +603,12 @@ class Guild extends Model
|
||||
//解散公会
|
||||
db::name('vs_guild')->where('id',$guild_id)->update(['delete_time'=>time(),'status'=>2]);
|
||||
//解散群
|
||||
model('Tencent')->delete_group('g'.$guild_id);
|
||||
if($guild_id<=95){
|
||||
$guild_id = "g".$guild_id;
|
||||
}else{
|
||||
$guild_id = $guild_id;
|
||||
}
|
||||
model('api/Tencent')->delete_group('g'.$guild_id);
|
||||
Db::commit();
|
||||
return ['code' => 1, 'msg' => '解散成功!', 'data' => null];
|
||||
}catch (\Exception $e) {
|
||||
@@ -666,25 +704,29 @@ class Guild extends Model
|
||||
//本周流水
|
||||
//本周的第一天
|
||||
$week = strtotime(date('Y-m-d 00:00:00', strtotime('this week Monday')));
|
||||
$guild_user = db::name('vs_guild_user')->where(['guild_id' => $guild_id])->select();
|
||||
$transaction = 0;
|
||||
foreach ($guild_user as $k => $v){
|
||||
$week_start_time_seach = $week;
|
||||
$week_end_time_seach = time();
|
||||
if($v['createtime'] && $week_start_time_seach < $v['createtime']){
|
||||
$week_start_time_seach = $v['createtime'];
|
||||
}
|
||||
if($v['quit_time'] && ($week_end_time_seach > $v['quit_time'])){
|
||||
$week_end_time_seach = $v['quit_time'];
|
||||
}
|
||||
$transaction_one = db::name('vs_give_gift')
|
||||
->whereIn('from_id',$v['room_id'])
|
||||
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$week_start_time_seach, $week_end_time_seach]]])
|
||||
->sum('total_price');
|
||||
$transaction += $transaction_one;
|
||||
|
||||
}
|
||||
$total_transaction = $transaction;
|
||||
// $guild_user = db::name('vs_guild_user')->where(['guild_id' => $guild_id])->select();
|
||||
// $transaction = 0;
|
||||
// foreach ($guild_user as $k => $v){
|
||||
// $week_start_time_seach = $week;
|
||||
// $week_end_time_seach = time();
|
||||
// if($v['createtime'] && $week_start_time_seach < $v['createtime']){
|
||||
// $week_start_time_seach = $v['createtime'];
|
||||
// }
|
||||
// if($v['quit_time'] && ($week_end_time_seach > $v['quit_time'])){
|
||||
// $week_end_time_seach = $v['quit_time'];
|
||||
// }
|
||||
// $transaction_one = db::name('vs_give_gift')
|
||||
// ->whereIn('from_id',$v['room_id'])
|
||||
// ->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$week_start_time_seach, $week_end_time_seach]]])
|
||||
// ->sum('total_price');
|
||||
// $transaction += $transaction_one;
|
||||
//
|
||||
// }
|
||||
// $total_transaction = $transaction;
|
||||
$total_transaction = db::name('vs_guild_flow')
|
||||
->where(['guild_id' => $guild_id])
|
||||
->where(['createtime' => ['between', [$week, time()]]])
|
||||
->sum('flow_price');
|
||||
$ss = 0;
|
||||
if($total_transaction){
|
||||
//根据工会流水 获取补贴比例 单位%
|
||||
@@ -737,9 +779,9 @@ class Guild extends Model
|
||||
continue;
|
||||
}
|
||||
|
||||
$consumption = db::name('vs_user_money_log')
|
||||
$consumption = db::name('user_coin_log')
|
||||
->whereIn('change_type',$coin_consumption_type_array)
|
||||
->where(['money_type'=>1,'user_id' => $value['user_id']])
|
||||
->where(['user_id' => $value['user_id']])
|
||||
->where('createtime', '>=', $actual_start_time)
|
||||
->where('createtime', '<=', $actual_end_time)
|
||||
->sum('change_value');
|
||||
@@ -759,7 +801,7 @@ class Guild extends Model
|
||||
$list = Db::name('vs_guild_user')
|
||||
->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->join('vs_user_money_log c', 'a.user_id = c.user_id AND c.money_type = 1 AND c.change_type IN (' . implode(',', $coin_consumption_type_array) . ') AND c.createtime >= a.createtime' . ($start_time ? ' AND c.createtime >= ' . $start_time : '') . ($end_time ? ' AND c.createtime <= ' . $end_time : ''), 'LEFT')
|
||||
->join('user_coin_log c', 'a.user_id = c.user_id AND c.change_type IN (' . implode(',', $coin_consumption_type_array) . ') AND c.createtime >= a.createtime' . ($start_time ? ' AND c.createtime >= ' . $start_time : '') . ($end_time ? ' AND c.createtime <= ' . $end_time : ''), 'LEFT')
|
||||
->field('a.id, a.user_id, a.guild_id, a.room_id, a.status, a.is_deacon, b.nickname, b.avatar, b.user_code, a.createtime, a.apply_time, SUM(c.change_value) AS total_consumption')
|
||||
->where(['a.guild_id' => $guild_id, 'a.status' => 1,'a.delete_time' => 0])
|
||||
->group('a.user_id')
|
||||
@@ -770,7 +812,7 @@ class Guild extends Model
|
||||
$count = Db::name('vs_guild_user')
|
||||
->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->join('vs_user_money_log c', 'a.user_id = c.user_id AND c.money_type = 1 AND c.change_type IN (' . implode(',', $coin_consumption_type_array) . ') AND c.createtime >= a.createtime' . ($start_time ? ' AND c.createtime >= ' . $start_time : '') . ($end_time ? ' AND c.createtime <= ' . $end_time : ''), 'LEFT')
|
||||
->join('user_coin_log c', 'a.user_id = c.user_id AND c.change_type IN (' . implode(',', $coin_consumption_type_array) . ') AND c.createtime >= a.createtime' . ($start_time ? ' AND c.createtime >= ' . $start_time : '') . ($end_time ? ' AND c.createtime <= ' . $end_time : ''), 'LEFT')
|
||||
->field('a.id, a.user_id, a.guild_id, a.room_id, a.status, a.is_deacon, b.nickname, b.avatar, b.user_code, a.createtime, a.apply_time, SUM(c.change_value) AS total_consumption')
|
||||
->where(['a.guild_id' => $guild_id, 'a.status' => 1,'a.delete_time' => 0])
|
||||
->group('a.user_id')
|
||||
@@ -807,30 +849,31 @@ class Guild extends Model
|
||||
return ['code' => 0, 'msg' => '公会不存在!', 'data' => null];
|
||||
}
|
||||
//工会总流水
|
||||
$all_guild_room = db::name('vs_guild_user')->where(['guild_id' => $guild_id,'status'=>1,"delete_time"=>0])->select();
|
||||
$total_transaction = 0;
|
||||
foreach ($all_guild_room as $key => $value) {
|
||||
$start_time = $seach_start_time;
|
||||
$end_time = $seach_end_time;
|
||||
if(!$start_time){
|
||||
$start_time_all = $value['createtime'];
|
||||
$end_time_all = time();
|
||||
}else{
|
||||
$start_time_all = strtotime($start_time." 00:00:00");
|
||||
$end_time_all = strtotime($end_time." 23:59:59");
|
||||
}
|
||||
if($value['createtime'] && $start_time_all < $value['createtime']){
|
||||
$start_time_all = $value['createtime'];
|
||||
}
|
||||
if($value['quit_time'] && ($end_time_all > $value['quit_time'])){
|
||||
$end_time_all = $value['quit_time'];
|
||||
}
|
||||
$transaction = db::name('vs_give_gift')
|
||||
->where('from_id',$value['room_id'])
|
||||
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$start_time_all, $end_time_all]]])
|
||||
->sum('total_price');
|
||||
$total_transaction = $total_transaction+$transaction;
|
||||
}
|
||||
// $all_guild_room = db::name('vs_guild_user')->where(['guild_id' => $guild_id,'status'=>1,"delete_time"=>0])->select();
|
||||
// $total_transaction = 0;
|
||||
// foreach ($all_guild_room as $key => $value) {
|
||||
// $start_time = $seach_start_time;
|
||||
// $end_time = $seach_end_time;
|
||||
// if(!$start_time){
|
||||
// $start_time_all = $value['createtime'];
|
||||
// $end_time_all = time();
|
||||
// }else{
|
||||
// $start_time_all = strtotime($start_time." 00:00:00");
|
||||
// $end_time_all = strtotime($end_time." 23:59:59");
|
||||
// }
|
||||
// if($value['createtime'] && $start_time_all < $value['createtime']){
|
||||
// $start_time_all = $value['createtime'];
|
||||
// }
|
||||
// if($value['quit_time'] && ($end_time_all > $value['quit_time'])){
|
||||
// $end_time_all = $value['quit_time'];
|
||||
// }
|
||||
// $transaction = db::name('vs_give_gift')
|
||||
// ->where('from_id',$value['room_id'])
|
||||
// ->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$start_time_all, $end_time_all]]])
|
||||
// ->sum('total_price');
|
||||
// $total_transaction = $total_transaction+$transaction;
|
||||
// }
|
||||
|
||||
//查询工会所有房间流水
|
||||
$list = db::name('vs_guild_user')->where(['guild_id'=>$guild_id,'delete_time'=>0,'status'=>1,'room_id'=>['<>',0]])
|
||||
->order('id asc')
|
||||
@@ -841,31 +884,31 @@ class Guild extends Model
|
||||
$room_data = [];
|
||||
$i=0;
|
||||
foreach ($list as $k=>$v){
|
||||
$start_time = $seach_start_time;
|
||||
$end_time = $seach_end_time;
|
||||
if(!$start_time){
|
||||
$start_time_seach = $value['createtime'];
|
||||
$end_time_seach = time();
|
||||
}else{
|
||||
$start_time_seach = strtotime($start_time." 00:00:00");
|
||||
$end_time_seach = strtotime($end_time." 23:59:59");
|
||||
}
|
||||
if($value['createtime'] && $start_time_all < $value['createtime']){
|
||||
$start_time_seach = $value['createtime'];
|
||||
}
|
||||
if($value['quit_time'] && ($end_time_all > $value['quit_time'])){
|
||||
$end_time_seach = $value['quit_time'];
|
||||
}
|
||||
// $start_time = $seach_start_time;
|
||||
// $end_time = $seach_end_time;
|
||||
// if(!$start_time){
|
||||
// $start_time_seach = $value['createtime'];
|
||||
// $end_time_seach = time();
|
||||
// }else{
|
||||
// $start_time_seach = strtotime($start_time." 00:00:00");
|
||||
// $end_time_seach = strtotime($end_time." 23:59:59");
|
||||
// }
|
||||
// if($value['createtime'] && $start_time_all < $value['createtime']){
|
||||
// $start_time_seach = $value['createtime'];
|
||||
// }
|
||||
// if($value['quit_time'] && ($end_time_all > $value['quit_time'])){
|
||||
// $end_time_seach = $value['quit_time'];
|
||||
// }
|
||||
$room_info = db::name('vs_room')->where(['id'=>$v['room_id'],'room_status'=>1,'delete_time'=>0])->find();
|
||||
if($room_info){
|
||||
$room_data[$i]['room_id'] = $room_info['id'];
|
||||
$room_data[$i]['room_number'] = model('Decorate')->user_decorate_detail($room_info['id'],7);
|
||||
$room_data[$i]['room_name'] = $room_info['room_name'];
|
||||
$room_data[$i]['room_cover'] = localpath_to_netpath($room_info['room_cover']);
|
||||
$room_data[$i]['total_price'] = db::name('vs_give_gift')
|
||||
->where('from_id',$v['room_id'])
|
||||
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$start_time_seach, $end_time_seach]]])
|
||||
->sum('total_price');
|
||||
$room_data[$i]['total_price'] = db::name('vs_guild_flow')
|
||||
->where('room_id',$v['room_id'])
|
||||
->where(['createtime' => ['between', [$seach_start_time, $seach_end_time]]])
|
||||
->sum('flow_price');
|
||||
$i++;
|
||||
}
|
||||
|
||||
@@ -875,7 +918,7 @@ class Guild extends Model
|
||||
'page' => $page,
|
||||
'limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'total_transaction' => $total_transaction ? $total_transaction : 0,
|
||||
'total_transaction' => $guild_info['income'] ? $guild_info['income'] : 0,
|
||||
'list' => $room_data,
|
||||
];
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $return_data];
|
||||
@@ -888,7 +931,7 @@ class Guild extends Model
|
||||
* @return array
|
||||
*/
|
||||
public function user_is_join($user_id){
|
||||
$guild = Db::name('vs_guild_user')->where(['user_id'=>$user_id,'delete_time'=>0])->find();
|
||||
$guild = Db::name('vs_guild_user')->where(['user_id'=>$user_id,'delete_time'=>0])->order('id desc,apply_time desc')->find();
|
||||
if(empty($guild)){
|
||||
return 0;
|
||||
}else{
|
||||
@@ -904,20 +947,40 @@ class Guild extends Model
|
||||
/*
|
||||
* 获取公会成员列表
|
||||
*/
|
||||
public function get_guild_user_list($guild_ids,$user_id,$page=1,$page_limit=30){
|
||||
public function get_guild_user_list($guild_ids,$user_id,$page=1,$page_limit=30,$seach=""){
|
||||
//获取$guild_id的第一个字母
|
||||
$guild_id_first_letter = substr($guild_ids, 0, 1);
|
||||
$guild_id = substr($guild_ids, 1);
|
||||
|
||||
if (substr($guild_ids, 0, 2) === 'gg') {
|
||||
$guild_id = substr($guild_ids, 2);
|
||||
|
||||
} elseif (substr($guild_ids, 0, 1) === 'g') {
|
||||
$guild_id = substr($guild_ids, 1);
|
||||
|
||||
} else {
|
||||
$guild_id = substr($guild_ids, 1);
|
||||
}
|
||||
|
||||
$seach_where = [];
|
||||
if($seach){
|
||||
if(is_numeric($seach)){
|
||||
$seach_where = ['b.user_code' => ['like', $seach . '%']];
|
||||
}else{
|
||||
$seach_where = ['b.nickname' => ['like', '%' . $seach . '%']];
|
||||
}
|
||||
}
|
||||
if($guild_id_first_letter == 'g'){
|
||||
$count = Db::name('vs_guild_user')
|
||||
->alias('a')
|
||||
->join('user b','a.user_id = b.id')
|
||||
->where($seach_where)
|
||||
->where(['a.guild_id'=>$guild_id,'a.status'=>1,'a.delete_time'=>0])
|
||||
->count();
|
||||
$list = Db::name('vs_guild_user')
|
||||
->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->field('a.id, a.user_id, a.guild_id, b.nickname, b.avatar, b.user_code, a.createtime')
|
||||
->where($seach_where)
|
||||
->where(['a.guild_id' => $guild_id, 'a.status' => 1,'a.delete_time' => 0])
|
||||
->order('a.id asc')
|
||||
->page($page, $page_limit)
|
||||
@@ -927,6 +990,7 @@ class Guild extends Model
|
||||
$list = db::name('vs_family')->alias('a')
|
||||
->join('user b','a.user_id = b.id')
|
||||
->field('b.is_online,b.market_value,b.nickname,b.avatar,b.user_code,a.user_id,a.createtime')
|
||||
->where($seach_where)
|
||||
->where(['a.pid' => $myFamilyPid,'a.deletetime' => 0,'a.type' => 0])
|
||||
->order('a.id asc')
|
||||
->page($page, $page_limit)
|
||||
@@ -934,6 +998,7 @@ class Guild extends Model
|
||||
|
||||
$count = db::name('vs_family')->alias('a')
|
||||
->join('user b','a.user_id = b.id')
|
||||
->where($seach_where)
|
||||
->where(['a.pid' => $myFamilyPid,'a.deletetime' => 0,'a.type' => 0])
|
||||
->count();
|
||||
}
|
||||
@@ -943,7 +1008,7 @@ class Guild extends Model
|
||||
foreach ($member_array as $k=> $v){
|
||||
$member_array_str[] = 'u' . $v;
|
||||
}
|
||||
$group_member_info = model('Tencent')->get_group_member_info($guild_ids,$member_array_str);
|
||||
$group_member_info = model('api/Tencent')->get_group_member_info($guild_ids,$member_array_str);
|
||||
if($group_member_info['code'] == 0){
|
||||
return V($group_member_info['code'],$group_member_info['msg'], $group_member_info['data']);
|
||||
}
|
||||
@@ -958,6 +1023,18 @@ class Guild extends Model
|
||||
'Member'=>'普通群成员',
|
||||
'NotMember'=>'非群成员'
|
||||
];
|
||||
$roles = [
|
||||
'Owner'=> 1,
|
||||
'Admin'=> 2,
|
||||
'Member'=> 3,
|
||||
'NotMember'=> 4
|
||||
];
|
||||
//禁言用户列表
|
||||
$mute_list = model('api/Tencent')->get_group_mute_list($guild_ids);
|
||||
$mute_user_list = [];
|
||||
if($mute_list['code'] == 1){
|
||||
$mute_user_list = array_column($mute_list['data'], 'Member_Account');
|
||||
}
|
||||
foreach ($list as $key => $value) {
|
||||
if($user_id == $value['user_id']){
|
||||
$list[$key]['is_self'] = 1;
|
||||
@@ -967,6 +1044,7 @@ class Guild extends Model
|
||||
$list[$key]['user_code'] = model('Decorate')->user_decorate_detail($value['user_id'], 6);
|
||||
//角色:
|
||||
$list[$key]['role'] = $member['u'.$value['user_id']];
|
||||
$list[$key]['group_role'] = $roles[$list[$key]['role']];
|
||||
$list[$key]['role_str'] = $role[$list[$key]['role']];
|
||||
$list[$key]['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
||||
//当前用户是否在房间
|
||||
@@ -977,6 +1055,12 @@ class Guild extends Model
|
||||
->where(['a.user_id' => $value['user_id'], 'a.is_delete' => 1])
|
||||
->find();
|
||||
$list[$key]['in_room_id'] = $in_room['room_id'] ?? 0;
|
||||
//用户是否被禁言
|
||||
if(in_array('u'.$value['user_id'], $mute_user_list)){
|
||||
$list[$key]['is_mute'] = 1;
|
||||
}else{
|
||||
$list[$key]['is_mute'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -997,33 +1081,64 @@ class Guild extends Model
|
||||
if(!$guild_ids){
|
||||
return ['code' => 0, 'msg' => '参数错误'];
|
||||
}
|
||||
//获取$guild_id的第一个字母
|
||||
$guild_id_first_letter = substr($guild_ids, 0, 1);
|
||||
$guild_id = substr($guild_ids, 1);
|
||||
if($guild_id_first_letter == 'g'){
|
||||
if (substr($guild_ids, 0, 2) === 'gg') {
|
||||
$guild_id = substr($guild_ids, 2);
|
||||
$guild_info = db::name('vs_guild')->where(['id'=>$guild_id,'status'=>1,'delete_time'=>0])->find();
|
||||
$cover = $guild_info['cover'] ?? "";
|
||||
}else{
|
||||
} elseif (substr($guild_ids, 0, 1) === 'g') {
|
||||
$guild_id = substr($guild_ids, 1);
|
||||
$guild_info = db::name('vs_guild')->where(['id'=>$guild_id,'status'=>1,'delete_time'=>0])->find();
|
||||
$cover = $guild_info['cover'] ?? "";
|
||||
} else {
|
||||
$guild_id = substr($guild_ids, 1);
|
||||
$guild_info = db::name('vs_family')->where(['id'=>$guild_id])->find();
|
||||
$cover = db::name('user')->where(['id'=>$guild_info['user_id']])->value('avatar');
|
||||
}
|
||||
//获取字符串里有几个g
|
||||
// $guild_id_count = substr_count($guild_ids, 'g');
|
||||
// $guild_id_first_letter = substr($guild_ids, 0, 1);
|
||||
// if($guild_id_count == 2){
|
||||
// //获取$guild_id的第一个字母
|
||||
// $guild_id = substr($guild_ids, 2);
|
||||
// }else{
|
||||
// //获取$guild_id的第一个字母
|
||||
// $guild_id = substr($guild_ids, 1);
|
||||
// }
|
||||
// if($guild_id_first_letter == 'g'){
|
||||
// $guild_info = db::name('vs_guild')->where(['id'=>$guild_id,'status'=>1,'delete_time'=>0])->find();
|
||||
// $cover = $guild_info['cover'] ?? "";
|
||||
// }else{
|
||||
// $guild_info = db::name('vs_family')->where(['id'=>$guild_id])->find();
|
||||
// $cover = db::name('user')->where(['id'=>$guild_info['user_id']])->value('avatar');
|
||||
// }
|
||||
|
||||
$group_member_info = model('Tencent')->get_group_info($guild_ids);
|
||||
$group_member_info = model('api/Tencent')->get_group_info($guild_ids);
|
||||
if($group_member_info['code']!=1){
|
||||
return ['code' => 0, 'msg' => '群聊不存在',null];
|
||||
}
|
||||
$user_list = $this->get_guild_user_list($guild_ids,0,1,10);
|
||||
$is_deacon = 2;
|
||||
if($guild_info['user_id'] ==$user_id){
|
||||
$is_deacon = 1;
|
||||
$role = model('api/Tencent')->get_group_member_info($guild_ids,['u'.$user_id]);
|
||||
if($role['code'] == 0){
|
||||
return V($role['code'],$role['msg'], $role['data']);
|
||||
}
|
||||
|
||||
$role_data = $role['data'][0];
|
||||
$roles = [
|
||||
'Owner'=> 1,
|
||||
'Admin'=> 2,
|
||||
'Member'=> 3,
|
||||
'NotMember'=> 4
|
||||
];
|
||||
//$roles[$list[$key]['role']]
|
||||
$is_deacon =$roles[$role_data['Role']];
|
||||
$return_data =[
|
||||
'guild_id' => $guild_ids,
|
||||
'guild_cover' => $cover,
|
||||
'is_deacon' => $is_deacon,
|
||||
'user_list' => $user_list['data']['list'],
|
||||
'name' => $group_member_info['data'][0]['Name'],
|
||||
'notification' => $group_member_info['data'][0]['Notification']
|
||||
'notification' => $group_member_info['data'][0]['Notification'],
|
||||
'mute_all_member' => $group_member_info['data'][0]['MuteAllMember'] == 'On' ? 1 : 0,
|
||||
];
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $return_data];
|
||||
|
||||
@@ -1032,18 +1147,26 @@ class Guild extends Model
|
||||
* 设置群聊信息
|
||||
*/
|
||||
public function set_guild_info($guild_id,$name,$notice,$avatar){
|
||||
$return = model('Tencent')->modify_group_base_info($guild_id, $name,$avatar, $notice);
|
||||
if($guild_id<=95){
|
||||
$guild_id = "g".$guild_id;
|
||||
}else{
|
||||
$guild_id = $guild_id;
|
||||
}
|
||||
$guild_id = 'g'.$guild_id;
|
||||
$return = model('api/Tencent')->modify_group_base_info($guild_id, $name,$avatar, $notice);
|
||||
return ['code' => $return['code'], 'msg' => $return['msg'], 'data' => $return['data']];
|
||||
}
|
||||
|
||||
/*
|
||||
/*dd
|
||||
* 我的公会
|
||||
* @param $id
|
||||
* @param $user_id
|
||||
*/
|
||||
public function my_guild($user_id)
|
||||
{
|
||||
$guild_user = Db::name('vs_guild_user')->where(['user_id'=>$user_id,'status'=>1,'delete_time'=>0])->find();
|
||||
$guild_user = Db::name('vs_guild_user')->where(['user_id'=>$user_id,'status'=>1,'delete_time'=>0])
|
||||
->order('createtime desc')
|
||||
->find();
|
||||
if(empty($guild_user)){
|
||||
return ['code' => 0, 'msg' => '您没有加入任何公会', 'data'=>null];
|
||||
}
|
||||
@@ -1069,10 +1192,9 @@ class Guild extends Model
|
||||
//本周的第一天
|
||||
$week = strtotime(date('Y-m-d 00:00:00', strtotime('this week Monday')));
|
||||
$week_end_time = time();
|
||||
$guild_data['week_income'] = db::name('vs_give_gift')
|
||||
->whereIn('gift_user',$user_id)
|
||||
$guild_data['week_income'] = db::name('vs_guild_flow')->where(['guild_id'=>$info['id']])
|
||||
->where(['createtime' => ['between', [$week, $week_end_time]]])
|
||||
->sum('total_price');
|
||||
->sum('flow_price');
|
||||
//厅主收益
|
||||
$guild_data['room_author_ratio'] = $guild_user['room_id']==0 ? 0 : get_system_config_value('room_author_ratio');
|
||||
//礼物分成
|
||||
@@ -1080,7 +1202,13 @@ class Guild extends Model
|
||||
//付费退出公会所需金
|
||||
$guild_data['quit_guild_gold'] = get_system_config_value('quit_guild_gold');
|
||||
//工会群组ID
|
||||
$guild_data['guild_group_id'] = "g".$info['id'];
|
||||
if($info['id']<=95){
|
||||
$guild_id = "g".$info['id'];
|
||||
}else{
|
||||
$guild_id = $info['id'];
|
||||
}
|
||||
$guild_data['guild_group_id'] = $guild_id;
|
||||
$guild_data['guild_id'] = $guild_id;
|
||||
//工会基础信息
|
||||
$guild_data_info = Db::name('vs_guild_data')->where(['guild_id'=>$info['id']])->find();
|
||||
$guild_data['agreement'] = $guild_data_info['agreement'] ?? '';
|
||||
@@ -1093,12 +1221,18 @@ class Guild extends Model
|
||||
*/
|
||||
public function join_guild($guild_id,$user_id=0,$settlement_ratio = 0)
|
||||
{
|
||||
$user_info = model('User')->get_user_info($user_id);
|
||||
$user_info = db::name('user')->where(['id'=>$user_id])->find();
|
||||
if(!$user_info){
|
||||
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||
}
|
||||
if($user_info['is_real']!=1 || empty($user_info['card_id'])){
|
||||
return ['code' => 0, 'msg' => '请先实名认证', 'data' => null];
|
||||
//查询是否实名认证
|
||||
$is_real = model('api/UserData')->real_name_info($user_id);
|
||||
if($is_real['code']==0){
|
||||
return ['code' => 0, 'msg' => '请先实名认证','data' => null];
|
||||
}else{
|
||||
if($is_real['data']['is_real'] !=1){
|
||||
return ['code' => 0, 'msg' => '请先实名认证','data' => null];
|
||||
}
|
||||
}
|
||||
//公会是否存在
|
||||
$guild_info = db::name('vs_guild')->where(['id'=>$guild_id,'delete_time'=>0])->find();
|
||||
@@ -1142,7 +1276,7 @@ class Guild extends Model
|
||||
}
|
||||
//是否有房间
|
||||
$rid = 0;
|
||||
$room_info = db::name('vs_room')->where('user_id', $user_id)->find();
|
||||
$room_info = db::name('vs_room')->where(['user_id'=>$user_id,'delete_time'=>0,'type_id'=>['<>',6]])->find();
|
||||
if($room_info){
|
||||
$rid = $room_info['id'];
|
||||
}
|
||||
@@ -1168,8 +1302,11 @@ class Guild extends Model
|
||||
//增加公会人数
|
||||
db::name('vs_guild')->where('id', $guild_info['id'])->setInc('num', 1);
|
||||
//拉用户进入工会群聊
|
||||
model('Tencent')->add_group_member('g'.$guild_id, $user_id);
|
||||
model('Tencent')->send_group_system_notification('g'.$guild_id,"欢迎".$user_info['nickname'].'加入公会');
|
||||
if($guild_id<=95){ //事故处理-114以前的群被删了
|
||||
$guild_id = "g".$guild_id;
|
||||
}
|
||||
model('api/Tencent')->add_group_member('g'.$guild_id, $user_id);
|
||||
model('api/Tencent')->send_group_system_notification('g'.$guild_id,"欢迎".$user_info['nickname'].'加入公会');
|
||||
//发系统信息
|
||||
$content = "恭喜加入{$guild_info['guild_name']}工会,您的个人收益增加{$configs['room_gift_guild_ratio']}%,目前总收益{$insert_data['settlement_ratio']}%";
|
||||
model('api/UserMessage')->send_system_message($user_id, "加入公会成功通知", $content, 1);
|
||||
|
||||
@@ -41,7 +41,7 @@ class HeadLine extends Model
|
||||
}
|
||||
}
|
||||
//检测用户余额
|
||||
$user_coin = model('UserWallet')->where('user_id' ,$uid)->value('coin');
|
||||
$user_coin = db::name('user_wallet_coin')->where('user_id' ,$uid)->value('coin');
|
||||
if($user_coin < $money) {
|
||||
return ['code' => 0, 'msg' => '余额不足!', 'data' => null];
|
||||
}
|
||||
@@ -81,26 +81,13 @@ class HeadLine extends Model
|
||||
}
|
||||
|
||||
//扣除用户余额
|
||||
$res4 = model('UserWallet')->where('user_id' ,$uid)->setDec('coin', $money);
|
||||
if(!$res4) {
|
||||
$wallet_update = model('api/UserWallet')->change_user_cion_log($uid,$money,$room_id,20,'发布头条');
|
||||
if(!$wallet_update){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '扣除用户余额失败!', 'data' => null];
|
||||
return ['code' => 0, 'msg' => '网络错误-1', 'data' => null];
|
||||
}
|
||||
//记录扣除用户余额
|
||||
$res5 =db::name('vs_user_money_log')->insert([
|
||||
'user_id' => $uid,
|
||||
'change_type' => 20,
|
||||
'money_type' => 1,
|
||||
'change_value' => $money,
|
||||
'from_id' => $res3,
|
||||
'remarks' => '发布头条扣除余额',
|
||||
'createtime' => time(),
|
||||
]);
|
||||
if(!$res5) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '记录扣除用户余额失败!', 'data' => null];
|
||||
}
|
||||
//给所有直播间发送消息 这个接口是要钱的 需要购买 暂时先藏起来
|
||||
|
||||
//给所有直播间发送消息
|
||||
$ToUserInfo = Db::name('user')->where(['id' => $uid])->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$text = [
|
||||
'type' => 1,
|
||||
|
||||
@@ -57,35 +57,24 @@ class Invited extends Model
|
||||
}
|
||||
|
||||
//下级充值推荐人收益计算
|
||||
public function invited_reward($sub_user_id,$money){
|
||||
//查询上级
|
||||
$invited_user_id = $this->where('sub_user_id', $sub_user_id)->value('user_id');
|
||||
if(!$invited_user_id){
|
||||
return ['code' => 0, 'msg' => "未绑定上级用户", 'data' => null];
|
||||
public function invited_reward($sub_user_id,$money,$invited_user_id){
|
||||
//查询下级用户充值总金额
|
||||
$sub_user_all_money = db::name('vs_user_recharge')
|
||||
->where('user_id', $sub_user_id)
|
||||
->where('pay_status',2)->sum('money');
|
||||
if($sub_user_all_money > 1000){
|
||||
return ['code' => 1, 'msg' => "下级充值金额大于1000元不需返利", 'data' => null];
|
||||
}
|
||||
|
||||
$invited_draw_conf = get_system_config_value('invited_draw');//分成比例
|
||||
$invited_draw = $invited_draw_conf / 100;
|
||||
$invited_draw_money = $money * $invited_draw;
|
||||
$invited_draw_money = $invited_draw_money / intval(get_system_config_value('rmb_coin_ratio')); //金币换算成钻石
|
||||
//修改用户资金
|
||||
$reslut = model('common/UserWallet')->change_user_money($invited_user_id, $invited_draw_money, model('common/UserWallet')::MONEYTYPEARNINGS, model('common/UserWallet')::OPERATION_INVITE_REBATE, '邀请用户充值返利');
|
||||
if($reslut['code'] == 1){
|
||||
//记录日志
|
||||
$data = [];
|
||||
$data['user_id'] = $invited_user_id;
|
||||
$data['sub_user_id'] = $sub_user_id;
|
||||
$data['coin'] = $money;
|
||||
$data['earnings'] = $invited_draw_money;
|
||||
$data['proportion'] = $invited_draw_conf;
|
||||
$data['createtime'] = time();
|
||||
$data['updatetime'] = time();
|
||||
$res = Db::name('vs_user_invited_income_log')->insert($data);
|
||||
if ($res) {
|
||||
return ['code' => 1, 'msg' => "操作成功", 'data' => null];
|
||||
}
|
||||
}else{
|
||||
return ['code' => $reslut['code'], 'msg' => $reslut['code'], 'data' => null];
|
||||
//增加余额并记录日志
|
||||
$wallet_update = model('api/UserWallet')->change_user_earnings_log($invited_user_id,$invited_draw_money,0,6,'邀请用户充值返利');
|
||||
if(!$wallet_update){
|
||||
return ['code' => 0, 'msg' => "邀请给上级返利失败", 'data' => null];
|
||||
}
|
||||
return ['code' => 1, 'msg' => "操作成功", 'data' => null];
|
||||
}
|
||||
|
||||
//账单明细
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace app\api\model;
|
||||
|
||||
use app\common\controller\Push;
|
||||
use app\common\service\LotteryService;
|
||||
use app\common\service\LotteryService5;
|
||||
use app\common\service\LotteryService10;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
use think\Log;
|
||||
@@ -15,7 +17,7 @@ class Lottery extends Model
|
||||
* 送礼参与抽奖接口
|
||||
* @return json
|
||||
*/
|
||||
public function gift($send_uid, $recv_uid,$gift_id, $room_id, $num)
|
||||
public function gift($send_uid, $recv_uid, $gift_id, $room_id, $num, $pool_gift_ids)
|
||||
{
|
||||
if (ceil($num) != $num) {
|
||||
return ['code' => 0, 'msg' => '打赏礼物数量必须为整数', 'data' => null];
|
||||
@@ -33,7 +35,7 @@ class Lottery extends Model
|
||||
//送给所有人的总价格
|
||||
$all_gift_price = $gift_info['gift_price'] * $num * count($toarray);
|
||||
//判断是否有足够的金币
|
||||
$user_waller = db::name('user_wallet')->where(['user_id'=>$send_uid])->find();
|
||||
$user_waller = db::name('user_wallet_coin')->where(['user_id'=>$send_uid])->find();
|
||||
if ($user_waller['coin'] < $all_gift_price) {
|
||||
return ['code' => 0, 'msg' => '用户金币不足', 'data' => null];
|
||||
}
|
||||
@@ -47,7 +49,7 @@ class Lottery extends Model
|
||||
//送礼 开启事务
|
||||
Db::startTrans();
|
||||
//扣除用户金币并记录日志
|
||||
$wallet_update = model('api/GiveGift')->change_user_cion_or_earnings_log($send_uid,$all_gift_price,$room_id,1,10,'用户金币购买礼物');
|
||||
$wallet_update = model('api/UserWallet')->change_user_cion_log($send_uid, $all_gift_price, $room_id, 10, '用户金币购买幸运币礼物');
|
||||
if(!$wallet_update){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '扣除用户金币失败', 'data' => null];
|
||||
@@ -61,6 +63,21 @@ class Lottery extends Model
|
||||
|
||||
//送给一人礼物的总价格(扣除用户的数额)
|
||||
$gift_price = $gift_info['gift_price'] * $num;
|
||||
//幸运币收益率
|
||||
$lucky_rate = db::name('bb_lottery_config')->where(['key' => 'lucky_rate'])->value('value');
|
||||
$recv_coin = round($gift_price * $lucky_rate / 100, 2);
|
||||
$small_pool = $gift_price - $recv_coin;
|
||||
|
||||
if($gift_id == $pool_gift_ids['pool_gift_id_5']){
|
||||
$table = 'bb_lottery_gift_record_5';
|
||||
$poole_type = 5;
|
||||
}elseif($gift_id == $pool_gift_ids['pool_gift_id_10']){
|
||||
$table = 'bb_lottery_gift_record_10';
|
||||
$poole_type = 10;
|
||||
}else{
|
||||
$table = 'bb_lottery_gift_record';
|
||||
$poole_type = 1;
|
||||
}
|
||||
|
||||
foreach ($toarray as $k => $to_id){
|
||||
// 1. 记录礼物赠送
|
||||
@@ -69,29 +86,24 @@ class Lottery extends Model
|
||||
'recv_uid' => $to_id,
|
||||
'gift_id' => $gift_id,
|
||||
'gift_gold' => $gift_price,
|
||||
'recv_gold' => $gift_price /2 ,
|
||||
'small_pool_add' => $gift_price /2 ,
|
||||
'create_time' => time()
|
||||
'recv_gold' => $recv_coin,
|
||||
'small_pool_add' => $small_pool,
|
||||
'create_time' => time(),
|
||||
'remark' => '幸运币收益率'.$lucky_rate.'%'
|
||||
];
|
||||
$giftId = Db::name('bb_lottery_gift_record')->insertGetId($giftRecord);
|
||||
$giftId = Db::name($table)->insertGetId($giftRecord);
|
||||
|
||||
//收礼记录行为日志
|
||||
$give_gift = model('api/GiveGift')->change_user_give_gift_log($send_uid,$gift_id,$gift_price,$num,$to_id,2,1,0,0);
|
||||
$give_gift = model('api/SendGift')->change_user_give_gift_logs($send_uid,$gift_id,$gift_price,$num,$to_id,2,1,0,'送幸运币');
|
||||
if(!$give_gift){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '送礼失败', 'data' => null];
|
||||
}
|
||||
//计算收礼人得益
|
||||
$receiver_earnings = $gift_price /2/get_system_config_value('rmb_coin_ratio');
|
||||
$receiver_earnings = $recv_coin/get_system_config_value('rmb_coin_ratio');
|
||||
//增加收益并记录日志
|
||||
$receiver = model('api/GiveGift') -> change_user_cion_or_earnings_log($to_id,$receiver_earnings,$room_id,2,11,'收礼增加收益');
|
||||
$receiver = model('api/UserWallet')->change_user_earnings_log($to_id,$receiver_earnings,$room_id,11,'收幸运币礼物增加收益');
|
||||
|
||||
// //用户魅力等级更新
|
||||
// $user_level = model('api/Level')->user_level_data_update($to_id,$gift_price,2,$room_id);
|
||||
// if(!$user_level){
|
||||
// Db::rollback();
|
||||
// return ['code' => 0, 'msg' => '用户等级更新失败', 'data' => null];
|
||||
// }
|
||||
//增加房间幸运值
|
||||
db::name('vs_room')->where(['id' => $room_id])->setInc('luck_value',$gift_price);
|
||||
db::name('vs_room_luck_value')->insert( [
|
||||
@@ -123,7 +135,7 @@ class Lottery extends Model
|
||||
|
||||
//计算爆币
|
||||
$nums = $num * count($toarray);
|
||||
$ress = $this->lottery($send_uid,$gift_info['gift_price'],$nums,$room_id,$gift_id,$FromUserInfo,$gift_info);
|
||||
$ress = $this->lottery($send_uid,$gift_info['gift_price'],$nums,$room_id,$gift_id,$FromUserInfo,$gift_info,$poole_type);
|
||||
if($ress['code'] == 0){
|
||||
return ['code' => 0, 'msg' => $ress['msg'], 'data' => null];
|
||||
}
|
||||
@@ -132,8 +144,76 @@ class Lottery extends Model
|
||||
}
|
||||
|
||||
|
||||
//抽奖
|
||||
public function lottery($send_uid,$gift_price,$num,$room_id,$giftId,$fromUserInfo=null,$gift_info=null)
|
||||
//抽奖(不带大奖池)
|
||||
public function lottery($send_uid,$gift_price,$num,$room_id,$giftId,$fromUserInfo=null,$gift_info=null,$poole_type = 1)
|
||||
{
|
||||
try {
|
||||
$gift_gold = $gift_price;
|
||||
if($poole_type == 5){
|
||||
$text = '中级';
|
||||
$small_prize_play_image = db::name('bb_lottery_config')->where(['key' => 'big_prize_play_image'])->value('value');
|
||||
$service = new LotteryService5();
|
||||
}elseif($poole_type == 10){
|
||||
$text = '高级';
|
||||
$small_prize_play_image = db::name('bb_lottery_config')->where(['key' => 'gao_prize_play_image'])->value('value');
|
||||
$service = new LotteryService10();
|
||||
}else{
|
||||
$text = '初级';
|
||||
$small_prize_play_image = db::name('bb_lottery_config')->where(['key' => 'small_prize_play_image'])->value('value');
|
||||
$service = new LotteryService();
|
||||
}
|
||||
|
||||
for($i=0;$i<$num;$i++){
|
||||
$reslut = $service->handleGift($send_uid, $gift_gold, $giftId);
|
||||
if ($reslut['code'] == 1) {
|
||||
$result = $reslut['data'];
|
||||
//(未开奖时)
|
||||
if ($result['is_small_prize'] == 0) {
|
||||
//不做处理
|
||||
} else {//开奖
|
||||
$beilv = floor($result['small_prize_amount'] / $gift_price);
|
||||
$small_prize_amount = floor($result['small_prize_amount'] / $gift_price) * $gift_price;
|
||||
$wallet_update = model('api/UserWallet')->change_user_cion_log($send_uid,$small_prize_amount,$room_id,58,'参与幸运币活动获得'.$beilv.'倍');
|
||||
if(!$wallet_update){
|
||||
return ['code' => 0, 'msg' => '流水记录失败', 'data' => null];
|
||||
}
|
||||
|
||||
$tet['text'] = '恭喜用户'.$fromUserInfo['nickname'].'在'.$text.'幸运币活动中获得幸运币'.$beilv.'倍';
|
||||
$tet['type'] = 2;
|
||||
$tet['beilv'] = $beilv;
|
||||
$tet['play_image'] = $small_prize_play_image;
|
||||
$tet['FromUserInfo'] = $fromUserInfo;
|
||||
$tet['user_id'] = $send_uid;
|
||||
model('api/Chat')->sendMsg(1100,$room_id,$tet);
|
||||
|
||||
$push = new Push($send_uid, $room_id);
|
||||
$room_name = Db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->value('room_name');
|
||||
$text = '恭喜'.$fromUserInfo['nickname'] . '在' . $room_name . '房间获得'.$text.'幸运币'. $beilv . '倍';
|
||||
$text_list_new[] = [
|
||||
'text' => $text,
|
||||
'gift_picture' => $gift_info['base_image'],
|
||||
'room_id' => $room_id,
|
||||
'fromUserName' => $fromUserInfo['nickname'],
|
||||
'toUserName' => '',
|
||||
'giftName' => '',
|
||||
'roomId' => $room_id,
|
||||
'number' => 1,
|
||||
];
|
||||
$push->giftBanner($text_list_new);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => '送礼成功', 'data' => null];
|
||||
} catch (Exception $e) {
|
||||
Log::error('抽奖处理失败:' . $e->getMessage());
|
||||
return ['code' => 0, 'msg' => $e->getMessage(), 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//抽奖(带大奖池)
|
||||
public function lotterys($send_uid,$gift_price,$num,$room_id,$giftId,$fromUserInfo=null,$gift_info=null)
|
||||
{
|
||||
$big_prize_play_image = db::name('bb_lottery_config')->where(['key' => 'big_prize_play_image'])->value('value');
|
||||
$small_prize_play_image = db::name('bb_lottery_config')->where(['key' => 'small_prize_play_image'])->value('value');
|
||||
@@ -141,7 +221,7 @@ class Lottery extends Model
|
||||
for($i=0;$i<$num;$i++){
|
||||
$gift_gold = $gift_price;
|
||||
$service = new LotteryService();
|
||||
$reslut = $service->handleGift($send_uid, $gift_gold, $giftId);
|
||||
$reslut = $service->handleGifts($send_uid, $gift_gold, $giftId);
|
||||
if ($reslut['code'] == 1) {
|
||||
$result = $reslut['data'];
|
||||
//(未开奖时)
|
||||
@@ -151,7 +231,8 @@ class Lottery extends Model
|
||||
// 大奖
|
||||
if ($result['is_big_prize'] == 1) {//$result['big_prize_amount'],//中奖金额
|
||||
$beilv = floor($result['big_prize_amount'] / $gift_price);
|
||||
$wallet_update = model('api/GiveGift')->change_user_cion_or_earnings_log($send_uid,$result['big_prize_amount'],$room_id,1,58,'参与幸运币活动获得'.$beilv.'倍');
|
||||
// $wallet_update = model('api/GiveGift')->change_user_cion_or_earnings_log($send_uid,$result['big_prize_amount'],$room_id,1,58,'参与幸运币活动获得'.$beilv.'倍');
|
||||
$wallet_update = model('api/UserWallet')->change_user_cion_log($send_uid,$result['big_prize_amount'],$room_id,58,'参与幸运币活动获得'.$beilv.'倍');
|
||||
if(!$wallet_update){
|
||||
return ['code' => 0, 'msg' => '流水记录失败', 'data' => null];
|
||||
}
|
||||
@@ -162,7 +243,8 @@ class Lottery extends Model
|
||||
$tet['play_image'] = $big_prize_play_image;
|
||||
} else { // 小奖 $result['small_prize_amount'],//中奖金额
|
||||
$beilv = floor($result['small_prize_amount'] / $gift_price);
|
||||
$wallet_update = model('api/GiveGift')->change_user_cion_or_earnings_log($send_uid,$result['small_prize_amount'],$room_id,1,58,'参与幸运币活动获得'.$beilv.'倍');
|
||||
// $wallet_update = model('api/GiveGift')->change_user_cion_or_earnings_log($send_uid,$result['small_prize_amount'],$room_id,1,58,'参与幸运币活动获得'.$beilv.'倍');
|
||||
$wallet_update = model('api/UserWallet')->change_user_cion_log($send_uid,$result['small_prize_amount'],$room_id,58,'参与幸运币活动获得'.$beilv.'倍');
|
||||
if(!$wallet_update){
|
||||
return ['code' => 0, 'msg' => '流水记录失败', 'data' => null];
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ class MarketValue extends Model
|
||||
* * @return array
|
||||
*/
|
||||
public function change($user_id,$change_value,$type){
|
||||
$change_value = abs($change_value);
|
||||
$before = db::name('user')->where('id',$user_id)->value('market_value');
|
||||
if($type == 0 || $type == 3){
|
||||
$result = db::name('user')->where('id',$user_id)->setInc('market_value',$change_value);
|
||||
|
||||
727
application/api/model/Monster.php
Normal file
727
application/api/model/Monster.php
Normal file
@@ -0,0 +1,727 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
use app\common\controller\Push;
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class Monster extends Model
|
||||
{
|
||||
|
||||
// 开启自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'int';
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
|
||||
public static function init()
|
||||
{
|
||||
self::beforeWrite(function ($row) {
|
||||
});
|
||||
}
|
||||
//选择金币列表
|
||||
public function choice_gold_list(){
|
||||
$list = db::name('monster_multiple')->field('multiple')->select();
|
||||
$data = [];
|
||||
$data['list'] = $list;
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//游戏详情
|
||||
public function get_monster_info($uid){
|
||||
$config = get_system_config();
|
||||
$user_info = db::name('user_wallet_coin')->where('user_id', $uid)->field('id,coin')->find();
|
||||
if(!$user_info){
|
||||
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||
}
|
||||
$now_time = time();
|
||||
|
||||
$data = [];
|
||||
$data['surplus_time'] = 0;
|
||||
$data['is_finsh'] = 3;
|
||||
$data['win_number'] = 0;
|
||||
// $data['list'] = [];
|
||||
$data['open_monster_price'] = $config['open_monster_price'];
|
||||
$data['integral'] = $user_info['coin'];
|
||||
$data['multiple_list'] = db::name('monster')->field('id,type,type_name,multiple')->order('id asc')->select();
|
||||
foreach ($data['multiple_list'] as $a => &$b){
|
||||
$b['num'] = 0;
|
||||
}
|
||||
//当前是否有开放该活动
|
||||
$monster_log = db::name('monster_log')->order('id desc')->limit(1)->find();
|
||||
if(empty($monster_log)){
|
||||
return ['code' => 0, 'msg' => '获取成功', 'data' => $data];
|
||||
}else{
|
||||
if($monster_log['end_time'] <= $now_time){
|
||||
$is_finish = 1;
|
||||
$data['win_number'] = $monster_log['win_type'];
|
||||
}else{
|
||||
$is_finish = 2;
|
||||
$data['surplus_time'] = $monster_log['end_time'] - $now_time;
|
||||
}
|
||||
$data['is_finsh'] = $is_finish;
|
||||
foreach ($data['multiple_list'] as $a => &$b){
|
||||
$user_monster_feed_log = db::name('user_monster_log')->where('uid', $uid)->where('mid', $monster_log['id'])->where('type', $b['type'])->find();
|
||||
if(!empty($user_monster_feed_log)){
|
||||
$b['num'] = $user_monster_feed_log['num'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $data];
|
||||
}
|
||||
|
||||
//生成当前国王游戏期数
|
||||
public function create_monster_log(){
|
||||
set_time_limit(0);
|
||||
ini_set('memory_limit', '1024M');
|
||||
|
||||
$config = get_system_config();
|
||||
$now_time = time();
|
||||
$is_push = 5;//不推送
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$map = [];
|
||||
$map['is_delete'] = 1;
|
||||
$monster_log = db::name('monster_log')->where($map)->find();
|
||||
if($monster_log){//当前有未结束的国王游戏期数
|
||||
if($now_time >= $monster_log['end_time']){
|
||||
$key_name = "api:monster:create_monster_log:id".$monster_log['id'];
|
||||
$redis_order_sn = redis_lock_exits($key_name,1,7);
|
||||
if(!$redis_order_sn){
|
||||
return ['code' => 0, 'msg' => '请重试1', 'data' => null];
|
||||
}
|
||||
|
||||
$win_type = $monster_log['win_type'];
|
||||
$in_amount = 0;
|
||||
|
||||
$win_type = $this->check_win_type_is_loss($win_type, $monster_log);
|
||||
|
||||
$win_gift_info = db::name('vs_gift')->alias('a')->join('monster b', 'a.gid = b.gid')->where('b.type', $win_type)->field('a.gid,a.gift_name,a.gift_price,a.base_image,b.multiple')->find();
|
||||
if(!$win_gift_info){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '为配置礼物', 'data' => null];
|
||||
}
|
||||
|
||||
//获取得奖用户ID
|
||||
$map = [];
|
||||
$map['mid'] = $monster_log['id'];
|
||||
$part_user_array = db::name('user_monster_log')->where($map)->group('uid')->column('uid');
|
||||
$map['type'] = $win_type;
|
||||
$user_array = db::name('user_monster_log')->where($map)->group('uid')->column('uid');
|
||||
if(!empty($user_array)){
|
||||
//有获奖用户
|
||||
$insert_all = [];
|
||||
foreach ($user_array as $a => $b){
|
||||
$map = [];
|
||||
$map['mid'] = $monster_log['id'];
|
||||
$map['uid'] = $b;
|
||||
$map['type'] = $win_type;
|
||||
$user_monster_log = db::name('user_monster_log')->where($map)->find();
|
||||
$wim_num = floor($user_monster_log['price'] * $win_gift_info['multiple'] / $win_gift_info['gift_price']);
|
||||
|
||||
$in_amount += $win_gift_info['gift_price'] * $wim_num;
|
||||
|
||||
//礼物送到背包
|
||||
if($wim_num > 0){
|
||||
$reslut = model('api/UserGiftPack')->change_user_gift_pack($b, $win_gift_info['gid'], $wim_num, model('UserGiftPack')::LY_DRAW_GIFT_GET, '炼仙传说中奖获取');
|
||||
if($reslut['code'] == 0){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => $reslut['msg'], 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//用户中奖信息
|
||||
$insert = [];
|
||||
$insert['uid'] = $b;
|
||||
$insert['rid'] = $user_monster_log['rid'];
|
||||
$insert['mid'] = $monster_log['id'];
|
||||
$insert['win_type'] = $win_type;
|
||||
$insert['win_gid'] = $win_gift_info['gid'];
|
||||
$insert['price'] = $user_monster_log['price'];
|
||||
$insert['num'] = $wim_num;
|
||||
$insert['createtime'] = time();
|
||||
$insert_all[] = $insert;
|
||||
|
||||
}
|
||||
|
||||
$reslut = db::name('user_monster_win_log')->insertAll($insert_all);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '请重试2', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//结束当前抽卡期数
|
||||
$update = [];
|
||||
$update['win_type'] = $win_type;
|
||||
$update['in_amount'] = $in_amount;
|
||||
$update['is_delete'] = 2;
|
||||
$update['updatetime'] = time();
|
||||
$reslut = db::name('monster_log')->where('id', $monster_log['id'])->update($update);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '请重试3', 'data' => null];
|
||||
}
|
||||
|
||||
$is_push = 2;
|
||||
}
|
||||
}else{//当前未有国王游戏期数
|
||||
if($config['open_monster_status'] != 1){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '游戏已关闭', 'data' => null];
|
||||
}
|
||||
|
||||
//距离上次多长时间
|
||||
$map = [];
|
||||
$map['is_delete'] = 2;
|
||||
$last_monster_log = db::name('monster_log')->where($map)->order('id desc')->limit(1)->find();
|
||||
if($last_monster_log){
|
||||
// $interval_time = $last_monster_log['end_time'] + 10 + $config['end_interval_time'];
|
||||
$interval_time = time() - $last_monster_log['end_time'];
|
||||
if($interval_time < $config['end_interval_time']){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '距离上次结束尚未超过'.$config['end_interval_time'].'秒', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//当前国王游戏配置信息
|
||||
$monster_list = db::name('monster')->order('id asc')->select();
|
||||
$monster_data = '';
|
||||
$total_num = 0;
|
||||
$win_number_data = [];
|
||||
foreach ($monster_list as $a => $b){
|
||||
$da = $b['id'].'-'.$b['gid'].'-'.$b['num'].';';
|
||||
$monster_data .= $da;
|
||||
$total_num += $b['num'];
|
||||
for($i = 0; $i < $b['num']; $i++){
|
||||
$win_number_data[] = $b['id'];
|
||||
}
|
||||
}
|
||||
|
||||
shuffle($win_number_data);
|
||||
$win_key = array_rand($win_number_data);
|
||||
//随机抽取中奖数字
|
||||
$win_type = $win_number_data[$win_key];
|
||||
|
||||
//生成最新
|
||||
$insert = [];
|
||||
$insert['win_type'] = $win_type;
|
||||
$insert['total_num'] = $total_num;
|
||||
$insert['config_text'] = $monster_data;
|
||||
$insert['createtime'] = $now_time;
|
||||
$insert['end_time'] = $now_time + $config['monster_count_down_time'];
|
||||
$reslut = db::name('monster_log')->insert($insert);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '生成失败', 'data' => null];
|
||||
}
|
||||
$is_push = 1;//开启推送
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
|
||||
if($is_push == 1){
|
||||
$push_feed_monster_data = $this->get_new_feed_monster_info();
|
||||
|
||||
$push_data = [];
|
||||
$push_data['code'] = 3031;
|
||||
$push_data['msg'] = "探索开始播报";
|
||||
$push_data['data'] = $push_feed_monster_data;
|
||||
// 推送
|
||||
$push = new Push();
|
||||
$push->xianxuan($push_data);
|
||||
}else if($is_push == 2){
|
||||
$push_feed_monster_data = $this->get_new_feed_monster_info();
|
||||
$push_feed_monster_data['win_count'] = count($user_array);
|
||||
$push_feed_monster_data['game_name'] = '国王游戏';
|
||||
$push_feed_monster_data['win_type_name'] = db::name('monster')->where('type', $win_type)->value('type_name');
|
||||
$push_feed_monster_data['gift_name'] = $win_gift_info['gift_name'];
|
||||
$push_feed_monster_data['num'] = 0;
|
||||
$push_feed_monster_data['total_gift_price'] = 0;
|
||||
$push_feed_monster_data['is_push_message'] = 2;
|
||||
|
||||
if(!empty($part_user_array)){
|
||||
foreach ($part_user_array as $k => $v){
|
||||
$push_user_monster_data = [];
|
||||
$push_user_monster_data['win_type'] = $win_type;
|
||||
$push_user_monster_data['type_name'] = db::name('monster')->where('type', $win_type)->value('type_name');
|
||||
//是否中奖
|
||||
$map = [];
|
||||
$map['mid'] = $monster_log['id'];
|
||||
$map['uid'] = $v;
|
||||
$user_win_info = db::name('user_monster_win_log')->where($map)->find();
|
||||
if($user_win_info){//中奖
|
||||
$push_user_monster_data['is_win'] = 1;
|
||||
$push_user_monster_data['gid'] = $win_gift_info['gid'];
|
||||
$push_user_monster_data['gift_name'] = $win_gift_info['gift_name'];
|
||||
$push_user_monster_data['base_image'] = localpath_to_netpath($win_gift_info['base_image']);
|
||||
$push_user_monster_data['gift_price'] = $win_gift_info['gift_price'];
|
||||
$push_user_monster_data['num'] = $user_win_info['num'];
|
||||
$push_user_monster_data['total_gift_price'] = $win_gift_info['gift_price'] * $user_win_info['num'];
|
||||
$push_feed_monster_data['num'] += $user_win_info['num'];
|
||||
$push_feed_monster_data['total_gift_price'] += $push_user_monster_data['total_gift_price'];
|
||||
}else{//未中奖
|
||||
$push_user_monster_data['is_win'] = 2;
|
||||
$push_user_monster_data['gid'] = 0;
|
||||
$push_user_monster_data['gift_name'] = '';
|
||||
$push_user_monster_data['base_image'] = '';
|
||||
$push_user_monster_data['gift_price'] = 0;
|
||||
$push_user_monster_data['num'] = 0;
|
||||
}
|
||||
|
||||
$push_data = [];
|
||||
$push_data['code'] = 3032;
|
||||
$push_data['msg'] = "抽卡个人结束播报";
|
||||
$push_data['data'] = $push_user_monster_data;
|
||||
$push = new Push();
|
||||
$push->xianxuan($push_data);
|
||||
// error_log(date('Y-m-d H:i:s').'_'.$v.'_'.$reslut."\r\n", 3, '1111.txt');
|
||||
}
|
||||
}
|
||||
|
||||
if($push_feed_monster_data['num'] > 0){
|
||||
$push_feed_monster_data['is_push_message'] = 1;
|
||||
}
|
||||
|
||||
$push_data = [];
|
||||
$push_data['code'] = 3033;
|
||||
$push_data['msg'] = "探索结束播报";
|
||||
$push_data['data'] = $push_feed_monster_data;
|
||||
$push = new Push();
|
||||
$push->xianxuan($push_data);
|
||||
|
||||
// $close_data = $this->get_close_monster_win_log();
|
||||
// $push_colse_data = [];
|
||||
// $push_colse_data['code'] = 3034;
|
||||
// $push_colse_data['msg'] = "国王游戏结束播报";
|
||||
// $push_colse_data['data'] = $close_data;
|
||||
// model('api/WebSocketPush')->send_to_all($push_colse_data);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
dump($e);
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '失败', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//是否修改中奖类型
|
||||
public function check_win_type_is_loss($win_type, $monster_log){
|
||||
$config = get_system_config();
|
||||
//当前亏损数值是否大于
|
||||
$map = [];
|
||||
$map['is_delete'] = 2;
|
||||
$map['out_amount'] = ['>', 0];
|
||||
$now_monster_out_amount = db::name('monster_log')->where($map)->sum('out_amount');//投入
|
||||
$now_monster_in_amount = db::name('monster_log')->where($map)->sum('in_amount');//产出
|
||||
|
||||
//获取得奖用户ID
|
||||
$map = [];
|
||||
$map['mid'] = [ '=', $monster_log['id']];
|
||||
$map['type'] = ['=', $win_type];
|
||||
$user_array = db::name('user_monster_log')->where($map)->group('uid')->column('uid');
|
||||
|
||||
if(!empty($user_array)){
|
||||
$wim_monster = db::name('monster')->where('type', $win_type)->find();
|
||||
$in_amount = 0;
|
||||
foreach ($user_array as $a => $b){
|
||||
$map = [];
|
||||
$map['mid'] = ['=', $monster_log['id']];
|
||||
$map['uid'] = ['=', $b];
|
||||
$map['type'] = ['=', $win_type];
|
||||
$user_monster_log = db::name('user_monster_log')->where($map)->find();
|
||||
|
||||
//中奖金额
|
||||
$win_price = $user_monster_log['price'] * $wim_monster['multiple'];
|
||||
|
||||
$in_amount += $win_price;
|
||||
}
|
||||
|
||||
$profit = ($now_monster_in_amount + $in_amount) - ($now_monster_out_amount + $monster_log['out_amount']);
|
||||
if($profit > $config['monster_max_loss_price']){//亏损大于3w
|
||||
$type_price_1 = db::name('user_monster_log')->where('mid', $monster_log['id'])->where('type', 1)->sum('price');
|
||||
$win_type_amount_1 = $type_price_1 * 2;
|
||||
$type_price_2 = db::name('user_monster_log')->where('mid', $monster_log['id'])->where('type', 2)->sum('price');
|
||||
$win_type_amount_2 = $type_price_2 * 4;
|
||||
$type_price_3 = db::name('user_monster_log')->where('mid', $monster_log['id'])->where('type', 3)->sum('price');
|
||||
$win_type_amount_3 = $type_price_3 * 6.5;
|
||||
$type_price_4 = db::name('user_monster_log')->where('mid', $monster_log['id'])->where('type', 4)->sum('price');
|
||||
$win_type_amount_4 = $type_price_4 * 10;
|
||||
$type_price_5 = db::name('user_monster_log')->where('mid', $monster_log['id'])->where('type', 5)->sum('price');
|
||||
$win_type_amount_5 = $type_price_5 * 15;
|
||||
$type_price_6 = db::name('user_monster_log')->where('mid', $monster_log['id'])->where('type', 6)->sum('price');
|
||||
$win_type_amount_6 = $type_price_6 * 20;
|
||||
// $type_price_6 = db::name('user_monster_log')->where('mid', $monster_log['id'])->where('type', 6)->sum('price');
|
||||
// $win_type_amount_6 = $type_price_6 * 50;
|
||||
|
||||
// $win_type_amount_arr = [$win_type_amount_1, $win_type_amount_2, $win_type_amount_3, $win_type_amount_4, $win_type_amount_5, $win_type_amount_6];
|
||||
$win_type_amount_arr = [$win_type_amount_1, $win_type_amount_2, $win_type_amount_3, $win_type_amount_4, $win_type_amount_5, $win_type_amount_6];
|
||||
// $win_type_amount_arr = [$win_type_amount_1, $win_type_amount_2, $win_type_amount_3, $win_type_amount_4];
|
||||
$win_type_min = min($win_type_amount_arr);
|
||||
|
||||
// if($win_type_amount_4 == $win_type_min && $win_type_amount_3 == $win_type_min && $win_type_amount_2 == $win_type_min && $win_type_amount_1 == $win_type_min){
|
||||
// $win_type = rand(1,4);
|
||||
// }else
|
||||
if($win_type_amount_1 == $win_type_min){
|
||||
$win_type = 1;
|
||||
}else if($win_type_amount_2 == $win_type_min){
|
||||
$win_type = 2;
|
||||
}else if($win_type_amount_3 == $win_type_min){
|
||||
$win_type = 3;
|
||||
}else if($win_type_amount_4 == $win_type_min){
|
||||
$win_type = 4;
|
||||
}else if($win_type_amount_5 == $win_type_min){
|
||||
$win_type = 5;
|
||||
}else if($win_type_amount_6 == $win_type_min){
|
||||
$win_type = 6;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return $win_type;
|
||||
}
|
||||
|
||||
//当前最新探索信息
|
||||
public function get_new_feed_monster_info(){
|
||||
$now_time = time();
|
||||
|
||||
$data = [];
|
||||
$data['surplus_time'] = 0;
|
||||
$data['is_finsh'] = 3;
|
||||
$data['win_number'] = 0;
|
||||
// $data['list'] = [];
|
||||
$data['multiple_list'] = db::name('monster')->field('id,type,type_name,multiple')->order('id asc')->select();
|
||||
|
||||
//当前是否有开放该活动
|
||||
$monster_log = db::name('monster_log')->order('id desc')->limit(1)->find();
|
||||
if(empty($monster_log)){
|
||||
return $data;
|
||||
}else{
|
||||
if($monster_log['end_time'] <= $now_time){
|
||||
$is_finish = 1;
|
||||
$data['win_number'] = $monster_log['win_type'];
|
||||
}else{
|
||||
$is_finish = 2;
|
||||
$data['surplus_time'] = $monster_log['end_time'] - $now_time;
|
||||
}
|
||||
$data['is_finsh'] = $is_finish;
|
||||
}
|
||||
|
||||
//当前参与用户探索列表
|
||||
// $list = db::name('user_monster_feed_log')->alias('a')->join('yy_user b', 'a.uid = b.uid')->join('yy_monster c', 'a.type = c.type')->where('a.mid', $monster_log['id'])->field('a.id,b.uid,b.nick_name,b.base64_nick_name,b.head_pic,c.type_name,a.price')->order('a.id desc')->select();
|
||||
// foreach ($list as $k => &$v){
|
||||
// $v['nick_name'] = mb_convert_encoding(base64_decode($v['base64_nick_name']), 'UTF-8', 'UTF-8');
|
||||
// $v['head_pic'] = localpath_to_netpath($v['head_pic']);
|
||||
// }
|
||||
// $data['list'] = $list;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
//国王游戏
|
||||
public function open_beat_monster($uid, $rid, $type, $num){
|
||||
$user_info = db::name('user_wallet_coin')->where('user_id', $uid)->field('id,coin')->find();
|
||||
if(!$user_info){
|
||||
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||
}
|
||||
|
||||
$config = get_system_config();
|
||||
$now_time = time();
|
||||
|
||||
$monster = db::name('monster')->where('type', $type)->find();
|
||||
if(!$monster){
|
||||
return ['code' => 0, 'msg' => '当前类型不存在', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
$map = [];
|
||||
$map['end_time'] = ['>', time()];
|
||||
$map['is_delete'] = 1;
|
||||
$monster_log = db::name('monster_log')->where($map)->find();
|
||||
if(!$monster_log){
|
||||
return ['code' => 0, 'msg' => '请等待新一轮开启', 'data' => null];
|
||||
}else{
|
||||
$surplus_time = $monster_log['end_time'] - 5;
|
||||
if($surplus_time < time()){
|
||||
return ['code' => 0, 'msg' => '最后五秒内无法参与', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
if($num < 1){
|
||||
return ['code' => 0, 'msg' => '次数不能小于1', 'data' => null];
|
||||
}
|
||||
|
||||
//该星途已探索多少次数
|
||||
$map = [];
|
||||
$map['mid'] = $monster_log['id'];
|
||||
$map['uid'] = $uid;
|
||||
$user_type_num = db::name('user_monster_log')->where($map)->column('type');
|
||||
$map['type'] = $type;
|
||||
$user_monster_num = db::name('user_monster_log')->where($map)->sum('num');
|
||||
if($user_monster_num > 0){
|
||||
if($user_monster_num + $num > $config['open_monster_max_num']){
|
||||
return ['code' => 0, 'msg' => '该玩法次数已达上限', 'data' => null];
|
||||
}
|
||||
}else{
|
||||
if($num > $config['open_monster_max_num']){
|
||||
return ['code' => 0, 'msg' => '该玩法次数已达上限', 'data' => null];
|
||||
}
|
||||
}
|
||||
$user_monster_log = db::name('user_monster_log')->where($map)->find();
|
||||
|
||||
if(count($user_type_num) >= 6 && !in_array($type, $user_type_num)){
|
||||
return ['code' => 0, 'msg' => '玩法类型不能大于六个', 'data' => null];
|
||||
}
|
||||
|
||||
// $open_monster_ticket = $config['open_monster_ticket'];
|
||||
// $pay_ticket = $num * $open_monster_ticket;
|
||||
// if($user_info['had_ticket_num'] < $pay_ticket){
|
||||
// return ['code' => 201, 'msg' => '用户剩余门票数不足', 'data' => null];
|
||||
// }
|
||||
$money = $num * $config['open_monster_price'];
|
||||
if($user_info['coin'] < $money){
|
||||
return ['code' => 0, 'msg' => '金币不足', 'data' => null];
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
//扣除用户金币
|
||||
$reslut = model('common/UserWallet')->change_user_money($uid, $money, 1, model('common/UserWallet')::LINGXIAN_TRADITION_LOTTERY_COIN,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::LINGXIAN_TRADITION_LOTTERY_COIN));
|
||||
if ($reslut['code'] != 1) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => $reslut['msg'], 'data' => null];
|
||||
}
|
||||
|
||||
//是否探索过
|
||||
if($user_monster_log){//已探索则继续
|
||||
$update = [];
|
||||
$update['updatetime'] = time();
|
||||
$reslut = db::name('user_monster_log')->where('id', $user_monster_log['id'])->inc('num', $num)->inc('price', $money)->update($update);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '请重试', 'data' => null];
|
||||
}
|
||||
}else{//未探索则探索
|
||||
$insert = [];
|
||||
$insert['uid'] = $uid;
|
||||
$insert['rid'] = $rid;
|
||||
$insert['mid'] = $monster_log['id'];
|
||||
$insert['type'] = $type;
|
||||
$insert['num'] = $num;
|
||||
$insert['price'] = $money;
|
||||
$insert['createtime'] = time();
|
||||
$reslut = db::name('user_monster_log')->insert($insert);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '请重试', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//用户探索记录表
|
||||
$insert_data = [];
|
||||
$insert_data['uid'] = $uid;
|
||||
$insert_data['rid'] = $rid;
|
||||
$insert_data['mid'] = $monster_log['id'];
|
||||
$insert_data['type'] = $type;
|
||||
$insert_data['num'] = $num;
|
||||
$insert_data['price'] = $money;
|
||||
$insert_data['createtime'] = time();
|
||||
$fid = db::name('user_monster_feed_log')->insertGetId($insert_data);
|
||||
if(!$fid){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '请重试', 'data' => null];
|
||||
}
|
||||
|
||||
//计入当期支出累消
|
||||
$update = [];
|
||||
$update['updatetime'] = time();
|
||||
$reslut = db::name('monster_log')->where('id', $monster_log['id'])->inc('out_amount', $money)->update($update);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '请重试', 'data' => null];
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
$user_data = db::name('user')->where('id', $uid)->find();
|
||||
$push_feed_monster_data = [];
|
||||
$push_feed_monster_data['id'] = $fid;
|
||||
$push_feed_monster_data['uid'] = $uid;
|
||||
$push_feed_monster_data['nick_name'] = $user_data['nickname']??"";
|
||||
$push_feed_monster_data['head_pic'] = $user_data['avatar']??"";
|
||||
$push_feed_monster_data['type'] = $type;
|
||||
$push_feed_monster_data['type_name'] = db::name('monster')->where('type', $type)->value('type_name');
|
||||
$push_feed_monster_data['price'] = $money;
|
||||
$push_feed_monster_data['num'] = db::name('user_monster_log')->where('mid',$monster_log['id'])->where('uid', $uid)->where('type', $type)->sum('num');
|
||||
// $push_feed_monster_data['pay_ticket'] = $pay_ticket;
|
||||
$push_feed_monster_data['integral'] = db::name('user_wallet_coin')->where('user_id', $uid)->value('coin');
|
||||
// $push_data = [];
|
||||
// $push_data['code'] = 334;
|
||||
// $push_data['msg'] = "探索公屏播报";
|
||||
// $push_data['data'] = $push_feed_monster_data;
|
||||
// model('api/WebSocketPush')->send_to_all($push_data);
|
||||
|
||||
|
||||
return ['code' => 1, 'msg' => '探索成功', 'data' => $push_feed_monster_data];
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
// dump($e);
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '探索失败', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//规则
|
||||
public function get_monster_note(){
|
||||
$config = get_system_config();
|
||||
$note = $config['monster_feed_note'];
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $note];
|
||||
|
||||
}
|
||||
//奖池
|
||||
public function get_monster_box_list(){
|
||||
$monster_gift_list = db::name('monster')->alias('a')->join('vs_gift b', 'a.gid = b.gid')->field('a.gid,b.base_image,b.gift_name,b.gift_price')->order('b.gift_price asc')->select();
|
||||
foreach ($monster_gift_list as $k => &$v){
|
||||
$v['base_image'] = localpath_to_netpath($v['base_image']);
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $monster_gift_list];
|
||||
}
|
||||
//开奖记录
|
||||
public function get_monster_log($uid, $page, $page_limit){
|
||||
$user_info = db::name('user')->where('id', $uid)->find();
|
||||
if(!$user_info){
|
||||
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||
}
|
||||
|
||||
$map = [];
|
||||
$map['a.is_delete'] = ['=', 2];
|
||||
$monster_list = db::name('monster_log')->alias('a')->join('monster b', 'a.win_type = b.type')->field('a.id,a.win_type,b.type_name,a.createtime as add_time')->where($map)->order('a.id desc')->page($page, $page_limit)->select();
|
||||
foreach ($monster_list as $k => &$v){
|
||||
$v['is_join'] = 3;
|
||||
$v['gift_name'] = '';
|
||||
$v['base_image'] = '';
|
||||
$v['gift_price'] = 0;
|
||||
$v['num'] = 0;
|
||||
$user_monster_log = db::name('user_monster_log')->where('uid', $uid)->where('mid', $v['id'])->find();
|
||||
if($user_monster_log){
|
||||
$v['is_join'] = 2;
|
||||
$user_monster_win_log = db::name('user_monster_win_log')->where('uid', $uid)->where('mid', $v['id'])->find();
|
||||
if($user_monster_win_log){
|
||||
$v['is_join'] = 1;
|
||||
$gift_info = db::name('vs_gift')->find($user_monster_win_log['win_gid']);
|
||||
$v['gift_name'] = $gift_info['gift_name'];
|
||||
$v['base_image'] = localpath_to_netpath($gift_info['base_image']);
|
||||
$v['gift_price'] = $gift_info['gift_price'];
|
||||
$v['num'] = $user_monster_win_log['num'];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $monster_list];
|
||||
}
|
||||
|
||||
//我的列表
|
||||
public function get_user_monster_log($uid, $page, $page_limit){
|
||||
$user_info = db::name('user')->where('id', $uid)->find();
|
||||
if(!$user_info){
|
||||
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||
}
|
||||
|
||||
// $map = [];
|
||||
// $map[] = ['a.uid', '=', $uid];
|
||||
$user_monster_log = db::name('user_monster_win_log')
|
||||
->alias('a')
|
||||
->join('user b', 'a.uid = b.id')
|
||||
->join('monster c', 'a.win_type = c.type')
|
||||
->join('vs_gift d', 'd.gid = a.win_gid')
|
||||
->field('a.id,a.mid,b.id as uid,b.nickname,b.avatar,a.win_type,c.type_name,d.gift_name,d.base_image,d.gift_price,a.num,a.createtime as add_time')->order('a.id desc')->page($page, $page_limit)->select();
|
||||
foreach ($user_monster_log as $k => &$v){
|
||||
$user_info = db::name('user')->where('id', $v['uid'])->field('id,nickname,avatar')->find();
|
||||
$v['nick_name'] = $user_info['nickname'];
|
||||
$v['head_pic'] = $user_info['avatar'];
|
||||
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $user_monster_log];
|
||||
}
|
||||
|
||||
//中奖次数榜单
|
||||
public function get_monster_winner_num_list($uid, $time){
|
||||
if(in_array($time, [1,2,3])){
|
||||
|
||||
}
|
||||
|
||||
$model = db::name('user_monster_win_log')->field('uid, count(id) as win_num');
|
||||
if($time == 1){
|
||||
$model = $model->whereTime('add_time', 'today');
|
||||
}else if($time == 2){
|
||||
$model = $model->whereTime('add_time', 'week');
|
||||
}else if($time == 3){
|
||||
$model = $model->whereTime('add_time', 'month');
|
||||
}
|
||||
$list = $model->group('uid')->order('win_num desc, uid asc')->limit(30)->select();
|
||||
foreach ($list as $k => &$v){
|
||||
$user_info = db::name('user')->where('id', $v['uid'])->field('id,nickname,avatar')->find();
|
||||
$v['nick_name'] = $user_info['nickname'];
|
||||
$v['head_pic'] = $user_info['avatar'];
|
||||
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
|
||||
}
|
||||
|
||||
//设置房间期数开关
|
||||
public function operate_room_monster_show_status($uid, $rid, $is_show_monster_push){
|
||||
$room_info = db::name('vs_room')-> where('id', $rid)->find();
|
||||
if(!$room_info){
|
||||
return ['code' => 0, 'msg' => '该房间不存在', 'data' => null];
|
||||
}
|
||||
|
||||
$room_admin_uid_arr = explode(',', $room_info['room_admin_uid']);
|
||||
if ($uid != $room_info['room_owner_uid'] && !in_array($uid, $room_admin_uid_arr)) {
|
||||
return ['code' => 0, 'msg' => '无权限操作', 'data' => null];
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
$update = [];
|
||||
$update['is_show_monster_push'] = $is_show_monster_push;
|
||||
$update['update_time'] = time();
|
||||
$reslut = db::name('room')->where('rid', $rid)->update($update);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
|
||||
$data = [];
|
||||
$data['rid'] = $rid;
|
||||
$data['is_show_monster_push'] = $is_show_monster_push;
|
||||
|
||||
//推送
|
||||
$push_data = [];
|
||||
$push_data['code'] = 3035;
|
||||
$push_data['msg'] = "修改房间期数开关";
|
||||
$push_data['data'] = $data;
|
||||
model('api/WebSocketPush')->send_to_group($rid, $push_data);
|
||||
|
||||
return ['code' => 1, 'msg' => '修改成功', 'data' => $data];
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
// dump($e);
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '修改失败', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -129,7 +129,7 @@ class Nobility extends Model
|
||||
}
|
||||
|
||||
//购买爵位
|
||||
public function buyNobility($user_id,$lid){
|
||||
public function buyNobility($user_id,$lid,$is_send=0){
|
||||
$nobility_info = db::name('vs_nobility')
|
||||
->field('lid,name,pay_price,renew_price,pay_coin,day,renew_coin')
|
||||
->where('delete_time', 0)
|
||||
@@ -177,12 +177,12 @@ class Nobility extends Model
|
||||
|
||||
}else{ //升级
|
||||
$is_renew = 2;
|
||||
if($user_nobility_info['end_time'] > time()){
|
||||
$old_end_time = $user_nobility_info['end_time'];
|
||||
}else{
|
||||
$old_end_time = time();
|
||||
}
|
||||
$end_time = $old_end_time + $nobility_info['day'] * 86400;
|
||||
// if($user_nobility_info['end_time'] > time()){
|
||||
// $old_end_time = $user_nobility_info['end_time'];
|
||||
// }else{
|
||||
// $old_end_time = time();
|
||||
// }
|
||||
$end_time = time() + $nobility_info['day'] * 86400; //结束时间重置
|
||||
$data = [
|
||||
'lid' => $lid,
|
||||
'user_id' => $user_id,
|
||||
@@ -219,17 +219,7 @@ class Nobility extends Model
|
||||
'createtime' => time(),
|
||||
];
|
||||
db::name('vs_user_nobility_log')->insert($log_data);
|
||||
//发放装扮
|
||||
$nobility_decorate = db::name('vs_nobility_decorate')
|
||||
->field('id,did,dpid,day')
|
||||
->where('delete_time', 0)
|
||||
->where('lid', $lid)
|
||||
->select();
|
||||
if($nobility_decorate){
|
||||
foreach ($nobility_decorate as $key => $value) {
|
||||
model('api/Decorate')->pay_decorate($user_id,$value['did'],$value['day'],9);
|
||||
}
|
||||
}
|
||||
|
||||
//发放金币
|
||||
if($is_renew == 1){
|
||||
$pay_coin = $nobility_info['renew_coin'] ?? 0;
|
||||
@@ -255,15 +245,29 @@ class Nobility extends Model
|
||||
$pay_coin = $nobility_info['pay_coin'] ?? 0;
|
||||
}
|
||||
if($pay_coin > 0){
|
||||
$reslut = model('common/UserWallet')->change_user_money($user_id, $pay_coin, model('common/UserWallet')::MONEYTYPECOIN, model('common/UserWallet')::NOBILITY_PURCHASE_COIN,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::NOBILITY_PURCHASE_COIN));
|
||||
if (!$reslut) {
|
||||
return ['code' => 0, 'msg' => '失败', 'data' => null];
|
||||
if($is_send != 1){
|
||||
$reslut = model('common/UserWallet')->change_user_money($user_id, $pay_coin, model('common/UserWallet')::MONEYTYPECOIN, model('common/UserWallet')::NOBILITY_PURCHASE_COIN,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::NOBILITY_PURCHASE_COIN));
|
||||
if (!$reslut) {
|
||||
return ['code' => 0, 'msg' => '失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//发放装扮
|
||||
$nobility_decorate = db::name('vs_nobility_decorate')
|
||||
->field('id,did,dpid,day')
|
||||
->where('delete_time', 0)
|
||||
->where('lid', $lid)
|
||||
->select();
|
||||
if($nobility_decorate){
|
||||
foreach ($nobility_decorate as $key => $value) {
|
||||
model('api/Decorate')->pay_decorate($user_id,$value['did'],$value['day'],9);
|
||||
}
|
||||
}
|
||||
//更新装备缓存
|
||||
$cache_key = 'user_base_info_'.$user_id;
|
||||
Cache::rm($cache_key);
|
||||
return ['code' => 1, 'msg' => '成功'];
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
}
|
||||
|
||||
//购买爵位价格
|
||||
@@ -302,7 +306,7 @@ class Nobility extends Model
|
||||
}
|
||||
}else{ //升级
|
||||
$old_nobility_info = db::name('vs_nobility')
|
||||
->field('lid,name,pay_price,pay_coin')
|
||||
->field('lid,name,pay_price,pay_coin,day')
|
||||
->where('delete_time', 0)
|
||||
->where('lid', $user_nobility_info['lid'])
|
||||
->find();
|
||||
@@ -312,8 +316,12 @@ class Nobility extends Model
|
||||
if($surplus_time > 0){
|
||||
//小时
|
||||
$surplus_time_hour = floor($surplus_time / 3600); //向下取整
|
||||
if($nobility_info['pay_price']!=0 && $nobility_info['day']!=0){
|
||||
$price = $nobility_info['pay_price'] - bcmul($surplus_time_hour * (($old_nobility_info['pay_price'] / $nobility_info['day']) / 24),1,2); //一小时的价格算
|
||||
if($surplus_time_hour / 24 > $old_nobility_info['day']*2){
|
||||
return ['code' => 0, 'msg' => '已超过2倍有效期,无法升级', 'data' => null];
|
||||
// $surplus_time_hour = $old_nobility_info['day'] * 24 * 2;
|
||||
}
|
||||
if($nobility_info['pay_price']!=0 && $old_nobility_info['day']!=0){
|
||||
$price = $nobility_info['pay_price'] - bcmul($surplus_time_hour * (($old_nobility_info['pay_price'] / $old_nobility_info['day']) / 24),1,2); //一小时的价格算
|
||||
}
|
||||
}else{
|
||||
$price = $nobility_info['pay_price'];
|
||||
|
||||
338
application/api/model/Payment.php
Normal file
338
application/api/model/Payment.php
Normal file
@@ -0,0 +1,338 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
use think\Loader;
|
||||
use think\Log;
|
||||
use Yzh\YunPay;
|
||||
|
||||
class Payment extends Controller
|
||||
{
|
||||
//生成订单号
|
||||
private function createOrderSn() {
|
||||
$orderSn = strtoupper(date('Ymd', time())).substr(time(), -5).substr(microtime(), 2, 5).sprintf('%02d',
|
||||
rand(0, 99));
|
||||
return $orderSn;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* APP支付
|
||||
*/
|
||||
public function app_pay() {
|
||||
$type = input('type', 0); //1-微信 2-支付宝 4-通联支付宝 5-通联微信
|
||||
$user_id = input('user_id', 0);
|
||||
$money = input('money', 0);
|
||||
$coin = input('coin', 0);
|
||||
$type_params = input('type_params', 0);
|
||||
$type_id = input('type_id', 0);
|
||||
$nobility_id = input('nobility_id', 0);//'0-购买金币(充值),其他是爵位id'
|
||||
if($nobility_id != 0){
|
||||
$nobility = model('Nobility')->buyNobilityPrice($user_id,$nobility_id);
|
||||
if($nobility['code'] == 0 || $nobility['data']['price'] != $money){
|
||||
return V(0, '网络错误,请重新操作!', null);
|
||||
}
|
||||
}
|
||||
|
||||
if(!$coin && $nobility_id == 0){
|
||||
$coin = $money * get_system_config_value('rmb_coin_ratio');
|
||||
}
|
||||
if (!$user_id) {
|
||||
return V(0, '请选择充值用户', null);
|
||||
}
|
||||
//获取用户的手机号
|
||||
$user_phone = db::name('user')->where(["id" => $user_id])->value('mobile');
|
||||
if(!$user_phone){
|
||||
return V(0, '请先绑定手机号!', null);
|
||||
}
|
||||
//获取用户的实名信息
|
||||
$real_name = db::name('user_auth')->where(["mobile" => $user_phone,'is_real' => 1])->find();
|
||||
if(!$real_name){
|
||||
return V(0, '请先实名认证', null);
|
||||
}
|
||||
//获取用户的年龄
|
||||
if(!getAgeId($real_name['card_id'])){
|
||||
return V(0, '未成年不可充值!', null);
|
||||
}
|
||||
|
||||
if (!is_numeric($money) || floor($money) != $money || $money <= 0 || $money > 5000) {
|
||||
return V(0, '请选择正确的充值金额', null);
|
||||
}
|
||||
$user_code = db::name('user')->where(["id" => $user_id])->value('user_code');
|
||||
$title = $nobility_id == 0 ? '充值到app用户'.($user_code ?? "") ."余额!" :'购买爵位';
|
||||
|
||||
$order_number = $this->createOrderSn();
|
||||
$data['order_sn'] = $order_number;
|
||||
$data['money'] = $money;
|
||||
$data['coin'] = $coin;
|
||||
$data['user_id'] = $user_id;
|
||||
$data['pay_type'] = $type;
|
||||
$data['createtime'] = time();
|
||||
$data['remarke'] = $nobility_id == 0 ? '充值到app用户'.($user_code ?? "") ."余额!" :'购买爵位';
|
||||
$data['type_params'] = $type_params;
|
||||
$data['type_id'] = $type_id;
|
||||
$data['nobility_id'] = $nobility_id;
|
||||
|
||||
$re = db::name('vs_user_recharge')->insert($data);
|
||||
if (!$re) {
|
||||
return V(0, '充值失败', null);
|
||||
}
|
||||
|
||||
if($type == 2){
|
||||
//引用支付宝sdk
|
||||
Loader::import('AliPayV2.AliPay', EXTEND_PATH, '.php');
|
||||
$ali = new \AliPay();
|
||||
$result['ali'] = $ali->aliAppPays($order_number, $money, $title, $user_id);
|
||||
}elseif($type == 1){
|
||||
//引用微信sdk
|
||||
Loader::import('WxPay.WxPay', EXTEND_PATH, '.php');
|
||||
$wx = new \WxPay();
|
||||
$result['wx'] = $wx->WxPayApp($data);
|
||||
}elseif($type == 4 || $type == 5){
|
||||
//引用通联sdk
|
||||
Loader::import('TongLian.TongLian', EXTEND_PATH, '.php');
|
||||
$tonglian = new \TongLian();
|
||||
$result['tl'] = $tonglian->TongLianPay($data, $type);
|
||||
}
|
||||
|
||||
return V(1, 'app支付', $result);
|
||||
}
|
||||
|
||||
//支付宝回调
|
||||
public function notify_ali() {
|
||||
//引用支付宝sdk
|
||||
Loader::import('AliPayV2.AliPay', EXTEND_PATH, '.php');
|
||||
$ali = new \AliPay();
|
||||
$verify_result = $ali->verify($_POST);
|
||||
Log::record("支付宝回调信息".json_encode($_POST),"info");
|
||||
|
||||
if($verify_result) {//验证成功
|
||||
//商户订单号
|
||||
$out_trade_no = $_POST['out_trade_no'];
|
||||
//支付宝交易号
|
||||
$trade_no = $_POST['trade_no'];
|
||||
|
||||
if ($_POST['trade_status'] == 'TRADE_SUCCESS') {
|
||||
$where['order_sn']=$out_trade_no;
|
||||
$where['order_type']=1;
|
||||
$where['pay_type']=2;
|
||||
$where['pay_status']=1;
|
||||
|
||||
$data=[
|
||||
'trade_no'=>$trade_no
|
||||
];
|
||||
|
||||
$res = handelCharge($where,$data);
|
||||
if($res==0){
|
||||
echo "fail";
|
||||
return;
|
||||
}
|
||||
|
||||
echo "success"; //请不要修改或删除
|
||||
return;
|
||||
}
|
||||
|
||||
echo "fail";
|
||||
}else {
|
||||
//验证失败
|
||||
echo "fail";
|
||||
//写入日志文件
|
||||
Log::record("支付宝回调验签失败","info");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//微信回调地址 示例
|
||||
public function notify_wx() {
|
||||
//引用微信sdk
|
||||
Loader::import('WxPay.WxPay', EXTEND_PATH, '.php');
|
||||
$wx = new \WxPay();
|
||||
//验证是否是微信发送且数据完整
|
||||
$flag = $wx->WxPayNotifyCheck();
|
||||
|
||||
if ($flag['status']) {
|
||||
if ($flag['data']['return_code'] == 'SUCCESS' && $flag['data']['result_code'] == 'SUCCESS') {
|
||||
$out_trade_no = $flag['data']['out_trade_no'];//订单号
|
||||
// $payType = $flag['data']['attach']; //商家数据包
|
||||
// $time_end = strtotime($flag['data']['time_end']); //支付完成时间
|
||||
$transaction_id = $flag['data']['transaction_id']; //微信支付订单号
|
||||
|
||||
//成功后的业务逻辑处理
|
||||
$where['order_sn']=$out_trade_no;
|
||||
$where['order_type']=1;//1 充值
|
||||
$where['pay_type']=1;//1微信2支付宝 3通联支付宝 4通联微信
|
||||
$where['pay_status']=1;
|
||||
|
||||
$data=[
|
||||
'trade_no'=>$transaction_id
|
||||
];
|
||||
|
||||
$res = handelCharge($where,$data);
|
||||
if($res==0){
|
||||
$r_arr['return_code'] = 'FAIL';
|
||||
$r_arr['return_msg'] = '回调失败';
|
||||
echo $wx->arrayToXml($r_arr);
|
||||
die;
|
||||
}
|
||||
|
||||
$r_arr['return_code'] = 'SUCCESS';
|
||||
$r_arr['return_msg'] = '回调成功';
|
||||
echo $wx->arrayToXml($r_arr);
|
||||
die;
|
||||
}
|
||||
}
|
||||
$r_arr['return_code'] = 'FAIL';
|
||||
$r_arr['return_msg'] = '回调失败';
|
||||
echo $wx->arrayToXml($r_arr);
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
//通联支付回调地址 示例
|
||||
public function allinpayNotify() {
|
||||
$params = array();
|
||||
foreach($_POST as $key=>$val) {//动态遍历获取所有收到的参数,此步非常关键,因为收银宝以后可能会加字段,动态获取可以兼容由于收银宝加字段而引起的签名异常
|
||||
$params[$key] = $val;
|
||||
}
|
||||
|
||||
if(count($params)<1){//如果参数为空,则不进行处理
|
||||
echo "error";
|
||||
exit();
|
||||
}
|
||||
|
||||
//引用通联sdk
|
||||
Loader::import('TongLian.TongLian', EXTEND_PATH, '.php');
|
||||
$tonglian = new \TongLian();
|
||||
|
||||
$ree = $tonglian->ValidSign($params);
|
||||
// Log::record("通联支付回调信息".json_encode($ree),"info");
|
||||
if($tonglian->ValidSign($params)){//验签成功
|
||||
Log::record("通联支付回调信息验签成功".json_encode($params),"info");
|
||||
//此处进行业务逻辑处理
|
||||
$pay_type =trim($params['trxreserved']);//备注信息remark
|
||||
$out_trade_no = trim($params['cusorderid']); //商户订单号
|
||||
$trade_no = trim($params['trxid']); // 交易号
|
||||
// $gmt_payment = strtotime(trim($_POST['paytime'])); //交易付款时间
|
||||
//成功后的业务逻辑处理
|
||||
$where['order_sn']=$out_trade_no;
|
||||
$where['order_type']=1;//1 充值
|
||||
$where['pay_type']=$pay_type;//1微信2支付宝 3通联支付宝 4通联微信
|
||||
$where['pay_status']=1;
|
||||
|
||||
$data=[
|
||||
'trade_no'=>$trade_no
|
||||
];
|
||||
|
||||
$res = handelCharge($where,$data);
|
||||
if($res==0){
|
||||
echo "erro";
|
||||
return;
|
||||
}
|
||||
|
||||
echo "success";
|
||||
}else{
|
||||
Log::record("通联支付回调信息验签失败".json_encode($params),"info");
|
||||
echo "erro";
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 云账户回调(提现)
|
||||
*/
|
||||
public function yun_callback(){
|
||||
// $data = input("data", "");
|
||||
// $mess = input("mess", "");
|
||||
// $timestamp = input("timestamp", "");
|
||||
// $sign = input("sign", "");
|
||||
$data = $_POST['data']??"";
|
||||
$mess = $_POST['mess']??"";
|
||||
$timestamp = $_POST['timestamp']?? "";
|
||||
$sign = $_POST['sign']??"";
|
||||
|
||||
write_log_redis("yunzhanghu_huidiao_原始数据",$_POST);
|
||||
$yun_pay = new YunPay();
|
||||
$result = $yun_pay->yun_callback($data,$mess,$timestamp,$sign);
|
||||
if($result['code']==1){
|
||||
$data = $result['data'];
|
||||
if($data){
|
||||
if(!isset($data['status'])){
|
||||
echo 'fail';
|
||||
die;
|
||||
}
|
||||
$status = $data['status'];
|
||||
switch ($status){
|
||||
case "1":
|
||||
// 支付成功(对于支付宝和微信支付是最终状态,对于银行卡大部分情况是终态,小概率会出现"退汇现象",状态由"成功"变为"退汇")
|
||||
db::name('vs_user_withdrawal')
|
||||
->where('order_sn',$data['order_id'])
|
||||
->where('status',4)
|
||||
->update([
|
||||
'status' => 6,
|
||||
'pay_message' => $data['status_message'],
|
||||
'pay_time' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
echo "success";
|
||||
break;
|
||||
case "2":
|
||||
// 支付失败(最终状态)
|
||||
// TODO 更新业务订单状态,提示用户提现失败,若有用户钱包体系,则需将提现金额退回至用户钱包
|
||||
db::name('vs_user_withdrawal')
|
||||
->where('order_sn',$data['order_id'])
|
||||
->where('status',4)
|
||||
->update([
|
||||
'status' => 5,
|
||||
'pay_message' => $data['status_message'],
|
||||
'pay_time' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
//支付失败资金退回
|
||||
$res = model('/UserWithdrawal')->withdrawal_fail($data['order_id']);
|
||||
echo "success";
|
||||
break;
|
||||
break;
|
||||
case "4":
|
||||
// 订单挂单(中间状态,挂单原因会在订单详细状态信息返回)
|
||||
// TODO 提示用户提现中,其他逻辑如:若因余额不足导致的挂单,可通知财务及时充值,72小时内补足余额后可自动继续支付
|
||||
echo "success";
|
||||
break;
|
||||
case "9":
|
||||
// 退汇,(最终状态,银行卡渠道特有现象,会先收到"成功"回调,然后再收到"退汇"的回调,一般以成功状态间隔24小时以上)
|
||||
// TODO 更新业务订单状态为“退汇”(失败),通知用户提现失败,建议用户更换其他银行卡提现,若有用户钱包体系,则需将提现金额退回至用户钱包
|
||||
db::name('vs_user_withdrawal')
|
||||
->where('order_sn',$data['order_id'])
|
||||
->where('status',4)
|
||||
->update([
|
||||
'status' => 5,
|
||||
'pay_message' => $data['status_message'],
|
||||
'pay_time' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
//支付失败资金退回
|
||||
$res = model('/UserWithdrawal')->withdrawal_fail($data['order_id']);
|
||||
echo "success";
|
||||
break;
|
||||
case "15":
|
||||
// 订单取消,(最终状态,只有挂单的订单才可以取消)
|
||||
// TODO 更新业务订单状态为“取消”(失败),通知用户提现失败,若有用户钱包体系,则需将提现金额退回至用户钱包
|
||||
db::name('vs_user_withdrawal')
|
||||
->where('order_sn',$data['order_id'])
|
||||
->where('status',4)
|
||||
->update([
|
||||
'status' => 5,
|
||||
'pay_message' => $data['status_message'],
|
||||
'pay_time' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
//支付失败资金退回
|
||||
$res = model('/UserWithdrawal')->withdrawal_fail($data['order_id']);
|
||||
echo "success";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
echo "fail";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,116 +41,107 @@ class Ranking extends Model
|
||||
public function ranking($ranking_type)
|
||||
{
|
||||
$where['a.createtime'] = ['between', [$this->begin_time, $this->end_time]];
|
||||
$my_ranking = db::name('user')
|
||||
->field('user_code,avatar,nickname,id as user_id,user_code,sex')
|
||||
->where('id',$this->user_id)->find();
|
||||
$my_ranking['icon'][0] = model('UserData')->user_wealth_icon($my_ranking['user_id']);//财富图标
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = 0;
|
||||
if($ranking_type == 1){//1财富榜,2魅力榜
|
||||
$lists = db::name('vs_give_gift')->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->field('a.user_id,b.nickname,b.avatar,b.user_code,sum(a.total_price) * 10 as total')
|
||||
->where($where)
|
||||
->order('total desc')
|
||||
->group('a.user_id')
|
||||
// ->page($this->page, $this->page_limit)
|
||||
->select();
|
||||
|
||||
$params['start_time']=$this->begin_time;
|
||||
$params['end_time']=$this->end_time;
|
||||
|
||||
if($ranking_type == 1){//1财富榜
|
||||
$lists = model('GiveGiftBases')->getGiftRanking($params,1);
|
||||
//把$lists 根据total倒序并只取前20名
|
||||
usort($lists, function($a, $b) {
|
||||
return $b['total'] <=> $a['total']; // 按total降序排序
|
||||
});
|
||||
$lists = array_slice($lists, 0, 20); // 取前20名
|
||||
|
||||
if($lists){
|
||||
$my_ranking = [];
|
||||
foreach ($lists as $key => &$value) {
|
||||
$lists[$key]['icon'][0] = model('UserData')->user_wealth_icon($value['user_id']);//财富图标
|
||||
$lists[$key]['icon'][1] = model('UserData')->user_charm_icon($value['user_id']);//魅力图标
|
||||
$value['total'] = $value['total'] * 10;
|
||||
$value['nickname'] = db::name('user')->where('id',$value['user_id'])->value('nickname');
|
||||
$value['user_code'] = db::name('user')->where('id',$value['user_id'])->value('user_code');
|
||||
$value['avatar'] = db::name('user')->where('id',$value['user_id'])->value('avatar');
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
if ($this->user_id == $value['user_id']) {
|
||||
$my_ranking = $lists[$key];
|
||||
$my_ranking['diff'] = $key == 0 ? 0 : ($lists[$key - 1]['total'] - $value['total']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$my_ranking && $lists && defined('UID')) {
|
||||
$my_ranking_data = db::name('vs_give_gift')->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->field('a.user_id,b.nickname,b.avatar,b.user_code,sum(a.total_price) * 10 as total')
|
||||
->where($where)
|
||||
->where('a.user_id',$this->user_id)
|
||||
->page($this->page, $this->page_limit)
|
||||
->select();
|
||||
$my_ranking_data['icon'][0] = model('UserData')->user_wealth_icon($my_ranking_data['user_id']);//财富图标
|
||||
$my_ranking_data['icon'][1] = model('UserData')->user_charm_icon($my_ranking_data['user_id']);//魅力图标
|
||||
$lists_last_number = $lists[count($lists) - 1]['total'] ?? 0;
|
||||
//自己不在前20名
|
||||
if (!$my_ranking) {
|
||||
$lists_last_number = $lists[count($lists) - 1]['total'] ?? 0;
|
||||
//获取自己的送礼记录
|
||||
$params['user_id'] = $this->user_id;
|
||||
$my_ranking_datas = model('GiveGiftBases')->getUserStatistics($params,1);
|
||||
|
||||
if (!isset($my_ranking_data['user_id']) || !$my_ranking_data['user_id']) {
|
||||
$my_ranking = db::name('user')
|
||||
->field('user_code,avatar,nickname,id as user_id,user_code,sex')
|
||||
->where('id',$this->user_id)->find();
|
||||
$my_ranking['icon'][0] = model('UserData')->user_wealth_icon($my_ranking['user_id']);//财富图标
|
||||
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['user_id'] = $my_ranking_datas['user_id'];
|
||||
$my_ranking['total'] = $my_ranking_datas['total_price']??0;
|
||||
$my_ranking['nickanme'] = db::name('user')->where('id',$this->user_id)->value('nickname');
|
||||
$my_ranking['user_code'] = db::name('user')->where('id',$this->user_id)->value('user_code');
|
||||
$my_ranking['avatar'] = db::name('user')->where('id',$this->user_id)->value('avatar');
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number);
|
||||
} else {
|
||||
$my_ranking = $my_ranking_data;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = numberFormat($my_ranking['total']);
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number - ($my_ranking_data['total'] ?: 0));
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number - ($my_ranking['total'] ?: 0));
|
||||
}
|
||||
}else{
|
||||
$my_ranking = db::name('user')
|
||||
->field('user_code,avatar,nickname,id as user_id,sex')
|
||||
->where('id',$this->user_id)->find();
|
||||
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = 0;
|
||||
}
|
||||
|
||||
//2魅力榜
|
||||
}else{
|
||||
$lists = db::name('vs_give_gift')->alias('a')
|
||||
->join('user b', 'a.gift_user = b.id')
|
||||
->field('a.gift_user as user_id,b.nickname,b.avatar,b.user_code,sum(a.total_price) * 10 as total')
|
||||
->where($where)
|
||||
->order('total desc')
|
||||
->group('a.gift_user')
|
||||
// ->page($this->page, $this->page_limit)
|
||||
->select();
|
||||
$lists = model('GiveGiftBases')->getGiftRanking($params,2);
|
||||
|
||||
//把$lists 根据total倒序并只取前20名
|
||||
usort($lists, function($a, $b) {
|
||||
return $b['total'] <=> $a['total']; // 按total降序排序
|
||||
});
|
||||
$lists = array_slice($lists, 0, 20); // 取前20名
|
||||
|
||||
if($lists){
|
||||
$my_ranking = [];
|
||||
foreach ($lists as $key => &$value) {
|
||||
$lists[$key]['icon'][0] = model('UserData')->user_wealth_icon($value['user_id']);//财富图标
|
||||
$lists[$key]['icon'][1] = model('UserData')->user_charm_icon($value['user_id']);//魅力图标
|
||||
$value['nickname'] = db::name('user')->where('id',$value['gift_user'])->value('nickname');
|
||||
$value['user_code'] = db::name('user')->where('id',$value['gift_user'])->value('user_code');
|
||||
$value['avatar'] = db::name('user')->where('id',$value['gift_user'])->value('avatar');
|
||||
$value['user_id'] = $value['gift_user'];
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
if ($this->user_id == $value['user_id']) {
|
||||
if ($this->user_id == $value['gift_user']) {
|
||||
$my_ranking = $lists[$key];
|
||||
$my_ranking['diff'] = $key == 0 ? 0 : ($lists[$key - 1]['total'] - $value['total']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$my_ranking && $lists && defined('UID')) {
|
||||
$my_ranking_data = db::name('vs_give_gift')->alias('a')
|
||||
->join('user b', 'a.gift_user = b.id')
|
||||
->field('a.gift_user as user_id,b.nickname,b.avatar,b.user_code,sum(a.total_price) * 10 as total')
|
||||
->where($where)
|
||||
->where('a.gift_user',$this->user_id)
|
||||
->select();
|
||||
//自己不在前20名
|
||||
if (!$my_ranking) {
|
||||
$lists_last_number = $lists[count($lists) - 1]['total'] ?? 0;
|
||||
//获取自己的收礼记录
|
||||
$params['gift_user'] = $this->user_id;
|
||||
$my_ranking_datas = model('GiveGiftBases')->getUserStatistics($params,2);
|
||||
|
||||
$my_ranking_data['icon'][0] = model('UserData')->user_wealth_icon($my_ranking_data['user_id']);//财富图标
|
||||
$my_ranking_data['icon'][1] = model('UserData')->user_charm_icon($my_ranking_data['user_id']);//魅力图标
|
||||
$lists_last_number = $lists[count($lists) - 1]['total'] ?? 0;
|
||||
|
||||
if (!isset($my_ranking_data['user_id']) || !$my_ranking_data['user_id']) {
|
||||
$my_ranking = db::name('user')
|
||||
->field('user_code,avatar,nickname,id as user_id,user_code,sex')
|
||||
->where('id',$this->user_id)->find();
|
||||
$my_ranking['icon'][0] = model('UserData')->user_wealth_icon($my_ranking['user_id']);//财富图标
|
||||
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['user_id'] = $my_ranking_datas['user_id'];
|
||||
$my_ranking['total'] = $my_ranking_datas['total_price']??0;
|
||||
$my_ranking['nickname'] = db::name('user')->where('id',$this->user_id)->value('nickname');
|
||||
$my_ranking['user_code'] = db::name('user')->where('id',$this->user_id)->value('user_code');
|
||||
$my_ranking['avatar'] = db::name('user')->where('id',$this->user_id)->value('avatar');
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number);
|
||||
} else {
|
||||
$my_ranking = $my_ranking_data;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = numberFormat($my_ranking['total']);
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number - ($my_ranking_data['total'] ?: 0));
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number - ($my_ranking['total'] ?: 0));
|
||||
}
|
||||
}else{
|
||||
$my_ranking = db::name('user')
|
||||
->field('user_code,avatar,nickname,id as user_id,sex')
|
||||
->where('id',$this->user_id)->find();
|
||||
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = 0;
|
||||
}
|
||||
}
|
||||
//截取20条
|
||||
$lists = array_slice($lists,0,20);
|
||||
|
||||
$data = [
|
||||
'my_ranking' => $my_ranking,
|
||||
'lists' => $lists
|
||||
@@ -159,299 +150,55 @@ class Ranking extends Model
|
||||
return ['code'=>1,'msg'=>'获取成功','data'=>$data];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//房间榜
|
||||
public function room_ranking()
|
||||
{
|
||||
//金币与魅力比例
|
||||
$ratio = get_system_config_value('coin_charm_exp');
|
||||
$where['a.createtime'] = ['between', [$this->begin_time, $this->end_time]];
|
||||
$where['b.type_id'] = ['<>', 6];
|
||||
$where['b.room_status'] = 1;
|
||||
$field = ['sum(a.total_price) *'.$ratio.' as total,b.room_name,a.from_id as room_id,b.room_cover,b.room_number'];
|
||||
$lists = db::name('vs_give_gift')->alias('a')
|
||||
->join('vs_room b','a.from_id = b.id','left')
|
||||
->where($where)->field($field)->group('a.from_id')
|
||||
->order('total desc')
|
||||
// ->page($this->page, $this->page_limit)
|
||||
->select();
|
||||
$my_ranking = null;
|
||||
if($lists){
|
||||
//获取当前用户的房间id
|
||||
$myRoom = db::name('vs_room')->where(['user_id' => UID ,'room_status' => 1])->find();
|
||||
if($myRoom){
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
if ($myRoom['id'] == $value['room_id']) {
|
||||
$my_ranking = $lists[$key];
|
||||
$my_ranking['diff'] = $key == 0 ? 0 : ($lists[$key - 1]['total'] - $value['total']);
|
||||
}
|
||||
// $lists[$key]['total'] = numberFormat($value['total']);
|
||||
}
|
||||
//时间转为天
|
||||
$begin_time = date('Y-m-d',$this->begin_time);
|
||||
$end_time = date('Y-m-d',$this->end_time);
|
||||
|
||||
if (!$my_ranking && $lists && defined('UID')) {
|
||||
$where1['a.createtime'] = ['between', [$this->begin_time, $this->end_time]];
|
||||
$where1['b.type_id'] = ['<>', 6];
|
||||
$my_ranking_data = db::name('vs_give_gift')->alias('a')
|
||||
->join('vs_room b','a.from_id = b.id','left')
|
||||
->where(['a.from_id' => $myRoom['id']])
|
||||
->where($where1)
|
||||
->field('a.from_id as room_id,sum(a.total_price) as total,b.room_name,b.room_cover,b.room_number')->find();
|
||||
$lists_last_number = $lists[count($lists) - 1]['total'] ?? 0;
|
||||
$diff = numberFormat($lists_last_number - ($my_ranking_data['total'] ?: 0));
|
||||
$diff = $diff<=0 ? 0 : $diff;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = numberFormat($my_ranking_data['total']);
|
||||
$my_ranking['diff'] = $diff;
|
||||
$my_ranking['room_name'] = $my_ranking_data['room_name'];
|
||||
$my_ranking['room_cover'] = $my_ranking_data['room_cover'];
|
||||
if(!$my_ranking_data['room_name']){
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['diff'] = $diff;
|
||||
$my_ranking['room_name'] = $myRoom['room_name'];
|
||||
$my_ranking['room_cover'] = $myRoom['room_cover'];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
}
|
||||
$lists_last_number = $lists[count($lists) - 1]['total'] ?? 0;
|
||||
//获取当前用户的房间id
|
||||
$myRoom = db::name('vs_room')->where(['user_id' => UID ,'room_status' => 1])->find();
|
||||
if($myRoom){
|
||||
$my_ranking['room_name'] = $myRoom['room_name'];
|
||||
$my_ranking['room_cover'] = $myRoom['room_cover'];
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number);
|
||||
}else{
|
||||
$my_ranking['room_name'] = '';
|
||||
$my_ranking['room_cover'] = '';
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number);
|
||||
}
|
||||
|
||||
}
|
||||
}else{
|
||||
//获取当前用户的房间id
|
||||
$myRoom = db::name('vs_room')->where(['user_id' => UID ,'room_status' => 1])->find();
|
||||
//获取当前用户的房间id
|
||||
$myRoom = db::name('vs_room')->where(['user_id' => UID ,'room_status' => 1])->find();
|
||||
if($myRoom){
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = 0;
|
||||
$totla = db::name('room_daily_income')
|
||||
->where(['room_id' => $myRoom['id'],'date' => ['between', [$begin_time, $end_time]]])->sum('income')??0 ;
|
||||
$my_ranking['total'] = $totla * $ratio;
|
||||
$my_ranking['diff'] = 0;
|
||||
$my_ranking['room_name'] = $myRoom['room_name'];
|
||||
$my_ranking['room_cover'] = $myRoom['room_cover'];
|
||||
}
|
||||
//截取20条
|
||||
$lists = array_slice($lists,0,20);
|
||||
$data = [
|
||||
'my_ranking' => $my_ranking,
|
||||
'lists' => $lists
|
||||
];
|
||||
return ['code'=>1,'msg'=>'获取成功','data'=>$data];
|
||||
}
|
||||
|
||||
//公会榜
|
||||
public function guild_ranking()
|
||||
{
|
||||
$where['createtime'] = ['between', [$this->begin_time, $this->end_time]];
|
||||
|
||||
//所有工会
|
||||
$guilds = db::name('vs_guild')->where(['status' => 1])->select();
|
||||
if($guilds){
|
||||
foreach ($guilds as $k=>$value){
|
||||
$total = 0;
|
||||
$roomids[$k] = db::name('vs_guild_user')->where(['guild_id' => $value['id']])->field('room_id')->select();
|
||||
if($roomids[$k]){
|
||||
foreach ($roomids[$k] as $key => $value1){
|
||||
$toomType = db::name('vs_room')->where(['id' => $value1['room_id']])->where($where)->value('type_id');
|
||||
if($toomType == 6){
|
||||
continue;
|
||||
}
|
||||
$total += db::name('vs_give_gift')->where(['from_id' => $value1['room_id']])->sum('total_price');
|
||||
}
|
||||
}
|
||||
$guilds[$k]['total'] = $total;
|
||||
}
|
||||
//剔除$guilds[$k]['total'] = 0的
|
||||
$guilds = array_filter($guilds, function ($value) {
|
||||
return $value['total'] > 0;
|
||||
});
|
||||
//根据$guilds[$k]['total']排序
|
||||
array_multisort(array_column($guilds, 'total'), SORT_DESC, $guilds);
|
||||
}
|
||||
|
||||
$lists = $guilds ;
|
||||
// $my_ranking = null;
|
||||
$my_ranking['guild_name'] = '';
|
||||
$my_ranking['cover'] = '';
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = 0;
|
||||
if($lists){
|
||||
//获取当前用户的工会
|
||||
$myGuild = db::name('vs_guild_user')->where(['user_id' => UID])->find();
|
||||
if($myGuild){
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
// $lists[$key]['total'] = numberFormat($value['total']);
|
||||
if ($myGuild['guild_id'] == $value['id']) {
|
||||
$my_ranking = $lists[$key];
|
||||
$my_ranking['diff'] = $key == 0 ? 0 : ($lists[$key - 1]['total'] - $value['total']);
|
||||
}
|
||||
}
|
||||
if (!$my_ranking && $lists && defined('UID')) {
|
||||
$my_rankings = null;
|
||||
//当前工会的所有房间
|
||||
$myguildroom = db::name('vs_guild_user')->where(['guild_id' => $myGuild['guild_id']])->field('room_id')->select();
|
||||
foreach ($myguildroom as $key => $gvalue1){
|
||||
$my_rankings['total'] += db::name('vs_give_gift')->where(['from_id' => $gvalue1['room_id']])->where($where)->sum('total_price');
|
||||
}
|
||||
|
||||
$lists_last_number = $lists[count($lists) - 1]['total'] ?? 0;
|
||||
$diff = numberFormat($lists_last_number - ($my_rankings['total'] ?: 0));
|
||||
$diff = $diff<=0 ? 0 : $diff;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = numberFormat($my_rankings['total']);
|
||||
$my_ranking['diff'] = $diff;
|
||||
$my_ranking['guild_name'] = $myGuild['room_name'];
|
||||
$my_ranking['cover'] = $myGuild['cover'];
|
||||
if(!$my_rankings){
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['diff'] = $diff;
|
||||
$my_ranking['guild_name'] = '';
|
||||
$my_ranking['cover'] = '';
|
||||
}
|
||||
}
|
||||
}else{
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
}
|
||||
$lists_last_number = $lists[count($lists) - 1]['total'] ?? 0;
|
||||
//获取当前用户所在工会
|
||||
$myGuild = db::name('vs_guild_user')->where(['user_id' => UID])->find();
|
||||
if($myGuild){
|
||||
$my_ranking['guild_name'] = db::name('vs_guild')->where(['id' => $myGuild['guild_id']])->value('guild_name');
|
||||
$my_ranking['cover'] = db::name('vs_guild')->where(['id' => $myGuild['guild_id']])->value('cover');
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number);
|
||||
}else{
|
||||
$my_ranking['guild_name'] = '';
|
||||
$my_ranking['cover'] = '';
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['diff'] = numberFormat($lists_last_number);
|
||||
}
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'my_ranking' => $my_ranking,
|
||||
'lists' => $lists
|
||||
];
|
||||
return ['code'=>1,'msg'=>'获取成功','data'=>$data];
|
||||
}
|
||||
|
||||
//真爱榜
|
||||
public function love_ranking()
|
||||
{
|
||||
$where['c.createtime'] = ['between', [$this->begin_time, $this->end_time]];
|
||||
$where['a.status'] = 1;
|
||||
$where['a.type'] = 0;
|
||||
$field = ['a.user_id,a.user_id1,sum(c.total_price) as total,a.room_id,b.room_cover,b.room_intro as room_name'];
|
||||
$lists = db::name('vs_room_cp_movie')->alias('a')
|
||||
->join('vs_room b','a.room_id = b.id','left')
|
||||
->join('vs_give_gift c','a.room_id = c.from_id','left')
|
||||
->where($where)->field($field)->group('a.room_id')
|
||||
->order('total desc')
|
||||
->page($this->page, $this->page_limit)
|
||||
->select();
|
||||
$my_ranking = null;
|
||||
if($lists){
|
||||
//获取当前用户的房间id $this->user_id
|
||||
$myRoom = db::name('vs_room_cp_movie')->where(['user_id' => UID ,'status' => 1])->find();
|
||||
if(!$myRoom){
|
||||
$myRoom = db::name('vs_room_cp_movie')->where(['user_id1' => UID ,'status' => 1])->find();
|
||||
}
|
||||
if($myRoom){
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
$lists[$key]['user_avatar'] = db::name('user')->where(['id' => $value['user_id']])->value('avatar');
|
||||
$lists[$key]['user_avatar1'] = db::name('user')->where(['id' => $value['user_id1']])->value('avatar');
|
||||
$lists[$key]['nickname'] = db::name('user')->where(['id' => $value['user_id']])->value('nickname');
|
||||
$lists[$key]['nickname1'] = db::name('user')->where(['id' => $value['user_id1']])->value('nickname');
|
||||
if ($myRoom['room_id'] == $value['room_id']) {
|
||||
$my_ranking = $lists[$key];
|
||||
$my_ranking['diff'] = $key == 0 ? 0 : ($lists[$key - 1]['total'] - $value['total']);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$my_ranking && $lists) {
|
||||
$where1['c.createtime'] = ['between', [$this->begin_time, $this->end_time]];
|
||||
$where1['a.status'] = 1;
|
||||
$my_ranking_data = db::name('vs_room_cp_movie')->alias('a')
|
||||
->join('vs_room b','a.room_id = b.id','left')
|
||||
->join('vs_give_gift c','a.room_id = c.from_id','left')
|
||||
->where(['c.from_id' => $myRoom['room_id']])
|
||||
->where($where1)
|
||||
->field('a.user_id,a.user_id1,a.room_id,sum(c.total_price) as total,b.room_intro as room_name,b.room_cover')->find();
|
||||
$lists_last_number = $lists[count($lists) - 1]['total'] ?? 0;
|
||||
$diff = numberFormat($lists_last_number - ($my_ranking_data['total'] ?: 0));
|
||||
$diff = max($diff, 0);
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = numberFormat($my_ranking_data['total']);
|
||||
$my_ranking['diff'] = $diff;
|
||||
$my_ranking['room_name'] = $my_ranking_data['room_name'];
|
||||
$my_ranking['room_cover'] = $my_ranking_data['room_cover'];
|
||||
$my_ranking['user_avatar'] = db::name('user')->where(['id' => $my_ranking_data['user_id']])->value('avatar');
|
||||
$my_ranking['user_avatar1'] = db::name('user')->where(['id' => $my_ranking_data['user_id1']])->value('avatar');
|
||||
|
||||
if(!$my_ranking_data['room_name']){
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['diff'] = $diff;
|
||||
$my_ranking['room_name'] = '';
|
||||
$my_ranking['room_cover'] = '';
|
||||
}
|
||||
}
|
||||
}else{
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
$lists[$key]['user_avatar'] = db::name('user')->where(['id' => $value['user_id']])->value('avatar');
|
||||
$lists[$key]['user_avatar1'] = db::name('user')->where(['id' => $value['user_id1']])->value('avatar');
|
||||
$lists[$key]['nickname'] = db::name('user')->where(['id' => $value['user_id']])->value('nickname');
|
||||
$lists[$key]['nickname1'] = db::name('user')->where(['id' => $value['user_id1']])->value('nickname');
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//获取当前用户的房间id $this->user_id
|
||||
$myRoom = db::name('vs_room_cp_movie')->where(['user_id' => UID ,'status' => 1])->find();
|
||||
if(!$myRoom){
|
||||
$myRoom = db::name('vs_room_cp_movie')->where(['user_id1' => UID ,'status' => 1])->find();
|
||||
}
|
||||
if($myRoom){
|
||||
$where1['a.status'] = 1;
|
||||
$where1['a.type'] = 0;
|
||||
$my_ranking_data = db::name('vs_room_cp_movie')->alias('a')
|
||||
->join('vs_room b','a.room_id = b.id','left')
|
||||
->where(['a.cp_id' => $myRoom['cp_id']])
|
||||
->where($where1)
|
||||
->field('a.user_id,a.user_id1,a.room_id,b.room_intro as room_name,b.room_cover')->find();
|
||||
$myRoom['id'] = 0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['diff'] = 0;
|
||||
$my_ranking['room_name'] = '';
|
||||
$my_ranking['room_cover'] = '';
|
||||
}
|
||||
|
||||
$diff =0;
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = 0;
|
||||
$my_ranking['diff'] = $diff;
|
||||
$my_ranking['room_name'] = $my_ranking_data['room_name'];
|
||||
$my_ranking['room_cover'] = $my_ranking_data['room_cover'];
|
||||
$my_ranking['user_avatar'] = db::name('user')->where(['id' => $my_ranking_data['user_id']])->value('avatar');
|
||||
$my_ranking['user_avatar1'] = db::name('user')->where(['id' => $my_ranking_data['user_id1']])->value('avatar');
|
||||
$my_ranking['nickname'] = db::name('user')->where(['id' => $my_ranking_data['user_id']])->value('nickname');
|
||||
$my_ranking['nickname1'] = db::name('user')->where(['id' => $my_ranking_data['user_id1']])->value('nickname');
|
||||
$lists = db::name('room_daily_income')->alias('a')
|
||||
->join('vs_room b','a.room_id = b.id','left')
|
||||
->field('a.room_id,sum(a.income) * ' . $ratio . ' as total,b.room_name,b.room_cover,b.room_number')
|
||||
->where(['a.date' => ['between', [$begin_time, $end_time]]])
|
||||
->group('a.room_id')
|
||||
->order('total desc')
|
||||
->limit(20)
|
||||
->select();
|
||||
// var_dump($lists);exit;
|
||||
if($lists){
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
if ($myRoom['id'] == $value['room_id']) {
|
||||
$my_ranking = $lists[$key];
|
||||
$my_ranking['diff'] = $key == 0 ? 0 : ($lists[$key - 1]['total'] - $value['total']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'my_ranking' => $my_ranking,
|
||||
'lists' => $lists
|
||||
@@ -459,6 +206,7 @@ class Ranking extends Model
|
||||
return ['code'=>1,'msg'=>'获取成功','data'=>$data];
|
||||
}
|
||||
|
||||
|
||||
//真爱榜
|
||||
public function love_rankings()
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,7 +12,18 @@ class RoomAuction extends Model
|
||||
public function room_relation_list($type_id)
|
||||
{
|
||||
$list = db::name('vs_relation')->field('id as relation_id,name,type,icon')->where(['type' => $type_id,'delete_time' => 0])->select();
|
||||
return ['code' => 1, 'msg' => '操作成功','data' => $list];
|
||||
if($list){
|
||||
$relation_array = [
|
||||
'relation_id' => 0,
|
||||
'name' => '无关系',
|
||||
'type' => 0,
|
||||
'icon' => db::name('vs_relation')->where(['id' => 0])->value('icon'),
|
||||
];
|
||||
$lists = array_merge([$relation_array], (array)$list);
|
||||
}else{
|
||||
$lists = [];
|
||||
}
|
||||
return ['code' => 1, 'msg' => '操作成功','data' => $lists];
|
||||
}
|
||||
|
||||
//礼物计算时间
|
||||
@@ -110,7 +121,7 @@ class RoomAuction extends Model
|
||||
|
||||
|
||||
//参与竞拍
|
||||
public function room_auction_join($auction_id,$user_id,$gift_id,$num,$type,$ext=[])
|
||||
public function room_auction_join($auction_id,$user_id,$gift_id,$num,$type,$gift_bag_id=0)
|
||||
{
|
||||
if(!$auction_id){
|
||||
return ['code' => 0, 'msg' => '拍卖已经结束','data' => null];
|
||||
@@ -122,13 +133,13 @@ class RoomAuction extends Model
|
||||
return ['code' => 0, 'msg' => '礼物ID不能为空','data' => null];
|
||||
}
|
||||
$auction = db::name('vs_room_auction')->where('auction_id',$auction_id)->field('room_id,gift_price,user_id,status')->find();
|
||||
$gift_price = db::name('vs_gift')->where('gid',$gift_id)->value('gift_price') ?? 0;
|
||||
// $gift_price = db::name('vs_gift')->where('gid',$gift_id)->value('gift_price') ?? 0;
|
||||
if($user_id == $auction['user_id']){
|
||||
return ['code' => 0, 'msg' => '不能参与自己的竞拍!','data' => null];
|
||||
}
|
||||
|
||||
//走送礼流程
|
||||
$ree = model('GiveGift')->give_gift($user_id,$auction['user_id'],$gift_id,$num,2,$type,$auction['room_id'],0,0,$ext);
|
||||
$ree = model('api/SendGift')->send_gift($user_id,$auction['user_id'],$gift_id,$num,$type,$auction['room_id'],$gift_bag_id);
|
||||
if($ree['code'] != 1){
|
||||
return ['code' => $ree['code'], 'msg' => $ree['msg'],'data' => null];
|
||||
}
|
||||
@@ -181,6 +192,32 @@ class RoomAuction extends Model
|
||||
$v['avatar'] = db::name('user')->where('id',$v['user_id'])->value('avatar');
|
||||
$v['sex'] = db::name('user')->where('id',$v['user_id'])->value('sex');
|
||||
}
|
||||
//获取 用户列表中的用户ID
|
||||
$user_ids = array_column((array)$list,'user_id');
|
||||
//获取上一次的这几个用户 缓存中获取
|
||||
$cache_list = Cache::get('room_auction_list_' . $auction_id);
|
||||
if($cache_list){
|
||||
//取交集(上次和本次都在线的)
|
||||
$user_idss = array_intersect($user_ids,$cache_list);
|
||||
if($user_idss){
|
||||
//取差集(上次的所有和这次还在的,剩余的就是该下线的) 那就是该下线的用户
|
||||
$user_ids_old = array_diff($user_idss,$cache_list);
|
||||
if($user_ids_old){
|
||||
foreach ($user_ids_old as $vvl){
|
||||
db::name('vs_room_visitor')->where(['room_id' => $auction['room_id'],'user_id' => $vvl])->update(['is_onpit' => 1]);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
foreach ($cache_list as $vl){
|
||||
db::name('vs_room_visitor')->where(['room_id' => $auction['room_id'],'user_id' => $vl])->update(['is_onpit' => 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
//没有就设置这个几个上线(在线列表的时候使用)
|
||||
foreach ($user_ids as $vv){
|
||||
db::name('vs_room_visitor')->where(['room_id' => $auction['room_id'],'user_id' => $vv])->update(['is_onpit' => 0]);
|
||||
}
|
||||
Cache::set('room_auction_list_' . $auction_id,$user_ids);
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
@@ -509,6 +546,7 @@ class RoomAuction extends Model
|
||||
'text' => '房间拍卖类型已修改'
|
||||
];
|
||||
model('api/Chat')->sendMsg(1027,$room_id,$text);
|
||||
Cache::rm('room_info_'.$room_id);
|
||||
return ['code' => 1, 'msg' => '操作成功,','data' => null];
|
||||
}
|
||||
}
|
||||
94
application/api/model/RoomDailyIncome.php
Normal file
94
application/api/model/RoomDailyIncome.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class RoomDailyIncome extends Model
|
||||
{
|
||||
// 定义表名(如果表名和模型名一致可省略,这里显式定义更清晰)
|
||||
protected $name = 'room_daily_income';
|
||||
|
||||
// 开启自动时间戳(TP5.1默认用时间戳格式,对应create_time/update_time)
|
||||
// protected $autoWriteTimestamp = true;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 累加用户当日收益(核心方法)
|
||||
* @param int $userId 用户ID
|
||||
* @param float $amount 新增收益金额(正数)
|
||||
* @return bool
|
||||
*/
|
||||
public function addDailyIncome($roomId, $amount)
|
||||
{
|
||||
$today = date('Y-m-d'); // 今日日期
|
||||
|
||||
$today_res = $this->where([
|
||||
'room_id' => $roomId,
|
||||
'date' => $today
|
||||
])->find();
|
||||
if($today_res){
|
||||
$res = $this->where([
|
||||
'room_id' => $roomId,
|
||||
'date' => $today
|
||||
])->update([
|
||||
'income' => $today_res['income'] +$amount,
|
||||
'update_time'=> time(),
|
||||
]);
|
||||
if($res){return true;}
|
||||
}else{
|
||||
$res = $this->insert([
|
||||
'room_id' => $roomId,
|
||||
'income' => $amount,
|
||||
'date' => $today,
|
||||
'create_time'=> time(),
|
||||
'update_time'=> time(),
|
||||
]);
|
||||
if($res){return true;}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询房间某一天收益
|
||||
* @param int $roomId 房间ID
|
||||
* @param string $today 日期(格式:YYYY-MM-DD)
|
||||
* @return float 收益(无收益则返回0)
|
||||
*/
|
||||
public function getTodayIncome($roomId,$today = 0)
|
||||
{
|
||||
if (!$today) {
|
||||
$today = date('Y-m-d');
|
||||
}
|
||||
$result = $this->where([
|
||||
'room_id' => $roomId,
|
||||
'date' => $today
|
||||
])->value('income');
|
||||
|
||||
return $result ? floatval($result) : 0.00;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户时间段内的收益总和
|
||||
* @param int $userId 用户ID
|
||||
* @param string $startDate 开始日期(格式:YYYY-MM-DD)
|
||||
* @param string $endDate 结束日期(格式:YYYY-MM-DD)
|
||||
* @return float 时间段总收益(无收益则返回0)
|
||||
*/
|
||||
public function getIncomeByPeriod($roomId, $startDate, $endDate)
|
||||
{
|
||||
// 校验日期格式(可选,增强健壮性)
|
||||
if (!strtotime($startDate) || !strtotime($endDate)) {
|
||||
return 0.00;
|
||||
}
|
||||
|
||||
$total = $this->where([
|
||||
'room_id' => $roomId,
|
||||
'date' => ['between', [$startDate, $endDate]]
|
||||
])->sum('income');
|
||||
|
||||
return $total ? floatval($total) : 0.00;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,80 +3,20 @@
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Log;
|
||||
use think\Model;
|
||||
use think\Env;
|
||||
|
||||
class RoomHourRanking extends Model
|
||||
{
|
||||
//房间小时榜
|
||||
public function room_hour_rankings($page, $page_limit,$start_time = null, $end_time = null)
|
||||
{
|
||||
//当前小时开始时间
|
||||
if($start_time == null){
|
||||
$start_time = strtotime(date('Y-m-d H:00:00'));
|
||||
}
|
||||
|
||||
//结束时间
|
||||
if($end_time == null){
|
||||
$end_time = strtotime(date('Y-m-d H:59:59'));
|
||||
}
|
||||
|
||||
//判断是否开启
|
||||
$open_time = db::name('vs_hour_ranking_config')->where('id', 1)->value('open_time');
|
||||
if ($open_time == 0) {
|
||||
return ['code' => 0, 'msg' => '排行榜暂未开启', 'data' => null];
|
||||
}
|
||||
|
||||
//是否开启巡乐会
|
||||
$is_open_xlh = db::name('vs_hour_ranking_config')->where('id', 1)->value('is_open_xlh');
|
||||
|
||||
// 更进一步的优化版本:
|
||||
$subQuery = Db::name('vs_give_gift')
|
||||
->where('from', 2)
|
||||
->whereBetween('createtime', [$start_time, $end_time])
|
||||
->buildSql();
|
||||
|
||||
$profit = db::name('vs_room')->alias('a')
|
||||
->join([$subQuery => 'b'], 'a.id = b.from_id', 'left')
|
||||
->join('vs_room_label c', 'a.label_id = c.id','left')
|
||||
->field('a.id as room_id,a.user_id,a.room_name,a.label_id,a.room_cover,IFNULL(SUM(b.total_price), 0) as total_price,c.label_icon')
|
||||
->where('a.room_status', 1)
|
||||
->where('a.apply_status', 2)
|
||||
->where('a.type_id', '<>', 6)
|
||||
->group('a.id')
|
||||
->order('total_price', 'desc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
|
||||
if($profit){
|
||||
foreach ($profit as &$v) {
|
||||
$v['total_price'] = $v['total_price'] * get_system_config_value('coin_charm_exp');
|
||||
if($v['room_id'] > 0 && $is_open_xlh == 1){
|
||||
$xlh_status = model('BlindBoxTurntableGift')->get_user_xlh_info($v['room_id']);
|
||||
$v['xlh_status'] = $xlh_status['xlh_status'];
|
||||
}else{
|
||||
$v['xlh_status'] = 0;
|
||||
}
|
||||
//查询房间是否有红包
|
||||
if($v['room_id'] > 0){
|
||||
$red_pack_status = Db::name('redpacket')->where(['room_id' => $v['room_id'], 'status' => ['<=',1]])->count();
|
||||
$v['redpacket_status'] = $red_pack_status;
|
||||
}else{
|
||||
$v['redpacket_status'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
//当前小时开始时间 和结束时间 00:00-00:59 这样的格式
|
||||
$time_range = date('H:') . '00-' . date('H:'). '59';
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => ['time_range' => $time_range, 'lists' =>$profit]];
|
||||
}
|
||||
|
||||
|
||||
//房间小时榜(更正版)
|
||||
public function room_hour_ranking($page, $page_limit,$start_time = null, $end_time = null)
|
||||
{
|
||||
//当前小时开始时间
|
||||
if($start_time == null){
|
||||
$start_time = strtotime(date('Y-m-d H:00:00'));
|
||||
// $start_time = strtotime(date('Y-m-d H:00:00'));
|
||||
$start_time = date('Y-m-d H:00:00');
|
||||
}
|
||||
|
||||
//结束时间
|
||||
@@ -90,66 +30,149 @@ class RoomHourRanking extends Model
|
||||
return ['code' => 0, 'msg' => '排行榜暂未开启', 'data' => null];
|
||||
}
|
||||
|
||||
//是否开启巡乐会
|
||||
$is_open_xlh = db::name('vs_hour_ranking_config')->where('id', 1)->value('is_open_xlh');
|
||||
// 查询这个时间段内收礼的房间ID集合,并实现分页
|
||||
$room_query = Db::name('vs_give_gift')
|
||||
->where(['from' => 2, 'from_id' => ['>',0]])
|
||||
->whereBetween('createtime', [$start_time, $end_time])
|
||||
->group('from_id')
|
||||
->field('from_id, SUM(total_price) as total_price');
|
||||
$coin_exp = get_system_config_value('coin_charm_exp');
|
||||
|
||||
// 应用分页限制
|
||||
$room_ids_with_price = $room_query
|
||||
->order('total_price', 'desc')
|
||||
->limit(($page - 1) * $page_limit, $page_limit)
|
||||
$rankList = Db::name('room_gift_hourly_sum')->alias('a')
|
||||
->join('vs_room b', 'a.room_id = b.id', 'left') // 关联房间表取名称/封面
|
||||
->join('vs_room_label c', 'b.label_id = c.id','left')
|
||||
->field('a.room_id, a.gift_amount * '.$coin_exp.' as total_price, a.gift_count, b.room_name, b.room_cover, b.label_id, c.label_icon')
|
||||
->where(['a.stat_hour' => $start_time,'a.room_id' => ['>',0]])
|
||||
->order('total_price DESC')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
|
||||
$profit = [];
|
||||
if($room_ids_with_price){
|
||||
foreach ($room_ids_with_price as $k => $item){
|
||||
$room_id = $item['from_id'];
|
||||
$profit[$k] = db::name('vs_room')->alias('a')
|
||||
->join('vs_give_gift b', 'a.id = b.from_id', 'left')
|
||||
->join('vs_room_label c', 'a.label_id = c.id','left')
|
||||
->field('a.id as room_id,a.room_name,a.label_id,a.room_cover,SUM(b.total_price) as total_price,c.label_icon')
|
||||
->where('a.type_id', '<>', 6)
|
||||
->where('a.id', $room_id)
|
||||
->whereBetween('b.createtime', [$start_time, $end_time])
|
||||
->find();
|
||||
|
||||
if(!empty($profit[$k])) {
|
||||
$profit[$k]['total_price'] = $profit[$k]['total_price'] * get_system_config_value('coin_charm_exp');
|
||||
|
||||
// 查询巡乐会状态
|
||||
if($room_id > 0 && $is_open_xlh == 1){
|
||||
$xlh_status = model('BlindBoxTurntableGift')->get_user_xlh_info($room_id);
|
||||
$profit[$k]['xlh_status'] = $xlh_status['xlh_status'] ?? 0;
|
||||
} else {
|
||||
$profit[$k]['xlh_status'] = 0;
|
||||
}
|
||||
|
||||
// 查询房间红包状态
|
||||
if($room_id > 0){
|
||||
$red_pack_status = Db::name('redpacket')->where(['room_id' => $room_id, 'status' => ['<=', 1]])->count();
|
||||
$profit[$k]['redpacket_status'] = $red_pack_status;
|
||||
} else {
|
||||
$profit[$k]['redpacket_status'] = 0;
|
||||
}
|
||||
} else {
|
||||
unset($profit[$k]);
|
||||
}
|
||||
|
||||
if($rankList){
|
||||
foreach ($rankList as &$item){
|
||||
$item['redpacket_status'] = Db::name('redpacket')->where(['room_id' => $item['room_id'], 'status' => ['<=', 1]])->count();
|
||||
}
|
||||
}
|
||||
|
||||
// 过滤掉空值并重新索引数组
|
||||
if($profit){
|
||||
$profit = array_values(array_filter($profit));
|
||||
}
|
||||
|
||||
// 查询这个时间段内收礼的房间ID集合,并实现分页
|
||||
// $room_query = Db::name('vs_give_gift')
|
||||
// ->where(['from' => 2, 'from_id' => ['>',0]])
|
||||
// ->whereBetween('createtime', [$start_time, $end_time])
|
||||
// ->group('from_id')
|
||||
// ->field('from_id, SUM(total_price) as total_price');
|
||||
//
|
||||
// // 应用分页限制
|
||||
// $room_ids_with_price = $room_query
|
||||
// ->order('total_price', 'desc')
|
||||
// ->limit(($page - 1) * $page_limit, $page_limit)
|
||||
// ->select();
|
||||
//
|
||||
// $profit = [];
|
||||
// if($room_ids_with_price){
|
||||
// foreach ($room_ids_with_price as $k => $item){
|
||||
// $room_id = $item['from_id'];
|
||||
// $profit[$k] = db::name('vs_room')->alias('a')
|
||||
// ->join('vs_give_gift b', 'a.id = b.from_id', 'left')
|
||||
// ->join('vs_room_label c', 'a.label_id = c.id','left')
|
||||
// ->field('a.id as room_id,a.room_name,a.label_id,a.room_cover,SUM(b.total_price) as total_price,c.label_icon')
|
||||
// ->where('a.type_id', '<>', 6)
|
||||
// ->where('a.id', $room_id)
|
||||
// ->whereBetween('b.createtime', [$start_time, $end_time])
|
||||
// ->find();
|
||||
//
|
||||
// if(!empty($profit[$k])) {
|
||||
// $profit[$k]['total_price'] = $profit[$k]['total_price'] * get_system_config_value('coin_charm_exp');
|
||||
//
|
||||
// // 查询巡乐会状态
|
||||
// if($room_id > 0 && $is_open_xlh == 1){
|
||||
// $xlh_status = model('BlindBoxTurntableGift')->get_user_xlh_info($room_id);
|
||||
// $profit[$k]['xlh_status'] = $xlh_status['xlh_status'] ?? 0;
|
||||
// } else {
|
||||
// $profit[$k]['xlh_status'] = 0;
|
||||
// }
|
||||
//
|
||||
// // 查询房间红包状态
|
||||
// if($room_id > 0){
|
||||
// $red_pack_status = Db::name('redpacket')->where(['room_id' => $room_id, 'status' => ['<=', 1]])->count();
|
||||
// $profit[$k]['redpacket_status'] = $red_pack_status;
|
||||
// } else {
|
||||
// $profit[$k]['redpacket_status'] = 0;
|
||||
// }
|
||||
// } else {
|
||||
// unset($profit[$k]);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 过滤掉空值并重新索引数组
|
||||
// if($profit){
|
||||
// $profit = array_values(array_filter($profit));
|
||||
// }
|
||||
|
||||
//当前小时开始时间 和结束时间 00:00-00:59 这样的格式
|
||||
$time_range = date('H:') . '00-' . date('H:'). '59';
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => ['time_range' => $time_range, 'lists' =>$profit]];
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => ['time_range' => $time_range, 'lists' =>$rankList]];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 核心方法:原生SQL实现每小时送礼流水累加(适配无duplicate()的TP/FastAdmin版本)
|
||||
* @param int $room_id 房间ID
|
||||
* @param float $amount 本次送礼金额(如10.00)
|
||||
* @param int $count 本次送礼次数(默认1)
|
||||
* @return bool 操作是否成功
|
||||
*/
|
||||
public function addGiftHourlySum($room_id, $amount, $count = 1)
|
||||
{
|
||||
// 1. 生成当前小时标识(固定为整点,保证每小时数据独立)
|
||||
$stat_hour = date('Y-m-d H:00:00');
|
||||
$now = date('Y-m-d H:i:s'); // 统一时间变量,避免重复生成
|
||||
|
||||
// 2. 获取数据库表前缀(自动适配FastAdmin配置,避免硬编码)
|
||||
$tablePrefix = Env::get('database.prefix', 'fa_');
|
||||
$tableName = $tablePrefix . 'room_gift_hourly_sum';
|
||||
|
||||
// 3. 构造SQL:所有参数替换为?(位置占位符),按顺序排列
|
||||
$sql = "INSERT INTO {$tableName}
|
||||
(room_id, stat_hour, gift_amount, gift_count, create_time, update_time)
|
||||
VALUES
|
||||
(?, ?, ?, ?, ?, ?) -- 新增部分的6个?
|
||||
ON DUPLICATE KEY UPDATE
|
||||
gift_amount = gift_amount + ?,
|
||||
gift_count = gift_count + ?,
|
||||
update_time = ?";
|
||||
|
||||
// 4. 构造参数数组:严格按SQL中?的顺序排列(核心!)
|
||||
$params = [
|
||||
// 新增部分的6个参数(对应VALUES后的6个?)
|
||||
$room_id, // ?1: room_id
|
||||
$stat_hour, // ?2: stat_hour
|
||||
$amount, // ?3: 新增的gift_amount
|
||||
$count, // ?4: 新增的gift_count
|
||||
$now, // ?5: create_time
|
||||
$now, // ?6: 新增的update_time
|
||||
// 更新部分的3个参数(对应ON DUPLICATE KEY UPDATE后的3个?)
|
||||
$amount, // ?7: 累加的gift_amount
|
||||
$count, // ?8: 累加的gift_count
|
||||
$now // ?9: 更新的update_time
|
||||
];
|
||||
|
||||
try {
|
||||
// 5. 执行原生SQL
|
||||
$result = Db::execute($sql, $params);
|
||||
// 执行成功返回影响行数(新增=1,更新=2),失败返回false
|
||||
if ($result === false) {
|
||||
// 6. 失败则记录异常日志
|
||||
Log::error("送礼流水累加失败:房间ID:{$room_id} | 金额:{$amount}");
|
||||
}
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
// 记录详细错误日志(含SQL和参数,方便排查)
|
||||
Log::error("送礼流水累加失败:{$e->getMessage()}
|
||||
| 房间ID:{$room_id} | 金额:{$amount}
|
||||
| SQL:{$sql}
|
||||
| 参数:" . json_encode($params));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -52,7 +52,15 @@ class RoomPit extends Model
|
||||
//用户上麦
|
||||
public function OnPit($user_id,$room_id,$pit_number)
|
||||
{
|
||||
$on = $this->where(['room_id' => $room_id, 'pit_number' => $pit_number])->update(['user_id' => $user_id]);
|
||||
$roomtype = db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
if($roomtype == 11 && $pit_number != 9 && $pit_number != 10){
|
||||
$pit_time = db::name('vs_room_bar')->where('id',$room_id)->value('pit_time') ?? 5;
|
||||
$text['end_time'] = time()+$pit_time * 60;
|
||||
}else{
|
||||
$text['end_time'] = 0;
|
||||
}
|
||||
|
||||
$on = $this->where(['room_id' => $room_id, 'pit_number' => $pit_number])->update(['user_id' => $user_id,'end_time' => $text['end_time']]);
|
||||
if(!$on){
|
||||
return ['code' => 0, 'msg' => '上麦失败', 'data' => null];
|
||||
}
|
||||
@@ -60,8 +68,8 @@ class RoomPit extends Model
|
||||
$FromUserInfo = model('api/User')->get_user_base_info($user_id);
|
||||
$FromUserInfo['is_online'] = db::name('vs_room_visitor')->where(['user_id' => $user_id,'room_id' => $room_id])->value('is_online');
|
||||
$FromUserInfo['charm'] = db::name('vs_room_user_charm')->where(['user_id' => $user_id,'room_id' => $room_id])->value('charm');
|
||||
$FromUserInfo['had_custom_gift'] = db::name('vs_user_custom_gift')->where(['user_id' => $user_id,'gift_remark_name' => ['<>','']])->find()?1:0;
|
||||
|
||||
$roomtype = db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
if($roomtype == 10){
|
||||
if($pit_number == 1){
|
||||
$pit_text = '签约麦';
|
||||
@@ -83,7 +91,7 @@ class RoomPit extends Model
|
||||
//查询房间是否隐藏
|
||||
$is_hide = db::name('vs_room')->where(['id' => $room_id])->value('is_show_room');
|
||||
if($is_hide == 2){
|
||||
db::name('vs_room')->where(['id' => $room_id])->update(['is_show_room' => 1]);
|
||||
// db::name('vs_room')->where(['id' => $room_id])->update(['is_show_room' => 1]);
|
||||
}
|
||||
}elseif ($pit_number == 10) {
|
||||
$pit_text = '嘉宾麦';
|
||||
@@ -142,7 +150,7 @@ class RoomPit extends Model
|
||||
}
|
||||
|
||||
//用户下麦
|
||||
public function DownPit($user_id,$room_id,$pit_number,$type = 0)
|
||||
public function DownPit($user_id,$room_id,$pit_number = 0,$type = 0)
|
||||
{
|
||||
$roomtype = db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
|
||||
@@ -166,6 +174,7 @@ class RoomPit extends Model
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($roomtype == 10){
|
||||
if($pit_number == 1){
|
||||
$pit_text = '签约麦';
|
||||
@@ -237,7 +246,7 @@ class RoomPit extends Model
|
||||
if(!$pit_info){
|
||||
return ['code' => 0, 'msg' => '该用户已不在'.$pit_text, 'data' => null];
|
||||
}
|
||||
$down = $this->where(['id' => $pit_info['id'] ])->update(['user_id' => 0, 'before_pit_number' => 0]);
|
||||
$down = $this->where(['id' => $pit_info['id'] ])->update(['user_id' => 0, 'before_pit_number' => 0,'end_time' => 0]);
|
||||
if(!$down){
|
||||
return ['code' => 0, 'msg' => '下麦失败', 'data' => null];
|
||||
}
|
||||
@@ -270,11 +279,8 @@ class RoomPit extends Model
|
||||
|
||||
|
||||
//申请上麦
|
||||
public function apply_pit($user_id,$room_id,$pit_number = 0)
|
||||
public function apply_pit($user_id,$room_id,$pit_number = 0,$gift_id = 0,$type = 0)
|
||||
{
|
||||
if($room_id <= 0){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
//查询房间状态
|
||||
$room_info = db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->field('id,room_status,room_up_pit_type,type_id,label_id,step')->find();
|
||||
if(!$room_info){
|
||||
@@ -295,7 +301,7 @@ class RoomPit extends Model
|
||||
}
|
||||
|
||||
//检查是否在坑位上
|
||||
$pit_infos = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id])->field('id,pit_number')->find();
|
||||
$pit_infos = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id])->field('id,pit_number,end_time')->find();
|
||||
if($pit_number == 9){
|
||||
//检查用户是否是房主或主持
|
||||
$is_room_owner =db::name('vs_room')->where(['id' => $room_id, 'user_id' => $user_id])->field('id')->find();
|
||||
@@ -331,9 +337,9 @@ class RoomPit extends Model
|
||||
}
|
||||
|
||||
//自由麦
|
||||
if($room_info['room_up_pit_type'] == 2){
|
||||
if($room_info['room_up_pit_type'] == 2 || $type == 2){
|
||||
if($pit_number > 0){
|
||||
if($room_info['label_id'] == 5){//交友(互娱)
|
||||
if($room_info['label_id'] == 5 || $room_info['label_id'] == 8){//互娱||酒吧
|
||||
if($pit_number == 7 || $pit_number == 8){
|
||||
return ['code' => 0, 'msg' => '该麦位已锁定了', 'data' => null];
|
||||
}
|
||||
@@ -353,7 +359,7 @@ class RoomPit extends Model
|
||||
return ['code' => 0, 'msg' => '该麦位被锁定', 'data' => null];
|
||||
}
|
||||
}else{
|
||||
if($room_info['label_id'] == 5){//交友
|
||||
if($room_info['label_id'] == 5 || $room_info['label_id'] == 8){//互娱||酒吧
|
||||
$pit_number = $this->getRoomNullPitWithout($room_id, [7,8,9,10]);
|
||||
}else{
|
||||
$pit_number = $this->getRoomNullPitWithout($room_id, [9, 10]);
|
||||
@@ -370,8 +376,8 @@ class RoomPit extends Model
|
||||
if($pit_infos['pit_number'] == 9){
|
||||
return ['code' => 0, 'msg' => '主持不允许换麦', 'data' => null];
|
||||
}
|
||||
$exchange1 = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_infos['pit_number']])->update([ 'user_id' => 0]);
|
||||
$exchange = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_number])->update([ 'user_id' => $user_id]);
|
||||
$exchange1 = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_infos['pit_number']])->update([ 'user_id' => 0, 'end_time' => 0]);
|
||||
$exchange = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_number])->update([ 'user_id' => $user_id,'end_time' => $pit_infos['end_time']]);
|
||||
if(!$exchange || !$exchange1){
|
||||
return ['code' => 0, 'msg' => '换麦失败', 'data' => null];
|
||||
}
|
||||
@@ -391,7 +397,9 @@ class RoomPit extends Model
|
||||
$text['FromUserInfo'] = $FromUserInfo;
|
||||
$text['from_pit_number'] = $pit_infos['pit_number'];
|
||||
$text['to_pit_number'] = $pit_number;
|
||||
$text['end_time'] = $pit_infos['end_time'];
|
||||
model('Chat')->sendMsg(1039,$room_id,$text);
|
||||
|
||||
//查看此房间是否处于pk中
|
||||
$is_pk = db::name('vs_room_pk')->where(['room_id_a' => $room_id])->where(['status' => ['in',[2,3,4]]])->value('room_id_b') ?? 0;
|
||||
if(!$is_pk){
|
||||
@@ -404,6 +412,14 @@ class RoomPit extends Model
|
||||
}
|
||||
return ['code' => 1, 'msg' => '上麦成功', 'data' => null];
|
||||
}else{
|
||||
//上麦设置礼物
|
||||
if($room_info['label_id'] == 8){
|
||||
$gift_info = model('api/BarRoom')->join_pit_choose_gift($user_id,$room_id,$gift_id);
|
||||
if($gift_info['code'] != 1){
|
||||
return ['code' => 0, 'msg' => '设置礼物失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
$ompit = $this->OnPit($user_id,$room_id,$pit_number);//用户上了这个房间的几号麦位
|
||||
if($ompit['code'] != 1){
|
||||
return ['code' => 0, 'msg' => '上麦失败', 'data' => null];
|
||||
@@ -460,6 +476,14 @@ class RoomPit extends Model
|
||||
return ['code' => 0, 'msg' => '用户已在麦上,请先下麦后再申请', 'data' => null];
|
||||
}
|
||||
|
||||
//上麦设置礼物
|
||||
if($room_info['label_id'] == 8){
|
||||
$gift_info = model('api/BarRoom')->join_pit_choose_gift($user_id,$room_id,$gift_id);
|
||||
if($gift_info['code'] != 1){
|
||||
return ['code' => 0, 'msg' => '设置礼物失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//放入等待区
|
||||
$data = [
|
||||
'room_id' => $room_id,
|
||||
@@ -483,22 +507,22 @@ class RoomPit extends Model
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//申请上麦列表
|
||||
public function apply_pit_list($userId,$room_id)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
|
||||
$where = [
|
||||
'a.room_id' => $room_id,
|
||||
'a.status' => 0,
|
||||
];
|
||||
|
||||
//常规通道 type: 0普通通道,1优先通道
|
||||
$list['regular'] = db::name('vs_room_pit_apply')->alias('a')->join('user b','a.user_id = b.id')
|
||||
->where($where)->where('a.type',0)->field('a.user_id,a.rank_value,b.nickname,b.avatar')
|
||||
->order('a.rank_value desc')->select();
|
||||
$list['regular'] = db::name('vs_room_pit_apply')->alias('a')
|
||||
->join('user b','a.user_id = b.id')
|
||||
->where($where)->where('a.type',0)
|
||||
->field('a.user_id,a.rank_value,b.nickname,b.avatar')
|
||||
->order('a.rank_value desc')
|
||||
->select();
|
||||
foreach ($list['regular'] as $k => $v){
|
||||
//查询用户的爵位
|
||||
$jue_wei = model('Nobility')->getUserNobilityInfo($v['user_id']);
|
||||
@@ -554,12 +578,6 @@ class RoomPit extends Model
|
||||
//上麦助力
|
||||
public function help_apply_pit($user_id,$room_id,$apply_id)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
if(!$apply_id){
|
||||
return ['code' => 0, 'msg' => '请选择助力用户', 'data' => null];
|
||||
}
|
||||
|
||||
//查询当前房间设置的助力;礼物
|
||||
$gift_info = db::name('vs_room_pit_apply_help_gift')->where(['room_id' => $room_id])->field('id,gift_id,gift_price')->find();
|
||||
@@ -567,24 +585,15 @@ class RoomPit extends Model
|
||||
return ['code' => 0, 'msg' => '当前房间没有设置助力礼物', 'data' => null];
|
||||
}
|
||||
|
||||
// $res = model('Room')->get_room_label($room_id);
|
||||
// $room_label = $res['data']['label_id'];
|
||||
// $room_type = $res['data']['type_id'];
|
||||
// if($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4)){
|
||||
// $apply_type = 1;
|
||||
// }elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4)){
|
||||
// $apply_type = 2;
|
||||
// }
|
||||
|
||||
//助力
|
||||
$data = [
|
||||
'user_id' => $user_id,
|
||||
'help_user_id' => $apply_id,
|
||||
'room_id' => $room_id,
|
||||
'rank_value' => $gift_info['gift_price'],
|
||||
// 'apply_type' => $apply_type,
|
||||
'createtime'=> time(),
|
||||
];
|
||||
|
||||
//开启事务
|
||||
db::startTrans();
|
||||
$reslut = db::name('vs_room_pit_apply_help')->insert($data);
|
||||
@@ -614,7 +623,8 @@ class RoomPit extends Model
|
||||
}
|
||||
|
||||
//走送礼流程(用户,在房间中,给谁(插队上麦给当前主持人),送了什么礼物,多少个)
|
||||
$give_gift = model('GiveGift')->give_gift($user_id,$room_host_id,$gift_info['gift_id'],1,2,1,$room_id,9);
|
||||
$give_gift = model('SendGift')->send_gift($user_id,$room_host_id,$gift_info['gift_id'],1,1,$room_id);
|
||||
// $give_gift = model('GiveGift')->give_gift($user_id,$room_host_id,$gift_info['gift_id'],1,2,1,$room_id,9);
|
||||
if($give_gift['code'] != 1){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => $give_gift['msg'].'助力失败。', 'data' => null];
|
||||
@@ -628,12 +638,6 @@ class RoomPit extends Model
|
||||
//同意上麦
|
||||
public function agree_pit($user_id,$room_id,$apply_id,$tpe = 0)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
if(!$apply_id){
|
||||
return ['code' => 0, 'msg' => '请选择申请用户', 'data' => null];
|
||||
}
|
||||
|
||||
$res = model('Room')->get_room_label($room_id);
|
||||
$room_label = $res['data']['label_id'];
|
||||
@@ -644,29 +648,14 @@ class RoomPit extends Model
|
||||
$apply_type = 2;//K歌
|
||||
}elseif($room_type == 2){
|
||||
$apply_type = 3;//拍卖
|
||||
}elseif($room_type == 7){
|
||||
$apply_type = 7;//交友
|
||||
}elseif($room_type == 7 || $room_type == 11){//互娱和酒吧
|
||||
$apply_type = 7;
|
||||
}elseif($room_type == 10){
|
||||
$apply_type = 10;//签约
|
||||
}else{
|
||||
$apply_type = 1;//聊天
|
||||
}
|
||||
|
||||
// if($apply_type == 1){
|
||||
// //判断当前用户是否是房主或在主持麦位上的主持
|
||||
// $is_room_owner = model('Room')->where(['id' => $room_id, 'user_id' => $user_id])->field('id')->find();
|
||||
// $is_room_host = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id,'pit_number' => 9])->field('id')->find();
|
||||
// if(!$is_room_owner && !$is_room_host){
|
||||
// return ['code' => 0, 'msg' => '您不是房主 或 不在主持位,没有权限操作', 'data' => null];
|
||||
// }
|
||||
// }else{
|
||||
// $is_room_host = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id,'pit_number' => 9])->field('id')->find();
|
||||
// if(!$is_room_host){
|
||||
// return ['code' => 0, 'msg' => '您不在主持位,没有权限操作', 'data' => null];
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
$to_user = explode(',',$apply_id);
|
||||
|
||||
if(count($to_user) >= 1){
|
||||
@@ -885,25 +874,12 @@ class RoomPit extends Model
|
||||
//清空上麦申请
|
||||
public function clear_apply_pit_list($userId,$room_id,$apply_id = 0)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
//判断当前用户是否是房主或主持
|
||||
$is_room_owner = model('Room')->where(['id' => $room_id, 'user_id' => $userId])->field('id')->find();
|
||||
$is_room_host = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $userId,'pit_number' => 9])->field('id')->find();
|
||||
if(!$is_room_owner && !$is_room_host){
|
||||
return ['code' => 0, 'msg' => '您不是房主 或 不在主持麦,没有权限操作', 'data' => null];
|
||||
}
|
||||
// $res = model('Room')->get_room_label($room_id);
|
||||
// $room_label = $res['data']['label_id'];
|
||||
// $room_type = $res['data']['type_id'];
|
||||
// if($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4)){
|
||||
// $apply_type = 1;
|
||||
// }elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4)){
|
||||
// $apply_type = 2;
|
||||
// }else{
|
||||
// $apply_type = 1;
|
||||
// }
|
||||
|
||||
if($apply_id){
|
||||
$to_user = explode(',',$apply_id);
|
||||
@@ -937,12 +913,6 @@ class RoomPit extends Model
|
||||
//设置插麦礼物
|
||||
public function set_room_pit_apply_help_gift($user_id,$room_id,$gift_id,$gift_price)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
if(!$gift_id){
|
||||
return ['code' => 0, 'msg' => '请选择礼物', 'data' => null];
|
||||
}
|
||||
//礼物不能是CP礼物
|
||||
$cp_gift_ids = explode(',', get_system_config_value('cp_gift_id'));
|
||||
if (in_array($gift_id, $cp_gift_ids)) {
|
||||
@@ -990,10 +960,6 @@ class RoomPit extends Model
|
||||
//修改房间上麦模式
|
||||
public function change_room_up_pit_type($user_id,$room_id)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
|
||||
//判断当前用户是否有权限
|
||||
$owner = db::name('vs_room')->where(['id' => $room_id, 'user_id' => $user_id])->field('id')->find();
|
||||
$host = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $user_id,'delete_time' => null])->find();
|
||||
@@ -1031,15 +997,6 @@ class RoomPit extends Model
|
||||
//1-抱麦 2-踢下去
|
||||
public function host_user_pit($user_id,$room_id,$pit_number,$accept_user_id,$type)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
|
||||
if(!$accept_user_id){
|
||||
return ['code' => 0, 'msg' => '请选择用户', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
$room_type = db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
if($type == 1){//抱麦
|
||||
//判断该用户是否在主持麦上
|
||||
@@ -1051,8 +1008,18 @@ class RoomPit extends Model
|
||||
if($accept_user_is_on_pit){
|
||||
return ['code' => 0, 'msg' => '该用户已在麦位上', 'data' => null];
|
||||
}
|
||||
if($room_type == 7 && ($pit_number == 7 || $pit_number == 8)){
|
||||
return ['code' => 0, 'msg' => '互娱房 不能上7、8号麦位', 'data' => null];
|
||||
if($room_type == 7 || $room_type == 11){
|
||||
if($pit_number == 7 || $pit_number == 8){
|
||||
return ['code' => 0, 'msg' => '此类型房间 不能上7、8号麦位', 'data' => null];
|
||||
}
|
||||
}
|
||||
if($room_type == 11 && $pit_number != 10){
|
||||
$text['text'] = '邀请你上麦';
|
||||
$text['user_id'] = $accept_user_id;
|
||||
$text['pit_number'] = $pit_number;
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1202,$room_id,$text);
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}
|
||||
$room_label = db::name('vs_room')->where(['id' => $room_id])->value('label_id');
|
||||
if($room_type == 1 && $room_label == 2 && !$pit_number){
|
||||
@@ -1184,11 +1151,11 @@ class RoomPit extends Model
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
if($room_type == 7){
|
||||
if($room_type == 7 || $room_type == 11){
|
||||
//查询当前空麦位
|
||||
$empty_pit = $this->getRoomNullPitWithout($room_id, [7,8,9, 10]);
|
||||
$empty_pit = $this->getRoomNullPitWithout($room_id, [7,8,9,10]);
|
||||
}else{
|
||||
$empty_pit = $this->getRoomNullPitWithout($room_id, [9, 10]);
|
||||
$empty_pit = $this->getRoomNullPitWithout($room_id, [9,10]);
|
||||
}
|
||||
|
||||
if(!$empty_pit){
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Log;
|
||||
use think\Model;
|
||||
|
||||
class RoomPk extends Model
|
||||
@@ -33,12 +34,19 @@ class RoomPk extends Model
|
||||
}
|
||||
}
|
||||
|
||||
//判断发起者是否是房间的主持
|
||||
$is_host = db::name('vs_room_host')->where('room_id', $room_id_a)->where('user_id', $create_user_id)->where(['type' => 1,'delete_time' =>null ])->find();
|
||||
$owner = db::name('vs_room')->where('id', $room_id_a)->value('user_id');
|
||||
if (!$is_host && $owner != $create_user_id) {
|
||||
return ['code' => 0, 'msg' => '您不是此房间的主持人,请联系房主', 'data' => ''];
|
||||
//判断发起者是否在房间的主持
|
||||
$roomPit = db::name('vs_room_pit')->where(['room_id' => $room_id_a,'pit_number' => 9])->value('user_id');
|
||||
if ($roomPit != $create_user_id) {
|
||||
return ['code' => 0, 'msg' => '您不在此房间的主持人麦位,请上麦后发起PK', 'data' => ''];
|
||||
}
|
||||
|
||||
//判断自己是否开启了pk
|
||||
$is_pk2 = db::name('vs_room_pk')->where(['room_id_a' => $room_id_a,'status' => ['in',[1,2,3,4]]])->find();
|
||||
$is_pk3 = db::name('vs_room_pk')->where(['room_id_b' => $room_id_a,'status' => ['in',[1,2,3,4]]])->find();
|
||||
if($is_pk2 || $is_pk3){
|
||||
return ['code' => 0, 'msg' => '您已经开启了PK,请勿重复操作!', 'data' => ''];
|
||||
}
|
||||
|
||||
//没有接收者
|
||||
if(!$room_id_b){
|
||||
$where = [
|
||||
@@ -166,6 +174,14 @@ class RoomPk extends Model
|
||||
//判断发起者是否和别人开启了pk
|
||||
$is_pk = db::name('vs_room_pk')->where(['pk_id' => ['<>',$pk_id],'room_id_a' => $pk_info['room_id_a'],'status' => ['in',[1,2,3,4]]])->find();
|
||||
$is_pk1 = db::name('vs_room_pk')->where(['pk_id' => ['<>',$pk_id],'room_id_b' => $pk_info['room_id_a'],'status' => ['in',[1,2,3,4]]])->find();
|
||||
//判断自己是否开启了pk 查看自己所在的房间
|
||||
$me_room = db::name('vs_room_pit')->where(['user_id' =>$user_id,'pit_number' =>9])->value('room_id');
|
||||
$is_pk2 = db::name('vs_room_pk')->where(['pk_id' => ['<>',$pk_id],'room_id_a' => $me_room,'status' => ['in',[1,2,3,4]]])->find();
|
||||
$is_pk3 = db::name('vs_room_pk')->where(['pk_id' => ['<>',$pk_id],'room_id_b' => $me_room,'status' => ['in',[1,2,3,4]]])->find();
|
||||
if($is_pk2 || $is_pk3){
|
||||
return ['code' => 0, 'msg' => '您已经开启了PK,请勿重复操作!', 'data' => ''];
|
||||
}
|
||||
|
||||
if($is_pk || $is_pk1){
|
||||
return ['code' => 0, 'msg' => '发起方已经重新开启了PK,请重新选择PK房间!', 'data' => ''];
|
||||
}
|
||||
@@ -279,18 +295,18 @@ class RoomPk extends Model
|
||||
public function search_pk_room($user_id,$room_id,$page,$limit)
|
||||
{
|
||||
//自己当前房间
|
||||
$room_id_a = db::name('vs_room')->where('user_id', $user_id)->value('id');
|
||||
// $room_id_a = db::name('vs_room')->where('user_id', $user_id)->value('id');
|
||||
$room_id_b = db::name('vs_room_pit')->where(['pit_number' => 9, 'user_id' => $user_id])->value('room_id') ?? 0;
|
||||
$room_id_c = [$room_id_a,$room_id_b];
|
||||
// $room_id_c = [$room_id_a,$room_id_b];
|
||||
$where = [
|
||||
'a.id' => ['not in',$room_id_c],
|
||||
'a.id' => ['<>',$room_id_b],
|
||||
'a.room_status' => 1,
|
||||
'a.apply_status' => 2,
|
||||
'a.is_pk' => 1,
|
||||
'a.is_show_room' => 1,
|
||||
// 'a.is_show_room' => 1,
|
||||
'b.pit_number' => 9,
|
||||
'b.user_id' => ['<>',0],
|
||||
'a.type_id' => ['in',[1,3,4,8]],
|
||||
'a.type_id' => 1,
|
||||
'a.label_id' => 1,
|
||||
];
|
||||
|
||||
@@ -431,6 +447,15 @@ class RoomPk extends Model
|
||||
];
|
||||
model('Chat')->sendMsg(1032,$pk_info['room_id_a'],$texta);
|
||||
model('Chat')->sendMsg(1032,$pk_info['room_id_b'],$textb);
|
||||
$Victory_user = db::name('vs_room_pit')
|
||||
->where(['room_id' => $pk_info['room_id_a'],'user_id' => ['>',0]])
|
||||
->column('user_id');
|
||||
$Victory_user_ids = implode(',',$Victory_user);
|
||||
$Failure_user = db::name('vs_room_pit')
|
||||
->where(['room_id' => $pk_info['room_id_b'],'user_id' => ['>',0]])
|
||||
->column('user_id');
|
||||
$Failure_user_ids = implode(',',$Failure_user);
|
||||
$Draw_user_ids = '';
|
||||
}elseif($pk_info['create_value_a'] < $pk_info['receive_value_b']){
|
||||
db::name('vs_room_pk')->where('pk_id', $pk_id)->update(['shibaifang_id' => $pk_info['create_user_id']]);
|
||||
$texta = [
|
||||
@@ -453,10 +478,19 @@ class RoomPk extends Model
|
||||
];
|
||||
model('Chat')->sendMsg(1032,$pk_info['room_id_a'],$texta);
|
||||
model('Chat')->sendMsg(1032,$pk_info['room_id_b'],$textb);
|
||||
$Victory_user = db::name('vs_room_pit')
|
||||
->where(['room_id' => $pk_info['room_id_b'],'user_id' => ['>',0]])
|
||||
->column('user_id');
|
||||
$Victory_user_ids = implode(',',$Victory_user);
|
||||
$Failure_user = db::name('vs_room_pit')
|
||||
->where(['room_id' => $pk_info['room_id_a'],'user_id' => ['>',0]])
|
||||
->column('user_id');
|
||||
$Failure_user_ids = implode(',',$Failure_user);
|
||||
$Draw_user_ids = '';
|
||||
}else{
|
||||
db::name('vs_room_pk')->where('pk_id', $pk_id)->update(['shibaifang_id' => -1]);
|
||||
$texta = [
|
||||
'type' => 2,//失败
|
||||
'type' => 2,//平局
|
||||
'victory_name' => db::name('vs_room')->where('id', $pk_info['room_id_a'])->value('room_name'),
|
||||
'victory_cover' => db::name('vs_room')->where('id', $pk_info['room_id_a'])->value('room_cover'),
|
||||
'defeated_name' => db::name('vs_room')->where('id', $pk_info['room_id_b'])->value('room_name'),
|
||||
@@ -465,7 +499,7 @@ class RoomPk extends Model
|
||||
'end_time' => $pk_info['end_time'] + 300,
|
||||
];
|
||||
$textb = [
|
||||
'type' => 2,//胜利
|
||||
'type' => 2,//平局
|
||||
'victory_name' => db::name('vs_room')->where('id', $pk_info['room_id_b'])->value('room_name'),
|
||||
'victory_cover' => db::name('vs_room')->where('id', $pk_info['room_id_b'])->value('room_cover'),
|
||||
'defeated_name' => db::name('vs_room')->where('id', $pk_info['room_id_a'])->value('room_name'),
|
||||
@@ -476,7 +510,22 @@ class RoomPk extends Model
|
||||
|
||||
model('Chat')->sendMsg(1032,$pk_info['room_id_a'],$texta);
|
||||
model('Chat')->sendMsg(1032,$pk_info['room_id_b'],$textb);
|
||||
$Victory_user = db::name('vs_room_pit')
|
||||
->where(['room_id' => $pk_info['room_id_b'],'user_id' => ['>',0]])
|
||||
->column('user_id');
|
||||
$Failure_user = db::name('vs_room_pit')
|
||||
->where(['room_id' => $pk_info['room_id_a'],'user_id' => ['>',0]])
|
||||
->column('user_id');
|
||||
|
||||
//合并字符串
|
||||
$Draw_user_ids = implode(',', array_unique(array_merge($Victory_user, $Failure_user)));
|
||||
|
||||
$Victory_user_ids = '';
|
||||
$Failure_user_ids = '';
|
||||
}
|
||||
Log::record("pk任务平双方:".$Draw_user_ids,"info");
|
||||
//任务:35-每日参与PK
|
||||
model('api/Tasks')->tasks_complete_pk($Victory_user_ids,$Failure_user_ids,$Draw_user_ids,35);
|
||||
|
||||
}elseif($type == 2){
|
||||
$text = [
|
||||
@@ -556,4 +605,45 @@ class RoomPk extends Model
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//PK闭麦
|
||||
public function close_pk_mic($pk_id, $type, $user_id)
|
||||
{
|
||||
$pk_info = db::name('vs_room_pk')->where('pk_id', $pk_id)->find();
|
||||
if(!$pk_info){
|
||||
return ['code' => 0, 'msg' => '失败', 'data' => ''];
|
||||
}
|
||||
if($type == 1){//1、关闭,2、开启
|
||||
//有就返回成功,没有就插入
|
||||
if(strpos($pk_info['close_users'], $user_id) !== false){
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => ''];
|
||||
}else{
|
||||
//查看里面有值吗
|
||||
if($pk_info['close_users']){
|
||||
$close = $pk_info['close_users'] .',' . $user_id;
|
||||
}else{
|
||||
$close = $user_id;
|
||||
}
|
||||
$res = db::name('vs_room_pk')->where('pk_id', $pk_id)->update(['close_users' => $close]);
|
||||
}
|
||||
}else{
|
||||
//没有就返回成功,有就删掉
|
||||
if(strpos($pk_info['close_users'], $user_id) === false){
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => ''];
|
||||
}else{
|
||||
//转成数组
|
||||
$close_users = explode(',', $pk_info['close_users']);
|
||||
array_splice($close_users, array_search($user_id, $close_users), 1);//删除
|
||||
$close_users = implode(',', $close_users);//转成字符串
|
||||
$res = db::name('vs_room_pk')->where('pk_id', $pk_id)->update(['close_users' => $close_users]);
|
||||
}
|
||||
}
|
||||
if ($res) {
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => ''];
|
||||
} else {
|
||||
return ['code' => 0, 'msg' => '失败', 'data' => ''];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -83,10 +83,12 @@ class RoomSong extends Model
|
||||
|
||||
//同意点歌
|
||||
public function agree_song($user_id,$room_id,$type){
|
||||
$owner = db::name('vs_room')->where(['id' => $room_id, 'user_id' => $user_id])->field('id')->find();
|
||||
$host = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $user_id,'delete_time' => null])->find();
|
||||
if(!$owner && !$host){
|
||||
return ['code' => 0, 'msg' => '没有权限操作', 'data' => null];
|
||||
if($user_id != 1){
|
||||
$owner = db::name('vs_room')->where(['id' => $room_id, 'user_id' => $user_id])->field('id')->find();
|
||||
$host = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $user_id,'delete_time' => null])->find();
|
||||
if(!$owner && !$host){
|
||||
return ['code' => 0, 'msg' => '没有权限操作', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//此房间类型为特殊存在,修改房间类型的时候 要判断一下条件
|
||||
@@ -137,7 +139,7 @@ class RoomSong extends Model
|
||||
->where('user_id','>',0)->select();
|
||||
if(!empty($roomPit)){
|
||||
foreach ($roomPit as $k=>$v){
|
||||
model('RoomPit')->DownPit($v['user_id'],$room_id,$v['pit_number']);
|
||||
model('api/RoomPit')->DownPit($v['user_id'],$room_id,$v['pit_number']);
|
||||
}
|
||||
}
|
||||
Cache::rm('room_info_'.$room_id);
|
||||
@@ -145,7 +147,7 @@ class RoomSong extends Model
|
||||
$text = [
|
||||
'text' => '房间类型变成k歌--2'
|
||||
];
|
||||
model('Chat')->sendMsg(1012,$room_id,$text);
|
||||
model('api/Chat')->sendMsg(1012,$room_id,$text);
|
||||
}else{
|
||||
$res = db::name('vs_room')->where('id',$room_id)->update(['is_song'=>4]);
|
||||
if(!$res){
|
||||
@@ -159,7 +161,7 @@ class RoomSong extends Model
|
||||
'FromUserInfo' => $FromUserInfo,
|
||||
'action' => 4 //拒绝申请点歌
|
||||
];
|
||||
model('Chat')->sendMsg(1013,$room_id,$text);
|
||||
model('api/Chat')->sendMsg(1013,$room_id,$text);
|
||||
}
|
||||
}
|
||||
//删除申请缓存
|
||||
@@ -173,7 +175,7 @@ class RoomSong extends Model
|
||||
public function song($room_id,$user_id,$song_code,$song_name,$singer,$poster,$duration){
|
||||
$action = 0;//初始值,1-申请点歌,2-切歌,3-下一首歌曲变化,4-拒绝申请点歌
|
||||
//查询当前房间中的场次状态
|
||||
$times_status = db::name('vs_room_song')->where('room_id',$room_id)->field('times,times_status')->order('did desc')->find();
|
||||
$times_status = db::name('vs_room_song')->where('room_id',$room_id)->field('times,times_status')->order('times desc,sort desc')->find();
|
||||
if(!empty($times_status)){//已经有歌曲
|
||||
if($times_status['times_status'] == 2){//这一场次结束了
|
||||
$data['sort'] = 10000;//排序,新场次第一首歌
|
||||
@@ -211,6 +213,18 @@ class RoomSong extends Model
|
||||
$action = 2;//走切歌,当前要唱的歌
|
||||
}
|
||||
|
||||
//本房间内总共还有多少首歌曲未唱
|
||||
$room_song = db::name('vs_room_song')->where(['room_id' => $room_id,'times' => $data['times'],'status' => 1])->count();
|
||||
if($room_song >= 60){
|
||||
return ['code'=>0,'msg'=>'房间内未唱歌曲已达上限,请待演唱完一首后再点歌','data'=>null];
|
||||
}
|
||||
|
||||
//查询当前用户还有几首没有唱
|
||||
$user_song = db::name('vs_room_song')->where(['user_id' => $user_id,'room_id' => $room_id,'times' => $data['times'],'status' => 1])->count();
|
||||
if($user_song >= 3){
|
||||
return ['code'=>0,'msg'=>'已经点了三首歌曲了!演唱后再点','data'=>null];
|
||||
}
|
||||
|
||||
$data['room_id'] = $room_id;
|
||||
$data['user_id'] = $user_id;
|
||||
|
||||
@@ -259,13 +273,16 @@ class RoomSong extends Model
|
||||
//把这个信息存储到redis
|
||||
Cache::set("api:room:song:nextInfo:" . $room_id, $did);
|
||||
}
|
||||
$text = [
|
||||
'action' => $action,
|
||||
'total' => $total,
|
||||
'songInfo' => $nowInfo,
|
||||
'nextInfo' => $nextInfo
|
||||
];
|
||||
model('Chat')->sendMsg(1013,$room_id,$text);
|
||||
if($action){
|
||||
$text = [
|
||||
'action' => $action,
|
||||
'total' => $total,
|
||||
'songInfo' => $nowInfo,
|
||||
'nextInfo' => $nextInfo
|
||||
];
|
||||
model('Chat')->sendMsg(1013,$room_id,$text);
|
||||
}
|
||||
|
||||
//1-禁麦位,2-清空消息,3-清空魅力值,4-加入黑名单,5-踢出房间,6-关闭麦克风,7-申请上麦,8-同意上麦,9-拒绝上麦,10-点歌,11-开启PK',
|
||||
model('Room')->room_operation_record($user_id,$room_id,10,0,0,$did);
|
||||
return ['code'=>1,'msg'=>'申请成功','data'=>null];
|
||||
@@ -281,6 +298,55 @@ class RoomSong extends Model
|
||||
foreach ($list as &$v){
|
||||
$v['nickname'] = db::name('user')->where('id',$v['user_id'])->value('nickname');
|
||||
$v['avatar'] = db::name('user')->where('id',$v['user_id'])->value('avatar');
|
||||
$v['user_code'] = db::name('user')->where('id',$v['user_id'])->value('user_code');
|
||||
$v['dress'] = model('Decorate')->user_decorate_detail($v['user_id'], 1);
|
||||
}
|
||||
}
|
||||
return ['code'=>1,'msg'=>'操作成功','data'=>$list];
|
||||
}
|
||||
|
||||
|
||||
//删除已点歌曲
|
||||
public function del_song($user_id,$did,$room_id){
|
||||
//查询当前用户是否是在9号麦的主持
|
||||
$is_host = db::name('vs_room_pit')->where(['user_id' => $user_id,'room_id' => $room_id,'pit_number' =>9])->find();
|
||||
if(!$is_host){
|
||||
return ['code'=>0,'msg'=>'您没有权限操作','data'=>null];
|
||||
}
|
||||
$is_song = db::name('vs_room_song')->where(['did' => $did,'status' => 2])->find();
|
||||
if($is_song){
|
||||
return ['code'=>0,'msg'=>'演唱中不能删除','data'=>null];
|
||||
}
|
||||
$next_song = Cache::get("api:room:song:nextInfo:" . $room_id);
|
||||
if($did == $next_song){
|
||||
return ['code'=>0,'msg'=>'下一首播放歌曲不能删除','data'=>null];
|
||||
}
|
||||
$res = db::name('vs_room_song')->where(['did' => $did,'status' => 1])->delete();
|
||||
if(!$res){
|
||||
return ['code'=>0,'msg'=>'操作失败','data'=>null];
|
||||
}
|
||||
return ['code'=>1,'msg'=>'操作成功','data'=>null];
|
||||
}
|
||||
|
||||
|
||||
//已点歌曲搜索
|
||||
public function search_song($room_id,$search_user){
|
||||
$userId = db::name('user')->where(['user_code' => $search_user])->value('id');
|
||||
if(!$userId){
|
||||
$userId = db::name('vs_user_decorate')
|
||||
->where(['special_num' => $search_user,'type'=> 6,'is_using' => 1])
|
||||
->value('user_id');
|
||||
}
|
||||
|
||||
$list = db::name('vs_room_song')
|
||||
->field('did,room_id,song_code,song_name,singer,poster,duration,sort,user_id')
|
||||
->where(['room_id' => $room_id,'status' => 1,'times_status' => 1,'user_id' =>$userId])
|
||||
->order('sort desc')->select();
|
||||
if($list){
|
||||
foreach ($list as &$v){
|
||||
$v['nickname'] = db::name('user')->where('id',$v['user_id'])->value('nickname');
|
||||
$v['avatar'] = db::name('user')->where('id',$v['user_id'])->value('avatar');
|
||||
$v['user_code'] = db::name('user')->where('id',$v['user_id'])->value('user_code');
|
||||
$v['dress'] = model('Decorate')->user_decorate_detail($v['user_id'], 1);
|
||||
}
|
||||
}
|
||||
@@ -298,49 +364,110 @@ class RoomSong extends Model
|
||||
return ['code'=>0,'msg'=>'您没有权限操作','data'=>null];
|
||||
}
|
||||
//根据房间ID查询当前房间中正在排序的歌曲 并获取当前排序的前一位的ID
|
||||
$sort_up = db::name('vs_room_song')->where(['room_id' => $sort['room_id'],'status' => 1,'times' =>$sort['times'],'times_status' => 1])->field('did')->order('sort desc')->select();
|
||||
$sort_up = db::name('vs_room_song')
|
||||
->where(['room_id' => $sort['room_id'],'status' => 1,'times' =>$sort['times'],'times_status' => 1])
|
||||
->field('did,status,song_code,song_name,singer,poster,duration,user_id')->order('sort desc')->select();
|
||||
|
||||
if($sort_up[0]['did'] == $room_song_id){
|
||||
return ['code'=>0,'msg'=>'已经是第一首歌了','data'=>null];
|
||||
}
|
||||
|
||||
$sort_ups = 1000;//默认值
|
||||
$now_room_song = 0;
|
||||
if($type == 1){ //上移
|
||||
foreach ($sort_up as $k=>$v){
|
||||
if($v['did'] == $room_song_id){
|
||||
$sort_ups = $sort_up[$k-1]['did'];
|
||||
}
|
||||
if($v['status'] == 2){
|
||||
$now_room_song = 1;
|
||||
}
|
||||
}
|
||||
$fa_zhi = 0;
|
||||
}else{ //置顶
|
||||
foreach ($sort_up as $k=>$v){
|
||||
$sort_ups = $sort_up[0]['did'];
|
||||
}
|
||||
$sort_ups = $sort_up[0]['did'];
|
||||
$now_room_song = db::name('vs_room_song')
|
||||
->where(['room_id' => $sort['room_id'],'status' => 2,'times' =>$sort['times'],'times_status' => 1])
|
||||
->find() ? 1 : 0;
|
||||
$fa_zhi = 9;//阈值 为了防止置顶后被上移歌曲覆盖
|
||||
}
|
||||
//获取现在正在排队的第一的排序号
|
||||
$sortt = db::name('vs_room_song')->where('did',$sort_ups)->value('sort');
|
||||
$sort_upp = $sortt + 1 + $fa_zhi;
|
||||
$sort_upp = $sortt + 1 + $fa_zhi;//计算需要挪动的歌曲的排序号并修改它
|
||||
$res = db::name('vs_room_song')->where('did',$room_song_id)->update(['sort'=>$sort_upp]);
|
||||
if(!$res){
|
||||
return ['code'=>0,'msg'=>'操作失败','data'=>null];
|
||||
}
|
||||
$data = db::name('vs_room_song')->where(['room_id' => $sort['room_id'],'status' => 1,'times' =>$sort['times'],'times_status' => 1])
|
||||
->order('sort desc')->select();
|
||||
|
||||
//移动后重新按照排序查找歌曲新排序
|
||||
$sort_up = db::name('vs_room_song')
|
||||
->where(['room_id' => $sort['room_id'],'status' => 1,'times' =>$sort['times'],'times_status' => 1])
|
||||
->field('did,status,song_code,song_name,singer,poster,duration,user_id')->order('sort desc')->select();
|
||||
|
||||
if(!$now_room_song){//没有正在演唱的歌曲
|
||||
$total = db::name('vs_room_song')
|
||||
->where(['room_id' => $sort['room_id'],'status' => 1,'times_status' => 1])
|
||||
->count();
|
||||
$nowInfo = [
|
||||
'did' => $sort_up[0]['did'],
|
||||
'song_code' => $sort_up[0]['song_code'],
|
||||
'song_name' => $sort_up[0]['song_name'],
|
||||
'singer' => $sort_up[0]['singer'],
|
||||
'poster' => $sort_up[0]['poster'],
|
||||
'duration' => $sort_up[0]['duration'],
|
||||
'user_id' => $sort_up[0]['user_id'],
|
||||
'dress' => model('Decorate')->user_decorate_detail($sort_up[0]['user_id'], 1),
|
||||
'nickname' => db::name('user')->where('id',$sort_up[0]['user_id'])->value('nickname'),
|
||||
'avatar' => db::name('user')->where('id',$sort_up[0]['user_id'])->value('avatar'),
|
||||
'charm' => db::name('vs_room_user_charm')->where(['user_id' => $sort_up[0]['user_id'],'room_id' => $sort['room_id']])->value('charm'),
|
||||
];
|
||||
if(count($sort_up) >= 2){
|
||||
$nextInfo = [
|
||||
'did' => $sort_up[1]['did'],
|
||||
'song_code' => $sort_up[1]['song_code'],
|
||||
'song_name' => $sort_up[1]['song_name'],
|
||||
'singer' => $sort_up[1]['singer'],
|
||||
'poster' => $sort_up[1]['poster'],
|
||||
'duration' => $sort_up[1]['duration'],
|
||||
'user_id' => $sort_up[1]['user_id'],
|
||||
'dress' => model('Decorate')->user_decorate_detail($sort_up[1]['user_id'], 1),
|
||||
'nickname' => db::name('user')->where('id',$sort_up[1]['user_id'])->value('nickname'),
|
||||
'avatar' => db::name('user')->where('id',$sort_up[1]['user_id'])->value('avatar'),
|
||||
'charm' => db::name('vs_room_user_charm')->where(['user_id' =>$sort_up[1]['user_id'],'room_id' => $sort['room_id']])->value('charm'),
|
||||
];
|
||||
}else{
|
||||
$nextInfo = null;
|
||||
}
|
||||
|
||||
$text = [
|
||||
'action' => 2,
|
||||
'total' => $total,
|
||||
'songInfo' => $nowInfo,
|
||||
'nextInfo' => $nextInfo
|
||||
];
|
||||
model('Chat')->sendMsg(1013,$sort['room_id'],$text);
|
||||
Cache::set("api:room:song:nextInfo:" . $sort['room_id'],$sort_up[0]['did']);
|
||||
return ['code'=>1,'msg'=>'操作成功','data'=>null];
|
||||
}
|
||||
|
||||
$did = Cache::get("api:room:song:nextInfo:" . $sort['room_id']);
|
||||
//歌曲移动后,下一首播放歌曲信息 发生改变 推送给前端
|
||||
if($data[0]['did'] != $did){
|
||||
if($sort_up[0]['did'] != $did){
|
||||
$total = db::name('vs_room_song')
|
||||
->where(['room_id' => $sort['room_id'],'status' => 1,'times_status' => 1])
|
||||
->count();
|
||||
$info = [
|
||||
'did' => $data[0]['did'],
|
||||
'song_code' => $data[0]['song_code'],
|
||||
'song_name' => $data[0]['song_name'],
|
||||
'singer' => $data[0]['singer'],
|
||||
'poster' => $data[0]['poster'],
|
||||
'duration' => $data[0]['duration'],
|
||||
'user_id' => $data[0]['user_id'],
|
||||
'dress' => model('Decorate')->user_decorate_detail($data[0]['user_id'], 1),
|
||||
'nickname' => db::name('user')->where('id',$data[0]['user_id'])->value('nickname'),
|
||||
'avatar' => db::name('user')->where('id',$data[0]['user_id'])->value('avatar'),
|
||||
'charm' => db::name('vs_room_user_charm')->where(['user_id' => $data[0]['user_id'],'room_id' => $sort['room_id']])->value('charm'),
|
||||
'did' => $sort_up[0]['did'],
|
||||
'song_code' => $sort_up[0]['song_code'],
|
||||
'song_name' => $sort_up[0]['song_name'],
|
||||
'singer' => $sort_up[0]['singer'],
|
||||
'poster' => $sort_up[0]['poster'],
|
||||
'duration' => $sort_up[0]['duration'],
|
||||
'user_id' => $sort_up[0]['user_id'],
|
||||
'dress' => model('Decorate')->user_decorate_detail($sort_up[0]['user_id'], 1),
|
||||
'nickname' => db::name('user')->where('id',$sort_up[0]['user_id'])->value('nickname'),
|
||||
'avatar' => db::name('user')->where('id',$sort_up[0]['user_id'])->value('avatar'),
|
||||
'charm' => db::name('vs_room_user_charm')->where(['user_id' => $sort_up[0]['user_id'],'room_id' => $sort['room_id']])->value('charm'),
|
||||
];
|
||||
$text = [
|
||||
'action' => 3,//下一首播放歌曲信息推送给前端
|
||||
@@ -349,9 +476,9 @@ class RoomSong extends Model
|
||||
'nextInfo' => $info
|
||||
];
|
||||
model('Chat')->sendMsg(1013,$sort['room_id'],$text);
|
||||
Cache::set("api:room:song:nextInfo:" . $sort['room_id'],$data[0]['did']);
|
||||
Cache::set("api:room:song:nextInfo:" . $sort['room_id'],$sort_up[0]['did']);
|
||||
}
|
||||
return ['code'=>1,'msg'=>'操作成功','data'=>$data];
|
||||
return ['code'=>1,'msg'=>'操作成功','data'=>null];
|
||||
}
|
||||
|
||||
//切歌
|
||||
|
||||
1780
application/api/model/SendGift.php
Normal file
1780
application/api/model/SendGift.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -83,7 +83,7 @@ class Sign extends Model
|
||||
*/
|
||||
public function sign_coin($user_id,$room_id,$sign_user_id,$sign_value,$sign_time){
|
||||
//查询用户金币
|
||||
$user_coin = db::name('user_wallet')->where('user_id',$user_id)->value('coin');
|
||||
$user_coin = db::name('user_wallet_coin')->where('user_id',$user_id)->value('coin');
|
||||
if($user_coin < $sign_value){
|
||||
return ['code' => 0, 'msg' => '金币不足','data' => null];
|
||||
}
|
||||
@@ -91,7 +91,7 @@ class Sign extends Model
|
||||
//开启事务
|
||||
db::startTrans();
|
||||
//扣除用户金币并记录日志
|
||||
$wallet_update = model('api/GiveGift') -> change_user_cion_or_earnings_log($user_id,$sign_value,$room_id,1,50,'用户签约关系');
|
||||
$wallet_update = model('api/UserWallet')->change_user_cion_log($user_id,$sign_value,$room_id,50,'用户签约关系');
|
||||
if(!$wallet_update){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '扣除用户金币失败', 'data' => null];
|
||||
@@ -101,7 +101,7 @@ class Sign extends Model
|
||||
$data = [
|
||||
'user_id' => $user_id,
|
||||
'room_id' => $room_id,
|
||||
'sign_time' => $sign_time,
|
||||
'sign_time' => $sign_time,//场次 vs_room_sign 的ID
|
||||
'sign_user_id' => $sign_user_id,
|
||||
'sign_value' => $sign_value,
|
||||
'createtime' => time(),
|
||||
@@ -112,20 +112,16 @@ class Sign extends Model
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试!','data' => null];
|
||||
}
|
||||
|
||||
//记录房间流水及明细
|
||||
//收礼记录行为日志
|
||||
// $give_gift = model('api/GiveGift') -> change_user_give_gift_log($user_id,0,$sign_value,0,$sign_user_id,2,1,$room_id,0,3);
|
||||
// if(!$give_gift){
|
||||
// Db::rollback();
|
||||
// return ['code' => 0, 'msg' => '出价失败', 'data' => null];
|
||||
// }
|
||||
|
||||
//增加房间火热值hot_value
|
||||
$gift_totalaa = $sign_value * get_system_config_value('coin_charm_exp');
|
||||
db::name('vs_room')->where(['id' => $room_id])->inc('hot_value', $gift_totalaa)->inc('today_hot_value', $gift_totalaa)->update();
|
||||
|
||||
//获取出价最高用户
|
||||
$sign_user = db::name('vs_user_sign_auction')->where(['room_id' => $room_id,'sign_time' => $sign_time,'type' => 0])->order('sign_value desc,id asc')->field('id,user_id,sign_value')->find();
|
||||
$sign_user = db::name('vs_user_sign_auction')
|
||||
->field('id,user_id,sign_value')
|
||||
->where(['room_id' => $room_id,'sign_time' => $sign_time,'type' => 0])
|
||||
->order('sign_value desc,id asc')
|
||||
->find();
|
||||
|
||||
//其他的出价退回到用户的钱包
|
||||
$refund = db::name('vs_user_sign_auction')->where(['room_id' => $room_id,'sign_time' => $sign_time,'type' => 0])->select();
|
||||
@@ -133,7 +129,7 @@ class Sign extends Model
|
||||
foreach ($refund as $k => $v){
|
||||
if($v['id'] != $sign_user['id']){
|
||||
//给用户退回签约金额记录行为日志
|
||||
$result2[$k] = model('api/GiveGift') -> change_user_cion_or_earnings_log($v['user_id'],$v['sign_value'],$room_id,1,51,'签约失败退款');
|
||||
$result2[$k] = model('api/UserWallet')->change_user_cion_log($v['user_id'],$v['sign_value'],$room_id,51,'签约失败退款');
|
||||
if(!$result2[$k]){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试,', 'data' => null];
|
||||
@@ -193,8 +189,11 @@ class Sign extends Model
|
||||
return ['code' => 0, 'msg' => '该场次签约已结束', 'data' => null];
|
||||
}
|
||||
//获取签约出价最高的
|
||||
$max_sign_user = db::name('vs_user_sign_auction')->where(['room_id' => $room_id,'sign_time' => $sign_time,'type' => 0])->order('sign_value desc,id asc')->find();
|
||||
if($max_sign_user){
|
||||
$max_sign_user = db::name('vs_user_sign_auction')
|
||||
->where(['room_id' => $room_id,'sign_time' => $sign_time,'type' => 0])
|
||||
->order('sign_value desc,id asc')
|
||||
->find();
|
||||
if($max_sign_user && $max_sign_user['sign_value'] > $sign['market_value']){
|
||||
$before_sign_user = null;
|
||||
$is_sign = null;
|
||||
//查询签约用户的身份 是否是第一次被签 是否当前有签
|
||||
@@ -221,7 +220,7 @@ class Sign extends Model
|
||||
|
||||
//记录房间流水及明细
|
||||
//收礼记录行为日志
|
||||
$give_gift = model('api/GiveGift') -> change_user_give_gift_log($max_sign_user['user_id'],0,$max_sign_user['sign_value'],0,$sign_user_id,2,1,$room_id,0,3);
|
||||
$give_gift = model('api/SendGift') -> change_user_give_gift_log($max_sign_user['user_id'],0,$max_sign_user['sign_value'],1,$sign_user_id,2,1,$room_id,'签约用户');
|
||||
if(!$give_gift){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '出价失败', 'data' => null];
|
||||
@@ -273,7 +272,7 @@ class Sign extends Model
|
||||
}
|
||||
|
||||
//签过没过期 给上任签约者
|
||||
$result4 = model('api/GiveGift') -> change_user_cion_or_earnings_log($before_sign_user,$shouyizs,$room_id,2,54,'解约补偿');
|
||||
$result4 = model('api/UserWallet')->change_user_earnings_log($before_sign_user,$shouyizs,$room_id,54,'解约补偿');
|
||||
if(!$result4){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
@@ -303,7 +302,7 @@ class Sign extends Model
|
||||
|
||||
if($sign_user_type == 0){
|
||||
//首次签约 给被签约的人
|
||||
$result4 = model('api/GiveGift') -> change_user_cion_or_earnings_log($max_sign_user['sign_user_id'],$shouyizs,$room_id,2,52,'被首次签约成功收入');
|
||||
$result4 = model('api/UserWallet')->change_user_earnings_log($max_sign_user['sign_user_id'],$shouyizs,$room_id,52,'首次签约收入');
|
||||
if(!$result4){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
@@ -364,7 +363,7 @@ class Sign extends Model
|
||||
foreach ($refund as $k => $v){
|
||||
if($v['id'] != $max_sign_user['id']){
|
||||
//给用户退回签约金额记录行为日志
|
||||
$result2[$k] = model('api/GiveGift') -> change_user_cion_or_earnings_log($v['user_id'],$v['sign_value'],$room_id,1,51,'签约失败退款');
|
||||
$result2[$k] = model('api/UserWallet')->change_user_cion_log($v['user_id'],$v['sign_value'],$room_id,51,'签约失败退款');
|
||||
if(!$result2[$k]){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
@@ -443,17 +442,37 @@ class Sign extends Model
|
||||
$text['sign_value'] = $max_sign_user['sign_value'];
|
||||
model('api/Chat')->sendMsg(1092,$room_id,$text);
|
||||
}else{
|
||||
//出价用户退
|
||||
$refund = db::name('vs_user_sign_auction')->where(['room_id' => $room_id,'sign_time' => $sign_time,'type' => 0])->select();
|
||||
if($refund){
|
||||
foreach ($refund as $k => $v){
|
||||
//给用户退回签约金额记录行为日志
|
||||
$result2[$k] = model('api/UserWallet')->change_user_cion_log($v['user_id'],$v['sign_value'],$room_id,51,'签约失败退款');
|
||||
if(!$result2[$k]){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
}
|
||||
$result3[$k] = db::name('vs_user_sign_auction')->where('id',$v['id'])->update(['type' => 2,'refundtime' => time()]);
|
||||
if(!$result3[$k]){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//修改房间信息
|
||||
db::name('vs_room')->where('id',$room_id)->update([
|
||||
'sign_type' => 0,
|
||||
'updatetime' => time()
|
||||
]);
|
||||
|
||||
//修改房间签约信息
|
||||
db::name('vs_room_sign')->where(['id' => $sign_time])
|
||||
->update([
|
||||
'sign_type' => 0,
|
||||
'end_time' => time()
|
||||
]);
|
||||
|
||||
$text['text'] = '流拍';
|
||||
$text['FromUserInfo'] = null;
|
||||
$text['ToUserInfo'] = null;
|
||||
@@ -633,7 +652,7 @@ class Sign extends Model
|
||||
];
|
||||
$result = db::name('vs_user_sign_earnings')->insert($data);
|
||||
if($result){
|
||||
$result4 = model('api/GiveGift') -> change_user_cion_or_earnings_log($sign_info['parent_user_id'],$earnings,$room_id,2,55,'签约用户收礼返佣');
|
||||
$result4 = model('api/UserWallet')->change_user_earnings_log($sign_info['parent_user_id'],$earnings,$room_id,55,'签约用户收礼返佣');
|
||||
if(!$result4){
|
||||
return true;
|
||||
}
|
||||
@@ -692,7 +711,7 @@ class Sign extends Model
|
||||
|
||||
|
||||
//获取签约者的金币
|
||||
$coin = db::name('user_wallet')->where('user_id',$user_id)->value('coin');
|
||||
$coin = db::name('user_wallet_coin')->where('user_id',$user_id)->value('coin');
|
||||
if($coin < $change_coin){
|
||||
return ['code' => 0, 'msg' => '您的金币不足', 'data' => null];
|
||||
}
|
||||
@@ -704,7 +723,7 @@ class Sign extends Model
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
}
|
||||
$res2 = model('api/GiveGift') -> change_user_cion_or_earnings_log($user_id,$change_coin,0,1,56,'续约');
|
||||
$res2 = model('api/UserWallet')->change_user_cion_log($user_id,$change_coin,0,56,'续约');
|
||||
if(!$res2){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
|
||||
@@ -75,10 +75,10 @@ class SingerSong extends Model
|
||||
return ['code' => 0, 'msg' => '请先认证歌手', 'data' => null];
|
||||
}
|
||||
//查询是否提交过歌曲
|
||||
$res = db::name('vs_singer_song')->where(['user_id' => $user_id, 'song_name' => $song_name])->find();
|
||||
if ($res) {
|
||||
return ['code' => 0, 'msg' => '请勿重复提交歌曲', 'data' => null];
|
||||
}
|
||||
// $res = db::name('vs_singer_song')->where(['user_id' => $user_id, 'song_name' => $song_name ,'deletetime' => 0])->find();
|
||||
// if ($res) {
|
||||
// return ['code' => 0, 'msg' => '请勿重复提交歌曲', 'data' => null];
|
||||
// }
|
||||
|
||||
//礼物不能是CP礼物
|
||||
$cp_gift_ids = explode(',', get_system_config_value('cp_gift_id'));
|
||||
@@ -157,7 +157,7 @@ class SingerSong extends Model
|
||||
return ['code' => 0, 'msg' => '不能点自己歌曲', 'data' => null];
|
||||
}
|
||||
//查询用户余额
|
||||
$user_money = db::name('user_wallet')->where(['user_id' => $user_id])->value('coin');
|
||||
$user_money = db::name('user_wallet_coin')->where(['user_id' => $user_id])->value('coin');
|
||||
$gift_price = db::name('vs_gift')->where(['gid' => $song['gift_id']])->value('gift_price');
|
||||
if ($user_money < $gift_price * $song['gift_num']) {
|
||||
return ['code' => 0, 'msg' => '余额不足', 'data' => null];
|
||||
@@ -344,7 +344,7 @@ class SingerSong extends Model
|
||||
if ($level) {
|
||||
db::name('vs_singer')->where(['id' => $is_singer['id']])->update(['exp' => $exps,'level' => $level['level']]);
|
||||
//任务:15-每日获得歌星经验
|
||||
model('Tasks')->tasks_complete($user_id,15,$exp_coin);
|
||||
model('api/Tasks')->tasks_complete($user_id,15,$exp_coin);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
use think\Log;
|
||||
use think\Model;
|
||||
use think\Session;
|
||||
use think\Db;
|
||||
@@ -56,9 +57,9 @@ class Tasks extends Model
|
||||
public function dailyTasksList($user_id=''){
|
||||
$reslut = [];
|
||||
//用户今日充值金币数量
|
||||
$user_gold = Db::name('vs_user_money_log')->where(['user_id'=>$user_id,'change_type'=>2,'money_type'=>1])
|
||||
$user_gold = Db::name('user_coin_log')->where(['user_id'=>$user_id,'change_type'=>2])
|
||||
->whereTime('createtime', 'today')
|
||||
->sum('change_value');
|
||||
->sum('coin');
|
||||
$reslut['user_gold'] = $user_gold ? $user_gold : 0;
|
||||
//礼盒列表
|
||||
$gift_box = Db::name('vs_gift_bag')->where('status',1)->where('activities_id',2)->select();
|
||||
@@ -106,9 +107,22 @@ class Tasks extends Model
|
||||
$reslut['gift_box_list'][$key]['status_str'] = '已用完('.$reslut['gift_box_list'][$key]['taday_number'].'/'.$ext['num'].')';
|
||||
}
|
||||
}
|
||||
//查询是否实名认证
|
||||
$mobile = db::name('user')->where(['id' => $user_id,'status'=>1])->value('mobile');
|
||||
$is_real = db::name('user_auth')->where('mobile' , $mobile)->field('real_name,card_id,is_real,mobile')->find();
|
||||
if($is_real && $is_real['is_real'] ==1){
|
||||
//查询同一个身份证下的 用户
|
||||
$user_auth_mobile = db::name('user_auth')->where(['card_id'=>$is_real['card_id']])->column('mobile');
|
||||
if(count($user_auth_mobile)>1){
|
||||
$user_ids = db::name('user')->whereIn('mobile',$user_auth_mobile)->column('id');
|
||||
}else{
|
||||
$user_ids = db::name('user')->where('mobile',$is_real['mobile'])->column('id');
|
||||
}
|
||||
}
|
||||
|
||||
//任务列表
|
||||
$data = db::name('vs_tasks')
|
||||
->field('id as task_id,icon,task_name,target_quantity,task_type,jump_type,tasks_bag_id')
|
||||
->field('id as task_id,icon,task_name,target_quantity,task_type,jump_type,tasks_bag_id,ext')
|
||||
->where('delete_time',0)
|
||||
->where('is_active',1)
|
||||
->order('sort desc,id asc')->select();
|
||||
@@ -141,7 +155,11 @@ class Tasks extends Model
|
||||
->whereTime('createtime', 'today')
|
||||
->find();
|
||||
}else{
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->where('user_id',$user_id)->where('task_id',$v['task_id'])->find();
|
||||
if(isset($user_ids) && $v['task_type'] == 1 && count($user_ids)>1){
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->whereIn('user_id',$user_ids)->where('task_id',$v['task_id'])->find();
|
||||
}else{
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->where('user_id',$user_id)->where('task_id',$v['task_id'])->find();
|
||||
}
|
||||
if($v['jump_type']==4){
|
||||
//跳转的房间路径
|
||||
$v['from_id'] = model('api/Room')->task_jump_room_recommend($v['task_id']);
|
||||
@@ -238,6 +256,10 @@ class Tasks extends Model
|
||||
$v['task_status'] = 1;
|
||||
$v['task_type_str'] = "未完成";
|
||||
}
|
||||
if($user_couple_task['day']<date('Y-m-d') && $user_couple_task['status'] !=2){
|
||||
$v['task_status'] = 1;
|
||||
$v['task_type_str'] = "已过期";
|
||||
}
|
||||
}elseif($v['task_id']==1){//每日签到处理
|
||||
$sign_in_info = Db::name('vs_user_tasks_sign_in')->where(['user_id'=>$user_id,'sign_in_date'=>date('Y-m-d'),'delete_time'=>0])->find();
|
||||
if ($sign_in_info) {
|
||||
@@ -270,6 +292,11 @@ class Tasks extends Model
|
||||
}
|
||||
$quantity_str= "({$progress}/{$v['target_quantity']})";
|
||||
}
|
||||
if($v['task_id'] == 35){
|
||||
//获胜数量
|
||||
$user_win_times = $user_daily_tasks['ext'] ?? 0;
|
||||
$quantity_str = $quantity_str." 胜:(".$user_win_times."/".$v['ext'].")场";
|
||||
}
|
||||
$v['task_name'] = $v['task_name'].$quantity_str;
|
||||
$v['jump_type_str'] = $this->jump_type[$v['jump_type']];
|
||||
//返回任务列表
|
||||
@@ -322,7 +349,25 @@ class Tasks extends Model
|
||||
if($task_info['task_type']==2){
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->where('user_id',$user_id)->where('task_id',$task_id)->whereTime('createtime', 'today')->find();
|
||||
}else{
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->where('user_id',$user_id)->where('task_id',$task_id)->find();
|
||||
if($task_info['task_type'] == 1){
|
||||
//判断用户是否实名认证,并查询用户手机号下的用户
|
||||
$mobile = db::name('user')->where(['id' => $user_id,'status'=>1])->value('mobile');
|
||||
$is_real = db::name('user_auth')->where('mobile' , $mobile)->field('real_name,card_id,is_real,mobile')->find();
|
||||
if($is_real && $is_real['is_real'] ==1){
|
||||
//查询同一个身份证下的 用户
|
||||
$user_auth_mobile = db::name('user_auth')->where(['card_id'=>$is_real['card_id']])->column('mobile');
|
||||
if(count($user_auth_mobile)>1){
|
||||
$user_ids = db::name('user')->whereIn('mobile',$user_auth_mobile)->column('id');
|
||||
}else{
|
||||
$user_ids = db::name('user')->where('mobile',$is_real['mobile'])->column('id');
|
||||
}
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->whereIn('user_id',$user_ids)->where('task_id',$task_id)->find();
|
||||
if($user_daily_tasks){
|
||||
return ['code' => 0, 'msg' => '您已完成该任务','data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->where('user_id', $user_id)->where('task_id', $task_id)->find();
|
||||
}
|
||||
$is_completed = 0;
|
||||
$completion_time = null;
|
||||
@@ -379,23 +424,41 @@ class Tasks extends Model
|
||||
$is_completed = 1;
|
||||
$completion_time = time();
|
||||
}
|
||||
$reslut = Db::name('vs_tasks_user_daily')->insert([
|
||||
'user_id' => $user_id,
|
||||
'task_id' => $task_id,
|
||||
'current_progress' => $current_progress,
|
||||
'tasks_bag_id' => $task_info['tasks_bag_id'],
|
||||
'is_completed' => $is_completed,
|
||||
'ext' => $ext_value,
|
||||
'createtime' => time(),
|
||||
'completion_time' => $completion_time,
|
||||
]);
|
||||
if($task_id == 1){//每日任务,完成即领取
|
||||
$is_claimed = 1;
|
||||
$collection_time = time();
|
||||
$insert_data = [
|
||||
'user_id' => $user_id,
|
||||
'task_id' => $task_id,
|
||||
'current_progress' => $current_progress,
|
||||
'tasks_bag_id' => $task_info['tasks_bag_id'],
|
||||
'is_completed' => $is_completed,
|
||||
'ext' => $ext_value,
|
||||
'createtime' => time(),
|
||||
'completion_time' => $completion_time,
|
||||
'is_claimed' => $is_claimed,
|
||||
'collection_time' => $collection_time,
|
||||
];
|
||||
}else{
|
||||
$insert_data = [
|
||||
'user_id' => $user_id,
|
||||
'task_id' => $task_id,
|
||||
'current_progress' => $current_progress,
|
||||
'tasks_bag_id' => $task_info['tasks_bag_id'],
|
||||
'is_completed' => $is_completed,
|
||||
'ext' => $ext_value,
|
||||
'createtime' => time(),
|
||||
'completion_time' => $completion_time,
|
||||
];
|
||||
}
|
||||
$reslut = Db::name('vs_tasks_user_daily')->insert($insert_data);
|
||||
}
|
||||
}
|
||||
|
||||
if ($reslut) {
|
||||
if($is_completed==1){
|
||||
if(in_array($task_id,[16,13,21,22,23])){
|
||||
model('Tasks')->tasks_complete($user_id,17);
|
||||
model('api/Tasks')->tasks_complete($user_id,17);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '操作成功','data' => ['is_completed'=>1]];
|
||||
}else{
|
||||
@@ -406,15 +469,107 @@ class Tasks extends Model
|
||||
}
|
||||
}
|
||||
|
||||
//PK任务完成
|
||||
public function tasks_complete_pk($Victory_user_ids,$Failure_user_ids,$Draw_user_ids,$task_id=35){
|
||||
//查询任务
|
||||
$task_info = Db::name('vs_tasks')->where('id',$task_id)->where('delete_time',0)->where('is_active',1)->find();
|
||||
if(empty($task_info)){
|
||||
return ['code' => 0, 'msg' => '任务不存在或已删除','data' => null];
|
||||
}
|
||||
//胜利场次配置
|
||||
$pk_victory_num = $task_info['ext']??1;
|
||||
$Victory_user_ids_array = explode(',',$Victory_user_ids);
|
||||
$Failure_user_ids_array = explode(',',$Failure_user_ids);
|
||||
$Draw_user_ids_array = explode(',',$Draw_user_ids);
|
||||
if(empty($Draw_user_ids)){
|
||||
$user_ids = array_unique(array_merge($Victory_user_ids_array,$Failure_user_ids_array));
|
||||
}else{
|
||||
$user_ids = array_unique($Draw_user_ids_array);
|
||||
}
|
||||
$insert_data = [];
|
||||
foreach ($user_ids as $user_id) {
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->where('user_id',$user_id)->where('task_id',$task_id)->whereTime('createtime', 'today')->find();
|
||||
Log::record("PK任务完成信息状态".$user_id.":".json_encode($user_daily_tasks),"info");
|
||||
if ($user_daily_tasks && $user_daily_tasks['is_completed'] == 1) {//已完成 不处理
|
||||
continue;
|
||||
}
|
||||
//本次是否获胜
|
||||
$ext = 0;
|
||||
if ($user_daily_tasks) {
|
||||
if(!empty($Victory_user_ids) && in_array($user_id,$Victory_user_ids_array)){
|
||||
//获胜数加1
|
||||
$ext = $user_daily_tasks['ext'] + 1;
|
||||
}else{
|
||||
$ext = $user_daily_tasks['ext'];
|
||||
}
|
||||
$current_progress = $user_daily_tasks['current_progress'] + 1;
|
||||
if($current_progress >= $task_info['target_quantity'] && $ext >= $pk_victory_num){
|
||||
$is_completed = 1;
|
||||
$completion_time = time();
|
||||
}else{
|
||||
$is_completed = 0;
|
||||
$completion_time = null;
|
||||
}
|
||||
if($current_progress > $task_info['target_quantity']){
|
||||
$current_progress = $task_info['target_quantity'];
|
||||
}
|
||||
if($ext > $pk_victory_num){
|
||||
$ext = $pk_victory_num;
|
||||
}
|
||||
$reslut = Db::name('vs_tasks_user_daily')->where('id',$user_daily_tasks['id'])->update([
|
||||
'current_progress' => $current_progress,
|
||||
'is_completed'=> $is_completed,
|
||||
'ext' => $ext,
|
||||
'completion_time' => $completion_time,
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
}else{
|
||||
$current_progress =1;
|
||||
if(!empty($Victory_user_ids) && in_array($user_id,$Victory_user_ids_array)){
|
||||
$ext = 1;
|
||||
}
|
||||
$insert_data[] = [
|
||||
'user_id' => $user_id,
|
||||
'task_id' => $task_id,
|
||||
'current_progress' => $current_progress,
|
||||
'tasks_bag_id' => $task_info['tasks_bag_id'],
|
||||
'is_completed' => 0,
|
||||
'ext' => $ext,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time(),
|
||||
];
|
||||
}
|
||||
}
|
||||
if (!empty($insert_data)) {
|
||||
$reslut = Db::name('vs_tasks_user_daily')->insertAll($insert_data);
|
||||
if ($reslut) {
|
||||
return ['code' => 1, 'msg' => '操作成功','data' => null];
|
||||
} else {
|
||||
return ['code' => 0, 'msg' => '操作失败','data' => null];
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => '操作成功','data' => null];
|
||||
}
|
||||
|
||||
//领取每日任务奖励
|
||||
public function daily_tasks_receive($user_id,$task_id,$student_id = 0){
|
||||
//查询是否实名认证
|
||||
$is_real = model('UserData')->real_name_info($user_id);
|
||||
if($is_real['code']==0){
|
||||
$mobile = db::name('user')->where(['id' => $user_id])->value('mobile');
|
||||
$is_real = db::name('user_auth')->where('mobile' , $mobile)->field('real_name,card_id,is_real,mobile')->find();
|
||||
if(empty($is_real)){
|
||||
return ['code' => 0, 'msg' => '请先实名认证','data' => null];
|
||||
}else{
|
||||
if($is_real['data']['is_real'] !=1){
|
||||
if($is_real['is_real'] !=1){
|
||||
return ['code' => 0, 'msg' => '请先实名认证','data' => null];
|
||||
}else{
|
||||
//查询同一个身份证下的 用户
|
||||
$user_auth_mobile = db::name('user_auth')->where(['card_id'=>$is_real['card_id']])->column('mobile');
|
||||
if(count($user_auth_mobile)>1){
|
||||
$user_ids = db::name('user')->whereIn('mobile',$user_auth_mobile)->column('id');
|
||||
}else{
|
||||
$user_ids = db::name('user')->where('mobile',$is_real['mobile'])->column('id');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
$task_info = Db::name('vs_tasks')->where('id',$task_id)->find();
|
||||
@@ -460,7 +615,11 @@ class Tasks extends Model
|
||||
if($task_info['task_type']==2){
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->where('user_id',$user_id)->where('task_id',$task_id)->whereTime('createtime', 'today')->find();
|
||||
}else{
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->where('user_id',$user_id)->where('task_id',$task_id)->find();
|
||||
if(isset($user_ids) && $task_info['task_type'] == 1 && count($user_ids)>1){
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->whereIn('user_id',$user_ids)->where('task_id',$task_id)->find();
|
||||
}else{
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')->where('user_id',$user_id)->where('task_id',$task_id)->find();
|
||||
}
|
||||
}
|
||||
if (!$user_daily_tasks) {
|
||||
return ['code' => 0, 'msg' => '请完成该任务','data' => null];
|
||||
@@ -471,9 +630,20 @@ class Tasks extends Model
|
||||
if ($user_daily_tasks['is_claimed'] == 1) {
|
||||
return ['code' => 0, 'msg' => '您已领取该奖励','data' => null];
|
||||
}
|
||||
if($user_daily_tasks['user_id'] != $user_id && $task_info['task_type']== 1){
|
||||
return ['code' => 0, 'msg' => '请用您的另一个实名认证账号领取,此账号无权领取','data' => null];
|
||||
}
|
||||
}
|
||||
Db::startTrans();
|
||||
|
||||
// 使用更严格的事务处理,统一加锁顺序
|
||||
$lockKey = 'task_receive_' . $user_id . '_' . $task_id . ($student_id ? '_' . $student_id : '');
|
||||
$lock = cache($lockKey);
|
||||
if ($lock) {
|
||||
return ['code' => 0, 'msg' => '操作过于频繁,请稍后再试','data' => null];
|
||||
}
|
||||
cache($lockKey, 1, 2); // 2秒锁
|
||||
try {
|
||||
Db::startTrans();
|
||||
if($task_id==24){
|
||||
//师徒任务
|
||||
$reslut = Db::name('vs_user_sign_task')->where('id',$user_sign_task['id'])->update([
|
||||
@@ -481,6 +651,7 @@ class Tasks extends Model
|
||||
]);
|
||||
if (!$reslut) {
|
||||
Db::rollback();
|
||||
cache($lockKey, null);
|
||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||
}
|
||||
Db::name('vs_tasks_user_daily')->insert([
|
||||
@@ -529,6 +700,7 @@ class Tasks extends Model
|
||||
]);
|
||||
if (!$reslut) {
|
||||
Db::rollback();
|
||||
cache($lockKey, null);
|
||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
@@ -538,6 +710,7 @@ class Tasks extends Model
|
||||
$op_bag_re = $this->open_tasks_bag($user_id,$task_info['tasks_bag_id']);
|
||||
if ($op_bag_re['code'] != 1) {
|
||||
Db::rollback();
|
||||
cache($lockKey, null);
|
||||
return ['code' => 0, 'msg' => $op_bag_re['msg'], 'data' => null];
|
||||
}
|
||||
}else{
|
||||
@@ -546,15 +719,18 @@ class Tasks extends Model
|
||||
$res = model('common/UserWallet')->change_user_money($user_id, $user_sign_task['value'], model('common/UserWallet')::MONEYTYPEARNINGS, model('common/UserWallet')::SIGN_MASTER_DAILY_RETURN,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::SIGN_MASTER_DAILY_RETURN)." 第".$user_sign_task['times']."天");
|
||||
if ($res['code'] != 1) {
|
||||
Db::rollback();
|
||||
cache($lockKey, null);
|
||||
return ['code' => 0, 'msg' => $res['msg'], 'data' => null];
|
||||
}
|
||||
}
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
cache($lockKey, null);
|
||||
return ['code' => 1, 'msg' => "领取成功", 'data' => null];
|
||||
}catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
cache($lockKey, null);
|
||||
return ['code' => 0, 'msg' => "请重试", 'data' => null];
|
||||
}
|
||||
}
|
||||
@@ -595,11 +771,12 @@ class Tasks extends Model
|
||||
}
|
||||
// 记录日志
|
||||
//添加礼盒记录
|
||||
$reslut = Db::name('vs_gift_bag_receive_log')->insert([
|
||||
$reslut = Db::name('vs_gift_bag_receive_tasks_log')->insert([
|
||||
'user_id' => $user_id,
|
||||
'gift_bag_id' => $gift_box_id,
|
||||
'parent_id' => $v['id'],
|
||||
'gift_id'=> $v['foreign_id'],
|
||||
'type' => $v['type'],
|
||||
'num' => $v['quantity'],
|
||||
'bag_price' => $gift_box_info['money'],
|
||||
'gift_price' => $v['gold'],
|
||||
@@ -768,6 +945,19 @@ class Tasks extends Model
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// 记录日志
|
||||
//添加礼盒记录
|
||||
$reslut = Db::name('vs_gift_bag_receive_tasks_log')->insert([
|
||||
'user_id' => $user_id,
|
||||
'gift_bag_id' => 18,
|
||||
'parent_id' => $v['id'],
|
||||
'gift_id'=> $v['foreign_id'],
|
||||
'type' => $v['type'],
|
||||
'num' => $v['quantity'],
|
||||
'gift_price' => $v['gold'],
|
||||
'createtime' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
}
|
||||
}
|
||||
// 提交事务
|
||||
@@ -905,7 +1095,7 @@ class Tasks extends Model
|
||||
->where(['user_id'=>$user_id,'is_claimed'=>0,'is_completed'=>1])
|
||||
->where('task_id', 'in', $daily_task_ids)
|
||||
->whereTime('createtime', 'today')
|
||||
->count();
|
||||
->count('id');
|
||||
$task_user_count += $daily_task_count;
|
||||
}
|
||||
|
||||
@@ -926,7 +1116,7 @@ class Tasks extends Model
|
||||
$task_user = Db::name('vs_tasks_user_daily')
|
||||
->where(['user_id'=>$user_id,'is_claimed'=>0,'is_completed'=>1])
|
||||
->where('task_id',$v['task_id'])
|
||||
->count();
|
||||
->count('id');
|
||||
}
|
||||
$task_user_count +=$task_user;
|
||||
}
|
||||
|
||||
@@ -15,9 +15,10 @@ class Tencent extends Model
|
||||
//获取腾讯IM UserSig信息
|
||||
//$uid => 用户id
|
||||
public function tencent_user_sig_info($uid){
|
||||
$config = get_system_config();
|
||||
$tencentyun_im_appid = $config['tencentyun_im_appid'];
|
||||
$tencentyun_im_key = $config['tencentyun_im_key'];
|
||||
|
||||
$tencentyun_im_appid = get_system_config_value('tencentyun_im_appid');
|
||||
$tencentyun_im_key = get_system_config_value('tencentyun_im_key');
|
||||
|
||||
$tencent = new Tencentst($tencentyun_im_appid, $tencentyun_im_key);
|
||||
$user_sig = $tencent->genUserSig($uid);
|
||||
|
||||
@@ -189,8 +190,8 @@ class Tencent extends Model
|
||||
//发送群内系统消息
|
||||
public function send_group_system_notification($rid, $message_data){
|
||||
Log::record("腾讯群内系统消息发送结果".json_encode($rid.$message_data),"info");
|
||||
$config = get_system_config();
|
||||
$tencentyun_im_appid = $config['tencentyun_im_appid'];
|
||||
|
||||
$tencentyun_im_appid = get_system_config_value('tencentyun_im_appid');
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
@@ -344,6 +345,7 @@ class Tencent extends Model
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
Log::record("增加群成员".json_encode($reslut),"info");
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
return ['code' => 1, 'msg' => '添加成功', 'data' => null];
|
||||
}else{
|
||||
@@ -403,23 +405,42 @@ class Tencent extends Model
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/openim/sendmsg?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
$curlPost = array(
|
||||
'SyncOtherMachine' => $machine_type,
|
||||
'From_Account' => strval('u'.$uid),
|
||||
'To_Account' => strval('u'.$receive_uid),
|
||||
'MsgRandom' => time(),
|
||||
'MsgBody' => array(
|
||||
array(
|
||||
'MsgType' => 'TIMTextElem',
|
||||
'MsgContent' => array(
|
||||
'Text' => $message,
|
||||
if($uid == 'administrator'){
|
||||
$from_Account ="administrator";
|
||||
$curlPost = array(
|
||||
'SyncOtherMachine' => $machine_type,
|
||||
'From_Account' => strval($from_Account),
|
||||
'To_Account' => strval('u'.$receive_uid),
|
||||
'MsgRandom' => time(),
|
||||
'SendMsgControl' => ["NoUnread", "NoLastMsg", "NoMsgCheck"],
|
||||
'MsgBody' => array(
|
||||
array(
|
||||
'MsgType' => 'TIMCustomElem',
|
||||
'MsgContent' => array(
|
||||
'Data' => $message,
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
}else{
|
||||
$from_Account ="u".$uid;
|
||||
$curlPost = array(
|
||||
'SyncOtherMachine' => $machine_type,
|
||||
'From_Account' => strval($from_Account),
|
||||
'To_Account' => strval('u'.$receive_uid),
|
||||
'MsgRandom' => time(),
|
||||
'MsgBody' => array(
|
||||
array(
|
||||
'MsgType' => 'TIMTextElem',
|
||||
'MsgContent' => array(
|
||||
'Text' => $message,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if($OnlineOnlyFlag == 1){
|
||||
$curlPost['OnlineOnlyFlag'] = 1;
|
||||
}
|
||||
@@ -1081,4 +1102,42 @@ class Tencent extends Model
|
||||
return true;
|
||||
}
|
||||
|
||||
//禁言
|
||||
public function mute_member($rid, $uida, $time=3600){
|
||||
$config = get_system_config();
|
||||
$tencentyun_im_appid = $config['tencentyun_im_appid'];
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
$postUrl = 'https://console.tim.qq.com/v4/live_engine_http_srv/mute_member?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
$curlPost['GroupId'] = $rid;
|
||||
$curlPost['Members_Account'] = $uida;
|
||||
$curlPost['MuteTime'] = $time;
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => $reslut['ErrorCode'], 'data' => null];
|
||||
}
|
||||
}
|
||||
//禁言用户列表
|
||||
public function get_group_mute_list($rid){
|
||||
$config = get_system_config();
|
||||
$tencentyun_im_appid = $config['tencentyun_im_appid'];
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
$postUrl = 'https://console.tim.qq.com/v4/group_open_http_svc/get_group_muted_account?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
$curlPost['GroupId'] = $rid;
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => $reslut['MutedAccountList']];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => $reslut['ErrorCode'], 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -60,9 +60,10 @@ class User extends Model
|
||||
}
|
||||
if(empty($field) || in_array('user_wallet',$field)) {
|
||||
//钱包信息
|
||||
$user_wallet = db::name('user_wallet')->where(['user_id' => $uid])->find();
|
||||
$user_info['coin'] = isset($user_wallet['coin']) ? $user_wallet['coin'] : 0;
|
||||
$user_info['earnings'] = isset($user_wallet['earnings']) ? $user_wallet['earnings'] : 0;
|
||||
$user_wallet_coin = db::name('user_wallet_coin')->where(['user_id' => $uid])->find();
|
||||
$user_wallet_earnings = db::name('user_wallet_earnings')->where(['user_id' => $uid])->find();
|
||||
$user_info['coin'] = isset($user_wallet_coin['coin']) ? $user_wallet_coin['coin'] : 0;
|
||||
$user_info['earnings'] = isset($user_wallet_earnings['earnings']) ? $user_wallet_earnings['earnings'] : 0;
|
||||
}
|
||||
if(empty($field) || in_array('user_decorate',$field)) {
|
||||
//装扮
|
||||
@@ -470,60 +471,50 @@ class User extends Model
|
||||
public function get_user_gift_wall_info($uid)
|
||||
{
|
||||
//查询用户礼物墙 以gift_id,send_user_id分组 同一用户送的同一礼物相加
|
||||
$result = db::name('vs_give_gift')->alias('a')
|
||||
$result = db::name('user_gift_wall')->alias('a')
|
||||
->join('vs_gift g', 'a.gift_id = g.gid')
|
||||
->where(['a.gift_user' => $uid,'g.label'=>['<>',2]])
|
||||
->field('a.gift_id,a.user_id,sum(a.number) as total')
|
||||
->group('a.gift_id,a.user_id')
|
||||
->order('total desc')
|
||||
->where(['a.user_id' => $uid, 'g.label' => ['not in', [2, 16]],'a.gift_id' => ['<>', 0]])
|
||||
->field('a.gift_id,a.user_id,a.count,a.give_user_ids,g.gift_name,g.gift_price,g.base_image')
|
||||
->order('count desc')
|
||||
->select();
|
||||
// var_dump($result);exit;
|
||||
// 根据礼物二次分组 获取礼物的总数和送的数量最多的三用户
|
||||
$data = [];
|
||||
// 按 gift_id 聚合数据
|
||||
foreach ($result as $item) {
|
||||
$giftId = $item['gift_id'];
|
||||
$sendUserId = $item['user_id'];
|
||||
$sendUserNickname = db::name('user')->where(['id' => $sendUserId])->value('nickname');
|
||||
$sendUserAvatar = db::name('user')->where(['id' => $sendUserId])->value('avatar');
|
||||
$total = $item['total'];
|
||||
|
||||
if (!isset($data[$giftId])) {
|
||||
$data[$giftId] = [
|
||||
'gift_id' => $giftId,
|
||||
'gift_price' => model('Gift')->where(['gid' => $giftId])->value('gift_price'),
|
||||
'gift_name' => model('Gift')->where(['gid' => $giftId])->value('gift_name'),
|
||||
'base_image' => model('Gift')->where(['gid' => $giftId])->value('base_image'),
|
||||
'total_count' => 0,
|
||||
'top_users' => []
|
||||
$data = [];
|
||||
|
||||
if($result){
|
||||
foreach ($result as $item){
|
||||
$userInfo = [];
|
||||
$top_users_count = 0;
|
||||
$users = json_decode($item['give_user_ids'], true);
|
||||
if($users){
|
||||
foreach ($users as $kk => $user_id){
|
||||
$userInfo[$kk] = db::name('user')->where(['id' => $user_id['user_id']])->field('id user_id,nickname,avatar')->find();
|
||||
$userInfo[$kk]['count'] = $user_id['count'];
|
||||
$top_users_count ++;
|
||||
}
|
||||
//用户信息$userInfo 按照数量 count 排序且保留前三个
|
||||
usort($userInfo, function ($a, $b) {
|
||||
return $b['count'] - $a['count'];
|
||||
});
|
||||
$userInfo = array_slice($userInfo, 0, 3);
|
||||
}
|
||||
|
||||
$data[] = [
|
||||
'top_users_count' => $top_users_count,//送礼人数
|
||||
'gift_id' => $item['gift_id'],
|
||||
'gift_name' => $item['gift_name'],
|
||||
'gift_price' => $item['gift_price'],
|
||||
'base_image' => $item['base_image'],
|
||||
'total_count' => $item['count'],//总数量
|
||||
'top_users' => $userInfo
|
||||
];
|
||||
}
|
||||
|
||||
// 累加总数量
|
||||
$data[$giftId]['total_count'] += $total;
|
||||
|
||||
// 存储用户赠送记录
|
||||
$data[$giftId]['top_users'][] = [
|
||||
'user_id' => $sendUserId,
|
||||
'nickname' => $sendUserNickname,
|
||||
'avatar' => $sendUserAvatar,
|
||||
'count' => $total
|
||||
];
|
||||
}
|
||||
|
||||
// 对每个礼物的 top_users 排序并取前三名
|
||||
foreach ($data as &$giftData) {
|
||||
// 按 count 降序排序
|
||||
usort($giftData['top_users'], function ($a, $b) {
|
||||
return $b['count'] <=> $a['count'];
|
||||
});
|
||||
$giftData['top_users_count'] = count($giftData['top_users']);
|
||||
// 取前3位
|
||||
$giftData['top_users'] = array_slice($giftData['top_users'], 0, 3);
|
||||
}
|
||||
$data = array_values($data);
|
||||
//查询所有的礼物
|
||||
$gift_list = db::name('vs_gift')->field('gid as gift_id,gift_name,base_image,gift_price')->where(['delete_time' => 0,'label'=>['<>',2]])->select();
|
||||
$gift_list = db::name('vs_gift')
|
||||
->field('gid as gift_id,gift_name,base_image,gift_price')
|
||||
->where(['delete_time' => 0,'label'=>['not in', [2, 16]]])
|
||||
->select();
|
||||
//对比去除$data 里面的礼物
|
||||
$gift_list = array_filter((array)$gift_list, function ($item) use ($data) {
|
||||
return !in_array($item['gift_id'], array_column($data, 'gift_id'));
|
||||
@@ -535,6 +526,28 @@ class User extends Model
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $redata];
|
||||
}
|
||||
|
||||
|
||||
//礼物墙用户列表
|
||||
public function gift_wall_user_list($uid, $gift_id){
|
||||
$result = db::name('user_gift_wall')
|
||||
->where(['user_id' => $uid,'gift_id' => $gift_id])
|
||||
->field('give_user_ids,count')->find();
|
||||
$user = [];
|
||||
$count = $result['count'];
|
||||
if($result){
|
||||
$user_list = json_decode($result['give_user_ids'], true);
|
||||
if($user_list){
|
||||
foreach ($user_list as $kk => $user_id){
|
||||
$user[$kk] = db::name('user')->where(['id' => $user_id['user_id']])->field('id user_id,nickname,avatar')->find();
|
||||
$user[$kk]['count'] = $user_id['count'];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => ['count' => $count, 'users' =>$user]];
|
||||
}
|
||||
|
||||
|
||||
//添加用户访问记录
|
||||
/*
|
||||
* @param $to_id 被访问对象id
|
||||
@@ -662,11 +675,7 @@ class User extends Model
|
||||
//循环插入数据库
|
||||
db::name('user_album_image')->insert($data);
|
||||
}
|
||||
//首次创建相册并上传9张照片【完成任务】
|
||||
$user_album_image_count = db::name('user_album_image')->where('album_id',$album_id)->count();
|
||||
if($user_album_image_count >= 9){
|
||||
model('DailyTasks')->tasks_complete($user_id,14);
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => '添加成功', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => '图片不能为空', 'data' => null];
|
||||
@@ -849,6 +858,7 @@ class User extends Model
|
||||
}
|
||||
}
|
||||
db::commit();
|
||||
Cache::rm('user_base_info_'.$user_id);
|
||||
//推送信息去所在房间
|
||||
//查询当前所在房间
|
||||
$room_id = db::name('vs_room_visitor')->where(['user_id' => $user_id])->order('id' , 'desc')->value('room_id');
|
||||
@@ -868,7 +878,7 @@ class User extends Model
|
||||
$member_name = db::name('user')->where('id' , $user_id)->value('nickname');
|
||||
$member_face_url = db::name('user')->where('id' , $user_id)->value('avatar');
|
||||
model('Tencent')->modify_user_infos($user_id, $member_name, $member_face_url);
|
||||
Cache::rm('user_base_info_'.$user_id);
|
||||
|
||||
return ['code' => 1, 'msg' => '修改成功', 'data' => null];
|
||||
}
|
||||
catch(\Exception $e){
|
||||
|
||||
@@ -33,8 +33,11 @@ class UserCp extends Model
|
||||
return 0;
|
||||
}
|
||||
//查询收礼人有没有给送礼人送过cp礼物 status:0-待回应,1-建交成功,2-已取消
|
||||
$res = Db::name('user_cp_find')->where(['from_user_id' => $to_user_id, 'to_user_id' => $from_user_id,'status' => 0])->find();
|
||||
if($res){
|
||||
$res = Db::name('user_cp_find')
|
||||
->where(['from_user_id' => $to_user_id, 'to_user_id' => $from_user_id,'status' => 0])
|
||||
->find();
|
||||
|
||||
if($res && $res['createtime'] + 86400 < time()){//24小时内
|
||||
//创建推送信息1:回应送礼 并创建Cp空间,
|
||||
$data = [
|
||||
'from_user_id' => $from_user_id,
|
||||
@@ -288,13 +291,14 @@ class UserCp extends Model
|
||||
* @param $gift_id 礼物ID
|
||||
* @param $room_id 房间ID
|
||||
* @param $cp_zone_id Cp空间ID
|
||||
* @param $gift_price 收礼总金币
|
||||
*/
|
||||
public function addCpLevel($from_user_id, $to_user_id, $room_id, $gift_id, $cp_zone_id, $num,$gift_price)
|
||||
{
|
||||
$jinbi_arr = explode(',', get_system_config_value('cp_exp_rate'));
|
||||
$jinbi = $jinbi_arr[0];
|
||||
$jinyan = $jinbi_arr[1];
|
||||
$exp = round($gift_price * $num / $jinbi * $jinyan, 2);
|
||||
$exp = round($gift_price / $jinbi * $jinyan, 2);
|
||||
$yuan_exp = Db::name('user_cp_zone')->where(['id' => $cp_zone_id])->value('exp');
|
||||
$zone_level = Db::name('user_cp_zone')->where(['id' => $cp_zone_id])->value('level');
|
||||
$toUserNickname =db::name('user')->where(['id' => $to_user_id])->value('nickname')??'未知用户';
|
||||
@@ -314,8 +318,12 @@ class UserCp extends Model
|
||||
];
|
||||
Db::name('user_cp_gift_log')->insert($datas);
|
||||
//判断是否升级
|
||||
$level = Db::name('user_cp_level')->where(['change_value' => ['<=', $yuan_exp + $exp],'deletetime' => 0])
|
||||
->order('change_value desc')->field('level,pendant_id,rights_icon_id')->find();
|
||||
$xianzhi = $yuan_exp + $exp;
|
||||
$level = Db::name('user_cp_level')
|
||||
->field('level,pendant_id,rights_icon_id')
|
||||
->where(['change_value' => ['<=', $xianzhi],'deletetime' => 0])
|
||||
->order('change_value desc')
|
||||
->find();
|
||||
if($level['level'] != $zone_level){//登记不一致 (升级)
|
||||
//修改Cp空间等级
|
||||
$data['level'] = $level['level'];
|
||||
|
||||
98
application/api/model/UserDailyIncome.php
Normal file
98
application/api/model/UserDailyIncome.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class UserDailyIncome extends Model
|
||||
{
|
||||
// 定义表名(如果表名和模型名一致可省略,这里显式定义更清晰)
|
||||
protected $name = 'user_daily_income';
|
||||
|
||||
// 开启自动时间戳(TP5.1默认用时间戳格式,对应create_time/update_time)
|
||||
protected $autoWriteTimestamp = true;
|
||||
|
||||
// 定义字段类型转换(确保金额为浮点型)
|
||||
protected $type = [
|
||||
'income' => 'float',
|
||||
'user_id' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* 累加用户当日收益(核心方法)
|
||||
* @param int $userId 用户ID
|
||||
* @param float $amount 新增收益金额(正数)
|
||||
* @return bool
|
||||
*/
|
||||
public function addDailyIncome($userId, $amount)
|
||||
{
|
||||
$today = date('Y-m-d'); // 今日日期
|
||||
|
||||
$today_res = $this->where([
|
||||
'user_id' => $userId,
|
||||
'date' => $today
|
||||
])->find();
|
||||
if($today_res){
|
||||
$res = $this->where([
|
||||
'user_id' => $userId,
|
||||
'date' => $today
|
||||
])->update([
|
||||
'income' => $amount,
|
||||
'update_time'=> time(),
|
||||
]);
|
||||
if($res){return true;}
|
||||
}else{
|
||||
$res = $this->insert([
|
||||
'user_id' => $userId,
|
||||
'income' => $amount,
|
||||
'date' => $today,
|
||||
'create_time'=> time(),
|
||||
'update_time'=> time(),
|
||||
]);
|
||||
if($res){return true;}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户今日收益
|
||||
* @param int $userId 用户ID
|
||||
* @param string $today 日期(格式:YYYY-MM-DD)
|
||||
* @return float 今日收益(无收益则返回0)
|
||||
*/
|
||||
public function getTodayIncome($userId, $today = 0)
|
||||
{
|
||||
if (!$today) {
|
||||
$today = date('Y-m-d');
|
||||
}
|
||||
$result = $this->where([
|
||||
'user_id' => $userId,
|
||||
'date' => $today
|
||||
])->value('income');
|
||||
|
||||
return $result ? floatval($result) : 0.00;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户时间段内的收益总和
|
||||
* @param int $userId 用户ID
|
||||
* @param string $startDate 开始日期(格式:YYYY-MM-DD)
|
||||
* @param string $endDate 结束日期(格式:YYYY-MM-DD)
|
||||
* @return float 时间段总收益(无收益则返回0)
|
||||
*/
|
||||
public function getIncomeByPeriod($userId, $startDate, $endDate)
|
||||
{
|
||||
// 校验日期格式(可选,增强健壮性)
|
||||
if (!strtotime($startDate) || !strtotime($endDate)) {
|
||||
return 0.00;
|
||||
}
|
||||
|
||||
$total = $this->where([
|
||||
'user_id' => $userId,
|
||||
'date' => ['between', [$startDate, $endDate]]
|
||||
])->sum('income');
|
||||
|
||||
return $total ? floatval($total) : 0.00;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -91,13 +91,13 @@ class UserData extends Model
|
||||
|
||||
$reslut = model('User')->update($data);
|
||||
if ($reslut) {
|
||||
$cache_key = 'user_base_info_'.$uid;
|
||||
Cache::rm($cache_key);
|
||||
$user_info = model('User')->where('id', $uid)->field('id,nickname,avatar,user_code')->find();
|
||||
//给腾讯同步用户信息
|
||||
$member_name = $user_info['nickname'];
|
||||
$member_face_url = $user_info['avatar'];
|
||||
model('Tencent')->modify_user_infos($uid, $member_name, $member_face_url);
|
||||
$cache_key = 'user_base_info_'.$uid;
|
||||
Cache::rm($cache_key);
|
||||
return ['code' => 1, 'msg' => '修改成功', 'data' => $user_info];
|
||||
} else {
|
||||
return ['code' => 0, 'msg' => '修改失败,','data' =>null];
|
||||
@@ -283,7 +283,10 @@ class UserData extends Model
|
||||
}else{
|
||||
$is_real = false;
|
||||
}
|
||||
|
||||
$mobile_count = db::name('user')->where(['mobile' => $new_mobile,'status'=>1])->count('id');
|
||||
if($mobile_count>=2){
|
||||
return ['code' => 0, 'msg' => '该手机号已存在两个以上的账号!请使用其他手机号!','data' =>null];
|
||||
}
|
||||
if($is_real){
|
||||
//开启事务
|
||||
db::startTrans();
|
||||
@@ -314,9 +317,14 @@ class UserData extends Model
|
||||
return ['code' => 0, 'msg' => '请先绑定手机号','data' =>null];
|
||||
}
|
||||
$card_id_count = db::name('user_auth')->where(['card_id' => $id_card,'is_real' => 1])->count();
|
||||
if($card_id_count >= 3){
|
||||
if($card_id_count >= 2){
|
||||
return ['code' => 0, 'msg' => '该身份证实名已达上限!','data' =>null];
|
||||
}
|
||||
$mobile_count = db::name('user')->where(['mobile' => $user_mobile,'status'=>1])->count('id');
|
||||
$user_auth_count = db::name('user_auth')->where(['mobile' => $user_mobile,'is_real' => 1])->count();
|
||||
if($mobile_count >= 2 && $user_auth_count > 0){
|
||||
return ['code' => 0, 'msg' => '该手机号已绑定多个账号!请勿重复注册!','data' =>null];
|
||||
}
|
||||
//查询是否已经提交过数据了
|
||||
$is_real = db::name('user_auth')->where(['card_id' => $id_card,'mobile' =>$user_mobile])->find();
|
||||
if($is_real){
|
||||
@@ -408,6 +416,7 @@ class UserData extends Model
|
||||
}
|
||||
//任务:3-实名认证
|
||||
model('Tasks')->tasks_complete($user_id,3);
|
||||
Cache::rm('user_base_info_'.$user_id);
|
||||
|
||||
return ['code' => 1, 'msg' => '实名成功','data' =>null];
|
||||
}
|
||||
@@ -415,7 +424,7 @@ class UserData extends Model
|
||||
//实名认证后的信息
|
||||
public function real_name_info($user_id)
|
||||
{
|
||||
$mobile = db::name('user')->where(['id' => $user_id,'status'=>1])->value('mobile');
|
||||
$mobile = db::name('user')->where(['id' => $user_id])->value('mobile');
|
||||
$data = db::name('user_auth')->where('mobile' , $mobile)->field('real_name,card_id,is_real,mobile')->find();
|
||||
if(!$data){
|
||||
return ['code' => 0, 'msg' => '未实名','data' =>null];
|
||||
@@ -471,14 +480,14 @@ class UserData extends Model
|
||||
->select();
|
||||
if($list){
|
||||
foreach($list as &$item){
|
||||
if($item['is_show_room'] == 2){ //是否显示房间 1是2否
|
||||
//查询当前房间是否有主持在麦上
|
||||
$room_host_info = db::name('vs_room_pit')->where(['room_id' => $item['room_id'], 'pit_number' => 9])->value('user_id');
|
||||
if($room_host_info == 0){
|
||||
unset($list[$item]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// if($item['is_show_room'] == 2){ //是否显示房间 1是2否
|
||||
// //查询当前房间是否有主持在麦上
|
||||
// $room_host_info = db::name('vs_room_pit')->where(['room_id' => $item['room_id'], 'pit_number' => 9])->value('user_id');
|
||||
// if($room_host_info == 0){
|
||||
// unset($list[$item]);
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
$item['label_icon'] = db::name('vs_room_label')->where('id',$item['label_id'])->value('label_icon');
|
||||
//获取房间用户总数
|
||||
$item['user_count'] = db::name('vs_room_visitor')->where('room_id',$item['room_id'])->count();
|
||||
@@ -583,17 +592,18 @@ class UserData extends Model
|
||||
public function bind_xinxi($user_id,$type,$alipay_account,$bank_card_number,$bank_user_name,$bank_card,$open_bank)
|
||||
{
|
||||
//查询是否实名认证
|
||||
$is_real = model('UserData')->real_name_info($user_id);
|
||||
if($is_real['code']==0){
|
||||
$mobile = db::name('user')->where(['id' => $user_id])->value('mobile');
|
||||
$is_real = db::name('user_auth')->where('mobile' , $mobile)->field('real_name,card_id,is_real,mobile')->find();
|
||||
if(empty($is_real)){
|
||||
return ['code' => 0, 'msg' => '请先实名认证','data' => null];
|
||||
}else{
|
||||
if($is_real['data']['is_real'] !=1){
|
||||
return ['code' => 0, 'msg' => '请先实名认证','data' => null];
|
||||
}else {
|
||||
if ($is_real['is_real'] != 1) {
|
||||
return ['code' => 0, 'msg' => '请先实名认证', 'data' => null];
|
||||
}
|
||||
}
|
||||
if($type == 2){
|
||||
$data = [
|
||||
'alipay_name' => $is_real['data']['real_name'],// 姓名
|
||||
'alipay_name' => $is_real['real_name'],// 姓名
|
||||
'alipay_account' => $alipay_account,// 支付宝账号
|
||||
];
|
||||
$reslut = db::name('user_data')->where('user_id',$user_id)->update($data);
|
||||
@@ -617,7 +627,7 @@ class UserData extends Model
|
||||
}
|
||||
$data = [
|
||||
'bank_card_number' => $bank_card_number,
|
||||
'bank_user_name' => $bank_user_name ? $bank_user_name : $is_real['data']['real_name'],
|
||||
'bank_user_name' => $bank_user_name ? $bank_user_name : $is_real['real_name'],
|
||||
'bank_card' => $bank_card,
|
||||
'open_bank' => $open_bank,
|
||||
];
|
||||
@@ -646,20 +656,15 @@ class UserData extends Model
|
||||
{
|
||||
$data = null;
|
||||
if($type == 2){
|
||||
$data = db::name('user_data')->where('user_id',$user_id)->field('id,alipay_name,alipay_account')->find();
|
||||
$data = db::name('user_data')->where('user_id',$user_id)->field('id,bank_card_number,alipay_name,alipay_account,bank_user_name,bank_card,open_bank')->find();
|
||||
}
|
||||
if($type == 3){
|
||||
$data = db::name('user_data')->where('user_id',$user_id)->field('id,bank_card_number,bank_user_name,bank_card,open_bank')->find();
|
||||
$data = db::name('user_data')->where('user_id',$user_id)->field('id,bank_card_number,alipay_name,alipay_account,bank_user_name,bank_card,open_bank')->find();
|
||||
}
|
||||
if($data['bank_card_number']==0){
|
||||
$data['bank_card_number'] = '';
|
||||
}
|
||||
if($data['bank_card']==0){
|
||||
$data['bank_card'] = '';
|
||||
}
|
||||
if($data['open_bank']==0){
|
||||
$data['open_bank'] = '';
|
||||
}
|
||||
|
||||
|
||||
return ['code' => 1, 'msg' => '获取成功','data' =>$data];
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ class UserGiftPack extends Model
|
||||
const DAILY_SIGN = 12;
|
||||
//盲盒转盘抽奖所得
|
||||
const BLANK_BOX_DRAW_GIFT_GET = 13;
|
||||
//炼仙传说中奖获取
|
||||
const LY_DRAW_GIFT_GET = 14;
|
||||
|
||||
public static function init()
|
||||
{
|
||||
@@ -66,7 +68,8 @@ class UserGiftPack extends Model
|
||||
self::NEW_CHARGE_GIFT => '新人充值好礼',
|
||||
self::TASK_REWARD => '任务奖励',
|
||||
self::DAILY_SIGN => '每日签到',
|
||||
self::BLANK_BOX_DRAW_GIFT_GET => '盲盒转盘抽奖所得'
|
||||
self::BLANK_BOX_DRAW_GIFT_GET => '盲盒转盘抽奖所得',
|
||||
self::LY_DRAW_GIFT_GET => '炼仙传说中奖获取'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ class UserMessage extends Model
|
||||
$system_message1 = db::name('system_message')
|
||||
->field('id')
|
||||
->where($map)
|
||||
->where(['delete_time' => 0])
|
||||
->where('FIND_IN_SET(:user_id, receiving_id)', ['user_id' => $uid])
|
||||
->select();
|
||||
|
||||
@@ -142,6 +143,7 @@ class UserMessage extends Model
|
||||
|
||||
//获取消息
|
||||
$list = db::name('system_message')
|
||||
->field('id,type,title,content,url,admin_id,image,createtime,room_id,user_id,remind_type,status,updatetime')
|
||||
->where($where)
|
||||
->where('FIND_IN_SET(:user_id, receiving_id)', ['user_id' => $uid])
|
||||
->order('id desc')
|
||||
|
||||
@@ -23,17 +23,17 @@ class UserToken extends Model
|
||||
$block1 = db::name('block')->where(['type' => 1,'type_text' => $user_token['user_id']])->find();
|
||||
$userState = db::name('user')->where(['id' => $user_token['user_id']])->value('status');
|
||||
if(isset($block1) || $userState == 2){
|
||||
return ['code' => 204, 'msg'=> '账号已被封禁,请联系管理员','data' => null];
|
||||
return ['code' => 301, 'msg'=> '账号已被封禁,请联系管理员','data' => null];
|
||||
}
|
||||
$login_device = request()->header('deviceId');
|
||||
$block2 = db::name('block')->where(['type' => 2,'type_text' => $login_device])->find();
|
||||
if(isset($block2)){
|
||||
return ['code' => 205, 'msg'=> '设备已被封禁,请联系管理员','data' => null];
|
||||
return ['code' => 301, 'msg'=> '设备已被封禁,请联系管理员','data' => null];
|
||||
}
|
||||
$Ip = request()->ip();
|
||||
$block3 = db::name('block')->where(['type' => 3,'type_text' => $Ip])->find();
|
||||
if(isset($block3)){
|
||||
return ['code' => 206, 'msg'=> 'IP已被封禁,请联系管理员','data' => null];
|
||||
return ['code' => 301, 'msg'=> 'IP已被封禁,请联系管理员','data' => null];
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg'=> '成功','data' => $user_token['user_id']];
|
||||
@@ -82,6 +82,16 @@ class UserToken extends Model
|
||||
return ['code' => 0, 'msg'=> 'token更新失败'];
|
||||
}
|
||||
}else{
|
||||
//查询有多少个信息
|
||||
$user_token = db::name('user_token')->where('user_id', $user_id)->select();
|
||||
if(count($user_token) > 1){
|
||||
//删除多余的token
|
||||
foreach ($user_token as $key => $value) {
|
||||
if($value['id'] != $data_token['id']){
|
||||
$this->where('id', $value['id'])->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!($this->where('user_id', $user_id)->update(['token' => $tokenString, 'expiretime' => $expiretime]))){
|
||||
return ['code' => 0, 'msg'=> 'token更新失败'];
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Cache;
|
||||
use think\Db;
|
||||
use think\Log;
|
||||
use think\Model;
|
||||
use Yzh\YunPay;
|
||||
|
||||
@@ -11,8 +13,14 @@ class UserWallet extends Model
|
||||
{
|
||||
public function create_data($uid)
|
||||
{
|
||||
$insert_data = ['user_id' => $uid];
|
||||
return Db::name('user_wallet')->insert($insert_data);
|
||||
$insert_data = ['user_id' => $uid, 'createtime' => time()];
|
||||
$coin = Db::name('user_wallet_coin')->insert($insert_data);
|
||||
$earnings = Db::name('user_wallet_earnings')->insert($insert_data);
|
||||
if($coin && $earnings){
|
||||
return true ;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//钱包
|
||||
@@ -21,8 +29,8 @@ class UserWallet extends Model
|
||||
if(!isset($uid)){
|
||||
return ['code' => 301, 'msg' => '登录失效,请重新登录!', 'data' => null];
|
||||
}
|
||||
|
||||
$user_info = db::name('user_wallet')->where('user_id', $uid)->find();
|
||||
$user_info['coin'] = db::name('user_wallet_coin')->where('user_id', $uid)->sum('coin');
|
||||
$user_info['earnings'] = db::name('user_wallet_earnings')->where('user_id', $uid)->sum('earnings');
|
||||
//获取云账号签约协议
|
||||
$yun_pay = new YunPay();
|
||||
$yun_pay_agreement = $yun_pay->getAgreementPreviewUrl();
|
||||
@@ -40,52 +48,64 @@ class UserWallet extends Model
|
||||
}
|
||||
|
||||
//金币/钻石 明细
|
||||
public function log_list($uid, $page, $page_limit,$in_out_type,$start_time,$end_time,$gift_type)
|
||||
//change_type
|
||||
// 1.系统调节 2.充值 3.提现 4.金币转增(送出) 5.每日任务奖励 6.充值返利 7.购买装扮
|
||||
// 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换
|
||||
// 15.首充 16.天降好礼充值 17.退出工会扣款 18.房主收益 19.主持人收益 20.抢头条 21.公会长收益,22.提现驳回或提现失败返还,23.财富等级奖励金币领取,24.删除关系扣金币,
|
||||
// 25.赠送好友金币,26.好友转赠所得金币,27.小时榜获得金币,28.新人充值好礼,29.发红包(钻石),30.抢红包(金币),31.抢红包(钻石),32.发红包(金币),
|
||||
// 33.红包剩余退回(金币),34-红包剩余退回(钻石),35-爵位购买赠送金币(金币),40-后台充值金币,41-后台充值钻石,42-后台扣除金币,43-后台扣除钻石,
|
||||
//50-签约,51-签约失败退回,52-首次被签约收入,53.签约师傅每日返还,54-叛徒补偿,55-徒弟收礼返佣,56-续约,57-签到,58-爆币,59-红包手续费 60-炼仙传说抽奖扣除金币
|
||||
public function log_list($uid, $last_id, $page_limit,$in_out_type,$start_time,$end_time,$gift_type)
|
||||
{
|
||||
$page = intval($page);
|
||||
$page_limit = $page_limit < 30 ? $page_limit : 30;
|
||||
$map = [];
|
||||
$map['money_type'] = $gift_type;//1金币,2收益(钻石)
|
||||
$in_out_types = [];
|
||||
// 1.系统调节 2.充值 3.提现 4.金币转增(送出) 5.每日任务奖励 6.充值返利 7.购买装扮
|
||||
// 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换
|
||||
// 15.首充 16.天降好礼充值 17.退出工会扣款 18.房主收益 19.主持人收益,20.发布头条扣除余额,21.公会长收益,22.提现驳回或提现失败返还,23.财富等级奖励金币领取,24.删除关系扣金币
|
||||
//27.小时榜获得,28-新人充值好礼,32-发红包(金币),29-发红包(钻石),30-抢红包(金币),31-抢红包(钻石) 33-红包剩余退回(金币),34-红包剩余退回(钻石)
|
||||
//50-签约 51-签约失败退回,52-首次被签约收入 53-师徒签到 54-叛徒补偿,55-徒弟收礼返佣,56-续约,57签到,58爆币
|
||||
if($gift_type == 1){ //1金币,2收益(钻石)
|
||||
if($in_out_type == 1){//1收入
|
||||
$in_out_types = [2,5,6,8,13,14,15,16,22,23,26,27,30,28,33,51,57,58];
|
||||
}elseif($in_out_type == 2){//2支出
|
||||
$in_out_types = [4,7,10,17,20,24,25,32,50,56];
|
||||
}
|
||||
}elseif($gift_type == 2){ //1金币,2收益(钻石)
|
||||
if($in_out_type == 1){//1收入
|
||||
$in_out_types = [6,9,11,12,18,19,21,22,31,28,34,52,53,54,55,57];
|
||||
}elseif($in_out_type == 2){//2支出
|
||||
$in_out_types = [3,14,29];
|
||||
}
|
||||
}
|
||||
|
||||
$map['change_type'] = ['in', $in_out_types];
|
||||
$map['user_id'] =$uid;
|
||||
|
||||
// 时间范围处理
|
||||
if (!empty($start_time) && !empty($end_time)) {
|
||||
$start_time = strtotime($start_time);
|
||||
$end_time = strtotime($end_time.' 23:59:59');
|
||||
$end_time = strtotime($end_time);
|
||||
$map['createtime'] = ['between', [$start_time, $end_time]];
|
||||
}
|
||||
|
||||
$list = Db::name('vs_user_money_log')
|
||||
->where($map)
|
||||
->field('log_id, user_id, change_type, change_value, remarks, createtime')
|
||||
->order('log_id desc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
foreach ($list as $key => &$value) {
|
||||
$value['change_type_name'] = model('common/UserWallet')->ChangeTypeLable($value['change_type']);
|
||||
if($in_out_type==2){
|
||||
$value['change_value'] = $value['change_value'] * -1;
|
||||
$map['user_id'] =$uid;
|
||||
if ($last_id > 0) {
|
||||
$map['id'] = ['<', $last_id]; // 下一页:只查id小于上一页最后一个id的记录
|
||||
}
|
||||
|
||||
//1-金币
|
||||
if($gift_type == 1){
|
||||
//1-收入
|
||||
if($in_out_type == 1){
|
||||
$in_out_types = [2,5,6,8,13,14,15,16,22,23,26,27,30,28,33,40,44,51,57,58];
|
||||
$map['change_type'] = ['in', $in_out_types];
|
||||
}else{//2-支出
|
||||
$in_out_types = [4,7,10,17,20,24,25,32,42,50,56,59,60];
|
||||
$map['change_type'] = ['in', $in_out_types];
|
||||
}
|
||||
|
||||
$list = Db::name('user_coin_log')
|
||||
->where($map)
|
||||
->field('id,change_type, coin as change_value, remarks, createtime')
|
||||
->order('id desc')
|
||||
->limit($page_limit) // 只取指定条数,无offset
|
||||
->select();
|
||||
foreach ($list as &$value) {
|
||||
$value['change_type_name'] = model('common/UserWallet')->ChangeTypeLable($value['change_type']);
|
||||
}
|
||||
}else{//-2收益(钻石)
|
||||
//1-收入
|
||||
if($in_out_type == 1){
|
||||
$in_out_types = [9,11,12,18,19,21,22,31,28,34,41,52,53,54,55,57];
|
||||
$map['change_type'] = ['in', $in_out_types];
|
||||
}else{//2-支出
|
||||
$in_out_types = [3,14,29,43];
|
||||
$map['change_type'] = ['in', $in_out_types];
|
||||
}
|
||||
$list = Db::name('user_earnings_log')
|
||||
->where($map)
|
||||
->field('id,change_type, earnings as change_value, remarks, createtime')
|
||||
->order('id desc')
|
||||
->limit($page_limit) // 只取指定条数,无offset
|
||||
->select();
|
||||
foreach ($list as &$value) {
|
||||
$value['change_type_name'] = model('common/UserWallet')->ChangeTypeLable($value['change_type']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,6 +115,13 @@ class UserWallet extends Model
|
||||
//收益(钻石)兑换金币
|
||||
public function exchange_coin($uid, $earnings_num)
|
||||
{
|
||||
//从缓存中获取
|
||||
$exchange_user = Cache::get('exchange_user_' . $uid);
|
||||
if($exchange_user){
|
||||
return ['code' => 0, 'msg' => '手速太快了', 'data' => null];
|
||||
}else{
|
||||
Cache::set('exchange_user_' . $uid, 1, 5);
|
||||
}
|
||||
if(empty($earnings_num)){
|
||||
return ['code' => 0, 'msg' => '请输入需要兑换的钻石数量', 'data' => null];
|
||||
}
|
||||
@@ -103,12 +130,14 @@ class UserWallet extends Model
|
||||
return ['code' => 0, 'msg' => '请输入正确的钻石数量', 'data' => null];
|
||||
}
|
||||
//判断用户的钻石数量是否大于等于兑换数量
|
||||
$user_info = db::name('user_wallet')->where('user_id',$uid)->find();
|
||||
$user_info = db::name('user_wallet_earnings')->where('user_id',$uid)->find();
|
||||
if($user_info['earnings'] < $earnings_num){
|
||||
return ['code' => 0, 'msg' => '钻石数量不足', 'data' => null];
|
||||
}
|
||||
|
||||
$ear_exchange_coin = get_system_config_value('coin_exchange_rate');
|
||||
$coin_num = $earnings_num * $ear_exchange_coin;
|
||||
|
||||
$data = [
|
||||
'user_id' => $uid,
|
||||
'earnings_num' => $earnings_num,
|
||||
@@ -119,30 +148,9 @@ class UserWallet extends Model
|
||||
db::startTrans();
|
||||
try{
|
||||
$give_gift_id = db::name('user_exchange')->insertGetId($data);
|
||||
// 1.系统调节 2.充值 3.提现 4.金币转增(送出) 5.每日任务奖励 6.充值返利 7.购买装扮
|
||||
// 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换
|
||||
$account_log[] = [
|
||||
'user_id' => $uid,
|
||||
'money_type' => 2,//1金币2钻石
|
||||
'change_value' => $earnings_num,
|
||||
'remarks' => '收益兑换',
|
||||
'change_type' => 14,
|
||||
'createtime' => time(),
|
||||
'from_id' => $give_gift_id,
|
||||
];
|
||||
$account_log[] = [
|
||||
'user_id' => $uid,
|
||||
'money_type' => 1,
|
||||
'change_value' => $earnings_num * $ear_exchange_coin,
|
||||
'remarks' => '收益兑换',
|
||||
'change_type' => 14,
|
||||
'createtime' => time(),
|
||||
'from_id' => $give_gift_id,
|
||||
];
|
||||
$re = db::name('vs_user_money_log')->insertAll($account_log);
|
||||
$re1 = db::name('user_wallet')->where(['user_id' => $uid,'earnings' => ['>=', $earnings_num]])->setDec('earnings',$earnings_num);
|
||||
$re2 = db::name('user_wallet')->where('user_id',$uid)->setInc('coin',$earnings_num * $ear_exchange_coin);
|
||||
if($re && $re1 && $re2){
|
||||
$earn = $this->change_user_earnings_log($uid,$earnings_num,0,14,'收益兑换');
|
||||
$coin = $this->change_user_cion_log($uid,$coin_num,0,14,'收益兑换');
|
||||
if($earn === true && $coin === true){
|
||||
db::commit();
|
||||
return ['code' => 1, 'msg' => '兑换成功', 'data' => null];
|
||||
}else{
|
||||
@@ -153,19 +161,24 @@ class UserWallet extends Model
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '兑换失败', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//转币
|
||||
public function give_coin($uid, $give_uid, $coin){
|
||||
//从缓存中获取
|
||||
$exchange_user = Cache::get('give_coin_user_' . $uid);
|
||||
if($exchange_user){
|
||||
return ['code' => 0, 'msg' => '请5分钟后再试', 'data' => null];
|
||||
}else{
|
||||
Cache::set('give_coin_user_' . $uid, 1, 5 * 60);
|
||||
}
|
||||
if(empty($coin)){
|
||||
return ['code' => 0, 'msg' => '请输入需要转的金币数量', 'data' => null];
|
||||
}
|
||||
if(strlen($coin) - strlen(str_replace('.', '', $coin)) > 1){
|
||||
return ['code' => 0, 'msg' => '请输入正确的金币数量', 'data' => null];
|
||||
}
|
||||
$user_info = db::name('user_wallet')->where('user_id',$uid)->find();
|
||||
$user_info = db::name('user_wallet_coin')->where('user_id',$uid)->find();
|
||||
if($user_info['coin'] < $coin){
|
||||
return ['code' => 0, 'msg' => '金币数量不足', 'data' => null];
|
||||
}
|
||||
@@ -204,4 +217,166 @@ class UserWallet extends Model
|
||||
return ['code' => 0, 'msg' => '转赠失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*操作用户金币并记录日志
|
||||
* @param int $user_id 用户id
|
||||
* @param int $money 金币数量
|
||||
* @param int $change_type 变动类型
|
||||
* @param int $room_id 房间
|
||||
* @param str $remarks 备注
|
||||
*/
|
||||
//change_type
|
||||
// 1.系统调节 2.充值 3.提现 4.金币转增(送出) 5.每日任务奖励 6.充值返利 7.购买装扮
|
||||
// 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换
|
||||
// 15.首充 16.天降好礼充值 17.退出工会扣款 18.房主收益 19.主持人收益 20.抢头条 21.公会长收益,22.提现驳回或提现失败返还,23.财富等级奖励金币领取,24.删除关系扣金币,
|
||||
// 25.赠送好友金币,26.好友转赠所得金币,27.小时榜获得金币,28.新人充值好礼,29.发红包(钻石),30.抢红包(金币),31.抢红包(钻石),32.发红包(金币),
|
||||
// 33.红包剩余退回(金币),34-红包剩余退回(钻石),35-爵位购买赠送金币(金币),,40-后台充值金币,41-后台充值钻石,42-后台扣除金币,43-后台扣除钻石,
|
||||
//50-签约,51-签约失败退回,52-首次被签约收入,53.签约师傅每日返还,54-叛徒补偿,55-徒弟收礼返佣,56-续约,57-签到,58-爆币,59-红包手续费 60-炼仙传说抽奖扣除金币
|
||||
//资金操作
|
||||
public function change_user_cion_log($user_id,$money,$room_id,$change_type,$remarks)
|
||||
{
|
||||
//增加用户金币类型
|
||||
$in_types = [2,5,6,8,13,14,15,16,23,26,27,28,30,33,35,40,51,57,58,44];
|
||||
//减少用户金币类型
|
||||
$out_types = [4,7,10,17,20,24,25,32,42,50,56,59,60];
|
||||
|
||||
$user_wallet = Db::name('user_wallet_coin')->where(['user_id' => $user_id])->lock(true)->find();
|
||||
if (!$user_wallet) {
|
||||
return false;
|
||||
}
|
||||
$user_coin = $user_wallet['coin'];
|
||||
$original_coin = $user_coin; // 保存原始值用于日志
|
||||
|
||||
if(in_array($change_type,$in_types)){
|
||||
$update_coin = $user_coin + $money;
|
||||
}elseif(in_array($change_type,$out_types)){
|
||||
if($user_coin < $money){
|
||||
return false;
|
||||
}
|
||||
$update_coin = $user_coin - $money;
|
||||
}else{
|
||||
$update_coin = $user_coin;
|
||||
}
|
||||
$res1 = Db::name('user_wallet_coin')->where(['user_id' => $user_id])->update(['coin' => $update_coin,'updatetime' => time()]);
|
||||
if(!$res1){
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'user_id' => $user_id,
|
||||
'room_id' => $room_id,
|
||||
'coin' => $money,
|
||||
'before' => $original_coin,
|
||||
'after' => $update_coin,
|
||||
'change_type' => $change_type,
|
||||
'remarks' => $remarks,
|
||||
'createtime' => time()
|
||||
];
|
||||
|
||||
$res = Db::name('user_coin_log')->insert($data);
|
||||
if(!$res){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*操作用户收益(钻石)并记录日志
|
||||
* @param int $user_id 用户id
|
||||
* @param int $money 数量
|
||||
* @param int $change_type 变动类型
|
||||
* @param int $room_id 房间
|
||||
* @param str $remarks 备注
|
||||
*/
|
||||
//change_type
|
||||
// 1.系统调节 2.充值 3.提现 4.金币转增(送出) 5.每日任务奖励 6.充值返利 7.购买装扮
|
||||
// 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换
|
||||
// 15.首充 16.天降好礼充值 17.退出工会扣款 18.房主收益 19.主持人收益 20.抢头条 21.公会长收益,22.提现驳回或提现失败返还,23.财富等级奖励金币领取,24.删除关系扣金币,
|
||||
// 25.赠送好友金币,26.好友转赠所得金币,27.小时榜获得金币,28.新人充值好礼,29.发红包(钻石),30.抢红包(金币),31.抢红包(钻石),32.发红包(金币),
|
||||
// 33.红包剩余退回(金币),34-红包剩余退回(钻石),35-爵位购买赠送金币(金币),40-后台充值金币,41-后台充值钻石,42-后台扣除金币,43-后台扣除钻石,
|
||||
//50-签约,51-签约失败退回,52-首次被签约收入,53.签约师傅每日返还,54-叛徒补偿,55-徒弟收礼返佣,56-续约,57-签到,58-爆币,59-红包手续费
|
||||
|
||||
//bcadd: 加法运算
|
||||
//bcsub: 减法运算
|
||||
//bcmul: 乘法运算
|
||||
//bcdiv: 除法运算
|
||||
public function change_user_earnings_log($user_id,$money,$room_id,$change_type,$remarks)
|
||||
{
|
||||
//增加用户钻石类型
|
||||
$in_types = [9,11,12,18,19,21,22,31,28,34,41,52,53,54,55,57];
|
||||
|
||||
//减少用户钻石类型
|
||||
$out_types = [3,14,29,43];
|
||||
$user_wallet = Db::name('user_wallet_earnings')->where(['user_id' => $user_id])->lock(true)->find();
|
||||
if(!$user_wallet){
|
||||
return false;
|
||||
}
|
||||
$user_earnings = $user_wallet['earnings'];
|
||||
$original_coin = $user_earnings; // 保存原始值用于日志
|
||||
|
||||
$money = $this ->formatScientificNumber($money);
|
||||
// Log::record("计算收益:".$money,"info");
|
||||
if(in_array($change_type,$in_types)){
|
||||
$update_coin = bcadd($user_earnings , $money,4);
|
||||
}elseif(in_array($change_type,$out_types)){
|
||||
if($user_earnings < $money){
|
||||
return false;
|
||||
}
|
||||
$update_coin = bcsub($user_earnings , $money,4);
|
||||
}else{
|
||||
$update_coin = $user_earnings;
|
||||
}
|
||||
$res1 = Db::name('user_wallet_earnings')->where(['user_id' => $user_id])->update(['earnings' => $update_coin,'updatetime' => time()]);
|
||||
if(!$res1){
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'user_id' => $user_id,
|
||||
'room_id' => $room_id,
|
||||
'earnings' => $money,
|
||||
'before' => $original_coin,
|
||||
'after' => $update_coin,
|
||||
'change_type' => $change_type,
|
||||
'remarks' => $remarks,
|
||||
'createtime' => time()
|
||||
];
|
||||
|
||||
$res = Db::name('user_earnings_log')->insert($data);
|
||||
if(!$res){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function formatScientificNumber($num) {
|
||||
// 1. 先将数值转为字符串,方便正则匹配
|
||||
$numStr = (string)$num;
|
||||
|
||||
// 2. 正则匹配科学计数法格式(匹配 E/e 开头的科学计数法,包含正负指数)
|
||||
$scientificPattern = '/^[+-]?\d+(\.\d+)?[Ee][+-]?\d+$/';
|
||||
|
||||
// 3. 判断是否是科学计数法
|
||||
if (preg_match($scientificPattern, $numStr)) {
|
||||
// 是科学计数法,转换为浮点数后保留4位小数
|
||||
$floatNum = (float)$numStr;
|
||||
// 保留4位小数,四舍五入,确保格式正确
|
||||
$result = number_format($floatNum, 4, '.', '');
|
||||
// echo "检测到科学计数法数值,处理后结果:{$result}\n";
|
||||
} else {
|
||||
// 不是科学计数法,直接保留4位小数(兼容普通数值)
|
||||
$floatNum = (float)$numStr;
|
||||
$result = number_format($floatNum, 4, '.', '');
|
||||
// echo "非科学计数法数值,处理后结果:{$result}\n";
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -142,14 +142,8 @@ class UserWithdrawal extends Model
|
||||
Db::rollback();
|
||||
return V($reslut['code'],$reslut['msg']);
|
||||
}
|
||||
//增加冻结余额
|
||||
$reslut = Db::name('user_wallet')->where('user_id', $user_id)->setInc('frozen_earnings', $number);
|
||||
if (!$reslut) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => "请重试2", 'data' => null];
|
||||
}
|
||||
//修改提现余额
|
||||
$surplus_earnings = Db::name('user_wallet')->where('user_id', $user_id)->value('earnings');
|
||||
$surplus_earnings = Db::name('user_wallet_earnings')->where('user_id', $user_id)->value('earnings');
|
||||
if ($surplus_earnings > 0) {
|
||||
$surplus_earnings = $surplus_earnings / $diamond_to_rmb_ratio; //剩余金额(人民币)
|
||||
}
|
||||
@@ -180,19 +174,23 @@ class UserWithdrawal extends Model
|
||||
*/
|
||||
public function withdrawal_fail($order_id){
|
||||
$withdraw_info = db::name('vs_user_withdrawal')->where('order_sn', $order_id)->find();
|
||||
if (empty($withdraw_info)) {
|
||||
return ['code' => 0, 'msg' => '提现订单不存在'];
|
||||
}
|
||||
if ($withdraw_info['refund_time'] != 0) {
|
||||
return ['code' => 0, 'msg' => '订单已处理过退款'];
|
||||
}
|
||||
//退回提现金额(释放冻结金额)
|
||||
//钻石兑换人民币比例
|
||||
$diamond_to_rmb_ratio = get_system_config_value('diamond_to_rmb_ratio');
|
||||
$money = $withdraw_info['money'] * $diamond_to_rmb_ratio; //提现金额转换 人民币转为钻石
|
||||
$result = db::name('user_wallet')->where('user_id', $withdraw_info['user_id'])->setDec('frozen_earnings', $money);
|
||||
if (!$result) {
|
||||
return ['code' => 0, 'msg' => '提现失败'];
|
||||
}
|
||||
//归还账户余额
|
||||
$reslut = model('common/UserWallet')->change_user_money($withdraw_info['user_id'], $money, model('common/UserWallet')::MONEYTYPEARNINGS, model('common/UserWallet')::WITHDRAW_FAILURE,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::WITHDRAW_FAILURE));
|
||||
if ($reslut['code'] != 1) {
|
||||
return ['code' => 0, 'msg' => $reslut['msg']];
|
||||
}
|
||||
//修改退款时间
|
||||
db::name('vs_user_withdrawal')->where('wid', $withdraw_info['wid'])->update(['refund_time' => time()]);
|
||||
return ['code' => 1, 'msg' => '成功'];
|
||||
}
|
||||
/*
|
||||
|
||||
@@ -49,25 +49,15 @@ class UserZone extends Model
|
||||
$res = db::name('user_zone_topic')->insert($datad);
|
||||
}
|
||||
}
|
||||
//判断是不是第一次发布
|
||||
$count = db::name('user_zone')->where('user_id' , $uid)->count();
|
||||
if($count <= 1){
|
||||
//首次发布动态【完成任务】
|
||||
model('DailyTasks')->tasks_complete($uid,12);
|
||||
}
|
||||
//发布的是几张 图片
|
||||
$count_images = count(explode(',', $images));
|
||||
if($count_images == 9){
|
||||
$first = db::name('vs_user_zone_manjiujiang')->where('user_id' , $uid)->find();
|
||||
if(!$first){
|
||||
//发布动态头图上传满九张【完成任务】第一次给奖励
|
||||
model('DailyTasks')->tasks_complete($uid,13);
|
||||
db::name('vs_user_zone_manjiujiang')->insert(['user_id' => $uid, 'createtime' =>time()]);
|
||||
}
|
||||
|
||||
}
|
||||
//注册后累计发布M条动态,奖励X金币 【完成任务】
|
||||
model('DailyTasks')->tasks_complete($uid,16);
|
||||
|
||||
return ['code' => 1, 'msg' => '发布成功', 'data' => null];
|
||||
} else {
|
||||
@@ -300,14 +290,7 @@ class UserZone extends Model
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '请重试,', 'data' => null];
|
||||
}
|
||||
//评论別人的帖子- 每天第一条奖励【完成任务】
|
||||
// if($info['user_id'] != $uid){
|
||||
//今天的第一条评论奖励
|
||||
$first_comment = db::name('user_zone_comment')->where(['user_id' => $uid, 'createtime' => ['between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]]])->count();
|
||||
if ($first_comment ==1) {
|
||||
model('DailyTasks')->tasks_complete($uid,5);
|
||||
}
|
||||
// }
|
||||
|
||||
//增加评论数量
|
||||
$reslut = db::name('user_zone')->where('id', $zid)->setInc('comment_num', 1);
|
||||
if (!$reslut) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user