Compare commits
1061 Commits
master
...
develop_te
| Author | SHA1 | Date | |
|---|---|---|---|
| 9539bc069e | |||
| 821ec4183f | |||
| bb68bdd25b | |||
| f5187c013e | |||
| f05205b3c1 | |||
| 454816959c | |||
| ed923cd0bf | |||
| f8e7ff1d52 | |||
| 6dc429ec36 | |||
| 51338300c5 | |||
| 87290ab4c9 | |||
| 479fd37014 | |||
| a2f11a319e | |||
| 48b217fce0 | |||
| 3cf0f68569 | |||
| 7a8faf7ae9 | |||
| 73094e132d | |||
| 0b8655e5d2 | |||
| 705018e3e8 | |||
| a17697056a | |||
| 793804fe45 | |||
| 805a665392 | |||
| 19a846c274 | |||
| 0499b8c98d | |||
| 69daeb15ee | |||
| 316b916052 | |||
| 81f44d4a81 | |||
| 797c6c1e62 | |||
| 7f0fbadb51 | |||
| 50396ae5e4 | |||
| 0f0907b534 | |||
| bfc40fb248 | |||
| 8df95110cf | |||
| 6cde21fe2d | |||
| 2ab9208236 | |||
| 32a8b351df | |||
| 84273faee1 | |||
| 674e026c29 | |||
| 85a3776ab0 | |||
| b695ef4209 | |||
| fccdfb1c0a | |||
| 56cfdea96e | |||
| 9522170898 | |||
| d787e3941a | |||
| 50ff822b10 | |||
| bf5333937e | |||
| 7b3fff03c4 | |||
| fd8e4c7c79 | |||
| 8f7ea8b289 | |||
| f9de7a3a06 | |||
| 8307b6c83d | |||
| 36f4187ada | |||
| 5a72687aee | |||
| 7d8b0d766c | |||
| f9539d9675 | |||
| 434caca2b0 | |||
| 9fca28c57f | |||
| 877c4cfcb4 | |||
| 769b5af542 | |||
| 5b0eac6db6 | |||
| 20e68f280d | |||
| 7d2c35c4c7 | |||
| 8e032deff2 | |||
| 4b68ed4ca1 | |||
| 58621423f1 | |||
| 843693f4f9 | |||
| a45d928567 | |||
| 440ff3b11f | |||
| 2143a7d6c8 | |||
| 82df081fd0 | |||
| 89c86fc21d | |||
| e3e51f222d | |||
| eab06a9b10 | |||
| d87d469aa3 | |||
| c5d1a2f893 | |||
| 136802fa48 | |||
| 6488f65bd3 | |||
| 545ce25703 | |||
| 3003b489a3 | |||
| 60d800ba0d | |||
| 25635b0e46 | |||
| 2fb87137dd | |||
| 16134c993a | |||
| d672397e35 | |||
| 3831baa37a | |||
| 20a8ff5e98 | |||
| fa35040a88 | |||
| d3d461e316 | |||
| ae518ca9e5 | |||
| 3ad46c624b | |||
| 6c311abb98 | |||
| f3e692f3fc | |||
| 0dfccdd617 | |||
| 6466b0cab7 | |||
| fc0f6cd725 | |||
| 270714928b | |||
| 53e5e52203 | |||
| 58d77b1e1a | |||
| ee59c5ccff | |||
| b63184ce52 | |||
| ef86241ad4 | |||
| 28b4c9bb76 | |||
| 697512c46d | |||
| 63b64dfb18 | |||
| 018865fcac | |||
| ea876dba28 | |||
| c95410311d | |||
| 242ae07d2a | |||
| 5fca7b9e06 | |||
| bae8b3158d | |||
| c2d6df9384 | |||
| c860344609 | |||
| 1e02332678 | |||
| d13dae6746 | |||
| 2860daef6e | |||
| bf02aaad14 | |||
| d03e1285e4 | |||
| a60937297b | |||
| f0898345a1 | |||
| 41be4738da | |||
| b8a55853d5 | |||
| 7664fd812d | |||
| 702f09d0de | |||
| 7c002eab1d | |||
| fe83b67ef4 | |||
| 9bfcc77d1c | |||
| 5e66113357 | |||
| 9429cf17c1 | |||
| 48f6ce44ab | |||
| 4ba205e565 | |||
| 2efcfd069c | |||
| 901fe0dbc2 | |||
| 88d21d0a6a | |||
| 1e69aa94a7 | |||
| 5dde1fa795 | |||
| 6f32ca2b08 | |||
| 8191237775 | |||
| b9d876437a | |||
| 0624562dda | |||
| 694483f526 | |||
| 0630170a72 | |||
| bf3b69da7d | |||
| cc922eceb8 | |||
| 43c188e8a9 | |||
| 33450890aa | |||
| 6e81a0942f | |||
| 58865a984a | |||
| 444a2c59e8 | |||
| 604d60eb71 | |||
| 95bb00e2cc | |||
| 92a2fb10cd | |||
| e0d854b1fd | |||
| e2b55a4f28 | |||
| f318e54a3a | |||
| 685bca8bdb | |||
| 73b3808dec | |||
| 400461fd5a | |||
| 763b1b1892 | |||
| f81440882b | |||
| c661018a1e | |||
| bdb738a47f | |||
| e71d01c5a0 | |||
| 051d6589e9 | |||
| f9f0d01948 | |||
| 4f32f98ad2 | |||
| 5cff222264 | |||
| c68bb44650 | |||
| 4b5eb28781 | |||
| 32815cc578 | |||
| ff5222e333 | |||
| 3e90c1ae38 | |||
| 9210cf9635 | |||
| 2cf309e082 | |||
| 8cfe127c32 | |||
| 690bc258d0 | |||
| cd69ab6b73 | |||
| 1c2b981649 | |||
| 301b7c6d5c | |||
| d470264617 | |||
| 0c989521d6 | |||
| eb76e324e9 | |||
| 1d6152acb4 | |||
| e12e8c4ad2 | |||
| 94184b89a8 | |||
| 9d68d429f6 | |||
| 86e91af96f | |||
| b6e669ac9d | |||
| 7323ed2028 | |||
| f1e9b82471 | |||
| f2dc348994 | |||
| cfadaf4326 | |||
| df4e3aabdf | |||
| 3b531033bf | |||
| 5db7367438 | |||
| bf0e187e71 | |||
| e9eaedd14d | |||
| 3c3c332d05 | |||
| 81621fe62c | |||
| 1b3f562bb0 | |||
| e6ed912f42 | |||
| 2155ce1d4e | |||
| a6724faa99 | |||
| 2121a0a28b | |||
| 3c37a5c481 | |||
| d514f39dc3 | |||
| aa498d682a | |||
| 5ec94fda56 | |||
| 8ed22d99be | |||
| 6065183faf | |||
| d2f9c457ad | |||
| cbaf8a6d2c | |||
| a462d63bc5 | |||
| 794ea56b09 | |||
| 52c34275f5 | |||
| e4528232ed | |||
| fc42e14b75 | |||
| 0af34072ff | |||
| 2ba8392f2c | |||
| 97c5322446 | |||
| aa3db1f068 | |||
| 6c29963372 | |||
| c1e22c5fe1 | |||
| c55716196c | |||
| 122ba13243 | |||
| 6135f82944 | |||
| dcf926e496 | |||
| 04349ae7f0 | |||
| 1502709a9f | |||
| 19d2b6c9f6 | |||
| 287b108ce6 | |||
| 4ccee5f8ac | |||
| cda159929c | |||
| 375867a2ea | |||
| c4cea0c231 | |||
| a4409b0bb3 | |||
| 78d7ae8279 | |||
| 820468263f | |||
| 5722486bc5 | |||
| d1b20bdcd4 | |||
| 071bb6a399 | |||
| e681918ca0 | |||
| 235b795eb8 | |||
| 817a1ad59b | |||
| ffaf75bb72 | |||
| 8058605a0b | |||
| 4f2ddedc5d | |||
| 32ba6cbf08 | |||
| 8f72278eaa | |||
| 326a819f72 | |||
| d9626c6a59 | |||
| 4ca0bbd84d | |||
| ca48f2682c | |||
| f8855c7191 | |||
| 0937ceac6b | |||
| 2b4b3509e8 | |||
| ebb341fef2 | |||
| bfb7fdb2e8 | |||
| 5d6d8af442 | |||
| fc102dceb2 | |||
| 3e3d0c7e20 | |||
| 483e985e94 | |||
| ff916aec3d | |||
| 728ab6c908 | |||
| 8bbf624a8c | |||
| 1f1a9c52a7 | |||
| 6fea1aa312 | |||
| d6eb1c19fd | |||
| cd12717f46 | |||
| aa88579e82 | |||
| 0ca96dc673 | |||
| c999f5af2b | |||
| 816cc9241e | |||
| 515493258b | |||
| f4a25cf20e | |||
| b1b1acb181 | |||
| 949195555d | |||
| 5bf22491d5 | |||
| 6be3116c35 | |||
| 70434c181c | |||
| 14b45c638c | |||
| 4e4f702273 | |||
| 3cca2d34ed | |||
| b810d7d584 | |||
| b4e01723b7 | |||
| 217c8d21ea | |||
| c6d936baa9 | |||
| d3289ed24e | |||
| b7d7938736 | |||
| 28751fea44 | |||
| 93482c3d95 | |||
| 2621912c8b | |||
| b5af9ac3a3 | |||
| 5baaf177f0 | |||
| 088e0ae163 | |||
| d6d9c30561 | |||
| 378a1cf11b | |||
| 8988b9a135 | |||
| a14df3b0e8 | |||
| 72b6c9eefe | |||
| ce5dbf7976 | |||
| c26ba285fb | |||
| 7217063ca3 | |||
| b67e093605 | |||
| afa0e019a0 | |||
| c6a078dd16 | |||
| da7b4f565b | |||
| c37179e908 | |||
| fa133911b8 | |||
| 68f574b10b | |||
| 38fb2eb501 | |||
| cb90a2c6a2 | |||
| 3f99248479 | |||
| bee75bc5e6 | |||
| 75eceaa656 | |||
| 624bae5acd | |||
| 95b6f4ce4d | |||
| bd3ffd9a0a | |||
| d608172252 | |||
| 93c49ecda0 | |||
| d42c37bd0e | |||
| a61753d3c7 | |||
| 7b33568abd | |||
| 8b7c48fe00 | |||
| 910ab76e2e | |||
| 9c2111ba9f | |||
| 18eab7ea4c | |||
| 77e328147d | |||
| 3ae792815c | |||
| 0a09b16e71 | |||
| a2383add23 | |||
| f67acd0866 | |||
| 72c64f7a98 | |||
| f628def5f4 | |||
| 51764f4f53 | |||
| 0fbe7a1f54 | |||
| 7c5b155b15 | |||
| 6858bd95d5 | |||
| bd2c8bd5b2 | |||
| d57faa5166 | |||
| b54d1c3ffb | |||
| 99a2c368e3 | |||
| 4f1092131f | |||
| ebefea922b | |||
| fc3a2eed01 | |||
| 4d90900227 | |||
| 032f99ef79 | |||
| 8b473b95d6 | |||
| f6869b0941 | |||
| 4723ad2e2d | |||
| c7d3aa4059 | |||
| 60134a68f7 | |||
| 2b625d176c | |||
| f67b530117 | |||
| 8822b40d57 | |||
| 34ee7081e9 | |||
| ec1abadae1 | |||
| 1a01ec66e5 | |||
| b2f535be6e | |||
| b21bc68610 | |||
| eba24310bc | |||
| e1d54f287a | |||
| 348f373d9e | |||
| ede2764fc7 | |||
| f0eb51edd9 | |||
| 5589f3a55b | |||
| 51ab47a3f6 | |||
| 89eb41d8c1 | |||
| d261d7ff65 | |||
| 671c659076 | |||
| fe12eed9e9 | |||
| 05bafb3458 | |||
| e733aa1317 | |||
| 23e469673f | |||
| d9ac47c2c1 | |||
| 77aaf97c9c | |||
| 5f77e537f2 | |||
| 0eaf84fbb3 | |||
| 7c077e9e44 | |||
| 619b7c36af | |||
| 742cd5aef2 | |||
| 1687640191 | |||
| f72d5782ed | |||
| 000d802def | |||
| 750275ddd6 | |||
| 3d47b350bb | |||
| f1feaea496 | |||
| 9fbc544a85 | |||
| b29b9bbcd9 | |||
| 2726aa852d | |||
| 41c90c615b | |||
| 6edee924c7 | |||
| dd8ec0d7df | |||
| a3f0a0cd83 | |||
| 156d2ed368 | |||
| 7ae760c78a | |||
| 3e66125e3e | |||
| e967900ce0 | |||
| 58a4dade1a | |||
| d31b8e1960 | |||
| 65abf4fb59 | |||
| e199c6bc4c | |||
| 9a316a2699 | |||
| 27ab27296f | |||
| 16c8ec2856 | |||
| 9fe9906f7d | |||
| 78f7f5ff75 | |||
| 672a43a599 | |||
| f4800b9d9d | |||
| a7236605e4 | |||
| 2d55d2cbf8 | |||
| 1ca65ed7ba | |||
| be28f83d8b | |||
| 35cc69be3c | |||
| 4ea5a630a1 | |||
| b5be581786 | |||
| dcc373fe2a | |||
| ea03bf88bc | |||
| f548dfa335 | |||
| d41c57fafc | |||
| d594dcbf1b | |||
| 4a383afa03 | |||
| 4111014542 | |||
| 844f22f17a | |||
| dceca03fbf | |||
| 6c09ba626d | |||
| 7349789c9a | |||
| 99369fc8cc | |||
| 8336217944 | |||
| dfe5fe96ec | |||
| 49dd2afc03 | |||
| d3de53715d | |||
| ec181d951f | |||
| 7484817c82 | |||
| c10f055585 | |||
| e4c3f572e5 | |||
| 5c0ab3b64c | |||
| 71ce9595e3 | |||
| bc60c3b9b9 | |||
| e2e27e386d | |||
| 5820fed771 | |||
| f0d4efa6f2 | |||
| 046f4cace3 | |||
| 89a4fdc7c9 | |||
| 505cf70f4c | |||
| 683816d3ec | |||
| 828a29d0ee | |||
| bbcb4a7a8c | |||
| 3b4a407d8a | |||
| be6383bd65 | |||
| d28167401b | |||
| 8aabd01f0b | |||
| 5c991b161a | |||
| 2f91d9f144 | |||
| 3231be78fd | |||
| 996fca617b | |||
| d0203ecc8b | |||
| 7ddfd45eec | |||
| d456099f56 | |||
| 77edc04069 | |||
| ab0b23539e | |||
| d6005ffe1f | |||
| 7aa07a0486 | |||
| c503b7a1d5 | |||
| bed754f8b5 | |||
| 76af99f47e | |||
| eb15a69649 | |||
| c6c4be30ce | |||
| 1460a2c788 | |||
| 020174c99b | |||
| 140d09f276 | |||
| f25774338f | |||
| 1a40974ee2 | |||
| 3df68b3c74 | |||
| 2ba055d5e9 | |||
| a88a83f2b0 | |||
| c2cae98437 | |||
| fe168eba18 | |||
| 0dca064fe8 | |||
| 384f631cd6 | |||
| ac708c793d | |||
| bca8131370 | |||
| 53cc460514 | |||
| 3702c0710f | |||
| 7d97217190 | |||
| fb3d7f9fc9 | |||
| bc24d6abad | |||
| 301a09ccf0 | |||
| 59c5fb1575 | |||
| 4c51486726 | |||
| 095c1a28fb | |||
| 30a774baf9 | |||
| 689897fd6c | |||
| 890e71e2eb | |||
| 409f9fb04b | |||
| 4cc6af9805 | |||
| a888de758d | |||
| 019cb8e737 | |||
| a732eaa2d5 | |||
| 0fd272bf37 | |||
| 0d36a906ff | |||
| ffe6768c0a | |||
| 92b9053c3a | |||
| 40f05adca5 | |||
| 38673d4eb4 | |||
| 7f4fd3d68f | |||
| c507f5ed1a | |||
| 2fd4e58d52 | |||
| a9cfaf86b9 | |||
| 584b86048c | |||
| f886dcbb8d | |||
| 550b1e4fd9 | |||
| 1f49b8d6e9 | |||
| 8285462258 | |||
| 0fdf551e0a | |||
| fde96159fd | |||
| d361b1157e | |||
| 748821467f | |||
| 0fac85c05d | |||
| a09c17bd60 | |||
| 2c96fb6a0e | |||
| a166932694 | |||
| 1da84f7f7a | |||
| 5475c6805e | |||
| e200b46379 | |||
| 2a74cc71c8 | |||
| 929fb8cdc3 | |||
| 16855049b8 | |||
| a274636bec | |||
| ba2e6943a0 | |||
| d1482d0271 | |||
| df3f668f11 | |||
| 44caa72ca8 | |||
| e7d3121215 | |||
| 51946d5300 | |||
| 0a832692b2 | |||
| 5262a62b82 | |||
| 8fe9e6f2f3 | |||
| 9192b58ff5 | |||
| 2b6add741d | |||
| da78a50621 | |||
| 57d6bfb72a | |||
| 01177ce7ca | |||
| e3d5b8cd37 | |||
| a984de992b | |||
| 3422c0931c | |||
| b2b9d9133a | |||
| d0eb2d4cf1 | |||
| 4a13de59ff | |||
| 4590503029 | |||
| 5b4101db1a | |||
| 0bfa4e6c3a | |||
| 2e819654fb | |||
| 1e5bf47891 | |||
| e0b4c7cf7e | |||
| 12b62fe679 | |||
| 7c9c82b208 | |||
| 1ed607a1db | |||
| 1d2cb34dd0 | |||
| 4ed322e636 | |||
| 05b230f811 | |||
| df52882ff9 | |||
| dbe3557ca8 | |||
| 89cfa4ca63 | |||
| 77f5c059f0 | |||
| 435915ef2e | |||
| e2ee2c8338 | |||
| 3a202fb50f | |||
| ca511768f3 | |||
| 83f404cb9e | |||
| a92b5d85f6 | |||
| 05db9b6f02 | |||
| be7dc27d20 | |||
| 2d5645813b | |||
| 496c7307dc | |||
| 02a5988800 | |||
| 4595d759a4 | |||
| dc468b0a2f | |||
| 7b5f017c49 | |||
| e078824070 | |||
| c4b03097bf | |||
| 6f9d80c744 | |||
| 8ce5e3f473 | |||
| f3104f30a8 | |||
| 4acf42aba3 | |||
| 68ff1ae76d | |||
| 22b7bf3b8c | |||
| 422938b03d | |||
| 963e6c9da6 | |||
| f1da50de78 | |||
| abf611d725 | |||
| a82ef834b4 | |||
| 48f0c44fba | |||
| 263cbe1bdc | |||
| bbc58d5752 | |||
| b99ef24a2e | |||
| 6d98047dc4 | |||
| c794c8c1f7 | |||
| 21d5951455 | |||
| 17788c162c | |||
| bde8bd5d69 | |||
| 768d3c9484 | |||
| 485da90f42 | |||
| 258ba5e5c2 | |||
| c6fc8163a9 | |||
| dfa38ac51b | |||
| 27bbd59fb5 | |||
| 2586346b73 | |||
| ef8b93c8d1 | |||
| 3ad2731dba | |||
| 0779bfce73 | |||
| bcd691bbf4 | |||
| 97dbbb1eb6 | |||
| 6ab1491301 | |||
| 2043893065 | |||
| d6e5e75f40 | |||
| 3f303cf069 | |||
| efaef64481 | |||
| c0da472500 | |||
| c310c4d833 | |||
| 4f48725e65 | |||
| 37b511006d | |||
| b1f6879334 | |||
| 6a3b885438 | |||
| fa268d3145 | |||
| da5d277a02 | |||
| 331addd004 | |||
| a4224b6524 | |||
| b6356f5fd2 | |||
| 8a53e8aeaf | |||
| 0fd40b7a2d | |||
| a6053adc7c | |||
| 76a7a1fec7 | |||
| 48970d2117 | |||
| 3b24126cdf | |||
| fedc496263 | |||
| dd81f497a9 | |||
| 315558a00c | |||
| 672df01ee4 | |||
| debbb4ad5c | |||
| 691146a3a4 | |||
| 23931f7afc | |||
| bf05496a17 | |||
| fefbf22fa1 | |||
| 19794dfe4e | |||
| 2e60b43a22 | |||
| 5d152e1b0e | |||
| 65704e0e8e | |||
| d5f6e8a2a2 | |||
| e71546fb90 | |||
| bc66d40f88 | |||
| edcc78affd | |||
| 30deb1ab92 | |||
| b696040549 | |||
| ee6b07ee98 | |||
| 09e3933b80 | |||
| 4355262512 | |||
| 35f304dec7 | |||
| 79458797d0 | |||
| cccb38ea7b | |||
| 037c9bdb71 | |||
| 9e67b9c1ff | |||
| a5351df13d | |||
| feb1224774 | |||
| 8b5e003713 | |||
| a126eac997 | |||
| 6d75474d17 | |||
| 87eb493259 | |||
| fc674262af | |||
| f04fa2166f | |||
| 1fac081547 | |||
| 1c84efb0a1 | |||
| 216a2c4010 | |||
| df812236c4 | |||
| 0f867666e7 | |||
| 7c950d0a0e | |||
| ef0814b850 | |||
| 17e50b95f8 | |||
| f23ed45309 | |||
| ba7c97f03e | |||
| 02f39cc02f | |||
| 06a01e4908 | |||
| 5d9ee030b8 | |||
| ad6b12bc4d | |||
| c5c0819374 | |||
| 74fa6796a1 | |||
| b3ea7f1b2c | |||
| 83e18a669a | |||
| c1c008b036 | |||
| ecf69fcf34 | |||
| e9d65a1bc3 | |||
| 0c0f71a181 | |||
| 3508c844f2 | |||
| 11afdf93aa | |||
| b42bc92366 | |||
| b5501cd6e8 | |||
| 8dbbe1e2b3 | |||
| acfda2f044 | |||
| aa96a2d805 | |||
| f0aca7ec79 | |||
| 5f71a0df80 | |||
| 82a078cae1 | |||
| a0fcc3b8dd | |||
| 3d17e38bb0 | |||
| 5618d9e80c | |||
| aebef67454 | |||
| 4fff67edaa | |||
| 72c7e76280 | |||
| ea405b6d11 | |||
| b040bf5f68 | |||
| c3670ec2b0 | |||
| 384355f52c | |||
| a6054e3db3 | |||
| ca8dca40fe | |||
| 99c499df82 | |||
| 6f43c6d4ac | |||
| b797c69cc1 | |||
| 42e61ca469 | |||
| 8110ea2f53 | |||
| 5975e892bb | |||
| e1afb178a7 | |||
| a66c0608d8 | |||
| 755a0c9af4 | |||
| ab99ecff49 | |||
| 9b5e1bed0e | |||
| ccfb0c0f30 | |||
| 7064f1e523 | |||
| fb743edee2 | |||
| 7f1ac47668 | |||
| 7413753d63 | |||
| d40d71ab68 | |||
| c7a514e313 | |||
| cb07adc207 | |||
| 0bba1504eb | |||
| 10b3a01513 | |||
| bdb727e28a | |||
| 56a7730da4 | |||
| 1c54c137f2 | |||
| 5df65a5cc4 | |||
| 7d1a3e4fc9 | |||
| 9045dbf219 | |||
| 06059ac9cc | |||
| 2b79407e37 | |||
| 1d191dae3a | |||
| 94529c0102 | |||
| 8d9659d0fa | |||
| 10370f0da5 | |||
| 81a09aadc3 | |||
| f57f6c3474 | |||
| 195c99cf97 | |||
| a9d155e9e0 | |||
| c3e7867823 | |||
| f840bd89b0 | |||
| a1b15f79f2 | |||
| 79d1549e99 | |||
| 251569b117 | |||
| 75626066b0 | |||
| 8f4975eb22 | |||
| 626df0fd65 | |||
| 8e726d8670 | |||
| aa061a126d | |||
| f1f01d8a62 | |||
| 31917a4aad | |||
| 81897a34b4 | |||
| afb6ee48f7 | |||
| e0c5846462 | |||
| e4b605d738 | |||
| bca0247363 | |||
| 57904ee568 | |||
| 53a6cd4c80 | |||
| 4aa8bbcc4a | |||
| 4d22a41ec4 | |||
| 9ad44c621e | |||
| 82387abf4e | |||
| 4f036119c8 | |||
| 10289a7bf3 | |||
| 90b85bc40a | |||
| eb40faf08e | |||
| 86fa4b8fa2 | |||
| 4a67312897 | |||
| aaff62d46c | |||
| f876d121c3 | |||
| 497a4d9717 | |||
| 4ab363301a | |||
| c79b047a55 | |||
| 8ac4357d33 | |||
| 38795fe94c | |||
| b8d5dc1ebe | |||
| e1aaaacdda | |||
| 658257bc0a | |||
| 8239615cb6 | |||
| 7b788cf81d | |||
| ea50e5678e | |||
| fd94c7815d | |||
| 1552ff51c4 | |||
| 843ed44a12 | |||
| 46b7767dcf | |||
| a49681a76d | |||
| b6ed0ff157 | |||
| 8aa6c779c5 | |||
| d9a54d7ea0 | |||
| 14f0686206 | |||
| 7490acac12 | |||
| dc239087d5 | |||
| 53375c3997 | |||
| 5d78a97823 | |||
| 63898a02e3 | |||
| b707b39dd0 | |||
| 74eccf0e4e | |||
| 1e63d189b0 | |||
| c3c1417466 | |||
| 795c950bc7 | |||
| 5961d3c21c | |||
| cdffb76b37 | |||
| 4bf358de6b | |||
| 9ea7e69f22 | |||
| 92f047756b | |||
| ada9cd495e | |||
| 93162a2e4c | |||
| f8310275df | |||
| 5d20cd1ea2 | |||
| 9d64218d75 | |||
| 20079ba01f | |||
| f8b444e395 | |||
| d3ac48d286 | |||
| 49e6e5e256 | |||
| 12341e3987 | |||
| 0b69fc5ddd | |||
| b82dac2ddd | |||
| 63a9c478d1 | |||
| 85945da148 | |||
| 03bf140f85 | |||
| b102995ab1 | |||
| 15df770071 | |||
| 770c78b3e2 | |||
| 5d67407029 | |||
| ce72bc86f4 | |||
| fb31eeb919 | |||
| 86e09fe175 | |||
| 722aaf5834 | |||
| 808a61060c | |||
| 32b9c57197 | |||
| d9bc6fc646 | |||
| 106602d625 | |||
| a9cc4c3922 | |||
| bd91f7c65c | |||
| 6db7935df2 | |||
| 9aac2ff737 | |||
| d19202765b | |||
| 21999cc62d | |||
| 2e7f0e84af | |||
| ce9895d43d | |||
| 2fd11dcab7 | |||
| cb9c901b35 | |||
| 2094ee35f2 | |||
| 5f167b4557 | |||
| a1f0578c29 | |||
| 0d8e371981 | |||
| fa3296c07e | |||
| cb96fefc08 | |||
| 720d814915 | |||
| aeb97bb2fc | |||
| eb95c9d0b4 | |||
| a37eb9f660 | |||
| b492e921c3 | |||
| 71ac1132f6 | |||
| cc787ccead | |||
| a21257f9c3 | |||
| 92cb473c7a | |||
| 3d7a3226c8 | |||
| 8bc77df88d | |||
| 2aa28a1be5 | |||
| 9b637ef207 | |||
| 59af01983e | |||
| 2c5d80dc45 | |||
| 06508ca830 | |||
| 8248363a83 | |||
| 36d9b70e49 | |||
| 49581504c3 | |||
| e16137c2a0 | |||
| e49f004005 | |||
| f3dfc3fb61 | |||
| ec8d680f8b | |||
| 5335f54462 | |||
| 2de7412550 | |||
| 3aef38f4fc | |||
| 789c01b47d | |||
| 5965cd1d07 | |||
| d68adcc386 | |||
| f67fbde73a | |||
| fbe80fff80 | |||
| f10be786cf | |||
| 59e973001f | |||
| bf28dee4fe | |||
| 6f1fc408f6 | |||
| b8a24abeef | |||
| 7f13ebbcbc | |||
| b59fd2a727 | |||
| 54d3b95f87 | |||
| 2def8d279d | |||
| e57366840c | |||
| 512ae2c06e | |||
| 430e7b1186 | |||
| 92550f3ce4 | |||
| d25e68256a | |||
| 8bcdfd200b | |||
| ddf0774367 | |||
| 6eca2f374d | |||
| 86b15c0017 | |||
| 5eb016a65c | |||
| a8f224c6d3 | |||
| f495e827e7 | |||
| 7b5dbd4bda | |||
| d8b5a3b22f | |||
| 2d89e1c6f7 | |||
| 7756313a94 | |||
| 58bed24f6b | |||
| f1c9081457 | |||
| f3c87b6c82 | |||
| d102fe5e19 | |||
| 150f233088 | |||
| 73f82b29da | |||
| 2122e11f3c | |||
| 8bd1293aa7 | |||
| afc21ca457 | |||
| fb016ed07e | |||
| bde107a92d | |||
| 94f87237fe | |||
| e96a8c8b4c | |||
| 8168a34ac2 | |||
| 80ae48b98e | |||
| 5c81d96ac2 | |||
| d47300ee8c | |||
| 6a5e767745 | |||
| 8d532b6658 | |||
| 8234782ece | |||
| 3beb63f2a2 | |||
| 57655e014d | |||
| 20b4962e90 | |||
| 910902731e | |||
| 29ffed2b1b | |||
| 032c1c3bcb | |||
| 5f1ec8c108 | |||
| fb0f5f0362 | |||
| 048771fbf0 | |||
| ee0469aa3f | |||
| fb8276d741 | |||
| f237ad2f17 | |||
| ed60919899 | |||
| be1324da3a | |||
| 3e9be53acb | |||
| 2f2c7a7c96 | |||
| 8c78d9d9ba | |||
| 18945048bd | |||
| b96dabbff2 | |||
| be8f205aba | |||
| f7752cceef | |||
| ccc3e1b909 | |||
| b5be88a728 | |||
| ceae162772 | |||
| c47a19fd51 | |||
| d96985b712 | |||
| 0c4d4b5d12 | |||
| 9e81410cee | |||
| df7a9a5d6c | |||
| b96dc56e30 | |||
| af146c5bf8 | |||
| fae8a63a92 | |||
| 0eb4f975b9 | |||
| 13cd6f58b1 | |||
| d84e5d4151 | |||
| 4dbe3c52a6 | |||
| 08eaf68a31 | |||
| f9ae895049 | |||
| ce6f13ad1d | |||
| a2de9cc9f5 | |||
| 96cb3cc9a0 | |||
| 2acfaa8a09 | |||
| c6f7685fed | |||
| 0bf4fff05e | |||
| 4fc82cbc3d | |||
| c1d217d8b1 | |||
| b27612e564 | |||
| b47d9e7471 | |||
| 8b12d876a0 | |||
| 950f8354ad | |||
| 87b3ec4e98 | |||
| 4600c657a9 | |||
| 0b4abbe3d6 | |||
| 5672b29d14 | |||
| 4654f24690 | |||
| 78a35941da | |||
| 7ac489a902 | |||
| 17cbde1094 | |||
| 9c458a8802 | |||
| a751597890 | |||
| c787abbcdf | |||
| 02f0c966c5 | |||
| 61a2484b0a | |||
| e9bedb277d | |||
| 97b03db6e1 | |||
| b0e53b14ee | |||
| d09bb36ad7 | |||
| 6c87a8540a | |||
| 7529c3f611 | |||
| ab7e7da011 | |||
| 13d413ed90 | |||
| 25de01dc99 | |||
| dc9d23b797 | |||
| 96f393ab4f | |||
| 1eeeeb1c7c | |||
| 5df6ffa870 | |||
| 5d131ebffe | |||
| 023fe399d7 | |||
| 7b8b7dedc6 | |||
| 4b10bf3cba | |||
| 16933674ca | |||
| e4546acd31 | |||
| ca1fc28af8 | |||
| b74b1ec0a9 | |||
| acb010e295 | |||
| 88ff83ef21 | |||
| f66221dfd1 | |||
| 53d4e4c380 | |||
| 113923f8ad | |||
| 484d561944 | |||
| e59c3e1df6 | |||
| c21fb674a5 | |||
| eb75b0d097 | |||
| a2533669bc | |||
| 8f31af203b | |||
| 20da900dd7 | |||
| fe50dc4ca3 | |||
| 06f0dfac62 | |||
| 1a089f49f4 | |||
| e79036a6dd | |||
| bf5ed0a0a7 | |||
| 4c24e7187d | |||
| 07a0330196 | |||
| ac2f232c3f | |||
| 791562cfd3 | |||
| 828bf74397 | |||
| f3e1d7fb60 | |||
| e4c98cbd49 | |||
| bb03e95eb7 | |||
| 1f08ea3c09 | |||
| 0dae5bf4d0 | |||
| 9d6fab3220 | |||
| 0ff014b899 | |||
| 70777b26a1 | |||
| 1c7412c98f | |||
| 1a1d192057 | |||
| 28b19e0619 | |||
| 5d1983fdb1 | |||
| 8e4907cab4 | |||
| 3fdb023fbe | |||
| 41f081078c | |||
| b0ca77e7ff | |||
| 7b8dba195c | |||
| cca261410f | |||
| 14af58889f | |||
| f9a51177fd |
28
.env
28
.env
@@ -1,27 +1,23 @@
|
||||
[app]
|
||||
# local:本地调试 test:测试环境 prod:生产环境
|
||||
system_type = test
|
||||
debug = ture
|
||||
trace = false
|
||||
|
||||
[database]
|
||||
; hostname = 127.0.0.1
|
||||
; database = super_chat
|
||||
; username = root
|
||||
; password = 1111111
|
||||
; hostport = 3306
|
||||
; prefix = fa_
|
||||
|
||||
|
||||
#测试
|
||||
hostname = 1.13.181.248
|
||||
database = midi
|
||||
username = midi
|
||||
password = 5B2zwShhTi5L7t2w
|
||||
database = yusheng
|
||||
username = yusheng
|
||||
password = GEDYGj3HbZfKYBjp
|
||||
hostport = 3306
|
||||
prefix = fa_
|
||||
|
||||
#hostname = 62.234.12.147
|
||||
#database = midi
|
||||
#username = midi
|
||||
#password = EC6cak6fzXdXnERz
|
||||
#正式
|
||||
#hostname = 1.13.20.30
|
||||
#database = yusheng
|
||||
#username = yusheng
|
||||
#password = GEDYGj3HbZfKYBjp
|
||||
#hostport = 3306
|
||||
#prefix = fa_
|
||||
|
||||
@@ -35,7 +31,7 @@ mqtt_password = public
|
||||
[smsbao]
|
||||
dxb_name = xqgy1818
|
||||
dxb_pwd = "xqgy1818!"
|
||||
dxb_temp = "【西安熙晟文化传媒】您的验证码是{code}。如非本人操作,请忽略本短信"
|
||||
dxb_temp = "【羽声语音】您的验证码是{code}。如非本人操作,请忽略本短信"
|
||||
|
||||
[wechatpay]
|
||||
mch_id = 1719907761
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,3 +3,5 @@
|
||||
.idea
|
||||
*.log
|
||||
.env
|
||||
.node_modules
|
||||
node_modules/
|
||||
|
||||
@@ -598,7 +598,14 @@ class Activities extends adminApi
|
||||
$lists[$key]['box_name'] = $bag_data['name'];
|
||||
$lists[$key]['gift_type'] = $value['type'];
|
||||
$lists[$key]['gift_type_str'] = $this->gift_type[$value['type']];
|
||||
if ($value['type'] == 2) {
|
||||
if ($value['type'] == 1) {
|
||||
$lists[$key]['gift_id'] = "--";
|
||||
$lists[$key]['gift_name'] = "--";
|
||||
$lists[$key]['base_image'] = localpath_to_netpath("static/image/icon/gold.png");
|
||||
$lists[$key]['quantity'] = $value['quantity'];
|
||||
$lists[$key]['quantity_str'] = $value['quantity']."个";
|
||||
$lists[$key]['gift_price'] = $value['gold']*$value['quantity'];
|
||||
} elseif ($value['type'] == 2) {
|
||||
$lists[$key]['gift_id'] = $value['foreign_id'];
|
||||
$lists[$key]['gift_name'] = $value['name'];
|
||||
$gift_data = db::name('vs_gift')->where(['gid' => $value['foreign_id']])->find();
|
||||
@@ -618,10 +625,10 @@ class Activities extends adminApi
|
||||
}else{
|
||||
$lists[$key]['gift_id'] = "--";
|
||||
$lists[$key]['gift_name'] = "--";
|
||||
$lists[$key]['base_image'] = "--";
|
||||
$lists[$key]['quantity'] = 0;
|
||||
$lists[$key]['quantity_str'] = "0";
|
||||
$lists[$key]['gift_price'] = $value['gold'];
|
||||
$lists[$key]['base_image'] = localpath_to_netpath("static/image/icon/diamond.png");
|
||||
$lists[$key]['quantity'] = $value['quantity'];
|
||||
$lists[$key]['quantity_str'] = $value['quantity']."个";
|
||||
$lists[$key]['gift_price'] = $value['gold']*$value['quantity'];
|
||||
}
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
|
||||
@@ -700,15 +707,26 @@ class Activities extends adminApi
|
||||
* 装扮列表
|
||||
*/
|
||||
public function decorate_list(){
|
||||
$type = input('type', '');
|
||||
$where = [];
|
||||
if($type){
|
||||
$where['b.type'] = $type;
|
||||
}
|
||||
$decorate_list = db::name('vs_decorate_price')->alias('a')
|
||||
->field('a.id,a.did,b.type,a.day,a.price,b.title,b.base_image')
|
||||
->where('b.delete_time',0)
|
||||
->where($where)
|
||||
->join('vs_decorate b','a.did = b.did')
|
||||
->select();
|
||||
$return_data = [];
|
||||
foreach ($decorate_list as $key => $value) {
|
||||
$return_data[$key]['id'] = $value['id'];
|
||||
$return_data[$key]['name'] = model('api/Decorate')->TypeArray[$value['type']].'-'.$value['day'].'天-'.$value['title'];
|
||||
if($value['day'] == 0){
|
||||
$day = "永久";
|
||||
}else{
|
||||
$day = $value['day'].'天';
|
||||
}
|
||||
$return_data[$key]['name'] = model('api/Decorate')->TypeArray[$value['type']].'-'.$day.'-'.$value['title'];
|
||||
$return_data[$key]['day'] = $value['day'];
|
||||
}
|
||||
return V(1,"成功", $return_data);
|
||||
|
||||
@@ -62,17 +62,14 @@ class BlindBox extends adminApi
|
||||
$lists[$key]['gift_id'] = $value['foreign_id'];
|
||||
$lists[$key]['gift_name'] = $value['name'];
|
||||
$gift_data = db::name('vs_gift')->where(['gid'=>$value['foreign_id']])->find();
|
||||
if(empty($gift_data)){
|
||||
continue;
|
||||
}
|
||||
$lists[$key]['base_image'] = $gift_data['base_image'];
|
||||
$lists[$key]['gift_price'] = $gift_data['gift_price'];
|
||||
$lists[$key]['quantity'] = $value['quantity'];
|
||||
$lists[$key]['remaining_number'] = $value['remaining_number'];
|
||||
$lists[$key]['is_public_screen'] = $gift_data['is_public_screen'];
|
||||
$lists[$key]['is_public_server'] = $gift_data['is_public_server'];
|
||||
$lists[$key]['is_world_show'] = $value['is_world_show'];
|
||||
$lists[$key]['weight'] = $value['weight'];
|
||||
$lists[$key]['base_image'] = $gift_data['base_image'] ?? "";
|
||||
$lists[$key]['gift_price'] = $gift_data['gift_price'] ?? 0;
|
||||
$lists[$key]['quantity'] = $value['quantity'] ?? 0;
|
||||
$lists[$key]['remaining_number'] = $value['remaining_number'] ?? 0;
|
||||
$lists[$key]['is_public_screen'] = $gift_data['is_public_screen'] ?? 0;
|
||||
$lists[$key]['is_public_server'] = $gift_data['is_public_server'] ?? 0;
|
||||
$lists[$key]['is_world_show'] = $value['is_world_show'] ?? 0;
|
||||
$lists[$key]['weight'] = $value['weight'] ?? 0;
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
|
||||
}
|
||||
@@ -354,6 +351,14 @@ class BlindBox extends adminApi
|
||||
foreach ($gift_bag_detail as $k=>$v){
|
||||
$bag_data = db::name($this->table)->where(['id'=>$v['id']])->update(['remaining_number'=>$v['quantity']]);
|
||||
}
|
||||
// 清除缓存
|
||||
Cache::rm("pan_gift_bag".$gift_bag_id);
|
||||
Cache::rm("pan_gift_bag_detail".$gift_bag_id);
|
||||
Cache::rm("pan_total_quantity".$gift_bag_id);
|
||||
Cache::rm("pan_total_remaining".$gift_bag_id);
|
||||
Cache::rm("pan_total_draw".$gift_bag_id);
|
||||
Cache::rm("pan_gift_info_map".$gift_bag_id);
|
||||
|
||||
return V(1,"成功");
|
||||
}
|
||||
|
||||
@@ -445,10 +450,10 @@ class BlindBox extends adminApi
|
||||
$where['createtime'] = ['>=', strtotime($stime)];
|
||||
}
|
||||
if($etime!==""){
|
||||
$where['createtime'] = ['<=', strtotime($etime.'23:59:59')];
|
||||
$where['createtime'] = ['<=', strtotime($etime)];
|
||||
}
|
||||
if($stime!=="" && $etime!==""){
|
||||
$where['createtime'] = ['between', [strtotime($stime), strtotime($etime.'23:59:59')]];
|
||||
$where['createtime'] = ['between', [strtotime($stime), strtotime($etime)]];
|
||||
}
|
||||
$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();
|
||||
@@ -752,10 +757,10 @@ class BlindBox extends adminApi
|
||||
$where['createtime'] = ['>=', strtotime($stime)];
|
||||
}
|
||||
if($etime!==""){
|
||||
$where['createtime'] = ['<=', strtotime($etime.'23:59:59')];
|
||||
$where['createtime'] = ['<=', strtotime($etime)];
|
||||
}
|
||||
if($stime!=="" && $etime!==""){
|
||||
$where['createtime'] = ['between', [strtotime($stime), strtotime($etime.'23:59:59')]];
|
||||
$where['createtime'] = ['between', [strtotime($stime), strtotime($etime)]];
|
||||
}
|
||||
$count = db::name('vs_gift_bag_receive_pan_log')->where($where)->count();
|
||||
$lists_data = db::name('vs_gift_bag_receive_pan_log')->where($where)->page($page, $page_limit)->order("id desc")->select();
|
||||
@@ -855,7 +860,7 @@ class BlindBox extends adminApi
|
||||
}
|
||||
if($user_id){
|
||||
$user_id = db::name('user')->where('user_code', $user_id)->value('id');
|
||||
$where['b.user_id'] = $user_id;
|
||||
$where['a.user_id'] = $user_id;
|
||||
}
|
||||
if($periods){
|
||||
$where['b.periods'] = $periods;
|
||||
@@ -866,7 +871,7 @@ class BlindBox extends adminApi
|
||||
->where($where)->count();
|
||||
$lists_data = db::name('vs_room_pan_xlh_log')->alias('a')
|
||||
->join('vs_room_pan_xlh b', 'a.xlh_id = b.id')
|
||||
->field('a.id,b.periods as periods,a.user_id,a.createtime,b.user_id,b.room_id,b.gift_id,b.num,a.is_send,b.pay_price,b.locking_gift_id')
|
||||
->field('a.id,b.periods as periods,a.user_id,a.createtime,b.room_id,b.gift_id,b.num,a.is_send,b.pay_price,b.locking_gift_id')
|
||||
->where($where)
|
||||
->page($page, $page_limit)
|
||||
->order("id desc")
|
||||
@@ -897,7 +902,9 @@ class BlindBox extends adminApi
|
||||
$today = strtotime(date('Y-m-d'));
|
||||
$locking_num = db::name('vs_room_pan_xlh_log')->alias('a')
|
||||
->join('vs_room_pan_xlh b', 'a.xlh_id = b.id')
|
||||
->where('a.createtime','>=',$today)->where(['a.is_send'=>1,'b.room_id'=>$room_id])->sum('a.num');
|
||||
->where('a.createtime','>=',$today)->where(['a.is_send'=>1])
|
||||
->where($where)
|
||||
->sum('a.num');
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
|
||||
@@ -39,7 +39,7 @@ class Decorate extends adminApi
|
||||
$type = input('type', '');
|
||||
$where = ['delete_time'=>0];
|
||||
if($name){
|
||||
$where['name'] = ['like', '%'.$name.'%'];
|
||||
$where['title'] = ['like', '%'.$name.'%'];
|
||||
}
|
||||
if($type){
|
||||
$where['type'] = $type;
|
||||
@@ -51,7 +51,7 @@ class Decorate extends adminApi
|
||||
$return_list[$k]['id'] = $v['did'];
|
||||
$return_list[$k]['name'] = $v['title'];
|
||||
$return_list[$k]['type'] = $v['type'];
|
||||
$return_list[$k]['type_str'] = model('api/Decorate')->TypeArray[$v['type']];
|
||||
$return_list[$k]['type_str'] = model('api/Decorate')->TypeArray[$v['type']] ?? "--";
|
||||
$return_list[$k]['base_image'] = $v['base_image'];
|
||||
$return_list[$k]['file_type'] = $v['file_type'];
|
||||
$return_list[$k]['file_type_str'] = $v['file_type']==1 ? "SVGA" : "MP4";
|
||||
@@ -60,6 +60,9 @@ class Decorate extends adminApi
|
||||
$return_list[$k]['is_buy'] = $v['is_buy'];
|
||||
$return_list[$k]['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
|
||||
$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_data = [
|
||||
@@ -86,6 +89,8 @@ class Decorate extends adminApi
|
||||
$play_image = input('play_image', '');
|
||||
//靓号
|
||||
$special_num = input('special_num', '');
|
||||
$ext_value = input('ext_value', '');
|
||||
$price = input('price', 0);
|
||||
if($title==""){
|
||||
return V(0,"参数错");
|
||||
}
|
||||
@@ -104,7 +109,9 @@ class Decorate extends adminApi
|
||||
'special_num' => $special_num,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time(),
|
||||
'admin_id' => $admin_id
|
||||
'admin_id' => $admin_id,
|
||||
'ext_value' => $ext_value,
|
||||
'price' => $price,
|
||||
];
|
||||
$id = db::name($this->table)->insertGetId($data);
|
||||
if(!$id){
|
||||
@@ -143,6 +150,8 @@ class Decorate extends adminApi
|
||||
$file_type = input('file_type', 2);
|
||||
$play_image = input('play_image', '');
|
||||
$special_num = input('special_num', '');
|
||||
$ext_value = input('ext_value', '');
|
||||
$price = input('price', '');
|
||||
$data = [];
|
||||
if($title!=""){
|
||||
$data['title'] = $title;
|
||||
@@ -168,6 +177,12 @@ class Decorate extends adminApi
|
||||
if($special_num!=""){
|
||||
$data['special_num'] = $special_num;
|
||||
}
|
||||
if($ext_value!=""){
|
||||
$data['ext_value'] = $ext_value;
|
||||
}
|
||||
if($price!=""){
|
||||
$data['price'] = $price;
|
||||
}
|
||||
$data['updatetime'] = time();
|
||||
$res = db::name($this->table)->where(['did'=>$did])->update($data);
|
||||
if(!$res){
|
||||
@@ -256,7 +271,7 @@ class Decorate extends adminApi
|
||||
if($price==""){
|
||||
return V(0,"参数错");
|
||||
}
|
||||
$decorate_data = db::name($this->table)->where(['did'=>$did,'day'=>$day])->find();
|
||||
$decorate_data = db::name('vs_decorate_price')->where(['did'=>$did,'day'=>$day])->find();
|
||||
if($decorate_data){
|
||||
return V(0,"该价格已存在");
|
||||
}
|
||||
@@ -343,8 +358,8 @@ class Decorate extends adminApi
|
||||
$return_list[$k]['id'] = $v['udid'];
|
||||
$user_data = db::name('user')->where(['id'=>$v['user_id']])->find();
|
||||
$return_list[$k]['user_name'] = $user_data['user_code']."-".db::name('user')->where(['id'=>$v['user_id']])->value('nickname');
|
||||
$return_list[$k]['type'] = model('api/Decorate')->TypeArray[$v['type']];
|
||||
if($v['type'] >= 6){
|
||||
$return_list[$k]['type'] = model('api/Decorate')->TypeArray[$v['type']] ?? "";
|
||||
if(in_array($v['type'], [6,7,8])){
|
||||
$return_list[$k]['name'] = $v['special_num'];
|
||||
|
||||
}else{
|
||||
@@ -375,7 +390,7 @@ class Decorate extends adminApi
|
||||
public function give_decorate(){
|
||||
$user_id = input('user_id', '');
|
||||
$decorate_id = input('decorate_id', '');
|
||||
$day = input('day', '');
|
||||
$day = input('day', 0);
|
||||
$user = db::name('user')->where(['user_code'=>$user_id])->find();
|
||||
if(!$user){
|
||||
return V(0,"用户不存在");
|
||||
@@ -385,10 +400,12 @@ class Decorate extends adminApi
|
||||
if(!$decorate){
|
||||
return V(0,"装扮不存在");
|
||||
}
|
||||
if($decorate['type']!=12){
|
||||
$decorate_price = db::name('vs_decorate_price')->where(['did'=>$decorate_id,'day'=>$day,'is_delete'=>1])->find();
|
||||
if(!$decorate_price){
|
||||
return V(0,"该装扮天数不存在");
|
||||
}
|
||||
}
|
||||
$result = model('api/Decorate')->pay_decorate($user_id,$decorate_id,$day,2);
|
||||
if($result['code'] == 1){
|
||||
return V(1,"成功");
|
||||
|
||||
@@ -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;
|
||||
@@ -99,6 +100,7 @@ class Gift extends adminApi
|
||||
$lists[$key]['is_can_buy'] = $value['is_can_buy'];
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
$lists[$key]['updatetime'] = date('Y-m-d H:i:s', $value['updatetime']);
|
||||
$lists[$key]['icon'] = $value['icon']??"";
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
@@ -126,6 +128,7 @@ class Gift extends adminApi
|
||||
$is_can_buy = input('is_can_buy', 1);
|
||||
$is_show = input('is_show', 1);
|
||||
$sort = input('sort', 0);
|
||||
$icon = input('icon', '');
|
||||
if($gift_name==""){
|
||||
return V(0,"礼物名称不能为空");
|
||||
}
|
||||
@@ -156,12 +159,19 @@ class Gift extends adminApi
|
||||
'is_show' => $is_show,
|
||||
'sort' => $sort,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time()
|
||||
'updatetime' => time(),
|
||||
'icon' => $icon,
|
||||
];
|
||||
$id = db::name($this->table)->insertGetId($data);
|
||||
if(!$id){
|
||||
return V(0,"添加失败");
|
||||
}
|
||||
//删除缓存
|
||||
$cache_key = 'gift_list_'.$label.'_1';
|
||||
Cache::rm($cache_key);
|
||||
$cache_key = 'gift_list_'.$label;
|
||||
Cache::rm($cache_key);
|
||||
|
||||
return V(1,"成功",['id'=>$id]);
|
||||
}
|
||||
/*
|
||||
@@ -196,6 +206,7 @@ class Gift extends adminApi
|
||||
$is_can_buy = input('is_can_buy', '');
|
||||
$is_show = input('is_show', '');
|
||||
$sort = input('sort', '');
|
||||
$icon = input('icon', '');
|
||||
if($gid == ''){
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
@@ -245,10 +256,18 @@ class Gift extends adminApi
|
||||
if($is_show){
|
||||
$data['is_show'] = $is_show;
|
||||
}
|
||||
if($icon){
|
||||
$data['icon'] = $icon;
|
||||
}
|
||||
$result = db::name($this->table)->where(['gid'=>$gid])->update($data);
|
||||
if(!$result){
|
||||
return V(0,"修改失败,礼物内容无更改");
|
||||
}
|
||||
//删除缓存
|
||||
$cache_key = 'gift_list_'.$gift_data['label'].'_1';
|
||||
Cache::rm($cache_key);
|
||||
$cache_key = 'gift_list_'.$gift_data['label'];
|
||||
Cache::rm($cache_key);
|
||||
return V(1,"成功", ['id'=>$gid]);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,36 +31,46 @@ class GiveGift extends adminApi
|
||||
$end_time = input('end_time', '');
|
||||
|
||||
$where=[];
|
||||
$gwhere = [];
|
||||
if($send_user != ''){
|
||||
$user_id = db::name('user')->where('user_code', $send_user)->value('id');
|
||||
$where['user_id'] = $user_id;
|
||||
$gwhere['gg.user_id'] = $user_id;
|
||||
}
|
||||
if($gift_user != ''){
|
||||
$gift_user_id = db::name('user')->where('user_code', $gift_user)->value('id');
|
||||
$where['gift_user'] = $gift_user_id;
|
||||
$gwhere['gg.gift_user'] = $gift_user_id;
|
||||
}
|
||||
if($from_id != ''){
|
||||
$room_id = db::name('vs_room')->where('room_number', $from_id)->value('id');
|
||||
if($room_id){
|
||||
$where['from_id'] = $room_id;
|
||||
$gwhere['gg.from_id'] = $room_id;
|
||||
}else{
|
||||
$where['from_id'] = $from_id;
|
||||
$gwhere['gg.from_id'] = $from_id;
|
||||
}
|
||||
}
|
||||
if($gift_id != ''){
|
||||
$where['gift_id'] = $gift_id;
|
||||
$gwhere['gg.gift_id'] = $gift_id;
|
||||
}
|
||||
if($from != ''){
|
||||
$where['from'] = $from;
|
||||
$gwhere['gg.from'] = $from;
|
||||
}
|
||||
// 时间筛选优化
|
||||
if (!empty($start_time) || !empty($end_time)) {
|
||||
if (!empty($start_time) && !empty($end_time)) {
|
||||
$where['createtime'] = ['between', [strtotime($start_time), strtotime($end_time)]];
|
||||
$gwhere['gg.createtime'] = ['between', [strtotime($start_time), strtotime($end_time)]];
|
||||
} elseif (!empty($start_time)) {
|
||||
$where['createtime'] = ['>=', strtotime($start_time)];
|
||||
$gwhere['gg.createtime'] = ['>=', strtotime($start_time)];
|
||||
} elseif (!empty($end_time)) {
|
||||
$where['createtime'] = ['<=', strtotime($end_time)];
|
||||
$gwhere['gg.createtime'] = ['<=', strtotime($end_time)];
|
||||
}
|
||||
}
|
||||
//礼物总数
|
||||
@@ -79,15 +89,12 @@ class GiveGift extends adminApi
|
||||
$count = db::name('vs_give_gift')->where($where)->count();
|
||||
$earning_list = [];
|
||||
if(!empty($where)){
|
||||
$gift_ids = db::name('vs_give_gift')->where($where)->column('id');
|
||||
if (!empty($gift_ids)) {
|
||||
// 批量获取所有收益记录
|
||||
$earning_list = db::name('vs_give_gift_ratio_log')
|
||||
->field('app_earning,gift_user_earning,room_owner_earning')
|
||||
->where('give_gift_id', 'in', $gift_ids)
|
||||
->order('id', 'desc')
|
||||
->alias('egl')
|
||||
->join('vs_give_gift gg', 'egl.give_gift_id = gg.id')
|
||||
->where($gwhere) // 替换为实际的筛选条件
|
||||
->field('egl.app_earning,egl.gift_user_earning,egl.room_owner_earning')
|
||||
->select();
|
||||
}
|
||||
}else{
|
||||
// 批量获取所有收益记录
|
||||
$earning_list = db::name('vs_give_gift_ratio_log')
|
||||
@@ -199,6 +206,8 @@ class GiveGift extends adminApi
|
||||
$value['gift_user_earning'] = $earning_info ? $earning_info['gift_user_earning'] : 0;
|
||||
$value['room_owner_earning'] = $earning_info ? $earning_info['room_owner_earning'] : 0;
|
||||
}
|
||||
//比例
|
||||
$config = get_system_config();
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
@@ -209,7 +218,10 @@ class GiveGift extends adminApi
|
||||
'total_price' => $total_price,
|
||||
'app_earning' => round($app_earning,2) ,
|
||||
'receive_earning' => round($receive_earning,2),
|
||||
'room_owner_earning' => round($room_owner_earning,2)
|
||||
'room_owner_earning' => round($room_owner_earning,2),
|
||||
'app_earning_ratio' => 100 - $config['room_gift_ratio'] - $config['room_author_ratio'],
|
||||
'receive_earning_ratio' => $config['room_gift_ratio'] ?? 0,
|
||||
'room_owner_earning_ratio' => $config['room_author_ratio'] ?? 0,
|
||||
]
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
|
||||
@@ -62,7 +62,7 @@ class Guild extends adminApi
|
||||
// $where['createtime'] = ['between',[strtotime($search_stime),strtotime($search_etime.' 23:59:59')]];
|
||||
// }
|
||||
$count = db::name('vs_guild')->where($where)->count();
|
||||
$data = db::name('vs_guild')->where($where)->page($page,$page_limit)->select();
|
||||
$data = db::name('vs_guild')->where($where)->order('income desc')->page($page,$page_limit)->select();
|
||||
$list = [];
|
||||
foreach ($data as $k=>$v) {
|
||||
$list[$k]['id'] = $v['id'];
|
||||
@@ -82,14 +82,19 @@ class Guild extends adminApi
|
||||
}
|
||||
$list[$k]['guild_logo'] = $v['cover'];
|
||||
//当日流水
|
||||
$list[$k]['today_money'] = model('Guild')->getTodayMoney($v['id'],$search_stime,$search_etime);
|
||||
$list[$k]['today_money'] = $v['income'];//model('Guild')->getTodayMoney($v['id'],$search_stime,$search_etime);
|
||||
$list[$k]['is_show'] = $v['is_show'];
|
||||
$list[$k]['is_show_str'] = $v['is_show'] == 1 ? '显示' : '隐藏';
|
||||
$list[$k]['status'] = $v['status'];
|
||||
$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]['user_id'] = $user['user_code']??"";
|
||||
$list[$k]['intro'] = $v['intro'];
|
||||
//幸运币流水
|
||||
$list[$k]['lucky_coin'] = model('Guild')->getTodayMoneyLuckyCoin($v['id'],$search_stime,$search_etime);
|
||||
//查询会长手机号和后台登录密码
|
||||
$list[$k]['mobile'] = db::name('user')->where('id',$v['user_id'])->value('mobile');
|
||||
}
|
||||
// 数组按today_money 排序
|
||||
usort($list, function($a, $b) {
|
||||
@@ -102,7 +107,21 @@ class Guild extends adminApi
|
||||
$reslut['list'] = $list;
|
||||
return V(1,"成功", $reslut);
|
||||
}
|
||||
|
||||
/*
|
||||
* 工会显示状态修改
|
||||
*/
|
||||
public function guild_show_status_edit(){
|
||||
$id = input('id',0);
|
||||
$guild = model('Guild')->getOne(['id'=>$id]);
|
||||
if (!$guild) {
|
||||
return V(0, "数据不存在");
|
||||
}
|
||||
if ($guild) {
|
||||
$status = $guild['is_show'] == 1 ? 0 : 1;
|
||||
}
|
||||
$res = db::name('vs_guild')->where('id',$id)->update(['is_show'=>$status]);;
|
||||
return V(1,"成功", $res);
|
||||
}
|
||||
/**
|
||||
* 工会添加
|
||||
* @param guild_special_id 靓号 guild_special_id
|
||||
@@ -154,6 +173,15 @@ class Guild extends adminApi
|
||||
return V(0, "靓号已使用");
|
||||
}
|
||||
}
|
||||
if(empty($request['guild_user_mobile'])){
|
||||
return V(0, "请填写会长手机号");
|
||||
}
|
||||
if($request['guild_user_mobile'] != $user['mobile']){
|
||||
return V(0, "请正确填写会长手机号");
|
||||
}
|
||||
if(empty($request['password'])){
|
||||
return V(0, "请填写后台登录密码");
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$data = [
|
||||
@@ -186,8 +214,18 @@ class Guild extends adminApi
|
||||
$insert_data['room_id'] = $rid;
|
||||
$insert_data['status'] = 1;
|
||||
$insert_data['is_deacon'] = 1;
|
||||
$insert_data['apply_time'] = time();
|
||||
$insert_data['createtime'] = time();
|
||||
$insert_data['is_show_room'] = 1;
|
||||
//结算比例
|
||||
$configs = get_system_config();
|
||||
//未加入工会的收益
|
||||
$ratiogr = $configs['room_gift_ratio'];
|
||||
//收益增加 加入工会的收益
|
||||
$ratiog = $configs['room_gift_guild_ratio'];
|
||||
//收礼人最终的收益比例
|
||||
$ratio = $ratiogr + $ratiog;
|
||||
$insert_data['settlement_ratio'] = $ratio;
|
||||
$re = db::name('vs_guild_user')->insert($insert_data);
|
||||
if (!$re) {
|
||||
db::rollback();
|
||||
@@ -199,6 +237,26 @@ class Guild extends adminApi
|
||||
return V(0, $reslut['msg']);
|
||||
}
|
||||
model('api/Tencent')->send_group_system_notification('g'.$res, $request['guild_name'].'工会群聊创建成功');
|
||||
|
||||
//新功能
|
||||
//创建基础信息数据
|
||||
$boss_auth = db::name('user_auth')->where('mobile',$user['mobile'])->find();
|
||||
$data = [
|
||||
'guild_id' => $res,
|
||||
'boss_mobile' => $request['guild_user_mobile'] ?? $user['mobile'],
|
||||
'boss_name' => $boss_auth['real_name']?? '',
|
||||
'createtime' => time(),
|
||||
];
|
||||
db::name('vs_guild_data')->insert($data);
|
||||
//创建后台登录账号
|
||||
$data = [
|
||||
'guild_id' => $res,
|
||||
'guild_name' => $request['guild_name'],
|
||||
'username' => $request['guild_user_mobile'],
|
||||
'password' => $request['password'],
|
||||
'nickname' => $request['guild_name']."管理员",
|
||||
];
|
||||
model('guildadmin/Admin')->createAdmin($data);
|
||||
db::commit();
|
||||
return V(1,"成功", []);
|
||||
} catch (\Exception $e) {
|
||||
@@ -224,7 +282,7 @@ class Guild extends adminApi
|
||||
return V(0, "该工会不存在");
|
||||
}
|
||||
if (!empty($request['guild_name'])) {
|
||||
$guild_name = model('Guild')->getOne(['guild_name'=>$request['guild_name']]);
|
||||
$guild_name = model('Guild')->getOne(['guild_name'=>$request['guild_name'],'delete_time'=>0]);
|
||||
if (!empty($guild_name) && $guild_name['id'] != $request['id']) {
|
||||
return V(0, "该工会名称已存在");
|
||||
}
|
||||
@@ -248,10 +306,10 @@ class Guild extends adminApi
|
||||
if(isset($request['guild_name']) && $request['guild_name']){
|
||||
$data['guild_name'] = $request['guild_name'];
|
||||
}
|
||||
if(isset($request['user_id']) && $request['user_id']){
|
||||
$userID = db::name('user')->where('user_code',$request['user_id'])->value('id');
|
||||
$data['user_id'] = $userID;
|
||||
}
|
||||
// if(isset($request['user_id']) && $request['user_id']){
|
||||
// $userID = db::name('user')->where('user_code',$request['user_id'])->value('id');
|
||||
// $data['user_id'] = $userID;
|
||||
// }
|
||||
if(isset($request['guild_logo']) && $request['guild_logo']){
|
||||
$data['cover'] = $request['guild_logo'];
|
||||
}
|
||||
@@ -259,14 +317,56 @@ class Guild extends adminApi
|
||||
$data['intro'] = $request['guild_desc'];
|
||||
}
|
||||
$res = model('Guild')->edit(['id' => $request['id']], $data);
|
||||
if ($res) {
|
||||
//新功能
|
||||
//创建基础信息数据
|
||||
$guild_data = db::name('vs_guild_data')->where('guild_id',$guild['id'])->find();
|
||||
$user = db::name('user')->where('id',$guild['user_id'])->find();
|
||||
if($request['guild_user_mobile'] != $user['mobile']){
|
||||
db::rollback();
|
||||
return V(0, "请正确填写会长手机号");
|
||||
}
|
||||
if(empty($guild_data)){
|
||||
$boss_auth = db::name('user_auth')->where('mobile',$user['mobile'])->find();
|
||||
$data = [
|
||||
'guild_id' => $guild['id'],
|
||||
'boss_mobile' => $request['guild_user_mobile'] ?? $user['mobile'],
|
||||
'boss_name' => $boss_auth['real_name']?? '',
|
||||
'createtime' => time(),
|
||||
];
|
||||
db::name('vs_guild_data')->insert($data);
|
||||
}
|
||||
$guildadmin = db::name('vs_guild_admin')->where('guild_id',$guild['id'])->order('id','asc')->find();
|
||||
if(empty($guildadmin)){
|
||||
//创建后台登录账号
|
||||
$data = [
|
||||
'guild_id' => $guild['id'],
|
||||
'guild_name' => $guild['guild_name'],
|
||||
'username' => $request['guild_user_mobile'],
|
||||
'password' => $request['password'],
|
||||
'nickname' => $request['guild_name']."管理员",
|
||||
];
|
||||
$res = model('guildadmin/Admin')->createAdmin($data);
|
||||
if($res['code']==0){
|
||||
db::rollback();
|
||||
return V(0, $res['msg']);
|
||||
}
|
||||
}else{
|
||||
$up_data =[];
|
||||
if($request['guild_user_mobile'] != $guildadmin['username']){
|
||||
db::rollback();
|
||||
return V(0, "会长手机号填写错误");
|
||||
}
|
||||
if($request['password'] != ""){
|
||||
$up_data['password'] = $request['password'];
|
||||
}
|
||||
$res = model('guildadmin/Admin')->edit($guildadmin['id'],$up_data);
|
||||
if($res['code']==0){
|
||||
db::rollback();
|
||||
return V(0, $res['msg']);
|
||||
}
|
||||
}
|
||||
db::commit();
|
||||
return V(1, "修改成功");
|
||||
} else {
|
||||
db::rollback();
|
||||
return V(0, "修改失败");
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
db::rollback();
|
||||
return V(0, $e->getMessage());
|
||||
@@ -379,8 +479,8 @@ class Guild extends adminApi
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$guild_id = input('guild_id', 0);
|
||||
$search_stime = input('search_stime','');
|
||||
$search_etime = input('search_etime','');
|
||||
$search_stime_str = input('search_stime','');
|
||||
$search_etime_str = input('search_etime','');
|
||||
$room_id = input('room_id', 0);
|
||||
$where=['a.status'=>1];
|
||||
$where=['a.room_id'=>['>',0]];
|
||||
@@ -399,38 +499,84 @@ class Guild extends adminApi
|
||||
->where(['a.guild_id'=>$guild_id])->where($where)->count();
|
||||
$list = db::name($this->table_guild_user)->alias('a')
|
||||
->join('vs_room b', 'a.room_id = b.id', 'left')
|
||||
->where(['a.guild_id'=>$guild_id])->where($where)->page($page, $page_limit)->select();
|
||||
->where(['a.guild_id'=>$guild_id])->where($where)
|
||||
// ->page($page, $page_limit)
|
||||
->select();
|
||||
if(!$list){
|
||||
return V(0,"暂无数据");
|
||||
}
|
||||
$rum_lists = [];
|
||||
//总流水
|
||||
$total_consumption = 0;
|
||||
foreach ($list as $k=>$v){
|
||||
if($search_stime!="" && $v['createtime'] < strtotime($search_stime)){
|
||||
$search_stime = $search_stime;
|
||||
}else{
|
||||
$search_stime = date('Y-m-d H:i:s',$v['createtime']) ;
|
||||
$search_stime = $search_stime_str;
|
||||
$search_etime = $search_etime_str;
|
||||
// $search_stime = date('Y-m-d H:i:s','1761554521');
|
||||
// $search_etime = date('Y-m-d H:i:s','1766564906');
|
||||
if($search_stime!=""){
|
||||
if($v['apply_time'] && strtotime($search_stime) < $v['apply_time']) {
|
||||
$search_stime = date('Y-m-d H:i:s',$v['apply_time']);
|
||||
}
|
||||
if($v['quit_time']){
|
||||
if($search_etime!="" && $v['quit_time'] > strtotime($search_etime)){
|
||||
$search_etime = $search_etime;
|
||||
}else{
|
||||
$search_stime = date('Y-m-d H:i:s',$v['apply_time']);
|
||||
}
|
||||
if($search_etime!=""){
|
||||
if($v['quit_time'] && (strtotime($search_etime) > $v['quit_time'])){
|
||||
$search_etime = date('Y-m-d H:i:s',$v['quit_time']);
|
||||
}
|
||||
}else{
|
||||
if($v['quit_time']){
|
||||
$search_etime = date('Y-m-d H:i:s',$v['quit_time']);
|
||||
}else{
|
||||
$search_etime = date('Y-m-d H:i:s',time());
|
||||
}
|
||||
}
|
||||
|
||||
$room_info = db::name('vs_room')->where(['id'=>$v['room_id']])->find();
|
||||
$rum_lists[$k]['id']=$v['id'];
|
||||
$rum_lists[$k]['room_id']=$v['room_id'];
|
||||
$room_ids[] =$v['room_id'];
|
||||
$rum_lists[$k]['room_code']= model('api/Decorate')->user_decorate_detail($v['room_id'], 7);
|
||||
$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']);
|
||||
$total_consumption += $rum_lists[$k]['consumption'];
|
||||
//幸运币统计
|
||||
$where_lucky = [];
|
||||
if($search_stime !== ''){
|
||||
$where_lucky['createtime'] = ['>=', strtotime($search_stime)];
|
||||
}
|
||||
if($search_etime !== ''){
|
||||
$where_lucky['createtime'] = ['<=', strtotime($search_etime)];
|
||||
}
|
||||
if(!empty($search_stime) && !empty($search_etime)){
|
||||
$where_lucky['createtime'] = ['between',[strtotime($search_stime),strtotime($search_etime)]];
|
||||
}
|
||||
$rum_lists[$k]['lucky_coin'] = db::name('vs_room_luck_value')->where('room_id',$room_id)->where($where_lucky)->sum('luck_value');
|
||||
}
|
||||
usort($rum_lists, function($a, $b) {
|
||||
return $b['consumption'] - $a['consumption'];
|
||||
});
|
||||
//分页
|
||||
$rum_lists = array_slice($rum_lists, ($page-1)*$page_limit, $page_limit);
|
||||
//幸运币统计
|
||||
|
||||
$where_lucky = [];
|
||||
if($search_stime !== ''){
|
||||
$where_lucky['createtime'] = ['>=', strtotime($search_stime)];
|
||||
}
|
||||
if($search_etime !== ''){
|
||||
$where_lucky['createtime'] = ['<=', strtotime($search_etime)];
|
||||
}
|
||||
if(!empty($search_stime) && !empty($search_etime)){
|
||||
$where_lucky['createtime'] = ['between',[strtotime($search_stime),strtotime($search_etime)]];
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'total_consumption' => $total_consumption,
|
||||
'total_lucky_coin' => db::name('vs_room_luck_value')->whereIn('room_id',$room_ids)->where($where_lucky)->sum('luck_value'),
|
||||
'count' => $count,
|
||||
'lists' => $rum_lists
|
||||
];
|
||||
@@ -661,7 +807,7 @@ class Guild extends adminApi
|
||||
$lists_data = db::name($this->table_guild_subsidy)->alias('a')
|
||||
->join('vs_guild b','a.guild_id = b.id')
|
||||
->where($where)
|
||||
->order('a.id desc')
|
||||
->order('a.total_transaction desc')
|
||||
->field('a.*,b.guild_name,b.user_id,b.guild_special_id')
|
||||
->page($page,$page_limit)
|
||||
->select();
|
||||
|
||||
@@ -243,6 +243,8 @@ class Inform extends adminApi
|
||||
$from_info = db::name('vs_room')->where('id',$item['from_id'])->field('room_number as code,room_name as title')->find();
|
||||
}elseif($item['report_type'] ==3){
|
||||
$from_info = db::name('user_zone')->where('id',$item['from_id'])->field('content as title ,id as code')->find();
|
||||
}elseif($item['report_type'] ==4){
|
||||
$from_info = db::name('vs_guild')->where('id',$item['from_id'])->field('guild_name as title,id as code')->find();
|
||||
}
|
||||
$item['createtime'] = date('Y-m-d H:i:s', $item['createtime']);
|
||||
$item['updatetime'] = date('Y-m-d H:i:s', $item['updatetime']);
|
||||
@@ -253,7 +255,8 @@ class Inform extends adminApi
|
||||
$item['report_type_str'] = [
|
||||
1=>'用户',
|
||||
2=>'房间',
|
||||
3=>'动态'
|
||||
3=>'动态',
|
||||
4=>'公会'
|
||||
][$item['report_type']];
|
||||
|
||||
}
|
||||
@@ -307,5 +310,43 @@ class Inform extends adminApi
|
||||
}
|
||||
}
|
||||
|
||||
//安卓日志列表
|
||||
public function android_log_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$count = db::name('vs_android_log')->where('delete_time',0)->count();
|
||||
$list = db::name('vs_android_log')->where('delete_time',0)->order('id desc')->page($page, $page_limit)->select();
|
||||
foreach ($list as &$item) {
|
||||
$user_info = db::name('user')->where('id',$item['user_id'])->field('nickname,user_code')->find();
|
||||
if($user_info){
|
||||
$item['nickname'] = $user_info['user_code'] ."-".$user_info['nickname'];
|
||||
}else{
|
||||
$item['nickname'] = '';
|
||||
}
|
||||
$item['createtime'] = date('Y-m-d H:i:s', $item['createtime']);
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
//安卓日志删除
|
||||
public function android_log_delete(){
|
||||
$id = input('id', '');
|
||||
if($id){
|
||||
$res = db::name('vs_android_log')->where('id',$id)->update(['delete_time'=>time()]);
|
||||
if($res){
|
||||
return V(1,"成功");
|
||||
}
|
||||
else{
|
||||
return V(0,"失败");
|
||||
}
|
||||
}else{
|
||||
return V(0,"ID不能为空");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -125,28 +125,28 @@ class Level extends adminApi
|
||||
if($id == ''){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
if($level){
|
||||
if($level!=''){
|
||||
$level_data['level'] = $level;
|
||||
}
|
||||
if($name){
|
||||
if($name!=''){
|
||||
$level_data['name'] = $name;
|
||||
}
|
||||
if($image){
|
||||
if($image!=''){
|
||||
$level_data['image'] = $image;
|
||||
}
|
||||
if($status){
|
||||
if($status!=''){
|
||||
$level_data['status'] = $status;
|
||||
}
|
||||
if($change_value){
|
||||
if($change_value!=''){
|
||||
$level_data['change_value'] = $change_value;
|
||||
}
|
||||
if($coins){
|
||||
if($coins!=''){
|
||||
$level_data['coins'] = $coins;
|
||||
}
|
||||
if($bg_image){
|
||||
if($bg_image!=''){
|
||||
$level_data['bg_image'] = $bg_image;
|
||||
}
|
||||
if($color){
|
||||
if($color!=''){
|
||||
$level_data['color'] = $color;
|
||||
}
|
||||
$level_data['updatetime'] = time();
|
||||
|
||||
129
application/adminapi/controller/Lottery.php
Normal file
129
application/adminapi/controller/Lottery.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 等级管理
|
||||
* @internal
|
||||
*/
|
||||
class Lottery extends adminApi
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = [];
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
}
|
||||
/*
|
||||
* 配置列表
|
||||
*/
|
||||
public function config_list(){
|
||||
$list = db::name("bb_lottery_config")->order('sort desc')->select();
|
||||
$list_data = [];
|
||||
foreach ($list as $k=>$v){
|
||||
$list_data[$k]['id'] = $v['id'];
|
||||
$list_data[$k]['key'] = $v['key'];
|
||||
$list_data[$k]['value'] = $v['value'];
|
||||
$list_data[$k]['desc'] = $v['desc'];
|
||||
$list_data[$k]['sort'] = $v['sort'];
|
||||
}
|
||||
return V(1,"成功", $list_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 配置设置
|
||||
*/
|
||||
public function config_set(){
|
||||
$params = $this->request->post();
|
||||
foreach ($params as $k=>$v){
|
||||
$data = [
|
||||
'value'=>$v,
|
||||
];
|
||||
db::name("bb_lottery_config")->where(['key'=>$k])->update($data);
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
|
||||
/*
|
||||
* 中奖记录
|
||||
*/
|
||||
public function record_list(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$stime = input('stime', '');
|
||||
$etime = input('etime', '');
|
||||
$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('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();
|
||||
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'];
|
||||
//奖项类型:1-小奖 2-大奖
|
||||
$lists_data[$k]['prize_type_str'] = $v['prize_type']==1?"小奖":"大奖";
|
||||
//状态:1-已发放 0-未发放'
|
||||
$lists_data[$k]['status_str'] = $v['status']==1?"已发放":"未发放";
|
||||
$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);
|
||||
|
||||
}
|
||||
/*
|
||||
* 实时统计
|
||||
*/
|
||||
public function realtime_statistics(){
|
||||
$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."金币)";
|
||||
|
||||
//蓄水池当前金额
|
||||
$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();
|
||||
//平台累计收入
|
||||
$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']."%)",
|
||||
'platform_total_income' => $platform_total_income." 金币",
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
}
|
||||
417
application/adminapi/controller/Nobility.php
Normal file
417
application/adminapi/controller/Nobility.php
Normal file
@@ -0,0 +1,417 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 等级管理
|
||||
* @internal
|
||||
*/
|
||||
class Nobility extends adminApi
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = [];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
//获取爵位列表
|
||||
public function get_nobility_list()
|
||||
{
|
||||
$order = input('order', 'lid');
|
||||
$sort = input('sort', 'desc');
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$count = db::name('vs_nobility')->where('delete_time', 0)->count();
|
||||
$lists = db::name('vs_nobility')
|
||||
->field('lid,name,image,images,pay_price,pay_price,renew_price,pay_coin,renew_coin,day,power_ids,nick_name_color,nick_name_color_name,createtime,updatetime,play_image,enter_image')
|
||||
->where('delete_time', 0)
|
||||
->order($order, $sort)
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
foreach ($lists as &$v) {
|
||||
$v['createtime'] = $v['createtime'] ? date('Y-m-d H:i:s', $v['createtime']) : '--';
|
||||
$v['updatetime'] = $v['updatetime'] ? date('Y-m-d H:i:s', $v['updatetime']) : '--';
|
||||
$power_ids = $v['power_ids'] ? explode(',', $v['power_ids']) : [];
|
||||
$v['power_ids_array'] = db::name('vs_nobility_power')
|
||||
->field('id,name')
|
||||
->where(['id'=>['in',$power_ids]])->select();
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
//添加爵位
|
||||
public function add_nobility(){
|
||||
$name = input('name', '');
|
||||
$image = input('image', '');
|
||||
$images = input('images', '');
|
||||
$pay_price = input('pay_price', '');
|
||||
$pay_coin = input('pay_coin', '');
|
||||
$renew_price = input('renew_price', '');
|
||||
$renew_coin = input('renew_coin', '');
|
||||
$day = input('day', '');
|
||||
$nick_name_color = input('nick_name_color', '');
|
||||
$nick_name_color_name = input('nick_name_color_name', '');
|
||||
$power_ids = input('power_ids', '');
|
||||
$play_image = input('play_image', '');
|
||||
$enter_image = input('enter_image', '');
|
||||
if (empty($name)) {
|
||||
return V(0, "请输入爵位名称");
|
||||
}
|
||||
$nobility_info = db::name('vs_nobility')->where('name', $name)->find();
|
||||
if ($nobility_info) {
|
||||
return V(0, "该爵位已存在");
|
||||
}
|
||||
$data = [
|
||||
'name' => $name,
|
||||
'image' => $image,
|
||||
'images' => $images,
|
||||
'pay_price' => $pay_price,
|
||||
'pay_coin' => $pay_coin,
|
||||
'renew_price' => $renew_price,
|
||||
'renew_coin' => $renew_coin,
|
||||
'play_image' => $play_image,
|
||||
'enter_image' => $enter_image,
|
||||
'day' => $day,
|
||||
'nick_name_color' => $nick_name_color,
|
||||
'nick_name_color_name' => $nick_name_color_name,
|
||||
'createtime' => time(),
|
||||
'power_ids' => $power_ids
|
||||
];
|
||||
$result = db::name('vs_nobility')->insert($data);
|
||||
if ($result) {
|
||||
return V(1, "添加成功");
|
||||
} else {
|
||||
return V(0, "添加失败");
|
||||
}
|
||||
}
|
||||
|
||||
//编辑爵位
|
||||
public function edit_nobility(){
|
||||
$name = input('name', '');
|
||||
$image = input('image', '');
|
||||
$images = input('images', '');
|
||||
$pay_price = input('pay_price', '');
|
||||
$pay_coin = input('pay_coin', '');
|
||||
$renew_price = input('renew_price', '');
|
||||
$renew_coin = input('renew_coin', '');
|
||||
$day = input('day', '');
|
||||
$nick_name_color = input('nick_name_color', '');
|
||||
$nick_name_color_name = input('nick_name_color_name', '');
|
||||
$power_ids = input('power_ids', '');
|
||||
$play_image = input('play_image', '');
|
||||
$enter_image = input('enter_image', '');
|
||||
$lid = input('lid', '');
|
||||
$nobility_info = db::name('vs_nobility')->where('lid', $lid)->find();
|
||||
if (!$nobility_info) {
|
||||
return V(0, "该爵位不存在");
|
||||
}
|
||||
$data = [];
|
||||
if(!empty($name)){
|
||||
$nobility_info_other = db::name('vs_nobility')->where(['lid'=>['neq', $lid], 'name'=>$name])->find();
|
||||
if ($nobility_info_other) {
|
||||
return V(0, "该爵位已存在");
|
||||
}
|
||||
$data['name'] = $name;
|
||||
}
|
||||
if(!empty($image)){
|
||||
$data['image'] = $image;
|
||||
}
|
||||
if(!empty($images)){
|
||||
$data['images'] = $images;
|
||||
}
|
||||
if(!empty($pay_price)){
|
||||
$data['pay_price'] = $pay_price;
|
||||
}
|
||||
if(!empty($pay_coin)){
|
||||
$data['pay_coin'] = $pay_coin;
|
||||
}
|
||||
if(!empty($renew_price)){
|
||||
$data['renew_price'] = $renew_price;
|
||||
}
|
||||
if(!empty($renew_coin)){
|
||||
$data['renew_coin'] = $renew_coin;
|
||||
}
|
||||
if(!empty($day)){
|
||||
$data['day'] = $day;
|
||||
}
|
||||
if(!empty($nick_name_color)){
|
||||
$data['nick_name_color'] = $nick_name_color;
|
||||
}
|
||||
if(!empty($nick_name_color_name)){
|
||||
$data['nick_name_color_name'] = $nick_name_color_name;
|
||||
}
|
||||
if(!empty($power_ids)){
|
||||
$data['power_ids'] = $power_ids;
|
||||
}
|
||||
if(!empty($play_image)){
|
||||
$data['play_image'] = $play_image;
|
||||
}
|
||||
if(!empty($enter_image)){
|
||||
$data['enter_image'] = $enter_image;
|
||||
}
|
||||
$data['updatetime'] = time();
|
||||
$result = db::name('vs_nobility')->where('lid', $lid)->update($data);
|
||||
if ($result) {
|
||||
return V(1, "编辑成功");
|
||||
} else {
|
||||
return V(0, "编辑失败");
|
||||
}
|
||||
}
|
||||
|
||||
//删除爵位
|
||||
public function del_nobility(){
|
||||
$lid = input('lid', '');
|
||||
$nobility_info = db::name('vs_nobility')->where('lid', $lid)->find();
|
||||
if (!$nobility_info) {
|
||||
return V(0, "该爵位不存在");
|
||||
}
|
||||
$result = db::name('vs_nobility')->where('lid', $lid)->update(['delete_time'=>time()]);
|
||||
if ($result) {
|
||||
return V(1, "删除成功");
|
||||
} else {
|
||||
return V(0, "删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
//爵位权限列表
|
||||
public function get_nobility_power_list(){
|
||||
$order = input('order', 'id');
|
||||
$sort = input('sort', 'desc');
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$count = db::name('vs_nobility_power')->where('delete_time', 0)->count();
|
||||
$lists = db::name('vs_nobility_power')
|
||||
->field('id,name,content,image,images,createtime,updatetime')
|
||||
->where('delete_time', 0)
|
||||
->order($order, $sort)
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
//添加爵位权限
|
||||
public function add_nobility_power(){
|
||||
$name = input('name', '');
|
||||
$content = input('content', '');
|
||||
$image = input('image', '');
|
||||
$images = input('images', '');
|
||||
if (empty($name)) {
|
||||
return V(0, "请输入爵位权限名称");
|
||||
}
|
||||
$nobility_power_info = db::name('vs_nobility_power')->where('name', $name)->find();
|
||||
if ($nobility_power_info) {
|
||||
return V(0, "该爵位权限已存在");
|
||||
}
|
||||
$data = [
|
||||
'name' => $name,
|
||||
'content' => $content,
|
||||
'image' => $image,
|
||||
'images' => $images,
|
||||
'createtime' => time(),
|
||||
];
|
||||
$result = db::name('vs_nobility_power')->insert($data);
|
||||
if ($result) {
|
||||
return V(1, "添加成功");
|
||||
} else {
|
||||
return V(0, "添加失败");
|
||||
}
|
||||
}
|
||||
|
||||
//编辑爵位权限
|
||||
public function edit_nobility_power(){
|
||||
$name = input('name', '');
|
||||
$content = input('content', '');
|
||||
$image = input('image', '');
|
||||
$images = input('images', '');
|
||||
$id = input('id', '');
|
||||
$nobility_power_info = db::name('vs_nobility_power')->where('id', $id)->find();
|
||||
if (!$nobility_power_info) {
|
||||
return V(0, "该爵位权限不存在");
|
||||
}
|
||||
$data = [];
|
||||
if(!empty($name)){
|
||||
$nobility_power_info_other = db::name('vs_nobility_power')->where(['id'=>['neq', $id], 'name'=>$name])->find();
|
||||
if ($nobility_power_info_other) {
|
||||
return V(0, "该爵位权限已存在");
|
||||
}
|
||||
$data['name'] = $name;
|
||||
}
|
||||
if(!empty($content)){
|
||||
$data['content'] = $content;
|
||||
}
|
||||
if(!empty($image)){
|
||||
$data['image'] = $image;
|
||||
}
|
||||
if(!empty($images)){
|
||||
$data['images'] = $images;
|
||||
}
|
||||
$data['updatetime'] = time();
|
||||
$result = db::name('vs_nobility_power')->where('id', $id)->update($data);
|
||||
if ($result) {
|
||||
return V(1, "编辑成功");
|
||||
} else {
|
||||
return V(0, "编辑失败");
|
||||
}
|
||||
}
|
||||
|
||||
//删除爵位权限
|
||||
public function del_nobility_power(){
|
||||
$id = input('id', '');
|
||||
$nobility_power_info = db::name('vs_nobility_power')->where('id', $id)->find();
|
||||
if (!$nobility_power_info) {
|
||||
return V(0, "该爵位权限不存在");
|
||||
}
|
||||
$result = db::name('vs_nobility_power')->where('id', $id)->update(['delete_time'=>time()]);
|
||||
if ($result) {
|
||||
return V(1, "删除成功");
|
||||
} else {
|
||||
return V(0, "删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
//用户爵位列表
|
||||
public function get_user_nobility_list(){
|
||||
$order = input('order', 'id');
|
||||
$sort = input('sort', 'desc');
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$count = db::name('vs_user_nobility')->where('delete_time', 0)->count();
|
||||
$lists = db::name('vs_user_nobility')
|
||||
->field('id,user_id,lid,end_time,createtime,updatetime')
|
||||
->where('delete_time', 0)
|
||||
->order($order, $sort)
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
foreach ($lists as &$list){
|
||||
$list['user_code'] = db::name('user')->where('id', $list['user_id'])->value('user_code');
|
||||
$list['user_nick_name'] = db::name('user')->where('id', $list['user_id'])->value('nickname');
|
||||
$list['nick_name_color'] = db::name('vs_nobility')->where('lid', $list['lid'])->value('nick_name_color');
|
||||
//头像
|
||||
$list['user_avatar'] = db::name('user')->where('id', $list['user_id'])->value('avatar');
|
||||
//爵位名称
|
||||
$list['nobility_name'] = db::name('vs_nobility')->where('lid', $list['lid'])->value('name');
|
||||
$list['createtime'] = $list['createtime'] ? date('Y-m-d H:i:s', $list['createtime']) : '--';
|
||||
$list['updatetime'] = $list['updatetime'] ? date('Y-m-d H:i:s', $list['updatetime']) : '--';
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
//装扮添加
|
||||
public function add_nobility_decorate(){
|
||||
$lid = input('lid', '');
|
||||
$dpid = input('dpid', '');
|
||||
if (empty($lid)) {
|
||||
return V(0, "请选择爵位");
|
||||
}
|
||||
if (empty($dpid)) {
|
||||
return V(0, "请选择装扮");
|
||||
}
|
||||
$decorate_price = db::name('vs_decorate_price')->where(['id'=>$dpid])->find();
|
||||
if (!$decorate_price) {
|
||||
return V(0, "该装扮不存在");
|
||||
}
|
||||
$decorate = db::name('vs_decorate')->where(['did'=>$decorate_price['did']])->find();
|
||||
if (!$decorate) {
|
||||
return V(0, "该装扮不存在");
|
||||
}
|
||||
$nobility_dress_info = db::name('vs_nobility_decorate')
|
||||
->where('delete_time', 0)
|
||||
->where(['lid'=>$lid, 'dpid'=>$dpid])->find();
|
||||
if ($nobility_dress_info) {
|
||||
return V(0, "该爵位已添加该装扮");
|
||||
}
|
||||
$data = [
|
||||
'lid' => $lid,
|
||||
'did' => $decorate['did'],
|
||||
'type' => $decorate['type'],
|
||||
'dpid' => $dpid,
|
||||
'day' => $decorate_price['day'],
|
||||
'createtime' => time(),
|
||||
];
|
||||
$result = db::name('vs_nobility_decorate')->insert($data);
|
||||
if ($result) {
|
||||
return V(1, "添加成功");
|
||||
} else {
|
||||
return V(0, "添加失败");
|
||||
}
|
||||
}
|
||||
//装扮列表
|
||||
public function get_nobility_decorate_list(){
|
||||
$order = input('order', 'id');
|
||||
$sort = input('sort', 'desc');
|
||||
$page = input('page', 1);
|
||||
$lid = input('lid', '');
|
||||
$page_limit = input('page_limit', 30);
|
||||
$count = db::name('vs_nobility_decorate')->where('delete_time', 0)->count();
|
||||
$lists = db::name('vs_nobility_decorate')
|
||||
->field('id,lid,did,type,dpid,day,createtime,updatetime')
|
||||
->where('delete_time', 0)
|
||||
->where('lid', $lid)
|
||||
->order($order, $sort)
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
$list = [];
|
||||
foreach ($lists as $key =>$value){
|
||||
$decorate = db::name('vs_decorate')->where('did', $value['did'])->find();
|
||||
$list[$key]['id'] = $value['id'];
|
||||
$list[$key]['lid'] = $value['lid'];
|
||||
$list[$key]['did'] = $value['did'];
|
||||
$list[$key]['dpid'] = $value['dpid'];
|
||||
$list[$key]['decorate_name'] = $decorate['title'] ?? '';
|
||||
$list[$key]['decorate_day'] = db::name('vs_decorate_price')->where('id', $value['dpid'])->value('day');
|
||||
$list[$key]['decorate_type_name'] = model('api/Decorate')->TypeArray[$value['type']] ?? '';
|
||||
$list[$key]['decorate_image'] = $decorate['base_image'] ?? '';
|
||||
$list[$key]['createtime'] = $value['createtime'] ? date('Y-m-d H:i:s', $value['createtime']) : '--';
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
//装扮删除
|
||||
public function del_nobility_decorate(){
|
||||
$id = input('id', '');
|
||||
$nobility_decorate_info = db::name('vs_nobility_decorate')->where('id', $id)->find();
|
||||
if (!$nobility_decorate_info) {
|
||||
return V(0, "该爵位装扮不存在");
|
||||
}
|
||||
$result = db::name('vs_nobility_decorate')->where('id', $id)->update(['delete_time'=>time()]);
|
||||
if ($result) {
|
||||
return V(1, "删除成功");
|
||||
} else {
|
||||
return V(0, "删除失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,14 +71,24 @@ class Room extends adminApi
|
||||
$label_icon = input('label_icon', '');
|
||||
$label_icon_room = input('label_icon_room', '');
|
||||
$status = input('status', 1);
|
||||
$default_index = input('default_index', 0);
|
||||
$sort = input('sort', 99);
|
||||
if($label_name == ''){
|
||||
return V(0,"请输入房间标签名称");
|
||||
}
|
||||
if($default_index == 1){
|
||||
$lebel_data = db::name($this->table_room_label)->where(['default_index'=>1])->find();
|
||||
if($lebel_data){
|
||||
db::name($this->table_room_label)->where(['id'=>$lebel_data['id']])->update(['default_index'=>0]);
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'label_name' => $label_name,
|
||||
'label_icon' => $label_icon,
|
||||
'label_icon_room' => $label_icon_room,
|
||||
'status' => $status,
|
||||
'default_index' => $default_index,
|
||||
'sort' => $sort,
|
||||
'updatetime' => time(),
|
||||
'createtime' => time()
|
||||
];
|
||||
@@ -144,6 +154,8 @@ class Room extends adminApi
|
||||
$label_icon = input('label_icon', '');
|
||||
$label_icon_room = input('label_icon_room', '');
|
||||
$status = input('status', 1);
|
||||
$default_index = input('default_index', 0);
|
||||
$sort = input('sort', 99);
|
||||
if($label_id == ''){
|
||||
return V(0,"标签ID不能为空");
|
||||
}
|
||||
@@ -171,6 +183,18 @@ class Room extends adminApi
|
||||
if($status){
|
||||
$data['status'] = $status;
|
||||
}
|
||||
if($default_index == 1){
|
||||
$lebel_data = db::name($this->table_room_label)->where(['default_index'=>1])->find();
|
||||
if($lebel_data){
|
||||
db::name($this->table_room_label)->where(['id'=>$lebel_data['id']])->update(['default_index'=>0]);
|
||||
}
|
||||
}
|
||||
$data['default_index'] = $default_index;
|
||||
if($sort){
|
||||
$data['sort'] = $sort;
|
||||
}
|
||||
|
||||
|
||||
$data['updatetime'] = time();
|
||||
$result = db::name($this->table_room_label)->where(['id'=>$label_id])->update($data);
|
||||
if(!$result){
|
||||
@@ -386,6 +410,12 @@ class Room extends adminApi
|
||||
public function edit_relation(){
|
||||
$relation_id = input('relation_id', '');
|
||||
$name = input('name', '');
|
||||
if($relation_id == 0){
|
||||
if($name != '无'){
|
||||
return V(0,'此关系不允许修改');
|
||||
}
|
||||
}
|
||||
|
||||
$type = input('type', '');
|
||||
$is_open_movie = input('is_open_movie', 1);
|
||||
$icon = input('icon', '');
|
||||
@@ -445,6 +475,8 @@ class Room extends adminApi
|
||||
}
|
||||
if($type_id!==''){
|
||||
$where['type_id'] = $type_id;
|
||||
}else{
|
||||
$where['type_id'] = ['<>',6];
|
||||
}
|
||||
if($label_id!==''){
|
||||
$where['label_id'] = $label_id;
|
||||
@@ -460,7 +492,6 @@ class Room extends adminApi
|
||||
}
|
||||
//房间列表只展示 审核通过的房间
|
||||
$where['apply_status'] = 2;//1待审核 2审核通过 3审核失败
|
||||
$where['type_id'] = ['<>',6];
|
||||
$count = db::name($this->table)->where($where)->count();
|
||||
$room_lists = db::name($this->table)->where($where)->page($page, $page_limit)->select();
|
||||
$lists = [];
|
||||
@@ -662,6 +693,8 @@ class Room extends adminApi
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 10);
|
||||
$type = input('type', 1);//1:全部流水 2:日流水 3:周流水 4:月流水
|
||||
$stime = input('stime', '');
|
||||
$etime = input('etime', '');
|
||||
if($room_id == ''){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
@@ -687,6 +720,19 @@ class Room extends adminApi
|
||||
$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')
|
||||
@@ -716,6 +762,8 @@ class Room extends adminApi
|
||||
|
||||
}
|
||||
}
|
||||
//幸运流水总计
|
||||
$total_lucky_coin = db::name('vs_room_luck_value')->alias('a')->where('room_id',$room_id)->where($where)->sum('luck_value');
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
@@ -726,7 +774,8 @@ class Room extends adminApi
|
||||
->join('user b', 'a.user_id = b.id', 'left')
|
||||
->where('a.from',2)
|
||||
->where('a.from_id',$room_id)
|
||||
->where($where)->sum('total_price')
|
||||
->where($where)->sum('total_price'),
|
||||
'total_lucky_coin' => $total_lucky_coin,
|
||||
]
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
@@ -768,6 +817,26 @@ class Room extends adminApi
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
//添加房间
|
||||
public function add_room(){
|
||||
$admin_id = Session::get('admin_id');
|
||||
$user_code = input('user_code', '');
|
||||
$room_name = input('room_name', '');
|
||||
$room_cover = input('room_cover', '');
|
||||
$room_intro = input('room_intro', '');
|
||||
if($user_code == '' || $room_name == '' || $room_cover == '' || $room_intro == ''){
|
||||
return V(0,"参数错误");
|
||||
}
|
||||
$user_id = db::name('user')->where('user_code', $user_code)->value('id');
|
||||
if(!$user_id){
|
||||
return V(0,"用户不存在");
|
||||
}
|
||||
$reslut = model('api/Room')->user_create_room($user_id, $room_name, $room_cover, $room_intro,0,0);
|
||||
if($reslut['code'] == 0){
|
||||
return V(0,$reslut['msg']);
|
||||
}
|
||||
return V(1,"成功", $reslut);
|
||||
}
|
||||
|
||||
//编辑房间
|
||||
public function edit_room()
|
||||
@@ -875,6 +944,12 @@ class Room extends adminApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//排序
|
||||
$sort = input('sort', '');//排序 越大越靠前
|
||||
if($sort !== ""){
|
||||
$data['sort'] = $sort;
|
||||
}
|
||||
$res = db::name('vs_room')->where('id',$room_id)->update($data);
|
||||
if($res){
|
||||
return V(1,"成功");
|
||||
@@ -1321,7 +1396,8 @@ class Room extends adminApi
|
||||
|
||||
foreach ($room_lists as &$value) {
|
||||
$value['room_code'] = model('api/Decorate')->user_decorate_detail($value['id'], 7);
|
||||
$value['user_name'] = model('User')->where(['id'=>$value['user_id']])->value('nickname').'-'.$value['user_id'];
|
||||
$user_code = db::name('user')->where(['id'=>$value['user_id']])->value('user_code');
|
||||
$value['user_name'] = model('User')->where(['id'=>$value['user_id']])->value('nickname').'-'.$user_code;
|
||||
$value['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
$value['room_name'] = $value['room_name'].'-'.$value['room_number'];
|
||||
}
|
||||
@@ -1362,6 +1438,8 @@ class Room extends adminApi
|
||||
//发系统信息
|
||||
if($apply_status ==2){
|
||||
$deal_content = '审核通过';
|
||||
//首次建立房间【完成任务】
|
||||
model('api/Tasks')->tasks_complete($room_data['user_id'],34);
|
||||
}elseif($apply_status ==3){
|
||||
$deal_content = '审核未通过';
|
||||
}
|
||||
|
||||
227
application/adminapi/controller/RoomEmoji.php
Normal file
227
application/adminapi/controller/RoomEmoji.php
Normal file
@@ -0,0 +1,227 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\admin\model\AdminLog;
|
||||
use app\common\controller\adminApi;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Hook;
|
||||
use think\Model;
|
||||
use think\Session;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 房间
|
||||
* @internal
|
||||
*/
|
||||
class RoomEmoji extends adminApi
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = ['emoji_list','add_emoji','edit_emoji','del_emoji','emoji_detail','emoji_type_list'];
|
||||
|
||||
protected $table = 'vs_room_emoji';
|
||||
protected $table_type = 'vs_room_emoji_type';
|
||||
|
||||
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
|
||||
|
||||
}
|
||||
//房间表情列表
|
||||
function emoji_list(){
|
||||
$id = input('id', '', 'intval');
|
||||
$name = input('name', '', 'trim');
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$where = [];
|
||||
if ($id) {
|
||||
$where['id'] = $id;
|
||||
}
|
||||
if ($name) {
|
||||
$where['name'] = ['like', '%' . $name . '%'];
|
||||
}
|
||||
$total = Db::name($this->table)
|
||||
->where($where)
|
||||
->count();
|
||||
$list = Db::name($this->table)
|
||||
->where($where)
|
||||
->where(['deletetime' => 0])
|
||||
->order('sort desc,id desc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
foreach ($list as &$item) {
|
||||
$item['type_str'] = Db::name($this->table_type)->where('id', $item['type_id'])->value('type_name');
|
||||
$item['createtime'] = date('Y-m-d H:i:s', $item['createtime']);
|
||||
$item['status_str'] = $item['status'] == 1 ? '显示' : '隐藏';
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $total,
|
||||
'list' => $list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
//添加房间表情
|
||||
function add_emoji(){
|
||||
$pid = input('pid', 0, 'intval');
|
||||
$name = input('name', '', 'trim');
|
||||
$img = input('image', '', 'trim');
|
||||
$animate_image = input('animate_image', '', 'trim');
|
||||
$sort = input('sort', 0, 'intval');
|
||||
$type_id = input('type_id', 0);
|
||||
$status = input('status', 1, 'intval');
|
||||
if (!$name) {
|
||||
return V(0, '请输入表情名称');
|
||||
}
|
||||
if (!$img) {
|
||||
return V(0, '请上传表情图片');
|
||||
}
|
||||
if (!$type_id) {
|
||||
return V(0, '请选择表情类型');
|
||||
}
|
||||
$data = [
|
||||
'pid' => $pid,
|
||||
'name' => $name,
|
||||
'image' => $img,
|
||||
'animate_image' => $animate_image,
|
||||
'sort' => $sort,
|
||||
'type_id' => $type_id,
|
||||
'status' => $status,
|
||||
'createtime' => time(),
|
||||
];
|
||||
$res = Db::name($this->table)->insert($data);
|
||||
if ($res) {
|
||||
return V(1, '添加成功');
|
||||
}
|
||||
}
|
||||
//房间表情修改
|
||||
function edit_emoji(){
|
||||
$id = input('id', 0, 'intval');
|
||||
$name = input('name', '', 'trim');
|
||||
$img = input('image', '', 'trim');
|
||||
$animate_image = input('animate_image', '', 'trim');
|
||||
$sort = input('sort', 0, 'intval');
|
||||
$type_id = input('type_id', 0);
|
||||
$status = input('status', 1, 'intval');
|
||||
if (!$id) {
|
||||
return V(0, '请选择要修改的表情');
|
||||
}
|
||||
if($name){
|
||||
$data['name'] = $name;
|
||||
}
|
||||
if($img){
|
||||
$data['image'] = $img;
|
||||
}
|
||||
if($animate_image){
|
||||
$data['animate_image'] = $animate_image;
|
||||
}
|
||||
if($sort){
|
||||
$data['sort'] = $sort;
|
||||
}
|
||||
if($type_id){
|
||||
$data['type_id'] = $type_id;
|
||||
}
|
||||
$data['status'] = $status;
|
||||
$res = Db::name($this->table)->where('id',$id)->update($data);
|
||||
if ($res) {
|
||||
return V(1, '修改成功');
|
||||
}
|
||||
}
|
||||
//房间表情删除
|
||||
function del_emoji(){
|
||||
$id = input('id', 0, 'intval');
|
||||
if (!$id) {
|
||||
return V(0, '请选择要删除的表情');
|
||||
}
|
||||
$res = Db::name($this->table)->where('id',$id)->update(
|
||||
['deletetime' => time()]
|
||||
);
|
||||
if ($res) {
|
||||
return V(1, '删除成功');
|
||||
}
|
||||
}
|
||||
//表情详情
|
||||
function emoji_detail(){
|
||||
$id = input('id', 0, 'intval');
|
||||
if (!$id) {
|
||||
return V(0, '请选择要查看的表情');
|
||||
}
|
||||
$detail = Db::name($this->table)->where('id',$id)->find();
|
||||
if (!$detail) {
|
||||
return V(0, '表情不存在');
|
||||
}
|
||||
return V(1,"成功", $detail);
|
||||
}
|
||||
|
||||
//表情类型列表
|
||||
function emoji_type_list(){
|
||||
$emoji_type = Db::name($this->table_type)
|
||||
->field('id,type_name')
|
||||
->where(['deletetime'=>0,'status'=>1])
|
||||
->order('sort desc,id desc')
|
||||
->select();
|
||||
return V(1,"成功", $emoji_type);
|
||||
}
|
||||
|
||||
//表情类型添加
|
||||
function add_emoji_type(){
|
||||
$type_name = input('type_name', '', 'trim');
|
||||
if (!$type_name) {
|
||||
return V(0, '请输入表情类型名称');
|
||||
}
|
||||
$data = [
|
||||
'type_name' => $type_name,
|
||||
'sort' => 0,
|
||||
'status' => 1,
|
||||
'createtime' => time(),
|
||||
];
|
||||
$res = Db::name($this->table_type)->insert($data);
|
||||
if ($res) {
|
||||
return V(1, '添加成功');
|
||||
}
|
||||
}
|
||||
//表情类型修改
|
||||
function edit_emoji_type(){
|
||||
$id = input('id', 0, 'intval');
|
||||
$type_name = input('type_name', '', 'trim');
|
||||
$sort = input('sort', 0, 'intval');
|
||||
$status = input('status', 1, 'intval');
|
||||
if (!$id) {
|
||||
return V(0, '请选择要修改的表情类型');
|
||||
}
|
||||
if($type_name){
|
||||
$data['type_name'] = $type_name;
|
||||
}
|
||||
if($sort){
|
||||
$data['sort'] = $sort;
|
||||
}
|
||||
if($status){
|
||||
$data['status'] = $status;
|
||||
}
|
||||
$res = Db::name($this->table_type)->where('id',$id)->update($data);
|
||||
if ($res) {
|
||||
return V(1, '修改成功');
|
||||
}
|
||||
return V(0, '修改失败');
|
||||
}
|
||||
//表情类型删除
|
||||
function del_emoji_type(){
|
||||
$id = input('id', 0, 'intval');
|
||||
if (!$id) {
|
||||
return V(0, '请选择要删除的表情类型');
|
||||
}
|
||||
$res = Db::name($this->table_type)->where('id',$id)->update(
|
||||
['deletetime' => time()]
|
||||
);
|
||||
if ($res) {
|
||||
return V(1, '删除成功');
|
||||
}
|
||||
return V(0, '删除失败');
|
||||
}
|
||||
}
|
||||
256
application/adminapi/controller/SingerSong.php
Normal file
256
application/adminapi/controller/SingerSong.php
Normal file
@@ -0,0 +1,256 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\common\controller\adminApi;
|
||||
use think\Db;
|
||||
use think\Session;
|
||||
|
||||
class SingerSong extends adminApi
|
||||
{
|
||||
|
||||
//歌手认证列表
|
||||
public function singerList()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$search = input('search', '');
|
||||
$status = input('status', '');
|
||||
$where=[];
|
||||
$wheres = [];
|
||||
//搜索信息有值且是纯数字
|
||||
if(is_numeric($search)){
|
||||
$where['u.user_code'] = $search;
|
||||
$user_id = db::name('user')->where('user_code', $search)->value('id');
|
||||
$wheres['user_id'] = $user_id;
|
||||
}
|
||||
if($search && !is_numeric($search)){
|
||||
$where['u.nickname'] = ['like', '%'.$search.'%'];
|
||||
$user_id = db::name('user')->where('nickname', $search)->value('id');
|
||||
$wheres['user_id'] = $user_id;
|
||||
}
|
||||
if($start_time && $end_time){
|
||||
$where['ss.createtime'] = ['between', [strtotime($start_time), strtotime($end_time)]];
|
||||
$wheres['createtime'] = ['between', [strtotime($start_time), strtotime($end_time)]];
|
||||
}
|
||||
if($status){
|
||||
$where['ss.status'] = $status;
|
||||
$wheres['status'] = $status;
|
||||
}
|
||||
|
||||
$count = db::name('vs_singer')->where($wheres)->count();
|
||||
$list = db::name('vs_singer')
|
||||
->alias('ss')
|
||||
->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')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
if($list){
|
||||
foreach ($list as &$v){
|
||||
$v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
|
||||
}
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
//歌手认证编辑
|
||||
public function singerEdit()
|
||||
{
|
||||
$id = input('id', '');
|
||||
if(empty($id)){
|
||||
return V(0, '参数错误');
|
||||
}
|
||||
$data = [
|
||||
'status' => input('status', ''),
|
||||
'remark' => input('remark', ''),
|
||||
];
|
||||
$res = db::name('vs_singer')->where('id', $id)->update($data);
|
||||
if($res){
|
||||
//推送消息-歌手认真成功
|
||||
//发系统信息
|
||||
if($data['status'] ==1){
|
||||
$deal_content = '审核通过';
|
||||
}elseif($data['status'] ==2){
|
||||
$deal_content = '审核拒绝';
|
||||
}
|
||||
if(!empty($data['remark'])){
|
||||
$deal_content .= ',原因:'.$data['remark'];
|
||||
}
|
||||
db::name('system_message')->insert([
|
||||
'title' => '歌手认证审核结果',
|
||||
'content' => '您的歌手认证申请 '.$deal_content,
|
||||
'type' => 1,
|
||||
'admin_id' => Session::get('admin_id'),
|
||||
'receiving_id' => db::name('vs_singer')->where('id', $id)->value('user_id'),
|
||||
'createtime' => time(),
|
||||
]);
|
||||
return V(1, '操作成功');
|
||||
}else{
|
||||
return V(0, '操作失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//认证歌手歌曲列表
|
||||
public function singerSongList()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$user_id = input('user_id', '');
|
||||
$where=[];
|
||||
if($user_id){
|
||||
$where['user_id'] = $user_id;
|
||||
}else{
|
||||
return V(0, '请填写用户ID');
|
||||
}
|
||||
$count = db::name('vs_singer_song')->where($where)->count();
|
||||
$list = db::name('vs_singer_song')
|
||||
->alias('o')
|
||||
->join('user u', 'o.user_id=u.id', 'left')
|
||||
->join('vs_gift g', 'o.gift_id=g.gid', 'left')
|
||||
->field('o.*,u.nickname,u.user_code,g.gift_name,g.gift_price')
|
||||
->where($where)
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
//歌手等级列表
|
||||
public function singerLevelList()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
|
||||
$where = ['deletetime' => 0];
|
||||
$count = db::name('vs_singer_level')->where($where)->count();
|
||||
$list = db::name('vs_singer_level')
|
||||
->where($where)
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
|
||||
//编辑歌手等级
|
||||
public function singerLevelEdit()
|
||||
{
|
||||
$id = input('id', '');
|
||||
//没有 id就是新增
|
||||
if(empty($id)){
|
||||
$data = [
|
||||
'level' => input('level', ''),
|
||||
'name' => input('name', ''),
|
||||
'image' => input('image', ''),
|
||||
'change_value' => input('change_value', ''),
|
||||
'rights_icon' => input('rights_icon', ''),
|
||||
'bg_image' => input('bg_image', ''),
|
||||
'color' => input('color', ''),
|
||||
'createtime' => time(),
|
||||
];
|
||||
$res = db::name('vs_singer_level')->insert($data);
|
||||
if($res){
|
||||
return V(1, '操作成功');
|
||||
}else{
|
||||
return V(0, '操作失败');
|
||||
}
|
||||
}else{
|
||||
$data = [
|
||||
'level' => input('level', ''),
|
||||
'name' => input('name', ''),
|
||||
'image' => input('image', ''),
|
||||
'change_value' => input('change_value', ''),
|
||||
'rights_icon' => input('rights_icon', ''),
|
||||
'bg_image' => input('bg_image', ''),
|
||||
'color' => input('color', ''),
|
||||
];
|
||||
$res = db::name('vs_singer_level')->where('id', $id)->update($data);
|
||||
if($res){
|
||||
return V(1, '操作成功');
|
||||
}else{
|
||||
return V(0, '操作失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//歌手等级删除
|
||||
public function singerLevelDel()
|
||||
{
|
||||
$id = input('id', '');
|
||||
$data['deletetime'] = time();
|
||||
$res = db::name('vs_singer_level')->where('id', $id)->update($data);
|
||||
if($res){
|
||||
return V(1, '操作成功');
|
||||
}else{
|
||||
return V(0, '操作失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//点歌信息列表
|
||||
public function songList()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$type = input('type', 3);//1-今天,2-本周,3-本月,4-昨天
|
||||
$room_id = input('room_id', '');
|
||||
|
||||
$where=[];
|
||||
if($room_id){
|
||||
$where['room_id'] = $room_id;
|
||||
}else{
|
||||
return V(0, '请填写房间ID');
|
||||
}
|
||||
if($type==1){
|
||||
$where['o.createtime'] = ['between', [strtotime(date('Y-m-d')), strtotime(date('Y-m-d', strtotime('+1 day')))]];
|
||||
}elseif($type==2){
|
||||
$where['o.createtime'] = ['between', [strtotime(date('Y-m-d', strtotime('-7 day'))), strtotime(date('Y-m-d'))]];
|
||||
}elseif($type==3){
|
||||
$where['o.createtime'] = ['between', [strtotime(date('Y-m-01')), strtotime(date('Y-m-t', strtotime(date('Y-m-01'))))]];
|
||||
}elseif($type==4){
|
||||
$where['o.createtime'] = ['between', [strtotime(date('Y-m-d', strtotime('-1 day'))), strtotime(date('Y-m-d'))]];
|
||||
}
|
||||
$count = db::name('vs_song_log')->alias('o')->where($where)->count();
|
||||
$list = db::name('vs_song_log')
|
||||
->alias('o')
|
||||
->join('user u', 'o.user_id=u.id', 'left')
|
||||
->join('vs_singer_song r', 'o.singer_song_id=r.id', 'left')
|
||||
->join('user uu', 'r.user_id=u.id', 'left')
|
||||
->join('vs_gift g', 'r.gift_id=g.gid', 'left')
|
||||
->field('o.*,u.nickname boss_nickname,u.user_code boss_user_code,r.song_name,r.gift_num,uu.nickname singer_nickname,uu.user_code singer_user_code,g.gift_name,g.gift_price')
|
||||
->where($where)
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -270,15 +270,41 @@ class Statistical extends adminApi
|
||||
$lists[$key]['room_cover'] = db::name('vs_room')->where('id', $value['from_id'])->value('room_cover');
|
||||
$label = db::name('vs_room')->where('id', $value['from_id'])->value('label_id');
|
||||
$lists[$key]['label'] = db::name('vs_room_label')->where('id', $label)->value('label_name');
|
||||
//幸运币统计
|
||||
$where_lucky = [];
|
||||
if($begin_time !== ''){
|
||||
$where_lucky['createtime'] = ['>=', strtotime($begin_time)];
|
||||
}
|
||||
if($end_time !== ''){
|
||||
$where_lucky['createtime'] = ['<=', strtotime($end_time)];
|
||||
}
|
||||
if(!empty($begin_time) && !empty($end_time)){
|
||||
$where_lucky['createtime'] = ['between',[strtotime($begin_time),strtotime($end_time)]];
|
||||
}
|
||||
$lists[$key]['lucky_coin'] = db::name('vs_room_luck_value')->where('room_id',$value['from_id'])->where($where_lucky)->sum('luck_value');
|
||||
|
||||
}
|
||||
$where_lucky = [];
|
||||
if($search_room_id !== '' || $room_name !== ''){
|
||||
$where_lucky['room_id'] = $room_id;
|
||||
}
|
||||
if($begin_time !== ''){
|
||||
$where_lucky['createtime'] = ['>=', strtotime($begin_time)];
|
||||
}
|
||||
if($end_time !== ''){
|
||||
$where_lucky['createtime'] = ['<=', strtotime($end_time)];
|
||||
}
|
||||
if(!empty($begin_time) && !empty($end_time)){
|
||||
$where_lucky['createtime'] = ['between',[strtotime($begin_time),strtotime($end_time)]];
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $lists,
|
||||
'total' =>[
|
||||
'total_price' => db::name('vs_give_gift')->where($where)->sum('total_price')
|
||||
'total_price' => db::name('vs_give_gift')->where($where)->sum('total_price'),
|
||||
'total_lucky_coin' => db::name('vs_room_luck_value')->where($where_lucky)->sum('luck_value'),
|
||||
]
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
@@ -481,4 +507,200 @@ class Statistical extends adminApi
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
//任务统计
|
||||
public function task_statistics(){
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 10);
|
||||
$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', '');
|
||||
$where =[];
|
||||
$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($end_time !== ''){
|
||||
$where['a.collection_time'] = ['<=', strtotime($end_time)];
|
||||
}
|
||||
|
||||
// 添加条件:只统计已领取的任务奖励
|
||||
// $where['a.is_claimed'] = 1;
|
||||
|
||||
$count = db::name('vs_tasks_user_daily')
|
||||
->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->join('vs_tasks c', 'a.task_id = c.id')
|
||||
->where($where)
|
||||
->count();
|
||||
$lists = db::name('vs_tasks_user_daily')
|
||||
->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->join('vs_tasks c', 'a.task_id = c.id')
|
||||
->where($where)
|
||||
->field('a.*,c.task_name,b.nickname,b.user_code,c.tasks_bag_id')
|
||||
->order('a.id desc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
|
||||
// 收集所有需要的用户ID和任务包ID以批量获取数据
|
||||
$user_ids = array_column($lists, 'user_id');
|
||||
$bag_ids = array_unique(array_filter(array_column($lists, 'tasks_bag_id')));
|
||||
|
||||
// 批量获取用户装饰详情
|
||||
$user_decorates = [];
|
||||
if (!empty($user_ids)) {
|
||||
foreach ($user_ids as $user_id) {
|
||||
$user_decorates[$user_id] = model('api/Decorate')->user_decorate_detail($user_id, 6);
|
||||
}
|
||||
}
|
||||
// 批量获取奖励包详情
|
||||
$bag_details = [];
|
||||
if (!empty($bag_ids)) {
|
||||
$details = db::name('vs_gift_bag_detail')
|
||||
->where('gift_bag_id', 'in', $bag_ids)
|
||||
->select();
|
||||
|
||||
foreach ($details as $detail) {
|
||||
$bag_details[$detail['gift_bag_id']][] = $detail;
|
||||
}
|
||||
}
|
||||
// 获取所有相关礼品的价格信息
|
||||
$gift_ids = [];
|
||||
$decorate_ids = [];
|
||||
foreach ($bag_details as $details) {
|
||||
foreach ($details as $detail) {
|
||||
if ($detail['type'] == 2) {
|
||||
$gift_ids[] = $detail['foreign_id'];
|
||||
} elseif ($detail['type'] == 3) {
|
||||
$decorate_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;
|
||||
}
|
||||
|
||||
// 批量获取装饰价格
|
||||
$decorate_prices = [];
|
||||
if (!empty($decorate_ids)) {
|
||||
$decorates = db::name('vs_decorate_price')
|
||||
->where('id', 'in', array_unique($decorate_ids))
|
||||
->column('price', 'id');
|
||||
$decorate_prices = $decorates;
|
||||
}
|
||||
|
||||
$data_list = [];
|
||||
$total_reward_price = 0;
|
||||
foreach ($lists as $listkey=>$list){
|
||||
$user_code = isset($user_decorates[$list['user_id']]) ? $user_decorates[$list['user_id']] : '';
|
||||
$data_list[$listkey]['user_code'] = $user_code;
|
||||
$data_list[$listkey]['nickname'] = $list['nickname']."-".$user_code;
|
||||
$data_list[$listkey]['task_name'] = $list['task_name'];
|
||||
$data_list[$listkey]['createtime'] = date('Y-m-d H:i:s', $list['createtime']);
|
||||
$data_list[$listkey]['is_completed'] = $list['is_completed'];//是否已完成
|
||||
$data_list[$listkey]['is_completed_str'] = $list['is_completed']==1 ?"是":"否";
|
||||
//领取状态
|
||||
$data_list[$listkey]['is_claimed'] = $list['is_claimed']; //奖励是否已领取
|
||||
$data_list[$listkey]['is_claimed_str'] = $list['is_claimed']==1 ?"是":"否";
|
||||
//奖品内容
|
||||
$data_list[$listkey]['reward_str'] = "";
|
||||
//奖品价值
|
||||
$data_list[$listkey]['reward_price'] = 0;
|
||||
|
||||
// 计算奖励信息
|
||||
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'];
|
||||
}
|
||||
$data_list[$listkey]['reward_str'] .= $reward_name." ";
|
||||
$data_list[$listkey]['reward_price'] += $reward_price;
|
||||
}
|
||||
}
|
||||
}
|
||||
$return_data = [
|
||||
'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),
|
||||
'lists' => $data_list,
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
//获取已领取任务奖励的总价值
|
||||
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();
|
||||
$total_reward_price = 0;
|
||||
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');
|
||||
$total_reward_price += $gift_price * $detail['quantity'];
|
||||
}
|
||||
}
|
||||
return $total_reward_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;
|
||||
@@ -35,6 +36,11 @@ class SysSet extends adminApi
|
||||
'10' => '邀请奖励',
|
||||
'11' => '二级密码',
|
||||
];
|
||||
public $noAdminConfigType = [
|
||||
'1' => '基础设置',
|
||||
'4' => '提现设置',
|
||||
'8' => '房间配置',
|
||||
];
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
@@ -45,7 +51,11 @@ class SysSet extends adminApi
|
||||
* 类型列表
|
||||
*/
|
||||
public function type_list(){
|
||||
if($this->auth->isSuperAdmin()){
|
||||
$configType = $this->configType;
|
||||
}else{
|
||||
$configType = $this->noAdminConfigType;
|
||||
}
|
||||
$list = [];
|
||||
$i=0;
|
||||
foreach ($configType as $k=>$v){
|
||||
@@ -86,9 +96,25 @@ class SysSet extends adminApi
|
||||
$data = [
|
||||
'key_value'=>$v,
|
||||
];
|
||||
if($k == 'is_maintenance' || $k == 'inside_uid'){
|
||||
Cache::rm($k);
|
||||
}
|
||||
db::name($this->table)->where(['key_title'=>$k])->update($data);
|
||||
}
|
||||
return V(1,"成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 二级密码验证
|
||||
*/
|
||||
public function check_second_pwd()
|
||||
{
|
||||
$secondary_password = input('password', '');
|
||||
$check_pass = model('adminapi/admin')->check_secondary_password($secondary_password);
|
||||
if ($check_pass['code'] == 1) {
|
||||
return V(1, "验证成功");
|
||||
} else {
|
||||
return V(0, $check_pass['msg']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,9 @@ class SystemMessage extends adminApi
|
||||
$lists[$key]['createtime'] = date('Y-m-d H:i:s', $value['createtime']);
|
||||
$lists[$key]['updatetime'] = date('Y-m-d H:i:s', $value['updatetime']);
|
||||
$lists[$key]['type_name'] = $value['type'] == 1 ? '系统消息' : '官方公告';
|
||||
if($value['type'] == 5){
|
||||
$lists[$key]['type_name'] = '公会公告';
|
||||
}
|
||||
$lists[$key]['admin_name'] = db::name('admin')->where('id', $value['admin_id'])->value('nickname');
|
||||
if($lists[$key]['room_id'] > 0){
|
||||
$lists[$key]['room_id'] = $lists[$key]['room_id'].'-'.db::name('vs_room')->where('id', $value['room_id'])->value('room_name');
|
||||
|
||||
@@ -18,13 +18,7 @@ class Tasks extends adminApi
|
||||
{
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = [];
|
||||
protected $table = 'vs_daily_tasks';
|
||||
public $task_type = [
|
||||
'1' => '每日任务',
|
||||
'2' => '每日特殊任务',
|
||||
'3' => '平台常规任务'
|
||||
];
|
||||
|
||||
protected $table = 'vs_tasks';
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
@@ -41,21 +35,20 @@ class Tasks extends adminApi
|
||||
if($seach_task_type != ''){
|
||||
$where['task_type'] = $seach_task_type;
|
||||
}
|
||||
$list = db::name('vs_daily_tasks')->where(['delete_time'=>0])->where($where)->page($page, $page_limit)->order(['sort'=>'desc','task_id'=>'desc'])->select();
|
||||
$count = db::name('vs_daily_tasks')->where(['delete_time'=>0])->where($where)->count();
|
||||
$list = db::name('vs_tasks')->where(['delete_time'=>0])->where($where)->page($page, $page_limit)->order(['sort'=>'desc','id'=>'desc'])->select();
|
||||
$count = db::name('vs_tasks')->where(['delete_time'=>0])->where($where)->count();
|
||||
$list_data = [];
|
||||
foreach ($list as $k=>$v){
|
||||
$list_data[$k]['task_id'] = $v['task_id'];
|
||||
$list_data[$k]['task_id'] = $v['id'];
|
||||
$list_data[$k]['icon'] = $v['icon'];
|
||||
$list_data[$k]['task_name'] = $v['task_name'];
|
||||
$list_data[$k]['task_description'] = $v['task_description']??"";
|
||||
$list_data[$k]['gold_reward'] = $v['gold_reward'];
|
||||
$list_data[$k]['target_quantity'] = $v['target_quantity'];
|
||||
$list_data[$k]['task_type'] = $v['task_type'];
|
||||
$list_data[$k]['task_type_str'] = $this->task_type[$v['task_type']];
|
||||
$list_data[$k]['task_type_str'] = model('api/Tasks')->task_type[$v['task_type']]?? '';
|
||||
$list_data[$k]['sort'] = $v['sort'];
|
||||
$list_data[$k]['bag_id'] = $v['bag_id'];
|
||||
$list_data[$k]['bag_name'] = $v['bag_id']?db::name('vs_gift_bag')->where(['id'=>$v['bag_id']])->value('name'):'';
|
||||
$list_data[$k]['bag_id'] = $v['tasks_bag_id'];
|
||||
$list_data[$k]['bag_name'] = $v['tasks_bag_id']?db::name('vs_gift_bag')->where(['id'=>$v['tasks_bag_id']])->value('name'):'';
|
||||
$list_data[$k]['is_active'] = $v['is_active'];
|
||||
}
|
||||
$return_data = [
|
||||
@@ -63,7 +56,7 @@ class Tasks extends adminApi
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list_data,
|
||||
'task_type' => $this->task_type,
|
||||
'task_type' => model('api/Tasks')->task_type,
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
@@ -95,7 +88,7 @@ class Tasks extends adminApi
|
||||
$data['sort'] = $sort;
|
||||
}
|
||||
if($bag_id != ''){
|
||||
$data['bag_id'] = $bag_id;
|
||||
$data['tasks_bag_id'] = $bag_id;
|
||||
}
|
||||
if($is_active != ''){
|
||||
$data['is_active'] = $is_active;
|
||||
@@ -103,13 +96,10 @@ class Tasks extends adminApi
|
||||
if($task_type != ''){
|
||||
$data['task_type'] = $task_type;
|
||||
}
|
||||
if($gold_reward != ''){
|
||||
$data['gold_reward'] = $gold_reward;
|
||||
}
|
||||
if($target_quantity){
|
||||
$data['target_quantity'] = $target_quantity;
|
||||
}
|
||||
$res = db::name($this->table)->where(['task_id'=>$task_id])->update($data);
|
||||
$res = db::name($this->table)->where(['id'=>$task_id])->update($data);
|
||||
if($res){
|
||||
return V(1,"修改成功");
|
||||
}else{
|
||||
@@ -123,7 +113,7 @@ class Tasks extends adminApi
|
||||
public function task_open(){
|
||||
$task_id = input('task_id', '');
|
||||
$is_active = input('is_active', '');
|
||||
$res = db::name($this->table)->where(['task_id'=>$task_id])->update(['is_active'=>$is_active]);
|
||||
$res = db::name($this->table)->where(['id'=>$task_id])->update(['is_active'=>$is_active]);
|
||||
if($res){
|
||||
return V(1,"开启成功");
|
||||
}else{
|
||||
|
||||
@@ -53,12 +53,19 @@ class UploadFile extends Upload
|
||||
$objectName = $fileName . '_' . $uniqueId . '.' . $extension;
|
||||
|
||||
// 调用父类方法上传到 OSS
|
||||
$result = $this->uploadFile($objectName, $filePath);
|
||||
// $result = $this->uploadFile($objectName, $filePath);
|
||||
// if (!$result) {
|
||||
// return V(0, '上传失败,请检查OSS配置或网络', null);
|
||||
// }
|
||||
// // 返回访问地址
|
||||
// $url = $this->config['oss_cdn_url'] . $objectName;
|
||||
|
||||
// 调用父类方法上传到 COS
|
||||
$result = $this->uploadFileCos($objectName, $filePath);
|
||||
if (!$result) {
|
||||
return V(0, '上传失败,请检查OSS配置或网络', null);
|
||||
return V(0, '上传失败,请检查COS配置或网络', null);
|
||||
}
|
||||
// 返回访问地址
|
||||
$url = $this->config['oss_cdn_url'] . $objectName;
|
||||
$url = $result;// 返回访问地址 具体访问地址根据你的实际配置来定这个需要修改 等域名通过备案后修改
|
||||
return V(1, '上传成功', ['url' => $url]);
|
||||
} catch (\Exception $e) {
|
||||
return V(0, '上传异常: ' . $e->getMessage(), null);
|
||||
|
||||
@@ -35,8 +35,10 @@ class User extends adminApi
|
||||
$page_limit = input('page_limit', 30);
|
||||
$search_str = input('search', '');
|
||||
$search_user_code = input('search_user_code', '');
|
||||
$order_type = input('order_type', 'id');
|
||||
$order_type_val = input('order_type_val', '');
|
||||
$where['a.is_robot'] =0;
|
||||
$where['a.delete_time'] = 0;
|
||||
// $where['a.delete_time'] = 0;
|
||||
//如果是手机号查手机号
|
||||
if($search_str !==''){
|
||||
if(is_numeric($search_str)) {
|
||||
@@ -60,7 +62,7 @@ class User extends adminApi
|
||||
if($is_real == 1) {
|
||||
$where['b.is_real'] = 1;
|
||||
}else {
|
||||
$where['b.is_real'] = ['<>',1];
|
||||
$where['b.is_real'] = [['<>',1],['null', null],'or'];
|
||||
}
|
||||
}
|
||||
//高级搜索
|
||||
@@ -72,7 +74,9 @@ class User extends adminApi
|
||||
if($v=='coin1'){
|
||||
$where['c.coin'] = ['>=',$input_data];
|
||||
}elseif($v=='coin2'){
|
||||
if($input_data){
|
||||
$where['c.coin'] = ['<=',$input_data];
|
||||
}
|
||||
}elseif($v=='createtime'){
|
||||
$where['a.createtime'] = ['>=',strtotime($input_data)];
|
||||
$where['a.createtime'] = ['<=',strtotime($input_data)];
|
||||
@@ -96,21 +100,39 @@ class User extends adminApi
|
||||
a.init_code,
|
||||
a.status
|
||||
';
|
||||
if($order_type_val ==2){
|
||||
$order_type_val_str = 'asc';
|
||||
}else{
|
||||
$order_type_val_str = 'desc';
|
||||
}
|
||||
$order = 'a.id '.$order_type_val_str;
|
||||
if($order_type=='coin'){
|
||||
$order = "c.coin ".$order_type_val_str;
|
||||
}elseif($order_type=='earnings'){
|
||||
$order = "c.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')
|
||||
->where($where)
|
||||
->field($field)
|
||||
->order('a.id desc');
|
||||
->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')
|
||||
->where($where)
|
||||
->field($field)
|
||||
->order('a.id desc')->count();
|
||||
->count();
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['status_str'] = $value['status'] == 1 ? '正常' : '禁用';
|
||||
if($value['status'] == 1){
|
||||
$lists[$key]['status_str'] ='正常';
|
||||
}elseif($value['status'] == 2){
|
||||
$lists[$key]['status_str'] ='禁用';
|
||||
}else{
|
||||
$lists[$key]['status_str'] ='注销';
|
||||
}
|
||||
|
||||
$lists[$key]['is_real_str'] = $value['is_real'] == 1 ? '已实名' : '未实名';
|
||||
//禁用状态
|
||||
//1:禁用账号 2:禁用设备号 3:禁用IP
|
||||
@@ -146,9 +168,25 @@ class User extends adminApi
|
||||
$lists[$key]['special_num'] = "无";
|
||||
}
|
||||
}
|
||||
$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')
|
||||
->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')
|
||||
->where(['a.delete_time'=>0])
|
||||
->where($where)
|
||||
->field($field)
|
||||
->sum('c.earnings');
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'total_coin' => $total_coin,
|
||||
'total_earnings' => $total_earnings,
|
||||
'count' => $count,
|
||||
'lists' => $lists
|
||||
];
|
||||
@@ -347,7 +385,16 @@ class User extends adminApi
|
||||
$user_data['user_info']['red_status_str'] = $user['red_status']==1 ? '开启' : '禁止';
|
||||
//标签
|
||||
$user_data['user_info']['tag'] = $user['tag_list'];
|
||||
$user_data['user_info']['createtime'] = date('Y-m-d H:i:s', $user['createtime']);//主持时间
|
||||
$user_data['user_info']['createtime'] = date('Y-m-d H:i:s', $user['createtime']);//注册时间
|
||||
//师傅 老师
|
||||
$user_sign = db::name('vs_user_sign')->where('sign_user_id', $user_id)->find();
|
||||
$user_data['user_info']['teacher_id'] = 0;
|
||||
$user_data['user_info']['teacher_nickname'] = '--';
|
||||
if($user_sign){
|
||||
$teacher_id = $user_sign['parent_user_id'];
|
||||
$user_data['user_info']['teacher_id'] = $teacher_id;
|
||||
$user_data['user_info']['teacher_nickname'] = db::name('user')->where('id', $teacher_id)->value('nickname');
|
||||
}
|
||||
//统计相关:
|
||||
$user_data['follow_num']['user_recharge_all_money'] = $user['user_recharge_all_money'];
|
||||
$user_data['follow_num']['coin'] = $user['coin'];
|
||||
@@ -423,7 +470,15 @@ class User extends adminApi
|
||||
$reslut = DB::name('user')->where('id', $user_id)->update($up_user);
|
||||
}
|
||||
if($up_user_data){
|
||||
$user_auth = DB::name('user_auth')->where('mobile', $user['mobile'])->find();
|
||||
if($user_auth){
|
||||
$res = DB::name('user_auth')->where('mobile', $user['mobile'])->update($up_user_data);
|
||||
}else{
|
||||
$up_user_data['mobile'] = $user['mobile'];
|
||||
if($real_name && $card_id){
|
||||
$res = DB::name('user_auth')->insert($up_user_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
return V(1,'操作成功');
|
||||
}
|
||||
@@ -436,7 +491,15 @@ class User extends adminApi
|
||||
$page = input('page',1);
|
||||
$page_limit = input('page_limit',10);
|
||||
$type = input('type','');
|
||||
$return = model('UserWallet')->money_change_log($user_id,$type,$page,$page_limit);
|
||||
$stime = input('stime','');
|
||||
$etime = input('etime','');
|
||||
$change_type = input('change_type','');
|
||||
$seach = [
|
||||
'stime' => $stime,
|
||||
'etime' => $etime,
|
||||
'change_type' => $change_type
|
||||
];
|
||||
$return = model('UserWallet')->money_change_log($user_id,$seach,$type,$page,$page_limit);
|
||||
$list = [];
|
||||
foreach($return['list'] as $k=>$v){
|
||||
$list[$k] = [
|
||||
@@ -456,6 +519,14 @@ class User extends adminApi
|
||||
return V(1,"操作成功", $return_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取用户资金类型
|
||||
*/
|
||||
public function get_money_type(){
|
||||
$reslut = model('UserWallet')->getChangeTypeLableList();
|
||||
return V(1,"操作成功", $reslut);
|
||||
}
|
||||
|
||||
/*
|
||||
* 相册列表
|
||||
*/
|
||||
@@ -600,32 +671,68 @@ class User extends adminApi
|
||||
$page_limit = input('page_limit',10);
|
||||
$where['a.is_tester'] = 1;
|
||||
if($user_id){
|
||||
$where['a.user_id'] = $user_id;
|
||||
$where['b.user_code'] = $user_id;
|
||||
}
|
||||
if($gid){
|
||||
$where['a.gid'] = $gid;
|
||||
}
|
||||
$count = db::name('vs_user_gift_pack')->alias('a')->join('user b', 'a.user_id = b.id')->where($where)->count();
|
||||
$count = db::name('vs_user_gift_pack')
|
||||
->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->join('vs_gift c', 'a.gid = c.gid')
|
||||
->where($where)
|
||||
->where(['a.num'=>['>',0]])
|
||||
->count();
|
||||
$list = db::name('vs_user_gift_pack')
|
||||
->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->join('vs_gift c', 'a.gid = c.gid')
|
||||
->field('a.*,b.user_code,b.nickname,c.gift_name,c.base_image,c.gift_price')->where($where)->order('a.pid', "desc")->page($page, $page_limit)->select();
|
||||
->field('a.*,b.user_code,b.nickname,c.gift_name,c.base_image,c.gift_price')
|
||||
->where($where)
|
||||
->where(['a.num'=>['>',0]])
|
||||
->order('a.pid', "desc")
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
$gift_total = 0;
|
||||
$gift_count = 0;
|
||||
foreach ($list as $key => &$value) {
|
||||
$value['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
||||
$value['user_id_nickname'] = $value['user_code'].'——'.$value['nickname'];
|
||||
$value['gift_id_name'] = $value['gid'].'——'.$value['gift_name'];
|
||||
$value['createtime'] = date('Y-m-d H:i:s',$value['updatetime']);
|
||||
$value['nickname'] = $value['nickname'].'-'.$value['user_code'];
|
||||
$value['gift_id_name'] = $value['gift_name'].'-'.$value['gid'];
|
||||
}
|
||||
//礼物个数
|
||||
$gift_count = db::name('vs_user_gift_pack')->alias('a')->join('user b', 'a.user_id = b.id')->where($where)->group('a.gid')->count();
|
||||
//礼物总金额
|
||||
$gift_total = db::name('vs_user_gift_pack')->alias('a')->join('user b', 'a.user_id = b.id')
|
||||
//礼物种类个数
|
||||
$gift_kinds = db::name('vs_user_gift_pack')->alias('a')->join('user b', 'a.user_id = b.id')->where($where)->where(['num'=>['>',0]])->group('a.gid')->count();
|
||||
$gift_count = db::name('vs_user_gift_pack')
|
||||
->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->join('vs_gift c', 'a.gid = c.gid')
|
||||
->where($where)->sum('c.gift_price');
|
||||
->where($where)
|
||||
->where(['a.num'=>['>',0]])
|
||||
->sum('a.num');
|
||||
// $gift_total = db::name('vs_user_gift_pack')
|
||||
// ->alias('a')
|
||||
// ->join('user b', 'a.user_id = b.id')
|
||||
// ->join('vs_gift c', 'a.gid = c.gid')
|
||||
// ->where($where)
|
||||
// ->where(['a.num'=>['>',0]])
|
||||
// ->sum('c.gift_price');
|
||||
$listss = Db::name('vs_user_gift_pack')->alias('a')
|
||||
->join('user b', 'a.user_id = b.id')
|
||||
->join('vs_gift c', 'a.gid = c.gid')
|
||||
->where($where)
|
||||
->field('a.num,c.gift_price')
|
||||
->select();
|
||||
|
||||
foreach ($listss as $v) {
|
||||
$gift_total += $v['num'] * $v['gift_price'];
|
||||
}
|
||||
|
||||
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'gift_kinds' => $gift_kinds,
|
||||
'gift_count' => $gift_count,
|
||||
'gift_total' => $gift_total,
|
||||
'lists' => $list
|
||||
@@ -744,4 +851,146 @@ class User extends adminApi
|
||||
$user = db::name('user')->field('id,nickname,avatar')->where($where)->where(['status'=>1,'is_robot'=>0,'delete_time'=>0])->select();
|
||||
return V(1,"操作成功", $user);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//注销用户找回
|
||||
public function cancel_user_recovery(){
|
||||
$mobile = input('mobile', 0);
|
||||
|
||||
if (!$mobile){
|
||||
return V(0, "手机号不能为空");
|
||||
}
|
||||
$user = db::name('user')->where(['mobile'=>$mobile,'delete_time' => ['<>',0],'status'=>0])->find();
|
||||
if (!$user){
|
||||
return V(0, "该手机号未注销");
|
||||
}
|
||||
$user_count = db::name('user')->where(['mobile'=>$mobile,'delete_time' => 0])->count();
|
||||
if ($user_count > 3){
|
||||
return V(0, "该手机号绑定账号超限了");
|
||||
}
|
||||
$user_del = db::name('user')->where(['mobile'=>$mobile,'delete_time' => ['<>',0]])->count();
|
||||
if ($user_del > 1){
|
||||
return V(0, "相关注销超过1个,暂不支持找回");
|
||||
}
|
||||
//开启事务
|
||||
db::startTrans();
|
||||
try{
|
||||
$user_id = db::name('user')->where(['mobile'=>$mobile,'delete_time' => ['<>',0]])->value('id');
|
||||
db::name('user')->where(['id'=>$user_id])->update([
|
||||
'delete_time' => 0,
|
||||
'status' => 1,
|
||||
'nickname' => '游客_'.$user_id.rand(1000,9999),
|
||||
'avatar' => get_system_config_value('web_site').'/data/avatar/head_pic.png',
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
db::name('user_data')->where(['user_id'=>$user_id])->update([
|
||||
'deletetime' => 0,
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
//查询创建的房间
|
||||
$room_list = db::name('vs_room')->where(['user_id'=>$user_id,'type_id' => ['<>',6]])->find();
|
||||
if($room_list){
|
||||
db::name('vs_room')->where(['id'=>$room_list['id']])->update([
|
||||
'room_status' => 1,
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
}
|
||||
//查他的钱包
|
||||
$wallet = db::name('user_wallet')->where(['user_id'=>$user_id])->find();
|
||||
if($wallet){
|
||||
db::name('user_wallet')->where(['id'=>$wallet['id']])->update([
|
||||
'coin' => 0,
|
||||
'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([
|
||||
'is_perpetual' => 2,
|
||||
'end_time' => time(),
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
db::commit();
|
||||
return V(1,"操作成功", null);
|
||||
}catch (\Exception $e){
|
||||
db::rollback();
|
||||
return V(0, "操作失败,".$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//家族成员
|
||||
public function get_family_member(){
|
||||
$user_id = input('user_id', 0);
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
if (!$user_id){
|
||||
return V(0, "参数错误");
|
||||
}
|
||||
$user_sign = db::name('vs_user_sign')->where(['parent_user_id'=>$user_id,'end_time'=>['>',time()]])->select();
|
||||
$count = db::name('vs_user_sign')->where(['parent_user_id'=>$user_id,'end_time'=>['>',time()]])->count();
|
||||
$list = [];
|
||||
foreach ($user_sign as $key => $value) {
|
||||
$sign_user = db::name('user')->field('id,user_code,nickname,market_value')->where(['id'=>$value['sign_user_id']])->find();
|
||||
$list[$key]['id'] = $value['id'];
|
||||
$list[$key]['user_id'] = $sign_user['id'];
|
||||
$list[$key]['user_code'] = $sign_user['user_code'];
|
||||
$list[$key]['nickname'] = $sign_user['nickname'];
|
||||
$list[$key]['createtime'] = date('Y-m-d H:i:s',$value['createtime']);
|
||||
$list[$key]['end_time'] = date('Y-m-d H:i:s',$value['end_time']);
|
||||
//剩余天数
|
||||
$list[$key]['surplus_days'] = ceil(($value['end_time'] - time())/86400);
|
||||
//免费续约次数
|
||||
$list[$key]['free_renewal_times'] = 3 - $value['sign_times'];
|
||||
if($list[$key]['free_renewal_times']<=0){
|
||||
$list[$key]['free_renewal_times'] = 0;
|
||||
}
|
||||
//当前身价
|
||||
$list[$key]['market_value'] = $sign_user['market_value'];
|
||||
}
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
//解约
|
||||
public function cancel_contract(){
|
||||
$user_sign_id = input('id', 0);
|
||||
if (!$user_sign_id){
|
||||
return V(0, "参数错误");
|
||||
}
|
||||
$user_sign = db::name('vs_user_sign')->where(['id'=>$user_sign_id])->find();
|
||||
if (!$user_sign){
|
||||
return V(0, "参数错误");
|
||||
}
|
||||
$resultt = db::name('vs_user_sign')
|
||||
->where(['id' => $user_sign_id])
|
||||
->update(['end_time' => time(),'sign_user_type' => 4,'type'=>4,'status' => 2]);
|
||||
if(!$resultt){
|
||||
return V(0, "操作失败");
|
||||
}
|
||||
//处理家族
|
||||
$myFamily = db::name('vs_family')
|
||||
->where(['user_id' => $user_sign['sign_user_id'],'type' => 0,'pid' => $user_sign['parent_user_id'],'deletetime' => 0])->find();
|
||||
if($myFamily){
|
||||
$mySignFamily = db::name('vs_family')->where(['user_id' => $user_sign['parent_user_id'],'type' => 1])->find();
|
||||
//删除群成员
|
||||
model('api/Tencent')->delete_group_member('f'.$mySignFamily['id'], $user_sign['sign_user_id']);
|
||||
//退出家族
|
||||
db::name('vs_family')->where('id', $myFamily['id'])->update(['deletetime' => time()]);
|
||||
}
|
||||
|
||||
|
||||
return V(1, "操作成功");
|
||||
}
|
||||
}
|
||||
121
application/adminapi/controller/UserCp.php
Normal file
121
application/adminapi/controller/UserCp.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\common\controller\adminApi;
|
||||
use think\Db;
|
||||
|
||||
class UserCp extends adminApi
|
||||
{
|
||||
//用户CP等级列表
|
||||
public function userCpLevelList()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$where=['deletetime' => 0];
|
||||
$count = db::name('user_cp_level')->where($where)->count();
|
||||
$list = db::name('user_cp_level')
|
||||
->where($where)
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
|
||||
//用户CP等级详情
|
||||
public function userCpLevelInfo()
|
||||
{
|
||||
$id = input('id', '');
|
||||
$where=['deletetime' => 0,'id'=>$id];
|
||||
$list = db::name('user_cp_level')->where($where)->find();
|
||||
if(empty($list)){
|
||||
return V(0,"数据不存在");
|
||||
}
|
||||
if($list['dress_id']){
|
||||
$dress = db::name('vs_decorate_price')->where('id',$list['dress_id'])->field('did,day')->find();
|
||||
$list['dress_title'] = '头像框-'.$dress['day'].'天-'.db::name('vs_decorate')->where('did',$dress['did'])->value('title');
|
||||
$list['dress_base_image'] = db::name('vs_decorate')->where('did',$dress['did'])->value('base_image');
|
||||
}else{
|
||||
$list['dress_title'] = '';
|
||||
$list['dress_base_image'] = '';
|
||||
}
|
||||
if($list['jiajia_id']){
|
||||
$jiajia = db::name('vs_decorate_price')->where('id',$list['jiajia_id'])->field('did,day')->find();
|
||||
$list['jiajia_title'] = '坐骑-'.$jiajia['day'].'天-'.db::name('vs_decorate')->where('did',$jiajia['did'])->value('title');
|
||||
$list['jiajia_base_image'] = db::name('vs_decorate')->where('did',$jiajia['did'])->value('base_image');
|
||||
}else{
|
||||
$list['jiajia_title'] = '';
|
||||
$list['jiajia_base_image'] = '';
|
||||
}
|
||||
if($list['pendant_id']){
|
||||
$pendant = db::name('vs_decorate_price')->where('id',$list['pendant_id'])->field('did,day')->find();
|
||||
$list['pendant_title'] = '装扮-'.$pendant['day'].'天-'.db::name('vs_decorate')->where('did',$pendant['did'])->value('title');
|
||||
$list['pendant_base_image'] = db::name('vs_decorate')->where('did',$pendant['did'])->value('base_image');
|
||||
}else{
|
||||
$list['pendant_title'] = '';
|
||||
$list['pendant_base_image'] = '';
|
||||
}
|
||||
if($list['rights_icon_id']){
|
||||
$rights_icon = db::name('vs_decorate_price')->where('id',$list['rights_icon_id'])->field('did,day')->find();
|
||||
$list['rights_icon_title'] = '特效-'.$rights_icon['day'].'天-'.db::name('vs_decorate')->where('did',$rights_icon['did'])->value('title');
|
||||
$list['rights_icon_base_image'] = db::name('vs_decorate')->where('did',$rights_icon['did'])->value('base_image');
|
||||
}else{
|
||||
$list['rights_icon_title'] = '';
|
||||
$list['rights_icon_base_image'] = '';
|
||||
}
|
||||
|
||||
return V(1,"成功", $list);
|
||||
}
|
||||
|
||||
//编辑用户CP等级
|
||||
public function userCpLevelEdit()
|
||||
{
|
||||
$id = input('id', '');
|
||||
$data = [
|
||||
'level' => input('level', ''),
|
||||
'name' => input('name', ''),
|
||||
'image' => input('image', ''),
|
||||
'change_value' => input('change_value', ''),
|
||||
'rights_icon_id' => input('rights_icon_id', ''),//特效id 11
|
||||
'dress_id' => input('dress_id', ''),
|
||||
'jiajia_id' => input('jiajia_id', ''),
|
||||
'pendant_id' => input('pendant_id', ''),//挂件(装扮)id 10
|
||||
'direction' => input('direction', 0),//挂件上的头像位置:0-上,1-右上,2-右,3-右下,4-下,5-左下,6-左,7-左上
|
||||
];
|
||||
//没有 id就是新增
|
||||
if(empty($id)){
|
||||
//新增
|
||||
$data['createtime'] = time();
|
||||
$res = db::name('user_cp_level')->insert($data);
|
||||
if($res){
|
||||
return V(1, '操作成功');
|
||||
}
|
||||
}else {
|
||||
$res = db::name('user_cp_level')->where('id', $id)->update($data);
|
||||
if($res){
|
||||
return V(1, '操作成功');
|
||||
}
|
||||
}
|
||||
return V(0, '操作失败');
|
||||
}
|
||||
|
||||
|
||||
//用户CP等级删除
|
||||
public function userCpLevelDel()
|
||||
{
|
||||
$id = input('id', '');
|
||||
$data['deletetime'] = time();
|
||||
$res = db::name('user_cp_level')->where('id', $id)->update($data);
|
||||
if($res){
|
||||
return V(1, '操作成功');
|
||||
}
|
||||
return V(0, '操作失败');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -162,6 +162,15 @@ class UserZone extends adminApi
|
||||
public function del_zone(){
|
||||
$id = input('id', 0);
|
||||
$res = db::name('user_zone')->where(['id'=>$id])->update(['is_delete'=> 2,'delete_time'=> time()]);
|
||||
if($res){
|
||||
//删除动态下的标签引用
|
||||
$top_zone = db::name('user_zone_topic')->where('zone_id',$id)->select();
|
||||
if($top_zone){
|
||||
foreach ($top_zone as $v){
|
||||
db::name('user_zone_topic')->where('id',$v['id'])->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
return V($res ? 1 : 0, $res ? '删除成功' : '删除失败');
|
||||
}
|
||||
|
||||
|
||||
@@ -98,27 +98,34 @@ class Version extends adminApi
|
||||
* 修改
|
||||
*/
|
||||
public function version_edit(){
|
||||
$version = input('version', '');
|
||||
$type = input('type', '');
|
||||
$downloadurl = input('downloadurl', '');
|
||||
$content = $_POST['content'] ?? '';
|
||||
$enforce = input('enforce', '');
|
||||
$version_code = input('version_code', '');
|
||||
$status = input('status', 1);
|
||||
$version = input('version', '');//新版本好
|
||||
$type = input('type', '');//1-安卓 2-IOS
|
||||
$downloadurl = input('downloadurl', '');//下载地址
|
||||
$content = $_POST['content'] ?? '';//更新内容
|
||||
$enforce = input('enforce', '');//强制更新 1-是 0-否
|
||||
$version_code = input('version_code', '');//版本号(目前安卓使用,用来判定是否升级)
|
||||
$status = input('status', 1);//0-待发布,1-已发布,2-禁用
|
||||
|
||||
$id = input('id', '');
|
||||
$versions = db::name($this->table)->where(['newversion'=>$version,'id'=>['neq',$id]])->find();
|
||||
if($versions){
|
||||
$now_version = db::name($this->table)->where(['id'=>$id])->find();
|
||||
if(!$now_version){
|
||||
return V(0,"数据不存在");
|
||||
}
|
||||
$res = version_compare($now_version['newversion'], $version);
|
||||
if($res == 0){
|
||||
return V(0,"版本号已存在");
|
||||
}
|
||||
|
||||
$data = [
|
||||
'newversion' => $version,
|
||||
'oldversion' => $now_version['newversion'],
|
||||
'type' => $type,
|
||||
'downloadurl' => $downloadurl,
|
||||
'content' => $content,
|
||||
'enforce' => $enforce,
|
||||
'code' => $version_code,
|
||||
'status' => $status,
|
||||
'createtime' => time()
|
||||
'updatetime' => time()
|
||||
];
|
||||
$res = db::name($this->table)->where(['id'=>$id])->update($data);
|
||||
if($res){
|
||||
|
||||
@@ -104,15 +104,27 @@ class Withdrawal extends adminApi
|
||||
//统计
|
||||
|
||||
//待审核数量
|
||||
$wait_num = db::name('vs_user_withdrawal')->where('status',1)->count();
|
||||
$wait_num = db::name('vs_user_withdrawal')->where('a.status',1)
|
||||
->alias('a')
|
||||
->join('user b', 'a.user_id = b.id', 'left')
|
||||
->where($where)
|
||||
->count();
|
||||
//今日提现
|
||||
$today_money = db::name('vs_user_withdrawal')->whereIn('status',[2,6])->whereTime('createtime', 'today')->sum('money');
|
||||
//昨日提现
|
||||
$yesterday_money = db::name('vs_user_withdrawal')->whereIn('status',[2,6])->whereTime('createtime', 'yesterday')->sum('money');
|
||||
//已完成提现总额
|
||||
$complete_money = db::name('vs_user_withdrawal')->whereIn('status',[2,6])->sum('money');
|
||||
$complete_money = db::name('vs_user_withdrawal')->whereIn('a.status',[2,6])
|
||||
->alias('a')
|
||||
->join('user b', 'a.user_id = b.id', 'left')
|
||||
->where($where)
|
||||
->sum('money');
|
||||
//手续费收入
|
||||
$server_money = db::name('vs_user_withdrawal')->whereIn('status',[2,6])->sum('server_money');
|
||||
$server_money = db::name('vs_user_withdrawal')->whereIn('a.status',[2,6])
|
||||
->alias('a')
|
||||
->join('user b', 'a.user_id = b.id', 'left')
|
||||
->where($where)
|
||||
->sum('server_money');
|
||||
//提现总额
|
||||
$total_money = $complete_money+$server_money;
|
||||
|
||||
|
||||
@@ -94,28 +94,104 @@ class Guild extends Model
|
||||
*
|
||||
*工会当日流水
|
||||
*/
|
||||
// public function getTodayMoney($guild_id,$stoday="",$etoday=""){
|
||||
// //获取所有工会房间ID
|
||||
// $guild_user_data = db::name('vs_guild_user')->where('guild_id', $guild_id)->where(['apply_time'=>['>',0],'status'=>1])->field('room_id,apply_time,quit_time')->select();
|
||||
// $transaction = 0;
|
||||
// foreach ($guild_user_data as $k => $v) {
|
||||
// if(empty($stoday) && empty($etoday)){
|
||||
// $stoday_seach = strtotime(date('Y-m-d 00:00:00',time()));
|
||||
// $etoday_seach = strtotime(date('Y-m-d 23:59:59',time()));
|
||||
// }else{
|
||||
// $stoday_seach = strtotime($stoday);
|
||||
// $etoday_seach = strtotime($etoday);
|
||||
// }
|
||||
// if($v['apply_time'] && $stoday_seach < $v['apply_time']){
|
||||
// $stoday_seach = $v['apply_time'];
|
||||
// }
|
||||
// if($v['quit_time'] && ($etoday > $v['quit_time'])){
|
||||
// $etoday_seach = $v['quit_time'];
|
||||
// }
|
||||
// $transaction_one = db::name('vs_give_gift')
|
||||
// ->where('from_id',$v['room_id'])
|
||||
// ->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$stoday_seach, $etoday_seach]]])
|
||||
// ->sum('total_price');
|
||||
// $transaction += $transaction_one;
|
||||
// }
|
||||
// return $transaction;
|
||||
// }
|
||||
|
||||
public function getTodayMoney($guild_id,$stoday="",$etoday=""){
|
||||
$where = [];
|
||||
$where['guild_id'] = $guild_id;
|
||||
if(empty($stoday) && empty($etoday)){
|
||||
$where['day'] = date('Y-m-d');
|
||||
}else{
|
||||
if(!empty($stoday)){
|
||||
$where['createtime'] = ['>=',strtotime($stoday)];
|
||||
}
|
||||
if(!empty($etime)){
|
||||
$where['createtime'] = ['<',strtotime($etoday)];
|
||||
}
|
||||
if(!empty($stime) && !empty($etime)){
|
||||
$where['createtime'] = [['>=',strtotime($stoday)],['<',strtotime($etoday)]];
|
||||
}
|
||||
}
|
||||
$guild_flow = db::name('vs_guild_flow')
|
||||
->where($where)
|
||||
->sum('flow_price');
|
||||
return $guild_flow;
|
||||
}
|
||||
//获取公会流水
|
||||
public function getGuildFlow($guild_id=0,$room_id=0,$stoday="",$etoday=""){
|
||||
$where = [];
|
||||
if($guild_id!=0) {
|
||||
$where['guild_id'] = $guild_id;
|
||||
}
|
||||
if($room_id!=0){
|
||||
$where['room_id'] = $room_id;
|
||||
}
|
||||
if(!empty($stoday)){
|
||||
$where['createtime'] = ['>=',strtotime($stoday)];
|
||||
}
|
||||
if(!empty($etime)){
|
||||
$where['createtime'] = ['<',strtotime($etoday)];
|
||||
}
|
||||
if(!empty($stime) && !empty($etime)){
|
||||
$where['createtime'] = [['>=',strtotime($stoday)],['<',strtotime($etoday)]];
|
||||
}
|
||||
$guild_flow = db::name('vs_guild_flow')->where($where)->sum('flow_price');
|
||||
return $guild_flow;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*工会幸运流水
|
||||
*/
|
||||
public function getTodayMoneyLuckyCoin($guild_id,$stoday="",$etoday=""){
|
||||
//获取所有工会房间ID
|
||||
$guild_user_data = db::name('vs_guild_user')->where('guild_id', $guild_id)->field('room_id,createtime,quit_time')->select();
|
||||
$guild_user_data = db::name('vs_guild_user')->where('guild_id', $guild_id)->where(['apply_time'=>['>',0],'status'=>1])->field('room_id,apply_time,createtime,quit_time')->select();
|
||||
$transaction = 0;
|
||||
foreach ($guild_user_data as $k => $v) {
|
||||
if(empty($stoday) && empty($etoday)){
|
||||
$stoday_seach = strtotime(date('Y-m-d 00:00:00',time()));
|
||||
$etoday_seach = strtotime(date('Y-m-d 23:59:59',time()));
|
||||
}else{
|
||||
$stoday_seach = strtotime("2025-12-21 00:00:00");
|
||||
$etoday_seach = time();
|
||||
if(!empty($stoday)){
|
||||
$stoday_seach = strtotime($stoday);
|
||||
}
|
||||
if(!empty($etoday)){
|
||||
$etoday_seach = strtotime($etoday);
|
||||
}
|
||||
if($v['createtime'] && $stoday_seach < $v['createtime']){
|
||||
$stoday_seach = $v['createtime'];
|
||||
if($v['apply_time'] && $stoday_seach < $v['apply_time']){
|
||||
$stoday_seach = $v['apply_time'];
|
||||
}
|
||||
if($v['quit_time'] && ($etoday > $v['quit_time'])){
|
||||
$etoday_seach = $v['quit_time'];
|
||||
}
|
||||
$transaction_one = db::name('vs_give_gift')
|
||||
->where('from_id',$v['room_id'])
|
||||
->where(['from'=>['in',[2,3,6]],'createtime' => ['between', [$stoday_seach, $etoday_seach]]])
|
||||
->sum('total_price');
|
||||
$transaction_one = db::name('vs_room_luck_value')
|
||||
->where('room_id',$v['room_id'])
|
||||
->where(['createtime'=>['>=',$stoday_seach]])
|
||||
->where(['createtime'=>['<',$etoday_seach]])
|
||||
->sum('luck_value');
|
||||
$transaction += $transaction_one;
|
||||
}
|
||||
return $transaction;
|
||||
|
||||
@@ -73,15 +73,17 @@ class Room extends Model
|
||||
public function getRoomFlow($room_id,$stime='',$etime=''){
|
||||
$give_where = [];
|
||||
$give_where['from_id'] = $room_id;
|
||||
$give_where['from'] = ["in",[2,3,6]];
|
||||
// $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)];
|
||||
$give_where['createtime'] = ['<',strtotime($etime)];
|
||||
}
|
||||
if(!empty($stime) && !empty($etime)){
|
||||
$give_where['createtime'] = ['between',[strtotime($stime),strtotime($etime)]];
|
||||
// $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');
|
||||
|
||||
@@ -52,7 +52,7 @@ class Activities extends BaseCom
|
||||
$gift = DB::name('vs_gift')->where(['gid'=>$vv['foreign_id']])->find();
|
||||
if($gift){
|
||||
$list[$kk]['gift_name'] = $gift['gift_name'];
|
||||
$list[$kk]['num'] = $vv['quantity'];
|
||||
$list[$kk]['num'] = $vv['quantity']." 个";
|
||||
$list[$kk]['gift_price'] = $gift['gift_price'];
|
||||
$list[$kk]['type'] =2;
|
||||
$list[$kk]['base_image'] = $gift['base_image'];
|
||||
@@ -62,7 +62,7 @@ class Activities extends BaseCom
|
||||
if($decorate_price){
|
||||
$gift = DB::name('vs_decorate')->where(['did'=>$decorate_price['did']])->find();
|
||||
$list[$kk]['gift_name'] = $gift['title']??""; //装扮名称
|
||||
$list[$kk]['num'] = $decorate_price['day']??0; //天数
|
||||
$list[$kk]['num'] = $decorate_price['day']." 天"??0; //天数
|
||||
$list[$kk]['gift_price'] = $decorate_price['price']??0; //价格
|
||||
$list[$kk]['type'] =3;
|
||||
$list[$kk]['base_image'] = $gift['base_image'] ?? "";
|
||||
@@ -98,7 +98,7 @@ class Activities 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['oldversion'],$app_version);
|
||||
$result = version_compare($api_versions['apiversion'],$app_version);
|
||||
if ($result < 0) {
|
||||
$api_version = 1;
|
||||
}
|
||||
@@ -157,7 +157,7 @@ class Activities extends BaseCom
|
||||
}elseif($v['type'] == 2) {
|
||||
$gift = DB::name('vs_gift')->where(['gid'=>$v['foreign_id']])->find();
|
||||
$list[$k]['gift_name'] = $gift['gift_name'];
|
||||
$list[$k]['num'] = $v['quantity'];
|
||||
$list[$k]['num'] = $v['quantity']." 个";
|
||||
$list[$k]['gift_price'] = $gift['gift_price'];
|
||||
$list[$k]['type'] =2;
|
||||
$list[$k]['base_image'] = $gift['base_image'];
|
||||
@@ -165,7 +165,7 @@ class Activities extends BaseCom
|
||||
$decorate_price = DB::name('vs_decorate_price')->where(['id'=>$v['foreign_id']])->find();
|
||||
$gift = DB::name('vs_decorate')->where(['did'=>$decorate_price['did']])->find();
|
||||
$list[$k]['gift_name'] = $gift['title']; //装扮名称
|
||||
$list[$k]['num'] = $decorate_price['day']; //天数
|
||||
$list[$k]['num'] = $decorate_price['day']." 天"??0; //天数
|
||||
$list[$k]['gift_price'] = $decorate_price['price']; //价格
|
||||
$list[$k]['type'] =3;
|
||||
$list[$k]['base_image'] = $gift['base_image'];
|
||||
@@ -238,7 +238,7 @@ class Activities extends BaseCom
|
||||
$gift = DB::name('vs_gift')->where(['gid'=>$vv['foreign_id']])->find();
|
||||
if($gift){
|
||||
$list[$kk]['gift_name'] = $gift['gift_name'];
|
||||
$list[$kk]['num'] = $vv['quantity'];
|
||||
$list[$kk]['num'] = $vv['quantity']." 个";
|
||||
$list[$kk]['gift_price'] = $gift['gift_price'];
|
||||
$list[$kk]['type'] =2;
|
||||
$list[$kk]['base_image'] = $gift['base_image'];
|
||||
@@ -248,7 +248,7 @@ class Activities extends BaseCom
|
||||
if($decorate_price){
|
||||
$gift = DB::name('vs_decorate')->where(['did'=>$decorate_price['did']])->find();
|
||||
$list[$kk]['gift_name'] = $gift['title']??""; //装扮名称
|
||||
$list[$kk]['num'] = $decorate_price['day']??0; //天数
|
||||
$list[$kk]['num'] = $decorate_price['day']." 天"??0; //天数
|
||||
$list[$kk]['gift_price'] = $decorate_price['price']??0; //价格
|
||||
$list[$kk]['type'] =3;
|
||||
$list[$kk]['base_image'] = $gift['base_image'] ?? "";
|
||||
@@ -303,7 +303,7 @@ class Activities 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['oldversion'],$app_version);
|
||||
$result = version_compare($api_versions['apiversion'],$app_version);
|
||||
if ($result < 0) {
|
||||
$api_version = 1;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,15 @@ class BlindBoxTurntable extends BaseCom
|
||||
$num = input('num',1);
|
||||
$heart_id = input('heart_id',0);
|
||||
$auction_id = input('auction_id',0);
|
||||
$reslut = model('BlindBoxTurntableGiftDrawWorld')->draw_gift($gift_bag_id, $user_id, $gift_user_ids,$num,$room_id,$heart_id,$auction_id);
|
||||
if(!in_array($gift_bag_id,[10,11,12])){
|
||||
return v(0,'非法活动ID', null);
|
||||
}
|
||||
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);
|
||||
}else{
|
||||
$reslut = model('BlindBoxTurntableGiftDrawWorldNew')->draw_gift_drop_bag($gift_bag_id, $user_id,$num,$room_id);
|
||||
}
|
||||
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
/*
|
||||
@@ -93,7 +101,7 @@ class BlindBoxTurntable extends BaseCom
|
||||
$user_id = $this->uid;
|
||||
$room_id = input('room_id',0);
|
||||
$num = input('num',1);
|
||||
$reslut = model('BlindBoxTurntableGiftDrawWorld')->xlh_draw_gift($user_id,$num,$room_id);
|
||||
$reslut = model('BlindBoxTurntableGiftDrawWorldNew')->xlh_draw_gift($user_id,$num,$room_id);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
/*
|
||||
@@ -128,4 +136,13 @@ class BlindBoxTurntable extends BaseCom
|
||||
$reslut = model('BlindBoxTurntableGift')->xlh_ranking_list($room_id,$page,$page_size);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
/*
|
||||
* 盲盒转盘状态
|
||||
* 1.开启 2.关闭
|
||||
*/
|
||||
public function blind_box_status(){
|
||||
$reslut = model('BlindBoxTurntableGift')->blind_box_status();
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
@@ -829,6 +829,13 @@ class Ceshi extends Controllers
|
||||
//数组末尾添加元素
|
||||
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();
|
||||
@@ -856,6 +863,27 @@ class Ceshi extends Controllers
|
||||
|
||||
|
||||
|
||||
//测试异步信息
|
||||
public function test_async_info(){
|
||||
// 创建子进程
|
||||
$pid = pcntl_fork();
|
||||
|
||||
if ($pid == -1) {
|
||||
die('无法创建子进程');
|
||||
} elseif ($pid) {
|
||||
// 父进程
|
||||
echo "父进程继续执行\n";
|
||||
// 父进程不等待子进程
|
||||
} else {
|
||||
// 子进程
|
||||
sleep(5);
|
||||
Log::record("子进程:5秒后执行".json_encode($pid),"infoss");
|
||||
echo "子进程:5秒后执行\n";
|
||||
exit(0); // 子进程结束
|
||||
}
|
||||
|
||||
echo "父进程继续执行其他代码\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,19 +5,39 @@ namespace app\api\controller;
|
||||
class Cron
|
||||
{
|
||||
//每秒执行
|
||||
/*
|
||||
*拍卖房结束提醒
|
||||
* Pk房连线中倒计时结束操作PK结束
|
||||
* Pk房PK进行中倒计时结束操作PK结束
|
||||
* Pk房PK结束惩罚倒计时结束断开操作
|
||||
* 房间红包清退
|
||||
* pk发起10秒后无应答拒绝
|
||||
* 提现云账号订单状态查询
|
||||
* 签约房时间结束处理
|
||||
* 签约到期处理
|
||||
*/
|
||||
public function PerformPerSecond()
|
||||
{
|
||||
$cron = new \app\cron\controller\PerformPerSecond();
|
||||
$cron->index();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//每周执行
|
||||
/*工会补贴生成开始
|
||||
*房间补贴生成开始
|
||||
*/
|
||||
public function PerformPerWeek()
|
||||
{
|
||||
$cron = new \app\cron\controller\Subsidy();
|
||||
$cron->index();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//经业务调整 暂时不要了
|
||||
//每10秒执行
|
||||
public function TenSeconds()
|
||||
{
|
||||
@@ -25,28 +45,60 @@ class Cron
|
||||
$cron->index();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//每天执行
|
||||
/*
|
||||
* 清除房间热度值
|
||||
* 系统降身价
|
||||
* 过期验证码删除
|
||||
*/
|
||||
public function DaySeconds()
|
||||
{
|
||||
$cron = new \app\cron\controller\DaySeconds();
|
||||
$cron->index();
|
||||
}
|
||||
|
||||
//巡乐会结束 礼物发放
|
||||
|
||||
|
||||
//巡乐会结束 礼物发放 3S执行一次
|
||||
/*
|
||||
* 巡乐会礼物发放开始
|
||||
*盲盒转盘礼物补发
|
||||
* 保持心跳
|
||||
*/
|
||||
public function XlhSend(){
|
||||
$cron = new \app\cron\controller\RoomPan();
|
||||
$cron->index();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//交友房结束
|
||||
/*
|
||||
* 清除交友房过期未结束数据开始
|
||||
* 清除私密小屋过期数据开始
|
||||
*/
|
||||
public function FriendEnd(){
|
||||
$cron = new \app\cron\controller\FriendEnd();
|
||||
$cron->index();
|
||||
}
|
||||
|
||||
//房间小时榜发礼物(每小时执行一次)
|
||||
|
||||
|
||||
//每小时执行一次
|
||||
/*
|
||||
* 小时榜 开始发礼物
|
||||
* 清除房间离线超1小时的用户
|
||||
*/
|
||||
public function RoomHourRanking(){
|
||||
$cron = new \app\cron\controller\RoomHourRanking();
|
||||
$cron->index();
|
||||
}
|
||||
|
||||
//临时
|
||||
public function teset(){
|
||||
$cron = new \app\cron\controller\Test();
|
||||
$cron->index();
|
||||
}
|
||||
}
|
||||
@@ -55,12 +55,13 @@ class Decorate extends BaseCom
|
||||
$did = input('did', 0);
|
||||
$day = input('day', 1);
|
||||
$user_id = input('user_id', 0);
|
||||
$num = input('num', 0);
|
||||
$keyname = "api:Decorate:pay_decorate:uid:".$uid;
|
||||
redis_lock_exit($keyname);
|
||||
if($user_id){//购买装扮 赠送好友
|
||||
$reslut = model('Decorate')->pay_decorate($user_id, $did, $day,4,$uid);
|
||||
$reslut = model('Decorate')->pay_decorate($user_id, $did, $day,4,$uid,'', $num);
|
||||
}else{
|
||||
$reslut = model('Decorate')->pay_decorate($uid, $did, $day,1);
|
||||
$reslut = model('Decorate')->pay_decorate($uid, $did, $day,1,0,'', $num);
|
||||
}
|
||||
redis_unlock($keyname);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
|
||||
53
application/api/controller/Family.php
Normal file
53
application/api/controller/Family.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Db;
|
||||
|
||||
class Family extends BaseCom
|
||||
{
|
||||
//我的家族
|
||||
public function myFamily()
|
||||
{
|
||||
$reslut = model('Family')->myFamily($this->uid);
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//我加入的家族
|
||||
public function myJoinFamily()
|
||||
{
|
||||
$user_id = db::name('vs_user_sign')->where(['sign_user_id' => $this->uid,'end_time' => ['>',time()]])->value('parent_user_id');
|
||||
if(!$user_id){
|
||||
return V(0, '没有加入家族');
|
||||
}
|
||||
$reslut = model('Family')->myFamily($user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//家族收益详情
|
||||
public function familyEarnings()
|
||||
{
|
||||
$user_id = input('user_id',0);//族长 id
|
||||
$where = ['a.user_id' => $user_id];
|
||||
if(input('start_time')){
|
||||
$where['a.createtime'][] = ['>', strtotime(input('start_time'))];
|
||||
}
|
||||
if(input('end_time')){
|
||||
$where['a.createtime'][] = ['<', strtotime(input('end_time'))];
|
||||
}
|
||||
|
||||
$reslut = db::name('vs_user_sign_earnings')->alias('a')
|
||||
->join('user b','a.sign_user_id = b.id')
|
||||
->join('vs_gift g','a.gift_id = g.gid')
|
||||
->field('b.nickname,b.avatar,b.user_code,a.earnings,a.createtime,g.gift_name,g.gift_price')
|
||||
->where($where)
|
||||
->order('a.createtime desc')
|
||||
->page(input('page',1),30)
|
||||
->select();
|
||||
return V(1, '成功', $reslut);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,8 @@ class Gift extends BaseCom
|
||||
{
|
||||
$label = input('label',0);
|
||||
$room_id = input('room_id',0);
|
||||
$reslut = model('Gift')->get_gift_list($label,$room_id);
|
||||
$user_id = $this->uid ?? 0;
|
||||
$reslut = model('Gift')->get_gift_list($label,$room_id,$user_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//聊天送礼物 (音信)
|
||||
|
||||
301
application/api/controller/GiftBase.php
Normal file
301
application/api/controller/GiftBase.php
Normal file
@@ -0,0 +1,301 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use app\common\model\GiveGiftBase;
|
||||
use think\Cache;
|
||||
use think\Log;
|
||||
|
||||
class GiftBase extends BaseCom
|
||||
{
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = ['*'];
|
||||
|
||||
protected $giftModel;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->giftModel = new GiveGiftBase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取送礼记录
|
||||
*/
|
||||
public function getGiftRecords()
|
||||
{
|
||||
$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($params['start_time'])) {
|
||||
$options['start_time'] = intval($params['start_time']);
|
||||
}
|
||||
if (!empty($params['end_time'])) {
|
||||
$options['end_time'] = intval($params['end_time']);
|
||||
}
|
||||
|
||||
// 分页参数
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 房间送礼统计
|
||||
*/
|
||||
public function getRoomStatistics()
|
||||
{
|
||||
$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 getUserStatistics()
|
||||
{
|
||||
$userId = $this->request->param('user_id/d', 0);
|
||||
$startTime = $this->request->param('start_time/d', strtotime('-30 days'));
|
||||
$endTime = $this->request->param('end_time/d', time());
|
||||
|
||||
if (!$userId) {
|
||||
$this->error('用户ID不能为空');
|
||||
}
|
||||
|
||||
$cacheKey = "gift:user:stats:{$userId}:" . date('Ymd', $startTime) . '-' . date('Ymd', $endTime);
|
||||
$cachedData = Cache::get($cacheKey);
|
||||
|
||||
if ($cachedData !== false) {
|
||||
Log::info("从缓存获取用户统计: {$cacheKey}");
|
||||
$this->success('获取成功', $cachedData);
|
||||
}
|
||||
|
||||
$where = ['user_id' => $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);
|
||||
|
||||
Log::info("用户统计计算完成: {$userId}, 房间数: " . count($roomStats) . ", 收礼人数: " . count($receiverStats));
|
||||
|
||||
$this->success('获取成功', $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
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
179
application/api/controller/GiveGiftBase.php
Normal file
179
application/api/controller/GiveGiftBase.php
Normal file
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\library\GiftQueue;
|
||||
use think\Log;
|
||||
use app\common\controller\BaseCom;
|
||||
|
||||
class GiveGiftBase extends BaseCom
|
||||
{
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = ['*'];
|
||||
|
||||
/**
|
||||
* 送礼接口
|
||||
*/
|
||||
public function give()
|
||||
{
|
||||
$params = $this->request->param();
|
||||
|
||||
// 验证必要参数
|
||||
$required = ['user_id', 'gift_id', 'gift_user', 'from_id'];
|
||||
foreach ($required as $field) {
|
||||
if (empty($params[$field])) {
|
||||
$this->error("{$field}不能为空");
|
||||
}
|
||||
}
|
||||
|
||||
// 构建送礼数据
|
||||
$giftData = [
|
||||
'user_id' => intval($params['user_id']),
|
||||
'gift_id' => intval($params['gift_id']),
|
||||
'gift_type' => intval($params['gift_type'] ?? 1),
|
||||
'number' => intval($params['number'] ?? 1),
|
||||
'gift_user' => intval($params['gift_user']),
|
||||
'from_id' => intval($params['from_id']),
|
||||
'pit_number' => intval($params['pit_number'] ?? 0),
|
||||
'total_price' => floatval($params['total_price'] ?? 0),
|
||||
'type' => intval($params['type'] ?? 1),
|
||||
'from' => intval($params['from'] ?? 1),
|
||||
'createtime' => time(),
|
||||
];
|
||||
|
||||
// 验证价格
|
||||
if ($giftData['total_price'] <= 0) {
|
||||
$this->error('礼物总价值必须大于0');
|
||||
}
|
||||
|
||||
// 验证数量
|
||||
if ($giftData['number'] <= 0) {
|
||||
$this->error('礼物数量必须大于0');
|
||||
}
|
||||
|
||||
// 使用队列异步处理
|
||||
$result = GiftQueue::push($giftData);
|
||||
|
||||
if ($result) {
|
||||
// 记录日志
|
||||
Log::info("用户送礼成功(队列),用户: {$giftData['user_id']}, 收礼人: {$giftData['gift_user']}, 房间: {$giftData['from_id']}");
|
||||
|
||||
// 立即返回成功,后台异步处理
|
||||
$this->success('送礼成功,正在处理中', [
|
||||
'queue_status' => 'processing',
|
||||
'user_id' => $giftData['user_id'],
|
||||
'gift_user' => $giftData['gift_user'],
|
||||
'timestamp' => time()
|
||||
]);
|
||||
} else {
|
||||
Log::error("用户送礼失败(队列),用户: {$giftData['user_id']}, 收礼人: {$giftData['gift_user']}");
|
||||
$this->error('送礼失败,请重试');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量送礼
|
||||
*/
|
||||
public function batchGive()
|
||||
{
|
||||
$gifts = $this->request->param('gifts/a', []);
|
||||
|
||||
if (empty($gifts) || !is_array($gifts)) {
|
||||
$this->error('礼物数据不能为空');
|
||||
}
|
||||
|
||||
$successCount = 0;
|
||||
$failCount = 0;
|
||||
$giftList = [];
|
||||
|
||||
foreach ($gifts as $gift) {
|
||||
// 验证必要参数
|
||||
if (empty($gift['user_id']) || empty($gift['gift_user']) || empty($gift['from_id'])) {
|
||||
$failCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
$giftData = [
|
||||
'user_id' => intval($gift['user_id']),
|
||||
'gift_id' => intval($gift['gift_id'] ?? 0),
|
||||
'gift_type' => intval($gift['gift_type'] ?? 1),
|
||||
'number' => intval($gift['number'] ?? 1),
|
||||
'gift_user' => intval($gift['gift_user']),
|
||||
'from_id' => intval($gift['from_id']),
|
||||
'pit_number' => intval($gift['pit_number'] ?? 0),
|
||||
'total_price' => floatval($gift['total_price'] ?? 0),
|
||||
'type' => intval($gift['type'] ?? 1),
|
||||
'from' => intval($gift['from'] ?? 1),
|
||||
'createtime' => time(),
|
||||
];
|
||||
|
||||
$giftList[] = $giftData;
|
||||
}
|
||||
|
||||
// 批量加入队列
|
||||
$result = GiftQueue::pushBatch($giftList);
|
||||
|
||||
Log::info("批量送礼提交,总计: {$result['total']}, 成功: {$result['success']}, 失败: {$result['failed']}");
|
||||
|
||||
$this->success("批量送礼提交成功", $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取队列状态
|
||||
*/
|
||||
public function queueStatus()
|
||||
{
|
||||
$stats = GiftQueue::stats();
|
||||
|
||||
$this->success('获取成功', $stats);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试送礼接口(直接写入,用于测试)
|
||||
*/
|
||||
public function testGive()
|
||||
{
|
||||
// 只有测试环境可用
|
||||
if (config('app_debug') != true) {
|
||||
$this->error('测试接口仅限开发环境使用');
|
||||
}
|
||||
|
||||
$params = $this->request->param();
|
||||
|
||||
// 验证必要参数
|
||||
$required = ['user_id', 'gift_id', 'gift_user', 'from_id'];
|
||||
foreach ($required as $field) {
|
||||
if (empty($params[$field])) {
|
||||
$this->error("{$field}不能为空");
|
||||
}
|
||||
}
|
||||
|
||||
// 构建送礼数据
|
||||
$giftData = [
|
||||
'user_id' => intval($params['user_id']),
|
||||
'gift_id' => intval($params['gift_id']),
|
||||
'gift_type' => intval($params['gift_type'] ?? 1),
|
||||
'number' => intval($params['number'] ?? 1),
|
||||
'gift_user' => intval($params['gift_user']),
|
||||
'from_id' => intval($params['from_id']),
|
||||
'pit_number' => intval($params['pit_number'] ?? 0),
|
||||
'total_price' => floatval($params['total_price'] ?? 0),
|
||||
'type' => intval($params['type'] ?? 1),
|
||||
'from' => intval($params['from'] ?? 1),
|
||||
'createtime' => time(),
|
||||
];
|
||||
|
||||
// 直接写入数据库(测试用)
|
||||
$model = new \app\common\model\GiveGiftBase();
|
||||
$result = $model->addGiftRecord($giftData);
|
||||
|
||||
if ($result) {
|
||||
$this->success('测试送礼成功(直接写入)', [
|
||||
'id' => $result,
|
||||
'data' => $giftData
|
||||
]);
|
||||
} else {
|
||||
$this->error('测试送礼失败: ' . $model->getError());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ class Guild extends BaseCom
|
||||
$guild_id = input('guild_id', 0);
|
||||
$key_name = "api:guild:join_guild:".$uid;
|
||||
redis_lock_exit($key_name);
|
||||
$reslut = model('Guild')->join_guild($guild_id,$uid);
|
||||
$reslut = model('Guild')->join_guild_apply($guild_id,$uid);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -63,7 +63,7 @@ class Guild extends BaseCom
|
||||
$type = input('type', 1);
|
||||
$key_name = "api:guild:operate_guild:".$uid;
|
||||
redis_lock_exit($key_name);
|
||||
$reslut = model('Guild')->operate_guild($uid, $apply_id, $type);
|
||||
$reslut = model('Guild')->operate_guild($apply_id, $type,$uid);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -174,9 +174,14 @@ class Guild extends BaseCom
|
||||
$uid = $this->uid;
|
||||
$reslut = model('Guild')->user_is_join($uid);
|
||||
if($reslut==0){
|
||||
return V(0,'用户不是工会成员');
|
||||
return V(0,'用户不是工会成员',['guild'=>[]]);
|
||||
}elseif($reslut['status']==2){
|
||||
return V(0,'用户已申请加入公会待会长审核', ['guild'=>$reslut]);
|
||||
}elseif($reslut['status']==3){
|
||||
return V(0,'用户加入公会申请已被拒绝', ['guild'=>$reslut]);
|
||||
}elseif($reslut['status']==1){
|
||||
return V(1,'用户是工会成员', ['guild'=>$reslut]);
|
||||
}
|
||||
return V(1,'用户是工会成员', ['guild_id'=>$reslut]);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -196,7 +201,7 @@ class Guild extends BaseCom
|
||||
*/
|
||||
public function get_guild_info(){
|
||||
$uid = $this->uid;
|
||||
$guild_id = input('guild_id', 0);
|
||||
$guild_id = input('guild_id', '');
|
||||
$reslut = model('Guild')->guild_info($guild_id,$uid);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -205,7 +210,7 @@ class Guild extends BaseCom
|
||||
*/
|
||||
public function set_guild_info(){
|
||||
$uid = $this->uid;
|
||||
$guild_id = input('guild_id', 0);
|
||||
$guild_id = input('guild_id', '');
|
||||
//群聊名称
|
||||
$name = input('name', '');
|
||||
//群聊公告
|
||||
@@ -216,5 +221,30 @@ class Guild extends BaseCom
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
/*
|
||||
* 我的工会
|
||||
*
|
||||
*/
|
||||
public function my_guild(){
|
||||
$uid = $this->uid;
|
||||
$reslut = model('Guild')->my_guild($uid);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
/*
|
||||
* 受邀申请处理
|
||||
*/
|
||||
public function invite_apply_handle(){
|
||||
$uid = $this->uid;
|
||||
$apply_id = input('apply_id', 0);
|
||||
$type = input('type', 0);
|
||||
$system_message = Db::name('system_message')->where(['id'=>$apply_id,'delete_time'=>0])->find();
|
||||
if($system_message['type'] == 6){
|
||||
$reslut = model('Guild')->guild_invite_handle($uid, $apply_id, $type);
|
||||
}elseif($system_message['type'] == 7){
|
||||
$reslut = model('Guild')->user_ratio_up_apply($uid, $apply_id, $type);
|
||||
}
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class Index extends BaseCom
|
||||
public function room_list()
|
||||
{
|
||||
$is_top = input('is_top', 0); //1非置顶2置顶
|
||||
$label_id = input('label_id', 0);
|
||||
$label_id = input('label_id');
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 20);
|
||||
|
||||
@@ -29,9 +29,47 @@ class Index extends BaseCom
|
||||
//房间类型列表
|
||||
public function room_type_list()
|
||||
{
|
||||
$list = db::name('vs_room_type')->where(['status' => 1, 'deletetime' => 0])->field('id,type_name as label_name')->order('sort asc')->select();
|
||||
$list = db::name('vs_room_label')
|
||||
->where(['status' => 1])
|
||||
->field('id,label_name,default_index,sort')->order('sort asc')->select();
|
||||
$is_default = 1;
|
||||
if($list){
|
||||
$default_index = 0;
|
||||
$label_name = '';
|
||||
$sort = 99;
|
||||
foreach ($list as $k => $v) {
|
||||
if($v['id'] == 3 || $v['id'] == 4){
|
||||
$label_name = '亲密/真爱拍';
|
||||
if($v['default_index'] == 1){
|
||||
$default_index = 1;
|
||||
}
|
||||
$sort = min($sort, $v['sort']);
|
||||
unset($list[$k]);
|
||||
}
|
||||
}
|
||||
if($label_name){
|
||||
//添加到列表后面
|
||||
$list[] = [
|
||||
'id' => 0,
|
||||
'label_name' => $label_name,
|
||||
'default_index' => $default_index,
|
||||
'sort' => $sort
|
||||
];
|
||||
}
|
||||
//数据重组避免乱序 再根据sort 排序 越小的越靠前
|
||||
$list = array_values($list);
|
||||
usort($list, function ($a, $b) {
|
||||
return $a['sort'] - $b['sort'];
|
||||
});
|
||||
}
|
||||
foreach ($list as $v){
|
||||
if($v['default_index'] == 1){
|
||||
$is_default = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//给前面添加一组数据
|
||||
array_unshift($list, ['id' => -1, 'label_name' => '热门']);
|
||||
array_unshift($list, ['id' => -1, 'label_name' => '热门','default_index' => $is_default, 'sort' => 99]);
|
||||
return V(1, '获取成功', $list);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,4 +36,27 @@ class Level extends BaseCom
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//歌手等级
|
||||
public function get_singer_level(){
|
||||
$uid = $this->uid;
|
||||
$reslut = model('Level')->get_singer_level($uid);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//是否歌手
|
||||
public function is_singer(){
|
||||
$uid = $this->uid;
|
||||
$singer = model('api/SingerSong')->singerAuthStatus($uid);
|
||||
if($singer['status'] == 1){
|
||||
$data = [
|
||||
'status' => 1,
|
||||
'level' => $singer['level'],
|
||||
];
|
||||
}else{
|
||||
$data = [
|
||||
'status' => 0,
|
||||
'level' => 0,
|
||||
];
|
||||
}
|
||||
return V(1,'成功', $data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use app\common\controller\NumberAuth;
|
||||
use app\api\controller\Sms;
|
||||
use http\Client;
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
use think\Loader;
|
||||
use Firebase\JWT\JWT;
|
||||
use think\Log;
|
||||
@@ -65,14 +66,21 @@ class Login extends Controller
|
||||
}
|
||||
|
||||
$user_name = input('user_login');
|
||||
|
||||
$sms_code = input('sms_code', ''); //短信验证码
|
||||
if (\think\Env::get('app.system_type','prod') != "prod" && $sms_code == "999999999") {
|
||||
// 非正式环境且验证码为999999,直接放行
|
||||
}else{
|
||||
$key_name = "api:login:phone_code_verify:" . $user_name;
|
||||
redis_lock_exit($key_name);
|
||||
// $sms = new Sms;
|
||||
// $ret = $sms->check($user_name, $sms_code);//$event = default-默认登录,1-更换手机号,2绑定手机号,3-忘记密码,4-设置密码,5-账号注销,6-提现
|
||||
$ret = model('sms')->verification_code('default',$user_name, $sms_code);
|
||||
redis_unlock($key_name);
|
||||
if ($ret['code'] == 0) {
|
||||
return V($ret['code'], $ret['msg'], null);
|
||||
}
|
||||
|
||||
}
|
||||
$reslut = model('Login')->phone_verification_code_log($user_name, $system,$login_device);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -106,6 +114,14 @@ class Login extends Controller
|
||||
if (!$mobile) {
|
||||
return V(0, '登录失败, 请更换登录方式!' );
|
||||
}
|
||||
//检测是否注销过
|
||||
$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天内,不可操作。');
|
||||
}
|
||||
}
|
||||
|
||||
if(ctype_digit($mobile)){
|
||||
$reslut = model('Login')->phone_verification_code_log($mobile,$system,$login_device);
|
||||
@@ -357,8 +373,32 @@ class Login extends Controller
|
||||
//注销
|
||||
public function cancel()
|
||||
{
|
||||
$system = input('system','');
|
||||
if(empty($system)){
|
||||
$system = request()->header('system');
|
||||
}
|
||||
$login_device = input('deviceId','');
|
||||
if(empty($login_device)){
|
||||
$login_device = request()->header('deviceId');
|
||||
}
|
||||
$token = input('token');
|
||||
$reslut = model('Login')->cancel($token);
|
||||
$sms_code = input('sms_code', ''); //短信验证码
|
||||
|
||||
$user_info = db::name('user_token')->where('token', $token)->find();
|
||||
$user_phone = db::name('user')->where(['id' => $user_info['user_id']])->value('mobile');
|
||||
if ($user_phone) {
|
||||
if(!$sms_code){
|
||||
return V(0, '网络错误,请返回【我的】刷新后重新尝试!' );
|
||||
}else{
|
||||
//$event = default-默认登录,1-更换手机号,2绑定手机号,3-忘记密码,4-设置密码,5-账号注销,6-提现
|
||||
$ret = model('sms')->verification_code(5,$user_phone, $sms_code);
|
||||
if ($ret['code'] == 0) {
|
||||
return V($ret['code'], $ret['msg'], null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$reslut = model('Login')->cancel($token, $system,$login_device);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
43
application/api/controller/Lottery.php
Normal file
43
application/api/controller/Lottery.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use app\common\service\LotteryService;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
use think\Log;
|
||||
|
||||
class Lottery extends BaseCom
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* 中奖统计接口
|
||||
* @return json
|
||||
*/
|
||||
public function stat()
|
||||
{
|
||||
try {
|
||||
$where = [
|
||||
'uid' => $this->request->param('uid/d', 0),
|
||||
'prize_type' => $this->request->param('prize_type/d', 0),
|
||||
'start_time' => $this->request->param('start_time/d', 0),
|
||||
'end_time' => $this->request->param('end_time/d', time())
|
||||
];
|
||||
$service = new LotteryService();
|
||||
$stat = $service->statWinner($where);
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '统计成功',
|
||||
'data' => $stat
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
Log::error('中奖统计失败:' . $e->getMessage());
|
||||
return json([
|
||||
'code' => 1,
|
||||
'msg' => $e->getMessage(),
|
||||
'data' => []
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
45
application/api/controller/Nobility.php
Normal file
45
application/api/controller/Nobility.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
|
||||
class Nobility extends BaseCom
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
//允许跨域
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
}
|
||||
//爵位列表
|
||||
public function get_nobility_list(){
|
||||
$uid = $this->uid;
|
||||
$reslut = model('Nobility')->getNobilityList($uid);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//爵位详情
|
||||
public function get_nobility_detail(){
|
||||
$uid = $this->uid;
|
||||
$reslut = model('Nobility')->getNobilityInfo($uid);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//爵位购买价格
|
||||
public function get_nobility_price(){
|
||||
$id = input('id', 0);
|
||||
$uid = $this->uid;
|
||||
$reslut = model('Nobility')->buyNobilityPrice($uid,$id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//爵位购买
|
||||
public function buy_nobility(){
|
||||
$lid = input('lid', 0);
|
||||
$uid = input('uid', $this->uid);
|
||||
$reslut = model('Nobility')->buyNobility($uid,$lid);
|
||||
return V($reslut['code'],$reslut['msg'], null);
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,12 @@ class Page extends controller
|
||||
{
|
||||
$id = input('id', '');
|
||||
$reslut = model('Page')->get_page($id);
|
||||
$html = $reslut['content'] ? $reslut['content'] : '';
|
||||
if($reslut){
|
||||
$html = $reslut['content'] ??'';
|
||||
}else{
|
||||
$html = '';
|
||||
}
|
||||
|
||||
//解析html
|
||||
$html = htmlspecialchars_decode($html);
|
||||
return $html;
|
||||
|
||||
@@ -22,14 +22,21 @@ class Payment extends Controller
|
||||
* APP支付
|
||||
*/
|
||||
public function app_pay() {
|
||||
$type = input('type', 0); //1-微信 2-支付宝 4-通联支付宝 5-通联微信
|
||||
$type = input('type', 0); //1-微信 2-支付宝 4-通联支付宝 5-通联微信 6-苹果支付
|
||||
$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){
|
||||
if(!$coin && $nobility_id == 0){
|
||||
$coin = $money * get_system_config_value('rmb_coin_ratio');
|
||||
}
|
||||
if (!$user_id) {
|
||||
@@ -50,22 +57,23 @@ class Payment extends Controller
|
||||
return V(0, '未成年不可充值!', null);
|
||||
}
|
||||
|
||||
if (!is_numeric($money) || floor($money) != $money || $money <= 0 || $money > 2000) {
|
||||
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 = "APP充值到用户". ($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['coin'] = $coin;
|
||||
$data['createtime'] = time();
|
||||
$data['remarke'] = '充值到app用户'.($user_code ?? "") ."余额!";
|
||||
$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) {
|
||||
@@ -76,7 +84,7 @@ class Payment extends Controller
|
||||
//引用支付宝sdk
|
||||
Loader::import('AliPayV2.AliPay', EXTEND_PATH, '.php');
|
||||
$ali = new \AliPay();
|
||||
$result['ali'] = $ali->aliAppPays($order_number, $money, $title);
|
||||
$result['ali'] = $ali->aliAppPays($order_number, $money, $title, $user_id);
|
||||
}elseif($type == 1){
|
||||
//引用微信sdk
|
||||
Loader::import('WxPay.WxPay', EXTEND_PATH, '.php');
|
||||
@@ -87,6 +95,13 @@ class Payment extends Controller
|
||||
Loader::import('TongLian.TongLian', EXTEND_PATH, '.php');
|
||||
$tonglian = new \TongLian();
|
||||
$result['tl'] = $tonglian->TongLianPay($data, $type);
|
||||
}elseif($type == 6){
|
||||
$result = [
|
||||
'order_no' => $order_number,
|
||||
// 'merchant_id' => get_system_config_value('merchant_id')
|
||||
];
|
||||
}else{
|
||||
return V(0, '请选择正确的支付方式', null);
|
||||
}
|
||||
|
||||
return V(1, 'app支付', $result);
|
||||
@@ -327,4 +342,92 @@ class Payment extends Controller
|
||||
echo "fail";
|
||||
}
|
||||
}
|
||||
|
||||
//苹果回调
|
||||
public function notify_apple(){
|
||||
// 1. 接收APP端参数
|
||||
$orderNo = input('order_no', 0);
|
||||
$paymentToken = input('payment_token', ''); // APP端获取的支付凭证
|
||||
|
||||
// 2. 参数校验
|
||||
if (empty($orderNo) || empty($paymentToken)) {
|
||||
return V(0, '参数缺失');
|
||||
}
|
||||
|
||||
// 3. 查询订单(防止订单不存在)
|
||||
$order = Db::name('vs_user_recharge')->where('order_sn', $orderNo)->find();
|
||||
if (!$order) {
|
||||
return V(0, '订单不存在');
|
||||
}
|
||||
if ($order['pay_status'] == 2) {
|
||||
return V(0, '订单已支付');// 幂等处理,防止重复回调
|
||||
}
|
||||
|
||||
// 4. 调用苹果接口验证支付凭证
|
||||
$verifyResult = $this->verifyApplePayReceipt($paymentToken);
|
||||
if (!$verifyResult) {
|
||||
return V(0, '支付凭证验证失败');
|
||||
}
|
||||
|
||||
// 2. 从苹果返回的凭证中解析实际支付金额(//沙箱环境没有这个参数)
|
||||
$applePayAmount = $verifyResult['receipt']['in_app'][0]['price'] ?? 0; // 苹果返回的实际支付金额
|
||||
|
||||
// 3. 校验金额一致性(允许微小误差,如分位四舍五入)
|
||||
if (abs($order['money'] - $applePayAmount) > 0.01) {
|
||||
// 金额不一致,拒绝更新订单
|
||||
// return V(0, '金额不一致');//沙箱环境没有这个参数
|
||||
}
|
||||
|
||||
$transaction_id = $verifyResult['receipt']['in_app'][0]['transaction_id'] ?? '';// 苹果返回的订单号
|
||||
// 5. 更新订单状态
|
||||
//成功后的业务逻辑处理
|
||||
$where['order_sn']=$orderNo;
|
||||
$where['order_type']=1;//1 充值
|
||||
$where['pay_type']=6;//1微信2支付宝 3通联支付宝 4通联微信
|
||||
$where['pay_status']=1;
|
||||
|
||||
$data=[
|
||||
'trade_no' => $transaction_id
|
||||
];
|
||||
|
||||
$res = handelCharge($where,$data);
|
||||
if($res==0){
|
||||
return V(0, '订单处理失败');
|
||||
}
|
||||
return V(1, '支付成功');
|
||||
}
|
||||
|
||||
|
||||
// 核心:调用苹果服务器验证支付凭证
|
||||
private function verifyApplePayReceipt($paymentToken)
|
||||
{
|
||||
// 订单创建时的金额(固定/用户输入的自由金额)
|
||||
|
||||
// 1. 组装请求参数
|
||||
$postData = json_encode([
|
||||
'receipt-data' => $paymentToken, // APP端传入的支付凭
|
||||
]);
|
||||
|
||||
// 2. 先请求生产环境,失败再试沙箱(苹果推荐逻辑)
|
||||
// $url = 'https://buy.itunes.apple.com/verifyReceipt';//正式验证环境
|
||||
$url = "https://sandbox.itunes.apple.com/verifyReceipt";//沙箱测试环境
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 生产环境建议开启
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
$result = json_decode($result, true);
|
||||
// 验证返回码:status=0表示验证成功
|
||||
if ($result['status'] == 0) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ class Ranking extends BaseCom
|
||||
//真爱榜
|
||||
public function love_ranking()
|
||||
{
|
||||
$reslut = $this->model->love_ranking();
|
||||
$reslut = $this->model->love_rankings();
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,14 +22,16 @@ class Report extends BaseCom
|
||||
public function report(){
|
||||
// $user_id = input('user_id', '');//举报者
|
||||
$type_id = input('type_id', '');//举报类型
|
||||
$report_type = input('report_type', '');//1-用户,2房间,3动态
|
||||
$report_type = input('report_type', '');//1-用户,2房间,3动态,4公会
|
||||
$content = input('content', '');//举报内容
|
||||
$image = input('image', '');//举报图片,多个用英文逗号隔开
|
||||
$from_id = input('from_id', '');//举报来源id
|
||||
if($type_id == '' || $report_type == '' || $from_id == ''){
|
||||
return V(0,"参数错误",null);
|
||||
}
|
||||
|
||||
if($content == '' && $image == ''){
|
||||
return V(0,"请填写举报内容或上传证据图片",null);
|
||||
}
|
||||
$data = [
|
||||
'user_id' => $this->uid,
|
||||
'type_id' => $type_id,
|
||||
@@ -42,5 +44,20 @@ class Report extends BaseCom
|
||||
$res = db::name('vs_user_inform')->insert($data);
|
||||
return V($res ? 1 : 0, $res ? "成功" : "失败", null);
|
||||
}
|
||||
//安卓日志提交
|
||||
public function android_log_report(){
|
||||
$log_name = input('log_name', '');
|
||||
$log_url = input('log_url', '');
|
||||
$user_id = $this->uid;
|
||||
$data = [
|
||||
'log_name' => $log_name,
|
||||
'log_url' => $log_url,
|
||||
'user_id' => $user_id,
|
||||
'createtime' => time(),
|
||||
];
|
||||
$res = db::name('vs_android_log')->insert($data);
|
||||
return V($res ? 1 : 0, $res ? "成功" : "失败", null);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,15 +7,25 @@ use think\Db;
|
||||
|
||||
class Room extends BaseCom
|
||||
{
|
||||
|
||||
|
||||
//创建房间
|
||||
public function create_room()
|
||||
{
|
||||
$room_name = input('room_name', '');
|
||||
$room_cover = input('room_cover', '');
|
||||
$room_intro = input('room_intro', '');
|
||||
|
||||
$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');
|
||||
if($signCount < $num){
|
||||
$need_sign_num = $num - $signCount;
|
||||
return V(0, '还需签约'.$need_sign_num.'人,才能创建房间!');
|
||||
}
|
||||
|
||||
$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);
|
||||
$reslut = model('Room')->user_create_room($this->uid, $room_name, $room_cover, $room_intro,0,0);
|
||||
redis_unlock($key_name);
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
@@ -35,15 +45,6 @@ class Room extends BaseCom
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//关注的用户现在所在房间(废弃)
|
||||
public function user_follow_in_room_list()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 15);
|
||||
|
||||
$reslut = model('Room')->user_follow_in_room_list($this->uid, $page, $page_limit);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//房间随机名称
|
||||
public function room_random_name()
|
||||
@@ -55,7 +56,7 @@ class Room extends BaseCom
|
||||
public function user_room_history_list()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 15);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$reslut = model('UserData')->user_room_history_list($this->uid, $page, $page_limit);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -116,6 +117,16 @@ class Room extends BaseCom
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//进入房间前的判断
|
||||
public function before_join_room_check()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$reslut = model('Room')->before_join_room_check($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 进入房间
|
||||
*/
|
||||
@@ -123,6 +134,24 @@ class Room extends BaseCom
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$password = input('password', '');
|
||||
|
||||
//检测系统是否维护中
|
||||
$is_maintenance = get_system_config_value('is_maintenance');
|
||||
//获取内侧账号
|
||||
$inside_uid = get_system_config_value('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, '不可访问');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$reslut = model('Room')->join_room($this->uid, $room_id, $password);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -153,13 +182,18 @@ class Room extends BaseCom
|
||||
redis_lock_exit($key_name);
|
||||
$room_id = input('room_id', 0);
|
||||
$gift_id = input('gift_id', 0);
|
||||
$gift_num = input('gift_num', 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']);
|
||||
}
|
||||
@@ -192,7 +226,7 @@ class Room extends BaseCom
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$page = input('page', 1);
|
||||
$limit = input('limit', 50);
|
||||
$limit = input('limit', 15);
|
||||
$reslut = model('Room')->room_online_list($room_id, $page, $limit);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -275,7 +309,7 @@ class Room extends BaseCom
|
||||
public function change_room_type()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$type = input('type', 1);//1-点唱,2-拍卖,3-男神,4-女神,7-交友
|
||||
$type = input('type', 1);//1-交友,2-拍卖,7-互娱,8-交友(不要了),9-点唱,10-签约
|
||||
$reslut = model('Room')->change_room_type($this->uid, $room_id, $type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -315,16 +349,6 @@ class Room extends BaseCom
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//禁麦 \解禁
|
||||
// public function set_mute_pit()
|
||||
// {
|
||||
// $room_id = input('room_id', 0);
|
||||
// $pit_number = input('pit_number', 0);
|
||||
// $is_mute = input('is_mute', 0);//0 未禁麦 1已
|
||||
// $reslut = model('Room')->set_mute_pit($this->uid, $room_id, $pit_number,$is_mute);
|
||||
// return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
// }
|
||||
|
||||
//锁麦\解锁
|
||||
public function set_lock_pit()
|
||||
{
|
||||
@@ -412,16 +436,6 @@ class Room extends BaseCom
|
||||
}
|
||||
|
||||
|
||||
//房间在线列表
|
||||
public function room_online_list_ceshi()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$page = input('page', 1);
|
||||
$limit = input('limit', 50);
|
||||
$reslut = model('Room')->room_online_list($room_id, $page, $limit);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//房间用户当前魅力值列表
|
||||
public function room_user_charm_list()
|
||||
{
|
||||
@@ -431,18 +445,6 @@ class Room extends BaseCom
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
// //创建房间
|
||||
// public function create_rooms()
|
||||
// {
|
||||
// //查询所有的房间信息
|
||||
// $room = db::name('vs_room')->field('id,user_id')->where(['room_status' => ['<>',3]])->select();
|
||||
// $i = 0;
|
||||
// foreach ($room as $value) {
|
||||
// $reslut = model('Tencent')->create_group($value['user_id'],'room'.$value['id']);
|
||||
// $i++;
|
||||
// }
|
||||
// return['code' => 1, 'msg' => '成功创建了'.$i.'个房间', 'data' => null];
|
||||
// }
|
||||
|
||||
//用户重连
|
||||
public function user_reconnect()
|
||||
@@ -460,4 +462,23 @@ class Room extends BaseCom
|
||||
$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()
|
||||
{
|
||||
$user_id = input('user_id', '');
|
||||
$room_id = input('room_id', 0);
|
||||
$reslut = model('Room')->send_room_message($this->uid, $user_id,$room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//师徒任务跳转房间
|
||||
public function task_jump_room()
|
||||
{
|
||||
$task_id = input('task_id', 0);
|
||||
$reslut = model('Room')->task_jump_room_recommend($task_id);
|
||||
return V(1, '成功', $reslut);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Db;
|
||||
|
||||
class RoomAuction extends BaseCom
|
||||
{
|
||||
@@ -18,6 +19,10 @@ class RoomAuction extends BaseCom
|
||||
public function room_auction_time()
|
||||
{
|
||||
$gift_id = input('gift_id');
|
||||
$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_time($gift_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -29,6 +34,15 @@ class RoomAuction extends BaseCom
|
||||
$room_id = input('room_id');
|
||||
$user_id = input('user_id');
|
||||
$gift_id = input('gift_id');
|
||||
//礼物不能是CP礼物
|
||||
$cp_gift_ids = explode(',', get_system_config_value('cp_gift_id'));
|
||||
if (in_array($gift_id, $cp_gift_ids)) {
|
||||
return V( 0, '礼物不能是CP礼物,请重新选择');
|
||||
}
|
||||
$pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
|
||||
if($gift_id == $pool_gift_id){
|
||||
return V(0, '此礼物不能进行此操作');
|
||||
}
|
||||
$relation_id = input('relation_id','');
|
||||
$auction_type = input('auction_type',1);//1真爱拍 2 亲密拍
|
||||
$time_day = input('time_day', 0);//小时
|
||||
@@ -54,7 +68,10 @@ class RoomAuction extends BaseCom
|
||||
$gift_id = input('gift_id');
|
||||
$num = input('num');
|
||||
$type = input('type',1);//1金币购买 2送背包礼物
|
||||
|
||||
$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);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
23
application/api/controller/RoomEmoji.php
Normal file
23
application/api/controller/RoomEmoji.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Db;
|
||||
|
||||
class RoomEmoji extends BaseCom
|
||||
{
|
||||
//表情类型列表
|
||||
public function type_list(){
|
||||
$reslut = model('RoomEmoji')->getRoomEmojiType();
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//表情列表
|
||||
public function emoji_list(){
|
||||
$type_id = input('type_id', "");
|
||||
$pid = input('pid', "");
|
||||
$user_id = $this->uid ?? 0;
|
||||
$reslut = model('RoomEmoji')->getRoomEmoji($type_id,$pid,true,$user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ class RoomPit extends BaseCom
|
||||
$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){
|
||||
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)){
|
||||
$reslut = model('RoomSong')->apply_kpit($this->uid, $room_id,$pit_number);
|
||||
@@ -89,6 +89,10 @@ class RoomPit extends BaseCom
|
||||
$room_id = input('room_id', 0);
|
||||
$gift_id = input('gift_id', 0);
|
||||
$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){
|
||||
return V(0, '此礼物不能进行此操作');
|
||||
}
|
||||
$reslut = model('RoomPit')->set_room_pit_apply_help_gift($this->uid, $room_id, $gift_id, $gift_price);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -107,7 +111,13 @@ class RoomPit extends BaseCom
|
||||
}
|
||||
$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 || $room_type == 8)) || $room_type == 2 || $room_type == 7){
|
||||
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)){
|
||||
$reslut = model('RoomSong')->down_kpit($this->uid, $room_id);
|
||||
@@ -138,4 +148,13 @@ class RoomPit extends BaseCom
|
||||
$reslut = model('RoomPit')->host_user_pit($this->uid, $room_id,$pit_number,$user_id,$type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//签约房间主持邀请上签约麦用户拒绝
|
||||
public function refuse_sign_room_host_invite()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$reslut = model('RoomPit')->refuse_sign_room_host_invite($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,8 @@ class RoomSong extends BaseCom
|
||||
redis_lock_exit($key_name);
|
||||
$room_id = input('room_id');
|
||||
$now_room_song_id = input('now_did');
|
||||
$res = model('RoomSong')->change_song($room_id,$now_room_song_id);
|
||||
$is_auto_next = input('is_auto_next');
|
||||
$res = model('RoomSong')->change_song($room_id,$now_room_song_id,$is_auto_next);
|
||||
redis_unlock($key_name);
|
||||
return V($res['code'], $res['msg'], $res['data']);
|
||||
}
|
||||
|
||||
@@ -147,8 +147,8 @@ class Search extends BaseCom
|
||||
}
|
||||
|
||||
$rooms = db::name('vs_room')->field('id as room_id,room_name,room_cover,room_number,label_id,today_hot_value')->where($where1)->select();
|
||||
if(isset($rooms)){
|
||||
foreach ($rooms as $vv){
|
||||
if($rooms){
|
||||
foreach ($rooms as &$vv){
|
||||
$vv['label_icon'] = db::name('vs_room_label')->where('id', $vv['label_id'])->value('label_icon');
|
||||
$vv['hot_value'] = $vv['today_hot_value'];
|
||||
}
|
||||
|
||||
150
application/api/controller/Sign.php
Normal file
150
application/api/controller/Sign.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Db;
|
||||
|
||||
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();
|
||||
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();
|
||||
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');
|
||||
}
|
||||
|
||||
$sign_market_value = get_system_config_value('sign_market_value');
|
||||
//组个列表
|
||||
$sign_coin_list = [];
|
||||
$first_value = $market_value + $sign_market_value; // 第一个值是身价加上sign_market_value
|
||||
for ($i = 0; $i < 8; $i++) {
|
||||
$sign_coin_list[] = (string)($first_value + $i); // 每个值在第一个值的基础上加i(0到7)
|
||||
}
|
||||
return v(1, '成功', $sign_coin_list);
|
||||
}
|
||||
|
||||
|
||||
//签约开始
|
||||
public function start_sign()
|
||||
{
|
||||
$key_name = "api:sign:start_sign:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$room_id = input('room_id', 0);
|
||||
$user_id = input('user_id', 0);
|
||||
if ($room_id <= 0 || $user_id <= 0) {
|
||||
return V(0, '参数错误');
|
||||
}
|
||||
$reslut = model('Sign')->start_sign($this->uid, $room_id, $user_id);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//签约出价
|
||||
public function sign_coin()
|
||||
{
|
||||
$key_name = "api:sign:sign_coin:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
|
||||
$sign_id = input('sign_id', 0);//场次id
|
||||
$sign_value = input('sign_value', 0);
|
||||
|
||||
if ($sign_value <= 0 || $sign_id <= 0) {
|
||||
return V(0, '参数错误');
|
||||
}
|
||||
|
||||
$sign = db::name('vs_room_sign')->where('id', $sign_id)->field('room_id,sign_user_id,sign_type')->find();
|
||||
if($sign['sign_type'] != 1){
|
||||
return V( 0, '该场次签约已结束', null);
|
||||
}
|
||||
$user_id = $sign['sign_user_id'];
|
||||
$room_id = $sign['room_id'];
|
||||
|
||||
$reslut = model('Sign')->sign_coin($this->uid, $room_id, $user_id, $sign_value,$sign_id);
|
||||
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//签约结束
|
||||
public function end_sign()
|
||||
{
|
||||
$sign_id = input('sign_id', 0);
|
||||
if ($sign_id <= 0) {
|
||||
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'];
|
||||
|
||||
$reslut = model('Sign')->end_sign($this->uid, $room_id, $sign_id,$user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//签约延时
|
||||
public function sign_delay()
|
||||
{
|
||||
$sign_id = input('sign_id', 0);
|
||||
if ($sign_id <= 0) {
|
||||
return V(0, '参数错误');
|
||||
}
|
||||
$sign = db::name('vs_room_sign')->where('id', $sign_id)->field('room_id,sign_user_id')->find();
|
||||
$room_id = $sign['room_id'];
|
||||
$reslut = model('Sign')->sign_delay($this->uid, $room_id, $sign_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//免费续约
|
||||
public function free_re_sign()
|
||||
{
|
||||
$sign_user_id = input('user_id', 0);
|
||||
if ($sign_user_id <= 0) {
|
||||
return V(0, '参数错误');
|
||||
}
|
||||
$reslut = model('Sign')->free_re_sign($this->uid, $sign_user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//续签
|
||||
public function re_sign()
|
||||
{
|
||||
$sign_user_id = input('user_id', 0);
|
||||
if ($sign_user_id <= 0) {
|
||||
return V(0, '参数错误');
|
||||
}
|
||||
$reslut = model('Sign')->re_sign($this->uid, $sign_user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//才艺列表
|
||||
public function skill_list()
|
||||
{
|
||||
$skill_list = [
|
||||
'唱歌','脱口秀','口技','喊麦','相声'
|
||||
];
|
||||
return V(1, '成功', $skill_list);
|
||||
}
|
||||
|
||||
//获取首次被签约且在约期内的徒弟列表
|
||||
public function get_first_sign_student_list()
|
||||
{
|
||||
$reslut = model('Sign')->get_first_sign_student_list($this->uid);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
209
application/api/controller/SingerSong.php
Normal file
209
application/api/controller/SingerSong.php
Normal file
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Db;
|
||||
|
||||
class SingerSong extends BaseCom
|
||||
{
|
||||
|
||||
//歌手认证
|
||||
public function singerAuth()
|
||||
{
|
||||
//试音地址
|
||||
$song = input('song', 0);
|
||||
if (!$song) {
|
||||
return V(0, '请上传试音地址');
|
||||
}
|
||||
|
||||
$reslut = model('SingerSong')->singerAuth($this->uid, $song);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//歌手添加歌曲
|
||||
public function singerAddSong()
|
||||
{
|
||||
$song_name = input('song_name', 0);
|
||||
if (!$song_name) {
|
||||
return V(0, '请输入歌曲名称');
|
||||
}
|
||||
$gift_id = input('gift_id', 0);
|
||||
if (!$gift_id) {
|
||||
return V(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, '此礼物不能进行此操作');
|
||||
}
|
||||
$gift_num = input('gift_num', 1);
|
||||
$reslut = model('SingerSong')->singerAddSong($this->uid, $song_name, $gift_id, $gift_num);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//歌手删除 歌曲
|
||||
public function singerDelSong()
|
||||
{
|
||||
$id = input('id', 0);
|
||||
if (!$id) {
|
||||
return V(0, '请选择歌曲');
|
||||
}
|
||||
$reslut = db::name('vs_singer_song')->where(['id' => $id])->update(['deletetime' => time()]);
|
||||
if ($reslut) {
|
||||
return V(1, '删除成功');
|
||||
} else {
|
||||
return V(0, '删除失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//歌手修改歌曲
|
||||
public function singerEditSong()
|
||||
{
|
||||
$id = input('id', 0);
|
||||
if (!$id) {
|
||||
return V(0, '请选择歌曲');
|
||||
}
|
||||
db::name('vs_singer_song')->where(['id' => $id])->update(['deletetime' => time()]);
|
||||
$song_name = input('song_name', 0);
|
||||
if (!$song_name) {
|
||||
return V(0, '请输入歌曲名称');
|
||||
}
|
||||
$gift_id = input('gift_id', 0);
|
||||
if (!$gift_id) {
|
||||
return V(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, '此礼物不能进行此操作');
|
||||
}
|
||||
$gift_num = input('gift_num', 1);
|
||||
$reslut = db::name('vs_singer_song')->insert([
|
||||
'user_id' => $this->uid,
|
||||
'song_name' => $song_name,
|
||||
'gift_id' => $gift_id,
|
||||
'gift_num' => $gift_num,
|
||||
'createtime' => time(),
|
||||
]);
|
||||
if ($reslut) {
|
||||
return V(1, '修改成功');
|
||||
} else {
|
||||
return V(0, '修改失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//获取房间内麦位上歌手歌曲
|
||||
public function getSong()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$room_id = input('room_id', 0);
|
||||
//用户ID
|
||||
$user_id = input('user_id', 0);
|
||||
//以上两个参数二选一
|
||||
if (!$room_id && !$user_id) {
|
||||
return V(0, '请选择房间或歌手');
|
||||
}
|
||||
|
||||
$reslut = model('SingerSong')->getSong($this->uid, $user_id, $room_id, $page, $page_limit);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//点歌
|
||||
public function singerSong()
|
||||
{
|
||||
$song_id = input('song_id', 0);
|
||||
if (!$song_id) {
|
||||
return V(0, '请选择歌曲');
|
||||
}
|
||||
$room_id = input('room_id', 0);
|
||||
if (!$room_id) {
|
||||
return V(0, '请选择房间');
|
||||
}
|
||||
$reslut = model('SingerSong')->singerSong($this->uid, $song_id ,$room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//点歌列表
|
||||
public function singerSongList()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 10);
|
||||
$room_id = input('room_id', 0);
|
||||
if (!$room_id) {
|
||||
return V(0, '请选择房间');
|
||||
}
|
||||
$type = input('type', 1);//1:已点列表,2:今日列表,3:昨日列表,4:本周列表,5:本月列表
|
||||
$reslut = model('SingerSong')->singerSongList($room_id,$type,$page,$page_limit);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//点歌各类型各个总数
|
||||
public function singerSongCount()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if (!$room_id) {
|
||||
return V(0, '请选择房间');
|
||||
}
|
||||
$reslut = model('SingerSong')->singerSongCount($room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//歌曲置顶
|
||||
public function singerSongTop()
|
||||
{
|
||||
$id = input('id', 0);
|
||||
if (!$id) {
|
||||
return V(0, '请选择歌曲');
|
||||
}
|
||||
$reslut = db::name('vs_song_log')->where(['id' => $id])->update(['sort' => time()]);
|
||||
if ($reslut) {
|
||||
//给前端推送下首歌曲信息
|
||||
$next_song_info = db::name('vs_song_log')->where(['id' => $id])->find();
|
||||
$next_song_info['boss_user_id'] = $next_song_info['user_id'];
|
||||
$next_song_info['boss_nickname'] = db::name('user')->where(['id' => $next_song_info['user_id']])->value('nickname');
|
||||
$next_song_info['boss_avatar'] = db::name('user')->where(['id' => $next_song_info['user_id']])->value('avatar');
|
||||
$next_song_info['boss_dress'] = model('api/Decorate')->user_decorate_detail($next_song_info['user_id'], 1);
|
||||
$next_song_info['boss_mic_cycle'] = model('api/Decorate')->user_decorate_detail($next_song_info['user_id'],3);
|
||||
$singer_song = db::name('vs_singer_song')->where(['id' => $next_song_info['singer_song_id']])->find();
|
||||
$next_song_info['singer_user_id'] = $singer_song['user_id'];
|
||||
$next_song_info['singer_nickname'] = db::name('user')->where(['id' => $singer_song['user_id']])->value('nickname');
|
||||
$next_song_info['singer_avatar'] = db::name('user')->where(['id' => $singer_song['user_id']])->value('avatar');
|
||||
$next_song_info['singer_dress'] = model('api/Decorate')->user_decorate_detail($singer_song['user_id'], 1);
|
||||
$next_song_info['singer_mic_cycle'] = model('api/Decorate')->user_decorate_detail($singer_song['user_id'],3);
|
||||
$next_song_info['song_name'] = $singer_song['song_name'];
|
||||
|
||||
$data = [
|
||||
'text' => '房间下一首演唱歌曲变化',
|
||||
'next_song_info' => $next_song_info
|
||||
];
|
||||
model('Chat')->sendMsg(1071,$next_song_info['room_id'],$data);
|
||||
|
||||
return V(1, '置顶成功');
|
||||
} else {
|
||||
return V(0, '置顶失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//切歌
|
||||
public function singerSongCut()
|
||||
{
|
||||
$id = input('id', 0);//点歌列表的ID
|
||||
if (!$id) {
|
||||
return V(0, '请选择要切的歌曲列表ID');
|
||||
}
|
||||
|
||||
$reslut = model('SingerSong')->singerSongCut($this->uid, $id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -30,14 +30,25 @@ class Sms extends Api
|
||||
if (!checkMobile($mobile)) {
|
||||
return V(0, '手机号不正确');
|
||||
}
|
||||
|
||||
//检测是否注销过
|
||||
$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天内,不可操作。');
|
||||
}
|
||||
}
|
||||
|
||||
//频率控制
|
||||
$last = db::name('sms')->where(['mobile' => $mobile, 'event' => $event])->order('id', 'DESC')->find();
|
||||
if ($last && time() - $last['createtime'] < 60) {
|
||||
return V(0, '发送频繁');
|
||||
return V(0, '发送频繁!');
|
||||
}
|
||||
$ipSendTotal = db::name('sms')->where(['ip' => $this->request->ip()])->whereTime('createtime', '-1 hours')->count();
|
||||
$ip = request()->server('HTTP_X_REAL_IP') ?: request()->server('HTTP_X_FORWARDED_FOR') ?: request()->ip();
|
||||
$ipSendTotal = db::name('sms')->where(['ip' => $ip])->whereTime('createtime', '-1 hours')->count();
|
||||
if ($ipSendTotal >= 7) {
|
||||
return V(0, '发送频繁');
|
||||
return V(0, '发送频繁!!');
|
||||
}
|
||||
//发送短信
|
||||
$ret = $this->send_smsbao_msg($mobile, $event);
|
||||
|
||||
96
application/api/controller/Tasks.php
Normal file
96
application/api/controller/Tasks.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Controller;
|
||||
/*
|
||||
* 每日任务
|
||||
*
|
||||
*/
|
||||
class Tasks extends BaseCom
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
//允许跨域
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
}
|
||||
|
||||
//每日任务列表
|
||||
public function dailyTasksList()
|
||||
{
|
||||
$user_id = $this->uid;
|
||||
$reslut = model('Tasks')->dailyTasksList($user_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
|
||||
}
|
||||
|
||||
//完成每日任务
|
||||
public function dailyTasksComplete()
|
||||
{
|
||||
$user_id = $this->uid;
|
||||
$task_id = input('task_id');
|
||||
if (!$task_id) {
|
||||
return V(0,'请选择任务');
|
||||
}
|
||||
$reslut = model('Tasks')->tasks_complete($user_id,$task_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//领取每日任务金币奖励
|
||||
public function dailyTasksReceive()
|
||||
{
|
||||
$user_id = $this->uid;
|
||||
$task_id = input('task_id');
|
||||
$student_id = input('student_id',0);
|
||||
if (!$task_id) {
|
||||
return V(0,'请选择任务');
|
||||
}
|
||||
$reslut = model('Tasks')->daily_tasks_receive($user_id,$task_id,$student_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//开启礼盒
|
||||
public function dailyTasksOpenBox()
|
||||
{
|
||||
$user_id = $this->uid;
|
||||
$gift_box_id = input('gift_box_id');
|
||||
if (!$gift_box_id) {
|
||||
return V(0,'请选择礼盒');
|
||||
}
|
||||
$reslut = model('Tasks')->open_gift_box($user_id,$gift_box_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//礼盒记录
|
||||
public function dailyTasksBoxRecord()
|
||||
{
|
||||
$user_id = $this->uid;
|
||||
$reslut = model('Tasks')->gift_bag_receive_list($user_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//签到
|
||||
public function dailyTasksSign(){
|
||||
$user_id = $this->uid;
|
||||
$reslut = model('Tasks')->sign_in($user_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
|
||||
}
|
||||
//签到页面
|
||||
public function dailyTasksSignList(){
|
||||
$user_id = $this->uid;
|
||||
$reslut = model('Tasks')->daily_tasks_sign_in($user_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//今日签到状态
|
||||
public function dailyTasksSignStatus(){
|
||||
$user_id = $this->uid;
|
||||
$reslut = model('Tasks')->daily_tasks_sign_in_status($user_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//未领取奖励任务数量
|
||||
public function dailyTasksUnReceiveCount(){
|
||||
$user_id = $this->uid;
|
||||
$reslut = model('Tasks')->daily_tasks_unfinished_count($user_id);
|
||||
return V($reslut['code'],$reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ class Tencent extends Controller
|
||||
{
|
||||
public function call_back()
|
||||
{
|
||||
return ['ActionStatus' => 'OK', 'ErrorInfo' => '', 'ErrorCode' => 0];
|
||||
$data = input('post.');
|
||||
$sign_data = input('get.');
|
||||
$reslut = model('Tencent')->tencent_call_back($data,$sign_data);
|
||||
|
||||
@@ -29,23 +29,52 @@ class Theme extends controller
|
||||
*/
|
||||
public function get_theme_data()
|
||||
{
|
||||
$reslut = DB::name('vs_theme')->field('theme_color,file_url,auxiliary_color')
|
||||
->where(['delete_time' => 0 ,'is_active' => 1,'begin_time' => ['<',time()],'end_time' => ['>',time()]])->order('id desc')->find();
|
||||
// $reslut = DB::name('vs_theme')->field('theme_color,file_url,auxiliary_color')
|
||||
// ->where(['delete_time' => 0 ,'is_active' => 1,'begin_time' => ['<',time()],'end_time' => ['>',time()]])->order('id desc')->find();
|
||||
//
|
||||
// if($reslut){
|
||||
// $url = $reslut['file_url'];
|
||||
// $reslut['btn_text_color'] = $reslut['auxiliary_color'];
|
||||
// $reslut['app_bg'] = get_system_config_value('web_site').'/static/theme/'.$url.'/app_bg.png';
|
||||
// $reslut['home_sel'] = get_system_config_value('web_site').'/static/theme/'.$url.'/home_sel.png';
|
||||
// $reslut['home_nor'] = get_system_config_value('web_site').'/static/theme/'.$url.'/home_nor.png';
|
||||
// $reslut['find_sel'] = get_system_config_value('web_site').'/static/theme/'.$url.'/find_sel.png';
|
||||
// $reslut['find_nor'] = get_system_config_value('web_site').'/static/theme/'.$url.'/find_nor.png';
|
||||
// $reslut['msg_sel'] = get_system_config_value('web_site').'/static/theme/'.$url.'/msg_sel.png';
|
||||
// $reslut['msg_nor'] = get_system_config_value('web_site').'/static/theme/'.$url.'/msg_nor.png';
|
||||
// $reslut['mine_sel'] = get_system_config_value('web_site').'/static/theme/'.$url.'/mine_sel.png';
|
||||
// $reslut['mine_nor'] = get_system_config_value('web_site').'/static/theme/'.$url.'/mine_nor.png';
|
||||
// }
|
||||
|
||||
if($reslut){
|
||||
$url = $reslut['file_url'];
|
||||
$reslut['btn_text_color'] = $reslut['auxiliary_color'];
|
||||
$reslut['app_bg'] = get_system_config_value('web_site').'/static/theme/'.$url.'/app_bg.png';
|
||||
$reslut['home_sel'] = get_system_config_value('web_site').'/static/theme/'.$url.'/home_sel.png';
|
||||
$reslut['home_nor'] = get_system_config_value('web_site').'/static/theme/'.$url.'/home_nor.png';
|
||||
$reslut['find_sel'] = get_system_config_value('web_site').'/static/theme/'.$url.'/find_sel.png';
|
||||
$reslut['find_nor'] = get_system_config_value('web_site').'/static/theme/'.$url.'/find_nor.png';
|
||||
$reslut['msg_sel'] = get_system_config_value('web_site').'/static/theme/'.$url.'/msg_sel.png';
|
||||
$reslut['msg_nor'] = get_system_config_value('web_site').'/static/theme/'.$url.'/msg_nor.png';
|
||||
$reslut['mine_sel'] = get_system_config_value('web_site').'/static/theme/'.$url.'/mine_sel.png';
|
||||
$reslut['mine_nor'] = get_system_config_value('web_site').'/static/theme/'.$url.'/mine_nor.png';
|
||||
//版本号
|
||||
$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;
|
||||
}
|
||||
}
|
||||
$reslut = [];
|
||||
return V(1,'操作成功', $reslut,$api_version);
|
||||
}
|
||||
|
||||
// 节日主题
|
||||
public function get_festival_theme()
|
||||
{
|
||||
$theme = DB::name('vs_theme')->field('theme_name,theme_color,file_url,auxiliary_color')
|
||||
->where(['delete_time' => 0 ,'is_active' => 1,'begin_time' => ['<=',time()],'end_time' => ['>=',time()]])->order('id desc')->find();
|
||||
$reslut['is_open'] = 0;
|
||||
if($theme){
|
||||
$reslut['theme_name'] = $theme['theme_name'];
|
||||
$reslut['is_open'] = 1;
|
||||
}
|
||||
return V(1,'操作成功', $reslut);
|
||||
}
|
||||
}
|
||||
|
||||
20
application/api/controller/Upload.php
Normal file
20
application/api/controller/Upload.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use app\common\controller\Upload as UploadFile;
|
||||
|
||||
class Upload extends BaseCom
|
||||
{
|
||||
|
||||
//获取上传文件的临时秘钥
|
||||
public function getTempKeys()
|
||||
{
|
||||
$upload = new UploadFile();
|
||||
$reslut = $upload->getTempCredential();
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ use app\common\library\Ems;
|
||||
use app\common\library\Sms;
|
||||
use fast\Random;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
@@ -222,7 +223,18 @@ class User extends BaseCom
|
||||
public function get_user_info()
|
||||
{
|
||||
$reslut = model('user')->get_me($this->uid);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
//版本号
|
||||
$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();
|
||||
$result = version_compare($api_versions['apiversion'],$app_version);
|
||||
if ($result < 0) {
|
||||
$api_version = 1;
|
||||
}
|
||||
}
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data'],$api_version);
|
||||
}
|
||||
|
||||
//关注(回关)
|
||||
@@ -273,4 +285,24 @@ class User extends BaseCom
|
||||
$reslut = model('UserWallet')->give_coin($this->uid, $give_uid, $coin);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//挚友列表
|
||||
public function get_friend_list()
|
||||
{
|
||||
$user_id = input('user_id', 0);//用户id
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$reslut = model('User')->get_friend_list($user_id, $page, $page_limit);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//挚友列表查看更多
|
||||
public function get_friend_list_more()
|
||||
{
|
||||
$user_id = input('user_id', 0);//用户id
|
||||
$relation_id = input('relation_id', 0);
|
||||
$reslut = model('User')->get_friend_list_more($user_id, $relation_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
|
||||
36
application/api/controller/UserCp.php
Normal file
36
application/api/controller/UserCp.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Db;
|
||||
|
||||
class UserCp extends BaseCom
|
||||
{
|
||||
//用户CP礼物回赠
|
||||
public function cpGiveGift()
|
||||
{
|
||||
$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);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//Cp 空间
|
||||
public function cpZone()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 15);
|
||||
$user_id = input('user_id', 0);
|
||||
$reslut = model('UserCp')->cpZone($user_id, $page, $page_limit);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,7 +15,7 @@ class UserData extends BaseCom
|
||||
$key_name = "api:user:follow_user:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$nick_name = input('nickname');
|
||||
$birthday = input('birthday');
|
||||
$birthday = input('birthday', '1990-01-01');
|
||||
$sex = input('sex', 0);
|
||||
$head_pic = input('avatar', '');
|
||||
$reg_code = input('init_code', '');
|
||||
@@ -47,7 +47,7 @@ class UserData extends BaseCom
|
||||
$key_name = "api:user:follow_user:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
$nick_name = input('nick_name');
|
||||
$birthday = input('birthday');
|
||||
$birthday = input('birthday', '1990-01-01');
|
||||
$sex = input('sex', 1);
|
||||
$head_pic = input('head_pic', '');
|
||||
$images = input('images', '');//背景图(以json字符串的形式可以多图)
|
||||
@@ -80,19 +80,28 @@ class UserData extends BaseCom
|
||||
{
|
||||
$key_name = "api:user:bind_mobile:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
|
||||
$mobile = input('new_mobile');
|
||||
$sms_code = input('sms_code', '');
|
||||
|
||||
//default-默认登录,1-更换手机号,2绑定手机号,3-忘记密码,4-设置密码,5-账号注销,6-提现
|
||||
$reslut = model('sms')->verification_code(2,$mobile, $sms_code);
|
||||
if ($reslut['code'] == 0) {
|
||||
redis_unlock($key_name);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
//查询新手机号绑定的数量
|
||||
$new_mobile_num = db::name('user')->where(['mobile' => $mobile,'status' => ['neq', 0]])->count();
|
||||
if ($new_mobile_num >= 3) {
|
||||
return v(0, '该手机号已达绑定上限');
|
||||
}
|
||||
$reslut = model('UserData')->modify_mobile($mobile,$this->uid);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//更换手机号
|
||||
//default-默认登录,1-更换手机号,2绑定手机号,3-忘记密码,4-设置密码,5-账号注销,6-提现
|
||||
//更换手机号
|
||||
public function modify_mobile()
|
||||
{
|
||||
@@ -102,10 +111,13 @@ class UserData extends BaseCom
|
||||
$new_mobile = input('new_mobile');
|
||||
$sms_code = input('sms_code', '');
|
||||
$user_mobile = db::name('user')->where('id',$this->uid)->value('mobile');
|
||||
if($user_mobile){
|
||||
if ($user_mobile != $mobile){
|
||||
redis_unlock($key_name);
|
||||
return V(0, "旧手机号错误", null);
|
||||
// return V(0, "旧手机号错误", null);
|
||||
}
|
||||
}
|
||||
|
||||
if ($new_mobile == $user_mobile){
|
||||
redis_unlock($key_name);
|
||||
return V(0, "新手机号不能与旧手机号一致", null);
|
||||
@@ -121,6 +133,59 @@ class UserData extends BaseCom
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//更换手机号
|
||||
//default-默认登录,1-更换手机号,2绑定手机号,3-忘记密码,4-设置密码,5-账号注销,6-提现
|
||||
public function modify_mobiles()
|
||||
{
|
||||
$key_name = "api:user:modify_mobile:" . $this->uid;
|
||||
redis_lock_exit($key_name);
|
||||
|
||||
$mobile = input('mobile');
|
||||
$sms_code = input('sms_code', '');
|
||||
$user_mobile = db::name('user')->where('id',$this->uid)->value('mobile');
|
||||
if ($user_mobile != $mobile){
|
||||
redis_unlock($key_name);
|
||||
return V(0, "旧手机号错误", null);
|
||||
}
|
||||
//验证原有手机号
|
||||
$reslut = model('sms')->verification_code(1,$mobile, $sms_code);
|
||||
if ($reslut['code'] == 0) {
|
||||
redis_unlock($key_name);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
$new_mobile = input('new_mobile');
|
||||
$new_sms_code = input('new_sms_code', '');
|
||||
if ($new_mobile == $user_mobile){
|
||||
redis_unlock($key_name);
|
||||
return V(0, "新手机号不能与旧手机号一致", null);
|
||||
}
|
||||
//验证新手机号
|
||||
$reslut1 = model('sms')->verification_code(1,$new_mobile, $new_sms_code);
|
||||
if ($reslut1['code'] == 0) {
|
||||
redis_unlock($key_name);
|
||||
return v($reslut1['code'], $reslut1['msg'], $reslut1['data']);
|
||||
}
|
||||
//查询新手机号是否绑定过
|
||||
$new_mobile_num = db::name('user')->where(['mobile' => $new_mobile])->select();
|
||||
if ($new_mobile_num){
|
||||
foreach ($new_mobile_num as $key => $value){
|
||||
if($value['status'] != 0){
|
||||
redis_unlock($key_name);
|
||||
return V(0, "换绑失败,请联系客服", null);
|
||||
}
|
||||
if(time() - $value['delete_time'] < 60 * 60 * 24 * 30){
|
||||
redis_unlock($key_name);
|
||||
return V(0, "此手机号已注销,30天内不允许操作", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$reslut2 = model('UserData')->modify_mobile($new_mobile,$this->uid);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut2['code'], $reslut2['msg'], $reslut2['data']);
|
||||
}
|
||||
|
||||
//实名认证
|
||||
public function real_name()
|
||||
{
|
||||
@@ -134,7 +199,7 @@ class UserData extends BaseCom
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//实名认证结果获取
|
||||
//实名认证成功后通知后端
|
||||
public function real_name_result()
|
||||
{
|
||||
$orderNo = input('orderNo', '');
|
||||
@@ -149,4 +214,13 @@ class UserData extends BaseCom
|
||||
$reslut = model('UserData')->real_name_info($this->uid);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//隐身设置
|
||||
public function modify_hide_status()
|
||||
{
|
||||
$status = input('hide_status', 0);//0-取消隐身,1-设置隐身
|
||||
$reslut = model('UserData')->modify_hide_status($this->uid,$status);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,8 +57,16 @@ class UserWallet extends BaseCom
|
||||
//收益(钻石)兑换金币
|
||||
public function exchange_coin()
|
||||
{
|
||||
$key_name = 'exchange_coin_' . $this->uid;
|
||||
redis_lock_exits($key_name, 10, 10);
|
||||
$earnings_num = input('earnings_num', 0);
|
||||
//最少兑换钻石
|
||||
$min_earnings_num = get_system_config_value('min_earnings_num');
|
||||
if ($earnings_num < $min_earnings_num) {
|
||||
return V(0, '兑换金额不能小于' . $min_earnings_num);
|
||||
}
|
||||
$reslut = model('UserWallet')->exchange_coin($this->uid,$earnings_num);
|
||||
redis_unlocks($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
@@ -77,9 +85,52 @@ class UserWallet extends BaseCom
|
||||
foreach ($reslut as $k=>$v){
|
||||
$reslut_data[$k]['money'] = $v['money'];
|
||||
$reslut_data[$k]['coins'] = $v['coins'];
|
||||
$reslut_data[$k]['ios_coins'] = $v['coins'] * 7 / 10;
|
||||
$reslut_data[$k]['product_id'] = $v['product_id'];
|
||||
}
|
||||
return V(1, '获取成功', $reslut_data);
|
||||
}
|
||||
|
||||
//苹果商店充值金额列表
|
||||
public function can_recharge_list_ios(){
|
||||
$app_version = request()->header('App-Version');
|
||||
$system = request()->header('system');
|
||||
|
||||
$reslut = db::name("vs_can_recharge")->where("status",1)->where("delete_time",0)->order('money asc')->select();
|
||||
$reslut_data = [];
|
||||
|
||||
if ($system == 'iOS') {
|
||||
$api_versions = db::name('version')->where(['type' => 2, 'status' => 1])->order('id', 'desc')->find();
|
||||
//app的版本和用户使用的当前版本比对
|
||||
//$api_versions['newversion'] 是数据库当前的版本 也是用户使用的版本
|
||||
//$app_version 有可能是appstore里面的审核版本 审核版本比用户的版本高
|
||||
|
||||
$result = version_compare($api_versions['newversion'],$app_version);
|
||||
if ($result < 0) {//-1:前面版本小于后面版本,0:相等,1:前面版本大于后面版本
|
||||
// $api_version = 1;//商店审核版本给前端返回1
|
||||
foreach ($reslut as $k=>$v){
|
||||
if($v['money'] == 2000){
|
||||
$reslut_data[$k]['money'] = '1999.00';
|
||||
}else{
|
||||
$reslut_data[$k]['money'] = $v['money'];
|
||||
}
|
||||
$reslut_data[$k]['coins'] = $v['coins'];
|
||||
$reslut_data[$k]['ios_coins'] = $v['coins'] * 7 / 10;
|
||||
$reslut_data[$k]['product_id'] = $v['product_id'];
|
||||
}
|
||||
}else{
|
||||
foreach ($reslut as $k=>$v){
|
||||
$reslut_data[$k]['money'] = $v['money'];
|
||||
$reslut_data[$k]['coins'] = $v['coins'];
|
||||
$reslut_data[$k]['ios_coins'] = $v['coins'] * 7 / 10;
|
||||
$reslut_data[$k]['product_id'] = $v['product_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return V(1, '获取成功', $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['oldversion'],$app_version);
|
||||
$result = version_compare($api_versions['apiversion'],$app_version);
|
||||
if ($result < 0) {
|
||||
$api_version = 1;
|
||||
}
|
||||
@@ -185,6 +185,10 @@ class UserZone extends BaseCom
|
||||
$gift_id = input('gift_id', 0);
|
||||
$num = input('num', 1);
|
||||
$is_pack = input('is_pack', 1);//2背包 1金币
|
||||
$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('GiveGift')->reward_zone($this->uid, $zid, $gift_id, $num, $is_pack);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
@@ -11,21 +11,102 @@ use app\common\controller\BaseCom;
|
||||
class Xintiao extends BaseCom
|
||||
{
|
||||
|
||||
|
||||
public function keep_xintiao()
|
||||
//房间内保持心跳
|
||||
public function keep_room_heartbeat()
|
||||
{
|
||||
$room_id = input('room_id');
|
||||
if(!$room_id){
|
||||
return V(0, '参数错误', null);
|
||||
}
|
||||
$user_id = $this->uid;
|
||||
$is_xintiao = db::name('vs_xintiao')->where('user_id' , $user_id)->find();
|
||||
$is_xintiao = db::name('vs_room_heartbeat')->where(['user_id' => $user_id, 'room_id' => $room_id])->find();
|
||||
if($is_xintiao){
|
||||
db::name('vs_xintiao')->where('user_id' , $user_id)->update(['updatetime' => time()]);
|
||||
db::name('vs_room_heartbeat')->where('id' , $is_xintiao['id'])->update(['updatetime' => time()]);
|
||||
}else{
|
||||
db::name('vs_xintiao')->insert([
|
||||
db::name('vs_room_heartbeat')->insert([
|
||||
'user_id' => $user_id,
|
||||
'room_id' => $room_id,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
}
|
||||
return true;
|
||||
//任务: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');
|
||||
//查询徒弟是否是首签的徒弟 sign_user_type:被签用户的类型:0-首次被签,1-签约过期,2-违约签
|
||||
$user_sign = db::name('vs_user_sign')
|
||||
->where(['sign_user_id' => $user_id,'sign_user_type' => 0,'end_time' => ['>',time()]])->field('parent_user_id,sign_user_id')->select();
|
||||
if($user_sign){
|
||||
foreach ($user_sign as $v){
|
||||
if($room_type == 2){
|
||||
//查询徒弟在不在房间
|
||||
$is_room = db::name('vs_room_visitor')
|
||||
->where(['user_id' => $v['sign_user_id'], 'room_id' => $room_id])->find();
|
||||
if($is_room){
|
||||
//任务:21-邀请徒弟在拍卖房停留(0/5)分钟,并送给徒弟(0/1 ,特殊礼物)
|
||||
model('Tasks')->tasks_complete($v['parent_user_id'], 21, 1,$v['sign_user_id']);
|
||||
}
|
||||
}
|
||||
if($room_type == 7){
|
||||
//查询徒弟在不在房间
|
||||
$is_room = db::name('vs_room_visitor')
|
||||
->where(['user_id' => $v['sign_user_id'], 'room_id' => $room_id])->find();
|
||||
if($is_room){
|
||||
//任务:23-邀请徒弟在交友房停留(0/5)分钟,并送给徒弟(0/1 ,特殊礼物)
|
||||
model('Tasks')->tasks_complete($v['parent_user_id'], 23, 1,$v['sign_user_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//是否有在限时时间内的Cp任务
|
||||
//查询是否已经存在Cp空间
|
||||
$rees = Db::name('user_cp_zone')->where(['user_id1' => $user_id,'status' => 1])->find();
|
||||
if(!$rees){
|
||||
$rees = Db::name('user_cp_zone')->where(['user_id2' => $user_id,'status' => 1])->find();
|
||||
}
|
||||
if($rees){
|
||||
//查询另一个 用户在不在 房间内
|
||||
if($rees['user_id1'] == $user_id){
|
||||
$UserId = $rees['user_id2'];
|
||||
}else{
|
||||
$UserId = $rees['user_id1'];
|
||||
}
|
||||
$is_room = db::name('vs_room_visitor')
|
||||
->where(['user_id' => $UserId, 'room_id' => $room_id])->find();
|
||||
if($is_room){
|
||||
//成为Cp的天数
|
||||
$createtime =Db::name('user_cp_zone')->where(['id' => $rees['id']])->value('createtime');
|
||||
$days = floor((time() - $createtime) / 86400);
|
||||
if($days <= 7){
|
||||
$is_time = Db::name('vs_user_cp_task')->where(['user_id' => $rees['user_id1'],'status' => 0,'day' => date('Y-m-d', time()),'delete_time' => 0])->find();
|
||||
$is_time2 = Db::name('vs_user_cp_task')->where(['user_id' => $rees['user_id2'],'status' => 0,'day' => date('Y-m-d', time()),'delete_time' => 0])->find();
|
||||
if($is_time && $is_time['need_time_value'] > $is_time['time_value']){
|
||||
$exo_value = ($is_time['time_value'] + 0.5) >= $is_time['need_time_value'] ? $is_time['need_time_value'] : ($is_time['time_value'] + 0.5);
|
||||
$data_cp = [
|
||||
'time_value' => $exo_value,
|
||||
];
|
||||
if($exo_value >= $is_time['need_time_value'] && $is_time['exp_value'] == $is_time['need_exp_value']){
|
||||
$data_cp['status'] = 1;
|
||||
}
|
||||
Db::name('vs_user_cp_task')->where(['id' => $is_time['id']])->update($data_cp);
|
||||
Db::name('vs_user_cp_task')->where(['id' => $is_time2['id']])->update($data_cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//返回任务未领取奖励数
|
||||
$not_received_tasks_num = model('Tasks')->daily_tasks_unfinished_count($user_id);
|
||||
$return_data = [
|
||||
'not_received_tasks_num' => $not_received_tasks_num['data']['num']
|
||||
];
|
||||
return V(1, '成功', $return_data);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +114,4 @@ class Xintiao extends BaseCom
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -11,424 +11,42 @@ use app\common\controller\Push;
|
||||
class Xxiaoshi extends Controller
|
||||
{
|
||||
|
||||
|
||||
public function send_gift()
|
||||
public function test()
|
||||
{
|
||||
//获取上一个小时的开始时间和结束时间
|
||||
$start_time = strtotime(date('Y-m-d H:00:00', strtotime('-1 hour')));
|
||||
$end_time = strtotime(date('Y-m-d H:00:00'));
|
||||
echo "开始时间:" .$start_time."\n";
|
||||
echo "结束时间:" .$end_time."\n";
|
||||
//当前小时的前一个小时(24小时计时法,0-23)
|
||||
$pre_hour = date('H', strtotime('-1 hour'));
|
||||
echo "上个时间段:" .$pre_hour."\n";
|
||||
$is_open_time = db::name('vs_hour_ranking_config')->where('id', 1)->value('open_time');
|
||||
if ($is_open_time == 0) {
|
||||
echo "未开启时间段:" .$is_open_time."\n";
|
||||
return;
|
||||
$res = db::name('user_zone')->where(['is_delete'=> 2,'delete_time'=> ['<>', 0]])->select();
|
||||
if($res){
|
||||
foreach ($res as $v){
|
||||
//删除动态下的标签引用
|
||||
$top_zone = db::name('user_zone_topic')->where('zone_id',$v['id'])->select();
|
||||
if($top_zone){
|
||||
foreach ($top_zone as $vs){
|
||||
db::name('user_zone_topic')->where('id',$vs['id'])->delete();
|
||||
}
|
||||
//是否全局飘瓶
|
||||
$is_public_server = db::name('vs_hour_ranking_config')->where('id', 1)->value('is_public_server');
|
||||
if ($is_public_server == 1) {
|
||||
//全局飘瓶时间段
|
||||
$xlh_time_range = db::name('vs_hour_ranking_config')->where('id', 1)->value('broadcast_times');
|
||||
if($xlh_time_range){
|
||||
if($xlh_time_range == 25){
|
||||
$is_piao = 1;
|
||||
}else{
|
||||
|
||||
//当前的前一个小时是否在 $xlh_time_range中
|
||||
if (in_array($pre_hour, explode(',', $xlh_time_range))) {
|
||||
$is_piao = 1;
|
||||
} else {
|
||||
$is_piao = 0;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$is_piao = 0;
|
||||
}
|
||||
}else{
|
||||
$is_piao = 0;
|
||||
}
|
||||
|
||||
//获取上一个时间段的配置
|
||||
// $gift_list = db::name('vs_hour_ranking_gift_config')->where('time_id',$pre_hour)->group('ranking')->order('id', 'desc')->select();
|
||||
$gift_list = $this->get_hour_ranking($pre_hour);
|
||||
// echo "上个时间段的配置:" .json_encode($gift_list)."\n";
|
||||
// 提取所有有奖励的内容
|
||||
$allRewards = $this->extractAllRewards($gift_list);
|
||||
// 按index分组
|
||||
$groupedRewards = $this->groupRewardsByIndex($allRewards);
|
||||
// 按名次顺序分配奖励
|
||||
$distributionResult = $this->distributeByRank($groupedRewards);
|
||||
|
||||
//获取上个数组的个数,从而获取配置了多少个名次
|
||||
$count = count($distributionResult);
|
||||
echo "上个时间段的配置总数:" .$count."\n";
|
||||
//获取前一个小时的 前$count名房间排行
|
||||
$room_list = model('api/RoomHourRanking')->room_hour_ranking(1, $count, $start_time, $end_time);
|
||||
$room_owner = [];
|
||||
if ($room_list['code'] == 1) {
|
||||
//获取房间排行奖励最低值
|
||||
$min_price = db::name('vs_hour_ranking_config')->where('id', 1)->value('min_price');
|
||||
if ($room_list['data']['lists']) {
|
||||
echo "房间列表:" .json_encode($room_list['data']['lists'])."\n";
|
||||
foreach ($room_list['data']['lists'] as $v){
|
||||
if ($v['total_price'] >= $min_price) {
|
||||
$room_owner[] = [
|
||||
'user_id' => $v['user_id'],
|
||||
'room_name' => $v['room_name'],
|
||||
'room_id' => $v['room_id'],
|
||||
'total_price' => $v['total_price']
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($distributionResult && $room_owner) {
|
||||
$text_list_new = [];
|
||||
echo "礼物数:" .json_encode($distributionResult)."\n";
|
||||
echo "房主:" .json_encode($room_owner)."\n";
|
||||
foreach ($distributionResult as $k => $value) {
|
||||
//礼物全部给他偷偷放在装扮表及金额 中
|
||||
//有几个用户就发几个
|
||||
if(count($room_owner) > $k){
|
||||
// 为每个房间添加一个标志,表示是否已处理推送信息
|
||||
$hasProcessedPush = false;
|
||||
|
||||
foreach ($value['rewards'] as $v){
|
||||
// if($v['type'] == 0){//1金币2礼物3头像4坐骑
|
||||
// echo "发金币:" .$v['value'].'==>'.$room_owner[$k]['user_id']."\n";
|
||||
// $res = $this->add_coin($v['value'], $room_owner[$k]['user_id'],$k + 1,$room_owner[$k]['room_id'],$room_owner[$k]['total_price'],$is_piao);
|
||||
// }elseif ($v['type'] == 1){
|
||||
// echo "发礼物:" .$v['value'].'==>'.$room_owner[$k]['user_id']."\n";
|
||||
// $res = $this->add_gift($v['value'], $room_owner[$k]['user_id'],$k + 1,$room_owner[$k]['room_id'],$room_owner[$k]['total_price'],$is_piao);
|
||||
// }elseif ($v['type'] == 2){
|
||||
// $res = $this->add_decorate($v['value'], $room_owner[$k]['user_id'],$k + 1,$room_owner[$k]['room_id'],$room_owner[$k]['total_price'],$is_piao,3);
|
||||
// }elseif ($v['type'] == 3){
|
||||
// $res = $this->add_decorate($v['value'], $room_owner[$k]['user_id'],$k + 1,$room_owner[$k]['room_id'],$room_owner[$k]['total_price'],$is_piao,4);
|
||||
// }
|
||||
// 只有在第一次处理奖励时添加推送信息,避免重复推送
|
||||
if(!$hasProcessedPush && $is_piao == 1) {
|
||||
$room_name = $room_owner[$k]['room_name'];
|
||||
//推送礼物横幅
|
||||
if ($k == 0) {
|
||||
$text = '新科状元!【' . $room_name . '】独占鳌头!';
|
||||
} elseif ($k == 1) {
|
||||
$text = '金榜榜眼!【' . $room_name . '】才气逼人!';
|
||||
} elseif ($k == 2) {
|
||||
$text = '风采探花!【' . $room_name . '】实力绽放!';
|
||||
}
|
||||
|
||||
$text_list_new[] = [
|
||||
'text' => $text ?? '恭喜【' . $room_name . '】获得礼物!',
|
||||
'room_id' => $room_owner[$k]['room_id'],
|
||||
'room_name' => $room_name,
|
||||
'rank_number' => $k + 1,
|
||||
];
|
||||
|
||||
$hasProcessedPush = true; // 标记已处理推送
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if(!empty($text_list_new)){
|
||||
$push = new Push();
|
||||
$push->hourRankingcs($text_list_new);
|
||||
Log::record("小时榜推送:".json_encode($text_list_new),"infos");
|
||||
}
|
||||
}
|
||||
echo "送礼-共" . count($room_owner) . "个房间房主获益\n";
|
||||
}
|
||||
|
||||
//添加金币到钱包
|
||||
// public function add_coin($coin,$user_id,$ranking,$room_id,$total_price,$is_piao){
|
||||
// if($coin > 0){
|
||||
// $data = [
|
||||
// 'user_id' => $user_id,
|
||||
// 'change_value' => $coin,
|
||||
// // 'room_id' => $room_ids,
|
||||
// 'money_type' => 1,
|
||||
// 'change_type' => 27,
|
||||
// 'from_id' => 0,
|
||||
// 'remarks' => '小时榜获得',
|
||||
// 'createtime' => time()
|
||||
// ];
|
||||
|
||||
// //开启事务
|
||||
// Db::startTrans();
|
||||
// $res = Db::name('vs_user_money_log')->insert($data);
|
||||
// if(!$res){
|
||||
// Db::rollback();
|
||||
// }
|
||||
|
||||
// //增加用户金币
|
||||
// $res1 = Db::name('user_wallet')->where(['user_id'=>$user_id])->setInc('coin',$coin);
|
||||
// if(!$res1){
|
||||
// Db::rollback();
|
||||
// }
|
||||
|
||||
// //添加到排行表
|
||||
// $start_time = strtotime(date('Y-m-d H:00:00', strtotime('-1 hour')));
|
||||
// $end_time = strtotime(date('Y-m-d H:00:00')) - 1;
|
||||
// $res2 = db::name('vs_hour_ranking')->insert([
|
||||
// 'ranking' => $ranking,
|
||||
// 'room_id' => $room_id,
|
||||
// 'flowing_water' => $total_price,
|
||||
// 'coin' => $coin,
|
||||
// 'time_id' => date('H', strtotime('-1 hour')),
|
||||
// 'stime' => $start_time,
|
||||
// 'etime' => $end_time,
|
||||
// 'createtime' => time(),
|
||||
// 'updatetime' => time(),
|
||||
// 'is_public_server' => $is_piao
|
||||
// ]);
|
||||
// if(!$res2){
|
||||
// Db::rollback();
|
||||
// }
|
||||
// Db::commit();
|
||||
// }
|
||||
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// //添加礼物到背包
|
||||
// public function add_gift($gift_id,$user_id,$ranking,$room_id,$total_price,$is_piao){
|
||||
// $res = model('api/UserGiftPack')->change_user_gift_pack($user_id,$gift_id,1,model('UserGiftPack')::HOUR_RANK_GET,"小时榜获得");
|
||||
// if($res['code'] == 0){
|
||||
// Log::record("小时榜获取礼物失败:".$res['msg'],"info");
|
||||
// }
|
||||
|
||||
// //添加到排行表
|
||||
// $start_time = strtotime(date('Y-m-d H:00:00', strtotime('-1 hour')));
|
||||
// $end_time = strtotime(date('Y-m-d H:00:00')) - 1;
|
||||
// $res2 = db::name('vs_hour_ranking')->insert([
|
||||
// 'ranking' => $ranking,
|
||||
// 'room_id' => $room_id,
|
||||
// 'flowing_water' => $total_price,
|
||||
// 'gift_id' => $gift_id,
|
||||
// 'gift_type' => 2,
|
||||
// 'time_id' => date('H', strtotime('-1 hour')),
|
||||
// 'stime' => $start_time,
|
||||
// 'etime' => $end_time,
|
||||
// 'createtime' => time(),
|
||||
// 'updatetime' => time(),
|
||||
// 'is_public_server' => $is_piao
|
||||
// ]);
|
||||
// if(!$res2){
|
||||
// Log::record("小时榜礼物锁定失败","info");
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// //添加装扮到背包
|
||||
// public function add_decorate($avatar_id,$user_id,$ranking,$room_id,$total_price,$is_piao,$type){
|
||||
// $decorate_price_info = db::name('vs_decorate_price')->where(['id'=>$avatar_id])->find();
|
||||
// if(empty($decorate_price_info)){
|
||||
// Log::record("小时榜获取装扮失败:没有找到装扮!".$avatar_id,"info");
|
||||
// }
|
||||
// $res = model('api/Decorate')->pay_decorate($user_id,$decorate_price_info['did'],$decorate_price_info['day'],2);
|
||||
// if($res['code'] == 0){
|
||||
// Log::record("小时榜获取装扮失败:".$res['msg']."-".$avatar_id,"info");
|
||||
// }
|
||||
// //添加到排行表
|
||||
// $start_time = strtotime(date('Y-m-d H:00:00', strtotime('-1 hour')));
|
||||
// $end_time = strtotime(date('Y-m-d H:00:00')) - 1;
|
||||
// $res2 = db::name('vs_hour_ranking')->insert([
|
||||
// 'ranking' => $ranking,
|
||||
// 'room_id' => $room_id,
|
||||
// 'flowing_water' => $total_price,
|
||||
// 'gift_id' => $avatar_id,
|
||||
// 'gift_type' => $type,
|
||||
// 'time_id' => date('H', strtotime('-1 hour')),
|
||||
// 'stime' => $start_time,
|
||||
// 'etime' => $end_time,
|
||||
// 'createtime' => time(),
|
||||
// 'updatetime' => time(),
|
||||
// 'is_public_server' => $is_piao,
|
||||
// ]);
|
||||
// if(!$res2){
|
||||
// Log::record("小时榜咋装扮锁定失败","info");
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 提取所有有奖励的内容
|
||||
*/
|
||||
private function extractAllRewards($responseData)
|
||||
//测试数据
|
||||
public function testData()
|
||||
{
|
||||
$allRewards = [];
|
||||
|
||||
foreach ($responseData as $timeSlot) {
|
||||
foreach ($timeSlot['reward'] as $rewardItem) {
|
||||
$index = $rewardItem['index'];
|
||||
$content = $rewardItem['content'];
|
||||
|
||||
// 只处理有奖励内容的数据
|
||||
if (!empty($content)) {
|
||||
foreach ($content as $rewardContent) {
|
||||
$allRewards[] = [
|
||||
'index' => $index,
|
||||
'type' => $rewardContent['type'],
|
||||
'value' => $rewardContent['value'],
|
||||
'name' => $rewardContent['name'] ?? ''
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $allRewards;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按index分组奖励
|
||||
*/
|
||||
private function groupRewardsByIndex($allRewards)
|
||||
{
|
||||
$grouped = [];
|
||||
|
||||
foreach ($allRewards as $reward) {
|
||||
$index = $reward['index'];
|
||||
if (!isset($grouped[$index])) {
|
||||
$grouped[$index] = [];
|
||||
}
|
||||
$grouped[$index][] = $reward;
|
||||
}
|
||||
|
||||
// 按index排序
|
||||
ksort($grouped);
|
||||
|
||||
return $grouped;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按名次顺序分配奖励
|
||||
*/
|
||||
private function distributeByRank($groupedRewards)
|
||||
{
|
||||
$distribution = [];
|
||||
$currentRank = 0; // 从第1名开始
|
||||
|
||||
// 按index顺序分配(index 0 = 第1名,index 1 = 第2名,以此类推)
|
||||
foreach ($groupedRewards as $index => $rewards) {
|
||||
// 确保名次连续,如果有空缺则填充空名次
|
||||
while ($currentRank < $index) {
|
||||
$distribution[] = [
|
||||
'rank' => $currentRank + 1,
|
||||
'rewards' => []
|
||||
];
|
||||
$currentRank++;
|
||||
}
|
||||
|
||||
// 分配当前名次的奖励
|
||||
$distribution[] = [
|
||||
'rank' => $currentRank + 1,
|
||||
'rewards' => $rewards
|
||||
];
|
||||
$currentRank++;
|
||||
}
|
||||
|
||||
return $distribution;
|
||||
}
|
||||
|
||||
public function get_hour_ranking($time){
|
||||
// 先按时间段和排名索引分组查询
|
||||
$timeRanges = db::name('vs_hour_ranking_gift_config')->distinct(true)
|
||||
->where('time_id', '=', $time)
|
||||
->order('time_id')
|
||||
->column('time_id');
|
||||
|
||||
$result = [];
|
||||
foreach ($timeRanges as $timeRange) {
|
||||
// 查询该时间段的所有数据
|
||||
$rewards = db::name('vs_hour_ranking_gift_config')->where('time_id', $timeRange)
|
||||
->field('ranking, gift_type, gift_id,coin,name')
|
||||
->order('ranking')
|
||||
$res = db::name('vs_user_gift_pack')
|
||||
->field('gid,after_num')
|
||||
->where(['a.updatetime'=> ['<=', 1766332800]])
|
||||
->group('a.gid')
|
||||
->select();
|
||||
|
||||
$rewardMap = [];
|
||||
foreach ($rewards as $reward) {
|
||||
$rankIndex = $reward['ranking'];
|
||||
|
||||
if (!isset($rewardMap[$rankIndex])) {
|
||||
$rewardMap[$rankIndex] = [
|
||||
'index' => $rankIndex,
|
||||
// 'name' => $reward['rank_name'],
|
||||
'content' => []
|
||||
];
|
||||
$total_price = 0;
|
||||
if($res){
|
||||
foreach ($res as $v){
|
||||
$gft_price = db::name('vs_gift')->where('gid',$v['gid'])->value('gift_price');
|
||||
$total_price += $gft_price * $v['after_num'];
|
||||
}
|
||||
|
||||
// 添加奖励内容到content数组
|
||||
if ($reward['gift_id'] != 0 || $reward['coin'] != 0) {
|
||||
if($reward['gift_id'] != 0){
|
||||
$rewardMap[$rankIndex]['content'][] = [
|
||||
'type' => $reward['gift_type'],
|
||||
'value' => $reward['gift_id'],
|
||||
// 'coin' => $reward['coin'],
|
||||
'name' => $reward['name'],
|
||||
];
|
||||
}
|
||||
if($reward['coin'] != 0){
|
||||
$rewardMap[$rankIndex]['content'][] = [
|
||||
'type' => $reward['gift_type'],
|
||||
'value' => $reward['coin'],
|
||||
'name' => $reward['name'],
|
||||
];
|
||||
echo $total_price;
|
||||
echo '<br>';
|
||||
var_dump($res);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 按index排序
|
||||
ksort($rewardMap);
|
||||
|
||||
$result[] = [
|
||||
'time' => $timeRange,
|
||||
'reward' => array_values($rewardMap)
|
||||
];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function give_gifts(){
|
||||
$data = db::name('vs_give_gift')->where('from_id',5483)->select();
|
||||
$num = 0;
|
||||
$i=0;
|
||||
$j = 0;
|
||||
foreach($data as $v){
|
||||
$j += $v['total_price'];
|
||||
$nuu = db::name('vs_give_gift_ratio_log')->where('give_gift_id',$v['id'])->value('room_owner_earning');
|
||||
$id = db::name('vs_give_gift_ratio_log')->where('give_gift_id',$v['id'])->value('id');
|
||||
// echo $id."--".$nuu."\n";
|
||||
$num += $nuu;
|
||||
$i++;
|
||||
}
|
||||
echo $num;
|
||||
echo "==".$i."==".$j;
|
||||
|
||||
// echo db::name()->where(['user_id' => 10857,'money_type' =>2,'change_type' =>18])-sum('change_value');
|
||||
}
|
||||
|
||||
|
||||
public function room_liushui(){
|
||||
// $room = db::name('vs_give_gift')->where(['from_id' => ['<>',5418],'from' => 2])->group('from_id');
|
||||
$dd = db::name('vs_user_gift_pack')->alias('a')->join('vs_gift b','a.gid = b.gid')->field('a.gid,a.num,b.gift_price')->where(['a.num' =>['>',0]])->select();
|
||||
$count = 0;
|
||||
foreach ($dd as $v){
|
||||
$count += $v['gift_price'] * $v['num'];
|
||||
}
|
||||
echo $count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -239,7 +239,7 @@ class Activities extends Model
|
||||
// 添加活动记录
|
||||
$reslut = Db::name('vs_activities_receive')->insert([
|
||||
'user_id' => $user_id,
|
||||
'activities_id' => 1,
|
||||
'activities_id' => 7,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
@@ -252,4 +252,29 @@ class Activities extends Model
|
||||
}
|
||||
}
|
||||
|
||||
//获取礼包总价值
|
||||
public static function get_gift_bag_total_price($gift_bag_id){
|
||||
$gift_bag_detail = Db::name('vs_gift_bag_detail')->where(['gift_bag_id'=>$gift_bag_id])->select();
|
||||
$total_price = 0;
|
||||
foreach ($gift_bag_detail as $k=>$v){
|
||||
switch ($v['type']) {
|
||||
case 1: //金币
|
||||
$total_price += $v['quantity']*$v['gold'];
|
||||
break;
|
||||
case 2: //礼物 方法2:添加到用户礼物背包
|
||||
$gift_price = db::name('vs_gift')->where(['gid'=>$v['foreign_id']])->value('gift_price');
|
||||
$total_price += $gift_price * $v['quantity'];
|
||||
break;
|
||||
case 3: //坐骑 方法3:添加到用户装扮
|
||||
$decorate_price = db::name('vs_decorate_price')->where(['id'=>$v['foreign_id']])->value('price');
|
||||
$total_price += $decorate_price * $v['quantity'];
|
||||
break;
|
||||
case 4: //道具 方法5:钻石
|
||||
$total_price += $v['quantity']*$v['gold'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $total_price;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ class Banner extends Model
|
||||
2 => '启动页',
|
||||
3 => '首页轮播图',
|
||||
4 => '房间首页',
|
||||
5 => '工会列表页广告位'
|
||||
5 => '工会列表页广告位',
|
||||
6 => '我的页面'
|
||||
];
|
||||
//1纯展示 2文章 3房间 4个人主页 5外站'
|
||||
public $Type = [
|
||||
|
||||
@@ -75,29 +75,30 @@ class BlindBoxTurntableGift extends Model
|
||||
*/
|
||||
public function gift_send($send_id){
|
||||
try{
|
||||
$blind_box_turntable = db('vs_blind_box_turntable_log')->where(['id'=>$send_id,'is_sued'=>0])->find();
|
||||
$blind_box_turntable = Db::name('vs_blind_box_turntable_log')->where(['id'=>$send_id,'is_sued'=>0])->find();
|
||||
if(!$blind_box_turntable){
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
}
|
||||
if(in_array($blind_box_turntable['gift_bag_id'],[11,12])){
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
}
|
||||
$room_id = $blind_box_turntable['room_id'];
|
||||
$blind_box_turntable_log = db('vs_blind_box_turntable_results_log')->where(['tid'=>$send_id])->select();
|
||||
$blind_box_turntable_log = Db::name('vs_blind_box_turntable_results_log')->where(['tid'=>$send_id])->select();
|
||||
if(!$blind_box_turntable_log){
|
||||
return ['code' => 0, 'msg' => '数据不存在','data' => null];
|
||||
}
|
||||
$room_name = Db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->value('room_name');
|
||||
$FromUserInfo = Db::name('user')->where(['id'=>$blind_box_turntable['user_id']])->find();
|
||||
$FromUserInfo['user_id'] = $FromUserInfo['id'];
|
||||
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($blind_box_turntable['user_id']);//财富图标
|
||||
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($blind_box_turntable['user_id']);//魅力图标
|
||||
$FromUserInfo['chat_bubble'] = model('Decorate')->user_decorate_detail($blind_box_turntable['user_id'],9);//聊天气泡
|
||||
$user_nickname = $FromUserInfo['nickname'];
|
||||
$textMessage = $user_nickname;
|
||||
$text_message = [];
|
||||
$userGiftMap = [];
|
||||
$ToUserInfo = [];
|
||||
foreach ($blind_box_turntable_log as $key => $value) {
|
||||
$ToUserInfo = Db::name('user')->where(['id' => $value['gift_user_id']])->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$draw_gift = Db::name('vs_gift')->where(['gid'=>$value['gift_id']])->find();
|
||||
$textMessage = $textMessage . ' 送给 ' . $ToUserInfo['nickname']. ' 盲盒转盘礼物 ' . $draw_gift['gift_name'].' x ' .$value['count']."\n";
|
||||
$play_image[] = $draw_gift['play_image'];
|
||||
$gift_names[] = $draw_gift['gift_name'];
|
||||
|
||||
$text_message = $user_nickname . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $draw_gift['gift_name'] . 'X' . $value['count']."\n";
|
||||
if($draw_gift['is_public_server'] == 1) {
|
||||
$text_list_new[] = [
|
||||
@@ -111,26 +112,73 @@ class BlindBoxTurntableGift extends Model
|
||||
'number' => $value['count'],
|
||||
];
|
||||
}
|
||||
$ToUserInfosList[$value['gift_user_id']] = $ToUserInfo;
|
||||
|
||||
$userId = $value['gift_user_id'];
|
||||
if (!isset($userGiftMap[$userId])) {
|
||||
$userGiftMap[$userId] = [
|
||||
'userInfo' => $ToUserInfo,
|
||||
'gifts' => []
|
||||
];
|
||||
}
|
||||
$userGiftMap[$userId]['gifts'][] = [
|
||||
'gift_id' => $draw_gift['gid'],
|
||||
'gift_name' => $draw_gift['gift_name'],
|
||||
'count' => $value['count'],
|
||||
'play_image' => $draw_gift['play_image'],
|
||||
'base_image' => $draw_gift['base_image']
|
||||
];
|
||||
}
|
||||
|
||||
// 为每个用户单独推送消息
|
||||
foreach($userGiftMap as $userId => $userData) {
|
||||
$userInfo = $userData['userInfo'];
|
||||
$gifts = $userData['gifts'];
|
||||
|
||||
// 构建用户专属文本消息,接收者名字只出现一次
|
||||
$userTextMessage = $user_nickname . ' 送给 ' . $userInfo['nickname'];
|
||||
// 添加该用户收到的所有礼物
|
||||
$giftCount = [];
|
||||
foreach ($gifts as $gift) {
|
||||
$userTextMessage .= ' 盲盒转盘礼物 ' . $gift['gift_name'].' x ' .$gift['count'];
|
||||
// 统计相同礼物的数量
|
||||
$giftCount[] = [
|
||||
'gift_info' => $gift,
|
||||
'count' => $gift['count']
|
||||
];
|
||||
|
||||
}
|
||||
foreach($ToUserInfosList as &$userInfo) {
|
||||
$userInfo['icon'][0] = model('UserData')->user_wealth_icon($userInfo['user_id']);//财富图标
|
||||
$userInfo['icon'][1] = model('UserData')->user_charm_icon($userInfo['user_id']);//魅力图标
|
||||
$userInfo['charm'] = db::name('vs_room_user_charm')->where(['user_id' => $userInfo['user_id'],'room_id' => $room_id])->value('charm');//魅力
|
||||
$ToUserInfos[] = $userInfo;
|
||||
}
|
||||
$text = [
|
||||
|
||||
$userInfo['icon'][0] = model('UserData')->user_wealth_icon($userInfo['user_id']);
|
||||
$userInfo['icon'][1] = model('UserData')->user_charm_icon($userInfo['user_id']);
|
||||
$userInfo['charm'] = db::name('vs_room_user_charm')->where(['user_id' => $userInfo['user_id'],'room_id' => $room_id])->value('charm');
|
||||
|
||||
$userText = [
|
||||
'FromUserInfo' => $FromUserInfo,
|
||||
'ToUserInfos' => $ToUserInfos,
|
||||
'GiftInfo' => [
|
||||
'play_image' => implode(',',$play_image),
|
||||
'gift_name' => implode(',',$gift_names),
|
||||
],
|
||||
'text' => rtrim($textMessage, "\n")
|
||||
'ToUserInfo' => $userInfo,
|
||||
'GiftInfos' => array_values($gifts),
|
||||
'text' => $userTextMessage
|
||||
];
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1005,$room_id,$text);
|
||||
|
||||
// 聊天室推送系统消息给每个用户
|
||||
model('Chat')->sendMsg(1038,$room_id,$userText);
|
||||
|
||||
foreach ($giftCount as $giftData) {
|
||||
$gift_inf = $giftData['gift_info'];
|
||||
$count = $giftData['count'];
|
||||
|
||||
// 推送礼物特效消息
|
||||
$effectData = [
|
||||
'FromUserInfo' => $FromUserInfo,
|
||||
'ToUserInfo' => $userInfo,
|
||||
'GiftInfo' => $gift_inf,
|
||||
'gift_num' => $count,
|
||||
'text' => null
|
||||
];
|
||||
|
||||
// 聊天室推送礼物特效消息
|
||||
model('Chat')->sendMsg(1005,$room_id,$effectData);
|
||||
}
|
||||
}
|
||||
$roomtype = Db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
if($roomtype == 6){
|
||||
//推送消息
|
||||
@@ -153,7 +201,7 @@ class BlindBoxTurntableGift extends Model
|
||||
db::name('vs_blind_box_turntable_log')->where('id', $send_id)->update(['is_sued' => 1, 'updatetime' => time()]);
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
return ['code' => 0, 'msg' => "网络请求错误,请重试!", 'data' => null];
|
||||
return ['code' => 0, 'msg' => "网络请求错误,请重试!".$e->getMessage(), 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -236,23 +284,26 @@ class BlindBoxTurntableGift extends Model
|
||||
$pan_xlh = db::name('vs_room_pan_xlh')->where(['send_time'=>0,'end_time'=>['>',time()]])->order('id desc')->find();
|
||||
$xlh_periods_num = Cache::get("xlh_periods_num") ?? 0;
|
||||
if(empty($pan_xlh)){
|
||||
if($xlh_periods_num >= $xlh_ext['open_condition']['start_num']){
|
||||
$xlh_periods = Cache::get("this_xlh_periods") ?? 0;
|
||||
$pan_xlh_id = db::name('vs_room_pan_xlh')->insertGetId([
|
||||
'room_id' => $room_id,
|
||||
'gift_id' => $xlh_ext['locking_condition']['locking_gift_id'],
|
||||
'homeowner_gift_id' => $xlh_ext['locking_condition']['give_homeowner_gift_id'],
|
||||
'periods' => $xlh_periods+1,
|
||||
'num' => 0,
|
||||
'end_time' => time() + $xlh_ext['locking_time']['end_time'] * 60,
|
||||
'createtime' => time()
|
||||
]);
|
||||
Cache::set("this_xlh_periods", $xlh_periods+1, 0);//修改巡乐会期数
|
||||
$pan_xlh = db::name('vs_room_pan_xlh')->where(['id'=>$pan_xlh_id])->find();
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => '巡乐会已结束', 'data' => null];
|
||||
}
|
||||
}
|
||||
// if(empty($pan_xlh)){
|
||||
// if($xlh_periods_num >= $xlh_ext['open_condition']['start_num']){
|
||||
// $xlh_periods = Cache::get("this_xlh_periods") ?? 0;
|
||||
// $pan_xlh_id = db::name('vs_room_pan_xlh')->insertGetId([
|
||||
// 'room_id' => $room_id,
|
||||
// 'gift_id' => $xlh_ext['locking_condition']['locking_gift_id'],
|
||||
// 'homeowner_gift_id' => $xlh_ext['locking_condition']['give_homeowner_gift_id'],
|
||||
// 'periods' => $xlh_periods+1,
|
||||
// 'num' => 0,
|
||||
// 'end_time' => time() + $xlh_ext['locking_time']['end_time'] * 60,
|
||||
// 'createtime' => time()
|
||||
// ]);
|
||||
// Cache::set("this_xlh_periods", $xlh_periods+1, 0);//修改巡乐会期数
|
||||
// $pan_xlh = db::name('vs_room_pan_xlh')->where(['id'=>$pan_xlh_id])->find();
|
||||
// }else{
|
||||
// return ['code' => 0, 'msg' => '巡乐会已结束', 'data' => null];
|
||||
// }
|
||||
// }
|
||||
$xlh_user_data= null;
|
||||
$room_user_data = null;
|
||||
if($pan_xlh && $pan_xlh['user_id']){
|
||||
@@ -413,4 +464,30 @@ class BlindBoxTurntableGift extends Model
|
||||
];
|
||||
}
|
||||
|
||||
//盲盒转盘开启状态
|
||||
public function blind_box_status(){
|
||||
$gift_bag_ids = [11,12];
|
||||
$gift_bag = db::name('vs_gift_bag')->where(['id'=>['in',$gift_bag_ids]])->select();
|
||||
foreach ($gift_bag as $bag){
|
||||
if($bag['status'] == 1){
|
||||
$result_data[] = [
|
||||
'gift_bag_id' => $bag['id'],
|
||||
'name' => $bag['name'],
|
||||
'status' => 1,
|
||||
'status_str' => '开启中',
|
||||
'icon' => $bag['icon'],
|
||||
];
|
||||
}else{
|
||||
$result_data[] = [
|
||||
'gift_bag_id' => $bag['id'],
|
||||
'name' => $bag['name'],
|
||||
'status' => 0,
|
||||
'status_str' => '未开启',
|
||||
'icon' => $bag['icon'],
|
||||
];
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => $result_data];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1815
application/api/model/BlindBoxTurntableGiftDrawWorldNew.php
Normal file
1815
application/api/model/BlindBoxTurntableGiftDrawWorldNew.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -124,6 +124,34 @@ class Chat extends Model
|
||||
//红包领完推送
|
||||
// RedPacketComplete = 1061,
|
||||
|
||||
//点歌房推送信息
|
||||
//当前歌曲发生变化
|
||||
// SongChange = 1070,
|
||||
//下一首歌曲发生变化
|
||||
// SongNextChange = 1071,
|
||||
//歌曲数量发生变化
|
||||
// SongCountChange = 1072,
|
||||
|
||||
//CP房间推送信息
|
||||
// CP进入房间触发特效
|
||||
// CPRoomEffect = 1080,
|
||||
|
||||
//签约房推送信息
|
||||
//开始签约
|
||||
// SignRoomStart = 1090,
|
||||
//签约房签约出价最高用户
|
||||
// SignRoomSignUser = 1091,
|
||||
//签约房间结束
|
||||
// SignRoomEnd = 1092,
|
||||
//签约延时
|
||||
// SignRoomDelay = 1093,
|
||||
//签约房 邀请用户上签约麦位
|
||||
// SignRoomInviteUser = 1094,
|
||||
|
||||
//爆币房推送信息
|
||||
// BlindCoinRoom = 1100,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -85,8 +85,9 @@ class DailyTasks extends Model
|
||||
$reslut['tasks']['daily_tasks'] = [];//每日任务1
|
||||
$reslut['tasks']['daily_tasks_special'] = [];//每日特殊任务2
|
||||
$reslut['tasks']['usual_tasks'] = [];//平台常规任务3
|
||||
$reslut['tasks']['teacher_tasks'] = [];//师徒任务4
|
||||
$data = db::name('vs_daily_tasks')
|
||||
->field('task_id,icon,task_name,gold_reward,target_quantity,task_type')
|
||||
->field('task_id,icon,task_name,gold_reward,target_quantity,task_type,reward_type')
|
||||
->where('delete_time',0)
|
||||
->where('is_active',1)
|
||||
->order('sort asc')->select();
|
||||
@@ -99,10 +100,26 @@ class DailyTasks extends Model
|
||||
->where('task_id',$v['task_id'])
|
||||
->whereTime('createtime', 'today')
|
||||
->find();
|
||||
}elseif($v['task_id'] == 17){
|
||||
//师徒任务
|
||||
//师傅签约返还
|
||||
$user_sign_task = Db::name('vs_user_sign_task')->where(['user_id'=>$user_id,'day'=>date('Y-m-d')])->find();
|
||||
if(empty($user_sign_task)){
|
||||
continue;
|
||||
}
|
||||
$v['gold_reward'] = $user_sign_task['value'];
|
||||
}else{
|
||||
$user_daily_tasks = Db::name('vs_user_daily_tasks')->where('user_id',$user_id)->where('task_id',$v['task_id'])->find();
|
||||
}
|
||||
$progress = isset($user_daily_tasks['current_progress']) ? $user_daily_tasks['current_progress'] : 0;
|
||||
if($v['task_id'] == 17){
|
||||
if($user_sign_task['status']==1){
|
||||
$progress = $user_sign_task['times'] ?? 0;
|
||||
}else{
|
||||
$progress = $user_sign_task['times']-1 ?? 0;
|
||||
}
|
||||
|
||||
}
|
||||
$quantity_str = "";
|
||||
if($v['target_quantity']!=1){
|
||||
$quantity_str= "({$progress}/{$v['target_quantity']})";
|
||||
@@ -129,6 +146,15 @@ class DailyTasks extends Model
|
||||
$v['task_type_str'] = "去签到";
|
||||
}
|
||||
}
|
||||
if($v['task_id'] == 17){
|
||||
if($user_sign_task['status'] == 0){
|
||||
$v['task_status'] = 2;
|
||||
$v['task_type_str'] = "领取钻石";
|
||||
}else{
|
||||
$v['task_status'] = 3;
|
||||
$v['task_type_str'] = "已领取";
|
||||
}
|
||||
}
|
||||
$v['from_id'] = 0;
|
||||
$v['is_time'] = 0;
|
||||
if(in_array($v['task_id'],[8,9])){
|
||||
@@ -152,15 +178,18 @@ class DailyTasks extends Model
|
||||
$reslut['tasks']['daily_tasks'][] = $v;
|
||||
}elseif ($v['task_type']==2) {
|
||||
$reslut['tasks']['daily_tasks_special'][] = $v;
|
||||
}else{
|
||||
}elseif ($v['task_type']==3) {
|
||||
$reslut['tasks']['usual_tasks'][] = $v;
|
||||
}elseif ($v['task_type']==4) {
|
||||
$reslut['tasks']['teacher_tasks'][] = $v;
|
||||
}
|
||||
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $reslut];
|
||||
}
|
||||
//完成每日任务
|
||||
public function tasks_complete($user_id,$task_id){
|
||||
//废弃
|
||||
return ['code' => 1, 'msg' => '操作成功','data' => ['is_completed'=>0]];
|
||||
//查询任务
|
||||
$task_info = Db::name('vs_daily_tasks')->where('task_id',$task_id)->where('delete_time',0)->where('is_active',1)->find();
|
||||
if(empty($task_info)){
|
||||
@@ -220,16 +249,27 @@ class DailyTasks extends Model
|
||||
|
||||
//领取每日任务金币奖励
|
||||
public function daily_tasks_receive($user_id,$task_id){
|
||||
//废弃
|
||||
return ['code' => 1, 'msg' => "领取成功", 'data' => null];
|
||||
//查询是否实名认证
|
||||
$is_real = model('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];
|
||||
}
|
||||
}
|
||||
$task_info = Db::name('vs_daily_tasks')->where('task_id',$task_id)->find();
|
||||
if (!$task_info) {
|
||||
return ['code' => 0, 'msg' => '任务不存在','data' => null];
|
||||
}
|
||||
if($task_id!=17){
|
||||
if($task_info['task_type']==3){
|
||||
$user_daily_tasks = Db::name('vs_user_daily_tasks')->where('user_id',$user_id)->where('task_id',$task_id)->find();
|
||||
}else{
|
||||
$user_daily_tasks = Db::name('vs_user_daily_tasks')->where('user_id',$user_id)->where('task_id',$task_id)->whereTime('createtime', 'today')->find();
|
||||
}
|
||||
|
||||
if (!$user_daily_tasks) {
|
||||
return ['code' => 0, 'msg' => '请完成该任务','data' => null];
|
||||
}
|
||||
@@ -239,8 +279,38 @@ class DailyTasks extends Model
|
||||
if ($user_daily_tasks['is_claimed'] == 1) {
|
||||
return ['code' => 0, 'msg' => '您已领取该奖励','data' => null];
|
||||
}
|
||||
}else{
|
||||
//师徒任务
|
||||
//师傅签约返还
|
||||
$user_sign_task = Db::name('vs_user_sign_task')->where(['user_id'=>$user_id,'day'=>date('Y-m-d')])->find();
|
||||
if (!$user_sign_task) {
|
||||
return ['code' => 0, 'msg' => '任务不存在或已结束','data' => null];
|
||||
}
|
||||
if($user_sign_task['status']==1){
|
||||
return ['code' => 0, 'msg' => '您已领取该奖励','data' => null];
|
||||
}
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
if($task_id==17){
|
||||
//师徒任务
|
||||
$reslut = Db::name('vs_user_sign_task')->where('id',$user_sign_task['id'])->update([
|
||||
'status' => 1
|
||||
]);
|
||||
if ($reslut) {
|
||||
//操作用户钻石
|
||||
if ($reslut) {
|
||||
$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();
|
||||
return ['code' => 0, 'msg' => $res['msg'], 'data' => null];
|
||||
}
|
||||
} else {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$reslut = Db::name('vs_user_daily_tasks')->where('id',$user_daily_tasks['id'])->update([
|
||||
'is_claimed' => 1,
|
||||
'updatetime' => time(),
|
||||
@@ -250,12 +320,13 @@ class DailyTasks extends Model
|
||||
$res = model('common/UserWallet')->change_user_money($user_id, $user_daily_tasks['gold_reward'], model('common/UserWallet')::MONEYTYPECOIN, model('common/UserWallet')::DAILY_TASKS_REWARD,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::DAILY_TASKS_REWARD)."( ".$task_info['task_name'].")");
|
||||
if ($res['code'] != 1) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => $reslut['msg'], 'data' => null];
|
||||
return ['code' => 0, 'msg' => $res['msg'], 'data' => null];
|
||||
}
|
||||
} else {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
return ['code' => 1, 'msg' => "领取成功", 'data' => null];
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
use think\Cache;
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
use think\Session;
|
||||
@@ -16,8 +17,8 @@ class Decorate extends Model
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
// 定义字段类型 1头像框 2坐骑 3麦圈 6个人靓号 7房间靓号 8公会靓号
|
||||
public $TypeArray = [1=>'头像框',2=>'坐骑',3=>'麦圈',6=>'个人靓号',7=>'房间靓号',8=>'公会靓号'];
|
||||
protected $FromType = [1=>'购买',2=>'后台赠送',3=>'礼盒开奖',4=>'好友赠送',5=>'首充赠送',6=>'天降好礼获得',7=>'财富等级特权赠送',8=>'新人充值好礼'];
|
||||
public $TypeArray = [1=>'头像框',12=>'降身卡',2=>'坐骑',9=>'聊天气泡',6=>'个人靓号',7=>'房间靓号',8=>'公会靓号',3=>'麦圈',10=>'CP特效',11=>'CP装扮'];
|
||||
protected $FromType = [1=>'购买',2=>'后台赠送',3=>'礼盒开奖',4=>'好友赠送',5=>'首充赠送',6=>'天降好礼获得',7=>'财富等级特权赠送',8=>'新人充值好礼',9=>'爵位购买赠送',10=>'任务奖励',11=>"每日签到"];
|
||||
public function __construct($data = [])
|
||||
{
|
||||
parent::__construct($data);
|
||||
@@ -27,6 +28,7 @@ class Decorate extends Model
|
||||
//获取装扮类型
|
||||
public function get_type_list($have_hot = 0)
|
||||
{
|
||||
$no_show_ids = [7,8,3,10,11];
|
||||
$label = $this->TypeArray;
|
||||
if ($have_hot) {
|
||||
$label = [100 => '热门'] + array_filter($this->TypeArray, fn($key) => $key != 100, ARRAY_FILTER_USE_KEY);
|
||||
@@ -34,6 +36,9 @@ class Decorate extends Model
|
||||
$data = [];
|
||||
$i = 0;
|
||||
foreach ($label as $k => $v) {
|
||||
if (in_array($k, $no_show_ids)) {
|
||||
continue;
|
||||
}
|
||||
$data[$i]['id'] = $k;
|
||||
$data[$i]['name'] = $v;
|
||||
++$i;
|
||||
@@ -71,7 +76,19 @@ class Decorate extends Model
|
||||
'a.type' => $type,
|
||||
];
|
||||
}
|
||||
if($type == 12){
|
||||
$map = [
|
||||
'type' => 12,
|
||||
'delete_time' => 0,
|
||||
'show_status' => 1,
|
||||
'is_buy' => 1
|
||||
];
|
||||
$list = DB::name($this->table)->where($map)->field('did,title,type,base_image,play_image,price')
|
||||
->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();
|
||||
}
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['base_image'] = localpath_to_netpath($v['base_image']);
|
||||
$v['play_image'] = localpath_to_netpath($v['play_image']);
|
||||
@@ -86,6 +103,11 @@ class Decorate extends Model
|
||||
if (!$decorate) {
|
||||
return ['code' => 0, 'msg' => '参数错误'];
|
||||
}
|
||||
if($decorate['type'] == 12){
|
||||
$result['title'] = $decorate['title'];
|
||||
$result['price'] = (int)$decorate['price'];
|
||||
$result['base_image'] = localpath_to_netpath($decorate['base_image']);
|
||||
}else{
|
||||
$decorate_price = DB::name('vs_decorate_price')->where(['did' => $did, 'is_delete' => 1])->order('day asc')->select();
|
||||
if (!$decorate_price) {
|
||||
return ['code' => 0, 'msg' => '参数错误'];
|
||||
@@ -100,6 +122,7 @@ class Decorate extends Model
|
||||
//有效期至
|
||||
$result['price_list'][$k]['end_time'] = date('Y-m-d',strtotime("+".$v['day']." day"));
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $result];
|
||||
}
|
||||
|
||||
@@ -113,7 +136,7 @@ class Decorate extends Model
|
||||
* @param $log_remark 日志备注
|
||||
*
|
||||
*/
|
||||
public function pay_decorate($uid, $did, $day,$from_type=1,$give_uid=0,$log_remark=""){
|
||||
public function pay_decorate($uid, $did, $day=0,$from_type=1,$give_uid=0,$log_remark="",$num=1){
|
||||
if(empty($log_remark)){
|
||||
$log_remark = $this->FromType[$from_type];
|
||||
}
|
||||
@@ -131,6 +154,7 @@ class Decorate extends Model
|
||||
if(!$decorate_info){
|
||||
return ['code' => 0, 'msg' => '该装扮不存在'.$did, 'data' => null];
|
||||
}
|
||||
if($decorate_info['type'] != 12){
|
||||
//该天数是否存在
|
||||
$map = [];
|
||||
$map = [
|
||||
@@ -151,6 +175,12 @@ class Decorate extends Model
|
||||
if($decorate_info['type'] == 8 && $decorate_info['is_user_buy'] == 1){
|
||||
return ['code' => 0, 'msg' => '该公会靓号已被购买', 'data' => null];
|
||||
}
|
||||
}else{
|
||||
$decorate_price_info = [
|
||||
'price' => $decorate_info['price'],
|
||||
'day' => 0
|
||||
];
|
||||
}
|
||||
$start_time = $now_time = time();
|
||||
Db::startTrans();
|
||||
try {
|
||||
@@ -193,21 +223,30 @@ class Decorate extends Model
|
||||
if($decorate_price_info['day'] == 0){//如果礼物购买配置的天数为0,则永久有效
|
||||
$data['is_using'] = 1;
|
||||
$data['end_time'] = 0;
|
||||
$data['is_perpetual'] = 1;
|
||||
}else{
|
||||
$change_time = $day * 24 * 3600;
|
||||
$data['is_using'] = 2;
|
||||
$data['end_time'] = $now_time + $change_time;
|
||||
}
|
||||
$data['createtime'] = $now_time;
|
||||
$data['special_num'] = $decorate_info['special_num'];
|
||||
$data['special_num'] = $decorate_info['special_num'] ?? '';
|
||||
$data['num'] = 1;
|
||||
$result = db::name('vs_user_decorate')->insert($data);
|
||||
}else{
|
||||
if($decorate_info['type'] == 12){
|
||||
$result = db::name('vs_user_decorate')->where('udid', $user_decorate_data['udid'])->update([
|
||||
'is_using' => 2,
|
||||
'num' => $user_decorate_data['num'] + $num,
|
||||
'end_time' => 0
|
||||
]);
|
||||
}else{
|
||||
if($decorate_price_info['day'] > 0){//是不是永久礼物
|
||||
if($decorate_price_info['price']<=0 && $user_decorate_data['end_time'] > $now_time + $change_time){
|
||||
return ['code' => 0, 'msg' => '您已购买过此装扮,请勿重复购买', 'data' => null];
|
||||
}
|
||||
if($user_decorate_data['end_time'] < $now_time){
|
||||
$user_decorate_data['end_time'] = 0;
|
||||
$user_decorate_data['end_time'] = time();
|
||||
}
|
||||
$change_time = $day * 24 * 3600;
|
||||
$update['is_using'] = 2;
|
||||
@@ -216,6 +255,7 @@ class Decorate extends Model
|
||||
$start_time = $update['end_time'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!$result){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||
@@ -258,7 +298,16 @@ class Decorate extends Model
|
||||
|
||||
//用户装扮列表
|
||||
public function user_decorate($uid, $type,$page=1, $limit=10){
|
||||
|
||||
if($type == 12){
|
||||
$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')
|
||||
->where('ud.user_id', $uid)
|
||||
->where('ud.type', $type)
|
||||
->where(['ud.num'=>[">",0]])
|
||||
->page($page, $limit)
|
||||
->select();
|
||||
}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')
|
||||
@@ -275,7 +324,7 @@ class Decorate extends Model
|
||||
//剩余天数 取整
|
||||
$v['remaining_day'] = $v['is_perpetual']==1 ? '永久' :$remaining_day;
|
||||
$v['end_time'] = date('Y-m-d H:i:s', $v['end_time']);
|
||||
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => "获取成功", 'data' => $reslut];
|
||||
}
|
||||
@@ -292,10 +341,15 @@ class Decorate extends Model
|
||||
if (empty($info)) {
|
||||
return ['code' => 0, 'msg' => '装扮不存在', 'data' => null];
|
||||
}
|
||||
if($info['type'] == 12){
|
||||
if ($info['num']-1 < 0) {
|
||||
return ['code' => 0, 'msg' => '无可用装扮', 'data' => null];
|
||||
}
|
||||
}else{
|
||||
if ($info['end_time'] < time()) {
|
||||
return ['code' => 0, 'msg' => '装扮已过期', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
//清理该类型装扮使用状态
|
||||
@@ -320,6 +374,9 @@ class Decorate extends Model
|
||||
$data = [];
|
||||
$data['is_using'] = 1;
|
||||
$data['updatetime'] = time();
|
||||
if($info['type'] == 12){
|
||||
$data['num'] = $info['num'] - 1;
|
||||
}
|
||||
$reslut = Db::name('vs_user_decorate')->where($map)->update($data);
|
||||
if (!$reslut) {
|
||||
Db::rollback();
|
||||
@@ -327,6 +384,32 @@ class Decorate extends Model
|
||||
}
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
if($info['type'] == 12){
|
||||
//使用降身卡,降低用户身价
|
||||
$reduce_ratio = db::name('vs_decorate')->where(['did' => $info['did']])->value('ext_value') ?? 0;
|
||||
$market_value = db::name('user')->where(['id' => $uid])->value('market_value');
|
||||
if($reduce_ratio){
|
||||
$reduce_market_value = $market_value * ($reduce_ratio / 100);
|
||||
}else{
|
||||
$reduce_market_value = 0;
|
||||
}
|
||||
if($reduce_market_value > 0){
|
||||
$up_market_value = $market_value - $reduce_market_value;
|
||||
if($up_market_value < 1){
|
||||
$up_market_value = 1;
|
||||
}
|
||||
db::name('user')->where(['id' => $uid])->update(['market_value' => $up_market_value]);
|
||||
//记录一条日志
|
||||
db::name('vs_user_market_value_log')->insert([
|
||||
'user_id' => $uid,
|
||||
'before' => $market_value,
|
||||
'change_value'=> $reduce_market_value,
|
||||
'afterwards'=> $up_market_value,
|
||||
'type' => 2,
|
||||
'createtime'=> time()
|
||||
]);
|
||||
}
|
||||
}else{
|
||||
//推送信息去所在房间
|
||||
//查询当前所在房间
|
||||
$room_id = db::name('vs_room_visitor')->where(['user_id' => $uid])->order('id' , 'desc')->value('room_id');
|
||||
@@ -336,11 +419,16 @@ class Decorate extends Model
|
||||
$text['jia_jia'] = model('Decorate')->user_decorate_detail($uid,2);
|
||||
$text['FromUserInfo'] = db::name('user')->where('id',$uid)->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$text['FromUserInfo']['dress'] = model('Decorate')->user_decorate_detail($uid,1);
|
||||
$text['FromUserInfo']['mic_dress'] = model('Decorate')->user_decorate_detail($uid,4);
|
||||
$text['FromUserInfo']['mic_cycle'] = model('Decorate')->user_decorate_detail($uid,3);
|
||||
$text['FromUserInfo']['chat_dress'] = model('Decorate')->user_decorate_detail($uid,5);
|
||||
$text['text'] = '用户 ' . $text['FromUserInfo']['nickname'] .' 修改了信息';
|
||||
model('Chat')->sendMsg(1035,$room_id,$text,$uid);
|
||||
}
|
||||
}
|
||||
//更新装备缓存
|
||||
$cache_key = 'user_base_info_'.$uid;
|
||||
Cache::rm($cache_key);
|
||||
|
||||
return ['code' => 1, 'msg' => "设置成功", 'data' => null];
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
@@ -363,7 +451,9 @@ class Decorate extends Model
|
||||
if (!$reslut) {
|
||||
return ['code' => 0, 'msg' => "取消装扮失败", 'data' => null];
|
||||
}
|
||||
|
||||
//更新装备缓存
|
||||
$cache_key = 'user_base_info_'.$uid;
|
||||
Cache::rm($cache_key);
|
||||
return ['code' => 1, 'msg' => "取消成功", 'data' => null];
|
||||
}
|
||||
|
||||
@@ -375,48 +465,67 @@ class Decorate extends Model
|
||||
public function user_decorate_detail($id, $type){
|
||||
//根据$type 组装查询条件
|
||||
$reslut = "";
|
||||
$map = [
|
||||
'type' => $type,
|
||||
'is_using' => 1
|
||||
];
|
||||
if($type == 7){//7房间靓号 8工会靓号
|
||||
$room = db::name('vs_room')->where('id', $id)->field('user_id,room_number')->find();
|
||||
if(empty($room)){
|
||||
return $reslut;
|
||||
}
|
||||
$map = [
|
||||
'user_id' => $room['user_id']??0,
|
||||
'type' => $type,
|
||||
'is_using' => 1
|
||||
];
|
||||
$reslut = db::name('vs_user_decorate')->where($map)->where('end_time',['>=',time()],'or')->value('special_num') ?? $room['room_number'];
|
||||
$map['user_id'] = $room['user_id'];
|
||||
$user_decorate = db::name('vs_user_decorate')->where($map)->order('createtime', 'desc')->find();
|
||||
if(empty($user_decorate)){
|
||||
return $room['room_number'];
|
||||
}
|
||||
if($user_decorate['is_perpetual']==2 && $user_decorate['end_time'] < time()){
|
||||
return $room['room_number'];
|
||||
}
|
||||
$reslut = $user_decorate['special_num'] ?? $room['room_number'];
|
||||
}elseif($type == 8){
|
||||
$guild = db::name('vs_guild')->where('id', $id)->field('user_id,guild_special_id')->find();
|
||||
$map = [
|
||||
'user_id' => $guild['user_id']??0,
|
||||
'type' => $type,
|
||||
'is_using' => 1
|
||||
];
|
||||
$reslut = db::name('vs_user_decorate')->where($map)->where('end_time',['>=',time()],'or')->value('special_num') ?? $guild['guild_special_id'];
|
||||
if(empty($guild)){
|
||||
return $reslut;
|
||||
}
|
||||
$map['user_id'] = $guild['user_id'];
|
||||
$user_decorate = db::name('vs_user_decorate')->where($map)->order('createtime', 'desc')->find();
|
||||
if(empty($user_decorate)){
|
||||
return $guild['guild_special_id'];
|
||||
}
|
||||
if($user_decorate['is_perpetual']==2 && $user_decorate['end_time'] < time()){
|
||||
return $guild['guild_special_id'];
|
||||
}
|
||||
$reslut = $user_decorate['special_num'] ?? $guild['guild_special_id'];
|
||||
}elseif($type == 6){
|
||||
$map = [
|
||||
'user_id' => $id??0,
|
||||
'type' => $type,
|
||||
'is_using' => 1
|
||||
];
|
||||
$user_code = db::name('user')->where('id', $id)->value('user_code');
|
||||
$reslut = db::name('vs_user_decorate')->where($map)->where('end_time',['>=',time()],'or')->value('special_num') ?? $user_code;
|
||||
if(empty($user_code)){
|
||||
return $reslut;
|
||||
}
|
||||
$map['user_id'] = $id;
|
||||
$user_decorate = db::name('vs_user_decorate')->where($map)->order('createtime', 'desc')->find();
|
||||
if(empty($user_decorate)){
|
||||
return $user_code;
|
||||
}
|
||||
if($user_decorate['is_perpetual']==2 && $user_decorate['end_time'] < time()){
|
||||
return $user_code;
|
||||
}
|
||||
$reslut = $user_decorate['special_num'] ?? $user_code;
|
||||
}else{
|
||||
$map = [
|
||||
'user_id' => $id??0,
|
||||
'type' => $type,
|
||||
'is_using' => 1
|
||||
];
|
||||
$did = db::name('vs_user_decorate')->where($map)->where('end_time',['>=',time()],'or')->value('did');
|
||||
if(empty($did)){
|
||||
$reslut = '';//返回数据
|
||||
$map['user_id'] = $id;
|
||||
$user_decorate = db::name('vs_user_decorate')->where($map)->order('createtime', 'desc')->find();
|
||||
if(empty($user_decorate)){
|
||||
return $reslut;
|
||||
}
|
||||
if($user_decorate['is_perpetual']==2 && $user_decorate['end_time'] < time()){
|
||||
return $reslut;
|
||||
}
|
||||
if(in_array($type, [9,12])){
|
||||
$reslut = db::name('vs_decorate')->where('did', $user_decorate['did'])->value('base_image');
|
||||
}else{
|
||||
$reslut = db::name('vs_decorate')->where('did', $did)->value('play_image');
|
||||
$reslut = db::name('vs_decorate')->where('did', $user_decorate['did'])->value('play_image');
|
||||
}
|
||||
}
|
||||
return $reslut;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
179
application/api/model/Family.php
Normal file
179
application/api/model/Family.php
Normal file
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Log;
|
||||
use think\Model;
|
||||
|
||||
class Family extends Model
|
||||
{
|
||||
/*
|
||||
* 创建家族
|
||||
* @param $name string 家族名称
|
||||
* @param $user_id int 用户id
|
||||
*/
|
||||
public function createFamily($user_id)
|
||||
{
|
||||
$name = db::name('user')->where('id', $user_id)->value('nickname').'的家族';
|
||||
$data = [
|
||||
'name' => $name,
|
||||
'user_id' => $user_id,
|
||||
'type' => 1,
|
||||
'createtime' => time(),
|
||||
];
|
||||
//开启事务
|
||||
db::startTrans();
|
||||
$id = db::name('vs_family')->insertGetId($data);
|
||||
if (!$id) {
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '创建失败', 'data' => null];
|
||||
}
|
||||
$reslut = model('api/Tencent')->create_group($user_id,'f'.$id,"Public","",$name);
|
||||
if ($reslut['code'] == 0) {
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '创建失败,请稍后再试!', 'data' => null];
|
||||
}
|
||||
//发送系统消息
|
||||
model('api/Tencent')->send_group_system_notification('f'.$id,"家族创建成功");
|
||||
//查找他是否有签约 用户
|
||||
$sign_user = db::name('vs_user_sign')->where(['parent_user_id' => $user_id, 'end_time' => ['>',time()]])->select();
|
||||
if($sign_user){
|
||||
//拉入群聊
|
||||
foreach ($sign_user as $k => $v){
|
||||
model('api/Tencent')->add_group_member('f'.$id, $v['sign_user_id']);
|
||||
$data[$k] = [
|
||||
'name' => $name,
|
||||
'pid' => $user_id,
|
||||
'user_id' => $v['sign_user_id'],
|
||||
'createtime' => time(),
|
||||
];
|
||||
db::name('vs_family')->insert($data[$k]);
|
||||
}
|
||||
//发送系统消息
|
||||
model('api/Tencent')->send_group_system_notification('f'.$id,"欢迎加入家族");
|
||||
}
|
||||
|
||||
db::commit();
|
||||
return ['code' => 1, 'msg' => '创建成功', 'data' => ['id' => $id]];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 我的家族
|
||||
* @param $user_id int 用户id(创建者id)
|
||||
*/
|
||||
public function myFamily($user_id)
|
||||
{
|
||||
$myFamily['group_owner_info'] = db::name('user')->where('id',$user_id)->field('nickname,avatar')->find();
|
||||
$myFamily['group_owner_info']['dress'] = model('api/Decorate')->user_decorate_detail($user_id,1);
|
||||
$myFamily['group_owner_info']['user_code'] = model('api/Decorate')->user_decorate_detail($user_id,6);
|
||||
$myFamily['group_owner_info']['icon'][0] = model('api/UserData')->user_wealth_icon($user_id);//财富图标
|
||||
$myFamily['group_owner_info']['icon'][1] = model('api/UserData')->user_charm_icon($user_id);//魅力图标
|
||||
//判断是否是歌手 如果是 返回等级图标
|
||||
$isSinger = db::name('vs_singer')->where(['user_id' => $user_id,'status' => 1])->find();
|
||||
if($isSinger){
|
||||
$myFamily['group_owner_info']['icon'][2] = db::name('vs_singer_level')->where(['level' => $isSinger['level'],'deletetime' => 0])
|
||||
->value('image');//等级图标
|
||||
}
|
||||
|
||||
$Nobility = model('api/Nobility')->getUserNobilityInfo($user_id);
|
||||
$myFamily['group_owner_info']['mic_cycle'] = model('api/Decorate')->user_decorate_detail($user_id,3);
|
||||
$myFamily['group_owner_info']['nobility_image'] = $Nobility['play_image'];
|
||||
$myFamily['group_owner_info']['nickname_color'] = $Nobility['nick_name_color'];
|
||||
|
||||
$myFamily['group_members_num'] = db::name('vs_user_sign')->where(['parent_user_id' => $user_id])->count();
|
||||
$myFamily['group_earnings'] = round(db::name('vs_user_sign_earnings')->where('user_id',$user_id)->sum('earnings'),4);
|
||||
|
||||
$myFamilys = db::name('vs_family')->where(['user_id' => $user_id,'type' => 1])->find();
|
||||
|
||||
if($myFamilys){
|
||||
$lists= db::name('vs_family')->alias('a')
|
||||
->join('user b','a.user_id = b.id')
|
||||
->join('vs_user_sign c','a.user_id = c.sign_user_id')
|
||||
->field('b.is_online,b.market_value,b.nickname,b.avatar,b.user_code,c.type,c.end_time,c.sign_user_type,a.user_id,a.createtime')
|
||||
->where(['a.pid' => $myFamilys['user_id'],'a.deletetime' => 0,'a.type' => 0,'c.end_time' => ['>',time()]])
|
||||
->order('c.end_time asc')
|
||||
->select();
|
||||
if($lists){
|
||||
foreach ($lists as $k => $v){
|
||||
$lists[$k]['dress'] = model('api/Decorate')->user_decorate_detail($v['user_id'],1);
|
||||
$lists[$k]['user_code'] = model('api/Decorate')->user_decorate_detail($v['user_id'],6);
|
||||
$lists[$k]['icon'][0] = model('api/UserData')->user_wealth_icon($v['user_id']);//财富图标
|
||||
$lists[$k]['icon'][1] = model('api/UserData')->user_charm_icon($v['user_id']);//魅力图标
|
||||
//判断是否是歌手 如果是 返回等级图标
|
||||
$isSinger = db::name('vs_singer')->where(['user_id' => $v['user_id'],'status' => 1])->find();
|
||||
if($isSinger){
|
||||
$lists[$k]['icon'][2] = db::name('vs_singer_level')->where(['level' => $isSinger['level'],'deletetime' => 0])
|
||||
->value('image');//等级图标
|
||||
}
|
||||
|
||||
$Nobility = model('api/Nobility')->getUserNobilityInfo($v['user_id']);
|
||||
$lists[$k]['mic_cycle'] = model('api/Decorate')->user_decorate_detail($v['user_id'],3);
|
||||
$lists[$k]['nobility_image'] = $Nobility['play_image'];
|
||||
$lists[$k]['nickname_color'] = $Nobility['nick_name_color'];
|
||||
if($v['sign_user_type'] == 0){
|
||||
$lists[$k]['free_renewal'] = max((3 - $v['type']), 0);
|
||||
}else{
|
||||
$lists[$k]['free_renewal'] = 0;
|
||||
}
|
||||
|
||||
// 优化今日收益计算逻辑
|
||||
$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);//今日收益
|
||||
}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);//今日收益
|
||||
}
|
||||
|
||||
// 昨日收益计算逻辑优化
|
||||
$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);
|
||||
}else{
|
||||
$lists[$k]['yesterday_earnings'] = 0;
|
||||
}
|
||||
$lists[$k]['is_show_sign'] = $v['end_time'] - time() < 48*3600 ? 1 : 0;
|
||||
$lists[$k]['sign_times'] = get_system_config_value('sign_times');//非首签签约时长
|
||||
$lists[$k]['free_re_sign_day'] = get_system_config_value('free_re_sign_day');//免费续签时间
|
||||
$lists[$k]['sign_user_ratio'] = get_system_config_value('sign_user_ratio');//签约者身价的百分比
|
||||
//end_time 换算为天数,不足1天,按小时显示
|
||||
$remaining_time = $v['end_time'] - time();
|
||||
if ($remaining_time > 0) {
|
||||
$days = ceil($remaining_time / (24 * 3600));
|
||||
if ($days > 0) {
|
||||
$lists[$k]['end_day'] = $days . '天';
|
||||
} else {
|
||||
$hours = ceil($remaining_time / 3600);
|
||||
$lists[$k]['end_day'] = $hours . '小时';
|
||||
}
|
||||
} else {
|
||||
$lists[$k]['end_day'] = '已过期';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$myFamily['group_members_lists'] = $lists ;
|
||||
$myFamily['group_id'] = 'f'.$myFamilys['id'];
|
||||
$myFamily['name'] = $myFamilys['name'];
|
||||
$myFamily['user_id'] = $myFamilys['user_id'];
|
||||
}else{
|
||||
$myFamily['group_id'] = null;
|
||||
$myFamily['group_members_lists'] = null ;
|
||||
$myFamily['name'] = null;
|
||||
$myFamily['user_id'] = null;
|
||||
}
|
||||
|
||||
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => $myFamily];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -155,7 +155,7 @@ class Friend extends Model
|
||||
public function createRelation($user_id,$room_id,$friend_id,$user1_id,$user2_id,$friending_config_id){
|
||||
|
||||
if (!$user1_id || !$user2_id || !$friend_id || !$room_id) {
|
||||
return ['code' => 0, 'msg' => '参数有误!', 'data' => null];
|
||||
return ['code' => 0, 'msg' => '参数有误!!', 'data' => null];
|
||||
}
|
||||
|
||||
$user1 = min($user1_id, $user2_id);
|
||||
@@ -167,7 +167,18 @@ class Friend extends Model
|
||||
->where(['id'=>$friending_heart['id']])
|
||||
->update(['status' => 3,'friend_config_id' =>$friending_config_id]);
|
||||
$msg = '';
|
||||
if ($originalPairs) {
|
||||
// 修改当前交友阶段
|
||||
$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) {
|
||||
//所有人下麦
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
|
||||
$relation = db::name('vs_relation')->where('id',$friending_config_id)->value('name');
|
||||
if($friending_heart['heart_value'] >= get_system_config_value('friend_heart_create_room') && $friending_config_id > 0){
|
||||
//创建小房间
|
||||
@@ -196,6 +207,7 @@ class Friend extends Model
|
||||
}else{
|
||||
$text['text'] = '交友结束未创建房间';
|
||||
}
|
||||
|
||||
$text['relation_name'] = $relation;
|
||||
$text['user1_id'] = $user1;
|
||||
$text['user2_id'] = $user2;
|
||||
@@ -205,17 +217,6 @@ class Friend extends Model
|
||||
$text['user2_nickname'] = db::name('user')->where(['id'=>$user2])->value('nickname');
|
||||
model('api/Chat')->sendMsg(1051,$room_id,$text);
|
||||
|
||||
// 修改当前交友阶段
|
||||
db::name('vs_room')->where(['id' => $room_id])->update(['step' => 1]);
|
||||
db::name('vs_user_friending')->where(['id' => $friend_id])->update(['status' => 2]);
|
||||
//所有人下麦
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
|
||||
$shijian = floor($friending_heart['heart_value']/get_system_config_value('friend_heart_value')) * get_system_config_value('friend_heart_times');
|
||||
$friendendtime = time() + $shijian * 3600;
|
||||
|
||||
@@ -226,17 +227,43 @@ class Friend extends Model
|
||||
$room_auction = model('RoomAuction')->room_auction_create_or_add($user1_id,$user2_id,$friending_config_id,$shijian*3600,0);
|
||||
|
||||
//推送给前端消息
|
||||
$text1['text'] = '交友结束';
|
||||
$text1['step'] = 1;//1 等待邂逅 2 心动连线 3 牵手良缘
|
||||
model('api/Chat')->sendMsg(1049,$room_id,$text1);
|
||||
//查询是否第一次创建关系
|
||||
$friend_count1 = db::name('vs_user_friending_heart')
|
||||
->where('status', 3)
|
||||
->where(function($query) use ($user1) {
|
||||
$query->where('user1_id', $user1)
|
||||
->whereOr('user2_id', $user1);
|
||||
})
|
||||
->count();
|
||||
if($friend_count1 == 1){
|
||||
//任务:10-第一次星球房卡关系(互娱房)
|
||||
model('Tasks')->tasks_complete($user1,10);
|
||||
}
|
||||
$friend_count2 = db::name('vs_user_friending_heart')
|
||||
->where('status', 3)
|
||||
->where(function($query) use ($user2) {
|
||||
$query->where('user1_id', $user2)
|
||||
->whereOr('user2_id', $user2);
|
||||
})
|
||||
->count();
|
||||
if($friend_count2 == 1){
|
||||
//任务:10-第一次星球房卡关系(互娱房)
|
||||
model('Tasks')->tasks_complete($user2,10);
|
||||
}
|
||||
|
||||
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]);
|
||||
//推送给前端消息
|
||||
$text['status1'] = $ress.'<=>'.$re2s.'<=>'.$res.'<=>'.$res2.'<=>'.$originalPairs;
|
||||
$text['text'] = '交友结束';
|
||||
$text['step'] = 1;//1 等待邂逅 2 心动连线 3 牵手良缘
|
||||
model('api/Chat')->sendMsg(1049,$room_id,$text);
|
||||
|
||||
return ['code' => 1, 'msg' => '创建关系成功!'.$msg, 'data' => null];
|
||||
} else {
|
||||
//推送给前端消息
|
||||
$text['text'] = '交友结束';
|
||||
$text['step'] = 1;//1 等待邂逅 2 心动连线 3 牵手良缘
|
||||
model('api/Chat')->sendMsg(1049,$room_id,$text);
|
||||
db::name('vs_user_friending')->where(['id' => $friend_id])->update(['status' => 2]);
|
||||
return ['code' => 0, 'msg' => '创建关系失败!', 'data' => null];
|
||||
}
|
||||
}
|
||||
@@ -329,7 +356,7 @@ class Friend extends Model
|
||||
}
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => '送礼成功', 'data' => null];
|
||||
return ['code' => 1, 'msg' => '送礼成功', 'data' => $res['data']];
|
||||
}
|
||||
|
||||
//是否主持
|
||||
@@ -681,6 +708,7 @@ class Friend extends Model
|
||||
$data_users[$key_data]['dress'] = model('Decorate')->user_decorate_detail($value_data['user_id'],1);
|
||||
$data_users[$key_data]['charm'] = $charm??0;
|
||||
$data_users[$key_data]['pit_number'] = $value_data['pit_number'];
|
||||
$data_users[$key_data]['is_online'] = db::name('vs_room_visitor')->where(['user_id' => $value_data['user_id'],'room_id' => $room_id])->value('is_online');
|
||||
}
|
||||
//推送给前端消息
|
||||
$text['text'] = '房间换麦位';
|
||||
@@ -738,6 +766,7 @@ class Friend extends Model
|
||||
$data_users[$key_data]['dress'] = model('Decorate')->user_decorate_detail($value_data['user_id'],1);
|
||||
$data_users[$key_data]['charm'] = $charm??0;
|
||||
$data_users[$key_data]['pit_number'] = $value_data['pit_number'];
|
||||
$data_users[$key_data]['is_online'] = db::name('vs_room_visitor')->where(['user_id' => $value_data['user_id'],'room_id' => $room_id])->value('is_online');
|
||||
}
|
||||
//推送给前端消息
|
||||
$text['text'] = '房间换麦位';
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
use think\Cache;
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
use think\Session;
|
||||
@@ -19,6 +20,7 @@ class Gift extends Model
|
||||
//获取礼物类型
|
||||
public function get_gift_label()
|
||||
{
|
||||
$giftType = [];
|
||||
$giftTypeData = db::name('vs_gift_label')->where('delete_time',0)->where('tid',1)->order("sort asc,id desc")->select();
|
||||
foreach ($giftTypeData as $key => $value) {
|
||||
$giftType[$key]['id'] = $value['id'];
|
||||
@@ -27,9 +29,30 @@ class Gift extends Model
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $giftType];
|
||||
}
|
||||
|
||||
//拉去礼物列表
|
||||
public function get_gift_list($label=0,$room_id=0)
|
||||
//拉取礼物列表
|
||||
public function get_gift_list($label = 0,$room_id = 0,$user_id = 0)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
//先从缓存获取
|
||||
if($is_lock){
|
||||
$cache_key = 'gift_list_'.$label.'_'.$is_lock;
|
||||
}else{
|
||||
$cache_key = 'gift_list_'.$label;
|
||||
}
|
||||
$list = json_decode(Cache::get($cache_key), true);
|
||||
|
||||
if($list){
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
|
||||
}
|
||||
|
||||
$map['delete_time'] = 0;
|
||||
$where['is_show'] = 1;
|
||||
if ($label && $label != 99) {
|
||||
@@ -38,12 +61,14 @@ class Gift extends Model
|
||||
if ($label == 99) {
|
||||
$gift_price = get_system_config_value('room_love_auction_cion');
|
||||
$where['gift_price'] = ['>',$gift_price];
|
||||
$where['label'] = ['<>',2];
|
||||
}
|
||||
$is_open_blind_box_turntable = 0;
|
||||
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')->where($map)->where($where)->order('sort asc, gift_price asc')->select();
|
||||
|
||||
$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();
|
||||
if($label==2){
|
||||
$list_data = [];
|
||||
foreach ($list as &$v) {
|
||||
@@ -60,6 +85,15 @@ class Gift extends Model
|
||||
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;
|
||||
}
|
||||
}
|
||||
foreach ($list as $gift) {
|
||||
if($is_open_blind_box_turntable == 1){
|
||||
@@ -75,6 +109,38 @@ class Gift extends Model
|
||||
});
|
||||
$list = $list_data;
|
||||
}
|
||||
|
||||
//获取配置里面的CP礼物
|
||||
$cp_gift_ids = explode(',', get_system_config_value('cp_gift_id'));
|
||||
$teacher_gift_ids = explode(',', get_system_config_value('master_special_gift'));
|
||||
$cp_gift = [];
|
||||
$teacher_gift = [];
|
||||
foreach ($list as $key =>&$v) {
|
||||
$v['is_lock'] = $is_lock;
|
||||
if (in_array($v['gift_id'], $cp_gift_ids)) {
|
||||
$v['is_cp'] = 1;
|
||||
$cp_gift[] = $v;
|
||||
unset($list[$key]);
|
||||
}else{
|
||||
$v['is_cp'] = 0;
|
||||
}
|
||||
if (in_array($v['gift_id'], $teacher_gift_ids)) {
|
||||
$v['is_teacher'] = 1;
|
||||
$teacher_gift[] = $v;
|
||||
unset($list[$key]);
|
||||
}else{
|
||||
$v['is_teacher'] = 0;
|
||||
}
|
||||
}
|
||||
//如果有CP礼物 则放在最前面
|
||||
if ($cp_gift) {
|
||||
array_unshift($list, ...$cp_gift);
|
||||
}
|
||||
if ($teacher_gift) {
|
||||
array_unshift($list, ...$teacher_gift);
|
||||
}
|
||||
//设置缓存
|
||||
Cache::set($cache_key, json_encode($list), 3600);
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use think\Log;
|
||||
use think\Model;
|
||||
use think\Session;
|
||||
use think\Db;
|
||||
use app\common\library\GiftQueue;
|
||||
|
||||
class GiveGift extends Model
|
||||
{
|
||||
@@ -41,8 +42,7 @@ class GiveGift extends Model
|
||||
public function give_gift($uid,$to_uid,$gid,$num,$from_type,$type,$from_id = 0,$pit_number = 0,$change_type = 0,$ext = [])
|
||||
{
|
||||
if(isset($ext['is_draw_gift']) && $ext['is_draw_gift'] == 1) {
|
||||
$return_pan = $this->give_gift_to_pan($uid, $to_uid, $gid, $num, $from_type, $type, $from_id, $pit_number, $change_type, $ext);
|
||||
return $return_pan;
|
||||
return $this->give_gift_to_pan($uid, $to_uid, $gid, $num, $from_type, $type, $from_id, $pit_number, $change_type, $ext);
|
||||
}
|
||||
//送的礼物信息
|
||||
$gift_info = Db::name('vs_gift')->where(['gid'=>$gid])
|
||||
@@ -72,6 +72,7 @@ class GiveGift extends Model
|
||||
$FromUserInfo = db::name('user')->where('id',$uid)->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($uid);//财富图标
|
||||
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($uid);//魅力图标
|
||||
$FromUserInfo['chat_bubble'] = model('Decorate')->user_decorate_detail($uid,9);//聊天气泡
|
||||
|
||||
//送给一人礼物的总价格(扣除用户的数额)
|
||||
$gift_price = $gift_info['gift_price'] * $num;
|
||||
@@ -89,6 +90,7 @@ class GiveGift extends Model
|
||||
//判断是否有足够的金币
|
||||
$user_waller = db::name('user_wallet')->where(['user_id'=>$uid])->find();
|
||||
if ($user_waller['coin'] < $all_gift_price) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '用户金币不足', 'data' => null];
|
||||
}
|
||||
//扣除用户金币并记录日志
|
||||
@@ -108,9 +110,11 @@ class GiveGift extends Model
|
||||
//背包礼物是否充足
|
||||
$user_gift_pack = db::name('vs_user_gift_pack')->where(['user_id'=>$uid,'gid'=>$gid])->find();
|
||||
if (empty($user_gift_pack)) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '用户背包礼物不足', 'data' => null];
|
||||
}
|
||||
if ($user_gift_pack['num'] < $num * count($toarray)) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '用户背包礼物不足', 'data' => null];
|
||||
}
|
||||
//扣除背包礼物并记录日志
|
||||
@@ -134,12 +138,17 @@ class GiveGift extends Model
|
||||
$gift_total = 0;
|
||||
$give_gift = 0;
|
||||
$gift_user_data = [];
|
||||
$cp_type = 0;
|
||||
$textt = '';
|
||||
$textt1 = '';
|
||||
foreach ($toarray as $k => $to_id){
|
||||
$gift_user_data[]['user_id'] = $to_id;
|
||||
$gift_box1 = [];
|
||||
$gift_box = [];
|
||||
//查询礼物是否是盲盒
|
||||
if($gift_info['label'] == 2){//趣味礼物(盲盒)
|
||||
$gift_info_label = Db::name('vs_gift')->where(['gid'=>$gid])
|
||||
->field('label')->find();
|
||||
if($gift_info_label['label'] == 2){//趣味礼物(盲盒)
|
||||
$gift_price_box = 0;
|
||||
if(isset($ext['is_draw_gift']) && $ext['is_draw_gift'] == 1){
|
||||
//收礼记录行为日志
|
||||
@@ -186,10 +195,21 @@ class GiveGift extends Model
|
||||
|
||||
//计算收礼人得益
|
||||
$receiver_earnings = $this -> receiver_earnings($to_id,$gift_price,$from_type);
|
||||
if($receiver_earnings <= 0){
|
||||
if($receiver_earnings < 0){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '收礼人收益配置有误', 'data' => null];
|
||||
}
|
||||
//收礼人认证歌手等级升级
|
||||
model('api/SingerSong')->singerLevelUp($to_id,$gift_price);
|
||||
|
||||
//收礼人身价计算 这里的增长身价是收礼物的价值按比率产生的身价值 身价=收礼产生的身价+签约时的溢价
|
||||
$coin_market_values = explode(',', get_system_config_value('coin_market_value'));
|
||||
$change_value = ceil($gift_price / ($coin_market_values[0] ?? 100) * ($coin_market_values[1] ?? 1));
|
||||
model('api/MarketValue')->change($to_id,$change_value,0);
|
||||
|
||||
//收礼人是否被签约 给上级返佣
|
||||
model('api/Sign')->check_sign_gift($to_id,$gid,$num,$gift_price,$from_id);
|
||||
|
||||
//1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏 5系统任务 6-cp房间送礼
|
||||
if($from_type == 1 || $from_type == 2 || $from_type == 3 ||$from_type == 4 || $from_type == 6){
|
||||
//增加收益并记录日志
|
||||
@@ -292,67 +312,35 @@ class GiveGift extends Model
|
||||
}
|
||||
}
|
||||
}
|
||||
if($gift_info['label'] == 2){
|
||||
if($gift_info_label['label'] == 2){
|
||||
foreach ($gift_box as $gv) {
|
||||
//记录送礼利率和各方收益
|
||||
//收礼人是否加入公会
|
||||
$configs = get_system_config();
|
||||
$is_join_guild = Db::name('vs_guild_user')->where(['user_id' => $to_uid, 'status' => 1, 'quit_time' => 0])->field('guild_id')->find();
|
||||
//收益增加 加入工会的收益
|
||||
if ($is_join_guild) {
|
||||
$ratiog = $configs['room_gift_guild_ratio'];
|
||||
} else {
|
||||
$ratiog = 0;
|
||||
}
|
||||
//未加入工会的收益
|
||||
$ratiogr = $configs['room_gift_ratio'];
|
||||
//收礼人最终的收益比例
|
||||
$ratio = $ratiogr + $ratiog;
|
||||
//房主收益大于0 就代表有收益 且在房间
|
||||
if ($room_owner_earningsg > 0) {
|
||||
$guid_ratio = $configs['room_cp_guild_user_ratio'];
|
||||
} else {
|
||||
$guid_ratio = 0;
|
||||
}
|
||||
//平台收益 = 总金额 - 收礼人收益 - 房主收益 - 工会长收益
|
||||
$app_ratio = 100 - $ratio - $configs['room_author_ratio'] - $guid_ratio;
|
||||
$app_earning = coin_earning($gv['gift_price'], $app_ratio);
|
||||
$receiver_earningss = $this -> receiver_earnings($to_id,$gv['gift_price'],$from_type);
|
||||
$room_owner_earningss = $this -> receiver_earnings($room_owner,$gv['gift_price'],99);//结果是钻石
|
||||
$gift_rate = $this->change_give_gift_profit($gv['give_gift_id'], $ratio, $receiver_earningss, $configs['room_author_ratio'], $room_owner_earningss, $app_ratio, $app_earning);
|
||||
if (!$gift_rate) {
|
||||
$ext_give_data = [
|
||||
'FromUserInfo' => $FromUserInfo,
|
||||
'GiftInfo' => $gift_info,
|
||||
'GiftType' => 2,
|
||||
];
|
||||
$gift_rate = $this->record_gift_profit($to_uid,$room_owner_earningsg,$gv['gift_price'],$gv['give_gift_id'],$receiver_earningss,$room_owner_earningss,$from_id,$ext_give_data);
|
||||
if ($gift_rate['code']==0) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '礼物记录失败', 'data' => null];
|
||||
return ['code' => 0, 'msg' => $gift_rate['msg'], 'data' => null];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//记录送礼利率和各方收益
|
||||
//收礼人是否加入公会
|
||||
$configs = get_system_config();
|
||||
$is_join_guild = Db::name('vs_guild_user')->where(['user_id' => $to_uid, 'status' => 1, 'quit_time' => 0])->field('guild_id')->find();
|
||||
//收益增加 加入工会的收益
|
||||
if ($is_join_guild) {
|
||||
$ratiog = $configs['room_gift_guild_ratio'];
|
||||
} else {
|
||||
$ratiog = 0;
|
||||
}
|
||||
//未加入工会的收益
|
||||
$ratiogr = $configs['room_gift_ratio'];
|
||||
//收礼人最终的收益比例
|
||||
$ratio = $ratiogr + $ratiog;
|
||||
//房主收益大于0 就代表有收益 且在房间
|
||||
if ($room_owner_earningsg > 0) {
|
||||
$guid_ratio = $configs['room_cp_guild_user_ratio'];
|
||||
} else {
|
||||
$guid_ratio = 0;
|
||||
}
|
||||
//平台收益 = 总金额 - 收礼人收益 - 房主收益 - 工会长收益
|
||||
$app_ratio = 100 - $ratio - $configs['room_author_ratio'] - $guid_ratio;
|
||||
$app_earning = coin_earning($gift_price, $app_ratio);
|
||||
$gift_rate = $this->change_give_gift_profit($give_gift, $ratio, $receiver_earnings, $configs['room_author_ratio'], $room_owner_earnings, $app_ratio, $app_earning);
|
||||
if (!$gift_rate) {
|
||||
$ext_give_data = [
|
||||
'FromUserInfo' => $FromUserInfo,
|
||||
'GiftInfo' => $gift_info,
|
||||
'GiftType' => 1,
|
||||
];
|
||||
$gift_rate = $this->record_gift_profit($to_uid,$room_owner_earningsg,$gift_price,$give_gift,$receiver_earnings,$room_owner_earnings,$from_id,$ext_give_data);
|
||||
if ($gift_rate['code']==0) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '礼物记录失败', 'data' => null];
|
||||
return ['code' => 0, 'msg' => $gift_rate['msg'], 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -400,7 +388,7 @@ class GiveGift extends Model
|
||||
}
|
||||
//推送礼物特效
|
||||
if(!isset($ext['is_draw_gift']) || $ext['is_draw_gift'] != 1){// 非盲盒转盘 推送
|
||||
if($gift_info['label'] == 2){
|
||||
if($gift_info_label['label'] == 2){
|
||||
//循环开出来的盲盒,相同的礼物只推送一次,消息推送为$FromUserInfo['nickname'] . ' 送给 ' . $ToUserInfo['nickname'].' 趣味礼物 ' .$gift_inf['gift_name'].' x 多少';
|
||||
if($gift_box){
|
||||
// 统计相同礼物的数量
|
||||
@@ -449,7 +437,7 @@ class GiveGift extends Model
|
||||
'FromUserInfo' => $FromUserInfo,
|
||||
'ToUserInfo' => $ToUserInfo,
|
||||
'GiftInfo' => $gift_inf,
|
||||
'GiftNum' => $count,
|
||||
'gift_num' => $count,
|
||||
'text' => null
|
||||
];
|
||||
|
||||
@@ -503,7 +491,7 @@ class GiveGift extends Model
|
||||
'FromUserInfo' => $FromUserInfo,
|
||||
'ToUserInfo' => $ToUserInfo,
|
||||
'GiftInfo' => $gift_info,
|
||||
'GiftNum' => $num,
|
||||
'gift_num' => $num,
|
||||
'text' => $text
|
||||
];
|
||||
//聊天室推送系统消息
|
||||
@@ -545,6 +533,16 @@ class GiveGift extends Model
|
||||
//直播间送礼物 每日任务
|
||||
model('DailyTasks')->tasks_complete($uid,3);
|
||||
}
|
||||
//cp检测且处理升级事宜
|
||||
$cp_type = model('api/UserCp')->checkGift($uid, $gid, $to_id, $from_id, $num,$gift_price);//0-不处理,1-表明心意,2-组成Cp
|
||||
if($cp_type == 1){
|
||||
$textt1 = "亲爱的用户,您好!\n".$FromUserInfo['nickname'] . ' 的 【' .$gift_info['gift_name'].' 】 已送达,这是他的心动信号。回赠一个,即可锁定这份缘分!';
|
||||
$textt = '';
|
||||
}elseif ($cp_type == 2){
|
||||
//接受方弹起的 信息
|
||||
$textt1 = "恭喜你!". $FromUserInfo['nickname'] ."也向您回赠了【" .$gift_info['gift_name']."】,并接受了你的心动信号。\n从现在起,你们正式成为彼此的专属CP,共同开启一段甜蜜的旅程。\n【心动空间】已为你们敞开大门!这里将记录你们在一起的点滴,见证所有心动与陪伴。快去心动空间,开启你们的CP升级之旅吧!";
|
||||
$textt = '【心动空间】已为你们敞开大门!这里将记录你们在一起的点滴,见证所有心动与陪伴。快去心动空间,开启你们的CP升级之旅吧!';//发送方弹起的信息
|
||||
}
|
||||
}
|
||||
|
||||
//增加房间火热值hot_value
|
||||
@@ -570,7 +568,7 @@ class GiveGift extends Model
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return ['code' => 1, 'msg' => '送礼成功', 'data' => ['gift_total' => $gift_total,'gift_user_data' =>$gift_user_data]];
|
||||
return ['code' => 1, 'msg' => '送礼成功', 'data' => ['gift_total' => $gift_total,'gift_user_data' =>$gift_user_data,'cp_type' => ['cp_type' => $cp_type,'text' => $textt,'text1' => $textt1,'gift_id' => $gid]]];
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -616,6 +614,7 @@ class GiveGift extends Model
|
||||
$FromUserInfo = db::name('user')->where('id',$uid)->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($uid);//财富图标
|
||||
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($uid);//魅力图标
|
||||
$FromUserInfo['chat_bubble'] = model('Decorate')->user_decorate_detail($uid,9);//聊天气泡
|
||||
|
||||
//送给一人礼物的总价格(扣除用户的数额)
|
||||
$gift_price = $gift_info['gift_price'] * $num;
|
||||
@@ -643,9 +642,21 @@ class GiveGift extends Model
|
||||
|
||||
//计算收礼人得益
|
||||
$receiver_earnings = $this -> receiver_earnings($to_id,$gift_price,$from_type);
|
||||
if($receiver_earnings <= 0){
|
||||
if($receiver_earnings < 0){
|
||||
return ['code' => 0, 'msg' => '收礼人收益配置有误', 'data' => null];
|
||||
}
|
||||
|
||||
//收礼人认证歌手等级升级
|
||||
model('api/SingerSong')->singerLevelUp($to_id,$gift_price);
|
||||
|
||||
//收礼人身价计算 这里的增长身价是收礼物的价值按比率产生的身价值 身价=收礼产生的身价+签约时的溢价
|
||||
$coin_market_values = explode(',', get_system_config_value('coin_market_value'));
|
||||
$change_value = ceil($gift_price / ($coin_market_values[0] ?? 100) * ($coin_market_values[1] ?? 1));
|
||||
model('api/MarketValue')->change($to_id,$change_value,0);
|
||||
|
||||
//收礼人是否被签约 给上级返佣
|
||||
model('api/Sign')->check_sign_gift($to_id,$gid,$num,$gift_price,$from_id);
|
||||
|
||||
//1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏 5系统任务 6-cp房间送礼
|
||||
if($from_type == 1 || $from_type == 2 || $from_type == 3 ||$from_type == 4 || $from_type == 6){
|
||||
//增加收益并记录日志
|
||||
@@ -744,62 +755,32 @@ class GiveGift extends Model
|
||||
foreach ($gift_box as $gv) {
|
||||
//记录送礼利率和各方收益
|
||||
//收礼人是否加入公会
|
||||
$configs = get_system_config();
|
||||
$is_join_guild = Db::name('vs_guild_user')->where(['user_id' => $to_uid, 'status' => 1, 'quit_time' => 0])->field('guild_id')->find();
|
||||
//收益增加 加入工会的收益
|
||||
if ($is_join_guild) {
|
||||
$ratiog = $configs['room_gift_guild_ratio'];
|
||||
} else {
|
||||
$ratiog = 0;
|
||||
}
|
||||
//未加入工会的收益
|
||||
$ratiogr = $configs['room_gift_ratio'];
|
||||
//收礼人最终的收益比例
|
||||
$ratio = $ratiogr + $ratiog;
|
||||
//房主收益大于0 就代表有收益 且在房间
|
||||
if ($room_owner_earningsg > 0) {
|
||||
$guid_ratio = $configs['room_cp_guild_user_ratio'];
|
||||
} else {
|
||||
$guid_ratio = 0;
|
||||
}
|
||||
//平台收益 = 总金额 - 收礼人收益 - 房主收益 - 工会长收益
|
||||
$app_ratio = 100 - $ratio - $configs['room_author_ratio'] - $guid_ratio;
|
||||
$app_earning = coin_earning($gv['gift_price'], $app_ratio);
|
||||
$receiver_earningss = $this -> receiver_earnings($to_id,$gv['gift_price'],$from_type);
|
||||
$room_owner_earningss = $this -> receiver_earnings($room_owner,$gv['gift_price'],99);//结果是钻石
|
||||
$gift_rate = $this->change_give_gift_profit($gv['give_gift_id'], $ratio, $receiver_earningss, $configs['room_author_ratio'], $room_owner_earningss, $app_ratio, $app_earning);
|
||||
if (!$gift_rate) {
|
||||
$ext_give_data = [
|
||||
'FromUserInfo' => $FromUserInfo,
|
||||
'GiftInfo' => $gift_info,
|
||||
'GiftType' => 3,
|
||||
];
|
||||
$gift_rate = $this->record_gift_profit($to_uid,$room_owner_earningsg,$gv['gift_price'],$gv['give_gift_id'],$receiver_earningss,$room_owner_earningss,$from_id,$ext_give_data);
|
||||
if ($gift_rate['code']==0) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '礼物记录失败', 'data' => null];
|
||||
return ['code' => 0, 'msg' => $gift_rate['msg'], 'data' => null];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//记录送礼利率和各方收益
|
||||
//收礼人是否加入公会
|
||||
$configs = get_system_config();
|
||||
$is_join_guild = Db::name('vs_guild_user')->where(['user_id' => $to_uid, 'status' => 1, 'quit_time' => 0])->field('guild_id')->find();
|
||||
//收益增加 加入工会的收益
|
||||
if ($is_join_guild) {
|
||||
$ratiog = $configs['room_gift_guild_ratio'];
|
||||
} else {
|
||||
$ratiog = 0;
|
||||
}
|
||||
//未加入工会的收益
|
||||
$ratiogr = $configs['room_gift_ratio'];
|
||||
//收礼人最终的收益比例
|
||||
$ratio = $ratiogr + $ratiog;
|
||||
//房主收益大于0 就代表有收益 且在房间
|
||||
if ($room_owner_earningsg > 0) {
|
||||
$guid_ratio = $configs['room_cp_guild_user_ratio'];
|
||||
} else {
|
||||
$guid_ratio = 0;
|
||||
}
|
||||
//平台收益 = 总金额 - 收礼人收益 - 房主收益 - 工会长收益
|
||||
$app_ratio = 100 - $ratio - $configs['room_author_ratio'] - $guid_ratio;
|
||||
$app_earning = coin_earning($gift_price, $app_ratio);
|
||||
$gift_rate = $this->change_give_gift_profit($give_gift, $ratio, $receiver_earnings, $configs['room_author_ratio'], $room_owner_earnings, $app_ratio, $app_earning);
|
||||
if (!$gift_rate) {
|
||||
return ['code' => 0, 'msg' => '礼物记录失败', 'data' => null];
|
||||
$ext_give_data = [
|
||||
'FromUserInfo' => $FromUserInfo,
|
||||
'GiftInfo' => $gift_info,
|
||||
'GiftType' => 3,
|
||||
];
|
||||
$gift_rate = $this->record_gift_profit($to_uid,$room_owner_earningsg,$gift_price,$give_gift,$receiver_earnings,$room_owner_earnings,$from_id,$ext_give_data
|
||||
);
|
||||
if ($gift_rate['code']==0) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => $gift_rate['msg'], 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -848,6 +829,8 @@ class GiveGift extends Model
|
||||
//直播间送礼物 每日任务
|
||||
model('DailyTasks')->tasks_complete($uid,3);
|
||||
}
|
||||
//cp检测
|
||||
model('api/UserCp')->checkGift($uid, $gid, $to_id, $from_id,$num,$gift_price);
|
||||
}
|
||||
|
||||
//增加房间火热值hot_value
|
||||
@@ -872,7 +855,7 @@ class GiveGift extends Model
|
||||
}
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => '送礼成功', 'data' => ['gift_total' => $gift_total,'gift_user_data' =>$gift_user_data]];
|
||||
return ['code' => 1, 'msg' => '送礼成功', 'data' => ['gift_total' => $gift_total,'gift_user_data' =>$gift_user_data,'cp_type' => ['cp_type' => 0,'text' => '','text1' => '','gift_id' => $gid]]];
|
||||
}
|
||||
|
||||
//送礼特效
|
||||
@@ -887,7 +870,7 @@ class GiveGift extends Model
|
||||
'FromUserInfo' => $FromUserInfo,
|
||||
'ToUserInfo' => $ToUserInfo,
|
||||
'GiftInfo' => $gift_info,
|
||||
'GiftNum' => $num,
|
||||
'gift_num' => $num,
|
||||
'text' => $text
|
||||
];
|
||||
//聊天室推送系统消息
|
||||
@@ -904,15 +887,13 @@ class GiveGift extends Model
|
||||
$ratio = $configs['gift_chat_earning'];
|
||||
}elseif ($from_type == 2 || $from_type == 3){
|
||||
//收礼人是否加入公会
|
||||
$is_join_guild = Db::name('vs_guild_user')->where(['user_id'=>$to_uid,'status'=>1,'quit_time' => 0])->field('guild_id')->find();
|
||||
$is_join_guild = Db::name('vs_guild_user')->where(['user_id'=>$to_uid,'status'=>1,'quit_time' => 0])->field('guild_id,settlement_ratio')->find();
|
||||
//收益增加 加入工会的收益
|
||||
if($is_join_guild){
|
||||
$ratiog = $configs['room_gift_guild_ratio'];
|
||||
$ratio = $is_join_guild['settlement_ratio'];
|
||||
}else{
|
||||
$ratiog = 0;
|
||||
$ratio = $configs['room_gift_ratio'];
|
||||
}
|
||||
$ratiogr = $configs['room_gift_ratio'];
|
||||
$ratio = $ratiogr +$ratiog;
|
||||
}elseif ($from_type == 4){
|
||||
$ratio = $configs['gift_zone_earnings'];
|
||||
}elseif ($from_type == 99){
|
||||
@@ -928,6 +909,8 @@ class GiveGift extends Model
|
||||
$ratio = $configs['room_cp_room_user_ratio'];
|
||||
}elseif ($from_type == 698){
|
||||
$ratio = $configs['room_cp_guild_user_ratio'];
|
||||
}else{
|
||||
$ratio = 0;
|
||||
}
|
||||
|
||||
//计算收礼人收益
|
||||
@@ -941,7 +924,8 @@ class GiveGift extends Model
|
||||
// 1.系统调节 2.充值 3.提现 4.金币转增(送出) 5.每日任务奖励 6.充值返利 7.购买装扮
|
||||
// 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换
|
||||
// 15.首充 16.天降好礼充值 17.退出工会扣款 18.房主收益 19.主持人收益 20.抢头条 21.公会长收益,22.提现驳回或提现失败返还,23.财富等级奖励金币领取,24.删除关系扣金币,
|
||||
if(in_array($change_type,[1,2,3,4,5,6,7,8,12,13,14,15,16,17,20])){
|
||||
//50-签约,51-签约失败退回,52-首次被签约收入,54-叛徒补偿,55-徒弟收礼返佣,56-续约,57-签到,58-爆币
|
||||
if(in_array($change_type,[1,2,3,4,5,6,7,8,12,13,14,15,16,17,20,57])){
|
||||
$room_ids = 0;
|
||||
}else{
|
||||
$room_ids = $room_id;
|
||||
@@ -965,39 +949,39 @@ class GiveGift extends Model
|
||||
//根据类型判断是操作金币还是钻石得增加或减少
|
||||
if($money_type == 1){//1金币
|
||||
//增加用户金币类型
|
||||
$in_types = [2,5,6,8,13,14,15,16];
|
||||
$in_types = [2,5,6,8,13,14,15,16,51,58];
|
||||
//减少用户金币类型
|
||||
$out_types = [4,7,10,17,20];
|
||||
$out_types = [4,7,10,17,20,50,56];
|
||||
if(in_array($change_type,$in_types)){
|
||||
//增加用户金币
|
||||
$res1 = Db::name('user_wallet')->where(['user_id'=>$user_id])->setInc('coin',$money);
|
||||
if(!$res1){
|
||||
return false;
|
||||
}
|
||||
// if(!$res1){
|
||||
// return false;
|
||||
// }
|
||||
}elseif(in_array($change_type,$out_types)){
|
||||
//减少用户金币
|
||||
$res1 = Db::name('user_wallet')->where(['user_id'=>$user_id,'coin'=>['>=',$money]])->setDec('coin',$money);
|
||||
if(!$res1){
|
||||
return false;
|
||||
}
|
||||
// if(!$res1){
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
}elseif ($money_type == 2){//2钻石
|
||||
//增加用户钻石类型
|
||||
$in_types = [9,11,12,18,19,21];
|
||||
$in_types = [9,11,12,18,19,21,52,54,55];
|
||||
//减少用户钻石类型
|
||||
$out_types = [3,14];
|
||||
if(in_array($change_type,$in_types)){
|
||||
//增加用户
|
||||
$res1 = Db::name('user_wallet')->where(['user_id'=>$user_id])->setInc('earnings',$money);
|
||||
if(!$res1){
|
||||
return false;
|
||||
}
|
||||
// if(!$res1){
|
||||
// return false;
|
||||
// }
|
||||
}elseif(in_array($change_type,$out_types)){
|
||||
//减少用户
|
||||
$res1 = Db::name('user_wallet')->where(['user_id'=>$user_id])->setDec('earnings',$money);
|
||||
if(!$res1){
|
||||
return false;
|
||||
}
|
||||
// if(!$res1){
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -1020,11 +1004,85 @@ class GiveGift extends Model
|
||||
'type' => $type,//1金币购买 2送背包礼物
|
||||
'createtime' => time(),
|
||||
];
|
||||
$res = Db::name('vs_give_gift')->insertGetId($data);
|
||||
if(!$res){
|
||||
return false;
|
||||
|
||||
GiftQueue::push($data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//送礼回调处理任务
|
||||
public function change_user_give_gift_log_callback($give_gift_id,$data)
|
||||
{
|
||||
$from_id = $data['from_id'];
|
||||
$uid = $data['user_id'];
|
||||
$to_id = $data['gift_user'];
|
||||
$gift_price = $data['total_price'];
|
||||
$gid = $data['gift_id'];
|
||||
//记录公会流水
|
||||
if($from_id > 0){
|
||||
model('api/Guild')->guild_flow($from_id,$gift_price,$give_gift_id);
|
||||
}
|
||||
//查询是否第一次送礼
|
||||
$is_first_gift = db::name('vs_give_gift')->where(['user_id'=>$uid])->count();
|
||||
if($is_first_gift == 1){
|
||||
//任务:7-第一次送礼
|
||||
model('api/Tasks')->tasks_complete($uid,7);
|
||||
}
|
||||
//查询是否第一次收礼
|
||||
$is_first_receive_gift = db::name('vs_give_gift')->where(['gift_user'=>$to_id])->count();
|
||||
if($is_first_receive_gift == 1){
|
||||
//任务:8-第一次收礼
|
||||
model('api/Tasks')->tasks_complete($to_id,8);
|
||||
}
|
||||
|
||||
//查询收礼人和送礼人的师徒关系
|
||||
//获取系统配置的特殊礼物
|
||||
$special_gift = explode(',',get_system_config_value('master_special_gift'));
|
||||
//收礼人是否是送礼人的师父
|
||||
$is_master = db::name('vs_user_sign')->where(['parent_user_id'=>$to_id,'sign_user_id'=>$uid,'end_time' => ['>=',time()]])->find();
|
||||
if($is_master){
|
||||
if(in_array($gid,$special_gift)){
|
||||
//任务:14-每日给师傅送一个特定的礼物
|
||||
model('api/Tasks')->tasks_complete($uid,14);
|
||||
//查询今天是否送过礼物了
|
||||
$is_today_gift = db::name('vs_give_gift')
|
||||
->where(['user_id'=>$uid,'gift_user'=>$to_id,'createtime' => ['>=',strtotime(date('Y-m-d'))],'gift_id' => ['in',$special_gift]])->count();
|
||||
if($is_today_gift <= 1){
|
||||
//任务:13-每日收到至少3个徒弟的特殊徐礼物
|
||||
model('api/Tasks')->tasks_complete($to_id,13);
|
||||
}
|
||||
}
|
||||
}
|
||||
//收礼人是否是送礼人的徒弟
|
||||
$is_student = db::name('vs_user_sign')->where(['parent_user_id'=>$uid,'sign_user_id'=>$to_id,'end_time' => ['>=',time()]])->find();
|
||||
if($is_student){
|
||||
if(in_array($gid,$special_gift)){
|
||||
//查询今天是否送过礼物了
|
||||
$is_today_gift = db::name('vs_give_gift')
|
||||
->where(['user_id'=>$uid,'gift_user'=>$to_id,'createtime' => ['>=',strtotime(date('Y-m-d'))],'gift_id' => ['in',$special_gift]])->count();
|
||||
// if($is_today_gift <= 2){
|
||||
//查询徒弟是否是首签的徒弟 sign_user_type:被签用户的类型:0-首次被签,1-签约过期,2-违约签
|
||||
$is_students = db::name('vs_user_sign')
|
||||
->where(['parent_user_id' => $uid,'sign_user_id' => $to_id,'sign_user_type' => 0,'end_time' => ['>',time()]])->value('id');
|
||||
if($is_students){
|
||||
//获取房间的类型
|
||||
$room_type = db::name('vs_room')->where(['id' => $from_id])->value('type_id');
|
||||
if($room_type == 2){
|
||||
//任务:21-邀请徒弟在拍卖房停留(0/5)分钟,并送给徒弟(0/1 ,特殊礼物)
|
||||
model('api/Tasks')->tasks_complete($uid,21,2,$to_id);
|
||||
}
|
||||
if($room_type == 9){
|
||||
//任务:22-邀请徒弟在点唱房点歌(0/1)首,并送给徒弟(0/1 ,特殊礼物)
|
||||
model('api/Tasks')->tasks_complete($uid,22,2,$to_id);
|
||||
}
|
||||
if($room_type == 7) {
|
||||
//任务:23-邀请徒弟在交友房停留(0/5)分钟,并送给徒弟(0/1 ,特殊礼物)
|
||||
model('api/Tasks')->tasks_complete($uid, 23, 2,$to_id);
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
@@ -1065,7 +1123,7 @@ class GiveGift extends Model
|
||||
`app_earning` decimal(10,0) DEFAULT '0' COMMENT '平台收益',
|
||||
*/
|
||||
|
||||
public function change_give_gift_profit($give_gift_id,$gift_user_ratio,$gift_user_earning,$room_owner_ratio = 0,$room_owner_earning = 0,$app_ratio = 0,$app_earning = 0)
|
||||
public function change_give_gift_profit($give_gift_id,$gift_user_ratio,$gift_user_earning,$room_owner_ratio = 0,$room_owner_earning = 0,$app_ratio = 0,$app_earning = 0,$guid_ratio=0,$guild_earning=0)
|
||||
{
|
||||
$data = [
|
||||
'give_gift_id' => $give_gift_id,
|
||||
@@ -1075,6 +1133,8 @@ class GiveGift extends Model
|
||||
'room_owner_earning' => $room_owner_earning,
|
||||
'app_ratio' => $app_ratio,
|
||||
'app_earning' => $app_earning,
|
||||
'guid_ratio' => $guid_ratio,
|
||||
'guid_ratio_earning' => $guild_earning,
|
||||
'createtime' => time(),
|
||||
];
|
||||
$res = Db::name('vs_give_gift_ratio_log')->insert($data);
|
||||
@@ -1257,7 +1317,8 @@ class GiveGift extends Model
|
||||
'user_id'=>$uid,
|
||||
'total_price'=>$total_gift_price,
|
||||
'type'=>$is_pack,
|
||||
'from'=>4//1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏'
|
||||
'from'=>4,//1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏'
|
||||
'createtime'=>time(),
|
||||
];
|
||||
$give_gift_res = Db::name('vs_give_gift')->insertGetId($give_gift_data);
|
||||
if(!$give_gift_res){
|
||||
@@ -1469,4 +1530,53 @@ class GiveGift extends Model
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => $result_data];
|
||||
}
|
||||
|
||||
//记录收礼各方收益
|
||||
public function record_gift_profit($to_uid,$room_owner_earningsg,$gift_price,$give_gift,$receiver_earnings,$room_owner_earnings,$room_id,$ext_give_data){
|
||||
//记录送礼利率和各方收益
|
||||
//收礼人是否加入公会
|
||||
$configs = get_system_config();
|
||||
$is_join_guild = Db::name('vs_guild_user')->where(['user_id' => $to_uid, 'status' => 1, 'quit_time' => 0])->field('guild_id,settlement_ratio')->find();
|
||||
//收益增加 加入工会的收益
|
||||
if ($is_join_guild) {//加入工会的收益
|
||||
$max_settlement_ratio = $configs['room_gift_ratio'] + $configs['room_gift_guild_ratio'];
|
||||
$ratio = $is_join_guild['settlement_ratio'] ?? 0;
|
||||
$guid_ratio = $max_settlement_ratio - $ratio;
|
||||
} else {//未加入工会的收益
|
||||
$ratio = $configs['room_gift_ratio'];
|
||||
$guid_ratio = 0;
|
||||
}
|
||||
//房主收益大于0 就代表有收益 且在房间
|
||||
$guild_earning = 0;
|
||||
if ($room_owner_earningsg > 0) {
|
||||
$guid_ratio = $configs['room_cp_guild_user_ratio'];
|
||||
$guild_earning = coin_earning($gift_price,$guid_ratio);
|
||||
}else{
|
||||
if($guid_ratio > 0){
|
||||
//增加收益并记录日志
|
||||
$guild = db::name('vs_guild')->where(['id' => $is_join_guild['guild_id']])->find();
|
||||
$guild_earning = coin_earning($gift_price,$guid_ratio);
|
||||
$to_uid_nickname = db::name('user')->where(['id' => $to_uid])->value('nickname');
|
||||
$room_name = db::name('vs_room')->where(['id' => $room_id])->value('room_name');
|
||||
$gift_type_str = '普通礼物';
|
||||
if($ext_give_data['GiftType'] ==2){
|
||||
$gift_type_str = '盲盒礼物';
|
||||
}elseif($ext_give_data['GiftType'] ==3){
|
||||
$gift_type_str = '盲盒转盘礼物';
|
||||
}
|
||||
$remarks = $ext_give_data['FromUserInfo']['nickname'].'在'.$room_name.'房间送给'.$to_uid_nickname.$gift_type_str.' 价值'.$gift_price.'金币,收礼人收益'.$receiver_earnings.'钻石,工会长收益'.$guild_earning.'钻石';
|
||||
$this->change_user_cion_or_earnings_log($guild['user_id'],$guild_earning,$room_id,2,21,$remarks);
|
||||
}
|
||||
}
|
||||
|
||||
//平台收益 = 总金额 - 收礼人收益 - 房主收益 - 工会长收益
|
||||
$app_ratio = 100 - $ratio - $configs['room_author_ratio'] - $guid_ratio;
|
||||
$app_earning = coin_earning($gift_price, $app_ratio);
|
||||
$gift_rate = $this->change_give_gift_profit($give_gift, $ratio, $receiver_earnings, $configs['room_author_ratio'], $room_owner_earnings, $app_ratio, $app_earning,$guid_ratio,$guild_earning);
|
||||
if (!$gift_rate) {
|
||||
return ['code' => 0, 'msg' => '礼物记录失败', 'data' => null];
|
||||
}else {
|
||||
return ['code' => 1, 'msg' => '礼物记录成功', 'data' => $gift_rate];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,8 +20,11 @@ class Guild extends Model
|
||||
public function get_guild_list($page,$page_limit,$search='',$user_id=0)
|
||||
{
|
||||
$where =[];
|
||||
if ($search) {
|
||||
//判断是不是数字
|
||||
if (is_numeric($search)) {
|
||||
$where = ['guild_special_id'=>['like',$search.'%']]; //通过工会ID搜索
|
||||
}else{
|
||||
$where = ['guild_name'=>['like',$search.'%']];
|
||||
}
|
||||
$list = [];
|
||||
$list = Db::name('vs_guild')
|
||||
@@ -29,6 +32,7 @@ class Guild extends Model
|
||||
->where(['is_show'=>1,'delete_time'=>0])
|
||||
->where($where)
|
||||
->page($page, $page_limit)
|
||||
->order('num desc')
|
||||
->select();
|
||||
$count = Db::name('vs_guild')
|
||||
->where(['is_show'=>1,'delete_time'=>0])
|
||||
@@ -111,7 +115,7 @@ class Guild extends Model
|
||||
/*
|
||||
* 加入工会申请
|
||||
*/
|
||||
public function join_guild($guild_id,$user_id=0)
|
||||
public function join_guild_apply($guild_id,$user_id=0)
|
||||
{
|
||||
$user_info = model('User')->get_user_info($user_id);
|
||||
if(!$user_info){
|
||||
@@ -125,16 +129,20 @@ class Guild extends Model
|
||||
if(!$guild_info){
|
||||
return ['code' => 0, 'msg' => '该公会不存在', 'data' => null];
|
||||
}
|
||||
$is_check_join = Db::name('vs_guild_user')->where(['user_id'=>$user_id,'delete_time'=>0])->find();
|
||||
if($is_check_join && $is_check_join['guild_id']!=$guild_id){
|
||||
return ['code'=>0,'msg'=>'您已加入别的工会,请先退出公会再加入', 'data' => null];
|
||||
}
|
||||
$is_check_join = Db::name('vs_guild_user')->where(['user_id'=>$user_id,'delete_time'=>0])->order('id desc')->find();
|
||||
if($is_check_join && $is_check_join['guild_id']==$guild_id && $is_check_join['status']==1){
|
||||
return ['code'=>0,'msg'=>'您已加入该工会', 'data' => null];
|
||||
}
|
||||
if($is_check_join && $is_check_join['guild_id']==$guild_id && $is_check_join['status']==2){
|
||||
return ['code'=>0,'msg'=>'您已提交申请,请耐心等待', 'data' => null];
|
||||
}
|
||||
if($is_check_join && $is_check_join['guild_id']!=$guild_id && $is_check_join['status']==1){
|
||||
return ['code'=>0,'msg'=>'您已加入别的工会,请先退出公会再加入', 'data' => null];
|
||||
}
|
||||
if($is_check_join && $is_check_join['guild_id']!=$guild_id && $is_check_join['status']==2){
|
||||
$other_guild_name = Db::name('vs_guild')->where(['id'=>$is_check_join['guild_id']])->value('guild_name');
|
||||
return ['code'=>0,'msg'=>'您已申请加入工会'.$other_guild_name.',请等待会长审核', 'data' => null];
|
||||
}
|
||||
//是否被踢出过
|
||||
$ti_chu = db::name('vs_guild_user')->where(['user_id'=>$user_id,'guild_id'=>$guild_id,'delete_time'=>['<>',0],'quit_type'=>2])->find();
|
||||
if(!empty($ti_chu)){
|
||||
@@ -166,17 +174,17 @@ class Guild extends Model
|
||||
$insert_data['user_id'] = $user_id;
|
||||
$insert_data['guild_id'] = $guild_id;
|
||||
$insert_data['room_id'] = $rid;
|
||||
$insert_data['status'] = 1;
|
||||
$insert_data['status'] = 2;
|
||||
$insert_data['is_deacon'] = 2;
|
||||
$insert_data['createtime'] = time();
|
||||
$update_data['apply_time'] = time();
|
||||
// $update_data['apply_time'] = time();
|
||||
$insert_data['is_show_room'] = 1;
|
||||
$reslut = db::name('vs_guild_user')->insert($insert_data);
|
||||
if($reslut){
|
||||
//增加公会人数
|
||||
db::name('vs_guild')->where('id', $guild_info['id'])->setInc('num', 1);
|
||||
//拉用户进入工会群聊
|
||||
model('Tencent')->add_group_member('g'.$guild_id, $user_id);
|
||||
// model('Tencent')->add_group_member('g'.$guild_id, $user_id);
|
||||
// model('Tencent')->send_group_system_notification('g'.$guild_id,"欢迎".$user_info['nickname'].'加入公会');
|
||||
|
||||
return ['code' => 1, 'msg' => '提交成功', 'data' => null];
|
||||
@@ -207,7 +215,7 @@ class Guild extends Model
|
||||
'a.guild_id' => $guild_id,
|
||||
'a.status' => 2
|
||||
];
|
||||
$count = db::name('vs_guild_user')-alias('a')->join('user b', 'a.user_id = b.id')->where($map)->count();
|
||||
$count = db::name('vs_guild_user')->alias('a')->join('user b', 'a.user_id = b.id')->where($map)->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, a.room_id, a.status, b.nickname, b.avatar,b.user_code')
|
||||
->where($map)
|
||||
@@ -230,11 +238,13 @@ class Guild extends Model
|
||||
/*
|
||||
* 同意,拒绝申请
|
||||
*/
|
||||
public function operate_guild($uid, $apply_id, $type){
|
||||
public function operate_guild($apply_id, $type,$uid=0,$remarks=""){
|
||||
if($uid != 0){
|
||||
$user_info = db::name('user')->find($uid);
|
||||
if(!$user_info){
|
||||
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||
}
|
||||
}
|
||||
//该申请是否已被操作
|
||||
$is_operate = db::name('vs_guild_user')->where(['id'=>$apply_id,'status'=>2])->find();
|
||||
if(!$is_operate){
|
||||
@@ -244,7 +254,7 @@ class Guild extends Model
|
||||
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||
}
|
||||
$guild_info = db::name('vs_guild')->where('id', $is_operate['guild_id'])->find();
|
||||
if($uid != $guild_info['user_id']){
|
||||
if($uid!=0 && $uid != $guild_info['user_id']){
|
||||
return ['code' => 0, 'msg' => '您没有权限操作', 'data' => null];
|
||||
}
|
||||
//审核通过
|
||||
@@ -262,20 +272,39 @@ class Guild extends Model
|
||||
$update_data['updatetime'] = time();
|
||||
$update_data['is_show_room'] = 1;
|
||||
$update_data['apply_time'] = time();
|
||||
$update_data['remarks'] = $remarks;
|
||||
//结算比例
|
||||
$configs = get_system_config();
|
||||
//未加入工会的收益
|
||||
$ratiogr = $configs['room_gift_ratio'];
|
||||
//收益增加 加入工会的收益
|
||||
$ratiog = $configs['room_gift_guild_ratio'];
|
||||
//收礼人最终的收益比例
|
||||
$ratio = $ratiogr + $ratiog;
|
||||
$update_data['settlement_ratio'] = $ratio;
|
||||
$reslut = db::name('vs_guild_user')->where(['id'=>$apply_id])->update($update_data);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||
}
|
||||
|
||||
//增加公会人数
|
||||
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.'加入公会');
|
||||
//发系统信息
|
||||
$content = "恭喜加入{$guild_info['guild_name']}工会,您的个人收益增加{$ratiog}%,目前总收益{$ratio}%";
|
||||
model('api/UserMessage')->send_system_message($is_operate['user_id'], "加入公会成功通知", $content, 1);
|
||||
//处理新手任务
|
||||
model('api/Tasks')->tasks_complete($is_operate['user_id'],11);
|
||||
}else if($type == 2){//拒绝
|
||||
$update_data = [];
|
||||
$update_data['status'] = 3;
|
||||
$update_data['updatetime'] = time();
|
||||
$update_data['apply_time'] = time();
|
||||
$reslut = db::name('user_guild')->where(['id'=>$apply_id])->update($update_data);
|
||||
$update_data['remarks'] = $remarks;
|
||||
$reslut = db::name('vs_guild_user')->where(['id'=>$apply_id])->update($update_data);
|
||||
if(!$reslut){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||
@@ -384,6 +413,20 @@ class Guild extends Model
|
||||
Db::rollback();
|
||||
return ['code' => 0, '' => '退出失败', 'data' => null];
|
||||
}
|
||||
//加入审核表
|
||||
$insert_data = [];
|
||||
$insert_data['guid'] = $user_guild_info['id'];
|
||||
$insert_data['user_id'] = $uid;
|
||||
$insert_data['guild_id'] = $guild_id;
|
||||
$insert_data['status'] = 1;
|
||||
$insert_data['type'] = 2;
|
||||
$insert_data['createtime'] = time();
|
||||
$insert_data['updatetime'] = time();
|
||||
$res = db::name('vs_guild_user_quit_log')->insert($insert_data);
|
||||
if(!$res){
|
||||
Db::rollback();
|
||||
return ['code' => 0, '' => '退出失败', 'data' => null];
|
||||
}
|
||||
//减少公会人数
|
||||
db::name('vs_guild')->where('id', $guild_info['id'])->setDec('num');
|
||||
model('Tencent')->delete_group_member('g'.$guild_id, $uid);
|
||||
@@ -400,6 +443,7 @@ class Guild extends Model
|
||||
$insert_data['user_id'] = $uid;
|
||||
$insert_data['guild_id'] = $guild_id;
|
||||
$insert_data['status'] = 0;
|
||||
$insert_data['type'] = 1;
|
||||
$insert_data['createtime'] = time();
|
||||
$insert_data['updatetime'] = time();
|
||||
$res = db::name('vs_guild_user_quit_log')->insert($insert_data);
|
||||
@@ -509,7 +553,7 @@ class Guild extends Model
|
||||
}catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '解散失败', 'data' => null];
|
||||
return ['code' => 0, 'msg' => '审核失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -757,7 +801,7 @@ class Guild extends Model
|
||||
* 工会流水查询
|
||||
* @return array
|
||||
*/
|
||||
public function get_guild_transaction($guild_id,$start_time=0,$end_time=0,$page=1,$page_limit=20){
|
||||
public function get_guild_transaction($guild_id,$seach_start_time,$seach_end_time,$page,$page_limit){
|
||||
$guild_info = db::name('vs_guild')->where(['id'=>$guild_id,'delete_time'=>0])->find();
|
||||
if(empty($guild_info)){
|
||||
return ['code' => 0, 'msg' => '公会不存在!', 'data' => null];
|
||||
@@ -766,6 +810,8 @@ class Guild extends Model
|
||||
$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();
|
||||
@@ -787,7 +833,7 @@ class Guild extends Model
|
||||
}
|
||||
//查询工会所有房间流水
|
||||
$list = db::name('vs_guild_user')->where(['guild_id'=>$guild_id,'delete_time'=>0,'status'=>1,'room_id'=>['<>',0]])
|
||||
->order('coin desc')
|
||||
->order('id asc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
|
||||
@@ -795,6 +841,8 @@ 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();
|
||||
@@ -840,18 +888,27 @@ class Guild extends Model
|
||||
* @return array
|
||||
*/
|
||||
public function user_is_join($user_id){
|
||||
$guild_id = Db::name('vs_guild_user')->where(['user_id'=>$user_id,'status'=>1,'delete_time'=>0])->value('guild_id');
|
||||
if(empty($guild_id)){
|
||||
$guild = Db::name('vs_guild_user')->where(['user_id'=>$user_id,'delete_time'=>0])->find();
|
||||
if(empty($guild)){
|
||||
return 0;
|
||||
}else{
|
||||
return $guild_id;
|
||||
$guild_data['guild_id'] = $guild['guild_id'];
|
||||
$guild_data['status'] = $guild['status'];
|
||||
//1已通过 2已提交 3已拒绝
|
||||
$guild_data['status_str'] = $guild['status'] == 1 ? '已通过' : ($guild['status'] == 2 ? '已提交' : '已拒绝');
|
||||
$guild_data['is_deacon'] = $guild['is_deacon'];
|
||||
return $guild_data;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取公会成员列表
|
||||
*/
|
||||
public function get_guild_user_list($guild_id,$user_id,$page=1,$page_limit=30){
|
||||
public function get_guild_user_list($guild_ids,$user_id,$page=1,$page_limit=30){
|
||||
//获取$guild_id的第一个字母
|
||||
$guild_id_first_letter = substr($guild_ids, 0, 1);
|
||||
$guild_id = substr($guild_ids, 1);
|
||||
if($guild_id_first_letter == 'g'){
|
||||
$count = Db::name('vs_guild_user')
|
||||
->alias('a')
|
||||
->join('user b','a.user_id = b.id')
|
||||
@@ -865,12 +922,28 @@ class Guild extends Model
|
||||
->order('a.id asc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
}else{
|
||||
$myFamilyPid = db::name('vs_family')->where(['id' => $guild_id])->value('user_id');
|
||||
$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(['a.pid' => $myFamilyPid,'a.deletetime' => 0,'a.type' => 0])
|
||||
->order('a.id asc')
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
|
||||
$count = db::name('vs_family')->alias('a')
|
||||
->join('user b','a.user_id = b.id')
|
||||
->where(['a.pid' => $myFamilyPid,'a.deletetime' => 0,'a.type' => 0])
|
||||
->count();
|
||||
}
|
||||
if($list){
|
||||
$member_array = array_column($list, 'user_id');
|
||||
$member_array_str = [];
|
||||
foreach ($member_array as $k=> $v){
|
||||
$member_array_str[] = 'u' . $v;
|
||||
}
|
||||
$group_member_info = model('Tencent')->get_group_member_info('g' .$guild_id,$member_array_str);
|
||||
$group_member_info = model('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']);
|
||||
}
|
||||
@@ -905,35 +978,48 @@ class Guild extends Model
|
||||
->find();
|
||||
$list[$key]['in_room_id'] = $in_room['room_id'] ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
$return_data =[
|
||||
'page' => $page,
|
||||
'limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'list' => $list,
|
||||
];
|
||||
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $return_data];
|
||||
|
||||
}
|
||||
/*
|
||||
* 群聊详情
|
||||
*/
|
||||
public function guild_info($guild_id,$user_id=0){
|
||||
if(!$guild_id){
|
||||
public function guild_info($guild_ids,$user_id=0){
|
||||
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'){
|
||||
$guild_info = db::name('vs_guild')->where(['id'=>$guild_id,'status'=>1,'delete_time'=>0])->find();
|
||||
$group_member_info = model('Tencent')->get_group_info('g'.$guild_id);
|
||||
$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);
|
||||
if($group_member_info['code']!=1){
|
||||
return ['code' => 0, 'msg' => '群聊不存在',null];
|
||||
}
|
||||
$user_list = $this->get_guild_user_list($guild_id,0,1,10);
|
||||
$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;
|
||||
}
|
||||
$return_data =[
|
||||
'guild_id' => $guild_id,
|
||||
'guild_cover' => $guild_info['cover'],
|
||||
'guild_id' => $guild_ids,
|
||||
'guild_cover' => $cover,
|
||||
'is_deacon' => $is_deacon,
|
||||
'user_list' => $user_list['data']['list'],
|
||||
'name' => $group_member_info['data'][0]['Name'],
|
||||
@@ -946,7 +1032,263 @@ class Guild extends Model
|
||||
* 设置群聊信息
|
||||
*/
|
||||
public function set_guild_info($guild_id,$name,$notice,$avatar){
|
||||
$return = model('Tencent')->modify_group_base_info('g'.$guild_id, $name,$avatar, $notice);
|
||||
$return = model('Tencent')->modify_group_base_info($guild_id, $name,$avatar, $notice);
|
||||
return ['code' => $return['code'], 'msg' => $return['msg'], 'data' => $return['data']];
|
||||
}
|
||||
|
||||
/*
|
||||
* 我的公会
|
||||
* @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();
|
||||
if(empty($guild_user)){
|
||||
return ['code' => 0, 'msg' => '您没有加入任何公会', 'data'=>null];
|
||||
}
|
||||
$info = Db::name('vs_guild')
|
||||
->field('id,guild_special_id,user_id,guild_name,cover,num,intro,createtime,income')
|
||||
->where(['id'=>$guild_user['guild_id'],'is_show'=>1,'delete_time'=>0])
|
||||
->find();
|
||||
$guild_data = [];
|
||||
if($info){
|
||||
//用户信息
|
||||
$user_data = Db::name('user')->where(['id'=>$user_id])->field('id,nickname,avatar')->find();
|
||||
$guild_data['user_id'] = $user_data['id'];
|
||||
$guild_data['user_nickname'] = $user_data['nickname'];
|
||||
$guild_data['user_code'] = model('Decorate')->user_decorate_detail($user_id, 6);
|
||||
$guild_data['user_avatar'] = localpath_to_netpath($user_data['avatar']);
|
||||
$guild_data['is_leader'] = $info['user_id'] == $user_id ? 1 : 0;//当前用户是否是会长
|
||||
$guild_data['guild_id'] = $info['id'];
|
||||
$guild_data['guild_code'] = $info['guild_special_id'];
|
||||
$guild_data['guild_name'] = $info['guild_name'];
|
||||
//加入公会时间
|
||||
$guild_data['join_time'] = date('Y-m-d H:i:s',$guild_user['apply_time']);
|
||||
//本周金额
|
||||
//本周的第一天
|
||||
$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)
|
||||
->where(['createtime' => ['between', [$week, $week_end_time]]])
|
||||
->sum('total_price');
|
||||
//厅主收益
|
||||
$guild_data['room_author_ratio'] = $guild_user['room_id']==0 ? 0 : get_system_config_value('room_author_ratio');
|
||||
//礼物分成
|
||||
$guild_data['settlement_ratio'] = $guild_user['settlement_ratio'];
|
||||
//付费退出公会所需金
|
||||
$guild_data['quit_guild_gold'] = get_system_config_value('quit_guild_gold');
|
||||
//工会群组ID
|
||||
$guild_data['guild_group_id'] = "g".$info['id'];
|
||||
//工会基础信息
|
||||
$guild_data_info = Db::name('vs_guild_data')->where(['guild_id'=>$info['id']])->find();
|
||||
$guild_data['agreement'] = $guild_data_info['agreement'] ?? '';
|
||||
}
|
||||
return ['code'=>1,'msg'=>'获取成功','data'=>$guild_data];
|
||||
}
|
||||
|
||||
/*
|
||||
* 加入工会——不用申请直接加入
|
||||
*/
|
||||
public function join_guild($guild_id,$user_id=0,$settlement_ratio = 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];
|
||||
}
|
||||
//公会是否存在
|
||||
$guild_info = db::name('vs_guild')->where(['id'=>$guild_id,'delete_time'=>0])->find();
|
||||
if(!$guild_info){
|
||||
return ['code' => 0, 'msg' => '该公会不存在', 'data' => null];
|
||||
}
|
||||
$is_check_join = Db::name('vs_guild_user')->where(['user_id'=>$user_id,'delete_time'=>0])->find();
|
||||
if($is_check_join && $is_check_join['guild_id']==$guild_id && $is_check_join['status']==1){
|
||||
return ['code'=>0,'msg'=>'您已加入该工会', 'data' => null];
|
||||
}
|
||||
if($is_check_join && $is_check_join['guild_id']==$guild_id && $is_check_join['status']==2){
|
||||
return ['code'=>0,'msg'=>'您已提交申请,请耐心等待', 'data' => null];
|
||||
}
|
||||
if($is_check_join && $is_check_join['guild_id']!=$guild_id && $is_check_join['status']==1){
|
||||
return ['code'=>0,'msg'=>'您已加入别的工会,请先退出公会再加入', 'data' => null];
|
||||
}
|
||||
if($is_check_join && $is_check_join['guild_id']!=$guild_id && $is_check_join['status']==2){
|
||||
$other_guild_name = Db::name('vs_guild')->where(['id'=>$is_check_join['guild_id']])->value('guild_name');
|
||||
return ['code'=>0,'msg'=>'您已申请加入工会'.$other_guild_name.',请等待会长审核', 'data' => null];
|
||||
}
|
||||
//是否被踢出过
|
||||
// $ti_chu = db::name('vs_guild_user')->where(['user_id'=>$user_id,'guild_id'=>$guild_id,'delete_time'=>['<>',0],'quit_type'=>2])->find();
|
||||
// if(!empty($ti_chu)){
|
||||
// return ['code' => 0, 'msg' => '已被踢出,禁止加入!', 'data' => null];
|
||||
// }
|
||||
//退出公会是否超过30天
|
||||
$map = [];
|
||||
$map['user_id'] = $user_id;
|
||||
$map['delete_time'] = ['<>',0];
|
||||
$map['quit_type'] = 1;
|
||||
$quit_guild_info = Db::name('vs_guild_user')->where($map)->order('quit_time', 'desc')->field('quit_time,guild_id,quit_type')->find();
|
||||
if(!empty($quit_guild_info)) {
|
||||
$quit_time = empty($quit_guild_info['quit_time']) ? 0 : $quit_guild_info['quit_time'];
|
||||
$quit_type = $quit_guild_info['quit_type'];
|
||||
if($quit_guild_info['guild_id'] != $guild_id) {
|
||||
$last_time = 30 * 24 * 3600;
|
||||
if((time() - $last_time) <= $quit_time) {
|
||||
return ['code' => 0, 'msg' => '退出公会未超过30天,不能重新加入其他公会', 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
//是否有房间
|
||||
$rid = 0;
|
||||
$room_info = db::name('vs_room')->where('user_id', $user_id)->find();
|
||||
if($room_info){
|
||||
$rid = $room_info['id'];
|
||||
}
|
||||
$insert_data = [];
|
||||
$insert_data['user_id'] = $user_id;
|
||||
$insert_data['guild_id'] = $guild_id;
|
||||
$insert_data['room_id'] = $rid;
|
||||
$insert_data['status'] = 1;
|
||||
$insert_data['is_deacon'] = 2;
|
||||
$insert_data['createtime'] = time();
|
||||
$insert_data['apply_time'] = time();
|
||||
$insert_data['is_show_room'] = 1;
|
||||
//结算比例
|
||||
$configs = get_system_config();
|
||||
//收礼人最终的收益比例 = 未加入工会的收益 + 加入工会的收益
|
||||
if($settlement_ratio){
|
||||
$insert_data['settlement_ratio'] = $settlement_ratio;
|
||||
}else{
|
||||
$insert_data['settlement_ratio'] = $configs['room_gift_ratio'] + $configs['room_gift_guild_ratio'];
|
||||
}
|
||||
$reslut = db::name('vs_guild_user')->insert($insert_data);
|
||||
if($reslut){
|
||||
//增加公会人数
|
||||
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'].'加入公会');
|
||||
//发系统信息
|
||||
$content = "恭喜加入{$guild_info['guild_name']}工会,您的个人收益增加{$configs['room_gift_guild_ratio']}%,目前总收益{$insert_data['settlement_ratio']}%";
|
||||
model('api/UserMessage')->send_system_message($user_id, "加入公会成功通知", $content, 1);
|
||||
//处理新手任务
|
||||
model('api/Tasks')->tasks_complete($user_id,11);
|
||||
return ['code' => 1, 'msg' => '提交成功', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => '提交失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//工会邀请用户处理
|
||||
public function guild_invite_handle($user_id,$message_id,$status){
|
||||
$guild_user_invited = Db::name('vs_guild_user_invited')->where(['message_id'=>$message_id,'delete_time'=>0])->find();
|
||||
if(empty($guild_user_invited)){
|
||||
return ['code' => 0, 'msg' => '邀请信息不存在', 'data' => null];
|
||||
}
|
||||
if($user_id != $guild_user_invited['user_id']){
|
||||
return ['code' => 0, 'msg' => '您没有权限处理此信息', 'data' => null];
|
||||
}
|
||||
if($guild_user_invited['status'] != 0){
|
||||
return ['code' => 0, 'msg' => '此邀请信息已处理过', 'data' => null];
|
||||
}
|
||||
if($status == 1){
|
||||
//加入工会
|
||||
$res = $this->join_guild($guild_user_invited['guild_id'],$guild_user_invited['user_id'],$guild_user_invited['settlement_ratio']);
|
||||
if($res['code'] != 1){
|
||||
return ['code' => 0, 'msg' => $res['msg'], 'data' => null];
|
||||
}
|
||||
$guild_user_invited_data = [
|
||||
'status' => 1,
|
||||
'apply_time' => time(),
|
||||
'updatetime' => time(),
|
||||
];
|
||||
}else{
|
||||
$guild_user_invited_data = [
|
||||
'status' => 2,
|
||||
'apply_time' => time(),
|
||||
'updatetime' => time(),
|
||||
];
|
||||
}
|
||||
$guild_user_invited_res = Db::name('vs_guild_user_invited')->where(['message_id'=>$message_id,'delete_time'=>0])->update($guild_user_invited_data);
|
||||
if($guild_user_invited_res){
|
||||
return ['code' => 1, 'msg' => '处理成功', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => '处理失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//公会调整收益审核接口
|
||||
public function user_ratio_up_apply($user_id,$message_id,$status){
|
||||
$guild_user_ratio_up = Db::name('vs_guild_user_ratio_up_log')->where(['message_id'=>$message_id,'delete_time'=>0])->find();
|
||||
if(empty($guild_user_ratio_up)){
|
||||
return ['code' => 0, 'msg' => '邀请信息不存在', 'data' => null];
|
||||
}
|
||||
if($user_id != $guild_user_ratio_up['user_id']){
|
||||
return ['code' => 0, 'msg' => '您没有权限处理此信息', 'data' => null];
|
||||
}
|
||||
if($guild_user_ratio_up['status'] != 0){
|
||||
return ['code' => 0, 'msg' => '此邀请信息已处理过', 'data' => null];
|
||||
}
|
||||
if($status == 1){
|
||||
//处理结算比例
|
||||
$res = db::name('vs_guild_user')->where(['id'=>$guild_user_ratio_up['guild_user_id']])->update(['settlement_ratio'=>$guild_user_ratio_up['settlement_ratio']]);
|
||||
if($res){
|
||||
$data = [
|
||||
'status' => 1,
|
||||
'apply_time' => time(),
|
||||
'updatetime' => time(),
|
||||
];
|
||||
$guild_user_res = Db::name('vs_guild_user_ratio_up_log')->where(['message_id'=>$message_id,'delete_time'=>0])->update($data);
|
||||
if($guild_user_res){
|
||||
return ['code' => 1, 'msg' => '处理成功', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => '处理失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
$data = [
|
||||
'status' => 2,
|
||||
'apply_time' => time(),
|
||||
'updatetime' => time(),
|
||||
];
|
||||
$guild_user_res = Db::name('vs_guild_user_ratio_up_log')->where(['message_id'=>$message_id,'delete_time'=>0])->update($data);
|
||||
if($guild_user_res){
|
||||
return ['code' => 1, 'msg' => '处理成功', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => '处理失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//公会流水记录
|
||||
public function guild_flow($room_id,$flow_price,$give_gift_id=0){
|
||||
if($room_id<=0 || $flow_price<=0){
|
||||
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||
}
|
||||
$guild_user_info = Db::name('vs_guild_user')->where(['room_id' => $room_id, 'delete_time' => 0, 'status' => 1, 'quit_time' => 0])->find();
|
||||
if ($guild_user_info) {
|
||||
//记录流水
|
||||
$data = [
|
||||
'guild_id' => $guild_user_info['guild_id'],
|
||||
'room_id' => $guild_user_info['room_id'],
|
||||
'give_gift_id' => $give_gift_id,
|
||||
'flow_price' => $flow_price,
|
||||
'day' => date('Y-m-d'),
|
||||
'createtime' => time(),
|
||||
'updatetime' => time(),
|
||||
];
|
||||
$res = Db::name('vs_guild_flow')->insert($data);
|
||||
if (!$res) {
|
||||
return ['code' => 0, 'msg' => '提交失败', 'data' => null];
|
||||
}
|
||||
//增加用户公会流水
|
||||
Db::name('vs_guild_user')->where(['id' => $guild_user_info['id']])->setInc('coin', $flow_price);
|
||||
//增加公会总流水
|
||||
Db::name('vs_guild')->where(['id' => $guild_user_info['guild_id']])->setInc('income', $flow_price);
|
||||
return ['code' => 1, 'msg' => '提交成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class Level extends Model
|
||||
//获取等级
|
||||
// 获取用户当前等级
|
||||
$currentUserLevel = $user['charm_level'];
|
||||
if($currentUserLevel == 1){
|
||||
if($currentUserLevel == 0){
|
||||
$level = Db::name('vs_charm_level')
|
||||
->where('status', 1)
|
||||
->order('level', 'asc')
|
||||
@@ -152,7 +152,7 @@ class Level extends Model
|
||||
//获取等级
|
||||
// 获取用户当前等级
|
||||
$currentUserLevel = $user['wealth_level'];
|
||||
if($currentUserLevel == 1){
|
||||
if($currentUserLevel == 0){
|
||||
$level = Db::name('vs_wealth_level')
|
||||
->where('status', 1)
|
||||
->order('level', 'asc')
|
||||
@@ -277,6 +277,44 @@ class Level extends Model
|
||||
return $return;
|
||||
}
|
||||
|
||||
/*
|
||||
* 通过等级获取魅力等级信息
|
||||
*
|
||||
*/
|
||||
public function get_singer_level_to_level($level){
|
||||
$return = [];
|
||||
$level_data = Db::name('vs_singer_level')->where('level', $level)->find();
|
||||
$next_level_data = Db::name('vs_singer_level')->where('level', $level+1)->find();
|
||||
if($level_data){
|
||||
$return['level'] = $level_data['level'];
|
||||
$return['level_name'] = $level_data['name'];
|
||||
$return['exp'] = $level_data['change_value'];
|
||||
$return['level_icon'] = $level_data['image'];
|
||||
$return['rights_icon'] = $level_data['rights_icon'];
|
||||
}else{
|
||||
$return['level'] = 0;
|
||||
$return['level_name'] = '';
|
||||
$return['exp'] = 0;
|
||||
$return['level_icon'] = '';
|
||||
$return['rights_icon'] = "";
|
||||
}
|
||||
|
||||
if($next_level_data){
|
||||
$return['next_level'] = $next_level_data['level'];
|
||||
$return['next_level_name'] = $next_level_data['name'];
|
||||
$return['next_level_exp'] = $next_level_data['change_value'];
|
||||
$return['next_level_icon'] = $next_level_data['image'];
|
||||
$return['next_rights_icon'] = $next_level_data['rights_icon'];
|
||||
}else{
|
||||
$return['next_level'] = $level_data['level'];
|
||||
$return['next_level_name'] = $level_data['name'];
|
||||
$return['next_level_exp'] = $level_data['change_value'];
|
||||
$return['next_level_icon'] = $level_data['image'];
|
||||
$return['next_rights_icon'] = $level_data['rights_icon'];
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/*
|
||||
* 用户财富/魅力等级更新
|
||||
* @param uid 用ID
|
||||
@@ -459,4 +497,103 @@ class Level extends Model
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
//歌手等级
|
||||
public function get_singer_level($uid){
|
||||
//经验值兑换金币比例
|
||||
$return['singer_coin_exp'] = get_system_config_value('singer_coin_exp');
|
||||
//用户信息
|
||||
$user = model('User')->get_user_info($uid);
|
||||
//用户头像
|
||||
$return['user']['user_avatar'] = $user['avatar'];
|
||||
//当前用户等级信息
|
||||
$singer = db::name('vs_singer')->where(['user_id' => $uid])->find();
|
||||
if(empty($singer)){
|
||||
$singer['level'] = 0;
|
||||
$singer['exp'] = 0;
|
||||
$singer['status'] = 0;
|
||||
$singer['level_name'] = '非歌手';
|
||||
}
|
||||
$user_level = $this->get_singer_level_to_level($singer['level']);
|
||||
if(!$user_level){
|
||||
return ['code' => 0, 'msg' => "数据配置有误 请联系管理员", 'data' => null];
|
||||
}
|
||||
// 获取最后等级
|
||||
$level_last = Db::name('vs_singer_level')
|
||||
->where('deletetime',0)
|
||||
->order('level', 'desc')
|
||||
->value('level');
|
||||
//用户当前经验
|
||||
$return['user']['level'] = $singer['level'];
|
||||
$return['user']['level_str'] = 'Lv.'.$singer['level'];
|
||||
$return['user']['exp'] = $singer['exp'];
|
||||
$return['user']['rights_icon'] = $user_level['rights_icon'];
|
||||
if($singer['level'] ==$level_last ){
|
||||
//距离下个等级需要的经验
|
||||
$return['user']['next_level'] = 0;
|
||||
$return['user']['next_level_str'] = "满级";
|
||||
$return['user']['next_exp'] = 0;
|
||||
$return['user']['next_rights_icon'] = "";
|
||||
}else{
|
||||
//距离下个等级需要的经验
|
||||
$return['user']['next_level'] = $user_level['next_level'];
|
||||
$return['user']['next_level_str'] = 'Lv.'.$return['user']['next_level'];
|
||||
$next_exp = $user_level['next_level_exp'] - $singer['exp'];
|
||||
$return['user']['next_exp'] = $next_exp <= 0 ? 0 : $next_exp;
|
||||
$return['user']['next_rights_icon'] = $user_level['next_rights_icon'];
|
||||
}
|
||||
//获取等级
|
||||
// 获取用户当前等级
|
||||
$currentUserLevel = $singer['level'];
|
||||
if($currentUserLevel == 0){
|
||||
$level = Db::name('vs_singer_level')
|
||||
->where('deletetime',0)
|
||||
->order('level', 'asc')
|
||||
->limit(3)
|
||||
->select();
|
||||
}elseif($currentUserLevel == $level_last){
|
||||
$limit_s = $level_last-2;
|
||||
if($limit_s < 0){
|
||||
$limit_s = 0;
|
||||
}
|
||||
$level = Db::name('vs_singer_level')
|
||||
->where('deletetime',0)
|
||||
->order('level', 'asc')
|
||||
->limit($limit_s,3)
|
||||
->select();
|
||||
}else{
|
||||
$level = Db::name('vs_singer_level')
|
||||
->where('deletetime',0)
|
||||
->where('level', 'in', [$currentUserLevel - 1, $currentUserLevel, $currentUserLevel + 1])
|
||||
->order('level', 'asc')
|
||||
->select();
|
||||
}
|
||||
$return['level'] = [];
|
||||
if($level) {
|
||||
foreach ($level as $key => $value) {
|
||||
$return['level'][$key]['level'] = $value['level'];
|
||||
$return['level'][$key]['image'] = $value['image'];
|
||||
$return['level'][$key]['bg_image'] = $value['bg_image'];
|
||||
$return['level'][$key]['color'] = $value['color'];
|
||||
$return['level'][$key]['name'] = $value['name'];
|
||||
$return['level'][$key]['change_value'] = $value['change_value'];
|
||||
//当前用户距离当前段位的距离
|
||||
$return['level'][$key]['distance'] = $value['change_value'] - $singer['exp'];
|
||||
$return['level'][$key]['rights_icon'] = $value['rights_icon'];
|
||||
}
|
||||
}
|
||||
$level_list = Db::name('vs_singer_level')
|
||||
->where('deletetime',0)
|
||||
->order('level', 'asc')
|
||||
->select();
|
||||
$return['level_list'] = [];
|
||||
$exp_s = 0;
|
||||
foreach ($level_list as $key => $value) {
|
||||
$return['level_list'][$key]['level'] = 'LV.'.$value['level'];
|
||||
$return['level_list'][$key]['exp_str'] = $exp_s.'-'.$value['change_value'];
|
||||
$return['level_list'][$key]['image'] = $value['image'];
|
||||
$exp_s = $value['change_value'];
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => $return];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace app\api\model;
|
||||
use fast\Http;
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
use think\facade\Env;
|
||||
use app\common\library\Token as TokenLib;
|
||||
|
||||
class Login extends Model
|
||||
{
|
||||
@@ -17,12 +17,27 @@ class Login extends Model
|
||||
if ($block) {
|
||||
return ['code' => 0, 'msg' => '设备已被封禁', 'data' => null];
|
||||
}
|
||||
$ip = request()->ip();
|
||||
$block = db::name('block')->where(['type_text' => $ip,'type' => 3])->find();
|
||||
//获取请求ip
|
||||
$login_ip = request()->server('HTTP_X_REAL_IP') ?: request()->server('HTTP_X_FORWARDED_FOR') ?: request()->ip();
|
||||
if (empty($login_ip)) {
|
||||
return ['code' => 0, 'msg' => '无法获取客户端IP地址', 'data' => null];
|
||||
}
|
||||
|
||||
$block = db::name('block')->where(['type_text' => $login_ip,'type' => 3])->find();
|
||||
if ($block) {
|
||||
return ['code' => 0, 'msg' => 'ip已被封禁', 'data' => null];
|
||||
}
|
||||
|
||||
if($user_name){
|
||||
$config_time = get_system_config_value('cancel_no_login');
|
||||
$is_del = db::name('user')->where(['mobile' => $user_name,'delete_time' => ['<>', 0]])->find();
|
||||
if ($is_del) {
|
||||
if (time() - $is_del['delete_time'] < $config_time * 24 * 3600) {//30天内注销过
|
||||
return V(0, '注销30天内,不可操作。');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$user_code = $this->get_user_code(); //获取用户code_id 过滤靓号
|
||||
|
||||
@@ -30,10 +45,10 @@ class Login extends Model
|
||||
$data['username'] = $user_name;
|
||||
$data['mobile'] = $user_name;
|
||||
$data['nickname'] = '游客'.$user_code;
|
||||
$data['joinip'] = request()->ip();
|
||||
$data['birthday'] = date('Y-m-d');
|
||||
$data['joinip'] = $login_ip;
|
||||
$data['birthday'] = '1990-01-01';
|
||||
$data['avatar'] = get_system_config_value('web_site').'/data/avatar/head_pic.png';
|
||||
$data['profile'] = '这个人很懒,什么都没写';
|
||||
$data['profile'] = '这个人很佛系,什么都没写';
|
||||
$data['system'] = $system;
|
||||
$data['login_device'] = $login_device;
|
||||
$data['createtime'] = time();
|
||||
@@ -96,6 +111,11 @@ class Login extends Model
|
||||
$return_res[0]['auth'] = 0;
|
||||
$return_res[0]['icon'][0] = model('UserData')->user_wealth_icon($user_id);//财富图标
|
||||
$return_res[0]['icon'][1] = model('UserData')->user_charm_icon($user_id);//魅力图标
|
||||
//判断是否是歌手 如果是 返回等级图标
|
||||
$isSinger = db::name('vs_singer')->where(['user_id' => $user_id,'status' => 1])->find();
|
||||
if($isSinger){
|
||||
$return_res[0]['icon'][2] = db::name('vs_singer_level')->where(['level' => $isSinger['level'],'deletetime' => 0])->value('image');//等级图标
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => '登录成功', 'data' => $return_res];
|
||||
}
|
||||
@@ -133,7 +153,7 @@ class Login extends Model
|
||||
}
|
||||
}
|
||||
}
|
||||
$ip = request()->ip();
|
||||
$ip = request()->server('HTTP_X_REAL_IP') ?: request()->server('HTTP_X_FORWARDED_FOR') ?: request()->ip();
|
||||
$block = db::name('block')->where(['type_text' => $ip,'type' => 3])->find();
|
||||
if ($block) {
|
||||
if($block['block_time'] != 0 && $block['block_time'] <= time()){
|
||||
@@ -183,9 +203,10 @@ class Login extends Model
|
||||
$save_data['system'] = $system;
|
||||
$save_data['login_device'] = $login_device;
|
||||
$save_data['logintime'] = time();
|
||||
$save_data['loginip'] = request()->ip();
|
||||
$save_data['loginip'] = $ip;
|
||||
$save_data['updatetime'] = time();
|
||||
$save_data['prevtime'] = $user_info['logintime'];//上次登录时间
|
||||
$save_data['is_online'] = 1;
|
||||
$reslut = model('User')->update($save_data);
|
||||
|
||||
if (!$reslut) {
|
||||
@@ -202,6 +223,14 @@ class Login extends Model
|
||||
$return_res[0]['mobile'] = $user_info['mobile'];
|
||||
$return_res[0]['icon'][0] = model('UserData')->user_wealth_icon($user_info['id']);//财富图标
|
||||
$return_res[0]['icon'][1] = model('UserData')->user_charm_icon($user_info['id']);//魅力图标
|
||||
//判断是否是歌手 如果是 返回等级图标
|
||||
$isSinger = db::name('vs_singer')->where(['user_id' => $user_info['id'],'status' => 1])->find();
|
||||
if($isSinger){
|
||||
$return_res[0]['icon'][2] = db::name('vs_singer_level')->where(['level' => $isSinger['level'],'deletetime' => 0])->value('image');//等级图标
|
||||
}
|
||||
|
||||
$return_res[0]['dress'] = model('Decorate')->user_decorate_detail($user_info['id'],1);
|
||||
$return_res[0]['chat_bubble'] = model('Decorate')->user_decorate_detail($user_info['id'],9);//聊天气泡
|
||||
|
||||
$isAuth = 0;
|
||||
if($user_info['mobile']){
|
||||
@@ -219,7 +248,6 @@ class Login extends Model
|
||||
$return_res[0]['is_can_chat'] = 1;
|
||||
}
|
||||
$return_res[0]['can_chat_money'] = $config_money;
|
||||
|
||||
return ['code' => 1, 'msg' => '登录成功', 'data' => $return_res];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => '登录失败,账号失效', 'data' => null];
|
||||
@@ -363,21 +391,21 @@ class Login extends Model
|
||||
if($type == 'wx'){
|
||||
$openid = $userinfo['openid'];
|
||||
$user_info_data = model('UserData')->where(['wx_openid' => $openid,'deletetime'=>0])->find();
|
||||
$config_time = get_system_config_value('cancel_to_reset_reg');
|
||||
$config_time = get_system_config_value('cancel_no_login');
|
||||
if(isset($user_info_data) && $user_info_data['deletetime'] != 0 && time() - $user_info_data['deletetime'] < 86400 * $config_time){
|
||||
return ['code' => 0, 'msg' => '注销后需等待'.$config_time.'天才能重新注册', 'data' => null];
|
||||
}
|
||||
}elseif ($type == 'ali'){
|
||||
$ali_userid = $userinfo['open_id'];
|
||||
$user_info_data = model('UserData')->where(['ali_userid' => $ali_userid,'deletetime'=>0])->find();
|
||||
$config_time = get_system_config_value('cancel_to_reset_reg');
|
||||
$config_time = get_system_config_value('cancel_no_login');
|
||||
if(isset($user_info_data) && $user_info_data['deletetime'] != 0 && time() - $user_info_data['deletetime'] < 86400 * $config_time){
|
||||
return ['code' => 0, 'msg' => '注销后需等待'.$config_time.'天才能重新注册', 'data' => null];
|
||||
}
|
||||
}elseif ($type == 'ios'){
|
||||
$apple_id = $userinfo;
|
||||
$user_info_data = model('UserData')->where(['apple_id' => $userinfo,'deletetime'=>0])->find();
|
||||
$config_time = get_system_config_value('cancel_to_reset_reg');
|
||||
$config_time = get_system_config_value('cancel_no_login');
|
||||
if(isset($user_info_data) && $user_info_data['deletetime'] != 0 && time() - $user_info_data['deletetime'] < 86400 * $config_time){
|
||||
return ['code' => 0, 'msg' => '注销后需等待'.$config_time.'天才能重新注册', 'data' => null];
|
||||
}
|
||||
@@ -402,6 +430,12 @@ class Login extends Model
|
||||
$return_res[0]['auth'] = 0;
|
||||
$return_res[0]['icon'][0] = model('UserData')->user_wealth_icon($user_info_data['user_id']);//财富图标
|
||||
$return_res[0]['icon'][1] = model('UserData')->user_charm_icon($user_info_data['user_id']);//魅力图标
|
||||
//判断是否是歌手 如果是 返回等级图标
|
||||
$isSinger = db::name('vs_singer')->where(['user_id' => $user_info_data['user_id'],'status' => 1])->find();
|
||||
if($isSinger){
|
||||
$return_res[0]['icon'][2] = db::name('vs_singer_level')->where(['level' => $isSinger['level'],'deletetime' => 0])
|
||||
->value('image');//等级图标
|
||||
}
|
||||
return ['code' => 1, 'msg' => '登录成功', 'data' => $return_res];
|
||||
}
|
||||
|
||||
@@ -434,9 +468,19 @@ class Login extends Model
|
||||
|
||||
//退出登录
|
||||
public function logout($token){
|
||||
$user_info = model('UserToken')->where('token', $token)->find();
|
||||
$user_info = db::name('user_token')->where('token', $token)->find();
|
||||
if($user_info){
|
||||
model('UserToken')->where('id', $user_info['id'])->update(['token' => 1]);
|
||||
db::name('user_token')->where('id', $user_info['id'])->update(['token' => 1]);
|
||||
//断线
|
||||
db::name('user')->where('id',$user_info['user_id'])->update(['is_online'=>2]);
|
||||
//是否在房间内
|
||||
$room_id = db::name('vs_room_visitor')->where('user_id',$user_info['user_id'])->order('id desc')->value('room_id');
|
||||
if($room_id){
|
||||
$text['text'] = '掉线!';
|
||||
$text['user_id'] = $user_info['user_id'];
|
||||
$text['type'] = 2;
|
||||
model('Chat')->sendMsg(1058,$room_id,$text);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '退出成功', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => '退出失败', 'data' => null];
|
||||
@@ -444,7 +488,7 @@ class Login extends Model
|
||||
}
|
||||
|
||||
//注销
|
||||
public function cancel($token){
|
||||
public function cancel($token,$system,$login_device){
|
||||
$user_info = model('UserToken')->where('token', $token)->find();
|
||||
//用户注册时间
|
||||
$register_time = db::name('user')->where('id', $user_info['user_id'])->value('createtime');
|
||||
@@ -452,40 +496,46 @@ class Login extends Model
|
||||
if(time() - $register_time < 86400 * $config_time){
|
||||
return ['code' => 0, 'msg' => '注册'.$config_time.'天内不能注销!', 'data' => null];
|
||||
}
|
||||
|
||||
if($user_info){
|
||||
model('UserToken')->where('id', $user_info['id'])->update(['token' => 1]);
|
||||
$isstatus = model('User')->where('id', $user_info['user_id'])->update(['status' => 0]);
|
||||
$isstatus = model('User')->where('id', $user_info['user_id'])->update([
|
||||
'status' => 0,
|
||||
'delete_time' => time(),
|
||||
'login_device' => $login_device,
|
||||
'system' =>$system,
|
||||
'avatar' => get_system_config_value('delete_avatar'),
|
||||
'nickname' => '注销用户'
|
||||
]);
|
||||
if($isstatus){
|
||||
//查询用户所在房间
|
||||
$room_list = db::name('vs_room_visitor')->where('user_id', $user_info['user_id'])->select();
|
||||
if($room_list){
|
||||
foreach ($room_list as &$value) {
|
||||
foreach ($room_list as $value) {
|
||||
model('Room')->quit_room($user_info['user_id'], $value['room_id'],$user_info['user_id']);
|
||||
}
|
||||
}
|
||||
//删除用户
|
||||
// model('Tencent')->account_delete($user_info['user_id']);
|
||||
model('User')->where('id', $user_info['user_id'])->update(['delete_time' => time()]);
|
||||
model('User')->where('id', $user_info['user_id'])->update(['avatar' => get_system_config_value('delete_avatar')]);
|
||||
|
||||
model('UserData')->where('user_id', $user_info['user_id'])->update(['deletetime' => time()]);
|
||||
//查询创建的房间
|
||||
$room_list = db::name('vs_room')->where('user_id', $user_info['user_id'])->select();
|
||||
if($room_list){
|
||||
foreach ($room_list as &$value) {
|
||||
foreach ($room_list as $value) {
|
||||
db::name('vs_room')->where('id', $value['id'])->update(['room_status' => 3]);
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => '注销失败', 'data' => null];
|
||||
}
|
||||
|
||||
//查询绑定的手机号
|
||||
$mob = db::name('user')->where('id', $user_info['user_id'])->value('mobile');
|
||||
$mobile = db::name('user')->where(['mobile' => $mob,'status' => ['<>',0]])->select();
|
||||
if(isset($mobile) && count($mobile) < 2){
|
||||
db::name('user_auth')->where('mobile', $mob)->delete();
|
||||
}
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => '注销失败', 'data' => null];
|
||||
}
|
||||
// 删除这个Token,使其失效
|
||||
TokenLib::delete($token);
|
||||
|
||||
return ['code' => 1, 'msg' => '注销成功', 'data' => null];
|
||||
}else{
|
||||
|
||||
203
application/api/model/Lottery.php
Normal file
203
application/api/model/Lottery.php
Normal file
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use app\common\controller\Push;
|
||||
use app\common\service\LotteryService;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
use think\Log;
|
||||
use think\Model;
|
||||
|
||||
class Lottery extends Model
|
||||
{
|
||||
/**
|
||||
* 送礼参与抽奖接口
|
||||
* @return json
|
||||
*/
|
||||
public function gift($send_uid, $recv_uid,$gift_id, $room_id, $num)
|
||||
{
|
||||
if (ceil($num) != $num) {
|
||||
return ['code' => 0, 'msg' => '打赏礼物数量必须为整数', 'data' => null];
|
||||
}
|
||||
$toarray = explode(',',$recv_uid);
|
||||
if(in_array($send_uid,$toarray)){
|
||||
return ['code' => 0, 'msg' => '收礼人不能包含自己', 'data' => null];
|
||||
}
|
||||
|
||||
//获取礼物信息
|
||||
$gift_info = Db::name('vs_gift')->where(['gid'=>$gift_id])
|
||||
->field('gid as gift_id,gift_name,gift_price,file_type,base_image,play_image,gift_type,label,is_public_server')->find();
|
||||
$gift_info['play_image'] = '';//不要特效
|
||||
|
||||
//送给所有人的总价格
|
||||
$all_gift_price = $gift_info['gift_price'] * $num * count($toarray);
|
||||
//判断是否有足够的金币
|
||||
$user_waller = db::name('user_wallet')->where(['user_id'=>$send_uid])->find();
|
||||
if ($user_waller['coin'] < $all_gift_price) {
|
||||
return ['code' => 0, 'msg' => '用户金币不足', 'data' => null];
|
||||
}
|
||||
|
||||
//获取送礼用户昵称
|
||||
$FromUserInfo = db::name('user')->where('id',$send_uid)->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($send_uid);//财富图标
|
||||
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($send_uid);//魅力图标
|
||||
$FromUserInfo['chat_bubble'] = model('Decorate')->user_decorate_detail($send_uid,9);//聊天气泡
|
||||
|
||||
//送礼 开启事务
|
||||
Db::startTrans();
|
||||
//扣除用户金币并记录日志
|
||||
$wallet_update = model('api/GiveGift')->change_user_cion_or_earnings_log($send_uid,$all_gift_price,$room_id,1,10,'用户金币购买礼物');
|
||||
if(!$wallet_update){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '扣除用户金币失败', 'data' => null];
|
||||
}
|
||||
//用户财富等级更新
|
||||
$user_level = model('api/Level')->user_level_data_update($send_uid,$all_gift_price,1,$room_id);
|
||||
if(!$user_level){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '用户等级更新失败', 'data' => null];
|
||||
}
|
||||
|
||||
//送给一人礼物的总价格(扣除用户的数额)
|
||||
$gift_price = $gift_info['gift_price'] * $num;
|
||||
|
||||
foreach ($toarray as $k => $to_id){
|
||||
// 1. 记录礼物赠送
|
||||
$giftRecord = [
|
||||
'send_uid' => $send_uid,
|
||||
'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()
|
||||
];
|
||||
$giftId = Db::name('bb_lottery_gift_record')->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);
|
||||
if(!$give_gift){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '送礼失败', 'data' => null];
|
||||
}
|
||||
//计算收礼人得益
|
||||
$receiver_earnings = $gift_price /2/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,'收礼增加收益');
|
||||
|
||||
// //用户魅力等级更新
|
||||
// $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( [
|
||||
'room_id' => $room_id,
|
||||
'send_uid' => $send_uid,
|
||||
'recv_uid' => $to_id,
|
||||
'gift_id' => $gift_id,
|
||||
'num' => $num,
|
||||
'luck_value' => $gift_price,
|
||||
'createtime' => time()
|
||||
]);
|
||||
|
||||
$ToUserInfo = Db::name('user')->where(['id' => $to_id])->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$ToUserInfo['icon'][0] = model('UserData')->user_wealth_icon($to_id);//财富图标
|
||||
$ToUserInfo['icon'][1] = model('UserData')->user_charm_icon($to_id);//魅力图标
|
||||
$ToUserInfo['charm'] = db::name('vs_room_user_charm')->where(['user_id' => $to_id,'room_id' => $room_id])->value('charm');//魅力
|
||||
$text = $FromUserInfo['nickname'] . ' 送给 ' . $ToUserInfo['nickname'].' 礼物 ' .$gift_info['gift_name'].' x ' .$num;
|
||||
$text = [
|
||||
'FromUserInfo' => $FromUserInfo,
|
||||
'ToUserInfo' => $ToUserInfo,
|
||||
'GiftInfo' => $gift_info,
|
||||
'gift_num' => $num,
|
||||
'text' => $text
|
||||
];
|
||||
//聊天室推送系统消息
|
||||
model('api/Chat')->sendMsg(1005,$room_id,$text);
|
||||
}
|
||||
Db::commit();
|
||||
|
||||
//计算爆币
|
||||
$nums = $num * count($toarray);
|
||||
$ress = $this->lottery($send_uid,$gift_info['gift_price'],$nums,$room_id,$gift_id,$FromUserInfo,$gift_info);
|
||||
if($ress['code'] == 0){
|
||||
return ['code' => 0, 'msg' => $ress['msg'], 'data' => null];
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => '送礼成功', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
//抽奖
|
||||
public function lottery($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');
|
||||
try {
|
||||
for($i=0;$i<$num;$i++){
|
||||
$gift_gold = $gift_price;
|
||||
$service = new LotteryService();
|
||||
$reslut = $service->handleGift($send_uid, $gift_gold, $giftId);
|
||||
if ($reslut['code'] == 1) {
|
||||
$result = $reslut['data'];
|
||||
//(未开奖时)
|
||||
if ($result['is_small_prize'] == 0) {
|
||||
//不做处理
|
||||
} else {//开奖
|
||||
// 大奖
|
||||
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.'倍');
|
||||
if(!$wallet_update){
|
||||
return ['code' => 0, 'msg' => '流水记录失败', 'data' => null];
|
||||
}
|
||||
|
||||
$tet['text'] = '恭喜用户'.$fromUserInfo['nickname'].'在幸运币活动中获得幸运币'.$beilv.'倍';
|
||||
$tet['type'] = 1;
|
||||
$tet['beilv'] = $beilv;
|
||||
$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.'倍');
|
||||
if(!$wallet_update){
|
||||
return ['code' => 0, 'msg' => '流水记录失败', 'data' => null];
|
||||
}
|
||||
|
||||
$tet['text'] = '恭喜用户'.$fromUserInfo['nickname'].'在幸运币活动中获得幸运币'.$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 . '房间获得幸运币'. $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];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
57
application/api/model/MarketValue.php
Normal file
57
application/api/model/MarketValue.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class MarketValue extends Model
|
||||
{
|
||||
/*
|
||||
* 身价变化
|
||||
* @param int $user_id 用户id
|
||||
* @param int $change_value 身价变化值
|
||||
* @param int $type 0-收礼升值,1-系统降身价,2-使用降身卡,3-签约溢价 涨身价
|
||||
* * @return array
|
||||
*/
|
||||
public function change($user_id,$change_value,$type){
|
||||
$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);
|
||||
if($result){
|
||||
//记录一条日志
|
||||
db::name('vs_user_market_value_log')->insert([
|
||||
'user_id' => $user_id,
|
||||
'before' => $before,
|
||||
'change_value' => $change_value,
|
||||
'afterwards' => $before + $change_value,
|
||||
'type' => $type,
|
||||
'createtime' => time()
|
||||
]);
|
||||
}
|
||||
}else{
|
||||
//降身价
|
||||
$change = $before-$change_value;
|
||||
if($change <= 1){
|
||||
$afterwards = 1;
|
||||
$result = db::name('user')->where('id',$user_id)->update(['market_value' => 1]);
|
||||
}else{
|
||||
$afterwards = $change;
|
||||
$result = db::name('user')->where('id',$user_id)->setDec('market_value',$change_value);
|
||||
}
|
||||
|
||||
if($result){
|
||||
//记录一条日志
|
||||
db::name('vs_user_market_value_log')->insert([
|
||||
'user_id' => $user_id,
|
||||
'before' => $before,
|
||||
'change_value' => $change_value,
|
||||
'afterwards' => $afterwards,
|
||||
'type' => $type,
|
||||
'createtime' => time()
|
||||
]);
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功'];
|
||||
}
|
||||
}
|
||||
389
application/api/model/Nobility.php
Normal file
389
application/api/model/Nobility.php
Normal file
@@ -0,0 +1,389 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
use think\Cache;
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
use think\Session;
|
||||
|
||||
class Nobility extends Model
|
||||
{
|
||||
|
||||
// 开启自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'int';
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
|
||||
public static function init()
|
||||
{
|
||||
self::beforeWrite(function ($row) {
|
||||
});
|
||||
}
|
||||
|
||||
//爵位列表
|
||||
public static function getNobilityList($user_id){
|
||||
//爵位列表
|
||||
$nobility_list = db::name('vs_nobility')
|
||||
->field('lid,name,image,images,pay_price,renew_price,pay_coin,renew_coin,day,power_ids')
|
||||
->where('delete_time', 0)
|
||||
->select();
|
||||
//爵位特权
|
||||
$power_count = db::name('vs_nobility_power')
|
||||
->field('id,name,image')
|
||||
->where('delete_time', 0)
|
||||
->count();
|
||||
$return = [];
|
||||
foreach ($nobility_list as $key => $value) {
|
||||
$power_ids = explode(',', $value['power_ids']);
|
||||
$return[$key]['lid'] = $value['lid'];
|
||||
$return[$key]['name'] = $value['name'];
|
||||
$return[$key]['image'] = $value['image'];
|
||||
$return[$key]['pay_price'] = $value['pay_price'];
|
||||
$return[$key]['day'] = $value['day'];
|
||||
$power_list = db::name('vs_nobility_power')
|
||||
->field('id,name,content,image')
|
||||
->whereIn('id', $power_ids)
|
||||
->where('delete_time', 0)
|
||||
->select();
|
||||
$return[$key]['power']['power_count'] = $power_count;
|
||||
$return[$key]['power']['this_power_count'] = count($power_list);
|
||||
$return[$key]['power']['count_str'] = count($power_list)."/".$power_count;
|
||||
$return[$key]['power']['list'] = $power_list;
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => $return];
|
||||
}
|
||||
|
||||
//爵位详情
|
||||
public static function getNobilityInfo($user_id){
|
||||
$user_info = db::name('user')
|
||||
->field('id as user_id,nickname,avatar')
|
||||
->where('delete_time', 0)
|
||||
->where('id', $user_id)
|
||||
->find();
|
||||
$user_nobility_info = db::name('vs_user_nobility')
|
||||
->field('id,user_id,lid,end_time')
|
||||
->where('delete_time', 0)
|
||||
->where(['end_time'=>['>',time()]])
|
||||
->where('user_id', $user_id)
|
||||
->find();
|
||||
$return = [];
|
||||
$return['user_info'] = $user_info; //用户信息
|
||||
$return['nobility_info'] = []; //爵位信息
|
||||
$return['nobility_info']['status'] = 0; //去开通
|
||||
$return['nobility_info']['end_time'] = '';
|
||||
if($user_nobility_info){
|
||||
$nobility_info = db::name('vs_nobility')
|
||||
->field('lid,name,image,images,pay_price,renew_price,pay_coin,renew_coin,day,power_ids')
|
||||
->where('delete_time', 0)
|
||||
->where('lid', $user_nobility_info['lid'])
|
||||
->find();
|
||||
$return['nobility_info']['status'] = 1; //去续费
|
||||
$return['nobility_info']['end_time'] = date('Y-m-d H:i:s', $user_nobility_info['end_time']);
|
||||
}
|
||||
$return['nobility_info']['lid'] = $nobility_info['lid'] ?? 0;
|
||||
$return['nobility_info']['name'] = $nobility_info['name'] ?? '';
|
||||
$return['nobility_info']['image'] = $nobility_info['image'] ?? '';
|
||||
|
||||
|
||||
$return['nobility_power_list'] = [];
|
||||
//爵位列表
|
||||
$nobility_list = db::name('vs_nobility')
|
||||
->field('lid,name,power_ids,nick_name_color,nick_name_color_name')
|
||||
->where('delete_time', 0)
|
||||
->select();
|
||||
//权限列表
|
||||
$power_list = db::name('vs_nobility_power')
|
||||
->field('id,name,image')
|
||||
->where('delete_time', 0)
|
||||
->select();
|
||||
$nobility_list_zw = [
|
||||
'lid' => 0,
|
||||
'name' => '特权',
|
||||
'power_ids' => '',
|
||||
'nick_name_color' => '无',
|
||||
'nick_name_color_name' => '无',
|
||||
];
|
||||
array_unshift($nobility_list, $nobility_list_zw);
|
||||
foreach ($nobility_list as $key => &$value) {
|
||||
$return['nobility_power_list'][$key] = $value;
|
||||
$power_ids = explode(',', $value['power_ids']);
|
||||
foreach ($power_list as $k => $v) {
|
||||
if (in_array($v['id'], $power_ids)) {
|
||||
$v['status'] = 1; //是
|
||||
}else{
|
||||
$v['status'] = 0; //否
|
||||
}
|
||||
$v['type'] = 1;
|
||||
$v['value'] = '';
|
||||
if($v['id']==2){
|
||||
$v['type'] = 2;
|
||||
$v['value'] = $value['nick_name_color_name'];
|
||||
$v['nick_name_color'] = $value['nick_name_color'];
|
||||
$v['nick_name_color_name'] = $value['nick_name_color_name'];
|
||||
}
|
||||
$return['nobility_power_list'][$key]['nobility_list'][$k] = $v;
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => $return];
|
||||
}
|
||||
|
||||
//购买爵位
|
||||
public function buyNobility($user_id,$lid){
|
||||
$nobility_info = db::name('vs_nobility')
|
||||
->field('lid,name,pay_price,renew_price,pay_coin,day,renew_coin')
|
||||
->where('delete_time', 0)
|
||||
->where('lid', $lid)
|
||||
->find();
|
||||
if (!$nobility_info) {
|
||||
return ['code' => 0, 'msg' => '爵位不存在', 'data' => null];
|
||||
}
|
||||
$user_info = db::name('user')
|
||||
->field('id,nickname,avatar')
|
||||
->where('delete_time', 0)
|
||||
->where('id', $user_id)
|
||||
->find();
|
||||
if (!$user_info) {
|
||||
return ['code' => 0, 'msg' => '用户不存在', 'data' => null];
|
||||
}
|
||||
$user_nobility_info = db::name('vs_user_nobility')
|
||||
->field('id,user_id,lid,end_time')
|
||||
->where('delete_time', 0)
|
||||
->where(['end_time'=>['>',time()]])
|
||||
->where('user_id', $user_id)
|
||||
->find();
|
||||
if ($user_nobility_info) { //已购买过 续费
|
||||
if($user_nobility_info['lid'] == $lid){//续费
|
||||
$is_renew = 1;
|
||||
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;
|
||||
//判断是否可以续费
|
||||
$end_time_to_day = floor(($end_time - time()) / 86400);
|
||||
if($end_time_to_day > $nobility_info['day'] * 2){
|
||||
return ['code' => 0, 'msg' => '已超过2倍有效期,无需续费', 'data' => null];
|
||||
}
|
||||
$data = [
|
||||
'end_time' => $end_time,
|
||||
'updatetime' => time(),
|
||||
];
|
||||
$re = db::name('vs_user_nobility')->where('id', $user_nobility_info['id'])->update($data);
|
||||
if (!$re) {
|
||||
return ['code' => 0, 'msg' => '失败', 'data' => null];
|
||||
}
|
||||
|
||||
}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;
|
||||
$data = [
|
||||
'lid' => $lid,
|
||||
'user_id' => $user_id,
|
||||
'end_time' => $end_time,
|
||||
'createtime' => time(),
|
||||
];
|
||||
db::name('vs_user_nobility')->where('id', $user_nobility_info['id'])->update(['delete_time'=>time()]);
|
||||
$re = db::name('vs_user_nobility')->insert($data);
|
||||
if (!$re) {
|
||||
return ['code' => 0, 'msg' => '失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
}else{ //未购买 新购
|
||||
$is_renew = 0;
|
||||
$end_time = time() + $nobility_info['day'] * 86400;
|
||||
$data = [
|
||||
'user_id' => $user_id,
|
||||
'lid' => $lid,
|
||||
'end_time' => $end_time,
|
||||
'createtime' => time(),
|
||||
];
|
||||
$re = db::name('vs_user_nobility')->insert($data);
|
||||
if (!$re) {
|
||||
return ['code' => 0, 'msg' => '失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
//记录日志
|
||||
$log_data = [
|
||||
'user_id' => $user_id,
|
||||
'lid' => $lid,
|
||||
'day' => $nobility_info['day'],
|
||||
'end_time' => $end_time,
|
||||
'is_renew' => $is_renew,
|
||||
'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;
|
||||
}elseif($is_renew ==2){
|
||||
//剩余时间
|
||||
$old_nobility_info = db::name('vs_nobility')
|
||||
->field('pay_coin')
|
||||
->where('delete_time', 0)
|
||||
->where('lid', $user_nobility_info['lid'])
|
||||
->find();
|
||||
$surplus_time = $user_nobility_info['end_time'] - time();
|
||||
if($surplus_time > 0){
|
||||
//小时
|
||||
$surplus_time_hour = floor($surplus_time / 3600); //向下取整
|
||||
if($nobility_info['pay_coin']!=0 && $nobility_info['day']!=0){
|
||||
$pay_coin = $nobility_info['pay_coin'] - bcmul($surplus_time_hour * (($old_nobility_info['pay_coin'] / $nobility_info['day']) / 24),1,2); //一小时的价格算
|
||||
}
|
||||
}else{
|
||||
$pay_coin = $nobility_info['pay_coin'] ?? 0;
|
||||
}
|
||||
$pay_coin = floor($pay_coin);
|
||||
}else{
|
||||
$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];
|
||||
}
|
||||
}
|
||||
//更新装备缓存
|
||||
$cache_key = 'user_base_info_'.$user_id;
|
||||
Cache::rm($cache_key);
|
||||
return ['code' => 1, 'msg' => '成功'];
|
||||
}
|
||||
|
||||
//购买爵位价格
|
||||
public function buyNobilityPrice($user_id,$lid){
|
||||
$nobility_info = db::name('vs_nobility')
|
||||
->field('lid,name,image,pay_price,renew_price,day,power_ids')
|
||||
->where('delete_time', 0)
|
||||
->where('lid', $lid)
|
||||
->find();
|
||||
if (!$nobility_info) {
|
||||
return ['code' => 0, 'msg' => '爵位不存在', 'data' => null];
|
||||
}
|
||||
$user_info = db::name('user')
|
||||
->field('id,nickname,avatar')
|
||||
->where('delete_time', 0)
|
||||
->where('id', $user_id)
|
||||
->find();
|
||||
if (!$user_info) {
|
||||
return ['code' => 0, 'msg' => '用户不存在', 'data' => null];
|
||||
}
|
||||
$user_nobility_info = db::name('vs_user_nobility')
|
||||
->field('id,user_id,lid,end_time')
|
||||
->where('delete_time', 0)
|
||||
->where(['end_time'=>['>',time()]])
|
||||
->where('user_id', $user_id)
|
||||
->find();
|
||||
$price = 0;
|
||||
if ($user_nobility_info) { //已购买过 续费
|
||||
if($user_nobility_info['lid'] == $lid){ //续费
|
||||
$price = $nobility_info['renew_price'];
|
||||
$end_time = $user_nobility_info['end_time'] + $nobility_info['day'] * 86400;
|
||||
//判断是否可以续费
|
||||
$end_time_to_day = floor(($end_time - time()) / 86400);
|
||||
if($end_time_to_day > $nobility_info['day'] * 2){
|
||||
return ['code' => 0, 'msg' => '已超过2倍有效期,无需续费', 'data' => null];
|
||||
}
|
||||
}else{ //升级
|
||||
$old_nobility_info = db::name('vs_nobility')
|
||||
->field('lid,name,pay_price,pay_coin')
|
||||
->where('delete_time', 0)
|
||||
->where('lid', $user_nobility_info['lid'])
|
||||
->find();
|
||||
$old_end_time = $user_nobility_info['end_time'];
|
||||
//剩余时间
|
||||
$surplus_time = $old_end_time - time();
|
||||
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); //一小时的价格算
|
||||
}
|
||||
}else{
|
||||
$price = $nobility_info['pay_price'];
|
||||
}
|
||||
$end_time = time() + $nobility_info['day'] * 86400;
|
||||
}
|
||||
}else{ //未购买 新购
|
||||
$price = $nobility_info['pay_price'];
|
||||
$end_time = time() + $nobility_info['day'] * 86400;
|
||||
}
|
||||
$power_ids = explode(',', $nobility_info['power_ids']);
|
||||
$power_list = db::name('vs_nobility_power')
|
||||
->field('id,content')
|
||||
->where('delete_time', 0)
|
||||
->where('id', 'in', $power_ids)
|
||||
->select();
|
||||
if(ceil($price) <= 0){
|
||||
return ['code' => 0, 'msg' => "当前权限暂时无法购买此爵位,请升级更高爵位", 'data' => null];
|
||||
}
|
||||
$return = [
|
||||
'lid' => $nobility_info['lid'],
|
||||
'nobility_name' => $nobility_info['name'],
|
||||
'nobility_image' => $nobility_info['image'],
|
||||
'price' => ceil($price),
|
||||
'pay_price' => $nobility_info['pay_price'],
|
||||
'day' => $nobility_info['day'],
|
||||
'power_list' => $power_list,
|
||||
'end_time' => date('Y-m-d H:i:s', $end_time),
|
||||
];
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => $return];
|
||||
}
|
||||
|
||||
//获取用户爵位信息
|
||||
public function getUserNobilityInfo($user_id){
|
||||
$user_nobility_info = db::name('vs_user_nobility')
|
||||
->field('id,user_id,lid,end_time')
|
||||
->where('delete_time', 0)
|
||||
->where('user_id', $user_id)
|
||||
->where('end_time', '>=', time())
|
||||
->find();
|
||||
if($user_nobility_info){
|
||||
$nobility_info = db::name('vs_nobility')
|
||||
->field('lid,name,image,pay_price,renew_price,day,power_ids,nick_name_color,nick_name_color_name,play_image,enter_image')
|
||||
->where('delete_time', 0)
|
||||
->where('lid', $user_nobility_info['lid'])
|
||||
->find();
|
||||
//权限
|
||||
$power_ids = [];
|
||||
if($nobility_info){
|
||||
$power_ids = explode(',', $nobility_info['power_ids']);
|
||||
}
|
||||
$power_list = db::name('vs_nobility_power')
|
||||
->field('id,name,content')
|
||||
->where('delete_time', 0)
|
||||
->where('id', 'in', $power_ids)
|
||||
->select();
|
||||
}
|
||||
$return = [
|
||||
'lid' => $user_nobility_info['lid'] ?? 0,
|
||||
'level' => $user_nobility_info['level'] ?? 0,
|
||||
'nobility_name' => $nobility_info['name'] ?? '',
|
||||
'nobility_image' => $nobility_info['image'] ?? '',
|
||||
'nobility_images' => $nobility_info['images'] ?? '',
|
||||
'nick_name_color' => $nobility_info['nick_name_color'] ?? '',
|
||||
'nick_name_color_name' => $nobility_info['nick_name_color_name'] ?? '',
|
||||
'play_image' => $nobility_info['play_image'] ?? '',
|
||||
'enter_image' => $nobility_info['enter_image'] ?? '',
|
||||
'end_time' => $user_nobility_info['end_time'] ?? 0,
|
||||
'power_list' => $power_list ?? [],
|
||||
];
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
@@ -359,6 +359,7 @@ class Ranking extends Model
|
||||
{
|
||||
$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')
|
||||
@@ -387,7 +388,7 @@ class Ranking extends Model
|
||||
}
|
||||
}
|
||||
|
||||
if (!$my_ranking && $lists && defined('UID')) {
|
||||
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')
|
||||
@@ -398,7 +399,7 @@ class Ranking extends Model
|
||||
->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 = $diff<=0 ? 0 : $diff;
|
||||
$diff = max($diff, 0);
|
||||
$my_ranking['rank'] = -1;
|
||||
$my_ranking['total'] = numberFormat($my_ranking_data['total']);
|
||||
$my_ranking['diff'] = $diff;
|
||||
@@ -424,6 +425,84 @@ class Ranking extends Model
|
||||
$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();
|
||||
|
||||
$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');
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'my_ranking' => $my_ranking,
|
||||
'lists' => $lists
|
||||
];
|
||||
return ['code'=>1,'msg'=>'获取成功','data'=>$data];
|
||||
}
|
||||
|
||||
//真爱榜
|
||||
public function love_rankings()
|
||||
{
|
||||
$lists = db::name('user_cp_zone')->alias('a')
|
||||
->join('user b','a.user_id1 = b.id','left')
|
||||
->join('user c','a.user_id2 = c.id','left')
|
||||
->where(['a.status' => 1])
|
||||
->field('a.exp,a.id,a.level as total,a.user_id1,a.user_id2 as user_id,b.nickname as nickname1,c.nickname as nickname,b.avatar as user_avatar1,c.avatar as user_avatar')
|
||||
->order('a.level desc')
|
||||
->page($this->page, $this->page_limit)
|
||||
->select();
|
||||
$my_ranking = null;
|
||||
if($lists){
|
||||
//获取当前用户的房间id $this->user_id
|
||||
$myRoom = db::name('user_cp_zone')->where(['user_id1' => UID ,'status' => 1])->find();
|
||||
if(!$myRoom){
|
||||
$myRoom = db::name('user_cp_zone')->where(['user_id2' => UID ,'status' => 1])->find();
|
||||
}
|
||||
if($myRoom){
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
if ($myRoom['id'] == $value['id']) {
|
||||
$my_ranking = $lists[$key];
|
||||
$my_ranking['diff'] = $key == 0 ? 0 : ($lists[$key - 1]['exp'] - $value['exp']);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
foreach ($lists as $key => $value) {
|
||||
$lists[$key]['rank'] = $key + 1;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$my_ranking = [
|
||||
'user_id' => UID,
|
||||
'user_id1' => 0,
|
||||
'nickname' => db::name('user')->where(['id' => UID])->value('nickname'),
|
||||
'nickname1' => '',
|
||||
'user_avatar' => db::name('user')->where(['id' => UID])->value('avatar'),
|
||||
'user_avatar1' => '',
|
||||
'exp' => 0,
|
||||
'diff' => 0,
|
||||
'rank' => -1,
|
||||
'total' => 0
|
||||
];
|
||||
}
|
||||
$data = [
|
||||
'my_ranking' => $my_ranking,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -54,8 +54,8 @@ class RoomAuction extends Model
|
||||
}
|
||||
}
|
||||
//查询房间是否正在拍卖
|
||||
$auction = db::name('vs_room_auction')->where('room_id',$room_id)->where('status',2)->find();
|
||||
if($auction){
|
||||
$auctions = db::name('vs_room_auction')->where('room_id',$room_id)->where('status',2)->find();
|
||||
if($auctions){
|
||||
return ['code' => 0, 'msg' => '房间正在竞拍中!请稍后继续','data' => null];
|
||||
}
|
||||
$user_ids = Cache::get('auction_user_'.$room_id);
|
||||
@@ -92,6 +92,7 @@ class RoomAuction extends Model
|
||||
$auction['relation_icon'] = db::name('vs_relation')->where('id',$auction['relation_id'])->value('icon');
|
||||
$auction['base_image'] = db::name('vs_gift')->where('gid',$auction['gift_id'])->value('base_image');
|
||||
$auction['gift_name'] = db::name('vs_gift')->where('gid',$auction['gift_id'])->value('gift_name');
|
||||
$auction['gift_price'] = db::name('vs_gift')->where('gid',$auction['gift_id'])->value('gift_price');
|
||||
$auction['time_day'] = $auction['time_day'] / 60 / 60;
|
||||
}
|
||||
// var_dump($auction);
|
||||
@@ -131,6 +132,7 @@ class RoomAuction extends Model
|
||||
if($ree['code'] != 1){
|
||||
return ['code' => $ree['code'], 'msg' => $ree['msg'],'data' => null];
|
||||
}
|
||||
$list = null;
|
||||
if($auction['status'] == 2){//1未开启 2进行中 3已结束
|
||||
//数据写入数据库
|
||||
$res = db::name('vs_room_auction_bid_log')->insert([
|
||||
@@ -322,6 +324,12 @@ class RoomAuction extends Model
|
||||
if($room_auction['code'] != 1){
|
||||
return ['code' => 0, 'msg'=>$room_auction['msg'], 'data'=>$room_auction['data']];
|
||||
}
|
||||
//查询是否第一次被拍卖成功
|
||||
$is_first = db::name('vs_room_auction')->where(['user_id' => $res['user_id'],'status' => 3,'bidder_user_id' =>['>',0]])->count();
|
||||
if($is_first == 1){
|
||||
//任务:9-第一次拍卖关系
|
||||
model('Tasks')->tasks_complete($res['user_id'],9);
|
||||
}
|
||||
}
|
||||
//拍卖位下麦
|
||||
$host = db::name('vs_room')->where(['id' => $res['room_id']])->value('user_id');
|
||||
@@ -440,10 +448,10 @@ class RoomAuction extends Model
|
||||
public function room_auction_create_or_add($user_id,$user_id1,$relation_id,$time_day,$cp_room_id){
|
||||
//查询两人是否已创建该关系
|
||||
$room = db::name('vs_room_auction_relation')
|
||||
->where(['user_id1' => $user_id,'user_id2' => $user_id1,'relation_id' => $relation_id,'end_time'=>['>',time()]])->order('id desc')->find();
|
||||
->where(['user_id1' => $user_id,'user_id2' => $user_id1,'relation_id' => $relation_id,'end_time'=>['>',time()],'delete_time' => 0])->order('id desc')->find();
|
||||
if(!$room){
|
||||
$room = db::name('vs_room_auction_relation')
|
||||
->where(['user_id2' => $user_id,'user_id1' => $user_id1,'relation_id' => $relation_id,'end_time'=>['>',time()]])->order('id desc')->find();
|
||||
->where(['user_id2' => $user_id,'user_id1' => $user_id1,'relation_id' => $relation_id,'end_time'=>['>',time()],'delete_time' => 0])->order('id desc')->find();
|
||||
}
|
||||
if($room){
|
||||
|
||||
|
||||
78
application/api/model/RoomEmoji.php
Normal file
78
application/api/model/RoomEmoji.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use app\common\controller\Push;
|
||||
use think\Cache;
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class RoomEmoji extends Model
|
||||
{
|
||||
protected $table = 'vs_room_emoji';
|
||||
protected $table_type = 'vs_room_emoji_type';
|
||||
private $redis;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->redis = \think\Cache::store('redis')->handler();
|
||||
}
|
||||
//获取房间表情包类型
|
||||
public function getRoomEmojiType(){
|
||||
$list = db($this->table_type)->field('id,type_name')->where(['status'=>1,'deletetime'=>0])->select();
|
||||
return ['code' => 1, 'msg' => '创建成功', 'data' => $list];
|
||||
}
|
||||
|
||||
//获取房间表情包
|
||||
public function getRoomEmoji($type_id=0,$pid=0, $isTree = false, $user_id = 0){
|
||||
$where = [];
|
||||
if($type_id){
|
||||
$where['type_id'] = $type_id;
|
||||
}
|
||||
if($pid!=""){
|
||||
$where['pid'] = $pid;
|
||||
}
|
||||
$list = db($this->table)
|
||||
->field('id,pid,type_id,name,image,animate_image')
|
||||
->where(['status'=>1,'deletetime'=>0])
|
||||
->where($where)
|
||||
->order('sort desc,id desc')
|
||||
->select();
|
||||
$is_lock = 0;
|
||||
if ($type_id == 3) { // 专属礼物
|
||||
$Nobility = model('api/Nobility')->getUserNobilityInfo($user_id);
|
||||
$power_list_ids = array_column($Nobility['power_list'],'id');
|
||||
if(!in_array(9,$power_list_ids)){
|
||||
$is_lock = 1;
|
||||
}
|
||||
}
|
||||
foreach ($list as &$v) {
|
||||
$v['is_lock'] = $is_lock;
|
||||
}
|
||||
if ($isTree && !empty($list) && empty($pid)) {
|
||||
$list = $this->buildTree($list);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => $list];
|
||||
}
|
||||
|
||||
/**
|
||||
* 将扁平数据转换为树状结构
|
||||
* @param array $data 数据列表
|
||||
* @param int $pid 父级ID
|
||||
* @return array
|
||||
*/
|
||||
private function buildTree($data, $pid = 0)
|
||||
{
|
||||
$tree = [];
|
||||
foreach ($data as $item) {
|
||||
if ($item['pid'] == $pid) {
|
||||
$children = $this->buildTree($data, $item['id']);
|
||||
if (!empty($children)) {
|
||||
$item['children'] = $children;
|
||||
}
|
||||
$tree[] = $item;
|
||||
}
|
||||
}
|
||||
return $tree;
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ use think\Model;
|
||||
class RoomHourRanking extends Model
|
||||
{
|
||||
//房间小时榜
|
||||
public function room_hour_ranking($page, $page_limit,$start_time = null, $end_time = null)
|
||||
public function room_hour_rankings($page, $page_limit,$start_time = null, $end_time = null)
|
||||
{
|
||||
//当前小时开始时间
|
||||
if($start_time == null){
|
||||
@@ -70,4 +70,86 @@ class RoomHourRanking extends Model
|
||||
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'));
|
||||
}
|
||||
|
||||
//结束时间
|
||||
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');
|
||||
// 查询这个时间段内收礼的房间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]];
|
||||
}
|
||||
}
|
||||
@@ -56,12 +56,27 @@ class RoomPit extends Model
|
||||
if(!$on){
|
||||
return ['code' => 0, 'msg' => '上麦失败', 'data' => null];
|
||||
}
|
||||
// $nickname = model('User')->where(['id' => $user_id])->value('nickname');
|
||||
$FromUserInfo = db::name('user')->where('id',$user_id)->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($user_id);//财富图标
|
||||
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($user_id);//魅力图标
|
||||
$FromUserInfo['dress'] = model('Decorate')->user_decorate_detail($user_id,1);
|
||||
|
||||
$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');
|
||||
|
||||
$roomtype = db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
if($roomtype == 10){
|
||||
if($pit_number == 1){
|
||||
$pit_text = '签约麦';
|
||||
}elseif($pit_number == 2){
|
||||
$pit_text = '师父麦';
|
||||
}elseif ($pit_number == 3 || $pit_number == 4 || $pit_number == 5) {
|
||||
$pit_text = '老板麦';
|
||||
}elseif($pit_number == 9){
|
||||
$pit_text = '主持麦';
|
||||
}elseif ($pit_number == 10) {
|
||||
$pit_text = '嘉宾麦';
|
||||
}else{
|
||||
$pit_text = $pit_number . '号麦';
|
||||
}
|
||||
}else{
|
||||
//推送告诉前端上了几号麦位
|
||||
if($pit_number == 9){
|
||||
$pit_text = '主持麦';
|
||||
@@ -75,29 +90,44 @@ class RoomPit extends Model
|
||||
}else{
|
||||
$pit_text = $pit_number . '号麦';
|
||||
}
|
||||
}
|
||||
|
||||
$text['text'] = $FromUserInfo['nickname'].' 上了 ' . $pit_text;
|
||||
$text['FromUserInfo'] = $FromUserInfo;
|
||||
$text['pit_number'] = $pit_number;
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1003,$room_id,$text);
|
||||
if($pit_number == 9){
|
||||
//推送消息给设置此用户开播提醒的人
|
||||
$remind_users = db::name('vs_user_live_remind')->where('remind_user_id' , $user_id)->select('user_id');
|
||||
$remind_user = [];
|
||||
foreach ($remind_users as $k=>$v){
|
||||
$remind_user[$k] = 'u'.$v['user_id'];
|
||||
if($k >= 499){ //批量发单聊消息 最大数500个
|
||||
//结束整个循环
|
||||
break;
|
||||
db::name('vs_room_visitor')->where(['user_id' => $user_id,'room_id' => $room_id])->update(['is_onpit' => 0]);
|
||||
|
||||
//查看此房间是否处于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){
|
||||
$is_pk = db::name('vs_room_pk')->where(['room_id_b' => $room_id])->where(['status' => ['in',[2,3,4]]])->value('room_id_a') ?? 0;
|
||||
}
|
||||
if($is_pk > 0){
|
||||
//如果此房间是pk中,则推送给pk中房间的成员
|
||||
$text['is_pk'] = 1;
|
||||
model('Chat')->sendMsg(1003,$is_pk,$text);
|
||||
}
|
||||
$content = [
|
||||
'type' => 1,
|
||||
'roomID' => $room_id,
|
||||
'content' => '您关注的用户' . $FromUserInfo['nickname'] . '正在直播,快去围观吧!',
|
||||
];
|
||||
model('Tencent')->batchsendmsg($remind_user,json_encode($content));
|
||||
}
|
||||
|
||||
// if($pit_number == 9){
|
||||
// //推送消息给设置此用户开播提醒的人
|
||||
// $remind_users = db::name('vs_user_live_remind')->where('remind_user_id' , $user_id)->select('user_id');
|
||||
// $remind_user = [];
|
||||
// foreach ($remind_users as $k=>$v){
|
||||
// $remind_user[$k] = 'u'.$v['user_id'];
|
||||
// if($k >= 499){ //批量发单聊消息 最大数500个
|
||||
// //结束整个循环
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// $content = [
|
||||
// 'type' => 1,
|
||||
// 'roomID' => $room_id,
|
||||
// 'content' => '您关注的用户' . $FromUserInfo['nickname'] . '正在直播,快去围观吧!',
|
||||
// ];
|
||||
// model('Tencent')->batchsendmsg($remind_user,json_encode($content));
|
||||
// }
|
||||
$reslut = db::name('vs_room_pit_apply')->where(['user_id' => $user_id, 'room_id' => $room_id, 'status' => 0])->delete();
|
||||
if($reslut){
|
||||
$count = db::name('vs_room_pit_apply')->where(['room_id' => $room_id,'status' => 0])->count();
|
||||
@@ -112,20 +142,67 @@ class RoomPit extends Model
|
||||
}
|
||||
|
||||
//用户下麦
|
||||
public function DownPit($user_id,$room_id,$pit_number)
|
||||
public function DownPit($user_id,$room_id,$pit_number,$type = 0)
|
||||
{
|
||||
$roomtype = db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
|
||||
if($roomtype == 2){
|
||||
//获取拍卖位用户
|
||||
if(Cache::get('auction_user_'.$room_id) == $user_id){
|
||||
$auctioning = db::name('vs_room_auction')
|
||||
->where(['room_id' => $room_id, 'status' => 2, 'user_id' => $user_id])->find();
|
||||
if($auctioning) {
|
||||
return ['code' => 0, 'msg' => '拍卖中不能能下麦', 'data' => null];
|
||||
}
|
||||
$pit_number = 888;
|
||||
}else{
|
||||
$pit_number = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id])->value('pit_number');
|
||||
}
|
||||
}else{
|
||||
if(!$pit_number){
|
||||
$pit_number = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id])->value('pit_number');
|
||||
if(!$pit_number){
|
||||
return ['code' => 0, 'msg' => '该用户已不在'.$pit_number.'麦', 'data' => null];
|
||||
return ['code' => 0, 'msg' => '该用户已不在麦上', 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
if($roomtype == 10){
|
||||
if($pit_number == 1){
|
||||
$pit_text = '签约麦';
|
||||
}elseif($pit_number == 2){
|
||||
$pit_text = '师父麦';
|
||||
if($type == 0){
|
||||
return ['code' => 0, 'msg' => '师父麦位不能下麦', 'data' => null];
|
||||
}
|
||||
}elseif ($pit_number == 3 || $pit_number == 4 || $pit_number == 5) {
|
||||
$pit_text = '老板麦';
|
||||
}elseif($pit_number == 9){
|
||||
$pit_text = '主持麦';
|
||||
}elseif ($pit_number == 10) {
|
||||
$pit_text = '嘉宾麦';
|
||||
}else{
|
||||
$pit_text = $pit_number . '号麦';
|
||||
}
|
||||
}else{
|
||||
if($pit_number == 9){
|
||||
$pit_text = '主持麦';
|
||||
}elseif ($pit_number == 10) {
|
||||
$pit_text = '嘉宾麦';
|
||||
}elseif ($pit_number == 888) {
|
||||
$pit_text = '拍卖位';
|
||||
}else{
|
||||
$pit_text = $pit_number . '号麦';
|
||||
}
|
||||
}
|
||||
|
||||
if($pit_number != 888){
|
||||
$where['room_id'] = $room_id;
|
||||
$where['pit_number'] = $pit_number;
|
||||
$where['user_id'] = $user_id;
|
||||
$accept_pit_info = db::name('vs_room_pit')->where($where)->find();
|
||||
if(!$accept_pit_info){
|
||||
return ['code' => 0, 'msg' => '该用户已不在'.$pit_number.'麦', 'data' => null];
|
||||
return ['code' => 0, 'msg' => '该用户已不在'.$pit_text, 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//判断当前房间是否正在pk
|
||||
@@ -140,9 +217,14 @@ class RoomPit extends Model
|
||||
if($step && $step != 1 && $pit_number < 9){
|
||||
return ['code' => 0, 'msg' => '交友房 此阶段不可操作', 'data' => null];
|
||||
}
|
||||
$FromUserInfo = db::name('user')->where('id',$user_id)->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($user_id);//财富图标
|
||||
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($user_id);//魅力图标
|
||||
//在签约麦中不能下麦
|
||||
$room_sign = db::name('vs_room_sign')->where(['room_id' => $room_id, 'sign_type' => 1,'sign_user_id' =>$user_id])->find();
|
||||
if($room_sign && $type == 0){
|
||||
return ['code' => 0, 'msg' => '签约麦 不可下麦', 'data' => null];
|
||||
}
|
||||
|
||||
$FromUserInfo = model('api/User')->get_user_base_info($user_id);
|
||||
|
||||
if($pit_number == 888){
|
||||
$text['text'] = $FromUserInfo['nickname'].' 下了拍卖位 ';
|
||||
$text['type'] = 2 ;
|
||||
@@ -150,17 +232,16 @@ class RoomPit extends Model
|
||||
if($pit_number <= 0){
|
||||
$pit_number = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id])->value('pit_number');
|
||||
}
|
||||
$down = $this->where(['room_id' => $room_id, 'user_id' => $user_id])->update(['user_id' => 0]);
|
||||
//查找所在麦位 然后修改他
|
||||
$pit_info = $this->where(['room_id' => $room_id, 'pit_number' => $pit_number,'user_id' => $user_id])->find();
|
||||
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]);
|
||||
if(!$down){
|
||||
return ['code' => 0, 'msg' => '下麦失败', 'data' => null];
|
||||
}
|
||||
if($pit_number == 9){
|
||||
$pit_text = '主持麦';
|
||||
}elseif ($pit_number == 10) {
|
||||
$pit_text = '嘉宾麦';
|
||||
}else{
|
||||
$pit_text = $pit_number . '号麦';
|
||||
}
|
||||
|
||||
$text['text'] = $FromUserInfo['nickname'].' 下了 ' . $pit_text;
|
||||
}
|
||||
|
||||
@@ -171,6 +252,17 @@ class RoomPit extends Model
|
||||
model('Chat')->sendMsg(1022,$room_id,$text);
|
||||
}else{
|
||||
model('Chat')->sendMsg(1004,$room_id,$text);
|
||||
db::name('vs_room_visitor')->where(['user_id' => $user_id,'room_id' => $room_id])->update(['is_onpit' => 1]);
|
||||
//查看此房间是否处于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){
|
||||
$is_pk = db::name('vs_room_pk')->where(['room_id_b' => $room_id])->where(['status' => ['in',[2,3,4]]])->value('room_id_a') ?? 0;
|
||||
}
|
||||
if($is_pk > 0){
|
||||
//如果此房间是pk中,则推送给pk中房间的成员
|
||||
$text['is_pk'] = 1;
|
||||
model('Chat')->sendMsg(1004,$is_pk,$text);
|
||||
}
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => '下麦成功', 'data' => null];
|
||||
@@ -184,7 +276,7 @@ class RoomPit extends Model
|
||||
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,label_id,step')->find();
|
||||
$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){
|
||||
return ['code' => 0, 'msg' => '房间不存在', 'data' => null];
|
||||
}
|
||||
@@ -192,6 +284,18 @@ class RoomPit extends Model
|
||||
return ['code' => 0, 'msg' => '房间违规或关闭', 'data' => null];
|
||||
}
|
||||
|
||||
$user_singer = db::name('vs_singer')->where(['user_id' => $user_id, 'status' => 1])->find();
|
||||
if($room_info['type_id'] == 9 && !$user_singer && $pit_number < 9){
|
||||
$user_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id])->value('pit_number');
|
||||
if($user_pit){
|
||||
return ['code' => 0, 'msg' => '不是歌手不能换麦', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => '不是歌手不能上麦', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//检查是否在坑位上
|
||||
$pit_infos = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id])->field('id,pit_number')->find();
|
||||
if($pit_number == 9){
|
||||
//检查用户是否是房主或主持
|
||||
$is_room_owner =db::name('vs_room')->where(['id' => $room_id, 'user_id' => $user_id])->field('id')->find();
|
||||
@@ -199,18 +303,32 @@ class RoomPit extends Model
|
||||
if(!$is_room_owner && !$is_room_host){
|
||||
return ['code' => 0, 'msg' => '没有权限', 'data' => null];
|
||||
}
|
||||
if($pit_infos){
|
||||
return ['code' => 0, 'msg' => '您已在麦上', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
if($pit_number == 10){
|
||||
return ['code' => 0, 'msg' => '请等待主持抱麦', 'data' => null];
|
||||
}
|
||||
|
||||
//检查是否在坑位上
|
||||
$pit_infos = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id])->field('id,pit_number')->find();
|
||||
|
||||
if($room_info['label_id'] == 5 && $room_info['step'] != 1 && $pit_number < 9){
|
||||
return ['code' => 0, 'msg' => '互娱房 此阶段不可此操作', 'data' => null];
|
||||
}
|
||||
//签约房间 主持邀请上麦 用户同意邀请后自己上1号麦
|
||||
if($room_info['type_id'] == 10 && $pit_number == 1){
|
||||
$is_user = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => 1])->value('user_id');
|
||||
if($is_user){
|
||||
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];
|
||||
}
|
||||
//删除主持邀请记录
|
||||
db::name('vs_room_sign_invite')->where(['room_id' => $room_id, 'user_id' => $user_id])->delete();
|
||||
return ['code' => 1, 'msg' => '上麦成功', 'data' => null];
|
||||
}
|
||||
|
||||
//自由麦
|
||||
if($room_info['room_up_pit_type'] == 2){
|
||||
@@ -248,16 +366,20 @@ class RoomPit extends Model
|
||||
|
||||
//换麦使用
|
||||
if(isset($pit_infos) && $pit_infos['pit_number'] > 0){
|
||||
//9号麦位不允许换
|
||||
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]);
|
||||
if(!$exchange || !$exchange1){
|
||||
return ['code' => 0, 'msg' => '换麦失败', 'data' => null];
|
||||
}
|
||||
$FromUserInfo = db::name('user')->where('id',$user_id)->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($user_id);//财富图标
|
||||
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($user_id);//魅力图标
|
||||
$FromUserInfo['dress'] = model('Decorate')->user_decorate_detail($user_id,1);
|
||||
|
||||
$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');
|
||||
|
||||
if($pit_number == 9){
|
||||
$pit_text = '主持麦';
|
||||
}elseif ($pit_number == 10) {
|
||||
@@ -270,6 +392,16 @@ class RoomPit extends Model
|
||||
$text['from_pit_number'] = $pit_infos['pit_number'];
|
||||
$text['to_pit_number'] = $pit_number;
|
||||
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){
|
||||
$is_pk = db::name('vs_room_pk')->where(['room_id_b' => $room_id])->where(['status' => ['in',[2,3,4]]])->value('room_id_a') ?? 0;
|
||||
}
|
||||
if($is_pk > 0){
|
||||
//如果此房间是pk中,则推送给pk中房间的成员
|
||||
$text['is_pk'] = 1;
|
||||
model('Chat')->sendMsg(1039,$is_pk,$text);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '上麦成功', 'data' => null];
|
||||
}else{
|
||||
$ompit = $this->OnPit($user_id,$room_id,$pit_number);//用户上了这个房间的几号麦位
|
||||
@@ -289,15 +421,17 @@ class RoomPit extends Model
|
||||
}
|
||||
}else{
|
||||
if(isset($pit_infos) && $pit_infos['pit_number'] > 0){
|
||||
if($room_info['type_id'] == 10){
|
||||
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]);
|
||||
if(!$exchange || !$exchange1){
|
||||
return ['code' => 0, 'msg' => '换麦失败', 'data' => null];
|
||||
}
|
||||
$FromUserInfo = db::name('user')->where('id',$user_id)->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($user_id);//财富图标
|
||||
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($user_id);//魅力图标
|
||||
$FromUserInfo['dress'] = model('Decorate')->user_decorate_detail($user_id,1);
|
||||
|
||||
$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');
|
||||
|
||||
$text['text'] = $FromUserInfo['nickname'].' 换到主持麦 ';
|
||||
@@ -361,12 +495,53 @@ class RoomPit extends Model
|
||||
'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();
|
||||
foreach ($list['regular'] as $k => $v){
|
||||
//查询用户的爵位
|
||||
$jue_wei = model('Nobility')->getUserNobilityInfo($v['user_id']);
|
||||
if($jue_wei['power_list']){
|
||||
foreach ($jue_wei['power_list'] as $k1 => $v1){
|
||||
if($v1['id'] == 11){
|
||||
$special = $list['regular'][$k];
|
||||
unset($list['regular'][$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//数组重组
|
||||
$list['regular'] = array_values($list['regular']);
|
||||
|
||||
$list['special'] = db::name('vs_room_pit_apply')->alias('a')->join('user b','a.user_id = b.id')
|
||||
->where($where)->where('a.type',1)->field('a.user_id,a.rank_value,b.nickname,b.avatar')
|
||||
->order('a.rank_value desc')->select();
|
||||
if(!empty($special)){
|
||||
//把特殊用户放在最前面
|
||||
array_unshift($list['special'],$special);
|
||||
}
|
||||
if($list['special']){
|
||||
foreach ($list['special'] as $k => $v){
|
||||
//查询用户的爵位
|
||||
$juewei = model('Nobility')->getUserNobilityInfo($v['user_id']);
|
||||
if($juewei){
|
||||
$v['jue_wei'] = $juewei;
|
||||
}else{
|
||||
$v['jue_wei'] = [
|
||||
'level' => 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
//先根据$v['jue_wei'] 下面的level 由大到小排序,再根据$v['rank_value'] 由大到小排序level
|
||||
usort($list['special'], function($a, $b) {
|
||||
if ($a['jue_wei']['level'] == $b['jue_wei']['level']) {
|
||||
return $b['rank_value'] - $a['rank_value'];
|
||||
}
|
||||
return $b['jue_wei']['level'] - $a['jue_wei']['level'];
|
||||
});
|
||||
}
|
||||
|
||||
$list['gift_info'] = db::name('vs_room_pit_apply_help_gift')->where('room_id',$room_id)->find();
|
||||
if($list['gift_info']){
|
||||
$list['gift_info']['gift_name'] = db::name('vs_gift')->where('gid',$list['gift_info']['gift_id'])->value('gift_name');
|
||||
@@ -451,7 +626,7 @@ class RoomPit extends Model
|
||||
}
|
||||
|
||||
//同意上麦
|
||||
public function agree_pit($user_id,$room_id,$apply_id)
|
||||
public function agree_pit($user_id,$room_id,$apply_id,$tpe = 0)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
@@ -471,6 +646,8 @@ class RoomPit extends Model
|
||||
$apply_type = 3;//拍卖
|
||||
}elseif($room_type == 7){
|
||||
$apply_type = 7;//交友
|
||||
}elseif($room_type == 10){
|
||||
$apply_type = 10;//签约
|
||||
}else{
|
||||
$apply_type = 1;//聊天
|
||||
}
|
||||
@@ -537,11 +714,14 @@ class RoomPit extends Model
|
||||
//结束循环
|
||||
break;
|
||||
}
|
||||
if($tpe == 0){
|
||||
//删除他的申请上麦
|
||||
$reslut = db::name('vs_room_pit_apply')->where(['user_id' => $value, 'room_id' => $room_id, 'status' => 0])->delete();
|
||||
if (!$reslut) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$ompit = db::name('vs_room_pit_simulate')->insert(
|
||||
[
|
||||
'room_id' => $room_id,
|
||||
@@ -553,14 +733,14 @@ class RoomPit extends Model
|
||||
continue;
|
||||
}
|
||||
//聊天室推送系统消息
|
||||
$FromUserInfo = db::name('user')->where('id',$value)->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($value);//财富图标
|
||||
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($value);//魅力图标
|
||||
$FromUserInfo['dress'] = model('Decorate')->user_decorate_detail($value,1);
|
||||
$FromUserInfo = model('api/User')->get_user_base_info($value);
|
||||
$FromUserInfo['is_online'] = db::name('vs_room_visitor')->where(['user_id' => $value,'room_id' => $room_id])->value('is_online');
|
||||
|
||||
$text['text'] = $FromUserInfo['nickname'].' 上麦了 ';
|
||||
$text['FromUserInfo'] = $FromUserInfo;
|
||||
$text['pit_number'] = 9999;
|
||||
model('Chat')->sendMsg(1003,$room_id,$text);
|
||||
db::name('vs_room_visitor')->where(['user_id' => $value,'room_id' => $room_id])->update(['is_onpit' => 0]);
|
||||
//1-禁麦位,2-清空消息,3-清空魅力值,4-加入黑名单,5-踢出房间,6-关闭麦克风,7-申请上麦,8-同意上麦,9-拒绝上麦,10-点歌,11-开启PK',
|
||||
model('Room')->room_operation_record($user_id,$room_id,8,$value);
|
||||
}
|
||||
@@ -598,10 +778,10 @@ class RoomPit extends Model
|
||||
// }
|
||||
Cache::set('auction_user_'.$room_id,$value);
|
||||
//聊天室推送系统消息
|
||||
$FromUserInfo = db::name('user')->where('id',$value)->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($value);//财富图标
|
||||
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($value);//魅力图标
|
||||
$FromUserInfo['dress'] = model('Decorate')->user_decorate_detail($value,1);
|
||||
|
||||
$FromUserInfo = model('api/User')->get_user_base_info($value);
|
||||
$FromUserInfo['is_online'] = db::name('vs_room_visitor')->where(['user_id' => $value,'room_id' => $room_id])->value('is_online');
|
||||
|
||||
$text['text'] = $FromUserInfo['nickname'].' 上了拍卖位 ';
|
||||
$text['FromUserInfo'] = $FromUserInfo;
|
||||
$text['pit_number'] = 888;
|
||||
@@ -657,6 +837,45 @@ class RoomPit extends Model
|
||||
];
|
||||
model('Chat')->sendMsg(1034,$room_id,$text);
|
||||
return ['code' => 1, 'msg' => $i . '位用户上麦成功', 'data' => null];
|
||||
}elseif($apply_type == 10){
|
||||
//(签约房:1号麦位是 被签约者【徒弟麦】,2号麦位是【师傅麦位】3、4、5是老板麦位,9号是主持位)
|
||||
$uid = $to_user[0];
|
||||
//查询是否已经上麦
|
||||
$on_pit_number = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $uid])->value('pit_number');
|
||||
if ($on_pit_number >= 1) {
|
||||
return ['code' => 0, 'msg' => '用户已在麦上', 'data' => null];
|
||||
}
|
||||
//查询1号麦位是否有人
|
||||
$is_one_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => 1])->value('user_id');
|
||||
if ($is_one_pit) {
|
||||
return ['code' => 0, 'msg' => '麦位上有人', 'data' => null];
|
||||
}
|
||||
$OnPit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => 1])->update(['user_id' => $uid]);
|
||||
if(!$OnPit){
|
||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||
}
|
||||
//制造上麦信息
|
||||
$FromUserInfo = model('api/User')->get_user_base_info($uid);
|
||||
$FromUserInfo['is_online'] = db::name('vs_room_visitor')->where(['user_id' => $uid,'room_id' => $room_id])->value('is_online');
|
||||
$FromUserInfo['charm'] = db::name('vs_room_user_charm')->where(['user_id' => $uid,'room_id' => $room_id])->value('charm');
|
||||
//推送告诉前端上了几号麦位
|
||||
$text['text'] = $FromUserInfo['nickname'].' 上了签约麦位';
|
||||
$text['FromUserInfo'] = $FromUserInfo;
|
||||
$text['pit_number'] = 1;
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1003,$room_id,$text);
|
||||
db::name('vs_room_visitor')->where(['user_id' => $uid,'room_id' => $room_id])->update(['is_onpit' => 0]);
|
||||
|
||||
//删除他的申请上麦
|
||||
db::name('vs_room_pit_apply')->where(['user_id' => $uid, 'room_id' => $room_id, 'status' => 0])->delete();
|
||||
$count = db::name('vs_room_pit_apply')->where(['room_id' => $room_id,'status' => 0])->count();
|
||||
//申请上麦推送消息
|
||||
$text = [
|
||||
'text' => '申请上麦',
|
||||
'count' => $count
|
||||
];
|
||||
model('Chat')->sendMsg(1034,$room_id,$text);
|
||||
return ['code' => 1, 'msg' => '1位用户上麦成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
return ['code' => 0, 'msg' => '请选择申请上麦的用户', 'data' => null];
|
||||
@@ -724,6 +943,12 @@ class RoomPit extends Model
|
||||
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)) {
|
||||
return ['code' => 0, 'msg' => '礼物不能是CP礼物,请重新选择', 'data' => null];
|
||||
}
|
||||
|
||||
if(!$gift_price){
|
||||
$gift_price = db::name('vs_gift')->where(['gid' => $gift_id])->value('gift_price');
|
||||
}
|
||||
@@ -780,8 +1005,8 @@ class RoomPit extends Model
|
||||
if($pit_type == 1){
|
||||
//房间模式
|
||||
$room_type = db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
if($room_type == 2){
|
||||
return ['code' => 0, 'msg' => '房间模式下,不允许切换麦位模式', 'data' => null];
|
||||
if($room_type == 2 || $room_type == 10){
|
||||
return ['code' => 0, 'msg' => '该房间模式下,不允许切换上麦模式', 'data' => null];
|
||||
}
|
||||
$type = 2;
|
||||
}else{
|
||||
@@ -798,6 +1023,7 @@ class RoomPit extends Model
|
||||
//推送消息给前端
|
||||
$text['room_up_pit_type'] = $type;
|
||||
model('Chat')->sendMsg(1014,$room_id,$text);
|
||||
Cache::rm('room_info_'.$room_id);
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}
|
||||
|
||||
@@ -813,7 +1039,105 @@ class RoomPit extends Model
|
||||
return ['code' => 0, 'msg' => '请选择用户', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
$room_type = db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
if($type == 1){//抱麦
|
||||
//判断该用户是否在主持麦上
|
||||
$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 ['code' => 0, 'msg' => '您不在主持麦位上', 'data' => null];
|
||||
}
|
||||
$accept_user_is_on_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $accept_user_id])->find();
|
||||
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];
|
||||
}
|
||||
$room_label = db::name('vs_room')->where(['id' => $room_id])->value('label_id');
|
||||
if($room_type == 1 && $room_label == 2 && !$pit_number){
|
||||
$res = model('RoomPit')->agree_pit($user_id, $room_id, $accept_user_id,1);
|
||||
if($res['code'] == 0){
|
||||
return ['code' => 0, 'msg' => $res['msg'], 'data' => null];
|
||||
}
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}
|
||||
if($room_type == 10){
|
||||
if($pit_number == 1){
|
||||
//查询主持邀请列表是否是有数据
|
||||
$is_invite = db::name('vs_room_sign_invite')->where(['room_id' => $room_id,'createtime' => ['>',time() - 5]])->find();
|
||||
if($is_invite){
|
||||
return ['code' => 0, 'msg' => '5秒内已经有人邀请了,请勿重复邀请', 'data' => null];
|
||||
}
|
||||
$is_user = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => 1])->value('user_id');
|
||||
if($is_user){
|
||||
return ['code' => 0, 'msg' => '签约买上已经有用户', 'data' => null];
|
||||
}
|
||||
//添加到主持邀请列表
|
||||
$data = [
|
||||
'user_id' => $accept_user_id,
|
||||
'room_id' => $room_id,
|
||||
'createtime' => time(),
|
||||
];
|
||||
$reslut = db::name('vs_room_sign_invite')->insert($data);
|
||||
if(!$reslut){
|
||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||
}
|
||||
$text['user_id'] = $accept_user_id;
|
||||
$text['text'] = '主持正在抱您上签约麦呢,您是否同意?';
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1094,$room_id,$text);
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}
|
||||
//$pit_number没有值 只能是抱老板位、3、4、5
|
||||
if(!$pit_number){
|
||||
$pit_number = $this->getRoomNullPitWithout($room_id, [1,2,6,7,8,9,10]);
|
||||
if(!$pit_number){
|
||||
return ['code' => 0, 'msg' => '没有空位了', 'data' => null];
|
||||
}
|
||||
}
|
||||
//麦位上否有人
|
||||
$on_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_number])->value('user_id');
|
||||
if($on_pit){
|
||||
return ['code' => 0, 'msg' => '麦位有人', 'data' => null];
|
||||
}
|
||||
$OnPit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_number])->update(['user_id' => $accept_user_id]);
|
||||
if(!$OnPit){
|
||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||
}
|
||||
//制造上麦信息
|
||||
$FromUserInfo = model('api/User')->get_user_base_info($accept_user_id);
|
||||
$FromUserInfo['is_online'] = db::name('vs_room_visitor')->where(['user_id' => $accept_user_id,'room_id' => $room_id])->value('is_online');
|
||||
$FromUserInfo['charm'] = db::name('vs_room_user_charm')->where(['user_id' => $accept_user_id,'room_id' => $room_id])->value('charm');
|
||||
|
||||
//推送告诉前端上了几号麦位
|
||||
if($pit_number == 1){
|
||||
$pit_text = '签约麦';
|
||||
}else{
|
||||
$pit_text = '老板麦';
|
||||
}
|
||||
$text['text'] = $FromUserInfo['nickname'].' 上了 ' . $pit_text;
|
||||
$text['FromUserInfo'] = $FromUserInfo;
|
||||
$text['pit_number'] = $pit_number;
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1003,$room_id,$text);
|
||||
db::name('vs_room_visitor')->where(['user_id' => $accept_user_id,'room_id' => $room_id])->update(['is_onpit' => 0]);
|
||||
|
||||
//查找当前用户是否有申请上麦 有就删掉
|
||||
$is_apply_pit = db::name('vs_room_pit_apply')->where(['room_id' => $room_id, 'user_id' => $accept_user_id])->find();
|
||||
if($is_apply_pit){
|
||||
db::name('vs_room_pit_apply')->where(['room_id' => $room_id, 'user_id' => $accept_user_id])->delete();
|
||||
}
|
||||
|
||||
$count = db::name('vs_room_pit_apply')->where(['room_id' => $room_id,'status' => 0])->count();
|
||||
//申请上麦推送消息
|
||||
$text = [
|
||||
'text' => '申请上麦',
|
||||
'count' => $count
|
||||
];
|
||||
model('Chat')->sendMsg(1034,$room_id,$text);
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}
|
||||
if($pit_number == 10){
|
||||
$on_9_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => 9])->value('user_id');
|
||||
if($on_9_pit != $user_id){
|
||||
@@ -833,24 +1157,40 @@ class RoomPit extends Model
|
||||
if(Cache::get('auction_user_'.$room_id)){
|
||||
return ['code' => 0, 'msg' => '拍卖位上已有人,请先抱对方下麦', 'data' => null];
|
||||
}else{
|
||||
$FromUserInfo = db::name('user')->where('id',$accept_user_id)->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$FromUserInfo['icon'][0] = model('api/UserData')->user_wealth_icon($accept_user_id);//财富图标
|
||||
$FromUserInfo['icon'][1] = model('api/UserData')->user_charm_icon($accept_user_id);//魅力图标
|
||||
$FromUserInfo['dress'] = model('api/Decorate')->user_decorate_detail($accept_user_id,1);
|
||||
$FromUserInfo = model('api/User')->get_user_base_info($accept_user_id);
|
||||
$FromUserInfo['is_online'] = db::name('vs_room_visitor')->where(['user_id' => $accept_user_id,'room_id' => $room_id])->value('is_online');
|
||||
$FromUserInfo['charm'] = db::name('vs_room_user_charm')->where(['room_id' => $room_id, 'user_id' => $accept_user_id])->value('charm');
|
||||
//推送告诉前端上了几号麦位
|
||||
$text['text'] = $FromUserInfo['nickname'].' 上了拍卖位 ';
|
||||
$text['FromUserInfo'] = $FromUserInfo;
|
||||
$text['pit_number'] = $pit_number;
|
||||
$text['pit_number'] = 888;
|
||||
$text['type'] = 1 ;
|
||||
//聊天室推送系统消息
|
||||
model('api/Chat')->sendMsg(1022,$room_id,$text);
|
||||
Cache::set('auction_user_'.$room_id,$accept_user_id);
|
||||
//查找当前用户是否有申请上麦 有就删掉
|
||||
$is_apply_pit = db::name('vs_room_pit_apply')->where(['room_id' => $room_id, 'user_id' => $accept_user_id])->find();
|
||||
if($is_apply_pit){
|
||||
db::name('vs_room_pit_apply')->where(['room_id' => $room_id, 'user_id' => $accept_user_id])->delete();
|
||||
}
|
||||
|
||||
$count = db::name('vs_room_pit_apply')->where(['room_id' => $room_id,'status' => 0])->count();
|
||||
//申请上麦推送消息
|
||||
$text = [
|
||||
'text' => '申请上麦',
|
||||
'count' => $count
|
||||
];
|
||||
model('Chat')->sendMsg(1034,$room_id,$text);
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
if($room_type == 7){
|
||||
//查询当前空麦位
|
||||
$empty_pit = $this->getRoomNullPitWithout($room_id, [7,8,9, 10]);
|
||||
}else{
|
||||
$empty_pit = $this->getRoomNullPitWithout($room_id, [9, 10]);
|
||||
}
|
||||
|
||||
if(!$empty_pit){
|
||||
return ['code' => 0, 'msg' => '没有空麦位', 'data' => null];
|
||||
}else{
|
||||
@@ -858,10 +1198,8 @@ class RoomPit extends Model
|
||||
}
|
||||
}else{
|
||||
if($pit_number == 888){
|
||||
$FromUserInfo = db::name('user')->where('id',$accept_user_id)->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$FromUserInfo['icon'][0] = model('api/UserData')->user_wealth_icon($accept_user_id);//财富图标
|
||||
$FromUserInfo['icon'][1] = model('api/UserData')->user_charm_icon($accept_user_id);//魅力图标
|
||||
$FromUserInfo['dress'] = model('api/Decorate')->user_decorate_detail($accept_user_id,1);
|
||||
$FromUserInfo = model('api/User')->get_user_base_info($accept_user_id);
|
||||
$FromUserInfo['is_online'] = db::name('vs_room_visitor')->where(['user_id' => $accept_user_id,'room_id' => $room_id])->value('is_online');
|
||||
$FromUserInfo['charm'] = db::name('vs_room_user_charm')->where(['room_id' => $room_id, 'user_id' => $accept_user_id])->value('charm');
|
||||
//推送告诉前端上了几号麦位
|
||||
$text['text'] = $FromUserInfo['nickname'].' 上了拍卖位 ';
|
||||
@@ -871,6 +1209,19 @@ class RoomPit extends Model
|
||||
//聊天室推送系统消息
|
||||
model('api/Chat')->sendMsg(1022,$room_id,$text);
|
||||
Cache::set('auction_user_'.$room_id,$accept_user_id);
|
||||
//查找当前用户是否有申请上麦 有就删掉
|
||||
$is_apply_pit = db::name('vs_room_pit_apply')->where(['room_id' => $room_id, 'user_id' => $accept_user_id])->find();
|
||||
if($is_apply_pit){
|
||||
db::name('vs_room_pit_apply')->where(['room_id' => $room_id, 'user_id' => $accept_user_id])->delete();
|
||||
}
|
||||
|
||||
$count = db::name('vs_room_pit_apply')->where(['room_id' => $room_id,'status' => 0])->count();
|
||||
//申请上麦推送消息
|
||||
$text = [
|
||||
'text' => '申请上麦',
|
||||
'count' => $count
|
||||
];
|
||||
model('Chat')->sendMsg(1034,$room_id,$text);
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}
|
||||
//判断当前麦位是否为空
|
||||
@@ -907,9 +1258,17 @@ class RoomPit extends Model
|
||||
if(!model('QuanXian')->quan_xian($user_id, $accept_user_id, $room_id)){
|
||||
return ['code' => 0, 'msg' => '您没有权限操作', 'data' => null];
|
||||
}
|
||||
|
||||
//获取被踢用户的爵位信息
|
||||
$user_jue_info = model('api/Nobility')->getUserNobilityInfo($accept_user_id);
|
||||
foreach ($user_jue_info['power_list'] as $key => $value){
|
||||
if($value['id'] == 7){
|
||||
return ['code' => 0, 'msg' => '该用户已是'.$user_jue_info['nobility_name'].'爵位,不能踢', 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$pit_number || $pit_number == 888){
|
||||
if(!$pit_number || $pit_number == 888 || $pit_number == 9999){
|
||||
$roomInfo = db::name('vs_room')->where('id',$room_id)->field('label_id,type_id')->find();
|
||||
if($roomInfo['type_id'] == 2 || Cache::get('auction_user_'.$room_id)){//拍卖
|
||||
//查询当前是否处于拍卖中
|
||||
@@ -930,7 +1289,7 @@ class RoomPit extends Model
|
||||
//推送告诉前端下了几号麦位
|
||||
$text['text'] = $FromUserInfo['nickname'].' 下了拍卖位 ';
|
||||
$text['FromUserInfo'] = $FromUserInfo;
|
||||
$text['pit_number'] = $pit_number;
|
||||
$text['pit_number'] = 888;
|
||||
$text['type'] = 2 ;
|
||||
model('api/Chat')->sendMsg(1022,$room_id,$text);
|
||||
}
|
||||
@@ -940,7 +1299,28 @@ class RoomPit extends Model
|
||||
return ['code' => 0, 'msg' => $res['msg'], 'data' => null];
|
||||
}
|
||||
}
|
||||
if($room_type == 10){
|
||||
$pit_numbers = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $accept_user_id])->value('pit_number');
|
||||
if($pit_numbers == 2){
|
||||
return ['code' => 0, 'msg' => '师傅麦 此阶段不可操作', 'data' => null];
|
||||
}
|
||||
//在签约麦中不能下麦
|
||||
$room_sign = db::name('vs_room_sign')->where(['room_id' => $room_id, 'sign_type' => 1,'sign_user_id' =>$user_id])->find();
|
||||
if($room_sign){
|
||||
return ['code' => 0, 'msg' => '签约麦 不可下麦', 'data' => null];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if($room_type == 10){
|
||||
if($pit_number == 2){
|
||||
return ['code' => 0, 'msg' => '师傅麦 此阶段不可操作', 'data' => null];
|
||||
}
|
||||
//在签约麦中不能下麦
|
||||
$room_sign = db::name('vs_room_sign')->where(['room_id' => $room_id, 'sign_type' => 1,'sign_user_id' =>$accept_user_id])->find();
|
||||
if($room_sign){
|
||||
return ['code' => 0, 'msg' => '签约麦 不可下麦', 'data' => null];
|
||||
}
|
||||
}
|
||||
$step = db::name('vs_room')->where(['id' => $room_id, 'type_id' => 7])->value('step');
|
||||
if($step && $step != 1 && $pit_number < 9){
|
||||
return ['code' => 0, 'msg' => '交友房 此阶段不可操作', 'data' => null];
|
||||
@@ -963,4 +1343,15 @@ class RoomPit extends Model
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
//签约房间主持邀请上签约麦用户拒绝
|
||||
public function refuse_sign_room_host_invite($user_id, $room_id)
|
||||
{
|
||||
$res = db::name('vs_room_sign_invite')->where(['user_id' => $user_id, 'room_id' => $room_id])->delete();
|
||||
if(!$res){
|
||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||
}
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -200,6 +200,9 @@ class RoomPk extends Model
|
||||
db::commit();
|
||||
//发送消息给对方
|
||||
if($type == 1){//1接受,2拒绝
|
||||
//把房间记录为不接受PK状态
|
||||
db::name('vs_room')->where('id', $pk_info['room_id_a'])->update(['is_pk' => 2,'updatetime' => time()]);
|
||||
db::name('vs_room')->where('id', $pk_info['room_id_b'])->update(['is_pk' => 2,'updatetime' => time()]);
|
||||
$texta = [
|
||||
'type' => $type,
|
||||
'room_id' => $pk_info['room_id_b'],
|
||||
@@ -287,7 +290,7 @@ class RoomPk extends Model
|
||||
'a.is_show_room' => 1,
|
||||
'b.pit_number' => 9,
|
||||
'b.user_id' => ['<>',0],
|
||||
'a.type_id' => ['in',[1,3,4]],
|
||||
'a.type_id' => ['in',[1,3,4,8]],
|
||||
'a.label_id' => 1,
|
||||
];
|
||||
|
||||
@@ -331,7 +334,7 @@ class RoomPk extends Model
|
||||
}else{
|
||||
//查询pk信息现在在哪个阶段
|
||||
if($pk_info['status'] == 4){
|
||||
if($pk_info['shibaifang_id'] == $user_id){
|
||||
if($pk_info['shibaifang_id'] == $user_id && $pk_info['shibaifang_id'] != 0){
|
||||
$data = [
|
||||
'status' => 7,//1-申请,2-链接中,3-PK进行中,4-已结束(惩罚阶段),5-拒绝 -6断开链接 7-败方申请断开链接',
|
||||
'close_time' => time(),
|
||||
@@ -523,6 +526,11 @@ class RoomPk extends Model
|
||||
model('Chat')->sendMsg(1033,$pk_info['room_id_a'],$text);
|
||||
model('Chat')->sendMsg(1033,$pk_info['room_id_b'],$text);
|
||||
}
|
||||
if($pk_info['status'] == 6){
|
||||
//把房间记录为不接受PK状态
|
||||
db::name('vs_room')->where('id', $pk_info['room_id_a'])->update(['is_pk' => 1,'updatetime' => time()]);
|
||||
db::name('vs_room')->where('id', $pk_info['room_id_b'])->update(['is_pk' => 1,'updatetime' => time()]);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => ''];
|
||||
} else {
|
||||
return ['code' => 0, 'msg' => '失败', 'data' => ''];
|
||||
|
||||
@@ -77,33 +77,58 @@ class RoomSong extends Model
|
||||
}else{
|
||||
return ['code'=>0,'msg'=>'点歌中!请稍后再试!','data'=>null];
|
||||
}
|
||||
return ['code'=>0,'msg'=>'系统繁忙!请稍后再试!','data'=>null];
|
||||
}
|
||||
|
||||
|
||||
//同意点歌
|
||||
public function agree_song($user_id,$room_id,$type){
|
||||
//判断用户是否在主持麦
|
||||
$host_id = db::name('vs_room_pit')->where(['room_id' => $room_id,'user_id' => $user_id])->value('pit_number');
|
||||
if($host_id != 9){
|
||||
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();
|
||||
if(!$owner && !$host){
|
||||
return ['code' => 0, 'msg' => '没有权限操作', 'data' => null];
|
||||
}
|
||||
$res1 = db::name('vs_room')->where('id',$room_id)->where(['label_id'=>2,'is_song'=>3])->find();
|
||||
if($res1){
|
||||
return ['code'=>0,'msg'=>'点歌中!请稍后再试!','data'=>null];
|
||||
|
||||
//此房间类型为特殊存在,修改房间类型的时候 要判断一下条件
|
||||
$roomInfo = db::name('vs_room')->where(['id' => $room_id])->find();
|
||||
if($roomInfo['type_id'] == 1 && $roomInfo['label_id'] == 2){
|
||||
return ['code' => 0, 'msg' => '房间类型已存在', 'data' => null];
|
||||
}
|
||||
|
||||
if($roomInfo['type_id'] == 7 && ($roomInfo['step'] == 2 || $roomInfo['step'] == 3)){
|
||||
return ['code' => 0, 'msg' => '请先结束交友后在修改房间类型', 'data' => null];
|
||||
}
|
||||
|
||||
if($roomInfo['type_id'] == 2){
|
||||
$room_auction = db::name('vs_room_auction')->where(['room_id' => $room_id,'status' => 2])->select();
|
||||
if($room_auction){
|
||||
return ['code' => 0, 'msg' => '请先结束竞拍后在修改房间类型', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
if($roomInfo['type_id'] == 9){
|
||||
db::name('vs_song_log')->where(['room_id' => $room_id,'status' => ['<>',2]])->update(['status' => 2]);
|
||||
}
|
||||
|
||||
if($roomInfo['type_id'] == 10 && $roomInfo['sign_type'] != 0){
|
||||
return ['code' => 0, 'msg' => '请先结束签约后在修改房间类型', 'data' => null];
|
||||
}
|
||||
|
||||
// $res1 = db::name('vs_room')->where('id',$room_id)->where(['label_id'=>2,'is_song'=>3])->find();
|
||||
// if($res1){
|
||||
// return ['code'=>0,'msg'=>'点歌中!请稍后再试!','data'=>null];
|
||||
// }
|
||||
if($type == 1){//1同意 2拒绝
|
||||
//开启事务
|
||||
db::startTrans();
|
||||
$res2 = db::name('vs_room')->where('id',$room_id)->field('room_up_pit_type')->find();
|
||||
if($res2['room_up_pit_type'] == 2){
|
||||
$data['room_up_pit_type'] = 1;
|
||||
}
|
||||
//修改房间label
|
||||
$data['type_id'] = 1;
|
||||
$data['label_id'] = 2;
|
||||
$data['is_song'] = 3;
|
||||
$res = db::name('vs_room')->where('id',$room_id)->update($data);
|
||||
if(!$res){
|
||||
db::rollback();
|
||||
return ['code'=>0,'msg'=>'操作失败,','data'=>null];
|
||||
}
|
||||
|
||||
@@ -115,28 +140,7 @@ class RoomSong extends Model
|
||||
model('RoomPit')->DownPit($v['user_id'],$room_id,$v['pit_number']);
|
||||
}
|
||||
}
|
||||
|
||||
//获取房间麦位
|
||||
// $roomPit = db::name('vs_room_pit')->where(['room_id' => $room_id])->count();
|
||||
// if($roomPit == 10){
|
||||
// //麦位增加到22个
|
||||
// $add_pit = model('RoomPit')->create_room_pit(2,$room_id);
|
||||
// if($add_pit['code'] == 0){
|
||||
// Db::rollback();
|
||||
// return ['code' => 0, 'msg' => '操作失败了', 'data' => null];
|
||||
// }
|
||||
// }elseif($roomPit == 22){
|
||||
// //开启11-22麦位
|
||||
// $pit_up = db::name('vs_room_pit')->where(['room_id' => $room_id])
|
||||
// ->where('pit_number','>',10)
|
||||
// ->update(['status'=>1]);
|
||||
// if(!$pit_up){
|
||||
// Db::rollback();
|
||||
// return ['code' => 0, 'msg' => '操作失败了.', 'data' => null];
|
||||
// }
|
||||
// }
|
||||
|
||||
db::commit();
|
||||
Cache::rm('room_info_'.$room_id);
|
||||
//推送消息
|
||||
$text = [
|
||||
'text' => '房间类型变成k歌--2'
|
||||
@@ -159,8 +163,8 @@ class RoomSong extends Model
|
||||
}
|
||||
}
|
||||
//删除申请缓存
|
||||
Cache::rm('apply_song_time_'.$room_id);
|
||||
Cache::rm('apply_song_user_'.$room_id);
|
||||
// Cache::rm('apply_song_time_'.$room_id);
|
||||
// Cache::rm('apply_song_user_'.$room_id);
|
||||
return ['code'=>1,'msg'=>'操作成功','data'=>null];
|
||||
}
|
||||
|
||||
@@ -351,7 +355,7 @@ class RoomSong extends Model
|
||||
}
|
||||
|
||||
//切歌
|
||||
public function change_song($room_id,$now_room_song_id){
|
||||
public function change_song($room_id,$now_room_song_id,$is_auto_next = 0){
|
||||
//根据传过来的参数查询当前场次
|
||||
$times = db::name('vs_room_song')->where('did',$now_room_song_id)->value('times');
|
||||
//查询下一首歌曲
|
||||
@@ -359,6 +363,11 @@ class RoomSong extends Model
|
||||
->order('sort desc')->select();
|
||||
//结束本首歌
|
||||
$now_song = db::name('vs_room_song')->where('did',$now_room_song_id)->update(['status'=>3]);
|
||||
if($is_auto_next == 1){
|
||||
$uid = db::name('vs_room_song')->where('did',$now_room_song_id)->value('user_id');
|
||||
//任务:33-每日增加练歌房唱5首歌
|
||||
model('Tasks')->tasks_complete($uid,33);
|
||||
}
|
||||
if(empty($data)){
|
||||
Cache::rm("api:room:song:nextInfo:" . $room_id);
|
||||
$text = [
|
||||
@@ -368,6 +377,13 @@ class RoomSong extends Model
|
||||
'nextInfo' => null
|
||||
];
|
||||
model('Chat')->sendMsg(1013,$room_id,$text);
|
||||
db::name('vs_room_song')->where(['room_id' => $room_id,'times_status' => 1,'status' => 1])->update(['status'=>4]);
|
||||
if(db::name('vs_room_song')->where(['room_id' => $room_id,'times_status' => 1,'status' => 2])->find()){
|
||||
db::name('vs_room_song')->where(['room_id' => $room_id,'times_status' => 1,'status' => 2])->update(['status'=>3]);
|
||||
}
|
||||
if(db::name('vs_room_song')->where('room_id',$room_id)->where(['times_status'=>1])->find()){
|
||||
db::name('vs_room_song')->where('room_id',$room_id)->update(['times_status'=>2]);
|
||||
}
|
||||
return ['code'=>0,'msg'=>'已经是最后一首歌了','data'=>null];
|
||||
}
|
||||
$total = db::name('vs_room_song')
|
||||
@@ -420,6 +436,7 @@ class RoomSong extends Model
|
||||
'nextInfo' => $next_song_info
|
||||
];
|
||||
model('Chat')->sendMsg(1013,$room_id,$text);
|
||||
|
||||
return ['code'=>1,'msg'=>'切歌成功','data'=>null];
|
||||
}
|
||||
|
||||
@@ -513,6 +530,11 @@ class RoomSong extends Model
|
||||
if(!$host && $owner != $user_id){
|
||||
return ['code' => 0, 'msg' => '您没有权限上麦', 'data' => null];
|
||||
}
|
||||
//检查是否在坑位上
|
||||
$pit_infos = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id])->field('id,pit_number')->find();
|
||||
if($pit_infos){
|
||||
return ['code' => 0, 'msg' => '您已在麦上', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
$ompit = model('RoomPit')->OnPit($user_id,$room_id,$pit_number);//用户上了这个房间的几号麦位
|
||||
@@ -534,7 +556,7 @@ class RoomSong extends Model
|
||||
if(isset($pit_infos)){
|
||||
return ['code' => 0, 'msg' => '用户已在麦上,请先下麦后再申请', 'data' => null];
|
||||
}
|
||||
$FromUserInfo = db::name('user')->where('id',$user_id)->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$FromUserInfo = db::name('user')->where('id',$user_id)->field('id as user_id,nickname,avatar,sex,is_online')->find();
|
||||
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($user_id);//财富图标
|
||||
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($user_id);//魅力图标
|
||||
$FromUserInfo['dress'] = model('Decorate')->user_decorate_detail($user_id,1);
|
||||
@@ -556,6 +578,7 @@ class RoomSong extends Model
|
||||
}
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1003,$room_id,$text);
|
||||
db::name('vs_room_visitor')->where(['user_id' => $user_id,'room_id' => $room_id])->update(['is_onpit' => 0]);
|
||||
return ['code' => 1, 'msg' => '上麦成功', 'data' => null];
|
||||
}else{
|
||||
//检查用户是否已经申请
|
||||
@@ -615,6 +638,7 @@ class RoomSong extends Model
|
||||
$text['FromUserInfo'] = $FromUserInfo;
|
||||
$text['pit_number'] = '';
|
||||
model('Chat')->sendMsg(1004,$room_id,$text);
|
||||
db::name('vs_room_visitor')->where(['user_id' => $user_id,'room_id' => $room_id])->update(['is_onpit' => 1]);
|
||||
return ['code' => 1, 'msg' => '下麦成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
737
application/api/model/Sign.php
Normal file
737
application/api/model/Sign.php
Normal file
@@ -0,0 +1,737 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class Sign extends Model
|
||||
{
|
||||
/*
|
||||
* 开始签约
|
||||
* @param int $user_id 用户id
|
||||
* @param int $room_id 房间id
|
||||
* @param int $sign_user_id 签约麦的用户id
|
||||
*/
|
||||
public function start_sign($user_id,$room_id,$sign_user_id){
|
||||
//权限判断主持及以上才可操作
|
||||
$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];
|
||||
}
|
||||
//查询签约用户是否在麦位上
|
||||
$accept_user_is_on_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => 1])->find();
|
||||
if($accept_user_is_on_pit['user_id'] == 0){
|
||||
return ['code' => 0, 'msg' => '签约麦位没有用户', 'data' => null];
|
||||
}
|
||||
|
||||
//判断房间内是否有正在签约的
|
||||
$is_sign = db::name('vs_room_sign')->where(['room_id' => $room_id,'sign_type' => 1])->count();
|
||||
if($is_sign > 0){
|
||||
return ['code' => 0, 'msg' => '房间内已有签约', 'data' => null];
|
||||
}
|
||||
|
||||
$is_first_sign = db::name('vs_user_sign')->where('sign_user_id',$sign_user_id)->count();
|
||||
if($is_first_sign < 1){
|
||||
//第一次被签默认时长
|
||||
$sign_times = get_system_config_value('first_sign_times');
|
||||
}else{
|
||||
//非首次签约默认时长
|
||||
$sign_times = get_system_config_value('sign_times');
|
||||
}
|
||||
|
||||
//修改房间状态
|
||||
db::name('vs_room')->where('id',$room_id)->update([
|
||||
'sign_type' => 1,//签约房状态:0-等待开始,1-进行中
|
||||
'updatetime' => time()
|
||||
]);
|
||||
$market_value = db::name('user')->where('id', $sign_user_id)->value('market_value');
|
||||
$res = db::name('vs_room_sign')->insertGetId([
|
||||
'room_id' => $room_id,
|
||||
'sign_type' => 1,
|
||||
'end_time' => time() + 60 * 5,//签约时长5分钟
|
||||
'sign_user_id' => $sign_user_id,
|
||||
'sign_day' => $sign_times,
|
||||
'market_value' => $market_value,
|
||||
'createtime' => time()
|
||||
]);
|
||||
if($res){
|
||||
//给前端推送数据
|
||||
$text['text'] = '开始签约';
|
||||
$text['sign_id'] = $res;
|
||||
$text['sign_day'] = $sign_times;
|
||||
$text['current_body_value'] = $market_value;
|
||||
$text['end_time'] = time() + 60 * 5;//签约时长5分钟
|
||||
model('api/Chat')->sendMsg(1090,$room_id,$text);
|
||||
|
||||
return ['code' => 1, 'msg' => '成功','data' => $res];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试','data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 签约出价
|
||||
* @param int $user_id 用户id
|
||||
* @param int $room_id 房间id
|
||||
* @param int $sign_user_id 签约麦的用户id
|
||||
* @param int $sign_value 出价
|
||||
* @param int $sign_time 签约场次
|
||||
* @return array
|
||||
*/
|
||||
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');
|
||||
if($user_coin < $sign_value){
|
||||
return ['code' => 0, 'msg' => '金币不足','data' => null];
|
||||
}
|
||||
|
||||
//开启事务
|
||||
db::startTrans();
|
||||
//扣除用户金币并记录日志
|
||||
$wallet_update = model('api/GiveGift') -> change_user_cion_or_earnings_log($user_id,$sign_value,$room_id,1,50,'用户签约关系');
|
||||
if(!$wallet_update){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '扣除用户金币失败', 'data' => null];
|
||||
}
|
||||
|
||||
//记录签约出价
|
||||
$data = [
|
||||
'user_id' => $user_id,
|
||||
'room_id' => $room_id,
|
||||
'sign_time' => $sign_time,
|
||||
'sign_user_id' => $sign_user_id,
|
||||
'sign_value' => $sign_value,
|
||||
'createtime' => time(),
|
||||
];
|
||||
$result = db::name('vs_user_sign_auction')->insert($data);
|
||||
if(!$result){
|
||||
db::rollback();
|
||||
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();
|
||||
|
||||
//其他的出价退回到用户的钱包
|
||||
$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){
|
||||
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,'签约失败退款');
|
||||
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::commit();
|
||||
//处理麦位
|
||||
$this->pit_number($room_id,$sign_user['user_id'],1);
|
||||
//给前端推送数据
|
||||
$FromUserInfo = model('api/User')->get_user_base_info($sign_user['user_id']);
|
||||
|
||||
//组个列表
|
||||
$sign_market_value = get_system_config_value('sign_market_value');
|
||||
$sign_coin_list = [];
|
||||
$first_value = $sign_user['sign_value'] + $sign_market_value; // 第一个值是身价加上sign_market_value
|
||||
for ($i = 0; $i < 8; $i++) {
|
||||
$sign_coin_list[] = (string)($first_value + $i); // 每个值在第一个值的基础上加i(0到7)
|
||||
}
|
||||
$text['text'] = '签约出价最高用户';
|
||||
$text['FromUserInfo'] = $FromUserInfo;
|
||||
$text['sign_value'] = $sign_user['sign_value'];
|
||||
$text['sign_id'] = $sign_time;
|
||||
$text['sign_coin_list'] = $sign_coin_list;
|
||||
model('api/Chat')->sendMsg(1091,$room_id,$text);
|
||||
return ['code' => 1, 'msg' => '成功','data' => null];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 签约结束
|
||||
* @param int $user_id 用户id
|
||||
* @param int $room_id 房间id
|
||||
* @param int $sign_time 签约场次
|
||||
* @param int $sign_user_id 签约麦的用户id
|
||||
*/
|
||||
public function end_sign($user_id,$room_id,$sign_time,$sign_user_id,$type = 1){
|
||||
if($type == 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];
|
||||
}
|
||||
}
|
||||
|
||||
//根据场次判断是否结束
|
||||
$sign = db::name('vs_room_sign')->where( ['id' => $sign_time])->find();
|
||||
if($sign['sign_type'] != 1){
|
||||
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){
|
||||
$before_sign_user = null;
|
||||
$is_sign = null;
|
||||
//查询签约用户的身份 是否是第一次被签 是否当前有签
|
||||
$is_first_sign = db::name('vs_user_sign')->where('sign_user_id',$sign_user_id)->count();
|
||||
if($is_first_sign < 1){
|
||||
//第一次被签平台抽成
|
||||
$sign_app_ratio = get_system_config_value('first_sign_app_ratio');
|
||||
$sign_user_type = 0;
|
||||
$sign_times = get_system_config_value('first_sign_times');
|
||||
}else{
|
||||
//不是第一次被签平台抽成
|
||||
$sign_app_ratio = get_system_config_value('sign_app_ratio');
|
||||
//查找该用户是否在约
|
||||
$sign_user_type = 1;
|
||||
$is_sign = db::name('vs_user_sign')->where(['sign_user_id' => $sign_user_id,'end_time' => ['>',time()]])->find();
|
||||
if($is_sign){
|
||||
$sign_user_type = 2;
|
||||
$before_sign_user = $is_sign['parent_user_id'];
|
||||
}
|
||||
$sign_times = get_system_config_value('sign_times');
|
||||
}
|
||||
//开启事务
|
||||
db::startTrans();
|
||||
|
||||
//记录房间流水及明细
|
||||
//收礼记录行为日志
|
||||
$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);
|
||||
if(!$give_gift){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '出价失败', 'data' => null];
|
||||
}
|
||||
//修改他的状态
|
||||
$result = db::name('vs_user_sign_auction')->where(['id' => $max_sign_user['id']])->update(['type' => 1,'signtime' => time()]);
|
||||
if(!$result){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
}
|
||||
//签约
|
||||
//根据被签约的用户类型计算给响应用户的金额
|
||||
//减去平台抽成 剩余的给相应的人
|
||||
$sign_user_cion = $max_sign_user['sign_value'] * (100 - $sign_app_ratio) / 100;//金币数
|
||||
//计算收益
|
||||
$shouyizs = coin_earning($sign_user_cion,100);
|
||||
|
||||
//签过没过期
|
||||
if($sign_user_type == 2){
|
||||
//本次签的还是上次的师傅
|
||||
if($before_sign_user == $max_sign_user['user_id']){
|
||||
$resultt = db::name('vs_user_sign')
|
||||
->where(['id' => $is_sign['id']])
|
||||
->update(['end_time' => time() + $sign_times*24*60*60,'sign_user_type' => $sign_user_type]);
|
||||
if(!$resultt){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
}
|
||||
}else{
|
||||
$result5 = db::name('vs_user_sign')->where(['id' => $is_sign['id']])
|
||||
->update(['end_time' => time(),'type' => 4]);
|
||||
if(!$result5){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
}
|
||||
$data = [
|
||||
'parent_user_id' => $max_sign_user['user_id'],
|
||||
'sign_user_id' => $max_sign_user['sign_user_id'],
|
||||
'sign_user_type' => $sign_user_type,
|
||||
'sign_times' => $sign_times*24*60*60,
|
||||
'end_time' => time() + $sign_times*24*60*60,
|
||||
'createtime' => time(),
|
||||
];
|
||||
$result11 = db::name('vs_user_sign')->insert($data);
|
||||
if(!$result11){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//签过没过期 给上任签约者
|
||||
$result4 = model('api/GiveGift') -> change_user_cion_or_earnings_log($before_sign_user,$shouyizs,$room_id,2,54,'解约补偿');
|
||||
if(!$result4){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
}
|
||||
|
||||
//查找是否有未完成的师徒任务 有就删除掉
|
||||
$student = db::name('vs_tasks_student')->where(['student_id' => $sign_user_id,'status' => 0])->select();
|
||||
if($student){
|
||||
foreach ($student as &$v){
|
||||
db::name('vs_tasks_student')->where(['id' => $v['id']])->update(['delete_time' => time()]);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$data = [
|
||||
'parent_user_id' => $max_sign_user['user_id'],
|
||||
'sign_user_id' => $max_sign_user['sign_user_id'],
|
||||
'sign_user_type' => $sign_user_type,
|
||||
'sign_times' => $sign_times*24*60*60,
|
||||
'end_time' => time() + $sign_times*24*60*60,
|
||||
'createtime' => time(),
|
||||
];
|
||||
$result1 = db::name('vs_user_sign')->insert($data);
|
||||
if(!$result1){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
}
|
||||
|
||||
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,'被首次签约成功收入');
|
||||
if(!$result4){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
}
|
||||
}elseif ($sign_user_type == 1) {
|
||||
//签过 给被签约的人分七天给他
|
||||
// 数据插入 循环插入7条数据 day 取值是今天开始连续七天 的每一天的值 到天
|
||||
|
||||
for ($i = 0; $i < 7; $i++) {
|
||||
$data1 = [
|
||||
'user_id' => $max_sign_user['sign_user_id'],
|
||||
'value' => round($shouyizs / 7, 4),
|
||||
'day' => date('Y-m-d', strtotime("+$i days")), // 从今天开始连续七天的日期
|
||||
'times' => $i + 1,
|
||||
'createtime' => time()
|
||||
];
|
||||
// 插入数据库
|
||||
$result = db::name('vs_user_sign_task')->insert($data1);
|
||||
if (!$result) {
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//查看当前出价用户是否创建家族
|
||||
$is_create_familys = db::name('vs_family')->where(['user_id' => $max_sign_user['user_id'],'type' => 1])->find();
|
||||
if(!$is_create_familys){
|
||||
$rres = model('Family')->createFamily($max_sign_user['user_id']);
|
||||
}
|
||||
$is_create_family = db::name('vs_family')->where(['user_id' => $max_sign_user['user_id'],'type' => 1])->find();
|
||||
if($is_create_family){
|
||||
//是否已在家族中
|
||||
$is_in_family = db::name('vs_family')
|
||||
->where(['pid' => $max_sign_user['user_id'],'user_id' => $max_sign_user['sign_user_id'],'type' => 0,'deletetime' => 0])->find();
|
||||
if(!$is_in_family){
|
||||
//拉进家族和群聊
|
||||
$data2 = [
|
||||
'name' => $is_create_family['name'],
|
||||
'pid' => $max_sign_user['user_id'],
|
||||
'user_id' => $max_sign_user['sign_user_id'],
|
||||
'createtime' => time(),
|
||||
];
|
||||
$result22 = db::name('vs_family')->insert($data2);
|
||||
if(!$result22){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试!!', 'data' => null];
|
||||
}
|
||||
//拉入群聊
|
||||
model('Tencent')->add_group_member('f'.$is_create_family['id'], $max_sign_user['sign_user_id']);
|
||||
}
|
||||
}
|
||||
|
||||
//其他的出价退回到用户的钱包 这个是为了防止上面并发产生的没退款用户
|
||||
$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){
|
||||
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,'签约失败退款');
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//修改房间信息
|
||||
$res1 = db::name('vs_room')->where('id',$room_id)->update([
|
||||
'sign_type' => 0,
|
||||
'updatetime' => time()
|
||||
]);
|
||||
//修改房间签约信息
|
||||
$res2 = db::name('vs_room_sign')->where(['id' => $sign_time])
|
||||
->update([
|
||||
'sign_type' => 0,
|
||||
'end_time' => time()
|
||||
]);
|
||||
if(!$res1 || !$res2){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试.!', 'data' => null];
|
||||
}
|
||||
//用户财富等级更新
|
||||
$user_level = model('Level')->user_level_data_update($max_sign_user['user_id'],$max_sign_user['sign_value'],1,$room_id);
|
||||
if(!$user_level){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '用户等级更新失败', 'data' => null];
|
||||
}
|
||||
|
||||
//获取用户签约开始的身价
|
||||
$market_value = $sign['market_value'];
|
||||
$sign_values = $max_sign_user['sign_value'] - $market_value;
|
||||
//更新用户的身价并且添加记录 此时增长的身价是出价 这个出价就是身价溢价
|
||||
$dd = model('api/MarketValue')->change($sign_user_id,$sign_values,3);
|
||||
if($dd['code'] != 1){
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => $dd['msg'], 'data' => null];
|
||||
}
|
||||
if($sign_user_type == 0){
|
||||
//任务:6-第一次签约师父
|
||||
model('Tasks')->tasks_complete($sign_user_id,6);
|
||||
//任务:21、22、23-师徒任务
|
||||
$task_ids = [21, 22, 23];
|
||||
$data_list = [];
|
||||
foreach ($task_ids as $task_id) {
|
||||
$data_list[] = [
|
||||
'user_id' => $max_sign_user['user_id'],
|
||||
'student_id' => $sign_user_id,
|
||||
'task_id' => $task_id,
|
||||
'createtime' => time()
|
||||
];
|
||||
}
|
||||
db::name('vs_tasks_student')->insertAll($data_list);
|
||||
}
|
||||
//判定是否 今日第一次签约徒弟
|
||||
$is_first_sign_student = db::name('vs_user_sign')->where(['parent_user_id' => $max_sign_user['user_id'],'createtime' => ['>=',strtotime(date('Y-m-d'))]])->count();
|
||||
if($is_first_sign_student == 1){
|
||||
//任务:16-每日签约一个新徒弟
|
||||
model('Tasks')->tasks_complete($max_sign_user['user_id'],16);
|
||||
}
|
||||
//提交事务
|
||||
db::commit();
|
||||
//给前端推送
|
||||
$FromUserInfo = model('api/User')->get_user_base_info($max_sign_user['user_id']);
|
||||
$ToUserInfo =model('api/User')->get_user_base_info($max_sign_user['sign_user_id']);
|
||||
|
||||
$text['text'] = '签约出价最高用户';
|
||||
$text['FromUserInfo'] = $FromUserInfo;
|
||||
$text['ToUserInfo'] = $ToUserInfo;
|
||||
$text['sign_value'] = $max_sign_user['sign_value'];
|
||||
model('api/Chat')->sendMsg(1092,$room_id,$text);
|
||||
}else{
|
||||
//修改房间信息
|
||||
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;
|
||||
$text['sign_value'] = 0;
|
||||
model('api/Chat')->sendMsg(1092,$room_id,$text);
|
||||
}
|
||||
|
||||
//处理麦位
|
||||
$this->pit_number($room_id,0,0);
|
||||
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 麦位处理
|
||||
*/
|
||||
public function pit_number($room_id,$user_id = 0,$type = 0){
|
||||
if($type == 1){//上麦或者换麦
|
||||
//获取房间2号位上的用户
|
||||
$on_pit2_user = db::name('vs_room_pit')
|
||||
->where(['room_id' => $room_id,'pit_number' => 2])->field('before_pit_number,user_id')->find();
|
||||
if($on_pit2_user['user_id'] == $user_id){
|
||||
return true;
|
||||
}
|
||||
|
||||
//处理2号位
|
||||
if($on_pit2_user && $on_pit2_user['user_id']){
|
||||
//2号位有其他用户,需要处理该用户
|
||||
//获取2号位用户之前的位置上是否有用户
|
||||
$before_pit_number = db::name('vs_room_pit')
|
||||
->where(['room_id' => $room_id,'pit_number' => $on_pit2_user['before_pit_number']])->value('user_id');
|
||||
|
||||
if($before_pit_number || $on_pit2_user['before_pit_number'] == 0){
|
||||
//之前位置有人或者之前麦位为空,直接下麦
|
||||
model('api/RoomPit')->DownPit($on_pit2_user['user_id'], $room_id, 2,1);
|
||||
} else {
|
||||
//之前位置无人,换麦
|
||||
db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $on_pit2_user['before_pit_number']])
|
||||
->update(['user_id' => $on_pit2_user['user_id']]);
|
||||
|
||||
//推送换麦消息
|
||||
$this->sendPitChangeMessage($on_pit2_user['user_id'], $room_id, 2, $on_pit2_user['before_pit_number']);
|
||||
}
|
||||
}
|
||||
|
||||
//处理当前用户上2号位
|
||||
if($user_id){
|
||||
//查询当前用户是否已在麦上
|
||||
$user_pit_info = db::name('vs_room_pit')
|
||||
->where(['room_id' => $room_id, 'user_id' => $user_id])
|
||||
->field('pit_number')->find();
|
||||
|
||||
if($user_pit_info && $user_pit_info['pit_number']){//用户已在麦上
|
||||
//移除原麦位上的自己信息
|
||||
db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $user_pit_info['pit_number']])
|
||||
->update(['user_id' => 0]);
|
||||
//换到2号位,记录原麦位信息
|
||||
db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => 2])
|
||||
->update(['user_id' => $user_id,'before_pit_number' => $user_pit_info['pit_number']]);
|
||||
//推送换麦消息
|
||||
$this->sendPitChangeMessage($user_id, $room_id, $user_pit_info['pit_number'], 2);
|
||||
} else {
|
||||
//用户不在麦上,直接上2号麦
|
||||
model('api/RoomPit')->OnPit($user_id, $room_id, 2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//下麦 - 在麦位上的用户全部下麦
|
||||
$on_pit_users = db::name('vs_room_pit')
|
||||
->where(['room_id' => $room_id, 'user_id' => ['>', 0], 'pit_number' => ['<', 3]])
|
||||
->select();
|
||||
|
||||
if($on_pit_users){
|
||||
foreach ($on_pit_users as $pit_user){
|
||||
model('RoomPit')->DownPit($pit_user['user_id'], $room_id, $pit_user['pit_number'],1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* 发送麦位变更消息
|
||||
*/
|
||||
private function sendPitChangeMessage($user_id, $room_id, $from_pit, $to_pit){
|
||||
$userInfo = db::name('user')->where('id', $user_id)->field('id as user_id,nickname,avatar,sex')->find();
|
||||
$userInfo['icon'][0] = model('UserData')->user_wealth_icon($user_id);//财富图标
|
||||
$userInfo['icon'][1] = model('UserData')->user_charm_icon($user_id);//魅力图标
|
||||
$userInfo['dress'] = model('Decorate')->user_decorate_detail($user_id, 1);
|
||||
$userInfo['charm'] = db::name('vs_room_user_charm')->where(['user_id' => $user_id, 'room_id' => $room_id])->value('charm');
|
||||
$nobility = model('api/Nobility')->getUserNobilityInfo($user_id);
|
||||
$userInfo['nobility_info'] = $nobility;
|
||||
$userInfo['mic_cycle'] = model('api/Decorate')->user_decorate_detail($user_id, 3);
|
||||
$userInfo['nobility_image'] = $nobility['play_image'];
|
||||
$userInfo['nickname_color'] = $nobility['nick_name_color'];
|
||||
$userInfo['is_online'] = db::name('vs_room_visitor')->where(['user_id' => $user_id,'room_id' => $room_id])->value('is_online');
|
||||
|
||||
if($to_pit == 1){
|
||||
$pit_text = '签约麦';
|
||||
}elseif($to_pit == 2){
|
||||
$pit_text = '师父麦';
|
||||
}elseif ($to_pit == 3 || $to_pit == 4 || $to_pit == 5) {
|
||||
$pit_text = '老板麦';
|
||||
}elseif($to_pit == 9){
|
||||
$pit_text = '主持麦';
|
||||
}elseif ($to_pit == 10) {
|
||||
$pit_text = '嘉宾麦';
|
||||
}else{
|
||||
$pit_text = $to_pit . '号麦';
|
||||
}
|
||||
$text['text'] = $userInfo['nickname'].' 换到'.$pit_text;
|
||||
$text['FromUserInfo'] = $userInfo;
|
||||
$text['from_pit_number'] = $from_pit;
|
||||
$text['to_pit_number'] = $to_pit;
|
||||
model('Chat')->sendMsg(1039, $room_id, $text);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 签约延时
|
||||
* @param $user_id 用户id
|
||||
* @param $room_id 房间id
|
||||
* @param $sign_id 签约场次id
|
||||
*/
|
||||
public function sign_delay($user_id,$room_id,$sign_id){
|
||||
//权限判断主持及以上才可操作
|
||||
$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];
|
||||
}
|
||||
|
||||
$sign_info = db::name('vs_room_sign')->where(['id' => $sign_id])->find();
|
||||
if(!$sign_info || (!empty($sign_info) && $sign_info['sign_type'] != 1)){
|
||||
return ['code' => 0, 'msg' => '本场签约结束', 'data' => null];
|
||||
}
|
||||
$res = db::name('vs_room_sign')->where(['id' => $sign_id])
|
||||
->update([
|
||||
'end_time' => $sign_info['end_time'] + 300,//延时5分钟
|
||||
]);
|
||||
if(!$res){
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
}
|
||||
//给前端推送
|
||||
$text['text'] = '签约延时';
|
||||
$text['end_time'] = $sign_info['end_time'] + 300;
|
||||
model('api/Chat')->sendMsg(1093,$room_id,$text);
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 收礼检查是否有被签约和在合约期内 给上级返佣
|
||||
* @param $user_id 用户id
|
||||
* @param $gift_id 礼物id
|
||||
* @param $gift_num 礼物数量
|
||||
* @param $gift_price 礼物价格
|
||||
* @param $room_id 房间id
|
||||
*/
|
||||
public function check_sign_gift($user_id,$gift_id,$gift_num,$gift_price,$room_id){
|
||||
//获取用户签约信息
|
||||
$sign_info = db::name('vs_user_sign')->where(['sign_user_id' => $user_id,'end_time' => ['>',time()]])->find();
|
||||
if(!$sign_info){
|
||||
return true;
|
||||
}
|
||||
$give_sign_ratio = get_system_config_value('give_sign_ratio');
|
||||
$earning = $gift_price * $give_sign_ratio / 100;
|
||||
$earnings = coin_earning($earning,100);
|
||||
$data = [
|
||||
'user_id' => $sign_info['parent_user_id'],
|
||||
'sign_user_id' => $user_id,
|
||||
'gift_id' => $gift_id,
|
||||
'gift_num' => $gift_num,
|
||||
'earnings' => $earnings,
|
||||
'createtime' => time()
|
||||
];
|
||||
$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,'签约用户收礼返佣');
|
||||
if(!$result4){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 免费续签
|
||||
* @param $user_id 用户id
|
||||
* @param $sign_user_id 签约麦的用户id
|
||||
*/
|
||||
public function free_re_sign($user_id,$sign_user_id){
|
||||
$first_sign_info = db::name('vs_user_sign')
|
||||
->where(['sign_user_id' => $sign_user_id])->count();
|
||||
if($first_sign_info > 1){
|
||||
return ['code' => 0, 'msg' => '该用户已不满足免费续签条件', 'data' => null];
|
||||
}
|
||||
$sign_info = db::name('vs_user_sign')
|
||||
->where(['parent_user_id' => $user_id,'sign_user_id' => $sign_user_id,'end_time' => ['>',time()]])->find();
|
||||
if(!$sign_info){
|
||||
return ['code' => 0, 'msg' => '您没有签约该用户或该用户已解约', 'data' => null];
|
||||
}
|
||||
if($sign_info['type'] >= 3){
|
||||
return ['code' => 0, 'msg' => '免费续签次数已用完', 'data' => null];
|
||||
}
|
||||
$end_time = $sign_info['end_time'] + 86400 * get_system_config_value('free_re_sign_day');
|
||||
$res = db::name('vs_user_sign')->where(['id' => $sign_info['id']])->update(['type' => $sign_info['type']+1,'end_time' => $end_time,'is_notice'=>0]);
|
||||
if(!$res){
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
}
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 续签
|
||||
* @param $user_id 用户id
|
||||
* @param $sign_user_id 签约麦的用户id
|
||||
*/
|
||||
public function re_sign($user_id,$sign_user_id){
|
||||
$sign_info = db::name('vs_user_sign')
|
||||
->where(['parent_user_id' => $user_id,'sign_user_id' => $sign_user_id,'end_time' => ['>',time()]])->find();
|
||||
if(!$sign_info){
|
||||
return ['code' => 0, 'msg' => '您没有签约该用户或该用户已解约', 'data' => null];
|
||||
}
|
||||
//获取被签约用户当前身价
|
||||
$market_value = db::name('user')->where('id',$sign_user_id)->value('market_value');
|
||||
//获取系统配置的签约身价百分比
|
||||
$sign_market_value = get_system_config_value('sign_user_ratio');
|
||||
//获取系统配置非首签签约时长
|
||||
$sign_times = get_system_config_value('sign_times');
|
||||
|
||||
$change_coin = ceil($market_value * $sign_market_value / 100);
|
||||
|
||||
|
||||
//获取签约者的金币
|
||||
$coin = db::name('user_wallet')->where('user_id',$user_id)->value('coin');
|
||||
if($coin < $change_coin){
|
||||
return ['code' => 0, 'msg' => '您的金币不足', 'data' => null];
|
||||
}
|
||||
$end_time = $sign_info['end_time'] + 86400 * $sign_times;
|
||||
//开启事务
|
||||
db::startTrans();
|
||||
$res = db::name('vs_user_sign')->where(['id' => $sign_info['id']])->update(['end_time' => $end_time,'is_notice'=>0]);
|
||||
if(!$res){
|
||||
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,'续约');
|
||||
if(!$res2){
|
||||
db::rollback();
|
||||
return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null];
|
||||
}
|
||||
db::commit();
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
//获取首次被签约且在约期内的徒弟列表
|
||||
public function get_first_sign_student_list($user_id)
|
||||
{
|
||||
$user = db::name('vs_user_sign')->field('sign_user_id as user_id')
|
||||
->where(['parent_user_id' => $user_id,'sign_user_type' => 0,'end_time' => ['>',time()]])
|
||||
->select();
|
||||
if($user){
|
||||
foreach ($user as $k => $v){
|
||||
$user[$k] = model('api/User')->get_user_base_info($v['user_id']);
|
||||
$is_in_room = db::name('vs_room_visitor')->where(['user_id' => $v['user_id']])->find();
|
||||
if($is_in_room){
|
||||
$user[$k]['is_in_room'] = 1;
|
||||
}else{
|
||||
$user[$k]['is_in_room'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => $user];
|
||||
}
|
||||
|
||||
}
|
||||
457
application/api/model/SingerSong.php
Normal file
457
application/api/model/SingerSong.php
Normal file
@@ -0,0 +1,457 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class SingerSong extends Model
|
||||
{
|
||||
/*
|
||||
* 歌手认证 状态及等级
|
||||
*/
|
||||
public function singerAuthStatus($user_id)
|
||||
{
|
||||
$res = db::name('vs_singer')->where(['user_id' => $user_id])->find();
|
||||
if ($res) {
|
||||
$data = [
|
||||
'status' => $res['status'],
|
||||
'level' => $res['level'],
|
||||
];
|
||||
} else {
|
||||
$data = [
|
||||
'status' => -1,
|
||||
'level' => 0,
|
||||
];
|
||||
}
|
||||
return $data ;
|
||||
}
|
||||
|
||||
/*
|
||||
* 歌手认证
|
||||
*/
|
||||
public function singerAuth($user_id, $song)
|
||||
{
|
||||
//查询是否提交过认证
|
||||
$res = db::name('vs_singer')->where(['user_id' => $user_id])->find();
|
||||
if ($res && $res['status'] == 1) {
|
||||
return ['code' => 0, 'msg' => '认证已通过,无需重复提交', 'data' => null];
|
||||
}
|
||||
if ($res) {
|
||||
$data = [
|
||||
'song' => $song,
|
||||
'status' => 0,
|
||||
'updatetime' => time()
|
||||
];
|
||||
$result = db::name('vs_singer')->where(['id' => $res['id']])->update($data);
|
||||
}else{
|
||||
$data = [
|
||||
'user_id' => $user_id,
|
||||
'song' => $song,
|
||||
'status' => 0,
|
||||
'createtime' => time()
|
||||
];
|
||||
$result = db::name('vs_singer')->insert($data);
|
||||
}
|
||||
if ($result) {
|
||||
return ['code' => 1, 'msg' => '提交成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 0, 'msg' => '提交失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 歌手添加歌曲
|
||||
* @param song_name 歌曲名称
|
||||
* @param gift_id 礼物id
|
||||
* @param gift_num 礼物数量
|
||||
*/
|
||||
public function singerAddSong($user_id, $song_name, $gift_id, $gift_num)
|
||||
{
|
||||
//查询是否是认证歌手
|
||||
$res = db::name('vs_singer')->where(['user_id' => $user_id])->find();
|
||||
if (!$res || $res['status'] != 1) {
|
||||
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];
|
||||
}
|
||||
|
||||
//礼物不能是CP礼物
|
||||
$cp_gift_ids = explode(',', get_system_config_value('cp_gift_id'));
|
||||
if (in_array($gift_id, $cp_gift_ids)) {
|
||||
return ['code' => 0, 'msg' => '礼物不能是CP礼物,请重新选择', 'data' => null];
|
||||
}
|
||||
|
||||
$data = [
|
||||
'user_id' => $user_id,
|
||||
'song_name' => $song_name,
|
||||
'gift_id' => $gift_id,
|
||||
'gift_num' => $gift_num,
|
||||
'createtime' => time()
|
||||
];
|
||||
$result = db::name('vs_singer_song')->insert($data);
|
||||
if ($result) {
|
||||
return ['code' => 1, 'msg' => '提交成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 0, 'msg' => '提交失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 获取房间内麦位上歌手歌曲
|
||||
* @param room_id 房间id
|
||||
* @param user_id 用户id
|
||||
*/
|
||||
public function getSong($uid, $user_id, $room_id, $page, $page_limit)
|
||||
{
|
||||
if($user_id > 0){
|
||||
$count = db::name('vs_singer_song')->where(['user_id' => $user_id,'deletetime' => 0])->count();
|
||||
$res = db::name('vs_singer_song')->where(['user_id' => $user_id,'deletetime' => 0])->page($page, $page_limit)->select();
|
||||
}else{
|
||||
//查询当前房间内麦位上的歌手
|
||||
$room_singer = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',9]])->column('user_id');
|
||||
if ($room_singer) {
|
||||
//$uid 是当前自己,有自己就去除自己
|
||||
$room_singer = array_diff($room_singer, [$uid]);
|
||||
$count = db::name('vs_singer_song')->where(['user_id' => ['in', $room_singer],'deletetime' => 0])->count();
|
||||
$res = db::name('vs_singer_song')->where(['user_id' => ['in', $room_singer],'deletetime' => 0])->page($page, $page_limit)->select();
|
||||
}else{
|
||||
$res = [];
|
||||
$count = 0;
|
||||
}
|
||||
}
|
||||
if ($res) {
|
||||
foreach ($res as $k => $v) {
|
||||
$res[$k]['gift_name'] = db::name('vs_gift')->where(['gid' => $v['gift_id']])->value('gift_name');
|
||||
$res[$k]['gift_price'] = db::name('vs_gift')->where(['gid' => $v['gift_id']])->value('gift_price');
|
||||
$res[$k]['base_image'] = db::name('vs_gift')->where(['gid' => $v['gift_id']])->value('base_image');
|
||||
$res[$k]['singer_nickname'] = db::name('user')->where(['id' => $v['user_id']])->value('nickname');
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => ['count' => $count, 'lists' =>$res]];
|
||||
} else {
|
||||
return ['code' => 1, 'msg' => '暂无数据', 'data' => ['count' => $count, 'lists' =>$res]];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 点歌
|
||||
* @param song_id 歌曲id
|
||||
* @param user_id 用户id
|
||||
*/
|
||||
public function singerSong($user_id, $song_id, $room_id)
|
||||
{
|
||||
//查询歌曲信息
|
||||
$song = db::name('vs_singer_song')->where(['id' => $song_id])->find();
|
||||
if (!$song) {
|
||||
return ['code' => 0, 'msg' => '歌曲不存在', 'data' => null];
|
||||
}
|
||||
//查询歌曲是否是自己的
|
||||
if ($song['user_id'] == $user_id) {
|
||||
return ['code' => 0, 'msg' => '不能点自己歌曲', 'data' => null];
|
||||
}
|
||||
//查询用户余额
|
||||
$user_money = db::name('user_wallet')->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];
|
||||
}
|
||||
|
||||
//走送礼流程
|
||||
$res = model('GiveGift')->give_gift($user_id,$song['user_id'],$song['gift_id'],$song['gift_num'],2,1,$room_id);
|
||||
if ($res['code'] == 1) {
|
||||
$data = [
|
||||
'user_id' => $user_id,
|
||||
'room_id' => $room_id,
|
||||
'singer_song_id' => $song_id,
|
||||
'createtime' => time()
|
||||
];
|
||||
//插入数据库并获取ID
|
||||
$result = db::name('vs_song_log')->insertGetId($data);
|
||||
if (!$result) {
|
||||
return ['code' => 0, 'msg' => '点歌失败', 'data' => null];
|
||||
}
|
||||
//查询点歌用户是否是首签的徒弟 sign_user_type:被签用户的类型:0-首次被签,1-签约过期,2-违约签
|
||||
$is_students = db::name('vs_user_sign')
|
||||
->where(['sign_user_id' => $user_id,'sign_user_type' => 0,'end_time' => ['>',time()]])->value('parent_user_id');
|
||||
//第一次点歌
|
||||
$frist_song = db::name('vs_song_log')->where(['user_id' => $user_id])->count();
|
||||
if ($is_students && $frist_song == 1) {
|
||||
//任务:22-邀请徒弟在点唱房点歌(0/1)首
|
||||
model('Tasks')->tasks_complete($is_students,22,1,$user_id);
|
||||
}
|
||||
|
||||
//获取当前房间内点歌总数
|
||||
$song_info_count = db::name('vs_song_log')->where(['room_id' => $room_id,'status' => ['in',[0,1]]])->count();
|
||||
//给前端推送
|
||||
$text = [
|
||||
'text' => '房间点歌数量变化',
|
||||
'count' => $song_info_count
|
||||
];
|
||||
model('Chat')->sendMsg(1072,$room_id,$text);
|
||||
|
||||
if($song_info_count == 1){
|
||||
//修改房间当前演唱歌曲
|
||||
db::name('vs_song_log')->where(['id' => $result])->update(['status' => 1]);
|
||||
$song_info = db::name('vs_song_log')->where(['id' => $result])->find();
|
||||
$song_info['boss_user_id'] = $song_info['user_id'];
|
||||
$song_info['boss_nickname'] = db::name('user')->where(['id' => $song_info['user_id']])->value('nickname');
|
||||
$song_info['boss_avatar'] = db::name('user')->where(['id' => $song_info['user_id']])->value('avatar');
|
||||
$song_info['boss_dress'] = model('api/Decorate')->user_decorate_detail($song_info['user_id'], 1);
|
||||
$song_info['boss_mic_cycle'] = model('api/Decorate')->user_decorate_detail($song_info['user_id'],3);
|
||||
$singer_song = db::name('vs_singer_song')->where(['id' => $song_info['singer_song_id']])->find();
|
||||
$song_info['singer_user_id'] = $singer_song['user_id'];
|
||||
$song_info['singer_nickname'] = db::name('user')->where(['id' => $singer_song['user_id']])->value('nickname');
|
||||
$song_info['singer_avatar'] = db::name('user')->where(['id' => $singer_song['user_id']])->value('avatar');
|
||||
$song_info['singer_dress'] = model('api/Decorate')->user_decorate_detail($singer_song['user_id'], 1);
|
||||
$song_info['singer_mic_cycle'] = model('api/Decorate')->user_decorate_detail($singer_song['user_id'],3);
|
||||
$song_info['song_name'] = $singer_song['song_name'];
|
||||
|
||||
$song_info_data = [
|
||||
'text' => '房间当前演唱歌曲变化',
|
||||
'song_info' => $song_info
|
||||
];
|
||||
model('Chat')->sendMsg(1070,$room_id,$song_info_data);
|
||||
}elseif ($song_info_count == 2){
|
||||
//给前端推送下首歌曲信息
|
||||
$next_song_info = db::name('vs_song_log')->where(['id' => $result])->find();
|
||||
$next_song_info['boss_user_id'] = $next_song_info['user_id'];
|
||||
$next_song_info['boss_nickname'] = db::name('user')->where(['id' => $next_song_info['user_id']])->value('nickname');
|
||||
$next_song_info['boss_avatar'] = db::name('user')->where(['id' => $next_song_info['user_id']])->value('avatar');
|
||||
$next_song_info['boss_dress'] = model('api/Decorate')->user_decorate_detail($next_song_info['user_id'], 1);
|
||||
$next_song_info['boss_mic_cycle'] = model('api/Decorate')->user_decorate_detail($next_song_info['user_id'],3);
|
||||
$singer_song = db::name('vs_singer_song')->where(['id' => $next_song_info['singer_song_id']])->find();
|
||||
$next_song_info['singer_user_id'] = $singer_song['user_id'];
|
||||
$next_song_info['singer_nickname'] = db::name('user')->where(['id' => $singer_song['user_id']])->value('nickname');
|
||||
$next_song_info['singer_avatar'] = db::name('user')->where(['id' => $singer_song['user_id']])->value('avatar');
|
||||
$next_song_info['singer_dress'] = model('api/Decorate')->user_decorate_detail($singer_song['user_id'], 1);
|
||||
$next_song_info['singer_mic_cycle'] = model('api/Decorate')->user_decorate_detail($singer_song['user_id'],3);
|
||||
$next_song_info['song_name'] = $singer_song['song_name'];
|
||||
|
||||
$data = [
|
||||
'text' => '房间下一首演唱歌曲变化',
|
||||
'next_song_info' => $next_song_info
|
||||
];
|
||||
model('Chat')->sendMsg(1071,$next_song_info['room_id'],$data);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '点歌成功', 'data' => null];
|
||||
} else {
|
||||
return ['code' => 0, 'msg' => $res['msg'], 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 点歌列表
|
||||
* @param room_id 房间id
|
||||
* @param type 类型 1:已点列表,2:今日列表,3:昨日列表,4:本周列表,5:本月列表
|
||||
*/
|
||||
public function singerSongList($room_id,$type,$page,$page_limit)
|
||||
{
|
||||
$where = [
|
||||
'room_id' => $room_id
|
||||
];
|
||||
switch ($type) {
|
||||
case 2:
|
||||
$where['createtime'] = ['between time',[strtotime(date('Y-m-d')),time()]];
|
||||
break;
|
||||
case 3:
|
||||
$where['createtime'] = ['between time',[strtotime(date('Y-m-d',strtotime("-1 day"))),strtotime(date('Y-m-d'))]];
|
||||
$where['status'] = 2;
|
||||
break;
|
||||
case 4:
|
||||
$where['createtime'] = ['between time',[strtotime(date('Y-m-d',strtotime("-1 week"))),time()]];
|
||||
$where['status'] = 2;
|
||||
break;
|
||||
case 5:
|
||||
$where['createtime'] = ['between time',[strtotime(date('Y-m-d',strtotime("-1 month"))),time()]];
|
||||
$where['status'] = 2;
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
$where['status'] = ['in','1,0'];
|
||||
break;
|
||||
}
|
||||
|
||||
$count = db::name('vs_song_log')->where($where)->count();
|
||||
if($type == 1){
|
||||
$res1 = db::name('vs_song_log')->where(['status' => 1,'room_id' => $room_id])->select();
|
||||
$res2 = db::name('vs_song_log')->where(['status' => 0,'room_id' => $room_id])->order('sort desc')->page($page,$page_limit-1)->select();
|
||||
//把$res2 添加到$res1的 最后
|
||||
$res = array_merge($res1,$res2);
|
||||
}else{
|
||||
$res = db::name('vs_song_log')->where($where)->order('sort desc')->page($page,$page_limit)->select();
|
||||
}
|
||||
if ($res) {
|
||||
foreach ($res as $k => $v) {
|
||||
$res[$k]['boss_nickname'] = db::name('user')->where(['id' => $v['user_id']])->value('nickname');
|
||||
$res[$k]['song_name'] = db::name('vs_singer_song')->where(['id' => $v['singer_song_id']])->value('song_name');
|
||||
$res[$k]['gift_name'] = db::name('vs_gift')->where(['gid' => db::name('vs_singer_song')->where(['id' => $v['singer_song_id']])->value('gift_id')])->value('gift_name');
|
||||
$res[$k]['gift_price'] = db::name('vs_gift')->where(['gid' => db::name('vs_singer_song')->where(['id' => $v['singer_song_id']])->value('gift_id')])->value('gift_price');
|
||||
$res[$k]['base_image'] = db::name('vs_gift')->where(['gid' => db::name('vs_singer_song')->where(['id' => $v['singer_song_id']])->value('gift_id')])->value('base_image');
|
||||
$res[$k]['gift_num'] = db::name('vs_singer_song')->where(['id' => $v['singer_song_id']])->value('gift_num');
|
||||
$res[$k]['singer_nickname'] = db::name('user')->where(['id' => db::name('vs_singer_song')->where(['id' => $v['singer_song_id']])->value('user_id')])->value('nickname');
|
||||
}
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => ['count' => $count, 'lists' =>$res]];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 点歌各类型各个总数
|
||||
* @param type 类型 1:已点列表,2:今日列表,3:昨日列表,4:本周列表,5:本月列表
|
||||
* @param room_id 房间id
|
||||
*/
|
||||
public function singerSongCount($room_id)
|
||||
{
|
||||
$where = [
|
||||
'room_id' => $room_id
|
||||
];
|
||||
$res = [
|
||||
'already' => db::name('vs_song_log')->where($where)->where(['status' => ['in','1,0']])->count(),
|
||||
'total' => db::name('vs_song_log')->where($where)->count(),
|
||||
'today' => db::name('vs_song_log')->where($where)->where('createtime', 'between time', [strtotime(date('Y-m-d')), time()])->count(),
|
||||
'yesterday' => db::name('vs_song_log')->where($where)->where('createtime', 'between time', [strtotime(date('Y-m-d', strtotime("-1 day"))), strtotime(date('Y-m-d'))])->count(),
|
||||
'week' => db::name('vs_song_log')->where($where)->where('createtime', 'between time', [strtotime(date('Y-m-d', strtotime("-1 week"))), time()])->count(),
|
||||
'month' => db::name('vs_song_log')->where($where)->where('createtime', 'between time', [strtotime(date('Y-m-01')), strtotime(date('Y-m-t'))])->count()
|
||||
];
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $res];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 歌手等级收礼升级
|
||||
* @param user_id 用户id
|
||||
*/
|
||||
public function singerLevelUp($user_id,$coin)
|
||||
{
|
||||
//判断用户是否认证歌手
|
||||
$is_singer = db::name('vs_singer')->where(['user_id' => $user_id,'status' => 1])->find();
|
||||
if ($is_singer) {
|
||||
//增加经验值并且判断是否可以升级
|
||||
$exp = db::name('vs_singer')->where(['id' => $is_singer['id']])->value('exp');
|
||||
$exp_coin = round($coin / get_system_config_value('singer_coin_exp'), 2);
|
||||
$exps = $exp + $exp_coin;
|
||||
//查询等级
|
||||
$level = db::name('vs_singer_level')->where(['change_value' => ['<=', $exps]])->order('change_value desc')->find();
|
||||
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);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 切歌
|
||||
* @param room_id 房间id
|
||||
* @param user_id 用户id
|
||||
* @param song_id 歌曲id
|
||||
*/
|
||||
public function singerSongCut($user_id,$song_id)
|
||||
{
|
||||
$sonng_log = db::name('vs_song_log')->where(['id' => $song_id])->find();
|
||||
$singer_user_id = db::name('vs_singer_song')->where(['id' => $sonng_log['singer_song_id']])->value('user_id');
|
||||
//判断用户是否是房主
|
||||
$room_info = db::name('vs_room')->where('id', $sonng_log['room_id'])->field('user_id')->find();
|
||||
//判断用户是否是主持
|
||||
$room_user_info = db::name('vs_room_host')->where(['room_id' => $sonng_log['room_id'], 'user_id' => $user_id,'delete_time' => null])->find();
|
||||
if ($room_info['user_id'] != $user_id && !$room_user_info && $singer_user_id != $user_id) {
|
||||
return ['code' => 0, 'msg' => '您没有权限切歌','data' => null];
|
||||
}
|
||||
if ($sonng_log) {
|
||||
if ($sonng_log['status'] == 1) {
|
||||
$up = db::name('vs_song_log')->where(['id' => $song_id])->update(['status' => 2]);
|
||||
if ($up) {
|
||||
$id = db::name('vs_song_log')->where(['room_id' => $sonng_log['room_id'],'status' => 0])->order('sort desc')->value('id');
|
||||
if($id){
|
||||
db::name('vs_song_log')->where(['id' => $id])->update(['status' => 1]);
|
||||
//给前端推送
|
||||
//获取当前房间内点歌总数
|
||||
$song_info_count = db::name('vs_song_log')->where(['room_id' => $sonng_log['room_id'],'status' => ['in',[0,1]]])->count();
|
||||
//给前端推送
|
||||
$text = [
|
||||
'text' => '房间点歌数量变化',
|
||||
'count' => $song_info_count
|
||||
];
|
||||
model('Chat')->sendMsg(1072,$sonng_log['room_id'],$text);
|
||||
|
||||
//房间当前演唱歌曲
|
||||
$song_info = db::name('vs_song_log')->where(['id' => $id])->find();
|
||||
$song_info['boss_user_id'] = $song_info['user_id'];
|
||||
$song_info['boss_nickname'] = db::name('user')->where(['id' => $song_info['user_id']])->value('nickname');
|
||||
$song_info['boss_avatar'] = db::name('user')->where(['id' => $song_info['user_id']])->value('avatar');
|
||||
$song_info['boss_dress'] = model('api/Decorate')->user_decorate_detail($song_info['user_id'], 1);
|
||||
$song_info['boss_mic_cycle'] = model('api/Decorate')->user_decorate_detail($song_info['user_id'],3);
|
||||
$singer_song = db::name('vs_singer_song')->where(['id' => $song_info['singer_song_id']])->find();
|
||||
$song_info['singer_user_id'] = $singer_song['user_id'];
|
||||
$song_info['singer_nickname'] = db::name('user')->where(['id' => $singer_song['user_id']])->value('nickname');
|
||||
$song_info['singer_avatar'] = db::name('user')->where(['id' => $singer_song['user_id']])->value('avatar');
|
||||
$song_info['singer_dress'] = model('api/Decorate')->user_decorate_detail($singer_song['user_id'], 1);
|
||||
$song_info['singer_mic_cycle'] = model('api/Decorate')->user_decorate_detail($singer_song['user_id'],3);
|
||||
$song_info['song_name'] = $singer_song['song_name'];
|
||||
|
||||
$song_info_data = [
|
||||
'text' => '房间当前演唱歌曲变化',
|
||||
'song_info' => $song_info
|
||||
];
|
||||
model('Chat')->sendMsg(1070,$sonng_log['room_id'],$song_info_data);
|
||||
|
||||
//给前端推送下首歌曲信息
|
||||
$next_song_info = db::name('vs_song_log')->where(['room_id' => $sonng_log['room_id'],'status' => 0])->order('sort desc')->find();
|
||||
if($next_song_info){
|
||||
$next_song_info['boss_user_id'] = $next_song_info['user_id'];
|
||||
$next_song_info['boss_nickname'] = db::name('user')->where(['id' => $next_song_info['user_id']])->value('nickname');
|
||||
$next_song_info['boss_avatar'] = db::name('user')->where(['id' => $next_song_info['user_id']])->value('avatar');
|
||||
$next_song_info['boss_dress'] = model('api/Decorate')->user_decorate_detail($next_song_info['user_id'], 1);
|
||||
$next_song_info['boss_mic_cycle'] = model('api/Decorate')->user_decorate_detail($next_song_info['user_id'],3);
|
||||
$singer_song = db::name('vs_singer_song')->where(['id' => $next_song_info['singer_song_id']])->find();
|
||||
$next_song_info['singer_user_id'] = $singer_song['user_id'];
|
||||
$next_song_info['singer_nickname'] = db::name('user')->where(['id' => $singer_song['user_id']])->value('nickname');
|
||||
$next_song_info['singer_avatar'] = db::name('user')->where(['id' => $singer_song['user_id']])->value('avatar');
|
||||
$next_song_info['singer_dress'] = model('api/Decorate')->user_decorate_detail($singer_song['user_id'], 1);
|
||||
$next_song_info['singer_mic_cycle'] = model('api/Decorate')->user_decorate_detail($singer_song['user_id'],3);
|
||||
$next_song_info['song_name'] = $singer_song['song_name'];
|
||||
}else{
|
||||
$next_song_info = null;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'text' => '房间下一首演唱歌曲变化',
|
||||
'next_song_info' => $next_song_info
|
||||
];
|
||||
model('Chat')->sendMsg(1071,$sonng_log['room_id'],$data);
|
||||
|
||||
}else{
|
||||
$song_info_data = [
|
||||
'text' => '房间当前演唱歌曲变化',
|
||||
'song_info' => null
|
||||
];
|
||||
model('Chat')->sendMsg(1070,$sonng_log['room_id'],$song_info_data);
|
||||
|
||||
$data = [
|
||||
'text' => '房间下一首演唱歌曲变化',
|
||||
'next_song_info' => null
|
||||
];
|
||||
model('Chat')->sendMsg(1071,$sonng_log['room_id'],$data);
|
||||
return ['code' => 0, 'msg' => '暂无歌曲,请点歌吧','data' => null];
|
||||
}
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => '切歌失败','data' => null];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => '网络错误','data' => null];
|
||||
}
|
||||
return ['code' => 1, 'msg' => '切歌成功','data' => null];
|
||||
}
|
||||
}
|
||||
@@ -42,20 +42,9 @@ class Sms extends Model
|
||||
return ['code' => 0, 'msg' => '验证码错误次数过多,账号已被封禁,请联系管理员处理','data' =>null];
|
||||
}
|
||||
|
||||
$is_code = db::name('sms')->where(['mobile' => $mobile, 'event' => $type])->order('id desc')->find();
|
||||
$is_code = db::name('sms')->where(['mobile' => $mobile, 'event' => $type,'deletetime' => 0])->order('id desc')->find();
|
||||
if ($is_code && $is_code['code'] == $code) {
|
||||
//验证码正确
|
||||
if($type == 1 || $type == 2){
|
||||
//查询手机号绑定的数量
|
||||
$map = [];
|
||||
$map['mobile'] = $mobile;
|
||||
$map['status'] = 1;
|
||||
$user_info = db::name('user')->where($map)->count();
|
||||
if($user_info >= 4){
|
||||
return ['code' => 0, 'msg' => '该手机号已达绑定上线','data' =>null];
|
||||
}
|
||||
}
|
||||
db::name('sms')->where(['mobile' => $mobile, 'event' => $type])->delete();
|
||||
db::name('sms')->where(['mobile' => $mobile, 'event' => $type])->update(['deletetime' => time()]);
|
||||
//登陆成功后 把所有的登录错误删除掉
|
||||
db::name('sms_error')->where(['mobile' => $mobile])->delete();
|
||||
return ['code' =>1, 'msg' =>'验证码正确','data' =>null];
|
||||
|
||||
938
application/api/model/Tasks.php
Normal file
938
application/api/model/Tasks.php
Normal file
@@ -0,0 +1,938 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
use think\Model;
|
||||
use think\Session;
|
||||
use think\Db;
|
||||
|
||||
class Tasks extends Model
|
||||
{
|
||||
|
||||
// 开启自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'int';
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
protected $table;
|
||||
//任务类型枚举
|
||||
public $task_type = [
|
||||
'1' => '新手任务',
|
||||
'2' => '每日任务',
|
||||
'3' => '情侣任务',
|
||||
'4' => '师徒任务',
|
||||
];
|
||||
//每日任务类型枚举
|
||||
public $processing_type_str = [
|
||||
1 => '登录',
|
||||
2 => '去观看',
|
||||
3 => '去完成',
|
||||
4 => '去送礼',
|
||||
5 => '去邀请',
|
||||
6 => '去充值',
|
||||
7 => '去发布',
|
||||
8 => '签到',
|
||||
9 => '自动完成',
|
||||
];
|
||||
//任务跳转类型:
|
||||
public $jump_type = [
|
||||
0 => '不跳转',
|
||||
1 => '跳转实名',
|
||||
2 => '跳转我的相册',
|
||||
3 => '跳转绑定管理',
|
||||
4 => '跳转房间',
|
||||
5 => '跳转申请加入公会',
|
||||
6 => '跳转充值',
|
||||
7 => '跳转创建房间',
|
||||
];
|
||||
|
||||
public function __construct($data = [])
|
||||
{
|
||||
$prefix = config('database.prefix');
|
||||
$this->table = $prefix . 'vs_tasks';
|
||||
parent::__construct($data);
|
||||
|
||||
}
|
||||
//每日任务列表
|
||||
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])
|
||||
->whereTime('createtime', 'today')
|
||||
->sum('change_value');
|
||||
$reslut['user_gold'] = $user_gold ? $user_gold : 0;
|
||||
//礼盒列表
|
||||
$gift_box = Db::name('vs_gift_bag')->where('status',1)->where('activities_id',2)->select();
|
||||
$reslut['gift_box_list'] = [];
|
||||
foreach ($this->task_type as $key => $value) {
|
||||
$reslut['tasks'][$key-1]['task_type_id'] = $key;
|
||||
$reslut['tasks'][$key-1]['task_type_name'] = $value;
|
||||
$reslut['tasks'][$key-1]['is_lock'] = 0;
|
||||
$reslut['tasks'][$key-1]['task_list'] = [];
|
||||
}
|
||||
foreach ($gift_box as $key => $val) {
|
||||
$reslut['gift_box_list'][$key]['id'] = $val['id'];
|
||||
$reslut['gift_box_list'][$key]['name'] = $val['name'];
|
||||
$reslut['gift_box_list'][$key]['title'] = $val['title'];
|
||||
$reslut['gift_box_list'][$key]['icon'] = localpath_to_netpath($val['icon']);
|
||||
$ext = json_decode($val['ext'],true);
|
||||
$reslut['gift_box_list'][$key]['highest_gain'] = $ext['highest_gain'];
|
||||
$reslut['gift_box_list'][$key]['meet'] = $ext['meet'] ? $ext['meet'] : 0;
|
||||
//解锁进度
|
||||
if($ext['meet']){
|
||||
if($user_gold > $ext['meet']){
|
||||
$reslut['gift_box_list'][$key]['unlock_progress'] = 1;
|
||||
}else{
|
||||
$reslut['gift_box_list'][$key]['unlock_progress'] = round(( $user_gold / $ext['meet']),2);
|
||||
}
|
||||
}else{
|
||||
$reslut['gift_box_list'][$key]['unlock_progress'] = 0;
|
||||
}
|
||||
//今日可抽奖次数
|
||||
$reslut['gift_box_list'][$key]['all_number'] = $ext['num'] ? $ext['num'] : 0;
|
||||
//今日已抽奖次数
|
||||
$reslut['gift_box_list'][$key]['taday_number'] = Db::name('vs_gift_bag_receive_log')->where('user_id',$user_id)->where('gift_bag_id',$val['id'])->whereTime('createtime', 'today')->count();
|
||||
//今日剩余抽奖次数
|
||||
$reslut['gift_box_list'][$key]['taday_number_left'] = $ext['num'] - $reslut['gift_box_list'][$key]['taday_number'];
|
||||
//状态
|
||||
if ($user_gold < $ext['meet']) {
|
||||
$reslut['gift_box_list'][$key]['status'] = 0;
|
||||
$reslut['gift_box_list'][$key]['status_str'] = '未解锁';
|
||||
} else {
|
||||
$reslut['gift_box_list'][$key]['status'] = 1;
|
||||
$reslut['gift_box_list'][$key]['status_str'] = '已解锁('.$reslut['gift_box_list'][$key]['taday_number'].'/'.$ext['num'].')';
|
||||
}
|
||||
if ($reslut['gift_box_list'][$key]['taday_number']>=$ext['num']) {
|
||||
$reslut['gift_box_list'][$key]['status'] = 2;
|
||||
$reslut['gift_box_list'][$key]['status_str'] = '已用完('.$reslut['gift_box_list'][$key]['taday_number'].'/'.$ext['num'].')';
|
||||
}
|
||||
}
|
||||
//任务列表
|
||||
$data = db::name('vs_tasks')
|
||||
->field('id as task_id,icon,task_name,target_quantity,task_type,jump_type,tasks_bag_id')
|
||||
->where('delete_time',0)
|
||||
->where('is_active',1)
|
||||
->order('sort desc,id asc')->select();
|
||||
foreach ($data as $k => $v) {
|
||||
//完成进度
|
||||
$v['from_id'] = 0;
|
||||
$v['is_time'] = 0;
|
||||
//奖励详情
|
||||
$v['reward_str'] = "";
|
||||
if($v['task_id'] != 1){
|
||||
$reward_info = db::name('vs_gift_bag_detail')->where('gift_bag_id',$v['tasks_bag_id'])->select();
|
||||
foreach ($reward_info as $key => $value) {
|
||||
if($value['type'] == 1){
|
||||
$reward_name = $value['quantity'].$value['name'];
|
||||
}elseif($value['type'] == 2){
|
||||
$reward_name = $value['name'].'x'.$value['quantity'];
|
||||
}elseif($value['type'] == 3){
|
||||
$reward_name = $value['name'].'x'.$value['days'].'天';
|
||||
}else{
|
||||
$reward_name = $value['quantity'].$value['name'];
|
||||
}
|
||||
$v['reward_str'] =$v['reward_str'].$reward_name." ";
|
||||
}
|
||||
}
|
||||
if($v['task_type'] == 2){
|
||||
//今日完成进度
|
||||
$user_daily_tasks = Db::name('vs_tasks_user_daily')
|
||||
->where('user_id',$user_id)
|
||||
->where('task_id',$v['task_id'])
|
||||
->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($v['jump_type']==4){
|
||||
//跳转的房间路径
|
||||
$v['from_id'] = model('api/Room')->task_jump_room_recommend($v['task_id']);
|
||||
}
|
||||
}
|
||||
if(in_array($v['task_id'],[21,22,23])){
|
||||
$i = 0;
|
||||
$sign_student_list = [];
|
||||
$first_sign_student_list = db::name('vs_tasks_student')
|
||||
->where('user_id',$user_id)
|
||||
->where('task_id',$v['task_id'])
|
||||
->where('delete_time', 0)
|
||||
->select();
|
||||
if(empty($first_sign_student_list)){
|
||||
continue;
|
||||
}else{
|
||||
//徒弟列表
|
||||
foreach ($first_sign_student_list as $key => $value) {
|
||||
if($v['task_id'] == 21){
|
||||
$title = "拍卖房停留({$value['value']} / {$v['target_quantity']})分钟";
|
||||
}elseif($v['task_id'] == 22){
|
||||
$title = "点唱房点歌({$value['value']} / {$v['target_quantity']})首";
|
||||
}elseif($v['task_id'] == 23){
|
||||
$title = "互娱房停留({$value['value']} / {$v['target_quantity']})分钟";
|
||||
}
|
||||
$sign_student_list[$i]['task_id'] = $v['task_id'];
|
||||
$sign_student_list[$i]['icon'] = "";
|
||||
$sign_student_list[$i]['target_quantity'] = $v['target_quantity'];
|
||||
$sign_student_list[$i]['task_type'] = $v['task_type'];
|
||||
$sign_student_list[$i]['jump_type'] = $v['jump_type'];
|
||||
$sign_student_list[$i]['tasks_bag_id'] = $v['tasks_bag_id'];
|
||||
$sign_student_list[$i]['student_id'] = $value['student_id'];
|
||||
$student_nickname = db::name('user')->where('id',$value['student_id'])->value('nickname');
|
||||
$sign_student_list[$i]['task_name'] = '邀请 '.$student_nickname." 徒弟在 {$title},并送给徒弟特殊礼物";
|
||||
$sign_student_list[$i]['reward_str'] = $v['reward_str'];
|
||||
$sign_student_list[$i]['from_id'] = model('api/Room')->task_jump_room_recommend($v['task_id'],$value['student_id']);
|
||||
if($value['status']==0){
|
||||
$sign_student_list[$i]['task_status'] = 1;
|
||||
$sign_student_list[$i]['task_type_str'] = "去完成";
|
||||
}elseif($value['status']==1){
|
||||
$sign_student_list[$i]['task_status'] = 2;
|
||||
$sign_student_list[$i]['task_type_str'] = "领取奖励";
|
||||
}else{
|
||||
$sign_student_list[$i]['task_status'] = 3;
|
||||
$sign_student_list[$i]['task_type_str'] = "已领取";
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($v['task_id'] == 24){
|
||||
//师徒任务
|
||||
//师傅签约返还
|
||||
$user_sign_task = Db::name('vs_user_sign_task')->where(['user_id'=>$user_id,'day'=>date('Y-m-d')])->find();
|
||||
if(empty($user_sign_task)){
|
||||
continue;
|
||||
}
|
||||
$user_sign_task_count = Db::name('vs_user_sign_task')->where(['user_id'=>$user_id])->count();
|
||||
$v['gold_reward'] = $user_sign_task['value'];
|
||||
$v['target_quantity'] = $v['target_quantity'] * $user_sign_task_count;
|
||||
$v['is_time'] = 1;
|
||||
if($user_sign_task['status']==1){
|
||||
$progress = $user_sign_task['times'] ?? 0;
|
||||
}else{
|
||||
$progress = $user_sign_task['times']-1 ?? 0;
|
||||
}
|
||||
if($user_sign_task['status']==1){
|
||||
$v['task_status'] = 3;
|
||||
$v['task_type_str'] = "已领取";
|
||||
}else{
|
||||
$v['task_status'] = 2;
|
||||
$v['task_type_str'] = "领取奖励";
|
||||
}
|
||||
$v['reward_str'] = $user_sign_task['value']." 个钻石";
|
||||
}elseif(in_array($v['task_id'],[26,27,28,29,30,31,32])){
|
||||
$user_couple_times =[26=>1,27=>2,28=>3,29=>4,30=>5,31=>6,32=>7];
|
||||
//情侣任务
|
||||
$user_couple_task = Db::name('vs_user_cp_task')->where(['user_id'=>$user_id,'times'=>$user_couple_times[$v['task_id']],'delete_time'=>0])->find();
|
||||
if(empty($user_couple_task)){
|
||||
continue;
|
||||
}
|
||||
$v['task_name'] = "第{$user_couple_times[$v['task_id']]}天:情侣等级提升 ({$user_couple_task['need_exp_value']})经验值,并在某一房间共同相处{$user_couple_task['need_time_value']}分钟";
|
||||
if($user_couple_task['status'] ==0 && $user_couple_task['day']==date('Y-m-d')){
|
||||
$v['task_status'] = 1;
|
||||
$v['task_type_str'] = "待完成";
|
||||
}elseif($user_couple_task['status'] ==1){
|
||||
$v['task_status'] = 2;
|
||||
$v['task_type_str'] = "领取奖励";
|
||||
}elseif($user_couple_task['status'] ==2){
|
||||
$v['task_status'] = 3;
|
||||
$v['task_type_str'] = "已领取";
|
||||
}else{
|
||||
$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) {
|
||||
$v['task_status'] =3;
|
||||
$v['task_type_str'] = "已签到";
|
||||
}else{
|
||||
$v['task_status'] = 1;
|
||||
$v['task_type_str'] = "去签到";
|
||||
}
|
||||
}else{
|
||||
//处理状态
|
||||
$v['task_status'] = 1;
|
||||
$v['task_type_str'] = "去完成";
|
||||
if(isset($user_daily_tasks['is_completed']) && $user_daily_tasks['is_completed'] ==1){ //已完成
|
||||
$v['task_status'] = 2;
|
||||
$v['task_type_str'] = "领取奖励";
|
||||
}
|
||||
if(isset($user_daily_tasks['is_claimed']) && $user_daily_tasks['is_claimed'] ==1){ //已完成
|
||||
$v['task_status'] = 3;
|
||||
$v['task_type_str'] = "已领取";
|
||||
}
|
||||
}
|
||||
if($v['task_id'] != 24) {
|
||||
$progress = isset($user_daily_tasks['current_progress']) ? $user_daily_tasks['current_progress'] : 0;
|
||||
}
|
||||
$quantity_str = "";
|
||||
if($v['target_quantity']!=1){
|
||||
if($progress > $v['target_quantity']){
|
||||
$progress = $v['target_quantity'];
|
||||
}
|
||||
$quantity_str= "({$progress}/{$v['target_quantity']})";
|
||||
}
|
||||
$v['task_name'] = $v['task_name'].$quantity_str;
|
||||
$v['jump_type_str'] = $this->jump_type[$v['jump_type']];
|
||||
//返回任务列表
|
||||
if($v['task_type']!=4){
|
||||
$reslut['tasks'][$v['task_type']-1]['task_list'][] = $v;
|
||||
}else{
|
||||
if($v['task_id'] == 24){
|
||||
$reslut['tasks'][$v['task_type']-1]['task_list'][] = $v;
|
||||
}else{
|
||||
if(!empty($sign_student_list)){
|
||||
foreach ($sign_student_list as $key => $value) {
|
||||
$reslut['tasks'][$v['task_type']-1]['task_list'][] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($reslut['tasks'] as &$value) {
|
||||
if(empty($value['task_list'])){
|
||||
$value['is_lock'] = 1;
|
||||
}
|
||||
$value['wait_reward_num'] = 0;
|
||||
//待领取数量
|
||||
foreach ($value['task_list'] as &$v) {
|
||||
if($v['task_status'] == 2){
|
||||
$value['wait_reward_num'] = $value['wait_reward_num']+1;
|
||||
}
|
||||
}
|
||||
//排序 $v['task_status'] 字段按照 [2 1 3]
|
||||
usort($value['task_list'], function ($a, $b) {
|
||||
$order = [2 => 0, 1 => 1, 3 => 2];
|
||||
return $order[$a['task_status']] - $order[$b['task_status']];
|
||||
});
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $reslut];
|
||||
}
|
||||
//完成每日任务
|
||||
public function tasks_complete($user_id,$task_id,$ext_value='',$student_id = 0){
|
||||
if($task_id ==15){
|
||||
$current_progress = $ext_value!='' ? $ext_value : 1;
|
||||
}else{
|
||||
$current_progress =1;
|
||||
}
|
||||
//查询任务
|
||||
$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];
|
||||
}
|
||||
//查询用户每日任务进度表
|
||||
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();
|
||||
}
|
||||
$is_completed = 0;
|
||||
$completion_time = null;
|
||||
if(in_array($task_id,[21,22,23])){
|
||||
$task_student_data =[];
|
||||
$task_student = Db::name('vs_tasks_student')->where(['user_id'=>$user_id,'task_id'=>$task_id,'student_id'=>$student_id,'status'=>0,'delete_time'=>0])->find();
|
||||
if(empty($task_student)){
|
||||
return ['code' => 0, 'msg' => '任务不存在或已删除','data' => null];
|
||||
}
|
||||
if($ext_value==1){
|
||||
if($task_info['target_quantity'] <= $task_student['value']){
|
||||
return ['code' => 1, 'msg' => '操作成功','data' => ['is_completed'=>1]];
|
||||
}else{
|
||||
$current_progress = $task_student['value']+1;
|
||||
if($task_info['target_quantity']==$current_progress && $task_student['is_reward']==1){
|
||||
$task_student_data['status'] = 1;
|
||||
$is_completed = 1;
|
||||
}
|
||||
$task_student_data['value'] = $current_progress;
|
||||
}
|
||||
|
||||
}else{
|
||||
$current_progress = $task_student['value'];
|
||||
if($task_info['target_quantity']==$current_progress){
|
||||
$task_student_data['status'] = 1;
|
||||
$is_completed = 1;
|
||||
}
|
||||
$task_student_data['is_reward'] = 1;
|
||||
}
|
||||
$task_student_data['updatetime'] = time();
|
||||
$reslut = Db::name('vs_tasks_student')->where('id',$task_student['id'])->update($task_student_data);
|
||||
}else{
|
||||
if ($user_daily_tasks && $user_daily_tasks['is_completed'] == 1) {
|
||||
return ['code' => 0, 'msg' => '您已完成该任务','data' => null];
|
||||
}
|
||||
if ($user_daily_tasks) {
|
||||
if($user_daily_tasks['current_progress'] > $task_info['target_quantity']){
|
||||
$current_progress = $task_info['target_quantity'];
|
||||
}else{
|
||||
$current_progress = $user_daily_tasks['current_progress'] +$current_progress;
|
||||
}
|
||||
if($task_info['target_quantity']==$current_progress){
|
||||
$is_completed = 1;
|
||||
$completion_time = time();
|
||||
}
|
||||
$reslut = Db::name('vs_tasks_user_daily')->where('id',$user_daily_tasks['id'])->update([
|
||||
'current_progress' => $current_progress,
|
||||
'is_completed'=> $is_completed,
|
||||
'ext' => $ext_value,
|
||||
'completion_time' => $completion_time,
|
||||
]);
|
||||
}else{
|
||||
if($task_info['target_quantity'] == 1){
|
||||
$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 ($reslut) {
|
||||
if($is_completed==1){
|
||||
if(in_array($task_id,[16,13,21,22,23])){
|
||||
model('Tasks')->tasks_complete($user_id,17);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '操作成功','data' => ['is_completed'=>1]];
|
||||
}else{
|
||||
return ['code' => 1, 'msg' => '操作成功','data' => ['is_completed'=>0]];
|
||||
}
|
||||
} else {
|
||||
return ['code' => 0, '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){
|
||||
return ['code' => 0, 'msg' => '请先实名认证','data' => null];
|
||||
}else{
|
||||
if($is_real['data']['is_real'] !=1){
|
||||
return ['code' => 0, 'msg' => '请先实名认证','data' => null];
|
||||
}
|
||||
}
|
||||
$task_info = Db::name('vs_tasks')->where('id',$task_id)->find();
|
||||
if (!$task_info) {
|
||||
return ['code' => 0, 'msg' => '任务不存在','data' => null];
|
||||
}
|
||||
if($task_id==24){
|
||||
//师徒任务
|
||||
//师傅签约返还
|
||||
$user_sign_task = Db::name('vs_user_sign_task')->where(['user_id'=>$user_id,'day'=>date('Y-m-d')])->find();
|
||||
if (!$user_sign_task) {
|
||||
return ['code' => 0, 'msg' => '任务不存在或已结束','data' => null];
|
||||
}
|
||||
if($user_sign_task['status']==1){
|
||||
return ['code' => 0, 'msg' => '您已领取该奖励','data' => null];
|
||||
}
|
||||
}elseif(in_array($task_id,[21,22,23])){
|
||||
if($student_id){
|
||||
$task_student = Db::name('vs_tasks_student')->where(['user_id'=>$user_id,'task_id'=>$task_id,'student_id'=>$student_id,'status'=>1,'delete_time'=>0])->find();
|
||||
if (!$task_student) {
|
||||
return ['code' => 0, 'msg' => '任务不存在或已结束','data' => null];
|
||||
}
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => '任务不存在','data' => null];
|
||||
}
|
||||
}elseif(in_array($task_id,[26,27,28,29,30,31,32])){
|
||||
$user_couple_times =[26=>1,27=>2,28=>3,29=>4,30=>5,31=>6,32=>7];
|
||||
//情侣任务
|
||||
$user_couple_task = Db::name('vs_user_cp_task')->where(['user_id'=>$user_id,'times'=>$user_couple_times[$task_id],'delete_time'=>0])->find();
|
||||
if (!$user_couple_task) {
|
||||
return ['code' => 0, 'msg' => '任务不存在或已结束','data' => null];
|
||||
}
|
||||
if ($user_couple_task['status'] == 2) {
|
||||
return ['code' => 0, 'msg' => '您已领取该奖励','data' => null];
|
||||
}
|
||||
if ($user_couple_task['status'] == 0) {
|
||||
return ['code' => 0, 'msg' => '请先去完成该任务再领取','data' => null];
|
||||
}
|
||||
if($user_couple_task['day'] != date('Y-m-d')){
|
||||
return ['code' => 0, 'msg' => '已过期或未到领取时间','data' => null];
|
||||
}
|
||||
}else{
|
||||
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 (!$user_daily_tasks) {
|
||||
return ['code' => 0, 'msg' => '请完成该任务','data' => null];
|
||||
}
|
||||
if ($user_daily_tasks['is_completed'] == 0) {
|
||||
return ['code' => 0, 'msg' => '请完成该任务','data' => null];
|
||||
}
|
||||
if ($user_daily_tasks['is_claimed'] == 1) {
|
||||
return ['code' => 0, 'msg' => '您已领取该奖励','data' => null];
|
||||
}
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
if($task_id==24){
|
||||
//师徒任务
|
||||
$reslut = Db::name('vs_user_sign_task')->where('id',$user_sign_task['id'])->update([
|
||||
'status' => 1
|
||||
]);
|
||||
if (!$reslut) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||
}
|
||||
Db::name('vs_tasks_user_daily')->insert([
|
||||
'user_id' => $user_id,
|
||||
'task_id' => $task_id,
|
||||
'tasks_bag_id' => $task_info['tasks_bag_id'],
|
||||
'is_completed' => 1,
|
||||
'is_claimed' => 1,
|
||||
'createtime' => time(),
|
||||
'completion_time' => $user_sign_task['createtime'],
|
||||
'collection_time' => time(),
|
||||
]);
|
||||
}elseif(in_array($task_id,[21,22,23])) {
|
||||
$reslut = Db::name('vs_tasks_student')->where('id', $task_student['id'])->update([
|
||||
'status' => 2,
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
Db::name('vs_tasks_user_daily')->insert([
|
||||
'user_id' => $user_id,
|
||||
'task_id' => $task_id,
|
||||
'tasks_bag_id' => $task_info['tasks_bag_id'],
|
||||
'is_completed' => 1,
|
||||
'is_claimed' => 1,
|
||||
'createtime' => time(),
|
||||
'completion_time' => $task_student['createtime'],
|
||||
'collection_time' => time(),
|
||||
]);
|
||||
}elseif(in_array($task_id,[26,27,28,29,30,31,32])){
|
||||
$reslut = Db::name('vs_user_cp_task')->where(['id'=>$user_couple_task['id']])->update([
|
||||
'status' => 2
|
||||
]);
|
||||
Db::name('vs_tasks_user_daily')->insert([
|
||||
'user_id' => $user_id,
|
||||
'task_id' => $task_id,
|
||||
'tasks_bag_id' => $task_info['tasks_bag_id'],
|
||||
'is_completed' => 1,
|
||||
'is_claimed' => 1,
|
||||
'createtime' => time(),
|
||||
'completion_time' => $user_couple_task['createtime'],
|
||||
'collection_time' => time(),
|
||||
]);
|
||||
} else{
|
||||
$reslut = Db::name('vs_tasks_user_daily')->where('id',$user_daily_tasks['id'])->update([
|
||||
'is_claimed' => 1,
|
||||
'collection_time' => time(),
|
||||
]);
|
||||
if (!$reslut) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
//24不发礼包
|
||||
if($task_id!=24){
|
||||
//发放任务礼包
|
||||
$op_bag_re = $this->open_tasks_bag($user_id,$task_info['tasks_bag_id']);
|
||||
if ($op_bag_re['code'] != 1) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => $op_bag_re['msg'], 'data' => null];
|
||||
}
|
||||
}else{
|
||||
//24发钻石
|
||||
//发放钻石
|
||||
$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();
|
||||
return ['code' => 0, 'msg' => $res['msg'], 'data' => null];
|
||||
}
|
||||
}
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
return ['code' => 1, 'msg' => "领取成功", 'data' => null];
|
||||
}catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => "请重试", 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//任务礼盒发放
|
||||
public function open_tasks_bag($user_id,$gift_box_id){
|
||||
$gift_box_info = Db::name('vs_gift_bag')->where('id',$gift_box_id)->find();
|
||||
if (!$gift_box_info) {
|
||||
return ['code' => 0, 'msg' => '礼包不存在','data' => null];
|
||||
}
|
||||
//查询礼盒详情
|
||||
$gift_bag_detail = DB::name('vs_gift_bag_detail')->where(['gift_bag_id'=>$gift_box_id])->select();
|
||||
if (!$gift_bag_detail) {
|
||||
return ['code' => 0, 'msg' => '礼包未配置','data' => null];
|
||||
}
|
||||
foreach ($gift_bag_detail as $k=>$v){
|
||||
switch ($v['type']) {
|
||||
case 1: //金币 方法1:直接添加到用户钱包
|
||||
$res = model('common/UserWallet')->change_user_money($user_id, $v['quantity'], model('common/UserWallet')::MONEYTYPECOIN, model('common/UserWallet')::DAILY_TASKS_REWARD,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::DAILY_TASKS_REWARD));
|
||||
break;
|
||||
case 2: //礼物 方法2:添加到用户礼物背包
|
||||
$res = model('UserGiftPack')->change_user_gift_pack($user_id,$v['foreign_id'],$v['quantity'],model('UserGiftPack')::TASK_REWARD,"完成任务获得礼物");
|
||||
break;
|
||||
case 3: //坐骑 方法3:添加到用户装扮
|
||||
$decorate_price_info = db::name('vs_decorate_price')->where(['id'=>$v['foreign_id']])->find();
|
||||
if(empty($decorate_price_info)){
|
||||
break;
|
||||
}
|
||||
$res = model('Decorate')->pay_decorate($user_id,$decorate_price_info['did'],$decorate_price_info['day'],10);
|
||||
break;
|
||||
case 4: //道具 方法5:钻石
|
||||
$res = model('common/UserWallet')->change_user_money($user_id, $v['quantity'], model('common/UserWallet')::MONEYTYPEARNINGS, model('common/UserWallet')::DAILY_TASKS_REWARD,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::DAILY_TASKS_REWARD));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if ($res['code'] != 1) {
|
||||
return ['code' => 0, 'msg' => $res['msg'], 'data' => null];
|
||||
}
|
||||
// 记录日志
|
||||
//添加礼盒记录
|
||||
$reslut = Db::name('vs_gift_bag_receive_log')->insert([
|
||||
'user_id' => $user_id,
|
||||
'gift_bag_id' => $gift_box_id,
|
||||
'parent_id' => $v['id'],
|
||||
'gift_id'=> $v['foreign_id'],
|
||||
'num' => $v['quantity'],
|
||||
'bag_price' => $gift_box_info['money'],
|
||||
'gift_price' => $v['gold'],
|
||||
'createtime' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
if (!$reslut) {
|
||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => '操作成功','data' => null];
|
||||
}
|
||||
|
||||
/*
|
||||
* 开启礼盒
|
||||
* $user_id 用户id
|
||||
* $gift_box_id 礼盒id
|
||||
*/
|
||||
public function open_gift_box($user_id,$gift_box_id){
|
||||
$gift_box_info = Db::name('vs_gift_bag')->where('id',$gift_box_id)->find();
|
||||
if (!$gift_box_info) {
|
||||
return ['code' => 0, 'msg' => '礼盒不存在','data' => null];
|
||||
}
|
||||
$ext = json_decode($gift_box_info['ext'],true);
|
||||
$gift_bag_receive_num = Db::name('vs_gift_bag_receive_log')->where('user_id',$user_id)->where('gift_bag_id',$gift_box_id)->whereTime('createtime', 'today')->count();
|
||||
if ($gift_bag_receive_num >= $ext['num']) {
|
||||
return ['code' => 0, 'msg' => '您已领取该礼盒','data' => null];
|
||||
}
|
||||
//查询礼盒详情
|
||||
$user_gift_box_details = db::name("vs_gift_bag_detail")->where('gift_bag_id',$gift_box_id)->orderRaw('rand()')->find();
|
||||
if (!$user_gift_box_details) {
|
||||
return ['code' => 0, 'msg' => '礼盒不存在','data' => null];
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
switch ($user_gift_box_details['type']) {
|
||||
case 1: //金币 方法1:直接添加到用户钱包
|
||||
$res = model('common/UserWallet')->change_user_money($user_id, $user_gift_box_details['quantity'], model('common/UserWallet')::MONEYTYPECOIN, model('common/UserWallet')::GIFT_BOX_REWARD,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::GIFT_BOX_REWARD));
|
||||
$return_data['gift_name']= "恭喜获得".$user_gift_box_details['gold']."金币";
|
||||
break;
|
||||
case 2: //礼物 方法2:添加到用户礼物背包
|
||||
$res = model('UserGiftPack')->change_user_gift_pack($user_id,$user_gift_box_details['foreign_id'],$user_gift_box_details['quantity'],model('UserGiftPack')::GIFT_PACK_GET,$gift_box_info['name']);
|
||||
$return_data['gift_name']= "恭喜获得".$user_gift_box_details['quantity']."X".$user_gift_box_details['name'];
|
||||
break;
|
||||
case 3: //坐骑 方法3:添加到用户装扮
|
||||
$res = model('Decorate')->pay_decorate($user_id,$user_gift_box_details['foreign_id'],$user_gift_box_details['days'],3);
|
||||
$return_data['gift_name']= "恭喜获得".$user_gift_box_details['quantity']."天".$user_gift_box_details['name'];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if ($res['code'] != 1) {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => $res['msg'], 'data' => null];
|
||||
}
|
||||
//添加礼盒记录
|
||||
$reslut = Db::name('vs_gift_bag_receive_log')->insert([
|
||||
'user_id' => $user_id,
|
||||
'gift_bag_id' => $gift_box_id,
|
||||
'parent_id' => $user_gift_box_details['id'],
|
||||
'gift_id' => $user_gift_box_details['foreign_id'],
|
||||
'num' => $user_gift_box_details['quantity'],
|
||||
'gift_price' => $user_gift_box_details['gold'],
|
||||
'bag_price' => $ext['meet'],
|
||||
'createtime' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
if ($reslut) {
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
return ['code' => 1, 'msg' => '操作成功','data' => $return_data];
|
||||
} else {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '操作失败','data' => null];
|
||||
}
|
||||
}catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => "请重试", 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 礼盒记录
|
||||
*
|
||||
*/
|
||||
public function gift_bag_receive_list($user_id){
|
||||
//查询每日任务礼盒记录
|
||||
$gift_bag_receive_list = Db::name('vs_gift_bag_receive_log')
|
||||
->field('bag.name as gift_bag_name,re.createtime as createtime,de.name as gift_name,de.quantity,de.type,de.foreign_id,de.days,de.gold')
|
||||
->alias('re')
|
||||
->join('vs_gift_bag bag', 'bag.id = re.gift_bag_id', 'LEFT')
|
||||
->join('vs_gift_bag_detail de', 'de.id = re.parent_id', 'LEFT')
|
||||
->where(['re.user_id'=>$user_id,'bag.activities_id'=>2,'bag.status'=>1])
|
||||
->order('re.createtime desc')
|
||||
->select();
|
||||
if (!$gift_bag_receive_list) {
|
||||
return ['code' => 0, 'msg' => '没有礼盒记录','data' => null];
|
||||
}
|
||||
$result = [];
|
||||
foreach ($gift_bag_receive_list as $k=>$v){
|
||||
$result[$k]['gift_bag_name'] = $v['gift_bag_name'];
|
||||
if($v['type'] == 1){
|
||||
$result[$k]['gift_name'] = $v['gold'].'金币';
|
||||
}elseif ($v['type'] == 2){
|
||||
$result[$k]['gift_name'] = $v['gift_name'].' x '.$v['quantity'];
|
||||
}elseif ($v['type'] == 3){
|
||||
$result[$k]['gift_name'] = $v['gift_name'].' x '.$v['days'].'天';
|
||||
}
|
||||
$result[$k]['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
|
||||
}
|
||||
return ['code' => 1, 'msg' => '操作成功','data' => $result];
|
||||
}
|
||||
|
||||
/*
|
||||
* 用户签到
|
||||
*/
|
||||
public function sign_in($user_id){
|
||||
$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) {
|
||||
return ['code' => 0, 'msg' => '今天已经签到过了','data' => null];
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
//每日签到 【完成任务】
|
||||
$this->tasks_complete($user_id,1);
|
||||
//判断连续签到
|
||||
$continuous = 1;
|
||||
$sign_in_info = Db::name('vs_user_tasks_sign_in')->where(['user_id'=>$user_id,'delete_time'=>0])->order('id desc')->find();
|
||||
if ($sign_in_info) {
|
||||
if ($sign_in_info['sign_in_date'] == date('Y-m-d',strtotime('-1 day'))) {
|
||||
$continuous = $sign_in_info['continuous'] + 1;
|
||||
} else {
|
||||
$continuous = 1;
|
||||
}
|
||||
}
|
||||
$reslut = Db::name('vs_user_tasks_sign_in')->insert([
|
||||
'user_id' => $user_id,
|
||||
'sign_in_date' => date('Y-m-d'),
|
||||
'continuous' => $continuous,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time()
|
||||
]);
|
||||
if ($reslut) {
|
||||
//发放签到礼物
|
||||
$detail_list = DB::name('vs_gift_bag_detail')->where(['gift_bag_id'=>18])->limit(7)->order('id asc')->select();
|
||||
foreach ($detail_list as $k=>$v){
|
||||
$day = $k+1;
|
||||
if($continuous == $day){
|
||||
switch ($v['type']) {
|
||||
case 1: //金币 方法1:直接添加到用户钱包
|
||||
$res = model('common/UserWallet')->change_user_money($user_id, $v['quantity'], model('common/UserWallet')::MONEYTYPECOIN, model('common/UserWallet')::DAILY_SIGN,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::DAILY_SIGN));
|
||||
break;
|
||||
case 2: //礼物 方法2:添加到用户礼物背包
|
||||
$res = model('UserGiftPack')->change_user_gift_pack($user_id,$v['foreign_id'],$v['quantity'],model('UserGiftPack')::DAILY_SIGN,"每日签到获得礼物");
|
||||
break;
|
||||
case 3: //坐骑 方法3:添加到用户装扮
|
||||
$decorate_price_info = db::name('vs_decorate_price')->where(['id'=>$v['foreign_id']])->find();
|
||||
if(empty($decorate_price_info)){
|
||||
break;
|
||||
}
|
||||
$res = model('Decorate')->pay_decorate($user_id,$decorate_price_info['did'],$decorate_price_info['day'],11);
|
||||
break;
|
||||
case 4: //道具 方法5:钻石
|
||||
$res = model('common/UserWallet')->change_user_money($user_id, $v['quantity'], model('common/UserWallet')::MONEYTYPEARNINGS, model('common/UserWallet')::DAILY_SIGN,model('common/UserWallet')::ChangeTypeLable(model('common/UserWallet')::DAILY_SIGN));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
return ['code' => 1, 'msg' => '操作成功','data' => null];
|
||||
} else {
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => '操作失败','data' => null];
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return ['code' => 0, 'msg' => "请重试", 'data' => null];
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 签到页面
|
||||
*/
|
||||
public function daily_tasks_sign_in($user_id){
|
||||
//查询昨天有没有签到
|
||||
$yesterday_sign_in_info = Db::name('vs_user_tasks_sign_in')->where(['user_id'=>$user_id,'sign_in_date'=>date('Y-m-d',strtotime('-1 day'))])->find();
|
||||
if(empty($yesterday_sign_in_info)){
|
||||
db::name('vs_user_tasks_sign_in')->where(['user_id'=>$user_id,'delete_time'=>0])
|
||||
->where('sign_in_date','<>',date('Y-m-d'))
|
||||
->update([
|
||||
'delete_time' => time()
|
||||
]);
|
||||
}else{
|
||||
if($yesterday_sign_in_info['continuous']>=7){
|
||||
db::name('vs_user_tasks_sign_in')->where(['user_id'=>$user_id,'delete_time'=>0])
|
||||
->where('sign_in_date','<>',date('Y-m-d'))
|
||||
->update([
|
||||
'delete_time' => time()
|
||||
]);
|
||||
}
|
||||
}
|
||||
//礼包
|
||||
$detail_list = DB::name('vs_gift_bag_detail')->where(['gift_bag_id'=>18])->limit(7)->order('id asc')->select();
|
||||
$list= [];
|
||||
foreach ($detail_list as $k=>$v){
|
||||
$day = $k+1;
|
||||
$list[$k]['day'] = $day;
|
||||
$sign_in = Db::name('vs_user_tasks_sign_in')->where(['user_id'=>$user_id,'continuous'=>$day,'delete_time'=>0])->find();
|
||||
if($sign_in){
|
||||
$list[$k]['sign_in_date'] = $sign_in['sign_in_date'];
|
||||
$list[$k]['sign_in_status'] = 1;
|
||||
$list[$k]['sign_in_status_str'] = "已签到";
|
||||
}else{
|
||||
if($k==0){
|
||||
$list[$k]['sign_in_date'] = date('Y-m-d');
|
||||
}else{
|
||||
$list[$k]['sign_in_date'] = date('Y-m-d',strtotime($list[$k-1]['sign_in_date'])+86400);
|
||||
}
|
||||
$list[$k]['sign_in_status'] = 0;
|
||||
$list[$k]['sign_in_status_str'] = "未签到";
|
||||
}
|
||||
//是否是当天
|
||||
$list[$k]['is_today'] = $list[$k]['sign_in_date'] == date('Y-m-d') ? 1 : 0;
|
||||
if($v['type'] == 1){
|
||||
$list[$k]['gift_name'] = "金币";
|
||||
$list[$k]['num'] = $v['quantity'];
|
||||
$list[$k]['gift_price'] = $v['gold'];
|
||||
$list[$k]['type'] = 1;
|
||||
$list[$k]['base_image'] = localpath_to_netpath("static/image/icon/gold.png");
|
||||
}elseif($v['type'] == 2) {
|
||||
$gift = DB::name('vs_gift')->where(['gid'=>$v['foreign_id']])->find();
|
||||
$list[$k]['gift_name'] = $gift['gift_name'];
|
||||
$list[$k]['num'] = $v['quantity']." 个";
|
||||
$list[$k]['gift_price'] = $gift['gift_price'];
|
||||
$list[$k]['type'] =2;
|
||||
$list[$k]['base_image'] = $gift['base_image'];
|
||||
} elseif($v['type'] == 3) {
|
||||
$decorate_price = DB::name('vs_decorate_price')->where(['id'=>$v['foreign_id']])->find();
|
||||
$gift = DB::name('vs_decorate')->where(['did'=>$decorate_price['did']])->find();
|
||||
$list[$k]['gift_name'] = $gift['title']; //装扮名称
|
||||
$list[$k]['num'] = $decorate_price['day']." 天"??0; //天数
|
||||
$list[$k]['gift_price'] = $decorate_price['price']; //价格
|
||||
$list[$k]['type'] =3;
|
||||
$list[$k]['base_image'] = $gift['base_image'];
|
||||
}elseif($v['type'] == 4) {
|
||||
$list[$k]['gift_name'] = "钻石";
|
||||
$list[$k]['num'] = $v['quantity'];
|
||||
$list[$k]['gift_price'] = $v['gold'];
|
||||
$list[$k]['type'] = 4;
|
||||
$list[$k]['base_image'] = localpath_to_netpath("static/image/icon/gold.png");
|
||||
}
|
||||
}
|
||||
$result = $list;
|
||||
return ['code' => 1, 'msg' => '成功','data' => $result];
|
||||
}
|
||||
|
||||
/*
|
||||
* 今日签到状态
|
||||
*/
|
||||
public function daily_tasks_sign_in_status($user_id){
|
||||
$task_info = Db::name('vs_tasks')->where('id',1)->where('delete_time',0)->where('is_active',1)->find();
|
||||
if(empty($task_info)){
|
||||
$result['status'] = 1;
|
||||
$result['status_str'] = "已签到";
|
||||
return ['code' => 1, 'msg' => '成功','data' => $result];
|
||||
}
|
||||
$sign_in_info = Db::name('vs_user_tasks_sign_in')->where(['user_id'=>$user_id,'sign_in_date'=>date('Y-m-d')])->find();
|
||||
$result = [];
|
||||
if ($sign_in_info) {
|
||||
$result['status'] = 1;
|
||||
$result['status_str'] = "已签到";
|
||||
}else{
|
||||
$result['status'] = 0;
|
||||
$result['status_str'] = "未签到";
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功','data' => $result];
|
||||
}
|
||||
|
||||
//未完成任务数量
|
||||
public function daily_tasks_unfinished_count($user_id){
|
||||
$task_ids = Db::name('vs_tasks')->field('id as task_id,task_type')->where('delete_time',0)->where(['is_active'=>1,'id'=>['<>',1]])->select();
|
||||
$result = [];
|
||||
$task_user_count = 0;
|
||||
|
||||
// 按任务类型分组,减少数据库查询次数
|
||||
$daily_task_ids = [];
|
||||
$other_task_ids = [];
|
||||
|
||||
foreach($task_ids as $k=>$v) {
|
||||
if($v['task_type']==2) {
|
||||
$daily_task_ids[] = $v['task_id'];
|
||||
} else {
|
||||
$other_task_ids[] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
// 一次性查询所有每日任务(task_type==2)
|
||||
if (!empty($daily_task_ids)) {
|
||||
$daily_task_count = Db::name('vs_tasks_user_daily')
|
||||
->where(['user_id'=>$user_id,'is_claimed'=>0,'is_completed'=>1])
|
||||
->where('task_id', 'in', $daily_task_ids)
|
||||
->whereTime('createtime', 'today')
|
||||
->count();
|
||||
$task_user_count += $daily_task_count;
|
||||
}
|
||||
|
||||
// 处理其他类型任务
|
||||
foreach($other_task_ids as $k=>$v) {
|
||||
if(in_array($v['task_id'],[21,22,23])){
|
||||
$task_user = db::name('vs_tasks_student')
|
||||
->where('user_id',$user_id)
|
||||
->where('task_id',$v['task_id'])
|
||||
->where('status',1)
|
||||
->where('delete_time', 0)
|
||||
->count();
|
||||
}elseif($v['task_id']==24){
|
||||
$task_user = Db::name('vs_user_sign_task')->where(['user_id'=>$user_id,'day'=>date('Y-m-d'),'status'=>0])->count();
|
||||
}elseif(in_array($v['task_id'],[26,27,28,29,30,31,32])){
|
||||
$task_user = Db::name('vs_user_cp_task')->where(['user_id'=>$user_id,'delete_time'=>0,'day'=>date('Y-m-d'),'status'=>1,'tasks_bag_id'=>$v['task_id']])->count();
|
||||
}else{
|
||||
$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();
|
||||
}
|
||||
$task_user_count +=$task_user;
|
||||
}
|
||||
|
||||
$result['num'] = $task_user_count;
|
||||
return ['code' => 1, 'msg' => '成功','data' => $result];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -282,7 +282,11 @@ class Tencent extends Model
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
// $txt = date('Y-m-d H:i:s').'测试';
|
||||
// error_log($txt, 3, 'a.txt');
|
||||
return $reslut;
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
return ['code' => 1, 'msg' => '发送成功', 'data' => $reslut];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => $reslut['ErrorCode'], 'data' => $reslut];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -326,7 +330,7 @@ class Tencent extends Model
|
||||
}
|
||||
$config = get_system_config();
|
||||
$tencentyun_im_appid = $config['tencentyun_im_appid'];
|
||||
$im_admin = 'administrator';
|
||||
$im_admin = '管理员';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
$postUrl = 'https://console.tim.qq.com/v4/group_open_http_svc/add_group_member?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
@@ -352,7 +356,7 @@ class Tencent extends Model
|
||||
public function delete_group_member($rid, $uid){
|
||||
$config = get_system_config();
|
||||
$tencentyun_im_appid = $config['tencentyun_im_appid'];
|
||||
$im_admin = 'administrator';
|
||||
$im_admin = '管理员';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
$postUrl = 'https://console.tim.qq.com/v4/group_open_http_svc/delete_group_member?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
@@ -364,7 +368,7 @@ class Tencent extends Model
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
// Log::record("腾讯群内删除成员结果".json_encode($reslut),"info");
|
||||
Log::record("腾讯群内删除成员结果".json_encode($reslut),"info");
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}else{
|
||||
@@ -916,6 +920,7 @@ class Tencent extends Model
|
||||
|
||||
//腾讯IM监控在线状态更新
|
||||
public function tencent_member_status_changeee($info){
|
||||
return true;
|
||||
$uid = substr($info['To_Account'],1);
|
||||
$action = $info['Action'];
|
||||
|
||||
@@ -973,106 +978,106 @@ class Tencent extends Model
|
||||
|
||||
//腾讯IM监控在线状态更新
|
||||
public function tencent_member_status_change($info){
|
||||
$uid = substr($info['To_Account'],1);
|
||||
$action = $info['Action'];
|
||||
|
||||
if($action == 'Disconnect') {
|
||||
$is_keep = 1;
|
||||
$keep = db::name('vs_xintiao')->where('user_id' , $uid)->find();
|
||||
if(isset($keep)){
|
||||
if(time() - $keep['updatetime'] >= 60){
|
||||
$is_keep = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//判断保活用户是否安卓用户
|
||||
$user_system = db::name('user')->where('id' , $uid)->value('system');
|
||||
if($user_system == 'android'){
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 0, 'updatetime' => time()]);
|
||||
$quit_room = Db::name('vs_room_visitor')->where('user_id', $uid)->select();
|
||||
Log::record("腾讯离线推送,用户安卓所在房间信息".json_encode($quit_room),"infos");
|
||||
if($quit_room) {
|
||||
foreach ($quit_room as &$v){
|
||||
if(isset($v['room_id'])){
|
||||
$room_type = db::name('vs_room')->where(['id' => $v['room_id']])->field('step,type_id,label_id')->find();
|
||||
// Log::record("腾讯离线推送,房间类型".json_encode($room_type),"infos");
|
||||
if($room_type['label_id'] == 1 && ($room_type['type_id'] == 1 || $room_type['type_id'] == 8)){
|
||||
// Log::record("腾讯离线推送,我是二卡八","infos");
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 1, 'updatetime' => time()]);
|
||||
}else{
|
||||
if(isset($room_type) && ($room_type['type_id'] == 7 && ($room_type['step'] == 2 ||$room_type['step'] == 3)) || $room_type == 2){
|
||||
$text['text'] = '掉线!';
|
||||
$text['user_id'] = $uid;
|
||||
$text['type'] = 2;
|
||||
model('Chat')->sendMsg(1058,$v['room_id'],$text);
|
||||
}else {
|
||||
//查询是否有切后台的操作
|
||||
// $uid = substr($info['To_Account'],1);
|
||||
// $action = $info['Action'];
|
||||
//
|
||||
// if($action == 'Disconnect') {
|
||||
// $is_keep = 1;
|
||||
// $keep = db::name('vs_xintiao')->where('user_id' , $uid)->find();
|
||||
// if(isset($keep)){
|
||||
// if(time() - $keep['updatetime'] >= 60){
|
||||
// $is_keep = 0;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //判断保活用户是否安卓用户
|
||||
// $user_system = db::name('user')->where('id' , $uid)->value('system');
|
||||
// if($user_system == 'android'){
|
||||
// Db::name('user')->where('id', $uid)->update(['is_online' => 0, 'updatetime' => time()]);
|
||||
// $quit_room = Db::name('vs_room_visitor')->where('user_id', $uid)->select();
|
||||
// Log::record("腾讯离线推送,用户安卓所在房间信息".json_encode($quit_room),"infos");
|
||||
// if($quit_room) {
|
||||
// foreach ($quit_room as &$v){
|
||||
// if(isset($v['room_id'])){
|
||||
// $room_type = db::name('vs_room')->where(['id' => $v['room_id']])->field('step,type_id,label_id')->find();
|
||||
// // Log::record("腾讯离线推送,房间类型".json_encode($room_type),"infos");
|
||||
// if($room_type['label_id'] == 1 && ($room_type['type_id'] == 1 || $room_type['type_id'] == 8)){
|
||||
// // Log::record("腾讯离线推送,我是二卡八","infos");
|
||||
// Db::name('user')->where('id', $uid)->update(['is_online' => 1, 'updatetime' => time()]);
|
||||
// }else{
|
||||
// if(isset($room_type) && ($room_type['type_id'] == 7 && ($room_type['step'] == 2 ||$room_type['step'] == 3)) || $room_type == 2){
|
||||
// $text['text'] = '掉线!';
|
||||
// $text['user_id'] = $uid;
|
||||
// $text['type'] = 2;
|
||||
// model('Chat')->sendMsg(1058,$v['room_id'],$text);
|
||||
// }else {
|
||||
// //查询是否有切后台的操作
|
||||
// // $bg_room = db::name('vs_user_in_room_bg')->where(['room_id' => $v['room_id'],'user_id' => $v['user_id']])->find();
|
||||
// // if(!$bg_room){
|
||||
// // // Log::record("腾讯离线推送,要踢你","infos");
|
||||
// // model('Room')->quit_room($v['user_id'], $v['room_id'],$v['user_id'],2);
|
||||
// // }
|
||||
// Log::record("腾讯离线推送,判断心跳".$is_keep,"infos");
|
||||
// if($is_keep == 0){
|
||||
// model('Room')->quit_room($v['user_id'], $v['room_id'],$v['user_id'],2);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// $room_type = null;
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
// Db::name('user')->where('id', $uid)->update(['is_online' => 0, 'updatetime' => time()]);
|
||||
// $quit_room = Db::name('vs_room_visitor')->where('user_id', $uid)->select();
|
||||
// // Log::record("腾讯离线推送,房间信息".json_encode($quit_room),"infos");
|
||||
// if($quit_room) {
|
||||
// foreach ($quit_room as &$v){
|
||||
// if(isset($v['room_id'])){
|
||||
// $room_type = db::name('vs_room')->where(['id' => $v['room_id']])->field('step,type_id,label_id')->find();
|
||||
// // Log::record("腾讯离线推送,房间类型".json_encode($room_type),"infos");
|
||||
// if($room_type['label_id'] == 1 && ($room_type['type_id'] == 1 || $room_type['type_id'] == 8)){
|
||||
// // Log::record("腾讯离线推送,我是二卡八","infos");
|
||||
// Db::name('user')->where('id', $uid)->update(['is_online' => 1, 'updatetime' => time()]);
|
||||
// }else{
|
||||
// if(isset($room_type) && ($room_type['type_id'] == 7 && ($room_type['step'] == 2 ||$room_type['step'] == 3)) || $room_type == 2){
|
||||
// $text['text'] = '掉线!';
|
||||
// $text['user_id'] = $uid;
|
||||
// $text['type'] = 2;
|
||||
// model('Chat')->sendMsg(1058,$v['room_id'],$text);
|
||||
// }else {
|
||||
// //查询是否有切后台的操作
|
||||
// $bg_room = db::name('vs_user_in_room_bg')->where(['room_id' => $v['room_id'],'user_id' => $v['user_id']])->find();
|
||||
// if(!$bg_room){
|
||||
// // Log::record("腾讯离线推送,要踢你","infos");
|
||||
// model('Room')->quit_room($v['user_id'], $v['room_id'],$v['user_id'],2);
|
||||
// }
|
||||
Log::record("腾讯离线推送,判断心跳".$is_keep,"infos");
|
||||
if($is_keep == 0){
|
||||
model('Room')->quit_room($v['user_id'], $v['room_id'],$v['user_id'],2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$room_type = null;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 0, 'updatetime' => time()]);
|
||||
$quit_room = Db::name('vs_room_visitor')->where('user_id', $uid)->select();
|
||||
// Log::record("腾讯离线推送,房间信息".json_encode($quit_room),"infos");
|
||||
if($quit_room) {
|
||||
foreach ($quit_room as &$v){
|
||||
if(isset($v['room_id'])){
|
||||
$room_type = db::name('vs_room')->where(['id' => $v['room_id']])->field('step,type_id,label_id')->find();
|
||||
// Log::record("腾讯离线推送,房间类型".json_encode($room_type),"infos");
|
||||
if($room_type['label_id'] == 1 && ($room_type['type_id'] == 1 || $room_type['type_id'] == 8)){
|
||||
// Log::record("腾讯离线推送,我是二卡八","infos");
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 1, 'updatetime' => time()]);
|
||||
}else{
|
||||
if(isset($room_type) && ($room_type['type_id'] == 7 && ($room_type['step'] == 2 ||$room_type['step'] == 3)) || $room_type == 2){
|
||||
$text['text'] = '掉线!';
|
||||
$text['user_id'] = $uid;
|
||||
$text['type'] = 2;
|
||||
model('Chat')->sendMsg(1058,$v['room_id'],$text);
|
||||
}else {
|
||||
//查询是否有切后台的操作
|
||||
$bg_room = db::name('vs_user_in_room_bg')->where(['room_id' => $v['room_id'],'user_id' => $v['user_id']])->find();
|
||||
if(!$bg_room){
|
||||
// Log::record("腾讯离线推送,要踢你","infos");
|
||||
model('Room')->quit_room($v['user_id'], $v['room_id'],$v['user_id'],2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$room_type = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} elseif ($action == 'Login') {
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 1, 'updatetime' => time()]);
|
||||
$room = Db::name('vs_room_visitor')->where('user_id', $uid)->order('id desc')->value('room_id');
|
||||
|
||||
$text['text'] = '重新上线!';
|
||||
$text['user_id'] = $uid;
|
||||
$text['type'] = 1;
|
||||
model('Chat')->sendMsg(1058,$room,$text);
|
||||
}elseif ($action == 'Logout'){
|
||||
// Db::name('user')->where('id', $uid)->update(['is_online' => 0, 'updatetime' => time()]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// $room_type = null;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// } elseif ($action == 'Login') {
|
||||
// Db::name('user')->where('id', $uid)->update(['is_online' => 1, 'updatetime' => time()]);
|
||||
// $room = Db::name('vs_room_visitor')->where('user_id', $uid)->order('id desc')->value('room_id');
|
||||
// $text['text'] = '掉线!';
|
||||
//
|
||||
// $text['text'] = '重新上线!';
|
||||
// $text['user_id'] = $uid;
|
||||
// $text['type'] = 2;
|
||||
// $text['type'] = 1;
|
||||
// model('Chat')->sendMsg(1058,$room,$text);
|
||||
}
|
||||
// }elseif ($action == 'Logout'){
|
||||
//// Db::name('user')->where('id', $uid)->update(['is_online' => 0, 'updatetime' => time()]);
|
||||
//// $room = Db::name('vs_room_visitor')->where('user_id', $uid)->order('id desc')->value('room_id');
|
||||
//// $text['text'] = '掉线!';
|
||||
//// $text['user_id'] = $uid;
|
||||
//// $text['type'] = 2;
|
||||
//// model('Chat')->sendMsg(1058,$room,$text);
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Cache;
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
@@ -113,19 +114,8 @@ class User extends Model
|
||||
//我的
|
||||
public function get_me($uid)
|
||||
{
|
||||
$user_info = db::name('user')
|
||||
->field('id as user_id,nickname,user_code,avatar,sex,mobile')
|
||||
->where('id', $uid)->find();
|
||||
if (empty($user_info)) {
|
||||
return ['code' => 0, 'msg' => '用户不存在', 'data' => null];
|
||||
}
|
||||
//头像判断 路径里面是否有https
|
||||
if (strpos($user_info['avatar'], 'https') === false) {
|
||||
$user_info['avatar'] = localpath_to_netpath($user_info['avatar']);
|
||||
}
|
||||
|
||||
$user_info['icon'][0] = model('UserData')->user_wealth_icon($uid);//财富图标
|
||||
$user_info['icon'][1] = model('UserData')->user_charm_icon($uid);//魅力图标
|
||||
$user_info = $this->get_user_base_info($uid);
|
||||
$user_info['is_use_code'] = $user_info['is_special_code'];
|
||||
|
||||
//关注数
|
||||
$user_info['follow_num'] = db::name('user_follow')->where(['user_id' => $uid,'type'=>1])->count();
|
||||
@@ -138,17 +128,6 @@ class User extends Model
|
||||
//我的魅力等级
|
||||
$user_info['charm_level'] = model('UserData')->where('user_id',$uid)->value('charm_level');
|
||||
|
||||
//查询用户是否有使用靓号
|
||||
$user_info['is_use_code'] = 0;
|
||||
$liang = db::name('vs_user_decorate')->where(['user_id' =>$uid,'type' => 6,'is_using' => 1])->where('end_time',['>=',time()],'or')->find();
|
||||
if($liang){
|
||||
$user_info['is_use_code'] = 1;
|
||||
$user_info['user_code'] = $liang['special_num'];
|
||||
}
|
||||
//头像装扮
|
||||
$user_info['dress'] = model('Decorate')->user_decorate_detail($user_info['user_id'],1);
|
||||
$user_info['auth'] = db::name('user_auth')->where(['mobile' => $user_info['mobile'],'is_real' => 1])->find() ? 1 : 0;
|
||||
|
||||
//是否可以发布动态
|
||||
$user_rechange = db::name('vs_user_recharge')->field('sum(money) as money')->where(['user_id' => $uid,'pay_status' => 2])->find();
|
||||
//系统配置
|
||||
@@ -160,9 +139,115 @@ class User extends Model
|
||||
}
|
||||
$user_info['can_chat_money'] = $config_money;
|
||||
|
||||
$user_info['hide_status'] = db::name('user')->where('id',$uid)->value('hide_status');//0-取消隐身,1-隐身进入
|
||||
|
||||
//cp
|
||||
//查询用户Cp空间
|
||||
$res = Db::name('user_cp_zone')->where(['user_id1' => $uid,'status' => 1])->field('user_id1,user_id2,level,exp')->find();
|
||||
if(!$res){
|
||||
$res = Db::name('user_cp_zone')->where(['user_id2' => $uid,'status' => 1])->find();
|
||||
}
|
||||
if(!$res){
|
||||
$user_info['cp_info'] = null;
|
||||
}else{
|
||||
$res['user_info1'] = Db::name('user')->where(['id' => $res['user_id1']])->field('id user_id,nickname,avatar')->find();
|
||||
$res['user_info1']['dress'] = model('api/Decorate')->user_decorate_detail($res['user_id1'], 1);
|
||||
$res['user_info2'] = Db::name('user')->where(['id' => $res['user_id2']])->field('id user_id,nickname,avatar')->find();
|
||||
$res['user_info2']['dress'] = model('api/Decorate')->user_decorate_detail($res['user_id2'], 1);
|
||||
//当前等级名称
|
||||
$res['name'] = Db::name('user_cp_level')->where(['level' => $res['level']])->value('name');
|
||||
$res['direction'] = Db::name('user_cp_level')->where(['level' => $res['level']])->value('direction');
|
||||
$res['pendant'] = model('api/Decorate')->user_decorate_detail($res['user_id1'], 11);
|
||||
$user_info['cp_info'] = $res;
|
||||
}
|
||||
//用户师傅
|
||||
$master = db::name('vs_user_sign')->where(['sign_user_id' => $uid,'end_time' => ['>',time()]])->value('parent_user_id');
|
||||
if($master){
|
||||
$user_info['master'] = Db::name('user')->where(['id' => $master])->field('id user_id,nickname,avatar')->find();
|
||||
}else{
|
||||
$user_info['master'] = null;
|
||||
}
|
||||
|
||||
//身价配置
|
||||
$coin_market_value = explode(',', get_system_config_value('coin_market_value'));;
|
||||
$user_info['market_value_coin'] = $coin_market_value[0];
|
||||
$user_info['market_value_market'] = $coin_market_value[1];
|
||||
|
||||
//用户所属工会
|
||||
$guild_id = Db::name('vs_guild_user')->where(['user_id'=>$uid,'delete_time'=>0,'status' => 1])->value('guild_id');
|
||||
if($guild_id){
|
||||
$user_info['guild_id'] = db::name('vs_guild')->where(['id'=>$guild_id])->value('guild_special_id');
|
||||
$user_info['guild_name'] = db::name('vs_guild')->where(['id'=>$guild_id])->value('guild_name');
|
||||
}else{
|
||||
$user_info['guild_id'] = null;
|
||||
$user_info['guild_name'] = null;
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $user_info];
|
||||
}
|
||||
|
||||
|
||||
//获取用户基础信息
|
||||
public function get_user_base_info($uid)
|
||||
{
|
||||
//先从缓存中获取
|
||||
$cache_key = 'user_base_info_'.$uid;
|
||||
$user_info = json_decode(Cache::get($cache_key), true);
|
||||
|
||||
if(!$user_info){
|
||||
$user_info = db::name('user')
|
||||
->field('id as user_id,nickname,avatar,sex,mobile,market_value,user_code as code')
|
||||
->where('id', $uid)->find();
|
||||
|
||||
if (empty($user_info)) {
|
||||
return ['code' => 0, 'msg' => '用户不存在', 'data' => null];
|
||||
}
|
||||
$user_info['dress'] = model('api/Decorate')->user_decorate_detail($uid,1);//头像装扮
|
||||
$user_info['user_code'] = model('api/Decorate')->user_decorate_detail($uid,6);//靓号
|
||||
$user_info['is_special_code'] = 0;//是否是靓号:0-普通,1-靓号
|
||||
if($user_info['user_code'] != $user_info['code']){
|
||||
$user_info['is_special_code'] = 1;//是靓号:0-普通,1-靓号
|
||||
}
|
||||
$user_info['mic_cycle'] = model('api/Decorate')->user_decorate_detail($uid,3);//麦圈
|
||||
$user_info['chat_bubble'] = model('api/Decorate')->user_decorate_detail($user_info['user_id'],9);//聊天气泡
|
||||
|
||||
$Nobility = model('api/Nobility')->getUserNobilityInfo($uid);//爵位
|
||||
$user_info['nobility_image'] = $Nobility['play_image'];//爵位图标
|
||||
$user_info['nickname_color'] = $Nobility['nick_name_color'];//昵称颜色
|
||||
$user_info['enter_image'] = $Nobility['enter_image'];//入场特效
|
||||
$user_info['nobility_name'] = $Nobility['nobility_name'];//入场特效
|
||||
|
||||
$user_info['is_hide'] = 0;//是否可以设置隐身:0-不可以,1-可以
|
||||
if($Nobility['power_list']){
|
||||
foreach ($Nobility['power_list'] as $key => $value){
|
||||
if($value['id'] == 8){
|
||||
$user_info['is_hide'] = 1;//隐身
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($user_info['mobile'])){
|
||||
$user_mo = $user_info['mobile'];
|
||||
}else{
|
||||
$user_mo = 1213131231;
|
||||
}
|
||||
|
||||
$user_info['auth'] = db::name('user_auth')->where(['mobile' => $user_mo,'is_real' => 1])->find() ? 1 : 0;//是否实名:0-未实名,1-实名
|
||||
$user_info['icon'][0] = model('api/UserData')->user_wealth_icon($uid);//财富图标
|
||||
$user_info['icon'][1] = model('api/UserData')->user_charm_icon($uid);//魅力图标
|
||||
//判断是否是歌手 如果是 返回等级图标
|
||||
$singer = model('api/SingerSong')->singerAuthStatus($uid);
|
||||
$user_info['singer_status'] = $singer['status'];//歌手认证状态0-待审核,1-通过,2-拒绝 -1-未认证
|
||||
$user_info['singer_level'] = $singer['level'];
|
||||
$user_info['market_value'] = db::name('user')->where(['id' => $uid])->value('market_value');
|
||||
if($singer['status'] == 1){
|
||||
$user_info['icon'][2] = db::name('vs_singer_level')->where(['level' =>$singer['level'],'deletetime' => 0])->value('image');//等级图标
|
||||
}
|
||||
//设置缓存
|
||||
Cache::set($cache_key, json_encode($user_info), 3600);
|
||||
return $user_info;
|
||||
}
|
||||
|
||||
//获取用户关注列表
|
||||
public function get_user_follow_list($uid, $page, $page_limit)
|
||||
{
|
||||
@@ -173,16 +258,17 @@ class User extends Model
|
||||
$list = $model->field('a.follow_id,a.createtime,b.nickname,b.avatar,b.sex,b.user_code')->order('a.id desc')->page($page, $page_limit)->select();
|
||||
foreach ($list as $k => &$v) {
|
||||
$v['user_id'] = $v['follow_id'];
|
||||
$v['is_online'] = 0;
|
||||
$v['is_online'] = 2;
|
||||
$v['is_follow'] = 1;
|
||||
// $is_follow = db::name('user_follow')->where(['user_id' => $v['follow_id'], 'follow_id' => $uid])->find();
|
||||
// if ($is_follow) {
|
||||
// $v['is_follow'] = 1;
|
||||
// }
|
||||
|
||||
//等级获取对应图标
|
||||
$v['icon'][0] = model('UserData')->user_wealth_icon($v['follow_id']);//财富图标
|
||||
$v['icon'][1] = model('UserData')->user_charm_icon($v['follow_id']);//魅力图标
|
||||
//判断是否是歌手 如果是 返回等级图标
|
||||
$isSinger = db::name('vs_singer')->where(['user_id' => $v['user_id'],'status' => 1])->find();
|
||||
if($isSinger){
|
||||
$v['icon'][2] = db::name('vs_singer_level')->where(['level' => $isSinger['level'],'deletetime' => 0])->value('image');//等级图标
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
|
||||
}
|
||||
@@ -206,6 +292,11 @@ class User extends Model
|
||||
//等级获取对应图标
|
||||
$v['icon'][0] = model('UserData')->user_wealth_icon($v['user_id']);//财富图标
|
||||
$v['icon'][1] = model('UserData')->user_charm_icon($v['user_id']);//魅力图标
|
||||
//判断是否是歌手 如果是 返回等级图标
|
||||
$isSinger = db::name('vs_singer')->where(['user_id' => $v['user_id'],'status' => 1])->find();
|
||||
if($isSinger){
|
||||
$v['icon'][2] = db::name('vs_singer_level')->where(['level' => $isSinger['level'],'deletetime' => 0])->value('image');//等级图标
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
|
||||
}
|
||||
@@ -289,11 +380,15 @@ class User extends Model
|
||||
public function get_user_home($from_uid,$uid)
|
||||
{
|
||||
$user_info = db::name('user')->alias('u')->join('user_data ud', 'u.id = ud.user_id')
|
||||
->field('u.id as user_id,u.nickname,u.user_code,u.avatar,u.sex,u.birthday,u.profile,ud.tag_id,ud.home_bgimages,u.is_online')
|
||||
->field('u.birthday,u.profile,ud.tag_id,ud.home_bgimages,u.is_online')
|
||||
->where(['u.id' => $uid,'u.status' => ['<>',0]])->find();
|
||||
if(!$user_info){
|
||||
return ['code' => 0, 'msg' => '用户不存在或已注销', 'data' => null];
|
||||
}
|
||||
$userInfo = $this->get_user_base_info($uid);
|
||||
//把$userInfo合并到后面
|
||||
$user_info = array_merge($user_info, $userInfo);
|
||||
|
||||
//标签
|
||||
$user_info['tag_list'] = [];
|
||||
if(isset($user_info['tag_id'])) {
|
||||
@@ -304,16 +399,8 @@ class User extends Model
|
||||
//礼物墙 获取收到的礼物图片名称数量 以及送每个礼物数量最多的用户的头像昵称 数量一样选最后送的用户
|
||||
$user_info['gift_wall'] = [];
|
||||
|
||||
$user_info['icon'][0] = model('UserData')->user_wealth_icon($uid) ?? '';//财富图标
|
||||
$user_info['icon'][1] = model('UserData')->user_charm_icon($uid) ?? '';//魅力图标
|
||||
|
||||
//查询用户是否有使用靓号
|
||||
$user_info['is_use_code'] = 0;
|
||||
$liang = db::name('vs_user_decorate')->where(['user_id' => $uid, 'is_using' => 1, 'type' => 6, 'end_time' => ['>=', time()]])->find();
|
||||
if($liang){
|
||||
$user_info['is_use_code'] = 1;
|
||||
$user_info['user_code'] = $liang['special_num'] ?? '';
|
||||
}
|
||||
$user_info['is_use_code'] = $userInfo['is_special_code'];
|
||||
|
||||
//是否关注
|
||||
$user_info['is_follow'] = 0;
|
||||
@@ -324,8 +411,6 @@ class User extends Model
|
||||
$user_info['room_id'] = db::name('vs_room_visitor')->where(['user_id' => $uid, 'is_delete' => 1])->order('id desc')->value('room_id') ?? 0;
|
||||
//用户年龄
|
||||
$user_info['age'] = getAge($user_info['birthday']);
|
||||
//头像装扮
|
||||
$user_info['dress'] = model('Decorate')->user_decorate_detail($user_info['user_id'],1);
|
||||
|
||||
//记录用户访问记录
|
||||
if($from_uid != $uid){
|
||||
@@ -335,10 +420,45 @@ class User extends Model
|
||||
//用户所属工会
|
||||
$guild_id = Db::name('vs_guild_user')->where(['user_id'=>$uid,'status'=>1,'delete_time'=>0])->value('guild_id');
|
||||
if($guild_id){
|
||||
$user_info['guild'] = Db::name('vs_guild')->where('id' ,$guild_id)->value('guild_name');
|
||||
$user_info['guild_id'] = db::name('vs_guild')->where(['id'=>$guild_id])->value('guild_special_id');
|
||||
$user_info['guild_name'] = db::name('vs_guild')->where(['id'=>$guild_id])->value('guild_name');
|
||||
}else{
|
||||
$user_info['guild'] = '';
|
||||
$user_info['guild_id'] = null;
|
||||
$user_info['guild_name'] = null;
|
||||
}
|
||||
|
||||
//cp
|
||||
//查询用户Cp空间
|
||||
$res = Db::name('user_cp_zone')->where(['user_id1' => $uid,'status' => 1])->field('user_id1,user_id2,level,exp')->find();
|
||||
if(!$res){
|
||||
$res = Db::name('user_cp_zone')->where(['user_id2' => $uid,'status' => 1])->find();
|
||||
}
|
||||
if(!$res){
|
||||
$user_info['cp_info'] = null;
|
||||
}else{
|
||||
$res['user_info1'] = Db::name('user')->where(['id' => $res['user_id1']])->field('id user_id,nickname,avatar')->find();
|
||||
$res['user_info1']['dress'] = model('api/Decorate')->user_decorate_detail($res['user_id1'], 1);
|
||||
$res['user_info2'] = Db::name('user')->where(['id' => $res['user_id2']])->field('id user_id,nickname,avatar')->find();
|
||||
$res['user_info2']['dress'] = model('api/Decorate')->user_decorate_detail($res['user_id2'], 1);
|
||||
//当前等级名称
|
||||
$res['name'] = Db::name('user_cp_level')->where(['level' => $res['level']])->value('name');
|
||||
$res['direction'] = Db::name('user_cp_level')->where(['level' => $res['level']])->value('direction');
|
||||
$res['pendant'] = model('api/Decorate')->user_decorate_detail($res['user_id1'], 11);
|
||||
$user_info['cp_info'] = $res;
|
||||
}
|
||||
//用户师傅
|
||||
$master = db::name('vs_user_sign')->where(['sign_user_id' => $uid,'end_time' => ['>',time()]])->value('parent_user_id');
|
||||
if($master){
|
||||
$user_info['master'] = Db::name('user')->where(['id' => $master])->field('id user_id,nickname,avatar')->find();
|
||||
}else{
|
||||
$user_info['master'] = null;
|
||||
}
|
||||
|
||||
//身价配置
|
||||
$coin_market_value = explode(',', get_system_config_value('coin_market_value'));;
|
||||
$user_info['market_value_coin'] = $coin_market_value[0];
|
||||
$user_info['market_value_market'] = $coin_market_value[1];
|
||||
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $user_info];
|
||||
}
|
||||
|
||||
@@ -424,6 +544,7 @@ class User extends Model
|
||||
public function add_user_visit_log($type,$from_uid,$to_uid){
|
||||
$visit = db::name('user_visit_log')->where(['from_uid' => $from_uid,'to_id' => $to_uid,'type' => $type])->find();
|
||||
if($visit){
|
||||
db::name('user_visit_log')->where(['id' => $visit['id']])->update(['updatetime' => time()]);
|
||||
return true;
|
||||
}
|
||||
$data = [
|
||||
@@ -431,6 +552,7 @@ class User extends Model
|
||||
'from_uid' => $from_uid,
|
||||
'to_id' => $to_uid,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time(),
|
||||
];
|
||||
db::name('user_visit_log')->insert($data);
|
||||
return true;
|
||||
@@ -514,6 +636,8 @@ class User extends Model
|
||||
'createtime' => time()
|
||||
];
|
||||
db::name('user_album')->insert($data);
|
||||
//任务:4-创建相册
|
||||
model('Tasks')->tasks_complete($user_id,4);
|
||||
return ['code' => 1, 'msg' => '创建成功', 'data' => null];
|
||||
}
|
||||
|
||||
@@ -744,7 +868,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){
|
||||
@@ -898,4 +1022,120 @@ class User extends Model
|
||||
return ['code' => 1, 'msg' => '可以发起私聊', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 挚友列表
|
||||
* @param int $user_id 用户ID
|
||||
*/
|
||||
public function get_friend_list($user_id,$page,$limit){
|
||||
//获取用户当前所拥有的关系
|
||||
$relation = db::name('vs_relation')->where(['id' => ['>',0],'delete_time' => 0])->page($page,$limit)->select();
|
||||
$return_data = [];
|
||||
$no_cp = [];
|
||||
if($relation){
|
||||
foreach ($relation as $k => $v){
|
||||
$relation_list = $this->relation_card($v['id'],$user_id);
|
||||
if($relation_list){
|
||||
$no_cp[$k]['relation_list'] = $relation_list;
|
||||
$no_cp[$k]['relation_name'] = $v['name'];
|
||||
}else{
|
||||
unset($relation[$k]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if($no_cp){
|
||||
//数组重新排序
|
||||
$no_cp = array_values($no_cp);
|
||||
}
|
||||
$return_data['no_cp'] = $no_cp;
|
||||
|
||||
//CP 信息
|
||||
$res = Db::name('user_cp_zone')->where(['user_id1' => $user_id,'status' => 1])->find();
|
||||
if(!$res){
|
||||
$res = Db::name('user_cp_zone')->where(['user_id2' => $user_id,'status' => 1])->find();
|
||||
}
|
||||
if($res){
|
||||
$res['name'] = Db::name('user_cp_level')->where(['level' => $res['level']])->value('name');
|
||||
$res['user_info1'] = Db::name('user')->where(['id' => $res['user_id1']])->field('id user_id,nickname,avatar')->find();
|
||||
$res['user_info2'] = Db::name('user')->where(['id' => $res['user_id2']])->field('id user_id,nickname,avatar')->find();
|
||||
}
|
||||
if($res){
|
||||
$return_data['cp'] = $res;
|
||||
}else{
|
||||
$return_data['cp'] = null;
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $return_data];
|
||||
}
|
||||
|
||||
|
||||
//关系卡,关系位
|
||||
public function relation_card($relation_id,$user_id,$type = 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')
|
||||
->where(['a.user_id1' => $user_id,'a.end_time' =>['>',time()],'a.delete_time' => 0,'a.relation_id' => $relation_id])
|
||||
->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')
|
||||
->where(['a.user_id2' => $user_id,'a.end_time' =>['>',time()],'a.delete_time' => 0,'a.relation_id' => $relation_id])
|
||||
->order('a.updatetime desc')
|
||||
->select();
|
||||
|
||||
$room_auction = array_merge((array)$room_auction1, (array)$room_auction2);
|
||||
|
||||
foreach ($room_auction as &$v){
|
||||
$v['delete_me_coin'] = get_system_config_value('delete_relation_card_money');
|
||||
if($v['cp_room_id'] > 1){
|
||||
//查找房间ID
|
||||
$v['heart_value'] = db::name('vs_room')->where('id',$v['cp_room_id'])->value('hot_value');
|
||||
}else{
|
||||
$v['heart_value'] = 0;
|
||||
}
|
||||
if(db::name('vs_room_auction_relation_top')->where(['user_id' => $user_id, 'au_re_id' => $v['id']])->find()){
|
||||
$v['is_top'] = 1;//置顶
|
||||
}else{
|
||||
$v['is_top'] = 0;
|
||||
}
|
||||
}
|
||||
//数据重组 根据是否置顶排序 然后根据 time_day 倒序
|
||||
if ($room_auction) {
|
||||
// 对于未置顶的项目,再根据 time_day 倒序排序
|
||||
$top_qinmi = array_filter($room_auction, function($item) { return $item['is_top'] == 1; });
|
||||
$untop_qinmi = array_filter($room_auction, function($item) { return $item['is_top'] != 1; });
|
||||
usort($untop_qinmi, function($a, $b) {
|
||||
return $b['time_day'] <=> $a['time_day'];
|
||||
});
|
||||
$room_auction = array_merge($top_qinmi, $untop_qinmi);
|
||||
$room_auction = array_values($room_auction);
|
||||
}
|
||||
|
||||
if($type == 0){
|
||||
//取前三个值
|
||||
$room_auction = array_slice($room_auction, 0, 3);
|
||||
}
|
||||
|
||||
return $room_auction ;
|
||||
// return ['code' => 1, 'msg' => '操作成功', 'data' => $room_auction];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 挚友列表查看更多
|
||||
* @param int $user_id 用户ID
|
||||
* @param int $relation_id 关系ID
|
||||
*/
|
||||
public function get_friend_list_more($user_id,$relation_id){
|
||||
$room_auction = $this->relation_card($relation_id,$user_id,1);
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => $room_auction];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,13 +2,443 @@
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class UserCp extends Model
|
||||
{
|
||||
//用户关系卡(亲密拍)、关系位(真爱拍 ->有电影房)
|
||||
public function user_cp_list($uid,$user_id)
|
||||
|
||||
/*
|
||||
* 检测是否赠送的Cp礼物
|
||||
* @param $from_user_id 送礼用户ID
|
||||
* @param $gift_id 礼物ID
|
||||
* @param $to_user_id 接收用户ID
|
||||
* @param $room_id 房间ID
|
||||
* @return int 0-无,1-等待回应,2-已建立Cp空间
|
||||
*/
|
||||
public function checkGift($from_user_id, $gift_id, $to_user_id, $room_id, $num,$gift_price)
|
||||
{
|
||||
//查询是否已经存在Cp空间
|
||||
$rees = Db::name('user_cp_zone')->where(['user_id1' => $from_user_id,'user_id2' => $to_user_id,'status' => 1])->find();
|
||||
if(!$rees){
|
||||
$rees = Db::name('user_cp_zone')->where(['user_id1' => $to_user_id,'user_id2' => $from_user_id,'status' => 1])->find();
|
||||
}
|
||||
if($rees){
|
||||
$this->addCpLevel($from_user_id, $to_user_id, $room_id, $gift_id, $rees['id'], $num,$gift_price);
|
||||
return 0;
|
||||
}
|
||||
|
||||
$cp_gift_id = explode(',', get_system_config_value('cp_gift_id'));
|
||||
if(!in_array($gift_id, $cp_gift_id)){
|
||||
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){
|
||||
//创建推送信息1:回应送礼 并创建Cp空间,
|
||||
$data = [
|
||||
'from_user_id' => $from_user_id,
|
||||
'to_user_id' => $to_user_id,
|
||||
'gift_id' => $gift_id,
|
||||
'createtime' => time(),
|
||||
'status' => 1
|
||||
];
|
||||
$r = Db::name('user_cp_find')->insertGetId($data);
|
||||
//修改状态
|
||||
Db::name('user_cp_find')->where(['id' => $res['id']])->update(['status' => 1]);
|
||||
|
||||
//先获取他连那个的原有cp
|
||||
$zone1 = Db::name('user_cp_zone')
|
||||
->where(['status' => 1])
|
||||
->where('(user_id1 = ' . $from_user_id . ' OR user_id2 = ' . $from_user_id . ')')
|
||||
->find();
|
||||
$zone2 = Db::name('user_cp_zone')
|
||||
->where(['status' => 1])
|
||||
->where('(user_id1 = ' . $to_user_id . ' OR user_id2 = ' . $to_user_id . ')')
|
||||
->find();
|
||||
|
||||
//创建Cp空间
|
||||
$data = [
|
||||
'user_id1' => $from_user_id,
|
||||
'user_id2' => $to_user_id,
|
||||
'createtime' => time(),
|
||||
'status' => 1,//1-已建立Cp空间,2-已取消
|
||||
'level' => 1,
|
||||
//经验值
|
||||
'exp' => 0,
|
||||
];
|
||||
$re = Db::name('user_cp_zone')->insertGetId($data);
|
||||
|
||||
//添加一个记录
|
||||
$datas = [
|
||||
'room_id' => $room_id,
|
||||
'from_user_id' => $from_user_id,
|
||||
'to_user_id' => $to_user_id,
|
||||
'gift_id' => 0,
|
||||
'num' => 0,
|
||||
'cp_zone_id' => $re,
|
||||
'exp' => 0,
|
||||
'exp_total' => 0,
|
||||
'remark' => '建立了心动空间,让我们相爱每一天吧!',
|
||||
'createtime' => time(),
|
||||
];
|
||||
Db::name('user_cp_gift_log')->insert($datas);
|
||||
|
||||
// 检查并更新CP空间状态
|
||||
$this->updateCpZoneStatus($from_user_id, $re, $res['id'] ?? 0);
|
||||
$this->updateCpZoneStatus($to_user_id, $re, $res['id'] ?? 0);
|
||||
|
||||
// 检查并更新CP查找记录状态
|
||||
$this->updateCpFindStatus($to_user_id, $r, $res['id'] ?? 0);
|
||||
$this->updateCpFindStatus($from_user_id, $r, $res['id'] ?? 0);
|
||||
|
||||
|
||||
// 给两个用户添加CP装扮
|
||||
$pendant_ids = Db::name('user_cp_level')->where(['deletetime' => 0])->order('level asc')->value('pendant_id');
|
||||
$pendant_id = Db::name('vs_decorate_price')->where(['id' => $pendant_ids])->value('did');
|
||||
if($pendant_id){
|
||||
$this->assignCpDecoration([$from_user_id, $to_user_id], 11, $pendant_id); // 11为CP装扮类型
|
||||
}
|
||||
|
||||
// 给两个用户添加CP特效
|
||||
$rights_icon_ids = Db::name('user_cp_level')->where(['deletetime' => 0])->order('level asc')->value('rights_icon_id');
|
||||
$rights_icon_id = Db::name('vs_decorate_price')->where(['id' => $rights_icon_ids])->value('did');
|
||||
if($rights_icon_id){
|
||||
$this->assignCpDecoration([$from_user_id, $to_user_id], 10, $rights_icon_id); // 10为CP特效类型
|
||||
}
|
||||
//创建cp任务
|
||||
if($zone1){
|
||||
//先查询她两用户有没有其他任务
|
||||
$tasks12 = Db::name('vs_user_cp_task')->where(['user_id' => $zone1['user_id1'],'delete_time' => 0])->select();
|
||||
if($tasks12){
|
||||
foreach ($tasks12 as $task){
|
||||
db::name('vs_user_cp_task')->where(['id' => $task['id']])->update(['delete_time' => time()]);
|
||||
}
|
||||
}
|
||||
$tasks122 = Db::name('vs_user_cp_task')->where(['user_id' => $zone1['user_id2'],'delete_time' => 0])->select();
|
||||
if($tasks122){
|
||||
foreach ($tasks122 as $task1){
|
||||
db::name('vs_user_cp_task')->where(['id' => $task1['id']])->update(['delete_time' => time()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if($zone2){
|
||||
//先查询她两用户有没有其他任务
|
||||
$tasks13 = Db::name('vs_user_cp_task')->where(['user_id' => $zone2['user_id1'],'delete_time' => 0])->select();
|
||||
if($tasks13){
|
||||
foreach ($tasks13 as $task2){
|
||||
db::name('vs_user_cp_task')->where(['id' => $task2['id']])->update(['delete_time' => time()]);
|
||||
}
|
||||
}
|
||||
$tasks133 = Db::name('vs_user_cp_task')->where(['user_id' => $zone2['user_id2'],'delete_time' => 0])->select();
|
||||
if($tasks133){
|
||||
foreach ($tasks133 as $task3){
|
||||
db::name('vs_user_cp_task')->where(['id' => $task3['id']])->update(['delete_time' => time()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 数据插入 循环插入7条数据 day 取值是今天开始连续七天 的每一天的值 到天
|
||||
$tasks_data = [];
|
||||
for ($i = 0; $i < 7; $i++) {
|
||||
// 为第一个用户准备数据
|
||||
$tasks_data[] = [
|
||||
'user_id' => $from_user_id,
|
||||
'need_exp_value' => get_system_config_value('cp_day_exp_value_'.$i),
|
||||
'need_time_value' => get_system_config_value('cp_day_time_value_'.$i),
|
||||
'tasks_bag_id' => 26 + $i, // 26的来源是任务表的id,因为从26开始连续7个是情侣任务的第一天到第七天的任务
|
||||
'day' => date('Y-m-d', strtotime("+$i days")), // 从今天开始连续七天的日期
|
||||
'times' => $i + 1,
|
||||
'createtime' => time()
|
||||
];
|
||||
|
||||
// 为第二个用户准备数据
|
||||
$tasks_data[] = [
|
||||
'user_id' => $to_user_id,
|
||||
'need_exp_value' => get_system_config_value('cp_day_exp_value_'.$i),
|
||||
'need_time_value' => get_system_config_value('cp_day_time_value_'.$i),
|
||||
'tasks_bag_id' => 26 + $i, // 26的来源是任务表的id,因为从26开始连续7个是情侣任务的第一天到第七天的任务
|
||||
'day' => date('Y-m-d', strtotime("+$i days")), // 从今天开始连续七天的日期
|
||||
'times' => $i + 1,
|
||||
'createtime' => time()
|
||||
];
|
||||
}
|
||||
|
||||
// 批量插入所有任务数据,减少数据库操作次数
|
||||
if (!empty($tasks_data)) {
|
||||
db::name('vs_user_cp_task')->insertAll($tasks_data);
|
||||
}
|
||||
|
||||
//给前端推送
|
||||
return 2;
|
||||
}else{//创建推送信息2:表达心动信号
|
||||
$ress = Db::name('user_cp_find')
|
||||
->where(['from_user_id' => $from_user_id,'status' => 0])
|
||||
->select();
|
||||
if($ress){
|
||||
//把状态改为2 status:0-待回应,1-建交成功,2-已取消,
|
||||
foreach ($ress as $v){
|
||||
Db::name('user_cp_find')->where(['id' => $v['id']])->update(['status' => 2]);
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'from_user_id' => $from_user_id,
|
||||
'to_user_id' => $to_user_id,
|
||||
'gift_id' => $gift_id,
|
||||
'createtime' => time(),
|
||||
];
|
||||
Db::name('user_cp_find')->insert($data);
|
||||
//给前端推送
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 更新CP空间状态
|
||||
* @param int $user_id 用户ID
|
||||
* @param int $current_zone_id 当前创建的CP空间ID
|
||||
* @param int $related_find_id 相关的查找记录ID
|
||||
*/
|
||||
private function updateCpZoneStatus($user_id, $current_zone_id)
|
||||
{
|
||||
$zone = Db::name('user_cp_zone')
|
||||
->where(['status' => 1])
|
||||
->where('(user_id1 = ' . $user_id . ' OR user_id2 = ' . $user_id . ')')
|
||||
->find();
|
||||
|
||||
if ($zone && $current_zone_id != $zone['id']) {
|
||||
Db::name('user_cp_zone')->where(['id' => $zone['id']])->update(['status' => 2]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 更新CP查找记录状态
|
||||
* @param int $user_id 用户ID
|
||||
* @param int $current_find_id 当前创建的查找记录ID
|
||||
* @param int $related_find_id 相关的查找记录ID
|
||||
*/
|
||||
private function updateCpFindStatus($user_id, $current_find_id, $related_find_id = 0)
|
||||
{
|
||||
$find_records = Db::name('user_cp_find')
|
||||
->where(['status' => 1])
|
||||
->where('(from_user_id = ' . $user_id . ' OR to_user_id = ' . $user_id . ')')
|
||||
->select();
|
||||
|
||||
if ($find_records) {
|
||||
foreach ($find_records as $record) {
|
||||
if ($record['id'] != $current_find_id && $record['id'] != $related_find_id) {
|
||||
Db::name('user_cp_find')->where(['id' => $record['id']])->update(['status' => 2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 为CP用户分配装扮或特效
|
||||
* @param array $user_ids 用户ID数组
|
||||
* @param int $type 装扮类型(10-特效, 11-装扮)
|
||||
* @param int $did 装扮ID
|
||||
*/
|
||||
private function assignCpDecoration($user_ids, $type, $did)
|
||||
{
|
||||
// 先检查用户是否已有该装扮,如果有则设为未使用
|
||||
foreach ($user_ids as $user_id) {
|
||||
$existing_decoration = Db::name('vs_user_decorate')
|
||||
->where([
|
||||
'user_id' => $user_id,
|
||||
'type' => $type,
|
||||
'did' => $did,
|
||||
'is_using' => 1
|
||||
])
|
||||
->find();
|
||||
|
||||
if ($existing_decoration) {
|
||||
Db::name('vs_user_decorate')
|
||||
->where(['udid' => $existing_decoration['udid']])
|
||||
->update(['is_using' => 2]);
|
||||
}
|
||||
}
|
||||
|
||||
// 给用户添加新装扮
|
||||
$decorate_data = [
|
||||
'type' => $type,
|
||||
'did' => $did,
|
||||
'is_using' => 1,
|
||||
'end_time' => 0,
|
||||
'is_perpetual' => 1,
|
||||
'createtime' => time(),
|
||||
];
|
||||
|
||||
foreach ($user_ids as $user_id) {
|
||||
$insert_data = array_merge(['user_id' => $user_id], $decorate_data);
|
||||
Db::name('vs_user_decorate')->insert($insert_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 送Cp礼物 增加Cp 经验 判断是否升级
|
||||
* @param $from_user_id 送礼用户ID
|
||||
* @param $to_user_id 接收用户ID
|
||||
* @param $gift_id 礼物ID
|
||||
* @param $room_id 房间ID
|
||||
* @param $cp_zone_id Cp空间ID
|
||||
*/
|
||||
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);
|
||||
$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')??'未知用户';
|
||||
$giftName = db::name('vs_gift')->where(['gid' => $gift_id])->value('gift_name')??'未知礼物';
|
||||
//添加一个记录
|
||||
$datas = [
|
||||
'room_id' => $room_id,
|
||||
'from_user_id' => $from_user_id,
|
||||
'to_user_id' => $to_user_id,
|
||||
'gift_id' => $gift_id,
|
||||
'num' => $num,
|
||||
'cp_zone_id' => $cp_zone_id,
|
||||
'exp' => $exp,
|
||||
'exp_total' => $yuan_exp + $exp,
|
||||
'remark' => '送给'.$toUserNickname.$num.'个'.$giftName.',获得'.$exp.'经验值,总经验值增加至'.($yuan_exp + $exp),
|
||||
'createtime' => time(),
|
||||
];
|
||||
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();
|
||||
if($level['level'] != $zone_level){//登记不一致 (升级)
|
||||
//修改Cp空间等级
|
||||
$data['level'] = $level['level'];
|
||||
//给用户修改Cp装扮
|
||||
if($level['pendant_id']){
|
||||
//先检查是否已有该装扮
|
||||
$pendant_id = Db::name('vs_decorate_price')->where(['id' => $level['pendant_id']])->value('did');
|
||||
if($pendant_id){
|
||||
$this->assignCpDecoration([$from_user_id, $to_user_id], 11, $pendant_id); // 11为CP装扮类型
|
||||
}
|
||||
|
||||
}else{//当前等级没有装扮挂件把原有的装扮取消掉
|
||||
$decorate_data = [
|
||||
'type' => 11, // 装扮类型11-cp装扮
|
||||
'is_using' => 2, // 1-使用中,2-未使用
|
||||
'updatetime' => time(),
|
||||
];
|
||||
foreach ([$from_user_id, $to_user_id] as $user_id) {
|
||||
$insert_data = array_merge(['user_id' => $user_id], $decorate_data);
|
||||
Db::name('vs_user_decorate')->where(['type' => 11])->update($insert_data);
|
||||
}
|
||||
|
||||
}
|
||||
//给用户修改Cp特效
|
||||
if($level['rights_icon_id']){
|
||||
//先检查是否已有该特效
|
||||
$rights_icon_id = Db::name('vs_decorate_price')->where(['id' => $level['rights_icon_id']])->value('did');
|
||||
if($rights_icon_id){
|
||||
$this->assignCpDecoration([$from_user_id, $to_user_id], 10, $rights_icon_id); // 10为CP特效类型
|
||||
}
|
||||
}else{//当前等级没有特效挂件把原有的特效取消掉
|
||||
$decorate_data = [
|
||||
'type' => 10, // 装扮类型10-cp特效
|
||||
'is_using' => 2, // 1-使用中,2-未使用
|
||||
'updatetime' => time(),
|
||||
];
|
||||
foreach ([$from_user_id, $to_user_id] as $user_id) {
|
||||
$insert_data = array_merge(['user_id' => $user_id], $decorate_data);
|
||||
Db::name('vs_user_decorate')->where(['type' => 10])->update($insert_data);
|
||||
}
|
||||
}
|
||||
|
||||
//添加一个记录
|
||||
$pendant = db::name('vs_decorate_price')->where('id',$level['pendant_id'])->field('did,day')->find();
|
||||
if($pendant){
|
||||
$pendant_title = '装扮-'.$pendant['day'].'天-'.db::name('vs_decorate')->where('did',$pendant['did'])->value('title');
|
||||
$datas = [
|
||||
'room_id' => $room_id,
|
||||
'from_user_id' => $from_user_id,
|
||||
'to_user_id' => $to_user_id,
|
||||
'gift_id' => 0,
|
||||
'num' => 0,
|
||||
'cp_zone_id' => $cp_zone_id,
|
||||
'exp' => 0,
|
||||
'exp_total' => 0,
|
||||
'remark' => '我们等级达到了'.$level['level'].'级,获得奖励'.$pendant_title,
|
||||
'createtime' => time(),
|
||||
];
|
||||
Db::name('user_cp_gift_log')->insert($datas);
|
||||
}
|
||||
|
||||
}
|
||||
$data['exp'] = $yuan_exp + $exp;
|
||||
Db::name('user_cp_zone')->where(['id' => $cp_zone_id])->update($data);
|
||||
//是否有在限时时间内的Cp任务
|
||||
//成为Cp的天数
|
||||
$createtime =Db::name('user_cp_zone')->where(['id' => $cp_zone_id])->value('createtime');
|
||||
$days = floor((time() - $createtime) / 86400);
|
||||
if($days <= 7){
|
||||
$is_time = Db::name('vs_user_cp_task')->where(['user_id' => $from_user_id,'status' => 0,'day' => date('Y-m-d', time()),'delete_time'=>0])->find();
|
||||
$is_time2 = Db::name('vs_user_cp_task')->where(['user_id' => $to_user_id,'status' => 0,'day' => date('Y-m-d', time()),'delete_time'=>0])->find();
|
||||
if($is_time && $is_time['need_exp_value'] > $is_time['exp_value']){
|
||||
$exo_value = ($is_time['exp_value'] + $exp) >= $is_time['need_exp_value'] ? $is_time['need_exp_value'] : ($is_time['exp_value'] + $exp);
|
||||
$data_cp = [
|
||||
'exp_value' => $exo_value,
|
||||
];
|
||||
if($exo_value >= $is_time['need_exp_value'] && $is_time['time_value'] == $is_time['need_time_value']){
|
||||
$data_cp['status'] = 1;
|
||||
}
|
||||
Db::name('vs_user_cp_task')->where(['id' => $is_time['id']])->update($data_cp);
|
||||
Db::name('vs_user_cp_task')->where(['id' => $is_time2['id']])->update($data_cp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Cp空间
|
||||
* @param $user_id 用户ID
|
||||
*/
|
||||
public function cpZone($user_id, $page, $page_limit)
|
||||
{
|
||||
$res = Db::name('user_cp_zone')->where(['user_id1' => $user_id,'status' => 1])->find();
|
||||
if(!$res){
|
||||
$res = Db::name('user_cp_zone')->where(['user_id2' => $user_id,'status' => 1])->find();
|
||||
}
|
||||
if($res){
|
||||
$res['user_info1'] = Db::name('user')->where(['id' => $res['user_id1']])->field('id user_id,nickname,avatar')->find();
|
||||
$res['user_info2'] = Db::name('user')->where(['id' => $res['user_id2']])->field('id user_id,nickname,avatar')->find();
|
||||
//升下一级所需经验值
|
||||
$next_level_exp = Db::name('user_cp_level')->where(['level' => ['>',$res['level']]])->order('level asc')->value('change_value');
|
||||
$res['next_level_exp'] = $next_level_exp - $res['exp'];
|
||||
if($res['next_level_exp'] < 0){
|
||||
$res['next_level_exp'] = 0;
|
||||
}
|
||||
$res['pendant'] = model('api/Decorate')->user_decorate_detail($user_id, 11);//挂件(装扮)
|
||||
//送礼记录
|
||||
$res['gift_log'] = Db::name('user_cp_gift_log')->where(['cp_zone_id' => $res['id']])->order('id desc')->page($page,$page_limit)->select();
|
||||
foreach ($res['gift_log'] as &$v){
|
||||
if($v['gift_id']){
|
||||
$v['gift_name'] = Db::name('vs_gift')->where(['gid' => $v['gift_id']])->value('gift_name');
|
||||
}
|
||||
$v['from_user_info'] = Db::name('user')->where(['id' => $v['from_user_id']])->field('id user_id,nickname,avatar')->find();
|
||||
$v['to_user_info'] = Db::name('user')->where(['id' => $v['to_user_id']])->field('id user_id,nickname,avatar')->find();
|
||||
}
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => $res ];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => '暂无Cp空间', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user